@oondemand/oon-core-front 0.3.14 → 0.3.16

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 CHANGED
@@ -674,8 +674,9 @@ interface CoreCollectionProps {
674
674
  list?: OonCollectionListConfig;
675
675
  relations?: Record<string, OonRelationDef>;
676
676
  detailModal?: OonDetailModalConfig;
677
+ cellRenderers?: OonComponentRegistry["cellRenderers"];
677
678
  }
678
- declare function CoreCollection({ model, label, section, mode, endpoint, columns, form, importExport, list, relations, detailModal }: CoreCollectionProps): react.JSX.Element;
679
+ declare function CoreCollection({ model, label, section, mode, endpoint, columns, form, importExport, list, relations, detailModal, cellRenderers }: CoreCollectionProps): react.JSX.Element;
679
680
 
680
681
  interface CoreDocumentProps {
681
682
  model: string;
package/dist/index.js CHANGED
@@ -787,6 +787,12 @@ function renderCell(value, kind) {
787
787
  }
788
788
  return formatted;
789
789
  }
790
+ function renderColumnCell(row, column, cellRenderers) {
791
+ const value = row[column.field];
792
+ const Renderer = column.renderer ? cellRenderers?.[column.renderer] : void 0;
793
+ if (Renderer) return /* @__PURE__ */ jsx7(Renderer, { value, row, column });
794
+ return renderCell(value, column.kind);
795
+ }
790
796
  function DataGrid({
791
797
  resource,
792
798
  resourceKey,
@@ -798,7 +804,8 @@ function DataGrid({
798
804
  toolbarExtra,
799
805
  filters = [],
800
806
  queryExtra,
801
- renderRowActions
807
+ renderRowActions,
808
+ cellRenderers
802
809
  }) {
803
810
  const [pageIndex, setPageIndex] = useState3(0);
804
811
  const [pageSize, setPageSize] = useState3(20);
@@ -904,7 +911,7 @@ function DataGrid({
904
911
  actionCount ? /* @__PURE__ */ jsx7(Table.ColumnHeader, { w: "84px", h: "39px", px: "10px", py: "8px", color: "#667085", borderBottomWidth: "1px", borderColor: "#D5DDE3", fontSize: "10px", fontWeight: "600", textAlign: "center", children: "A\xE7\xF5es" }) : null
905
912
  ] }) }),
