@ttoss/react-dashboard 0.2.4 → 0.3.0

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/README.md CHANGED
@@ -274,6 +274,71 @@ import { DashboardGrid } from '@ttoss/react-dashboard';
274
274
  | --------- | --------- | ------- | ----------------------------- |
275
275
  | `loading` | `boolean` | - | Shows loading spinner if true |
276
276
 
277
+ ### DashboardSectionDivider
278
+
279
+ Component that displays a section divider with a title and horizontal line to visually separate sections in the dashboard grid.
280
+
281
+ ```tsx
282
+ import { DashboardSectionDivider } from '@ttoss/react-dashboard';
283
+
284
+ <DashboardSectionDivider title="Performance Metrics" />;
285
+ ```
286
+
287
+ **Props:**
288
+
289
+ | Prop | Type | Default | Description |
290
+ | ------- | -------- | ------- | -------------------------- |
291
+ | `title` | `string` | - | The title of the section |
292
+ | `type` | `string` | - | Must be `'sectionDivider'` |
293
+
294
+ **Usage in Dashboard Grid:**
295
+
296
+ Section dividers can be added to the dashboard grid just like regular cards. They help organize dashboard content into logical sections:
297
+
298
+ ```tsx
299
+ const selectedTemplate: DashboardTemplate = {
300
+ id: 'default',
301
+ name: 'Default Template',
302
+ grid: [
303
+ {
304
+ i: 'card-1',
305
+ x: 0,
306
+ y: 0,
307
+ w: 4,
308
+ h: 4,
309
+ card: {
310
+ title: 'Total Revenue',
311
+ type: 'bigNumber',
312
+ // ... other card properties
313
+ },
314
+ },
315
+ {
316
+ i: 'divider-1',
317
+ x: 0,
318
+ y: 4,
319
+ w: 12, // Full width for divider
320
+ h: 2, // Smaller height for divider
321
+ card: {
322
+ type: 'sectionDivider',
323
+ title: 'Performance Metrics',
324
+ },
325
+ },
326
+ {
327
+ i: 'card-2',
328
+ x: 0,
329
+ y: 6,
330
+ w: 4,
331
+ h: 4,
332
+ card: {
333
+ title: 'ROAS',
334
+ type: 'bigNumber',
335
+ // ... other card properties
336
+ },
337
+ },
338
+ ],
339
+ };
340
+ ```
341
+
277
342
  ## Filter Types
278
343
 
279
344
  ### Text Filter
