@oondemand/oon-core-front 0.3.28 → 0.3.30
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 +37 -3
- package/dist/index.js +55 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -618,9 +618,20 @@ interface CentralUiManifest {
|
|
|
618
618
|
model?: string;
|
|
619
619
|
mode?: string;
|
|
620
620
|
stageField?: string;
|
|
621
|
+
stages?: Array<{
|
|
622
|
+
id: string;
|
|
623
|
+
label: string;
|
|
624
|
+
}>;
|
|
625
|
+
titleField?: string;
|
|
621
626
|
path?: string;
|
|
622
627
|
label?: string;
|
|
623
628
|
section?: string;
|
|
629
|
+
/** Overrides do formulário usado ao editar um ticket. */
|
|
630
|
+
form?: CentralFormFieldDef[];
|
|
631
|
+
/** Relações consumidas por abas de resumo e grids relacionados. */
|
|
632
|
+
relations?: Record<string, OonRelationDef>;
|
|
633
|
+
/** Abas, grupos e tamanho do modal aberto pelo card da esteira. */
|
|
634
|
+
ticketModal?: OonDetailModalConfig;
|
|
624
635
|
}>;
|
|
625
636
|
documents?: Array<{
|
|
626
637
|
model: string;
|
|
@@ -660,6 +671,23 @@ declare function manifestToConfig(manifest: CentralUiManifest, runtime: Manifest
|
|
|
660
671
|
*/
|
|
661
672
|
declare function startFromManifest(manifest: CentralUiManifest, runtime: ManifestRuntime): void;
|
|
662
673
|
|
|
674
|
+
/** Configuração declarativa do editor de um ticket aberto pela esteira. */
|
|
675
|
+
type OonPipelineTicketModalConfig = OonDetailModalConfig;
|
|
676
|
+
/**
|
|
677
|
+
* Extensão pública da view de esteira com formulário, relações e modal do ticket.
|
|
678
|
+
* Continua estruturalmente compatível com `PipelineViewDef`.
|
|
679
|
+
*/
|
|
680
|
+
type OonPipelineViewDef = PipelineViewDef & {
|
|
681
|
+
/** Campo exibido como título do card e do modal. */
|
|
682
|
+
titleField?: string;
|
|
683
|
+
/** Overrides de formulário mesclados à metadata do model. */
|
|
684
|
+
form?: OonFormFieldDef[];
|
|
685
|
+
/** Relações disponíveis para abas summary/relatedGrid/readonlyGrid. */
|
|
686
|
+
relations?: Record<string, OonRelationDef>;
|
|
687
|
+
/** Modal declarativo usado ao abrir um ticket da esteira. */
|
|
688
|
+
ticketModal?: OonPipelineTicketModalConfig;
|
|
689
|
+
};
|
|
690
|
+
|
|
663
691
|
/**
|
|
664
692
|
* Helpers declarativos (API pública da Seção 4.3). São identidades tipadas que
|
|
665
693
|
* fixam o `type` da view — servem para o autocomplete e para registrar a view
|
|
@@ -667,7 +695,7 @@ declare function startFromManifest(manifest: CentralUiManifest, runtime: Manifes
|
|
|
667
695
|
*/
|
|
668
696
|
declare function defineCollectionView(def: Omit<CollectionViewDef, "type">): CollectionViewDef;
|
|
669
697
|
declare function defineDocumentView(def: Omit<DocumentViewDef, "type">): DocumentViewDef;
|
|
670
|
-
declare function definePipelineView(def: Omit<
|
|
698
|
+
declare function definePipelineView(def: Omit<OonPipelineViewDef, "type">): OonPipelineViewDef;
|
|
671
699
|
declare function defineDashboard(def: Omit<DashboardViewDef, "type">): DashboardViewDef;
|
|
672
700
|
/** Açúcar para declarar um módulo com tipagem. */
|
|
673
701
|
declare function defineOonModule(mod: OonModule): OonModule;
|
|
@@ -717,9 +745,15 @@ interface CorePipelineProps {
|
|
|
717
745
|
label: string;
|
|
718
746
|
}>;
|
|
719
747
|
titleField?: string;
|
|
748
|
+
/** Overrides mesclados aos campos derivados da metadata. */
|
|
749
|
+
form?: OonFormFieldDef[];
|
|
750
|
+
/** Relações utilizadas pelas abas de resumo e grids relacionados. */
|
|
751
|
+
relations?: Record<string, OonRelationDef>;
|
|
752
|
+
/** Configuração declarativa do editor aberto ao clicar no ticket. */
|
|
753
|
+
ticketModal?: OonDetailModalConfig;
|
|
720
754
|
}
|
|
721
755
|
/** Esteira horizontal padrão, com tickets clicáveis e formulário completo em modal. */
|
|
722
|
-
declare function CorePipeline({ model, label, endpoint, stageField, stages, titleField }: CorePipelineProps): react.JSX.Element;
|
|
756
|
+
declare function CorePipeline({ model, label, endpoint, stageField, stages, titleField, form, relations, ticketModal, }: CorePipelineProps): react.JSX.Element;
|
|
723
757
|
|
|
724
758
|
interface CoreIntegrationProps {
|
|
725
759
|
label?: string;
|
|
@@ -902,4 +936,4 @@ declare function useCoreMetadata(): _tanstack_react_query.UseQueryResult<NoInfer
|
|
|
902
936
|
/** Descrição de uma model específica — base do modo "dynamic". */
|
|
903
937
|
declare function useModelSchema(name: string): _tanstack_react_query.UseQueryResult<NoInfer<ModelSummary>, Error>;
|
|
904
938
|
|
|
905
|
-
export { type CentralFormFieldDef, type CentralUiManifest, type CollectionMode, type CollectionViewDef, CoreActions, CoreAssistant, CoreCards, CoreCollection, CoreCurrency, CoreDashboard, CoreDataGrid, CoreDocument, CoreEmptyState, CoreField, CoreForm, CoreIntegration, CoreLoadingState, type CoreMetadata, CorePage, CorePageHeader, CorePipeline, CoreRelationField, CoreToolbar, type DashboardViewDef, type DashboardWidgetDef, type DocumentViewDef, type FieldKind, type FieldMeta, type ListParams, type ManifestRuntime, type ModelSummary, type OonActionDef, type OonApiConfig, type OonAppConfig, type OonAppKind, type OonAuthConfig, type OonAuthMode, type OonBlockDef, type OonColumnDef, type OonComponentRegistry, type OonCoreFrontConfig, type OonError, type OonFormFieldDef, type OonLayoutConfig, type OonMenuItem, type OonModule, type OonNavigationConfig, type OonNavigationMode, type OonPageDef, type OonRoute, type OonSchemaVersion, type OonSecurityConfig, type OonUiManifest, type OonUser, type OonViewDefinition, type PaginatedResult, type Pagination, PermissionGate, type PipelineViewDef, defineCollectionView, defineDashboard, defineDocumentView, defineOonModule, definePipelineView, manifestToConfig, oonCoreFront, start, startFromManifest, useCoreMetadata, useModelSchema, useOonApi, useOonAuth, useOonResource };
|
|
939
|
+
export { type CentralFormFieldDef, type CentralUiManifest, type CollectionMode, type CollectionViewDef, CoreActions, CoreAssistant, CoreCards, CoreCollection, CoreCurrency, CoreDashboard, CoreDataGrid, CoreDocument, CoreEmptyState, CoreField, CoreForm, CoreIntegration, CoreLoadingState, type CoreMetadata, CorePage, CorePageHeader, CorePipeline, CoreRelationField, CoreToolbar, type DashboardViewDef, type DashboardWidgetDef, type DocumentViewDef, type FieldKind, type FieldMeta, type ListParams, type ManifestRuntime, type ModelSummary, type OonActionDef, type OonApiConfig, type OonAppConfig, type OonAppKind, type OonAuthConfig, type OonAuthMode, type OonBlockDef, type OonColumnDef, type OonComponentRegistry, type OonCoreFrontConfig, type OonError, type OonFormFieldDef, type OonLayoutConfig, type OonMenuItem, type OonModule, type OonNavigationConfig, type OonNavigationMode, type OonPageDef, type OonPipelineTicketModalConfig, type OonPipelineViewDef, type OonRoute, type OonSchemaVersion, type OonSecurityConfig, type OonUiManifest, type OonUser, type OonViewDefinition, type PaginatedResult, type Pagination, PermissionGate, type PipelineViewDef, defineCollectionView, defineDashboard, defineDocumentView, defineOonModule, definePipelineView, manifestToConfig, oonCoreFront, start, startFromManifest, useCoreMetadata, useModelSchema, useOonApi, useOonAuth, useOonResource };
|
package/dist/index.js
CHANGED
|
@@ -2561,7 +2561,27 @@ function ticketId(row) {
|
|
|
2561
2561
|
const id = row._id ?? row.id;
|
|
2562
2562
|
return id == null ? void 0 : String(id);
|
|
2563
2563
|
}
|
|
2564
|
-
function
|
|
2564
|
+
function mergeFormFields2(metadataFields, overrides) {
|
|
2565
|
+
if (!overrides?.length) return metadataFields;
|
|
2566
|
+
const byField = new Map(overrides.map((field) => [field.field, field]));
|
|
2567
|
+
const merged = metadataFields.map((field) => ({ ...field, ...byField.get(field.field) }));
|
|
2568
|
+
const known = new Set(metadataFields.map((field) => field.field));
|
|
2569
|
+
overrides.forEach((field) => {
|
|
2570
|
+
if (!known.has(field.field)) merged.push(field);
|
|
2571
|
+
});
|
|
2572
|
+
return merged;
|
|
2573
|
+
}
|
|
2574
|
+
function CorePipeline({
|
|
2575
|
+
model,
|
|
2576
|
+
label,
|
|
2577
|
+
endpoint,
|
|
2578
|
+
stageField = "status",
|
|
2579
|
+
stages,
|
|
2580
|
+
titleField,
|
|
2581
|
+
form,
|
|
2582
|
+
relations,
|
|
2583
|
+
ticketModal
|
|
2584
|
+
}) {
|
|
2565
2585
|
const schemaQuery = useModelSchema(model);
|
|
2566
2586
|
const schema = schemaQuery.data;
|
|
2567
2587
|
const basePath = endpoint ?? schema?.basePath ?? `/${model.toLowerCase()}s`;
|
|
@@ -2574,6 +2594,7 @@ function CorePipeline({ model, label, endpoint, stageField = "status", stages, t
|
|
|
2574
2594
|
queryFn: () => resource.list({ pageSize: 200 }),
|
|
2575
2595
|
enabled: !!schema
|
|
2576
2596
|
});
|
|
2597
|
+
const invalidate = () => queryClient.invalidateQueries({ queryKey: ["oon", "pipeline", basePath] });
|
|
2577
2598
|
const saveMutation = useMutation3({
|
|
2578
2599
|
mutationFn: (values) => {
|
|
2579
2600
|
const id = selectedTicket ? ticketId(selectedTicket) : void 0;
|
|
@@ -2581,7 +2602,7 @@ function CorePipeline({ model, label, endpoint, stageField = "status", stages, t
|
|
|
2581
2602
|
return resource.update(id, values);
|
|
2582
2603
|
},
|
|
2583
2604
|
onSuccess: async () => {
|
|
2584
|
-
await
|
|
2605
|
+
await invalidate();
|
|
2585
2606
|
setSelectedTicket(null);
|
|
2586
2607
|
setFormError(null);
|
|
2587
2608
|
},
|
|
@@ -2592,9 +2613,9 @@ function CorePipeline({ model, label, endpoint, stageField = "status", stages, t
|
|
|
2592
2613
|
if (listQuery.isError) return /* @__PURE__ */ jsx18(ErrorState, { error: listQuery.error });
|
|
2593
2614
|
const stageFieldMeta = schema?.fields.find((field) => field.name === stageField);
|
|
2594
2615
|
const resolvedStages = stages ?? (stageFieldMeta?.options ?? []).map((option) => ({ id: option, label: option }));
|
|
2595
|
-
const
|
|
2596
|
-
const detailFields = (schema?.fields ?? []).filter((field) => field.name !== stageField && field.name !==
|
|
2597
|
-
const formFields = formFieldsFromMeta(schema?.fields ?? []);
|
|
2616
|
+
const resolvedTitleField = titleField ?? ticketModal?.titleField ?? schema?.fields.find((field) => field.kind === "string")?.name ?? schema?.searchable[0] ?? "_id";
|
|
2617
|
+
const detailFields = (schema?.fields ?? []).filter((field) => field.name !== stageField && field.name !== resolvedTitleField && !["raw"].includes(field.kind)).slice(0, 3);
|
|
2618
|
+
const formFields = mergeFormFields2(formFieldsFromMeta(schema?.fields ?? []), form);
|
|
2598
2619
|
const rows = listQuery.data?.results ?? [];
|
|
2599
2620
|
const byStage = /* @__PURE__ */ new Map();
|
|
2600
2621
|
for (const stage of resolvedStages) byStage.set(stage.id, []);
|
|
@@ -2628,7 +2649,7 @@ function CorePipeline({ model, label, endpoint, stageField = "status", stages, t
|
|
|
2628
2649
|
/* @__PURE__ */ jsx18(Badge4, { colorPalette: "brand", variant: "solid", borderRadius: "full", minW: "24px", justifyContent: "center", children: items.length })
|
|
2629
2650
|
] }),
|
|
2630
2651
|
/* @__PURE__ */ jsx18(Stack5, { gap: 2, children: items.length === 0 ? /* @__PURE__ */ jsx18(Box10, { borderWidth: "1px", borderStyle: "dashed", borderColor: "#C8D0D5", borderRadius: "10px", p: 5, textAlign: "center", children: /* @__PURE__ */ jsx18(Text12, { fontSize: "12px", color: "gray.500", children: "Nenhum ticket nesta etapa." }) }) : items.map((row, index) => {
|
|
2631
|
-
const ticketTitle = formatCell(row[
|
|
2652
|
+
const ticketTitle = formatCell(row[resolvedTitleField], "string");
|
|
2632
2653
|
return /* @__PURE__ */ jsxs13(
|
|
2633
2654
|
Button9,
|
|
2634
2655
|
{
|
|
@@ -2670,7 +2691,23 @@ function CorePipeline({ model, label, endpoint, stageField = "status", stages, t
|
|
|
2670
2691
|
stageId
|
|
2671
2692
|
);
|
|
2672
2693
|
}) }),
|
|
2673
|
-
selectedTicket ? /* @__PURE__ */ jsx18(
|
|
2694
|
+
selectedTicket && ticketModal && ticketModal.enabled !== false ? /* @__PURE__ */ jsx18(
|
|
2695
|
+
CoreDetailModal,
|
|
2696
|
+
{
|
|
2697
|
+
model,
|
|
2698
|
+
title: schema?.singular ?? label ?? model,
|
|
2699
|
+
config: { ...ticketModal, titleField: ticketModal.titleField ?? resolvedTitleField },
|
|
2700
|
+
formFields,
|
|
2701
|
+
recordId: ticketId(selectedTicket),
|
|
2702
|
+
initialRecord: selectedTicket,
|
|
2703
|
+
relations,
|
|
2704
|
+
onClose: () => {
|
|
2705
|
+
setSelectedTicket(null);
|
|
2706
|
+
setFormError(null);
|
|
2707
|
+
},
|
|
2708
|
+
onSaved: invalidate
|
|
2709
|
+
}
|
|
2710
|
+
) : selectedTicket ? /* @__PURE__ */ jsx18(
|
|
2674
2711
|
DynamicForm,
|
|
2675
2712
|
{
|
|
2676
2713
|
title: `Editar ${schema?.singular ?? label ?? model}`,
|
|
@@ -2939,7 +2976,11 @@ function renderView(view, registry) {
|
|
|
2939
2976
|
model: v.model,
|
|
2940
2977
|
label: viewLabel(v),
|
|
2941
2978
|
stageField: v.stageField,
|
|
2942
|
-
stages: v.stages
|
|
2979
|
+
stages: v.stages,
|
|
2980
|
+
titleField: v.titleField,
|
|
2981
|
+
form: v.form,
|
|
2982
|
+
relations: v.relations,
|
|
2983
|
+
ticketModal: v.ticketModal
|
|
2943
2984
|
}
|
|
2944
2985
|
);
|
|
2945
2986
|
}
|
|
@@ -4066,7 +4107,12 @@ function manifestToConfig(manifest, runtime) {
|
|
|
4066
4107
|
label: p.label ?? p.name,
|
|
4067
4108
|
path: p.path,
|
|
4068
4109
|
stageField: p.stageField,
|
|
4069
|
-
|
|
4110
|
+
stages: p.stages,
|
|
4111
|
+
titleField: p.titleField,
|
|
4112
|
+
section: p.section,
|
|
4113
|
+
form: p.form,
|
|
4114
|
+
relations: p.relations,
|
|
4115
|
+
ticketModal: p.ticketModal
|
|
4070
4116
|
};
|
|
4071
4117
|
views.push(view);
|
|
4072
4118
|
}
|