@pulzr/perses-figure-panel 0.1.0 → 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.
Files changed (47) hide show
  1. package/README.md +2 -0
  2. package/__mf/js/{PulzrFigurePanel.1c9caa47a5.js → PulzrFigurePanel.222ed57f17.js} +2 -2
  3. package/__mf/js/async/{0.9e7a9b5c36.js → 0.73358ef06f.js} +2 -2
  4. package/__mf/js/async/{0p.451f0623f4.js → 0p.a434b768a9.js} +2 -2
  5. package/__mf/js/async/{2.d85e4cd480.js → 2.eb2d03fe10.js} +2 -2
  6. package/__mf/js/async/5.b8898f130f.js +83 -0
  7. package/__mf/js/async/{6.915fe1c941.js → 6.bf1ee74593.js} +1 -1
  8. package/__mf/js/async/{9.37089349b7.js → 9.dc16e89090.js} +1 -1
  9. package/__mf/js/async/__federation_expose_PulzrFigurePanel.1c3d39adbe.js +1 -0
  10. package/__mf/js/async/b.09e9dadd98.js +92 -0
  11. package/__mf/js/async/{f.d6fd5293bd.js → f.6ef0146b6f.js} +2 -2
  12. package/__mf/js/async/{k.34593cda39.js → k.d692a3f373.js} +1 -1
  13. package/__mf/js/async/kk.50088d6550.js +1 -0
  14. package/__mf/js/async/{o.07d26e58ef.js → o.d3ab28c6c2.js} +1 -1
  15. package/__mf/js/async/{os.bb0eaba793.js → os.61448719cf.js} +2 -2
  16. package/__mf/js/async/{p.70694aaf0b.js → p.f145ba64f8.js} +2 -2
  17. package/__mf/js/async/{s.9f2e71867d.js → s.c517b47b4d.js} +1 -1
  18. package/__mf/js/{main.c18e128493.js → main.fb996ef195.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.73358ef06f.js.LICENSE.txt} +0 -0
  41. /package/__mf/js/async/{0p.451f0623f4.js.LICENSE.txt → 0p.a434b768a9.js.LICENSE.txt} +0 -0
  42. /package/__mf/js/async/{2.d85e4cd480.js.LICENSE.txt → 2.eb2d03fe10.js.LICENSE.txt} +0 -0
  43. /package/__mf/js/async/{u.26db4151f9.js.LICENSE.txt → 5.b8898f130f.js.LICENSE.txt} +0 -0
  44. /package/__mf/js/async/{n.e553b0554b.js.LICENSE.txt → b.09e9dadd98.js.LICENSE.txt} +0 -0
  45. /package/__mf/js/async/{f.d6fd5293bd.js.LICENSE.txt → f.6ef0146b6f.js.LICENSE.txt} +0 -0
  46. /package/__mf/js/async/{os.bb0eaba793.js.LICENSE.txt → os.61448719cf.js.LICENSE.txt} +0 -0
  47. /package/__mf/js/async/{p.70694aaf0b.js.LICENSE.txt → p.f145ba64f8.js.LICENSE.txt} +0 -0
@@ -1 +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,0GAA0G;AAC1G,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"}
1
+ {"version":3,"file":"figure.d.ts","s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BAAgB,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"}
@@ -25,12 +25,15 @@ const TO_MINUTES = {
25
25
  minutes: 1,
26
26
  hours: 60
27
27
  };
