@oondemand/oon-core-front 0.3.52 → 0.3.54
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/bin/cli.js +55 -0
- package/dist/index.js +1091 -810
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
-
var __defNormalProp = (obj, key,
|
|
3
|
-
var __publicField = (obj, key,
|
|
2
|
+
var __defNormalProp = (obj, key, value2) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value2 }) : obj[key] = value2;
|
|
3
|
+
var __publicField = (obj, key, value2) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value2);
|
|
4
4
|
|
|
5
5
|
// src/start.tsx
|
|
6
6
|
import { StrictMode } from "react";
|
|
@@ -19,6 +19,7 @@ function normalizeError(err) {
|
|
|
19
19
|
if (axios.isAxiosError(err)) {
|
|
20
20
|
const status = err.response?.status;
|
|
21
21
|
const data = err.response?.data;
|
|
22
|
+
const responseRequestId = err.response?.headers?.["x-request-id"] ?? err.response?.headers?.["x-correlation-id"];
|
|
22
23
|
const contentType = String(err.response?.headers?.["content-type"] || "");
|
|
23
24
|
const isTextPayload = typeof data === "string";
|
|
24
25
|
const isProbablyHtml = isTextPayload && /<html|<!doctype/i.test(data);
|
|
@@ -28,17 +29,19 @@ function normalizeError(err) {
|
|
|
28
29
|
message: nonJsonMessage(status, err.config?.url, isProbablyHtml),
|
|
29
30
|
status,
|
|
30
31
|
details: isProbablyHtml ? void 0 : data,
|
|
31
|
-
requestId:
|
|
32
|
+
requestId: responseRequestId
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
|
-
const
|
|
35
|
+
const rawError = data?.error;
|
|
36
|
+
const envelope = rawError && typeof rawError === "object" ? rawError : void 0;
|
|
35
37
|
const legacyDetails = envelope && envelope.details === void 0 && envelope.field ? envelope : void 0;
|
|
38
|
+
const rawTechnicalDetails = typeof rawError === "string" ? { technicalMessage: rawError } : void 0;
|
|
36
39
|
return {
|
|
37
|
-
code: envelope?.code || codeFromStatus(status),
|
|
40
|
+
code: envelope?.code || data?.code || codeFromStatus(status),
|
|
38
41
|
message: envelope?.message || data?.message || err.message || "Erro inesperado.",
|
|
39
42
|
status,
|
|
40
|
-
details: envelope?.details ?? legacyDetails,
|
|
41
|
-
requestId: envelope?.requestId ||
|
|
43
|
+
details: envelope?.details ?? legacyDetails ?? data?.details ?? rawTechnicalDetails,
|
|
44
|
+
requestId: envelope?.requestId || data?.requestId || responseRequestId
|
|
42
45
|
};
|
|
43
46
|
}
|
|
44
47
|
if (err instanceof Error) {
|
|
@@ -282,9 +285,9 @@ function createCoreClient(http) {
|
|
|
282
285
|
// src/api/resourceClient.ts
|
|
283
286
|
var META_KEYS = /* @__PURE__ */ new Set(["pagination", "results", "message", "requestId"]);
|
|
284
287
|
function unwrap(data) {
|
|
285
|
-
for (const [key,
|
|
286
|
-
if (!META_KEYS.has(key) &&
|
|
287
|
-
return
|
|
288
|
+
for (const [key, value2] of Object.entries(data)) {
|
|
289
|
+
if (!META_KEYS.has(key) && value2 && typeof value2 === "object") {
|
|
290
|
+
return value2;
|
|
288
291
|
}
|
|
289
292
|
}
|
|
290
293
|
return data;
|
|
@@ -343,7 +346,7 @@ function createResourceClient(http, basePath) {
|
|
|
343
346
|
import { jsx } from "react/jsx-runtime";
|
|
344
347
|
var ApiContext = createContext(null);
|
|
345
348
|
function ApiProvider({ http, children }) {
|
|
346
|
-
const
|
|
349
|
+
const value2 = useMemo(() => {
|
|
347
350
|
const cache = /* @__PURE__ */ new Map();
|
|
348
351
|
return {
|
|
349
352
|
http,
|
|
@@ -358,7 +361,7 @@ function ApiProvider({ http, children }) {
|
|
|
358
361
|
}
|
|
359
362
|
};
|
|
360
363
|
}, [http]);
|
|
361
|
-
return /* @__PURE__ */ jsx(ApiContext.Provider, { value, children });
|
|
364
|
+
return /* @__PURE__ */ jsx(ApiContext.Provider, { value: value2, children });
|
|
362
365
|
}
|
|
363
366
|
function useOonApi() {
|
|
364
367
|
const ctx = useContext(ApiContext);
|
|
@@ -460,9 +463,9 @@ function encodeBasicCredentials(email, password) {
|
|
|
460
463
|
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
461
464
|
return window.btoa(binary);
|
|
462
465
|
}
|
|
463
|
-
function normalizeList(
|
|
464
|
-
if (Array.isArray(
|
|
465
|
-
if (typeof
|
|
466
|
+
function normalizeList(value2) {
|
|
467
|
+
if (Array.isArray(value2)) return value2.map(String).filter(Boolean);
|
|
468
|
+
if (typeof value2 === "string") return value2.split(/[\s,;]+/).map((item) => item.trim()).filter(Boolean);
|
|
466
469
|
return [];
|
|
467
470
|
}
|
|
468
471
|
function extractCapabilities(user) {
|
|
@@ -607,12 +610,12 @@ function AuthProvider({
|
|
|
607
610
|
if (required.length === 0) return true;
|
|
608
611
|
if (roles.includes("admin") || roles.includes("master")) return true;
|
|
609
612
|
return required.some(
|
|
610
|
-
(
|
|
613
|
+
(value3) => roles.includes(value3) || capabilities.includes(value3) || roles.some((role) => value3.startsWith(`${role}.`))
|
|
611
614
|
);
|
|
612
615
|
},
|
|
613
616
|
[roles, capabilities]
|
|
614
617
|
);
|
|
615
|
-
const
|
|
618
|
+
const value2 = {
|
|
616
619
|
user,
|
|
617
620
|
roles,
|
|
618
621
|
capabilities,
|
|
@@ -623,7 +626,7 @@ function AuthProvider({
|
|
|
623
626
|
retry,
|
|
624
627
|
logout
|
|
625
628
|
};
|
|
626
|
-
return /* @__PURE__ */ jsx3(AuthContext.Provider, { value, children });
|
|
629
|
+
return /* @__PURE__ */ jsx3(AuthContext.Provider, { value: value2, children });
|
|
627
630
|
}
|
|
628
631
|
function useOonAuth() {
|
|
629
632
|
const context = useContext3(AuthContext);
|
|
@@ -646,7 +649,7 @@ function OonProviders({ config, http, storage, children }) {
|
|
|
646
649
|
|
|
647
650
|
// src/components/CoreCollection.tsx
|
|
648
651
|
import { useState as useState10 } from "react";
|
|
649
|
-
import { Box as
|
|
652
|
+
import { Box as Box11, Heading as Heading4, Stack as Stack4, Text as Text12 } from "@chakra-ui/react";
|
|
650
653
|
import { useMutation as useMutation2, useQueryClient as useQueryClient3 } from "@tanstack/react-query";
|
|
651
654
|
|
|
652
655
|
// src/components/internal/fieldUtils.ts
|
|
@@ -672,12 +675,12 @@ function formRequired(field) {
|
|
|
672
675
|
}
|
|
673
676
|
function formOptions(field) {
|
|
674
677
|
const rawOptions = field.options;
|
|
675
|
-
if (Array.isArray(rawOptions)) return rawOptions.filter((
|
|
678
|
+
if (Array.isArray(rawOptions)) return rawOptions.filter((value2) => typeof value2 === "string");
|
|
676
679
|
if (!rawOptions || typeof rawOptions !== "object") return void 0;
|
|
677
680
|
const options = rawOptions;
|
|
678
681
|
const candidates = [options.values, options.enum, options.options];
|
|
679
682
|
for (const candidate of candidates) {
|
|
680
|
-
if (Array.isArray(candidate)) return candidate.filter((
|
|
683
|
+
if (Array.isArray(candidate)) return candidate.filter((value2) => typeof value2 === "string");
|
|
681
684
|
}
|
|
682
685
|
return void 0;
|
|
683
686
|
}
|
|
@@ -706,28 +709,28 @@ function formFieldsFromMeta(fields) {
|
|
|
706
709
|
};
|
|
707
710
|
});
|
|
708
711
|
}
|
|
709
|
-
function formatCell(
|
|
710
|
-
if (
|
|
712
|
+
function formatCell(value2, kind) {
|
|
713
|
+
if (value2 == null || value2 === "") return "\u2014";
|
|
711
714
|
switch (kind) {
|
|
712
715
|
case "boolean":
|
|
713
|
-
return
|
|
716
|
+
return value2 ? "Sim" : "N\xE3o";
|
|
714
717
|
case "date":
|
|
715
718
|
try {
|
|
716
|
-
return new Date(
|
|
719
|
+
return new Date(value2).toLocaleDateString("pt-BR");
|
|
717
720
|
} catch {
|
|
718
|
-
return String(
|
|
721
|
+
return String(value2);
|
|
719
722
|
}
|
|
720
723
|
case "currency":
|
|
721
724
|
case "currencyConverted":
|
|
722
|
-
return new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(Number(
|
|
725
|
+
return new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(Number(value2));
|
|
723
726
|
case "ref":
|
|
724
|
-
if (
|
|
725
|
-
const object =
|
|
727
|
+
if (value2 && typeof value2 === "object") {
|
|
728
|
+
const object = value2;
|
|
726
729
|
return String(object.nome ?? object.label ?? object.descricao ?? object._id ?? "\u2014");
|
|
727
730
|
}
|
|
728
|
-
return String(
|
|
731
|
+
return String(value2);
|
|
729
732
|
default:
|
|
730
|
-
return String(
|
|
733
|
+
return String(value2);
|
|
731
734
|
}
|
|
732
735
|
}
|
|
733
736
|
|
|
@@ -794,24 +797,24 @@ function ChevronIcon({ direction }) {
|
|
|
794
797
|
function PlusIcon() {
|
|
795
798
|
return /* @__PURE__ */ jsx7("svg", { viewBox: "0 0 20 20", width: "17", height: "17", "aria-hidden": "true", children: /* @__PURE__ */ jsx7("path", { d: "M10 4v12M4 10h12", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" }) });
|
|
796
799
|
}
|
|
797
|
-
function renderCell(
|
|
798
|
-
const formatted = formatCell(
|
|
800
|
+
function renderCell(value2, kind) {
|
|
801
|
+
const formatted = formatCell(value2, kind);
|
|
799
802
|
if (kind === "enum") {
|
|
800
|
-
const normalized2 = String(
|
|
803
|
+
const normalized2 = String(value2 ?? "").toLowerCase();
|
|
801
804
|
const palette = /erro|cancel|inativo|recus|critica/.test(normalized2) ? "red" : /pendente|aguardando|rascunho/.test(normalized2) ? "orange" : /processando|conferencia|integrando|validando/.test(normalized2) ? "blue" : /ativo|sucesso|conclu|aplicada|disponivel|aprov/.test(normalized2) ? "green" : "gray";
|
|
802
805
|
return /* @__PURE__ */ jsx7(Badge, { colorPalette: palette, variant: "subtle", borderRadius: "full", px: "7px", py: "3px", fontSize: "9px", fontWeight: "600", textTransform: "capitalize", children: formatted });
|
|
803
806
|
}
|
|
804
807
|
if (kind === "boolean") {
|
|
805
|
-
const active =
|
|
808
|
+
const active = value2 === true || value2 === "true";
|
|
806
809
|
return /* @__PURE__ */ jsx7(Badge, { colorPalette: active ? "green" : "gray", variant: "subtle", borderRadius: "full", px: "7px", py: "3px", fontSize: "9px", fontWeight: "600", children: formatted });
|
|
807
810
|
}
|
|
808
811
|
return formatted;
|
|
809
812
|
}
|
|
810
813
|
function renderColumnCell(row, column, cellRenderers) {
|
|
811
|
-
const
|
|
814
|
+
const value2 = row[column.field];
|
|
812
815
|
const Renderer = column.renderer ? cellRenderers?.[column.renderer] : void 0;
|
|
813
|
-
if (Renderer) return /* @__PURE__ */ jsx7(Renderer, { value, row, column });
|
|
814
|
-
return renderCell(
|
|
816
|
+
if (Renderer) return /* @__PURE__ */ jsx7(Renderer, { value: value2, row, column });
|
|
817
|
+
return renderCell(value2, column.kind);
|
|
815
818
|
}
|
|
816
819
|
function DataGrid({
|
|
817
820
|
resource,
|
|
@@ -833,7 +836,7 @@ function DataGrid({
|
|
|
833
836
|
const deferredSearch = useDeferredValue(searchTerm);
|
|
834
837
|
const [sort, setSort] = useState3(void 0);
|
|
835
838
|
const [filterValues, setFilterValues] = useState3(() => Object.fromEntries(filters.map((filter) => [filter.field, filter.defaultValue ?? ""])));
|
|
836
|
-
const effectiveFilters = Object.fromEntries(Object.entries({ ...queryExtra, ...filterValues }).filter(([,
|
|
839
|
+
const effectiveFilters = Object.fromEntries(Object.entries({ ...queryExtra, ...filterValues }).filter(([, value2]) => value2 !== "" && value2 != null));
|
|
837
840
|
const query = useQuery2({
|
|
838
841
|
queryKey: ["oon", "list", resourceKey, { pageIndex, pageSize, searchTerm: deferredSearch, sort, filters: effectiveFilters }],
|
|
839
842
|
queryFn: () => resource.list({ pageIndex, pageSize, searchTerm: deferredSearch || void 0, sort, ...effectiveFilters }),
|
|
@@ -981,7 +984,7 @@ function DataGrid({
|
|
|
981
984
|
|
|
982
985
|
// src/components/internal/DynamicForm.tsx
|
|
983
986
|
import { useEffect as useEffect4, useMemo as useMemo4, useState as useState5 } from "react";
|
|
984
|
-
import { Box as
|
|
987
|
+
import { Box as Box5, Button as Button4, Flex as Flex4, Heading as Heading2, Input as Input3, NativeSelect as NativeSelect2, SimpleGrid, Stack as Stack2, Text as Text6, Textarea } from "@chakra-ui/react";
|
|
985
988
|
|
|
986
989
|
// src/domain/domainExpressions.ts
|
|
987
990
|
var DomainExpressionError = class extends Error {
|
|
@@ -998,8 +1001,8 @@ var NUMERIC_KINDS = /* @__PURE__ */ new Set(["number", "currency", "currencyConv
|
|
|
998
1001
|
function hasOwn(object, key) {
|
|
999
1002
|
return Object.prototype.hasOwnProperty.call(object, key);
|
|
1000
1003
|
}
|
|
1001
|
-
function isEmpty(
|
|
1002
|
-
return
|
|
1004
|
+
function isEmpty(value2) {
|
|
1005
|
+
return value2 === null || value2 === void 0 || typeof value2 === "string" && !value2.trim();
|
|
1003
1006
|
}
|
|
1004
1007
|
function getFieldValue(record, fieldPath) {
|
|
1005
1008
|
const parts = String(fieldPath).split(".");
|
|
@@ -1011,9 +1014,9 @@ function getFieldValue(record, fieldPath) {
|
|
|
1011
1014
|
}
|
|
1012
1015
|
return current;
|
|
1013
1016
|
}
|
|
1014
|
-
function toNumber(
|
|
1015
|
-
if (isEmpty(
|
|
1016
|
-
const numeric = typeof
|
|
1017
|
+
function toNumber(value2, context = {}) {
|
|
1018
|
+
if (isEmpty(value2)) return context.nullAsZero ? 0 : null;
|
|
1019
|
+
const numeric = typeof value2 === "number" ? value2 : Number(value2);
|
|
1017
1020
|
if (!Number.isFinite(numeric)) {
|
|
1018
1021
|
throw new DomainExpressionError(
|
|
1019
1022
|
`A f\xF3rmula do campo ${context.field ?? "calculado"} recebeu um valor n\xE3o num\xE9rico.`,
|
|
@@ -1025,7 +1028,7 @@ function toNumber(value, context = {}) {
|
|
|
1025
1028
|
function numericArguments(args, record, context) {
|
|
1026
1029
|
const values = args.map((arg) => evaluateDomainExpression(arg, record, context));
|
|
1027
1030
|
if (!context.nullAsZero && values.some(isEmpty)) return null;
|
|
1028
|
-
return values.map((
|
|
1031
|
+
return values.map((value2) => toNumber(value2, context) ?? 0);
|
|
1029
1032
|
}
|
|
1030
1033
|
function compareValues(leftValue, rightValue, operator) {
|
|
1031
1034
|
let left = leftValue;
|
|
@@ -1066,15 +1069,15 @@ function evaluateDomainExpression(expression, record = {}, context = {}) {
|
|
|
1066
1069
|
switch (operation.op) {
|
|
1067
1070
|
case "add": {
|
|
1068
1071
|
const values = numericArguments(args, record, context);
|
|
1069
|
-
return values === null ? null : values.reduce((total,
|
|
1072
|
+
return values === null ? null : values.reduce((total, value2) => total + value2, 0);
|
|
1070
1073
|
}
|
|
1071
1074
|
case "subtract": {
|
|
1072
1075
|
const values = numericArguments(args, record, context);
|
|
1073
|
-
return values === null ? null : values.slice(1).reduce((total,
|
|
1076
|
+
return values === null ? null : values.slice(1).reduce((total, value2) => total - value2, values[0] ?? 0);
|
|
1074
1077
|
}
|
|
1075
1078
|
case "multiply": {
|
|
1076
1079
|
const values = numericArguments(args, record, context);
|
|
1077
|
-
return values === null ? null : values.reduce((total,
|
|
1080
|
+
return values === null ? null : values.reduce((total, value2) => total * value2, 1);
|
|
1078
1081
|
}
|
|
1079
1082
|
case "divide": {
|
|
1080
1083
|
const values = numericArguments(args, record, context);
|
|
@@ -1107,8 +1110,8 @@ function evaluateDomainExpression(expression, record = {}, context = {}) {
|
|
|
1107
1110
|
}
|
|
1108
1111
|
case "coalesce": {
|
|
1109
1112
|
for (const arg of args) {
|
|
1110
|
-
const
|
|
1111
|
-
if (!isEmpty(
|
|
1113
|
+
const value2 = evaluateDomainExpression(arg, record, context);
|
|
1114
|
+
if (!isEmpty(value2)) return value2;
|
|
1112
1115
|
}
|
|
1113
1116
|
return null;
|
|
1114
1117
|
}
|
|
@@ -1132,9 +1135,9 @@ function evaluateDomainExpression(expression, record = {}, context = {}) {
|
|
|
1132
1135
|
case "present":
|
|
1133
1136
|
return !isEmpty(evaluateDomainExpression(args[0], record, context));
|
|
1134
1137
|
case "in": {
|
|
1135
|
-
const
|
|
1138
|
+
const value2 = evaluateDomainExpression(args[0], record, context);
|
|
1136
1139
|
const list = evaluateDomainExpression(args[1], record, context);
|
|
1137
|
-
return Array.isArray(list) && list.some((item) => Object.is(item,
|
|
1140
|
+
return Array.isArray(list) && list.some((item) => Object.is(item, value2));
|
|
1138
1141
|
}
|
|
1139
1142
|
default:
|
|
1140
1143
|
throw new DomainExpressionError(`Operador declarativo n\xE3o suportado: ${String(operation.op)}.`, {
|
|
@@ -1142,9 +1145,9 @@ function evaluateDomainExpression(expression, record = {}, context = {}) {
|
|
|
1142
1145
|
});
|
|
1143
1146
|
}
|
|
1144
1147
|
}
|
|
1145
|
-
function roundValue(
|
|
1146
|
-
if (
|
|
1147
|
-
const numeric = toNumber(
|
|
1148
|
+
function roundValue(value2, precision = 0) {
|
|
1149
|
+
if (value2 === null || value2 === void 0) return value2;
|
|
1150
|
+
const numeric = toNumber(value2);
|
|
1148
1151
|
if (numeric === null) return null;
|
|
1149
1152
|
const factor = 10 ** precision;
|
|
1150
1153
|
return Math.round((numeric + Number.EPSILON) * factor) / factor;
|
|
@@ -1189,15 +1192,15 @@ function orderComputedFields(fields) {
|
|
|
1189
1192
|
computed.forEach(visit);
|
|
1190
1193
|
return ordered;
|
|
1191
1194
|
}
|
|
1192
|
-
function coerceDomainFormValue(
|
|
1193
|
-
if (
|
|
1194
|
-
if (NUMERIC_KINDS.has(kind ?? "")) return Number(
|
|
1195
|
-
if (kind === "boolean") return
|
|
1196
|
-
return
|
|
1195
|
+
function coerceDomainFormValue(value2, kind) {
|
|
1196
|
+
if (value2 === "") return void 0;
|
|
1197
|
+
if (NUMERIC_KINDS.has(kind ?? "")) return Number(value2);
|
|
1198
|
+
if (kind === "boolean") return value2 === "true";
|
|
1199
|
+
return value2;
|
|
1197
1200
|
}
|
|
1198
|
-
function displayFormValue(
|
|
1199
|
-
if (
|
|
1200
|
-
return String(
|
|
1201
|
+
function displayFormValue(value2) {
|
|
1202
|
+
if (value2 === null || value2 === void 0) return "";
|
|
1203
|
+
return String(value2);
|
|
1201
1204
|
}
|
|
1202
1205
|
function applyReactiveFormulas(fields, currentValues) {
|
|
1203
1206
|
const values = { ...currentValues };
|
|
@@ -1217,11 +1220,11 @@ function applyReactiveFormulas(fields, currentValues) {
|
|
|
1217
1220
|
for (const field of ordered) {
|
|
1218
1221
|
try {
|
|
1219
1222
|
const computed = field.computed;
|
|
1220
|
-
const
|
|
1223
|
+
const value2 = evaluateDomainExpression(computed.expression, record, {
|
|
1221
1224
|
field: field.field,
|
|
1222
1225
|
nullAsZero: computed.nullAsZero !== false
|
|
1223
1226
|
});
|
|
1224
|
-
const normalized2 =
|
|
1227
|
+
const normalized2 = value2 === null || value2 === void 0 ? value2 : roundValue(value2, computed.precision ?? 2);
|
|
1225
1228
|
record[field.field] = normalized2;
|
|
1226
1229
|
values[field.field] = displayFormValue(normalized2);
|
|
1227
1230
|
} catch (error) {
|
|
@@ -1235,8 +1238,8 @@ function buildDomainMutationPayload(fields, values) {
|
|
|
1235
1238
|
const payload = {};
|
|
1236
1239
|
for (const field of fields) {
|
|
1237
1240
|
if (field.readonly || field.computed) continue;
|
|
1238
|
-
const
|
|
1239
|
-
if (
|
|
1241
|
+
const value2 = coerceDomainFormValue(values[field.field] ?? "", field.kind);
|
|
1242
|
+
if (value2 !== void 0) payload[field.field] = value2;
|
|
1240
1243
|
}
|
|
1241
1244
|
return payload;
|
|
1242
1245
|
}
|
|
@@ -1259,9 +1262,9 @@ var COMMON_LABEL_FIELDS = [
|
|
|
1259
1262
|
"label",
|
|
1260
1263
|
"email"
|
|
1261
1264
|
];
|
|
1262
|
-
function primitiveText(
|
|
1263
|
-
if (
|
|
1264
|
-
if (typeof
|
|
1265
|
+
function primitiveText(value2) {
|
|
1266
|
+
if (value2 == null || value2 === "") return null;
|
|
1267
|
+
if (typeof value2 === "string" || typeof value2 === "number") return String(value2);
|
|
1265
1268
|
return null;
|
|
1266
1269
|
}
|
|
1267
1270
|
function referenceOptionLabel(row, searchableFields = []) {
|
|
@@ -1281,9 +1284,9 @@ function referenceOptionLabel(row, searchableFields = []) {
|
|
|
1281
1284
|
if (values.length) return values.join(" \u2014 ");
|
|
1282
1285
|
return primitiveText(row._id) ?? primitiveText(row.id) ?? "Registro sem identifica\xE7\xE3o";
|
|
1283
1286
|
}
|
|
1284
|
-
function initialReferenceLabel(
|
|
1285
|
-
if (!
|
|
1286
|
-
return referenceOptionLabel(
|
|
1287
|
+
function initialReferenceLabel(value2) {
|
|
1288
|
+
if (!value2 || typeof value2 !== "object") return "";
|
|
1289
|
+
return referenceOptionLabel(value2);
|
|
1287
1290
|
}
|
|
1288
1291
|
function referenceId(row) {
|
|
1289
1292
|
return String(row._id ?? row.id ?? "");
|
|
@@ -1315,7 +1318,7 @@ function ClearIcon() {
|
|
|
1315
1318
|
}
|
|
1316
1319
|
function cleanFilters(filters) {
|
|
1317
1320
|
return Object.fromEntries(
|
|
1318
|
-
Object.entries(filters ?? {}).filter(([,
|
|
1321
|
+
Object.entries(filters ?? {}).filter(([, value2]) => value2 !== void 0 && value2 !== null && value2 !== "")
|
|
1319
1322
|
);
|
|
1320
1323
|
}
|
|
1321
1324
|
function ReferenceSelect({
|
|
@@ -1324,7 +1327,7 @@ function ReferenceSelect({
|
|
|
1324
1327
|
errorId,
|
|
1325
1328
|
label,
|
|
1326
1329
|
refModel,
|
|
1327
|
-
value,
|
|
1330
|
+
value: value2,
|
|
1328
1331
|
initialValue,
|
|
1329
1332
|
required,
|
|
1330
1333
|
invalid,
|
|
@@ -1356,9 +1359,9 @@ function ReferenceSelect({
|
|
|
1356
1359
|
return () => window.clearTimeout(timer);
|
|
1357
1360
|
}, [search]);
|
|
1358
1361
|
useEffect3(() => {
|
|
1359
|
-
if (!
|
|
1362
|
+
if (!value2) setSelectedLabel("");
|
|
1360
1363
|
else if (initialLabel) setSelectedLabel(initialLabel);
|
|
1361
|
-
}, [initialLabel,
|
|
1364
|
+
}, [initialLabel, value2]);
|
|
1362
1365
|
useEffect3(() => {
|
|
1363
1366
|
if (!disabled) return;
|
|
1364
1367
|
setOpen(false);
|
|
@@ -1391,9 +1394,9 @@ function ReferenceSelect({
|
|
|
1391
1394
|
staleTime: 3e4
|
|
1392
1395
|
});
|
|
1393
1396
|
const currentQuery = useQuery3({
|
|
1394
|
-
queryKey: ["oon", "reference-current", refModel, basePath,
|
|
1395
|
-
queryFn: () => resource.get(
|
|
1396
|
-
enabled: !!schema && !!
|
|
1397
|
+
queryKey: ["oon", "reference-current", refModel, basePath, value2],
|
|
1398
|
+
queryFn: () => resource.get(value2),
|
|
1399
|
+
enabled: !!schema && !!value2 && !selectedLabel,
|
|
1397
1400
|
staleTime: 5 * 6e4
|
|
1398
1401
|
});
|
|
1399
1402
|
useEffect3(() => {
|
|
@@ -1511,9 +1514,9 @@ function ReferenceSelect({
|
|
|
1511
1514
|
_focusVisible: { borderColor: invalid ? "#DC2626" : "#0F8DD0", boxShadow: invalid ? "0 0 0 3px rgba(220,38,38,.08)" : "0 0 0 3px rgba(15,141,208,.10)" },
|
|
1512
1515
|
_disabled: { cursor: "not-allowed", color: "#98A2B3", bg: "#F8FAFC", opacity: 1 },
|
|
1513
1516
|
children: [
|
|
1514
|
-
/* @__PURE__ */ jsx8(Text4, { as: "span", minW: 0, flex: "1", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", color: selectedLabel ||
|
|
1517
|
+
/* @__PURE__ */ jsx8(Text4, { as: "span", minW: 0, flex: "1", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", color: selectedLabel || value2 ? "#475467" : "#98A2B3", children: selectedLabel || (value2 ? String(value2) : placeholder) }),
|
|
1515
1518
|
/* @__PURE__ */ jsxs4(Flex3, { as: "span", align: "center", gap: 1, flex: "0 0 auto", color: "#98A2B3", children: [
|
|
1516
|
-
|
|
1519
|
+
value2 && !disabled ? /* @__PURE__ */ jsx8(
|
|
1517
1520
|
Box3,
|
|
1518
1521
|
{
|
|
1519
1522
|
as: "span",
|
|
@@ -1598,7 +1601,7 @@ function ReferenceSelect({
|
|
|
1598
1601
|
] }) : schemaQuery.isError || listQuery.isError ? /* @__PURE__ */ jsx8(Text4, { py: "18px", px: "10px", color: "#B42318", fontSize: "10px", textAlign: "center", children: "N\xE3o foi poss\xEDvel carregar as op\xE7\xF5es." }) : items.length === 0 ? /* @__PURE__ */ jsx8(Text4, { py: "18px", px: "10px", color: "#98A2B3", fontSize: "10px", textAlign: "center", children: "Nenhum registro encontrado." }) : items.map((record, index) => {
|
|
1599
1602
|
const id = referenceId(record);
|
|
1600
1603
|
if (!id) return null;
|
|
1601
|
-
const selected = String(id) === String(
|
|
1604
|
+
const selected = String(id) === String(value2);
|
|
1602
1605
|
const active = index === activeIndex;
|
|
1603
1606
|
const optionLabel = referenceOptionLabel(record, schema?.searchable);
|
|
1604
1607
|
const status = record.status;
|
|
@@ -1646,10 +1649,131 @@ function ReferenceSelect({
|
|
|
1646
1649
|
] });
|
|
1647
1650
|
}
|
|
1648
1651
|
|
|
1652
|
+
// src/components/internal/CoreErrorAlert.tsx
|
|
1653
|
+
import { Box as Box4, Text as Text5 } from "@chakra-ui/react";
|
|
1654
|
+
|
|
1655
|
+
// src/components/internal/actionError.ts
|
|
1656
|
+
function asRecord(value2) {
|
|
1657
|
+
return value2 && typeof value2 === "object" ? value2 : void 0;
|
|
1658
|
+
}
|
|
1659
|
+
function firstText(...values) {
|
|
1660
|
+
return values.find((value2) => typeof value2 === "string" && value2.trim().length > 0)?.trim();
|
|
1661
|
+
}
|
|
1662
|
+
function firstNumber(...values) {
|
|
1663
|
+
return values.find((value2) => typeof value2 === "number" && Number.isFinite(value2));
|
|
1664
|
+
}
|
|
1665
|
+
function collectDetailMessages(value2, visited = /* @__PURE__ */ new WeakSet(), depth = 0) {
|
|
1666
|
+
if (depth > 4 || value2 == null) return [];
|
|
1667
|
+
if (typeof value2 === "string") return value2.trim() ? [value2.trim()] : [];
|
|
1668
|
+
if (Array.isArray(value2)) {
|
|
1669
|
+
return value2.flatMap((item) => collectDetailMessages(item, visited, depth + 1));
|
|
1670
|
+
}
|
|
1671
|
+
if (typeof value2 !== "object" || visited.has(value2)) return [];
|
|
1672
|
+
visited.add(value2);
|
|
1673
|
+
const record = value2;
|
|
1674
|
+
const field = firstText(record.field, record.path, record.property, record.name);
|
|
1675
|
+
const message = firstText(record.message, record.msg, record.reason);
|
|
1676
|
+
const technicalMessage = firstText(record.technicalMessage);
|
|
1677
|
+
const index = firstText(record.index);
|
|
1678
|
+
const direct = [
|
|
1679
|
+
message ? field ? `${field}: ${message}` : message : void 0,
|
|
1680
|
+
technicalMessage,
|
|
1681
|
+
index ? `\xCDndice: ${index}` : void 0
|
|
1682
|
+
].filter((item) => Boolean(item));
|
|
1683
|
+
const nestedKeys = ["details", "errors", "validation", "fields"];
|
|
1684
|
+
const nested = nestedKeys.flatMap((key) => collectDetailMessages(record[key], visited, depth + 1));
|
|
1685
|
+
if (direct.length || nested.length) return [...direct, ...nested];
|
|
1686
|
+
return Object.entries(record).filter(([key]) => !["code", "status", "statusCode", "requestId"].includes(key)).flatMap(([, nestedValue]) => collectDetailMessages(nestedValue, visited, depth + 1));
|
|
1687
|
+
}
|
|
1688
|
+
function unique(values) {
|
|
1689
|
+
return [...new Set(values.map((value2) => value2.trim()).filter(Boolean))];
|
|
1690
|
+
}
|
|
1691
|
+
function describeActionError(error) {
|
|
1692
|
+
if (error instanceof Error) return { message: error.message };
|
|
1693
|
+
if (typeof error === "string") return { message: error };
|
|
1694
|
+
const record = asRecord(error);
|
|
1695
|
+
if (!record) return { message: "N\xE3o foi poss\xEDvel executar a a\xE7\xE3o." };
|
|
1696
|
+
const nestedEnvelope = asRecord(record.error);
|
|
1697
|
+
const envelope = nestedEnvelope ?? record;
|
|
1698
|
+
const message = firstText(envelope.message, record.message) ?? "N\xE3o foi poss\xEDvel executar a a\xE7\xE3o.";
|
|
1699
|
+
const rawError = typeof record.error === "string" ? record.error : void 0;
|
|
1700
|
+
const details = unique(collectDetailMessages(envelope.details ?? record.details ?? rawError)).filter((detail) => detail !== message).slice(0, 5);
|
|
1701
|
+
const code = firstText(envelope.code, record.code);
|
|
1702
|
+
const status = firstNumber(envelope.status, envelope.statusCode, record.status, record.statusCode);
|
|
1703
|
+
const requestId = firstText(envelope.requestId, record.requestId);
|
|
1704
|
+
const technical = [
|
|
1705
|
+
code ? `C\xF3digo: ${code}` : void 0,
|
|
1706
|
+
status ? `HTTP: ${status}` : void 0,
|
|
1707
|
+
requestId ? `ID da requisi\xE7\xE3o: ${requestId}` : void 0
|
|
1708
|
+
].filter((value2) => Boolean(value2));
|
|
1709
|
+
const contextParts = [...details, ...technical];
|
|
1710
|
+
return {
|
|
1711
|
+
message,
|
|
1712
|
+
...contextParts.length ? { context: contextParts.join(" \u2022 ") } : {}
|
|
1713
|
+
};
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
// src/components/internal/CoreErrorAlert.tsx
|
|
1717
|
+
import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1718
|
+
function CoreErrorAlert({
|
|
1719
|
+
error,
|
|
1720
|
+
mt
|
|
1721
|
+
}) {
|
|
1722
|
+
const description = describeActionError(error);
|
|
1723
|
+
const details = description.context?.split(" \u2022 ").filter(Boolean) ?? [];
|
|
1724
|
+
return /* @__PURE__ */ jsxs5(
|
|
1725
|
+
Box4,
|
|
1726
|
+
{
|
|
1727
|
+
role: "alert",
|
|
1728
|
+
mt,
|
|
1729
|
+
p: "10px 12px",
|
|
1730
|
+
color: "#B42318",
|
|
1731
|
+
bg: "#FEF3F2",
|
|
1732
|
+
borderWidth: "1px",
|
|
1733
|
+
borderColor: "#FECDCA",
|
|
1734
|
+
borderRadius: "7px",
|
|
1735
|
+
fontSize: "11px",
|
|
1736
|
+
children: [
|
|
1737
|
+
/* @__PURE__ */ jsx9(Text5, { fontSize: "11px", fontWeight: "500", children: description.message }),
|
|
1738
|
+
details.length ? /* @__PURE__ */ jsxs5(Box4, { as: "details", mt: "5px", children: [
|
|
1739
|
+
/* @__PURE__ */ jsx9(
|
|
1740
|
+
Box4,
|
|
1741
|
+
{
|
|
1742
|
+
as: "summary",
|
|
1743
|
+
w: "fit-content",
|
|
1744
|
+
color: "#9B1C1C",
|
|
1745
|
+
cursor: "pointer",
|
|
1746
|
+
fontSize: "10px",
|
|
1747
|
+
fontWeight: "600",
|
|
1748
|
+
textDecoration: "underline",
|
|
1749
|
+
children: "Detalhes"
|
|
1750
|
+
}
|
|
1751
|
+
),
|
|
1752
|
+
/* @__PURE__ */ jsx9(
|
|
1753
|
+
Box4,
|
|
1754
|
+
{
|
|
1755
|
+
as: "ul",
|
|
1756
|
+
mt: "6px",
|
|
1757
|
+
mb: 0,
|
|
1758
|
+
pl: "18px",
|
|
1759
|
+
color: "#7A271A",
|
|
1760
|
+
fontFamily: "mono",
|
|
1761
|
+
fontSize: "9px",
|
|
1762
|
+
lineHeight: "1.45",
|
|
1763
|
+
overflowWrap: "anywhere",
|
|
1764
|
+
children: details.map((detail) => /* @__PURE__ */ jsx9("li", { children: detail }, detail))
|
|
1765
|
+
}
|
|
1766
|
+
)
|
|
1767
|
+
] }) : null
|
|
1768
|
+
]
|
|
1769
|
+
}
|
|
1770
|
+
);
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1649
1773
|
// src/components/internal/inputMasks.ts
|
|
1650
|
-
var digitsOnly = (
|
|
1651
|
-
var normalizedName = (
|
|
1652
|
-
var hasLetters = (
|
|
1774
|
+
var digitsOnly = (value2) => String(value2 ?? "").replace(/\D/g, "");
|
|
1775
|
+
var normalizedName = (value2) => String(value2 ?? "").normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
|
|
1776
|
+
var hasLetters = (value2) => /[a-zA-Z]/.test(String(value2 ?? ""));
|
|
1653
1777
|
function personType(values) {
|
|
1654
1778
|
return normalizedName(values?.tipo ?? values?.tipoPessoa ?? values?.pessoaTipo);
|
|
1655
1779
|
}
|
|
@@ -1671,16 +1795,16 @@ function resolveInputMask(field, values) {
|
|
|
1671
1795
|
if (/telefone|celular|whatsapp|fone|phone/.test(name)) return "phone";
|
|
1672
1796
|
return void 0;
|
|
1673
1797
|
}
|
|
1674
|
-
function formatCpf(
|
|
1675
|
-
const digits = digitsOnly(
|
|
1798
|
+
function formatCpf(value2) {
|
|
1799
|
+
const digits = digitsOnly(value2).slice(0, 11);
|
|
1676
1800
|
return digits.replace(/^(\d{3})(\d)/, "$1.$2").replace(/^(\d{3})\.(\d{3})(\d)/, "$1.$2.$3").replace(/\.(\d{3})(\d)/, ".$1-$2");
|
|
1677
1801
|
}
|
|
1678
|
-
function formatCnpj(
|
|
1679
|
-
const digits = digitsOnly(
|
|
1802
|
+
function formatCnpj(value2) {
|
|
1803
|
+
const digits = digitsOnly(value2).slice(0, 14);
|
|
1680
1804
|
return digits.replace(/^(\d{2})(\d)/, "$1.$2").replace(/^(\d{2})\.(\d{3})(\d)/, "$1.$2.$3").replace(/\.(\d{3})(\d)/, ".$1/$2").replace(/(\/\d{4})(\d)/, "$1-$2");
|
|
1681
1805
|
}
|
|
1682
|
-
function formatPhone(
|
|
1683
|
-
const digits = digitsOnly(
|
|
1806
|
+
function formatPhone(value2) {
|
|
1807
|
+
const digits = digitsOnly(value2).slice(0, 11);
|
|
1684
1808
|
if (!digits) return "";
|
|
1685
1809
|
if (digits.length <= 2) return `(${digits}`;
|
|
1686
1810
|
const ddd = digits.slice(0, 2);
|
|
@@ -1690,18 +1814,18 @@ function formatPhone(value) {
|
|
|
1690
1814
|
const suffix = number.slice(prefixLength);
|
|
1691
1815
|
return `(${ddd}) ${prefix}${suffix ? `-${suffix}` : ""}`;
|
|
1692
1816
|
}
|
|
1693
|
-
function parseCurrencyInitial(
|
|
1694
|
-
if (
|
|
1695
|
-
if (typeof
|
|
1696
|
-
const raw = String(
|
|
1817
|
+
function parseCurrencyInitial(value2) {
|
|
1818
|
+
if (value2 == null || value2 === "") return "";
|
|
1819
|
+
if (typeof value2 === "number") return Number.isFinite(value2) ? String(value2) : "";
|
|
1820
|
+
const raw = String(value2).trim();
|
|
1697
1821
|
if (!raw) return "";
|
|
1698
1822
|
if (/^-?\d+(?:\.\d+)?$/.test(raw)) return raw;
|
|
1699
1823
|
const localized = raw.replace(/[^\d,.-]/g, "").replace(/\.(?=\d{3}(?:\D|$))/g, "").replace(",", ".");
|
|
1700
1824
|
const parsed = Number(localized);
|
|
1701
1825
|
return Number.isFinite(parsed) ? String(parsed) : "";
|
|
1702
1826
|
}
|
|
1703
|
-
function formatCurrency(
|
|
1704
|
-
const normalized2 = parseCurrencyInitial(
|
|
1827
|
+
function formatCurrency(value2) {
|
|
1828
|
+
const normalized2 = parseCurrencyInitial(value2);
|
|
1705
1829
|
if (!normalized2) return "";
|
|
1706
1830
|
const numeric = Number(normalized2);
|
|
1707
1831
|
if (!Number.isFinite(numeric)) return "";
|
|
@@ -1712,32 +1836,32 @@ function formatCurrency(value) {
|
|
|
1712
1836
|
maximumFractionDigits: 2
|
|
1713
1837
|
}).format(numeric);
|
|
1714
1838
|
}
|
|
1715
|
-
function normalizeMaskedValue(
|
|
1716
|
-
if (!mask) return String(
|
|
1717
|
-
if (mask === "currency") return parseCurrencyInitial(
|
|
1718
|
-
if (mask === "document" && hasLetters(
|
|
1839
|
+
function normalizeMaskedValue(value2, mask) {
|
|
1840
|
+
if (!mask) return String(value2 ?? "");
|
|
1841
|
+
if (mask === "currency") return parseCurrencyInitial(value2);
|
|
1842
|
+
if (mask === "document" && hasLetters(value2)) return String(value2 ?? "").slice(0, 30);
|
|
1719
1843
|
const limit = mask === "cnpj" ? 14 : mask === "cpf" ? 11 : mask === "phone" ? 11 : 14;
|
|
1720
|
-
return digitsOnly(
|
|
1721
|
-
}
|
|
1722
|
-
function formatMaskedValue(
|
|
1723
|
-
if (!mask) return String(
|
|
1724
|
-
if (mask === "currency") return formatCurrency(
|
|
1725
|
-
if (mask === "phone") return formatPhone(
|
|
1726
|
-
if (mask === "cpf") return formatCpf(
|
|
1727
|
-
if (mask === "cnpj") return formatCnpj(
|
|
1728
|
-
if (hasLetters(
|
|
1729
|
-
const digits = digitsOnly(
|
|
1844
|
+
return digitsOnly(value2).slice(0, limit);
|
|
1845
|
+
}
|
|
1846
|
+
function formatMaskedValue(value2, mask) {
|
|
1847
|
+
if (!mask) return String(value2 ?? "");
|
|
1848
|
+
if (mask === "currency") return formatCurrency(value2);
|
|
1849
|
+
if (mask === "phone") return formatPhone(value2);
|
|
1850
|
+
if (mask === "cpf") return formatCpf(value2);
|
|
1851
|
+
if (mask === "cnpj") return formatCnpj(value2);
|
|
1852
|
+
if (hasLetters(value2)) return String(value2 ?? "");
|
|
1853
|
+
const digits = digitsOnly(value2);
|
|
1730
1854
|
return digits.length > 11 ? formatCnpj(digits) : formatCpf(digits);
|
|
1731
1855
|
}
|
|
1732
|
-
function parseMaskedInput(
|
|
1733
|
-
if (!mask) return
|
|
1856
|
+
function parseMaskedInput(value2, mask) {
|
|
1857
|
+
if (!mask) return value2;
|
|
1734
1858
|
if (mask === "currency") {
|
|
1735
|
-
const digits = digitsOnly(
|
|
1859
|
+
const digits = digitsOnly(value2);
|
|
1736
1860
|
if (!digits) return "";
|
|
1737
1861
|
const amount = Number(digits) / 100;
|
|
1738
|
-
return `${
|
|
1862
|
+
return `${value2.includes("-") ? "-" : ""}${amount.toFixed(2)}`;
|
|
1739
1863
|
}
|
|
1740
|
-
return normalizeMaskedValue(
|
|
1864
|
+
return normalizeMaskedValue(value2, mask);
|
|
1741
1865
|
}
|
|
1742
1866
|
function inputModeForMask(mask) {
|
|
1743
1867
|
if (mask === "document") return "text";
|
|
@@ -1752,42 +1876,42 @@ function maxLengthForMask(mask) {
|
|
|
1752
1876
|
}
|
|
1753
1877
|
|
|
1754
1878
|
// src/components/internal/DynamicForm.tsx
|
|
1755
|
-
import { jsx as
|
|
1879
|
+
import { jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1756
1880
|
var idFor = (field) => `oon-form-field-${field.replace(/[^a-zA-Z0-9_-]/g, "-")}`;
|
|
1757
1881
|
var errorIdFor = (field) => `${idFor(field)}-error`;
|
|
1758
|
-
var normalize = (
|
|
1882
|
+
var normalize = (value2) => String(value2 ?? "").normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
|
|
1759
1883
|
function CloseIcon() {
|
|
1760
|
-
return /* @__PURE__ */
|
|
1884
|
+
return /* @__PURE__ */ jsx10("svg", { viewBox: "0 0 20 20", width: "18", height: "18", "aria-hidden": "true", children: /* @__PURE__ */ jsx10("path", { d: "m6 6 8 8M14 6l-8 8", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" }) });
|
|
1761
1885
|
}
|
|
1762
1886
|
function CheckIcon() {
|
|
1763
|
-
return /* @__PURE__ */
|
|
1764
|
-
/* @__PURE__ */
|
|
1765
|
-
/* @__PURE__ */
|
|
1887
|
+
return /* @__PURE__ */ jsxs6("svg", { viewBox: "0 0 20 20", width: "16", height: "16", "aria-hidden": "true", children: [
|
|
1888
|
+
/* @__PURE__ */ jsx10("circle", { cx: "10", cy: "10", r: "7", fill: "none", stroke: "currentColor", strokeWidth: "1.4" }),
|
|
1889
|
+
/* @__PURE__ */ jsx10("path", { d: "m6.8 10.1 2 2 4.3-4.4", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
1766
1890
|
] });
|
|
1767
1891
|
}
|
|
1768
1892
|
function AlertIcon() {
|
|
1769
|
-
return /* @__PURE__ */
|
|
1770
|
-
/* @__PURE__ */
|
|
1771
|
-
/* @__PURE__ */
|
|
1893
|
+
return /* @__PURE__ */ jsxs6("svg", { viewBox: "0 0 20 20", width: "17", height: "17", "aria-hidden": "true", children: [
|
|
1894
|
+
/* @__PURE__ */ jsx10("circle", { cx: "10", cy: "10", r: "7", fill: "none", stroke: "currentColor", strokeWidth: "1.4" }),
|
|
1895
|
+
/* @__PURE__ */ jsx10("path", { d: "M10 6.5v4.2M10 13.5v.1", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" })
|
|
1772
1896
|
] });
|
|
1773
1897
|
}
|
|
1774
|
-
function toValue(
|
|
1775
|
-
if (
|
|
1898
|
+
function toValue(value2, kind) {
|
|
1899
|
+
if (value2 == null) return "";
|
|
1776
1900
|
if (kind === "date") {
|
|
1777
1901
|
try {
|
|
1778
|
-
return new Date(
|
|
1902
|
+
return new Date(value2).toISOString().slice(0, 10);
|
|
1779
1903
|
} catch {
|
|
1780
1904
|
return "";
|
|
1781
1905
|
}
|
|
1782
1906
|
}
|
|
1783
|
-
if (typeof
|
|
1784
|
-
const record =
|
|
1907
|
+
if (typeof value2 === "object") {
|
|
1908
|
+
const record = value2;
|
|
1785
1909
|
return String(record._id ?? record.id ?? "");
|
|
1786
1910
|
}
|
|
1787
|
-
return String(
|
|
1911
|
+
return String(value2);
|
|
1788
1912
|
}
|
|
1789
|
-
function initialFieldValue(field,
|
|
1790
|
-
return normalizeMaskedValue(toValue(
|
|
1913
|
+
function initialFieldValue(field, value2) {
|
|
1914
|
+
return normalizeMaskedValue(toValue(value2, field.kind), resolveInputMask(field));
|
|
1791
1915
|
}
|
|
1792
1916
|
function initialReactiveValues(fields, initialValues) {
|
|
1793
1917
|
const initial = Object.fromEntries(fields.map((field) => [field.field, initialFieldValue(field, initialValues?.[field.field])]));
|
|
@@ -1817,12 +1941,12 @@ function detailErrors(error, fields) {
|
|
|
1817
1941
|
const result = {};
|
|
1818
1942
|
const lookup = new Map(fields.flatMap((field) => [[normalize(field.field), field], [normalize(field.label), field]]));
|
|
1819
1943
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
1820
|
-
const visit = (
|
|
1821
|
-
if (
|
|
1822
|
-
if (Array.isArray(
|
|
1823
|
-
if (typeof
|
|
1824
|
-
seen.add(
|
|
1825
|
-
const record =
|
|
1944
|
+
const visit = (value2, hint) => {
|
|
1945
|
+
if (value2 == null) return;
|
|
1946
|
+
if (Array.isArray(value2)) return value2.forEach((item) => visit(item, hint));
|
|
1947
|
+
if (typeof value2 !== "object" || seen.has(value2)) return;
|
|
1948
|
+
seen.add(value2);
|
|
1949
|
+
const record = value2;
|
|
1826
1950
|
const candidate = String(record.field ?? record.path ?? record.property ?? record.name ?? hint ?? "");
|
|
1827
1951
|
const field = lookup.get(normalize(candidate.split(/[.[\]]+/).filter(Boolean).pop() ?? candidate));
|
|
1828
1952
|
const raw = record.message ?? record.msg ?? record.reason;
|
|
@@ -1850,14 +1974,14 @@ function isMultiline(field) {
|
|
|
1850
1974
|
return field.multiline === true || /observa|descricao|mensagem|detalhe|necessidade/i.test(field.field);
|
|
1851
1975
|
}
|
|
1852
1976
|
function Label({ id, label, required, readonly }) {
|
|
1853
|
-
return /* @__PURE__ */
|
|
1977
|
+
return /* @__PURE__ */ jsx10("label", { htmlFor: id, children: /* @__PURE__ */ jsxs6(Text6, { as: "span", display: "block", mb: "6px", color: "#475467", fontSize: "11px", fontWeight: "600", children: [
|
|
1854
1978
|
label,
|
|
1855
|
-
required && !readonly ? /* @__PURE__ */
|
|
1856
|
-
readonly ? /* @__PURE__ */
|
|
1979
|
+
required && !readonly ? /* @__PURE__ */ jsx10(Text6, { as: "span", color: "#DC2626", children: " *" }) : null,
|
|
1980
|
+
readonly ? /* @__PURE__ */ jsx10(Text6, { as: "span", ml: "5px", color: "#98A2B3", fontSize: "9px", fontWeight: "500", children: "somente leitura" }) : null
|
|
1857
1981
|
] }) });
|
|
1858
1982
|
}
|
|
1859
1983
|
function ErrorText({ id, text }) {
|
|
1860
|
-
return text ? /* @__PURE__ */
|
|
1984
|
+
return text ? /* @__PURE__ */ jsx10(Text6, { id, role: "alert", mt: "5px", color: "#DC2626", fontSize: "10px", fontWeight: "500", children: text }) : null;
|
|
1861
1985
|
}
|
|
1862
1986
|
var controlProps = (invalid, readonly = false) => ({
|
|
1863
1987
|
minH: "37px",
|
|
@@ -1888,8 +2012,8 @@ function resolveReference(field, values) {
|
|
|
1888
2012
|
const filters = { ...field.referenceFilters ?? {} };
|
|
1889
2013
|
const missing = [];
|
|
1890
2014
|
Object.entries(field.referenceFilterFrom ?? {}).forEach(([queryField, formField]) => {
|
|
1891
|
-
const
|
|
1892
|
-
if (
|
|
2015
|
+
const value2 = values[formField];
|
|
2016
|
+
if (value2) filters[queryField] = value2;
|
|
1893
2017
|
else missing.push(formField);
|
|
1894
2018
|
});
|
|
1895
2019
|
return { filters, disabled: missing.length > 0 };
|
|
@@ -1922,15 +2046,15 @@ function DynamicForm({ title, eyebrow = "Cadastro", fields: rawFields, initialVa
|
|
|
1922
2046
|
const first = fields.find((field) => next[field.field]);
|
|
1923
2047
|
if (first) focusField(first.field);
|
|
1924
2048
|
}, [error]);
|
|
1925
|
-
const change = (fieldName,
|
|
2049
|
+
const change = (fieldName, value2) => {
|
|
1926
2050
|
const selected = fields.find((field) => field.field === fieldName);
|
|
1927
2051
|
if (selected?.readonly || selected?.computed) return;
|
|
1928
2052
|
const dependentFields = fields.filter(
|
|
1929
2053
|
(candidate) => Object.values(candidate.referenceFilterFrom ?? {}).includes(fieldName)
|
|
1930
2054
|
);
|
|
1931
2055
|
setValues((current) => {
|
|
1932
|
-
const changed = current[fieldName] !==
|
|
1933
|
-
const next = { ...current, [fieldName]:
|
|
2056
|
+
const changed = current[fieldName] !== value2;
|
|
2057
|
+
const next = { ...current, [fieldName]: value2 };
|
|
1934
2058
|
if (changed) dependentFields.forEach((candidate) => {
|
|
1935
2059
|
next[candidate.field] = "";
|
|
1936
2060
|
});
|
|
@@ -1968,21 +2092,21 @@ function DynamicForm({ title, eyebrow = "Cadastro", fields: rawFields, initialVa
|
|
|
1968
2092
|
const multiline = isMultiline(field);
|
|
1969
2093
|
const span = field.span === 2 || multiline;
|
|
1970
2094
|
const readonly = Boolean(field.readonly || field.computed);
|
|
1971
|
-
const wrap = (control, showLabel = true) => /* @__PURE__ */
|
|
1972
|
-
showLabel ? /* @__PURE__ */
|
|
2095
|
+
const wrap = (control, showLabel = true) => /* @__PURE__ */ jsxs6(Box5, { minW: grouped ? "150px" : void 0, flex: grouped ? "0 1 auto" : void 0, gridColumn: !grouped && span ? "1 / -1" : void 0, children: [
|
|
2096
|
+
showLabel ? /* @__PURE__ */ jsx10(Label, { id, label, required: field.required, readonly }) : null,
|
|
1973
2097
|
control,
|
|
1974
|
-
/* @__PURE__ */
|
|
2098
|
+
/* @__PURE__ */ jsx10(ErrorText, { id: errorId, text: message })
|
|
1975
2099
|
] }, field.field);
|
|
1976
2100
|
if (field.widget === "checkbox") {
|
|
1977
2101
|
const checkedValue = String(field.checkedValue ?? true);
|
|
1978
2102
|
const uncheckedValue = String(field.uncheckedValue ?? false);
|
|
1979
2103
|
const checked = (values[field.field] ?? uncheckedValue) === checkedValue;
|
|
1980
2104
|
return wrap(
|
|
1981
|
-
/* @__PURE__ */
|
|
1982
|
-
/* @__PURE__ */
|
|
1983
|
-
/* @__PURE__ */
|
|
2105
|
+
/* @__PURE__ */ jsxs6(Box5, { as: "label", display: "flex", minH: "37px", px: "11px", alignItems: "center", gap: "8px", color: "#344054", bg: readonly ? "#F8FAFC" : checked ? "#F0F7FF" : "white", borderWidth: "1px", borderColor: message ? "#DC2626" : checked ? "#8FC9E7" : "#D5DDE3", borderRadius: "7px", cursor: readonly ? "not-allowed" : "pointer", transition: "background .15s ease, border-color .15s ease", children: [
|
|
2106
|
+
/* @__PURE__ */ jsx10("input", { id, type: "checkbox", checked, disabled: readonly, "aria-invalid": !!message, "aria-describedby": errorId, style: { width: 16, height: 16, accentColor: "#0474AF", cursor: readonly ? "not-allowed" : "pointer" }, onChange: (event) => change(field.field, event.currentTarget.checked ? checkedValue : uncheckedValue) }),
|
|
2107
|
+
/* @__PURE__ */ jsxs6(Text6, { as: "span", fontSize: "11px", fontWeight: "600", children: [
|
|
1984
2108
|
label,
|
|
1985
|
-
field.required && !readonly ? /* @__PURE__ */
|
|
2109
|
+
field.required && !readonly ? /* @__PURE__ */ jsx10(Text6, { as: "span", color: "#DC2626", children: " *" }) : null
|
|
1986
2110
|
] })
|
|
1987
2111
|
] }),
|
|
1988
2112
|
false
|
|
@@ -1990,77 +2114,74 @@ function DynamicForm({ title, eyebrow = "Cadastro", fields: rawFields, initialVa
|
|
|
1990
2114
|
}
|
|
1991
2115
|
if (field.kind === "ref" && field.ref) {
|
|
1992
2116
|
const reference = resolveReference(field, values);
|
|
1993
|
-
return wrap(/* @__PURE__ */
|
|
2117
|
+
return wrap(/* @__PURE__ */ jsx10(ReferenceSelect, { field: field.field, inputId: id, errorId, label, refModel: field.ref, value: values[field.field] ?? "", initialValue: initialValues?.[field.field], required: field.required && !readonly, invalid: !!message, error: message, filters: reference.filters, emptyFields: field.referenceEmptyFields, disabled: readonly || reference.disabled, disabledMessage: field.referenceDisabledMessage, onChange: (value3) => change(field.field, value3) }));
|
|
1994
2118
|
}
|
|
1995
|
-
if (field.kind === "enum" && field.options?.length) return wrap(/* @__PURE__ */
|
|
1996
|
-
/* @__PURE__ */
|
|
1997
|
-
/* @__PURE__ */
|
|
1998
|
-
field.options.map((option) => /* @__PURE__ */
|
|
2119
|
+
if (field.kind === "enum" && field.options?.length) return wrap(/* @__PURE__ */ jsxs6(NativeSelect2.Root, { size: "sm", disabled: readonly, children: [
|
|
2120
|
+
/* @__PURE__ */ jsxs6(NativeSelect2.Field, { id, "aria-invalid": !!message, "aria-describedby": errorId, value: values[field.field] ?? "", ...controlProps(!!message, readonly), onChange: (event) => change(field.field, event.currentTarget.value), children: [
|
|
2121
|
+
/* @__PURE__ */ jsx10("option", { value: "", children: "\u2014 Selecione \u2014" }),
|
|
2122
|
+
field.options.map((option) => /* @__PURE__ */ jsx10("option", { value: option, children: option }, option))
|
|
1999
2123
|
] }),
|
|
2000
|
-
/* @__PURE__ */
|
|
2124
|
+
/* @__PURE__ */ jsx10(NativeSelect2.Indicator, {})
|
|
2001
2125
|
] }));
|
|
2002
|
-
if (field.kind === "boolean") return wrap(/* @__PURE__ */
|
|
2003
|
-
/* @__PURE__ */
|
|
2004
|
-
/* @__PURE__ */
|
|
2005
|
-
/* @__PURE__ */
|
|
2006
|
-
/* @__PURE__ */
|
|
2126
|
+
if (field.kind === "boolean") return wrap(/* @__PURE__ */ jsxs6(NativeSelect2.Root, { size: "sm", disabled: readonly, children: [
|
|
2127
|
+
/* @__PURE__ */ jsxs6(NativeSelect2.Field, { id, "aria-invalid": !!message, "aria-describedby": errorId, value: values[field.field] ?? "", ...controlProps(!!message, readonly), onChange: (event) => change(field.field, event.currentTarget.value), children: [
|
|
2128
|
+
/* @__PURE__ */ jsx10("option", { value: "", children: "\u2014 Selecione \u2014" }),
|
|
2129
|
+
/* @__PURE__ */ jsx10("option", { value: "true", children: "Sim" }),
|
|
2130
|
+
/* @__PURE__ */ jsx10("option", { value: "false", children: "N\xE3o" })
|
|
2007
2131
|
] }),
|
|
2008
|
-
/* @__PURE__ */
|
|
2132
|
+
/* @__PURE__ */ jsx10(NativeSelect2.Indicator, {})
|
|
2009
2133
|
] }));
|
|
2010
|
-
if (multiline) return wrap(/* @__PURE__ */
|
|
2134
|
+
if (multiline) return wrap(/* @__PURE__ */ jsx10(Textarea, { id, rows: field.rows ?? 4, resize: "vertical", readOnly: readonly, "aria-invalid": !!message, "aria-describedby": errorId, value: values[field.field] ?? "", ...controlProps(!!message, readonly), lineHeight: "1.5", onChange: (event) => change(field.field, event.currentTarget.value) }));
|
|
2011
2135
|
const mask = resolveInputMask(field);
|
|
2012
2136
|
const numeric = ["number", "currency", "currencyConverted"].includes(field.kind ?? "");
|
|
2013
2137
|
const type = mask ? "text" : field.kind === "date" ? "date" : numeric ? "number" : "text";
|
|
2014
|
-
const
|
|
2138
|
+
const value2 = values[field.field] ?? "";
|
|
2015
2139
|
return wrap(
|
|
2016
|
-
/* @__PURE__ */
|
|
2140
|
+
/* @__PURE__ */ jsx10(Input3, { id, type, step: type === "number" ? "any" : void 0, inputMode: inputModeForMask(mask), maxLength: maxLengthForMask(mask), autoComplete: "off", readOnly: readonly, "aria-invalid": !!message, "aria-describedby": errorId, value: mask ? formatMaskedValue(value2, mask) : value2, ...controlProps(!!message, readonly), onChange: (event) => change(field.field, parseMaskedInput(event.currentTarget.value, mask)) })
|
|
2017
2141
|
);
|
|
2018
2142
|
};
|
|
2019
2143
|
const combinedErrors = { ...formulaErrors, ...errors };
|
|
2020
2144
|
const invalid = fields.filter((field) => combinedErrors[field.field]);
|
|
2021
2145
|
const generic = dismissed ? null : messageOf(error);
|
|
2022
|
-
return /* @__PURE__ */
|
|
2146
|
+
return /* @__PURE__ */ jsx10(Flex4, { position: "fixed", inset: 0, zIndex: 1e3, align: "center", justify: "center", p: { base: 2, md: 6 }, bg: "rgba(15,23,42,.48)", backdropFilter: "blur(2px)", onMouseDown: (event) => {
|
|
2023
2147
|
if (event.currentTarget === event.target && !submitting) onCancel();
|
|
2024
|
-
}, children: /* @__PURE__ */
|
|
2025
|
-
/* @__PURE__ */
|
|
2026
|
-
/* @__PURE__ */
|
|
2027
|
-
/* @__PURE__ */
|
|
2028
|
-
/* @__PURE__ */
|
|
2148
|
+
}, children: /* @__PURE__ */ jsxs6(Box5, { role: "dialog", "aria-modal": "true", "aria-label": title, w: "min(860px, 96vw)", maxH: "min(880px, 94vh)", overflow: "hidden", bg: "white", borderWidth: "1px", borderColor: "#E5E9ED", borderRadius: "14px", boxShadow: "0 24px 70px rgba(15,23,42,.24)", children: [
|
|
2149
|
+
/* @__PURE__ */ jsxs6(Flex4, { minH: "76px", px: "20px", py: "16px", align: "center", justify: "space-between", borderBottomWidth: "1px", borderColor: "#E5E9ED", children: [
|
|
2150
|
+
/* @__PURE__ */ jsxs6(Box5, { children: [
|
|
2151
|
+
/* @__PURE__ */ jsx10(Text6, { color: "#0474AF", fontSize: "10px", fontWeight: "600", letterSpacing: ".07em", textTransform: "uppercase", children: eyebrow }),
|
|
2152
|
+
/* @__PURE__ */ jsx10(Heading2, { mt: "3px", color: "#344054", fontSize: "18px", fontWeight: "600", children: title })
|
|
2029
2153
|
] }),
|
|
2030
|
-
/* @__PURE__ */
|
|
2154
|
+
/* @__PURE__ */ jsx10(Button4, { type: "button", "aria-label": "Fechar", w: "31px", minW: "31px", h: "31px", p: 0, color: "#667085", bg: "white", borderWidth: "1px", borderColor: "#E5E9ED", borderRadius: "6px", disabled: submitting, onClick: onCancel, _hover: { color: "#036491", bg: "#F0F7FF", borderColor: "#B8D9EB" }, children: /* @__PURE__ */ jsx10(CloseIcon, {}) })
|
|
2031
2155
|
] }),
|
|
2032
|
-
/* @__PURE__ */
|
|
2033
|
-
/* @__PURE__ */
|
|
2034
|
-
invalid.length ? /* @__PURE__ */
|
|
2035
|
-
/* @__PURE__ */
|
|
2036
|
-
/* @__PURE__ */
|
|
2037
|
-
/* @__PURE__ */
|
|
2156
|
+
/* @__PURE__ */ jsxs6("form", { noValidate: true, onSubmit: submit, children: [
|
|
2157
|
+
/* @__PURE__ */ jsx10(Box5, { maxH: "calc(94vh - 148px)", px: "20px", pt: "18px", pb: "24px", overflowY: "auto", children: /* @__PURE__ */ jsxs6(Stack2, { gap: 4, children: [
|
|
2158
|
+
invalid.length ? /* @__PURE__ */ jsxs6(Box5, { role: "alert", p: "11px 13px", color: "#9B1C1C", bg: "#FFF5F5", borderWidth: "1px", borderColor: "#FECACA", borderLeftWidth: "4px", borderLeftColor: "#DC2626", borderRadius: "8px", fontSize: "11px", children: [
|
|
2159
|
+
/* @__PURE__ */ jsxs6(Flex4, { align: "center", gap: "7px", children: [
|
|
2160
|
+
/* @__PURE__ */ jsx10(AlertIcon, {}),
|
|
2161
|
+
/* @__PURE__ */ jsx10(Text6, { as: "strong", children: "Revise os campos abaixo:" })
|
|
2038
2162
|
] }),
|
|
2039
|
-
/* @__PURE__ */
|
|
2163
|
+
/* @__PURE__ */ jsx10(Box5, { as: "ul", mt: "7px", mb: 0, pl: "20px", display: "grid", gap: "3px", children: invalid.map((field) => /* @__PURE__ */ jsx10("li", { children: /* @__PURE__ */ jsxs6(Button4, { type: "button", variant: "plain", minH: "auto", h: "auto", p: 0, color: "#B42318", fontSize: "10px", fontWeight: "400", textDecoration: "underline", onClick: () => focusField(field.field), children: [
|
|
2040
2164
|
fieldLabel({ name: field.field, label: field.label }),
|
|
2041
2165
|
": ",
|
|
2042
2166
|
combinedErrors[field.field]
|
|
2043
2167
|
] }) }, field.field)) })
|
|
2044
2168
|
] }) : null,
|
|
2045
|
-
generic && !invalid.length ? /* @__PURE__ */
|
|
2046
|
-
|
|
2047
|
-
generic
|
|
2048
|
-
] }) : null,
|
|
2049
|
-
/* @__PURE__ */ jsx9(SimpleGrid, { columns: { base: 1, lg: 2 }, gapX: "16px", gapY: "15px", children: items.map((item) => {
|
|
2169
|
+
generic && !invalid.length ? /* @__PURE__ */ jsx10(CoreErrorAlert, { error }) : null,
|
|
2170
|
+
/* @__PURE__ */ jsx10(SimpleGrid, { columns: { base: 1, lg: 2 }, gapX: "16px", gapY: "15px", children: items.map((item) => {
|
|
2050
2171
|
if (item.type === "field") return renderField(item.field);
|
|
2051
2172
|
const first = item.fields[0];
|
|
2052
2173
|
const inline = item.fields.some((field) => field.inline !== false);
|
|
2053
|
-
return /* @__PURE__ */
|
|
2054
|
-
/* @__PURE__ */
|
|
2055
|
-
first.groupDescription ? /* @__PURE__ */
|
|
2056
|
-
/* @__PURE__ */
|
|
2174
|
+
return /* @__PURE__ */ jsxs6(Box5, { gridColumn: "1 / -1", p: "12px", bg: "#FAFCFD", borderWidth: "1px", borderColor: "#E5E9ED", borderRadius: "9px", children: [
|
|
2175
|
+
/* @__PURE__ */ jsx10(Text6, { color: "#344054", fontSize: "11px", fontWeight: "700", children: first.groupLabel ?? item.id }),
|
|
2176
|
+
first.groupDescription ? /* @__PURE__ */ jsx10(Text6, { mt: "2px", mb: "10px", color: "#667085", fontSize: "10px", children: first.groupDescription }) : /* @__PURE__ */ jsx10(Box5, { h: "8px" }),
|
|
2177
|
+
/* @__PURE__ */ jsx10(Flex4, { direction: inline ? "row" : "column", wrap: "wrap", gap: "9px", children: item.fields.map((field) => renderField(field, true)) })
|
|
2057
2178
|
] }, item.id);
|
|
2058
2179
|
}) })
|
|
2059
2180
|
] }) }),
|
|
2060
|
-
/* @__PURE__ */
|
|
2061
|
-
/* @__PURE__ */
|
|
2062
|
-
/* @__PURE__ */
|
|
2063
|
-
/* @__PURE__ */
|
|
2181
|
+
/* @__PURE__ */ jsxs6(Flex4, { minH: "68px", px: "20px", py: "14px", justify: "flex-end", gap: "9px", borderTopWidth: "1px", borderColor: "#E5E9ED", children: [
|
|
2182
|
+
/* @__PURE__ */ jsx10(Button4, { type: "button", minH: "35px", px: "13px", color: "#475467", bg: "white", borderWidth: "1px", borderColor: "#D5DDE3", borderRadius: "6px", fontSize: "11px", fontWeight: "600", disabled: submitting, onClick: onCancel, children: "Cancelar" }),
|
|
2183
|
+
/* @__PURE__ */ jsxs6(Button4, { type: "submit", minH: "35px", px: "13px", colorPalette: "brand", borderRadius: "6px", fontSize: "11px", fontWeight: "600", loading: submitting, children: [
|
|
2184
|
+
/* @__PURE__ */ jsx10(CheckIcon, {}),
|
|
2064
2185
|
" Salvar"
|
|
2065
2186
|
] })
|
|
2066
2187
|
] })
|
|
@@ -2070,15 +2191,15 @@ function DynamicForm({ title, eyebrow = "Cadastro", fields: rawFields, initialVa
|
|
|
2070
2191
|
|
|
2071
2192
|
// src/components/internal/CoreDetailModal.tsx
|
|
2072
2193
|
import { useEffect as useEffect6, useMemo as useMemo7, useRef as useRef2, useState as useState9 } from "react";
|
|
2073
|
-
import { Box as
|
|
2194
|
+
import { Box as Box10, Button as Button8, Flex as Flex7, Heading as Heading3, IconButton, Text as Text11 } from "@chakra-ui/react";
|
|
2074
2195
|
import { useQuery as useQuery6, useQueryClient as useQueryClient2 } from "@tanstack/react-query";
|
|
2075
2196
|
|
|
2076
2197
|
// src/components/internal/CoreTabbedDetail.tsx
|
|
2077
2198
|
import { useEffect as useEffect5, useMemo as useMemo6, useState as useState8 } from "react";
|
|
2078
|
-
import { Box as
|
|
2199
|
+
import { Box as Box9, Button as Button7, Flex as Flex6, Input as Input5, NativeSelect as NativeSelect4, SimpleGrid as SimpleGrid3, Stack as Stack3, Text as Text10, Textarea as Textarea3 } from "@chakra-ui/react";
|
|
2079
2200
|
|
|
2080
2201
|
// src/components/internal/CoreSummaryCards.tsx
|
|
2081
|
-
import { SimpleGrid as SimpleGrid2, Box as
|
|
2202
|
+
import { SimpleGrid as SimpleGrid2, Box as Box6, Text as Text7, Badge as Badge2 } from "@chakra-ui/react";
|
|
2082
2203
|
import { useQuery as useQuery4 } from "@tanstack/react-query";
|
|
2083
2204
|
|
|
2084
2205
|
// src/components/internal/manifestUtils.ts
|
|
@@ -2108,12 +2229,12 @@ function resolveInitialDetailTab(config, recordId, initialTab) {
|
|
|
2108
2229
|
}
|
|
2109
2230
|
|
|
2110
2231
|
// src/components/internal/CoreSummaryCards.tsx
|
|
2111
|
-
import { Fragment, jsx as
|
|
2112
|
-
function format(
|
|
2113
|
-
if (format2 === "currency") return new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(Number(
|
|
2114
|
-
if (format2 === "percent") return `${Number(
|
|
2115
|
-
if (format2 === "date") return formatCell(
|
|
2116
|
-
return
|
|
2232
|
+
import { Fragment, jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2233
|
+
function format(value2, format2) {
|
|
2234
|
+
if (format2 === "currency") return new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(Number(value2 ?? 0));
|
|
2235
|
+
if (format2 === "percent") return `${Number(value2 ?? 0).toLocaleString("pt-BR")}%`;
|
|
2236
|
+
if (format2 === "date") return formatCell(value2, "date");
|
|
2237
|
+
return value2 == null || value2 === "" ? "\u2014" : String(value2);
|
|
2117
2238
|
}
|
|
2118
2239
|
function RelatedMetric({ card, relation, parent }) {
|
|
2119
2240
|
const schema = useModelSchema(relation.model).data;
|
|
@@ -2121,58 +2242,58 @@ function RelatedMetric({ card, relation, parent }) {
|
|
|
2121
2242
|
const parentValue = parent[relation.parentKey ?? "_id"];
|
|
2122
2243
|
const query = useQuery4({ queryKey: ["oon", "summary", relation.model, relation.foreignKey, parentValue, card.source, card.field], queryFn: () => resource.list({ [relation.foreignKey]: parentValue, pageSize: 1e3 }) });
|
|
2123
2244
|
const rows = query.data?.results ?? [];
|
|
2124
|
-
let
|
|
2125
|
-
if (card.source === "relatedSum")
|
|
2126
|
-
if (card.source === "relatedAvg")
|
|
2127
|
-
return /* @__PURE__ */
|
|
2245
|
+
let value2 = rows.length;
|
|
2246
|
+
if (card.source === "relatedSum") value2 = rows.reduce((sum, row) => sum + Number(row[card.field ?? ""] ?? 0), 0);
|
|
2247
|
+
if (card.source === "relatedAvg") value2 = rows.length ? rows.reduce((sum, row) => sum + Number(row[card.field ?? ""] ?? 0), 0) / rows.length : 0;
|
|
2248
|
+
return /* @__PURE__ */ jsx11(Fragment, { children: query.isLoading ? "..." : format(value2, card.format) });
|
|
2128
2249
|
}
|
|
2129
2250
|
function CoreSummaryCards({ cards = [], parent, relations }) {
|
|
2130
|
-
return /* @__PURE__ */
|
|
2251
|
+
return /* @__PURE__ */ jsx11(SimpleGrid2, { columns: { base: 1, md: 3 }, gap: 3, children: cards.map((card, index) => {
|
|
2131
2252
|
const relation = card.relation ? relationFrom(card.relation, relations) : void 0;
|
|
2132
|
-
const content = relation && card.source?.startsWith("related") ? /* @__PURE__ */
|
|
2133
|
-
return /* @__PURE__ */
|
|
2134
|
-
/* @__PURE__ */
|
|
2135
|
-
/* @__PURE__ */
|
|
2253
|
+
const content = relation && card.source?.startsWith("related") ? /* @__PURE__ */ jsx11(RelatedMetric, { card, relation, parent }) : format(parent[card.field ?? ""], card.format);
|
|
2254
|
+
return /* @__PURE__ */ jsxs7(Box6, { p: "14px", bg: "white", borderWidth: "1px", borderColor: "#E5E9ED", borderRadius: "10px", children: [
|
|
2255
|
+
/* @__PURE__ */ jsx11(Text7, { color: "#667085", fontSize: "10px", fontWeight: "600", children: card.label }),
|
|
2256
|
+
/* @__PURE__ */ jsx11(Text7, { mt: "6px", color: "#24323A", fontSize: "20px", fontWeight: "700", children: card.format === "badge" ? /* @__PURE__ */ jsx11(Badge2, { children: content }) : content })
|
|
2136
2257
|
] }, `${card.label}-${index}`);
|
|
2137
2258
|
}) });
|
|
2138
2259
|
}
|
|
2139
2260
|
|
|
2140
2261
|
// src/components/internal/CoreRelatedGrid.tsx
|
|
2141
2262
|
import { useMemo as useMemo5, useState as useState7 } from "react";
|
|
2142
|
-
import { Badge as Badge3, Box as
|
|
2263
|
+
import { Badge as Badge3, Box as Box8, Button as Button6, Flex as Flex5, Table as Table2, Text as Text9 } from "@chakra-ui/react";
|
|
2143
2264
|
import { useMutation, useQuery as useQuery5, useQueryClient } from "@tanstack/react-query";
|
|
2144
2265
|
|
|
2145
2266
|
// src/components/internal/CoreInlineEditableCell.tsx
|
|
2146
2267
|
import { Input as Input4, NativeSelect as NativeSelect3, Textarea as Textarea2 } from "@chakra-ui/react";
|
|
2147
|
-
import { jsx as
|
|
2148
|
-
function CoreInlineEditableCell({ column, meta, value, onChange }) {
|
|
2268
|
+
import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2269
|
+
function CoreInlineEditableCell({ column, meta, value: value2, onChange }) {
|
|
2149
2270
|
const kind = column.editor ?? meta?.kind ?? column.kind ?? "string";
|
|
2150
|
-
const plainValue =
|
|
2271
|
+
const plainValue = value2 == null ? "" : String(value2);
|
|
2151
2272
|
const common = {
|
|
2152
2273
|
size: "xs",
|
|
2153
2274
|
fontSize: "11px",
|
|
2154
2275
|
value: plainValue,
|
|
2155
2276
|
onChange: (event) => onChange(event.currentTarget.value)
|
|
2156
2277
|
};
|
|
2157
|
-
if (kind === "boolean") return /* @__PURE__ */
|
|
2158
|
-
/* @__PURE__ */
|
|
2159
|
-
/* @__PURE__ */
|
|
2160
|
-
/* @__PURE__ */
|
|
2161
|
-
/* @__PURE__ */
|
|
2278
|
+
if (kind === "boolean") return /* @__PURE__ */ jsxs8(NativeSelect3.Root, { size: "xs", children: [
|
|
2279
|
+
/* @__PURE__ */ jsxs8(NativeSelect3.Field, { ...common, children: [
|
|
2280
|
+
/* @__PURE__ */ jsx12("option", { value: "", children: "\u2014" }),
|
|
2281
|
+
/* @__PURE__ */ jsx12("option", { value: "true", children: "Sim" }),
|
|
2282
|
+
/* @__PURE__ */ jsx12("option", { value: "false", children: "N\xE3o" })
|
|
2162
2283
|
] }),
|
|
2163
|
-
/* @__PURE__ */
|
|
2284
|
+
/* @__PURE__ */ jsx12(NativeSelect3.Indicator, {})
|
|
2164
2285
|
] });
|
|
2165
|
-
if ((kind === "enum" || kind === "select") && meta?.options?.length) return /* @__PURE__ */
|
|
2166
|
-
/* @__PURE__ */
|
|
2167
|
-
/* @__PURE__ */
|
|
2168
|
-
meta.options.map((option) => /* @__PURE__ */
|
|
2286
|
+
if ((kind === "enum" || kind === "select") && meta?.options?.length) return /* @__PURE__ */ jsxs8(NativeSelect3.Root, { size: "xs", children: [
|
|
2287
|
+
/* @__PURE__ */ jsxs8(NativeSelect3.Field, { ...common, children: [
|
|
2288
|
+
/* @__PURE__ */ jsx12("option", { value: "", children: "\u2014" }),
|
|
2289
|
+
meta.options.map((option) => /* @__PURE__ */ jsx12("option", { value: option, children: option }, option))
|
|
2169
2290
|
] }),
|
|
2170
|
-
/* @__PURE__ */
|
|
2291
|
+
/* @__PURE__ */ jsx12(NativeSelect3.Indicator, {})
|
|
2171
2292
|
] });
|
|
2172
|
-
if (kind === "textarea") return /* @__PURE__ */
|
|
2293
|
+
if (kind === "textarea") return /* @__PURE__ */ jsx12(Textarea2, { ...common, rows: 2 });
|
|
2173
2294
|
const mask = resolveInputMask({ field: column.field, kind });
|
|
2174
2295
|
const type = mask ? "text" : kind === "date" ? "date" : kind === "number" ? "number" : "text";
|
|
2175
|
-
return /* @__PURE__ */
|
|
2296
|
+
return /* @__PURE__ */ jsx12(
|
|
2176
2297
|
Input4,
|
|
2177
2298
|
{
|
|
2178
2299
|
size: "xs",
|
|
@@ -2189,60 +2310,7 @@ function CoreInlineEditableCell({ column, meta, value, onChange }) {
|
|
|
2189
2310
|
|
|
2190
2311
|
// src/components/internal/CoreRowAction.tsx
|
|
2191
2312
|
import { useState as useState6 } from "react";
|
|
2192
|
-
import { Box as
|
|
2193
|
-
|
|
2194
|
-
// src/components/internal/actionError.ts
|
|
2195
|
-
function asRecord(value) {
|
|
2196
|
-
return value && typeof value === "object" ? value : void 0;
|
|
2197
|
-
}
|
|
2198
|
-
function firstText(...values) {
|
|
2199
|
-
return values.find((value) => typeof value === "string" && value.trim().length > 0)?.trim();
|
|
2200
|
-
}
|
|
2201
|
-
function firstNumber(...values) {
|
|
2202
|
-
return values.find((value) => typeof value === "number" && Number.isFinite(value));
|
|
2203
|
-
}
|
|
2204
|
-
function collectDetailMessages(value, visited = /* @__PURE__ */ new WeakSet(), depth = 0) {
|
|
2205
|
-
if (depth > 4 || value == null) return [];
|
|
2206
|
-
if (typeof value === "string") return value.trim() ? [value.trim()] : [];
|
|
2207
|
-
if (Array.isArray(value)) {
|
|
2208
|
-
return value.flatMap((item) => collectDetailMessages(item, visited, depth + 1));
|
|
2209
|
-
}
|
|
2210
|
-
if (typeof value !== "object" || visited.has(value)) return [];
|
|
2211
|
-
visited.add(value);
|
|
2212
|
-
const record = value;
|
|
2213
|
-
const field = firstText(record.field, record.path, record.property, record.name);
|
|
2214
|
-
const message = firstText(record.message, record.msg, record.reason);
|
|
2215
|
-
const direct = message ? [field ? `${field}: ${message}` : message] : [];
|
|
2216
|
-
const nestedKeys = ["details", "errors", "validation", "fields"];
|
|
2217
|
-
const nested = nestedKeys.flatMap((key) => collectDetailMessages(record[key], visited, depth + 1));
|
|
2218
|
-
if (direct.length || nested.length) return [...direct, ...nested];
|
|
2219
|
-
return Object.entries(record).filter(([key]) => !["code", "status", "statusCode", "requestId"].includes(key)).flatMap(([, nestedValue]) => collectDetailMessages(nestedValue, visited, depth + 1));
|
|
2220
|
-
}
|
|
2221
|
-
function unique(values) {
|
|
2222
|
-
return [...new Set(values.map((value) => value.trim()).filter(Boolean))];
|
|
2223
|
-
}
|
|
2224
|
-
function describeActionError(error) {
|
|
2225
|
-
if (error instanceof Error) return { message: error.message };
|
|
2226
|
-
if (typeof error === "string") return { message: error };
|
|
2227
|
-
const record = asRecord(error);
|
|
2228
|
-
if (!record) return { message: "N\xE3o foi poss\xEDvel executar a a\xE7\xE3o." };
|
|
2229
|
-
const envelope = asRecord(record.error) ?? record;
|
|
2230
|
-
const message = firstText(envelope.message, record.message) ?? "N\xE3o foi poss\xEDvel executar a a\xE7\xE3o.";
|
|
2231
|
-
const details = unique(collectDetailMessages(envelope.details ?? record.details)).filter((detail) => detail !== message).slice(0, 3);
|
|
2232
|
-
const code = firstText(envelope.code, record.code);
|
|
2233
|
-
const status = firstNumber(envelope.status, envelope.statusCode, record.status, record.statusCode);
|
|
2234
|
-
const requestId = firstText(envelope.requestId, record.requestId);
|
|
2235
|
-
const technical = [
|
|
2236
|
-
code ? `C\xF3digo: ${code}` : void 0,
|
|
2237
|
-
status ? `HTTP: ${status}` : void 0,
|
|
2238
|
-
requestId ? `ID da requisi\xE7\xE3o: ${requestId}` : void 0
|
|
2239
|
-
].filter((value) => Boolean(value));
|
|
2240
|
-
const contextParts = [...details, ...technical];
|
|
2241
|
-
return {
|
|
2242
|
-
message,
|
|
2243
|
-
...contextParts.length ? { context: contextParts.join(" \u2022 ") } : {}
|
|
2244
|
-
};
|
|
2245
|
-
}
|
|
2313
|
+
import { Box as Box7, Button as Button5, Text as Text8 } from "@chakra-ui/react";
|
|
2246
2314
|
|
|
2247
2315
|
// src/components/internal/conditions.ts
|
|
2248
2316
|
function valueAt(source, path) {
|
|
@@ -2254,12 +2322,12 @@ function valueAt(source, path) {
|
|
|
2254
2322
|
}
|
|
2255
2323
|
function evaluateCondition(condition, row) {
|
|
2256
2324
|
if (!condition) return false;
|
|
2257
|
-
const
|
|
2258
|
-
if ("exists" in condition) return condition.exists ?
|
|
2259
|
-
if ("equals" in condition) return
|
|
2260
|
-
if ("notEquals" in condition) return
|
|
2261
|
-
if ("in" in condition) return condition.in.includes(
|
|
2262
|
-
const numeric = Number(
|
|
2325
|
+
const value2 = valueAt(row, condition.field);
|
|
2326
|
+
if ("exists" in condition) return condition.exists ? value2 != null && value2 !== "" : value2 == null || value2 === "";
|
|
2327
|
+
if ("equals" in condition) return value2 === condition.equals;
|
|
2328
|
+
if ("notEquals" in condition) return value2 !== condition.notEquals;
|
|
2329
|
+
if ("in" in condition) return condition.in.includes(value2);
|
|
2330
|
+
const numeric = Number(value2);
|
|
2263
2331
|
if (Number.isNaN(numeric)) return false;
|
|
2264
2332
|
if ("gt" in condition) return numeric > condition.gt;
|
|
2265
2333
|
if ("gte" in condition) return numeric >= condition.gte;
|
|
@@ -2278,14 +2346,14 @@ function interpolateEndpoint(endpoint, row, parent) {
|
|
|
2278
2346
|
|
|
2279
2347
|
// src/components/internal/DetailRecordContext.tsx
|
|
2280
2348
|
import { createContext as createContext4, useContext as useContext4 } from "react";
|
|
2281
|
-
import { jsx as
|
|
2349
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
2282
2350
|
var DetailRecordContext = createContext4(null);
|
|
2283
2351
|
function DetailRecordProvider({
|
|
2284
2352
|
record,
|
|
2285
2353
|
setRecord,
|
|
2286
2354
|
children
|
|
2287
2355
|
}) {
|
|
2288
|
-
return /* @__PURE__ */
|
|
2356
|
+
return /* @__PURE__ */ jsx13(DetailRecordContext.Provider, { value: { record, setRecord }, children });
|
|
2289
2357
|
}
|
|
2290
2358
|
function useDetailRecord() {
|
|
2291
2359
|
return useContext4(DetailRecordContext);
|
|
@@ -2296,7 +2364,7 @@ function mergeDetailRecord(current, saved, changes = {}) {
|
|
|
2296
2364
|
}
|
|
2297
2365
|
|
|
2298
2366
|
// src/components/internal/CoreRowAction.tsx
|
|
2299
|
-
import { jsx as
|
|
2367
|
+
import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2300
2368
|
var ACTION_TONES = {
|
|
2301
2369
|
success: { bg: "#DCFCE7", color: "#166534", border: "#BBF7D0", hover: "#D1FAE5" },
|
|
2302
2370
|
danger: { bg: "#FEE2E2", color: "#991B1B", border: "#FECACA", hover: "#FDE2E2" },
|
|
@@ -2306,8 +2374,8 @@ var ACTION_TONES = {
|
|
|
2306
2374
|
};
|
|
2307
2375
|
function ActionErrorMessage({ error }) {
|
|
2308
2376
|
const description = describeActionError(error);
|
|
2309
|
-
return /* @__PURE__ */
|
|
2310
|
-
|
|
2377
|
+
return /* @__PURE__ */ jsxs9(
|
|
2378
|
+
Box7,
|
|
2311
2379
|
{
|
|
2312
2380
|
role: "alert",
|
|
2313
2381
|
mt: "5px",
|
|
@@ -2318,15 +2386,15 @@ function ActionErrorMessage({ error }) {
|
|
|
2318
2386
|
borderColor: "#FECDCA",
|
|
2319
2387
|
borderRadius: "6px",
|
|
2320
2388
|
children: [
|
|
2321
|
-
/* @__PURE__ */
|
|
2322
|
-
description.context ? /* @__PURE__ */
|
|
2389
|
+
/* @__PURE__ */ jsx14(Text8, { color: "#B42318", fontSize: "10px", fontWeight: "600", lineHeight: "1.35", children: description.message }),
|
|
2390
|
+
description.context ? /* @__PURE__ */ jsx14(Text8, { mt: "2px", color: "#7A271A", fontSize: "9px", lineHeight: "1.35", children: description.context }) : null
|
|
2323
2391
|
]
|
|
2324
2392
|
}
|
|
2325
2393
|
);
|
|
2326
2394
|
}
|
|
2327
|
-
function unwrap2(
|
|
2328
|
-
if (!
|
|
2329
|
-
const record =
|
|
2395
|
+
function unwrap2(value2) {
|
|
2396
|
+
if (!value2 || typeof value2 !== "object") return {};
|
|
2397
|
+
const record = value2;
|
|
2330
2398
|
const data = record.data;
|
|
2331
2399
|
if (data && typeof data === "object") return data;
|
|
2332
2400
|
return record;
|
|
@@ -2420,8 +2488,8 @@ function CoreRowAction({ action, row, parent, onOpenDetail, onRefresh, onUpdate
|
|
|
2420
2488
|
setLoading(false);
|
|
2421
2489
|
}
|
|
2422
2490
|
};
|
|
2423
|
-
return /* @__PURE__ */
|
|
2424
|
-
/* @__PURE__ */
|
|
2491
|
+
return /* @__PURE__ */ jsxs9("span", { style: { display: "inline-flex", flexDirection: "column" }, children: [
|
|
2492
|
+
/* @__PURE__ */ jsxs9(
|
|
2425
2493
|
Button5,
|
|
2426
2494
|
{
|
|
2427
2495
|
type: "button",
|
|
@@ -2444,13 +2512,13 @@ function CoreRowAction({ action, row, parent, onOpenDetail, onRefresh, onUpdate
|
|
|
2444
2512
|
_hover: tone ? { bg: tone.hover, borderColor: tone.border } : void 0,
|
|
2445
2513
|
_disabled: tone ? { opacity: isSelected ? 1 : 0.55, cursor: "not-allowed" } : void 0,
|
|
2446
2514
|
children: [
|
|
2447
|
-
isWorkStatus ? /* @__PURE__ */
|
|
2515
|
+
isWorkStatus ? /* @__PURE__ */ jsx14("span", { "aria-hidden": "true", style: { width: 8, height: 8, display: "inline-block", marginRight: 7, borderRadius: "999px", background: tone?.color ?? "#64748B", boxShadow: isSelected ? "0 0 0 2px rgba(255,255,255,.9)" : "none" } }) : null,
|
|
2448
2516
|
action.label
|
|
2449
2517
|
]
|
|
2450
2518
|
}
|
|
2451
2519
|
),
|
|
2452
|
-
error ? /* @__PURE__ */
|
|
2453
|
-
formOpen && pipelineAction.type === "formAction" ? /* @__PURE__ */
|
|
2520
|
+
error ? /* @__PURE__ */ jsx14(ActionErrorMessage, { error }) : null,
|
|
2521
|
+
formOpen && pipelineAction.type === "formAction" ? /* @__PURE__ */ jsx14(
|
|
2454
2522
|
DynamicForm,
|
|
2455
2523
|
{
|
|
2456
2524
|
title: pipelineAction.title ?? pipelineAction.label,
|
|
@@ -2485,7 +2553,7 @@ function CoreRowAction({ action, row, parent, onOpenDetail, onRefresh, onUpdate
|
|
|
2485
2553
|
}
|
|
2486
2554
|
|
|
2487
2555
|
// src/components/internal/CoreRelatedGrid.tsx
|
|
2488
|
-
import { Fragment as Fragment2, jsx as
|
|
2556
|
+
import { Fragment as Fragment2, jsx as jsx15, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2489
2557
|
function parentValueAt(parent, path) {
|
|
2490
2558
|
return path.split(".").reduce((current, part) => {
|
|
2491
2559
|
if (!current || typeof current !== "object") return void 0;
|
|
@@ -2566,38 +2634,38 @@ function CoreRelatedGrid({
|
|
|
2566
2634
|
mutationFn: (id) => resource.delete(id),
|
|
2567
2635
|
onSuccess: invalidate
|
|
2568
2636
|
});
|
|
2569
|
-
if (!relation) return /* @__PURE__ */
|
|
2570
|
-
if (query.isLoading || schemaQuery.isLoading) return /* @__PURE__ */
|
|
2637
|
+
if (!relation) return /* @__PURE__ */ jsx15(Text9, { color: "#B42318", children: "Rela\xE7\xE3o n\xE3o encontrada." });
|
|
2638
|
+
if (query.isLoading || schemaQuery.isLoading) return /* @__PURE__ */ jsx15(Text9, { color: "#667085", children: "Carregando..." });
|
|
2571
2639
|
const rows = query.data?.results ?? [];
|
|
2572
|
-
const setDraft = (id, field,
|
|
2640
|
+
const setDraft = (id, field, value2) => setDrafts((current) => ({
|
|
2573
2641
|
...current,
|
|
2574
|
-
[id]: { ...current[id] ?? {}, [field]:
|
|
2642
|
+
[id]: { ...current[id] ?? {}, [field]: value2 }
|
|
2575
2643
|
}));
|
|
2576
|
-
return /* @__PURE__ */
|
|
2577
|
-
canCreate ? /* @__PURE__ */
|
|
2644
|
+
return /* @__PURE__ */ jsxs10(Box8, { children: [
|
|
2645
|
+
canCreate ? /* @__PURE__ */ jsx15(Flex5, { justify: "flex-end", mb: "10px", children: /* @__PURE__ */ jsx15(Button6, { size: "sm", colorPalette: "brand", onClick: () => {
|
|
2578
2646
|
setCreateError(null);
|
|
2579
2647
|
setCreating(true);
|
|
2580
2648
|
}, children: tab.create?.label ?? "Novo registro" }) }) : null,
|
|
2581
|
-
/* @__PURE__ */
|
|
2582
|
-
/* @__PURE__ */
|
|
2583
|
-
columns.map((column) => /* @__PURE__ */
|
|
2584
|
-
hasActions ? /* @__PURE__ */
|
|
2649
|
+
/* @__PURE__ */ jsx15(Box8, { overflowX: "auto", borderWidth: "1px", borderColor: "#E5E9ED", borderRadius: "10px", children: /* @__PURE__ */ jsxs10(Table2.Root, { size: "sm", minW: "760px", children: [
|
|
2650
|
+
/* @__PURE__ */ jsx15(Table2.Header, { children: /* @__PURE__ */ jsxs10(Table2.Row, { bg: "#F4F7F9", children: [
|
|
2651
|
+
columns.map((column) => /* @__PURE__ */ jsx15(Table2.ColumnHeader, { fontSize: "10px", children: column.label ?? column.field }, column.field)),
|
|
2652
|
+
hasActions ? /* @__PURE__ */ jsx15(Table2.ColumnHeader, { children: "A\xE7\xF5es" }) : null
|
|
2585
2653
|
] }) }),
|
|
2586
|
-
/* @__PURE__ */
|
|
2654
|
+
/* @__PURE__ */ jsxs10(Table2.Body, { children: [
|
|
2587
2655
|
rows.map((row, index) => {
|
|
2588
2656
|
const id = String(row._id ?? row.id ?? index);
|
|
2589
2657
|
const draft = drafts[id] ?? {};
|
|
2590
2658
|
const dirty = Object.keys(draft).length > 0;
|
|
2591
|
-
return /* @__PURE__ */
|
|
2659
|
+
return /* @__PURE__ */ jsxs10(Table2.Row, { bg: dirty ? "#FFFBEB" : index % 2 ? "#FBFCFD" : "white", children: [
|
|
2592
2660
|
columns.map((column) => {
|
|
2593
|
-
const
|
|
2661
|
+
const value2 = column.field in draft ? draft[column.field] : row[column.field];
|
|
2594
2662
|
const meta = schema?.fields.find((field) => field.name === column.field);
|
|
2595
2663
|
const canEdit = editable && column.readonly !== true && (column.editable === true || !column.readonly);
|
|
2596
|
-
return /* @__PURE__ */
|
|
2664
|
+
return /* @__PURE__ */ jsx15(Table2.Cell, { fontSize: "11px", children: canEdit ? /* @__PURE__ */ jsx15(CoreInlineEditableCell, { column, meta, value: value2, onChange: (next) => setDraft(id, column.field, next) }) : column.display === "badgeExists" ? /* @__PURE__ */ jsx15(Badge3, { colorPalette: value2 ? "green" : "gray", children: value2 ? "Sim" : "N\xE3o" }) : formatCell(value2, column.kind) }, column.field);
|
|
2597
2665
|
}),
|
|
2598
|
-
hasActions ? /* @__PURE__ */
|
|
2599
|
-
dirty ? /* @__PURE__ */
|
|
2600
|
-
/* @__PURE__ */
|
|
2666
|
+
hasActions ? /* @__PURE__ */ jsx15(Table2.Cell, { children: /* @__PURE__ */ jsxs10(Flex5, { gap: "5px", align: "center", wrap: "wrap", children: [
|
|
2667
|
+
dirty ? /* @__PURE__ */ jsxs10(Fragment2, { children: [
|
|
2668
|
+
/* @__PURE__ */ jsx15(
|
|
2601
2669
|
Button6,
|
|
2602
2670
|
{
|
|
2603
2671
|
size: "xs",
|
|
@@ -2616,14 +2684,14 @@ function CoreRelatedGrid({
|
|
|
2616
2684
|
children: "Salvar"
|
|
2617
2685
|
}
|
|
2618
2686
|
),
|
|
2619
|
-
/* @__PURE__ */
|
|
2687
|
+
/* @__PURE__ */ jsx15(Button6, { size: "xs", variant: "outline", onClick: () => setDrafts((current) => {
|
|
2620
2688
|
const next = { ...current };
|
|
2621
2689
|
delete next[id];
|
|
2622
2690
|
return next;
|
|
2623
2691
|
}), children: "Cancelar" })
|
|
2624
2692
|
] }) : null,
|
|
2625
|
-
tab.rowActions?.map((action) => /* @__PURE__ */
|
|
2626
|
-
canDelete ? /* @__PURE__ */
|
|
2693
|
+
tab.rowActions?.map((action) => /* @__PURE__ */ jsx15(CoreRowAction, { action, row, parent, onRefresh }, action.id ?? action.label)),
|
|
2694
|
+
canDelete ? /* @__PURE__ */ jsx15(
|
|
2627
2695
|
Button6,
|
|
2628
2696
|
{
|
|
2629
2697
|
size: "xs",
|
|
@@ -2636,14 +2704,14 @@ function CoreRelatedGrid({
|
|
|
2636
2704
|
children: "Excluir"
|
|
2637
2705
|
}
|
|
2638
2706
|
) : null,
|
|
2639
|
-
errors[id] ? /* @__PURE__ */
|
|
2707
|
+
errors[id] ? /* @__PURE__ */ jsx15(Text9, { color: "#B42318", fontSize: "9px", children: "Erro ao salvar." }) : null
|
|
2640
2708
|
] }) }) : null
|
|
2641
2709
|
] }, id);
|
|
2642
2710
|
}),
|
|
2643
|
-
rows.length === 0 ? /* @__PURE__ */
|
|
2711
|
+
rows.length === 0 ? /* @__PURE__ */ jsx15(Table2.Row, { children: /* @__PURE__ */ jsx15(Table2.Cell, { colSpan: columns.length + (hasActions ? 1 : 0), children: /* @__PURE__ */ jsx15(Text9, { p: "8", textAlign: "center", color: "#98A2B3", children: "Nenhum registro relacionado." }) }) }) : null
|
|
2644
2712
|
] })
|
|
2645
2713
|
] }) }),
|
|
2646
|
-
creating ? /* @__PURE__ */
|
|
2714
|
+
creating ? /* @__PURE__ */ jsx15(
|
|
2647
2715
|
DynamicForm,
|
|
2648
2716
|
{
|
|
2649
2717
|
title: tab.create?.label ?? `Novo ${schema?.singular ?? relation.model}`,
|
|
@@ -2663,24 +2731,24 @@ function CoreRelatedGrid({
|
|
|
2663
2731
|
}
|
|
2664
2732
|
|
|
2665
2733
|
// src/components/internal/CoreTabbedDetail.tsx
|
|
2666
|
-
import { jsx as
|
|
2667
|
-
function toValue2(
|
|
2668
|
-
if (
|
|
2734
|
+
import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
2735
|
+
function toValue2(value2, kind) {
|
|
2736
|
+
if (value2 == null) return "";
|
|
2669
2737
|
if (kind === "date") {
|
|
2670
2738
|
try {
|
|
2671
|
-
return new Date(
|
|
2739
|
+
return new Date(value2).toISOString().slice(0, 10);
|
|
2672
2740
|
} catch {
|
|
2673
2741
|
return "";
|
|
2674
2742
|
}
|
|
2675
2743
|
}
|
|
2676
|
-
if (typeof
|
|
2677
|
-
const record =
|
|
2744
|
+
if (typeof value2 === "object") {
|
|
2745
|
+
const record = value2;
|
|
2678
2746
|
return String(record._id ?? record.id ?? "");
|
|
2679
2747
|
}
|
|
2680
|
-
return String(
|
|
2748
|
+
return String(value2);
|
|
2681
2749
|
}
|
|
2682
|
-
function initialFieldValue2(field,
|
|
2683
|
-
return normalizeMaskedValue(toValue2(
|
|
2750
|
+
function initialFieldValue2(field, value2) {
|
|
2751
|
+
return normalizeMaskedValue(toValue2(value2, field.kind), resolveInputMask(field));
|
|
2684
2752
|
}
|
|
2685
2753
|
function initialReactiveValues2(fields, parent) {
|
|
2686
2754
|
const initial = Object.fromEntries(fields.map((field) => [field.field, initialFieldValue2(field, parent[field.field])]));
|
|
@@ -2689,34 +2757,20 @@ function initialReactiveValues2(fields, parent) {
|
|
|
2689
2757
|
function isMultiline2(field) {
|
|
2690
2758
|
return /observa|descricao|mensagem|detalhe|necessidade/i.test(field.field);
|
|
2691
2759
|
}
|
|
2692
|
-
function messageOf2(error) {
|
|
2693
|
-
if (!error) return null;
|
|
2694
|
-
if (typeof error === "string") return error;
|
|
2695
|
-
if (error instanceof Error) return error.message;
|
|
2696
|
-
if (typeof error === "object") {
|
|
2697
|
-
const record = error;
|
|
2698
|
-
if (typeof record.message === "string") return record.message;
|
|
2699
|
-
if (record.error && typeof record.error === "object") {
|
|
2700
|
-
const nested = record.error;
|
|
2701
|
-
if (typeof nested.message === "string") return nested.message;
|
|
2702
|
-
}
|
|
2703
|
-
}
|
|
2704
|
-
return "N\xE3o foi poss\xEDvel salvar o registro.";
|
|
2705
|
-
}
|
|
2706
2760
|
function fieldErrorsOf(error) {
|
|
2707
2761
|
if (!error || typeof error !== "object") return {};
|
|
2708
2762
|
const record = error;
|
|
2709
2763
|
const envelope = record.error && typeof record.error === "object" ? record.error : void 0;
|
|
2710
2764
|
const details = record.details ?? envelope?.details ?? envelope;
|
|
2711
2765
|
const result = {};
|
|
2712
|
-
const visit = (
|
|
2713
|
-
if (!
|
|
2714
|
-
if (Array.isArray(
|
|
2715
|
-
|
|
2766
|
+
const visit = (value2) => {
|
|
2767
|
+
if (!value2) return;
|
|
2768
|
+
if (Array.isArray(value2)) {
|
|
2769
|
+
value2.forEach(visit);
|
|
2716
2770
|
return;
|
|
2717
2771
|
}
|
|
2718
|
-
if (typeof
|
|
2719
|
-
const item =
|
|
2772
|
+
if (typeof value2 !== "object") return;
|
|
2773
|
+
const item = value2;
|
|
2720
2774
|
if (typeof item.field === "string" && typeof item.message === "string") {
|
|
2721
2775
|
result[item.field] = item.message;
|
|
2722
2776
|
}
|
|
@@ -2740,8 +2794,8 @@ function resolveReference2(field, values) {
|
|
|
2740
2794
|
const filters = { ...field.referenceFilters ?? {} };
|
|
2741
2795
|
const missing = [];
|
|
2742
2796
|
Object.entries(field.referenceFilterFrom ?? {}).forEach(([queryField, formField]) => {
|
|
2743
|
-
const
|
|
2744
|
-
if (
|
|
2797
|
+
const value2 = values[formField];
|
|
2798
|
+
if (value2) filters[queryField] = value2;
|
|
2745
2799
|
else missing.push(formField);
|
|
2746
2800
|
});
|
|
2747
2801
|
return { filters, disabled: missing.length > 0 };
|
|
@@ -2749,18 +2803,18 @@ function resolveReference2(field, values) {
|
|
|
2749
2803
|
function FieldLabel({ field, htmlFor }) {
|
|
2750
2804
|
const label = fieldLabel({ name: field.field, label: field.label });
|
|
2751
2805
|
const readonly = Boolean(field.readonly || field.computed);
|
|
2752
|
-
return /* @__PURE__ */
|
|
2806
|
+
return /* @__PURE__ */ jsx16("label", { htmlFor, children: /* @__PURE__ */ jsxs11(Text10, { as: "span", display: "block", mb: "5px", color: "#475467", fontSize: "11px", fontWeight: "600", children: [
|
|
2753
2807
|
label,
|
|
2754
|
-
field.required && !readonly ? /* @__PURE__ */
|
|
2755
|
-
readonly ? /* @__PURE__ */
|
|
2808
|
+
field.required && !readonly ? /* @__PURE__ */ jsx16(Text10, { as: "span", color: "#DC2626", children: " *" }) : null,
|
|
2809
|
+
readonly ? /* @__PURE__ */ jsx16(Text10, { as: "span", ml: "5px", color: "#98A2B3", fontSize: "9px", fontWeight: "500", children: "somente leitura" }) : null
|
|
2756
2810
|
] }) });
|
|
2757
2811
|
}
|
|
2758
2812
|
function ErrorText2({ id, message }) {
|
|
2759
|
-
return message ? /* @__PURE__ */
|
|
2813
|
+
return message ? /* @__PURE__ */ jsx16(Text10, { id, role: "alert", mt: "5px", color: "#DC2626", fontSize: "10px", fontWeight: "500", children: message }) : null;
|
|
2760
2814
|
}
|
|
2761
2815
|
function FieldControl({
|
|
2762
2816
|
field,
|
|
2763
|
-
value,
|
|
2817
|
+
value: value2,
|
|
2764
2818
|
values,
|
|
2765
2819
|
initialValue,
|
|
2766
2820
|
error,
|
|
@@ -2780,10 +2834,10 @@ function FieldControl({
|
|
|
2780
2834
|
if (field.widget === "checkbox") {
|
|
2781
2835
|
const checkedValue = String(field.checkedValue ?? true);
|
|
2782
2836
|
const uncheckedValue = String(field.uncheckedValue ?? false);
|
|
2783
|
-
const checked = (
|
|
2784
|
-
return /* @__PURE__ */
|
|
2785
|
-
/* @__PURE__ */
|
|
2786
|
-
|
|
2837
|
+
const checked = (value2 || uncheckedValue) === checkedValue;
|
|
2838
|
+
return /* @__PURE__ */ jsxs11(Box9, { children: [
|
|
2839
|
+
/* @__PURE__ */ jsxs11(
|
|
2840
|
+
Box9,
|
|
2787
2841
|
{
|
|
2788
2842
|
as: "label",
|
|
2789
2843
|
display: "flex",
|
|
@@ -2798,7 +2852,7 @@ function FieldControl({
|
|
|
2798
2852
|
borderRadius: "7px",
|
|
2799
2853
|
cursor: readonly ? "not-allowed" : "pointer",
|
|
2800
2854
|
children: [
|
|
2801
|
-
/* @__PURE__ */
|
|
2855
|
+
/* @__PURE__ */ jsx16(
|
|
2802
2856
|
"input",
|
|
2803
2857
|
{
|
|
2804
2858
|
id: inputId,
|
|
@@ -2811,18 +2865,18 @@ function FieldControl({
|
|
|
2811
2865
|
onChange: (event) => onChange(event.currentTarget.checked ? checkedValue : uncheckedValue)
|
|
2812
2866
|
}
|
|
2813
2867
|
),
|
|
2814
|
-
/* @__PURE__ */
|
|
2868
|
+
/* @__PURE__ */ jsx16(Text10, { as: "span", fontSize: "11px", fontWeight: "600", children: label })
|
|
2815
2869
|
]
|
|
2816
2870
|
}
|
|
2817
2871
|
),
|
|
2818
|
-
/* @__PURE__ */
|
|
2872
|
+
/* @__PURE__ */ jsx16(ErrorText2, { id: errorId, message: error })
|
|
2819
2873
|
] });
|
|
2820
2874
|
}
|
|
2821
2875
|
if (field.kind === "ref" && field.ref) {
|
|
2822
2876
|
const reference = resolveReference2(field, values);
|
|
2823
|
-
return /* @__PURE__ */
|
|
2824
|
-
/* @__PURE__ */
|
|
2825
|
-
/* @__PURE__ */
|
|
2877
|
+
return /* @__PURE__ */ jsxs11(Box9, { children: [
|
|
2878
|
+
/* @__PURE__ */ jsx16(FieldLabel, { field, htmlFor: inputId }),
|
|
2879
|
+
/* @__PURE__ */ jsx16(
|
|
2826
2880
|
ReferenceSelect,
|
|
2827
2881
|
{
|
|
2828
2882
|
field: field.field,
|
|
@@ -2830,7 +2884,7 @@ function FieldControl({
|
|
|
2830
2884
|
errorId,
|
|
2831
2885
|
label,
|
|
2832
2886
|
refModel: field.ref,
|
|
2833
|
-
value,
|
|
2887
|
+
value: value2,
|
|
2834
2888
|
initialValue,
|
|
2835
2889
|
required: field.required && !readonly,
|
|
2836
2890
|
invalid: !!error,
|
|
@@ -2845,20 +2899,20 @@ function FieldControl({
|
|
|
2845
2899
|
] });
|
|
2846
2900
|
}
|
|
2847
2901
|
const mask = resolveInputMask(field);
|
|
2848
|
-
const control = field.kind === "enum" && field.options?.length ? /* @__PURE__ */
|
|
2849
|
-
/* @__PURE__ */
|
|
2850
|
-
/* @__PURE__ */
|
|
2851
|
-
field.options.map((option) => /* @__PURE__ */
|
|
2902
|
+
const control = field.kind === "enum" && field.options?.length ? /* @__PURE__ */ jsxs11(NativeSelect4.Root, { size: "sm", disabled: readonly, children: [
|
|
2903
|
+
/* @__PURE__ */ jsxs11(NativeSelect4.Field, { id: inputId, value: value2, ...invalidProps, onChange: (event) => onChange(event.currentTarget.value), children: [
|
|
2904
|
+
/* @__PURE__ */ jsx16("option", { value: "", children: "\u2014 Selecione \u2014" }),
|
|
2905
|
+
field.options.map((option) => /* @__PURE__ */ jsx16("option", { value: option, children: option }, option))
|
|
2852
2906
|
] }),
|
|
2853
|
-
/* @__PURE__ */
|
|
2854
|
-
] }) : field.kind === "boolean" ? /* @__PURE__ */
|
|
2855
|
-
/* @__PURE__ */
|
|
2856
|
-
/* @__PURE__ */
|
|
2857
|
-
/* @__PURE__ */
|
|
2858
|
-
/* @__PURE__ */
|
|
2907
|
+
/* @__PURE__ */ jsx16(NativeSelect4.Indicator, {})
|
|
2908
|
+
] }) : field.kind === "boolean" ? /* @__PURE__ */ jsxs11(NativeSelect4.Root, { size: "sm", disabled: readonly, children: [
|
|
2909
|
+
/* @__PURE__ */ jsxs11(NativeSelect4.Field, { id: inputId, value: value2, ...invalidProps, onChange: (event) => onChange(event.currentTarget.value), children: [
|
|
2910
|
+
/* @__PURE__ */ jsx16("option", { value: "", children: "\u2014 Selecione \u2014" }),
|
|
2911
|
+
/* @__PURE__ */ jsx16("option", { value: "true", children: "Sim" }),
|
|
2912
|
+
/* @__PURE__ */ jsx16("option", { value: "false", children: "N\xE3o" })
|
|
2859
2913
|
] }),
|
|
2860
|
-
/* @__PURE__ */
|
|
2861
|
-
] }) : isMultiline2(field) ? /* @__PURE__ */
|
|
2914
|
+
/* @__PURE__ */ jsx16(NativeSelect4.Indicator, {})
|
|
2915
|
+
] }) : isMultiline2(field) ? /* @__PURE__ */ jsx16(Textarea3, { id: inputId, rows: 4, resize: "vertical", readOnly: readonly, value: value2, ...invalidProps, onChange: (event) => onChange(event.currentTarget.value) }) : /* @__PURE__ */ jsx16(
|
|
2862
2916
|
Input5,
|
|
2863
2917
|
{
|
|
2864
2918
|
id: inputId,
|
|
@@ -2868,15 +2922,15 @@ function FieldControl({
|
|
|
2868
2922
|
inputMode: inputModeForMask(mask),
|
|
2869
2923
|
maxLength: maxLengthForMask(mask),
|
|
2870
2924
|
readOnly: readonly,
|
|
2871
|
-
value: mask ? formatMaskedValue(
|
|
2925
|
+
value: mask ? formatMaskedValue(value2, mask) : value2,
|
|
2872
2926
|
...invalidProps,
|
|
2873
2927
|
onChange: (event) => onChange(parseMaskedInput(event.currentTarget.value, mask))
|
|
2874
2928
|
}
|
|
2875
2929
|
);
|
|
2876
|
-
return /* @__PURE__ */
|
|
2877
|
-
/* @__PURE__ */
|
|
2930
|
+
return /* @__PURE__ */ jsxs11(Box9, { children: [
|
|
2931
|
+
/* @__PURE__ */ jsx16(FieldLabel, { field, htmlFor: inputId }),
|
|
2878
2932
|
control,
|
|
2879
|
-
/* @__PURE__ */
|
|
2933
|
+
/* @__PURE__ */ jsx16(ErrorText2, { id: errorId, message: error })
|
|
2880
2934
|
] });
|
|
2881
2935
|
}
|
|
2882
2936
|
function GroupSection({
|
|
@@ -2889,10 +2943,10 @@ function GroupSection({
|
|
|
2889
2943
|
}) {
|
|
2890
2944
|
if (!fields.length) return null;
|
|
2891
2945
|
const columns = group.columns ?? 2;
|
|
2892
|
-
return /* @__PURE__ */
|
|
2893
|
-
/* @__PURE__ */
|
|
2894
|
-
group.description ? /* @__PURE__ */
|
|
2895
|
-
/* @__PURE__ */
|
|
2946
|
+
return /* @__PURE__ */ jsxs11(Box9, { p: { base: "12px", md: "14px" }, bg: "#FAFCFD", borderWidth: "1px", borderColor: "#E5E9ED", borderRadius: "9px", children: [
|
|
2947
|
+
/* @__PURE__ */ jsx16(Text10, { color: "#344054", fontSize: "12px", fontWeight: "700", children: group.label }),
|
|
2948
|
+
group.description ? /* @__PURE__ */ jsx16(Text10, { mt: "2px", mb: "12px", color: "#667085", fontSize: "10px", children: group.description }) : /* @__PURE__ */ jsx16(Box9, { h: "10px" }),
|
|
2949
|
+
/* @__PURE__ */ jsx16(SimpleGrid3, { columns: { base: 1, md: Math.min(columns, 2), xl: columns }, gapX: "16px", gapY: "14px", children: fields.map((field) => /* @__PURE__ */ jsx16(
|
|
2896
2950
|
FieldControl,
|
|
2897
2951
|
{
|
|
2898
2952
|
field,
|
|
@@ -2900,7 +2954,7 @@ function GroupSection({
|
|
|
2900
2954
|
values,
|
|
2901
2955
|
initialValue: initialValues[field.field],
|
|
2902
2956
|
error: errors[field.field],
|
|
2903
|
-
onChange: (
|
|
2957
|
+
onChange: (value2) => onChange(field.field, value2)
|
|
2904
2958
|
},
|
|
2905
2959
|
field.field
|
|
2906
2960
|
)) })
|
|
@@ -2953,15 +3007,15 @@ function InlineParentForm({
|
|
|
2953
3007
|
onDirtyChange?.(dirty);
|
|
2954
3008
|
}, [dirty, onDirtyChange]);
|
|
2955
3009
|
const fieldsByName = useMemo6(() => new Map(fields.map((field) => [field.field, field])), [rawFields]);
|
|
2956
|
-
const change = (fieldName,
|
|
3010
|
+
const change = (fieldName, value2) => {
|
|
2957
3011
|
const selected = fieldsByName.get(fieldName);
|
|
2958
3012
|
if (selected?.readonly || selected?.computed) return;
|
|
2959
3013
|
const dependentFields = fields.filter(
|
|
2960
3014
|
(candidate) => Object.values(candidate.referenceFilterFrom ?? {}).includes(fieldName)
|
|
2961
3015
|
);
|
|
2962
3016
|
setValues((current) => {
|
|
2963
|
-
const changed = current[fieldName] !==
|
|
2964
|
-
const next = { ...current, [fieldName]:
|
|
3017
|
+
const changed = current[fieldName] !== value2;
|
|
3018
|
+
const next = { ...current, [fieldName]: value2 };
|
|
2965
3019
|
if (changed) dependentFields.forEach((candidate) => {
|
|
2966
3020
|
next[candidate.field] = "";
|
|
2967
3021
|
});
|
|
@@ -2980,7 +3034,7 @@ function InlineParentForm({
|
|
|
2980
3034
|
const combinedErrors = { ...formulaErrors, ...fieldErrors };
|
|
2981
3035
|
const renderFields = () => {
|
|
2982
3036
|
if (groups?.length) {
|
|
2983
|
-
return /* @__PURE__ */
|
|
3037
|
+
return /* @__PURE__ */ jsx16(Stack3, { gap: "14px", children: groups.map((group) => /* @__PURE__ */ jsx16(
|
|
2984
3038
|
GroupSection,
|
|
2985
3039
|
{
|
|
2986
3040
|
group,
|
|
@@ -2993,7 +3047,7 @@ function InlineParentForm({
|
|
|
2993
3047
|
`${group.label}-${group.fields.join("-")}`
|
|
2994
3048
|
)) });
|
|
2995
3049
|
}
|
|
2996
|
-
return /* @__PURE__ */
|
|
3050
|
+
return /* @__PURE__ */ jsx16(SimpleGrid3, { columns: { base: 1, md: 2 }, gap: "14px", children: visibleFields.map((field) => /* @__PURE__ */ jsx16(
|
|
2997
3051
|
FieldControl,
|
|
2998
3052
|
{
|
|
2999
3053
|
field,
|
|
@@ -3001,12 +3055,12 @@ function InlineParentForm({
|
|
|
3001
3055
|
values,
|
|
3002
3056
|
initialValue: parent[field.field],
|
|
3003
3057
|
error: combinedErrors[field.field],
|
|
3004
|
-
onChange: (
|
|
3058
|
+
onChange: (value2) => change(field.field, value2)
|
|
3005
3059
|
},
|
|
3006
3060
|
field.field
|
|
3007
3061
|
)) });
|
|
3008
3062
|
};
|
|
3009
|
-
return /* @__PURE__ */
|
|
3063
|
+
return /* @__PURE__ */ jsx16(
|
|
3010
3064
|
"form",
|
|
3011
3065
|
{
|
|
3012
3066
|
id: formId,
|
|
@@ -3036,10 +3090,10 @@ function InlineParentForm({
|
|
|
3036
3090
|
setSaving(false);
|
|
3037
3091
|
}
|
|
3038
3092
|
},
|
|
3039
|
-
children: /* @__PURE__ */
|
|
3040
|
-
error ? /* @__PURE__ */
|
|
3093
|
+
children: /* @__PURE__ */ jsxs11(Stack3, { gap: "16px", children: [
|
|
3094
|
+
error ? /* @__PURE__ */ jsx16(CoreErrorAlert, { error }) : null,
|
|
3041
3095
|
renderFields(),
|
|
3042
|
-
!externalSubmit ? /* @__PURE__ */
|
|
3096
|
+
!externalSubmit ? /* @__PURE__ */ jsx16(Flex6, { justify: "flex-end", children: /* @__PURE__ */ jsx16(Button7, { type: "submit", colorPalette: "brand", loading: saving, children: "Salvar dados principais" }) }) : null
|
|
3043
3097
|
] })
|
|
3044
3098
|
}
|
|
3045
3099
|
);
|
|
@@ -3065,10 +3119,10 @@ function CoreTabbedDetail({
|
|
|
3065
3119
|
const draftFields = useMemo6(() => fieldsForFormTabs(formFields, tabs), [formFields, tabs]);
|
|
3066
3120
|
const formParent = useMemo6(() => parent ?? {}, [parent]);
|
|
3067
3121
|
const hasFormTab = draftFields.length > 0;
|
|
3068
|
-
return /* @__PURE__ */
|
|
3069
|
-
/* @__PURE__ */
|
|
3122
|
+
return /* @__PURE__ */ jsxs11(Stack3, { gap: 4, children: [
|
|
3123
|
+
/* @__PURE__ */ jsx16(Flex6, { gap: 2, borderBottomWidth: "1px", borderColor: "#E5E9ED", overflowX: "auto", children: tabs.map((tab) => {
|
|
3070
3124
|
const disabled = !parent?._id && (tab.type === "relatedGrid" || tab.type === "readonlyGrid" || tab.type === "summary");
|
|
3071
|
-
return /* @__PURE__ */
|
|
3125
|
+
return /* @__PURE__ */ jsx16(
|
|
3072
3126
|
Button7,
|
|
3073
3127
|
{
|
|
3074
3128
|
type: "button",
|
|
@@ -3081,8 +3135,8 @@ function CoreTabbedDetail({
|
|
|
3081
3135
|
tab.id
|
|
3082
3136
|
);
|
|
3083
3137
|
}) }),
|
|
3084
|
-
/* @__PURE__ */
|
|
3085
|
-
hasFormTab ? /* @__PURE__ */
|
|
3138
|
+
/* @__PURE__ */ jsxs11(Box9, { children: [
|
|
3139
|
+
hasFormTab ? /* @__PURE__ */ jsx16(Box9, { display: activeForm ? "block" : "none", children: /* @__PURE__ */ jsx16(
|
|
3086
3140
|
InlineParentForm,
|
|
3087
3141
|
{
|
|
3088
3142
|
fields: draftFields,
|
|
@@ -3097,7 +3151,7 @@ function CoreTabbedDetail({
|
|
|
3097
3151
|
externalSubmit
|
|
3098
3152
|
}
|
|
3099
3153
|
) }) : null,
|
|
3100
|
-
!active || active.type === "form" ? null : active.type === "summary" && parent ? /* @__PURE__ */
|
|
3154
|
+
!active || active.type === "form" ? null : active.type === "summary" && parent ? /* @__PURE__ */ jsx16(CoreSummaryCards, { cards: active.cards, parent, relations }) : (active.type === "relatedGrid" || active.type === "readonlyGrid") && parent ? /* @__PURE__ */ jsx16(
|
|
3101
3155
|
CoreRelatedGrid,
|
|
3102
3156
|
{
|
|
3103
3157
|
tab: active,
|
|
@@ -3106,16 +3160,16 @@ function CoreTabbedDetail({
|
|
|
3106
3160
|
refreshToken: refreshTokens[active.id],
|
|
3107
3161
|
onRefresh
|
|
3108
3162
|
}
|
|
3109
|
-
) : active.type === "customComponent" ? /* @__PURE__ */
|
|
3163
|
+
) : active.type === "customComponent" ? /* @__PURE__ */ jsxs11(Text10, { color: "#667085", children: [
|
|
3110
3164
|
"Componente customizado: ",
|
|
3111
3165
|
active.component
|
|
3112
|
-
] }) : /* @__PURE__ */
|
|
3166
|
+
] }) : /* @__PURE__ */ jsx16(Text10, { color: "#667085", children: "Salve o registro principal para liberar esta aba." })
|
|
3113
3167
|
] })
|
|
3114
3168
|
] });
|
|
3115
3169
|
}
|
|
3116
3170
|
|
|
3117
3171
|
// src/components/internal/CoreDetailModal.tsx
|
|
3118
|
-
import { jsx as
|
|
3172
|
+
import { jsx as jsx17, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
3119
3173
|
function CoreDetailModal({ model, title, config, formFields, recordId, initialRecord, initialTab, relations, topActions, bottomActions, onClose, onSaved }) {
|
|
3120
3174
|
const schemaQuery = useModelSchema(model);
|
|
3121
3175
|
const schema = schemaQuery.data;
|
|
@@ -3175,19 +3229,19 @@ function CoreDetailModal({ model, title, config, formFields, recordId, initialRe
|
|
|
3175
3229
|
setConfirmingClose(false);
|
|
3176
3230
|
form.requestSubmit();
|
|
3177
3231
|
};
|
|
3178
|
-
return /* @__PURE__ */
|
|
3179
|
-
/* @__PURE__ */
|
|
3180
|
-
/* @__PURE__ */
|
|
3181
|
-
/* @__PURE__ */
|
|
3182
|
-
/* @__PURE__ */
|
|
3183
|
-
/* @__PURE__ */
|
|
3232
|
+
return /* @__PURE__ */ jsx17(DetailRecordProvider, { record: parent, setRecord: setParent, children: /* @__PURE__ */ jsxs12(Flex7, { position: "fixed", inset: 0, zIndex: 1e3, align: "center", justify: "center", p: 4, bg: "rgba(15,23,42,.48)", children: [
|
|
3233
|
+
/* @__PURE__ */ jsxs12(Box10, { role: "dialog", "aria-modal": "true", display: "flex", flexDirection: "column", w: `min(${width}, 98vw)`, h: "94vh", maxH: "94vh", overflow: "hidden", bg: "white", borderRadius: "14px", boxShadow: "0 24px 70px rgba(15,23,42,.24)", children: [
|
|
3234
|
+
/* @__PURE__ */ jsxs12(Flex7, { minH: "72px", px: "20px", py: "10px", align: "center", justify: "space-between", gap: 4, borderBottomWidth: "1px", borderColor: "#E5E9ED", children: [
|
|
3235
|
+
/* @__PURE__ */ jsxs12(Box10, { minW: "160px", children: [
|
|
3236
|
+
/* @__PURE__ */ jsx17(Text11, { color: "#0474AF", fontSize: "10px", fontWeight: "700", textTransform: "uppercase", children: "Detalhe" }),
|
|
3237
|
+
/* @__PURE__ */ jsx17(Heading3, { size: "md", children: recordId ? displayTitle : `Novo ${title}` })
|
|
3184
3238
|
] }),
|
|
3185
|
-
/* @__PURE__ */
|
|
3239
|
+
/* @__PURE__ */ jsxs12(Flex7, { flex: "1", align: "center", justify: "flex-end", gap: "8px", wrap: "wrap", children: [
|
|
3186
3240
|
recordId ? topActions : null,
|
|
3187
|
-
/* @__PURE__ */
|
|
3241
|
+
/* @__PURE__ */ jsx17(IconButton, { "aria-label": "Fechar", title: "Fechar", size: "sm", minW: "32px", h: "32px", borderRadius: "full", variant: "ghost", color: "#475569", fontSize: "21px", fontWeight: "400", lineHeight: "1", onClick: requestClose, _hover: { bg: "#F1F5F9", color: "#0F172A" }, children: "\xD7" })
|
|
3188
3242
|
] })
|
|
3189
3243
|
] }),
|
|
3190
|
-
/* @__PURE__ */
|
|
3244
|
+
/* @__PURE__ */ jsx17(Box10, { flex: "1", minH: 0, p: "20px", overflowY: "auto", children: schemaQuery.isLoading || parentQuery.isLoading ? /* @__PURE__ */ jsx17(Text11, { children: "Carregando..." }) : /* @__PURE__ */ jsx17(
|
|
3191
3245
|
CoreTabbedDetail,
|
|
3192
3246
|
{
|
|
3193
3247
|
tabs: config.tabs,
|
|
@@ -3217,32 +3271,32 @@ function CoreDetailModal({ model, title, config, formFields, recordId, initialRe
|
|
|
3217
3271
|
}
|
|
3218
3272
|
}
|
|
3219
3273
|
) }),
|
|
3220
|
-
/* @__PURE__ */
|
|
3221
|
-
/* @__PURE__ */
|
|
3222
|
-
/* @__PURE__ */
|
|
3274
|
+
/* @__PURE__ */ jsxs12(Flex7, { flex: "0 0 auto", minH: "64px", px: "20px", py: "10px", align: "center", justify: "space-between", gap: "12px", bg: "white", borderTopWidth: "1px", borderColor: "#E5E9ED", boxShadow: "0 -8px 24px rgba(15,23,42,.06)", children: [
|
|
3275
|
+
/* @__PURE__ */ jsx17(Box10, { children: recordId ? bottomActions : null }),
|
|
3276
|
+
/* @__PURE__ */ jsx17(Button8, { type: "submit", form: formId, colorPalette: "brand", disabled: !hasFormTab || !activeIsForm && !dirty || schemaQuery.isLoading || parentQuery.isLoading, children: "Salvar" })
|
|
3223
3277
|
] })
|
|
3224
3278
|
] }),
|
|
3225
|
-
confirmingClose ? /* @__PURE__ */
|
|
3226
|
-
/* @__PURE__ */
|
|
3227
|
-
/* @__PURE__ */
|
|
3228
|
-
/* @__PURE__ */
|
|
3229
|
-
/* @__PURE__ */
|
|
3279
|
+
confirmingClose ? /* @__PURE__ */ jsx17(Flex7, { position: "fixed", inset: 0, zIndex: 1100, align: "center", justify: "center", p: 4, bg: "rgba(15,23,42,.58)", children: /* @__PURE__ */ jsxs12(Box10, { role: "alertdialog", "aria-modal": "true", "aria-labelledby": "oon-unsaved-title", w: "min(520px, 94vw)", p: "22px", bg: "white", borderRadius: "12px", boxShadow: "0 24px 70px rgba(15,23,42,.28)", children: [
|
|
3280
|
+
/* @__PURE__ */ jsx17(Heading3, { id: "oon-unsaved-title", size: "md", children: "Altera\xE7\xF5es n\xE3o salvas" }),
|
|
3281
|
+
/* @__PURE__ */ jsx17(Text11, { mt: "8px", color: "#667085", fontSize: "13px", children: "As informa\xE7\xF5es preenchidas ainda n\xE3o foram salvas. Voc\xEA pode continuar editando, sair sem salvar ou salvar antes de fechar." }),
|
|
3282
|
+
/* @__PURE__ */ jsxs12(Flex7, { mt: "22px", justify: "flex-end", gap: "10px", wrap: "wrap", children: [
|
|
3283
|
+
/* @__PURE__ */ jsx17(Button8, { variant: "ghost", onClick: () => {
|
|
3230
3284
|
closeAfterSaveRef.current = false;
|
|
3231
3285
|
setConfirmingClose(false);
|
|
3232
3286
|
}, children: "Continuar editando" }),
|
|
3233
|
-
/* @__PURE__ */
|
|
3287
|
+
/* @__PURE__ */ jsx17(Button8, { variant: "outline", colorPalette: "red", onClick: () => {
|
|
3234
3288
|
closeAfterSaveRef.current = false;
|
|
3235
3289
|
setConfirmingClose(false);
|
|
3236
3290
|
onClose();
|
|
3237
3291
|
}, children: "Sair sem salvar" }),
|
|
3238
|
-
/* @__PURE__ */
|
|
3292
|
+
/* @__PURE__ */ jsx17(Button8, { colorPalette: "brand", onClick: saveAndClose, children: "Salvar e sair" })
|
|
3239
3293
|
] })
|
|
3240
3294
|
] }) }) : null
|
|
3241
3295
|
] }) });
|
|
3242
3296
|
}
|
|
3243
3297
|
|
|
3244
3298
|
// src/components/CoreCollection.tsx
|
|
3245
|
-
import { jsx as
|
|
3299
|
+
import { jsx as jsx18, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
3246
3300
|
function mergeFormFields(metadataFields, overrides) {
|
|
3247
3301
|
if (!overrides?.length) return metadataFields;
|
|
3248
3302
|
const byField = new Map(overrides.map((field) => [field.field, field]));
|
|
@@ -3284,16 +3338,16 @@ function CoreCollection({ model, label, section = "Cole\xE7\xE3o", mode = "dynam
|
|
|
3284
3338
|
mutationFn: (row) => resource.delete(row._id),
|
|
3285
3339
|
onSuccess: invalidate
|
|
3286
3340
|
});
|
|
3287
|
-
if (needsSchema && schemaQuery.isLoading) return /* @__PURE__ */
|
|
3288
|
-
if (needsSchema && schemaQuery.isError) return /* @__PURE__ */
|
|
3341
|
+
if (needsSchema && schemaQuery.isLoading) return /* @__PURE__ */ jsx18(LoadingScreen, {});
|
|
3342
|
+
if (needsSchema && schemaQuery.isError) return /* @__PURE__ */ jsx18(ErrorState, { error: schemaQuery.error });
|
|
3289
3343
|
const title = label ?? schema?.name ?? model;
|
|
3290
|
-
return /* @__PURE__ */
|
|
3291
|
-
/* @__PURE__ */
|
|
3292
|
-
/* @__PURE__ */
|
|
3293
|
-
/* @__PURE__ */
|
|
3294
|
-
/* @__PURE__ */
|
|
3344
|
+
return /* @__PURE__ */ jsxs13(Stack4, { gap: 5, children: [
|
|
3345
|
+
/* @__PURE__ */ jsxs13(Box11, { children: [
|
|
3346
|
+
/* @__PURE__ */ jsx18(Text12, { fontSize: "11px", fontWeight: "700", color: "brand.500", textTransform: "uppercase", letterSpacing: "0.08em", mb: 1, children: section }),
|
|
3347
|
+
/* @__PURE__ */ jsx18(Heading4, { size: "lg", color: "#24323A", letterSpacing: "-0.02em", children: title }),
|
|
3348
|
+
/* @__PURE__ */ jsx18(Text12, { mt: 1, fontSize: "13px", color: "gray.500", children: "Consulte, filtre e mantenha os registros desta opera\xE7\xE3o." })
|
|
3295
3349
|
] }),
|
|
3296
|
-
/* @__PURE__ */
|
|
3350
|
+
/* @__PURE__ */ jsx18(
|
|
3297
3351
|
DataGrid,
|
|
3298
3352
|
{
|
|
3299
3353
|
resource,
|
|
@@ -3314,7 +3368,7 @@ function CoreCollection({ model, label, section = "Cole\xE7\xE3o", mode = "dynam
|
|
|
3314
3368
|
onDelete: (row) => {
|
|
3315
3369
|
if (window.confirm("Excluir este registro?")) deleteMutation.mutate(row);
|
|
3316
3370
|
},
|
|
3317
|
-
renderRowActions: list?.rowActions?.length ? (row) => list.rowActions?.map((action) => /* @__PURE__ */
|
|
3371
|
+
renderRowActions: list?.rowActions?.length ? (row) => list.rowActions?.map((action) => /* @__PURE__ */ jsx18(
|
|
3318
3372
|
CoreRowAction,
|
|
3319
3373
|
{
|
|
3320
3374
|
action,
|
|
@@ -3326,7 +3380,7 @@ function CoreCollection({ model, label, section = "Cole\xE7\xE3o", mode = "dynam
|
|
|
3326
3380
|
)) : void 0
|
|
3327
3381
|
}
|
|
3328
3382
|
),
|
|
3329
|
-
formState.open ? /* @__PURE__ */
|
|
3383
|
+
formState.open ? /* @__PURE__ */ jsx18(
|
|
3330
3384
|
DynamicForm,
|
|
3331
3385
|
{
|
|
3332
3386
|
title: formState.row ? `Editar ${title}` : `Novo ${title}`,
|
|
@@ -3347,7 +3401,7 @@ function CoreCollection({ model, label, section = "Cole\xE7\xE3o", mode = "dynam
|
|
|
3347
3401
|
}
|
|
3348
3402
|
) : null,
|
|
3349
3403
|
importExport ? null : null,
|
|
3350
|
-
detailState.open && detailModal?.enabled ? /* @__PURE__ */
|
|
3404
|
+
detailState.open && detailModal?.enabled ? /* @__PURE__ */ jsx18(
|
|
3351
3405
|
CoreDetailModal,
|
|
3352
3406
|
{
|
|
3353
3407
|
model,
|
|
@@ -3366,9 +3420,9 @@ function CoreCollection({ model, label, section = "Cole\xE7\xE3o", mode = "dynam
|
|
|
3366
3420
|
}
|
|
3367
3421
|
|
|
3368
3422
|
// src/components/CoreDocument.tsx
|
|
3369
|
-
import { jsx as
|
|
3423
|
+
import { jsx as jsx19 } from "react/jsx-runtime";
|
|
3370
3424
|
function CoreDocument({ model, label, endpoint, columns, form }) {
|
|
3371
|
-
return /* @__PURE__ */
|
|
3425
|
+
return /* @__PURE__ */ jsx19(
|
|
3372
3426
|
CoreCollection,
|
|
3373
3427
|
{
|
|
3374
3428
|
model,
|
|
@@ -3383,7 +3437,7 @@ function CoreDocument({ model, label, endpoint, columns, form }) {
|
|
|
3383
3437
|
|
|
3384
3438
|
// src/components/CorePipeline.tsx
|
|
3385
3439
|
import { useEffect as useEffect7, useRef as useRef3, useState as useState11 } from "react";
|
|
3386
|
-
import { Badge as Badge4, Box as
|
|
3440
|
+
import { Badge as Badge4, Box as Box12, Button as Button9, Flex as Flex8, Heading as Heading5, Input as Input6, NativeSelect as NativeSelect5, Stack as Stack5, Text as Text13 } from "@chakra-ui/react";
|
|
3387
3441
|
import { useMutation as useMutation3, useQuery as useQuery7, useQueryClient as useQueryClient4 } from "@tanstack/react-query";
|
|
3388
3442
|
|
|
3389
3443
|
// src/pipelineTicket.ts
|
|
@@ -3395,11 +3449,11 @@ var DEFAULT_EXCLUDED_STAGES = [
|
|
|
3395
3449
|
"rejeitada",
|
|
3396
3450
|
"rejected"
|
|
3397
3451
|
];
|
|
3398
|
-
function normalized(
|
|
3399
|
-
return String(
|
|
3452
|
+
function normalized(value2) {
|
|
3453
|
+
return String(value2 ?? "").normalize("NFD").replace(/[\u0300-\u036f]/g, "").trim().toLowerCase();
|
|
3400
3454
|
}
|
|
3401
|
-
function slug(
|
|
3402
|
-
return normalized(
|
|
3455
|
+
function slug(value2) {
|
|
3456
|
+
return normalized(value2).replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
3403
3457
|
}
|
|
3404
3458
|
function approvalTone(action) {
|
|
3405
3459
|
const key = normalized(`${action.id ?? ""} ${action.label}`);
|
|
@@ -3407,8 +3461,8 @@ function approvalTone(action) {
|
|
|
3407
3461
|
if (/aprovar|approve/.test(key)) return "success";
|
|
3408
3462
|
return void 0;
|
|
3409
3463
|
}
|
|
3410
|
-
function workStatusPresentation(
|
|
3411
|
-
const key = normalized(
|
|
3464
|
+
function workStatusPresentation(value2) {
|
|
3465
|
+
const key = normalized(value2);
|
|
3412
3466
|
if (/aguardando.*inicio|nao.*iniciado|waiting/.test(key)) {
|
|
3413
3467
|
return { order: 0, label: "Aguardando in\xEDcio", tone: "warning" };
|
|
3414
3468
|
}
|
|
@@ -3486,14 +3540,14 @@ function resolvePipelineActions({
|
|
|
3486
3540
|
});
|
|
3487
3541
|
}
|
|
3488
3542
|
if (config?.workStatus !== false && !hasExplicitWorkStatus && workStatusValues.length) {
|
|
3489
|
-
workStatusValues.map((
|
|
3543
|
+
workStatusValues.map((value2) => ({ value: value2, presentation: workStatusPresentation(value2) })).filter((item) => Boolean(item.presentation)).sort((a, b) => a.presentation.order - b.presentation.order).forEach(({ value: value2, presentation }) => {
|
|
3490
3544
|
resolved.push({
|
|
3491
|
-
id: `core-status-trabalho-${slug(
|
|
3545
|
+
id: `core-status-trabalho-${slug(value2)}`,
|
|
3492
3546
|
label: presentation.label,
|
|
3493
3547
|
type: "setField",
|
|
3494
3548
|
field: workStatusField,
|
|
3495
|
-
value,
|
|
3496
|
-
disabledWhen: { field: workStatusField, equals:
|
|
3549
|
+
value: value2,
|
|
3550
|
+
disabledWhen: { field: workStatusField, equals: value2 },
|
|
3497
3551
|
refresh: ["all"],
|
|
3498
3552
|
group: "workStatus",
|
|
3499
3553
|
tone: presentation.tone,
|
|
@@ -3525,7 +3579,7 @@ function pipelineBoardScrollStep(clientWidth) {
|
|
|
3525
3579
|
}
|
|
3526
3580
|
|
|
3527
3581
|
// src/components/CorePipeline.tsx
|
|
3528
|
-
import { jsx as
|
|
3582
|
+
import { jsx as jsx20, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
3529
3583
|
function ticketId(row) {
|
|
3530
3584
|
const id = row._id ?? row.id;
|
|
3531
3585
|
return id == null ? void 0 : String(id);
|
|
@@ -3540,8 +3594,8 @@ function mergeFormFields2(metadataFields, overrides) {
|
|
|
3540
3594
|
});
|
|
3541
3595
|
return merged;
|
|
3542
3596
|
}
|
|
3543
|
-
function workStatusColor(
|
|
3544
|
-
const normalized2 = String(
|
|
3597
|
+
function workStatusColor(value2) {
|
|
3598
|
+
const normalized2 = String(value2 ?? "").normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
|
|
3545
3599
|
if (/aguardando.*inicio|nao.*iniciado|waiting/.test(normalized2)) return "#D97706";
|
|
3546
3600
|
if (/trabalhando|em.*andamento|working/.test(normalized2)) return "#16A34A";
|
|
3547
3601
|
if (/revisar|revisao|review/.test(normalized2)) return "#DC2626";
|
|
@@ -3549,24 +3603,24 @@ function workStatusColor(value) {
|
|
|
3549
3603
|
}
|
|
3550
3604
|
function PipelineArrowIcon({ direction }) {
|
|
3551
3605
|
const path = direction === "left" ? "M12.5 5 7.5 10l5 5" : "m7.5 5 5 5-5 5";
|
|
3552
|
-
return /* @__PURE__ */
|
|
3606
|
+
return /* @__PURE__ */ jsx20("svg", { viewBox: "0 0 20 20", width: "18", height: "18", "aria-hidden": "true", children: /* @__PURE__ */ jsx20("path", { d: path, fill: "none", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) });
|
|
3553
3607
|
}
|
|
3554
3608
|
function PipelineFilterControl({
|
|
3555
3609
|
filter,
|
|
3556
|
-
value,
|
|
3610
|
+
value: value2,
|
|
3557
3611
|
meta,
|
|
3558
3612
|
onChange
|
|
3559
3613
|
}) {
|
|
3560
3614
|
if (filter.type === "ref" && meta?.ref) {
|
|
3561
|
-
return /* @__PURE__ */
|
|
3615
|
+
return /* @__PURE__ */ jsx20(Box12, { w: "220px", children: /* @__PURE__ */ jsx20(
|
|
3562
3616
|
ReferenceSelect,
|
|
3563
3617
|
{
|
|
3564
3618
|
field: filter.field,
|
|
3565
3619
|
inputId: `pipeline-filter-${filter.field}`,
|
|
3566
3620
|
label: filter.label ?? filter.field,
|
|
3567
3621
|
refModel: meta.ref,
|
|
3568
|
-
value: String(
|
|
3569
|
-
initialValue:
|
|
3622
|
+
value: String(value2 ?? ""),
|
|
3623
|
+
initialValue: value2,
|
|
3570
3624
|
required: false,
|
|
3571
3625
|
invalid: false,
|
|
3572
3626
|
filters: {},
|
|
@@ -3576,12 +3630,12 @@ function PipelineFilterControl({
|
|
|
3576
3630
|
) });
|
|
3577
3631
|
}
|
|
3578
3632
|
if (filter.type === "select") {
|
|
3579
|
-
return /* @__PURE__ */
|
|
3580
|
-
/* @__PURE__ */
|
|
3581
|
-
/* @__PURE__ */
|
|
3633
|
+
return /* @__PURE__ */ jsxs14(NativeSelect5.Root, { size: "sm", w: "190px", children: [
|
|
3634
|
+
/* @__PURE__ */ jsx20(NativeSelect5.Field, { value: String(value2 ?? ""), onChange: (event) => onChange(event.currentTarget.value), children: (filter.options ?? []).map((option) => /* @__PURE__ */ jsx20("option", { value: String(option.value ?? ""), children: option.label }, String(option.value ?? ""))) }),
|
|
3635
|
+
/* @__PURE__ */ jsx20(NativeSelect5.Indicator, {})
|
|
3582
3636
|
] });
|
|
3583
3637
|
}
|
|
3584
|
-
return /* @__PURE__ */
|
|
3638
|
+
return /* @__PURE__ */ jsx20(
|
|
3585
3639
|
Input6,
|
|
3586
3640
|
{
|
|
3587
3641
|
w: "190px",
|
|
@@ -3589,7 +3643,7 @@ function PipelineFilterControl({
|
|
|
3589
3643
|
fontSize: "11px",
|
|
3590
3644
|
type: filter.type === "date" ? "date" : "text",
|
|
3591
3645
|
placeholder: filter.placeholder ?? filter.label ?? filter.field,
|
|
3592
|
-
value: String(
|
|
3646
|
+
value: String(value2 ?? ""),
|
|
3593
3647
|
onChange: (event) => onChange(event.currentTarget.value)
|
|
3594
3648
|
}
|
|
3595
3649
|
);
|
|
@@ -3629,7 +3683,7 @@ function CorePipeline({
|
|
|
3629
3683
|
const boardRef = useRef3(null);
|
|
3630
3684
|
const [boardScrollState, setBoardScrollState] = useState11({ canScrollLeft: false, canScrollRight: false });
|
|
3631
3685
|
const effectiveFilters = Object.fromEntries(
|
|
3632
|
-
Object.entries(filterValues).filter(([,
|
|
3686
|
+
Object.entries(filterValues).filter(([, value2]) => value2 !== "" && value2 != null)
|
|
3633
3687
|
);
|
|
3634
3688
|
const listQuery = useQuery7({
|
|
3635
3689
|
queryKey: ["oon", "pipeline", basePath, effectiveFilters],
|
|
@@ -3672,9 +3726,9 @@ function CorePipeline({
|
|
|
3672
3726
|
},
|
|
3673
3727
|
onError: (error) => setFormError(error)
|
|
3674
3728
|
});
|
|
3675
|
-
if (schemaQuery.isLoading || viewMode === "board" && listQuery.isLoading) return /* @__PURE__ */
|
|
3676
|
-
if (schemaQuery.isError) return /* @__PURE__ */
|
|
3677
|
-
if (viewMode === "board" && listQuery.isError) return /* @__PURE__ */
|
|
3729
|
+
if (schemaQuery.isLoading || viewMode === "board" && listQuery.isLoading) return /* @__PURE__ */ jsx20(LoadingScreen, {});
|
|
3730
|
+
if (schemaQuery.isError) return /* @__PURE__ */ jsx20(ErrorState, { error: schemaQuery.error });
|
|
3731
|
+
if (viewMode === "board" && listQuery.isError) return /* @__PURE__ */ jsx20(ErrorState, { error: listQuery.error });
|
|
3678
3732
|
const stageFieldMeta = schema?.fields.find((field) => field.name === stageField);
|
|
3679
3733
|
const resolvedStages = stages ?? (stageFieldMeta?.options ?? []).map((option) => ({ id: option, label: option }));
|
|
3680
3734
|
const defaultActionsConfig = defaultActions === false ? void 0 : defaultActions;
|
|
@@ -3715,7 +3769,7 @@ function CorePipeline({
|
|
|
3715
3769
|
const step = pipelineBoardScrollStep(board.clientWidth);
|
|
3716
3770
|
board.scrollBy({ left: direction === "left" ? -step : step, behavior: "smooth" });
|
|
3717
3771
|
};
|
|
3718
|
-
const renderModalAction = (action, index) => selectedTicket ? /* @__PURE__ */
|
|
3772
|
+
const renderModalAction = (action, index) => selectedTicket ? /* @__PURE__ */ jsx20(
|
|
3719
3773
|
CoreRowAction,
|
|
3720
3774
|
{
|
|
3721
3775
|
action,
|
|
@@ -3734,40 +3788,40 @@ function CorePipeline({
|
|
|
3734
3788
|
},
|
|
3735
3789
|
action.id ?? `${action.label}-${index}`
|
|
3736
3790
|
) : null;
|
|
3737
|
-
const modalTopActions = selectedTicket && !creating && groupedTicketActions.workStatus.length ? /* @__PURE__ */
|
|
3738
|
-
const modalBottomActions = selectedTicket && !creating ? /* @__PURE__ */
|
|
3739
|
-
groupedTicketActions.approval.length ? /* @__PURE__ */
|
|
3740
|
-
groupedTicketActions.custom.length ? /* @__PURE__ */
|
|
3791
|
+
const modalTopActions = selectedTicket && !creating && groupedTicketActions.workStatus.length ? /* @__PURE__ */ jsx20(Flex8, { role: "group", "aria-label": "Status da atividade", gap: "6px", align: "center", wrap: "wrap", children: groupedTicketActions.workStatus.map(renderModalAction) }) : null;
|
|
3792
|
+
const modalBottomActions = selectedTicket && !creating ? /* @__PURE__ */ jsxs14(Flex8, { gap: "8px", align: "center", wrap: "wrap", children: [
|
|
3793
|
+
groupedTicketActions.approval.length ? /* @__PURE__ */ jsx20(Flex8, { role: "group", "aria-label": "Aprova\xE7\xE3o do ticket", gap: "6px", align: "center", wrap: "wrap", children: groupedTicketActions.approval.map(renderModalAction) }) : null,
|
|
3794
|
+
groupedTicketActions.custom.length ? /* @__PURE__ */ jsx20(Flex8, { role: "group", "aria-label": "A\xE7\xF5es do neg\xF3cio", gap: "6px", align: "center", wrap: "wrap", children: groupedTicketActions.custom.map(renderModalAction) }) : null
|
|
3741
3795
|
] }) : null;
|
|
3742
|
-
return /* @__PURE__ */
|
|
3743
|
-
/* @__PURE__ */
|
|
3744
|
-
/* @__PURE__ */
|
|
3745
|
-
/* @__PURE__ */
|
|
3746
|
-
/* @__PURE__ */
|
|
3747
|
-
/* @__PURE__ */
|
|
3796
|
+
return /* @__PURE__ */ jsxs14(Stack5, { gap: 5, children: [
|
|
3797
|
+
/* @__PURE__ */ jsxs14(Flex8, { align: { base: "stretch", md: "flex-end" }, justify: "space-between", gap: 4, direction: { base: "column", md: "row" }, children: [
|
|
3798
|
+
/* @__PURE__ */ jsxs14(Box12, { children: [
|
|
3799
|
+
/* @__PURE__ */ jsx20(Text13, { fontSize: "11px", fontWeight: "700", color: "brand.500", textTransform: "uppercase", letterSpacing: "0.08em", mb: 1, children: "Esteira de processo" }),
|
|
3800
|
+
/* @__PURE__ */ jsx20(Heading5, { size: "lg", color: "#24323A", letterSpacing: "-0.02em", children: label ?? schema?.name ?? model }),
|
|
3801
|
+
/* @__PURE__ */ jsx20(Text13, { mt: 1, fontSize: "13px", color: "gray.500", children: "Acompanhe os tickets por etapa e visualize os principais dados de cada item." })
|
|
3748
3802
|
] }),
|
|
3749
|
-
/* @__PURE__ */
|
|
3750
|
-
allowedViewModes.length > 1 ? allowedViewModes.map((mode) => /* @__PURE__ */
|
|
3751
|
-
create?.enabled ? /* @__PURE__ */
|
|
3803
|
+
/* @__PURE__ */ jsxs14(Flex8, { gap: "8px", align: "center", wrap: "wrap", children: [
|
|
3804
|
+
allowedViewModes.length > 1 ? allowedViewModes.map((mode) => /* @__PURE__ */ jsx20(Button9, { size: "sm", variant: viewMode === mode ? "solid" : "outline", colorPalette: "brand", onClick: () => setViewMode(mode), children: mode === "board" ? "Quadro" : "Lista" }, mode)) : null,
|
|
3805
|
+
create?.enabled ? /* @__PURE__ */ jsx20(Button9, { size: "sm", colorPalette: "brand", onClick: openCreate, children: create.label ?? "Novo ticket" }) : null
|
|
3752
3806
|
] })
|
|
3753
3807
|
] }),
|
|
3754
|
-
filters.length ? /* @__PURE__ */
|
|
3808
|
+
filters.length ? /* @__PURE__ */ jsxs14(Flex8, { p: "12px", gap: "10px", align: "flex-end", wrap: "wrap", bg: "white", borderWidth: "1px", borderColor: "#E5E9ED", borderRadius: "10px", children: [
|
|
3755
3809
|
filters.map((filter) => {
|
|
3756
3810
|
const meta = schema?.fields.find((field) => field.name === filter.field);
|
|
3757
|
-
return /* @__PURE__ */
|
|
3758
|
-
/* @__PURE__ */
|
|
3759
|
-
/* @__PURE__ */
|
|
3811
|
+
return /* @__PURE__ */ jsxs14(Box12, { children: [
|
|
3812
|
+
/* @__PURE__ */ jsx20(Text13, { mb: "4px", fontSize: "10px", color: "#667085", fontWeight: "600", children: filter.label ?? fieldLabel({ name: filter.field }) }),
|
|
3813
|
+
/* @__PURE__ */ jsx20(
|
|
3760
3814
|
PipelineFilterControl,
|
|
3761
3815
|
{
|
|
3762
3816
|
filter,
|
|
3763
3817
|
value: filterValues[filter.field],
|
|
3764
3818
|
meta,
|
|
3765
|
-
onChange: (
|
|
3819
|
+
onChange: (value2) => setFilterValues((current) => ({ ...current, [filter.field]: value2 }))
|
|
3766
3820
|
}
|
|
3767
3821
|
)
|
|
3768
3822
|
] }, filter.field);
|
|
3769
3823
|
}),
|
|
3770
|
-
/* @__PURE__ */
|
|
3824
|
+
/* @__PURE__ */ jsx20(
|
|
3771
3825
|
Button9,
|
|
3772
3826
|
{
|
|
3773
3827
|
size: "sm",
|
|
@@ -3777,7 +3831,7 @@ function CorePipeline({
|
|
|
3777
3831
|
}
|
|
3778
3832
|
)
|
|
3779
3833
|
] }) : null,
|
|
3780
|
-
viewMode === "list" ? /* @__PURE__ */
|
|
3834
|
+
viewMode === "list" ? /* @__PURE__ */ jsx20(
|
|
3781
3835
|
DataGrid,
|
|
3782
3836
|
{
|
|
3783
3837
|
resource,
|
|
@@ -3790,8 +3844,8 @@ function CorePipeline({
|
|
|
3790
3844
|
setSelectedTicket(row);
|
|
3791
3845
|
}
|
|
3792
3846
|
}
|
|
3793
|
-
) : /* @__PURE__ */
|
|
3794
|
-
/* @__PURE__ */
|
|
3847
|
+
) : /* @__PURE__ */ jsxs14(Box12, { position: "relative", children: [
|
|
3848
|
+
/* @__PURE__ */ jsx20(
|
|
3795
3849
|
Flex8,
|
|
3796
3850
|
{
|
|
3797
3851
|
ref: boardRef,
|
|
@@ -3809,14 +3863,14 @@ function CorePipeline({
|
|
|
3809
3863
|
overscrollBehaviorX: "contain",
|
|
3810
3864
|
children: Array.from(byStage.entries()).map(([stageId, items]) => {
|
|
3811
3865
|
const stageLabel = resolvedStages.find((stage) => stage.id === stageId)?.label ?? (stageId || "Sem etapa");
|
|
3812
|
-
return /* @__PURE__ */
|
|
3813
|
-
/* @__PURE__ */
|
|
3814
|
-
/* @__PURE__ */
|
|
3815
|
-
/* @__PURE__ */
|
|
3866
|
+
return /* @__PURE__ */ jsxs14(Box12, { minW: "300px", maxW: "340px", flex: "1 0 300px", bg: "#E8ECEF", borderRadius: "12px", p: 3, borderWidth: "1px", borderColor: "#DDE3E7", children: [
|
|
3867
|
+
/* @__PURE__ */ jsxs14(Flex8, { align: "center", justify: "space-between", mb: 3, px: 1, children: [
|
|
3868
|
+
/* @__PURE__ */ jsx20(Text13, { fontWeight: "700", fontSize: "12px", color: "#33434C", textTransform: "uppercase", letterSpacing: "0.03em", children: stageLabel }),
|
|
3869
|
+
/* @__PURE__ */ jsx20(Badge4, { colorPalette: "brand", variant: "solid", borderRadius: "full", minW: "24px", justifyContent: "center", children: items.length })
|
|
3816
3870
|
] }),
|
|
3817
|
-
/* @__PURE__ */
|
|
3871
|
+
/* @__PURE__ */ jsx20(Stack5, { gap: 2, children: items.length === 0 ? /* @__PURE__ */ jsx20(Box12, { borderWidth: "1px", borderStyle: "dashed", borderColor: "#C8D0D5", borderRadius: "10px", p: 5, textAlign: "center", children: /* @__PURE__ */ jsx20(Text13, { fontSize: "12px", color: "gray.500", children: "Nenhum ticket nesta etapa." }) }) : items.map((row, index) => {
|
|
3818
3872
|
const ticketTitle = formatCell(row[resolvedTitleField], "string");
|
|
3819
|
-
return /* @__PURE__ */
|
|
3873
|
+
return /* @__PURE__ */ jsxs14(
|
|
3820
3874
|
Button9,
|
|
3821
3875
|
{
|
|
3822
3876
|
type: "button",
|
|
@@ -3841,10 +3895,10 @@ function CorePipeline({
|
|
|
3841
3895
|
},
|
|
3842
3896
|
_hover: { borderColor: "brand.300", transform: "translateY(-1px)", boxShadow: "0 7px 18px rgba(7, 38, 46, 0.09)" },
|
|
3843
3897
|
children: [
|
|
3844
|
-
/* @__PURE__ */
|
|
3845
|
-
/* @__PURE__ */
|
|
3846
|
-
/* @__PURE__ */
|
|
3847
|
-
|
|
3898
|
+
/* @__PURE__ */ jsxs14(Flex8, { align: "flex-start", justify: "space-between", gap: "8px", mb: 2, children: [
|
|
3899
|
+
/* @__PURE__ */ jsx20(Text13, { fontSize: "13px", fontWeight: "700", color: "#24323A", lineClamp: 2, children: ticketTitle }),
|
|
3900
|
+
/* @__PURE__ */ jsx20(
|
|
3901
|
+
Box12,
|
|
3848
3902
|
{
|
|
3849
3903
|
as: "span",
|
|
3850
3904
|
title: `Status da atividade: ${String(row[workStatusField] ?? "N\xE3o informado")}`,
|
|
@@ -3859,9 +3913,9 @@ function CorePipeline({
|
|
|
3859
3913
|
}
|
|
3860
3914
|
)
|
|
3861
3915
|
] }),
|
|
3862
|
-
/* @__PURE__ */
|
|
3863
|
-
/* @__PURE__ */
|
|
3864
|
-
/* @__PURE__ */
|
|
3916
|
+
/* @__PURE__ */ jsx20(Stack5, { gap: 1, children: detailFields.map((field) => /* @__PURE__ */ jsxs14(Flex8, { gap: 2, align: "baseline", justify: "space-between", children: [
|
|
3917
|
+
/* @__PURE__ */ jsx20(Text13, { fontSize: "10px", color: "gray.500", textTransform: "uppercase", letterSpacing: "0.03em", children: fieldLabel(field) }),
|
|
3918
|
+
/* @__PURE__ */ jsx20(Text13, { fontSize: "11px", color: "#46545C", fontWeight: "500", textAlign: "right", lineClamp: 1, children: formatCell(row[field.name], field.kind) })
|
|
3865
3919
|
] }, field.name)) })
|
|
3866
3920
|
]
|
|
3867
3921
|
},
|
|
@@ -3872,7 +3926,7 @@ function CorePipeline({
|
|
|
3872
3926
|
})
|
|
3873
3927
|
}
|
|
3874
3928
|
),
|
|
3875
|
-
/* @__PURE__ */
|
|
3929
|
+
/* @__PURE__ */ jsx20(
|
|
3876
3930
|
Button9,
|
|
3877
3931
|
{
|
|
3878
3932
|
type: "button",
|
|
@@ -3896,10 +3950,10 @@ function CorePipeline({
|
|
|
3896
3950
|
onClick: () => scrollBoard("left"),
|
|
3897
3951
|
_hover: { bg: "white", borderColor: "brand.400" },
|
|
3898
3952
|
_disabled: { opacity: 0.25, cursor: "not-allowed" },
|
|
3899
|
-
children: /* @__PURE__ */
|
|
3953
|
+
children: /* @__PURE__ */ jsx20(PipelineArrowIcon, { direction: "left" })
|
|
3900
3954
|
}
|
|
3901
3955
|
),
|
|
3902
|
-
/* @__PURE__ */
|
|
3956
|
+
/* @__PURE__ */ jsx20(
|
|
3903
3957
|
Button9,
|
|
3904
3958
|
{
|
|
3905
3959
|
type: "button",
|
|
@@ -3923,11 +3977,11 @@ function CorePipeline({
|
|
|
3923
3977
|
onClick: () => scrollBoard("right"),
|
|
3924
3978
|
_hover: { bg: "white", borderColor: "brand.400" },
|
|
3925
3979
|
_disabled: { opacity: 0.25, cursor: "not-allowed" },
|
|
3926
|
-
children: /* @__PURE__ */
|
|
3980
|
+
children: /* @__PURE__ */ jsx20(PipelineArrowIcon, { direction: "right" })
|
|
3927
3981
|
}
|
|
3928
3982
|
)
|
|
3929
3983
|
] }),
|
|
3930
|
-
selectedTicket && ticketModal && ticketModal.enabled !== false ? /* @__PURE__ */
|
|
3984
|
+
selectedTicket && ticketModal && ticketModal.enabled !== false ? /* @__PURE__ */ jsx20(
|
|
3931
3985
|
CoreDetailModal,
|
|
3932
3986
|
{
|
|
3933
3987
|
model,
|
|
@@ -3953,7 +4007,7 @@ function CorePipeline({
|
|
|
3953
4007
|
}
|
|
3954
4008
|
}
|
|
3955
4009
|
}
|
|
3956
|
-
) : selectedTicket ? /* @__PURE__ */
|
|
4010
|
+
) : selectedTicket ? /* @__PURE__ */ jsx20(
|
|
3957
4011
|
DynamicForm,
|
|
3958
4012
|
{
|
|
3959
4013
|
title: `${creating ? "Novo" : "Editar"} ${schema?.singular ?? label ?? model}`,
|
|
@@ -3980,9 +4034,9 @@ function CorePipeline({
|
|
|
3980
4034
|
}
|
|
3981
4035
|
|
|
3982
4036
|
// src/components/CoreDashboard.tsx
|
|
3983
|
-
import { Box as
|
|
4037
|
+
import { Box as Box13, Heading as Heading6, SimpleGrid as SimpleGrid4, Stack as Stack6, Text as Text14 } from "@chakra-ui/react";
|
|
3984
4038
|
import { useQueries } from "@tanstack/react-query";
|
|
3985
|
-
import { jsx as
|
|
4039
|
+
import { jsx as jsx21, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3986
4040
|
function CoreDashboard({ label = "Dashboard", widgets = [] }) {
|
|
3987
4041
|
const { resource } = useOonApi();
|
|
3988
4042
|
const queries = useQueries({
|
|
@@ -3999,46 +4053,46 @@ function CoreDashboard({ label = "Dashboard", widgets = [] }) {
|
|
|
3999
4053
|
}))
|
|
4000
4054
|
});
|
|
4001
4055
|
let queryIdx = 0;
|
|
4002
|
-
return /* @__PURE__ */
|
|
4003
|
-
/* @__PURE__ */
|
|
4004
|
-
/* @__PURE__ */
|
|
4056
|
+
return /* @__PURE__ */ jsxs15(Stack6, { gap: 6, children: [
|
|
4057
|
+
/* @__PURE__ */ jsx21(Heading6, { size: "lg", children: label }),
|
|
4058
|
+
/* @__PURE__ */ jsx21(SimpleGrid4, { columns: { base: 1, md: 2, lg: 3 }, gap: 4, children: widgets.map((w) => {
|
|
4005
4059
|
if (w.kind === "custom" && w.render) {
|
|
4006
|
-
return /* @__PURE__ */
|
|
4060
|
+
return /* @__PURE__ */ jsx21(Box13, { borderWidth: "1px", borderColor: "gray.200", borderRadius: "md", bg: "white", p: 5, children: w.render() }, w.id);
|
|
4007
4061
|
}
|
|
4008
4062
|
const q = queries[queryIdx++];
|
|
4009
|
-
const
|
|
4010
|
-
return /* @__PURE__ */
|
|
4011
|
-
/* @__PURE__ */
|
|
4012
|
-
/* @__PURE__ */
|
|
4063
|
+
const value2 = q?.isLoading ? "\u2026" : q?.isError ? "\u2014" : formatWidget(q?.data, w.kind, w.field);
|
|
4064
|
+
return /* @__PURE__ */ jsxs15(Box13, { borderWidth: "1px", borderColor: "gray.200", borderRadius: "md", bg: "white", p: 5, children: [
|
|
4065
|
+
/* @__PURE__ */ jsx21(Text14, { fontSize: "sm", color: "gray.500", children: w.label }),
|
|
4066
|
+
/* @__PURE__ */ jsx21(Heading6, { size: "xl", mt: 1, children: value2 })
|
|
4013
4067
|
] }, w.id);
|
|
4014
4068
|
}) })
|
|
4015
4069
|
] });
|
|
4016
4070
|
}
|
|
4017
|
-
function formatWidget(
|
|
4018
|
-
if (
|
|
4071
|
+
function formatWidget(value2, kind, field) {
|
|
4072
|
+
if (value2 == null) return "\u2014";
|
|
4019
4073
|
if (kind === "sum" && field?.toLowerCase().includes("valor") || kind === "sum") {
|
|
4020
|
-
return new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(Number(
|
|
4074
|
+
return new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(Number(value2));
|
|
4021
4075
|
}
|
|
4022
|
-
return String(
|
|
4076
|
+
return String(value2);
|
|
4023
4077
|
}
|
|
4024
4078
|
|
|
4025
4079
|
// src/components/ui-v2/CorePage.tsx
|
|
4026
|
-
import { Box as
|
|
4080
|
+
import { Box as Box16, Heading as Heading8, Stack as Stack7, Text as Text17 } from "@chakra-ui/react";
|
|
4027
4081
|
|
|
4028
4082
|
// src/security/PermissionGate.tsx
|
|
4029
|
-
import { Fragment as Fragment3, jsx as
|
|
4083
|
+
import { Fragment as Fragment3, jsx as jsx22 } from "react/jsx-runtime";
|
|
4030
4084
|
function PermissionGate({
|
|
4031
4085
|
permission,
|
|
4032
4086
|
fallback = null,
|
|
4033
4087
|
children
|
|
4034
4088
|
}) {
|
|
4035
4089
|
const { hasPermission } = useOonAuth();
|
|
4036
|
-
return /* @__PURE__ */
|
|
4090
|
+
return /* @__PURE__ */ jsx22(Fragment3, { children: hasPermission(permission) ? children : fallback });
|
|
4037
4091
|
}
|
|
4038
4092
|
|
|
4039
4093
|
// src/app/componentRegistry.tsx
|
|
4040
|
-
import { Box as
|
|
4041
|
-
import { Fragment as Fragment4, jsx as
|
|
4094
|
+
import { Box as Box14, Text as Text15 } from "@chakra-ui/react";
|
|
4095
|
+
import { Fragment as Fragment4, jsx as jsx23, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
4042
4096
|
var PREFIX_BUCKETS = {
|
|
4043
4097
|
"custom": "pageComponents",
|
|
4044
4098
|
"fields": "fieldRenderers",
|
|
@@ -4058,12 +4112,12 @@ function resolveComponent(registry, key, bucket) {
|
|
|
4058
4112
|
return registry?.[targetBucket]?.[normalized2] ?? registry?.[targetBucket]?.[key] ?? null;
|
|
4059
4113
|
}
|
|
4060
4114
|
function MissingRenderer({ renderer, children }) {
|
|
4061
|
-
if (import.meta.env?.MODE === "production") return /* @__PURE__ */
|
|
4062
|
-
return /* @__PURE__ */
|
|
4063
|
-
/* @__PURE__ */
|
|
4064
|
-
/* @__PURE__ */
|
|
4115
|
+
if (import.meta.env?.MODE === "production") return /* @__PURE__ */ jsx23(Fragment4, { children: children ?? null });
|
|
4116
|
+
return /* @__PURE__ */ jsxs16(Box14, { borderWidth: "1px", borderStyle: "dashed", borderColor: "orange.300", bg: "orange.50", color: "orange.900", borderRadius: "md", p: 3, children: [
|
|
4117
|
+
/* @__PURE__ */ jsx23(Text15, { fontSize: "sm", fontWeight: "600", children: "Renderer n\xE3o encontrado" }),
|
|
4118
|
+
/* @__PURE__ */ jsxs16(Text15, { fontSize: "xs", children: [
|
|
4065
4119
|
"Registre a chave ",
|
|
4066
|
-
renderer ? /* @__PURE__ */
|
|
4120
|
+
renderer ? /* @__PURE__ */ jsx23("code", { children: renderer }) : "solicitada",
|
|
4067
4121
|
" no registry da UI."
|
|
4068
4122
|
] }),
|
|
4069
4123
|
children
|
|
@@ -4071,61 +4125,61 @@ function MissingRenderer({ renderer, children }) {
|
|
|
4071
4125
|
}
|
|
4072
4126
|
|
|
4073
4127
|
// src/components/ui-v2/CorePrimitives.tsx
|
|
4074
|
-
import { Box as
|
|
4075
|
-
import { jsx as
|
|
4128
|
+
import { Box as Box15, Button as Button10, Flex as Flex9, Heading as Heading7, Spinner as Spinner3, Text as Text16 } from "@chakra-ui/react";
|
|
4129
|
+
import { jsx as jsx24, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
4076
4130
|
function CorePage({ children }) {
|
|
4077
|
-
return /* @__PURE__ */
|
|
4131
|
+
return /* @__PURE__ */ jsx24(Box15, { children });
|
|
4078
4132
|
}
|
|
4079
4133
|
function CorePageHeader({ title, description, actions }) {
|
|
4080
|
-
return /* @__PURE__ */
|
|
4081
|
-
/* @__PURE__ */
|
|
4082
|
-
title ? /* @__PURE__ */
|
|
4083
|
-
description ? /* @__PURE__ */
|
|
4134
|
+
return /* @__PURE__ */ jsxs17(Flex9, { align: "start", justify: "space-between", gap: 4, mb: 6, children: [
|
|
4135
|
+
/* @__PURE__ */ jsxs17(Box15, { children: [
|
|
4136
|
+
title ? /* @__PURE__ */ jsx24(Heading7, { size: "lg", children: title }) : null,
|
|
4137
|
+
description ? /* @__PURE__ */ jsx24(Text16, { color: "gray.600", mt: 1, children: description }) : null
|
|
4084
4138
|
] }),
|
|
4085
4139
|
actions
|
|
4086
4140
|
] });
|
|
4087
4141
|
}
|
|
4088
4142
|
function CoreToolbar({ children }) {
|
|
4089
|
-
return /* @__PURE__ */
|
|
4143
|
+
return /* @__PURE__ */ jsx24(Flex9, { align: "center", gap: 2, mb: 4, children });
|
|
4090
4144
|
}
|
|
4091
4145
|
function CoreDataGrid(props) {
|
|
4092
|
-
return /* @__PURE__ */
|
|
4146
|
+
return /* @__PURE__ */ jsx24(CoreCollection, { ...props });
|
|
4093
4147
|
}
|
|
4094
4148
|
function CoreCards(props) {
|
|
4095
|
-
return /* @__PURE__ */
|
|
4149
|
+
return /* @__PURE__ */ jsx24(CoreCollection, { model: props.model, mode: "minimal", label: props.model });
|
|
4096
4150
|
}
|
|
4097
4151
|
function CoreForm(props) {
|
|
4098
|
-
return /* @__PURE__ */
|
|
4152
|
+
return /* @__PURE__ */ jsx24(Box15, { children: props.children });
|
|
4099
4153
|
}
|
|
4100
4154
|
function CoreField({ label, children }) {
|
|
4101
|
-
return /* @__PURE__ */
|
|
4102
|
-
/* @__PURE__ */
|
|
4155
|
+
return /* @__PURE__ */ jsxs17(Box15, { children: [
|
|
4156
|
+
/* @__PURE__ */ jsx24(Text16, { fontSize: "sm", fontWeight: "600", children: label }),
|
|
4103
4157
|
children
|
|
4104
4158
|
] });
|
|
4105
4159
|
}
|
|
4106
4160
|
function CoreRelationField(props) {
|
|
4107
|
-
return /* @__PURE__ */
|
|
4161
|
+
return /* @__PURE__ */ jsx24(CoreField, { ...props });
|
|
4108
4162
|
}
|
|
4109
4163
|
function CoreActions({ children }) {
|
|
4110
|
-
return /* @__PURE__ */
|
|
4164
|
+
return /* @__PURE__ */ jsx24(Flex9, { gap: 2, children });
|
|
4111
4165
|
}
|
|
4112
4166
|
function CoreEmptyState({ title = "Nenhum dado encontrado", actionLabel, onAction }) {
|
|
4113
|
-
return /* @__PURE__ */
|
|
4114
|
-
/* @__PURE__ */
|
|
4115
|
-
actionLabel ? /* @__PURE__ */
|
|
4167
|
+
return /* @__PURE__ */ jsxs17(Box15, { textAlign: "center", py: 10, children: [
|
|
4168
|
+
/* @__PURE__ */ jsx24(Text16, { children: title }),
|
|
4169
|
+
actionLabel ? /* @__PURE__ */ jsx24(Button10, { mt: 3, onClick: onAction, children: actionLabel }) : null
|
|
4116
4170
|
] });
|
|
4117
4171
|
}
|
|
4118
4172
|
function CoreLoadingState({ label = "Carregando..." }) {
|
|
4119
|
-
return /* @__PURE__ */
|
|
4120
|
-
/* @__PURE__ */
|
|
4121
|
-
/* @__PURE__ */
|
|
4173
|
+
return /* @__PURE__ */ jsxs17(Flex9, { align: "center", gap: 3, children: [
|
|
4174
|
+
/* @__PURE__ */ jsx24(Spinner3, { size: "sm" }),
|
|
4175
|
+
/* @__PURE__ */ jsx24(Text16, { children: label })
|
|
4122
4176
|
] });
|
|
4123
4177
|
}
|
|
4124
4178
|
|
|
4125
4179
|
// src/components/ui-v2/CorePage.tsx
|
|
4126
|
-
import { jsx as
|
|
4180
|
+
import { jsx as jsx25, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
4127
4181
|
function renderMarkdown(content) {
|
|
4128
|
-
return content.split(/\n{2,}/).map((paragraph, index) => /* @__PURE__ */
|
|
4182
|
+
return content.split(/\n{2,}/).map((paragraph, index) => /* @__PURE__ */ jsx25(Text17, { whiteSpace: "pre-wrap", children: paragraph }, index));
|
|
4129
4183
|
}
|
|
4130
4184
|
function requiredAccess(source) {
|
|
4131
4185
|
const values = [...source.permissions ?? [], ...source.capabilities ?? []].filter(Boolean);
|
|
@@ -4137,40 +4191,40 @@ function CoreBlock({ block, registry }) {
|
|
|
4137
4191
|
switch (block.type) {
|
|
4138
4192
|
case "custom": {
|
|
4139
4193
|
const Component = resolveComponent(registry, block.component, "pageComponents");
|
|
4140
|
-
return Component ? /* @__PURE__ */
|
|
4194
|
+
return Component ? /* @__PURE__ */ jsx25(Component, { block, ...block.props }) : /* @__PURE__ */ jsx25(MissingRenderer, { renderer: block.component });
|
|
4141
4195
|
}
|
|
4142
4196
|
case "collection.datagrid":
|
|
4143
|
-
return /* @__PURE__ */
|
|
4197
|
+
return /* @__PURE__ */ jsx25(CoreDataGrid, { model: block.model, mode: block.mode, columns: block.columns, form: block.form, label: block.title ?? block.model });
|
|
4144
4198
|
case "collection.cards": {
|
|
4145
4199
|
const Component = resolveComponent(registry, block.renderer, "cardRenderers");
|
|
4146
|
-
return Component ? /* @__PURE__ */
|
|
4200
|
+
return Component ? /* @__PURE__ */ jsx25(Component, { block, model: block.model }) : /* @__PURE__ */ jsx25(CoreCards, { model: block.model, renderer: block.renderer });
|
|
4147
4201
|
}
|
|
4148
4202
|
case "section":
|
|
4149
|
-
return /* @__PURE__ */
|
|
4150
|
-
/* @__PURE__ */
|
|
4151
|
-
block.description ? /* @__PURE__ */
|
|
4152
|
-
/* @__PURE__ */
|
|
4203
|
+
return /* @__PURE__ */ jsxs18(Box16, { children: [
|
|
4204
|
+
/* @__PURE__ */ jsx25(Heading8, { size: "md", mb: block.description ? 1 : 4, children: block.title }),
|
|
4205
|
+
block.description ? /* @__PURE__ */ jsx25(Text17, { color: "gray.600", mb: 4, children: block.description }) : null,
|
|
4206
|
+
/* @__PURE__ */ jsx25(Stack7, { gap: 4, children: block.blocks?.map((child, index) => /* @__PURE__ */ jsx25(CoreBlock, { block: child, registry }, child.id ?? index)) })
|
|
4153
4207
|
] });
|
|
4154
4208
|
case "markdown":
|
|
4155
|
-
return /* @__PURE__ */
|
|
4209
|
+
return /* @__PURE__ */ jsx25(Stack7, { gap: 2, children: renderMarkdown(block.content) });
|
|
4156
4210
|
default:
|
|
4157
|
-
return /* @__PURE__ */
|
|
4211
|
+
return /* @__PURE__ */ jsx25(MissingRenderer, { renderer: block.type });
|
|
4158
4212
|
}
|
|
4159
4213
|
})();
|
|
4160
|
-
return /* @__PURE__ */
|
|
4214
|
+
return /* @__PURE__ */ jsx25(PermissionGate, { permission: requiredAccess(block), children: content });
|
|
4161
4215
|
}
|
|
4162
4216
|
function CorePage2({ page, registry }) {
|
|
4163
4217
|
const Component = resolveComponent(registry, page.component, "pageComponents");
|
|
4164
|
-
return /* @__PURE__ */
|
|
4165
|
-
/* @__PURE__ */
|
|
4166
|
-
/* @__PURE__ */
|
|
4218
|
+
return /* @__PURE__ */ jsx25(PermissionGate, { permission: requiredAccess(page), children: Component ? /* @__PURE__ */ jsx25(Component, { page }) : /* @__PURE__ */ jsxs18(CorePage, { children: [
|
|
4219
|
+
/* @__PURE__ */ jsx25(CorePageHeader, { title: page.title ?? page.label }),
|
|
4220
|
+
/* @__PURE__ */ jsx25(Stack7, { gap: 6, children: page.blocks?.map((block, index) => /* @__PURE__ */ jsx25(CoreBlock, { block, registry }, block.id ?? index)) })
|
|
4167
4221
|
] }) });
|
|
4168
4222
|
}
|
|
4169
4223
|
|
|
4170
4224
|
// src/app/moduleRegistry.tsx
|
|
4171
|
-
import { jsx as
|
|
4172
|
-
function slug2(
|
|
4173
|
-
return
|
|
4225
|
+
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
4226
|
+
function slug2(value2) {
|
|
4227
|
+
return value2.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
4174
4228
|
}
|
|
4175
4229
|
function requiredAccess2(source) {
|
|
4176
4230
|
const values = [...source.permissions ?? [], ...source.capabilities ?? []].filter(Boolean);
|
|
@@ -4195,7 +4249,7 @@ function renderView(view, registry) {
|
|
|
4195
4249
|
switch (view.type) {
|
|
4196
4250
|
case "collection": {
|
|
4197
4251
|
const v = view;
|
|
4198
|
-
return /* @__PURE__ */
|
|
4252
|
+
return /* @__PURE__ */ jsx26(
|
|
4199
4253
|
CoreCollection,
|
|
4200
4254
|
{
|
|
4201
4255
|
model: v.model,
|
|
@@ -4214,11 +4268,11 @@ function renderView(view, registry) {
|
|
|
4214
4268
|
}
|
|
4215
4269
|
case "document": {
|
|
4216
4270
|
const v = view;
|
|
4217
|
-
return /* @__PURE__ */
|
|
4271
|
+
return /* @__PURE__ */ jsx26(CoreDocument, { model: v.model, label: viewLabel(v), approval: v.approval, attachments: v.attachments });
|
|
4218
4272
|
}
|
|
4219
4273
|
case "pipeline": {
|
|
4220
4274
|
const v = view;
|
|
4221
|
-
return /* @__PURE__ */
|
|
4275
|
+
return /* @__PURE__ */ jsx26(
|
|
4222
4276
|
CorePipeline,
|
|
4223
4277
|
{
|
|
4224
4278
|
model: v.model,
|
|
@@ -4241,7 +4295,7 @@ function renderView(view, registry) {
|
|
|
4241
4295
|
}
|
|
4242
4296
|
case "dashboard": {
|
|
4243
4297
|
const v = view;
|
|
4244
|
-
return /* @__PURE__ */
|
|
4298
|
+
return /* @__PURE__ */ jsx26(CoreDashboard, { label: viewLabel(v), widgets: v.widgets });
|
|
4245
4299
|
}
|
|
4246
4300
|
default:
|
|
4247
4301
|
return null;
|
|
@@ -4255,7 +4309,7 @@ function viewToRoute(view, registry) {
|
|
|
4255
4309
|
};
|
|
4256
4310
|
}
|
|
4257
4311
|
function pageToRoute(page, registry) {
|
|
4258
|
-
return { path: page.path, element: /* @__PURE__ */
|
|
4312
|
+
return { path: page.path, element: /* @__PURE__ */ jsx26(CorePage2, { page, registry }), permissions: requiredAccess2(page) };
|
|
4259
4313
|
}
|
|
4260
4314
|
function pageToMenu(page) {
|
|
4261
4315
|
if (page.hidden || !page.label) return null;
|
|
@@ -4317,13 +4371,13 @@ import {
|
|
|
4317
4371
|
} from "react-router-dom";
|
|
4318
4372
|
|
|
4319
4373
|
// src/shell/DefaultShell.tsx
|
|
4320
|
-
import { Box as
|
|
4374
|
+
import { Box as Box18, Button as Button11, Flex as Flex11, Spacer as Spacer2, Text as Text19 } from "@chakra-ui/react";
|
|
4321
4375
|
import { Outlet } from "react-router-dom";
|
|
4322
4376
|
|
|
4323
4377
|
// src/shell/Sidebar.tsx
|
|
4324
|
-
import { Box as
|
|
4378
|
+
import { Box as Box17, Flex as Flex10, Image, Stack as Stack8, Text as Text18 } from "@chakra-ui/react";
|
|
4325
4379
|
import { NavLink } from "react-router-dom";
|
|
4326
|
-
import { jsx as
|
|
4380
|
+
import { jsx as jsx27, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
4327
4381
|
function groupBySection(items) {
|
|
4328
4382
|
const groups = /* @__PURE__ */ new Map();
|
|
4329
4383
|
for (const item of items) {
|
|
@@ -4336,8 +4390,8 @@ function groupBySection(items) {
|
|
|
4336
4390
|
function Sidebar({ app, menu, registry }) {
|
|
4337
4391
|
const { hasPermission } = useOonAuth();
|
|
4338
4392
|
const visible = menu.filter((item) => !item.hidden && hasPermission(item.permissions));
|
|
4339
|
-
return /* @__PURE__ */
|
|
4340
|
-
|
|
4393
|
+
return /* @__PURE__ */ jsxs19(
|
|
4394
|
+
Box17,
|
|
4341
4395
|
{
|
|
4342
4396
|
as: "nav",
|
|
4343
4397
|
w: { base: "76px", lg: "248px" },
|
|
@@ -4352,8 +4406,8 @@ function Sidebar({ app, menu, registry }) {
|
|
|
4352
4406
|
alignSelf: "flex-start",
|
|
4353
4407
|
overflowY: "auto",
|
|
4354
4408
|
children: [
|
|
4355
|
-
/* @__PURE__ */
|
|
4356
|
-
app.logo ? /* @__PURE__ */
|
|
4409
|
+
/* @__PURE__ */ jsxs19(Flex10, { align: "center", gap: 3, mb: 6, px: { base: 1, lg: 2 }, minH: "42px", children: [
|
|
4410
|
+
app.logo ? /* @__PURE__ */ jsx27(Image, { src: app.logo, alt: app.name, maxH: "36px", maxW: { base: "44px", lg: "150px" }, objectFit: "contain" }) : /* @__PURE__ */ jsx27(
|
|
4357
4411
|
Flex10,
|
|
4358
4412
|
{
|
|
4359
4413
|
w: "38px",
|
|
@@ -4369,14 +4423,14 @@ function Sidebar({ app, menu, registry }) {
|
|
|
4369
4423
|
children: "O"
|
|
4370
4424
|
}
|
|
4371
4425
|
),
|
|
4372
|
-
/* @__PURE__ */
|
|
4373
|
-
/* @__PURE__ */
|
|
4374
|
-
/* @__PURE__ */
|
|
4426
|
+
/* @__PURE__ */ jsxs19(Box17, { display: { base: "none", lg: "block" }, minW: 0, children: [
|
|
4427
|
+
/* @__PURE__ */ jsx27(Text18, { fontWeight: "700", fontSize: "sm", color: "#07262E", lineClamp: 1, children: app.name }),
|
|
4428
|
+
/* @__PURE__ */ jsx27(Text18, { fontSize: "10px", color: "gray.500", textTransform: "uppercase", letterSpacing: "0.08em", children: "Opera\xE7\xE3o digital" })
|
|
4375
4429
|
] })
|
|
4376
4430
|
] }),
|
|
4377
|
-
/* @__PURE__ */
|
|
4378
|
-
/* @__PURE__ */
|
|
4379
|
-
|
|
4431
|
+
/* @__PURE__ */ jsx27(Stack8, { gap: 5, children: groupBySection(visible).map(([section, items]) => /* @__PURE__ */ jsxs19(Stack8, { gap: 1, children: [
|
|
4432
|
+
/* @__PURE__ */ jsx27(
|
|
4433
|
+
Text18,
|
|
4380
4434
|
{
|
|
4381
4435
|
display: { base: "none", lg: "block" },
|
|
4382
4436
|
fontSize: "10px",
|
|
@@ -4391,8 +4445,8 @@ function Sidebar({ app, menu, registry }) {
|
|
|
4391
4445
|
),
|
|
4392
4446
|
items.map((item) => {
|
|
4393
4447
|
const CustomMenuItem = resolveComponent(registry, item.renderer, "menuRenderers");
|
|
4394
|
-
if (CustomMenuItem) return /* @__PURE__ */
|
|
4395
|
-
return /* @__PURE__ */
|
|
4448
|
+
if (CustomMenuItem) return /* @__PURE__ */ jsx27(CustomMenuItem, { item }, item.href);
|
|
4449
|
+
return /* @__PURE__ */ jsx27(NavLink, { to: item.href, end: item.href === "/", title: item.label, children: ({ isActive }) => /* @__PURE__ */ jsxs19(
|
|
4396
4450
|
Flex10,
|
|
4397
4451
|
{
|
|
4398
4452
|
align: "center",
|
|
@@ -4410,8 +4464,8 @@ function Sidebar({ app, menu, registry }) {
|
|
|
4410
4464
|
transition: "all 0.15s ease",
|
|
4411
4465
|
_hover: { bg: isActive ? "brand.50" : "#F8F9FA", color: "brand.700" },
|
|
4412
4466
|
children: [
|
|
4413
|
-
item.icon ? /* @__PURE__ */
|
|
4414
|
-
/* @__PURE__ */
|
|
4467
|
+
item.icon ? /* @__PURE__ */ jsx27(Box17, { flex: "0 0 auto", children: item.icon }) : /* @__PURE__ */ jsx27(Box17, { w: "7px", h: "7px", borderRadius: "full", bg: isActive ? "brand.500" : "gray.300" }),
|
|
4468
|
+
/* @__PURE__ */ jsx27(Text18, { display: { base: "none", lg: "block" }, lineClamp: 1, children: item.label })
|
|
4415
4469
|
]
|
|
4416
4470
|
}
|
|
4417
4471
|
) }, item.href);
|
|
@@ -4422,68 +4476,295 @@ function Sidebar({ app, menu, registry }) {
|
|
|
4422
4476
|
);
|
|
4423
4477
|
}
|
|
4424
4478
|
|
|
4479
|
+
// package.json
|
|
4480
|
+
var package_default = {
|
|
4481
|
+
name: "@oondemand/oon-core-front",
|
|
4482
|
+
version: "0.3.54",
|
|
4483
|
+
repository: {
|
|
4484
|
+
type: "git",
|
|
4485
|
+
url: "git+https://github.com/oondemand/oon-platform.git",
|
|
4486
|
+
directory: "packages/oonCore-front"
|
|
4487
|
+
},
|
|
4488
|
+
description: "Core de frontend para Centrais Oon: shell, providers, roteamento por metadata, SDK REST do /core/*, RBAC e componentes Core* (Cole\xE7\xE3o, Documento, Esteira, Multi-moedas, Assistente, Dashboard).",
|
|
4489
|
+
type: "module",
|
|
4490
|
+
main: "dist/index.js",
|
|
4491
|
+
module: "dist/index.js",
|
|
4492
|
+
types: "dist/index.d.ts",
|
|
4493
|
+
exports: {
|
|
4494
|
+
".": {
|
|
4495
|
+
types: "./dist/index.d.ts",
|
|
4496
|
+
import: "./dist/index.js"
|
|
4497
|
+
}
|
|
4498
|
+
},
|
|
4499
|
+
bin: {
|
|
4500
|
+
"oonCore-front": "bin/cli.js"
|
|
4501
|
+
},
|
|
4502
|
+
files: [
|
|
4503
|
+
"bin",
|
|
4504
|
+
"dist",
|
|
4505
|
+
"README.md"
|
|
4506
|
+
],
|
|
4507
|
+
scripts: {
|
|
4508
|
+
build: "tsup",
|
|
4509
|
+
prepublishOnly: "npm run build",
|
|
4510
|
+
typecheck: "tsc --noEmit",
|
|
4511
|
+
test: "vitest run"
|
|
4512
|
+
},
|
|
4513
|
+
engines: {
|
|
4514
|
+
node: ">=18"
|
|
4515
|
+
},
|
|
4516
|
+
keywords: [
|
|
4517
|
+
"oondemand",
|
|
4518
|
+
"ooncore",
|
|
4519
|
+
"central",
|
|
4520
|
+
"frontend",
|
|
4521
|
+
"metadata-driven",
|
|
4522
|
+
"react",
|
|
4523
|
+
"vite"
|
|
4524
|
+
],
|
|
4525
|
+
license: "SEE LICENSE IN LICENSE",
|
|
4526
|
+
publishConfig: {
|
|
4527
|
+
access: "public"
|
|
4528
|
+
},
|
|
4529
|
+
dependencies: {
|
|
4530
|
+
axios: "^1.7.7"
|
|
4531
|
+
},
|
|
4532
|
+
peerDependencies: {
|
|
4533
|
+
"@chakra-ui/react": "^3.0.0",
|
|
4534
|
+
"@tanstack/react-query": "^5.0.0",
|
|
4535
|
+
"@tanstack/react-table": "^8.0.0",
|
|
4536
|
+
react: "^18.0.0",
|
|
4537
|
+
"react-dom": "^18.0.0",
|
|
4538
|
+
"react-router-dom": "^6.0.0"
|
|
4539
|
+
},
|
|
4540
|
+
devDependencies: {
|
|
4541
|
+
"@testing-library/dom": "^10.4.1",
|
|
4542
|
+
"@testing-library/react": "^16.3.2",
|
|
4543
|
+
"@types/react": "^18.3.18",
|
|
4544
|
+
"@types/react-dom": "^18.3.5",
|
|
4545
|
+
"happy-dom": "^20.10.2",
|
|
4546
|
+
tsup: "^8.5.1",
|
|
4547
|
+
typescript: "^5.5.0",
|
|
4548
|
+
vitest: "^2.0.0"
|
|
4549
|
+
}
|
|
4550
|
+
};
|
|
4551
|
+
|
|
4552
|
+
// src/runtime/versionInfo.ts
|
|
4553
|
+
function value(...candidates) {
|
|
4554
|
+
return candidates.find((candidate) => typeof candidate === "string" && candidate.trim())?.trim();
|
|
4555
|
+
}
|
|
4556
|
+
function browserBuildEnvironment() {
|
|
4557
|
+
return import.meta.env ?? {};
|
|
4558
|
+
}
|
|
4559
|
+
function resolveRuntimeVersionInfo(app, metadata, environment = browserBuildEnvironment()) {
|
|
4560
|
+
const extended = metadata;
|
|
4561
|
+
const runtime = extended?.runtime;
|
|
4562
|
+
const deployment = runtime?.deployment;
|
|
4563
|
+
return {
|
|
4564
|
+
centralVersion: value(
|
|
4565
|
+
environment.VITE_OON_CENTRAL_VERSION,
|
|
4566
|
+
app.version,
|
|
4567
|
+
runtime?.central?.version
|
|
4568
|
+
),
|
|
4569
|
+
coreFrontVersion: package_default.version,
|
|
4570
|
+
coreBackVersion: value(runtime?.core?.backendVersion, metadata?.service?.version),
|
|
4571
|
+
updatedAt: value(
|
|
4572
|
+
environment.VITE_OON_BUILD_TIME,
|
|
4573
|
+
deployment?.builtAt,
|
|
4574
|
+
deployment?.startedAt
|
|
4575
|
+
),
|
|
4576
|
+
startedAt: deployment?.startedAt,
|
|
4577
|
+
commit: value(environment.VITE_OON_BUILD_COMMIT, deployment?.commit),
|
|
4578
|
+
releaseId: value(environment.VITE_OON_RELEASE_ID, deployment?.releaseId),
|
|
4579
|
+
environment: value(environment.VITE_OON_ENVIRONMENT, deployment?.environment)
|
|
4580
|
+
};
|
|
4581
|
+
}
|
|
4582
|
+
function formatRuntimeDate(valueToFormat) {
|
|
4583
|
+
if (!valueToFormat) return void 0;
|
|
4584
|
+
const date = new Date(valueToFormat);
|
|
4585
|
+
if (Number.isNaN(date.getTime())) return valueToFormat;
|
|
4586
|
+
return new Intl.DateTimeFormat("pt-BR", {
|
|
4587
|
+
day: "2-digit",
|
|
4588
|
+
month: "2-digit",
|
|
4589
|
+
year: "numeric",
|
|
4590
|
+
hour: "2-digit",
|
|
4591
|
+
minute: "2-digit",
|
|
4592
|
+
hour12: false
|
|
4593
|
+
}).format(date);
|
|
4594
|
+
}
|
|
4595
|
+
function shortCommit(commit) {
|
|
4596
|
+
if (!commit) return void 0;
|
|
4597
|
+
return commit.length > 8 ? commit.slice(0, 8) : commit;
|
|
4598
|
+
}
|
|
4599
|
+
|
|
4425
4600
|
// src/shell/DefaultShell.tsx
|
|
4426
|
-
import { jsx as
|
|
4601
|
+
import { jsx as jsx28, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
4427
4602
|
function CoreTopbar({ app }) {
|
|
4428
4603
|
const { user, logout } = useOonAuth();
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4604
|
+
const metadataQuery = useCoreMetadata();
|
|
4605
|
+
const runtime = resolveRuntimeVersionInfo(app, metadataQuery.data);
|
|
4606
|
+
const centralVersion = runtime.centralVersion ?? "n\xE3o informada";
|
|
4607
|
+
const backendVersion = metadataQuery.isLoading ? "carregando" : runtime.coreBackVersion ?? "indispon\xEDvel";
|
|
4608
|
+
const updatedAt = formatRuntimeDate(runtime.updatedAt);
|
|
4609
|
+
const commit = shortCommit(runtime.commit);
|
|
4610
|
+
const publicationParts = [
|
|
4611
|
+
updatedAt ? `Atualizado ${updatedAt}` : void 0,
|
|
4612
|
+
commit ? `commit ${commit}` : void 0,
|
|
4613
|
+
runtime.releaseId ? `release ${runtime.releaseId}` : void 0
|
|
4614
|
+
].filter(Boolean);
|
|
4615
|
+
const details = [
|
|
4616
|
+
`Central ${centralVersion}`,
|
|
4617
|
+
`OonCore front ${runtime.coreFrontVersion}`,
|
|
4618
|
+
`OonCore back ${backendVersion}`,
|
|
4619
|
+
runtime.environment ? `Ambiente ${runtime.environment}` : void 0,
|
|
4620
|
+
runtime.commit ? `Commit ${runtime.commit}` : void 0,
|
|
4621
|
+
runtime.releaseId ? `Release ${runtime.releaseId}` : void 0,
|
|
4622
|
+
runtime.startedAt ? `Backend iniciado ${formatRuntimeDate(runtime.startedAt)}` : void 0
|
|
4623
|
+
].filter(Boolean).join(" \xB7 ");
|
|
4624
|
+
return /* @__PURE__ */ jsxs20(
|
|
4625
|
+
Flex11,
|
|
4626
|
+
{
|
|
4627
|
+
as: "header",
|
|
4628
|
+
align: "center",
|
|
4629
|
+
minH: "64px",
|
|
4630
|
+
px: { base: 4, lg: 6 },
|
|
4631
|
+
py: 3,
|
|
4632
|
+
borderBottomWidth: "1px",
|
|
4633
|
+
borderColor: "#E8ECEF",
|
|
4634
|
+
bg: "rgba(255, 255, 255, 0.96)",
|
|
4635
|
+
backdropFilter: "blur(10px)",
|
|
4636
|
+
position: "sticky",
|
|
4637
|
+
top: 0,
|
|
4638
|
+
zIndex: 10,
|
|
4639
|
+
children: [
|
|
4640
|
+
/* @__PURE__ */ jsxs20(Box18, { minW: 0, title: details, children: [
|
|
4641
|
+
/* @__PURE__ */ jsx28(
|
|
4642
|
+
Text19,
|
|
4643
|
+
{
|
|
4644
|
+
fontSize: "xs",
|
|
4645
|
+
fontWeight: "600",
|
|
4646
|
+
color: "brand.500",
|
|
4647
|
+
textTransform: "uppercase",
|
|
4648
|
+
letterSpacing: "0.08em",
|
|
4649
|
+
children: "Central Oon"
|
|
4650
|
+
}
|
|
4651
|
+
),
|
|
4652
|
+
/* @__PURE__ */ jsx28(Text19, { fontSize: "sm", fontWeight: "600", color: "#24323A", children: app.title ?? app.name }),
|
|
4653
|
+
/* @__PURE__ */ jsxs20(Text19, { fontSize: "10px", color: "gray.600", lineHeight: "1.35", children: [
|
|
4654
|
+
"Central ",
|
|
4655
|
+
centralVersion,
|
|
4656
|
+
" \xB7 Front ",
|
|
4657
|
+
runtime.coreFrontVersion,
|
|
4658
|
+
" \xB7 Back ",
|
|
4659
|
+
backendVersion
|
|
4660
|
+
] }),
|
|
4661
|
+
publicationParts.length ? /* @__PURE__ */ jsx28(Text19, { fontSize: "10px", color: "gray.500", lineHeight: "1.35", children: publicationParts.join(" \xB7 ") }) : null
|
|
4662
|
+
] }),
|
|
4663
|
+
/* @__PURE__ */ jsx28(Spacer2, {}),
|
|
4664
|
+
user ? /* @__PURE__ */ jsxs20(Flex11, { align: "center", gap: 3, children: [
|
|
4665
|
+
/* @__PURE__ */ jsxs20(Box18, { textAlign: "right", display: { base: "none", md: "block" }, children: [
|
|
4666
|
+
/* @__PURE__ */ jsx28(Text19, { fontSize: "sm", fontWeight: "600", color: "#24323A", children: user.nome }),
|
|
4667
|
+
user.email ? /* @__PURE__ */ jsx28(Text19, { fontSize: "xs", color: "gray.500", children: user.email }) : null
|
|
4668
|
+
] }),
|
|
4669
|
+
/* @__PURE__ */ jsx28(
|
|
4670
|
+
Button11,
|
|
4671
|
+
{
|
|
4672
|
+
size: "sm",
|
|
4673
|
+
variant: "outline",
|
|
4674
|
+
colorPalette: "brand",
|
|
4675
|
+
borderRadius: "8px",
|
|
4676
|
+
onClick: logout,
|
|
4677
|
+
children: "Sair"
|
|
4678
|
+
}
|
|
4679
|
+
)
|
|
4680
|
+
] }) : null
|
|
4681
|
+
]
|
|
4682
|
+
}
|
|
4683
|
+
);
|
|
4443
4684
|
}
|
|
4444
|
-
function Slot({
|
|
4685
|
+
function Slot({
|
|
4686
|
+
name,
|
|
4687
|
+
slot,
|
|
4688
|
+
registry,
|
|
4689
|
+
app,
|
|
4690
|
+
menu
|
|
4691
|
+
}) {
|
|
4445
4692
|
if (slot === "none") return null;
|
|
4446
4693
|
if (slot?.startsWith("custom:")) {
|
|
4447
|
-
const
|
|
4448
|
-
return
|
|
4694
|
+
const Component = resolveComponent(registry, slot, "layoutSlots");
|
|
4695
|
+
return Component ? /* @__PURE__ */ jsx28(Component, { app, menu }) : /* @__PURE__ */ jsx28(MissingRenderer, { renderer: slot });
|
|
4696
|
+
}
|
|
4697
|
+
if (name === "sidebar") return /* @__PURE__ */ jsx28(Sidebar, { app, menu, registry });
|
|
4698
|
+
if (name === "topbar") return /* @__PURE__ */ jsx28(CoreTopbar, { app });
|
|
4699
|
+
if (name === "footer" && slot === "core") {
|
|
4700
|
+
return /* @__PURE__ */ jsx28(Box18, { as: "footer", px: 6, py: 4, color: "gray.500", fontSize: "xs", borderTopWidth: "1px", children: "OonCore" });
|
|
4449
4701
|
}
|
|
4450
|
-
if (name === "sidebar") return /* @__PURE__ */ jsx27(Sidebar, { app, menu, registry });
|
|
4451
|
-
if (name === "topbar") return /* @__PURE__ */ jsx27(CoreTopbar, { app });
|
|
4452
|
-
if (name === "footer" && slot === "core") return /* @__PURE__ */ jsx27(Box17, { as: "footer", px: 6, py: 4, color: "gray.500", fontSize: "xs", borderTopWidth: "1px", children: "OonCore" });
|
|
4453
4702
|
return null;
|
|
4454
4703
|
}
|
|
4455
|
-
function DefaultShell({
|
|
4704
|
+
function DefaultShell({
|
|
4705
|
+
app,
|
|
4706
|
+
menu,
|
|
4707
|
+
layout,
|
|
4708
|
+
registry
|
|
4709
|
+
}) {
|
|
4456
4710
|
const portal = layout?.shell === "portal" || layout?.shell === "content-only";
|
|
4457
4711
|
const mainPadding = portal ? { base: 4, lg: 10 } : { base: 4, lg: 6 };
|
|
4458
|
-
return /* @__PURE__ */
|
|
4459
|
-
/* @__PURE__ */
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4712
|
+
return /* @__PURE__ */ jsxs20(Flex11, { align: "stretch", minH: "100vh", bg: portal ? "white" : "#F8F9FA", children: [
|
|
4713
|
+
/* @__PURE__ */ jsx28(
|
|
4714
|
+
Slot,
|
|
4715
|
+
{
|
|
4716
|
+
name: "sidebar",
|
|
4717
|
+
slot: layout?.sidebar ?? "core",
|
|
4718
|
+
registry,
|
|
4719
|
+
app,
|
|
4720
|
+
menu
|
|
4721
|
+
}
|
|
4722
|
+
),
|
|
4723
|
+
/* @__PURE__ */ jsxs20(Flex11, { direction: "column", flex: "1", minW: 0, children: [
|
|
4724
|
+
/* @__PURE__ */ jsx28(
|
|
4725
|
+
Slot,
|
|
4726
|
+
{
|
|
4727
|
+
name: "topbar",
|
|
4728
|
+
slot: layout?.topbar ?? "core",
|
|
4729
|
+
registry,
|
|
4730
|
+
app,
|
|
4731
|
+
menu
|
|
4732
|
+
}
|
|
4733
|
+
),
|
|
4734
|
+
/* @__PURE__ */ jsx28(Slot, { name: "header", slot: layout?.header, registry, app, menu }),
|
|
4735
|
+
/* @__PURE__ */ jsx28(Box18, { as: "main", flex: "1", p: mainPadding, minW: 0, children: /* @__PURE__ */ jsx28(Box18, { maxW: portal ? "1180px" : "1680px", mx: "auto", children: /* @__PURE__ */ jsx28(Outlet, {}) }) }),
|
|
4736
|
+
/* @__PURE__ */ jsx28(
|
|
4737
|
+
Slot,
|
|
4738
|
+
{
|
|
4739
|
+
name: "footer",
|
|
4740
|
+
slot: layout?.footer ?? "none",
|
|
4741
|
+
registry,
|
|
4742
|
+
app,
|
|
4743
|
+
menu
|
|
4744
|
+
}
|
|
4745
|
+
)
|
|
4465
4746
|
] })
|
|
4466
4747
|
] });
|
|
4467
4748
|
}
|
|
4468
4749
|
function PortalShell(props) {
|
|
4469
|
-
return /* @__PURE__ */
|
|
4750
|
+
return /* @__PURE__ */ jsx28(DefaultShell, { ...props, layout: { ...props.layout, shell: "portal" } });
|
|
4470
4751
|
}
|
|
4471
4752
|
|
|
4472
4753
|
// src/shell/AuthenticatedLayout.tsx
|
|
4473
|
-
import { jsx as
|
|
4754
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
4474
4755
|
function AuthenticatedLayout({ app, menu, layout, registry }) {
|
|
4475
4756
|
if (layout?.shell?.startsWith("custom:")) {
|
|
4476
4757
|
const CustomShell = resolveComponent(registry, layout.shell, "layoutSlots");
|
|
4477
|
-
return CustomShell ? /* @__PURE__ */
|
|
4758
|
+
return CustomShell ? /* @__PURE__ */ jsx29(CustomShell, { app, menu, layout }) : /* @__PURE__ */ jsx29(MissingRenderer, { renderer: layout.shell });
|
|
4478
4759
|
}
|
|
4479
|
-
if (layout?.shell === "portal") return /* @__PURE__ */
|
|
4480
|
-
return /* @__PURE__ */
|
|
4760
|
+
if (layout?.shell === "portal") return /* @__PURE__ */ jsx29(PortalShell, { app, menu, layout, registry });
|
|
4761
|
+
return /* @__PURE__ */ jsx29(DefaultShell, { app, menu, layout, registry });
|
|
4481
4762
|
}
|
|
4482
4763
|
|
|
4483
4764
|
// src/security/AccessDeniedPage.tsx
|
|
4484
|
-
import { Box as
|
|
4765
|
+
import { Box as Box19, Button as Button12, Flex as Flex12, Heading as Heading9, Text as Text20, VStack } from "@chakra-ui/react";
|
|
4485
4766
|
import { useNavigate } from "react-router-dom";
|
|
4486
|
-
import { jsx as
|
|
4767
|
+
import { jsx as jsx30, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
4487
4768
|
function AccessDeniedPage({ app }) {
|
|
4488
4769
|
const { logout } = useOonAuth();
|
|
4489
4770
|
const navigate = useNavigate();
|
|
@@ -4491,8 +4772,8 @@ function AccessDeniedPage({ app }) {
|
|
|
4491
4772
|
logout();
|
|
4492
4773
|
navigate("/login", { replace: true });
|
|
4493
4774
|
}
|
|
4494
|
-
return /* @__PURE__ */
|
|
4495
|
-
|
|
4775
|
+
return /* @__PURE__ */ jsx30(Flex12, { minH: "100vh", align: "center", justify: "center", bg: "#F5F8FA", px: 4, children: /* @__PURE__ */ jsx30(
|
|
4776
|
+
Box19,
|
|
4496
4777
|
{
|
|
4497
4778
|
width: "100%",
|
|
4498
4779
|
maxW: "560px",
|
|
@@ -4502,9 +4783,9 @@ function AccessDeniedPage({ app }) {
|
|
|
4502
4783
|
borderRadius: "18px",
|
|
4503
4784
|
boxShadow: "0 24px 70px rgba(7, 38, 46, 0.10)",
|
|
4504
4785
|
p: { base: 6, md: 10 },
|
|
4505
|
-
children: /* @__PURE__ */
|
|
4506
|
-
/* @__PURE__ */
|
|
4507
|
-
|
|
4786
|
+
children: /* @__PURE__ */ jsxs21(VStack, { align: "stretch", gap: 6, children: [
|
|
4787
|
+
/* @__PURE__ */ jsx30(
|
|
4788
|
+
Box19,
|
|
4508
4789
|
{
|
|
4509
4790
|
width: "56px",
|
|
4510
4791
|
height: "56px",
|
|
@@ -4520,9 +4801,9 @@ function AccessDeniedPage({ app }) {
|
|
|
4520
4801
|
children: "!"
|
|
4521
4802
|
}
|
|
4522
4803
|
),
|
|
4523
|
-
/* @__PURE__ */
|
|
4524
|
-
/* @__PURE__ */
|
|
4525
|
-
|
|
4804
|
+
/* @__PURE__ */ jsxs21(Box19, { children: [
|
|
4805
|
+
/* @__PURE__ */ jsx30(
|
|
4806
|
+
Text20,
|
|
4526
4807
|
{
|
|
4527
4808
|
color: "#39BFED",
|
|
4528
4809
|
fontSize: "xs",
|
|
@@ -4532,14 +4813,14 @@ function AccessDeniedPage({ app }) {
|
|
|
4532
4813
|
children: "Acesso negado"
|
|
4533
4814
|
}
|
|
4534
4815
|
),
|
|
4535
|
-
/* @__PURE__ */
|
|
4536
|
-
/* @__PURE__ */
|
|
4816
|
+
/* @__PURE__ */ jsx30(Heading9, { mt: 2, size: "lg", color: "#07262E", children: "Voc\xEA n\xE3o possui permiss\xE3o para este aplicativo" }),
|
|
4817
|
+
/* @__PURE__ */ jsxs21(Text20, { mt: 3, color: "gray.600", children: [
|
|
4537
4818
|
"Seu usu\xE1rio foi autenticado, mas n\xE3o existe uma permiss\xE3o ativa para acessar ",
|
|
4538
4819
|
app.title ?? app.name,
|
|
4539
4820
|
". Solicite o acesso ao administrador da sua organiza\xE7\xE3o."
|
|
4540
4821
|
] })
|
|
4541
4822
|
] }),
|
|
4542
|
-
/* @__PURE__ */
|
|
4823
|
+
/* @__PURE__ */ jsx30(
|
|
4543
4824
|
Button12,
|
|
4544
4825
|
{
|
|
4545
4826
|
alignSelf: "flex-start",
|
|
@@ -4557,7 +4838,7 @@ function AccessDeniedPage({ app }) {
|
|
|
4557
4838
|
|
|
4558
4839
|
// src/security/AppAccessGuard.tsx
|
|
4559
4840
|
import { Navigate, useLocation } from "react-router-dom";
|
|
4560
|
-
import { Fragment as Fragment5, jsx as
|
|
4841
|
+
import { Fragment as Fragment5, jsx as jsx31 } from "react/jsx-runtime";
|
|
4561
4842
|
function loginRedirect(pathname, search) {
|
|
4562
4843
|
const destination = `${pathname}${search}`;
|
|
4563
4844
|
return `/login?redirect=${encodeURIComponent(destination)}`;
|
|
@@ -4565,9 +4846,9 @@ function loginRedirect(pathname, search) {
|
|
|
4565
4846
|
function AppAccessGuard({ children }) {
|
|
4566
4847
|
const { status, retry } = useOonAuth();
|
|
4567
4848
|
const location = useLocation();
|
|
4568
|
-
if (status === "loading") return /* @__PURE__ */
|
|
4849
|
+
if (status === "loading") return /* @__PURE__ */ jsx31(LoadingScreen, {});
|
|
4569
4850
|
if (status === "unauthenticated") {
|
|
4570
|
-
return /* @__PURE__ */
|
|
4851
|
+
return /* @__PURE__ */ jsx31(
|
|
4571
4852
|
Navigate,
|
|
4572
4853
|
{
|
|
4573
4854
|
to: loginRedirect(location.pathname, location.search),
|
|
@@ -4576,10 +4857,10 @@ function AppAccessGuard({ children }) {
|
|
|
4576
4857
|
);
|
|
4577
4858
|
}
|
|
4578
4859
|
if (status === "forbidden") {
|
|
4579
|
-
return /* @__PURE__ */
|
|
4860
|
+
return /* @__PURE__ */ jsx31(Navigate, { to: "/acesso-negado", replace: true });
|
|
4580
4861
|
}
|
|
4581
4862
|
if (status === "error") {
|
|
4582
|
-
return /* @__PURE__ */
|
|
4863
|
+
return /* @__PURE__ */ jsx31(
|
|
4583
4864
|
LoadingScreen,
|
|
4584
4865
|
{
|
|
4585
4866
|
message: "N\xE3o foi poss\xEDvel validar seu acesso. Tente novamente.",
|
|
@@ -4590,29 +4871,29 @@ function AppAccessGuard({ children }) {
|
|
|
4590
4871
|
}
|
|
4591
4872
|
);
|
|
4592
4873
|
}
|
|
4593
|
-
return /* @__PURE__ */
|
|
4874
|
+
return /* @__PURE__ */ jsx31(Fragment5, { children });
|
|
4594
4875
|
}
|
|
4595
4876
|
|
|
4596
4877
|
// src/security/LoginPage.tsx
|
|
4597
4878
|
import { useState as useState12 } from "react";
|
|
4598
4879
|
import {
|
|
4599
|
-
Box as
|
|
4880
|
+
Box as Box20,
|
|
4600
4881
|
Button as Button13,
|
|
4601
4882
|
Flex as Flex13,
|
|
4602
4883
|
Heading as Heading10,
|
|
4603
4884
|
Input as Input7,
|
|
4604
|
-
Text as
|
|
4885
|
+
Text as Text21,
|
|
4605
4886
|
VStack as VStack2
|
|
4606
4887
|
} from "@chakra-ui/react";
|
|
4607
4888
|
import { Navigate as Navigate2, useLocation as useLocation2 } from "react-router-dom";
|
|
4608
|
-
import { jsx as
|
|
4889
|
+
import { jsx as jsx32, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
4609
4890
|
function safeRedirect(search) {
|
|
4610
|
-
const
|
|
4611
|
-
if (!
|
|
4612
|
-
if (
|
|
4891
|
+
const value2 = new URLSearchParams(search).get("redirect") || "/";
|
|
4892
|
+
if (!value2.startsWith("/") || value2.startsWith("//")) return "/";
|
|
4893
|
+
if (value2.startsWith("/login") || value2.startsWith("/acesso-negado")) {
|
|
4613
4894
|
return "/";
|
|
4614
4895
|
}
|
|
4615
|
-
return
|
|
4896
|
+
return value2;
|
|
4616
4897
|
}
|
|
4617
4898
|
function LoginPage({ app }) {
|
|
4618
4899
|
const { status, login } = useOonAuth();
|
|
@@ -4623,10 +4904,10 @@ function LoginPage({ app }) {
|
|
|
4623
4904
|
const [message, setMessage] = useState12(null);
|
|
4624
4905
|
const redirect = safeRedirect(location.search);
|
|
4625
4906
|
if (status === "authenticated") {
|
|
4626
|
-
return /* @__PURE__ */
|
|
4907
|
+
return /* @__PURE__ */ jsx32(Navigate2, { to: redirect, replace: true });
|
|
4627
4908
|
}
|
|
4628
4909
|
if (status === "forbidden") {
|
|
4629
|
-
return /* @__PURE__ */
|
|
4910
|
+
return /* @__PURE__ */ jsx32(Navigate2, { to: "/acesso-negado", replace: true });
|
|
4630
4911
|
}
|
|
4631
4912
|
async function handleSubmit(event) {
|
|
4632
4913
|
event.preventDefault();
|
|
@@ -4644,8 +4925,8 @@ function LoginPage({ app }) {
|
|
|
4644
4925
|
setSubmitting(false);
|
|
4645
4926
|
}
|
|
4646
4927
|
}
|
|
4647
|
-
return /* @__PURE__ */
|
|
4648
|
-
|
|
4928
|
+
return /* @__PURE__ */ jsx32(Flex13, { minH: "100vh", align: "center", justify: "center", bg: "#F5F8FA", px: 4, children: /* @__PURE__ */ jsx32(
|
|
4929
|
+
Box20,
|
|
4649
4930
|
{
|
|
4650
4931
|
width: "100%",
|
|
4651
4932
|
maxW: "440px",
|
|
@@ -4655,10 +4936,10 @@ function LoginPage({ app }) {
|
|
|
4655
4936
|
borderRadius: "18px",
|
|
4656
4937
|
boxShadow: "0 24px 70px rgba(7, 38, 46, 0.10)",
|
|
4657
4938
|
p: { base: 6, md: 9 },
|
|
4658
|
-
children: /* @__PURE__ */
|
|
4659
|
-
/* @__PURE__ */
|
|
4660
|
-
/* @__PURE__ */
|
|
4661
|
-
|
|
4939
|
+
children: /* @__PURE__ */ jsx32("form", { onSubmit: handleSubmit, children: /* @__PURE__ */ jsxs22(VStack2, { align: "stretch", gap: 6, children: [
|
|
4940
|
+
/* @__PURE__ */ jsxs22(Box20, { children: [
|
|
4941
|
+
/* @__PURE__ */ jsx32(
|
|
4942
|
+
Text21,
|
|
4662
4943
|
{
|
|
4663
4944
|
color: "#39BFED",
|
|
4664
4945
|
fontSize: "xs",
|
|
@@ -4668,13 +4949,13 @@ function LoginPage({ app }) {
|
|
|
4668
4949
|
children: "Central Oon"
|
|
4669
4950
|
}
|
|
4670
4951
|
),
|
|
4671
|
-
/* @__PURE__ */
|
|
4672
|
-
/* @__PURE__ */
|
|
4952
|
+
/* @__PURE__ */ jsx32(Heading10, { mt: 2, size: "lg", color: "#07262E", children: app.title ?? app.name }),
|
|
4953
|
+
/* @__PURE__ */ jsx32(Text21, { mt: 2, color: "gray.600", fontSize: "sm", children: "Entre com seu usu\xE1rio autorizado para acessar este aplicativo." })
|
|
4673
4954
|
] }),
|
|
4674
|
-
/* @__PURE__ */
|
|
4675
|
-
/* @__PURE__ */
|
|
4676
|
-
/* @__PURE__ */
|
|
4677
|
-
/* @__PURE__ */
|
|
4955
|
+
/* @__PURE__ */ jsxs22(VStack2, { align: "stretch", gap: 4, children: [
|
|
4956
|
+
/* @__PURE__ */ jsxs22(Box20, { children: [
|
|
4957
|
+
/* @__PURE__ */ jsx32(Text21, { mb: 2, fontSize: "sm", fontWeight: "600", color: "#24323A", children: "E-mail" }),
|
|
4958
|
+
/* @__PURE__ */ jsx32(
|
|
4678
4959
|
Input7,
|
|
4679
4960
|
{
|
|
4680
4961
|
type: "email",
|
|
@@ -4686,9 +4967,9 @@ function LoginPage({ app }) {
|
|
|
4686
4967
|
}
|
|
4687
4968
|
)
|
|
4688
4969
|
] }),
|
|
4689
|
-
/* @__PURE__ */
|
|
4690
|
-
/* @__PURE__ */
|
|
4691
|
-
/* @__PURE__ */
|
|
4970
|
+
/* @__PURE__ */ jsxs22(Box20, { children: [
|
|
4971
|
+
/* @__PURE__ */ jsx32(Text21, { mb: 2, fontSize: "sm", fontWeight: "600", color: "#24323A", children: "Senha" }),
|
|
4972
|
+
/* @__PURE__ */ jsx32(
|
|
4692
4973
|
Input7,
|
|
4693
4974
|
{
|
|
4694
4975
|
type: "password",
|
|
@@ -4701,8 +4982,8 @@ function LoginPage({ app }) {
|
|
|
4701
4982
|
)
|
|
4702
4983
|
] })
|
|
4703
4984
|
] }),
|
|
4704
|
-
message ? /* @__PURE__ */
|
|
4705
|
-
|
|
4985
|
+
message ? /* @__PURE__ */ jsx32(
|
|
4986
|
+
Box20,
|
|
4706
4987
|
{
|
|
4707
4988
|
role: "alert",
|
|
4708
4989
|
borderRadius: "10px",
|
|
@@ -4714,7 +4995,7 @@ function LoginPage({ app }) {
|
|
|
4714
4995
|
children: message
|
|
4715
4996
|
}
|
|
4716
4997
|
) : null,
|
|
4717
|
-
/* @__PURE__ */
|
|
4998
|
+
/* @__PURE__ */ jsx32(
|
|
4718
4999
|
Button13,
|
|
4719
5000
|
{
|
|
4720
5001
|
type: "submit",
|
|
@@ -4732,8 +5013,8 @@ function LoginPage({ app }) {
|
|
|
4732
5013
|
|
|
4733
5014
|
// src/security/ActivationPage.tsx
|
|
4734
5015
|
import { useEffect as useEffect8, useState as useState13 } from "react";
|
|
4735
|
-
import { Box as
|
|
4736
|
-
import { Fragment as Fragment6, jsx as
|
|
5016
|
+
import { Box as Box21, Button as Button14, Heading as Heading11, Input as Input8, Text as Text22, VStack as VStack3 } from "@chakra-ui/react";
|
|
5017
|
+
import { Fragment as Fragment6, jsx as jsx33, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
4737
5018
|
function encodeBasicCredentials2(email, password) {
|
|
4738
5019
|
const bytes = new TextEncoder().encode(`${email}:${password}`);
|
|
4739
5020
|
let binary = "";
|
|
@@ -4867,12 +5148,12 @@ function ActivationPage() {
|
|
|
4867
5148
|
}
|
|
4868
5149
|
}
|
|
4869
5150
|
function renderField(field, values, setValues) {
|
|
4870
|
-
return /* @__PURE__ */
|
|
4871
|
-
/* @__PURE__ */
|
|
5151
|
+
return /* @__PURE__ */ jsxs23(Box21, { w: "100%", children: [
|
|
5152
|
+
/* @__PURE__ */ jsxs23(Text22, { fontWeight: "medium", children: [
|
|
4872
5153
|
field.label,
|
|
4873
5154
|
field.required ? " *" : ""
|
|
4874
5155
|
] }),
|
|
4875
|
-
/* @__PURE__ */
|
|
5156
|
+
/* @__PURE__ */ jsx33(
|
|
4876
5157
|
Input8,
|
|
4877
5158
|
{
|
|
4878
5159
|
type: field.type === "password" || field.type === "secret" ? "password" : field.type === "email" ? "email" : field.type === "url" ? "url" : field.type === "number" || field.type === "integer" ? "number" : "text",
|
|
@@ -4884,15 +5165,15 @@ function ActivationPage() {
|
|
|
4884
5165
|
onChange: (event) => setValues({ ...values, [field.name]: event.target.value })
|
|
4885
5166
|
}
|
|
4886
5167
|
),
|
|
4887
|
-
field.helpText ? /* @__PURE__ */
|
|
5168
|
+
field.helpText ? /* @__PURE__ */ jsx33(Text22, { fontSize: "sm", color: "gray.500", children: field.helpText }) : null
|
|
4888
5169
|
] }, field.name);
|
|
4889
5170
|
}
|
|
4890
5171
|
function renderDevLocalActivation() {
|
|
4891
|
-
return /* @__PURE__ */
|
|
4892
|
-
/* @__PURE__ */
|
|
4893
|
-
/* @__PURE__ */
|
|
4894
|
-
/* @__PURE__ */
|
|
4895
|
-
/* @__PURE__ */
|
|
5172
|
+
return /* @__PURE__ */ jsxs23(Fragment6, { children: [
|
|
5173
|
+
/* @__PURE__ */ jsx33(Text22, { color: "gray.700", children: "Entre com seu e-mail e senha para ativar esta Central em ambiente de desenvolvimento. Se o e-mail ainda n\xE3o existir na Central de Ativa\xE7\xF5es, o usu\xE1rio ser\xE1 criado automaticamente com perfil de desenvolvedor." }),
|
|
5174
|
+
/* @__PURE__ */ jsxs23(Box21, { w: "100%", children: [
|
|
5175
|
+
/* @__PURE__ */ jsx33(Text22, { fontWeight: "medium", children: "Nome do usu\xE1rio" }),
|
|
5176
|
+
/* @__PURE__ */ jsx33(
|
|
4896
5177
|
Input8,
|
|
4897
5178
|
{
|
|
4898
5179
|
value: devName,
|
|
@@ -4902,9 +5183,9 @@ function ActivationPage() {
|
|
|
4902
5183
|
}
|
|
4903
5184
|
)
|
|
4904
5185
|
] }),
|
|
4905
|
-
/* @__PURE__ */
|
|
4906
|
-
/* @__PURE__ */
|
|
4907
|
-
/* @__PURE__ */
|
|
5186
|
+
/* @__PURE__ */ jsxs23(Box21, { w: "100%", children: [
|
|
5187
|
+
/* @__PURE__ */ jsx33(Text22, { fontWeight: "medium", children: "E-mail *" }),
|
|
5188
|
+
/* @__PURE__ */ jsx33(
|
|
4908
5189
|
Input8,
|
|
4909
5190
|
{
|
|
4910
5191
|
type: "email",
|
|
@@ -4915,9 +5196,9 @@ function ActivationPage() {
|
|
|
4915
5196
|
}
|
|
4916
5197
|
)
|
|
4917
5198
|
] }),
|
|
4918
|
-
/* @__PURE__ */
|
|
4919
|
-
/* @__PURE__ */
|
|
4920
|
-
/* @__PURE__ */
|
|
5199
|
+
/* @__PURE__ */ jsxs23(Box21, { w: "100%", children: [
|
|
5200
|
+
/* @__PURE__ */ jsx33(Text22, { fontWeight: "medium", children: "Senha *" }),
|
|
5201
|
+
/* @__PURE__ */ jsx33(
|
|
4921
5202
|
Input8,
|
|
4922
5203
|
{
|
|
4923
5204
|
type: "password",
|
|
@@ -4929,7 +5210,7 @@ function ActivationPage() {
|
|
|
4929
5210
|
}
|
|
4930
5211
|
)
|
|
4931
5212
|
] }),
|
|
4932
|
-
/* @__PURE__ */
|
|
5213
|
+
/* @__PURE__ */ jsx33(
|
|
4933
5214
|
Button14,
|
|
4934
5215
|
{
|
|
4935
5216
|
colorPalette: "blue",
|
|
@@ -4939,7 +5220,7 @@ function ActivationPage() {
|
|
|
4939
5220
|
children: "Ativar ambiente de desenvolvimento"
|
|
4940
5221
|
}
|
|
4941
5222
|
),
|
|
4942
|
-
/* @__PURE__ */
|
|
5223
|
+
/* @__PURE__ */ jsx33(
|
|
4943
5224
|
Button14,
|
|
4944
5225
|
{
|
|
4945
5226
|
variant: "outline",
|
|
@@ -4953,7 +5234,7 @@ function ActivationPage() {
|
|
|
4953
5234
|
const rootMode = config?.mode === "root-bootstrap" || activation.details?.role === "root";
|
|
4954
5235
|
const isDevelopmentMember = !rootMode && config?.technical?.ambiente === "desenvolvimento";
|
|
4955
5236
|
if (activation.status === "loading" || !config) {
|
|
4956
|
-
return /* @__PURE__ */
|
|
5237
|
+
return /* @__PURE__ */ jsx33(Box21, { minH: "100vh", bg: "gray.50", p: 8, children: /* @__PURE__ */ jsxs23(
|
|
4957
5238
|
VStack3,
|
|
4958
5239
|
{
|
|
4959
5240
|
maxW: "760px",
|
|
@@ -4964,14 +5245,14 @@ function ActivationPage() {
|
|
|
4964
5245
|
align: "stretch",
|
|
4965
5246
|
gap: 5,
|
|
4966
5247
|
children: [
|
|
4967
|
-
/* @__PURE__ */
|
|
4968
|
-
error ? /* @__PURE__ */
|
|
5248
|
+
/* @__PURE__ */ jsx33(Heading11, { children: "Preparando ativa\xE7\xE3o..." }),
|
|
5249
|
+
error ? /* @__PURE__ */ jsx33(Text22, { color: "red.600", children: error }) : null
|
|
4969
5250
|
]
|
|
4970
5251
|
}
|
|
4971
5252
|
) });
|
|
4972
5253
|
}
|
|
4973
5254
|
if (rootMode) {
|
|
4974
|
-
return /* @__PURE__ */
|
|
5255
|
+
return /* @__PURE__ */ jsx33(Box21, { minH: "100vh", bg: "gray.50", p: 8, children: /* @__PURE__ */ jsxs23(
|
|
4975
5256
|
VStack3,
|
|
4976
5257
|
{
|
|
4977
5258
|
maxW: "560px",
|
|
@@ -4982,20 +5263,20 @@ function ActivationPage() {
|
|
|
4982
5263
|
align: "stretch",
|
|
4983
5264
|
gap: 5,
|
|
4984
5265
|
children: [
|
|
4985
|
-
/* @__PURE__ */
|
|
4986
|
-
/* @__PURE__ */
|
|
4987
|
-
/* @__PURE__ */
|
|
5266
|
+
/* @__PURE__ */ jsx33(Heading11, { children: "Ativa\xE7\xE3o inicial do Ecossistema Oon" }),
|
|
5267
|
+
/* @__PURE__ */ jsx33(Text22, { color: "gray.600", children: "Esta \xE9 a aplica\xE7\xE3o root do ecossistema. Informe somente o e-mail e a senha do primeiro administrador. O Core criar\xE1 a estrutura m\xEDnima necess\xE1ria para liberar o primeiro login." }),
|
|
5268
|
+
/* @__PURE__ */ jsxs23(Text22, { fontSize: "sm", color: "gray.500", children: [
|
|
4988
5269
|
"App: ",
|
|
4989
5270
|
config.technical.appCode,
|
|
4990
5271
|
" \xB7 Ambiente:",
|
|
4991
5272
|
" ",
|
|
4992
5273
|
config.technical.ambiente
|
|
4993
5274
|
] }),
|
|
4994
|
-
error ? /* @__PURE__ */
|
|
4995
|
-
step !== 6 ? /* @__PURE__ */
|
|
4996
|
-
/* @__PURE__ */
|
|
4997
|
-
/* @__PURE__ */
|
|
4998
|
-
/* @__PURE__ */
|
|
5275
|
+
error ? /* @__PURE__ */ jsx33(Text22, { color: "red.600", children: error }) : null,
|
|
5276
|
+
step !== 6 ? /* @__PURE__ */ jsxs23(Fragment6, { children: [
|
|
5277
|
+
/* @__PURE__ */ jsxs23(Box21, { w: "100%", children: [
|
|
5278
|
+
/* @__PURE__ */ jsx33(Text22, { fontWeight: "medium", children: "E-mail do administrador *" }),
|
|
5279
|
+
/* @__PURE__ */ jsx33(
|
|
4999
5280
|
Input8,
|
|
5000
5281
|
{
|
|
5001
5282
|
type: "email",
|
|
@@ -5006,9 +5287,9 @@ function ActivationPage() {
|
|
|
5006
5287
|
}
|
|
5007
5288
|
)
|
|
5008
5289
|
] }),
|
|
5009
|
-
/* @__PURE__ */
|
|
5010
|
-
/* @__PURE__ */
|
|
5011
|
-
/* @__PURE__ */
|
|
5290
|
+
/* @__PURE__ */ jsxs23(Box21, { w: "100%", children: [
|
|
5291
|
+
/* @__PURE__ */ jsx33(Text22, { fontWeight: "medium", children: "Senha *" }),
|
|
5292
|
+
/* @__PURE__ */ jsx33(
|
|
5012
5293
|
Input8,
|
|
5013
5294
|
{
|
|
5014
5295
|
type: "password",
|
|
@@ -5020,7 +5301,7 @@ function ActivationPage() {
|
|
|
5020
5301
|
}
|
|
5021
5302
|
)
|
|
5022
5303
|
] }),
|
|
5023
|
-
/* @__PURE__ */
|
|
5304
|
+
/* @__PURE__ */ jsx33(
|
|
5024
5305
|
Button14,
|
|
5025
5306
|
{
|
|
5026
5307
|
colorPalette: "blue",
|
|
@@ -5030,15 +5311,15 @@ function ActivationPage() {
|
|
|
5030
5311
|
children: "Criar ecossistema e ativar"
|
|
5031
5312
|
}
|
|
5032
5313
|
)
|
|
5033
|
-
] }) : /* @__PURE__ */
|
|
5034
|
-
/* @__PURE__ */
|
|
5035
|
-
/* @__PURE__ */
|
|
5314
|
+
] }) : /* @__PURE__ */ jsxs23(Fragment6, { children: [
|
|
5315
|
+
/* @__PURE__ */ jsx33(Heading11, { size: "md", children: "Ativa\xE7\xE3o conclu\xEDda" }),
|
|
5316
|
+
/* @__PURE__ */ jsx33(Text22, { children: "Usu\xE1rio, tenant, aplicativo, licen\xE7a e permiss\xF5es foram preparados. Redirecionando para o primeiro login..." })
|
|
5036
5317
|
] })
|
|
5037
5318
|
]
|
|
5038
5319
|
}
|
|
5039
5320
|
) });
|
|
5040
5321
|
}
|
|
5041
|
-
return /* @__PURE__ */
|
|
5322
|
+
return /* @__PURE__ */ jsx33(Box21, { minH: "100vh", bg: "gray.50", p: 8, children: /* @__PURE__ */ jsxs23(
|
|
5042
5323
|
VStack3,
|
|
5043
5324
|
{
|
|
5044
5325
|
maxW: "760px",
|
|
@@ -5049,8 +5330,8 @@ function ActivationPage() {
|
|
|
5049
5330
|
align: "stretch",
|
|
5050
5331
|
gap: 5,
|
|
5051
5332
|
children: [
|
|
5052
|
-
/* @__PURE__ */
|
|
5053
|
-
/* @__PURE__ */
|
|
5333
|
+
/* @__PURE__ */ jsx33(Heading11, { children: "Ativa\xE7\xE3o da Central Oon" }),
|
|
5334
|
+
/* @__PURE__ */ jsxs23(Text22, { children: [
|
|
5054
5335
|
"App: ",
|
|
5055
5336
|
config.technical.appCode,
|
|
5056
5337
|
" \xB7 Ambiente:",
|
|
@@ -5060,11 +5341,11 @@ function ActivationPage() {
|
|
|
5060
5341
|
" ",
|
|
5061
5342
|
config.technical.centralAtivacaoUrl || config.technical.centralAtivacaoHost
|
|
5062
5343
|
] }),
|
|
5063
|
-
error ? /* @__PURE__ */
|
|
5344
|
+
error ? /* @__PURE__ */ jsx33(Text22, { color: "red.600", children: error }) : null,
|
|
5064
5345
|
step === 1 && isDevelopmentMember && !showCodeFlow ? renderDevLocalActivation() : null,
|
|
5065
|
-
step === 1 && (!isDevelopmentMember || showCodeFlow) && /* @__PURE__ */
|
|
5066
|
-
/* @__PURE__ */
|
|
5067
|
-
/* @__PURE__ */
|
|
5346
|
+
step === 1 && (!isDevelopmentMember || showCodeFlow) && /* @__PURE__ */ jsxs23(Fragment6, { children: [
|
|
5347
|
+
/* @__PURE__ */ jsx33(Text22, { children: "Informe o c\xF3digo de ativa\xE7\xE3o para validar tenant, aplicativo e licen\xE7a antes de consumir o c\xF3digo." }),
|
|
5348
|
+
/* @__PURE__ */ jsx33(
|
|
5068
5349
|
Input8,
|
|
5069
5350
|
{
|
|
5070
5351
|
"aria-label": "C\xF3digo de ativa\xE7\xE3o",
|
|
@@ -5073,7 +5354,7 @@ function ActivationPage() {
|
|
|
5073
5354
|
placeholder: "OON-XXXX"
|
|
5074
5355
|
}
|
|
5075
5356
|
),
|
|
5076
|
-
/* @__PURE__ */
|
|
5357
|
+
/* @__PURE__ */ jsx33(
|
|
5077
5358
|
Button14,
|
|
5078
5359
|
{
|
|
5079
5360
|
onClick: validateCode,
|
|
@@ -5082,7 +5363,7 @@ function ActivationPage() {
|
|
|
5082
5363
|
children: "Validar c\xF3digo"
|
|
5083
5364
|
}
|
|
5084
5365
|
),
|
|
5085
|
-
isDevelopmentMember ? /* @__PURE__ */
|
|
5366
|
+
isDevelopmentMember ? /* @__PURE__ */ jsx33(
|
|
5086
5367
|
Button14,
|
|
5087
5368
|
{
|
|
5088
5369
|
variant: "outline",
|
|
@@ -5092,24 +5373,24 @@ function ActivationPage() {
|
|
|
5092
5373
|
}
|
|
5093
5374
|
) : null
|
|
5094
5375
|
] }),
|
|
5095
|
-
step === 2 && /* @__PURE__ */
|
|
5096
|
-
/* @__PURE__ */
|
|
5097
|
-
/* @__PURE__ */
|
|
5098
|
-
/* @__PURE__ */
|
|
5376
|
+
step === 2 && /* @__PURE__ */ jsxs23(Fragment6, { children: [
|
|
5377
|
+
/* @__PURE__ */ jsx33(Heading11, { size: "md", children: "Confirma\xE7\xE3o" }),
|
|
5378
|
+
/* @__PURE__ */ jsx33("pre", { children: JSON.stringify(preview, null, 2) }),
|
|
5379
|
+
/* @__PURE__ */ jsx33(Button14, { onClick: () => setStep(3), children: "Continuar" })
|
|
5099
5380
|
] }),
|
|
5100
|
-
step === 3 && /* @__PURE__ */
|
|
5381
|
+
step === 3 && /* @__PURE__ */ jsxs23(Fragment6, { children: [
|
|
5101
5382
|
config.globalFields.map(
|
|
5102
5383
|
(field) => renderField(field, global, setGlobal)
|
|
5103
5384
|
),
|
|
5104
|
-
/* @__PURE__ */
|
|
5385
|
+
/* @__PURE__ */ jsx33(Button14, { onClick: () => setStep(4), children: "Continuar" })
|
|
5105
5386
|
] }),
|
|
5106
|
-
step === 4 && /* @__PURE__ */
|
|
5107
|
-
config.appFields.length ? config.appFields.map((field) => renderField(field, app, setApp)) : /* @__PURE__ */
|
|
5108
|
-
/* @__PURE__ */
|
|
5387
|
+
step === 4 && /* @__PURE__ */ jsxs23(Fragment6, { children: [
|
|
5388
|
+
config.appFields.length ? config.appFields.map((field) => renderField(field, app, setApp)) : /* @__PURE__ */ jsx33(Text22, { children: "Nenhum par\xE2metro adicional declarado." }),
|
|
5389
|
+
/* @__PURE__ */ jsx33(Button14, { onClick: () => setStep(5), children: "Revisar" })
|
|
5109
5390
|
] }),
|
|
5110
|
-
step === 5 && /* @__PURE__ */
|
|
5111
|
-
/* @__PURE__ */
|
|
5112
|
-
/* @__PURE__ */
|
|
5391
|
+
step === 5 && /* @__PURE__ */ jsxs23(Fragment6, { children: [
|
|
5392
|
+
/* @__PURE__ */ jsx33(Text22, { children: "Ao confirmar, o c\xF3digo ser\xE1 consumido e a inst\xE2ncia ser\xE1 registrada no Ecossistema Oon." }),
|
|
5393
|
+
/* @__PURE__ */ jsx33(
|
|
5113
5394
|
Button14,
|
|
5114
5395
|
{
|
|
5115
5396
|
colorPalette: "blue",
|
|
@@ -5120,14 +5401,14 @@ function ActivationPage() {
|
|
|
5120
5401
|
}
|
|
5121
5402
|
)
|
|
5122
5403
|
] }),
|
|
5123
|
-
step === 6 && /* @__PURE__ */
|
|
5124
|
-
/* @__PURE__ */
|
|
5125
|
-
devResult?.appCode ? /* @__PURE__ */
|
|
5404
|
+
step === 6 && /* @__PURE__ */ jsxs23(Fragment6, { children: [
|
|
5405
|
+
/* @__PURE__ */ jsx33(Heading11, { size: "md", children: "Ativa\xE7\xE3o conclu\xEDda" }),
|
|
5406
|
+
devResult?.appCode ? /* @__PURE__ */ jsxs23(Text22, { children: [
|
|
5126
5407
|
"C\xF3digo do app: ",
|
|
5127
5408
|
devResult.appCode,
|
|
5128
5409
|
". Redirecionando para a Central em desenvolvimento..."
|
|
5129
|
-
] }) : /* @__PURE__ */
|
|
5130
|
-
devResult?.instrucoes?.env ? /* @__PURE__ */
|
|
5410
|
+
] }) : /* @__PURE__ */ jsx33(Text22, { children: "Redirecionando para o login..." }),
|
|
5411
|
+
devResult?.instrucoes?.env ? /* @__PURE__ */ jsx33(Text22, { fontSize: "sm", color: "gray.500", children: devResult.instrucoes.env }) : null
|
|
5131
5412
|
] })
|
|
5132
5413
|
]
|
|
5133
5414
|
}
|
|
@@ -5137,47 +5418,47 @@ function InstanceBlockedPage({
|
|
|
5137
5418
|
title,
|
|
5138
5419
|
message
|
|
5139
5420
|
}) {
|
|
5140
|
-
return /* @__PURE__ */
|
|
5141
|
-
/* @__PURE__ */
|
|
5142
|
-
/* @__PURE__ */
|
|
5421
|
+
return /* @__PURE__ */ jsxs23(Box21, { p: 8, children: [
|
|
5422
|
+
/* @__PURE__ */ jsx33(Heading11, { children: title }),
|
|
5423
|
+
/* @__PURE__ */ jsx33(Text22, { children: message })
|
|
5143
5424
|
] });
|
|
5144
5425
|
}
|
|
5145
5426
|
|
|
5146
5427
|
// src/security/RouteGuard.tsx
|
|
5147
|
-
import { Fragment as Fragment7, jsx as
|
|
5428
|
+
import { Fragment as Fragment7, jsx as jsx34 } from "react/jsx-runtime";
|
|
5148
5429
|
function RouteGuard({
|
|
5149
5430
|
permission,
|
|
5150
5431
|
children
|
|
5151
5432
|
}) {
|
|
5152
5433
|
const { status, hasPermission } = useOonAuth();
|
|
5153
|
-
if (status === "loading") return /* @__PURE__ */
|
|
5154
|
-
if (status === "unauthenticated") return /* @__PURE__ */
|
|
5434
|
+
if (status === "loading") return /* @__PURE__ */ jsx34(LoadingScreen, {});
|
|
5435
|
+
if (status === "unauthenticated") return /* @__PURE__ */ jsx34(LoadingScreen, { message: "Redirecionando para o login..." });
|
|
5155
5436
|
if (!hasPermission(permission)) {
|
|
5156
|
-
return /* @__PURE__ */
|
|
5437
|
+
return /* @__PURE__ */ jsx34(LoadingScreen, { message: "Voc\xEA n\xE3o tem acesso a esta tela." });
|
|
5157
5438
|
}
|
|
5158
|
-
return /* @__PURE__ */
|
|
5439
|
+
return /* @__PURE__ */ jsx34(Fragment7, { children });
|
|
5159
5440
|
}
|
|
5160
5441
|
|
|
5161
5442
|
// src/security/ActivationGuard.tsx
|
|
5162
5443
|
import { Navigate as Navigate3 } from "react-router-dom";
|
|
5163
|
-
import { jsx as
|
|
5444
|
+
import { jsx as jsx35 } from "react/jsx-runtime";
|
|
5164
5445
|
function ActivationGuard({ children }) {
|
|
5165
5446
|
const { status } = useActivation();
|
|
5166
5447
|
if (status === "loading") return null;
|
|
5167
|
-
if (status === "suspended") return /* @__PURE__ */
|
|
5168
|
-
if (status === "revoked") return /* @__PURE__ */
|
|
5169
|
-
if (status !== "active" && window.location.pathname !== "/ativacao") return /* @__PURE__ */
|
|
5448
|
+
if (status === "suspended") return /* @__PURE__ */ jsx35(Navigate3, { to: "/instancia-suspensa", replace: true });
|
|
5449
|
+
if (status === "revoked") return /* @__PURE__ */ jsx35(Navigate3, { to: "/instancia-revogada", replace: true });
|
|
5450
|
+
if (status !== "active" && window.location.pathname !== "/ativacao") return /* @__PURE__ */ jsx35(Navigate3, { to: "/ativacao", replace: true });
|
|
5170
5451
|
return children;
|
|
5171
5452
|
}
|
|
5172
5453
|
|
|
5173
5454
|
// src/app/createOonRouter.tsx
|
|
5174
|
-
import { jsx as
|
|
5455
|
+
import { jsx as jsx36 } from "react/jsx-runtime";
|
|
5175
5456
|
function createOonRouter({ app, menu, routes, security, layout, registry }) {
|
|
5176
5457
|
const guardEnabled = security?.enableRouteGuard !== false;
|
|
5177
5458
|
const publicRoutes = routes.filter((route) => route.public).map((route) => ({ path: route.path, element: route.element }));
|
|
5178
5459
|
const privateSource = routes.filter((route) => !route.public);
|
|
5179
5460
|
const privateRoutes = privateSource.map((route) => {
|
|
5180
|
-
const element = guardEnabled ? /* @__PURE__ */
|
|
5461
|
+
const element = guardEnabled ? /* @__PURE__ */ jsx36(RouteGuard, { permission: route.permissions, children: route.element }) : route.element;
|
|
5181
5462
|
return route.path === "/" ? { index: true, element } : { path: route.path.replace(/^\//, ""), element };
|
|
5182
5463
|
});
|
|
5183
5464
|
const hasIndexRoute = privateSource.some((route) => route.path === "/");
|
|
@@ -5185,7 +5466,7 @@ function createOonRouter({ app, menu, routes, security, layout, registry }) {
|
|
|
5185
5466
|
if (!hasIndexRoute && firstRoute) {
|
|
5186
5467
|
privateRoutes.unshift({
|
|
5187
5468
|
index: true,
|
|
5188
|
-
element: /* @__PURE__ */
|
|
5469
|
+
element: /* @__PURE__ */ jsx36(Navigate4, { to: firstRoute.path, replace: true })
|
|
5189
5470
|
});
|
|
5190
5471
|
}
|
|
5191
5472
|
const customPaths = new Set(publicRoutes.map((route) => route.path));
|
|
@@ -5193,19 +5474,19 @@ function createOonRouter({ app, menu, routes, security, layout, registry }) {
|
|
|
5193
5474
|
if (!customPaths.has("/login")) {
|
|
5194
5475
|
builtInPublicRoutes.push({
|
|
5195
5476
|
path: "/login",
|
|
5196
|
-
element: /* @__PURE__ */
|
|
5477
|
+
element: /* @__PURE__ */ jsx36(ActivationGuard, { children: /* @__PURE__ */ jsx36(LoginPage, { app }) })
|
|
5197
5478
|
});
|
|
5198
5479
|
}
|
|
5199
5480
|
if (!customPaths.has("/ativacao")) {
|
|
5200
5481
|
builtInPublicRoutes.push({
|
|
5201
5482
|
path: "/ativacao",
|
|
5202
|
-
element: /* @__PURE__ */
|
|
5483
|
+
element: /* @__PURE__ */ jsx36(ActivationPage, {})
|
|
5203
5484
|
});
|
|
5204
5485
|
}
|
|
5205
5486
|
if (!customPaths.has("/instancia-suspensa")) {
|
|
5206
5487
|
builtInPublicRoutes.push({
|
|
5207
5488
|
path: "/instancia-suspensa",
|
|
5208
|
-
element: /* @__PURE__ */
|
|
5489
|
+
element: /* @__PURE__ */ jsx36(
|
|
5209
5490
|
InstanceBlockedPage,
|
|
5210
5491
|
{
|
|
5211
5492
|
title: "Inst\xE2ncia suspensa",
|
|
@@ -5217,7 +5498,7 @@ function createOonRouter({ app, menu, routes, security, layout, registry }) {
|
|
|
5217
5498
|
if (!customPaths.has("/instancia-revogada")) {
|
|
5218
5499
|
builtInPublicRoutes.push({
|
|
5219
5500
|
path: "/instancia-revogada",
|
|
5220
|
-
element: /* @__PURE__ */
|
|
5501
|
+
element: /* @__PURE__ */ jsx36(
|
|
5221
5502
|
InstanceBlockedPage,
|
|
5222
5503
|
{
|
|
5223
5504
|
title: "Inst\xE2ncia revogada",
|
|
@@ -5229,7 +5510,7 @@ function createOonRouter({ app, menu, routes, security, layout, registry }) {
|
|
|
5229
5510
|
if (!customPaths.has("/acesso-negado")) {
|
|
5230
5511
|
builtInPublicRoutes.push({
|
|
5231
5512
|
path: "/acesso-negado",
|
|
5232
|
-
element: /* @__PURE__ */
|
|
5513
|
+
element: /* @__PURE__ */ jsx36(AccessDeniedPage, { app })
|
|
5233
5514
|
});
|
|
5234
5515
|
}
|
|
5235
5516
|
const tree = [
|
|
@@ -5237,7 +5518,7 @@ function createOonRouter({ app, menu, routes, security, layout, registry }) {
|
|
|
5237
5518
|
...publicRoutes,
|
|
5238
5519
|
{
|
|
5239
5520
|
path: "/",
|
|
5240
|
-
element: /* @__PURE__ */
|
|
5521
|
+
element: /* @__PURE__ */ jsx36(ActivationGuard, { children: /* @__PURE__ */ jsx36(AppAccessGuard, { children: /* @__PURE__ */ jsx36(AuthenticatedLayout, { app, menu, layout, registry }) }) }),
|
|
5241
5522
|
children: privateRoutes
|
|
5242
5523
|
}
|
|
5243
5524
|
];
|
|
@@ -5245,7 +5526,7 @@ function createOonRouter({ app, menu, routes, security, layout, registry }) {
|
|
|
5245
5526
|
}
|
|
5246
5527
|
|
|
5247
5528
|
// src/app/OonApp.tsx
|
|
5248
|
-
import { jsx as
|
|
5529
|
+
import { jsx as jsx37 } from "react/jsx-runtime";
|
|
5249
5530
|
function localLoginUrl() {
|
|
5250
5531
|
const current = `${window.location.pathname}${window.location.search}`;
|
|
5251
5532
|
return `/login?redirect=${encodeURIComponent(current)}`;
|
|
@@ -5280,7 +5561,7 @@ function OonApp({ config }) {
|
|
|
5280
5561
|
});
|
|
5281
5562
|
return { http: http2, storage: storage2, router: router2 };
|
|
5282
5563
|
}, [config]);
|
|
5283
|
-
return /* @__PURE__ */
|
|
5564
|
+
return /* @__PURE__ */ jsx37(OonProviders, { config, http, storage, children: /* @__PURE__ */ jsx37(RouterProvider, { router }) });
|
|
5284
5565
|
}
|
|
5285
5566
|
|
|
5286
5567
|
// src/components/internal/pipelineBoardLayout.ts
|
|
@@ -5338,7 +5619,7 @@ function installPipelineBoardLayoutStyles(targetDocument = document) {
|
|
|
5338
5619
|
}
|
|
5339
5620
|
|
|
5340
5621
|
// src/start.tsx
|
|
5341
|
-
import { jsx as
|
|
5622
|
+
import { jsx as jsx38 } from "react/jsx-runtime";
|
|
5342
5623
|
function validateConfig(config) {
|
|
5343
5624
|
if (!config?.app?.id) throw new Error("oonCoreFront.start: config.app.id \xE9 obrigat\xF3rio.");
|
|
5344
5625
|
if (!config?.api?.baseUrl) throw new Error("oonCoreFront.start: config.api.baseUrl \xE9 obrigat\xF3rio.");
|
|
@@ -5373,7 +5654,7 @@ function start(config) {
|
|
|
5373
5654
|
const el = document.getElementById(rootId);
|
|
5374
5655
|
if (!el) throw new Error(`oonCoreFront.start: elemento #${rootId} n\xE3o encontrado no DOM.`);
|
|
5375
5656
|
createRoot(el).render(
|
|
5376
|
-
/* @__PURE__ */
|
|
5657
|
+
/* @__PURE__ */ jsx38(StrictMode, { children: /* @__PURE__ */ jsx38(OonApp, { config }) })
|
|
5377
5658
|
);
|
|
5378
5659
|
}
|
|
5379
5660
|
var oonCoreFront = { start };
|
|
@@ -5531,34 +5812,34 @@ function defineOonModule(mod) {
|
|
|
5531
5812
|
}
|
|
5532
5813
|
|
|
5533
5814
|
// src/components/CoreIntegration.tsx
|
|
5534
|
-
import { Badge as Badge5, Box as
|
|
5815
|
+
import { Badge as Badge5, Box as Box22, Button as Button15, Flex as Flex14, Heading as Heading12, Stack as Stack9, Text as Text23 } from "@chakra-ui/react";
|
|
5535
5816
|
import { useMutation as useMutation4 } from "@tanstack/react-query";
|
|
5536
|
-
import { jsx as
|
|
5817
|
+
import { jsx as jsx39, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
5537
5818
|
function CoreIntegration({ label = "Integra\xE7\xF5es" }) {
|
|
5538
5819
|
const { http } = useOonApi();
|
|
5539
5820
|
const metadata = useCoreMetadata();
|
|
5540
5821
|
const reprocess = useMutation4({
|
|
5541
5822
|
mutationFn: () => http.post("/integrations/actions/process-active", {}, { headers: { "x-oon-origin": "integration" } })
|
|
5542
5823
|
});
|
|
5543
|
-
if (metadata.isLoading) return /* @__PURE__ */
|
|
5544
|
-
if (metadata.isError) return /* @__PURE__ */
|
|
5824
|
+
if (metadata.isLoading) return /* @__PURE__ */ jsx39(LoadingScreen, {});
|
|
5825
|
+
if (metadata.isError) return /* @__PURE__ */ jsx39(ErrorState, { error: metadata.error });
|
|
5545
5826
|
const integrations = metadata.data?.integrations ?? [];
|
|
5546
|
-
return /* @__PURE__ */
|
|
5547
|
-
/* @__PURE__ */
|
|
5548
|
-
/* @__PURE__ */
|
|
5549
|
-
/* @__PURE__ */
|
|
5827
|
+
return /* @__PURE__ */ jsxs24(Stack9, { gap: 6, children: [
|
|
5828
|
+
/* @__PURE__ */ jsxs24(Flex14, { align: "center", justify: "space-between", children: [
|
|
5829
|
+
/* @__PURE__ */ jsx39(Heading12, { size: "lg", children: label }),
|
|
5830
|
+
/* @__PURE__ */ jsx39(Button15, { size: "sm", variant: "outline", loading: reprocess.isPending, onClick: () => reprocess.mutate(), children: "Reprocessar ativos" })
|
|
5550
5831
|
] }),
|
|
5551
|
-
/* @__PURE__ */
|
|
5552
|
-
|
|
5832
|
+
/* @__PURE__ */ jsx39(Stack9, { gap: 3, children: integrations.length === 0 ? /* @__PURE__ */ jsx39(Text23, { color: "gray.400", children: "Nenhuma integra\xE7\xE3o declarada." }) : integrations.map((it, idx) => /* @__PURE__ */ jsx39(
|
|
5833
|
+
Box22,
|
|
5553
5834
|
{
|
|
5554
5835
|
borderWidth: "1px",
|
|
5555
5836
|
borderColor: "gray.200",
|
|
5556
5837
|
borderRadius: "md",
|
|
5557
5838
|
bg: "white",
|
|
5558
5839
|
p: 4,
|
|
5559
|
-
children: /* @__PURE__ */
|
|
5560
|
-
/* @__PURE__ */
|
|
5561
|
-
/* @__PURE__ */
|
|
5840
|
+
children: /* @__PURE__ */ jsxs24(Flex14, { align: "center", justify: "space-between", children: [
|
|
5841
|
+
/* @__PURE__ */ jsx39(Text23, { fontWeight: "medium", children: it.label ?? it.name ?? "Integra\xE7\xE3o" }),
|
|
5842
|
+
/* @__PURE__ */ jsx39(Badge5, { colorPalette: it.status === "erro" ? "red" : it.status === "ativo" ? "green" : "gray", children: it.status ?? "\u2014" })
|
|
5562
5843
|
] })
|
|
5563
5844
|
},
|
|
5564
5845
|
it.id ?? it.name ?? idx
|
|
@@ -5567,9 +5848,9 @@ function CoreIntegration({ label = "Integra\xE7\xF5es" }) {
|
|
|
5567
5848
|
}
|
|
5568
5849
|
|
|
5569
5850
|
// src/components/CoreCurrency.tsx
|
|
5570
|
-
import { Button as Button16, Flex as Flex15, Heading as Heading13, Stack as Stack10, Text as
|
|
5851
|
+
import { Button as Button16, Flex as Flex15, Heading as Heading13, Stack as Stack10, Text as Text24 } from "@chakra-ui/react";
|
|
5571
5852
|
import { useMutation as useMutation5, useQueryClient as useQueryClient5 } from "@tanstack/react-query";
|
|
5572
|
-
import { jsx as
|
|
5853
|
+
import { jsx as jsx40, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
5573
5854
|
function CoreCurrency({ model = "Moeda", label = "Multi-moedas", endpoint = "/moedas", columns }) {
|
|
5574
5855
|
const { http } = useOonApi();
|
|
5575
5856
|
const queryClient = useQueryClient5();
|
|
@@ -5577,21 +5858,21 @@ function CoreCurrency({ model = "Moeda", label = "Multi-moedas", endpoint = "/mo
|
|
|
5577
5858
|
mutationFn: () => http.post(`${endpoint}/actions/update-rates`, {}, { headers: { "x-oon-origin": "integration" } }),
|
|
5578
5859
|
onSuccess: () => queryClient.invalidateQueries({ queryKey: ["oon", "list", endpoint] })
|
|
5579
5860
|
});
|
|
5580
|
-
return /* @__PURE__ */
|
|
5581
|
-
/* @__PURE__ */
|
|
5582
|
-
/* @__PURE__ */
|
|
5583
|
-
/* @__PURE__ */
|
|
5861
|
+
return /* @__PURE__ */ jsxs25(Stack10, { gap: 6, children: [
|
|
5862
|
+
/* @__PURE__ */ jsxs25(Flex15, { align: "center", justify: "space-between", children: [
|
|
5863
|
+
/* @__PURE__ */ jsx40(Heading13, { size: "lg", children: label }),
|
|
5864
|
+
/* @__PURE__ */ jsx40(Button16, { size: "sm", colorPalette: "blue", loading: updateRates.isPending, onClick: () => updateRates.mutate(), children: "Atualizar cota\xE7\xF5es" })
|
|
5584
5865
|
] }),
|
|
5585
|
-
updateRates.isError ? /* @__PURE__ */
|
|
5586
|
-
/* @__PURE__ */
|
|
5866
|
+
updateRates.isError ? /* @__PURE__ */ jsx40(Text24, { fontSize: "sm", color: "red.600", children: updateRates.error?.message }) : null,
|
|
5867
|
+
/* @__PURE__ */ jsx40(CoreCollection, { model, label: "", mode: columns ? "full" : "dynamic", endpoint, columns })
|
|
5587
5868
|
] });
|
|
5588
5869
|
}
|
|
5589
5870
|
|
|
5590
5871
|
// src/components/CoreAssistant.tsx
|
|
5591
5872
|
import { useState as useState14 } from "react";
|
|
5592
|
-
import { Box as
|
|
5873
|
+
import { Box as Box23, Button as Button17, Flex as Flex16, Heading as Heading14, Input as Input9, Stack as Stack11, Text as Text25 } from "@chakra-ui/react";
|
|
5593
5874
|
import { useMutation as useMutation6 } from "@tanstack/react-query";
|
|
5594
|
-
import { jsx as
|
|
5875
|
+
import { jsx as jsx41, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
5595
5876
|
function CoreAssistant({ assistantCode, label = "Assistente", entity, endpoint = "/assistant-runs" }) {
|
|
5596
5877
|
const { http } = useOonApi();
|
|
5597
5878
|
const [messages, setMessages] = useState14([]);
|
|
@@ -5620,11 +5901,11 @@ function CoreAssistant({ assistantCode, label = "Assistente", entity, endpoint =
|
|
|
5620
5901
|
setInput("");
|
|
5621
5902
|
ask.mutate(text);
|
|
5622
5903
|
};
|
|
5623
|
-
return /* @__PURE__ */
|
|
5624
|
-
/* @__PURE__ */
|
|
5625
|
-
/* @__PURE__ */
|
|
5626
|
-
messages.length === 0 ? /* @__PURE__ */
|
|
5627
|
-
|
|
5904
|
+
return /* @__PURE__ */ jsxs26(Stack11, { gap: 4, maxW: "560px", children: [
|
|
5905
|
+
/* @__PURE__ */ jsx41(Heading14, { size: "md", children: label }),
|
|
5906
|
+
/* @__PURE__ */ jsx41(Box23, { borderWidth: "1px", borderColor: "gray.200", borderRadius: "md", bg: "white", p: 4, minH: "240px", children: /* @__PURE__ */ jsxs26(Stack11, { gap: 3, children: [
|
|
5907
|
+
messages.length === 0 ? /* @__PURE__ */ jsx41(Text25, { color: "gray.400", fontSize: "sm", children: "Fa\xE7a uma pergunta ao assistente." }) : messages.map((m, idx) => /* @__PURE__ */ jsx41(Flex16, { justify: m.role === "user" ? "flex-end" : "flex-start", children: /* @__PURE__ */ jsx41(
|
|
5908
|
+
Box23,
|
|
5628
5909
|
{
|
|
5629
5910
|
bg: m.role === "user" ? "brand.500" : "gray.100",
|
|
5630
5911
|
color: m.role === "user" ? "white" : "gray.800",
|
|
@@ -5636,11 +5917,11 @@ function CoreAssistant({ assistantCode, label = "Assistente", entity, endpoint =
|
|
|
5636
5917
|
children: m.content
|
|
5637
5918
|
}
|
|
5638
5919
|
) }, idx)),
|
|
5639
|
-
ask.isPending ? /* @__PURE__ */
|
|
5640
|
-
ask.isError ? /* @__PURE__ */
|
|
5920
|
+
ask.isPending ? /* @__PURE__ */ jsx41(Text25, { color: "gray.400", fontSize: "sm", children: "Pensando\u2026" }) : null,
|
|
5921
|
+
ask.isError ? /* @__PURE__ */ jsx41(Text25, { color: "red.600", fontSize: "sm", children: ask.error?.message }) : null
|
|
5641
5922
|
] }) }),
|
|
5642
|
-
/* @__PURE__ */
|
|
5643
|
-
/* @__PURE__ */
|
|
5923
|
+
/* @__PURE__ */ jsxs26(Flex16, { gap: 2, children: [
|
|
5924
|
+
/* @__PURE__ */ jsx41(
|
|
5644
5925
|
Input9,
|
|
5645
5926
|
{
|
|
5646
5927
|
size: "sm",
|
|
@@ -5652,7 +5933,7 @@ function CoreAssistant({ assistantCode, label = "Assistente", entity, endpoint =
|
|
|
5652
5933
|
}
|
|
5653
5934
|
}
|
|
5654
5935
|
),
|
|
5655
|
-
/* @__PURE__ */
|
|
5936
|
+
/* @__PURE__ */ jsx41(Button17, { size: "sm", colorPalette: "blue", onClick: send, loading: ask.isPending, children: "Enviar" })
|
|
5656
5937
|
] })
|
|
5657
5938
|
] });
|
|
5658
5939
|
}
|