@ttoss/react-dashboard 0.2.1 → 0.2.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.
- package/README.md +50 -0
- package/dist/esm/index.js +23 -12
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -442,6 +442,56 @@ type DashboardCardType =
|
|
|
442
442
|
type CardVariant = 'default' | 'dark' | 'light-green';
|
|
443
443
|
```
|
|
444
444
|
|
|
445
|
+
### TrendIndicator
|
|
446
|
+
|
|
447
|
+
Trend indicator that displays a percentage change with visual indicators.
|
|
448
|
+
|
|
449
|
+
```tsx
|
|
450
|
+
type TrendIndicator = {
|
|
451
|
+
value: number;
|
|
452
|
+
status?: 'positive' | 'negative' | 'neutral';
|
|
453
|
+
type?: 'higher' | 'lower';
|
|
454
|
+
};
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
**Behavior:**
|
|
458
|
+
|
|
459
|
+
- **Positive status**: Displays an up arrow icon and the percentage value (e.g., "10.5% vs. período anterior")
|
|
460
|
+
- **Negative status**: Displays a down arrow icon and the percentage value (e.g., "5.2% vs. período anterior")
|
|
461
|
+
- **Neutral status**: Displays no arrow icon, only the percentage value (e.g., "0.0% vs. período anterior")
|
|
462
|
+
- The value is always formatted to 1 decimal place followed by "%"
|
|
463
|
+
- Note: Positive values do not include a "+" sign prefix
|
|
464
|
+
|
|
465
|
+
**Example:**
|
|
466
|
+
|
|
467
|
+
```tsx
|
|
468
|
+
trend={{
|
|
469
|
+
value: 15.5,
|
|
470
|
+
status: 'positive',
|
|
471
|
+
type: 'higher', // Optional: indicates if higher/lower is good
|
|
472
|
+
}}
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
### StatusIndicator
|
|
476
|
+
|
|
477
|
+
Status indicator that displays text with an optional icon.
|
|
478
|
+
|
|
479
|
+
```tsx
|
|
480
|
+
type StatusIndicator = {
|
|
481
|
+
text: string;
|
|
482
|
+
icon?: string;
|
|
483
|
+
};
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
**Example:**
|
|
487
|
+
|
|
488
|
+
```tsx
|
|
489
|
+
status={{
|
|
490
|
+
text: 'Active',
|
|
491
|
+
icon: 'mdi:check-circle',
|
|
492
|
+
}}
|
|
493
|
+
```
|
|
494
|
+
|
|
445
495
|
## Complete Example
|
|
446
496
|
|
|
447
497
|
```tsx
|
package/dist/esm/index.js
CHANGED
|
@@ -45,7 +45,7 @@ var CardWrapper = /* @__PURE__ */__name(({
|
|
|
45
45
|
return "feedback.text.positive.default";
|
|
46
46
|
case "default":
|
|
47
47
|
default:
|
|
48
|
-
return "
|
|
48
|
+
return "input.background.muted.disabled";
|
|
49
49
|
}
|
|
50
50
|
}, "getTitleColor");
|
|
51
51
|
return /* @__PURE__ */React.createElement(Flex, {
|
|
@@ -65,8 +65,9 @@ var CardWrapper = /* @__PURE__ */__name(({
|
|
|
65
65
|
gap: "2"
|
|
66
66
|
}
|
|
67
67
|
}, /* @__PURE__ */React.createElement(Text, {
|
|
68
|
-
variant: "h5",
|
|
69
68
|
sx: {
|
|
69
|
+
fontSize: "sm",
|
|
70
|
+
fontWeight: "bold",
|
|
70
71
|
color: getTitleColor(),
|
|
71
72
|
flex: 1,
|
|
72
73
|
minWidth: 0
|
|
@@ -130,14 +131,24 @@ var getValueColor = /* @__PURE__ */__name((color, variant) => {
|
|
|
130
131
|
}
|
|
131
132
|
return "display.text.primary.default";
|
|
132
133
|
}, "getValueColor");
|
|
133
|
-
var getTrendColor = /* @__PURE__ */__name(
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
var getTrendColor = /* @__PURE__ */__name(trend => {
|
|
135
|
+
const colors = {
|
|
136
|
+
positive: "feedback.text.positive.default",
|
|
137
|
+
negative: "feedback.text.negative.default",
|
|
138
|
+
neutral: "display.text.primary.default"
|
|
139
|
+
};
|
|
140
|
+
if (!trend) {
|
|
141
|
+
return colors.neutral;
|
|
136
142
|
}
|
|
137
|
-
|
|
138
|
-
|
|
143
|
+
const isGoodTrend = trend.type === "higher" && trend.status === "positive" || trend.type === "lower" && trend.status === "negative";
|
|
144
|
+
if (isGoodTrend) {
|
|
145
|
+
return colors.positive;
|
|
139
146
|
}
|
|
140
|
-
|
|
147
|
+
const isBadTrend = trend.type === "higher" && trend.status === "negative" || trend.type === "lower" && trend.status === "positive";
|
|
148
|
+
if (isBadTrend) {
|
|
149
|
+
return colors.negative;
|
|
150
|
+
}
|
|
151
|
+
return colors.neutral;
|
|
141
152
|
}, "getTrendColor");
|
|
142
153
|
var BigNumber = /* @__PURE__ */__name(props => {
|
|
143
154
|
const total = props.data.meta?.total ?? props.data.api?.total ?? void 0;
|
|
@@ -167,7 +178,7 @@ var BigNumber = /* @__PURE__ */__name(props => {
|
|
|
167
178
|
}
|
|
168
179
|
}, /* @__PURE__ */React.createElement(Box2, {
|
|
169
180
|
sx: {
|
|
170
|
-
color: getTrendColor(props.trend
|
|
181
|
+
color: getTrendColor(props.trend),
|
|
171
182
|
display: "flex",
|
|
172
183
|
alignItems: "center"
|
|
173
184
|
}
|
|
@@ -177,13 +188,13 @@ var BigNumber = /* @__PURE__ */__name(props => {
|
|
|
177
188
|
}) : props.trend.status === "negative" ? /* @__PURE__ */React.createElement(Icon, {
|
|
178
189
|
icon: "mdi:arrow-down",
|
|
179
190
|
width: 16
|
|
180
|
-
}) : null),
|
|
191
|
+
}) : null), /* @__PURE__ */React.createElement(Text2, {
|
|
181
192
|
sx: {
|
|
182
|
-
color: getTrendColor(props.trend
|
|
193
|
+
color: getTrendColor(props.trend),
|
|
183
194
|
fontSize: "sm",
|
|
184
195
|
fontWeight: "medium"
|
|
185
196
|
}
|
|
186
|
-
}, props.trend.
|
|
197
|
+
}, props.trend.value.toFixed(1), "%", " ", props.trend ? "vs. per\xEDodo anterior" : "")), props.additionalInfo && /* @__PURE__ */React.createElement(Text2, {
|
|
187
198
|
sx: {
|
|
188
199
|
color: getValueColor(props.color, props.variant),
|
|
189
200
|
fontSize: "sm",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/react-dashboard",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
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/react-i18n": "^2.0.25",
|
|
31
30
|
"@ttoss/forms": "^0.38.0",
|
|
32
31
|
"@ttoss/react-icons": "^0.5.6",
|
|
33
|
-
"@ttoss/ui": "^6.5.0"
|
|
32
|
+
"@ttoss/ui": "^6.5.0",
|
|
33
|
+
"@ttoss/react-i18n": "^2.0.25"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"react": ">=16.8.0"
|