@pulzr/perses-figure-panel 0.0.0-stage → 0.2.0
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/LICENSE +201 -0
- package/README.md +52 -2
- package/__mf/css/async/b.7481ca0159.css +1 -0
- package/__mf/font/inter-cyrillic-300-normal.432f2b2104.woff +0 -0
- package/__mf/font/inter-cyrillic-300-normal.9da9100900.woff2 +0 -0
- package/__mf/font/inter-cyrillic-400-normal.372704ff40.woff2 +0 -0
- package/__mf/font/inter-cyrillic-400-normal.a6b6ef6faf.woff +0 -0
- package/__mf/font/inter-cyrillic-500-normal.7c15bba8be.woff2 +0 -0
- package/__mf/font/inter-cyrillic-500-normal.b9f8c929ad.woff +0 -0
- package/__mf/font/inter-cyrillic-600-normal.2f42892af1.woff2 +0 -0
- package/__mf/font/inter-cyrillic-600-normal.c3987adc32.woff +0 -0
- package/__mf/font/inter-cyrillic-700-normal.93eba3c390.woff +0 -0
- package/__mf/font/inter-cyrillic-700-normal.e9e5b2dce1.woff2 +0 -0
- package/__mf/font/inter-cyrillic-900-normal.f285bd7ab1.woff2 +0 -0
- package/__mf/font/inter-cyrillic-900-normal.ffbd8a3a24.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-300-normal.95bb90387a.woff2 +0 -0
- package/__mf/font/inter-cyrillic-ext-300-normal.cfc143a9bf.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-400-normal.2a31c04be1.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-400-normal.f572b170fb.woff2 +0 -0
- package/__mf/font/inter-cyrillic-ext-500-normal.5a6bb1da50.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-500-normal.fe0d9b14f7.woff2 +0 -0
- package/__mf/font/inter-cyrillic-ext-600-normal.ecbdecadef.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-600-normal.f7b3c15b2a.woff2 +0 -0
- package/__mf/font/inter-cyrillic-ext-700-normal.4b4022a6b0.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-700-normal.74b516d253.woff2 +0 -0
- package/__mf/font/inter-cyrillic-ext-900-normal.9970ddb5c6.woff +0 -0
- package/__mf/font/inter-cyrillic-ext-900-normal.a0d59adc71.woff2 +0 -0
- package/__mf/font/inter-greek-300-normal.0d7be68343.woff2 +0 -0
- package/__mf/font/inter-greek-300-normal.8f0b988e58.woff +0 -0
- package/__mf/font/inter-greek-400-normal.cc58c11b20.woff +0 -0
- package/__mf/font/inter-greek-400-normal.d7020e3c6f.woff2 +0 -0
- package/__mf/font/inter-greek-500-normal.d9a33207d7.woff +0 -0
- package/__mf/font/inter-greek-500-normal.f41f43dbd9.woff2 +0 -0
- package/__mf/font/inter-greek-600-normal.4ec0c1c1a5.woff +0 -0
- package/__mf/font/inter-greek-600-normal.cc53293782.woff2 +0 -0
- package/__mf/font/inter-greek-700-normal.5ec6c758e5.woff +0 -0
- package/__mf/font/inter-greek-700-normal.97f0eeeb81.woff2 +0 -0
- package/__mf/font/inter-greek-900-normal.46b66369cb.woff2 +0 -0
- package/__mf/font/inter-greek-900-normal.9ae3a3c52a.woff +0 -0
- package/__mf/font/inter-greek-ext-300-normal.10247a668b.woff2 +0 -0
- package/__mf/font/inter-greek-ext-300-normal.4668e5cbdb.woff +0 -0
- package/__mf/font/inter-greek-ext-400-normal.4ce1df5d07.woff2 +0 -0
- package/__mf/font/inter-greek-ext-400-normal.88ede1ea0a.woff +0 -0
- package/__mf/font/inter-greek-ext-500-normal.7a4aa726ab.woff +0 -0
- package/__mf/font/inter-greek-ext-500-normal.cbd51e2da9.woff2 +0 -0
- package/__mf/font/inter-greek-ext-600-normal.089a95ee7c.woff +0 -0
- package/__mf/font/inter-greek-ext-600-normal.1f33d317c3.woff2 +0 -0
- package/__mf/font/inter-greek-ext-700-normal.31f1075d7b.woff +0 -0
- package/__mf/font/inter-greek-ext-700-normal.827cd61841.woff2 +0 -0
- package/__mf/font/inter-greek-ext-900-normal.531bcee7cb.woff +0 -0
- package/__mf/font/inter-greek-ext-900-normal.8a9b36b965.woff2 +0 -0
- package/__mf/font/inter-latin-300-normal.15fb600d42.woff2 +0 -0
- package/__mf/font/inter-latin-300-normal.6f95f59015.woff +0 -0
- package/__mf/font/inter-latin-400-normal.2c7a775c1c.woff +0 -0
- package/__mf/font/inter-latin-400-normal.ef6d3f52c5.woff2 +0 -0
- package/__mf/font/inter-latin-500-normal.b7b43acee8.woff2 +0 -0
- package/__mf/font/inter-latin-500-normal.cb4c8ceb01.woff +0 -0
- package/__mf/font/inter-latin-600-normal.8fb1a96451.woff2 +0 -0
- package/__mf/font/inter-latin-600-normal.ce0f5f4333.woff +0 -0
- package/__mf/font/inter-latin-700-normal.953b7aa585.woff2 +0 -0
- package/__mf/font/inter-latin-700-normal.9c21d4dcc3.woff +0 -0
- package/__mf/font/inter-latin-900-normal.2a8028ec71.woff2 +0 -0
- package/__mf/font/inter-latin-900-normal.fa2521357c.woff +0 -0
- package/__mf/font/inter-latin-ext-300-normal.167cc8c93d.woff2 +0 -0
- package/__mf/font/inter-latin-ext-300-normal.f695be66ae.woff +0 -0
- package/__mf/font/inter-latin-ext-400-normal.32a2544228.woff2 +0 -0
- package/__mf/font/inter-latin-ext-400-normal.4edcaacee0.woff +0 -0
- package/__mf/font/inter-latin-ext-500-normal.a19a84a6cb.woff +0 -0
- package/__mf/font/inter-latin-ext-500-normal.d9b491decc.woff2 +0 -0
- package/__mf/font/inter-latin-ext-600-normal.38b075d8fe.woff2 +0 -0
- package/__mf/font/inter-latin-ext-600-normal.49faa47a23.woff +0 -0
- package/__mf/font/inter-latin-ext-700-normal.93534b5003.woff +0 -0
- package/__mf/font/inter-latin-ext-700-normal.b63daa1ade.woff2 +0 -0
- package/__mf/font/inter-latin-ext-900-normal.0efdb30743.woff +0 -0
- package/__mf/font/inter-latin-ext-900-normal.9c0fc2c78c.woff2 +0 -0
- package/__mf/font/inter-vietnamese-300-normal.aad496d810.woff +0 -0
- package/__mf/font/inter-vietnamese-300-normal.ad9ef503d8.woff2 +0 -0
- package/__mf/font/inter-vietnamese-400-normal.a9dd2faf81.woff +0 -0
- package/__mf/font/inter-vietnamese-400-normal.de4fc44f89.woff2 +0 -0
- package/__mf/font/inter-vietnamese-500-normal.7c0a695f6f.woff2 +0 -0
- package/__mf/font/inter-vietnamese-500-normal.a3a73b952b.woff +0 -0
- package/__mf/font/inter-vietnamese-600-normal.9d5185991f.woff2 +0 -0
- package/__mf/font/inter-vietnamese-600-normal.c5ce3fcb68.woff +0 -0
- package/__mf/font/inter-vietnamese-700-normal.bc68b19944.woff +0 -0
- package/__mf/font/inter-vietnamese-700-normal.faf12809fe.woff2 +0 -0
- package/__mf/font/inter-vietnamese-900-normal.2b782045d9.woff +0 -0
- package/__mf/font/inter-vietnamese-900-normal.e639b65a0d.woff2 +0 -0
- package/__mf/js/PulzrFigurePanel.222ed57f17.js +7 -0
- package/__mf/js/async/0.73358ef06f.js +2 -0
- package/__mf/js/async/0.73358ef06f.js.LICENSE.txt +9 -0
- package/__mf/js/async/0p.a434b768a9.js +2 -0
- package/__mf/js/async/0p.a434b768a9.js.LICENSE.txt +8 -0
- package/__mf/js/async/2.eb2d03fe10.js +2 -0
- package/__mf/js/async/2.eb2d03fe10.js.LICENSE.txt +9 -0
- package/__mf/js/async/5.b8898f130f.js +83 -0
- package/__mf/js/async/5.b8898f130f.js.LICENSE.txt +30 -0
- package/__mf/js/async/6.bf1ee74593.js +1 -0
- package/__mf/js/async/9.dc16e89090.js +1 -0
- package/__mf/js/async/__federation_expose_PulzrFigurePanel.1c3d39adbe.js +1 -0
- package/__mf/js/async/b.09e9dadd98.js +92 -0
- package/__mf/js/async/b.09e9dadd98.js.LICENSE.txt +100 -0
- package/__mf/js/async/f.6ef0146b6f.js +2 -0
- package/__mf/js/async/f.6ef0146b6f.js.LICENSE.txt +19 -0
- package/__mf/js/async/k.d692a3f373.js +1 -0
- package/__mf/js/async/kk.50088d6550.js +1 -0
- package/__mf/js/async/o.d3ab28c6c2.js +1 -0
- package/__mf/js/async/os.61448719cf.js +2 -0
- package/__mf/js/async/os.61448719cf.js.LICENSE.txt +8 -0
- package/__mf/js/async/p.f145ba64f8.js +2 -0
- package/__mf/js/async/p.f145ba64f8.js.LICENSE.txt +9 -0
- package/__mf/js/async/s.c517b47b4d.js +1 -0
- package/__mf/js/main.fb996ef195.js +7 -0
- package/lib/bootstrap.d.ts +2 -0
- package/lib/bootstrap.d.ts.map +1 -0
- package/lib/bootstrap.js +7 -0
- package/lib/bootstrap.js.map +1 -0
- package/lib/env.d.js +3 -0
- package/lib/env.d.js.map +1 -0
- package/lib/getPluginModule.d.ts +6 -0
- package/lib/getPluginModule.d.ts.map +1 -0
- package/lib/getPluginModule.js +18 -0
- package/lib/getPluginModule.js.map +1 -0
- package/lib/index-federation.d.ts +1 -0
- package/lib/index-federation.d.ts.map +1 -0
- package/lib/index-federation.js +3 -0
- package/lib/index-federation.js.map +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +4 -0
- package/lib/index.js.map +1 -0
- package/lib/panels/index.d.ts +2 -0
- package/lib/panels/index.d.ts.map +1 -0
- package/lib/panels/index.js +3 -0
- package/lib/panels/index.js.map +1 -0
- package/lib/panels/pulzr-figure-panel/PulzrFigurePanel.d.ts +4 -0
- package/lib/panels/pulzr-figure-panel/PulzrFigurePanel.d.ts.map +1 -0
- package/lib/panels/pulzr-figure-panel/PulzrFigurePanel.js +17 -0
- package/lib/panels/pulzr-figure-panel/PulzrFigurePanel.js.map +1 -0
- package/lib/panels/pulzr-figure-panel/PulzrFigurePanelComponent.d.ts +5 -0
- package/lib/panels/pulzr-figure-panel/PulzrFigurePanelComponent.d.ts.map +1 -0
- package/lib/panels/pulzr-figure-panel/PulzrFigurePanelComponent.js +210 -0
- package/lib/panels/pulzr-figure-panel/PulzrFigurePanelComponent.js.map +1 -0
- package/lib/panels/pulzr-figure-panel/PulzrFigurePanelSettingsEditor.d.ts +5 -0
- package/lib/panels/pulzr-figure-panel/PulzrFigurePanelSettingsEditor.d.ts.map +1 -0
- package/lib/panels/pulzr-figure-panel/PulzrFigurePanelSettingsEditor.js +309 -0
- package/lib/panels/pulzr-figure-panel/PulzrFigurePanelSettingsEditor.js.map +1 -0
- package/lib/panels/pulzr-figure-panel/figure.d.ts +44 -0
- package/lib/panels/pulzr-figure-panel/figure.d.ts.map +1 -0
- package/lib/panels/pulzr-figure-panel/figure.js +98 -0
- package/lib/panels/pulzr-figure-panel/figure.js.map +1 -0
- package/lib/panels/pulzr-figure-panel/index.d.ts +6 -0
- package/lib/panels/pulzr-figure-panel/index.d.ts.map +1 -0
- package/lib/panels/pulzr-figure-panel/index.js +7 -0
- package/lib/panels/pulzr-figure-panel/index.js.map +1 -0
- package/lib/panels/pulzr-figure-panel/pulzr-figure-panel-types.d.ts +38 -0
- package/lib/panels/pulzr-figure-panel/pulzr-figure-panel-types.d.ts.map +1 -0
- package/lib/panels/pulzr-figure-panel/pulzr-figure-panel-types.js +3 -0
- package/lib/panels/pulzr-figure-panel/pulzr-figure-panel-types.js.map +1 -0
- package/lib/setup-tests.js +25 -0
- package/lib/setup-tests.js.map +1 -0
- package/mf-manifest.json +217 -0
- package/mf-stats.json +251 -0
- package/package.json +118 -4
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { c as _c } from "react-compiler-runtime";
|
|
3
|
+
import { Box, Typography } from "@mui/material";
|
|
4
|
+
import { formatValue } from "@perses-dev/components";
|
|
5
|
+
import { changeOf, changeText, figureOf, fill, sizeChange, timeInParts, valuesOf } from "./figure.js";
|
|
6
|
+
const numbers = {
|
|
7
|
+
fontFeatureSettings: "'tnum' 1",
|
|
8
|
+
fontVariantNumeric: "tabular-nums"
|
|
9
|
+
};
|
|
10
|
+
/** The figure as text: a time in parts when asked, else by its format. */ function figure(now, spec) {
|
|
11
|
+
if (now === undefined) return "—";
|
|
12
|
+
return spec.timeInParts && timeInParts(now, spec.format?.unit) || formatValue(now, spec.format);
|
|
13
|
+
}
|
|
14
|
+
const TONE = {
|
|
15
|
+
good: "success.main",
|
|
16
|
+
bad: "error.main",
|
|
17
|
+
flat: "text.disabled"
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The line under the figure: its change in the style asked, good news in the success color, bad in the error
|
|
21
|
+
* color, flat quiet; or the caption, secondary, with nothing to compare with.
|
|
22
|
+
*/ function changeLine(now, before, spec) {
|
|
23
|
+
const label = spec.comparedLabel ?? "vs the period before";
|
|
24
|
+
if (spec.changeStyle === "size") {
|
|
25
|
+
const change = sizeChange(now, before, spec.lowerIsBetter);
|
|
26
|
+
return change ? {
|
|
27
|
+
line: `${change.text} ${label}`,
|
|
28
|
+
lineColor: TONE[change.tone]
|
|
29
|
+
} : {
|
|
30
|
+
line: spec.caption,
|
|
31
|
+
lineColor: "text.secondary"
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const change = changeOf(now, before);
|
|
35
|
+
if (!change) return {
|
|
36
|
+
line: spec.caption,
|
|
37
|
+
lineColor: "text.secondary"
|
|
38
|
+
};
|
|
39
|
+
if (change.direction === "flat") return {
|
|
40
|
+
line: changeText(change, label),
|
|
41
|
+
lineColor: TONE.flat
|
|
42
|
+
};
|
|
43
|
+
const good = change.direction === (spec.lowerIsBetter ? "down" : "up");
|
|
44
|
+
return {
|
|
45
|
+
line: changeText(change, label),
|
|
46
|
+
lineColor: good ? TONE.good : TONE.bad
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/** One figure, large and light, and under it its change against the period before (or a caption). */ export function PulzrFigurePanelComponent(t0) {
|
|
50
|
+
const $ = _c(20);
|
|
51
|
+
const { queryResults, spec } = t0;
|
|
52
|
+
let t1;
|
|
53
|
+
if ($[0] !== queryResults || $[1] !== spec) {
|
|
54
|
+
const { now, before, total } = figureOf(queryResults, spec.of?.series);
|
|
55
|
+
const values = spec.subtitle || spec.detail ? valuesOf(queryResults) : undefined;
|
|
56
|
+
const { line, lineColor } = changeLine(now, before, spec);
|
|
57
|
+
let t2;
|
|
58
|
+
if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
|
|
59
|
+
t2 = {
|
|
60
|
+
px: "10px",
|
|
61
|
+
pt: "2px",
|
|
62
|
+
pb: "7px",
|
|
63
|
+
minWidth: 0,
|
|
64
|
+
overflow: "hidden"
|
|
65
|
+
};
|
|
66
|
+
$[3] = t2;
|
|
67
|
+
} else {
|
|
68
|
+
t2 = $[3];
|
|
69
|
+
}
|
|
70
|
+
const t3 = spec.color ?? "text.primary";
|
|
71
|
+
let t4;
|
|
72
|
+
if ($[4] !== t3) {
|
|
73
|
+
t4 = {
|
|
74
|
+
...numbers,
|
|
75
|
+
fontSize: 22,
|
|
76
|
+
fontWeight: 300,
|
|
77
|
+
lineHeight: 1.05,
|
|
78
|
+
letterSpacing: "-0.02em",
|
|
79
|
+
mb: "4px",
|
|
80
|
+
color: t3
|
|
81
|
+
};
|
|
82
|
+
$[4] = t3;
|
|
83
|
+
$[5] = t4;
|
|
84
|
+
} else {
|
|
85
|
+
t4 = $[5];
|
|
86
|
+
}
|
|
87
|
+
let t5;
|
|
88
|
+
if ($[6] !== now || $[7] !== spec) {
|
|
89
|
+
t5 = figure(now, spec);
|
|
90
|
+
$[6] = now;
|
|
91
|
+
$[7] = spec;
|
|
92
|
+
$[8] = t5;
|
|
93
|
+
} else {
|
|
94
|
+
t5 = $[8];
|
|
95
|
+
}
|
|
96
|
+
let t6;
|
|
97
|
+
if ($[9] !== now || $[10] !== spec.of || $[11] !== total) {
|
|
98
|
+
t6 = spec.of && total !== undefined && now !== undefined && /*#__PURE__*/ _jsx(Typography, {
|
|
99
|
+
component: "span",
|
|
100
|
+
sx: {
|
|
101
|
+
...numbers,
|
|
102
|
+
fontSize: 13,
|
|
103
|
+
fontWeight: 400,
|
|
104
|
+
letterSpacing: "0.02em",
|
|
105
|
+
color: "text.secondary",
|
|
106
|
+
ml: "8px",
|
|
107
|
+
whiteSpace: "nowrap"
|
|
108
|
+
},
|
|
109
|
+
children: `${Math.round(now * total)}/${total}${spec.of.label ? ` ${spec.of.label}` : ""}`
|
|
110
|
+
});
|
|
111
|
+
$[9] = now;
|
|
112
|
+
$[10] = spec.of;
|
|
113
|
+
$[11] = total;
|
|
114
|
+
$[12] = t6;
|
|
115
|
+
} else {
|
|
116
|
+
t6 = $[12];
|
|
117
|
+
}
|
|
118
|
+
let t7;
|
|
119
|
+
if ($[13] !== t4 || $[14] !== t5 || $[15] !== t6) {
|
|
120
|
+
t7 = /*#__PURE__*/ _jsxs(Typography, {
|
|
121
|
+
component: "div",
|
|
122
|
+
sx: t4,
|
|
123
|
+
children: [
|
|
124
|
+
t5,
|
|
125
|
+
t6
|
|
126
|
+
]
|
|
127
|
+
});
|
|
128
|
+
$[13] = t4;
|
|
129
|
+
$[14] = t5;
|
|
130
|
+
$[15] = t6;
|
|
131
|
+
$[16] = t7;
|
|
132
|
+
} else {
|
|
133
|
+
t7 = $[16];
|
|
134
|
+
}
|
|
135
|
+
let t8;
|
|
136
|
+
if ($[17] !== line || $[18] !== lineColor) {
|
|
137
|
+
t8 = line && /*#__PURE__*/ _jsx(Typography, {
|
|
138
|
+
component: "div",
|
|
139
|
+
sx: {
|
|
140
|
+
...numbers,
|
|
141
|
+
fontSize: 10,
|
|
142
|
+
fontWeight: 500,
|
|
143
|
+
lineHeight: 1.4,
|
|
144
|
+
letterSpacing: "0.02em",
|
|
145
|
+
textTransform: "uppercase",
|
|
146
|
+
whiteSpace: "nowrap",
|
|
147
|
+
overflow: "hidden",
|
|
148
|
+
textOverflow: "ellipsis",
|
|
149
|
+
color: lineColor
|
|
150
|
+
},
|
|
151
|
+
children: line
|
|
152
|
+
});
|
|
153
|
+
$[17] = line;
|
|
154
|
+
$[18] = lineColor;
|
|
155
|
+
$[19] = t8;
|
|
156
|
+
} else {
|
|
157
|
+
t8 = $[19];
|
|
158
|
+
}
|
|
159
|
+
t1 = /*#__PURE__*/ _jsxs(Box, {
|
|
160
|
+
sx: t2,
|
|
161
|
+
children: [
|
|
162
|
+
spec.subtitle && values && /*#__PURE__*/ _jsx(Typography, {
|
|
163
|
+
component: "div",
|
|
164
|
+
sx: {
|
|
165
|
+
fontSize: 9,
|
|
166
|
+
letterSpacing: "0.04em",
|
|
167
|
+
textTransform: "uppercase",
|
|
168
|
+
color: "text.secondary",
|
|
169
|
+
mt: "-4px",
|
|
170
|
+
mb: "6px",
|
|
171
|
+
whiteSpace: "nowrap",
|
|
172
|
+
overflow: "hidden",
|
|
173
|
+
textOverflow: "ellipsis"
|
|
174
|
+
},
|
|
175
|
+
children: fill(spec.subtitle, values)
|
|
176
|
+
}),
|
|
177
|
+
t7,
|
|
178
|
+
t8,
|
|
179
|
+
spec.detail && values && /*#__PURE__*/ _jsx(Typography, {
|
|
180
|
+
component: "div",
|
|
181
|
+
sx: {
|
|
182
|
+
...numbers,
|
|
183
|
+
display: "inline-block",
|
|
184
|
+
fontSize: 9,
|
|
185
|
+
fontWeight: 500,
|
|
186
|
+
lineHeight: 1.4,
|
|
187
|
+
letterSpacing: "0.04em",
|
|
188
|
+
textTransform: "uppercase",
|
|
189
|
+
color: "text.secondary",
|
|
190
|
+
mt: "5px",
|
|
191
|
+
px: "6px",
|
|
192
|
+
py: "2px",
|
|
193
|
+
bgcolor: "action.hover",
|
|
194
|
+
border: 1,
|
|
195
|
+
borderColor: "divider"
|
|
196
|
+
},
|
|
197
|
+
children: fill(spec.detail, values)
|
|
198
|
+
})
|
|
199
|
+
]
|
|
200
|
+
});
|
|
201
|
+
$[0] = queryResults;
|
|
202
|
+
$[1] = spec;
|
|
203
|
+
$[2] = t1;
|
|
204
|
+
} else {
|
|
205
|
+
t1 = $[2];
|
|
206
|
+
}
|
|
207
|
+
return t1;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
//# sourceMappingURL=PulzrFigurePanelComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/panels/pulzr-figure-panel/PulzrFigurePanelComponent.tsx"],"sourcesContent":["import { Box, Typography } from '@mui/material';\nimport { formatValue } from '@perses-dev/components';\nimport type { ReactElement } from 'react';\n\nimport { changeOf, changeText, figureOf, fill, sizeChange, timeInParts, valuesOf } from './figure';\nimport type { PulzrFigurePanelProps } from './pulzr-figure-panel-types';\n\nconst numbers = { fontFeatureSettings: \"'tnum' 1\", fontVariantNumeric: 'tabular-nums' } as const;\n\n/** The figure as text: a time in parts when asked, else by its format. */\nfunction figure(now: number | undefined, spec: PulzrFigurePanelProps['spec']): string {\n if (now === undefined) return '—';\n return (spec.timeInParts && timeInParts(now, spec.format?.unit)) || formatValue(now, spec.format);\n}\n\nconst TONE = { good: 'success.main', bad: 'error.main', flat: 'text.disabled' } as const;\n\n/**\n * The line under the figure: its change in the style asked, good news in the success color, bad in the error\n * color, flat quiet; or the caption, secondary, with nothing to compare with.\n */\nfunction changeLine(\n now: number | undefined,\n before: number | undefined,\n spec: PulzrFigurePanelProps['spec'],\n): { line?: string; lineColor: string } {\n const label = spec.comparedLabel ?? 'vs the period before';\n if (spec.changeStyle === 'size') {\n const change = sizeChange(now, before, spec.lowerIsBetter);\n return change\n ? { line: `${change.text} ${label}`, lineColor: TONE[change.tone] }\n : { line: spec.caption, lineColor: 'text.secondary' };\n }\n const change = changeOf(now, before);\n if (!change) return { line: spec.caption, lineColor: 'text.secondary' };\n if (change.direction === 'flat') return { line: changeText(change, label), lineColor: TONE.flat };\n const good = change.direction === (spec.lowerIsBetter ? 'down' : 'up');\n return { line: changeText(change, label), lineColor: good ? TONE.good : TONE.bad };\n}\n\n/** One figure, large and light, and under it its change against the period before (or a caption). */\nexport function PulzrFigurePanelComponent({ queryResults, spec }: PulzrFigurePanelProps): ReactElement {\n const { now, before, total } = figureOf(queryResults, spec.of?.series);\n const values = spec.subtitle || spec.detail ? valuesOf(queryResults) : undefined;\n const { line, lineColor } = changeLine(now, before, spec);\n return (\n <Box sx={{ px: '10px', pt: '2px', pb: '7px', minWidth: 0, overflow: 'hidden' }}>\n {spec.subtitle && values && (\n <Typography\n component=\"div\"\n sx={{\n fontSize: 9,\n letterSpacing: '0.04em',\n textTransform: 'uppercase',\n color: 'text.secondary',\n mt: '-4px',\n mb: '6px',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n }}\n >\n {fill(spec.subtitle, values)}\n </Typography>\n )}\n <Typography\n component=\"div\"\n sx={{\n ...numbers,\n fontSize: 22,\n fontWeight: 300,\n lineHeight: 1.05,\n letterSpacing: '-0.02em',\n mb: '4px',\n color: spec.color ?? 'text.primary',\n }}\n >\n {figure(now, spec)}\n {spec.of && total !== undefined && now !== undefined && (\n <Typography\n component=\"span\"\n sx={{\n ...numbers,\n fontSize: 13,\n fontWeight: 400,\n letterSpacing: '0.02em',\n color: 'text.secondary',\n ml: '8px',\n whiteSpace: 'nowrap',\n }}\n >\n {`${Math.round(now * total)}/${total}${spec.of.label ? ` ${spec.of.label}` : ''}`}\n </Typography>\n )}\n </Typography>\n {line && (\n <Typography\n component=\"div\"\n sx={{\n ...numbers,\n fontSize: 10,\n fontWeight: 500,\n lineHeight: 1.4,\n letterSpacing: '0.02em',\n textTransform: 'uppercase',\n whiteSpace: 'nowrap',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n color: lineColor,\n }}\n >\n {line}\n </Typography>\n )}\n {spec.detail && values && (\n <Typography\n component=\"div\"\n sx={{\n ...numbers,\n display: 'inline-block',\n fontSize: 9,\n fontWeight: 500,\n lineHeight: 1.4,\n letterSpacing: '0.04em',\n textTransform: 'uppercase',\n color: 'text.secondary',\n mt: '5px',\n px: '6px',\n py: '2px',\n bgcolor: 'action.hover',\n border: 1,\n borderColor: 'divider',\n }}\n >\n {fill(spec.detail, values)}\n </Typography>\n )}\n </Box>\n );\n}\n"],"names":["Box","Typography","formatValue","changeOf","changeText","figureOf","fill","sizeChange","timeInParts","valuesOf","numbers","fontFeatureSettings","fontVariantNumeric","figure","now","spec","undefined","format","unit","TONE","good","bad","flat","changeLine","before","label","comparedLabel","changeStyle","change","lowerIsBetter","line","text","lineColor","tone","caption","direction"],"mappings":";;AAAA,SAASA,GAAG,EAAEC,UAAU,QAAQ,gBAAgB;AAChD,SAASC,WAAW,QAAQ,yBAAyB;AAGrD,SAASC,QAAQ,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,IAAI,EAAEC,UAAU,EAAEC,WAAW,EAAEC,QAAQ,QAAQ,cAAW;AAGnG,MAAMC,UAAU;IAAEC,qBAAqB;IAAYC,oBAAoB;AAAe;AAEtF,wEAAwE,GACxE,SAASC,OAAOC,GAAG,EAAsBC,IAAI;IAC3C,IAAID,QAAQE,WAAW,OAAO;IAC9B,OAAO,AAACD,KAAKP,WAAW,IAAIA,YAAYM,KAAKC,KAAKE,MAAM,EAAEC,SAAUhB,YAAYY,KAAKC,KAAKE,MAAM;AAClG;AAEA,MAAME,OAAO;IAAEC,MAAM;IAAgBC,KAAK;IAAcC,MAAM;AAAgB;AAE9E;;;CAGC,GACD,SAASC,WACPT,GAAG,EACHU,MAAM,EACNT,IAAI;IAEJ,MAAMU,QAAQV,KAAKW,aAAa,IAAI;IACpC,IAAIX,KAAKY,WAAW,KAAK,QAAQ;QAC/B,MAAMC,SAASrB,WAAWO,KAAKU,QAAQT,KAAKc,aAAa;QACzD,OAAOD,SACH;YAAEE,MAAM,GAAGF,OAAOG,IAAI,CAAC,CAAC,EAAEN,OAAO;YAAEO,WAAWb,IAAKS,CAAAA,OAAOK,IAAI,CAAA,AAAC;QAAC,IAChE;YAAEH,MAAMf,KAAKmB,OAAO;YAAEF,WAAW;QAAiB;IACxD;IACA,MAAMJ,SAASzB,SAASW,KAAKU;IAC7B,IAAI,CAACI,QAAQ,OAAO;QAAEE,MAAMf,KAAKmB,OAAO;QAAEF,WAAW;IAAiB;IACtE,IAAIJ,OAAOO,SAAS,KAAK,QAAQ,OAAO;QAAEL,MAAM1B,WAAWwB,QAAQH;QAAQO,WAAWb,KAAKG,IAAI;IAAC;IAChG,MAAMF,OAAOQ,OAAOO,SAAS,KAAMpB,CAAAA,KAAKc,aAAa,GAAG,SAAS,IAAG;IACpE,OAAO;QAAEC,MAAM1B,WAAWwB,QAAQH;QAAQO,WAAWZ,OAAOD,KAAKC,IAAI,GAAGD,KAAKE,GAAG;IAAC;AACnF;AAEA,mGAAmG,GACnG,OAAO"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { OptionsEditorProps } from '@perses-dev/plugin-system';
|
|
2
|
+
import type { ReactElement } from 'react';
|
|
3
|
+
import type { PulzrFigurePanelOptions } from './pulzr-figure-panel-types';
|
|
4
|
+
export declare function PulzrFigurePanelSettingsEditor({ value, onChange, }: OptionsEditorProps<PulzrFigurePanelOptions>): ReactElement;
|
|
5
|
+
//# sourceMappingURL=PulzrFigurePanelSettingsEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PulzrFigurePanelSettingsEditor.d.ts","sourceRoot":"","sources":["../../../../src/panels/pulzr-figure-panel/PulzrFigurePanelSettingsEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAI1E,wBAAgB,8BAA8B,CAAC,EAC7C,KAAK,EACL,QAAQ,GACT,EAAE,kBAAkB,CAAC,uBAAuB,CAAC,GAAG,YAAY,CAuE5D"}
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { c as _c } from "react-compiler-runtime";
|
|
3
|
+
import { FormControlLabel, MenuItem, Switch, TextField } from "@mui/material";
|
|
4
|
+
import { FormatControls, OptionsEditorColumn, OptionsEditorGrid, OptionsEditorGroup } from "@perses-dev/components";
|
|
5
|
+
const text = (v)=>v.trim() ? v : undefined;
|
|
6
|
+
export function PulzrFigurePanelSettingsEditor(t0) {
|
|
7
|
+
const $ = _c(63);
|
|
8
|
+
const { value, onChange } = t0;
|
|
9
|
+
let t1;
|
|
10
|
+
if ($[0] !== value.format) {
|
|
11
|
+
t1 = value.format ?? {
|
|
12
|
+
unit: "decimal"
|
|
13
|
+
};
|
|
14
|
+
$[0] = value.format;
|
|
15
|
+
$[1] = t1;
|
|
16
|
+
} else {
|
|
17
|
+
t1 = $[1];
|
|
18
|
+
}
|
|
19
|
+
let t2;
|
|
20
|
+
if ($[2] !== onChange || $[3] !== value) {
|
|
21
|
+
t2 = (format)=>onChange({
|
|
22
|
+
...value,
|
|
23
|
+
format
|
|
24
|
+
});
|
|
25
|
+
$[2] = onChange;
|
|
26
|
+
$[3] = value;
|
|
27
|
+
$[4] = t2;
|
|
28
|
+
} else {
|
|
29
|
+
t2 = $[4];
|
|
30
|
+
}
|
|
31
|
+
let t3;
|
|
32
|
+
if ($[5] !== t1 || $[6] !== t2) {
|
|
33
|
+
t3 = /*#__PURE__*/ _jsx(OptionsEditorColumn, {
|
|
34
|
+
children: /*#__PURE__*/ _jsx(OptionsEditorGroup, {
|
|
35
|
+
title: "Format",
|
|
36
|
+
children: /*#__PURE__*/ _jsx(FormatControls, {
|
|
37
|
+
value: t1,
|
|
38
|
+
onChange: t2
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
$[5] = t1;
|
|
43
|
+
$[6] = t2;
|
|
44
|
+
$[7] = t3;
|
|
45
|
+
} else {
|
|
46
|
+
t3 = $[7];
|
|
47
|
+
}
|
|
48
|
+
const t4 = value.color ?? "";
|
|
49
|
+
let t5;
|
|
50
|
+
if ($[8] !== onChange || $[9] !== value) {
|
|
51
|
+
t5 = (e)=>onChange({
|
|
52
|
+
...value,
|
|
53
|
+
color: text(e.target.value)
|
|
54
|
+
});
|
|
55
|
+
$[8] = onChange;
|
|
56
|
+
$[9] = value;
|
|
57
|
+
$[10] = t5;
|
|
58
|
+
} else {
|
|
59
|
+
t5 = $[10];
|
|
60
|
+
}
|
|
61
|
+
let t6;
|
|
62
|
+
if ($[11] !== t4 || $[12] !== t5) {
|
|
63
|
+
t6 = /*#__PURE__*/ _jsx(TextField, {
|
|
64
|
+
size: "small",
|
|
65
|
+
label: "Color",
|
|
66
|
+
helperText: "Any CSS color. Empty: the text color.",
|
|
67
|
+
value: t4,
|
|
68
|
+
onChange: t5
|
|
69
|
+
});
|
|
70
|
+
$[11] = t4;
|
|
71
|
+
$[12] = t5;
|
|
72
|
+
$[13] = t6;
|
|
73
|
+
} else {
|
|
74
|
+
t6 = $[13];
|
|
75
|
+
}
|
|
76
|
+
const t7 = value.comparedLabel ?? "";
|
|
77
|
+
let t8;
|
|
78
|
+
if ($[14] !== onChange || $[15] !== value) {
|
|
79
|
+
t8 = (e_0)=>onChange({
|
|
80
|
+
...value,
|
|
81
|
+
comparedLabel: text(e_0.target.value)
|
|
82
|
+
});
|
|
83
|
+
$[14] = onChange;
|
|
84
|
+
$[15] = value;
|
|
85
|
+
$[16] = t8;
|
|
86
|
+
} else {
|
|
87
|
+
t8 = $[16];
|
|
88
|
+
}
|
|
89
|
+
let t9;
|
|
90
|
+
if ($[17] !== t7 || $[18] !== t8) {
|
|
91
|
+
t9 = /*#__PURE__*/ _jsx(TextField, {
|
|
92
|
+
size: "small",
|
|
93
|
+
label: "Compared label",
|
|
94
|
+
helperText: "After the change: vs last week.",
|
|
95
|
+
value: t7,
|
|
96
|
+
onChange: t8
|
|
97
|
+
});
|
|
98
|
+
$[17] = t7;
|
|
99
|
+
$[18] = t8;
|
|
100
|
+
$[19] = t9;
|
|
101
|
+
} else {
|
|
102
|
+
t9 = $[19];
|
|
103
|
+
}
|
|
104
|
+
const t10 = value.caption ?? "";
|
|
105
|
+
let t11;
|
|
106
|
+
if ($[20] !== onChange || $[21] !== value) {
|
|
107
|
+
t11 = (e_1)=>onChange({
|
|
108
|
+
...value,
|
|
109
|
+
caption: text(e_1.target.value)
|
|
110
|
+
});
|
|
111
|
+
$[20] = onChange;
|
|
112
|
+
$[21] = value;
|
|
113
|
+
$[22] = t11;
|
|
114
|
+
} else {
|
|
115
|
+
t11 = $[22];
|
|
116
|
+
}
|
|
117
|
+
let t12;
|
|
118
|
+
if ($[23] !== t10 || $[24] !== t11) {
|
|
119
|
+
t12 = /*#__PURE__*/ _jsx(TextField, {
|
|
120
|
+
size: "small",
|
|
121
|
+
label: "Caption",
|
|
122
|
+
helperText: "When there is nothing to compare with.",
|
|
123
|
+
value: t10,
|
|
124
|
+
onChange: t11
|
|
125
|
+
});
|
|
126
|
+
$[23] = t10;
|
|
127
|
+
$[24] = t11;
|
|
128
|
+
$[25] = t12;
|
|
129
|
+
} else {
|
|
130
|
+
t12 = $[25];
|
|
131
|
+
}
|
|
132
|
+
const t13 = value.subtitle ?? "";
|
|
133
|
+
let t14;
|
|
134
|
+
if ($[26] !== onChange || $[27] !== value) {
|
|
135
|
+
t14 = (e_2)=>onChange({
|
|
136
|
+
...value,
|
|
137
|
+
subtitle: text(e_2.target.value)
|
|
138
|
+
});
|
|
139
|
+
$[26] = onChange;
|
|
140
|
+
$[27] = value;
|
|
141
|
+
$[28] = t14;
|
|
142
|
+
} else {
|
|
143
|
+
t14 = $[28];
|
|
144
|
+
}
|
|
145
|
+
let t15;
|
|
146
|
+
if ($[29] !== t13 || $[30] !== t14) {
|
|
147
|
+
t15 = /*#__PURE__*/ _jsx(TextField, {
|
|
148
|
+
size: "small",
|
|
149
|
+
label: "Subtitle",
|
|
150
|
+
helperText: "Under the title. {{series}}, {{series|%}}.",
|
|
151
|
+
value: t13,
|
|
152
|
+
onChange: t14
|
|
153
|
+
});
|
|
154
|
+
$[29] = t13;
|
|
155
|
+
$[30] = t14;
|
|
156
|
+
$[31] = t15;
|
|
157
|
+
} else {
|
|
158
|
+
t15 = $[31];
|
|
159
|
+
}
|
|
160
|
+
const t16 = value.detail ?? "";
|
|
161
|
+
let t17;
|
|
162
|
+
if ($[32] !== onChange || $[33] !== value) {
|
|
163
|
+
t17 = (e_3)=>onChange({
|
|
164
|
+
...value,
|
|
165
|
+
detail: text(e_3.target.value)
|
|
166
|
+
});
|
|
167
|
+
$[32] = onChange;
|
|
168
|
+
$[33] = value;
|
|
169
|
+
$[34] = t17;
|
|
170
|
+
} else {
|
|
171
|
+
t17 = $[34];
|
|
172
|
+
}
|
|
173
|
+
let t18;
|
|
174
|
+
if ($[35] !== t16 || $[36] !== t17) {
|
|
175
|
+
t18 = /*#__PURE__*/ _jsx(TextField, {
|
|
176
|
+
size: "small",
|
|
177
|
+
label: "Detail",
|
|
178
|
+
helperText: "A box under the figure, as the subtitle.",
|
|
179
|
+
value: t16,
|
|
180
|
+
onChange: t17
|
|
181
|
+
});
|
|
182
|
+
$[35] = t16;
|
|
183
|
+
$[36] = t17;
|
|
184
|
+
$[37] = t18;
|
|
185
|
+
} else {
|
|
186
|
+
t18 = $[37];
|
|
187
|
+
}
|
|
188
|
+
const t19 = value.changeStyle ?? "signed";
|
|
189
|
+
let t20;
|
|
190
|
+
if ($[38] !== onChange || $[39] !== value) {
|
|
191
|
+
t20 = (e_4)=>onChange({
|
|
192
|
+
...value,
|
|
193
|
+
changeStyle: e_4.target.value === "size" ? "size" : undefined
|
|
194
|
+
});
|
|
195
|
+
$[38] = onChange;
|
|
196
|
+
$[39] = value;
|
|
197
|
+
$[40] = t20;
|
|
198
|
+
} else {
|
|
199
|
+
t20 = $[40];
|
|
200
|
+
}
|
|
201
|
+
let t21;
|
|
202
|
+
let t22;
|
|
203
|
+
if ($[41] === Symbol.for("react.memo_cache_sentinel")) {
|
|
204
|
+
t21 = /*#__PURE__*/ _jsx(MenuItem, {
|
|
205
|
+
value: "signed",
|
|
206
|
+
children: "↑ +0.7%"
|
|
207
|
+
});
|
|
208
|
+
t22 = /*#__PURE__*/ _jsx(MenuItem, {
|
|
209
|
+
value: "size",
|
|
210
|
+
children: "↑ 0.7%"
|
|
211
|
+
});
|
|
212
|
+
$[41] = t21;
|
|
213
|
+
$[42] = t22;
|
|
214
|
+
} else {
|
|
215
|
+
t21 = $[41];
|
|
216
|
+
t22 = $[42];
|
|
217
|
+
}
|
|
218
|
+
let t23;
|
|
219
|
+
if ($[43] !== t19 || $[44] !== t20) {
|
|
220
|
+
t23 = /*#__PURE__*/ _jsxs(TextField, {
|
|
221
|
+
select: true,
|
|
222
|
+
size: "small",
|
|
223
|
+
label: "Change reads",
|
|
224
|
+
value: t19,
|
|
225
|
+
onChange: t20,
|
|
226
|
+
children: [
|
|
227
|
+
t21,
|
|
228
|
+
t22
|
|
229
|
+
]
|
|
230
|
+
});
|
|
231
|
+
$[43] = t19;
|
|
232
|
+
$[44] = t20;
|
|
233
|
+
$[45] = t23;
|
|
234
|
+
} else {
|
|
235
|
+
t23 = $[45];
|
|
236
|
+
}
|
|
237
|
+
const t24 = Boolean(value.lowerIsBetter);
|
|
238
|
+
let t25;
|
|
239
|
+
if ($[46] !== onChange || $[47] !== value) {
|
|
240
|
+
t25 = (e_5)=>onChange({
|
|
241
|
+
...value,
|
|
242
|
+
lowerIsBetter: e_5.target.checked || undefined
|
|
243
|
+
});
|
|
244
|
+
$[46] = onChange;
|
|
245
|
+
$[47] = value;
|
|
246
|
+
$[48] = t25;
|
|
247
|
+
} else {
|
|
248
|
+
t25 = $[48];
|
|
249
|
+
}
|
|
250
|
+
let t26;
|
|
251
|
+
if ($[49] !== t24 || $[50] !== t25) {
|
|
252
|
+
t26 = /*#__PURE__*/ _jsx(FormControlLabel, {
|
|
253
|
+
control: /*#__PURE__*/ _jsx(Switch, {
|
|
254
|
+
checked: t24,
|
|
255
|
+
onChange: t25
|
|
256
|
+
}),
|
|
257
|
+
label: "Lower is better"
|
|
258
|
+
});
|
|
259
|
+
$[49] = t24;
|
|
260
|
+
$[50] = t25;
|
|
261
|
+
$[51] = t26;
|
|
262
|
+
} else {
|
|
263
|
+
t26 = $[51];
|
|
264
|
+
}
|
|
265
|
+
let t27;
|
|
266
|
+
if ($[52] !== t12 || $[53] !== t15 || $[54] !== t18 || $[55] !== t23 || $[56] !== t26 || $[57] !== t6 || $[58] !== t9) {
|
|
267
|
+
t27 = /*#__PURE__*/ _jsx(OptionsEditorColumn, {
|
|
268
|
+
children: /*#__PURE__*/ _jsxs(OptionsEditorGroup, {
|
|
269
|
+
title: "Figure",
|
|
270
|
+
children: [
|
|
271
|
+
t6,
|
|
272
|
+
t9,
|
|
273
|
+
t12,
|
|
274
|
+
t15,
|
|
275
|
+
t18,
|
|
276
|
+
t23,
|
|
277
|
+
t26
|
|
278
|
+
]
|
|
279
|
+
})
|
|
280
|
+
});
|
|
281
|
+
$[52] = t12;
|
|
282
|
+
$[53] = t15;
|
|
283
|
+
$[54] = t18;
|
|
284
|
+
$[55] = t23;
|
|
285
|
+
$[56] = t26;
|
|
286
|
+
$[57] = t6;
|
|
287
|
+
$[58] = t9;
|
|
288
|
+
$[59] = t27;
|
|
289
|
+
} else {
|
|
290
|
+
t27 = $[59];
|
|
291
|
+
}
|
|
292
|
+
let t28;
|
|
293
|
+
if ($[60] !== t27 || $[61] !== t3) {
|
|
294
|
+
t28 = /*#__PURE__*/ _jsxs(OptionsEditorGrid, {
|
|
295
|
+
children: [
|
|
296
|
+
t3,
|
|
297
|
+
t27
|
|
298
|
+
]
|
|
299
|
+
});
|
|
300
|
+
$[60] = t27;
|
|
301
|
+
$[61] = t3;
|
|
302
|
+
$[62] = t28;
|
|
303
|
+
} else {
|
|
304
|
+
t28 = $[62];
|
|
305
|
+
}
|
|
306
|
+
return t28;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
//# sourceMappingURL=PulzrFigurePanelSettingsEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/panels/pulzr-figure-panel/PulzrFigurePanelSettingsEditor.tsx"],"sourcesContent":["import { FormControlLabel, MenuItem, Switch, TextField } from '@mui/material';\nimport { FormatControls, OptionsEditorColumn, OptionsEditorGrid, OptionsEditorGroup } from '@perses-dev/components';\nimport type { OptionsEditorProps } from '@perses-dev/plugin-system';\nimport type { ReactElement } from 'react';\n\nimport type { PulzrFigurePanelOptions } from './pulzr-figure-panel-types';\n\nconst text = (v: string): string | undefined => (v.trim() ? v : undefined);\n\nexport function PulzrFigurePanelSettingsEditor({\n value,\n onChange,\n}: OptionsEditorProps<PulzrFigurePanelOptions>): ReactElement {\n return (\n <OptionsEditorGrid>\n <OptionsEditorColumn>\n <OptionsEditorGroup title=\"Format\">\n <FormatControls\n value={value.format ?? { unit: 'decimal' }}\n onChange={(format) => onChange({ ...value, format })}\n />\n </OptionsEditorGroup>\n </OptionsEditorColumn>\n <OptionsEditorColumn>\n <OptionsEditorGroup title=\"Figure\">\n <TextField\n size=\"small\"\n label=\"Color\"\n helperText=\"Any CSS color. Empty: the text color.\"\n value={value.color ?? ''}\n onChange={(e) => onChange({ ...value, color: text(e.target.value) })}\n />\n <TextField\n size=\"small\"\n label=\"Compared label\"\n helperText=\"After the change: vs last week.\"\n value={value.comparedLabel ?? ''}\n onChange={(e) => onChange({ ...value, comparedLabel: text(e.target.value) })}\n />\n <TextField\n size=\"small\"\n label=\"Caption\"\n helperText=\"When there is nothing to compare with.\"\n value={value.caption ?? ''}\n onChange={(e) => onChange({ ...value, caption: text(e.target.value) })}\n />\n <TextField\n size=\"small\"\n label=\"Subtitle\"\n helperText=\"Under the title. {{series}}, {{series|%}}.\"\n value={value.subtitle ?? ''}\n onChange={(e) => onChange({ ...value, subtitle: text(e.target.value) })}\n />\n <TextField\n size=\"small\"\n label=\"Detail\"\n helperText=\"A box under the figure, as the subtitle.\"\n value={value.detail ?? ''}\n onChange={(e) => onChange({ ...value, detail: text(e.target.value) })}\n />\n <TextField\n select\n size=\"small\"\n label=\"Change reads\"\n value={value.changeStyle ?? 'signed'}\n onChange={(e) => onChange({ ...value, changeStyle: e.target.value === 'size' ? 'size' : undefined })}\n >\n <MenuItem value=\"signed\">↑ +0.7%</MenuItem>\n <MenuItem value=\"size\">↑ 0.7%</MenuItem>\n </TextField>\n <FormControlLabel\n control={\n <Switch\n checked={Boolean(value.lowerIsBetter)}\n onChange={(e) => onChange({ ...value, lowerIsBetter: e.target.checked || undefined })}\n />\n }\n label=\"Lower is better\"\n />\n </OptionsEditorGroup>\n </OptionsEditorColumn>\n </OptionsEditorGrid>\n );\n}\n"],"names":["FormControlLabel","MenuItem","Switch","TextField","FormatControls","OptionsEditorColumn","OptionsEditorGrid","OptionsEditorGroup","text","v","trim","undefined"],"mappings":";;AAAA,SAASA,gBAAgB,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,SAAS,QAAQ,gBAAgB;AAC9E,SAASC,cAAc,EAAEC,mBAAmB,EAAEC,iBAAiB,EAAEC,kBAAkB,QAAQ,yBAAyB;AAMpH,MAAMC,OAAO,CAACC,IAAmCA,EAAEC,IAAI,KAAKD,IAAIE;AAEhE,OAAO"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { TimeSeries, TimeSeriesData } from '@perses-dev/spec';
|
|
2
|
+
/** A series' last value that is a number. */
|
|
3
|
+
export declare function lastValue(series: TimeSeries | undefined): number | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* The figure and the one it is set against. A series labelled `compare` (the
|
|
6
|
+
* period before, as the Pulzr and Parkeze datasources label it) is the one
|
|
7
|
+
* set against; the first other series is the figure.
|
|
8
|
+
*/
|
|
9
|
+
export declare function figureOf(results: Array<{
|
|
10
|
+
data?: TimeSeriesData;
|
|
11
|
+
}>, of?: string): {
|
|
12
|
+
now?: number;
|
|
13
|
+
before?: number;
|
|
14
|
+
total?: number;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* A time in parts, as people say it: 45m, 6h 46m, 7h, and past two days 2d 3h, the minutes being noise there.
|
|
18
|
+
* Undefined for a unit that is not a time.
|
|
19
|
+
*/
|
|
20
|
+
export declare function timeInParts(value: number, unit: string | undefined): string | undefined;
|
|
21
|
+
export type Direction = 'up' | 'down' | 'flat';
|
|
22
|
+
/** The change from before to now, in percent, and which way: flat within half a percent. */
|
|
23
|
+
export declare function changeOf(now: number | undefined, before: number | undefined): {
|
|
24
|
+
percent: number;
|
|
25
|
+
direction: Direction;
|
|
26
|
+
} | undefined;
|
|
27
|
+
/** `↓ -47.3% vs last week`. */
|
|
28
|
+
export declare function changeText(change: {
|
|
29
|
+
percent: number;
|
|
30
|
+
direction: Direction;
|
|
31
|
+
}, comparedLabel?: string): string;
|
|
32
|
+
/** The last value of each series not labelled `compare`, by its formatted name. */
|
|
33
|
+
export declare function valuesOf(results: Array<{
|
|
34
|
+
data?: TimeSeriesData;
|
|
35
|
+
}>): Map<string, number>;
|
|
36
|
+
/** A template's `{{name}}` and `{{name|%}}` filled from the series' values; `—` for one with none. */
|
|
37
|
+
export declare function fill(template: string, values: Map<string, number>): string;
|
|
38
|
+
export type Tone = 'good' | 'bad' | 'flat';
|
|
39
|
+
/** The change as its size, good or bad news: `↑ 35.8%`, whole past 100%, `0%` within a twentieth of one. */
|
|
40
|
+
export declare function sizeChange(now: number | undefined, before: number | undefined, lowerIsBetter?: boolean): {
|
|
41
|
+
text: string;
|
|
42
|
+
tone: Tone;
|
|
43
|
+
} | undefined;
|
|
44
|
+
//# sourceMappingURL=figure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"figure.d.ts","sourceRoot":"","sources":["../../../../src/panels/pulzr-figure-panel/figure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEnE,6CAA6C;AAC7C,wBAAgB,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAO5E;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CACtB,OAAO,EAAE,KAAK,CAAC;IAAE,IAAI,CAAC,EAAE,cAAc,CAAA;CAAE,CAAC,EACzC,EAAE,CAAC,EAAE,MAAM,GACV;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAWnD;AAID;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAavF;AAED,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC;AAE/C,4FAA4F;AAC5F,wBAAgB,QAAQ,CACtB,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,SAAS,CAAA;CAAE,GAAG,SAAS,CAOvD;AAID,+BAA+B;AAC/B,wBAAgB,UAAU,CACxB,MAAM,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,SAAS,CAAA;CAAE,EACjD,aAAa,SAAyB,GACrC,MAAM,CAGR;AAED,mFAAmF;AACnF,wBAAgB,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC;IAAE,IAAI,CAAC,EAAE,cAAc,CAAA;CAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAQvF;AAED,sGAAsG;AACtG,wBAAgB,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAM1E;AAED,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,CAAC;AAE3C,4GAA4G;AAC5G,wBAAgB,UAAU,CACxB,GAAG,EAAE,MAAM,GAAG,SAAS,EACvB,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,aAAa,UAAQ,GACpB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,GAAG,SAAS,CAO1C"}
|