@ttoss/react-dashboard 0.1.6 → 0.1.10
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/dist/esm/index.js +17 -27
- package/dist/index.d.ts +11 -1
- package/package.json +5 -5
package/dist/esm/index.js
CHANGED
|
@@ -8,7 +8,6 @@ var __name = (target, value) => __defProp(target, "name", {
|
|
|
8
8
|
|
|
9
9
|
// src/Dashboard.tsx
|
|
10
10
|
import { Divider, Flex as Flex6 } from "@ttoss/ui";
|
|
11
|
-
import * as React8 from "react";
|
|
12
11
|
|
|
13
12
|
// src/DashboardGrid.tsx
|
|
14
13
|
import "react-grid-layout/css/styles.css";
|
|
@@ -133,10 +132,10 @@ var getValueColor = /* @__PURE__ */__name((color, variant) => {
|
|
|
133
132
|
}, "getValueColor");
|
|
134
133
|
var getTrendColor = /* @__PURE__ */__name(status => {
|
|
135
134
|
if (status === "positive") {
|
|
136
|
-
return "
|
|
135
|
+
return "feedback.text.positive.default";
|
|
137
136
|
}
|
|
138
137
|
if (status === "negative") {
|
|
139
|
-
return "
|
|
138
|
+
return "feedback.text.negative.default";
|
|
140
139
|
}
|
|
141
140
|
return "display.text.primary.default";
|
|
142
141
|
}, "getTrendColor");
|
|
@@ -179,16 +178,13 @@ var BigNumber = /* @__PURE__ */__name(props => {
|
|
|
179
178
|
}) : props.trend.status === "negative" ? /* @__PURE__ */React.createElement(Icon, {
|
|
180
179
|
icon: "mdi:arrow-down",
|
|
181
180
|
width: 16
|
|
182
|
-
}) : null, props.trend
|
|
183
|
-
icon: "mdi:arrow-right",
|
|
184
|
-
width: 16
|
|
185
|
-
}) : null), /* @__PURE__ */React.createElement(Text2, {
|
|
181
|
+
}) : null), ["positive", "negative"].includes(props.trend?.status || "") && /* @__PURE__ */React.createElement(Text2, {
|
|
186
182
|
sx: {
|
|
187
183
|
color: getTrendColor(props.trend.status),
|
|
188
184
|
fontSize: "sm",
|
|
189
185
|
fontWeight: "medium"
|
|
190
186
|
}
|
|
191
|
-
}, props.trend.status === "positive" ? "+" : "", props.trend.
|
|
187
|
+
}, props.trend.status === "positive" ? "+" : "", props.trend.value.toFixed(1), "%", " ", props.trend ? "vs. per\xEDodo anterior" : "")), props.additionalInfo && /* @__PURE__ */React.createElement(Text2, {
|
|
192
188
|
sx: {
|
|
193
189
|
color: getValueColor(props.color, props.variant),
|
|
194
190
|
fontSize: "sm",
|
|
@@ -315,7 +311,8 @@ var DashboardProvider = /* @__PURE__ */__name(props => {
|
|
|
315
311
|
const {
|
|
316
312
|
filters: externalFilters,
|
|
317
313
|
templates: externalTemplates,
|
|
318
|
-
onFiltersChange
|
|
314
|
+
onFiltersChange,
|
|
315
|
+
selectedTemplate
|
|
319
316
|
} = props;
|
|
320
317
|
const onFiltersChangeRef = React2.useRef(onFiltersChange);
|
|
321
318
|
const filtersRef = React2.useRef(externalFilters);
|
|
@@ -336,14 +333,6 @@ var DashboardProvider = /* @__PURE__ */__name(props => {
|
|
|
336
333
|
}, []
|
|
337
334
|
// Empty deps - we use refs for current values
|
|
338
335
|
);
|
|
339
|
-
const selectedTemplate = React2.useMemo(() => {
|
|
340
|
-
const templateId = externalFilters.find(filter => {
|
|
341
|
-
return filter.key === "template";
|
|
342
|
-
})?.value;
|
|
343
|
-
return externalTemplates.find(template => {
|
|
344
|
-
return template.id === templateId;
|
|
345
|
-
});
|
|
346
|
-
}, [externalFilters, externalTemplates]);
|
|
347
336
|
return /* @__PURE__ */React2.createElement(DashboardContext.Provider, {
|
|
348
337
|
value: {
|
|
349
338
|
filters: externalFilters,
|
|
@@ -573,37 +562,38 @@ var DashboardHeader = /* @__PURE__ */__name(({
|
|
|
573
562
|
// src/Dashboard.tsx
|
|
574
563
|
var DashboardContent = /* @__PURE__ */__name(({
|
|
575
564
|
loading = false,
|
|
576
|
-
headerChildren
|
|
565
|
+
headerChildren,
|
|
566
|
+
selectedTemplate
|
|
577
567
|
}) => {
|
|
578
|
-
|
|
579
|
-
selectedTemplate
|
|
580
|
-
} = useDashboard();
|
|
581
|
-
return /* @__PURE__ */React8.createElement(Flex6, {
|
|
568
|
+
return /* @__PURE__ */React.createElement(Flex6, {
|
|
582
569
|
sx: {
|
|
583
570
|
flexDirection: "column",
|
|
584
571
|
gap: "5",
|
|
585
572
|
padding: "2",
|
|
586
573
|
width: "100%"
|
|
587
574
|
}
|
|
588
|
-
}, /* @__PURE__ */
|
|
575
|
+
}, /* @__PURE__ */React.createElement(DashboardHeader, null, headerChildren), /* @__PURE__ */React.createElement(Divider, null), /* @__PURE__ */React.createElement(DashboardGrid, {
|
|
589
576
|
loading,
|
|
590
577
|
selectedTemplate
|
|
591
578
|
}));
|
|
592
579
|
}, "DashboardContent");
|
|
593
580
|
var Dashboard = /* @__PURE__ */__name(({
|
|
581
|
+
selectedTemplate,
|
|
594
582
|
loading = false,
|
|
595
583
|
templates = [],
|
|
596
584
|
filters = [],
|
|
597
585
|
headerChildren,
|
|
598
586
|
onFiltersChange
|
|
599
587
|
}) => {
|
|
600
|
-
return /* @__PURE__ */
|
|
588
|
+
return /* @__PURE__ */React.createElement(DashboardProvider, {
|
|
601
589
|
filters,
|
|
602
590
|
templates,
|
|
603
|
-
onFiltersChange
|
|
604
|
-
|
|
591
|
+
onFiltersChange,
|
|
592
|
+
selectedTemplate
|
|
593
|
+
}, /* @__PURE__ */React.createElement(DashboardContent, {
|
|
605
594
|
loading,
|
|
606
|
-
headerChildren
|
|
595
|
+
headerChildren,
|
|
596
|
+
selectedTemplate
|
|
607
597
|
}));
|
|
608
598
|
}, "Dashboard");
|
|
609
599
|
export { Dashboard, DashboardCard, DashboardFilterType, DashboardFilters, DashboardGrid, DashboardHeader, DashboardProvider, useDashboard };
|
package/dist/index.d.ts
CHANGED
|
@@ -23,11 +23,18 @@ type CardVariant = 'default' | 'dark' | 'light-green';
|
|
|
23
23
|
type TrendIndicator = {
|
|
24
24
|
value: number;
|
|
25
25
|
status?: 'positive' | 'negative' | 'neutral';
|
|
26
|
+
type?: 'higher' | 'lower';
|
|
26
27
|
};
|
|
27
28
|
type StatusIndicator = {
|
|
28
29
|
text: string;
|
|
29
30
|
icon?: string;
|
|
30
31
|
};
|
|
32
|
+
type SourceType = CardSourceType['source'];
|
|
33
|
+
type MetricsRecord = {
|
|
34
|
+
[K in SourceType]: {
|
|
35
|
+
[P in K]: string[];
|
|
36
|
+
} & Partial<Record<Exclude<SourceType, K>, string[]>>;
|
|
37
|
+
}[SourceType];
|
|
31
38
|
interface DashboardCard {
|
|
32
39
|
title: string;
|
|
33
40
|
description?: string;
|
|
@@ -42,6 +49,7 @@ interface DashboardCard {
|
|
|
42
49
|
trend?: TrendIndicator;
|
|
43
50
|
additionalInfo?: string;
|
|
44
51
|
status?: StatusIndicator;
|
|
52
|
+
metrics?: MetricsRecord[];
|
|
45
53
|
}
|
|
46
54
|
declare const DashboardCard: (props: DashboardCard) => react_jsx_runtime.JSX.Element | null;
|
|
47
55
|
|
|
@@ -83,7 +91,8 @@ interface DashboardTemplate {
|
|
|
83
91
|
description?: string;
|
|
84
92
|
grid: DashboardGridItem[];
|
|
85
93
|
}
|
|
86
|
-
declare const Dashboard: ({ loading, templates, filters, headerChildren, onFiltersChange, }: {
|
|
94
|
+
declare const Dashboard: ({ selectedTemplate, loading, templates, filters, headerChildren, onFiltersChange, }: {
|
|
95
|
+
selectedTemplate?: DashboardTemplate;
|
|
87
96
|
loading?: boolean;
|
|
88
97
|
headerChildren?: React.ReactNode;
|
|
89
98
|
templates?: DashboardTemplate[];
|
|
@@ -105,6 +114,7 @@ declare const DashboardProvider: (props: {
|
|
|
105
114
|
filters: DashboardFilter[];
|
|
106
115
|
templates: DashboardTemplate[];
|
|
107
116
|
onFiltersChange?: (filters: DashboardFilter[]) => void;
|
|
117
|
+
selectedTemplate?: DashboardTemplate;
|
|
108
118
|
}) => react_jsx_runtime.JSX.Element;
|
|
109
119
|
declare const useDashboard: () => {
|
|
110
120
|
filters: DashboardFilter[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ttoss/react-dashboard",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
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/components": "^2.11.
|
|
30
|
-
"@ttoss/forms": "^0.36.
|
|
31
|
-
"@ttoss/react-i18n": "^2.0.25",
|
|
29
|
+
"@ttoss/components": "^2.11.4",
|
|
30
|
+
"@ttoss/forms": "^0.36.5",
|
|
32
31
|
"@ttoss/react-icons": "^0.5.6",
|
|
33
|
-
"@ttoss/
|
|
32
|
+
"@ttoss/react-i18n": "^2.0.25",
|
|
33
|
+
"@ttoss/ui": "^6.3.2"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"react": ">=16.8.0"
|