@nubitio/dashboard 1.1.1 → 1.1.2

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.
@@ -1,9 +1,9 @@
1
- const require_ChartTooltip = require("./ChartTooltip-C0m3o4tP.cjs");
1
+ const require_ChartTooltip = require("./ChartTooltip-D1cB6hZ7.cjs");
2
2
  const require_chartPalette = require("./chartPalette-BmJoPzOC.cjs");
3
3
  let _nubitio_ui = require("@nubitio/ui");
4
4
  let react_jsx_runtime = require("react/jsx-runtime");
5
5
  let recharts = require("recharts");
6
- recharts = require_ChartTooltip.__toESM(recharts);
6
+ recharts = require_ChartTooltip.__toESM(recharts, 1);
7
7
  //#region packages/dashboard/dashboard/widgets/AreaChartWidgetView.tsx
8
8
  const Area = recharts.Area;
9
9
  const AreaChart = recharts.AreaChart;
@@ -15,7 +15,7 @@ var __copyProps = (to, from, except, desc) => {
15
15
  }
16
16
  return to;
17
17
  };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
19
19
  value: mod,
20
20
  enumerable: true
21
21
  }) : target, mod));
@@ -1,9 +1,9 @@
1
- const require_ChartTooltip = require("./ChartTooltip-C0m3o4tP.cjs");
1
+ const require_ChartTooltip = require("./ChartTooltip-D1cB6hZ7.cjs");
2
2
  const require_chartPalette = require("./chartPalette-BmJoPzOC.cjs");
3
3
  let _nubitio_ui = require("@nubitio/ui");
4
4
  let react_jsx_runtime = require("react/jsx-runtime");
5
5
  let recharts = require("recharts");
6
- recharts = require_ChartTooltip.__toESM(recharts);
6
+ recharts = require_ChartTooltip.__toESM(recharts, 1);
7
7
  //#region packages/dashboard/dashboard/widgets/LineChartWidgetView.tsx
8
8
  const CartesianGrid = recharts.CartesianGrid;
9
9
  const Legend = recharts.Legend;
package/dist/index.cjs CHANGED
@@ -329,13 +329,14 @@ function BarChartWidgetView({ widget, data, loading }) {
329
329
  children: rows.map((row, index) => {
330
330
  const label = String(row[widget.xKey] ?? "");
331
331
  const value = toNumber$2(row[widget.yKey]);
332
+ const pct = Math.max(4, value / max * 100);
332
333
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
333
334
  className: "nb-dashboard-bar-chart__item",
334
335
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
335
336
  className: "nb-dashboard-bar-chart__bar-wrap",
336
337
  children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
337
338
  className: "nb-dashboard-bar-chart__bar",
338
- style: { height: `${Math.max(4, value / max * 100)}%` },
339
+ style: { height: `${pct}%` },
339
340
  title: `${label}: ${require_chartPalette.formatDashboardValue(value, widget.valueFormat)}`
340
341
  })
341
342
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
@@ -505,7 +506,8 @@ function resolveTrend(widget, data) {
505
506
  };
506
507
  }
507
508
  function StatWidgetView({ widget, data, loading }) {
508
- const valueText = require_chartPalette.formatDashboardValue(widget.valuePath !== void 0 ? require_chartPalette.resolvePath(data, widget.valuePath) : widget.value, widget.format ?? "text");
509
+ const rawValue = widget.valuePath !== void 0 ? require_chartPalette.resolvePath(data, widget.valuePath) : widget.value;
510
+ const valueText = require_chartPalette.formatDashboardValue(rawValue, widget.format ?? "text");
509
511
  const trend = resolveTrend(widget, data);
510
512
  const trendDirection = trend.value === null || trend.value === 0 ? "flat" : trend.value > 0 ? "up" : "down";
511
513
  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";
@@ -543,10 +545,12 @@ function renderCell(row, column) {
543
545
  const raw = row[column.key];
544
546
  if (column.badge) {
545
547
  const key = raw == null ? "" : String(raw);
548
+ const variant = column.badge[key] ?? "secondary";
549
+ const label = column.badgeLabels?.[key] ?? key.replace(/_/g, " ");
546
550
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_nubitio_ui.Badge, {
547
- variant: column.badge[key] ?? "secondary",
551
+ variant,
548
552
  size: "sm",
549
- children: column.badgeLabels?.[key] ?? key.replace(/_/g, " ")
553
+ children: label
550
554
  });
551
555
  }
552
556
  return require_chartPalette.formatDashboardValue(raw, column.format ?? "text");
@@ -594,8 +598,8 @@ function TableWidgetView({ widget, data, loading }) {
594
598
  registerWidgetType("stat", StatWidgetView);
595
599
  registerWidgetType("bar-chart", BarChartWidgetView);
596
600
  registerWidgetType("donut-chart", DonutChartWidgetView);
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 }))));
601
+ registerWidgetType("line-chart", (0, react.lazy)(() => Promise.resolve().then(() => require("./LineChartWidgetView-D4YrumsC.cjs")).then((m) => ({ default: m.LineChartWidgetView }))));
602
+ registerWidgetType("area-chart", (0, react.lazy)(() => Promise.resolve().then(() => require("./AreaChartWidgetView-CQw0yRF0.cjs")).then((m) => ({ default: m.AreaChartWidgetView }))));
599
603
  registerWidgetType("progress", ProgressWidgetView);
