@pulzr/perses-figure-panel 0.1.0 → 0.2.1

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.
Files changed (47) hide show
  1. package/README.md +2 -0
  2. package/__mf/js/{PulzrFigurePanel.1c9caa47a5.js → PulzrFigurePanel.577b888ef4.js} +2 -2
  3. package/__mf/js/async/{0.9e7a9b5c36.js → 0.325dac5c70.js} +2 -2
  4. package/__mf/js/async/{0p.451f0623f4.js → 0p.68da90f323.js} +2 -2
  5. package/__mf/js/async/{2.d85e4cd480.js → 2.18619a1037.js} +2 -2
  6. package/__mf/js/async/5.9d2ef52231.js +83 -0
  7. package/__mf/js/async/{6.915fe1c941.js → 6.02956de769.js} +1 -1
  8. package/__mf/js/async/{9.37089349b7.js → 9.952436a6ee.js} +1 -1
  9. package/__mf/js/async/__federation_expose_PulzrFigurePanel.e4e9ee3624.js +1 -0
  10. package/__mf/js/async/b.5f50cdb328.js +92 -0
  11. package/__mf/js/async/{f.d6fd5293bd.js → f.daba8eec81.js} +2 -2
  12. package/__mf/js/async/{k.34593cda39.js → k.7c4213442a.js} +1 -1
  13. package/__mf/js/async/kk.c246b3edb4.js +1 -0
  14. package/__mf/js/async/{o.07d26e58ef.js → o.0d1a3636bd.js} +1 -1
  15. package/__mf/js/async/{os.bb0eaba793.js → os.7ddd6e9621.js} +2 -2
  16. package/__mf/js/async/{p.70694aaf0b.js → p.3fb8172ba3.js} +2 -2
  17. package/__mf/js/async/{s.9f2e71867d.js → s.f71e79b6e1.js} +1 -1
  18. package/__mf/js/{main.c18e128493.js → main.d9b3dd4bc6.js} +2 -2
  19. package/lib/panels/pulzr-figure-panel/PulzrFigurePanelComponent.d.ts.map +1 -1
  20. package/lib/panels/pulzr-figure-panel/PulzrFigurePanelComponent.js +182 -143
  21. package/lib/panels/pulzr-figure-panel/PulzrFigurePanelComponent.js.map +1 -1
  22. package/lib/panels/pulzr-figure-panel/PulzrFigurePanelSettingsEditor.d.ts.map +1 -1
  23. package/lib/panels/pulzr-figure-panel/PulzrFigurePanelSettingsEditor.js +140 -29
  24. package/lib/panels/pulzr-figure-panel/PulzrFigurePanelSettingsEditor.js.map +1 -1
  25. package/lib/panels/pulzr-figure-panel/figure.d.ts +16 -1
  26. package/lib/panels/pulzr-figure-panel/figure.d.ts.map +1 -1
  27. package/lib/panels/pulzr-figure-panel/figure.js +37 -2
  28. package/lib/panels/pulzr-figure-panel/figure.js.map +1 -1
  29. package/lib/panels/pulzr-figure-panel/pulzr-figure-panel-types.d.ts +12 -0
  30. package/lib/panels/pulzr-figure-panel/pulzr-figure-panel-types.d.ts.map +1 -1
  31. package/lib/panels/pulzr-figure-panel/pulzr-figure-panel-types.js.map +1 -1
  32. package/mf-manifest.json +19 -19
  33. package/mf-stats.json +19 -19
  34. package/package.json +1 -1
  35. package/__mf/js/async/__federation_expose_PulzrFigurePanel.4e6d8dd142.js +0 -1
  36. package/__mf/js/async/kk.8a52a2d98b.js +0 -1
  37. package/__mf/js/async/n.e553b0554b.js +0 -92
  38. package/__mf/js/async/u.26db4151f9.js +0 -83
  39. /package/__mf/css/async/{n.7481ca0159.css → b.7481ca0159.css} +0 -0
  40. /package/__mf/js/async/{0.9e7a9b5c36.js.LICENSE.txt → 0.325dac5c70.js.LICENSE.txt} +0 -0
  41. /package/__mf/js/async/{0p.451f0623f4.js.LICENSE.txt → 0p.68da90f323.js.LICENSE.txt} +0 -0
  42. /package/__mf/js/async/{2.d85e4cd480.js.LICENSE.txt → 2.18619a1037.js.LICENSE.txt} +0 -0
  43. /package/__mf/js/async/{u.26db4151f9.js.LICENSE.txt → 5.9d2ef52231.js.LICENSE.txt} +0 -0
  44. /package/__mf/js/async/{n.e553b0554b.js.LICENSE.txt → b.5f50cdb328.js.LICENSE.txt} +0 -0
  45. /package/__mf/js/async/{f.d6fd5293bd.js.LICENSE.txt → f.daba8eec81.js.LICENSE.txt} +0 -0
  46. /package/__mf/js/async/{os.bb0eaba793.js.LICENSE.txt → os.7ddd6e9621.js.LICENSE.txt} +0 -0
  47. /package/__mf/js/async/{p.70694aaf0b.js.LICENSE.txt → p.3fb8172ba3.js.LICENSE.txt} +0 -0
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { c as _c } from "react-compiler-runtime";
3
3
  import { Box, Typography } from "@mui/material";
