@oondemand/oon-core-front 0.3.52 → 0.3.53
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 +480 -253
- 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";
|
|
@@ -282,9 +282,9 @@ function createCoreClient(http) {
|
|
|
282
282
|
// src/api/resourceClient.ts
|
|
283
283
|
var META_KEYS = /* @__PURE__ */ new Set(["pagination", "results", "message", "requestId"]);
|
|
284
284
|
function unwrap(data) {
|
|
285
|
-
for (const [key,
|
|
286
|
-
if (!META_KEYS.has(key) &&
|
|
287
|
-
return
|
|
285
|
+
for (const [key, value2] of Object.entries(data)) {
|
|
286
|
+
if (!META_KEYS.has(key) && value2 && typeof value2 === "object") {
|
|
287
|
+
return value2;
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
return data;
|
|
@@ -343,7 +343,7 @@ function createResourceClient(http, basePath) {
|
|
|
343
343
|
import { jsx } from "react/jsx-runtime";
|
|
344
344
|
var ApiContext = createContext(null);
|
|
345
345
|
function ApiProvider({ http, children }) {
|
|
346
|
-
const
|
|
346
|
+
const value2 = useMemo(() => {
|
|
347
347
|
const cache = /* @__PURE__ */ new Map();
|
|
348
348
|
return {
|
|
349
349
|
http,
|
|
@@ -358,7 +358,7 @@ function ApiProvider({ http, children }) {
|
|
|
358
358
|
}
|
|
359
359
|
};
|
|
360
360
|
}, [http]);
|
|
361
|
-
return /* @__PURE__ */ jsx(ApiContext.Provider, { value, children });
|
|
361
|
+
return /* @__PURE__ */ jsx(ApiContext.Provider, { value: value2, children });
|
|
362
362
|
}
|
|
363
363
|
function useOonApi() {
|
|
364
364
|
const ctx = useContext(ApiContext);
|
|
@@ -460,9 +460,9 @@ function encodeBasicCredentials(email, password) {
|
|
|
460
460
|
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
461
461
|
return window.btoa(binary);
|
|
462
462
|
}
|
|
463
|
-
function normalizeList(
|
|
464
|
-
if (Array.isArray(
|
|
465
|
-
if (typeof
|
|
463
|
+
function normalizeList(value2) {
|
|
464
|
+
if (Array.isArray(value2)) return value2.map(String).filter(Boolean);
|
|
465
|
+
if (typeof value2 === "string") return value2.split(/[\s,;]+/).map((item) => item.trim()).filter(Boolean);
|
|
466
466
|
return [];
|
|
467
467
|
}
|
|
468
468
|
function extractCapabilities(user) {
|
|
@@ -607,12 +607,12 @@ function AuthProvider({
|
|
|
607
607
|
if (required.length === 0) return true;
|
|
608
608
|
if (roles.includes("admin") || roles.includes("master")) return true;
|
|
609
609
|
return required.some(
|
|
610
|
-
(
|
|
610
|
+
(value3) => roles.includes(value3) || capabilities.includes(value3) || roles.some((role) => value3.startsWith(`${role}.`))
|
|
611
611
|
);
|
|
612
612
|
},
|
|
613
613
|
[roles, capabilities]
|
|
614
614
|
);
|
|
615
|
-
const
|
|
615
|
+
const value2 = {
|
|
616
616
|
user,
|
|
617
617
|
roles,
|
|
618
618
|
capabilities,
|
|
@@ -623,7 +623,7 @@ function AuthProvider({
|
|
|
623
623
|
retry,
|
|
624
624
|
logout
|
|
625
625
|
};
|
|
626
|
-
return /* @__PURE__ */ jsx3(AuthContext.Provider, { value, children });
|
|
626
|
+
return /* @__PURE__ */ jsx3(AuthContext.Provider, { value: value2, children });
|
|
627
627
|
}
|
|
628
628
|
function useOonAuth() {
|
|
629
629
|
const context = useContext3(AuthContext);
|
|
@@ -672,12 +672,12 @@ function formRequired(field) {
|
|
|
672
672
|
}
|
|
673
673
|
function formOptions(field) {
|
|
674
674
|
const rawOptions = field.options;
|
|
675
|
-
if (Array.isArray(rawOptions)) return rawOptions.filter((
|
|
675
|
+
if (Array.isArray(rawOptions)) return rawOptions.filter((value2) => typeof value2 === "string");
|
|
676
676
|
if (!rawOptions || typeof rawOptions !== "object") return void 0;
|
|
677
677
|
const options = rawOptions;
|
|
678
678
|
const candidates = [options.values, options.enum, options.options];
|
|
679
679
|
for (const candidate of candidates) {
|
|
680
|
-
if (Array.isArray(candidate)) return candidate.filter((
|
|
680
|
+
if (Array.isArray(candidate)) return candidate.filter((value2) => typeof value2 === "string");
|
|
681
681
|
}
|
|
682
682
|
return void 0;
|
|
683
683
|
}
|
|
@@ -706,28 +706,28 @@ function formFieldsFromMeta(fields) {
|
|
|
706
706
|
};
|
|
707
707
|
});
|
|
708
708
|
}
|
|
709
|
-
function formatCell(
|
|
710
|
-
if (
|
|
709
|
+
function formatCell(value2, kind) {
|
|
710
|
+
if (value2 == null || value2 === "") return "\u2014";
|
|
711
711
|
switch (kind) {
|
|
712
712
|
case "boolean":
|
|
713
|
-
return
|
|
713
|
+
return value2 ? "Sim" : "N\xE3o";
|
|
714
714
|
case "date":
|
|
715
715
|
try {
|
|
716
|
-
return new Date(
|
|
716
|
+
return new Date(value2).toLocaleDateString("pt-BR");
|
|
717
717
|
} catch {
|
|
718
|
-
return String(
|
|
718
|
+
return String(value2);
|
|
719
719
|
}
|
|
720
720
|
case "currency":
|
|
721
721
|
case "currencyConverted":
|
|
722
|
-
return new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(Number(
|
|
722
|
+
return new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(Number(value2));
|
|
723
723
|
case "ref":
|
|
724
|
-
if (
|
|
725
|
-
const object =
|
|
724
|
+
if (value2 && typeof value2 === "object") {
|
|
725
|
+
const object = value2;
|
|
726
726
|
return String(object.nome ?? object.label ?? object.descricao ?? object._id ?? "\u2014");
|
|
727
727
|
}
|
|
728
|
-
return String(
|
|
728
|
+
return String(value2);
|
|
729
729
|
default:
|
|
730
|
-
return String(
|
|
730
|
+
return String(value2);
|
|
731
731
|
}
|
|
732
732
|
}
|
|
733
733
|
|
|
@@ -794,24 +794,24 @@ function ChevronIcon({ direction }) {
|
|
|
794
794
|
function PlusIcon() {
|
|
795
795
|
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
796
|
}
|
|
797
|
-
function renderCell(
|
|
798
|
-
const formatted = formatCell(
|
|
797
|
+
function renderCell(value2, kind) {
|
|
798
|
+
const formatted = formatCell(value2, kind);
|
|
799
799
|
if (kind === "enum") {
|
|
800
|
-
const normalized2 = String(
|
|
800
|
+
const normalized2 = String(value2 ?? "").toLowerCase();
|
|
801
801
|
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
802
|
return /* @__PURE__ */ jsx7(Badge, { colorPalette: palette, variant: "subtle", borderRadius: "full", px: "7px", py: "3px", fontSize: "9px", fontWeight: "600", textTransform: "capitalize", children: formatted });
|
|
803
803
|
}
|
|
804
804
|
if (kind === "boolean") {
|
|
805
|
-
const active =
|
|
805
|
+
const active = value2 === true || value2 === "true";
|
|
806
806
|
return /* @__PURE__ */ jsx7(Badge, { colorPalette: active ? "green" : "gray", variant: "subtle", borderRadius: "full", px: "7px", py: "3px", fontSize: "9px", fontWeight: "600", children: formatted });
|
|
807
807
|
}
|
|
808
808
|
return formatted;
|
|
809
809
|
}
|
|
810
810
|
function renderColumnCell(row, column, cellRenderers) {
|
|
811
|
-
const
|
|
811
|
+
const value2 = row[column.field];
|
|
812
812
|
const Renderer = column.renderer ? cellRenderers?.[column.renderer] : void 0;
|
|
813
|
-
if (Renderer) return /* @__PURE__ */ jsx7(Renderer, { value, row, column });
|
|
814
|
-
return renderCell(
|
|
813
|
+
if (Renderer) return /* @__PURE__ */ jsx7(Renderer, { value: value2, row, column });
|
|
814
|
+
return renderCell(value2, column.kind);
|
|
815
815
|
}
|
|
816
816
|
function DataGrid({
|
|
817
817
|
resource,
|
|
@@ -833,7 +833,7 @@ function DataGrid({
|
|
|
833
833
|
const deferredSearch = useDeferredValue(searchTerm);
|
|
834
834
|
const [sort, setSort] = useState3(void 0);
|
|
835
835
|
const [filterValues, setFilterValues] = useState3(() => Object.fromEntries(filters.map((filter) => [filter.field, filter.defaultValue ?? ""])));
|
|
836
|
-
const effectiveFilters = Object.fromEntries(Object.entries({ ...queryExtra, ...filterValues }).filter(([,
|
|
836
|
+
const effectiveFilters = Object.fromEntries(Object.entries({ ...queryExtra, ...filterValues }).filter(([, value2]) => value2 !== "" && value2 != null));
|
|
837
837
|
const query = useQuery2({
|
|
838
838
|
queryKey: ["oon", "list", resourceKey, { pageIndex, pageSize, searchTerm: deferredSearch, sort, filters: effectiveFilters }],
|
|
839
839
|
queryFn: () => resource.list({ pageIndex, pageSize, searchTerm: deferredSearch || void 0, sort, ...effectiveFilters }),
|
|
@@ -998,8 +998,8 @@ var NUMERIC_KINDS = /* @__PURE__ */ new Set(["number", "currency", "currencyConv
|
|
|
998
998
|
function hasOwn(object, key) {
|
|
999
999
|
return Object.prototype.hasOwnProperty.call(object, key);
|
|
1000
1000
|
}
|
|
1001
|
-
function isEmpty(
|
|
1002
|
-
return
|
|
1001
|
+
function isEmpty(value2) {
|
|
1002
|
+
return value2 === null || value2 === void 0 || typeof value2 === "string" && !value2.trim();
|
|
1003
1003
|
}
|
|
1004
1004
|
function getFieldValue(record, fieldPath) {
|
|
1005
1005
|
const parts = String(fieldPath).split(".");
|
|
@@ -1011,9 +1011,9 @@ function getFieldValue(record, fieldPath) {
|
|
|
1011
1011
|
}
|
|
1012
1012
|
return current;
|
|
1013
1013
|
}
|
|
1014
|
-
function toNumber(
|
|
1015
|
-
if (isEmpty(
|
|
1016
|
-
const numeric = typeof
|
|
1014
|
+
function toNumber(value2, context = {}) {
|
|
1015
|
+
if (isEmpty(value2)) return context.nullAsZero ? 0 : null;
|
|
1016
|
+
const numeric = typeof value2 === "number" ? value2 : Number(value2);
|
|
1017
1017
|
if (!Number.isFinite(numeric)) {
|
|
1018
1018
|
throw new DomainExpressionError(
|
|
1019
1019
|
`A f\xF3rmula do campo ${context.field ?? "calculado"} recebeu um valor n\xE3o num\xE9rico.`,
|
|
@@ -1025,7 +1025,7 @@ function toNumber(value, context = {}) {
|
|
|
1025
1025
|
function numericArguments(args, record, context) {
|
|
1026
1026
|
const values = args.map((arg) => evaluateDomainExpression(arg, record, context));
|
|
1027
1027
|
if (!context.nullAsZero && values.some(isEmpty)) return null;
|
|
1028
|
-
return values.map((
|
|
1028
|
+
return values.map((value2) => toNumber(value2, context) ?? 0);
|
|
1029
1029
|
}
|
|
1030
1030
|
function compareValues(leftValue, rightValue, operator) {
|
|
1031
1031
|
let left = leftValue;
|
|
@@ -1066,15 +1066,15 @@ function evaluateDomainExpression(expression, record = {}, context = {}) {
|
|
|
1066
1066
|
switch (operation.op) {
|
|
1067
1067
|
case "add": {
|
|
1068
1068
|
const values = numericArguments(args, record, context);
|
|
1069
|
-
return values === null ? null : values.reduce((total,
|
|
1069
|
+
return values === null ? null : values.reduce((total, value2) => total + value2, 0);
|
|
1070
1070
|
}
|
|
1071
1071
|
case "subtract": {
|
|
1072
1072
|
const values = numericArguments(args, record, context);
|
|
1073
|
-
return values === null ? null : values.slice(1).reduce((total,
|
|
1073
|
+
return values === null ? null : values.slice(1).reduce((total, value2) => total - value2, values[0] ?? 0);
|
|
1074
1074
|
}
|
|
1075
1075
|
case "multiply": {
|
|
1076
1076
|
const values = numericArguments(args, record, context);
|
|
1077
|
-
return values === null ? null : values.reduce((total,
|
|
1077
|
+
return values === null ? null : values.reduce((total, value2) => total * value2, 1);
|
|
1078
1078
|
}
|
|
1079
1079
|
case "divide": {
|
|
1080
1080
|
const values = numericArguments(args, record, context);
|
|
@@ -1107,8 +1107,8 @@ function evaluateDomainExpression(expression, record = {}, context = {}) {
|
|
|
1107
1107
|
}
|
|
1108
1108
|
case "coalesce": {
|
|
1109
1109
|
for (const arg of args) {
|
|
1110
|
-
const
|
|
1111
|
-
if (!isEmpty(
|
|
1110
|
+
const value2 = evaluateDomainExpression(arg, record, context);
|
|
1111
|
+
if (!isEmpty(value2)) return value2;
|
|
1112
1112
|
}
|
|
1113
1113
|
return null;
|
|
1114
1114
|
}
|
|
@@ -1132,9 +1132,9 @@ function evaluateDomainExpression(expression, record = {}, context = {}) {
|
|
|
1132
1132
|
case "present":
|
|
1133
1133
|
return !isEmpty(evaluateDomainExpression(args[0], record, context));
|
|
1134
1134
|
case "in": {
|
|
1135
|
-
const
|
|
1135
|
+
const value2 = evaluateDomainExpression(args[0], record, context);
|
|
1136
1136
|
const list = evaluateDomainExpression(args[1], record, context);
|
|
1137
|
-
return Array.isArray(list) && list.some((item) => Object.is(item,
|
|
1137
|
+
return Array.isArray(list) && list.some((item) => Object.is(item, value2));
|
|
1138
1138
|
}
|
|
1139
1139
|
default:
|
|
1140
1140
|
throw new DomainExpressionError(`Operador declarativo n\xE3o suportado: ${String(operation.op)}.`, {
|
|
@@ -1142,9 +1142,9 @@ function evaluateDomainExpression(expression, record = {}, context = {}) {
|
|
|
1142
1142
|
});
|
|
1143
1143
|
}
|
|
1144
1144
|
}
|
|
1145
|
-
function roundValue(
|
|
1146
|
-
if (
|
|
1147
|
-
const numeric = toNumber(
|
|
1145
|
+
function roundValue(value2, precision = 0) {
|
|
1146
|
+
if (value2 === null || value2 === void 0) return value2;
|
|
1147
|
+
const numeric = toNumber(value2);
|
|
1148
1148
|
if (numeric === null) return null;
|
|
1149
1149
|
const factor = 10 ** precision;
|
|
1150
1150
|
return Math.round((numeric + Number.EPSILON) * factor) / factor;
|
|
@@ -1189,15 +1189,15 @@ function orderComputedFields(fields) {
|
|
|
1189
1189
|
computed.forEach(visit);
|
|
1190
1190
|
return ordered;
|
|
1191
1191
|
}
|
|
1192
|
-
function coerceDomainFormValue(
|
|
1193
|
-
if (
|
|
1194
|
-
if (NUMERIC_KINDS.has(kind ?? "")) return Number(
|
|
1195
|
-
if (kind === "boolean") return
|
|
1196
|
-
return
|
|
1192
|
+
function coerceDomainFormValue(value2, kind) {
|
|
1193
|
+
if (value2 === "") return void 0;
|
|
1194
|
+
if (NUMERIC_KINDS.has(kind ?? "")) return Number(value2);
|
|
1195
|
+
if (kind === "boolean") return value2 === "true";
|
|
1196
|
+
return value2;
|
|
1197
1197
|
}
|
|
1198
|
-
function displayFormValue(
|
|
1199
|
-
if (
|
|
1200
|
-
return String(
|
|
1198
|
+
function displayFormValue(value2) {
|
|
1199
|
+
if (value2 === null || value2 === void 0) return "";
|
|
1200
|
+
return String(value2);
|
|
1201
1201
|
}
|
|
1202
1202
|
function applyReactiveFormulas(fields, currentValues) {
|
|
1203
1203
|
const values = { ...currentValues };
|
|
@@ -1217,11 +1217,11 @@ function applyReactiveFormulas(fields, currentValues) {
|
|
|
1217
1217
|
for (const field of ordered) {
|
|
1218
1218
|
try {
|
|
1219
1219
|
const computed = field.computed;
|
|
1220
|
-
const
|
|
1220
|
+
const value2 = evaluateDomainExpression(computed.expression, record, {
|
|
1221
1221
|
field: field.field,
|
|
1222
1222
|
nullAsZero: computed.nullAsZero !== false
|
|
1223
1223
|
});
|
|
1224
|
-
const normalized2 =
|
|
1224
|
+
const normalized2 = value2 === null || value2 === void 0 ? value2 : roundValue(value2, computed.precision ?? 2);
|
|
1225
1225
|
record[field.field] = normalized2;
|
|
1226
1226
|
values[field.field] = displayFormValue(normalized2);
|
|
1227
1227
|
} catch (error) {
|
|
@@ -1235,8 +1235,8 @@ function buildDomainMutationPayload(fields, values) {
|
|
|
1235
1235
|
const payload = {};
|
|
1236
1236
|
for (const field of fields) {
|
|
1237
1237
|
if (field.readonly || field.computed) continue;
|
|
1238
|
-
const
|
|
1239
|
-
if (
|
|
1238
|
+
const value2 = coerceDomainFormValue(values[field.field] ?? "", field.kind);
|
|
1239
|
+
if (value2 !== void 0) payload[field.field] = value2;
|
|
1240
1240
|
}
|
|
1241
1241
|
return payload;
|
|
1242
1242
|
}
|
|
@@ -1259,9 +1259,9 @@ var COMMON_LABEL_FIELDS = [
|
|
|
1259
1259
|
"label",
|
|
1260
1260
|
"email"
|
|
1261
1261
|
];
|
|
1262
|
-
function primitiveText(
|
|
1263
|
-
if (
|
|
1264
|
-
if (typeof
|
|
1262
|
+
function primitiveText(value2) {
|
|
1263
|
+
if (value2 == null || value2 === "") return null;
|
|
1264
|
+
if (typeof value2 === "string" || typeof value2 === "number") return String(value2);
|
|
1265
1265
|
return null;
|
|
1266
1266
|
}
|
|
1267
1267
|
function referenceOptionLabel(row, searchableFields = []) {
|
|
@@ -1281,9 +1281,9 @@ function referenceOptionLabel(row, searchableFields = []) {
|
|
|
1281
1281
|
if (values.length) return values.join(" \u2014 ");
|
|
1282
1282
|
return primitiveText(row._id) ?? primitiveText(row.id) ?? "Registro sem identifica\xE7\xE3o";
|
|
1283
1283
|
}
|
|
1284
|
-
function initialReferenceLabel(
|
|
1285
|
-
if (!
|
|
1286
|
-
return referenceOptionLabel(
|
|
1284
|
+
function initialReferenceLabel(value2) {
|
|
1285
|
+
if (!value2 || typeof value2 !== "object") return "";
|
|
1286
|
+
return referenceOptionLabel(value2);
|
|
1287
1287
|
}
|
|
1288
1288
|
function referenceId(row) {
|
|
1289
1289
|
return String(row._id ?? row.id ?? "");
|
|
@@ -1315,7 +1315,7 @@ function ClearIcon() {
|
|
|
1315
1315
|
}
|
|
1316
1316
|
function cleanFilters(filters) {
|
|
1317
1317
|
return Object.fromEntries(
|
|
1318
|
-
Object.entries(filters ?? {}).filter(([,
|
|
1318
|
+
Object.entries(filters ?? {}).filter(([, value2]) => value2 !== void 0 && value2 !== null && value2 !== "")
|
|
1319
1319
|
);
|
|
1320
1320
|
}
|
|
1321
1321
|
function ReferenceSelect({
|
|
@@ -1324,7 +1324,7 @@ function ReferenceSelect({
|
|
|
1324
1324
|
errorId,
|
|
1325
1325
|
label,
|
|
1326
1326
|
refModel,
|
|
1327
|
-
value,
|
|
1327
|
+
value: value2,
|
|
1328
1328
|
initialValue,
|
|
1329
1329
|
required,
|
|
1330
1330
|
invalid,
|
|
@@ -1356,9 +1356,9 @@ function ReferenceSelect({
|
|
|
1356
1356
|
return () => window.clearTimeout(timer);
|
|
1357
1357
|
}, [search]);
|
|
1358
1358
|
useEffect3(() => {
|
|
1359
|
-
if (!
|
|
1359
|
+
if (!value2) setSelectedLabel("");
|
|
1360
1360
|
else if (initialLabel) setSelectedLabel(initialLabel);
|
|
1361
|
-
}, [initialLabel,
|
|
1361
|
+
}, [initialLabel, value2]);
|
|
1362
1362
|
useEffect3(() => {
|
|
1363
1363
|
if (!disabled) return;
|
|
1364
1364
|
setOpen(false);
|
|
@@ -1391,9 +1391,9 @@ function ReferenceSelect({
|
|
|
1391
1391
|
staleTime: 3e4
|
|
1392
1392
|
});
|
|
1393
1393
|
const currentQuery = useQuery3({
|
|
1394
|
-
queryKey: ["oon", "reference-current", refModel, basePath,
|
|
1395
|
-
queryFn: () => resource.get(
|
|
1396
|
-
enabled: !!schema && !!
|
|
1394
|
+
queryKey: ["oon", "reference-current", refModel, basePath, value2],
|
|
1395
|
+
queryFn: () => resource.get(value2),
|
|
1396
|
+
enabled: !!schema && !!value2 && !selectedLabel,
|
|
1397
1397
|
staleTime: 5 * 6e4
|
|
1398
1398
|
});
|
|
1399
1399
|
useEffect3(() => {
|
|
@@ -1511,9 +1511,9 @@ function ReferenceSelect({
|
|
|
1511
1511
|
_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
1512
|
_disabled: { cursor: "not-allowed", color: "#98A2B3", bg: "#F8FAFC", opacity: 1 },
|
|
1513
1513
|
children: [
|
|
1514
|
-
/* @__PURE__ */ jsx8(Text4, { as: "span", minW: 0, flex: "1", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", color: selectedLabel ||
|
|
1514
|
+
/* @__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
1515
|
/* @__PURE__ */ jsxs4(Flex3, { as: "span", align: "center", gap: 1, flex: "0 0 auto", color: "#98A2B3", children: [
|
|
1516
|
-
|
|
1516
|
+
value2 && !disabled ? /* @__PURE__ */ jsx8(
|
|
1517
1517
|
Box3,
|
|
1518
1518
|
{
|
|
1519
1519
|
as: "span",
|
|
@@ -1598,7 +1598,7 @@ function ReferenceSelect({
|
|
|
1598
1598
|
] }) : 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
1599
|
const id = referenceId(record);
|
|
1600
1600
|
if (!id) return null;
|
|
1601
|
-
const selected = String(id) === String(
|
|
1601
|
+
const selected = String(id) === String(value2);
|
|
1602
1602
|
const active = index === activeIndex;
|
|
1603
1603
|
const optionLabel = referenceOptionLabel(record, schema?.searchable);
|
|
1604
1604
|
const status = record.status;
|
|
@@ -1647,9 +1647,9 @@ function ReferenceSelect({
|
|
|
1647
1647
|
}
|
|
1648
1648
|
|
|
1649
1649
|
// src/components/internal/inputMasks.ts
|
|
1650
|
-
var digitsOnly = (
|
|
1651
|
-
var normalizedName = (
|
|
1652
|
-
var hasLetters = (
|
|
1650
|
+
var digitsOnly = (value2) => String(value2 ?? "").replace(/\D/g, "");
|
|
1651
|
+
var normalizedName = (value2) => String(value2 ?? "").normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
|
|
1652
|
+
var hasLetters = (value2) => /[a-zA-Z]/.test(String(value2 ?? ""));
|
|
1653
1653
|
function personType(values) {
|
|
1654
1654
|
return normalizedName(values?.tipo ?? values?.tipoPessoa ?? values?.pessoaTipo);
|
|
1655
1655
|
}
|
|
@@ -1671,16 +1671,16 @@ function resolveInputMask(field, values) {
|
|
|
1671
1671
|
if (/telefone|celular|whatsapp|fone|phone/.test(name)) return "phone";
|
|
1672
1672
|
return void 0;
|
|
1673
1673
|
}
|
|
1674
|
-
function formatCpf(
|
|
1675
|
-
const digits = digitsOnly(
|
|
1674
|
+
function formatCpf(value2) {
|
|
1675
|
+
const digits = digitsOnly(value2).slice(0, 11);
|
|
1676
1676
|
return digits.replace(/^(\d{3})(\d)/, "$1.$2").replace(/^(\d{3})\.(\d{3})(\d)/, "$1.$2.$3").replace(/\.(\d{3})(\d)/, ".$1-$2");
|
|
1677
1677
|
}
|
|
1678
|
-
function formatCnpj(
|
|
1679
|
-
const digits = digitsOnly(
|
|
1678
|
+
function formatCnpj(value2) {
|
|
1679
|
+
const digits = digitsOnly(value2).slice(0, 14);
|
|
1680
1680
|
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
1681
|
}
|
|
1682
|
-
function formatPhone(
|
|
1683
|
-
const digits = digitsOnly(
|
|
1682
|
+
function formatPhone(value2) {
|
|
1683
|
+
const digits = digitsOnly(value2).slice(0, 11);
|
|
1684
1684
|
if (!digits) return "";
|
|
1685
1685
|
if (digits.length <= 2) return `(${digits}`;
|
|
1686
1686
|
const ddd = digits.slice(0, 2);
|
|
@@ -1690,18 +1690,18 @@ function formatPhone(value) {
|
|
|
1690
1690
|
const suffix = number.slice(prefixLength);
|
|
1691
1691
|
return `(${ddd}) ${prefix}${suffix ? `-${suffix}` : ""}`;
|
|
1692
1692
|
}
|
|
1693
|
-
function parseCurrencyInitial(
|
|
1694
|
-
if (
|
|
1695
|
-
if (typeof
|
|
1696
|
-
const raw = String(
|
|
1693
|
+
function parseCurrencyInitial(value2) {
|
|
1694
|
+
if (value2 == null || value2 === "") return "";
|
|
1695
|
+
if (typeof value2 === "number") return Number.isFinite(value2) ? String(value2) : "";
|
|
1696
|
+
const raw = String(value2).trim();
|
|
1697
1697
|
if (!raw) return "";
|
|
1698
1698
|
if (/^-?\d+(?:\.\d+)?$/.test(raw)) return raw;
|
|
1699
1699
|
const localized = raw.replace(/[^\d,.-]/g, "").replace(/\.(?=\d{3}(?:\D|$))/g, "").replace(",", ".");
|
|
1700
1700
|
const parsed = Number(localized);
|
|
1701
1701
|
return Number.isFinite(parsed) ? String(parsed) : "";
|
|
1702
1702
|
}
|
|
1703
|
-
function formatCurrency(
|
|
1704
|
-
const normalized2 = parseCurrencyInitial(
|
|
1703
|
+
function formatCurrency(value2) {
|
|
1704
|
+
const normalized2 = parseCurrencyInitial(value2);
|
|
1705
1705
|
if (!normalized2) return "";
|
|
1706
1706
|
const numeric = Number(normalized2);
|
|
1707
1707
|
if (!Number.isFinite(numeric)) return "";
|
|
@@ -1712,32 +1712,32 @@ function formatCurrency(value) {
|
|
|
1712
1712
|
maximumFractionDigits: 2
|
|
1713
1713
|
}).format(numeric);
|
|
1714
1714
|
}
|
|
1715
|
-
function normalizeMaskedValue(
|
|
1716
|
-
if (!mask) return String(
|
|
1717
|
-
if (mask === "currency") return parseCurrencyInitial(
|
|
1718
|
-
if (mask === "document" && hasLetters(
|
|
1715
|
+
function normalizeMaskedValue(value2, mask) {
|
|
1716
|
+
if (!mask) return String(value2 ?? "");
|
|
1717
|
+
if (mask === "currency") return parseCurrencyInitial(value2);
|
|
1718
|
+
if (mask === "document" && hasLetters(value2)) return String(value2 ?? "").slice(0, 30);
|
|
1719
1719
|
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(
|
|
1720
|
+
return digitsOnly(value2).slice(0, limit);
|
|
1721
|
+
}
|
|
1722
|
+
function formatMaskedValue(value2, mask) {
|
|
1723
|
+
if (!mask) return String(value2 ?? "");
|
|
1724
|
+
if (mask === "currency") return formatCurrency(value2);
|
|
1725
|
+
if (mask === "phone") return formatPhone(value2);
|
|
1726
|
+
if (mask === "cpf") return formatCpf(value2);
|
|
1727
|
+
if (mask === "cnpj") return formatCnpj(value2);
|
|
1728
|
+
if (hasLetters(value2)) return String(value2 ?? "");
|
|
1729
|
+
const digits = digitsOnly(value2);
|
|
1730
1730
|
return digits.length > 11 ? formatCnpj(digits) : formatCpf(digits);
|
|
1731
1731
|
}
|
|
1732
|
-
function parseMaskedInput(
|
|
1733
|
-
if (!mask) return
|
|
1732
|
+
function parseMaskedInput(value2, mask) {
|
|
1733
|
+
if (!mask) return value2;
|
|
1734
1734
|
if (mask === "currency") {
|
|
1735
|
-
const digits = digitsOnly(
|
|
1735
|
+
const digits = digitsOnly(value2);
|
|
1736
1736
|
if (!digits) return "";
|
|
1737
1737
|
const amount = Number(digits) / 100;
|
|
1738
|
-
return `${
|
|
1738
|
+
return `${value2.includes("-") ? "-" : ""}${amount.toFixed(2)}`;
|
|
1739
1739
|
}
|
|
1740
|
-
return normalizeMaskedValue(
|
|
1740
|
+
return normalizeMaskedValue(value2, mask);
|
|
1741
1741
|
}
|
|
1742
1742
|
function inputModeForMask(mask) {
|
|
1743
1743
|
if (mask === "document") return "text";
|
|
@@ -1755,7 +1755,7 @@ function maxLengthForMask(mask) {
|
|
|
1755
1755
|
import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1756
1756
|
var idFor = (field) => `oon-form-field-${field.replace(/[^a-zA-Z0-9_-]/g, "-")}`;
|
|
1757
1757
|
var errorIdFor = (field) => `${idFor(field)}-error`;
|
|
1758
|
-
var normalize = (
|
|
1758
|
+
var normalize = (value2) => String(value2 ?? "").normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
|
|
1759
1759
|
function CloseIcon() {
|
|
1760
1760
|
return /* @__PURE__ */ jsx9("svg", { viewBox: "0 0 20 20", width: "18", height: "18", "aria-hidden": "true", children: /* @__PURE__ */ jsx9("path", { d: "m6 6 8 8M14 6l-8 8", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" }) });
|
|
1761
1761
|
}
|
|
@@ -1771,23 +1771,23 @@ function AlertIcon() {
|
|
|
1771
1771
|
/* @__PURE__ */ jsx9("path", { d: "M10 6.5v4.2M10 13.5v.1", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" })
|
|
1772
1772
|
] });
|
|
1773
1773
|
}
|
|
1774
|
-
function toValue(
|
|
1775
|
-
if (
|
|
1774
|
+
function toValue(value2, kind) {
|
|
1775
|
+
if (value2 == null) return "";
|
|
1776
1776
|
if (kind === "date") {
|
|
1777
1777
|
try {
|
|
1778
|
-
return new Date(
|
|
1778
|
+
return new Date(value2).toISOString().slice(0, 10);
|
|
1779
1779
|
} catch {
|
|
1780
1780
|
return "";
|
|
1781
1781
|
}
|
|
1782
1782
|
}
|
|
1783
|
-
if (typeof
|
|
1784
|
-
const record =
|
|
1783
|
+
if (typeof value2 === "object") {
|
|
1784
|
+
const record = value2;
|
|
1785
1785
|
return String(record._id ?? record.id ?? "");
|
|
1786
1786
|
}
|
|
1787
|
-
return String(
|
|
1787
|
+
return String(value2);
|
|
1788
1788
|
}
|
|
1789
|
-
function initialFieldValue(field,
|
|
1790
|
-
return normalizeMaskedValue(toValue(
|
|
1789
|
+
function initialFieldValue(field, value2) {
|
|
1790
|
+
return normalizeMaskedValue(toValue(value2, field.kind), resolveInputMask(field));
|
|
1791
1791
|
}
|
|
1792
1792
|
function initialReactiveValues(fields, initialValues) {
|
|
1793
1793
|
const initial = Object.fromEntries(fields.map((field) => [field.field, initialFieldValue(field, initialValues?.[field.field])]));
|
|
@@ -1817,12 +1817,12 @@ function detailErrors(error, fields) {
|
|
|
1817
1817
|
const result = {};
|
|
1818
1818
|
const lookup = new Map(fields.flatMap((field) => [[normalize(field.field), field], [normalize(field.label), field]]));
|
|
1819
1819
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
1820
|
-
const visit = (
|
|
1821
|
-
if (
|
|
1822
|
-
if (Array.isArray(
|
|
1823
|
-
if (typeof
|
|
1824
|
-
seen.add(
|
|
1825
|
-
const record =
|
|
1820
|
+
const visit = (value2, hint) => {
|
|
1821
|
+
if (value2 == null) return;
|
|
1822
|
+
if (Array.isArray(value2)) return value2.forEach((item) => visit(item, hint));
|
|
1823
|
+
if (typeof value2 !== "object" || seen.has(value2)) return;
|
|
1824
|
+
seen.add(value2);
|
|
1825
|
+
const record = value2;
|
|
1826
1826
|
const candidate = String(record.field ?? record.path ?? record.property ?? record.name ?? hint ?? "");
|
|
1827
1827
|
const field = lookup.get(normalize(candidate.split(/[.[\]]+/).filter(Boolean).pop() ?? candidate));
|
|
1828
1828
|
const raw = record.message ?? record.msg ?? record.reason;
|
|
@@ -1888,8 +1888,8 @@ function resolveReference(field, values) {
|
|
|
1888
1888
|
const filters = { ...field.referenceFilters ?? {} };
|
|
1889
1889
|
const missing = [];
|
|
1890
1890
|
Object.entries(field.referenceFilterFrom ?? {}).forEach(([queryField, formField]) => {
|
|
1891
|
-
const
|
|
1892
|
-
if (
|
|
1891
|
+
const value2 = values[formField];
|
|
1892
|
+
if (value2) filters[queryField] = value2;
|
|
1893
1893
|
else missing.push(formField);
|
|
1894
1894
|
});
|
|
1895
1895
|
return { filters, disabled: missing.length > 0 };
|
|
@@ -1922,15 +1922,15 @@ function DynamicForm({ title, eyebrow = "Cadastro", fields: rawFields, initialVa
|
|
|
1922
1922
|
const first = fields.find((field) => next[field.field]);
|
|
1923
1923
|
if (first) focusField(first.field);
|
|
1924
1924
|
}, [error]);
|
|
1925
|
-
const change = (fieldName,
|
|
1925
|
+
const change = (fieldName, value2) => {
|
|
1926
1926
|
const selected = fields.find((field) => field.field === fieldName);
|
|
1927
1927
|
if (selected?.readonly || selected?.computed) return;
|
|
1928
1928
|
const dependentFields = fields.filter(
|
|
1929
1929
|
(candidate) => Object.values(candidate.referenceFilterFrom ?? {}).includes(fieldName)
|
|
1930
1930
|
);
|
|
1931
1931
|
setValues((current) => {
|
|
1932
|
-
const changed = current[fieldName] !==
|
|
1933
|
-
const next = { ...current, [fieldName]:
|
|
1932
|
+
const changed = current[fieldName] !== value2;
|
|
1933
|
+
const next = { ...current, [fieldName]: value2 };
|
|
1934
1934
|
if (changed) dependentFields.forEach((candidate) => {
|
|
1935
1935
|
next[candidate.field] = "";
|
|
1936
1936
|
});
|
|
@@ -1990,7 +1990,7 @@ function DynamicForm({ title, eyebrow = "Cadastro", fields: rawFields, initialVa
|
|
|
1990
1990
|
}
|
|
1991
1991
|
if (field.kind === "ref" && field.ref) {
|
|
1992
1992
|
const reference = resolveReference(field, values);
|
|
1993
|
-
return wrap(/* @__PURE__ */ jsx9(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: (
|
|
1993
|
+
return wrap(/* @__PURE__ */ jsx9(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
1994
|
}
|
|
1995
1995
|
if (field.kind === "enum" && field.options?.length) return wrap(/* @__PURE__ */ jsxs5(NativeSelect2.Root, { size: "sm", disabled: readonly, children: [
|
|
1996
1996
|
/* @__PURE__ */ jsxs5(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: [
|
|
@@ -2011,9 +2011,9 @@ function DynamicForm({ title, eyebrow = "Cadastro", fields: rawFields, initialVa
|
|
|
2011
2011
|
const mask = resolveInputMask(field);
|
|
2012
2012
|
const numeric = ["number", "currency", "currencyConverted"].includes(field.kind ?? "");
|
|
2013
2013
|
const type = mask ? "text" : field.kind === "date" ? "date" : numeric ? "number" : "text";
|
|
2014
|
-
const
|
|
2014
|
+
const value2 = values[field.field] ?? "";
|
|
2015
2015
|
return wrap(
|
|
2016
|
-
/* @__PURE__ */ jsx9(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(
|
|
2016
|
+
/* @__PURE__ */ jsx9(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
2017
|
);
|
|
2018
2018
|
};
|
|
2019
2019
|
const combinedErrors = { ...formulaErrors, ...errors };
|
|
@@ -2109,11 +2109,11 @@ function resolveInitialDetailTab(config, recordId, initialTab) {
|
|
|
2109
2109
|
|
|
2110
2110
|
// src/components/internal/CoreSummaryCards.tsx
|
|
2111
2111
|
import { Fragment, jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
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
|
|
2112
|
+
function format(value2, format2) {
|
|
2113
|
+
if (format2 === "currency") return new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(Number(value2 ?? 0));
|
|
2114
|
+
if (format2 === "percent") return `${Number(value2 ?? 0).toLocaleString("pt-BR")}%`;
|
|
2115
|
+
if (format2 === "date") return formatCell(value2, "date");
|
|
2116
|
+
return value2 == null || value2 === "" ? "\u2014" : String(value2);
|
|
2117
2117
|
}
|
|
2118
2118
|
function RelatedMetric({ card, relation, parent }) {
|
|
2119
2119
|
const schema = useModelSchema(relation.model).data;
|
|
@@ -2121,10 +2121,10 @@ function RelatedMetric({ card, relation, parent }) {
|
|
|
2121
2121
|
const parentValue = parent[relation.parentKey ?? "_id"];
|
|
2122
2122
|
const query = useQuery4({ queryKey: ["oon", "summary", relation.model, relation.foreignKey, parentValue, card.source, card.field], queryFn: () => resource.list({ [relation.foreignKey]: parentValue, pageSize: 1e3 }) });
|
|
2123
2123
|
const rows = query.data?.results ?? [];
|
|
2124
|
-
let
|
|
2125
|
-
if (card.source === "relatedSum")
|
|
2126
|
-
if (card.source === "relatedAvg")
|
|
2127
|
-
return /* @__PURE__ */ jsx10(Fragment, { children: query.isLoading ? "..." : format(
|
|
2124
|
+
let value2 = rows.length;
|
|
2125
|
+
if (card.source === "relatedSum") value2 = rows.reduce((sum, row) => sum + Number(row[card.field ?? ""] ?? 0), 0);
|
|
2126
|
+
if (card.source === "relatedAvg") value2 = rows.length ? rows.reduce((sum, row) => sum + Number(row[card.field ?? ""] ?? 0), 0) / rows.length : 0;
|
|
2127
|
+
return /* @__PURE__ */ jsx10(Fragment, { children: query.isLoading ? "..." : format(value2, card.format) });
|
|
2128
2128
|
}
|
|
2129
2129
|
function CoreSummaryCards({ cards = [], parent, relations }) {
|
|
2130
2130
|
return /* @__PURE__ */ jsx10(SimpleGrid2, { columns: { base: 1, md: 3 }, gap: 3, children: cards.map((card, index) => {
|
|
@@ -2145,9 +2145,9 @@ import { useMutation, useQuery as useQuery5, useQueryClient } from "@tanstack/re
|
|
|
2145
2145
|
// src/components/internal/CoreInlineEditableCell.tsx
|
|
2146
2146
|
import { Input as Input4, NativeSelect as NativeSelect3, Textarea as Textarea2 } from "@chakra-ui/react";
|
|
2147
2147
|
import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2148
|
-
function CoreInlineEditableCell({ column, meta, value, onChange }) {
|
|
2148
|
+
function CoreInlineEditableCell({ column, meta, value: value2, onChange }) {
|
|
2149
2149
|
const kind = column.editor ?? meta?.kind ?? column.kind ?? "string";
|
|
2150
|
-
const plainValue =
|
|
2150
|
+
const plainValue = value2 == null ? "" : String(value2);
|
|
2151
2151
|
const common = {
|
|
2152
2152
|
size: "xs",
|
|
2153
2153
|
fontSize: "11px",
|
|
@@ -2192,24 +2192,24 @@ import { useState as useState6 } from "react";
|
|
|
2192
2192
|
import { Box as Box6, Button as Button5, Text as Text7 } from "@chakra-ui/react";
|
|
2193
2193
|
|
|
2194
2194
|
// src/components/internal/actionError.ts
|
|
2195
|
-
function asRecord(
|
|
2196
|
-
return
|
|
2195
|
+
function asRecord(value2) {
|
|
2196
|
+
return value2 && typeof value2 === "object" ? value2 : void 0;
|
|
2197
2197
|
}
|
|
2198
2198
|
function firstText(...values) {
|
|
2199
|
-
return values.find((
|
|
2199
|
+
return values.find((value2) => typeof value2 === "string" && value2.trim().length > 0)?.trim();
|
|
2200
2200
|
}
|
|
2201
2201
|
function firstNumber(...values) {
|
|
2202
|
-
return values.find((
|
|
2202
|
+
return values.find((value2) => typeof value2 === "number" && Number.isFinite(value2));
|
|
2203
2203
|
}
|
|
2204
|
-
function collectDetailMessages(
|
|
2205
|
-
if (depth > 4 ||
|
|
2206
|
-
if (typeof
|
|
2207
|
-
if (Array.isArray(
|
|
2208
|
-
return
|
|
2204
|
+
function collectDetailMessages(value2, visited = /* @__PURE__ */ new WeakSet(), depth = 0) {
|
|
2205
|
+
if (depth > 4 || value2 == null) return [];
|
|
2206
|
+
if (typeof value2 === "string") return value2.trim() ? [value2.trim()] : [];
|
|
2207
|
+
if (Array.isArray(value2)) {
|
|
2208
|
+
return value2.flatMap((item) => collectDetailMessages(item, visited, depth + 1));
|
|
2209
2209
|
}
|
|
2210
|
-
if (typeof
|
|
2211
|
-
visited.add(
|
|
2212
|
-
const record =
|
|
2210
|
+
if (typeof value2 !== "object" || visited.has(value2)) return [];
|
|
2211
|
+
visited.add(value2);
|
|
2212
|
+
const record = value2;
|
|
2213
2213
|
const field = firstText(record.field, record.path, record.property, record.name);
|
|
2214
2214
|
const message = firstText(record.message, record.msg, record.reason);
|
|
2215
2215
|
const direct = message ? [field ? `${field}: ${message}` : message] : [];
|
|
@@ -2219,7 +2219,7 @@ function collectDetailMessages(value, visited = /* @__PURE__ */ new WeakSet(), d
|
|
|
2219
2219
|
return Object.entries(record).filter(([key]) => !["code", "status", "statusCode", "requestId"].includes(key)).flatMap(([, nestedValue]) => collectDetailMessages(nestedValue, visited, depth + 1));
|
|
2220
2220
|
}
|
|
2221
2221
|
function unique(values) {
|
|
2222
|
-
return [...new Set(values.map((
|
|
2222
|
+
return [...new Set(values.map((value2) => value2.trim()).filter(Boolean))];
|
|
2223
2223
|
}
|
|
2224
2224
|
function describeActionError(error) {
|
|
2225
2225
|
if (error instanceof Error) return { message: error.message };
|
|
@@ -2236,7 +2236,7 @@ function describeActionError(error) {
|
|
|
2236
2236
|
code ? `C\xF3digo: ${code}` : void 0,
|
|
2237
2237
|
status ? `HTTP: ${status}` : void 0,
|
|
2238
2238
|
requestId ? `ID da requisi\xE7\xE3o: ${requestId}` : void 0
|
|
2239
|
-
].filter((
|
|
2239
|
+
].filter((value2) => Boolean(value2));
|
|
2240
2240
|
const contextParts = [...details, ...technical];
|
|
2241
2241
|
return {
|
|
2242
2242
|
message,
|
|
@@ -2254,12 +2254,12 @@ function valueAt(source, path) {
|
|
|
2254
2254
|
}
|
|
2255
2255
|
function evaluateCondition(condition, row) {
|
|
2256
2256
|
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(
|
|
2257
|
+
const value2 = valueAt(row, condition.field);
|
|
2258
|
+
if ("exists" in condition) return condition.exists ? value2 != null && value2 !== "" : value2 == null || value2 === "";
|
|
2259
|
+
if ("equals" in condition) return value2 === condition.equals;
|
|
2260
|
+
if ("notEquals" in condition) return value2 !== condition.notEquals;
|
|
2261
|
+
if ("in" in condition) return condition.in.includes(value2);
|
|
2262
|
+
const numeric = Number(value2);
|
|
2263
2263
|
if (Number.isNaN(numeric)) return false;
|
|
2264
2264
|
if ("gt" in condition) return numeric > condition.gt;
|
|
2265
2265
|
if ("gte" in condition) return numeric >= condition.gte;
|
|
@@ -2324,9 +2324,9 @@ function ActionErrorMessage({ error }) {
|
|
|
2324
2324
|
}
|
|
2325
2325
|
);
|
|
2326
2326
|
}
|
|
2327
|
-
function unwrap2(
|
|
2328
|
-
if (!
|
|
2329
|
-
const record =
|
|
2327
|
+
function unwrap2(value2) {
|
|
2328
|
+
if (!value2 || typeof value2 !== "object") return {};
|
|
2329
|
+
const record = value2;
|
|
2330
2330
|
const data = record.data;
|
|
2331
2331
|
if (data && typeof data === "object") return data;
|
|
2332
2332
|
return record;
|
|
@@ -2569,9 +2569,9 @@ function CoreRelatedGrid({
|
|
|
2569
2569
|
if (!relation) return /* @__PURE__ */ jsx14(Text8, { color: "#B42318", children: "Rela\xE7\xE3o n\xE3o encontrada." });
|
|
2570
2570
|
if (query.isLoading || schemaQuery.isLoading) return /* @__PURE__ */ jsx14(Text8, { color: "#667085", children: "Carregando..." });
|
|
2571
2571
|
const rows = query.data?.results ?? [];
|
|
2572
|
-
const setDraft = (id, field,
|
|
2572
|
+
const setDraft = (id, field, value2) => setDrafts((current) => ({
|
|
2573
2573
|
...current,
|
|
2574
|
-
[id]: { ...current[id] ?? {}, [field]:
|
|
2574
|
+
[id]: { ...current[id] ?? {}, [field]: value2 }
|
|
2575
2575
|
}));
|
|
2576
2576
|
return /* @__PURE__ */ jsxs9(Box7, { children: [
|
|
2577
2577
|
canCreate ? /* @__PURE__ */ jsx14(Flex5, { justify: "flex-end", mb: "10px", children: /* @__PURE__ */ jsx14(Button6, { size: "sm", colorPalette: "brand", onClick: () => {
|
|
@@ -2590,10 +2590,10 @@ function CoreRelatedGrid({
|
|
|
2590
2590
|
const dirty = Object.keys(draft).length > 0;
|
|
2591
2591
|
return /* @__PURE__ */ jsxs9(Table2.Row, { bg: dirty ? "#FFFBEB" : index % 2 ? "#FBFCFD" : "white", children: [
|
|
2592
2592
|
columns.map((column) => {
|
|
2593
|
-
const
|
|
2593
|
+
const value2 = column.field in draft ? draft[column.field] : row[column.field];
|
|
2594
2594
|
const meta = schema?.fields.find((field) => field.name === column.field);
|
|
2595
2595
|
const canEdit = editable && column.readonly !== true && (column.editable === true || !column.readonly);
|
|
2596
|
-
return /* @__PURE__ */ jsx14(Table2.Cell, { fontSize: "11px", children: canEdit ? /* @__PURE__ */ jsx14(CoreInlineEditableCell, { column, meta, value, onChange: (next) => setDraft(id, column.field, next) }) : column.display === "badgeExists" ? /* @__PURE__ */ jsx14(Badge3, { colorPalette:
|
|
2596
|
+
return /* @__PURE__ */ jsx14(Table2.Cell, { fontSize: "11px", children: canEdit ? /* @__PURE__ */ jsx14(CoreInlineEditableCell, { column, meta, value: value2, onChange: (next) => setDraft(id, column.field, next) }) : column.display === "badgeExists" ? /* @__PURE__ */ jsx14(Badge3, { colorPalette: value2 ? "green" : "gray", children: value2 ? "Sim" : "N\xE3o" }) : formatCell(value2, column.kind) }, column.field);
|
|
2597
2597
|
}),
|
|
2598
2598
|
hasActions ? /* @__PURE__ */ jsx14(Table2.Cell, { children: /* @__PURE__ */ jsxs9(Flex5, { gap: "5px", align: "center", wrap: "wrap", children: [
|
|
2599
2599
|
dirty ? /* @__PURE__ */ jsxs9(Fragment2, { children: [
|
|
@@ -2664,23 +2664,23 @@ function CoreRelatedGrid({
|
|
|
2664
2664
|
|
|
2665
2665
|
// src/components/internal/CoreTabbedDetail.tsx
|
|
2666
2666
|
import { jsx as jsx15, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
2667
|
-
function toValue2(
|
|
2668
|
-
if (
|
|
2667
|
+
function toValue2(value2, kind) {
|
|
2668
|
+
if (value2 == null) return "";
|
|
2669
2669
|
if (kind === "date") {
|
|
2670
2670
|
try {
|
|
2671
|
-
return new Date(
|
|
2671
|
+
return new Date(value2).toISOString().slice(0, 10);
|
|
2672
2672
|
} catch {
|
|
2673
2673
|
return "";
|
|
2674
2674
|
}
|
|
2675
2675
|
}
|
|
2676
|
-
if (typeof
|
|
2677
|
-
const record =
|
|
2676
|
+
if (typeof value2 === "object") {
|
|
2677
|
+
const record = value2;
|
|
2678
2678
|
return String(record._id ?? record.id ?? "");
|
|
2679
2679
|
}
|
|
2680
|
-
return String(
|
|
2680
|
+
return String(value2);
|
|
2681
2681
|
}
|
|
2682
|
-
function initialFieldValue2(field,
|
|
2683
|
-
return normalizeMaskedValue(toValue2(
|
|
2682
|
+
function initialFieldValue2(field, value2) {
|
|
2683
|
+
return normalizeMaskedValue(toValue2(value2, field.kind), resolveInputMask(field));
|
|
2684
2684
|
}
|
|
2685
2685
|
function initialReactiveValues2(fields, parent) {
|
|
2686
2686
|
const initial = Object.fromEntries(fields.map((field) => [field.field, initialFieldValue2(field, parent[field.field])]));
|
|
@@ -2709,14 +2709,14 @@ function fieldErrorsOf(error) {
|
|
|
2709
2709
|
const envelope = record.error && typeof record.error === "object" ? record.error : void 0;
|
|
2710
2710
|
const details = record.details ?? envelope?.details ?? envelope;
|
|
2711
2711
|
const result = {};
|
|
2712
|
-
const visit = (
|
|
2713
|
-
if (!
|
|
2714
|
-
if (Array.isArray(
|
|
2715
|
-
|
|
2712
|
+
const visit = (value2) => {
|
|
2713
|
+
if (!value2) return;
|
|
2714
|
+
if (Array.isArray(value2)) {
|
|
2715
|
+
value2.forEach(visit);
|
|
2716
2716
|
return;
|
|
2717
2717
|
}
|
|
2718
|
-
if (typeof
|
|
2719
|
-
const item =
|
|
2718
|
+
if (typeof value2 !== "object") return;
|
|
2719
|
+
const item = value2;
|
|
2720
2720
|
if (typeof item.field === "string" && typeof item.message === "string") {
|
|
2721
2721
|
result[item.field] = item.message;
|
|
2722
2722
|
}
|
|
@@ -2740,8 +2740,8 @@ function resolveReference2(field, values) {
|
|
|
2740
2740
|
const filters = { ...field.referenceFilters ?? {} };
|
|
2741
2741
|
const missing = [];
|
|
2742
2742
|
Object.entries(field.referenceFilterFrom ?? {}).forEach(([queryField, formField]) => {
|
|
2743
|
-
const
|
|
2744
|
-
if (
|
|
2743
|
+
const value2 = values[formField];
|
|
2744
|
+
if (value2) filters[queryField] = value2;
|
|
2745
2745
|
else missing.push(formField);
|
|
2746
2746
|
});
|
|
2747
2747
|
return { filters, disabled: missing.length > 0 };
|
|
@@ -2760,7 +2760,7 @@ function ErrorText2({ id, message }) {
|
|
|
2760
2760
|
}
|
|
2761
2761
|
function FieldControl({
|
|
2762
2762
|
field,
|
|
2763
|
-
value,
|
|
2763
|
+
value: value2,
|
|
2764
2764
|
values,
|
|
2765
2765
|
initialValue,
|
|
2766
2766
|
error,
|
|
@@ -2780,7 +2780,7 @@ function FieldControl({
|
|
|
2780
2780
|
if (field.widget === "checkbox") {
|
|
2781
2781
|
const checkedValue = String(field.checkedValue ?? true);
|
|
2782
2782
|
const uncheckedValue = String(field.uncheckedValue ?? false);
|
|
2783
|
-
const checked = (
|
|
2783
|
+
const checked = (value2 || uncheckedValue) === checkedValue;
|
|
2784
2784
|
return /* @__PURE__ */ jsxs10(Box8, { children: [
|
|
2785
2785
|
/* @__PURE__ */ jsxs10(
|
|
2786
2786
|
Box8,
|
|
@@ -2830,7 +2830,7 @@ function FieldControl({
|
|
|
2830
2830
|
errorId,
|
|
2831
2831
|
label,
|
|
2832
2832
|
refModel: field.ref,
|
|
2833
|
-
value,
|
|
2833
|
+
value: value2,
|
|
2834
2834
|
initialValue,
|
|
2835
2835
|
required: field.required && !readonly,
|
|
2836
2836
|
invalid: !!error,
|
|
@@ -2846,19 +2846,19 @@ function FieldControl({
|
|
|
2846
2846
|
}
|
|
2847
2847
|
const mask = resolveInputMask(field);
|
|
2848
2848
|
const control = field.kind === "enum" && field.options?.length ? /* @__PURE__ */ jsxs10(NativeSelect4.Root, { size: "sm", disabled: readonly, children: [
|
|
2849
|
-
/* @__PURE__ */ jsxs10(NativeSelect4.Field, { id: inputId, value, ...invalidProps, onChange: (event) => onChange(event.currentTarget.value), children: [
|
|
2849
|
+
/* @__PURE__ */ jsxs10(NativeSelect4.Field, { id: inputId, value: value2, ...invalidProps, onChange: (event) => onChange(event.currentTarget.value), children: [
|
|
2850
2850
|
/* @__PURE__ */ jsx15("option", { value: "", children: "\u2014 Selecione \u2014" }),
|
|
2851
2851
|
field.options.map((option) => /* @__PURE__ */ jsx15("option", { value: option, children: option }, option))
|
|
2852
2852
|
] }),
|
|
2853
2853
|
/* @__PURE__ */ jsx15(NativeSelect4.Indicator, {})
|
|
2854
2854
|
] }) : field.kind === "boolean" ? /* @__PURE__ */ jsxs10(NativeSelect4.Root, { size: "sm", disabled: readonly, children: [
|
|
2855
|
-
/* @__PURE__ */ jsxs10(NativeSelect4.Field, { id: inputId, value, ...invalidProps, onChange: (event) => onChange(event.currentTarget.value), children: [
|
|
2855
|
+
/* @__PURE__ */ jsxs10(NativeSelect4.Field, { id: inputId, value: value2, ...invalidProps, onChange: (event) => onChange(event.currentTarget.value), children: [
|
|
2856
2856
|
/* @__PURE__ */ jsx15("option", { value: "", children: "\u2014 Selecione \u2014" }),
|
|
2857
2857
|
/* @__PURE__ */ jsx15("option", { value: "true", children: "Sim" }),
|
|
2858
2858
|
/* @__PURE__ */ jsx15("option", { value: "false", children: "N\xE3o" })
|
|
2859
2859
|
] }),
|
|
2860
2860
|
/* @__PURE__ */ jsx15(NativeSelect4.Indicator, {})
|
|
2861
|
-
] }) : isMultiline2(field) ? /* @__PURE__ */ jsx15(Textarea3, { id: inputId, rows: 4, resize: "vertical", readOnly: readonly, value, ...invalidProps, onChange: (event) => onChange(event.currentTarget.value) }) : /* @__PURE__ */ jsx15(
|
|
2861
|
+
] }) : isMultiline2(field) ? /* @__PURE__ */ jsx15(Textarea3, { id: inputId, rows: 4, resize: "vertical", readOnly: readonly, value: value2, ...invalidProps, onChange: (event) => onChange(event.currentTarget.value) }) : /* @__PURE__ */ jsx15(
|
|
2862
2862
|
Input5,
|
|
2863
2863
|
{
|
|
2864
2864
|
id: inputId,
|
|
@@ -2868,7 +2868,7 @@ function FieldControl({
|
|
|
2868
2868
|
inputMode: inputModeForMask(mask),
|
|
2869
2869
|
maxLength: maxLengthForMask(mask),
|
|
2870
2870
|
readOnly: readonly,
|
|
2871
|
-
value: mask ? formatMaskedValue(
|
|
2871
|
+
value: mask ? formatMaskedValue(value2, mask) : value2,
|
|
2872
2872
|
...invalidProps,
|
|
2873
2873
|
onChange: (event) => onChange(parseMaskedInput(event.currentTarget.value, mask))
|
|
2874
2874
|
}
|
|
@@ -2900,7 +2900,7 @@ function GroupSection({
|
|
|
2900
2900
|
values,
|
|
2901
2901
|
initialValue: initialValues[field.field],
|
|
2902
2902
|
error: errors[field.field],
|
|
2903
|
-
onChange: (
|
|
2903
|
+
onChange: (value2) => onChange(field.field, value2)
|
|
2904
2904
|
},
|
|
2905
2905
|
field.field
|
|
2906
2906
|
)) })
|
|
@@ -2953,15 +2953,15 @@ function InlineParentForm({
|
|
|
2953
2953
|
onDirtyChange?.(dirty);
|
|
2954
2954
|
}, [dirty, onDirtyChange]);
|
|
2955
2955
|
const fieldsByName = useMemo6(() => new Map(fields.map((field) => [field.field, field])), [rawFields]);
|
|
2956
|
-
const change = (fieldName,
|
|
2956
|
+
const change = (fieldName, value2) => {
|
|
2957
2957
|
const selected = fieldsByName.get(fieldName);
|
|
2958
2958
|
if (selected?.readonly || selected?.computed) return;
|
|
2959
2959
|
const dependentFields = fields.filter(
|
|
2960
2960
|
(candidate) => Object.values(candidate.referenceFilterFrom ?? {}).includes(fieldName)
|
|
2961
2961
|
);
|
|
2962
2962
|
setValues((current) => {
|
|
2963
|
-
const changed = current[fieldName] !==
|
|
2964
|
-
const next = { ...current, [fieldName]:
|
|
2963
|
+
const changed = current[fieldName] !== value2;
|
|
2964
|
+
const next = { ...current, [fieldName]: value2 };
|
|
2965
2965
|
if (changed) dependentFields.forEach((candidate) => {
|
|
2966
2966
|
next[candidate.field] = "";
|
|
2967
2967
|
});
|
|
@@ -3001,7 +3001,7 @@ function InlineParentForm({
|
|
|
3001
3001
|
values,
|
|
3002
3002
|
initialValue: parent[field.field],
|
|
3003
3003
|
error: combinedErrors[field.field],
|
|
3004
|
-
onChange: (
|
|
3004
|
+
onChange: (value2) => change(field.field, value2)
|
|
3005
3005
|
},
|
|
3006
3006
|
field.field
|
|
3007
3007
|
)) });
|
|
@@ -3395,11 +3395,11 @@ var DEFAULT_EXCLUDED_STAGES = [
|
|
|
3395
3395
|
"rejeitada",
|
|
3396
3396
|
"rejected"
|
|
3397
3397
|
];
|
|
3398
|
-
function normalized(
|
|
3399
|
-
return String(
|
|
3398
|
+
function normalized(value2) {
|
|
3399
|
+
return String(value2 ?? "").normalize("NFD").replace(/[\u0300-\u036f]/g, "").trim().toLowerCase();
|
|
3400
3400
|
}
|
|
3401
|
-
function slug(
|
|
3402
|
-
return normalized(
|
|
3401
|
+
function slug(value2) {
|
|
3402
|
+
return normalized(value2).replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
|
|
3403
3403
|
}
|
|
3404
3404
|
function approvalTone(action) {
|
|
3405
3405
|
const key = normalized(`${action.id ?? ""} ${action.label}`);
|
|
@@ -3407,8 +3407,8 @@ function approvalTone(action) {
|
|
|
3407
3407
|
if (/aprovar|approve/.test(key)) return "success";
|
|
3408
3408
|
return void 0;
|
|
3409
3409
|
}
|
|
3410
|
-
function workStatusPresentation(
|
|
3411
|
-
const key = normalized(
|
|
3410
|
+
function workStatusPresentation(value2) {
|
|
3411
|
+
const key = normalized(value2);
|
|
3412
3412
|
if (/aguardando.*inicio|nao.*iniciado|waiting/.test(key)) {
|
|
3413
3413
|
return { order: 0, label: "Aguardando in\xEDcio", tone: "warning" };
|
|
3414
3414
|
}
|
|
@@ -3486,14 +3486,14 @@ function resolvePipelineActions({
|
|
|
3486
3486
|
});
|
|
3487
3487
|
}
|
|
3488
3488
|
if (config?.workStatus !== false && !hasExplicitWorkStatus && workStatusValues.length) {
|
|
3489
|
-
workStatusValues.map((
|
|
3489
|
+
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
3490
|
resolved.push({
|
|
3491
|
-
id: `core-status-trabalho-${slug(
|
|
3491
|
+
id: `core-status-trabalho-${slug(value2)}`,
|
|
3492
3492
|
label: presentation.label,
|
|
3493
3493
|
type: "setField",
|
|
3494
3494
|
field: workStatusField,
|
|
3495
|
-
value,
|
|
3496
|
-
disabledWhen: { field: workStatusField, equals:
|
|
3495
|
+
value: value2,
|
|
3496
|
+
disabledWhen: { field: workStatusField, equals: value2 },
|
|
3497
3497
|
refresh: ["all"],
|
|
3498
3498
|
group: "workStatus",
|
|
3499
3499
|
tone: presentation.tone,
|
|
@@ -3540,8 +3540,8 @@ function mergeFormFields2(metadataFields, overrides) {
|
|
|
3540
3540
|
});
|
|
3541
3541
|
return merged;
|
|
3542
3542
|
}
|
|
3543
|
-
function workStatusColor(
|
|
3544
|
-
const normalized2 = String(
|
|
3543
|
+
function workStatusColor(value2) {
|
|
3544
|
+
const normalized2 = String(value2 ?? "").normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
|
|
3545
3545
|
if (/aguardando.*inicio|nao.*iniciado|waiting/.test(normalized2)) return "#D97706";
|
|
3546
3546
|
if (/trabalhando|em.*andamento|working/.test(normalized2)) return "#16A34A";
|
|
3547
3547
|
if (/revisar|revisao|review/.test(normalized2)) return "#DC2626";
|
|
@@ -3553,7 +3553,7 @@ function PipelineArrowIcon({ direction }) {
|
|
|
3553
3553
|
}
|
|
3554
3554
|
function PipelineFilterControl({
|
|
3555
3555
|
filter,
|
|
3556
|
-
value,
|
|
3556
|
+
value: value2,
|
|
3557
3557
|
meta,
|
|
3558
3558
|
onChange
|
|
3559
3559
|
}) {
|
|
@@ -3565,8 +3565,8 @@ function PipelineFilterControl({
|
|
|
3565
3565
|
inputId: `pipeline-filter-${filter.field}`,
|
|
3566
3566
|
label: filter.label ?? filter.field,
|
|
3567
3567
|
refModel: meta.ref,
|
|
3568
|
-
value: String(
|
|
3569
|
-
initialValue:
|
|
3568
|
+
value: String(value2 ?? ""),
|
|
3569
|
+
initialValue: value2,
|
|
3570
3570
|
required: false,
|
|
3571
3571
|
invalid: false,
|
|
3572
3572
|
filters: {},
|
|
@@ -3577,7 +3577,7 @@ function PipelineFilterControl({
|
|
|
3577
3577
|
}
|
|
3578
3578
|
if (filter.type === "select") {
|
|
3579
3579
|
return /* @__PURE__ */ jsxs13(NativeSelect5.Root, { size: "sm", w: "190px", children: [
|
|
3580
|
-
/* @__PURE__ */ jsx19(NativeSelect5.Field, { value: String(
|
|
3580
|
+
/* @__PURE__ */ jsx19(NativeSelect5.Field, { value: String(value2 ?? ""), onChange: (event) => onChange(event.currentTarget.value), children: (filter.options ?? []).map((option) => /* @__PURE__ */ jsx19("option", { value: String(option.value ?? ""), children: option.label }, String(option.value ?? ""))) }),
|
|
3581
3581
|
/* @__PURE__ */ jsx19(NativeSelect5.Indicator, {})
|
|
3582
3582
|
] });
|
|
3583
3583
|
}
|
|
@@ -3589,7 +3589,7 @@ function PipelineFilterControl({
|
|
|
3589
3589
|
fontSize: "11px",
|
|
3590
3590
|
type: filter.type === "date" ? "date" : "text",
|
|
3591
3591
|
placeholder: filter.placeholder ?? filter.label ?? filter.field,
|
|
3592
|
-
value: String(
|
|
3592
|
+
value: String(value2 ?? ""),
|
|
3593
3593
|
onChange: (event) => onChange(event.currentTarget.value)
|
|
3594
3594
|
}
|
|
3595
3595
|
);
|
|
@@ -3629,7 +3629,7 @@ function CorePipeline({
|
|
|
3629
3629
|
const boardRef = useRef3(null);
|
|
3630
3630
|
const [boardScrollState, setBoardScrollState] = useState11({ canScrollLeft: false, canScrollRight: false });
|
|
3631
3631
|
const effectiveFilters = Object.fromEntries(
|
|
3632
|
-
Object.entries(filterValues).filter(([,
|
|
3632
|
+
Object.entries(filterValues).filter(([, value2]) => value2 !== "" && value2 != null)
|
|
3633
3633
|
);
|
|
3634
3634
|
const listQuery = useQuery7({
|
|
3635
3635
|
queryKey: ["oon", "pipeline", basePath, effectiveFilters],
|
|
@@ -3762,7 +3762,7 @@ function CorePipeline({
|
|
|
3762
3762
|
filter,
|
|
3763
3763
|
value: filterValues[filter.field],
|
|
3764
3764
|
meta,
|
|
3765
|
-
onChange: (
|
|
3765
|
+
onChange: (value2) => setFilterValues((current) => ({ ...current, [filter.field]: value2 }))
|
|
3766
3766
|
}
|
|
3767
3767
|
)
|
|
3768
3768
|
] }, filter.field);
|
|
@@ -4006,20 +4006,20 @@ function CoreDashboard({ label = "Dashboard", widgets = [] }) {
|
|
|
4006
4006
|
return /* @__PURE__ */ jsx20(Box12, { borderWidth: "1px", borderColor: "gray.200", borderRadius: "md", bg: "white", p: 5, children: w.render() }, w.id);
|
|
4007
4007
|
}
|
|
4008
4008
|
const q = queries[queryIdx++];
|
|
4009
|
-
const
|
|
4009
|
+
const value2 = q?.isLoading ? "\u2026" : q?.isError ? "\u2014" : formatWidget(q?.data, w.kind, w.field);
|
|
4010
4010
|
return /* @__PURE__ */ jsxs14(Box12, { borderWidth: "1px", borderColor: "gray.200", borderRadius: "md", bg: "white", p: 5, children: [
|
|
4011
4011
|
/* @__PURE__ */ jsx20(Text13, { fontSize: "sm", color: "gray.500", children: w.label }),
|
|
4012
|
-
/* @__PURE__ */ jsx20(Heading6, { size: "xl", mt: 1, children:
|
|
4012
|
+
/* @__PURE__ */ jsx20(Heading6, { size: "xl", mt: 1, children: value2 })
|
|
4013
4013
|
] }, w.id);
|
|
4014
4014
|
}) })
|
|
4015
4015
|
] });
|
|
4016
4016
|
}
|
|
4017
|
-
function formatWidget(
|
|
4018
|
-
if (
|
|
4017
|
+
function formatWidget(value2, kind, field) {
|
|
4018
|
+
if (value2 == null) return "\u2014";
|
|
4019
4019
|
if (kind === "sum" && field?.toLowerCase().includes("valor") || kind === "sum") {
|
|
4020
|
-
return new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(Number(
|
|
4020
|
+
return new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(Number(value2));
|
|
4021
4021
|
}
|
|
4022
|
-
return String(
|
|
4022
|
+
return String(value2);
|
|
4023
4023
|
}
|
|
4024
4024
|
|
|
4025
4025
|
// src/components/ui-v2/CorePage.tsx
|
|
@@ -4169,8 +4169,8 @@ function CorePage2({ page, registry }) {
|
|
|
4169
4169
|
|
|
4170
4170
|
// src/app/moduleRegistry.tsx
|
|
4171
4171
|
import { jsx as jsx25 } from "react/jsx-runtime";
|
|
4172
|
-
function slug2(
|
|
4173
|
-
return
|
|
4172
|
+
function slug2(value2) {
|
|
4173
|
+
return value2.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
4174
4174
|
}
|
|
4175
4175
|
function requiredAccess2(source) {
|
|
4176
4176
|
const values = [...source.permissions ?? [], ...source.capabilities ?? []].filter(Boolean);
|
|
@@ -4422,46 +4422,273 @@ function Sidebar({ app, menu, registry }) {
|
|
|
4422
4422
|
);
|
|
4423
4423
|
}
|
|
4424
4424
|
|
|
4425
|
+
// package.json
|
|
4426
|
+
var package_default = {
|
|
4427
|
+
name: "@oondemand/oon-core-front",
|
|
4428
|
+
version: "0.3.53",
|
|
4429
|
+
repository: {
|
|
4430
|
+
type: "git",
|
|
4431
|
+
url: "git+https://github.com/oondemand/oon-platform.git",
|
|
4432
|
+
directory: "packages/oonCore-front"
|
|
4433
|
+
},
|
|
4434
|
+
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).",
|
|
4435
|
+
type: "module",
|
|
4436
|
+
main: "dist/index.js",
|
|
4437
|
+
module: "dist/index.js",
|
|
4438
|
+
types: "dist/index.d.ts",
|
|
4439
|
+
exports: {
|
|
4440
|
+
".": {
|
|
4441
|
+
types: "./dist/index.d.ts",
|
|
4442
|
+
import: "./dist/index.js"
|
|
4443
|
+
}
|
|
4444
|
+
},
|
|
4445
|
+
bin: {
|
|
4446
|
+
"oonCore-front": "bin/cli.js"
|
|
4447
|
+
},
|
|
4448
|
+
files: [
|
|
4449
|
+
"bin",
|
|
4450
|
+
"dist",
|
|
4451
|
+
"README.md"
|
|
4452
|
+
],
|
|
4453
|
+
scripts: {
|
|
4454
|
+
build: "tsup",
|
|
4455
|
+
prepublishOnly: "npm run build",
|
|
4456
|
+
typecheck: "tsc --noEmit",
|
|
4457
|
+
test: "vitest run"
|
|
4458
|
+
},
|
|
4459
|
+
engines: {
|
|
4460
|
+
node: ">=18"
|
|
4461
|
+
},
|
|
4462
|
+
keywords: [
|
|
4463
|
+
"oondemand",
|
|
4464
|
+
"ooncore",
|
|
4465
|
+
"central",
|
|
4466
|
+
"frontend",
|
|
4467
|
+
"metadata-driven",
|
|
4468
|
+
"react",
|
|
4469
|
+
"vite"
|
|
4470
|
+
],
|
|
4471
|
+
license: "SEE LICENSE IN LICENSE",
|
|
4472
|
+
publishConfig: {
|
|
4473
|
+
access: "public"
|
|
4474
|
+
},
|
|
4475
|
+
dependencies: {
|
|
4476
|
+
axios: "^1.7.7"
|
|
4477
|
+
},
|
|
4478
|
+
peerDependencies: {
|
|
4479
|
+
"@chakra-ui/react": "^3.0.0",
|
|
4480
|
+
"@tanstack/react-query": "^5.0.0",
|
|
4481
|
+
"@tanstack/react-table": "^8.0.0",
|
|
4482
|
+
react: "^18.0.0",
|
|
4483
|
+
"react-dom": "^18.0.0",
|
|
4484
|
+
"react-router-dom": "^6.0.0"
|
|
4485
|
+
},
|
|
4486
|
+
devDependencies: {
|
|
4487
|
+
"@testing-library/dom": "^10.4.1",
|
|
4488
|
+
"@testing-library/react": "^16.3.2",
|
|
4489
|
+
"@types/react": "^18.3.18",
|
|
4490
|
+
"@types/react-dom": "^18.3.5",
|
|
4491
|
+
"happy-dom": "^20.10.2",
|
|
4492
|
+
tsup: "^8.5.1",
|
|
4493
|
+
typescript: "^5.5.0",
|
|
4494
|
+
vitest: "^2.0.0"
|
|
4495
|
+
}
|
|
4496
|
+
};
|
|
4497
|
+
|
|
4498
|
+
// src/runtime/versionInfo.ts
|
|
4499
|
+
function value(...candidates) {
|
|
4500
|
+
return candidates.find((candidate) => typeof candidate === "string" && candidate.trim())?.trim();
|
|
4501
|
+
}
|
|
4502
|
+
function browserBuildEnvironment() {
|
|
4503
|
+
return import.meta.env ?? {};
|
|
4504
|
+
}
|
|
4505
|
+
function resolveRuntimeVersionInfo(app, metadata, environment = browserBuildEnvironment()) {
|
|
4506
|
+
const extended = metadata;
|
|
4507
|
+
const runtime = extended?.runtime;
|
|
4508
|
+
const deployment = runtime?.deployment;
|
|
4509
|
+
return {
|
|
4510
|
+
centralVersion: value(
|
|
4511
|
+
environment.VITE_OON_CENTRAL_VERSION,
|
|
4512
|
+
app.version,
|
|
4513
|
+
runtime?.central?.version
|
|
4514
|
+
),
|
|
4515
|
+
coreFrontVersion: package_default.version,
|
|
4516
|
+
coreBackVersion: value(runtime?.core?.backendVersion, metadata?.service?.version),
|
|
4517
|
+
updatedAt: value(
|
|
4518
|
+
environment.VITE_OON_BUILD_TIME,
|
|
4519
|
+
deployment?.builtAt,
|
|
4520
|
+
deployment?.startedAt
|
|
4521
|
+
),
|
|
4522
|
+
startedAt: deployment?.startedAt,
|
|
4523
|
+
commit: value(environment.VITE_OON_BUILD_COMMIT, deployment?.commit),
|
|
4524
|
+
releaseId: value(environment.VITE_OON_RELEASE_ID, deployment?.releaseId),
|
|
4525
|
+
environment: value(environment.VITE_OON_ENVIRONMENT, deployment?.environment)
|
|
4526
|
+
};
|
|
4527
|
+
}
|
|
4528
|
+
function formatRuntimeDate(valueToFormat) {
|
|
4529
|
+
if (!valueToFormat) return void 0;
|
|
4530
|
+
const date = new Date(valueToFormat);
|
|
4531
|
+
if (Number.isNaN(date.getTime())) return valueToFormat;
|
|
4532
|
+
return new Intl.DateTimeFormat("pt-BR", {
|
|
4533
|
+
day: "2-digit",
|
|
4534
|
+
month: "2-digit",
|
|
4535
|
+
year: "numeric",
|
|
4536
|
+
hour: "2-digit",
|
|
4537
|
+
minute: "2-digit",
|
|
4538
|
+
hour12: false
|
|
4539
|
+
}).format(date);
|
|
4540
|
+
}
|
|
4541
|
+
function shortCommit(commit) {
|
|
4542
|
+
if (!commit) return void 0;
|
|
4543
|
+
return commit.length > 8 ? commit.slice(0, 8) : commit;
|
|
4544
|
+
}
|
|
4545
|
+
|
|
4425
4546
|
// src/shell/DefaultShell.tsx
|
|
4426
4547
|
import { jsx as jsx27, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
4427
4548
|
function CoreTopbar({ app }) {
|
|
4428
4549
|
const { user, logout } = useOonAuth();
|
|
4429
|
-
|
|
4430
|
-
|
|
4431
|
-
|
|
4432
|
-
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4550
|
+
const metadataQuery = useCoreMetadata();
|
|
4551
|
+
const runtime = resolveRuntimeVersionInfo(app, metadataQuery.data);
|
|
4552
|
+
const centralVersion = runtime.centralVersion ?? "n\xE3o informada";
|
|
4553
|
+
const backendVersion = metadataQuery.isLoading ? "carregando" : runtime.coreBackVersion ?? "indispon\xEDvel";
|
|
4554
|
+
const updatedAt = formatRuntimeDate(runtime.updatedAt);
|
|
4555
|
+
const commit = shortCommit(runtime.commit);
|
|
4556
|
+
const publicationParts = [
|
|
4557
|
+
updatedAt ? `Atualizado ${updatedAt}` : void 0,
|
|
4558
|
+
commit ? `commit ${commit}` : void 0,
|
|
4559
|
+
runtime.releaseId ? `release ${runtime.releaseId}` : void 0
|
|
4560
|
+
].filter(Boolean);
|
|
4561
|
+
const details = [
|
|
4562
|
+
`Central ${centralVersion}`,
|
|
4563
|
+
`OonCore front ${runtime.coreFrontVersion}`,
|
|
4564
|
+
`OonCore back ${backendVersion}`,
|
|
4565
|
+
runtime.environment ? `Ambiente ${runtime.environment}` : void 0,
|
|
4566
|
+
runtime.commit ? `Commit ${runtime.commit}` : void 0,
|
|
4567
|
+
runtime.releaseId ? `Release ${runtime.releaseId}` : void 0,
|
|
4568
|
+
runtime.startedAt ? `Backend iniciado ${formatRuntimeDate(runtime.startedAt)}` : void 0
|
|
4569
|
+
].filter(Boolean).join(" \xB7 ");
|
|
4570
|
+
return /* @__PURE__ */ jsxs19(
|
|
4571
|
+
Flex11,
|
|
4572
|
+
{
|
|
4573
|
+
as: "header",
|
|
4574
|
+
align: "center",
|
|
4575
|
+
minH: "64px",
|
|
4576
|
+
px: { base: 4, lg: 6 },
|
|
4577
|
+
py: 3,
|
|
4578
|
+
borderBottomWidth: "1px",
|
|
4579
|
+
borderColor: "#E8ECEF",
|
|
4580
|
+
bg: "rgba(255, 255, 255, 0.96)",
|
|
4581
|
+
backdropFilter: "blur(10px)",
|
|
4582
|
+
position: "sticky",
|
|
4583
|
+
top: 0,
|
|
4584
|
+
zIndex: 10,
|
|
4585
|
+
children: [
|
|
4586
|
+
/* @__PURE__ */ jsxs19(Box17, { minW: 0, title: details, children: [
|
|
4587
|
+
/* @__PURE__ */ jsx27(
|
|
4588
|
+
Text18,
|
|
4589
|
+
{
|
|
4590
|
+
fontSize: "xs",
|
|
4591
|
+
fontWeight: "600",
|
|
4592
|
+
color: "brand.500",
|
|
4593
|
+
textTransform: "uppercase",
|
|
4594
|
+
letterSpacing: "0.08em",
|
|
4595
|
+
children: "Central Oon"
|
|
4596
|
+
}
|
|
4597
|
+
),
|
|
4598
|
+
/* @__PURE__ */ jsx27(Text18, { fontSize: "sm", fontWeight: "600", color: "#24323A", children: app.title ?? app.name }),
|
|
4599
|
+
/* @__PURE__ */ jsxs19(Text18, { fontSize: "10px", color: "gray.600", lineHeight: "1.35", children: [
|
|
4600
|
+
"Central ",
|
|
4601
|
+
centralVersion,
|
|
4602
|
+
" \xB7 Front ",
|
|
4603
|
+
runtime.coreFrontVersion,
|
|
4604
|
+
" \xB7 Back ",
|
|
4605
|
+
backendVersion
|
|
4606
|
+
] }),
|
|
4607
|
+
publicationParts.length ? /* @__PURE__ */ jsx27(Text18, { fontSize: "10px", color: "gray.500", lineHeight: "1.35", children: publicationParts.join(" \xB7 ") }) : null
|
|
4608
|
+
] }),
|
|
4609
|
+
/* @__PURE__ */ jsx27(Spacer2, {}),
|
|
4610
|
+
user ? /* @__PURE__ */ jsxs19(Flex11, { align: "center", gap: 3, children: [
|
|
4611
|
+
/* @__PURE__ */ jsxs19(Box17, { textAlign: "right", display: { base: "none", md: "block" }, children: [
|
|
4612
|
+
/* @__PURE__ */ jsx27(Text18, { fontSize: "sm", fontWeight: "600", color: "#24323A", children: user.nome }),
|
|
4613
|
+
user.email ? /* @__PURE__ */ jsx27(Text18, { fontSize: "xs", color: "gray.500", children: user.email }) : null
|
|
4614
|
+
] }),
|
|
4615
|
+
/* @__PURE__ */ jsx27(
|
|
4616
|
+
Button11,
|
|
4617
|
+
{
|
|
4618
|
+
size: "sm",
|
|
4619
|
+
variant: "outline",
|
|
4620
|
+
colorPalette: "brand",
|
|
4621
|
+
borderRadius: "8px",
|
|
4622
|
+
onClick: logout,
|
|
4623
|
+
children: "Sair"
|
|
4624
|
+
}
|
|
4625
|
+
)
|
|
4626
|
+
] }) : null
|
|
4627
|
+
]
|
|
4628
|
+
}
|
|
4629
|
+
);
|
|
4443
4630
|
}
|
|
4444
|
-
function Slot({
|
|
4631
|
+
function Slot({
|
|
4632
|
+
name,
|
|
4633
|
+
slot,
|
|
4634
|
+
registry,
|
|
4635
|
+
app,
|
|
4636
|
+
menu
|
|
4637
|
+
}) {
|
|
4445
4638
|
if (slot === "none") return null;
|
|
4446
4639
|
if (slot?.startsWith("custom:")) {
|
|
4447
|
-
const
|
|
4448
|
-
return
|
|
4640
|
+
const Component = resolveComponent(registry, slot, "layoutSlots");
|
|
4641
|
+
return Component ? /* @__PURE__ */ jsx27(Component, { app, menu }) : /* @__PURE__ */ jsx27(MissingRenderer, { renderer: slot });
|
|
4449
4642
|
}
|
|
4450
4643
|
if (name === "sidebar") return /* @__PURE__ */ jsx27(Sidebar, { app, menu, registry });
|
|
4451
4644
|
if (name === "topbar") return /* @__PURE__ */ jsx27(CoreTopbar, { app });
|
|
4452
|
-
if (name === "footer" && slot === "core")
|
|
4645
|
+
if (name === "footer" && slot === "core") {
|
|
4646
|
+
return /* @__PURE__ */ jsx27(Box17, { as: "footer", px: 6, py: 4, color: "gray.500", fontSize: "xs", borderTopWidth: "1px", children: "OonCore" });
|
|
4647
|
+
}
|
|
4453
4648
|
return null;
|
|
4454
4649
|
}
|
|
4455
|
-
function DefaultShell({
|
|
4650
|
+
function DefaultShell({
|
|
4651
|
+
app,
|
|
4652
|
+
menu,
|
|
4653
|
+
layout,
|
|
4654
|
+
registry
|
|
4655
|
+
}) {
|
|
4456
4656
|
const portal = layout?.shell === "portal" || layout?.shell === "content-only";
|
|
4457
4657
|
const mainPadding = portal ? { base: 4, lg: 10 } : { base: 4, lg: 6 };
|
|
4458
4658
|
return /* @__PURE__ */ jsxs19(Flex11, { align: "stretch", minH: "100vh", bg: portal ? "white" : "#F8F9FA", children: [
|
|
4459
|
-
/* @__PURE__ */ jsx27(
|
|
4659
|
+
/* @__PURE__ */ jsx27(
|
|
4660
|
+
Slot,
|
|
4661
|
+
{
|
|
4662
|
+
name: "sidebar",
|
|
4663
|
+
slot: layout?.sidebar ?? "core",
|
|
4664
|
+
registry,
|
|
4665
|
+
app,
|
|
4666
|
+
menu
|
|
4667
|
+
}
|
|
4668
|
+
),
|
|
4460
4669
|
/* @__PURE__ */ jsxs19(Flex11, { direction: "column", flex: "1", minW: 0, children: [
|
|
4461
|
-
/* @__PURE__ */ jsx27(
|
|
4670
|
+
/* @__PURE__ */ jsx27(
|
|
4671
|
+
Slot,
|
|
4672
|
+
{
|
|
4673
|
+
name: "topbar",
|
|
4674
|
+
slot: layout?.topbar ?? "core",
|
|
4675
|
+
registry,
|
|
4676
|
+
app,
|
|
4677
|
+
menu
|
|
4678
|
+
}
|
|
4679
|
+
),
|
|
4462
4680
|
/* @__PURE__ */ jsx27(Slot, { name: "header", slot: layout?.header, registry, app, menu }),
|
|
4463
4681
|
/* @__PURE__ */ jsx27(Box17, { as: "main", flex: "1", p: mainPadding, minW: 0, children: /* @__PURE__ */ jsx27(Box17, { maxW: portal ? "1180px" : "1680px", mx: "auto", children: /* @__PURE__ */ jsx27(Outlet, {}) }) }),
|
|
4464
|
-
/* @__PURE__ */ jsx27(
|
|
4682
|
+
/* @__PURE__ */ jsx27(
|
|
4683
|
+
Slot,
|
|
4684
|
+
{
|
|
4685
|
+
name: "footer",
|
|
4686
|
+
slot: layout?.footer ?? "none",
|
|
4687
|
+
registry,
|
|
4688
|
+
app,
|
|
4689
|
+
menu
|
|
4690
|
+
}
|
|
4691
|
+
)
|
|
4465
4692
|
] })
|
|
4466
4693
|
] });
|
|
4467
4694
|
}
|
|
@@ -4607,12 +4834,12 @@ import {
|
|
|
4607
4834
|
import { Navigate as Navigate2, useLocation as useLocation2 } from "react-router-dom";
|
|
4608
4835
|
import { jsx as jsx31, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
4609
4836
|
function safeRedirect(search) {
|
|
4610
|
-
const
|
|
4611
|
-
if (!
|
|
4612
|
-
if (
|
|
4837
|
+
const value2 = new URLSearchParams(search).get("redirect") || "/";
|
|
4838
|
+
if (!value2.startsWith("/") || value2.startsWith("//")) return "/";
|
|
4839
|
+
if (value2.startsWith("/login") || value2.startsWith("/acesso-negado")) {
|
|
4613
4840
|
return "/";
|
|
4614
4841
|
}
|
|
4615
|
-
return
|
|
4842
|
+
return value2;
|
|
4616
4843
|
}
|
|
4617
4844
|
function LoginPage({ app }) {
|
|
4618
4845
|
const { status, login } = useOonAuth();
|