@ttoss/react-dashboard 0.1.18 → 0.2.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
@@ -195,6 +195,7 @@ import { DashboardCard } from '@ttoss/react-dashboard';
195
195
  title="Total Revenue"
196
196
  description="Revenue from all sources"
197
197
  numberType="currency"
198
+ numberDecimalPlaces={2}
198
199
  type="bigNumber"
199
200
  sourceType={[{ source: 'api' }]}
200
201
  data={{
@@ -209,21 +210,22 @@ import { DashboardCard } from '@ttoss/react-dashboard';
209
210
 
210
211
  **Props:**
211
212
 
212
- | Prop | Type | Default | Description |
213
- | ---------------- | ------------------------- | ------- | ----------------------------------------------------------------------------------------- |
214
- | `title` | `string` | - | Card title |
215
- | `description` | `string` | - | Optional card description |
216
- | `icon` | `string` | - | Optional icon name |
217
- | `color` | `string` | - | Optional color for the card |
218
- | `variant` | `CardVariant` | - | Card variant (`'default' \| 'dark' \| 'light-green'`) |
219
- | `numberType` | `CardNumberType` | - | Number formatting type (`'number' \| 'percentage' \| 'currency'`) |
220
- | `type` | `DashboardCardType` | - | Card type (`'bigNumber' \| 'pieChart' \| 'barChart' \| 'lineChart' \| 'table' \| 'list'`) |
221
- | `sourceType` | `CardSourceType[]` | - | Data source configuration |
222
- | `labels` | `Array<string \| number>` | - | Optional labels for the card |
223
- | `data` | `DashboardCardData` | - | Card data from various sources |
224
- | `trend` | `TrendIndicator` | - | Optional trend indicator |
225
- | `additionalInfo` | `string` | - | Optional additional information text |
226
- | `status` | `StatusIndicator` | - | Optional status indicator |
213
+ | Prop | Type | Default | Description |
214
+ | --------------------- | ------------------------- | ------- | ----------------------------------------------------------------------------------------- |
215
+ | `title` | `string` | - | Card title |
216
+ | `description` | `string` | - | Optional card description |
217
+ | `icon` | `string` | - | Optional icon name |
218
+ | `color` | `string` | - | Optional color for the card |
219
+ | `variant` | `CardVariant` | - | Card variant (`'default' \| 'dark' \| 'light-green'`) |
220
+ | `numberType` | `CardNumberType` | - | Number formatting type (`'number' \| 'percentage' \| 'currency'`) |
221
+ | `numberDecimalPlaces` | `number` | `2` | Optional number of decimal places for number formatting (defaults to 2) |
222
+ | `type` | `DashboardCardType` | - | Card type (`'bigNumber' \| 'pieChart' \| 'barChart' \| 'lineChart' \| 'table' \| 'list'`) |
223
+ | `sourceType` | `CardSourceType[]` | - | Data source configuration |
224
+ | `labels` | `Array<string \| number>` | - | Optional labels for the card |
225
+ | `data` | `DashboardCardData` | - | Card data from various sources |
226
+ | `trend` | `TrendIndicator` | - | Optional trend indicator |
227
+ | `additionalInfo` | `string` | - | Optional additional information text |
228
+ | `status` | `StatusIndicator` | - | Optional status indicator |
227
229
 
228
230
  ### DashboardFilters
229
231
 
@@ -484,6 +486,7 @@ const App = () => {
484
486
  card: {
485
487
  title: 'ROAS',
486
488
  numberType: 'number',
489
+ numberDecimalPlaces: 2,
487
490
  type: 'bigNumber',
488
491
  sourceType: [{ source: 'api' }],
489
492
  data: {
package/dist/esm/index.js CHANGED
@@ -92,7 +92,7 @@ var CardWrapper = /* @__PURE__ */__name(({
92
92
  }, "CardWrapper");
93
93
 
94
94
  // src/Cards/BigNumber.tsx
95
- var formatNumber = /* @__PURE__ */__name((value, type) => {
95
+ var formatNumber = /* @__PURE__ */__name((value, type, numberDecimalPlaces) => {
96
96
  if (value === void 0 || value === null) {
97
97
  return "-";
98
98
  }
@@ -108,8 +108,8 @@ var formatNumber = /* @__PURE__ */__name((value, type) => {
108
108
  default:
109
109
  {
110
110
  const formatted = new Intl.NumberFormat("pt-BR", {
111
- minimumFractionDigits: 2,
112
- maximumFractionDigits: 2
111
+ minimumFractionDigits: numberDecimalPlaces ?? 2,
112
+ maximumFractionDigits: numberDecimalPlaces ?? 2
113
113
  }).format(value);
114
114
  return formatted;
115
115
  }
@@ -140,8 +140,8 @@ var getTrendColor = /* @__PURE__ */__name(status => {
140
140
  return "display.text.primary.default";
141
141
  }, "getTrendColor");
142
142
  var BigNumber = /* @__PURE__ */__name(props => {
143
- const total = props.data.api?.total ?? props.data.meta?.total ?? void 0;
144
- const formattedValue = formatNumber(total, props.numberType);
143
+ const total = props.data.meta?.total ?? props.data.api?.total ?? void 0;
144
+ const formattedValue = formatNumber(total, props.numberType, props.numberDecimalPlaces);
145
145
  const displayValue = props.numberType === "number" && props.title.toLowerCase().includes("roas") ? `${formattedValue}x` : formattedValue;
146
146
  const valueColor = getValueColor(props.color, props.variant);
147
147
  const variant = props.variant || "default";
package/dist/index.d.ts CHANGED
@@ -42,6 +42,7 @@ interface DashboardCard {
42
42
  color?: string;
43
43
  variant?: CardVariant;
44
44
  numberType: CardNumberType;
45
+ numberDecimalPlaces?: number;
45
46
  type: DashboardCardType;
46
47
  sourceType: CardSourceType[];
47
48
  labels?: Array<string | number>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/react-dashboard",
3
- "version": "0.1.18",
3
+ "version": "0.2.0",
4
4
  "description": "ttoss dashboard module for React apps.",
5
5
  "license": "MIT",
6
6
  "author": "ttoss",
@@ -26,11 +26,11 @@
26
26
  "dependencies": {
27
27
  "react-day-picker": "^9.11.3",
28
28
  "react-grid-layout": "^1.5.2",
29
- "@ttoss/forms": "^0.37.5",
30
- "@ttoss/components": "^2.12.3",
29
+ "@ttoss/components": "^2.12.4",
30
+ "@ttoss/forms": "^0.38.0",
31
31
  "@ttoss/react-i18n": "^2.0.25",
32
32
  "@ttoss/react-icons": "^0.5.6",
33
- "@ttoss/ui": "^6.4.3"
33
+ "@ttoss/ui": "^6.5.0"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "react": ">=16.8.0"
@@ -41,7 +41,8 @@
41
41
  "jest": "^30.2.0",
42
42
  "react": "^19.2.1",
43
43
  "tsup": "^8.5.1",
44
- "@ttoss/config": "^1.35.12"
44
+ "@ttoss/config": "^1.35.12",
45
+ "@ttoss/test-utils": "^4.0.2"
45
46
  },
46
47
  "keywords": [
47
48
  "React",