@hybridcore/ui 1.5.80 → 1.5.82

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.
@@ -1,46 +1,91 @@
1
- import { Remove as f, TrendingUp as T, TrendingDown as w } from "@mui/icons-material";
2
- import { useThemeProps as b } from "@mui/material";
3
- const I = (s) => {
4
- const n = b({ props: s, name: "MuiMetricCard" }), {
5
- label: p,
6
- value: a,
7
- change: d,
1
+ import { ArrowForward as S, TrendingUp as $, TrendingDown as y } from "@mui/icons-material";
2
+ import { useThemeProps as P } from "@mui/material";
3
+ const L = (N) => {
4
+ const u = P({ props: N, name: "MuiMetricCard" }), {
5
+ label: w,
6
+ value: e = [],
7
+ description: b,
8
+ variant: f = "default",
9
+ loading: v = !1,
10
+ showChange: p = !1,
8
11
  changeType: r = "percentage",
9
- trend: e,
10
- icon: i,
11
- iconPosition: o = "right",
12
- description: g,
13
- variant: c = "default",
14
- sx: l,
15
- ...m
16
- } = n, h = {
17
- ...n,
12
+ showTrend: d = !1,
13
+ showIcon: l = !1,
14
+ icon: c,
15
+ iconPosition: i = "right",
16
+ showChart: T = !1,
17
+ chartType: C,
18
+ sx: I,
19
+ ...x
20
+ } = u, m = e.length > 0;
21
+ let h = "—";
22
+ if (m) {
23
+ const t = Number(e[e.length - 1].v);
24
+ isNaN(t) || (h = new Intl.NumberFormat("en-US", {
25
+ maximumFractionDigits: 2
26
+ }).format(t));
27
+ }
28
+ let s;
29
+ if (p)
30
+ if (e.length >= 2) {
31
+ const t = Number(e[e.length - 1].v), n = Number(e[e.length - 2].v);
32
+ if (isNaN(t) || isNaN(n))
33
+ s = "—";
34
+ else if (n === 0 && r === "percentage")
35
+ s = "—";
36
+ else {
37
+ let a = 0;
38
+ r === "absolute" ? a = t - n : a = (t - n) / n * 100, s = `${a > 0 ? "+" : a < 0 ? "−" : ""}${Math.abs(a).toFixed(
39
+ r === "percentage" ? 1 : 2
40
+ )}${r === "percentage" ? "%" : ""}`;
41
+ }
42
+ } else
43
+ s = "—";
44
+ let o;
45
+ if (d && e.length >= 2) {
46
+ const t = Number(e[e.length - 1].v), n = Number(e[e.length - 2].v);
47
+ !isNaN(t) && !isNaN(n) && (t > n ? o = "up" : t < n ? o = "down" : o = "neutral");
48
+ }
49
+ const F = {
50
+ ...u,
51
+ calculatedValue: h,
52
+ calculatedChange: s,
53
+ calculatedTrend: o,
54
+ hasData: m,
18
55
  changeType: r,
19
- iconPosition: o,
20
- variant: c
56
+ iconPosition: i,
57
+ variant: f
21
58
  };
22
- let t = f;
23
- e === "up" ? t = T : e === "down" && (t = w);
24
- const u = !!i && ["top-left", "top-right", "bottom-left", "bottom-right"].includes(
25
- o || ""
26
- );
59
+ let g = S;
60
+ o === "up" ? g = $ : o === "down" && (g = y);
61
+ const M = l && !!c && ["top-left", "top-right", "bottom-left", "bottom-right"].includes(
62
+ i || ""
63
+ ), D = l && !!c && ["left", "right"].includes(i || "");
27
64
  return {
28
- label: p,
29
- value: a,
30
- change: d,
65
+ label: w,
66
+ value: e,
67
+ calculatedValue: h,
68
+ calculatedChange: s,
69
+ calculatedTrend: o,
70
+ description: b,
71
+ variant: f,
72
+ loading: v,
73
+ showChange: p,
31
74
  changeType: r,
32
- trend: e,
33
- Icon: i,
34
- iconPosition: o,
35
- description: g,
36
- variant: c,
37
- sx: l,
38
- other: m,
39
- ownerState: h,
40
- TrendIcon: t,
41
- showCornerIcon: u
75
+ showTrend: d,
76
+ showIcon: l,
77
+ Icon: c,
78
+ iconPosition: i,
79
+ showChart: T,
80
+ chartType: C,
81
+ sx: I,
82
+ other: x,
83
+ ownerState: F,
84
+ TrendIcon: g,
85
+ showCornerIcon: M,
86
+ showSideIcon: D
42
87
  };
43
88
  };
44
89
  export {
45
- I as useMetricCardLogic
90
+ L as useMetricCardLogic
46
91
  };
@@ -1,136 +1,155 @@
1
- import { styled as n, alpha as i, Stack as l, Typography as e } from "@mui/material";
2
- const p = n("div", {
1
+ import { styled as t, alpha as o, Stack as s, Typography as e } from "@mui/material";
2
+ const c = t("div", {
3
3
  name: "MuiMetricCard",
4
4
  slot: "Root"
5
- })(({ theme: o, ownerState: a }) => {
6
- const t = {
5
+ })(({ theme: a, ownerState: i }) => {
6
+ const r = {
7
7
  position: "relative",
8
8
  overflow: "hidden",
9
- padding: o.spacing(3),
10
- borderRadius: o.shape.borderRadius * 2,
11
- boxShadow: o.shadows[1],
9
+ padding: a.spacing(2, 3),
10
+ borderRadius: a.shape.borderRadius * 2,
11
+ boxShadow: a.shadows[1],
12
12
  transition: "all 0.3s",
13
- "&:hover": { boxShadow: o.shadows[3] },
14
- border: `1px solid ${o.palette.divider}`,
15
- backgroundColor: o.palette.background.paper
13
+ "&:hover": { boxShadow: a.shadows[3] },
14
+ border: `1px solid ${a.palette.divider}`,
15
+ backgroundColor: a.palette.background.paper,
16
+ display: "flex",
17
+ flexDirection: "column",
18
+ minHeight: 120
16
19
  };
17
- let r = {};
18
- switch (a.variant) {
20
+ let n = {};
21
+ switch (i.variant) {
19
22
  case "primary":
20
- r = {
21
- backgroundColor: i(o.palette.primary.main, 0.05),
22
- borderColor: i(o.palette.primary.main, 0.2)
23
+ n = {
24
+ backgroundColor: o(a.palette.primary.main, 0.05),
25
+ borderColor: o(a.palette.primary.main, 0.2)
23
26
  };
24
27
  break;
25
28
  case "success":
26
- r = {
27
- backgroundColor: i(o.palette.success.main, 0.05),
28
- borderColor: i(o.palette.success.main, 0.2)
29
+ n = {
30
+ backgroundColor: o(a.palette.success.main, 0.05),
31
+ borderColor: o(a.palette.success.main, 0.2)
29
32
  };
30
33
  break;
31
34
  case "warning":
32
- r = {
33
- backgroundColor: i(o.palette.warning.main, 0.05),
34
- borderColor: i(o.palette.warning.main, 0.2)
35
+ n = {
36
+ backgroundColor: o(a.palette.warning.main, 0.05),
37
+ borderColor: o(a.palette.warning.main, 0.2)
35
38
  };
36
39
  break;
37
40
  case "danger":
38
- r = {
39
- backgroundColor: i(o.palette.error.main, 0.05),
40
- borderColor: i(o.palette.error.main, 0.2)
41
+ n = {
42
+ backgroundColor: o(a.palette.error.main, 0.05),
43
+ borderColor: o(a.palette.error.main, 0.2)
41
44
  };
42
45
  break;
43
46
  default:
44
- r = {
45
- backgroundColor: o.palette.background.paper,
46
- borderColor: o.palette.divider
47
+ n = {
48
+ backgroundColor: a.palette.background.paper,
49
+ borderColor: a.palette.divider
47
50
  };
48
51
  break;
49
52
  }
50
53
  return {
51
- ...t,
52
- ...r
54
+ ...r,
55
+ ...n
53
56
  };
54
- }), g = n(l, {
57
+ }), p = t(s, {
55
58
  name: "MuiMetricCard",
56
59
  slot: "Content"
57
- })(() => ({
58
- flex: 1
59
- })), u = n(e, {
60
+ })(({ theme: a }) => ({
61
+ flex: 1,
62
+ width: "100%",
63
+ zIndex: 1,
64
+ [a.breakpoints.down("sm")]: {
65
+ alignItems: "center",
66
+ textAlign: "center"
67
+ }
68
+ })), d = t(e, {
60
69
  name: "MuiMetricCard",
61
70
  slot: "Label"
62
- })(({ theme: o }) => ({
63
- color: o.palette.text.secondary,
64
- marginBottom: o.spacing(0.5)
65
- })), C = n(e, {
71
+ })(({ theme: a }) => ({
72
+ color: a.palette.text.secondary,
73
+ marginBottom: a.spacing(0.5),
74
+ fontWeight: 500
75
+ })), g = t(e, {
66
76
  name: "MuiMetricCard",
67
77
  slot: "Value"
68
- })(({ theme: o }) => ({
69
- color: o.palette.text.primary,
70
- fontWeight: "bold",
71
- marginBottom: o.spacing(1)
72
- })), b = n("div", {
78
+ })(({ theme: a, ownerState: i }) => {
79
+ let r = a.palette.text.primary;
80
+ return i.variant === "primary" && (r = a.palette.primary.main), i.variant === "success" && (r = a.palette.success.main), i.variant === "warning" && (r = a.palette.warning.main), i.variant === "danger" && (r = a.palette.error.main), {
81
+ color: r,
82
+ fontWeight: "bold",
83
+ marginBottom: a.spacing(0.5)
84
+ };
85
+ }), u = t("div", {
73
86
  name: "MuiMetricCard",
74
87
  slot: "TrendContainer"
75
- })(({ theme: o, ownerState: a }) => {
76
- let t = o.palette.text.secondary, r = o.palette.action.hover;
77
- return a.trend === "up" ? (t = o.palette.success.main, r = i(o.palette.success.main, 0.1)) : a.trend === "down" && (t = o.palette.error.main, r = i(o.palette.error.main, 0.1)), {
88
+ })(({ theme: a, ownerState: i }) => {
89
+ let r = a.palette.text.secondary;
90
+ return i.calculatedTrend === "up" ? r = a.palette.success.main : i.calculatedTrend === "down" ? r = a.palette.error.main : i.calculatedTrend === "neutral" && (r = a.palette.text.secondary), {
78
91
  display: "inline-flex",
79
92
  alignItems: "center",
80
- gap: o.spacing(0.5),
81
- padding: o.spacing(0.5, 1),
82
- borderRadius: 10,
83
- ...o.typography.caption,
93
+ gap: a.spacing(0.5),
94
+ fontSize: "0.875rem",
84
95
  fontWeight: 500,
85
- color: t,
86
- backgroundColor: r
96
+ color: r
87
97
  };
88
- }), M = n(e, {
98
+ }), C = t(e, {
89
99
  name: "MuiMetricCard",
90
100
  slot: "Description"
91
- })(({ theme: o }) => ({
92
- color: o.palette.text.secondary
93
- })), y = n("div", {
101
+ })(({ theme: a }) => ({
102
+ color: a.palette.text.secondary,
103
+ display: "block"
104
+ })), f = t("div", {
94
105
  name: "MuiMetricCard",
95
106
  slot: "Icon"
96
- })(({ theme: o, ownerState: a }) => ({
97
- width: 48,
98
- height: 48,
99
- borderRadius: "50%",
100
- backgroundColor: o.palette.action.hover,
101
- display: "flex",
102
- alignItems: "center",
103
- justifyContent: "center",
104
- marginRight: a.iconPosition === "left" ? o.spacing(2) : 0,
105
- marginLeft: a.iconPosition === "right" ? o.spacing(2) : 0
106
- })), v = n("div", {
107
+ })(({ theme: a, ownerState: i }) => {
108
+ let r = a.palette.text.secondary;
109
+ return i.variant === "primary" && (r = a.palette.primary.main), i.variant === "success" && (r = a.palette.success.main), i.variant === "warning" && (r = a.palette.warning.main), i.variant === "danger" && (r = a.palette.error.main), {
110
+ display: "flex",
111
+ alignItems: "center",
112
+ justifyContent: "center",
113
+ color: r,
114
+ marginRight: i.iconPosition === "left" ? a.spacing(2) : 0,
115
+ marginLeft: i.iconPosition === "right" ? a.spacing(2) : 0,
116
+ [a.breakpoints.down("sm")]: {
117
+ position: "absolute",
118
+ top: a.spacing(2),
119
+ left: a.spacing(2),
120
+ margin: 0
121
+ }
122
+ };
123
+ }), b = t("div", {
107
124
  name: "MuiMetricCard",
108
125
  slot: "CornerIcon"
109
- })(({ theme: o, ownerState: a }) => {
110
- var t, r, c, d;
111
- return {
126
+ })(({ theme: a, ownerState: i }) => {
127
+ let r = a.palette.text.secondary;
128
+ i.variant === "primary" && (r = a.palette.primary.main), i.variant === "success" && (r = a.palette.success.main), i.variant === "warning" && (r = a.palette.warning.main), i.variant === "danger" && (r = a.palette.error.main);
129
+ const n = {};
130
+ return i.iconPosition === "top-left" ? (n.top = a.spacing(2), n.left = a.spacing(2)) : i.iconPosition === "top-right" ? (n.top = a.spacing(2), n.right = a.spacing(2)) : i.iconPosition === "bottom-left" ? (n.bottom = a.spacing(2), n.left = a.spacing(2)) : i.iconPosition === "bottom-right" && (n.bottom = a.spacing(2), n.right = a.spacing(2)), {
112
131
  position: "absolute",
113
- top: (t = a.iconPosition) != null && t.includes("top") ? 24 : void 0,
114
- bottom: (r = a.iconPosition) != null && r.includes("bottom") ? 24 : void 0,
115
- left: (c = a.iconPosition) != null && c.includes("left") ? 24 : void 0,
116
- right: (d = a.iconPosition) != null && d.includes("right") ? 24 : void 0,
117
- zIndex: 1,
118
- width: 48,
119
- height: 48,
120
- borderRadius: "50%",
121
- backgroundColor: o.palette.action.hover,
122
- display: "flex",
123
- alignItems: "center",
124
- justifyContent: "center"
132
+ ...n,
133
+ color: r,
134
+ zIndex: 2
125
135
  };
126
- });
136
+ }), y = t("div", {
137
+ name: "MuiMetricCard",
138
+ slot: "ChartContainer"
139
+ })(() => ({
140
+ height: 40,
141
+ width: "100%",
142
+ display: "flex",
143
+ alignItems: "flex-end"
144
+ }));
127
145
  export {
128
- g as MetricCardContent,
129
- v as MetricCardCornerIconContainer,
130
- M as MetricCardDescription,
131
- y as MetricCardIconContainer,
132
- u as MetricCardLabel,
133
- p as MetricCardRoot,
134
- b as MetricCardTrendContainer,
135
- C as MetricCardValue
146
+ y as MetricCardChartContainer,
147
+ p as MetricCardContent,
148
+ b as MetricCardCornerIconContainer,
149
+ C as MetricCardDescription,
150
+ f as MetricCardIconContainer,
151
+ d as MetricCardLabel,
152
+ c as MetricCardRoot,
153
+ u as MetricCardTrendContainer,
154
+ g as MetricCardValue
136
155
  };
@@ -11,7 +11,7 @@ const s = t(e, {
11
11
  slot: "Header"
12
12
  })(({ theme: i }) => ({
13
13
  padding: i.spacing(3),
14
- paddingBottom: 0,
14
+ paddingBottom: i.spacing(2),
15
15
  "& .MuiCardHeader-title": {
16
16
  fontSize: "1rem",
17
17
  fontWeight: 500
@@ -34,7 +34,7 @@ const s = t(e, {
34
34
  })(() => ({
35
35
  flex: 1,
36
36
  overflowY: "auto"
37
- })), m = t("div", {
37
+ })), p = t("div", {
38
38
  name: "MuiPaginatedList",
39
39
  slot: "Pagination"
40
40
  })(({ theme: i }) => ({
@@ -44,6 +44,6 @@ export {
44
44
  l as PaginatedListContent,
45
45
  r as PaginatedListHeader,
46
46
  g as PaginatedListList,
47
- m as PaginatedListPagination,
47
+ p as PaginatedListPagination,
48
48
  s as PaginatedListRoot
49
49
  };
package/dist/main.d.ts CHANGED
@@ -195,6 +195,11 @@ export declare const ContextMenu: React.FC<Props_3>;
195
195
 
196
196
  export { createTheme }
197
197
 
198
+ declare interface DataPointType {
199
+ t: string; // ISO date
200
+ v: number;
201
+ }
202
+
198
203
  declare interface DataType extends ItemProps {
199
204
  idKey?: string;
200
205
  children?: DataType[];
@@ -676,26 +681,39 @@ export declare namespace Map_2 {
676
681
  export declare const MetricCard: (props: MetricCardProps & React_2.RefAttributes<HTMLDivElement>) => React_2.ReactNode | null;
677
682
 
678
683
  export declare interface MetricCardProps {
679
- label?: string;
680
- value?: string | number;
681
- change?: number;
682
- changeType?: MetricChangeType;
683
- trend?: MetricTrend;
684
- icon?: React.ElementType;
685
- iconPosition?:
686
- | "left"
687
- | "right"
688
- | "top-left"
689
- | "top-right"
690
- | "bottom-left"
691
- | "bottom-right";
684
+ label: string;
685
+ value: DataPointType[];
692
686
  description?: string;
693
687
  variant?: MetricVariant;
688
+ loading?: boolean;
689
+
690
+ showChange?: boolean;
691
+ changeType?: MetricChangeType;
692
+
693
+ showTrend?: boolean;
694
+
695
+ showIcon?: boolean;
696
+ icon?: React.ElementType;
697
+ iconPosition?: MetricIconPosition;
698
+
699
+ showChart?: boolean;
700
+ chartType?: MetricChartType;
701
+
694
702
  sx?: SxProps<Theme>;
695
703
  }
696
704
 
697
705
  export declare type MetricChangeType = "percentage" | "absolute";
698
706
 
707
+ declare type MetricChartType = "column" | "line";
708
+
709
+ declare type MetricIconPosition =
710
+ | "left"
711
+ | "right"
712
+ | "top-left"
713
+ | "top-right"
714
+ | "bottom-left"
715
+ | "bottom-right";
716
+
699
717
  export declare type MetricTrend = "up" | "down" | "neutral";
700
718
 
701
719
  export declare type MetricVariant =
@@ -1306,7 +1324,8 @@ declare module "@mui/material/styles" {
1306
1324
  | "trendValue"
1307
1325
  | "description"
1308
1326
  | "icon"
1309
- | "cornerIcon";
1327
+ | "cornerIcon"
1328
+ | "chart";
1310
1329
  }
1311
1330
 
1312
1331
  interface ComponentsPropsList {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hybridcore/ui",
3
3
  "description": "Hybrid Core UI Library",
4
- "version": "1.5.80",
4
+ "version": "1.5.82",
5
5
  "author": "Hybrid Core",
6
6
  "license": "ISC",
7
7
  "type": "module",