@@ -364,7 +429,7 @@ interface DashboardTemplate {
364
429
 
365
430
  ```tsx
366
431
  interface DashboardGridItem extends ReactGridLayout.Layout {
367
- card: DashboardCard;
432
+ card: DashboardCard | SectionDivider;
368
433
  }
369
434
  ```
370
435
 
@@ -492,6 +557,33 @@ status={{
492
557
  }}
493
558
  ```
494
559
 
560
+ ### SectionDivider
561
+
562
+ Type for section divider items in the dashboard grid.
563
+
564
+ ```tsx
565
+ type SectionDivider = {
566
+ type: 'sectionDivider';
567
+ title: string;
568
+ };
569
+ ```
570
+
571
+ **Example:**
572
+
573
+ ```tsx
574
+ {
575
+ i: 'divider-1',
576
+ x: 0,
577
+ y: 4,
578
+ w: 12,
579
+ h: 2,
580
+ card: {
581
+ type: 'sectionDivider',
582
+ title: 'Performance Metrics',
583
+ },
584
+ }
585
+ ```
586
+
495
587
  ## Complete Example
496
588
 
497
589
  ```tsx
package/dist/esm/index.js CHANGED
@@ -7,11 +7,11 @@ var __name = (target, value) => __defProp(target, "name", {
7
7
  });
8
8
 
9
9
  // src/Dashboard.tsx
10
- import { Divider, Flex as Flex6 } from "@ttoss/ui";
10
+ import { Divider as Divider2, Flex as Flex7 } from "@ttoss/ui";
11
11
 
12
12
  // src/DashboardGrid.tsx
13
13
  import "react-grid-layout/css/styles.css";
14
- import { Box as Box3, Flex as Flex3, Spinner } from "@ttoss/ui";
14
+ import { Box as Box3, Flex as Flex4, Spinner } from "@ttoss/ui";
15
15
  import { Responsive, WidthProvider } from "react-grid-layout";
16
16
 
17
17
  // src/Cards/BigNumber.tsx
@@ -104,7 +104,7 @@ var formatNumber = /* @__PURE__ */__name((value, type, numberDecimalPlaces) => {
104
104
  currency: "BRL"
105
105
  }).format(value);
106
106
  case "percentage":
107
- return `${value.toFixed(2)}%`;
107
+ return `${value.toFixed(numberDecimalPlaces ?? 2)}%`;
108
108
  case "number":
109
109
  default:
110
110
  {
@@ -234,6 +234,36 @@ var DashboardCard = /* @__PURE__ */__name(props => {
234
234
  }
235
235
  }, "DashboardCard");
236
236
 
237
+ // src/DashboardSectionDivider.tsx
238
+ import { Divider, Flex as Flex3, Text as Text3 } from "@ttoss/ui";
239
+ var DashboardSectionDivider = /* @__PURE__ */__name(({
240
+ title
241
+ }) => {
242
+ return /* @__PURE__ */React.createElement(Flex3, {
243
+ sx: {
244
+ width: "100%",
245
+ height: "100%",
246
+ alignItems: "center",
247
+ justifyContent: "center",
248
+ flexDirection: "row",
249
+ gap: "6",
250
+ paddingTop: "10"
251
+ }
252
+ }, /* @__PURE__ */React.createElement(Text3, {
253
+ sx: {
254
+ color: "input.background.muted.disabled",
255
+ fontSize: "md",
256
+ fontWeight: "bold",
257
+ flex: "none"
258
+ }
259
+ }, title), /* @__PURE__ */React.createElement(Divider, {
260
+ sx: {
261
+ width: "100%",
262
+ color: "display.border.muted.default"
263
+ }
264
+ }));
265
+ }, "DashboardSectionDivider");
266
+
237
267
  // src/DashboardGrid.tsx
238
268
  var ResponsiveGridLayout = WidthProvider(Responsive);
239
269
  var DashboardGrid = /* @__PURE__ */__name(({
@@ -279,7 +309,7 @@ var DashboardGrid = /* @__PURE__ */__name(({
279
309
  width: "100%",
280
310
  height: "full"
281
311
  }
282
- }, loading ? /* @__PURE__ */React.createElement(Flex3, {
312
+ }, loading ? /* @__PURE__ */React.createElement(Flex4, {
283
313
  sx: {
284
314
  width: "100%",
285
315
  height: "full",
@@ -295,6 +325,11 @@ var DashboardGrid = /* @__PURE__ */__name(({
295
325
  margin: [10, 10],
296
326
  containerPadding: [0, 0]
297
327
  }, selectedTemplate.grid.map(item => {
328
+ if (item.card.type === "sectionDivider") {
329
+ return /* @__PURE__ */React.createElement("div", {
330
+ key: item.i
331
+ }, /* @__PURE__ */React.createElement(DashboardSectionDivider, item.card));
332
+ }
298
333
  return /* @__PURE__ */React.createElement("div", {
299
334
  key: item.i
300
335
  }, /* @__PURE__ */React.createElement(DashboardCard, item.card));
@@ -302,11 +337,11 @@ var DashboardGrid = /* @__PURE__ */__name(({
302
337
  }, "DashboardGrid");
303
338
 
304
339
  // src/DashboardHeader.tsx
305
- import { Flex as Flex5 } from "@ttoss/ui";
340
+ import { Flex as Flex6 } from "@ttoss/ui";
306
341
  import * as React7 from "react";
307
342
 
308
343
  // src/DashboardFilters.tsx
309
- import { Flex as Flex4 } from "@ttoss/ui";
344
+ import { Flex as Flex5 } from "@ttoss/ui";
310
345
  import * as React6 from "react";
311
346
 
312
347
  // src/DashboardProvider.tsx
@@ -508,7 +543,7 @@ var DashboardFilters = /* @__PURE__ */__name(() => {
508
543
  }
509
544
  return handlers;
510
545
  }, [filters, updateFilter]);
511
- return /* @__PURE__ */React6.createElement(Flex4, {
546
+ return /* @__PURE__ */React6.createElement(Flex5, {
512
547
  sx: {
513
548
  gap: "2",
514
549
  flexDirection: "row",
@@ -562,7 +597,7 @@ var DashboardFilters = /* @__PURE__ */__name(() => {
562
597
  var DashboardHeader = /* @__PURE__ */__name(({
563
598
  children
564
599
  }) => {
565
- return /* @__PURE__ */React7.createElement(Flex5, {
600
+ return /* @__PURE__ */React7.createElement(Flex6, {
566
601
  sx: {
567
602
  padding: "2"
568
603
  }
@@ -575,14 +610,14 @@ var DashboardContent = /* @__PURE__ */__name(({
575
610
  headerChildren,
576
611
  selectedTemplate
577
612
  }) => {
578
- return /* @__PURE__ */React.createElement(Flex6, {
613
+ return /* @__PURE__ */React.createElement(Flex7, {
579
614
  sx: {
580
615
  flexDirection: "column",
581
616
  gap: "5",
582
617
  padding: "2",
583
618
  width: "100%"
584
619
  }
585
- }, /* @__PURE__ */React.createElement(DashboardHeader, null, headerChildren), /* @__PURE__ */React.createElement(Divider, null), /* @__PURE__ */React.createElement(DashboardGrid, {
620
+ }, /* @__PURE__ */React.createElement(DashboardHeader, null, headerChildren), /* @__PURE__ */React.createElement(Divider2, null), /* @__PURE__ */React.createElement(DashboardGrid, {
586
621
  loading,
587
622
  selectedTemplate
588
623
  }));
@@ -606,4 +641,4 @@ var Dashboard = /* @__PURE__ */__name(({
606
641
  selectedTemplate
607
642
  }));
608
643
  }, "Dashboard");
609
- export { Dashboard, DashboardCard, DashboardFilterType, DashboardFilters, DashboardGrid, DashboardHeader, DashboardProvider, useDashboard };
644
+ export { Dashboard, DashboardCard, DashboardFilterType, DashboardFilters, DashboardGrid, DashboardHeader, DashboardProvider, DashboardSectionDivider, useDashboard };
package/dist/index.d.ts CHANGED
@@ -83,8 +83,14 @@ type DashboardFilter = {
83
83
  };
84
84
  declare const DashboardFilters: () => react_jsx_runtime.JSX.Element;
85
85
 
86
+ type SectionDivider = {
87
+ type: string;
88
+ title: string;
89
+ };
90
+ declare const DashboardSectionDivider: ({ title }: SectionDivider) => react_jsx_runtime.JSX.Element;
91
+
86
92
  type DashboardGridItem = ReactGridLayout.Layout & {
87
- card: DashboardCard;
93
+ card: DashboardCard | SectionDivider;
88
94
  };
89
95
  interface DashboardTemplate {
90
96
  id: string;
@@ -124,4 +130,4 @@ declare const useDashboard: () => {
124
130
  selectedTemplate: DashboardTemplate | undefined;
125
131
  };
126
132
 
127
- export { Dashboard, DashboardCard, type DashboardFilter, DashboardFilterType, type DashboardFilterValue, DashboardFilters, DashboardGrid, type DashboardGridItem, DashboardHeader, DashboardProvider, type DashboardTemplate, useDashboard };
133
+ export { Dashboard, DashboardCard, type DashboardFilter, DashboardFilterType, type DashboardFilterValue, DashboardFilters, DashboardGrid, type DashboardGridItem, DashboardHeader, DashboardProvider, DashboardSectionDivider, type DashboardTemplate, type SectionDivider, useDashboard };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/react-dashboard",
3
- "version": "0.2.4",
3
+ "version": "0.3.0",
4
4
  "description": "ttoss dashboard module for React apps.",
5
5
  "license": "MIT",
6
6
  "author": "ttoss",
@@ -41,8 +41,8 @@
41
41
  "jest": "^30.2.0",
42
42
  "react": "^19.2.3",
43
43
  "tsup": "^8.5.1",
44
- "@ttoss/test-utils": "^4.0.3",
45
- "@ttoss/config": "^1.35.12"
44
+ "@ttoss/config": "^1.35.12",
45
+ "@ttoss/test-utils": "^4.0.3"
46
46
  },
47
47
  "keywords": [
48
48
  "React",