@oondemand/oon-core-front 0.7.13 → 0.7.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.
@@ -5396,6 +5396,302 @@ function CoreTransactionalEmail() {
5396
5396
  ] });
5397
5397
  }
5398
5398
 
5399
+ // src/components/ui-v2/CoreKit.tsx
5400
+ import {
5401
+ Badge as Badge7,
5402
+ Box as Box20,
5403
+ Button as Button14,
5404
+ Dialog,
5405
+ Drawer,
5406
+ Flex as Flex13,
5407
+ Heading as Heading12,
5408
+ IconButton as IconButton4,
5409
+ Input as Input9,
5410
+ NativeSelect as NativeSelect6,
5411
+ Portal,
5412
+ SimpleGrid as SimpleGrid7,
5413
+ Skeleton,
5414
+ Stack as Stack11,
5415
+ Text as Text21
5416
+ } from "@chakra-ui/react";
5417
+ import { useState as useState13 } from "react";
5418
+ import { Fragment as Fragment6, jsx as jsx24, jsxs as jsxs21 } from "react/jsx-runtime";
5419
+ var STATUS = {
5420
+ contract: {
5421
+ vigente: { label: "Ativo", tone: "success" },
5422
+ ativa: { label: "Ativo", tone: "success" },
5423
+ active: { label: "Ativo", tone: "success" },
5424
+ pendente: { label: "Pendente de ativa\xE7\xE3o", tone: "warning" },
5425
+ pending: { label: "Pendente de ativa\xE7\xE3o", tone: "warning" },
5426
+ suspensa: { label: "Bloqueado", tone: "danger" },
5427
+ bloqueado: { label: "Bloqueado", tone: "danger" },
5428
+ blocked: { label: "Bloqueado", tone: "danger" },
5429
+ encerrada: { label: "Encerrado", tone: "neutral" },
5430
+ expirada: { label: "Encerrado", tone: "neutral" },
5431
+ cancelada: { label: "Encerrado", tone: "neutral" },
5432
+ revogada: { label: "Encerrado", tone: "neutral" }
5433
+ },
5434
+ charge: {
5435
+ aberta: { label: "Em aberto", tone: "info" },
5436
+ open: { label: "Em aberto", tone: "info" },
5437
+ vencida: { label: "Vencida", tone: "danger" },
5438
+ overdue: { label: "Vencida", tone: "danger" },
5439
+ paga: { label: "Paga", tone: "success" },
5440
+ paid: { label: "Paga", tone: "success" },
5441
+ cancelada: { label: "Cancelada", tone: "neutral" },
5442
+ cancelled: { label: "Cancelada", tone: "neutral" }
5443
+ },
5444
+ publication: {
5445
+ publicada: { label: "Publicada", tone: "success" },
5446
+ verified: { label: "Publicada", tone: "success" },
5447
+ cancelada: { label: "Cancelada", tone: "neutral" },
5448
+ excluida: { label: "Cancelada", tone: "neutral" },
5449
+ recovery_required: { label: "Em recupera\xE7\xE3o", tone: "warning" },
5450
+ recovering: { label: "Em recupera\xE7\xE3o", tone: "warning" }
5451
+ },
5452
+ environment: {
5453
+ active: { label: "Ativo", tone: "success" },
5454
+ recovering: { label: "Em recupera\xE7\xE3o", tone: "warning" },
5455
+ publication_failed: { label: "Em recupera\xE7\xE3o", tone: "warning" },
5456
+ provisioning: { label: "Em andamento", tone: "info" },
5457
+ cleanup_requested: { label: "Em andamento", tone: "info" },
5458
+ cleaning: { label: "Em andamento", tone: "info" },
5459
+ never_published: { label: "N\xE3o utilizado", tone: "neutral" },
5460
+ deleted: { label: "Exclu\xEDdo", tone: "neutral" },
5461
+ cleanup_failed: { label: "Em recupera\xE7\xE3o", tone: "warning" }
5462
+ },
5463
+ entity: {
5464
+ ativo: { label: "Ativo", tone: "success" },
5465
+ active: { label: "Ativo", tone: "success" },
5466
+ pendente: { label: "Pendente", tone: "warning" },
5467
+ pending: { label: "Pendente", tone: "warning" },
5468
+ rascunho: { label: "Pendente", tone: "warning" },
5469
+ inativo: { label: "Inativo", tone: "neutral" },
5470
+ inactive: { label: "Inativo", tone: "neutral" },
5471
+ suspenso: { label: "Inativo", tone: "neutral" },
5472
+ arquivado: { label: "Inativo", tone: "neutral" },
5473
+ deleted: { label: "Inativo", tone: "neutral" }
5474
+ }
5475
+ };
5476
+ function coreStatus(kind, status) {
5477
+ const key = String(status ?? "").trim();
5478
+ const known = STATUS[kind]?.[key];
5479
+ if (known) return known;
5480
+ if (kind === "publication") {
5481
+ if (key.startsWith("falha_")) return { label: "Falhou", tone: "danger" };
5482
+ if (key) return { label: "Em andamento", tone: "info" };
5483
+ }
5484
+ return { label: "Indefinido", tone: "neutral" };
5485
+ }
5486
+ var PALETTE = { success: "green", warning: "orange", danger: "red", info: "blue", neutral: "gray" };
5487
+ function CoreStatusBadge({ kind, status, label, tone }) {
5488
+ const view = label ? { label, tone: tone ?? "neutral" } : coreStatus(kind ?? "entity", status);
5489
+ return /* @__PURE__ */ jsx24(Badge7, { colorPalette: PALETTE[view.tone], variant: "subtle", borderRadius: "full", px: 2.5, py: 0.5, fontWeight: "600", children: view.label });
5490
+ }
5491
+ function CoreKpiGrid({ items, loading }) {
5492
+ return /* @__PURE__ */ jsx24(SimpleGrid7, { columns: { base: 1, sm: 2, lg: Math.min(Math.max(items.length, 1), 5) }, gap: 4, children: items.map((item) => /* @__PURE__ */ jsxs21(Box20, { borderWidth: "1px", borderColor: "border.default", borderRadius: "lg", bg: "surface.panel", p: 4, children: [
5493
+ /* @__PURE__ */ jsx24(Text21, { color: "text.muted", fontSize: "sm", children: item.label }),
5494
+ loading ? /* @__PURE__ */ jsx24(Skeleton, { height: "28px", mt: 2 }) : /* @__PURE__ */ jsx24(Text21, { mt: 1, fontSize: "2xl", fontWeight: "700", color: item.tone === "danger" ? "red.600" : item.tone === "success" ? "green.700" : "text.primary", children: item.value }),
5495
+ item.hint ? /* @__PURE__ */ jsx24(Text21, { mt: 1, fontSize: "xs", color: "text.muted", children: item.hint }) : null
5496
+ ] }, item.id)) });
5497
+ }
5498
+ function CoreEmpty({ title, description, action }) {
5499
+ return /* @__PURE__ */ jsxs21(Stack11, { align: "center", textAlign: "center", gap: 2, py: 10, px: 4, children: [
5500
+ /* @__PURE__ */ jsx24(Text21, { fontWeight: "600", color: "text.primary", children: title }),
5501
+ description ? /* @__PURE__ */ jsx24(Text21, { color: "text.muted", fontSize: "sm", maxW: "440px", children: description }) : null,
5502
+ action ? /* @__PURE__ */ jsx24(Box20, { mt: 2, children: action }) : null
5503
+ ] });
5504
+ }
5505
+ function cell(row, column) {
5506
+ if (column.render) return column.render(row);
5507
+ const value2 = row[column.key];
5508
+ return value2 === null || value2 === void 0 || value2 === "" ? "\u2014" : String(value2);
5509
+ }
5510
+ function CoreDataTable({ columns, rows, rowKey, loading, error, empty, search, filters, onRowClick, selectedKey, paging, label }) {
5511
+ const toolbar = search || filters ? /* @__PURE__ */ jsxs21(Flex13, { gap: 2, wrap: "wrap", mb: 3, align: "center", children: [
5512
+ search ? /* @__PURE__ */ jsx24(
5513
+ Input9,
5514
+ {
5515
+ type: "search",
5516
+ "aria-label": search.placeholder ?? "Buscar",
5517
+ placeholder: search.placeholder ?? "Buscar",
5518
+ value: search.value,
5519
+ onChange: (event) => search.onChange(event.target.value),
5520
+ maxW: { base: "100%", md: "320px" },
5521
+ bg: "surface.panel"
5522
+ }
5523
+ ) : null,
5524
+ filters
5525
+ ] }) : null;
5526
+ const body = (() => {
5527
+ if (error) return /* @__PURE__ */ jsx24(Box20, { p: 4, children: error });
5528
+ if (loading) return /* @__PURE__ */ jsx24(Stack11, { p: 4, gap: 3, children: [0, 1, 2].map((i) => /* @__PURE__ */ jsx24(Skeleton, { height: "20px" }, i)) });
5529
+ if (!rows.length) return empty ?? /* @__PURE__ */ jsx24(CoreEmpty, { title: "Nada por aqui ainda" });
5530
+ return /* @__PURE__ */ jsxs21(Fragment6, { children: [
5531
+ /* @__PURE__ */ jsx24(Box20, { display: { base: "none", md: "block" }, overflowX: "auto", children: /* @__PURE__ */ jsxs21(Box20, { as: "table", width: "100%", style: { borderCollapse: "collapse" }, "aria-label": label, children: [
5532
+ /* @__PURE__ */ jsx24(Box20, { as: "thead", children: /* @__PURE__ */ jsx24(Box20, { as: "tr", children: columns.map((column) => /* @__PURE__ */ jsx24(Box20, { as: "th", textAlign: "left", fontSize: "xs", textTransform: "uppercase", letterSpacing: "0.04em", color: "text.muted", px: 3, py: 2.5, borderBottomWidth: "1px", borderColor: "border.default", width: column.width, children: column.header }, column.key)) }) }),
5533
+ /* @__PURE__ */ jsx24(Box20, { as: "tbody", children: rows.map((row) => {
5534
+ const key = rowKey(row);
5535
+ return /* @__PURE__ */ jsx24(
5536
+ Box20,
5537
+ {
5538
+ as: "tr",
5539
+ tabIndex: onRowClick ? 0 : void 0,
5540
+ cursor: onRowClick ? "pointer" : void 0,
5541
+ bg: selectedKey === key ? "brand.50" : void 0,
5542
+ _hover: onRowClick ? { bg: "bg.muted" } : void 0,
5543
+ "aria-selected": selectedKey === key || void 0,
5544
+ onClick: onRowClick ? () => onRowClick(row) : void 0,
5545
+ onKeyDown: onRowClick ? (event) => {
5546
+ if (event.key === "Enter" || event.key === " ") {
5547
+ event.preventDefault();
5548
+ onRowClick(row);
5549
+ }
5550
+ } : void 0,
5551
+ children: columns.map((column) => /* @__PURE__ */ jsx24(Box20, { as: "td", fontSize: "sm", px: 3, py: 3, borderBottomWidth: "1px", borderColor: "border.subtle", children: cell(row, column) }, column.key))
5552
+ },
5553
+ key
5554
+ );
5555
+ }) })
5556
+ ] }) }),
5557
+ /* @__PURE__ */ jsx24(Stack11, { display: { base: "flex", md: "none" }, gap: 2, p: 2, "aria-label": label, children: rows.map((row) => {
5558
+ const key = rowKey(row);
5559
+ return /* @__PURE__ */ jsx24(
5560
+ Box20,
5561
+ {
5562
+ as: onRowClick ? "button" : "div",
5563
+ textAlign: "left",
5564
+ width: "100%",
5565
+ borderWidth: "1px",
5566
+ borderColor: selectedKey === key ? "brand.500" : "border.default",
5567
+ borderRadius: "md",
5568
+ p: 3,
5569
+ onClick: onRowClick ? () => onRowClick(row) : void 0,
5570
+ children: columns.filter((column) => !column.hideOnMobile).map((column, index) => /* @__PURE__ */ jsxs21(Flex13, { justify: "space-between", gap: 3, fontSize: "sm", mt: index ? 1 : 0, children: [
5571
+ /* @__PURE__ */ jsx24(Text21, { color: "text.muted", children: column.header }),
5572
+ /* @__PURE__ */ jsx24(Box20, { textAlign: "right", children: cell(row, column) })
5573
+ ] }, column.key))
5574
+ },
5575
+ key
5576
+ );
5577
+ }) })
5578
+ ] });
5579
+ })();
5580
+ return /* @__PURE__ */ jsxs21(Box20, { children: [
5581
+ toolbar,
5582
+ /* @__PURE__ */ jsx24(Box20, { borderWidth: "1px", borderColor: "border.default", borderRadius: "lg", bg: "surface.panel", overflow: "hidden", children: body }),
5583
+ paging && rows.length ? /* @__PURE__ */ jsxs21(Flex13, { justify: "space-between", align: "center", mt: 3, fontSize: "sm", color: "text.muted", gap: 3, wrap: "wrap", children: [
5584
+ /* @__PURE__ */ jsx24(Text21, { children: paging.total !== void 0 ? `${paging.total} registro(s)` : `P\xE1gina ${paging.page + 1}` }),
5585
+ /* @__PURE__ */ jsxs21(Flex13, { gap: 2, children: [
5586
+ /* @__PURE__ */ jsx24(Button14, { size: "sm", variant: "outline", disabled: paging.page <= 0, onClick: () => paging.onPage(paging.page - 1), children: "Anterior" }),
5587
+ /* @__PURE__ */ jsx24(Button14, { size: "sm", variant: "outline", disabled: paging.hasNext === false || paging.total !== void 0 && (paging.page + 1) * paging.pageSize >= paging.total, onClick: () => paging.onPage(paging.page + 1), children: "Pr\xF3xima" })
5588
+ ] })
5589
+ ] }) : null
5590
+ ] });
5591
+ }
5592
+ function CoreDetailDrawer({ open, onClose, title, status, tabs, actions, children }) {
5593
+ const [tab, setTab] = useState13(tabs?.[0]?.id);
5594
+ const active = tabs?.find((item) => item.id === tab) ?? tabs?.[0];
5595
+ return /* @__PURE__ */ jsx24(Drawer.Root, { open, onOpenChange: (event) => {
5596
+ if (!event.open) onClose();
5597
+ }, placement: "end", size: { base: "full", md: "md" }, children: /* @__PURE__ */ jsxs21(Portal, { children: [
5598
+ /* @__PURE__ */ jsx24(Drawer.Backdrop, {}),
5599
+ /* @__PURE__ */ jsx24(Drawer.Positioner, { children: /* @__PURE__ */ jsxs21(Drawer.Content, { children: [
5600
+ /* @__PURE__ */ jsx24(Drawer.Header, { borderBottomWidth: "1px", borderColor: "border.default", children: /* @__PURE__ */ jsxs21(Flex13, { align: "center", gap: 3, justify: "space-between", width: "100%", children: [
5601
+ /* @__PURE__ */ jsx24(Drawer.Title, { children: title }),
5602
+ /* @__PURE__ */ jsxs21(Flex13, { align: "center", gap: 2, children: [
5603
+ status,
5604
+ /* @__PURE__ */ jsx24(Drawer.CloseTrigger, { asChild: true, children: /* @__PURE__ */ jsx24(IconButton4, { "aria-label": "Fechar", variant: "ghost", size: "sm", children: "\xD7" }) })
5605
+ ] })
5606
+ ] }) }),
5607
+ /* @__PURE__ */ jsx24(Drawer.Body, { children: tabs?.length ? /* @__PURE__ */ jsxs21(Fragment6, { children: [
5608
+ /* @__PURE__ */ jsx24(Flex13, { gap: 4, borderBottomWidth: "1px", borderColor: "border.default", mb: 4, role: "tablist", children: tabs.map((item) => /* @__PURE__ */ jsx24(
5609
+ Button14,
5610
+ {
5611
+ role: "tab",
5612
+ "aria-selected": item.id === active?.id,
5613
+ variant: "plain",
5614
+ px: 0,
5615
+ borderRadius: 0,
5616
+ borderBottomWidth: "2px",
5617
+ borderColor: item.id === active?.id ? "brand.500" : "transparent",
5618
+ color: item.id === active?.id ? "brand.700" : "text.muted",
5619
+ onClick: () => setTab(item.id),
5620
+ children: item.label
5621
+ },
5622
+ item.id
5623
+ )) }),
5624
+ active?.content
5625
+ ] }) : children }),
5626
+ actions ? /* @__PURE__ */ jsx24(Drawer.Footer, { borderTopWidth: "1px", borderColor: "border.default", children: /* @__PURE__ */ jsx24(Flex13, { gap: 2, wrap: "wrap", justify: "flex-end", width: "100%", children: actions }) }) : null
5627
+ ] }) })
5628
+ ] }) });
5629
+ }
5630
+ function CoreConfirmDialog({ open, title, effect, confirmLabel = "Confirmar", cancelLabel = "Cancelar", tone = "danger", busy, onConfirm, onClose }) {
5631
+ return /* @__PURE__ */ jsx24(Dialog.Root, { open, onOpenChange: (event) => {
5632
+ if (!event.open && !busy) onClose();
5633
+ }, role: "alertdialog", children: /* @__PURE__ */ jsxs21(Portal, { children: [
5634
+ /* @__PURE__ */ jsx24(Dialog.Backdrop, {}),
5635
+ /* @__PURE__ */ jsx24(Dialog.Positioner, { children: /* @__PURE__ */ jsxs21(Dialog.Content, { children: [
5636
+ /* @__PURE__ */ jsx24(Dialog.Header, { children: /* @__PURE__ */ jsx24(Dialog.Title, { children: title }) }),
5637
+ /* @__PURE__ */ jsx24(Dialog.Body, { children: /* @__PURE__ */ jsx24(Text21, { color: "text.primary", children: effect }) }),
5638
+ /* @__PURE__ */ jsxs21(Dialog.Footer, { children: [
5639
+ /* @__PURE__ */ jsx24(Button14, { variant: "outline", onClick: onClose, disabled: busy, children: cancelLabel }),
5640
+ /* @__PURE__ */ jsx24(Button14, { colorPalette: tone === "danger" ? "red" : "brand", onClick: onConfirm, loading: busy, children: confirmLabel })
5641
+ ] })
5642
+ ] }) })
5643
+ ] }) });
5644
+ }
5645
+ function CoreTechnicalDetails({ items, label = "Detalhes t\xE9cnicos" }) {
5646
+ const visible = items.filter((item) => item.value !== void 0 && item.value !== null && item.value !== "");
5647
+ const [copied, setCopied] = useState13(null);
5648
+ if (!visible.length) return null;
5649
+ const copy = async (text, key) => {
5650
+ try {
5651
+ await navigator.clipboard?.writeText(text);
5652
+ setCopied(key);
5653
+ } catch {
5654
+ setCopied(null);
5655
+ }
5656
+ };
5657
+ return /* @__PURE__ */ jsxs21(Box20, { as: "details", fontSize: "sm", color: "text.muted", borderWidth: "1px", borderColor: "border.subtle", borderRadius: "md", px: 3, py: 2, children: [
5658
+ /* @__PURE__ */ jsx24(Box20, { as: "summary", cursor: "pointer", fontWeight: "600", children: label }),
5659
+ /* @__PURE__ */ jsx24(Stack11, { gap: 1, mt: 2, children: visible.map((item) => /* @__PURE__ */ jsxs21(Flex13, { gap: 3, justify: "space-between", align: "center", children: [
5660
+ /* @__PURE__ */ jsx24(Text21, { children: item.label }),
5661
+ /* @__PURE__ */ jsxs21(Flex13, { gap: 2, align: "center", minW: 0, children: [
5662
+ /* @__PURE__ */ jsx24(Text21, { fontFamily: "mono", truncate: true, maxW: "240px", title: String(item.value), children: String(item.value) }),
5663
+ /* @__PURE__ */ jsx24(Button14, { size: "xs", variant: "ghost", onClick: () => void copy(String(item.value), item.label), "aria-label": `Copiar ${item.label}`, children: copied === item.label ? "Copiado" : "Copiar" })
5664
+ ] })
5665
+ ] }, item.label)) })
5666
+ ] });
5667
+ }
5668
+ function CoreFormSection({ title, description, children, onSave, saving, saveLabel = "Salvar", disabled }) {
5669
+ return /* @__PURE__ */ jsxs21(Box20, { as: "section", borderWidth: "1px", borderColor: "border.default", borderRadius: "lg", bg: "surface.panel", p: 5, children: [
5670
+ /* @__PURE__ */ jsx24(Heading12, { as: "h2", size: "sm", children: title }),
5671
+ description ? /* @__PURE__ */ jsx24(Text21, { color: "text.muted", fontSize: "sm", mt: 1, children: description }) : null,
5672
+ /* @__PURE__ */ jsx24(Stack11, { gap: 4, mt: 4, children }),
5673
+ onSave ? /* @__PURE__ */ jsx24(Flex13, { justify: "flex-end", mt: 4, children: /* @__PURE__ */ jsx24(Button14, { colorPalette: "brand", onClick: onSave, loading: saving, disabled, children: saveLabel }) }) : null
5674
+ ] });
5675
+ }
5676
+ function CoreOrganizationSwitcher({ organizations, value: value2, onChange, allLabel, label = "Organiza\xE7\xE3o" }) {
5677
+ if (!organizations.length) return null;
5678
+ return /* @__PURE__ */ jsxs21(Flex13, { as: "label", align: "center", gap: 2, fontSize: "sm", color: "text.muted", children: [
5679
+ /* @__PURE__ */ jsx24(Text21, { display: { base: "none", md: "block" }, children: label }),
5680
+ /* @__PURE__ */ jsxs21(NativeSelect6.Root, { size: "sm", width: { base: "160px", md: "220px" }, children: [
5681
+ /* @__PURE__ */ jsxs21(NativeSelect6.Field, { "aria-label": label, value: value2 ?? "", onChange: (event) => onChange(event.currentTarget.value || null), children: [
5682
+ allLabel ? /* @__PURE__ */ jsx24("option", { value: "", children: allLabel }) : null,
5683
+ organizations.map((organization) => /* @__PURE__ */ jsx24("option", { value: organization.id, children: organization.name }, organization.id))
5684
+ ] }),
5685
+ /* @__PURE__ */ jsx24(NativeSelect6.Indicator, {})
5686
+ ] })
5687
+ ] });
5688
+ }
5689
+ function coreInitials(name) {
5690
+ const parts = String(name ?? "").trim().split(/\s+/).filter(Boolean);
5691
+ if (!parts.length) return "?";
5692
+ return ((parts[0][0] ?? "") + (parts.length > 1 ? parts[parts.length - 1][0] ?? "" : "")).toUpperCase();
5693
+ }
5694
+
5399
5695
  export {
5400
5696
  DomainExpressionError,
5401
5697
  evaluateDomainExpression,
@@ -5430,6 +5726,17 @@ export {
5430
5726
  CoreActivityLog,
5431
5727
  CoreConfirmAction,
5432
5728
  CorePage2 as CorePage,
5433
- CoreTransactionalEmail
5729
+ CoreTransactionalEmail,
5730
+ coreStatus,
5731
+ CoreStatusBadge,
5732
+ CoreKpiGrid,
5733
+ CoreEmpty,
5734
+ CoreDataTable,
5735
+ CoreDetailDrawer,
5736
+ CoreConfirmDialog,
5737
+ CoreTechnicalDetails,
5738
+ CoreFormSection,
5739
+ CoreOrganizationSwitcher,
5740
+ coreInitials
5434
5741
  };
5435
- //# sourceMappingURL=chunk-EIFIGMY7.js.map
5742
+ //# sourceMappingURL=chunk-TWOOUSQ6.js.map