@oondemand/oon-core-front 0.4.10 → 0.4.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +5 -2
- package/dist/index.js +8 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -237,11 +237,14 @@ interface OonModule {
|
|
|
237
237
|
views?: OonViewDefinition[];
|
|
238
238
|
}
|
|
239
239
|
type CollectionMode = "full" | "minimal" | "dynamic";
|
|
240
|
+
type OonValueFormat = "text" | "number" | "currency" | "percent" | "date" | "datetime" | "badge";
|
|
240
241
|
interface OonColumnDef {
|
|
241
242
|
field: string;
|
|
242
243
|
label?: string;
|
|
243
244
|
/** kind sobrescreve o inferido da metadata. */
|
|
244
245
|
kind?: FieldKind;
|
|
246
|
+
/** Formato de apresentação; datetime preserva data e hora no locale do usuário. */
|
|
247
|
+
format?: OonValueFormat;
|
|
245
248
|
sortable?: boolean;
|
|
246
249
|
width?: number;
|
|
247
250
|
renderer?: string;
|
|
@@ -362,7 +365,7 @@ type OonRelationDef = {
|
|
|
362
365
|
type OonRelatedGridColumnDef = OonColumnDef & {
|
|
363
366
|
editable?: boolean;
|
|
364
367
|
readonly?: boolean;
|
|
365
|
-
format?:
|
|
368
|
+
format?: OonValueFormat;
|
|
366
369
|
editor?: "string" | "number" | "currency" | "date" | "enum" | "select" | "ref" | "boolean" | "textarea";
|
|
367
370
|
hidden?: boolean;
|
|
368
371
|
roles?: string[];
|
|
@@ -375,7 +378,7 @@ type OonSummaryCardDef = {
|
|
|
375
378
|
field?: string;
|
|
376
379
|
relation?: string | OonRelationDef;
|
|
377
380
|
metric?: string;
|
|
378
|
-
format?:
|
|
381
|
+
format?: OonValueFormat;
|
|
379
382
|
};
|
|
380
383
|
type OonDetailTabDef = {
|
|
381
384
|
id: string;
|
package/dist/index.js
CHANGED
|
@@ -1053,7 +1053,7 @@ function formFieldsFromMeta(fields) {
|
|
|
1053
1053
|
};
|
|
1054
1054
|
});
|
|
1055
1055
|
}
|
|
1056
|
-
function formatCell(value3, kind) {
|
|
1056
|
+
function formatCell(value3, kind, format2) {
|
|
1057
1057
|
if (value3 == null || value3 === "") return "\u2014";
|
|
1058
1058
|
if (value3 && typeof value3 === "object" && !Array.isArray(value3) && kind !== "date") {
|
|
1059
1059
|
return referenceOptionLabel(value3);
|
|
@@ -1063,7 +1063,8 @@ function formatCell(value3, kind) {
|
|
|
1063
1063
|
return value3 ? "Sim" : "N\xE3o";
|
|
1064
1064
|
case "date":
|
|
1065
1065
|
try {
|
|
1066
|
-
|
|
1066
|
+
const date = new Date(value3);
|
|
1067
|
+
return format2 === "datetime" ? date.toLocaleString("pt-BR", { dateStyle: "short", timeStyle: "short" }) : date.toLocaleDateString("pt-BR");
|
|
1067
1068
|
} catch {
|
|
1068
1069
|
return String(value3);
|
|
1069
1070
|
}
|
|
@@ -1140,8 +1141,8 @@ function ChevronIcon({ direction }) {
|
|
|
1140
1141
|
function PlusIcon() {
|
|
1141
1142
|
return /* @__PURE__ */ jsx11("svg", { viewBox: "0 0 20 20", width: "17", height: "17", "aria-hidden": "true", children: /* @__PURE__ */ jsx11("path", { d: "M10 4v12M4 10h12", fill: "none", stroke: "currentColor", strokeWidth: "1.6", strokeLinecap: "round" }) });
|
|
1142
1143
|
}
|
|
1143
|
-
function renderCell(value3, kind) {
|
|
1144
|
-
const formatted = formatCell(value3, kind);
|
|
1144
|
+
function renderCell(value3, kind, format2) {
|
|
1145
|
+
const formatted = formatCell(value3, kind, format2);
|
|
1145
1146
|
if (kind === "enum") {
|
|
1146
1147
|
const normalized3 = String(value3 ?? "").toLowerCase();
|
|
1147
1148
|
const palette = /erro|cancel|inativo|recus|critica/.test(normalized3) ? "red" : /pendente|aguardando|rascunho/.test(normalized3) ? "orange" : /processando|conferencia|integrando|validando/.test(normalized3) ? "blue" : /ativo|sucesso|conclu|aplicada|disponivel|aprov/.test(normalized3) ? "green" : "gray";
|
|
@@ -1157,7 +1158,7 @@ function renderColumnCell(row, column, cellRenderers) {
|
|
|
1157
1158
|
const value3 = row[column.field];
|
|
1158
1159
|
const Renderer = column.renderer ? cellRenderers?.[column.renderer] : void 0;
|
|
1159
1160
|
if (Renderer) return /* @__PURE__ */ jsx11(Renderer, { value: value3, row, column });
|
|
1160
|
-
return renderCell(value3, column.kind);
|
|
1161
|
+
return renderCell(value3, column.kind, column.format);
|
|
1161
1162
|
}
|
|
1162
1163
|
function DataGrid({
|
|
1163
1164
|
resource,
|
|
@@ -2539,7 +2540,7 @@ import { Fragment as Fragment2, jsx as jsx15, jsxs as jsxs10 } from "react/jsx-r
|
|
|
2539
2540
|
function format(value3, format2) {
|
|
2540
2541
|
if (format2 === "currency") return new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(Number(value3 ?? 0));
|
|
2541
2542
|
if (format2 === "percent") return `${Number(value3 ?? 0).toLocaleString("pt-BR")}%`;
|
|
2542
|
-
if (format2 === "date") return formatCell(value3, "date");
|
|
2543
|
+
if (format2 === "date" || format2 === "datetime") return formatCell(value3, "date", format2);
|
|
2543
2544
|
return value3 == null || value3 === "" ? "\u2014" : String(value3);
|
|
2544
2545
|
}
|
|
2545
2546
|
function RelatedMetric({ card, relation, parent }) {
|
|
@@ -5277,7 +5278,7 @@ function Sidebar({ app, menu, registry }) {
|
|
|
5277
5278
|
// package.json
|
|
5278
5279
|
var package_default = {
|
|
5279
5280
|
name: "@oondemand/oon-core-front",
|
|
5280
|
-
version: "0.4.
|
|
5281
|
+
version: "0.4.11",
|
|
5281
5282
|
repository: {
|
|
5282
5283
|
type: "git",
|
|
5283
5284
|
url: "git+https://github.com/oondemand/oon-platform.git",
|