@ttoss/react-dashboard 0.1.19 → 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/README.md +18 -15
- package/dist/esm/index.js +6 -7
- package/dist/index.d.ts +1 -0
- package/package.json +6 -5
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
|
|
213
|
-
|
|
|
214
|
-
| `title`
|
|
215
|
-
| `description`
|
|
216
|
-
| `icon`
|
|
217
|
-
| `color`
|
|
218
|
-
| `variant`
|
|
219
|
-
| `numberType`
|
|
220
|
-
| `
|
|
221
|
-
| `
|
|
222
|
-
| `
|
|
223
|
-
| `
|
|
224
|
-
| `
|
|
225
|
-
| `
|
|
226
|
-
| `
|
|
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,9 +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.
|
|
144
|
-
const formattedValue = formatNumber(total, props.numberType);
|
|
145
|
-
const displayValue = props.numberType === "number" && props.title.toLowerCase().includes("roas") ? `${formattedValue}x` : formattedValue;
|
|
143
|
+
const total = props.data.meta?.total ?? props.data.api?.total ?? void 0;
|
|
144
|
+
const formattedValue = formatNumber(total, props.numberType, props.numberDecimalPlaces);
|
|
146
145
|
const valueColor = getValueColor(props.color, props.variant);
|
|
147
146
|
const variant = props.variant || "default";
|
|
148
147
|
return /* @__PURE__ */React.createElement(CardWrapper, {
|
|
@@ -161,7 +160,7 @@ var BigNumber = /* @__PURE__ */__name(props => {
|
|
|
161
160
|
fontWeight: "bold",
|
|
162
161
|
lineHeight: "1.2"
|
|
163
162
|
}
|
|
164
|
-
},
|
|
163
|
+
}, formattedValue), props.trend && /* @__PURE__ */React.createElement(Flex2, {
|
|
165
164
|
sx: {
|
|
166
165
|
alignItems: "center",
|
|
167
166
|
gap: "1"
|
package/dist/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/react-dashboard",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "ttoss dashboard module for React apps.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ttoss",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"react-day-picker": "^9.11.3",
|
|
28
28
|
"react-grid-layout": "^1.5.2",
|
|
29
29
|
"@ttoss/components": "^2.12.4",
|
|
30
|
-
"@ttoss/forms": "^0.38.0",
|
|
31
30
|
"@ttoss/react-i18n": "^2.0.25",
|
|
32
|
-
"@ttoss/
|
|
33
|
-
"@ttoss/react-icons": "^0.5.6"
|
|
31
|
+
"@ttoss/forms": "^0.38.0",
|
|
32
|
+
"@ttoss/react-icons": "^0.5.6",
|
|
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",
|