28
- /** A time in parts, as people say it: 45m, 6h 46m, 7h, 2d 3h. Undefined for a unit that is not a time. */ export function timeInParts(value, unit) {
28
+ /**
29
+ * A time in parts, as people say it: 45m, 6h 46m, 7h, and past two days 2d 3h, the minutes being noise there.
30
+ * Undefined for a unit that is not a time.
31
+ */ export function timeInParts(value, unit) {
29
32
  const per = unit ? TO_MINUTES[unit] : undefined;
30
33
  if (per === undefined) return undefined;
31
34
  const minutes = Math.round(value * per);
32
35
  if (minutes < 60) return `${minutes}m`;
33
- if (minutes < 24 * 60) {
36
+ if (minutes < 48 * 60) {
34
37
  const h = Math.floor(minutes / 60);
35
38
  const m = minutes % 60;
36
39
  return m ? `${h}h ${m}m` : `${h}h`;
@@ -59,5 +62,37 @@ const ARROW = {
59
62
  const sign = change.percent > 0 ? '+' : '';
60
63
  return `${ARROW[change.direction]} ${sign}${change.percent.toFixed(1)}% ${comparedLabel}`;
61
64
  }
65
+ /** The last value of each series not labelled `compare`, by its formatted name. */ export function valuesOf(results) {
66
+ const values = new Map();
67
+ for (const s of results.flatMap((r)=>r.data?.series ?? [])){
68
+ if (s.labels?.compare) continue;
69
+ const v = lastValue(s);
70
+ if (v !== undefined) values.set(s.formattedName ?? s.name, v);
71
+ }
72
+ return values;
73
+ }
74
+ /** A template's `{{name}}` and `{{name|%}}` filled from the series' values; `—` for one with none. */ export function fill(template, values) {
75
+ return template.replace(/\{\{\s*([^}|]+?)\s*(\|\s*%\s*)?\}\}/g, (_, name, percent)=>{
76
+ const v = values.get(name);
77
+ if (v === undefined) return '—';
78
+ return percent ? `${v.toFixed(1)}%` : v.toLocaleString(undefined, {
79
+ maximumFractionDigits: 1
80
+ });
81
+ });
82
+ }
83
+ /** The change as its size, good or bad news: `↑ 35.8%`, whole past 100%, `0%` within a twentieth of one. */ export function sizeChange(now, before, lowerIsBetter = false) {
84
+ if (now === undefined || before === undefined || before === 0) return undefined;
85
+ const percent = (now - before) / Math.abs(before) * 100;
86
+ if (Math.abs(percent) < 0.05) return {
87
+ text: '0%',
88
+ tone: 'flat'
89
+ };
90
+ const size = Math.abs(percent) >= 100 ? String(Math.round(Math.abs(percent))) : Math.abs(percent).toFixed(1);
91
+ const good = lowerIsBetter ? percent < 0 : percent > 0;
92
+ return {
93
+ text: `${percent > 0 ? '↑' : '↓'} ${size}%`,
94
+ tone: good ? 'good' : 'bad'
95
+ };
96
+ }
62
97
 
63
98
  //# sourceMappingURL=figure.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/panels/pulzr-figure-panel/figure.ts"],"sourcesContent":["import type { TimeSeries, TimeSeriesData } from '@perses-dev/spec';\n\n/** A series' last value that is a number. */\nexport function lastValue(series: TimeSeries | undefined): number | undefined {\n const values = series?.values ?? [];\n for (let i = values.length - 1; i >= 0; i--) {\n const v = values[i]![1];\n if (v !== null && Number.isFinite(v)) return v;\n }\n return undefined;\n}\n\n/**\n * The figure and the one it is set against. A series labelled `compare` (the\n * period before, as the Pulzr and Parkeze datasources label it) is the one\n * set against; the first other series is the figure.\n */\nexport function figureOf(\n results: Array<{ data?: TimeSeriesData }>,\n of?: string,\n): { now?: number; before?: number; total?: number } {\n const series = results.flatMap((r) => r.data?.series ?? []);\n const compared = (s: TimeSeries): boolean => Boolean(s.labels?.compare);\n const named = (s: TimeSeries): boolean => of !== undefined && (s.formattedName ?? s.name) === of;\n return {\n now: lastValue(series.find((s) => !compared(s) && !named(s))),\n before: lastValue(\n series.find((s) => compared(s) && !(of !== undefined && (s.formattedName ?? s.name).startsWith(of))),\n ),\n total: of === undefined ? undefined : lastValue(series.find((s) => !compared(s) && named(s))),\n };\n}\n\nconst TO_MINUTES: Record<string, number> = { seconds: 1 / 60, minutes: 1, hours: 60 };\n\n/** A time in parts, as people say it: 45m, 6h 46m, 7h, 2d 3h. Undefined for a unit that is not a time. */\nexport function timeInParts(value: number, unit: string | undefined): string | undefined {\n const per = unit ? TO_MINUTES[unit] : undefined;\n if (per === undefined) return undefined;\n const minutes = Math.round(value * per);\n if (minutes < 60) return `${minutes}m`;\n if (minutes < 24 * 60) {\n const h = Math.floor(minutes / 60);\n const m = minutes % 60;\n return m ? `${h}h ${m}m` : `${h}h`;\n }\n const d = Math.floor(minutes / (24 * 60));\n const h = Math.round((minutes % (24 * 60)) / 60);\n return h ? `${d}d ${h}h` : `${d}d`;\n}\n\nexport type Direction = 'up' | 'down' | 'flat';\n\n/** The change from before to now, in percent, and which way: flat within half a percent. */\nexport function changeOf(\n now: number | undefined,\n before: number | undefined,\n): { percent: number; direction: Direction } | undefined {\n if (now === undefined || before === undefined || before <= 0) return undefined;\n const percent = ((now - before) / before) * 100;\n let direction: Direction = 'flat';\n if (percent > 0.5) direction = 'up';\n else if (percent < -0.5) direction = 'down';\n return { percent, direction };\n}\n\nconst ARROW: Record<Direction, string> = { up: '↑', down: '↓', flat: '→' };\n\n/** `↓ -47.3% vs last week`. */\nexport function changeText(\n change: { percent: number; direction: Direction },\n comparedLabel = 'vs the period before',\n): string {\n const sign = change.percent > 0 ? '+' : '';\n return `${ARROW[change.direction]} ${sign}${change.percent.toFixed(1)}% ${comparedLabel}`;\n}\n"],"names":["lastValue","series","values","i","length","v","Number","isFinite","undefined","figureOf","results","of","flatMap","r","data","compared","s","Boolean","labels","compare","named","formattedName","name","now","find","before","startsWith","total","TO_MINUTES","seconds","minutes","hours","timeInParts","value","unit","per","Math","round","h","floor","m","d","changeOf","percent","direction","ARROW","up","down","flat","changeText","change","comparedLabel","sign","toFixed"],"mappings":"AAEA,2CAA2C,GAC3C,OAAO,SAASA,UAAUC,MAA8B;IACtD,MAAMC,SAASD,QAAQC,UAAU,EAAE;IACnC,IAAK,IAAIC,IAAID,OAAOE,MAAM,GAAG,GAAGD,KAAK,GAAGA,IAAK;QAC3C,MAAME,IAAIH,MAAM,CAACC,EAAE,AAAC,CAAC,EAAE;QACvB,IAAIE,MAAM,QAAQC,OAAOC,QAAQ,CAACF,IAAI,OAAOA;IAC/C;IACA,OAAOG;AACT;AAEA;;;;CAIC,GACD,OAAO,SAASC,SACdC,OAAyC,EACzCC,EAAW;IAEX,MAAMV,SAASS,QAAQE,OAAO,CAAC,CAACC,IAAMA,EAAEC,IAAI,EAAEb,UAAU,EAAE;IAC1D,MAAMc,WAAW,CAACC,IAA2BC,QAAQD,EAAEE,MAAM,EAAEC;IAC/D,MAAMC,QAAQ,CAACJ,IAA2BL,OAAOH,aAAa,AAACQ,CAAAA,EAAEK,aAAa,IAAIL,EAAEM,IAAI,AAAD,MAAOX;IAC9F,OAAO;QACLY,KAAKvB,UAAUC,OAAOuB,IAAI,CAAC,CAACR,IAAM,CAACD,SAASC,MAAM,CAACI,MAAMJ;QACzDS,QAAQzB,UACNC,OAAOuB,IAAI,CAAC,CAACR,IAAMD,SAASC,MAAM,CAAEL,CAAAA,OAAOH,aAAa,AAACQ,CAAAA,EAAEK,aAAa,IAAIL,EAAEM,IAAI,AAAD,EAAGI,UAAU,CAACf,GAAE;QAEnGgB,OAAOhB,OAAOH,YAAYA,YAAYR,UAAUC,OAAOuB,IAAI,CAAC,CAACR,IAAM,CAACD,SAASC,MAAMI,MAAMJ;IAC3F;AACF;AAEA,MAAMY,aAAqC;IAAEC,SAAS,IAAI;IAAIC,SAAS;IAAGC,OAAO;AAAG;AAE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AAGE,KAAK,CAACK,OAAON,SAAS,CAAC,CAAC,CAAC,EAAEQ,OAAOF,OAAOP,OAAO,CAACU,OAAO,CAAC,GAAG,EAAE,EAAEF,eAAe;AAC3F"}
1
+ {"version":3,"sources":["../../../../src/panels/pulzr-figure-panel/figure.ts"],"sourcesContent":["import type { TimeSeries, TimeSeriesData } from '@perses-dev/spec';\n\n/** A series' last value that is a number. */\nexport function lastValue(series: TimeSeries | undefined): number | undefined {\n const values = series?.values ?? [];\n for (let i = values.length - 1; i >= 0; i--) {\n const v = values[i]![1];\n if (v !== null && Number.isFinite(v)) return v;\n }\n return undefined;\n}\n\n/**\n * The figure and the one it is set against. A series labelled `compare` (the\n * period before, as the Pulzr and Parkeze datasources label it) is the one\n * set against; the first other series is the figure.\n */\nexport function figureOf(\n results: Array<{ data?: TimeSeriesData }>,\n of?: string,\n): { now?: number; before?: number; total?: number } {\n const series = results.flatMap((r) => r.data?.series ?? []);\n const compared = (s: TimeSeries): boolean => Boolean(s.labels?.compare);\n const named = (s: TimeSeries): boolean => of !== undefined && (s.formattedName ?? s.name) === of;\n return {\n now: lastValue(series.find((s) => !compared(s) && !named(s))),\n before: lastValue(\n series.find((s) => compared(s) && !(of !== undefined && (s.formattedName ?? s.name).startsWith(of))),\n ),\n total: of === undefined ? undefined : lastValue(series.find((s) => !compared(s) && named(s))),\n };\n}\n\nconst TO_MINUTES: Record<string, number> = { seconds: 1 / 60, minutes: 1, hours: 60 };\n\n/**\n * A time in parts, as people say it: 45m, 6h 46m, 7h, and past two days 2d 3h, the minutes being noise there.\n * Undefined for a unit that is not a time.\n */\nexport function timeInParts(value: number, unit: string | undefined): string | undefined {\n const per = unit ? TO_MINUTES[unit] : undefined;\n if (per === undefined) return undefined;\n const minutes = Math.round(value * per);\n if (minutes < 60) return `${minutes}m`;\n if (minutes < 48 * 60) {\n const h = Math.floor(minutes / 60);\n const m = minutes % 60;\n return m ? `${h}h ${m}m` : `${h}h`;\n }\n const d = Math.floor(minutes / (24 * 60));\n const h = Math.round((minutes % (24 * 60)) / 60);\n return h ? `${d}d ${h}h` : `${d}d`;\n}\n\nexport type Direction = 'up' | 'down' | 'flat';\n\n/** The change from before to now, in percent, and which way: flat within half a percent. */\nexport function changeOf(\n now: number | undefined,\n before: number | undefined,\n): { percent: number; direction: Direction } | undefined {\n if (now === undefined || before === undefined || before <= 0) return undefined;\n const percent = ((now - before) / before) * 100;\n let direction: Direction = 'flat';\n if (percent > 0.5) direction = 'up';\n else if (percent < -0.5) direction = 'down';\n return { percent, direction };\n}\n\nconst ARROW: Record<Direction, string> = { up: '↑', down: '↓', flat: '→' };\n\n/** `↓ -47.3% vs last week`. */\nexport function changeText(\n change: { percent: number; direction: Direction },\n comparedLabel = 'vs the period before',\n): string {\n const sign = change.percent > 0 ? '+' : '';\n return `${ARROW[change.direction]} ${sign}${change.percent.toFixed(1)}% ${comparedLabel}`;\n}\n\n/** The last value of each series not labelled `compare`, by its formatted name. */\nexport function valuesOf(results: Array<{ data?: TimeSeriesData }>): Map<string, number> {\n const values = new Map<string, number>();\n for (const s of results.flatMap((r) => r.data?.series ?? [])) {\n if (s.labels?.compare) continue;\n const v = lastValue(s);\n if (v !== undefined) values.set(s.formattedName ?? s.name, v);\n }\n return values;\n}\n\n/** A template's `{{name}}` and `{{name|%}}` filled from the series' values; `—` for one with none. */\nexport function fill(template: string, values: Map<string, number>): string {\n return template.replace(/\\{\\{\\s*([^}|]+?)\\s*(\\|\\s*%\\s*)?\\}\\}/g, (_, name: string, percent?: string) => {\n const v = values.get(name);\n if (v === undefined) return '—';\n return percent ? `${v.toFixed(1)}%` : v.toLocaleString(undefined, { maximumFractionDigits: 1 });\n });\n}\n\nexport type Tone = 'good' | 'bad' | 'flat';\n\n/** The change as its size, good or bad news: `↑ 35.8%`, whole past 100%, `0%` within a twentieth of one. */\nexport function sizeChange(\n now: number | undefined,\n before: number | undefined,\n lowerIsBetter = false,\n): { text: string; tone: Tone } | undefined {\n if (now === undefined || before === undefined || before === 0) return undefined;\n const percent = ((now - before) / Math.abs(before)) * 100;\n if (Math.abs(percent) < 0.05) return { text: '0%', tone: 'flat' };\n const size = Math.abs(percent) >= 100 ? String(Math.round(Math.abs(percent))) : Math.abs(percent).toFixed(1);\n const good = lowerIsBetter ? percent < 0 : percent > 0;\n return { text: `${percent > 0 ? '↑' : '↓'} ${size}%`, tone: good ? 'good' : 'bad' };\n}\n"],"names":["lastValue","series","values","i","length","v","Number","isFinite","undefined","figureOf","results","of","flatMap","r","data","compared","s","Boolean","labels","compare","named","formattedName","name","now","find","before","startsWith","total","TO_MINUTES","seconds","minutes","hours","timeInParts","value","unit","per","Math","round","h","floor","m","d","changeOf","percent","direction","ARROW","up","down","flat","changeText","change","comparedLabel","sign","toFixed","valuesOf","Map","set","fill","template","replace","_","get","toLocaleString","maximumFractionDigits","sizeChange","lowerIsBetter","abs","text","tone","size","String","good"],"mappings":"AAEA,2CAA2C,GAC3C,OAAO,SAASA,UAAUC,MAA8B;IACtD,MAAMC,SAASD,QAAQC,UAAU,EAAE;IACnC,IAAK,IAAIC,IAAID,OAAOE,MAAM,GAAG,GAAGD,KAAK,GAAGA,IAAK;QAC3C,MAAME,IAAIH,MAAM,CAACC,EAAE,AAAC,CAAC,EAAE;QACvB,IAAIE,MAAM,QAAQC,OAAOC,QAAQ,CAACF,IAAI,OAAOA;IAC/C;IACA,OAAOG;AACT;AAEA;;;;CAIC,GACD,OAAO,SAASC,SACdC,OAAyC,EACzCC,EAAW;IAEX,MAAMV,SAASS,QAAQE,OAAO,CAAC,CAACC,IAAMA,EAAEC,IAAI,EAAEb,UAAU,EAAE;IAC1D,MAAMc,WAAW,CAACC,IAA2BC,QAAQD,EAAEE,MAAM,EAAEC;IAC/D,MAAMC,QAAQ,CAACJ,IAA2BL,OAAOH,aAAa,AAACQ,CAAAA,EAAEK,aAAa,IAAIL,EAAEM,IAAI,AAAD,MAAOX;IAC9F,OAAO;QACLY,KAAKvB,UAAUC,OAAOuB,IAAI,CAAC,CAACR,IA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F;AAIA,0GAA0G,GAC1G,OAAO,SAASC,WACdzC,GAAuB,EACvBE,MAA0B,EAC1BwC,gBAAgB,KAAK;IAErB,IAAI1C,QAAQf,aAAaiB,WAAWjB,aAAaiB,WAAW,GAAG,OAAOjB;IACtE,MAAMmC,UAAU,AAAEpB,CAAAA,MAAME,MAAK,IAAKW,KAAK8B,GAAG,CAACzC,UAAW;IACtD,IAAIW,KAAK8B,GAAG,CAACvB,WAAW,MAAM,OAAO;QAAEwB,MAAM;QAAMC,MAAM;IAAO;IAChE,MAAMC,OAAOjC,KAAK8B,GAAG,CAACvB,YAAY,MAAM2B,OAAOlC,KAAKC,KAAK,CAACD,KAAK8B,GAAG,CAACvB,aAAaP,KAAK8B,GAAG,CAACvB,SAASU,OAAO,CAAC;IAC1G,MAAMkB,OAAON,gBAAgBtB,UAAU,IAAIA,UAAU;IACrD,OAAO;QAAEwB,MAAM,GAAGxB,UAAU,IAAI,MAAM,IAAI,CAAC,EAAE0B,KAAK,CAAC,CAAC;QAAED,MAAMG,OAAO,SAAS;IAAM;AACpF"}
@@ -21,6 +21,18 @@ export interface PulzrFigurePanelOptions {
21
21
  series: string;
22
22
  label?: string;
23
23
  };
24
+ /**
25
+ * A line under the title, from the query's series: `of {{booked_space_hours}} booked hours, occupied`. `{{name}}` is
26
+ * the series' value, `{{name|%}}` the value as a percent (16.4%).
27
+ */
28
+ subtitle?: string;
29
+ /** A small box under the figure, from the query's series as `subtitle` is: `{{new}} new · {{renewals}} renewals`. */
30
+ detail?: string;
31
+ /**
32
+ * How the change reads. `signed` (the default): `↑ +0.7% vs last week`, flat within half a percent. `size`: `↑ 35.8%
33
+ * vs last week`, whole past 100%, `0%` within a twentieth of one.
34
+ */
35
+ changeStyle?: 'signed' | 'size';
24
36
  }
25
37
  export type PulzrFigurePanelProps = PanelProps<PulzrFigurePanelOptions, TimeSeriesData>;
26
38
  //# sourceMappingURL=pulzr-figure-panel-types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pulzr-figure-panel-types.d.ts","sourceRoot":"","sources":["../../../../src/panels/pulzr-figure-panel/pulzr-figure-panel-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,WAAW,uBAAuB;IACtC,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2GAA2G;IAC3G,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+FAA+F;IAC/F,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,sGAAsG;IACtG,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,EAAE,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACzC;AAED,MAAM,MAAM,qBAAqB,GAAG,UAAU,CAAC,uBAAuB,EAAE,cAAc,CAAC,CAAC"}
1
+ {"version":3,"file":"pulzr-figure-panel-types.d.ts","sourceRoot":"","sources":["../../../../src/panels/pulzr-figure-panel/pulzr-figure-panel-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,MAAM,WAAW,uBAAuB;IACtC,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2GAA2G;IAC3G,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+FAA+F;IAC/F,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,sGAAsG;IACtG,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,EAAE,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qHAAqH;IACrH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;CACjC;AAED,MAAM,MAAM,qBAAqB,GAAG,UAAU,CAAC,uBAAuB,EAAE,cAAc,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/panels/pulzr-figure-panel/pulzr-figure-panel-types.ts"],"sourcesContent":["import type { FormatOptions } from '@perses-dev/components';\nimport type { PanelProps } from '@perses-dev/plugin-system';\nimport type { TimeSeriesData } from '@perses-dev/spec';\n\nexport interface PulzrFigurePanelOptions {\n format?: FormatOptions;\n /** The figure's color, any CSS color. The theme's text color unless set. */\n color?: string;\n /** What the period compared is called, after the change: `vs last week`. */\n comparedLabel?: string;\n /** Shown in place of the change when there is nothing to compare with: `Average for the selected week`. */\n caption?: string;\n /** A fall is good news: a fall is drawn in the success color and a rise in the error color. */\n lowerIsBetter?: boolean;\n /** A time in parts, as people say it: 6h 46m, not 6.8h. For a format in seconds, minutes or hours. */\n timeInParts?: boolean;\n /**\n * The figure, a rate, as a count of a total beside it: `1690/2639 Spaces Occupied`. `series` names the\n * series holding the total (the query asks for both); `label` follows.\n */\n of?: { series: string; label?: string };\n}\n\nexport type PulzrFigurePanelProps = PanelProps<PulzrFigurePanelOptions, TimeSeriesData>;\n"],"names":[],"mappings":"AAuBA,WAAwF"}
1
+ {"version":3,"sources":["../../../../src/panels/pulzr-figure-panel/pulzr-figure-panel-types.ts"],"sourcesContent":["import type { FormatOptions } from '@perses-dev/components';\nimport type { PanelProps } from '@perses-dev/plugin-system';\nimport type { TimeSeriesData } from '@perses-dev/spec';\n\nexport interface PulzrFigurePanelOptions {\n format?: FormatOptions;\n /** The figure's color, any CSS color. The theme's text color unless set. */\n color?: string;\n /** What the period compared is called, after the change: `vs last week`. */\n comparedLabel?: string;\n /** Shown in place of the change when there is nothing to compare with: `Average for the selected week`. */\n caption?: string;\n /** A fall is good news: a fall is drawn in the success color and a rise in the error color. */\n lowerIsBetter?: boolean;\n /** A time in parts, as people say it: 6h 46m, not 6.8h. For a format in seconds, minutes or hours. */\n timeInParts?: boolean;\n /**\n * The figure, a rate, as a count of a total beside it: `1690/2639 Spaces Occupied`. `series` names the\n * series holding the total (the query asks for both); `label` follows.\n */\n of?: { series: string; label?: string };\n /**\n * A line under the title, from the query's series: `of {{booked_space_hours}} booked hours, occupied`. `{{name}}` is\n * the series' value, `{{name|%}}` the value as a percent (16.4%).\n */\n subtitle?: string;\n /** A small box under the figure, from the query's series as `subtitle` is: `{{new}} new · {{renewals}} renewals`. */\n detail?: string;\n /**\n * How the change reads. `signed` (the default): `↑ +0.7% vs last week`, flat within half a percent. `size`: `↑ 35.8%\n * vs last week`, whole past 100%, `0%` within a twentieth of one.\n */\n changeStyle?: 'signed' | 'size';\n}\n\nexport type PulzrFigurePanelProps = PanelProps<PulzrFigurePanelOptions, TimeSeriesData>;\n"],"names":[],"mappings":"AAmCA,WAAwF"}
package/mf-manifest.json CHANGED
@@ -5,11 +5,11 @@
5
5
  "name": "PulzrFigurePanel",
6
6
  "type": "app",
7
7
  "buildInfo": {
8
- "buildVersion": "0.1.0",
8
+ "buildVersion": "0.2.0",
9
9
  "buildName": "@pulzr/perses-figure-panel"
10
10
  },
11
11
  "remoteEntry": {
12
- "name": "__mf/js/PulzrFigurePanel.1c9caa47a5.js",
12
+ "name": "__mf/js/PulzrFigurePanel.222ed57f17.js",
13
13
  "path": "",
14
14
  "type": "global"
15
15
  },
@@ -19,9 +19,9 @@
19
19
  "zip": "",
20
20
  "api": ""
21
21
  },
22
- "globalName": "PulzrFigurePanel_0_1_0",
22
+ "globalName": "PulzrFigurePanel_0_2_0",
23
23
  "pluginVersion": "2.9.3",
24
- "getPublicPath": "function() { return (window.PERSES_PLUGIN_ASSETS_PATH || window.PERSES_APP_CONFIG?.api_prefix || \"\") + \"/plugins/PulzrFigurePanel~0.1.0/\"; }"
24
+ "getPublicPath": "function() { return (window.PERSES_PLUGIN_ASSETS_PATH || window.PERSES_APP_CONFIG?.api_prefix || \"\") + \"/plugins/PulzrFigurePanel~0.2.0/\"; }"
25
25
  },