4
4
  import { formatValue } from "@perses-dev/components";
5
- import { changeOf, changeText, figureOf, timeInParts } from "./figure.js";
5
+ import { changeOf, changeText, figureOf, fill, sizeChange, timeInParts, valuesOf } from "./figure.js";
6
6
  const numbers = {
7
7
  fontFeatureSettings: "'tnum' 1",
8
8
  fontVariantNumeric: "tabular-nums"
@@ -11,161 +11,200 @@ const numbers = {
11
11
  if (now === undefined) return "—";
12
12
  return spec.timeInParts && timeInParts(now, spec.format?.unit) || formatValue(now, spec.format);
13
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
+ }
14
49
  /** One figure, large and light, and under it its change against the period before (or a caption). */ export function PulzrFigurePanelComponent(t0) {
15
- const $ = _c(28);
50
+ const $ = _c(20);
16
51
  const { queryResults, spec } = t0;
17
- let change;
18
- let now;
19
52
  let t1;
20
- let total;
21
- if ($[0] !== queryResults || $[1] !== spec.caption || $[2] !== spec.comparedLabel || $[3] !== spec.of?.series) {
22
- const { now: t2, before, total: t3 } = figureOf(queryResults, spec.of?.series);
23
- now = t2;
24
- total = t3;
25
- change = changeOf(now, before);
26
- t1 = change ? changeText(change, spec.comparedLabel) : spec.caption;
27
- $[0] = queryResults;
28
- $[1] = spec.caption;
29
- $[2] = spec.comparedLabel;
30
- $[3] = spec.of?.series;
31
- $[4] = change;
32
- $[5] = now;
33
- $[6] = t1;
34
- $[7] = total;
35
- } else {
36
- change = $[4];
37
- now = $[5];
38
- t1 = $[6];
39
- total = $[7];
40
- }
41
- const line = t1;
42
- let lineColor = "text.secondary";
43
- if (change) {
44
- const better = spec.lowerIsBetter ? "down" : "up";
45
- if (change.direction === "flat") {
46
- lineColor = "text.disabled";
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;
47
67
  } else {
48
- lineColor = change.direction === better ? "success.main" : "error.main";
68
+ t2 = $[3];
49
69
  }
50
- }
51
- let t2;
52
- if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
53
- t2 = {
54
- px: "10px",
55
- pt: "2px",
56
- pb: "7px",
57
- minWidth: 0,
58
- overflow: "hidden"
59
- };
60
- $[8] = t2;
61
- } else {
62
- t2 = $[8];
63
- }
64
- const t3 = spec.color ?? "text.primary";
65
- let t4;
66
- if ($[9] !== t3) {
67
- t4 = {
68
- ...numbers,
69
- fontSize: 22,
70
- fontWeight: 300,
71
- lineHeight: 1.05,
72
- letterSpacing: "-0.02em",
73
- mb: "4px",
74
- color: t3
75
- };
76
- $[9] = t3;
77
- $[10] = t4;
78
- } else {
79
- t4 = $[10];
80
- }
81
- let t5;
82
- if ($[11] !== now || $[12] !== spec) {
83
- t5 = figure(now, spec);
84
- $[11] = now;
85
- $[12] = spec;
86
- $[13] = t5;
87
- } else {
88
- t5 = $[13];
89
- }
90
- let t6;
91
- if ($[14] !== now || $[15] !== spec.of || $[16] !== total) {
92
- t6 = spec.of && total !== undefined && now !== undefined && /*#__PURE__*/ _jsx(Typography, {
93
- component: "span",
94
- sx: {
70
+ const t3 = spec.color ?? "text.primary";
71
+ let t4;
72
+ if ($[4] !== t3) {
73
+ t4 = {
95
74
  ...numbers,
96
- fontSize: 13,
97
- fontWeight: 400,
98
- letterSpacing: "0.02em",
99
- color: "text.secondary",
100
- ml: "8px",
101
- whiteSpace: "nowrap"
102
- },
103
- children: `${Math.round(now * total)}/${total}${spec.of.label ? ` ${spec.of.label}` : ""}`
104
- });
105
- $[14] = now;
106
- $[15] = spec.of;
107
- $[16] = total;
108
- $[17] = t6;
109
- } else {
110
- t6 = $[17];
111
- }
112
- let t7;
113
- if ($[18] !== t4 || $[19] !== t5 || $[20] !== t6) {
114
- t7 = /*#__PURE__*/ _jsxs(Typography, {
115
- component: "div",
116
- sx: t4,
117
- children: [
118
- t5,
119
- t6
120
- ]
121
- });
122
- $[18] = t4;
123
- $[19] = t5;
124
- $[20] = t6;
125
- $[21] = t7;
126
- } else {
127
- t7 = $[21];
128
- }
129
- let t8;
130
- if ($[22] !== line || $[23] !== lineColor) {
131
- t8 = line && /*#__PURE__*/ _jsx(Typography, {
132
- component: "div",
133
- sx: {
134
- ...numbers,
135
- fontSize: 10,
136
- fontWeight: 500,
137
- lineHeight: 1.4,
138
- letterSpacing: "0.02em",
139
- textTransform: "uppercase",
140
- whiteSpace: "nowrap",
141
- overflow: "hidden",
142
- textOverflow: "ellipsis",
143
- color: lineColor
144
- },
145
- children: line
146
- });
147
- $[22] = line;
148
- $[23] = lineColor;
149
- $[24] = t8;
150
- } else {
151
- t8 = $[24];
152
- }
153
- let t9;
154
- if ($[25] !== t7 || $[26] !== t8) {
155
- t9 = /*#__PURE__*/ _jsxs(Box, {
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, {
156
160
  sx: t2,
157
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: "2px",
171
+ whiteSpace: "nowrap",
172
+ overflow: "hidden",
173
+ textOverflow: "ellipsis"
174
+ },
175
+ children: fill(spec.subtitle, values)
176
+ }),
158
177
  t7,
159
- t8
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
+ })
160
199
  ]
161
200
  });
