@burdenoff/microfe-bigconsole 2026.1119.1 → 2026.1119.3

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 (43) hide show
  1. package/dist/bigconsole/asof/AsOfBanner.js +28 -14
  2. package/dist/bigconsole/asof/AsOfControl.js +84 -16
  3. package/dist/bigconsole/asof/AsOfProvider.d.ts +7 -0
  4. package/dist/bigconsole/asof/AsOfProvider.js +74 -52
  5. package/dist/bigconsole/asof/index.d.ts +1 -1
  6. package/dist/bigconsole/asof/index.js +4 -4
  7. package/dist/bigconsole/compare/compareEngine.d.ts +104 -0
  8. package/dist/bigconsole/compare/compareEngine.js +172 -0
  9. package/dist/bigconsole/compare/compareParam.d.ts +9 -0
  10. package/dist/bigconsole/compare/compareParam.js +13 -0
  11. package/dist/bigconsole/compare/compareSide.d.ts +5 -0
  12. package/dist/bigconsole/compare/compareSide.js +39 -0
  13. package/dist/bigconsole/compare/index.d.ts +3 -0
  14. package/dist/bigconsole/components/widgets/FilterNotAppliedNotice.d.ts +15 -0
  15. package/dist/bigconsole/components/widgets/FilterNotAppliedNotice.js +62 -0
  16. package/dist/bigconsole/components/widgets/WidgetCompareView.d.ts +12 -0
  17. package/dist/bigconsole/components/widgets/WidgetCompareView.js +215 -0
  18. package/dist/bigconsole/components/widgets/WidgetWrapper.js +380 -329
  19. package/dist/bigconsole/components/widgets/chart/ChartWidget.js +131 -126
  20. package/dist/bigconsole/components/widgets/chart/chartRows.d.ts +16 -0
  21. package/dist/bigconsole/components/widgets/chart/chartRows.js +33 -1
  22. package/dist/bigconsole/components/widgets/metric-card/MetricCardWidget.d.ts +2 -20
  23. package/dist/bigconsole/components/widgets/metric-card/MetricCardWidget.js +48 -148
  24. package/dist/bigconsole/components/widgets/metric-card/metricCardData.d.ts +48 -0
  25. package/dist/bigconsole/components/widgets/metric-card/metricCardData.js +96 -0
  26. package/dist/bigconsole/components/widgets/metric-card/metricData.d.ts +30 -0
  27. package/dist/bigconsole/components/widgets/metric-card/metricData.js +46 -0
  28. package/dist/bigconsole/components/widgets/table/TableCell.d.ts +2 -1
  29. package/dist/bigconsole/components/widgets/table/TableCell.js +1 -1
  30. package/dist/bigconsole/components/widgets/table/TableWidget.js +142 -168
  31. package/dist/bigconsole/components/widgets/table/tableRows.d.ts +17 -0
  32. package/dist/bigconsole/components/widgets/table/tableRows.js +35 -0
  33. package/dist/bigconsole/hooks/index.d.ts +1 -0
  34. package/dist/bigconsole/hooks/index.js +25 -24
  35. package/dist/bigconsole/hooks/useWidgetCompareData.d.ts +8 -0
  36. package/dist/bigconsole/hooks/useWidgetCompareData.js +24 -0
  37. package/dist/bigconsole/utils/applyGlobalFilters.d.ts +3 -1
  38. package/dist/bigconsole/utils/applyGlobalFilters.js +53 -4
  39. package/dist/bigconsole/utils/globalFilterMatching.d.ts +21 -3
  40. package/dist/bigconsole/utils/globalFilterMatching.js +14 -9
  41. package/dist/bigconsole/utils/widgetDisplayData.d.ts +10 -0
  42. package/dist/bigconsole/utils/widgetDisplayData.js +8 -1
  43. package/package.json +1 -1