906
913
  /* @__PURE__ */ jsx7(Table.Body, { children: rows.length === 0 ? /* @__PURE__ */ jsx7(Table.Row, { children: /* @__PURE__ */ jsx7(Table.Cell, { colSpan: columns.length + actionCount, children: /* @__PURE__ */ jsx7(Text3, { minH: "140px", display: "grid", placeItems: "center", color: "#98A2B3", fontSize: "12px", children: "Nenhum registro encontrado." }) }) }) : rows.map((row, index) => /* @__PURE__ */ jsxs3(Table.Row, { bg: index % 2 ? "#FBFCFD" : "white", _hover: { bg: "#F0F7FF" }, children: [
907
- columns.map((column) => /* @__PURE__ */ jsx7(Table.Cell, { maxW: "250px", h: "42px", px: "10px", py: "8px", overflow: "hidden", color: "#52606D", borderBottomWidth: "1px", borderColor: "#EEF1F3", fontSize: "11px", textOverflow: "ellipsis", whiteSpace: "nowrap", children: renderCell(row[column.field], column.kind) }, column.field)),
914
+ columns.map((column) => /* @__PURE__ */ jsx7(Table.Cell, { maxW: "250px", h: "42px", px: "10px", py: "8px", overflow: "hidden", color: "#52606D", borderBottomWidth: "1px", borderColor: "#EEF1F3", fontSize: "11px", textOverflow: "ellipsis", whiteSpace: "nowrap", children: renderColumnCell(row, column, cellRenderers) }, column.field)),
908
915
  actionCount ? /* @__PURE__ */ jsx7(Table.Cell, { h: "42px", px: "10px", py: "5px", borderBottomWidth: "1px", borderColor: "#EEF1F3", textAlign: "center", children: /* @__PURE__ */ jsxs3(Flex2, { justify: "center", gap: "5px", children: [
909
916
  onEdit ? /* @__PURE__ */ jsx7(Button2, { type: "button", "aria-label": "Editar", w: "31px", minW: "31px", h: "31px", p: 0, color: "#667085", bg: "white", borderWidth: "1px", borderColor: "#E5E9ED", borderRadius: "6px", onClick: () => onEdit(row), _hover: { color: "#036491", bg: "#F0F7FF", borderColor: "#B8D9EB" }, children: /* @__PURE__ */ jsx7(EditIcon, {}) }) : null,
910
917
  onDelete ? /* @__PURE__ */ jsx7(Button2, { type: "button", "aria-label": "Excluir", w: "31px", minW: "31px", h: "31px", p: 0, color: "#667085", bg: "white", borderWidth: "1px", borderColor: "#E5E9ED", borderRadius: "6px", onClick: () => onDelete(row), _hover: { color: "#B42318", bg: "#FFF5F5", borderColor: "#FECACA" }, children: /* @__PURE__ */ jsx7(TrashIcon, {}) }) : null,
@@ -1991,7 +1998,7 @@ function mergeFormFields(metadataFields, overrides) {
1991
1998
  });
1992
1999
  return merged;
1993
2000
  }
1994
- function CoreCollection({ model, label, section = "Cole\xE7\xE3o", mode = "dynamic", endpoint, columns, form, importExport, list, relations, detailModal }) {
2001
+ function CoreCollection({ model, label, section = "Cole\xE7\xE3o", mode = "dynamic", endpoint, columns, form, importExport, list, relations, detailModal, cellRenderers }) {
1995
2002
  const needsSchema = mode !== "full" || !columns || !form || !endpoint;
1996
2003
  const schemaQuery = useModelSchema(needsSchema ? model : "");
1997
2004
  const schema = schemaQuery.data;
@@ -2038,6 +2045,7 @@ function CoreCollection({ model, label, section = "Cole\xE7\xE3o", mode = "dynam
2038
2045
  resourceKey: basePath,
2039
2046
  columns: resolvedColumns,
2040
2047
  filters: list?.filters,
2048
+ cellRenderers,
2041
2049
  onCreate: () => {
2042
2050
  setFormError(null);
2043
2051
  if (detailModal?.enabled) setDetailState({ open: true });
@@ -2471,7 +2479,7 @@ function viewLabel(view) {
2471
2479
  if (view.type === "dashboard") return "Dashboard";
2472
2480
  return view.model;
2473
2481
  }
2474
- function renderView(view) {
2482
+ function renderView(view, registry) {
2475
2483
  switch (view.type) {
2476
2484
  case "collection": {
2477
2485
  const v = view;
@@ -2487,7 +2495,8 @@ function renderView(view) {
2487
2495
  importExport: v.importExport,
2488
2496
  list: v.list,
2489
2497
  relations: v.relations,
2490
- detailModal: v.detailModal
2498
+ detailModal: v.detailModal,
2499
+ cellRenderers: registry?.cellRenderers
2491
2500
  }
2492
2501
  );
2493
2502
  }
@@ -2515,10 +2524,10 @@ function renderView(view) {
2515
2524
  return null;
2516
2525
  }
2517
2526
  }
2518
- function viewToRoute(view) {
2527
+ function viewToRoute(view, registry) {
2519
2528
  return {
2520
2529
  path: viewPath(view),
2521
- element: renderView(view),
2530
+ element: renderView(view, registry),
2522
2531
  permissions: requiredAccess2(view)
2523
2532
  };
2524
2533
  }
@@ -2543,6 +2552,7 @@ function resolveRegistry(config) {
2543
2552
  const routes = [];
2544
2553
  const menu = [];
2545
2554
  const seenPaths = /* @__PURE__ */ new Set();
2555
+ const componentRegistry = config.registry ?? config.ui?.registry;
2546
2556
  const pushRoute = (route) => {
2547
2557
  if (seenPaths.has(route.path)) return;
2548
2558
  seenPaths.add(route.path);
@@ -2552,7 +2562,7 @@ function resolveRegistry(config) {
2552
2562
  for (const route of mod.routes ?? []) pushRoute({ ...route, permissions: requiredAccess2(route) });
2553
2563
  for (const item of mod.menu ?? []) menu.push({ ...item, permissions: requiredAccess2(item) });
2554
2564
  for (const view of mod.views ?? []) {
2555
- pushRoute(viewToRoute(view));
2565
+ pushRoute(viewToRoute(view, componentRegistry));
2556
2566
  menu.push(viewToMenu(view));
2557
2567
  }
2558
2568
  }
@@ -2561,11 +2571,11 @@ function resolveRegistry(config) {
2561
2571
  const includeManual = navMode === "manual" || navMode === "mixed";
2562
2572
  if (includeAuto) {
2563
2573
  for (const view of config.ui?.views ?? []) {
2564
- pushRoute(viewToRoute(view));
2574
+ pushRoute(viewToRoute(view, componentRegistry));
2565
2575
  menu.push(viewToMenu(view));
2566
2576
  }
2567
2577
  for (const page of config.ui?.pages ?? []) {
2568
- pushRoute(pageToRoute(page, config.registry ?? config.ui?.registry));
2578
+ pushRoute(pageToRoute(page, componentRegistry));
2569
2579
  const item = pageToMenu(page);
2570
2580
  if (item) menu.push(item);
2571
2581
  }