162
- $[25] = t7;
163
- $[26] = t8;
164
- $[27] = t9;
201
+ $[0] = queryResults;
202
+ $[1] = spec;
203
+ $[2] = t1;
165
204
  } else {
166
- t9 = $[27];
205
+ t1 = $[2];
167
206
  }
168
- return t9;
207
+ return t1;
169
208
  }
170
209
 
171
210
  //# sourceMappingURL=PulzrFigurePanelComponent.js.map
@@ -1 +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, timeInParts } 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\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 change = changeOf(now, before);\n const line = change ? changeText(change, spec.comparedLabel) : spec.caption;\n // A change: good news in the success color, bad in the error color, flat quiet. A caption: secondary.\n let lineColor = 'text.secondary';\n if (change) {\n const better = spec.lowerIsBetter ? 'down' : 'up';\n if (change.direction === 'flat') lineColor = 'text.disabled';\n else lineColor = change.direction === better ? 'success.main' : 'error.main';\n }\n return (\n <Box sx={{ px: '10px', pt: '2px', pb: '7px', minWidth: 0, overflow: 'hidden' }}>\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 </Box>\n );\n}\n"],"names":["Box","Typography","formatValue","changeOf","changeText","figureOf","timeInParts","numbers","fontFeatureSettings","fontVariantNumeric","figure","now","spec","undefined","format","unit"],"mappings":";;AAAA,SAASA,GAAG,EAAEC,UAAU,QAAQ,gBAAgB;AAChD,SAASC,WAAW,QAAQ,yBAAyB;AAGrD,SAASC,QAAQ,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,WAAW,QAAQ,cAAW;AAGvE,MAAMC,UAAU;IAAEC,qBAAqB;IAAYC,oBAAoB;AAAe;AAEtF,wEAAwE,GACxE,SAASC,OAAOC,GAAG,EAAsBC,IAAI;IAC3C,IAAID,QAAQE,WAAW,OAAO;IAC9B,OAAO,AAACD,KAAKN,WAAW,IAAIA,YAAYK,KAAKC,KAAKE,MAAM,EAAEC,SAAUb,YAAYS,KAAKC,KAAKE,MAAM;AAClG;AAEA,mGAAmG,GACnG,OAAO"}
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: '2px',\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"}
@@ -1 +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,CA+C5D"}
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"}
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { c as _c } from "react-compiler-runtime";
3
- import { FormControlLabel, Switch, TextField } from "@mui/material";
3
+ import { FormControlLabel, MenuItem, Switch, TextField } from "@mui/material";
4
4
  import { FormatControls, OptionsEditorColumn, OptionsEditorGrid, OptionsEditorGroup } from "@perses-dev/components";