@@ -0,0 +1,9 @@
1
+ export declare const COMPARE_PARAM = "compareTo";
2
+ /** The word for "live data" in the URL. */
3
+ export declare const COMPARE_NOW = "now";
4
+ /** What the board is compared with: live data, or the data at a past time. */
5
+ export type CompareTarget = 'now' | Date;
6
+ /** The compare target in a `compareTo` URL value, or null when it is not a valid one after `asOf`. */
7
+ export declare function parseCompareTarget(value: string | null | undefined, asOf: Date | null, now?: Date): CompareTarget | null;
8
+ /** The URL value for a compare target. */
9
+ export declare function formatCompareTarget(target: CompareTarget): string;
@@ -0,0 +1,13 @@
1
+ import { formatAsOf as e, parseAsOf as t } from "../asof/asOfParam.js";
2
+ // src/bigconsole/compare/compareParam.ts
3
+ var n = "compareTo";
4
+ function r(e, n, r = /* @__PURE__ */ new Date()) {
5
+ if (!n || !e) return null;
6
+ if (e === "now") return "now";
7
+ let i = t(e, r);
8
+ return i && i.getTime() > n.getTime() ? i : null;
9
+ }
10
+ function i(t) {
11
+ return t === "now" ? "now" : e(t);
12
+ }
13
+ export { n as COMPARE_PARAM, i as formatCompareTarget, r as parseCompareTarget };
@@ -0,0 +1,5 @@
1
+ import { WidgetData } from '../types';
2
+ import { CompareSide } from './compareEngine';
3
+ export declare function readCompareSide(fetched: WidgetData | null | undefined, config: Record<string, unknown> | undefined,
4
+ /** Narrows the rows the way the board's active filters do. */
5
+ narrow?: (data: unknown) => unknown): CompareSide;
@@ -0,0 +1,39 @@
1
+ import { unwrapRows as e } from "../components/widgets/utils/inferFields.js";
2
+ import { resolveWidgetDataPath as t, resolveWidgetDisplayData as n } from "../utils/widgetDisplayData.js";
3
+ // src/bigconsole/compare/compareSide.ts
4
+ function r(e) {
5
+ let t = e?.dataKey ?? e?.dataPath ?? e?.seriesPath;
6
+ return typeof t == "string" && t.trim() !== "" ? t : null;
7
+ }
8
+ var i = (e) => Array.isArray(e) && e.length === 0;
9
+ function a(t, n) {
10
+ if (t.error) return !1;
11
+ let a = t.processed;
12
+ if (typeof a == "string") try {
13
+ a = JSON.parse(a);
14
+ } catch {
15
+ return !1;
16
+ }
17
+ if (i(a)) return !0;
18
+ let o = r(n);
19
+ return o && i(o.split(".").reduce((e, t) => e && typeof e == "object" ? e[t] : void 0, a)) ? !0 : i(e(a));
20
+ }
21
+ function o(e, r, i) {
22
+ if (!e || e.asOf?.historyAvailable === !1) return { available: !1 };
23
+ let { data: o } = n({
24
+ fetched: e,
25
+ config: r,
26
+ allowSamples: !1,
27
+ asOf: !0
28
+ });
29
+ if (o === null) return a(e, r) ? {
30
+ available: !0,
31
+ data: []
32
+ } : { available: !1 };
33
+ let s = t(o, r);
34
+ return {
35
+ available: !0,
36
+ data: i ? i(s) : s
37
+ };
38
+ }
39
+ export { o as readCompareSide };
@@ -0,0 +1,3 @@
1
+ export * from './compareEngine';
2
+ export * from './compareParam';
3
+ export * from './compareSide';
@@ -0,0 +1,15 @@
1
+ import { FC } from 'react';
2
+ import { InapplicableFilter } from '../../utils/globalFilterMatching';
3
+ type Translate = (key: string, defaultValue?: string, vars?: Record<string, string | number>) => string;
4
+ interface FilterNotAppliedNoticeProps {
5
+ filters: readonly InapplicableFilter[];
6
+ t: Translate;
7
+ /** Start expanded (tests and server rendering); viewers start collapsed. */
8
+ defaultExpanded?: boolean;
9
+ }
10
+ /** The full sentence explaining why one filter does not narrow the widget. */
11
+ export declare function filterNotAppliedReason(filter: InapplicableFilter, t: Translate): string;
12
+ /** The one-line summary shown while the notice is collapsed. */
13
+ export declare function filterNotAppliedSummary(filters: readonly InapplicableFilter[], t: Translate): string;
14
+ export declare const FilterNotAppliedNotice: FC<FilterNotAppliedNoticeProps>;
15
+ export {};
@@ -0,0 +1,62 @@
1
+ import { useId as e, useState as t } from "react";
2
+ import { ChevronDown as n, FilterX as r } from "lucide-react";
3
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
4
+ // src/bigconsole/components/widgets/FilterNotAppliedNotice.tsx
5
+ function o(e, t) {
6
+ let n = {
7
+ name: e.name,
8
+ field: e.field
9
+ };
10
+ return e.reason === "precomputedValue" ? t("bigconsole.widget.filterNotApplicablePrecomputed", "Filter '{{name}}' does not change this value: it is a precomputed figure, not calculated from rows.", n) : t("bigconsole.widget.filterNotApplicable", "Filter '{{name}}' does not apply to this widget (no field '{{field}}').", n);
11
+ }
12
+ function s(e, t) {
13
+ return e.length === 1 ? t("bigconsole.widget.filterNotAppliedSummary", "Filter '{{name}}' not applied", { name: e[0].name }) : t("bigconsole.widget.filterNotAppliedSummaryMany", "{{count}} filters not applied", { count: e.length });
14
+ }
15
+ var c = ({ filters: c, t: l, defaultExpanded: u = !1 }) => {
16
+ let [d, f] = t(u), p = e();
17
+ if (c.length === 0) return null;
18
+ let m = c.map((e) => ({
19
+ id: e.filterId,
20
+ text: o(e, l)
21
+ })), h = m.map((e) => e.text).join("\n");
22
+ return /* @__PURE__ */ a("div", {
23
+ role: "status",
24
+ "data-testid": "widget-filter-not-applicable",
25
+ className: "mx-3 mt-2 min-w-0 shrink-0 rounded bg-status-warning-bg-subtle text-xs text-status-warning-text",
26
+ children: [/* @__PURE__ */ a("button", {
27
+ type: "button",
28
+ "data-testid": "widget-filter-not-applicable-toggle",
29
+ "aria-expanded": d,
30
+ "aria-controls": p,
31
+ title: h,
32
+ onClick: (e) => {
33
+ e.stopPropagation(), f((e) => !e);
34
+ },
35
+ className: "flex w-full min-w-0 items-center gap-1.5 px-2 py-1 text-left",
36
+ children: [
37
+ /* @__PURE__ */ i(r, {
38
+ className: "h-icon-xs w-icon-xs shrink-0",
39
+ "aria-hidden": "true"
40
+ }),
41
+ /* @__PURE__ */ i("span", {
42
+ className: "min-w-0 flex-1 truncate",
43
+ children: s(c, l)
44
+ }),
45
+ /* @__PURE__ */ i(n, {
46
+ className: `h-icon-xs w-icon-xs shrink-0 transition-transform ${d ? "rotate-180" : ""}`,
47
+ "aria-hidden": "true"
48
+ })
49
+ ]
50
+ }), d ? /* @__PURE__ */ i("ul", {
51
+ id: p,
52
+ "data-testid": "widget-filter-not-applicable-details",
53
+ className: "space-y-0.5 px-2 pb-1",
54
+ children: m.map((e) => /* @__PURE__ */ i("li", { children: e.text }, e.id))
55
+ }) : /* @__PURE__ */ i("span", {
56
+ id: p,
57
+ className: "sr-only",
58
+ children: h
59
+ })]
60
+ });
61
+ };
62
+ export { c as FilterNotAppliedNotice, o as filterNotAppliedReason, s as filterNotAppliedSummary };
@@ -0,0 +1,12 @@
1
+ import { FC } from 'react';
2
+ import { CompareResult } from '../../compare';
3
+ export interface WidgetCompareViewProps {
4
+ result: CompareResult;
5
+ /** The earlier time, as text. */
6
+ fromLabel: string;
7
+ /** The later time, as text. */
8
+ toLabel: string;
9
+ /** The widget's saved config; a metric card is formatted with it, as the card itself is. */
10
+ config?: Record<string, unknown>;
11
+ }
12
+ export declare const WidgetCompareView: FC<WidgetCompareViewProps>;
@@ -0,0 +1,215 @@
1
+ import { formatValue as e, resolveFormat as t } from "./metric-card/metricData.js";
2
+ import { formatValue as n } from "./table/TableCell.js";
3
+ import { buildCellFormats as r, tableColumnHeader as i } from "./table/tableRows.js";
4
+ import { memo as a } from "react";
5
+ import { ArrowDown as o, ArrowRight as s, ArrowUp as c } from "lucide-react";
6
+ import { EmptyState as l, ResponsiveTable as u } from "@burdenoff/fe-libs/ui";
7
+ import { useI18n as d } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
8
+ import { jsx as f, jsxs as p } from "react/jsx-runtime";
9
+ // src/bigconsole/components/widgets/WidgetCompareView.tsx
10
+ var m = 200, h = new Intl.NumberFormat(void 0, { maximumFractionDigits: 2 }), g = (e) => e == null || e === "" ? "—" : typeof e == "number" ? h.format(e) : typeof e == "object" ? JSON.stringify(e) : String(e), _ = ({ change: e, format: t }) => {
11
+ if (e.absolute === null) return /* @__PURE__ */ f("span", {
12
+ className: "text-text-muted",
13
+ children: "—"
14
+ });
15
+ let n = e.direction === "up" ? c : e.direction === "down" ? o : s, r = e.absolute > 0 ? "+" : "";
16
+ return /* @__PURE__ */ p("span", {
17
+ className: "inline-flex items-center gap-1 whitespace-nowrap text-text-primary",
18
+ "data-direction": e.direction,
19
+ children: [
20
+ /* @__PURE__ */ f(n, {
21
+ className: "size-3.5",
22
+ "aria-hidden": "true"
23
+ }),
24
+ r,
25
+ t ? t(e.absolute) : h.format(e.absolute),
26
+ e.percent !== null && /* @__PURE__ */ p("span", {
27
+ className: "text-text-secondary",
28
+ children: [
29
+ "(",
30
+ r,
31
+ h.format(e.percent),
32
+ "%)"
33
+ ]
34
+ })
35
+ ]
36
+ });
37
+ }, v = ({ text: e }) => /* @__PURE__ */ f("div", {
38
+ "data-testid": "compare-message",
39
+ className: "flex h-full items-center justify-center",
40
+ children: /* @__PURE__ */ f(l, {
41
+ compact: !0,
42
+ icon: null,
43
+ title: e
44
+ })
45
+ }), y = a(function({ result: a, fromLabel: o, toLabel: c, config: l }) {
46
+ let { t: h } = d(), y = {
47
+ no_data_from: h("bigconsole.compare.unavailable.noDataFrom", "No data at {{date}}, so there is nothing to compare", { date: o }),
48
+ no_data_to: h("bigconsole.compare.unavailable.noDataTo", "No data at {{date}}, so there is nothing to compare", { date: c }),
49
+ unreadable_data: h("bigconsole.compare.unavailable.unreadable", "The data of this widget cannot be compared"),
50
+ duplicate_keys: h("bigconsole.compare.unavailable.duplicateKeys", "Some rows share the same label, so they cannot be matched between the two times"),
51
+ no_key_column: h("bigconsole.compare.unavailable.noKeyColumn", "This table has no column to match rows on")
52
+ };
53
+ if (a.kind === "unsupported") return /* @__PURE__ */ f(v, { text: h("bigconsole.compare.unsupported", "Compare is not available for this widget yet") });
54
+ if (a.kind === "unavailable") return /* @__PURE__ */ f(v, { text: y[a.reason] });
55
+ if (a.kind === "metric") {
56
+ let { value: n } = a, r = l ?? void 0, i = (n) => n ? e(n.value, r, t(r, n)) : "—", s = a.to ?? a.from ?? void 0;
57
+ return /* @__PURE__ */ p("div", {
58
+ className: "flex h-full flex-col justify-center gap-3 p-4",
59
+ "data-testid": "compare-metric",
60
+ children: [/* @__PURE__ */ p("div", {
61
+ className: "grid grid-cols-2 gap-4",
62
+ children: [/* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("p", {
63
+ className: "text-xs text-text-muted",
64
+ children: o
65
+ }), /* @__PURE__ */ f("p", {
66
+ className: "text-2xl font-semibold text-text-primary",
67
+ "data-testid": "compare-from",
68
+ children: i(a.from)
69
+ })] }), /* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("p", {
70
+ className: "text-xs text-text-muted",
71
+ children: c
72
+ }), /* @__PURE__ */ f("p", {
73
+ className: "text-2xl font-semibold text-text-primary",
74
+ "data-testid": "compare-to",
75
+ children: i(a.to)
76
+ })] })]
77
+ }), /* @__PURE__ */ f("p", {
78
+ className: "text-sm",
79
+ "data-testid": "compare-change",
80
+ children: /* @__PURE__ */ f(_, {
81
+ change: n.change,
82
+ format: (n) => {
83
+ let i = e(Math.abs(n), r, t(r, s));
84
+ return n < 0 ? `-${i}` : i;
85
+ }
86
+ })
87
+ })]
88
+ });
89
+ }
90
+ if (a.kind === "chart") {
91
+ let e = a.series.length > 1, t = a.points.flatMap((e) => e.values.map((t, n) => ({
92
+ label: e.label,
93
+ series: a.series[n],
94
+ value: t
95
+ }))), n = t.slice(0, m), r = [
96
+ {
97
+ key: "label",
98
+ header: h("bigconsole.compare.column.label", "Label"),
99
+ priority: "primary",
100
+ cell: (e) => /* @__PURE__ */ f("span", {
101
+ className: "text-text-primary",
102
+ children: e.label || "—"
103
+ })
104
+ },
105
+ ...e ? [{
106
+ key: "series",
107
+ header: h("bigconsole.compare.column.series", "Series"),
108
+ priority: "secondary",
109
+ cell: (e) => /* @__PURE__ */ f("span", {
110
+ className: "text-text-secondary",
111
+ children: e.series
112
+ })
113
+ }] : [],
114
+ {
115
+ key: "from",
116
+ header: o,
117
+ priority: "secondary",
118
+ cell: (e) => /* @__PURE__ */ f("span", {
119
+ className: "text-text-primary",
120
+ children: g(e.value.from)
121
+ })
122
+ },
123
+ {
124
+ key: "to",
125
+ header: c,
126
+ priority: "secondary",
127
+ cell: (e) => /* @__PURE__ */ f("span", {
128
+ className: "text-text-primary",
129
+ children: g(e.value.to)
130
+ })
131
+ },
132
+ {
133
+ key: "change",
134
+ header: h("bigconsole.compare.column.change", "Change"),
135
+ priority: "secondary",
136
+ cell: (e) => /* @__PURE__ */ f(_, { change: e.value.change })
137
+ }
138
+ ];
139
+ return /* @__PURE__ */ p("div", {
140
+ className: "h-full overflow-auto p-2",
141
+ "data-testid": "compare-chart",
142
+ children: [/* @__PURE__ */ f(u, {
143
+ columns: r,
144
+ data: n,
145
+ rowKey: (e, t) => `${e.label}-${e.series}-${t}`
146
+ }), t.length > n.length && /* @__PURE__ */ f("p", {
147
+ className: "p-2 text-xs text-text-muted",
148
+ children: h("bigconsole.compare.more", "{{count}} more rows not shown", { count: t.length - n.length })
149
+ })]
150
+ });
151
+ }
152
+ let { summary: b } = a, x = a.rows.slice(0, m), S = {
153
+ added: h("bigconsole.compare.status.added", "Added"),
154
+ removed: h("bigconsole.compare.status.removed", "Removed"),
155
+ changed: h("bigconsole.compare.status.changed", "Changed"),
156
+ unchanged: h("bigconsole.compare.status.unchanged", "Unchanged")
157
+ }, C = l?.columns, w = r(C), T = (e, t) => w[e] ? n(t, w[e]) : g(t), E = [{
158
+ key: "__status",
159
+ header: h("bigconsole.compare.column.status", "Status"),
160
+ priority: "primary",
161
+ cell: (e) => /* @__PURE__ */ f("span", {
162
+ "data-status": e.status,
163
+ children: S[e.status]
164
+ })
165
+ }, ...a.columns.map((e, t) => ({
166
+ key: e,
167
+ header: i(C, e),
168
+ priority: t === 0 ? "primary" : "secondary",
169
+ cell: (t) => {
170
+ let n = t.cells.find((t) => t.column === e);
171
+ return n ? t.status === "changed" && n.changed ? /* @__PURE__ */ p("span", {
172
+ className: "inline-flex flex-wrap items-center gap-1 text-text-primary",
173
+ children: [
174
+ /* @__PURE__ */ f("span", {
175
+ className: "text-text-muted line-through",
176
+ children: T(e, n.from)
177
+ }),
178
+ /* @__PURE__ */ f(s, {
179
+ className: "size-3",
180
+ "aria-hidden": "true"
181
+ }),
182
+ /* @__PURE__ */ f("span", { children: T(e, n.to) })
183
+ ]
184
+ }) : /* @__PURE__ */ f("span", {
185
+ className: t.status === "unchanged" ? "text-text-muted" : "text-text-primary",
186
+ children: T(e, t.status === "removed" ? n.from : n.to)
187
+ }) : null;
188
+ }
189
+ }))];
190
+ return /* @__PURE__ */ p("div", {
191
+ className: "flex h-full flex-col",
192
+ "data-testid": "compare-table",
193
+ children: [/* @__PURE__ */ f("p", {
194
+ className: "px-3 pt-2 text-xs text-text-secondary",
195
+ "data-testid": "compare-summary",
196
+ children: h("bigconsole.compare.summary", "{{added}} added, {{removed}} removed, {{changed}} changed, {{unchanged}} unchanged", {
197
+ added: b.added,
198
+ removed: b.removed,
199
+ changed: b.changed,
200
+ unchanged: b.unchanged
201
+ })
202
+ }), /* @__PURE__ */ p("div", {
203
+ className: "min-h-0 flex-1 overflow-auto p-2",
204
+ children: [/* @__PURE__ */ f(u, {
205
+ columns: E,
206
+ data: x,
207
+ rowKey: (e) => e.key
208
+ }), a.rows.length > x.length && /* @__PURE__ */ f("p", {
209
+ className: "p-2 text-xs text-text-muted",
210
+ children: h("bigconsole.compare.more", "{{count}} more rows not shown", { count: a.rows.length - x.length })
211
+ })]
212
+ })]
213
+ });
214
+ });
215
+ export { y as WidgetCompareView };