26
26
  "shared": [
27
27
  {
@@ -34,7 +34,7 @@
34
34
  "js": {
35
35
  "async": [],
36
36
  "sync": [
37
- "__mf/js/async/0p.451f0623f4.js"
37
+ "__mf/js/async/0p.a434b768a9.js"
38
38
  ]
39
39
  },
40
40
  "css": {
@@ -54,8 +54,8 @@
54
54
  "js": {
55
55
  "async": [],
56
56
  "sync": [
57
- "__mf/js/async/6.915fe1c941.js",
58
- "__mf/js/async/o.07d26e58ef.js"
57
+ "__mf/js/async/6.bf1ee74593.js",
58
+ "__mf/js/async/o.d3ab28c6c2.js"
59
59
  ]
60
60
  },
61
61
  "css": {
@@ -75,13 +75,13 @@
75
75
  "js": {
76
76
  "async": [],
77
77
  "sync": [
78
- "__mf/js/async/n.e553b0554b.js"
78
+ "__mf/js/async/b.09e9dadd98.js"
79
79
  ]
80
80
  },
81
81
  "css": {
82
82
  "async": [],
83
83
  "sync": [
84
- "__mf/css/async/n.7481ca0159.css"
84
+ "__mf/css/async/b.7481ca0159.css"
85
85
  ]
86
86
  }
87
87
  },
@@ -97,7 +97,7 @@
97
97
  "js": {
98
98
  "async": [],
99
99
  "sync": [
100
- "__mf/js/async/s.9f2e71867d.js"
100
+ "__mf/js/async/s.c517b47b4d.js"
101
101
  ]
102
102
  },
103
103
  "css": {
@@ -117,7 +117,7 @@
117
117
  "js": {
118
118
  "async": [],
119
119
  "sync": [
120
- "__mf/js/async/os.bb0eaba793.js"
120
+ "__mf/js/async/os.61448719cf.js"
121
121
  ]
122
122
  },
123
123
  "css": {
@@ -137,7 +137,7 @@
137
137
  "js": {
138
138
  "async": [],
139
139
  "sync": [
140
- "__mf/js/async/f.d6fd5293bd.js"
140
+ "__mf/js/async/f.6ef0146b6f.js"
141
141
  ]
142
142
  },
143
143
  "css": {
@@ -157,8 +157,8 @@
157
157
  "js": {
158
158
  "async": [],
159
159
  "sync": [
160
- "__mf/js/async/2.d85e4cd480.js",
161
- "__mf/js/async/p.70694aaf0b.js"
160
+ "__mf/js/async/2.eb2d03fe10.js",
161
+ "__mf/js/async/p.f145ba64f8.js"
162
162
  ]
163
163
  },
164
164
  "css": {
@@ -178,7 +178,7 @@
178
178
  "js": {
179
179
  "async": [],
180
180
  "sync": [
181
- "__mf/js/async/0.9e7a9b5c36.js"
181
+ "__mf/js/async/0.73358ef06f.js"
182
182
  ]
183
183
  },
184
184
  "css": {
@@ -197,17 +197,17 @@
197
197
  "assets": {
198
198
  "js": {
199
199
  "sync": [
200
- "__mf/js/async/u.26db4151f9.js",
201
- "__mf/js/async/__federation_expose_PulzrFigurePanel.4e6d8dd142.js"
200
+ "__mf/js/async/5.b8898f130f.js",
201
+ "__mf/js/async/__federation_expose_PulzrFigurePanel.1c3d39adbe.js"
202
202
  ],
203
203
  "async": [
204
- "__mf/js/async/k.34593cda39.js"
204
+ "__mf/js/async/k.d692a3f373.js"
205
205
  ]
206
206
  },
207
207
  "css": {
208
208
  "sync": [],
209
209
  "async": [
210
- "__mf/css/async/n.7481ca0159.css"
210
+ "__mf/css/async/b.7481ca0159.css"
211
211
  ]
212
212
  }
213
213
  },
package/mf-stats.json CHANGED
@@ -5,11 +5,11 @@
5
5
  "name": "PulzrFigurePanel",
6
6
  "type": "app",
7
7
  "buildInfo": {
8
- "buildVersion": "0.1.0",
8
+ "buildVersion": "0.2.0",
9
9
  "buildName": "@pulzr/perses-figure-panel"
10
10
  },
11
11
  "remoteEntry": {
12
- "name": "__mf/js/PulzrFigurePanel.1c9caa47a5.js",
12
+ "name": "__mf/js/PulzrFigurePanel.222ed57f17.js",
13
13
  "path": "",
14
14
  "type": "global"
15
15
  },
@@ -19,9 +19,9 @@
19
19
  "zip": "",
20
20
  "api": ""
21
21
  },
22
- "globalName": "PulzrFigurePanel_0_1_0",
22
+ "globalName": "PulzrFigurePanel_0_2_0",
23
23
  "pluginVersion": "2.9.3",
24
- "getPublicPath": "function() { return (window.PERSES_PLUGIN_ASSETS_PATH || window.PERSES_APP_CONFIG?.api_prefix || \"\") + \"/plugins/PulzrFigurePanel~0.1.0/\"; }"
24
+ "getPublicPath": "function() { return (window.PERSES_PLUGIN_ASSETS_PATH || window.PERSES_APP_CONFIG?.api_prefix || \"\") + \"/plugins/PulzrFigurePanel~0.2.0/\"; }"
25
25
  },
26
26
  "shared": [
27
27
  {
@@ -36,7 +36,7 @@
36
36
  "js": {
37
37
  "async": [],
38
38
  "sync": [
39
- "__mf/js/async/0p.451f0623f4.js"
39
+ "__mf/js/async/0p.a434b768a9.js"
40
40
  ]
41
41
  },
42
42
  "css": {
@@ -60,8 +60,8 @@
60
60
  "js": {
61
61
  "async": [],
62
62
  "sync": [
63
- "__mf/js/async/6.915fe1c941.js",
64
- "__mf/js/async/o.07d26e58ef.js"
63
+ "__mf/js/async/6.bf1ee74593.js",
64
+ "__mf/js/async/o.d3ab28c6c2.js"
65
65
  ]
66
66
  },
67
67
  "css": {
@@ -85,13 +85,13 @@
85
85
  "js": {
86
86
  "async": [],
87
87
  "sync": [
88
- "__mf/js/async/n.e553b0554b.js"
88
+ "__mf/js/async/b.09e9dadd98.js"
89
89
  ]
90
90
  },
91
91
  "css": {
92
92
  "async": [],
93
93
  "sync": [
94
- "__mf/css/async/n.7481ca0159.css"
94
+ "__mf/css/async/b.7481ca0159.css"
95
95
  ]
96
96
  }
97
97
  },
@@ -111,7 +111,7 @@
111
111
  "js": {
112
112
  "async": [],
113
113
  "sync": [
114
- "__mf/js/async/s.9f2e71867d.js"
114
+ "__mf/js/async/s.c517b47b4d.js"
115
115
  ]
116
116
  },
117
117
  "css": {
@@ -135,7 +135,7 @@
135
135
  "js": {
136
136
  "async": [],
137
137
  "sync": [
138
- "__mf/js/async/os.bb0eaba793.js"
138
+ "__mf/js/async/os.61448719cf.js"
139
139
  ]
140
140
  },
141
141
  "css": {
@@ -159,7 +159,7 @@
159
159
  "js": {
160
160
  "async": [],
161
161
  "sync": [
162
- "__mf/js/async/f.d6fd5293bd.js"
162
+ "__mf/js/async/f.6ef0146b6f.js"
163
163
  ]
164
164
  },
165
165
  "css": {
@@ -183,8 +183,8 @@
183
183
  "js": {
184
184
  "async": [],
185
185
  "sync": [
186
- "__mf/js/async/2.d85e4cd480.js",
187
- "__mf/js/async/p.70694aaf0b.js"
186
+ "__mf/js/async/2.eb2d03fe10.js",
187
+ "__mf/js/async/p.f145ba64f8.js"
188
188
  ]
189
189
  },
190
190
  "css": {
@@ -208,7 +208,7 @@
208
208
  "js": {
209
209
  "async": [],
210
210
  "sync": [
211
- "__mf/js/async/0.9e7a9b5c36.js"
211
+ "__mf/js/async/0.73358ef06f.js"
212
212
  ]
213
213
  },
214
214
  "css": {
@@ -232,17 +232,17 @@
232
232
  "assets": {
233
233
  "js": {
234
234
  "sync": [
235
- "__mf/js/async/u.26db4151f9.js",
236
- "__mf/js/async/__federation_expose_PulzrFigurePanel.4e6d8dd142.js"
235
+ "__mf/js/async/5.b8898f130f.js",
236
+ "__mf/js/async/__federation_expose_PulzrFigurePanel.1c3d39adbe.js"
237
237
  ],
238
238
  "async": [
239
- "__mf/js/async/k.34593cda39.js"
239
+ "__mf/js/async/k.d692a3f373.js"
240
240
  ]
241
241
  },
242
242
  "css": {
243
243
  "sync": [],
244
244
  "async": [
245
- "__mf/css/async/n.7481ca0159.css"
245
+ "__mf/css/async/b.7481ca0159.css"
246
246
  ]
247
247
  }
248
248
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pulzr/perses-figure-panel",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "engines": {
@@ -1 +0,0 @@
1
- "use strict";(self.chunk_PulzrFigurePanel_0_1_0=self.chunk_PulzrFigurePanel_0_1_0||[]).push([["2k"],{RK(e,t,o){function r(e){let t=e?.values??[];for(let e=t.length-1;e>=0;e--){let o=t[e][1];if(null!==o&&Number.isFinite(o))return o}}function n(e,t){let o=e.flatMap(e=>e.data?.series??[]),n=e=>!!e.labels?.compare,l=e=>void 0!==t&&(e.formattedName??e.name)===t;return{now:r(o.find(e=>!n(e)&&!l(e))),before:r(o.find(e=>n(e)&&!(void 0!==t&&(e.formattedName??e.name).startsWith(t)))),total:void 0===t?void 0:r(o.find(e=>!n(e)&&l(e)))}}o.r(t),o.d(t,{PulzrFigurePanel:()=>j,PulzrFigurePanelComponent:()=>x,PulzrFigurePanelSettingsEditor:()=>C,changeOf:()=>a,changeText:()=>c,figureOf:()=>n,lastValue:()=>r,timeInParts:()=>i});let l={seconds:1/60,minutes:1,hours:60};function i(e,t){let o=t?l[t]:void 0;if(void 0===o)return;let r=Math.round(e*o);if(r<60)return`${r}m`;if(r<1440){let e=Math.floor(r/60),t=r%60;return t?`${e}h ${t}m`:`${e}h`}let n=Math.floor(r/1440),i=Math.round(r%1440/60);return i?`${n}d ${i}h`:`${n}d`}function a(e,t){if(void 0===e||void 0===t||t<=0)return;let o=(e-t)/t*100,r="flat";return o>.5?r="up":o<-.5&&(r="down"),{percent:o,direction:r}}let s={up:"↑",down:"↓",flat:"→"};function c(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"vs the period before",o=e.percent>0?"+":"";return`${s[e.direction]} ${o}${e.percent.toFixed(1)}% ${t}`}var d=o("P2"),u=o("K2"),p=o("X3"),f=o("ZQ"),m=o("Q6");let h={fontFeatureSettings:"'tnum' 1",fontVariantNumeric:"tabular-nums"};function x(e){let t,o,r,l,s,x,g,v,b,w,C,j=(0,u.c)(28),{queryResults:S,spec:$}=e;if(j[0]!==S||j[1]!==$.caption||j[2]!==$.comparedLabel||j[3]!==$.of?.series){let{now:e,before:i,total:s}=n(S,$.of?.series);o=e,l=s,r=(t=a(o,i))?c(t,$.comparedLabel):$.caption,j[0]=S,j[1]=$.caption,j[2]=$.comparedLabel,j[3]=$.of?.series,j[4]=t,j[5]=o,j[6]=r,j[7]=l}else t=j[4],o=j[5],r=j[6],l=j[7];let P=r,A="text.secondary";if(t){let e=$.lowerIsBetter?"down":"up";A="flat"===t.direction?"text.disabled":t.direction===e?"success.main":"error.main"}j[8]===Symbol.for("react.memo_cache_sentinel")?(s={px:"10px",pt:"2px",pb:"7px",minWidth:0,overflow:"hidden"},j[8]=s):s=j[8];let z=$.color??"text.primary";if(j[9]!==z?(x={...h,fontSize:22,fontWeight:300,lineHeight:1.05,letterSpacing:"-0.02em",mb:"4px",color:z},j[9]=z,j[10]=x):x=j[10],j[11]!==o||j[12]!==$){var F;g=void 0===(F=o)?"—":$.timeInParts&&i(F,$.format?.unit)||(0,m.formatValue)(F,$.format),j[11]=o,j[12]=$,j[13]=g}else g=j[13];return j[14]!==o||j[15]!==$.of||j[16]!==l?(v=$.of&&void 0!==l&&void 0!==o&&(0,d.jsx)(p.A,{component:"span",sx:{...h,fontSize:13,fontWeight:400,letterSpacing:"0.02em",color:"text.secondary",ml:"8px",whiteSpace:"nowrap"},children:`${Math.round(o*l)}/${l}${$.of.label?` ${$.of.label}`:""}`}),j[14]=o,j[15]=$.of,j[16]=l,j[17]=v):v=j[17],j[18]!==x||j[19]!==g||j[20]!==v?(b=(0,d.jsxs)(p.A,{component:"div",sx:x,children:[g,v]}),j[18]=x,j[19]=g,j[20]=v,j[21]=b):b=j[21],j[22]!==P||j[23]!==A?(w=P&&(0,d.jsx)(p.A,{component:"div",sx:{...h,fontSize:10,fontWeight:500,lineHeight:1.4,letterSpacing:"0.02em",textTransform:"uppercase",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",color:A},children:P}),j[22]=P,j[23]=A,j[24]=w):w=j[24],j[25]!==b||j[26]!==w?(C=(0,d.jsxs)(f.A,{sx:s,children:[b,w]}),j[25]=b,j[26]=w,j[27]=C):C=j[27],C}var g=o("AI"),v=o("Ct"),b=o("hA");let w=e=>e.trim()?e:void 0;function C(e){let t,o,r,n,l,i,a,s,c,p,f,h,x,C=(0,u.c)(40),{value:j,onChange:S}=e;C[0]!==j.format?(t=j.format??{unit:"decimal"},C[0]=j.format,C[1]=t):t=C[1],C[2]!==S||C[3]!==j?(o=e=>S({...j,format:e}),C[2]=S,C[3]=j,C[4]=o):o=C[4],C[5]!==t||C[6]!==o?(r=(0,d.jsx)(m.OptionsEditorColumn,{children:(0,d.jsx)(m.OptionsEditorGroup,{title:"Format",children:(0,d.jsx)(m.FormatControls,{value:t,onChange:o})})}),C[5]=t,C[6]=o,C[7]=r):r=C[7];let $=j.color??"";C[8]!==S||C[9]!==j?(n=e=>S({...j,color:w(e.target.value)}),C[8]=S,C[9]=j,C[10]=n):n=C[10],C[11]!==$||C[12]!==n?(l=(0,d.jsx)(g.A,{size:"small",label:"Color",helperText:"Any CSS color. Empty: the text color.",value:$,onChange:n}),C[11]=$,C[12]=n,C[13]=l):l=C[13];let P=j.comparedLabel??"";C[14]!==S||C[15]!==j?(i=e=>S({...j,comparedLabel:w(e.target.value)}),C[14]=S,C[15]=j,C[16]=i):i=C[16],C[17]!==P||C[18]!==i?(a=(0,d.jsx)(g.A,{size:"small",label:"Compared label",helperText:"After the change: vs last week.",value:P,onChange:i}),C[17]=P,C[18]=i,C[19]=a):a=C[19];let A=j.caption??"";C[20]!==S||C[21]!==j?(s=e=>S({...j,caption:w(e.target.value)}),C[20]=S,C[21]=j,C[22]=s):s=C[22],C[23]!==A||C[24]!==s?(c=(0,d.jsx)(g.A,{size:"small",label:"Caption",helperText:"When there is nothing to compare with.",value:A,onChange:s}),C[23]=A,C[24]=s,C[25]=c):c=C[25];let z=!!j.lowerIsBetter;return C[26]!==S||C[27]!==j?(p=e=>S({...j,lowerIsBetter:e.target.checked||void 0}),C[26]=S,C[27]=j,C[28]=p):p=C[28],C[29]!==z||C[30]!==p?(f=(0,d.jsx)(v.A,{control:(0,d.jsx)(b.A,{checked:z,onChange:p}),label:"Lower is better"}),C[29]=z,C[30]=p,C[31]=f):f=C[31],C[32]!==c||C[33]!==f||C[34]!==l||C[35]!==a?(h=(0,d.jsx)(m.OptionsEditorColumn,{children:(0,d.jsxs)(m.OptionsEditorGroup,{title:"Figure",children:[l,a,c,f]})}),C[32]=c,C[33]=f,C[34]=l,C[35]=a,C[36]=h):h=C[36],C[37]!==h||C[38]!==r?(x=(0,d.jsxs)(m.OptionsEditorGrid,{children:[r,h]}),C[37]=h,C[38]=r,C[39]=x):x=C[39],x}let j={PanelComponent:x,panelOptionsEditorComponents:[{label:"Settings",content:C}],supportedQueryTypes:["TimeSeriesQuery"],createInitialOptions:()=>({})}}}]);
@@ -1 +0,0 @@
1
- "use strict";(self.chunk_PulzrFigurePanel_0_1_0=self.chunk_PulzrFigurePanel_0_1_0||[]).push([["kk"],{Wp(e,r,t){var u=t("A");r.H=u.createRoot,u.hydrateRoot},K0(e,r,t){t.r(r);var u=t("P2"),o=t("HE");t("Wp").H(document.getElementById("root")).render((0,u.jsx)(o.StrictMode,{}))}}]);