@fayz-ai/ui 0.1.7 → 0.2.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/LICENSE +21 -0
- package/dist/chunk-22J2RTMN.js +1397 -0
- package/dist/chunk-22J2RTMN.js.map +1 -0
- package/dist/chunk-2P7T6QQK.cjs +206 -0
- package/dist/chunk-2P7T6QQK.cjs.map +1 -0
- package/dist/chunk-7TBDPNLY.cjs +649 -0
- package/dist/chunk-7TBDPNLY.cjs.map +1 -0
- package/dist/chunk-CZ6X6PZT.js +1237 -0
- package/dist/chunk-CZ6X6PZT.js.map +1 -0
- package/dist/chunk-D6SXPF4F.cjs +397 -0
- package/dist/chunk-D6SXPF4F.cjs.map +1 -0
- package/dist/chunk-DNYVEOAX.js +11 -0
- package/dist/chunk-DNYVEOAX.js.map +1 -0
- package/dist/chunk-E526FHZ4.js +169 -0
- package/dist/chunk-E526FHZ4.js.map +1 -0
- package/dist/chunk-GE6XUREM.cjs +1277 -0
- package/dist/chunk-GE6XUREM.cjs.map +1 -0
- package/dist/chunk-GFH5HOCO.js +605 -0
- package/dist/chunk-GFH5HOCO.js.map +1 -0
- package/dist/chunk-IWBXYV4U.js +203 -0
- package/dist/chunk-IWBXYV4U.js.map +1 -0
- package/dist/chunk-MYZT2OG7.js +350 -0
- package/dist/chunk-MYZT2OG7.js.map +1 -0
- package/dist/chunk-O5F4LLSL.js +445 -0
- package/dist/chunk-O5F4LLSL.js.map +1 -0
- package/dist/chunk-TDGSY5W6.cjs +474 -0
- package/dist/chunk-TDGSY5W6.cjs.map +1 -0
- package/dist/chunk-VVVZO2LE.cjs +13 -0
- package/dist/chunk-VVVZO2LE.cjs.map +1 -0
- package/dist/chunk-W4XXXJRW.cjs +196 -0
- package/dist/chunk-W4XXXJRW.cjs.map +1 -0
- package/dist/chunk-YB5ZJKNG.cjs +1484 -0
- package/dist/chunk-YB5ZJKNG.cjs.map +1 -0
- package/dist/dashboard/index.cjs +102 -0
- package/dist/dashboard/index.cjs.map +1 -0
- package/dist/dashboard/index.js +5 -0
- package/dist/dashboard/index.js.map +1 -0
- package/dist/index.cjs +569 -4288
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +15 -4136
- package/dist/index.js.map +1 -1
- package/dist/layout/ModulePage.d.ts.map +1 -1
- package/dist/layout/Topbar.d.ts.map +1 -1
- package/dist/layout/index.cjs +90 -0
- package/dist/layout/index.cjs.map +1 -0
- package/dist/layout/index.js +5 -0
- package/dist/layout/index.js.map +1 -0
- package/dist/layout/useCrossModuleBack.d.ts +16 -0
- package/dist/layout/useCrossModuleBack.d.ts.map +1 -0
- package/dist/preset.cjs +18 -0
- package/dist/preset.cjs.map +1 -0
- package/dist/preset.js +3 -0
- package/dist/preset.js.map +1 -0
- package/dist/primitives/breadcrumb.d.ts.map +1 -1
- package/dist/primitives/index.cjs +347 -0
- package/dist/primitives/index.cjs.map +1 -0
- package/dist/primitives/index.js +6 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/theme/index.cjs +41 -0
- package/dist/theme/index.cjs.map +1 -0
- package/dist/theme/index.js +4 -0
- package/dist/theme/index.js.map +1 -0
- package/package.json +10 -10
- package/src/layout/ModulePage.tsx +15 -8
- package/src/layout/Topbar.tsx +5 -1
- package/src/layout/useCrossModuleBack.ts +30 -0
- package/src/primitives/breadcrumb.tsx +7 -3
|
@@ -0,0 +1,649 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkD6SXPF4F_cjs = require('./chunk-D6SXPF4F.cjs');
|
|
4
|
+
var chunkVVVZO2LE_cjs = require('./chunk-VVVZO2LE.cjs');
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var LucideIcons = require('lucide-react');
|
|
7
|
+
var core = require('@fayz-ai/core');
|
|
8
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
+
var recharts = require('recharts');
|
|
10
|
+
|
|
11
|
+
function _interopNamespace(e) {
|
|
12
|
+
if (e && e.__esModule) return e;
|
|
13
|
+
var n = Object.create(null);
|
|
14
|
+
if (e) {
|
|
15
|
+
Object.keys(e).forEach(function (k) {
|
|
16
|
+
if (k !== 'default') {
|
|
17
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
18
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () { return e[k]; }
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
n.default = e;
|
|
26
|
+
return Object.freeze(n);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
30
|
+
var LucideIcons__namespace = /*#__PURE__*/_interopNamespace(LucideIcons);
|
|
31
|
+
|
|
32
|
+
var SPAN_CLASS = {
|
|
33
|
+
1: "",
|
|
34
|
+
2: "sm:col-span-2",
|
|
35
|
+
3: "sm:col-span-2 lg:col-span-3",
|
|
36
|
+
4: "sm:col-span-2 lg:col-span-4"
|
|
37
|
+
};
|
|
38
|
+
function DashboardGrid({ items, className }) {
|
|
39
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: chunkVVVZO2LE_cjs.cn("grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4", className), children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: SPAN_CLASS[Math.min(Math.max(item.span ?? 1, 1), 4)] ?? "", children: item.node }, item.id)) });
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// src/dashboard/layout.ts
|
|
43
|
+
function resolveDashboardLayout(registered, appConfig, userPrefs, forceVisibleByDefault = false) {
|
|
44
|
+
const overrides = /* @__PURE__ */ new Map();
|
|
45
|
+
const merge = (cfg) => {
|
|
46
|
+
for (const w of cfg?.widgets ?? []) {
|
|
47
|
+
overrides.set(w.id, { ...overrides.get(w.id), ...w });
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
merge(appConfig);
|
|
51
|
+
merge(userPrefs);
|
|
52
|
+
return registered.map((def, index) => {
|
|
53
|
+
const o = overrides.get(def.id);
|
|
54
|
+
const baseVisible = forceVisibleByDefault ? true : def.defaultVisible ?? true;
|
|
55
|
+
const visible = o?.visible ?? baseVisible;
|
|
56
|
+
const order = o?.order ?? def.defaultOrder ?? index;
|
|
57
|
+
const span = Math.min(Math.max(o?.span ?? def.span ?? 1, 1), 4);
|
|
58
|
+
return { def, visible, order, span };
|
|
59
|
+
}).filter((x) => x.visible).sort((a, b) => a.order - b.order).map(({ def, span, order }) => ({ def, span, order }));
|
|
60
|
+
}
|
|
61
|
+
var KEY = (surface, scope) => `fayz.dashboard.prefs.${scope}.${surface}`;
|
|
62
|
+
function read(key) {
|
|
63
|
+
if (typeof window === "undefined") return null;
|
|
64
|
+
try {
|
|
65
|
+
const raw = window.localStorage.getItem(key);
|
|
66
|
+
return raw ? JSON.parse(raw) : null;
|
|
67
|
+
} catch {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function useDashboardPreferences(surface, scope = "home") {
|
|
72
|
+
const key = KEY(surface, scope);
|
|
73
|
+
const [prefs, setPrefs] = React__namespace.useState(() => read(key));
|
|
74
|
+
React__namespace.useEffect(() => {
|
|
75
|
+
setPrefs(read(key));
|
|
76
|
+
}, [key]);
|
|
77
|
+
const save = React__namespace.useCallback((next) => {
|
|
78
|
+
setPrefs(next);
|
|
79
|
+
if (typeof window !== "undefined") {
|
|
80
|
+
try {
|
|
81
|
+
window.localStorage.setItem(key, JSON.stringify(next));
|
|
82
|
+
} catch {
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}, [key]);
|
|
86
|
+
const setVisible = React__namespace.useCallback((widgetId, visible) => {
|
|
87
|
+
setPrefs((cur) => {
|
|
88
|
+
const widgets = [...cur?.widgets ?? []];
|
|
89
|
+
const i = widgets.findIndex((w) => w.id === widgetId);
|
|
90
|
+
if (i >= 0) widgets[i] = { ...widgets[i], visible };
|
|
91
|
+
else widgets.push({ id: widgetId, visible });
|
|
92
|
+
const next = { ...cur, widgets };
|
|
93
|
+
if (typeof window !== "undefined") {
|
|
94
|
+
try {
|
|
95
|
+
window.localStorage.setItem(key, JSON.stringify(next));
|
|
96
|
+
} catch {
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return next;
|
|
100
|
+
});
|
|
101
|
+
}, [key]);
|
|
102
|
+
const reset = React__namespace.useCallback(() => {
|
|
103
|
+
setPrefs(null);
|
|
104
|
+
if (typeof window !== "undefined") {
|
|
105
|
+
try {
|
|
106
|
+
window.localStorage.removeItem(key);
|
|
107
|
+
} catch {
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}, [key]);
|
|
111
|
+
return { prefs, save, setVisible, reset };
|
|
112
|
+
}
|
|
113
|
+
var DEFAULT_RANGE_OPTIONS = ["7d", "30d", "90d"];
|
|
114
|
+
var DashboardRangeContext = React__namespace.createContext(null);
|
|
115
|
+
function useDashboardRange() {
|
|
116
|
+
return React__namespace.useContext(DashboardRangeContext);
|
|
117
|
+
}
|
|
118
|
+
function DashboardRangeProvider({
|
|
119
|
+
options = DEFAULT_RANGE_OPTIONS,
|
|
120
|
+
defaultRange,
|
|
121
|
+
onChange,
|
|
122
|
+
children
|
|
123
|
+
}) {
|
|
124
|
+
const [range, setRangeState] = React__namespace.useState(defaultRange ?? options[1] ?? options[0] ?? "30d");
|
|
125
|
+
const setRange = React__namespace.useCallback((r) => {
|
|
126
|
+
setRangeState(r);
|
|
127
|
+
onChange?.(r);
|
|
128
|
+
}, [onChange]);
|
|
129
|
+
const value = React__namespace.useMemo(() => ({ range, setRange, options }), [range, setRange, options]);
|
|
130
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DashboardRangeContext.Provider, { value, children });
|
|
131
|
+
}
|
|
132
|
+
function DashboardRangeControl({ className }) {
|
|
133
|
+
const ctx = useDashboardRange();
|
|
134
|
+
if (!ctx) return null;
|
|
135
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
136
|
+
chunkD6SXPF4F_cjs.SegmentedControl,
|
|
137
|
+
{
|
|
138
|
+
options: ctx.options,
|
|
139
|
+
value: ctx.range,
|
|
140
|
+
onChange: ctx.setRange,
|
|
141
|
+
className,
|
|
142
|
+
"aria-label": "Time range"
|
|
143
|
+
}
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
function DashboardCustomizeMenu({ widgets, visibleIds, onToggle, onReset, label }) {
|
|
147
|
+
const t = core.useTranslation();
|
|
148
|
+
if (widgets.length === 0) return null;
|
|
149
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(chunkD6SXPF4F_cjs.Dropdown, { children: [
|
|
150
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkD6SXPF4F_cjs.DropdownTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(chunkD6SXPF4F_cjs.Button, { variant: "outline", size: "sm", className: "gap-1.5", children: [
|
|
151
|
+
/* @__PURE__ */ jsxRuntime.jsx(LucideIcons.SlidersHorizontal, { className: "h-3.5 w-3.5" }),
|
|
152
|
+
label ?? "Customize"
|
|
153
|
+
] }) }),
|
|
154
|
+
/* @__PURE__ */ jsxRuntime.jsxs(chunkD6SXPF4F_cjs.DropdownContent, { align: "end", className: "max-h-[70vh] w-60 overflow-y-auto", children: [
|
|
155
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkD6SXPF4F_cjs.DropdownLabel, { children: label ?? "Show widgets" }),
|
|
156
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkD6SXPF4F_cjs.DropdownSeparator, {}),
|
|
157
|
+
widgets.map((w) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
158
|
+
chunkD6SXPF4F_cjs.DropdownCheckboxItem,
|
|
159
|
+
{
|
|
160
|
+
checked: visibleIds.has(w.id),
|
|
161
|
+
onCheckedChange: (checked) => onToggle(w.id, Boolean(checked)),
|
|
162
|
+
onSelect: (e) => e.preventDefault(),
|
|
163
|
+
children: t(w.title)
|
|
164
|
+
},
|
|
165
|
+
w.id
|
|
166
|
+
)),
|
|
167
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkD6SXPF4F_cjs.DropdownSeparator, {}),
|
|
168
|
+
/* @__PURE__ */ jsxRuntime.jsxs(chunkD6SXPF4F_cjs.DropdownItem, { onSelect: () => onReset(), children: [
|
|
169
|
+
/* @__PURE__ */ jsxRuntime.jsx(LucideIcons.RotateCcw, { className: "mr-2 h-3.5 w-3.5" }),
|
|
170
|
+
"Reset to defaults"
|
|
171
|
+
] })
|
|
172
|
+
] })
|
|
173
|
+
] });
|
|
174
|
+
}
|
|
175
|
+
function HoverHide({ id, onHide, children }) {
|
|
176
|
+
if (!onHide) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
|
|
177
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "group relative h-full", children: [
|
|
178
|
+
children,
|
|
179
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
180
|
+
"button",
|
|
181
|
+
{
|
|
182
|
+
type: "button",
|
|
183
|
+
onClick: () => onHide(id),
|
|
184
|
+
title: "Hide widget",
|
|
185
|
+
"aria-label": "Hide widget",
|
|
186
|
+
className: "absolute right-2 top-2 z-10 inline-flex h-6 w-6 items-center justify-center rounded-md border border-border bg-background/90 text-muted-foreground opacity-0 shadow-sm transition-opacity hover:text-foreground group-hover:opacity-100",
|
|
187
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.EyeOff, { className: "h-3.5 w-3.5" })
|
|
188
|
+
}
|
|
189
|
+
)
|
|
190
|
+
] });
|
|
191
|
+
}
|
|
192
|
+
function toGridItems(laidOut, onHide) {
|
|
193
|
+
return laidOut.map(({ def, span }) => {
|
|
194
|
+
const Component = core.resolvePluginComponent(def);
|
|
195
|
+
const node = Component ? /* @__PURE__ */ jsxRuntime.jsx(Component, { ...def.props ?? {} }) : null;
|
|
196
|
+
return { id: def.id, span, node: /* @__PURE__ */ jsxRuntime.jsx(HoverHide, { id: def.id, onHide, children: node }) };
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
var DashboardNavigateContext = React__namespace.createContext(
|
|
200
|
+
(path) => core.hashRouterAdapter().navigate(path)
|
|
201
|
+
);
|
|
202
|
+
var DashboardNavigateProvider = DashboardNavigateContext.Provider;
|
|
203
|
+
function useDashboardNavigate() {
|
|
204
|
+
return React__namespace.useContext(DashboardNavigateContext);
|
|
205
|
+
}
|
|
206
|
+
function WidgetGrid({ widgets, appLayout, surface }) {
|
|
207
|
+
const { prefs, setVisible } = useDashboardPreferences(surface);
|
|
208
|
+
const laidOut = resolveDashboardLayout(widgets, appLayout, prefs ?? void 0);
|
|
209
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DashboardGrid, { items: toGridItems(laidOut, (id) => setVisible(id, false)) });
|
|
210
|
+
}
|
|
211
|
+
function DashboardCanvas({
|
|
212
|
+
surface,
|
|
213
|
+
domain,
|
|
214
|
+
title,
|
|
215
|
+
subtitle,
|
|
216
|
+
showHeader = true,
|
|
217
|
+
appLayout,
|
|
218
|
+
range,
|
|
219
|
+
customizable = true,
|
|
220
|
+
customizeLabel,
|
|
221
|
+
initialVisibility,
|
|
222
|
+
onNavigate,
|
|
223
|
+
className
|
|
224
|
+
}) {
|
|
225
|
+
const runtime = core.usePluginRuntime();
|
|
226
|
+
const widgets = core.getDashboardWidgets(runtime, { surface, domain });
|
|
227
|
+
const rangeOpts = range ? range === true ? {} : range : null;
|
|
228
|
+
const forceAll = (initialVisibility ?? (surface === "plugin-home" ? "all" : "default")) === "all";
|
|
229
|
+
const { prefs, setVisible, reset } = useDashboardPreferences(surface, domain ?? "home");
|
|
230
|
+
const laidOut = resolveDashboardLayout(widgets, appLayout, prefs ?? void 0, forceAll);
|
|
231
|
+
const visibleIds = React__namespace.useMemo(() => new Set(laidOut.map((w) => w.def.id)), [laidOut]);
|
|
232
|
+
const hasControls = Boolean(rangeOpts) || customizable && widgets.length > 0;
|
|
233
|
+
const headerBlock = showHeader && (title || subtitle) ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
234
|
+
title ? /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-2xl font-semibold tracking-tight", children: title }) : null,
|
|
235
|
+
subtitle ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: subtitle }) : null
|
|
236
|
+
] }) : null;
|
|
237
|
+
const topRow = headerBlock || hasControls ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between gap-4", children: [
|
|
238
|
+
headerBlock ?? /* @__PURE__ */ jsxRuntime.jsx("span", {}),
|
|
239
|
+
hasControls ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex shrink-0 items-center gap-2", children: [
|
|
240
|
+
customizable && widgets.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
241
|
+
DashboardCustomizeMenu,
|
|
242
|
+
{
|
|
243
|
+
widgets,
|
|
244
|
+
visibleIds,
|
|
245
|
+
onToggle: setVisible,
|
|
246
|
+
onReset: reset,
|
|
247
|
+
label: customizeLabel
|
|
248
|
+
}
|
|
249
|
+
) : null,
|
|
250
|
+
rangeOpts ? /* @__PURE__ */ jsxRuntime.jsx(DashboardRangeControl, {}) : null
|
|
251
|
+
] }) : null
|
|
252
|
+
] }) : null;
|
|
253
|
+
const content = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: className ?? "space-y-6 p-6", children: [
|
|
254
|
+
topRow,
|
|
255
|
+
widgets.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs(chunkD6SXPF4F_cjs.Card, { children: [
|
|
256
|
+
/* @__PURE__ */ jsxRuntime.jsxs(chunkD6SXPF4F_cjs.CardHeader, { children: [
|
|
257
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkD6SXPF4F_cjs.CardTitle, { children: "Welcome!" }),
|
|
258
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkD6SXPF4F_cjs.CardDescription, { children: "Your dashboard will show key metrics and information here." })
|
|
259
|
+
] }),
|
|
260
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkD6SXPF4F_cjs.CardContent, { children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Enable plugins or register dashboard widgets to populate this view." }) })
|
|
261
|
+
] }) : laidOut.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(chunkD6SXPF4F_cjs.Card, { children: /* @__PURE__ */ jsxRuntime.jsx(chunkD6SXPF4F_cjs.CardContent, { className: "p-6 text-sm text-muted-foreground", children: "All widgets are hidden. Use \u201CCustomize\u201D to choose what to show." }) }) : /* @__PURE__ */ jsxRuntime.jsx(DashboardGrid, { items: toGridItems(laidOut) })
|
|
262
|
+
] });
|
|
263
|
+
const navWrapped = onNavigate ? /* @__PURE__ */ jsxRuntime.jsx(DashboardNavigateProvider, { value: onNavigate, children: content }) : content;
|
|
264
|
+
return rangeOpts ? /* @__PURE__ */ jsxRuntime.jsx(DashboardRangeProvider, { options: rangeOpts.options, defaultRange: rangeOpts.default, onChange: rangeOpts.onChange, children: navWrapped }) : navWrapped;
|
|
265
|
+
}
|
|
266
|
+
function renderIcon(icon, className = "h-4 w-4") {
|
|
267
|
+
if (!icon) return null;
|
|
268
|
+
if (typeof icon === "string") {
|
|
269
|
+
const Comp = LucideIcons__namespace[icon];
|
|
270
|
+
return Comp ? React__namespace.createElement(Comp, { className }) : null;
|
|
271
|
+
}
|
|
272
|
+
return React__namespace.createElement(icon, { className });
|
|
273
|
+
}
|
|
274
|
+
function formatKpiValue(value, format, currency) {
|
|
275
|
+
const locale = currency?.locale ?? "pt-BR";
|
|
276
|
+
switch (format) {
|
|
277
|
+
case "currency":
|
|
278
|
+
return new Intl.NumberFormat(locale, { style: "currency", currency: currency?.code ?? "BRL", maximumFractionDigits: 0 }).format(value);
|
|
279
|
+
case "percent":
|
|
280
|
+
return `${new Intl.NumberFormat(locale, { maximumFractionDigits: 1 }).format(value)}%`;
|
|
281
|
+
case "duration":
|
|
282
|
+
return `${Math.round(value)} min`;
|
|
283
|
+
default:
|
|
284
|
+
return new Intl.NumberFormat(locale, { maximumFractionDigits: 1 }).format(value);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
function deriveTrend(current, previous, explicit) {
|
|
288
|
+
if (explicit) return explicit;
|
|
289
|
+
if (previous == null) return void 0;
|
|
290
|
+
return current > previous ? "up" : current < previous ? "down" : "neutral";
|
|
291
|
+
}
|
|
292
|
+
function TrendChip({ trend, delta, invert }) {
|
|
293
|
+
if (trend === "neutral") return null;
|
|
294
|
+
const good = invert ? trend === "down" : trend === "up";
|
|
295
|
+
const Icon = trend === "up" ? LucideIcons.TrendingUp : LucideIcons.TrendingDown;
|
|
296
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: chunkVVVZO2LE_cjs.cn(
|
|
297
|
+
"inline-flex items-center gap-0.5 text-xs font-medium",
|
|
298
|
+
good ? "text-emerald-600" : "text-rose-600"
|
|
299
|
+
), children: [
|
|
300
|
+
/* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "h-3 w-3" }),
|
|
301
|
+
delta != null ? `${delta > 0 ? "+" : ""}${delta}%` : null
|
|
302
|
+
] });
|
|
303
|
+
}
|
|
304
|
+
function trendColor(trend, invert) {
|
|
305
|
+
if (!trend || trend === "neutral") return "hsl(var(--info))";
|
|
306
|
+
const good = invert ? trend === "down" : trend === "up";
|
|
307
|
+
return good ? "#10b981" : "#f43f5e";
|
|
308
|
+
}
|
|
309
|
+
function Sparkline({ data, color }) {
|
|
310
|
+
const gid = React__namespace.useId();
|
|
311
|
+
if (!data || data.length < 2) return null;
|
|
312
|
+
const W = 96, H = 32, P = 3;
|
|
313
|
+
const min = Math.min(...data);
|
|
314
|
+
const max = Math.max(...data);
|
|
315
|
+
const span = max - min || 1;
|
|
316
|
+
const step = (W - P * 2) / (data.length - 1);
|
|
317
|
+
const pts = data.map((d, i) => {
|
|
318
|
+
const x = P + i * step;
|
|
319
|
+
const y = P + (H - P * 2) * (1 - (d - min) / span);
|
|
320
|
+
return [x, y];
|
|
321
|
+
});
|
|
322
|
+
const line = pts.map(([x, y], i) => `${i === 0 ? "M" : "L"}${x.toFixed(1)},${y.toFixed(1)}`).join(" ");
|
|
323
|
+
const area = `${line} L${pts[pts.length - 1][0].toFixed(1)},${H} L${pts[0][0].toFixed(1)},${H} Z`;
|
|
324
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: `0 0 ${W} ${H}`, className: "h-8 w-24 shrink-0 overflow-visible", preserveAspectRatio: "none", "aria-hidden": true, children: [
|
|
325
|
+
/* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs("linearGradient", { id: gid, x1: "0", y1: "0", x2: "0", y2: "1", children: [
|
|
326
|
+
/* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "0%", stopColor: color, stopOpacity: "0.22" }),
|
|
327
|
+
/* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "100%", stopColor: color, stopOpacity: "0" })
|
|
328
|
+
] }) }),
|
|
329
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: area, fill: `url(#${gid})` }),
|
|
330
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: line, fill: "none", stroke: color, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", vectorEffect: "non-scaling-stroke" })
|
|
331
|
+
] });
|
|
332
|
+
}
|
|
333
|
+
function Gauge({ value, goal, color, children }) {
|
|
334
|
+
const pct = goal > 0 ? Math.min(1, Math.max(0, value / goal)) : 0;
|
|
335
|
+
const R = 40, CX = 50, CY = 46, SW = 9;
|
|
336
|
+
const len = Math.PI * R;
|
|
337
|
+
const d = `M ${CX - R} ${CY} A ${R} ${R} 0 0 1 ${CX + R} ${CY}`;
|
|
338
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative mx-auto w-full max-w-[160px]", children: [
|
|
339
|
+
/* @__PURE__ */ jsxRuntime.jsxs("svg", { viewBox: "0 0 100 52", className: "w-full", "aria-hidden": true, children: [
|
|
340
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d, fill: "none", stroke: "hsl(var(--muted))", strokeWidth: SW, strokeLinecap: "round" }),
|
|
341
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
342
|
+
"path",
|
|
343
|
+
{
|
|
344
|
+
d,
|
|
345
|
+
fill: "none",
|
|
346
|
+
stroke: color,
|
|
347
|
+
strokeWidth: SW,
|
|
348
|
+
strokeLinecap: "round",
|
|
349
|
+
strokeDasharray: len,
|
|
350
|
+
strokeDashoffset: len * (1 - pct)
|
|
351
|
+
}
|
|
352
|
+
)
|
|
353
|
+
] }),
|
|
354
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-x-0 bottom-0 text-center text-2xl font-semibold tracking-tight text-foreground", children })
|
|
355
|
+
] });
|
|
356
|
+
}
|
|
357
|
+
function KpiCard(props) {
|
|
358
|
+
const { label, icon, sub, format, currency, invertTrend } = props;
|
|
359
|
+
const [computed, setComputed] = React__namespace.useState(null);
|
|
360
|
+
const [errored, setErrored] = React__namespace.useState(false);
|
|
361
|
+
React__namespace.useEffect(() => {
|
|
362
|
+
if (!props.compute) return;
|
|
363
|
+
let cancelled = false;
|
|
364
|
+
props.compute().then((v) => {
|
|
365
|
+
if (!cancelled) setComputed(v);
|
|
366
|
+
}).catch(() => {
|
|
367
|
+
if (!cancelled) setErrored(true);
|
|
368
|
+
});
|
|
369
|
+
return () => {
|
|
370
|
+
cancelled = true;
|
|
371
|
+
};
|
|
372
|
+
}, [props.compute]);
|
|
373
|
+
const isAsync = Boolean(props.compute);
|
|
374
|
+
const loading = props.loading || isAsync && computed === null && !errored;
|
|
375
|
+
let display = props.value;
|
|
376
|
+
let current = props.current;
|
|
377
|
+
let previous = props.previous;
|
|
378
|
+
let trend = props.trend;
|
|
379
|
+
let unit;
|
|
380
|
+
let spark = props.spark;
|
|
381
|
+
if (isAsync && computed) {
|
|
382
|
+
display = formatKpiValue(computed.value, format, currency);
|
|
383
|
+
current = computed.value;
|
|
384
|
+
previous = computed.previousValue;
|
|
385
|
+
trend = computed.trend;
|
|
386
|
+
unit = computed.unit;
|
|
387
|
+
spark = computed.spark ?? spark;
|
|
388
|
+
} else if (display == null && props.amount != null) {
|
|
389
|
+
display = formatKpiValue(props.amount, format, currency);
|
|
390
|
+
current = current ?? props.amount;
|
|
391
|
+
}
|
|
392
|
+
const resolvedTrend = current != null ? deriveTrend(current, previous, trend) : trend;
|
|
393
|
+
const delta = current != null && previous != null && previous !== 0 ? Math.round((current - previous) / previous * 100) : null;
|
|
394
|
+
const accent = props.accent ?? trendColor(resolvedTrend, invertTrend);
|
|
395
|
+
const valueText = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
396
|
+
display,
|
|
397
|
+
unit ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-1 text-sm font-normal text-muted-foreground", children: unit }) : null
|
|
398
|
+
] });
|
|
399
|
+
const trendChip = resolvedTrend ? /* @__PURE__ */ jsxRuntime.jsx(TrendChip, { trend: resolvedTrend, delta, invert: invertTrend }) : null;
|
|
400
|
+
const isGauge = props.goal != null && current != null;
|
|
401
|
+
const hasSpark = Boolean(spark && spark.length >= 2);
|
|
402
|
+
let body;
|
|
403
|
+
if (errored) {
|
|
404
|
+
body = /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: "\u2014" });
|
|
405
|
+
} else if (loading) {
|
|
406
|
+
body = isGauge ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mx-auto h-16 w-32 animate-pulse rounded bg-muted" }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-7 w-20 animate-pulse rounded bg-muted" });
|
|
407
|
+
} else if (isGauge) {
|
|
408
|
+
body = /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
409
|
+
/* @__PURE__ */ jsxRuntime.jsx(Gauge, { value: current, goal: props.goal, color: accent, children: valueText }),
|
|
410
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-1 flex items-center justify-center gap-2 text-xs text-muted-foreground", children: [
|
|
411
|
+
trendChip,
|
|
412
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: sub ?? `out of ${formatKpiValue(props.goal, format, currency)}` })
|
|
413
|
+
] })
|
|
414
|
+
] });
|
|
415
|
+
} else if (hasSpark) {
|
|
416
|
+
body = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-end justify-between gap-3", children: [
|
|
417
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0", children: [
|
|
418
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-2xl font-semibold tracking-tight text-foreground", children: valueText }),
|
|
419
|
+
trendChip ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-0.5", children: trendChip }) : null
|
|
420
|
+
] }),
|
|
421
|
+
/* @__PURE__ */ jsxRuntime.jsx(Sparkline, { data: spark, color: accent })
|
|
422
|
+
] });
|
|
423
|
+
} else {
|
|
424
|
+
body = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-baseline justify-between gap-2", children: [
|
|
425
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-2xl font-semibold tracking-tight text-foreground", children: valueText }),
|
|
426
|
+
trendChip ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "mb-0.5", children: trendChip }) : null
|
|
427
|
+
] });
|
|
428
|
+
}
|
|
429
|
+
return /* @__PURE__ */ jsxRuntime.jsx(chunkD6SXPF4F_cjs.Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(chunkD6SXPF4F_cjs.CardContent, { className: "p-4", children: [
|
|
430
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-2 flex items-center justify-between gap-2", children: [
|
|
431
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: label }),
|
|
432
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: renderIcon(icon) })
|
|
433
|
+
] }),
|
|
434
|
+
body,
|
|
435
|
+
sub && !isGauge ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-0.5 text-xs text-muted-foreground", children: sub }) : null
|
|
436
|
+
] }) });
|
|
437
|
+
}
|
|
438
|
+
var PALETTE = [
|
|
439
|
+
"hsl(var(--info))",
|
|
440
|
+
"hsl(var(--magic))",
|
|
441
|
+
"hsl(var(--success))",
|
|
442
|
+
"hsl(var(--warning))",
|
|
443
|
+
"hsl(var(--destructive))"
|
|
444
|
+
];
|
|
445
|
+
var AXIS = "hsl(var(--muted-foreground))";
|
|
446
|
+
var GRID = "hsl(var(--border))";
|
|
447
|
+
function ChartWidget({
|
|
448
|
+
type,
|
|
449
|
+
data,
|
|
450
|
+
series,
|
|
451
|
+
categoryKey = "name",
|
|
452
|
+
title,
|
|
453
|
+
icon,
|
|
454
|
+
headerAction,
|
|
455
|
+
height = 240,
|
|
456
|
+
className
|
|
457
|
+
}) {
|
|
458
|
+
const color = (i, explicit) => explicit ?? PALETTE[i % PALETTE.length];
|
|
459
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(chunkD6SXPF4F_cjs.Card, { className, children: [
|
|
460
|
+
(title || headerAction) && /* @__PURE__ */ jsxRuntime.jsxs(chunkD6SXPF4F_cjs.CardHeader, { className: "flex-row items-center justify-between space-y-0", children: [
|
|
461
|
+
title ? /* @__PURE__ */ jsxRuntime.jsxs(chunkD6SXPF4F_cjs.CardTitle, { className: "flex items-center gap-2", children: [
|
|
462
|
+
renderIcon(icon),
|
|
463
|
+
title
|
|
464
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("span", {}),
|
|
465
|
+
headerAction
|
|
466
|
+
] }),
|
|
467
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkD6SXPF4F_cjs.CardContent, { className: "p-4 pt-2", children: /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height, children: type === "pie" ? /* @__PURE__ */ jsxRuntime.jsxs(recharts.PieChart, { children: [
|
|
468
|
+
/* @__PURE__ */ jsxRuntime.jsx(recharts.Tooltip, {}),
|
|
469
|
+
/* @__PURE__ */ jsxRuntime.jsx(recharts.Pie, { data, dataKey: series[0]?.dataKey ?? "value", nameKey: categoryKey, innerRadius: 50, outerRadius: 80, paddingAngle: 2, children: data.map((_, i) => /* @__PURE__ */ jsxRuntime.jsx(recharts.Cell, { fill: color(i, series[0]?.color) }, i)) }),
|
|
470
|
+
/* @__PURE__ */ jsxRuntime.jsx(recharts.Legend, {})
|
|
471
|
+
] }) : type === "bar" ? /* @__PURE__ */ jsxRuntime.jsxs(recharts.BarChart, { data, children: [
|
|
472
|
+
/* @__PURE__ */ jsxRuntime.jsx(recharts.CartesianGrid, { strokeDasharray: "3 3", stroke: GRID, vertical: false }),
|
|
473
|
+
/* @__PURE__ */ jsxRuntime.jsx(recharts.XAxis, { dataKey: categoryKey, stroke: AXIS, fontSize: 12, tickLine: false, axisLine: false }),
|
|
474
|
+
/* @__PURE__ */ jsxRuntime.jsx(recharts.YAxis, { stroke: AXIS, fontSize: 12, tickLine: false, axisLine: false, width: 36 }),
|
|
475
|
+
/* @__PURE__ */ jsxRuntime.jsx(recharts.Tooltip, { cursor: { fill: GRID, opacity: 0.3 } }),
|
|
476
|
+
series.length > 1 && /* @__PURE__ */ jsxRuntime.jsx(recharts.Legend, {}),
|
|
477
|
+
series.map((s, i) => /* @__PURE__ */ jsxRuntime.jsx(recharts.Bar, { dataKey: s.dataKey, name: s.label ?? s.dataKey, fill: color(i, s.color), radius: [4, 4, 0, 0] }, s.dataKey))
|
|
478
|
+
] }) : type === "area" ? /* @__PURE__ */ jsxRuntime.jsxs(recharts.AreaChart, { data, children: [
|
|
479
|
+
/* @__PURE__ */ jsxRuntime.jsx(recharts.CartesianGrid, { strokeDasharray: "3 3", stroke: GRID, vertical: false }),
|
|
480
|
+
/* @__PURE__ */ jsxRuntime.jsx(recharts.XAxis, { dataKey: categoryKey, stroke: AXIS, fontSize: 12, tickLine: false, axisLine: false }),
|
|
481
|
+
/* @__PURE__ */ jsxRuntime.jsx(recharts.YAxis, { stroke: AXIS, fontSize: 12, tickLine: false, axisLine: false, width: 36 }),
|
|
482
|
+
/* @__PURE__ */ jsxRuntime.jsx(recharts.Tooltip, {}),
|
|
483
|
+
series.length > 1 && /* @__PURE__ */ jsxRuntime.jsx(recharts.Legend, {}),
|
|
484
|
+
series.map((s, i) => /* @__PURE__ */ jsxRuntime.jsx(recharts.Area, { dataKey: s.dataKey, name: s.label ?? s.dataKey, stroke: color(i, s.color), fill: color(i, s.color), fillOpacity: 0.15 }, s.dataKey))
|
|
485
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(recharts.LineChart, { data, children: [
|
|
486
|
+
/* @__PURE__ */ jsxRuntime.jsx(recharts.CartesianGrid, { strokeDasharray: "3 3", stroke: GRID, vertical: false }),
|
|
487
|
+
/* @__PURE__ */ jsxRuntime.jsx(recharts.XAxis, { dataKey: categoryKey, stroke: AXIS, fontSize: 12, tickLine: false, axisLine: false }),
|
|
488
|
+
/* @__PURE__ */ jsxRuntime.jsx(recharts.YAxis, { stroke: AXIS, fontSize: 12, tickLine: false, axisLine: false, width: 36 }),
|
|
489
|
+
/* @__PURE__ */ jsxRuntime.jsx(recharts.Tooltip, {}),
|
|
490
|
+
series.length > 1 && /* @__PURE__ */ jsxRuntime.jsx(recharts.Legend, {}),
|
|
491
|
+
series.map((s, i) => /* @__PURE__ */ jsxRuntime.jsx(recharts.Line, { dataKey: s.dataKey, name: s.label ?? s.dataKey, stroke: color(i, s.color), strokeWidth: 2, dot: false }, s.dataKey))
|
|
492
|
+
] }) }) })
|
|
493
|
+
] });
|
|
494
|
+
}
|
|
495
|
+
function TableWidget({
|
|
496
|
+
title,
|
|
497
|
+
icon,
|
|
498
|
+
columns,
|
|
499
|
+
data,
|
|
500
|
+
loading,
|
|
501
|
+
emptyMessage,
|
|
502
|
+
onRowClick,
|
|
503
|
+
headerAction,
|
|
504
|
+
className
|
|
505
|
+
}) {
|
|
506
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(chunkD6SXPF4F_cjs.Card, { className, children: [
|
|
507
|
+
(title || headerAction) && /* @__PURE__ */ jsxRuntime.jsxs(chunkD6SXPF4F_cjs.CardHeader, { className: "flex-row items-center justify-between space-y-0", children: [
|
|
508
|
+
title ? /* @__PURE__ */ jsxRuntime.jsxs(chunkD6SXPF4F_cjs.CardTitle, { className: "flex items-center gap-2", children: [
|
|
509
|
+
renderIcon(icon),
|
|
510
|
+
title
|
|
511
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("span", {}),
|
|
512
|
+
headerAction
|
|
513
|
+
] }),
|
|
514
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkD6SXPF4F_cjs.CardContent, { className: "p-0", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
515
|
+
chunkD6SXPF4F_cjs.DataTable,
|
|
516
|
+
{
|
|
517
|
+
columns,
|
|
518
|
+
data,
|
|
519
|
+
loading,
|
|
520
|
+
emptyMessage,
|
|
521
|
+
onRowClick,
|
|
522
|
+
variant: "flat",
|
|
523
|
+
compact: true
|
|
524
|
+
}
|
|
525
|
+
) })
|
|
526
|
+
] });
|
|
527
|
+
}
|
|
528
|
+
function OnboardingWidget({
|
|
529
|
+
title = "Getting started",
|
|
530
|
+
subtitle,
|
|
531
|
+
steps,
|
|
532
|
+
onNavigate,
|
|
533
|
+
hideWhenComplete = true,
|
|
534
|
+
className
|
|
535
|
+
}) {
|
|
536
|
+
const [completed, setCompleted] = React__namespace.useState(
|
|
537
|
+
() => Object.fromEntries(steps.map((s) => [s.id, Boolean(s.done)]))
|
|
538
|
+
);
|
|
539
|
+
React__namespace.useEffect(() => {
|
|
540
|
+
let cancelled = false;
|
|
541
|
+
Promise.all(steps.map(async (s) => {
|
|
542
|
+
if (s.done != null) return [s.id, s.done];
|
|
543
|
+
if (!s.check) return [s.id, false];
|
|
544
|
+
try {
|
|
545
|
+
return [s.id, await s.check()];
|
|
546
|
+
} catch {
|
|
547
|
+
return [s.id, false];
|
|
548
|
+
}
|
|
549
|
+
})).then((entries) => {
|
|
550
|
+
if (!cancelled) setCompleted(Object.fromEntries(entries));
|
|
551
|
+
});
|
|
552
|
+
return () => {
|
|
553
|
+
cancelled = true;
|
|
554
|
+
};
|
|
555
|
+
}, [steps]);
|
|
556
|
+
const doneCount = steps.filter((s) => completed[s.id]).length;
|
|
557
|
+
const allDone = doneCount === steps.length;
|
|
558
|
+
if (allDone && hideWhenComplete) return null;
|
|
559
|
+
const runAction = (action) => {
|
|
560
|
+
if (!action) return;
|
|
561
|
+
if (typeof action === "string") onNavigate?.(action);
|
|
562
|
+
else action();
|
|
563
|
+
};
|
|
564
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(chunkD6SXPF4F_cjs.Card, { className, children: [
|
|
565
|
+
/* @__PURE__ */ jsxRuntime.jsxs(chunkD6SXPF4F_cjs.CardHeader, { children: [
|
|
566
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkD6SXPF4F_cjs.CardTitle, { children: title }),
|
|
567
|
+
subtitle ? /* @__PURE__ */ jsxRuntime.jsx(chunkD6SXPF4F_cjs.CardDescription, { children: subtitle }) : null,
|
|
568
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2 flex items-center gap-3", children: [
|
|
569
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-1.5 flex-1 overflow-hidden rounded-full bg-muted", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
570
|
+
"div",
|
|
571
|
+
{
|
|
572
|
+
className: "h-full rounded-full bg-primary transition-all",
|
|
573
|
+
style: { width: `${steps.length ? doneCount / steps.length * 100 : 0}%` }
|
|
574
|
+
}
|
|
575
|
+
) }),
|
|
576
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs font-medium text-muted-foreground", children: [
|
|
577
|
+
doneCount,
|
|
578
|
+
"/",
|
|
579
|
+
steps.length
|
|
580
|
+
] })
|
|
581
|
+
] })
|
|
582
|
+
] }),
|
|
583
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunkD6SXPF4F_cjs.CardContent, { className: "space-y-1 pt-0", children: steps.map((step) => {
|
|
584
|
+
const isDone = completed[step.id];
|
|
585
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 rounded-lg px-2 py-2.5 hover:bg-muted/50", children: [
|
|
586
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: chunkVVVZO2LE_cjs.cn(
|
|
587
|
+
"flex h-7 w-7 shrink-0 items-center justify-center rounded-full",
|
|
588
|
+
isDone ? "bg-emerald-100 text-emerald-600" : "bg-muted text-muted-foreground"
|
|
589
|
+
), children: isDone ? /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.Check, { className: "h-4 w-4" }) : renderIcon(step.icon, "h-4 w-4") ?? /* @__PURE__ */ jsxRuntime.jsx(LucideIcons.Circle, { className: "h-4 w-4" }) }),
|
|
590
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
591
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: chunkVVVZO2LE_cjs.cn("text-sm font-medium", isDone && "text-muted-foreground line-through"), children: step.title }),
|
|
592
|
+
step.description ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "truncate text-xs text-muted-foreground", children: step.description }) : null
|
|
593
|
+
] }),
|
|
594
|
+
!isDone && step.action ? /* @__PURE__ */ jsxRuntime.jsx(chunkD6SXPF4F_cjs.Button, { size: "sm", variant: "outline", onClick: () => runAction(step.action), children: step.actionLabel ?? "Start" }) : null
|
|
595
|
+
] }, step.id);
|
|
596
|
+
}) })
|
|
597
|
+
] });
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
// src/dashboard/define.ts
|
|
601
|
+
function build(kind, defaultSpan, input) {
|
|
602
|
+
return {
|
|
603
|
+
kind,
|
|
604
|
+
span: input.span ?? defaultSpan,
|
|
605
|
+
defaultVisible: input.defaultVisible ?? true,
|
|
606
|
+
id: input.id,
|
|
607
|
+
title: input.title,
|
|
608
|
+
description: input.description,
|
|
609
|
+
icon: input.icon,
|
|
610
|
+
domain: input.domain,
|
|
611
|
+
defaultOrder: input.defaultOrder,
|
|
612
|
+
surfaces: input.surfaces,
|
|
613
|
+
verticalId: input.verticalId,
|
|
614
|
+
permission: input.permission,
|
|
615
|
+
component: input.component,
|
|
616
|
+
props: input.props
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
var defineKpiWidget = (input) => build("kpi", 1, input);
|
|
620
|
+
var defineChartWidget = (input) => build("chart", 2, input);
|
|
621
|
+
var defineTableWidget = (input) => build("table", 4, input);
|
|
622
|
+
var defineOnboardingWidget = (input) => build("onboarding", 2, input);
|
|
623
|
+
var defineCustomWidget = (input) => build("custom", 2, input);
|
|
624
|
+
|
|
625
|
+
exports.ChartWidget = ChartWidget;
|
|
626
|
+
exports.DEFAULT_RANGE_OPTIONS = DEFAULT_RANGE_OPTIONS;
|
|
627
|
+
exports.DashboardCanvas = DashboardCanvas;
|
|
628
|
+
exports.DashboardCustomizeMenu = DashboardCustomizeMenu;
|
|
629
|
+
exports.DashboardGrid = DashboardGrid;
|
|
630
|
+
exports.DashboardNavigateProvider = DashboardNavigateProvider;
|
|
631
|
+
exports.DashboardRangeControl = DashboardRangeControl;
|
|
632
|
+
exports.DashboardRangeProvider = DashboardRangeProvider;
|
|
633
|
+
exports.KpiCard = KpiCard;
|
|
634
|
+
exports.OnboardingWidget = OnboardingWidget;
|
|
635
|
+
exports.TableWidget = TableWidget;
|
|
636
|
+
exports.WidgetGrid = WidgetGrid;
|
|
637
|
+
exports.defineChartWidget = defineChartWidget;
|
|
638
|
+
exports.defineCustomWidget = defineCustomWidget;
|
|
639
|
+
exports.defineKpiWidget = defineKpiWidget;
|
|
640
|
+
exports.defineOnboardingWidget = defineOnboardingWidget;
|
|
641
|
+
exports.defineTableWidget = defineTableWidget;
|
|
642
|
+
exports.formatKpiValue = formatKpiValue;
|
|
643
|
+
exports.renderIcon = renderIcon;
|
|
644
|
+
exports.resolveDashboardLayout = resolveDashboardLayout;
|
|
645
|
+
exports.useDashboardNavigate = useDashboardNavigate;
|
|
646
|
+
exports.useDashboardPreferences = useDashboardPreferences;
|
|
647
|
+
exports.useDashboardRange = useDashboardRange;
|
|
648
|
+
//# sourceMappingURL=chunk-7TBDPNLY.cjs.map
|
|
649
|
+
//# sourceMappingURL=chunk-7TBDPNLY.cjs.map
|