@nubitio/dashboard 0.11.4 → 1.0.0-rc.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/AreaChartWidgetView-BBp9C1bD.mjs +111 -0
- package/dist/AreaChartWidgetView-CmHmNCUh.cjs +112 -0
- package/dist/ChartTooltip-C0m3o4tP.cjs +70 -0
- package/dist/ChartTooltip-DQbTw6D2.mjs +37 -0
- package/dist/LineChartWidgetView-_HlG1ODm.cjs +90 -0
- package/dist/LineChartWidgetView-gNlby0Gq.mjs +89 -0
- package/dist/chartPalette-BmJoPzOC.cjs +90 -0
- package/dist/chartPalette-VDQwLcM-.mjs +67 -0
- package/dist/index.cjs +32 -297
- package/dist/index.mjs +15 -280
- package/package.json +9 -4
package/dist/index.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_chartPalette = require("./chartPalette-BmJoPzOC.cjs");
|
|
2
3
|
let _nubitio_ui = require("@nubitio/ui");
|
|
3
4
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
4
5
|
let react = require("react");
|
|
5
6
|
let react_router_dom = require("react-router-dom");
|
|
6
7
|
let _tanstack_react_query = require("@tanstack/react-query");
|
|
7
8
|
let _nubitio_core = require("@nubitio/core");
|
|
8
|
-
let recharts = require("recharts");
|
|
9
9
|
//#region packages/dashboard/dashboard/defineDashboard.ts
|
|
10
10
|
const dashboardCache = /* @__PURE__ */ new Map();
|
|
11
11
|
function cacheKey(config) {
|
|
@@ -300,209 +300,13 @@ function isWidgetTypeRegistered(type) {
|
|
|
300
300
|
return registry.has(type);
|
|
301
301
|
}
|
|
302
302
|
//#endregion
|
|
303
|
-
//#region packages/dashboard/dashboard/chartPalette.ts
|
|
304
|
-
const DEFAULT_CHART_COLORS = [
|
|
305
|
-
"var(--accent-color)",
|
|
306
|
-
"var(--success-color)",
|
|
307
|
-
"var(--warning-color)",
|
|
308
|
-
"var(--info-color)",
|
|
309
|
-
"#6b4fc8",
|
|
310
|
-
"#c2410c"
|
|
311
|
-
];
|
|
312
|
-
//#endregion
|
|
313
|
-
//#region packages/dashboard/dashboard/formatValue.ts
|
|
314
|
-
function formatDashboardValue(value, format = "text") {
|
|
315
|
-
if (value === null || value === void 0) return "—";
|
|
316
|
-
if (format === "text") return String(value);
|
|
317
|
-
if (format === "date" || format === "datetime") {
|
|
318
|
-
const date = value instanceof Date ? value : new Date(String(value));
|
|
319
|
-
if (Number.isNaN(date.getTime())) return String(value);
|
|
320
|
-
return new Intl.DateTimeFormat((0, _nubitio_core.getCoreLocale)(), {
|
|
321
|
-
dateStyle: format === "date" ? "medium" : void 0,
|
|
322
|
-
timeStyle: format === "datetime" ? "short" : void 0
|
|
323
|
-
}).format(date);
|
|
324
|
-
}
|
|
325
|
-
const numeric = typeof value === "number" ? value : Number(value);
|
|
326
|
-
if (!Number.isFinite(numeric)) return String(value);
|
|
327
|
-
const baseOptions = {
|
|
328
|
-
minimumFractionDigits: format === "currency" ? 2 : void 0,
|
|
329
|
-
maximumFractionDigits: format === "currency" ? 2 : void 0
|
|
330
|
-
};
|
|
331
|
-
if (format === "currency") {
|
|
332
|
-
const currency = (0, _nubitio_core.getCoreCurrency)();
|
|
333
|
-
if (!currency) return new Intl.NumberFormat((0, _nubitio_core.getCoreLocale)(), baseOptions).format(numeric);
|
|
334
|
-
return new Intl.NumberFormat((0, _nubitio_core.getCoreLocale)(), {
|
|
335
|
-
...baseOptions,
|
|
336
|
-
style: "currency",
|
|
337
|
-
currency,
|
|
338
|
-
currencyDisplay: "narrowSymbol"
|
|
339
|
-
}).format(numeric);
|
|
340
|
-
}
|
|
341
|
-
if (format === "percent") {
|
|
342
|
-
const normalized = Math.abs(numeric) <= 1 ? numeric : numeric / 100;
|
|
343
|
-
return new Intl.NumberFormat((0, _nubitio_core.getCoreLocale)(), {
|
|
344
|
-
style: "percent",
|
|
345
|
-
minimumFractionDigits: 1,
|
|
346
|
-
maximumFractionDigits: 1
|
|
347
|
-
}).format(normalized);
|
|
348
|
-
}
|
|
349
|
-
return new Intl.NumberFormat((0, _nubitio_core.getCoreLocale)()).format(numeric);
|
|
350
|
-
}
|
|
351
|
-
//#endregion
|
|
352
|
-
//#region packages/dashboard/dashboard/resolvePath.ts
|
|
353
|
-
function resolvePath(source, path) {
|
|
354
|
-
if (path === void 0 || path === "") return source;
|
|
355
|
-
if (source === null || source === void 0) return void 0;
|
|
356
|
-
return path.split(".").reduce((current, segment) => {
|
|
357
|
-
if (current === null || current === void 0) return void 0;
|
|
358
|
-
if (typeof current !== "object") return void 0;
|
|
359
|
-
return current[segment];
|
|
360
|
-
}, source);
|
|
361
|
-
}
|
|
362
|
-
function resolveArray(source, path) {
|
|
363
|
-
const value = resolvePath(source, path);
|
|
364
|
-
if (!Array.isArray(value)) return [];
|
|
365
|
-
return value.filter((item) => item !== null && typeof item === "object");
|
|
366
|
-
}
|
|
367
|
-
//#endregion
|
|
368
|
-
//#region packages/dashboard/dashboard/widgets/ChartTooltip.tsx
|
|
369
|
-
function ChartTooltip({ active, label, payload, labelFormat, series }) {
|
|
370
|
-
if (!active || !payload?.length) return null;
|
|
371
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
372
|
-
className: "nb-dashboard-chart-tooltip",
|
|
373
|
-
children: [label !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
374
|
-
className: "nb-dashboard-chart-tooltip__label",
|
|
375
|
-
children: label
|
|
376
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
377
|
-
className: "nb-dashboard-chart-tooltip__items",
|
|
378
|
-
children: payload.map((item) => {
|
|
379
|
-
const seriesConfig = series?.find((s) => s.key === item.dataKey);
|
|
380
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
381
|
-
className: "nb-dashboard-chart-tooltip__item",
|
|
382
|
-
children: [
|
|
383
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
384
|
-
className: "nb-dashboard-chart-tooltip__swatch",
|
|
385
|
-
style: { background: item.color }
|
|
386
|
-
}),
|
|
387
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
388
|
-
className: "nb-dashboard-chart-tooltip__name",
|
|
389
|
-
children: item.name
|
|
390
|
-
}),
|
|
391
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
392
|
-
className: "nb-dashboard-chart-tooltip__value",
|
|
393
|
-
children: formatDashboardValue(item.value, seriesConfig?.valueFormat ?? labelFormat)
|
|
394
|
-
})
|
|
395
|
-
]
|
|
396
|
-
}, String(item.dataKey));
|
|
397
|
-
})
|
|
398
|
-
})]
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
//#endregion
|
|
402
|
-
//#region packages/dashboard/dashboard/widgets/AreaChartWidgetView.tsx
|
|
403
|
-
function AreaChartWidgetView({ widget, data, loading }) {
|
|
404
|
-
const rows = resolveArray(data, widget.dataPath);
|
|
405
|
-
const height = widget.height ?? 240;
|
|
406
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_nubitio_ui.StatCard, {
|
|
407
|
-
title: widget.title,
|
|
408
|
-
headerExtra: widget.subtitle ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
409
|
-
className: "nb-dashboard-widget__subtitle",
|
|
410
|
-
children: widget.subtitle
|
|
411
|
-
}) : void 0,
|
|
412
|
-
menuVisible: widget.menuVisible,
|
|
413
|
-
isLoading: loading,
|
|
414
|
-
className: "nb-dashboard-chart-card",
|
|
415
|
-
children: rows.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
416
|
-
className: "nb-dashboard-chart-empty",
|
|
417
|
-
children: "No data"
|
|
418
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
419
|
-
style: { height },
|
|
420
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(recharts.ResponsiveContainer, {
|
|
421
|
-
width: "100%",
|
|
422
|
-
height: "100%",
|
|
423
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(recharts.AreaChart, {
|
|
424
|
-
data: rows,
|
|
425
|
-
margin: {
|
|
426
|
-
top: 4,
|
|
427
|
-
right: 8,
|
|
428
|
-
bottom: 0,
|
|
429
|
-
left: 0
|
|
430
|
-
},
|
|
431
|
-
children: [
|
|
432
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("defs", { children: widget.series.map((series, index) => {
|
|
433
|
-
const color = series.color ?? DEFAULT_CHART_COLORS[index % DEFAULT_CHART_COLORS.length];
|
|
434
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("linearGradient", {
|
|
435
|
-
id: `nb-area-${widget.id}-${series.key}`,
|
|
436
|
-
x1: "0",
|
|
437
|
-
y1: "0",
|
|
438
|
-
x2: "0",
|
|
439
|
-
y2: "1",
|
|
440
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
441
|
-
offset: "5%",
|
|
442
|
-
stopColor: color,
|
|
443
|
-
stopOpacity: .35
|
|
444
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("stop", {
|
|
445
|
-
offset: "95%",
|
|
446
|
-
stopColor: color,
|
|
447
|
-
stopOpacity: .02
|
|
448
|
-
})]
|
|
449
|
-
}, series.key);
|
|
450
|
-
}) }),
|
|
451
|
-
widget.showGrid !== false && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(recharts.CartesianGrid, {
|
|
452
|
-
strokeDasharray: "3 3",
|
|
453
|
-
stroke: "var(--border-color)",
|
|
454
|
-
vertical: false
|
|
455
|
-
}),
|
|
456
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(recharts.XAxis, {
|
|
457
|
-
dataKey: widget.xKey,
|
|
458
|
-
tick: {
|
|
459
|
-
fontSize: 11,
|
|
460
|
-
fill: "var(--text-tertiary)"
|
|
461
|
-
},
|
|
462
|
-
axisLine: { stroke: "var(--border-color)" },
|
|
463
|
-
tickLine: false
|
|
464
|
-
}),
|
|
465
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(recharts.YAxis, {
|
|
466
|
-
tick: {
|
|
467
|
-
fontSize: 11,
|
|
468
|
-
fill: "var(--text-tertiary)"
|
|
469
|
-
},
|
|
470
|
-
axisLine: false,
|
|
471
|
-
tickLine: false,
|
|
472
|
-
width: 48,
|
|
473
|
-
tickFormatter: (v) => formatDashboardValue(v, widget.valueFormat)
|
|
474
|
-
}),
|
|
475
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(recharts.Tooltip, { content: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChartTooltip, {
|
|
476
|
-
labelFormat: widget.valueFormat,
|
|
477
|
-
series: widget.series
|
|
478
|
-
}) }),
|
|
479
|
-
widget.showLegend && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(recharts.Legend, { wrapperStyle: { fontSize: 12 } }),
|
|
480
|
-
widget.series.map((series, index) => {
|
|
481
|
-
const color = series.color ?? DEFAULT_CHART_COLORS[index % DEFAULT_CHART_COLORS.length];
|
|
482
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(recharts.Area, {
|
|
483
|
-
type: "monotone",
|
|
484
|
-
dataKey: series.key,
|
|
485
|
-
name: series.label ?? series.key,
|
|
486
|
-
stroke: color,
|
|
487
|
-
strokeWidth: 2,
|
|
488
|
-
fill: `url(#nb-area-${widget.id}-${series.key})`,
|
|
489
|
-
stackId: widget.stacked ? "stack" : void 0
|
|
490
|
-
}, series.key);
|
|
491
|
-
})
|
|
492
|
-
]
|
|
493
|
-
})
|
|
494
|
-
})
|
|
495
|
-
})
|
|
496
|
-
});
|
|
497
|
-
}
|
|
498
|
-
//#endregion
|
|
499
303
|
//#region packages/dashboard/dashboard/widgets/BarChartWidgetView.tsx
|
|
500
304
|
function toNumber$2(value) {
|
|
501
305
|
const numeric = typeof value === "number" ? value : Number(value);
|
|
502
306
|
return Number.isFinite(numeric) ? numeric : 0;
|
|
503
307
|
}
|
|
504
308
|
function BarChartWidgetView({ widget, data, loading }) {
|
|
505
|
-
const rows = resolveArray(data, widget.dataPath);
|
|
309
|
+
const rows = require_chartPalette.resolveArray(data, widget.dataPath);
|
|
506
310
|
const max = rows.reduce((peak, row) => Math.max(peak, toNumber$2(row[widget.yKey])), 0) || 1;
|
|
507
311
|
const height = widget.height ?? 200;
|
|
508
312
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_nubitio_ui.StatCard, {
|
|
@@ -532,7 +336,7 @@ function BarChartWidgetView({ widget, data, loading }) {
|
|
|
532
336
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
533
337
|
className: "nb-dashboard-bar-chart__bar",
|
|
534
338
|
style: { height: `${Math.max(4, value / max * 100)}%` },
|
|
535
|
-
title: `${label}: ${formatDashboardValue(value, widget.valueFormat)}`
|
|
339
|
+
title: `${label}: ${require_chartPalette.formatDashboardValue(value, widget.valueFormat)}`
|
|
536
340
|
})
|
|
537
341
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
538
342
|
className: "nb-dashboard-bar-chart__label",
|
|
@@ -550,10 +354,10 @@ function toNumber$1(value) {
|
|
|
550
354
|
return Number.isFinite(numeric) ? numeric : 0;
|
|
551
355
|
}
|
|
552
356
|
function DonutChartWidgetView({ widget, data, loading }) {
|
|
553
|
-
const rows = resolveArray(data, widget.dataPath);
|
|
554
|
-
const colors = widget.colors ?? DEFAULT_CHART_COLORS;
|
|
357
|
+
const rows = require_chartPalette.resolveArray(data, widget.dataPath);
|
|
358
|
+
const colors = widget.colors ?? require_chartPalette.DEFAULT_CHART_COLORS;
|
|
555
359
|
const total = rows.reduce((sum, row) => sum + toNumber$1(row[widget.valueKey]), 0);
|
|
556
|
-
const centerValue = widget.centerValuePath !== void 0 ? resolvePath(data, widget.centerValuePath) : total;
|
|
360
|
+
const centerValue = widget.centerValuePath !== void 0 ? require_chartPalette.resolvePath(data, widget.centerValuePath) : total;
|
|
557
361
|
const radius = 38;
|
|
558
362
|
const stroke = 14;
|
|
559
363
|
const circumference = 2 * Math.PI * radius;
|
|
@@ -615,7 +419,7 @@ function DonutChartWidgetView({ widget, data, loading }) {
|
|
|
615
419
|
children: widget.centerLabel
|
|
616
420
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
617
421
|
className: "nb-dashboard-donut__center-value",
|
|
618
|
-
children: formatDashboardValue(centerValue, widget.valueFormat)
|
|
422
|
+
children: require_chartPalette.formatDashboardValue(centerValue, widget.valueFormat)
|
|
619
423
|
})]
|
|
620
424
|
})]
|
|
621
425
|
}), widget.showLegend !== false && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
@@ -647,89 +451,14 @@ function DonutChartWidgetView({ widget, data, loading }) {
|
|
|
647
451
|
});
|
|
648
452
|
}
|
|
649
453
|
//#endregion
|
|
650
|
-
//#region packages/dashboard/dashboard/widgets/LineChartWidgetView.tsx
|
|
651
|
-
function LineChartWidgetView({ widget, data, loading }) {
|
|
652
|
-
const rows = resolveArray(data, widget.dataPath);
|
|
653
|
-
const height = widget.height ?? 240;
|
|
654
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_nubitio_ui.StatCard, {
|
|
655
|
-
title: widget.title,
|
|
656
|
-
headerExtra: widget.subtitle ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
657
|
-
className: "nb-dashboard-widget__subtitle",
|
|
658
|
-
children: widget.subtitle
|
|
659
|
-
}) : void 0,
|
|
660
|
-
menuVisible: widget.menuVisible,
|
|
661
|
-
isLoading: loading,
|
|
662
|
-
className: "nb-dashboard-chart-card",
|
|
663
|
-
children: rows.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
664
|
-
className: "nb-dashboard-chart-empty",
|
|
665
|
-
children: "No data"
|
|
666
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
667
|
-
style: { height },
|
|
668
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(recharts.ResponsiveContainer, {
|
|
669
|
-
width: "100%",
|
|
670
|
-
height: "100%",
|
|
671
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(recharts.LineChart, {
|
|
672
|
-
data: rows,
|
|
673
|
-
margin: {
|
|
674
|
-
top: 4,
|
|
675
|
-
right: 8,
|
|
676
|
-
bottom: 0,
|
|
677
|
-
left: 0
|
|
678
|
-
},
|
|
679
|
-
children: [
|
|
680
|
-
widget.showGrid !== false && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(recharts.CartesianGrid, {
|
|
681
|
-
strokeDasharray: "3 3",
|
|
682
|
-
stroke: "var(--border-color)",
|
|
683
|
-
vertical: false
|
|
684
|
-
}),
|
|
685
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(recharts.XAxis, {
|
|
686
|
-
dataKey: widget.xKey,
|
|
687
|
-
tick: {
|
|
688
|
-
fontSize: 11,
|
|
689
|
-
fill: "var(--text-tertiary)"
|
|
690
|
-
},
|
|
691
|
-
axisLine: { stroke: "var(--border-color)" },
|
|
692
|
-
tickLine: false
|
|
693
|
-
}),
|
|
694
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(recharts.YAxis, {
|
|
695
|
-
tick: {
|
|
696
|
-
fontSize: 11,
|
|
697
|
-
fill: "var(--text-tertiary)"
|
|
698
|
-
},
|
|
699
|
-
axisLine: false,
|
|
700
|
-
tickLine: false,
|
|
701
|
-
width: 48,
|
|
702
|
-
tickFormatter: (v) => formatDashboardValue(v, widget.valueFormat)
|
|
703
|
-
}),
|
|
704
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(recharts.Tooltip, { content: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChartTooltip, {
|
|
705
|
-
labelFormat: widget.valueFormat,
|
|
706
|
-
series: widget.series
|
|
707
|
-
}) }),
|
|
708
|
-
widget.showLegend && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(recharts.Legend, { wrapperStyle: { fontSize: 12 } }),
|
|
709
|
-
widget.series.map((series, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(recharts.Line, {
|
|
710
|
-
type: widget.curved === false ? "linear" : "monotone",
|
|
711
|
-
dataKey: series.key,
|
|
712
|
-
name: series.label ?? series.key,
|
|
713
|
-
stroke: series.color ?? DEFAULT_CHART_COLORS[index % DEFAULT_CHART_COLORS.length],
|
|
714
|
-
strokeWidth: 2,
|
|
715
|
-
dot: false,
|
|
716
|
-
activeDot: { r: 4 }
|
|
717
|
-
}, series.key))
|
|
718
|
-
]
|
|
719
|
-
})
|
|
720
|
-
})
|
|
721
|
-
})
|
|
722
|
-
});
|
|
723
|
-
}
|
|
724
|
-
//#endregion
|
|
725
454
|
//#region packages/dashboard/dashboard/widgets/ProgressWidgetView.tsx
|
|
726
455
|
function toNumber(value, fallback) {
|
|
727
456
|
const numeric = typeof value === "number" ? value : Number(value);
|
|
728
457
|
return Number.isFinite(numeric) ? numeric : fallback;
|
|
729
458
|
}
|
|
730
459
|
function ProgressWidgetView({ widget, data, loading }) {
|
|
731
|
-
const value = toNumber(widget.valuePath !== void 0 ? resolvePath(data, widget.valuePath) : widget.value, 0);
|
|
732
|
-
const max = widget.maxPath !== void 0 ? toNumber(resolvePath(data, widget.maxPath), 100) : widget.max ?? 100;
|
|
460
|
+
const value = toNumber(widget.valuePath !== void 0 ? require_chartPalette.resolvePath(data, widget.valuePath) : widget.value, 0);
|
|
461
|
+
const max = widget.maxPath !== void 0 ? toNumber(require_chartPalette.resolvePath(data, widget.maxPath), 100) : widget.max ?? 100;
|
|
733
462
|
const pct = max > 0 ? Math.min(100, Math.max(0, value / max * 100)) : 0;
|
|
734
463
|
const tone = widget.tone ?? "accent";
|
|
735
464
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_nubitio_ui.StatCard, {
|
|
@@ -755,10 +484,10 @@ function ProgressWidgetView({ widget, data, loading }) {
|
|
|
755
484
|
className: "nb-dashboard-progress__labels",
|
|
756
485
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
757
486
|
className: "nb-dashboard-progress__value",
|
|
758
|
-
children: formatDashboardValue(value, widget.format ?? "number")
|
|
487
|
+
children: require_chartPalette.formatDashboardValue(value, widget.format ?? "number")
|
|
759
488
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
760
489
|
className: "nb-dashboard-progress__max",
|
|
761
|
-
children: ["/ ", formatDashboardValue(max, widget.format ?? "number")]
|
|
490
|
+
children: ["/ ", require_chartPalette.formatDashboardValue(max, widget.format ?? "number")]
|
|
762
491
|
})]
|
|
763
492
|
})]
|
|
764
493
|
});
|
|
@@ -767,7 +496,7 @@ function ProgressWidgetView({ widget, data, loading }) {
|
|
|
767
496
|
//#region packages/dashboard/dashboard/widgets/StatWidgetView.tsx
|
|
768
497
|
function resolveTrend(widget, data) {
|
|
769
498
|
if (!widget.trend) return { value: null };
|
|
770
|
-
const raw = widget.trend.valuePath !== void 0 ? resolvePath(data, widget.trend.valuePath) : widget.trend.value;
|
|
499
|
+
const raw = widget.trend.valuePath !== void 0 ? require_chartPalette.resolvePath(data, widget.trend.valuePath) : widget.trend.value;
|
|
771
500
|
const numeric = typeof raw === "number" ? raw : Number(raw);
|
|
772
501
|
return {
|
|
773
502
|
value: Number.isFinite(numeric) ? numeric : null,
|
|
@@ -776,12 +505,12 @@ function resolveTrend(widget, data) {
|
|
|
776
505
|
};
|
|
777
506
|
}
|
|
778
507
|
function StatWidgetView({ widget, data, loading }) {
|
|
779
|
-
const valueText = formatDashboardValue(widget.valuePath !== void 0 ? resolvePath(data, widget.valuePath) : widget.value, widget.format ?? "text");
|
|
508
|
+
const valueText = require_chartPalette.formatDashboardValue(widget.valuePath !== void 0 ? require_chartPalette.resolvePath(data, widget.valuePath) : widget.value, widget.format ?? "text");
|
|
780
509
|
const trend = resolveTrend(widget, data);
|
|
781
510
|
const trendDirection = trend.value === null || trend.value === 0 ? "flat" : trend.value > 0 ? "up" : "down";
|
|
782
511
|
const trendClass = trendDirection === "flat" ? "nb-stat-card__delta--flat" : trendDirection === "up" ? trend.invert ? "nb-stat-card__delta--down" : "nb-stat-card__delta--up" : trend.invert ? "nb-stat-card__delta--up" : "nb-stat-card__delta--down";
|
|
783
512
|
const trendArrow = trendDirection === "up" ? "▲" : trendDirection === "down" ? "▼" : "—";
|
|
784
|
-
const trendText = trend.value === null ? null : `${trendArrow} ${formatDashboardValue(Math.abs(trend.value), "percent")}${trend.label ? ` ${trend.label}` : ""}`;
|
|
513
|
+
const trendText = trend.value === null ? null : `${trendArrow} ${require_chartPalette.formatDashboardValue(Math.abs(trend.value), "percent")}${trend.label ? ` ${trend.label}` : ""}`;
|
|
785
514
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_nubitio_ui.StatCard, {
|
|
786
515
|
title: widget.title,
|
|
787
516
|
menuVisible: widget.menuVisible,
|
|
@@ -820,10 +549,10 @@ function renderCell(row, column) {
|
|
|
820
549
|
children: column.badgeLabels?.[key] ?? key.replace(/_/g, " ")
|
|
821
550
|
});
|
|
822
551
|
}
|
|
823
|
-
return formatDashboardValue(raw, column.format ?? "text");
|
|
552
|
+
return require_chartPalette.formatDashboardValue(raw, column.format ?? "text");
|
|
824
553
|
}
|
|
825
554
|
function TableWidgetView({ widget, data, loading }) {
|
|
826
|
-
const rows = resolveArray(data, widget.dataPath);
|
|
555
|
+
const rows = require_chartPalette.resolveArray(data, widget.dataPath);
|
|
827
556
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_nubitio_ui.StatCard, {
|
|
828
557
|
title: widget.title,
|
|
829
558
|
headerExtra: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -865,8 +594,8 @@ function TableWidgetView({ widget, data, loading }) {
|
|
|
865
594
|
registerWidgetType("stat", StatWidgetView);
|
|
866
595
|
registerWidgetType("bar-chart", BarChartWidgetView);
|
|
867
596
|
registerWidgetType("donut-chart", DonutChartWidgetView);
|
|
868
|
-
registerWidgetType("line-chart", LineChartWidgetView);
|
|
869
|
-
registerWidgetType("area-chart", AreaChartWidgetView);
|
|
597
|
+
registerWidgetType("line-chart", (0, react.lazy)(() => Promise.resolve().then(() => require("./LineChartWidgetView-_HlG1ODm.cjs")).then((m) => ({ default: m.LineChartWidgetView }))));
|
|
598
|
+
registerWidgetType("area-chart", (0, react.lazy)(() => Promise.resolve().then(() => require("./AreaChartWidgetView-CmHmNCUh.cjs")).then((m) => ({ default: m.AreaChartWidgetView }))));
|
|
870
599
|
registerWidgetType("progress", ProgressWidgetView);
|
|
871
600
|
registerWidgetType("table", TableWidgetView);
|
|
872
601
|
//#endregion
|
|
@@ -878,10 +607,16 @@ function WidgetRenderer({ widget, data, loading }) {
|
|
|
878
607
|
if (isDev) console.warn(`[@nubitio/dashboard] No widget registered for type "${widget.type}".`);
|
|
879
608
|
return null;
|
|
880
609
|
}
|
|
881
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
610
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react.Suspense, {
|
|
611
|
+
fallback: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
612
|
+
className: "nb-dashboard-widget-loading",
|
|
613
|
+
style: { height: "100%" }
|
|
614
|
+
}),
|
|
615
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, {
|
|
616
|
+
widget,
|
|
617
|
+
data,
|
|
618
|
+
loading
|
|
619
|
+
})
|
|
885
620
|
});
|
|
886
621
|
}
|
|
887
622
|
//#endregion
|
|
@@ -1203,7 +938,7 @@ function progressWidget(config) {
|
|
|
1203
938
|
}
|
|
1204
939
|
//#endregion
|
|
1205
940
|
exports.CUSTOM_PERIOD_KEY = CUSTOM_PERIOD_KEY;
|
|
1206
|
-
exports.DEFAULT_CHART_COLORS = DEFAULT_CHART_COLORS;
|
|
941
|
+
exports.DEFAULT_CHART_COLORS = require_chartPalette.DEFAULT_CHART_COLORS;
|
|
1207
942
|
exports.DEFAULT_PERIOD_PARAM_NAMES = DEFAULT_PERIOD_PARAM_NAMES;
|
|
1208
943
|
exports.DEFAULT_PERIOD_PRESETS = DEFAULT_PERIOD_PRESETS;
|
|
1209
944
|
exports.DashboardLayoutControls = DashboardLayoutControls;
|
|
@@ -1214,15 +949,15 @@ exports.areaChartWidget = areaChartWidget;
|
|
|
1214
949
|
exports.barChartWidget = barChartWidget;
|
|
1215
950
|
exports.defineDashboard = defineDashboard;
|
|
1216
951
|
exports.donutChartWidget = donutChartWidget;
|
|
1217
|
-
exports.formatDashboardValue = formatDashboardValue;
|
|
952
|
+
exports.formatDashboardValue = require_chartPalette.formatDashboardValue;
|
|
1218
953
|
exports.getPeriodPreset = getPeriodPreset;
|
|
1219
954
|
exports.getWidgetComponent = getWidgetComponent;
|
|
1220
955
|
exports.isWidgetTypeRegistered = isWidgetTypeRegistered;
|
|
1221
956
|
exports.lineChartWidget = lineChartWidget;
|
|
1222
957
|
exports.progressWidget = progressWidget;
|
|
1223
958
|
exports.registerWidgetType = registerWidgetType;
|
|
1224
|
-
exports.resolveArray = resolveArray;
|
|
1225
|
-
exports.resolvePath = resolvePath;
|
|
959
|
+
exports.resolveArray = require_chartPalette.resolveArray;
|
|
960
|
+
exports.resolvePath = require_chartPalette.resolvePath;
|
|
1226
961
|
exports.statWidget = statWidget;
|
|
1227
962
|
exports.tableWidget = tableWidget;
|
|
1228
963
|
exports.useDashboardData = useDashboardData;
|