5
5
  const text = (v)=>v.trim() ? v : undefined;
6
6
  export function PulzrFigurePanelSettingsEditor(t0) {
7
- const $ = _c(40);
7
+ const $ = _c(63);
8
8
  const { value, onChange } = t0;
9
9
  let t1;
10
10
  if ($[0] !== value.format) {
@@ -129,12 +129,12 @@ export function PulzrFigurePanelSettingsEditor(t0) {
129
129
  } else {
130
130
  t12 = $[25];
131
131
  }
132
- const t13 = Boolean(value.lowerIsBetter);
132
+ const t13 = value.subtitle ?? "";
133
133
  let t14;
134
134
  if ($[26] !== onChange || $[27] !== value) {
135
135
  t14 = (e_2)=>onChange({
136
136
  ...value,
137
- lowerIsBetter: e_2.target.checked || undefined
137
+ subtitle: text(e_2.target.value)
138
138
  });
139
139
  $[26] = onChange;
140
140
  $[27] = value;
@@ -144,12 +144,12 @@ export function PulzrFigurePanelSettingsEditor(t0) {
144
144
  }
145
145
  let t15;
146
146
  if ($[29] !== t13 || $[30] !== t14) {
147
- t15 = /*#__PURE__*/ _jsx(FormControlLabel, {
148
- control: /*#__PURE__*/ _jsx(Switch, {
149
- checked: t13,
150
- onChange: t14
151
- }),
152
- label: "Lower is better"
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
153
  });
154
154
  $[29] = t13;
155
155
  $[30] = t14;
@@ -157,42 +157,153 @@ export function PulzrFigurePanelSettingsEditor(t0) {
157
157
  } else {
158
158
  t15 = $[31];
159
159
  }
160
- let t16;
161
- if ($[32] !== t12 || $[33] !== t15 || $[34] !== t6 || $[35] !== t9) {
162
- t16 = /*#__PURE__*/ _jsx(OptionsEditorColumn, {
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, {
163
268
  children: /*#__PURE__*/ _jsxs(OptionsEditorGroup, {
164
269
  title: "Figure",
165
270
  children: [
166
271
  t6,
167
272
  t9,
168
273
  t12,
169
- t15
274
+ t15,
275
+ t18,
276
+ t23,
277
+ t26
170
278
  ]
171
279
  })
172
280
  });
173
- $[32] = t12;
174
- $[33] = t15;
175
- $[34] = t6;
176
- $[35] = t9;
177
- $[36] = t16;
281
+ $[52] = t12;
282
+ $[53] = t15;
283
+ $[54] = t18;
284
+ $[55] = t23;
285
+ $[56] = t26;
286
+ $[57] = t6;
287
+ $[58] = t9;
288
+ $[59] = t27;
178
289
  } else {
179
- t16 = $[36];
290
+ t27 = $[59];
180
291
  }
181
- let t17;
182
- if ($[37] !== t16 || $[38] !== t3) {
183
- t17 = /*#__PURE__*/ _jsxs(OptionsEditorGrid, {
292
+ let t28;
293
+ if ($[60] !== t27 || $[61] !== t3) {
294
+ t28 = /*#__PURE__*/ _jsxs(OptionsEditorGrid, {
184
295
  children: [
185
296
  t3,
186
- t16
297
+ t27
187
298
  ]
188
299
  });
189
- $[37] = t16;
190
- $[38] = t3;
191
- $[39] = t17;
300
+ $[60] = t27;
301
+ $[61] = t3;
302
+ $[62] = t28;
192
303
  } else {
193
- t17 = $[39];
304
+ t28 = $[62];
194
305
  }
195
- return t17;
306
+ return t28;
196
307
  }
197
308
 
198
309
  //# sourceMappingURL=PulzrFigurePanelSettingsEditor.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/panels/pulzr-figure-panel/PulzrFigurePanelSettingsEditor.tsx"],"sourcesContent":["import { FormControlLabel, 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 <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","Switch","TextField","FormatControls","OptionsEditorColumn","OptionsEditorGrid","OptionsEditorGroup","text","v","trim","undefined"],"mappings":";;AAAA,SAASA,gBAAgB,EAAEC,MAAM,EAAEC,SAAS,QAAQ,gBAAgB;AACpE,SAASC,cAAc,EAAEC,mBAAmB,EAAEC,iBAAiB,EAAEC,kBAAkB,QAAQ,yBAAyB;AAMpH,MAAMC,OAAO,CAACC,IAAmCA,EAAEC,IAAI,KAAKD,IAAIE;AAEhE,OAAO"}
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"}
@@ -13,7 +13,10 @@ export declare function figureOf(results: Array<{
13
13
  before?: number;
14
14
  total?: number;
15
15
  };
16
- /** A time in parts, as people say it: 45m, 6h 46m, 7h, 2d 3h. Undefined for a unit that is not a time. */
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
+ */
17
20
  export declare function timeInParts(value: number, unit: string | undefined): string | undefined;
18
21
  export type Direction = 'up' | 'down' | 'flat';
19
22
  /** The change from before to now, in percent, and which way: flat within half a percent. */
@@ -26,4 +29,16 @@ export declare function changeText(change: {
26
29
  percent: number;
27
30
  direction: Direction;
28
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;
29
44
  //# sourceMappingURL=figure.d.ts.map