600
604
  registerWidgetType("table", TableWidgetView);
601
605
  //#endregion
package/dist/index.d.cts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { BadgeVariant } from "@nubitio/ui";
2
2
  import { ComponentType } from "react";
3
-
4
3
  //#region packages/dashboard/dashboard/types.d.ts
5
4
  type ValueFormat = 'text' | 'number' | 'currency' | 'percent' | 'date' | 'datetime';
6
5
  interface TrendConfig {
@@ -215,9 +214,7 @@ declare function defineDashboard(config: DashboardConfig): DashboardConfig;
215
214
  interface DashboardPageProps {
216
215
  config: DashboardConfig;
217
216
  }
218
- declare function DashboardPage({
219
- config
220
- }: DashboardPageProps): import("react").JSX.Element;
217
+ declare function DashboardPage({ config }: DashboardPageProps): import("react").JSX.Element;
221
218
  //#endregion
222
219
  //#region packages/dashboard/dashboard/useDashboardPeriod.d.ts
223
220
  declare const CUSTOM_PERIOD_KEY = "custom";
@@ -231,9 +228,7 @@ interface DashboardPeriodState {
231
228
  declare function useDashboardPeriod(config?: DashboardPeriodConfig): DashboardPeriodState | undefined;
232
229
  //#endregion
233
230
  //#region packages/dashboard/dashboard/DashboardPeriodFilter.d.ts
234
- declare function DashboardPeriodFilter({
235
- period
236
- }: {
231
+ declare function DashboardPeriodFilter({ period }: {
237
232
  period: DashboardPeriodState;
238
233
  }): import("react").JSX.Element;
239
234
  //#endregion
@@ -255,9 +250,7 @@ interface DashboardLayoutState {
255
250
  declare function useDashboardLayout(dashboardId: string | undefined, sections: DashboardSection[], enabled: boolean): DashboardLayoutState | undefined;
256
251
  //#endregion
257
252
  //#region packages/dashboard/dashboard/DashboardLayoutControls.d.ts
258
- declare function DashboardLayoutControls({
259
- layout
260
- }: {
253
+ declare function DashboardLayoutControls({ layout }: {
261
254
  layout: DashboardLayoutState;
262
255
  }): import("react").JSX.Element;
263
256
  //#endregion
@@ -276,17 +269,7 @@ type Props = {
276
269
  end: string;
277
270
  };
278
271
  };
279
- declare function DashboardWidgetSlot({
280
- widget,
281
- data,
282
- loading,
283
- editMode,
284
- onHide,
285
- onMoveUp,
286
- onMoveDown,
287
- period,
288
- periodParamNames
289
- }: Props): import("react").JSX.Element;
272
+ declare function DashboardWidgetSlot({ widget, data, loading, editMode, onHide, onMoveUp, onMoveDown, period, periodParamNames }: Props): import("react").JSX.Element;
290
273
  //#endregion
291
274
  //#region packages/dashboard/dashboard/useDashboardData.d.ts
292
275
  declare function useDashboardData(dataUrl?: string, refreshInterval?: number, period?: DashboardPeriodValue, periodParamNames?: {
package/dist/index.d.mts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { BadgeVariant } from "@nubitio/ui";
2
2
  import { ComponentType } from "react";
3
-
4
3
  //#region packages/dashboard/dashboard/types.d.ts
5
4
  type ValueFormat = 'text' | 'number' | 'currency' | 'percent' | 'date' | 'datetime';
6
5
  interface TrendConfig {
@@ -215,9 +214,7 @@ declare function defineDashboard(config: DashboardConfig): DashboardConfig;
215
214
  interface DashboardPageProps {
216
215
  config: DashboardConfig;
217
216
  }
218
- declare function DashboardPage({
219
- config
220
- }: DashboardPageProps): import("react").JSX.Element;
217
+ declare function DashboardPage({ config }: DashboardPageProps): import("react").JSX.Element;
221
218
  //#endregion
222
219
  //#region packages/dashboard/dashboard/useDashboardPeriod.d.ts
223
220
  declare const CUSTOM_PERIOD_KEY = "custom";
@@ -231,9 +228,7 @@ interface DashboardPeriodState {
231
228
  declare function useDashboardPeriod(config?: DashboardPeriodConfig): DashboardPeriodState | undefined;
232
229
  //#endregion
233
230
  //#region packages/dashboard/dashboard/DashboardPeriodFilter.d.ts
234
- declare function DashboardPeriodFilter({
235
- period
236
- }: {
231
+ declare function DashboardPeriodFilter({ period }: {
237
232
  period: DashboardPeriodState;
238
233
  }): import("react").JSX.Element;
239
234
  //#endregion
@@ -255,9 +250,7 @@ interface DashboardLayoutState {
255
250
  declare function useDashboardLayout(dashboardId: string | undefined, sections: DashboardSection[], enabled: boolean): DashboardLayoutState | undefined;
256
251
  //#endregion
257
252
  //#region packages/dashboard/dashboard/DashboardLayoutControls.d.ts
258
- declare function DashboardLayoutControls({
259
- layout
260
- }: {
253
+ declare function DashboardLayoutControls({ layout }: {
261
254
  layout: DashboardLayoutState;
262
255
  }): import("react").JSX.Element;
263
256
  //#endregion
@@ -276,17 +269,7 @@ type Props = {
276
269
  end: string;
277
270
  };
278
271
  };
279
- declare function DashboardWidgetSlot({
280
- widget,
281
- data,
282
- loading,
283
- editMode,
284
- onHide,
285
- onMoveUp,
286
- onMoveDown,
287
- period,
288
- periodParamNames
289
- }: Props): import("react").JSX.Element;
272
+ declare function DashboardWidgetSlot({ widget, data, loading, editMode, onHide, onMoveUp, onMoveDown, period, periodParamNames }: Props): import("react").JSX.Element;
290
273
  //#endregion
291
274
  //#region packages/dashboard/dashboard/useDashboardData.d.ts
292
275
  declare function useDashboardData(dataUrl?: string, refreshInterval?: number, period?: DashboardPeriodValue, periodParamNames?: {
package/dist/index.mjs CHANGED
@@ -328,13 +328,14 @@ function BarChartWidgetView({ widget, data, loading }) {
328
328
  children: rows.map((row, index) => {
329
329
  const label = String(row[widget.xKey] ?? "");
330
330
  const value = toNumber$2(row[widget.yKey]);
331
+ const pct = Math.max(4, value / max * 100);
331
332
  return /* @__PURE__ */ jsxs("div", {
332
333
  className: "nb-dashboard-bar-chart__item",
333
334
  children: [/* @__PURE__ */ jsx("div", {
334
335
  className: "nb-dashboard-bar-chart__bar-wrap",
335
336
  children: /* @__PURE__ */ jsx("div", {
336
337
  className: "nb-dashboard-bar-chart__bar",
337
- style: { height: `${Math.max(4, value / max * 100)}%` },
338
+ style: { height: `${pct}%` },
338
339
  title: `${label}: ${formatDashboardValue(value, widget.valueFormat)}`
339
340
  })
340
341
  }), /* @__PURE__ */ jsx("span", {
@@ -504,7 +505,8 @@ function resolveTrend(widget, data) {
504
505
  };
505
506
  }
506
507
  function StatWidgetView({ widget, data, loading }) {
507
- const valueText = formatDashboardValue(widget.valuePath !== void 0 ? resolvePath(data, widget.valuePath) : widget.value, widget.format ?? "text");
508
+ const rawValue = widget.valuePath !== void 0 ? resolvePath(data, widget.valuePath) : widget.value;
509
+ const valueText = formatDashboardValue(rawValue, widget.format ?? "text");
508
510
  const trend = resolveTrend(widget, data);
509
511
  const trendDirection = trend.value === null || trend.value === 0 ? "flat" : trend.value > 0 ? "up" : "down";
510
512
  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";
@@ -542,10 +544,12 @@ function renderCell(row, column) {
542
544
  const raw = row[column.key];
543
545
  if (column.badge) {
544
546
  const key = raw == null ? "" : String(raw);
547
+ const variant = column.badge[key] ?? "secondary";
548
+ const label = column.badgeLabels?.[key] ?? key.replace(/_/g, " ");
545
549
  return /* @__PURE__ */ jsx(Badge, {
546
- variant: column.badge[key] ?? "secondary",
550
+ variant,
547
551
  size: "sm",
548
- children: column.badgeLabels?.[key] ?? key.replace(/_/g, " ")
552
+ children: label
549
553
  });
550
554
  }
551
555
  return formatDashboardValue(raw, column.format ?? "text");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nubitio/dashboard",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "type": "module",
5
5
  "description": "Declarative dashboard engine with stat cards, charts, and data tables for Nubit admin apps.",
6
6
  "license": "MIT",
@@ -56,12 +56,13 @@
56
56
  "react-dom": "^18.2.0 || ^19.0.0",
57
57
  "react-router-dom": "^6.0.0 || ^7.0.0",
58
58
  "recharts": "^3.0.0",
59
- "@nubitio/core": "^1.1.1",
60
- "@nubitio/ui": "^1.1.1"
59
+ "@nubitio/core": "^1.1.2",
60
+ "@nubitio/ui": "^1.1.2"
61
61
  },
62
62
  "devDependencies": {
63
- "@tanstack/react-query": "^5.0.0",
64
- "recharts": "^3.9.2"
63
+ "@tanstack/react-query": "^5.104.0",
64
+ "react-router-dom": "^6.30.6",
65
+ "recharts": "^3.10.1"
65
66
  },
66
67
  "peerDependenciesMeta": {
67
68
  "recharts": {