@ttoss/react-dashboard 0.2.1 → 0.2.3

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.
Files changed (3) hide show
  1. package/README.md +50 -0
  2. package/dist/esm/index.js +23 -12
  3. package/package.json +11 -11
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 "display.text.primary.default";
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(status => {
134
- if (status === "positive") {
135
- return "feedback.text.positive.default";
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
- if (status === "negative") {
138
- return "feedback.text.negative.default";
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
- return "display.text.primary.default";
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.status),
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), ["positive", "negative"].includes(props.trend?.status || "") && /* @__PURE__ */React.createElement(Text2, {
191
+ }) : null), /* @__PURE__ */React.createElement(Text2, {
181
192
  sx: {
182
- color: getTrendColor(props.trend.status),
193
+ color: getTrendColor(props.trend),
183
194
  fontSize: "sm",
184
195
  fontWeight: "medium"
185
196
  }
186
- }, props.trend.status === "positive" ? "+" : "", props.trend.value.toFixed(1), "%", " ", props.trend ? "vs. per\xEDodo anterior" : "")), props.additionalInfo && /* @__PURE__ */React.createElement(Text2, {
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.1",
3
+ "version": "0.2.3",
4
4
  "description": "ttoss dashboard module for React apps.",
5
5
  "license": "MIT",
6
6
  "author": "ttoss",
@@ -24,25 +24,25 @@
24
24
  ],
25
25
  "sideEffects": false,
26
26
  "dependencies": {
27
- "react-day-picker": "^9.11.3",
27
+ "react-day-picker": "^9.13.0",
28
28
  "react-grid-layout": "^1.5.2",
29
- "@ttoss/components": "^2.12.4",
30
- "@ttoss/react-i18n": "^2.0.25",
31
- "@ttoss/forms": "^0.38.0",
32
- "@ttoss/react-icons": "^0.5.6",
33
- "@ttoss/ui": "^6.5.0"
29
+ "@ttoss/forms": "^0.38.1",
30
+ "@ttoss/components": "^2.12.5",
31
+ "@ttoss/react-i18n": "^2.0.26",
32
+ "@ttoss/ui": "^6.5.1",
33
+ "@ttoss/react-icons": "^0.5.7"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "react": ">=16.8.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@types/react": "^19.2.7",
39
+ "@types/react": "^19.2.8",
40
40
  "@types/react-grid-layout": "^1.3.6",
41
41
  "jest": "^30.2.0",
42
- "react": "^19.2.1",
42
+ "react": "^19.2.3",
43
43
  "tsup": "^8.5.1",
44
- "@ttoss/config": "^1.35.12",
45
- "@ttoss/test-utils": "^4.0.2"
44
+ "@ttoss/test-utils": "^4.0.3",
45
+ "@ttoss/config": "^1.35.12"
46
46
  },
47
47
  "keywords": [
48
48
  "React",