@hybridcore/ui 1.6.2 → 1.6.4

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,160 +1,118 @@
1
- import { styled as o, alpha as t, Stack as e, Typography as s } from "@mui/material";
2
- const c = o("div", {
1
+ import { styled as i, alpha as p, Stack as C, Typography as d } from "@mui/material";
2
+ import { Widget as g } from "../widget/styled.js";
3
+ import { variantColor as s, trendColor as f } from "./helpers.js";
4
+ const e = {
5
+ shouldForwardProp: (o) => o !== "ownerState"
6
+ }, x = i(g.Root, {
3
7
  name: "HCMetricCard",
4
- slot: "Root"
5
- })(({ theme: a, ownerState: i }) => {
6
- const r = {
8
+ slot: "Root",
9
+ ...e
10
+ })(({ theme: o, ownerState: t }) => {
11
+ const n = s(o, t.variant), a = t.layout === "panel";
12
+ let r;
13
+ return n ? r = p(n, 0.05) : a && (r = o.palette.background.default), {
7
14
  position: "relative",
8
15
  overflow: "hidden",
9
- borderRadius: a.shape.borderRadius * 2,
10
- boxShadow: a.shadows[1],
11
- transition: "all 0.3s",
12
- "&:hover": { boxShadow: a.shadows[3] },
13
- border: `1px solid ${a.palette.divider}`,
14
- backgroundColor: a.palette.background.paper,
15
- display: "flex",
16
- flexDirection: "column",
17
- minHeight: 120,
18
- [a.breakpoints.down("md")]: {
19
- padding: a.spacing(1.5, 1.5)
20
- },
21
- [a.breakpoints.up("md")]: {
22
- padding: a.spacing(1.5, 2)
16
+ padding: o.spacing(1.5, 2),
17
+ ...r && { backgroundColor: r },
18
+ [o.breakpoints.down("md")]: {
19
+ padding: o.spacing(1.5)
23
20
  }
24
21
  };
25
- let n = {};
26
- switch (i.variant) {
27
- case "primary":
28
- n = {
29
- backgroundColor: t(a.palette.primary.main, 0.05),
30
- borderColor: t(a.palette.primary.main, 0.2)
31
- };
32
- break;
33
- case "success":
34
- n = {
35
- backgroundColor: t(a.palette.success.main, 0.05),
36
- borderColor: t(a.palette.success.main, 0.2)
37
- };
38
- break;
39
- case "warning":
40
- n = {
41
- backgroundColor: t(a.palette.warning.main, 0.05),
42
- borderColor: t(a.palette.warning.main, 0.2)
43
- };
44
- break;
45
- case "danger":
46
- n = {
47
- backgroundColor: t(a.palette.error.main, 0.05),
48
- borderColor: t(a.palette.error.main, 0.2)
49
- };
50
- break;
51
- default:
52
- n = {
53
- backgroundColor: a.palette.background.paper,
54
- borderColor: a.palette.divider
55
- };
56
- break;
57
- }
58
- return {
59
- ...r,
60
- ...n
61
- };
62
- }), d = o(e, {
22
+ }), m = i(C, {
63
23
  name: "HCMetricCard",
64
24
  slot: "Content"
65
- })(({ theme: a }) => ({
25
+ })(() => ({
66
26
  flex: 1,
67
27
  width: "100%",
68
- zIndex: 1,
69
- [a.breakpoints.down("md")]: {}
70
- })), p = o(s, {
28
+ minWidth: 0,
29
+ zIndex: 1
30
+ })), v = i(d, {
71
31
  name: "HCMetricCard",
72
32
  slot: "Label"
73
- })(({ theme: a }) => ({
74
- color: a.palette.text.secondary,
75
- marginBottom: a.spacing(0.5),
33
+ })(({ theme: o }) => ({
34
+ color: o.palette.text.secondary,
35
+ marginBottom: o.spacing(0.5),
76
36
  fontWeight: 500
77
- })), g = o(s, {
37
+ })), y = i(d, {
78
38
  name: "HCMetricCard",
79
- slot: "Value"
80
- })(({ theme: a, ownerState: i }) => {
81
- let r = a.palette.text.primary;
82
- 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), {
83
- [a.breakpoints.down("md")]: {
84
- fontSize: "1.35rem"
85
- },
86
- [a.breakpoints.up("md")]: {
87
- fontSize: "2rem"
88
- },
89
- color: r,
90
- fontWeight: 500,
91
- marginBottom: a.spacing(0.5)
92
- };
93
- }), C = o("div", {
39
+ slot: "Value",
40
+ ...e
41
+ })(({ theme: o, ownerState: t }) => ({
42
+ color: s(o, t.variant) ?? o.palette.text.primary,
43
+ fontWeight: 500,
44
+ marginBottom: o.spacing(0.5),
45
+ whiteSpace: "nowrap",
46
+ [o.breakpoints.down("md")]: { fontSize: "1.35rem" },
47
+ [o.breakpoints.up("md")]: { fontSize: "2rem" }
48
+ })), I = i("div", {
94
49
  name: "HCMetricCard",
95
- slot: "TrendContainer"
96
- })(({ theme: a, ownerState: i }) => {
97
- let r = a.palette.text.secondary;
98
- 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), {
99
- [a.breakpoints.down("md")]: {
100
- fontSize: "0.7rem",
101
- ".MuiSvgIcon-root": {
102
- display: "none"
103
- }
104
- },
105
- [a.breakpoints.up("md")]: {
106
- fontSize: "0.875rem"
107
- },
50
+ slot: "TrendContainer",
51
+ ...e
52
+ })(({ theme: o, ownerState: t }) => {
53
+ const n = f(o, t.calculatedTrend), a = t.layout === "panel";
54
+ return {
108
55
  display: "inline-flex",
109
56
  alignItems: "center",
110
- gap: a.spacing(0.5),
57
+ gap: o.spacing(0.5),
111
58
  fontWeight: 500,
112
- color: r
59
+ color: n,
60
+ ...a ? {
61
+ backgroundColor: p(n, 0.14),
62
+ borderRadius: 999,
63
+ padding: o.spacing(0.25, 1),
64
+ fontSize: "0.8125rem",
65
+ whiteSpace: "nowrap"
66
+ } : {
67
+ fontSize: "0.875rem",
68
+ [o.breakpoints.down("md")]: {
69
+ fontSize: "0.7rem",
70
+ ".MuiSvgIcon-root": { display: "none" }
71
+ }
72
+ }
113
73
  };
114
- }), f = o(s, {
74
+ }), k = i(d, {
115
75
  name: "HCMetricCard",
116
76
  slot: "Description"
117
- })(({ theme: a }) => ({
118
- color: a.palette.text.secondary,
77
+ })(({ theme: o }) => ({
78
+ color: o.palette.text.secondary,
119
79
  display: "block",
120
80
  position: "relative",
121
81
  zIndex: 1
122
- })), b = o("div", {
82
+ })), w = i("div", {
123
83
  name: "HCMetricCard",
124
- slot: "Icon"
125
- })(({ theme: a, ownerState: i }) => {
126
- let r = a.palette.text.secondary;
127
- 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), {
128
- display: "flex",
129
- alignItems: "center",
130
- justifyContent: "center",
131
- color: r,
132
- marginRight: i.iconPosition === "left" ? a.spacing(2) : 0,
133
- marginLeft: i.iconPosition === "right" ? a.spacing(2) : 0,
134
- [a.breakpoints.down("sm")]: {
135
- position: "absolute",
136
- top: a.spacing(2),
137
- left: a.spacing(2),
138
- margin: 0
139
- }
140
- };
141
- }), u = o("div", {
84
+ slot: "Icon",
85
+ ...e
86
+ })(({ theme: o, ownerState: t }) => ({
87
+ display: "flex",
88
+ alignItems: "center",
89
+ justifyContent: "center",
90
+ color: s(o, t.variant) ?? o.palette.text.secondary,
91
+ marginRight: t.iconPosition === "left" ? o.spacing(2) : 0,
92
+ marginLeft: t.iconPosition === "right" ? o.spacing(2) : 0,
93
+ [o.breakpoints.down("sm")]: {
94
+ position: "absolute",
95
+ top: o.spacing(2),
96
+ left: o.spacing(2),
97
+ margin: 0
98
+ }
99
+ })), H = i("div", {
142
100
  name: "HCMetricCard",
143
- slot: "CornerIcon"
144
- })(({ theme: a, ownerState: i }) => {
145
- let r = a.palette.text.secondary;
146
- 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);
147
- const n = {};
148
- 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)), {
101
+ slot: "CornerIcon",
102
+ ...e
103
+ })(({ theme: o, ownerState: t }) => {
104
+ var c, l;
105
+ const n = {}, a = (c = t.iconPosition) != null && c.startsWith("top") ? "top" : "bottom", r = (l = t.iconPosition) != null && l.endsWith("left") ? "left" : "right";
106
+ return n[a] = o.spacing(2), n[r] = o.spacing(2), {
149
107
  position: "absolute",
150
108
  ...n,
151
- color: r,
109
+ color: s(o, t.variant) ?? o.palette.text.secondary,
152
110
  zIndex: 2
153
111
  };
154
- }), y = o("div", {
112
+ }), P = i("div", {
155
113
  name: "HCMetricCard",
156
- slot: "ChartContainer"
157
- })(({ theme: a }) => ({
114
+ slot: "Chart"
115
+ })(({ theme: o }) => ({
158
116
  position: "absolute",
159
117
  right: 0,
160
118
  bottom: 0,
@@ -163,16 +121,46 @@ const c = o("div", {
163
121
  display: "flex",
164
122
  alignItems: "flex-end",
165
123
  overflow: "hidden",
166
- borderRadius: a.shape.borderRadius
124
+ borderRadius: o.shape.borderRadius
125
+ })), S = i("div", {
126
+ name: "HCMetricCard",
127
+ slot: "Panel"
128
+ })(({ theme: o }) => ({
129
+ display: "flex",
130
+ flexDirection: "row",
131
+ alignItems: "stretch",
132
+ gap: o.spacing(2),
133
+ flex: 1,
134
+ minHeight: 0,
135
+ marginTop: o.spacing(1),
136
+ padding: o.spacing(2),
137
+ borderRadius: o.shape.borderRadius * 2,
138
+ border: `1px solid ${o.palette.divider}`,
139
+ backgroundColor: o.palette.background.paper,
140
+ boxShadow: o.shadows[1],
141
+ overflow: "hidden"
142
+ })), z = i("div", {
143
+ name: "HCMetricCard",
144
+ slot: "SideChart"
145
+ })(() => ({
146
+ // Take only the space the value/trend column leaves: grow into the gap, shrink to 0
147
+ // when the left content is wide (basis 0 + minWidth 0), so the value/pill never wrap.
148
+ flex: "1 1 0",
149
+ minWidth: 0,
150
+ alignSelf: "stretch",
151
+ display: "flex",
152
+ alignItems: "flex-end"
167
153
  }));
168
154
  export {
169
- y as MetricCardChartContainer,
170
- d as MetricCardContent,
171
- u as MetricCardCornerIconContainer,
172
- f as MetricCardDescription,
173
- b as MetricCardIconContainer,
174
- p as MetricCardLabel,
175
- c as MetricCardRoot,
176
- C as MetricCardTrendContainer,
177
- g as MetricCardValue
155
+ P as MetricCardChartContainer,
156
+ m as MetricCardContent,
157
+ H as MetricCardCornerIconContainer,
158
+ k as MetricCardDescription,
159
+ w as MetricCardIconContainer,
160
+ v as MetricCardLabel,
161
+ S as MetricCardPanel,
162
+ x as MetricCardRoot,
163
+ z as MetricCardSideChart,
164
+ I as MetricCardTrendContainer,
165
+ y as MetricCardValue
178
166
  };