@fayz-ai/plugin-dashboard 0.1.1

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.js ADDED
@@ -0,0 +1,242 @@
1
+ import * as React from 'react';
2
+ import React__default from 'react';
3
+ import { defineKpiWidget, KpiCard, defineCustomWidget, defineOnboardingWidget, WidgetGrid, DashboardCanvas, useDashboardNavigate, OnboardingWidget } from '@fayz-ai/ui';
4
+ export { DashboardCanvas, DashboardNavigateProvider, resolveDashboardLayout, useDashboardNavigate, useDashboardPreferences } from '@fayz-ai/ui';
5
+ import { jsx, jsxs } from 'react/jsx-runtime';
6
+
7
+ // src/index.ts
8
+ var DOMAIN = "dashboard";
9
+ function metricsToWidgets(metrics, currency) {
10
+ return metrics.map(
11
+ (metric, i) => defineKpiWidget({
12
+ id: `dashboard.kpi.${metric.id}`,
13
+ title: metric.label,
14
+ icon: metric.icon,
15
+ domain: DOMAIN,
16
+ defaultVisible: metric.defaultVisible,
17
+ defaultOrder: metric.defaultOrder ?? i,
18
+ component: () => /* @__PURE__ */ jsx(
19
+ KpiCard,
20
+ {
21
+ label: metric.label,
22
+ icon: metric.icon,
23
+ compute: metric.compute,
24
+ format: metric.format,
25
+ currency,
26
+ goal: metric.goal,
27
+ accent: metric.accent
28
+ }
29
+ )
30
+ })
31
+ );
32
+ }
33
+ function sectionsToWidgets(sections) {
34
+ return sections.map((section) => {
35
+ const SectionComponent = section.component;
36
+ const Wrapped = () => {
37
+ const navigate = useDashboardNavigate();
38
+ return /* @__PURE__ */ jsx(SectionComponent, { onNavigate: navigate });
39
+ };
40
+ return defineCustomWidget({
41
+ id: `dashboard.section.${section.id}`,
42
+ title: section.title,
43
+ icon: section.icon,
44
+ domain: DOMAIN,
45
+ // Half-width by default (guide/section cards like "Agenda de Hoje" should
46
+ // sit beside others, not dominate the row). Sections can opt into full
47
+ // width with `span: 4`.
48
+ span: section.span ?? 2,
49
+ defaultOrder: 100 + section.order,
50
+ verticalId: section.verticalId,
51
+ component: Wrapped
52
+ });
53
+ });
54
+ }
55
+ function onboardingToWidget(steps, labels) {
56
+ const sorted = [...steps].sort((a, b) => a.order - b.order);
57
+ const Onboarding = () => {
58
+ const navigate = useDashboardNavigate();
59
+ const items = sorted.map((s) => ({
60
+ id: s.id,
61
+ title: s.title,
62
+ description: s.description,
63
+ icon: s.icon,
64
+ check: s.check,
65
+ action: s.action
66
+ }));
67
+ return /* @__PURE__ */ jsx(OnboardingWidget, { title: labels.title, subtitle: labels.subtitle, steps: items, onNavigate: navigate });
68
+ };
69
+ return defineOnboardingWidget({
70
+ id: "dashboard.onboarding",
71
+ title: labels.title,
72
+ domain: DOMAIN,
73
+ // Half-width (2 of 4 cols) so the getting-started guide sits beside other
74
+ // content rather than dominating the row.
75
+ span: 2,
76
+ defaultOrder: 50,
77
+ component: Onboarding
78
+ });
79
+ }
80
+
81
+ // src/locales/en.ts
82
+ var en = {
83
+ "dashboard.title": "Dashboard",
84
+ "dashboard.subtitle": "Business overview",
85
+ "dashboard.kpi.title": "Key Metrics",
86
+ "dashboard.kpi.noData": "No metrics configured",
87
+ "dashboard.kpi.error": "Failed to load",
88
+ "dashboard.kpi.refresh": "Refresh",
89
+ "dashboard.onboarding.title": "Getting Started",
90
+ "dashboard.onboarding.subtitle": "Complete these steps to set up your business",
91
+ "dashboard.onboarding.completed": "Completed",
92
+ "dashboard.onboarding.allDone": "All done! You're all set.",
93
+ "dashboard.onboarding.dismiss": "Dismiss",
94
+ "dashboard.onboarding.step": "Step",
95
+ "dashboard.onboarding.of": "of",
96
+ "dashboard.settings.title": "Dashboard",
97
+ "dashboard.settings.subtitle": "Choose which metrics appear on your dashboard",
98
+ "dashboard.settings.metricsVisibility": "Visible Metrics",
99
+ "dashboard.settings.metricOrder": "Metric Order",
100
+ "dashboard.settings.resetDefaults": "Reset to Defaults",
101
+ "dashboard.settings.saved": "Dashboard preferences saved",
102
+ "dashboard.empty.title": "Welcome!",
103
+ "dashboard.empty.subtitle": "Your dashboard will show key metrics and information here."
104
+ };
105
+
106
+ // src/locales/pt-BR.ts
107
+ var ptBR = {
108
+ "dashboard.title": "Painel",
109
+ "dashboard.subtitle": "Visao geral do seu negocio",
110
+ "dashboard.kpi.title": "Metricas",
111
+ "dashboard.kpi.noData": "Nenhuma metrica configurada",
112
+ "dashboard.kpi.error": "Falha ao carregar",
113
+ "dashboard.kpi.refresh": "Atualizar",
114
+ "dashboard.onboarding.title": "Primeiros Passos",
115
+ "dashboard.onboarding.subtitle": "Complete estes passos para configurar seu negocio",
116
+ "dashboard.onboarding.completed": "Concluido",
117
+ "dashboard.onboarding.allDone": "Tudo pronto! Voce esta configurado.",
118
+ "dashboard.onboarding.dismiss": "Dispensar",
119
+ "dashboard.onboarding.step": "Passo",
120
+ "dashboard.onboarding.of": "de",
121
+ "dashboard.settings.title": "Painel",
122
+ "dashboard.settings.subtitle": "Escolha quais metricas aparecem no seu painel",
123
+ "dashboard.settings.metricsVisibility": "Metricas Visiveis",
124
+ "dashboard.settings.metricOrder": "Ordem das Metricas",
125
+ "dashboard.settings.resetDefaults": "Restaurar Padrao",
126
+ "dashboard.settings.saved": "Preferencias do painel salvas",
127
+ "dashboard.empty.title": "Bem-vindo!",
128
+ "dashboard.empty.subtitle": "Seu painel mostrara metricas e informacoes importantes aqui."
129
+ };
130
+
131
+ // src/locales/index.ts
132
+ var dashboardLocales = {
133
+ en,
134
+ "pt-BR": ptBR
135
+ };
136
+ function DashboardPage({
137
+ title = "Dashboard",
138
+ subtitle = "Business overview",
139
+ metrics = [],
140
+ sections = [],
141
+ currency,
142
+ showHeader = true
143
+ }) {
144
+ const widgets = React.useMemo(
145
+ () => [...metricsToWidgets(metrics, currency), ...sectionsToWidgets(sections)],
146
+ [metrics, sections, currency]
147
+ );
148
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-6 p-6", children: [
149
+ showHeader ? /* @__PURE__ */ jsxs("div", { children: [
150
+ /* @__PURE__ */ jsx("h1", { className: "text-2xl font-semibold tracking-tight", children: title }),
151
+ /* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: subtitle })
152
+ ] }) : null,
153
+ /* @__PURE__ */ jsx(WidgetGrid, { widgets, surface: "home" })
154
+ ] });
155
+ }
156
+ var DEFAULT_LABELS = {
157
+ pageTitle: "Dashboard",
158
+ pageSubtitle: "Business overview",
159
+ kpiTitle: "Key Metrics",
160
+ onboardingTitle: "Getting Started",
161
+ onboardingSubtitle: "Complete these steps to set up your business",
162
+ settingsTitle: "Dashboard"
163
+ };
164
+ function createDashboardPlugin(options) {
165
+ const labels = { ...DEFAULT_LABELS, ...options?.labels };
166
+ const onboardingSteps = options?.onboardingSteps ?? [];
167
+ const showOnboarding = options?.showOnboarding ?? onboardingSteps.length > 0;
168
+ const dashboardWidgets = [
169
+ ...metricsToWidgets(options?.metrics ?? [], options?.currency),
170
+ ...sectionsToWidgets(options?.sections ?? []),
171
+ ...showOnboarding && onboardingSteps.length > 0 ? [onboardingToWidget(onboardingSteps, { title: labels.onboardingTitle, subtitle: labels.onboardingSubtitle })] : [],
172
+ ...options?.customWidgets ?? []
173
+ ];
174
+ const PageComponent = () => React__default.createElement(DashboardCanvas, {
175
+ surface: "home",
176
+ title: labels.pageTitle,
177
+ subtitle: labels.pageSubtitle,
178
+ showHeader: options?.showHeader,
179
+ appLayout: options?.layout,
180
+ range: options?.range
181
+ });
182
+ return {
183
+ id: "dashboard",
184
+ name: labels.pageTitle,
185
+ icon: "LayoutDashboard",
186
+ version: "1.0.0",
187
+ scope: options?.scope ?? "universal",
188
+ verticalId: options?.verticalId,
189
+ defaultEnabled: true,
190
+ dependencies: [],
191
+ declaredFeatures: [
192
+ { id: "dashboard", label: labels.pageTitle, group: "Core" }
193
+ ],
194
+ navigation: options?.skipNavigation ? [] : [
195
+ {
196
+ section: options?.navSection ?? "main",
197
+ position: options?.navPosition ?? 0,
198
+ label: labels.pageTitle,
199
+ route: "/",
200
+ icon: options?.navIcon ?? "LayoutDashboard"
201
+ }
202
+ ],
203
+ routes: [
204
+ {
205
+ path: "/",
206
+ component: PageComponent
207
+ }
208
+ ],
209
+ widgets: [],
210
+ dashboardWidgets,
211
+ aiTools: [
212
+ {
213
+ id: "dashboard.kpi-summary",
214
+ name: "getKpiSummary",
215
+ description: "Returns a summary of all KPI metrics for the current dashboard, including trends and comparisons.",
216
+ icon: "BarChart3",
217
+ mode: "read",
218
+ category: "Dashboard",
219
+ parameters: {
220
+ type: "object",
221
+ properties: {
222
+ category: {
223
+ type: "string",
224
+ description: "Filter by metric category",
225
+ enum: ["revenue", "operations", "clients", "custom", "all"]
226
+ }
227
+ }
228
+ },
229
+ suggestions: [
230
+ { label: "How is my business doing today?" },
231
+ { label: "What's my revenue today?" },
232
+ { label: "Give me a summary of today" }
233
+ ]
234
+ }
235
+ ],
236
+ locales: dashboardLocales
237
+ };
238
+ }
239
+
240
+ export { DashboardPage, createDashboardPlugin, metricsToWidgets, onboardingToWidget, sectionsToWidgets };
241
+ //# sourceMappingURL=index.js.map
242
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/builders.tsx","../src/locales/en.ts","../src/locales/pt-BR.ts","../src/locales/index.ts","../src/DashboardPage.tsx","../src/index.ts"],"names":["jsx","React"],"mappings":";;;;;;;AAcA,IAAM,MAAA,GAAS,WAAA;AAGR,SAAS,gBAAA,CAAiB,SAA4B,QAAA,EAA8C;AACzG,EAAA,OAAO,OAAA,CAAQ,GAAA;AAAA,IAAI,CAAC,MAAA,EAAQ,CAAA,KAC1B,eAAA,CAAgB;AAAA,MACd,EAAA,EAAI,CAAA,cAAA,EAAiB,MAAA,CAAO,EAAE,CAAA,CAAA;AAAA,MAC9B,OAAO,MAAA,CAAO,KAAA;AAAA,MACd,MAAM,MAAA,CAAO,IAAA;AAAA,MACb,MAAA,EAAQ,MAAA;AAAA,MACR,gBAAgB,MAAA,CAAO,cAAA;AAAA,MACvB,YAAA,EAAc,OAAO,YAAA,IAAgB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AEA,UAAA,EAAY,OAAA,EAAS,cAAA,GAAiB,EAAC,GAAI;AAAA,MACzC;AAAA,QACE,OAAA,EAAS,SAAS,UAAA,IAAc,MAAA;AAAA,QAChC,QAAA,EAAU,SAAS,WAAA,IAAe,CAAA;AAAA,QAClC,OAAO,MAAA,CAAO,SAAA;AAAA,QACd,KAAA,EAAO,GAAA;AAAA,QACP,IAAA,EAAM,SAAS,OAAA,IAAW;AAAA;AAC5B,KACF;AAAA,IAEA,MAAA,EAAQ;AAAA,MACN;AAAA,QACE,IAAA,EAAM,GAAA;AAAA,QACN,SAAA,EAAW;AAAA;AACb,KACF;AAAA,IAEA,SAAS,EAAC;AAAA,IACV,gBAAA;AAAA,IAEA,OAAA,EAAS;AAAA,MACP;AAAA,QACE,EAAA,EAAI,uBAAA;AAAA,QACJ,IAAA,EAAM,eAAA;AAAA,QACN,WAAA,EAAa,mGAAA;AAAA,QACb,IAAA,EAAM,WAAA;AAAA,QACN,IAAA,EAAM,MAAA;AAAA,QACN,QAAA,EAAU,WAAA;AAAA,QACV,UAAA,EAAY;AAAA,UACV,IAAA,EAAM,QAAA;AAAA,UACN,UAAA,EAAY;AAAA,YACV,QAAA,EAAU;AAAA,cACR,IAAA,EAAM,QAAA;AAAA,cACN,WAAA,EAAa,2BAAA;AAAA,cACb,MAAM,CAAC,SAAA,EAAW,YAAA,EAAc,SAAA,EAAW,UAAU,KAAK;AAAA;AAC5D;AACF,SACF;AAAA,QACA,WAAA,EAAa;AAAA,UACX,EAAE,OAAO,iCAAA,EAAkC;AAAA,UAC3C,EAAE,OAAO,0BAAA,EAA2B;AAAA,UACpC,EAAE,OAAO,4BAAA;AAA6B;AACxC;AACF,KACF;AAAA,IAEA,OAAA,EAAS;AAAA,GACX;AACF","file":"index.js","sourcesContent":["import * as React from 'react'\nimport type { DashboardWidgetDef } from '@fayz-ai/core'\nimport {\n KpiCard,\n OnboardingWidget,\n defineKpiWidget,\n defineCustomWidget,\n defineOnboardingWidget,\n useDashboardNavigate,\n type KpiCurrency,\n type OnboardingStepInput,\n} from '@fayz-ai/ui'\nimport type { DashboardMetric, DashboardSection, OnboardingStep } from './types'\n\nconst DOMAIN = 'dashboard'\n\n/** Legacy DashboardMetric[] → KPI widgets (async compute via the shared KpiCard). */\nexport function metricsToWidgets(metrics: DashboardMetric[], currency?: KpiCurrency): DashboardWidgetDef[] {\n return metrics.map((metric, i) =>\n defineKpiWidget({\n id: `dashboard.kpi.${metric.id}`,\n title: metric.label,\n icon: metric.icon,\n domain: DOMAIN,\n defaultVisible: metric.defaultVisible,\n defaultOrder: metric.defaultOrder ?? i,\n component: () => (\n <KpiCard\n label={metric.label}\n icon={metric.icon}\n compute={metric.compute}\n format={metric.format}\n currency={currency}\n goal={metric.goal}\n accent={metric.accent}\n />\n ),\n }),\n )\n}\n\n/** Legacy DashboardSection[] → full-width custom widgets. */\nexport function sectionsToWidgets(sections: DashboardSection[]): DashboardWidgetDef[] {\n return sections.map((section) => {\n const SectionComponent = section.component\n const Wrapped = () => {\n const navigate = useDashboardNavigate()\n return <SectionComponent onNavigate={navigate} />\n }\n return defineCustomWidget({\n id: `dashboard.section.${section.id}`,\n title: section.title,\n icon: section.icon,\n domain: DOMAIN,\n // Half-width by default (guide/section cards like \"Agenda de Hoje\" should\n // sit beside others, not dominate the row). Sections can opt into full\n // width with `span: 4`.\n span: section.span ?? 2,\n defaultOrder: 100 + section.order,\n verticalId: section.verticalId,\n component: Wrapped,\n })\n })\n}\n\n/** Onboarding steps → a single \"first steps to set up\" checklist widget. */\nexport function onboardingToWidget(\n steps: OnboardingStep[],\n labels: { title: string; subtitle: string },\n): DashboardWidgetDef {\n const sorted = [...steps].sort((a, b) => a.order - b.order)\n const Onboarding = () => {\n const navigate = useDashboardNavigate()\n const items: OnboardingStepInput[] = sorted.map((s) => ({\n id: s.id,\n title: s.title,\n description: s.description,\n icon: s.icon,\n check: s.check,\n action: s.action,\n }))\n return <OnboardingWidget title={labels.title} subtitle={labels.subtitle} steps={items} onNavigate={navigate} />\n }\n return defineOnboardingWidget({\n id: 'dashboard.onboarding',\n title: labels.title,\n domain: DOMAIN,\n // Half-width (2 of 4 cols) so the getting-started guide sits beside other\n // content rather than dominating the row.\n span: 2,\n defaultOrder: 50,\n component: Onboarding,\n })\n}\n","export const en: Record<string, string> = {\n 'dashboard.title': 'Dashboard',\n 'dashboard.subtitle': 'Business overview',\n 'dashboard.kpi.title': 'Key Metrics',\n 'dashboard.kpi.noData': 'No metrics configured',\n 'dashboard.kpi.error': 'Failed to load',\n 'dashboard.kpi.refresh': 'Refresh',\n 'dashboard.onboarding.title': 'Getting Started',\n 'dashboard.onboarding.subtitle': 'Complete these steps to set up your business',\n 'dashboard.onboarding.completed': 'Completed',\n 'dashboard.onboarding.allDone': \"All done! You're all set.\",\n 'dashboard.onboarding.dismiss': 'Dismiss',\n 'dashboard.onboarding.step': 'Step',\n 'dashboard.onboarding.of': 'of',\n 'dashboard.settings.title': 'Dashboard',\n 'dashboard.settings.subtitle': 'Choose which metrics appear on your dashboard',\n 'dashboard.settings.metricsVisibility': 'Visible Metrics',\n 'dashboard.settings.metricOrder': 'Metric Order',\n 'dashboard.settings.resetDefaults': 'Reset to Defaults',\n 'dashboard.settings.saved': 'Dashboard preferences saved',\n 'dashboard.empty.title': 'Welcome!',\n 'dashboard.empty.subtitle': 'Your dashboard will show key metrics and information here.',\n}\n","export const ptBR: Record<string, string> = {\n 'dashboard.title': 'Painel',\n 'dashboard.subtitle': 'Visao geral do seu negocio',\n 'dashboard.kpi.title': 'Metricas',\n 'dashboard.kpi.noData': 'Nenhuma metrica configurada',\n 'dashboard.kpi.error': 'Falha ao carregar',\n 'dashboard.kpi.refresh': 'Atualizar',\n 'dashboard.onboarding.title': 'Primeiros Passos',\n 'dashboard.onboarding.subtitle': 'Complete estes passos para configurar seu negocio',\n 'dashboard.onboarding.completed': 'Concluido',\n 'dashboard.onboarding.allDone': 'Tudo pronto! Voce esta configurado.',\n 'dashboard.onboarding.dismiss': 'Dispensar',\n 'dashboard.onboarding.step': 'Passo',\n 'dashboard.onboarding.of': 'de',\n 'dashboard.settings.title': 'Painel',\n 'dashboard.settings.subtitle': 'Escolha quais metricas aparecem no seu painel',\n 'dashboard.settings.metricsVisibility': 'Metricas Visiveis',\n 'dashboard.settings.metricOrder': 'Ordem das Metricas',\n 'dashboard.settings.resetDefaults': 'Restaurar Padrao',\n 'dashboard.settings.saved': 'Preferencias do painel salvas',\n 'dashboard.empty.title': 'Bem-vindo!',\n 'dashboard.empty.subtitle': 'Seu painel mostrara metricas e informacoes importantes aqui.',\n}\n","import { en } from './en'\nimport { ptBR } from './pt-BR'\n\nexport const dashboardLocales: Record<string, Record<string, string>> = {\n en,\n 'pt-BR': ptBR,\n}\n","import * as React from 'react'\nimport type { DashboardWidgetDef } from '@fayz-ai/core'\nimport { WidgetGrid } from '@fayz-ai/ui'\nimport { metricsToWidgets, sectionsToWidgets } from './builders'\nimport type { DashboardMetric, DashboardSection } from './types'\n\nexport interface DashboardPageProps {\n title?: string\n subtitle?: string\n metrics?: DashboardMetric[]\n sections?: DashboardSection[]\n currency?: { code?: string; locale?: string; symbol?: string }\n /** Render the in-content title/subtitle. Set false when the app shell owns\n * the page title (sidebar/GHL-style layouts). Default: true. */\n showHeader?: boolean\n}\n\n/**\n * Back-compat shim. The dashboard is now a widget registry (see DashboardCanvas),\n * but standalone callers can still render a fixed set of metrics/sections. This\n * converts them to widget definitions and renders them through the shared grid.\n */\nexport function DashboardPage({\n title = 'Dashboard', subtitle = 'Business overview', metrics = [], sections = [], currency, showHeader = true,\n}: DashboardPageProps) {\n const widgets: DashboardWidgetDef[] = React.useMemo(\n () => [...metricsToWidgets(metrics, currency), ...sectionsToWidgets(sections)],\n [metrics, sections, currency],\n )\n\n return (\n <div className=\"space-y-6 p-6\">\n {showHeader ? (\n <div>\n <h1 className=\"text-2xl font-semibold tracking-tight\">{title}</h1>\n <p className=\"mt-1 text-sm text-muted-foreground\">{subtitle}</p>\n </div>\n ) : null}\n <WidgetGrid widgets={widgets} surface=\"home\" />\n </div>\n )\n}\n","import React from 'react'\nimport type { PluginManifest, PluginScope, VerticalId, DashboardWidgetDef, DashboardLayoutConfig } from '@fayz-ai/core'\nimport { DashboardCanvas, type DashboardCanvasProps } from '@fayz-ai/ui'\nimport { DashboardPage } from './DashboardPage'\nimport { metricsToWidgets, sectionsToWidgets, onboardingToWidget } from './builders'\nimport { dashboardLocales } from './locales'\nimport type { DashboardMetric, DashboardSection, OnboardingStep } from './types'\n\n// ---------------------------------------------------------------------------\n// Public types\n// ---------------------------------------------------------------------------\n\nexport interface DashboardPluginLabels {\n pageTitle: string\n pageSubtitle: string\n kpiTitle: string\n onboardingTitle: string\n onboardingSubtitle: string\n settingsTitle: string\n}\n\nexport interface DashboardPluginOptions {\n /** KPI metrics to show on the dashboard */\n metrics?: DashboardMetric[]\n /** Custom sections injected by the consumer app */\n sections?: DashboardSection[]\n /** Onboarding steps for the getting-started checklist */\n onboardingSteps?: OnboardingStep[]\n /** Label overrides */\n labels?: Partial<DashboardPluginLabels>\n /** Currency config for metrics that use 'currency' format */\n currency?: { code?: string; locale?: string; symbol?: string }\n /** Plugin scope */\n scope?: PluginScope\n /** Vertical ID */\n verticalId?: VerticalId\n /** Whether to show onboarding module. Default: true if onboardingSteps provided */\n showOnboarding?: boolean\n /** Nav position (default: 0 — first item) */\n navPosition?: number\n /** Nav section (default: 'main') */\n navSection?: 'main' | 'secondary'\n /** Navigation icon override (default: 'LayoutDashboard') */\n navIcon?: string\n /** Skip adding a navigation entry (use when the consumer app provides its own page entry for '/') */\n skipNavigation?: boolean\n /** Render the in-content title/subtitle. Set false when the app shell owns the\n * page title (sidebar/GHL-style layouts). Default: true. */\n showHeader?: boolean\n /** App-level curation of the home surface — which widgets show, order, span.\n * Applied on top of every plugin's registered defaults. */\n layout?: DashboardLayoutConfig\n /** Custom widgets the consumer app contributes directly to the home surface. */\n customWidgets?: DashboardWidgetDef[]\n /** Show the shared, sticky time-range control on the home. Pass `true` for\n * defaults (7d/30d/90d) or an options object. Widgets read it via\n * useDashboardRange(); provide `onChange` to drive app-level refetching. */\n range?: DashboardCanvasProps['range']\n}\n\n// ---------------------------------------------------------------------------\n// Defaults\n// ---------------------------------------------------------------------------\n\nconst DEFAULT_LABELS: DashboardPluginLabels = {\n pageTitle: 'Dashboard',\n pageSubtitle: 'Business overview',\n kpiTitle: 'Key Metrics',\n onboardingTitle: 'Getting Started',\n onboardingSubtitle: 'Complete these steps to set up your business',\n settingsTitle: 'Dashboard',\n}\n\n// ---------------------------------------------------------------------------\n// Factory\n// ---------------------------------------------------------------------------\n\nexport function createDashboardPlugin(options?: DashboardPluginOptions): PluginManifest {\n const labels: DashboardPluginLabels = { ...DEFAULT_LABELS, ...options?.labels }\n const onboardingSteps = options?.onboardingSteps ?? []\n const showOnboarding = options?.showOnboarding ?? onboardingSteps.length > 0\n\n // Everything the dashboard plugin owns flows through the widget registry:\n // legacy metrics/sections, the onboarding checklist, and app custom widgets.\n const dashboardWidgets: DashboardWidgetDef[] = [\n ...metricsToWidgets(options?.metrics ?? [], options?.currency),\n ...sectionsToWidgets(options?.sections ?? []),\n ...(showOnboarding && onboardingSteps.length > 0\n ? [onboardingToWidget(onboardingSteps, { title: labels.onboardingTitle, subtitle: labels.onboardingSubtitle })]\n : []),\n ...(options?.customWidgets ?? []),\n ]\n\n const PageComponent: React.ComponentType<unknown> = () =>\n React.createElement(DashboardCanvas, {\n surface: 'home',\n title: labels.pageTitle,\n subtitle: labels.pageSubtitle,\n showHeader: options?.showHeader,\n appLayout: options?.layout,\n range: options?.range,\n })\n\n return {\n id: 'dashboard',\n name: labels.pageTitle,\n icon: 'LayoutDashboard',\n version: '1.0.0',\n scope: options?.scope ?? 'universal',\n verticalId: options?.verticalId,\n defaultEnabled: true,\n dependencies: [],\n declaredFeatures: [\n { id: 'dashboard', label: labels.pageTitle, group: 'Core' },\n ],\n\n navigation: options?.skipNavigation ? [] : [\n {\n section: options?.navSection ?? 'main',\n position: options?.navPosition ?? 0,\n label: labels.pageTitle,\n route: '/',\n icon: options?.navIcon ?? 'LayoutDashboard',\n },\n ],\n\n routes: [\n {\n path: '/',\n component: PageComponent,\n },\n ],\n\n widgets: [],\n dashboardWidgets,\n\n aiTools: [\n {\n id: 'dashboard.kpi-summary',\n name: 'getKpiSummary',\n description: 'Returns a summary of all KPI metrics for the current dashboard, including trends and comparisons.',\n icon: 'BarChart3',\n mode: 'read' as const,\n category: 'Dashboard',\n parameters: {\n type: 'object' as const,\n properties: {\n category: {\n type: 'string' as const,\n description: 'Filter by metric category',\n enum: ['revenue', 'operations', 'clients', 'custom', 'all'],\n },\n },\n },\n suggestions: [\n { label: 'How is my business doing today?' },\n { label: \"What's my revenue today?\" },\n { label: 'Give me a summary of today' },\n ],\n },\n ],\n\n locales: dashboardLocales,\n }\n}\n\n// ---------------------------------------------------------------------------\n// Re-exports\n// ---------------------------------------------------------------------------\n\nexport { DashboardPage } from './DashboardPage'\nexport {\n DashboardCanvas,\n DashboardNavigateProvider,\n useDashboardNavigate,\n resolveDashboardLayout,\n useDashboardPreferences,\n type DashboardCanvasProps,\n type LaidOutWidget,\n type DashboardPreferencesState,\n} from '@fayz-ai/ui'\nexport {\n metricsToWidgets,\n sectionsToWidgets,\n onboardingToWidget,\n} from './builders'\n\nexport type {\n DashboardMetric,\n MetricValue,\n MetricCategory,\n MetricFormat,\n ResolvedMetric,\n DashboardSection,\n DashboardSectionProps,\n DashboardZone,\n OnboardingStep,\n OnboardingProgress,\n DashboardPreferences,\n} from './types'\n"]}
@@ -0,0 +1,2 @@
1
+ export declare const en: Record<string, string>;
2
+ //# sourceMappingURL=en.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/locales/en.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAsBrC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const dashboardLocales: Record<string, Record<string, string>>;
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/locales/index.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAGnE,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const ptBR: Record<string, string>;
2
+ //# sourceMappingURL=pt-BR.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pt-BR.d.ts","sourceRoot":"","sources":["../../src/locales/pt-BR.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAsBvC,CAAA"}
@@ -0,0 +1,102 @@
1
+ import type React from 'react';
2
+ import type { VerticalId } from '@fayz-ai/core';
3
+ export type MetricCategory = 'revenue' | 'operations' | 'clients' | 'custom';
4
+ export type MetricFormat = 'number' | 'currency' | 'percent' | 'duration';
5
+ export interface MetricValue {
6
+ /** Primary numeric value */
7
+ value: number;
8
+ /** Comparison value for trend (e.g., yesterday, last week) */
9
+ previousValue?: number;
10
+ /** Unit suffix (e.g., 'min', 'BRL') */
11
+ unit?: string;
12
+ /** Trend direction for visual indicator */
13
+ trend?: 'up' | 'down' | 'neutral';
14
+ /** Optional series (oldest → newest) rendered as an inline sparkline. */
15
+ spark?: number[];
16
+ }
17
+ export interface DashboardMetric {
18
+ /** Unique metric ID, e.g. 'revenue-today' */
19
+ id: string;
20
+ /** i18n key or plain label */
21
+ label: string;
22
+ /** Tooltip description */
23
+ description?: string;
24
+ /** Lucide icon name */
25
+ icon: string;
26
+ /** Grouping category */
27
+ category: MetricCategory;
28
+ /** Async function that computes the current value */
29
+ compute: () => Promise<MetricValue>;
30
+ /** Whether visible by default (before user customization) */
31
+ defaultVisible: boolean;
32
+ /** Default display order (lower = first) */
33
+ defaultOrder: number;
34
+ /** How to format the value */
35
+ format?: MetricFormat;
36
+ /** Render the card as a radial gauge toward this goal value. */
37
+ goal?: number;
38
+ /** Accent color for the gauge/sparkline. Defaults to a trend-aware color. */
39
+ accent?: string;
40
+ }
41
+ export interface ResolvedMetric extends DashboardMetric {
42
+ /** Current computed value (null while loading) */
43
+ currentValue: MetricValue | null;
44
+ /** Whether this metric is currently loading */
45
+ loading: boolean;
46
+ /** Error message if compute() failed */
47
+ error?: string;
48
+ }
49
+ export type DashboardZone = 'main' | 'sidebar' | 'bottom-right';
50
+ export interface DashboardSectionProps {
51
+ tenantId?: string;
52
+ onNavigate?: (path: string) => void;
53
+ }
54
+ export interface DashboardSection {
55
+ /** Unique section ID */
56
+ id: string;
57
+ /** i18n key or plain title */
58
+ title: string;
59
+ /** Lucide icon name */
60
+ icon?: string;
61
+ /** Zone placement on the dashboard */
62
+ zone: DashboardZone;
63
+ /** Column span on the 4-col grid (1–4). Default: 2 (half width). */
64
+ span?: 1 | 2 | 3 | 4;
65
+ /** Sort order within zone (lower = first) */
66
+ order: number;
67
+ /** React component to render */
68
+ component: React.ComponentType<DashboardSectionProps>;
69
+ /** Only show for specific verticals */
70
+ verticalId?: VerticalId;
71
+ }
72
+ export interface OnboardingStep {
73
+ /** Unique step ID, e.g. 'add-first-client' */
74
+ id: string;
75
+ /** i18n key or plain title */
76
+ title: string;
77
+ /** i18n key or plain description */
78
+ description: string;
79
+ /** Lucide icon name */
80
+ icon: string;
81
+ /** Async check: returns true if this step is already completed */
82
+ check: () => Promise<boolean>;
83
+ /** Route path to navigate to, or a callback */
84
+ action: string | (() => void);
85
+ /** Sort order (lower = first) */
86
+ order: number;
87
+ }
88
+ export interface OnboardingProgress {
89
+ stepId: string;
90
+ completedAt: string | null;
91
+ }
92
+ export interface DashboardPreferences {
93
+ id: string;
94
+ tenantId: string;
95
+ /** Ordered list of metric IDs the user wants visible */
96
+ visibleMetrics: string[];
97
+ /** Full metric ordering (visible + hidden) */
98
+ metricOrder: string[];
99
+ createdAt: string;
100
+ updatedAt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M,IAAI,CAAC,CAAA;IAC7B,iCAAiC;IACjC,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;CAC3B;AAMD,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,MAAM,CAAA;IAChB,wDAAwD;IACxD,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,8CAA8C;IAC9C,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;CAClB"}
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@fayz-ai/plugin-dashboard",
3
+ "version": "0.1.1",
4
+ "description": "Fayz SDK — plugin-dashboard plugin",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "source": "./src/index.ts",
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "require": "./dist/index.cjs"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "src"
20
+ ],
21
+ "peerDependencies": {
22
+ "react": "^18.0.0 || ^19.0.0",
23
+ "react-dom": "^18.0.0 || ^19.0.0"
24
+ },
25
+ "dependencies": {
26
+ "lucide-react": "^0.400.0",
27
+ "zustand": "^4.5.0",
28
+ "@fayz-ai/ui": "^0.1.6",
29
+ "@fayz-ai/core": "^0.1.6"
30
+ },
31
+ "devDependencies": {
32
+ "@types/react": "^18.3.0",
33
+ "react": "^18.3.0",
34
+ "tsup": "^8.2.0",
35
+ "typescript": "^5.5.0"
36
+ },
37
+ "license": "MIT",
38
+ "keywords": [
39
+ "fayz",
40
+ "fayz-plugin",
41
+ "fayz-sdk"
42
+ ],
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "scripts": {
47
+ "build": "tsup && tsc --emitDeclarationOnly --declaration --declarationMap --noEmit false",
48
+ "dev": "tsup --watch",
49
+ "typecheck": "tsc --noEmit",
50
+ "clean": "rm -rf dist"
51
+ }
52
+ }
@@ -0,0 +1,42 @@
1
+ import * as React from 'react'
2
+ import type { DashboardWidgetDef } from '@fayz-ai/core'
3
+ import { WidgetGrid } from '@fayz-ai/ui'
4
+ import { metricsToWidgets, sectionsToWidgets } from './builders'
5
+ import type { DashboardMetric, DashboardSection } from './types'
6
+
7
+ export interface DashboardPageProps {
8
+ title?: string
9
+ subtitle?: string
10
+ metrics?: DashboardMetric[]
11
+ sections?: DashboardSection[]
12
+ currency?: { code?: string; locale?: string; symbol?: string }
13
+ /** Render the in-content title/subtitle. Set false when the app shell owns
14
+ * the page title (sidebar/GHL-style layouts). Default: true. */
15
+ showHeader?: boolean
16
+ }
17
+
18
+ /**
19
+ * Back-compat shim. The dashboard is now a widget registry (see DashboardCanvas),
20
+ * but standalone callers can still render a fixed set of metrics/sections. This
21
+ * converts them to widget definitions and renders them through the shared grid.
22
+ */
23
+ export function DashboardPage({
24
+ title = 'Dashboard', subtitle = 'Business overview', metrics = [], sections = [], currency, showHeader = true,
25
+ }: DashboardPageProps) {
26
+ const widgets: DashboardWidgetDef[] = React.useMemo(
27
+ () => [...metricsToWidgets(metrics, currency), ...sectionsToWidgets(sections)],
28
+ [metrics, sections, currency],
29
+ )
30
+
31
+ return (
32
+ <div className="space-y-6 p-6">
33
+ {showHeader ? (
34
+ <div>
35
+ <h1 className="text-2xl font-semibold tracking-tight">{title}</h1>
36
+ <p className="mt-1 text-sm text-muted-foreground">{subtitle}</p>
37
+ </div>
38
+ ) : null}
39
+ <WidgetGrid widgets={widgets} surface="home" />
40
+ </div>
41
+ )
42
+ }
@@ -0,0 +1,94 @@
1
+ import * as React from 'react'
2
+ import type { DashboardWidgetDef } from '@fayz-ai/core'
3
+ import {
4
+ KpiCard,
5
+ OnboardingWidget,
6
+ defineKpiWidget,
7
+ defineCustomWidget,
8
+ defineOnboardingWidget,
9
+ useDashboardNavigate,
10
+ type KpiCurrency,
11
+ type OnboardingStepInput,
12
+ } from '@fayz-ai/ui'
13
+ import type { DashboardMetric, DashboardSection, OnboardingStep } from './types'
14
+
15
+ const DOMAIN = 'dashboard'
16
+
17
+ /** Legacy DashboardMetric[] → KPI widgets (async compute via the shared KpiCard). */
18
+ export function metricsToWidgets(metrics: DashboardMetric[], currency?: KpiCurrency): DashboardWidgetDef[] {
19
+ return metrics.map((metric, i) =>
20
+ defineKpiWidget({
21
+ id: `dashboard.kpi.${metric.id}`,
22
+ title: metric.label,
23
+ icon: metric.icon,
24
+ domain: DOMAIN,
25
+ defaultVisible: metric.defaultVisible,
26
+ defaultOrder: metric.defaultOrder ?? i,
27
+ component: () => (
28
+ <KpiCard
29
+ label={metric.label}
30
+ icon={metric.icon}
31
+ compute={metric.compute}
32
+ format={metric.format}
33
+ currency={currency}
34
+ goal={metric.goal}
35
+ accent={metric.accent}
36
+ />
37
+ ),
38
+ }),
39
+ )
40
+ }
41
+
42
+ /** Legacy DashboardSection[] → full-width custom widgets. */
43
+ export function sectionsToWidgets(sections: DashboardSection[]): DashboardWidgetDef[] {
44
+ return sections.map((section) => {
45
+ const SectionComponent = section.component
46
+ const Wrapped = () => {
47
+ const navigate = useDashboardNavigate()
48
+ return <SectionComponent onNavigate={navigate} />
49
+ }
50
+ return defineCustomWidget({
51
+ id: `dashboard.section.${section.id}`,
52
+ title: section.title,
53
+ icon: section.icon,
54
+ domain: DOMAIN,
55
+ // Half-width by default (guide/section cards like "Agenda de Hoje" should
56
+ // sit beside others, not dominate the row). Sections can opt into full
57
+ // width with `span: 4`.
58
+ span: section.span ?? 2,
59
+ defaultOrder: 100 + section.order,
60
+ verticalId: section.verticalId,
61
+ component: Wrapped,
62
+ })
63
+ })
64
+ }
65
+
66
+ /** Onboarding steps → a single "first steps to set up" checklist widget. */
67
+ export function onboardingToWidget(
68
+ steps: OnboardingStep[],
69
+ labels: { title: string; subtitle: string },
70
+ ): DashboardWidgetDef {
71
+ const sorted = [...steps].sort((a, b) => a.order - b.order)
72
+ const Onboarding = () => {
73
+ const navigate = useDashboardNavigate()
74
+ const items: OnboardingStepInput[] = sorted.map((s) => ({
75
+ id: s.id,
76
+ title: s.title,
77
+ description: s.description,
78
+ icon: s.icon,
79
+ check: s.check,
80
+ action: s.action,
81
+ }))
82
+ return <OnboardingWidget title={labels.title} subtitle={labels.subtitle} steps={items} onNavigate={navigate} />
83
+ }
84
+ return defineOnboardingWidget({
85
+ id: 'dashboard.onboarding',
86
+ title: labels.title,
87
+ domain: DOMAIN,
88
+ // Half-width (2 of 4 cols) so the getting-started guide sits beside other
89
+ // content rather than dominating the row.
90
+ span: 2,
91
+ defaultOrder: 50,
92
+ component: Onboarding,
93
+ })
94
+ }