@hybridcore/ui 1.6.6 → 1.6.7
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/components/charts/_common/format.js +29 -23
- package/dist/components/charts/chart-wrapper/helpers.js +46 -21
- package/dist/components/charts/chart-wrapper/logic.js +57 -40
- package/dist/components/charts/column-line-mix/logic.js +71 -70
- package/dist/components/charts/line/logic.js +201 -103
- package/dist/components/charts/multiple-value-axes/logic.js +77 -76
- package/dist/components/charts/stacked-area-radar/logic.js +58 -57
- package/dist/components/charts/stacked-column-chart/logic.js +45 -44
- package/dist/components/charts/xy-chart/logic.js +76 -70
- package/dist/components/metric-card/index.js +58 -54
- package/dist/components/metric-card/logic.js +62 -53
- package/dist/components/metric-card/styled.js +53 -43
- package/dist/components/simple-pivot-table/index.js +13 -13
- package/dist/main.d.ts +27 -4
- package/package.json +1 -1
|
@@ -1,41 +1,42 @@
|
|
|
1
|
-
import { R as
|
|
1
|
+
import { R as V, A as W, T as x, b as z, L as G } from "../../../AnimatedTheme-jnasw6rT.js";
|
|
2
2
|
import { useThemeProps as N, useTheme as j } from "@mui/material";
|
|
3
|
-
import
|
|
4
|
-
import { useId as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { C as te } from "../../../
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
3
|
+
import X from "lodash";
|
|
4
|
+
import { useId as H, useRef as M, useEffect as U } from "react";
|
|
5
|
+
import { humanizeLabel as k } from "../_common/format.js";
|
|
6
|
+
import { colorSetFromPalette as _, applyValueFormat as $ } from "../_common/utils.js";
|
|
7
|
+
import { c as p, a as g, p as q } from "../../../ColorSet-C7vpNXhM.js";
|
|
8
|
+
import { X as J, V as K } from "../../../AxisRenderer-DTyLLA6c.js";
|
|
9
|
+
import { L as Q } from "../../../Legend-Dp_MKfS4.js";
|
|
10
|
+
import { D as Z } from "../../../DateAxis-YX3QNIB-.js";
|
|
11
|
+
import { A as F, a as ee } from "../../../AxisRendererY-C_ItLPNV.js";
|
|
12
|
+
import { C as te } from "../../../CategoryAxis-CwnfaGc8.js";
|
|
13
|
+
import { C as re } from "../../../ColumnSeries-CjgdJ2QL.js";
|
|
14
|
+
import { D as oe } from "../../../DataProcessor-CHDO51q4.js";
|
|
15
|
+
import { B as ae } from "../../../Bullet-DVczI2TD.js";
|
|
16
|
+
const be = (L) => {
|
|
17
|
+
const y = N({ props: L, name: "HCXYChart" }), {
|
|
18
|
+
dimensions: c,
|
|
18
19
|
values: n,
|
|
19
20
|
data: d,
|
|
20
|
-
initDelay:
|
|
21
|
-
baseInterval:
|
|
22
|
-
colors:
|
|
23
|
-
sx:
|
|
24
|
-
...
|
|
25
|
-
} =
|
|
26
|
-
|
|
21
|
+
initDelay: R = 0,
|
|
22
|
+
baseInterval: O,
|
|
23
|
+
colors: w,
|
|
24
|
+
sx: B,
|
|
25
|
+
...S
|
|
26
|
+
} = y, i = j(), A = `hc-xy-chart-${H().replace(/:/g, "")}`, u = M(null), b = c.length < 1 ? "Missing dimensions config!" : null;
|
|
27
|
+
U(() => {
|
|
27
28
|
if (b) return;
|
|
28
29
|
let f;
|
|
29
30
|
return f = setTimeout(() => {
|
|
30
|
-
var Y, D
|
|
31
|
-
const e =
|
|
32
|
-
u.current = e, e.setThemes([
|
|
33
|
-
text:
|
|
34
|
-
grid:
|
|
35
|
-
stroke:
|
|
31
|
+
var C, Y, D;
|
|
32
|
+
const e = V.new(A);
|
|
33
|
+
u.current = e, e.setThemes([W.new(e)]), e.interfaceColors.setAll({
|
|
34
|
+
text: p(i.palette.text.primary),
|
|
35
|
+
grid: p(i.palette.divider),
|
|
36
|
+
stroke: p(i.palette.divider)
|
|
36
37
|
});
|
|
37
38
|
const o = e.container.children.push(
|
|
38
|
-
|
|
39
|
+
J.new(e, {
|
|
39
40
|
panX: !1,
|
|
40
41
|
panY: !1,
|
|
41
42
|
wheelX: "none",
|
|
@@ -43,31 +44,31 @@ const we = (F) => {
|
|
|
43
44
|
layout: e.verticalLayout
|
|
44
45
|
})
|
|
45
46
|
);
|
|
46
|
-
o.set("colors",
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
centerX:
|
|
50
|
-
x:
|
|
47
|
+
o.set("colors", _(e, w));
|
|
48
|
+
const I = o.children.push(
|
|
49
|
+
Q.new(e, {
|
|
50
|
+
centerX: g,
|
|
51
|
+
x: g
|
|
51
52
|
})
|
|
52
|
-
), a =
|
|
53
|
+
), a = c[0];
|
|
53
54
|
let s, m = d;
|
|
54
55
|
if (a.type === "date")
|
|
55
56
|
s = o.xAxes.push(
|
|
56
|
-
|
|
57
|
+
Z.new(e, {
|
|
57
58
|
maxDeviation: 0,
|
|
58
|
-
baseInterval:
|
|
59
|
-
renderer:
|
|
59
|
+
baseInterval: O || { timeUnit: "day", count: 1 },
|
|
60
|
+
renderer: F.new(e, { minGridDistance: 60 }),
|
|
60
61
|
tooltip: x.new(e, {})
|
|
61
62
|
})
|
|
62
|
-
), m =
|
|
63
|
+
), m = X.orderBy(d, [a.value]);
|
|
63
64
|
else {
|
|
64
|
-
const t =
|
|
65
|
+
const t = F.new(e, {
|
|
65
66
|
cellStartLocation: 0.1,
|
|
66
67
|
cellEndLocation: 0.9,
|
|
67
68
|
minGridDistance: 30
|
|
68
69
|
});
|
|
69
70
|
s = o.xAxes.push(
|
|
70
|
-
|
|
71
|
+
te.new(e, {
|
|
71
72
|
categoryField: a.value,
|
|
72
73
|
renderer: t,
|
|
73
74
|
tooltip: x.new(e, {})
|
|
@@ -82,8 +83,8 @@ const we = (F) => {
|
|
|
82
83
|
}), t.labels.template.setup = function(r) {
|
|
83
84
|
r.set(
|
|
84
85
|
"background",
|
|
85
|
-
|
|
86
|
-
fill:
|
|
86
|
+
z.new(e, {
|
|
87
|
+
fill: p(0),
|
|
87
88
|
fillOpacity: 0
|
|
88
89
|
})
|
|
89
90
|
);
|
|
@@ -94,73 +95,78 @@ const we = (F) => {
|
|
|
94
95
|
numericFields: ["valueX"]
|
|
95
96
|
}), s.data.setAll(m);
|
|
96
97
|
}
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
renderer:
|
|
98
|
+
const v = o.yAxes.push(
|
|
99
|
+
K.new(e, {
|
|
100
|
+
renderer: ee.new(e, { strokeOpacity: 0.1 })
|
|
100
101
|
})
|
|
101
102
|
);
|
|
102
|
-
(
|
|
103
|
-
stroke:
|
|
103
|
+
(C = s.get("renderer")) == null || C.grid.template.setAll({
|
|
104
|
+
stroke: p(i.palette.divider),
|
|
104
105
|
strokeOpacity: 1
|
|
105
|
-
}), (
|
|
106
|
-
stroke:
|
|
106
|
+
}), (Y = v.get("renderer")) == null || Y.grid.template.setAll({
|
|
107
|
+
stroke: p(i.palette.divider),
|
|
107
108
|
strokeOpacity: 1
|
|
108
109
|
});
|
|
109
|
-
function T(t, r, h,
|
|
110
|
+
function T(t, r, h, P) {
|
|
110
111
|
const l = o.series.push(
|
|
111
|
-
|
|
112
|
+
re.new(e, {
|
|
112
113
|
name: t,
|
|
113
114
|
xAxis: s,
|
|
114
|
-
yAxis:
|
|
115
|
-
valueYField:
|
|
115
|
+
yAxis: v,
|
|
116
|
+
valueYField: P,
|
|
116
117
|
...a.type === "date" ? { valueXField: h } : { categoryXField: h }
|
|
117
118
|
})
|
|
118
119
|
);
|
|
119
120
|
l.columns.template.setAll({
|
|
120
121
|
tooltipText: "{name}, {categoryX}:{valueY}",
|
|
121
|
-
width:
|
|
122
|
+
width: q(90),
|
|
122
123
|
tooltipY: 0,
|
|
123
124
|
strokeOpacity: 0
|
|
124
|
-
}), a.type === "date" && (l.data.processor =
|
|
125
|
+
}), a.type === "date" && (l.data.processor = oe.new(e, {
|
|
125
126
|
dateFormat: "i",
|
|
126
127
|
dateFields: [h]
|
|
127
128
|
})), l.data.setAll(r), l.appear(), l.bullets.push(function() {
|
|
128
|
-
return
|
|
129
|
+
return ae.new(e, {
|
|
129
130
|
locationY: 0,
|
|
130
131
|
sprite: G.new(e, {
|
|
131
132
|
text: "{valueY}",
|
|
132
133
|
fill: e.interfaceColors.get("alternativeText"),
|
|
133
134
|
centerY: 0,
|
|
134
|
-
centerX:
|
|
135
|
+
centerX: g,
|
|
135
136
|
populateText: !0
|
|
136
137
|
})
|
|
137
138
|
});
|
|
138
|
-
}),
|
|
139
|
+
}), I.data.push(l);
|
|
139
140
|
}
|
|
140
|
-
if (
|
|
141
|
+
if (c.length === 1)
|
|
141
142
|
n.forEach((t) => {
|
|
142
|
-
T(
|
|
143
|
+
T(
|
|
144
|
+
t.label ?? k(t.name),
|
|
145
|
+
m,
|
|
146
|
+
a.value,
|
|
147
|
+
t.dataFieldName
|
|
148
|
+
);
|
|
143
149
|
});
|
|
144
150
|
else {
|
|
145
|
-
const t =
|
|
151
|
+
const t = X.groupBy(m, c[1].value);
|
|
146
152
|
Object.keys(t).forEach((r) => {
|
|
147
153
|
T(
|
|
148
|
-
|
|
154
|
+
k(r),
|
|
149
155
|
t[r],
|
|
150
156
|
a.value,
|
|
151
157
|
n[0].dataFieldName
|
|
152
158
|
);
|
|
153
159
|
});
|
|
154
160
|
}
|
|
155
|
-
|
|
156
|
-
},
|
|
161
|
+
$(e, (D = n == null ? void 0 : n[0]) == null ? void 0 : D.format), o.appear(1e3, 100);
|
|
162
|
+
}, R), () => {
|
|
157
163
|
var e;
|
|
158
164
|
f && clearTimeout(f), (e = u.current) == null || e.dispose(), u.current = null;
|
|
159
165
|
};
|
|
160
|
-
}, [d,
|
|
161
|
-
const
|
|
162
|
-
return { chartId:
|
|
166
|
+
}, [d, c, n, i.palette.mode, w]);
|
|
167
|
+
const E = { ...y };
|
|
168
|
+
return { chartId: A, ownerState: E, sx: B, error: b, other: S };
|
|
163
169
|
};
|
|
164
170
|
export {
|
|
165
|
-
|
|
171
|
+
be as useXYChartLogic
|
|
166
172
|
};
|
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Stack as
|
|
3
|
-
import { MetricChart as
|
|
4
|
-
import { useMetricCardLogic as
|
|
5
|
-
import { MetricCardRoot as
|
|
6
|
-
const
|
|
7
|
-
const { state:
|
|
1
|
+
import { jsx as e, jsxs as n, Fragment as u } from "react/jsx-runtime";
|
|
2
|
+
import { Stack as r, Skeleton as c } from "@mui/material";
|
|
3
|
+
import { MetricChart as x } from "./MetricChart.js";
|
|
4
|
+
import { useMetricCardLogic as j } from "./logic.js";
|
|
5
|
+
import { MetricCardRoot as m, MetricCardValue as z, MetricCardSecondValue as V, MetricCardTrendContainer as k, MetricCardLabel as w, MetricCardPanel as P, MetricCardDescription as f, MetricCardSideChart as L, MetricCardCornerIconContainer as A, MetricCardIconContainer as v, MetricCardContent as D, MetricCardChartContainer as F } from "./styled.js";
|
|
6
|
+
const G = (t) => {
|
|
7
|
+
const { state: M } = j(t), {
|
|
8
8
|
ownerState: i,
|
|
9
9
|
layout: d,
|
|
10
|
-
calculatedValue:
|
|
10
|
+
calculatedValue: y,
|
|
11
|
+
calculatedSecondValue: l,
|
|
11
12
|
calculatedChange: h,
|
|
12
|
-
TrendIcon:
|
|
13
|
-
Icon:
|
|
13
|
+
TrendIcon: S,
|
|
14
|
+
Icon: a,
|
|
14
15
|
showCornerIcon: I,
|
|
15
|
-
showSideIcon:
|
|
16
|
-
iconPosition:
|
|
17
|
-
snapshotPayload:
|
|
18
|
-
} =
|
|
19
|
-
if (
|
|
20
|
-
return /* @__PURE__ */
|
|
21
|
-
/* @__PURE__ */
|
|
22
|
-
/* @__PURE__ */
|
|
23
|
-
/* @__PURE__ */
|
|
24
|
-
|
|
16
|
+
showSideIcon: o,
|
|
17
|
+
iconPosition: s,
|
|
18
|
+
snapshotPayload: b
|
|
19
|
+
} = M, C = !!t.showChart && !!t.chartType && (t.value ?? []).length >= 2, T = (t.showChange || t.showTrend) && h !== "—";
|
|
20
|
+
if (t.loading)
|
|
21
|
+
return /* @__PURE__ */ e(m, { ownerState: i, sx: t.sx, children: /* @__PURE__ */ n(r, { spacing: 1, children: [
|
|
22
|
+
/* @__PURE__ */ e(c, { variant: "text", width: "60%" }),
|
|
23
|
+
/* @__PURE__ */ e(c, { variant: "rectangular", height: 40, width: "40%" }),
|
|
24
|
+
/* @__PURE__ */ e(c, { variant: "text", width: "80%" }),
|
|
25
|
+
t.showChart && /* @__PURE__ */ e(
|
|
25
26
|
c,
|
|
26
27
|
{
|
|
27
28
|
variant: "rectangular",
|
|
@@ -31,80 +32,83 @@ const B = (e) => {
|
|
|
31
32
|
}
|
|
32
33
|
)
|
|
33
34
|
] }) });
|
|
34
|
-
const
|
|
35
|
-
|
|
35
|
+
const g = /* @__PURE__ */ n(
|
|
36
|
+
r,
|
|
36
37
|
{
|
|
37
38
|
direction: "row",
|
|
38
39
|
alignItems: "center",
|
|
39
40
|
spacing: 1,
|
|
40
41
|
flexWrap: d === "panel" ? "nowrap" : "wrap",
|
|
41
42
|
children: [
|
|
42
|
-
/* @__PURE__ */
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
/* @__PURE__ */ n(r, { direction: "row", alignItems: "baseline", spacing: 0.5, children: [
|
|
44
|
+
/* @__PURE__ */ e(z, { variant: "h4", ownerState: i, children: y }),
|
|
45
|
+
l && /* @__PURE__ */ e(V, { variant: "h5", children: l })
|
|
46
|
+
] }),
|
|
47
|
+
T && /* @__PURE__ */ n(k, { ownerState: i, children: [
|
|
48
|
+
d === "overlay" && t.showTrend && /* @__PURE__ */ e(S, { size: 16 }),
|
|
49
|
+
t.showChange && h
|
|
46
50
|
] })
|
|
47
51
|
]
|
|
48
52
|
}
|
|
49
53
|
);
|
|
50
|
-
return /* @__PURE__ */
|
|
51
|
-
|
|
54
|
+
return /* @__PURE__ */ e(
|
|
55
|
+
m,
|
|
52
56
|
{
|
|
53
57
|
ownerState: i,
|
|
54
|
-
sx:
|
|
55
|
-
"data-snapshot":
|
|
56
|
-
children: d === "panel" ? /* @__PURE__ */ n(
|
|
57
|
-
/* @__PURE__ */
|
|
58
|
-
/* @__PURE__ */ n(
|
|
59
|
-
/* @__PURE__ */ n(
|
|
60
|
-
C,
|
|
61
|
-
e.description && /* @__PURE__ */ t(w, { variant: "caption", children: e.description })
|
|
62
|
-
] }),
|
|
63
|
-
s && /* @__PURE__ */ t(P, { children: /* @__PURE__ */ t(
|
|
58
|
+
sx: t.sx,
|
|
59
|
+
"data-snapshot": b,
|
|
60
|
+
children: d === "panel" ? /* @__PURE__ */ n(u, { children: [
|
|
61
|
+
/* @__PURE__ */ e(w, { variant: "body2", children: t.label }),
|
|
62
|
+
/* @__PURE__ */ n(P, { children: [
|
|
63
|
+
/* @__PURE__ */ n(r, { justifyContent: "center", spacing: 0.5, sx: { flexShrink: 0 }, children: [
|
|
64
64
|
g,
|
|
65
|
+
t.description && /* @__PURE__ */ e(f, { variant: "caption", children: t.description })
|
|
66
|
+
] }),
|
|
67
|
+
C && /* @__PURE__ */ e(L, { children: /* @__PURE__ */ e(
|
|
68
|
+
x,
|
|
65
69
|
{
|
|
66
|
-
type:
|
|
67
|
-
data:
|
|
70
|
+
type: t.chartType,
|
|
71
|
+
data: t.value,
|
|
68
72
|
inset: !0,
|
|
69
73
|
gradient: !0
|
|
70
74
|
}
|
|
71
75
|
) })
|
|
72
76
|
] })
|
|
73
|
-
] }) : /* @__PURE__ */ n(
|
|
74
|
-
I &&
|
|
77
|
+
] }) : /* @__PURE__ */ n(u, { children: [
|
|
78
|
+
I && a && /* @__PURE__ */ e(A, { ownerState: i, children: /* @__PURE__ */ e(a, { size: 24 }) }),
|
|
75
79
|
/* @__PURE__ */ n(
|
|
76
|
-
|
|
80
|
+
r,
|
|
77
81
|
{
|
|
78
82
|
direction: "row",
|
|
79
83
|
justifyContent: "space-between",
|
|
80
84
|
alignItems: "flex-start",
|
|
81
85
|
sx: { flex: 1 },
|
|
82
86
|
children: [
|
|
83
|
-
|
|
84
|
-
/* @__PURE__ */ n(
|
|
85
|
-
/* @__PURE__ */
|
|
86
|
-
|
|
87
|
+
o && a && s === "left" && /* @__PURE__ */ e(v, { ownerState: i, children: /* @__PURE__ */ e(a, { sx: { fontSize: 24 } }) }),
|
|
88
|
+
/* @__PURE__ */ n(D, { children: [
|
|
89
|
+
/* @__PURE__ */ e(w, { variant: "body2", children: t.label }),
|
|
90
|
+
g
|
|
87
91
|
] }),
|
|
88
|
-
|
|
92
|
+
o && a && s === "right" && /* @__PURE__ */ e(v, { ownerState: i, children: /* @__PURE__ */ e(a, { sx: { fontSize: 24 } }) })
|
|
89
93
|
]
|
|
90
94
|
}
|
|
91
95
|
),
|
|
92
96
|
/* @__PURE__ */ n(
|
|
93
|
-
|
|
97
|
+
r,
|
|
94
98
|
{
|
|
95
99
|
direction: { xs: "column-reverse", sm: "column" },
|
|
96
100
|
spacing: 1,
|
|
97
101
|
sx: { width: "100%", mt: 2 },
|
|
98
102
|
children: [
|
|
99
|
-
|
|
100
|
-
|
|
103
|
+
t.description && /* @__PURE__ */ e(
|
|
104
|
+
f,
|
|
101
105
|
{
|
|
102
106
|
variant: "caption",
|
|
103
107
|
sx: { textAlign: { xs: "center", sm: "left" } },
|
|
104
|
-
children:
|
|
108
|
+
children: t.description
|
|
105
109
|
}
|
|
106
110
|
),
|
|
107
|
-
|
|
111
|
+
C && /* @__PURE__ */ e(F, { children: /* @__PURE__ */ e(x, { type: t.chartType, data: t.value }) })
|
|
108
112
|
]
|
|
109
113
|
}
|
|
110
114
|
)
|
|
@@ -113,5 +117,5 @@ const B = (e) => {
|
|
|
113
117
|
);
|
|
114
118
|
};
|
|
115
119
|
export {
|
|
116
|
-
|
|
120
|
+
G as MetricCard
|
|
117
121
|
};
|
|
@@ -1,103 +1,112 @@
|
|
|
1
|
-
import { useThemeProps as
|
|
2
|
-
import { formatValue as
|
|
3
|
-
import { c as
|
|
1
|
+
import { useThemeProps as q } from "@mui/material";
|
|
2
|
+
import { formatValue as V, resolveConditionalStyle as z } from "../charts/_common/format.js";
|
|
3
|
+
import { c as N } from "../../createReactComponent-C7L-DMHj.js";
|
|
4
4
|
/**
|
|
5
5
|
* @license @tabler/icons-react v3.44.0 - MIT
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license.
|
|
8
8
|
* See the LICENSE file in the root directory of this source tree.
|
|
9
9
|
*/
|
|
10
|
-
const
|
|
10
|
+
const E = [["path", { d: "M5 12l14 0", key: "svg-0" }], ["path", { d: "M13 18l6 -6", key: "svg-1" }], ["path", { d: "M13 6l6 6", key: "svg-2" }]], G = N("outline", "arrow-right", "ArrowRight", E);
|
|
11
11
|
/**
|
|
12
12
|
* @license @tabler/icons-react v3.44.0 - MIT
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the MIT license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
16
|
*/
|
|
17
|
-
const
|
|
17
|
+
const K = [["path", { d: "M3 7l6 6l4 -4l8 8", key: "svg-0" }], ["path", { d: "M21 10l0 7l-7 0", key: "svg-1" }]], Q = N("outline", "trending-down", "TrendingDown", K);
|
|
18
18
|
/**
|
|
19
19
|
* @license @tabler/icons-react v3.44.0 - MIT
|
|
20
20
|
*
|
|
21
21
|
* This source code is licensed under the MIT license.
|
|
22
22
|
* See the LICENSE file in the root directory of this source tree.
|
|
23
23
|
*/
|
|
24
|
-
const
|
|
25
|
-
const i =
|
|
26
|
-
value:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
const W = [["path", { d: "M3 17l6 -6l4 4l8 -8", key: "svg-0" }], ["path", { d: "M14 7l7 0l0 7", key: "svg-1" }]], X = N("outline", "trending-up", "TrendingUp", W), ne = (_) => {
|
|
25
|
+
const i = q({ props: _, name: "HCMetricCard" }), {
|
|
26
|
+
value: l = [],
|
|
27
|
+
secondValue: y = [],
|
|
28
|
+
secondValueFormat: R,
|
|
29
|
+
variant: $ = "default",
|
|
30
|
+
layout: w = "overlay",
|
|
31
|
+
valuePrefix: D,
|
|
32
|
+
valueSuffix: P,
|
|
31
33
|
format: e,
|
|
32
|
-
showChange:
|
|
33
|
-
changeType:
|
|
34
|
-
showTrend:
|
|
35
|
-
showIcon:
|
|
34
|
+
showChange: B = !1,
|
|
35
|
+
changeType: c = "percentage",
|
|
36
|
+
showTrend: F = !1,
|
|
37
|
+
showIcon: C = !1,
|
|
36
38
|
icon: r,
|
|
37
39
|
iconPosition: d = "right"
|
|
38
|
-
} = i,
|
|
39
|
-
prefix: (e == null ? void 0 : e.prefix) ??
|
|
40
|
-
suffix: (e == null ? void 0 : e.suffix) ??
|
|
40
|
+
} = i, A = l.length > 0, u = l[l.length - 1], b = l[l.length - 2], o = u ? Number(u.v) : NaN, n = b ? Number(b.v) : NaN, k = !isNaN(o) && !isNaN(n), g = {
|
|
41
|
+
prefix: (e == null ? void 0 : e.prefix) ?? D,
|
|
42
|
+
suffix: (e == null ? void 0 : e.suffix) ?? P,
|
|
41
43
|
decimals: e == null ? void 0 : e.decimals,
|
|
44
|
+
color: e == null ? void 0 : e.color,
|
|
45
|
+
backgroundColor: e == null ? void 0 : e.backgroundColor,
|
|
42
46
|
conditionalRules: e == null ? void 0 : e.conditionalRules
|
|
43
47
|
};
|
|
44
|
-
let a = "—",
|
|
45
|
-
if (!isNaN(
|
|
46
|
-
a =
|
|
47
|
-
const
|
|
48
|
-
M =
|
|
48
|
+
let a = "—", m = "", M, I;
|
|
49
|
+
if (!isNaN(o)) {
|
|
50
|
+
a = V(o, g), m = u.t;
|
|
51
|
+
const f = z(o, g);
|
|
52
|
+
M = f.color, I = f.backgroundColor;
|
|
49
53
|
}
|
|
50
|
-
let
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
let p;
|
|
55
|
+
const T = y[y.length - 1], x = T ? Number(T.v) : NaN;
|
|
56
|
+
isNaN(x) || (p = V(x, R ?? g));
|
|
57
|
+
let s;
|
|
58
|
+
if (B)
|
|
59
|
+
if (k && !(n === 0 && c === "percentage")) {
|
|
60
|
+
const v = c === "absolute" ? o - n : (o - n) / n * 100, J = v > 0 ? "+" : v < 0 ? "−" : "", L = c === "percentage" ? 1 : 2, j = c === "percentage" ? "%" : "";
|
|
61
|
+
s = `${J}${Math.abs(v).toFixed(L)}${j}`;
|
|
55
62
|
} else
|
|
56
|
-
|
|
57
|
-
let
|
|
58
|
-
|
|
59
|
-
let
|
|
60
|
-
|
|
61
|
-
const
|
|
63
|
+
s = "—";
|
|
64
|
+
let t;
|
|
65
|
+
F && k && (o > n ? t = "up" : o < n ? t = "down" : t = "neutral");
|
|
66
|
+
let h = G;
|
|
67
|
+
t === "up" ? h = X : t === "down" && (h = Q);
|
|
68
|
+
const S = [
|
|
62
69
|
"top-left",
|
|
63
70
|
"top-right",
|
|
64
71
|
"bottom-left",
|
|
65
72
|
"bottom-right"
|
|
66
|
-
].includes(d),
|
|
73
|
+
].includes(d), O = C && !!r && S, U = C && !!r && !S, Z = JSON.stringify({
|
|
67
74
|
metric: i.label,
|
|
68
75
|
value: a,
|
|
69
|
-
change:
|
|
70
|
-
asOf:
|
|
71
|
-
}),
|
|
76
|
+
change: s,
|
|
77
|
+
asOf: m
|
|
78
|
+
}), H = {
|
|
72
79
|
...i,
|
|
73
|
-
variant:
|
|
74
|
-
layout:
|
|
75
|
-
changeType:
|
|
80
|
+
variant: $,
|
|
81
|
+
layout: w,
|
|
82
|
+
changeType: c,
|
|
76
83
|
iconPosition: d,
|
|
77
84
|
calculatedValue: a,
|
|
78
|
-
|
|
79
|
-
|
|
85
|
+
calculatedSecondValue: p,
|
|
86
|
+
calculatedChange: s,
|
|
87
|
+
calculatedTrend: t,
|
|
80
88
|
calculatedValueColor: M,
|
|
81
89
|
calculatedValueBg: I,
|
|
82
|
-
hasData:
|
|
90
|
+
hasData: A
|
|
83
91
|
};
|
|
84
92
|
return {
|
|
85
93
|
refs: {},
|
|
86
94
|
state: {
|
|
87
|
-
ownerState:
|
|
88
|
-
layout:
|
|
95
|
+
ownerState: H,
|
|
96
|
+
layout: w,
|
|
89
97
|
calculatedValue: a,
|
|
90
|
-
|
|
91
|
-
|
|
98
|
+
calculatedSecondValue: p,
|
|
99
|
+
calculatedChange: s,
|
|
100
|
+
TrendIcon: h,
|
|
92
101
|
Icon: r,
|
|
93
|
-
showCornerIcon:
|
|
94
|
-
showSideIcon:
|
|
102
|
+
showCornerIcon: O,
|
|
103
|
+
showSideIcon: U,
|
|
95
104
|
iconPosition: d,
|
|
96
|
-
snapshotPayload:
|
|
105
|
+
snapshotPayload: Z
|
|
97
106
|
},
|
|
98
107
|
actions: {}
|
|
99
108
|
};
|
|
100
109
|
};
|
|
101
110
|
export {
|
|
102
|
-
|
|
111
|
+
ne as useMetricCardLogic
|
|
103
112
|
};
|