@dashspec/renderer 0.1.39 → 0.1.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/{chunk-UL6VRMFZ.js → chunk-YOCDUP7X.js} +2 -2
- package/dist/{chunk-UL6VRMFZ.js.map → chunk-YOCDUP7X.js.map} +1 -1
- package/dist/{core-B6Up94OI.d.ts → core-DE2SVeij.d.ts} +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +1 -1
- package/dist/index.d.ts +57 -15
- package/dist/index.js +285 -258
- package/dist/index.js.map +1 -1
- package/docs/theming.md +57 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -116,7 +116,7 @@ import {
|
|
|
116
116
|
translator,
|
|
117
117
|
validateDocument,
|
|
118
118
|
widgetChecks
|
|
119
|
-
} from "./chunk-
|
|
119
|
+
} from "./chunk-YOCDUP7X.js";
|
|
120
120
|
import {
|
|
121
121
|
createStateProxy,
|
|
122
122
|
getPath,
|
|
@@ -131,9 +131,9 @@ import {
|
|
|
131
131
|
import { createContext, useCallback, useContext, useRef, useSyncExternalStore } from "react";
|
|
132
132
|
var DashboardContext = createContext(null);
|
|
133
133
|
function useDashboard() {
|
|
134
|
-
const
|
|
135
|
-
if (!
|
|
136
|
-
return
|
|
134
|
+
const v2 = useContext(DashboardContext);
|
|
135
|
+
if (!v2) throw new Error("DashSpec components must be inside <DashboardRenderer>");
|
|
136
|
+
return v2;
|
|
137
137
|
}
|
|
138
138
|
function shallowEqual(a, b) {
|
|
139
139
|
if (Object.is(a, b)) return true;
|
|
@@ -323,7 +323,7 @@ function createActionRunner(deps) {
|
|
|
323
323
|
drill: drillValues(tree, event?.panel)
|
|
324
324
|
});
|
|
325
325
|
};
|
|
326
|
-
const fill = (
|
|
326
|
+
const fill = (v2, event) => resolve(v2, scopeFor(event));
|
|
327
327
|
const go = (to, opts) => {
|
|
328
328
|
const href = safeLink(to);
|
|
329
329
|
if (href === void 0) {
|
|
@@ -352,13 +352,13 @@ function createActionRunner(deps) {
|
|
|
352
352
|
}
|
|
353
353
|
async function runCallback(code, event, key, mode) {
|
|
354
354
|
if (mode === "latest") runs.get(key)?.ctrl.abort();
|
|
355
|
-
const
|
|
355
|
+
const token2 = {};
|
|
356
356
|
const ctrl = new AbortController();
|
|
357
|
-
runs.set(key, { token, ctrl });
|
|
357
|
+
runs.set(key, { token: token2, ctrl });
|
|
358
358
|
const state = createStateProxy({
|
|
359
359
|
read: deps.getTree,
|
|
360
360
|
write: (path, value) => deps.dispatch(stateActions.set({ path, value })),
|
|
361
|
-
isCancelled: () => mode === "latest" && runs.get(key)?.token !==
|
|
361
|
+
isCancelled: () => mode === "latest" && runs.get(key)?.token !== token2
|
|
362
362
|
});
|
|
363
363
|
try {
|
|
364
364
|
await deps.scripts.callback(code, event ?? {}, state, api(ctrl.signal));
|
|
@@ -371,7 +371,7 @@ function createActionRunner(deps) {
|
|
|
371
371
|
});
|
|
372
372
|
deps.hooks.toast?.(e.message, "bad");
|
|
373
373
|
} finally {
|
|
374
|
-
if (runs.get(key)?.token ===
|
|
374
|
+
if (runs.get(key)?.token === token2) runs.delete(key);
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
377
|
async function runAction(a, event, key, mode) {
|
|
@@ -672,10 +672,10 @@ async function pool(items, limit, fn) {
|
|
|
672
672
|
await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
|
|
673
673
|
return out;
|
|
674
674
|
}
|
|
675
|
-
function strings(
|
|
676
|
-
if (typeof
|
|
677
|
-
else if (Array.isArray(
|
|
678
|
-
else if (
|
|
675
|
+
function strings(v2, out = []) {
|
|
676
|
+
if (typeof v2 === "string") out.push(v2);
|
|
677
|
+
else if (Array.isArray(v2)) for (const x of v2) strings(x, out);
|
|
678
|
+
else if (v2 && typeof v2 === "object") for (const x of Object.values(v2)) strings(x, out);
|
|
679
679
|
return out;
|
|
680
680
|
}
|
|
681
681
|
function pollInterval(every) {
|
|
@@ -688,7 +688,7 @@ function pollInterval(every) {
|
|
|
688
688
|
}
|
|
689
689
|
return ms > 0 ? Math.max(1e3, ms) : void 0;
|
|
690
690
|
}
|
|
691
|
-
var isObjLike = (
|
|
691
|
+
var isObjLike = (v2) => v2 !== null && typeof v2 === "object";
|
|
692
692
|
function createDataEngine(deps) {
|
|
693
693
|
const { datasources: defs, http } = deps;
|
|
694
694
|
const now = deps.now ?? Date.now;
|
|
@@ -1003,8 +1003,8 @@ function createDataEngine(deps) {
|
|
|
1003
1003
|
}
|
|
1004
1004
|
if (ds.type === "host") {
|
|
1005
1005
|
const key = ds.key;
|
|
1006
|
-
const
|
|
1007
|
-
if (cur?.data !==
|
|
1006
|
+
const v2 = hostData && Object.hasOwn(hostData, key) ? hostData[key] : void 0;
|
|
1007
|
+
if (cur?.data !== v2) deps.dispatch(dataActions.success({ id, key: "host", data: v2, at: now() }));
|
|
1008
1008
|
return;
|
|
1009
1009
|
}
|
|
1010
1010
|
if (typeof ds.enabled === "string") {
|
|
@@ -1193,9 +1193,9 @@ function presetRange(preset, t) {
|
|
|
1193
1193
|
return r(addDays(today, -6), today);
|
|
1194
1194
|
}
|
|
1195
1195
|
}
|
|
1196
|
-
function initialFilterValue(
|
|
1197
|
-
const kind =
|
|
1198
|
-
const raw = fromUrl !== void 0 ? fromUrl :
|
|
1196
|
+
function initialFilterValue(v2, t, fromUrl) {
|
|
1197
|
+
const kind = v2.kind;
|
|
1198
|
+
const raw = fromUrl !== void 0 ? fromUrl : v2.default;
|
|
1199
1199
|
switch (kind) {
|
|
1200
1200
|
case "DateRange":
|
|
1201
1201
|
if (typeof raw === "string") return presetRange(raw, t);
|
|
@@ -1210,13 +1210,13 @@ function initialFilterValue(v, t, fromUrl) {
|
|
|
1210
1210
|
case "Search":
|
|
1211
1211
|
return typeof raw === "string" ? raw : "";
|
|
1212
1212
|
case "Chips":
|
|
1213
|
-
return raw ?? (
|
|
1213
|
+
return raw ?? (v2.multiple ? [] : null);
|
|
1214
1214
|
default:
|
|
1215
1215
|
return raw ?? null;
|
|
1216
1216
|
}
|
|
1217
1217
|
}
|
|
1218
1218
|
function initialFilters(variables, t, url = {}) {
|
|
1219
|
-
return Object.fromEntries(variables.map((
|
|
1219
|
+
return Object.fromEntries(variables.map((v2) => [v2.name, initialFilterValue(v2, t, url[v2.name])]));
|
|
1220
1220
|
}
|
|
1221
1221
|
|
|
1222
1222
|
// src/runtime/index.ts
|
|
@@ -1243,7 +1243,7 @@ function pickRunner(o) {
|
|
|
1243
1243
|
}
|
|
1244
1244
|
function timeSettingsFor(doc, time = {}) {
|
|
1245
1245
|
const d = doc.spec.display ?? {};
|
|
1246
|
-
const own = Object.fromEntries(Object.entries(time).filter(([,
|
|
1246
|
+
const own = Object.fromEntries(Object.entries(time).filter(([, v2]) => v2 !== void 0));
|
|
1247
1247
|
return {
|
|
1248
1248
|
...d.timeZone ? { timeZone: d.timeZone } : {},
|
|
1249
1249
|
...d.dayStartsAt ? { dayStartsAt: d.dayStartsAt } : {},
|
|
@@ -1341,14 +1341,14 @@ function createDashboardRuntime(doc, options = {}) {
|
|
|
1341
1341
|
hooks: options.hooks ?? {}
|
|
1342
1342
|
});
|
|
1343
1343
|
const optionSources = (doc.spec.variables ?? []).map(
|
|
1344
|
-
(
|
|
1344
|
+
(v2) => v2.options && typeof v2.options === "object" && !Array.isArray(v2.options) ? v2.options.source : void 0
|
|
1345
1345
|
).filter((s) => typeof s === "string");
|
|
1346
1346
|
engine.want(optionSources);
|
|
1347
|
-
const variableDefs = new Map((doc.spec.variables ?? []).map((
|
|
1347
|
+
const variableDefs = new Map((doc.spec.variables ?? []).map((v2) => [v2.name, v2]));
|
|
1348
1348
|
const dependents = /* @__PURE__ */ new Map();
|
|
1349
|
-
for (const
|
|
1350
|
-
for (const parent of
|
|
1351
|
-
dependents.set(parent, [...dependents.get(parent) ?? [],
|
|
1349
|
+
for (const v2 of variableDefs.values())
|
|
1350
|
+
for (const parent of v2.dependsOn ?? [])
|
|
1351
|
+
dependents.set(parent, [...dependents.get(parent) ?? [], v2.name]);
|
|
1352
1352
|
let offFilters = null;
|
|
1353
1353
|
let loadedOnce = false;
|
|
1354
1354
|
const watches = [
|
|
@@ -1577,14 +1577,14 @@ var dark = {
|
|
|
1577
1577
|
var defaultTheme = { name: "default", mode: "auto", scale, light, dark };
|
|
1578
1578
|
|
|
1579
1579
|
// src/theme/createTheme.ts
|
|
1580
|
-
var isObject = (
|
|
1580
|
+
var isObject = (v2) => typeof v2 === "object" && v2 !== null && !Array.isArray(v2);
|
|
1581
1581
|
function mergeDeep(base, patch) {
|
|
1582
1582
|
if (patch === void 0) return base;
|
|
1583
1583
|
if (!isObject(base) || !isObject(patch)) return patch;
|
|
1584
1584
|
const out = { ...base };
|
|
1585
|
-
for (const [k,
|
|
1586
|
-
if (
|
|
1587
|
-
out[k] = mergeDeep(base[k],
|
|
1585
|
+
for (const [k, v2] of Object.entries(patch)) {
|
|
1586
|
+
if (v2 === void 0) continue;
|
|
1587
|
+
out[k] = mergeDeep(base[k], v2);
|
|
1588
1588
|
}
|
|
1589
1589
|
return out;
|
|
1590
1590
|
}
|
|
@@ -1599,7 +1599,11 @@ function shortcutColors(c) {
|
|
|
1599
1599
|
...c.series ? { chart: { series: c.series } } : {}
|
|
1600
1600
|
};
|
|
1601
1601
|
}
|
|
1602
|
-
function createTheme(input = {}) {
|
|
1602
|
+
function createTheme(input = {}, start) {
|
|
1603
|
+
if (typeof input === "function") {
|
|
1604
|
+
const from = start ?? defaultTheme;
|
|
1605
|
+
return createTheme({ extends: from, ...input(from) });
|
|
1606
|
+
}
|
|
1603
1607
|
const base = input.extends ?? defaultTheme;
|
|
1604
1608
|
const shortcut = input.colors ? shortcutColors(input.colors) : void 0;
|
|
1605
1609
|
let scale2 = mergeDeep(base.scale, input.scale);
|
|
@@ -1758,9 +1762,9 @@ function cssRulesToString(rules, unsafe) {
|
|
|
1758
1762
|
for (const [selector, decl2] of Object.entries(rules)) {
|
|
1759
1763
|
if (!decl2 || typeof decl2 !== "object" || /[{};<>]/.test(selector)) continue;
|
|
1760
1764
|
const sel = selector.includes("&") ? selector : `& ${selector}`;
|
|
1761
|
-
const body = Object.entries(decl2).filter(([,
|
|
1765
|
+
const body = Object.entries(decl2).filter(([, v2]) => (typeof v2 === "string" || typeof v2 === "number") && !unsafe.test(String(v2))).map(([k, v2]) => {
|
|
1762
1766
|
const prop = k.startsWith("--") ? k : k.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
|
|
1763
|
-
const val = typeof
|
|
1767
|
+
const val = typeof v2 === "number" && v2 !== 0 && !k.startsWith("--") && !UNITLESS.has(k) ? `${v2}px` : String(v2);
|
|
1764
1768
|
return `${prop}: ${val};`;
|
|
1765
1769
|
}).join(" ");
|
|
1766
1770
|
if (body) out.push(`${sel} { ${body} }`);
|
|
@@ -1772,9 +1776,9 @@ function cssRulesToString(rules, unsafe) {
|
|
|
1772
1776
|
var kebab = (s) => s.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
|
|
1773
1777
|
function flatten(prefix, value, out, unit = "") {
|
|
1774
1778
|
if (Array.isArray(value)) {
|
|
1775
|
-
value.forEach((
|
|
1779
|
+
value.forEach((v2, i) => flatten(`${prefix}-${i + 1}`, v2, out, unit));
|
|
1776
1780
|
} else if (typeof value === "object" && value !== null) {
|
|
1777
|
-
for (const [k,
|
|
1781
|
+
for (const [k, v2] of Object.entries(value)) flatten(`${prefix}-${kebab(k)}`, v2, out, unit);
|
|
1778
1782
|
} else if (value !== void 0) {
|
|
1779
1783
|
out[prefix] = typeof value === "number" && unit ? `${value}${unit}` : String(value);
|
|
1780
1784
|
}
|
|
@@ -1793,7 +1797,7 @@ function themeCssVars(theme, mode) {
|
|
|
1793
1797
|
out["--ds-color-surface-table-header"] ??= c.surface.sunken;
|
|
1794
1798
|
const density = Object.hasOwn(DENSITY, s.density) ? s.density : "comfortable";
|
|
1795
1799
|
const d = DENSITY[density];
|
|
1796
|
-
const space = Object.fromEntries(Object.entries(s.space).map(([k,
|
|
1800
|
+
const space = Object.fromEntries(Object.entries(s.space).map(([k, v2]) => [k, Math.round(v2 * d.space)]));
|
|
1797
1801
|
flatten("--ds-space", space, out, "px");
|
|
1798
1802
|
out["--ds-control-height"] = `${d.control}px`;
|
|
1799
1803
|
out["--ds-density"] = density;
|
|
@@ -1851,62 +1855,70 @@ var UNSAFE_CSS = /[;{}<>\r\n\f\\]/;
|
|
|
1851
1855
|
var SAFE_NAME = /^--[\w-]+$/;
|
|
1852
1856
|
function themeStylesheet(theme, selector = ".ds-root") {
|
|
1853
1857
|
const block = (sel, vars) => `${sel} {
|
|
1854
|
-
${Object.entries(vars).filter(([k,
|
|
1858
|
+
${Object.entries(vars).filter(([k, v2]) => SAFE_NAME.test(k) && !UNSAFE_CSS.test(v2)).map(([k, v2]) => ` ${k}: ${v2};`).join("\n")}
|
|
1855
1859
|
}`;
|
|
1856
1860
|
return [
|
|
1857
1861
|
block(selector, themeCssVars(theme, "light")),
|
|
1858
1862
|
block(`${selector}[data-ds-theme="dark"]`, themeCssVars(theme, "dark"))
|
|
1859
1863
|
].join("\n\n");
|
|
1860
1864
|
}
|
|
1861
|
-
function widgetThemeCss(theme, scope2) {
|
|
1865
|
+
function widgetThemeCss(theme, scope2, mode = "light") {
|
|
1862
1866
|
const out = [];
|
|
1863
1867
|
for (const [kind, w] of Object.entries(theme.widgets ?? {})) {
|
|
1864
1868
|
const m = /^([A-Za-z][\w.-]*)(?::([A-Za-z][\w-]*))?$/.exec(kind);
|
|
1865
1869
|
if (!m || !w) continue;
|
|
1866
1870
|
const sel = `${scope2} .ds-panel[data-kind="${m[1]}"]${m[2] ? `[data-variant="${m[2]}"]` : ""}`;
|
|
1867
|
-
const vars = Object.entries(w.vars ?? {}).filter(([k,
|
|
1868
|
-
if (vars.length) out.push(`${sel} { ${vars.map(([k,
|
|
1871
|
+
const vars = Object.entries(w.vars ?? {}).filter(([k, v2]) => SAFE_NAME.test(k) && !UNSAFE_CSS.test(String(v2)));
|
|
1872
|
+
if (vars.length) out.push(`${sel} { ${vars.map(([k, v2]) => `${k}: ${v2};`).join(" ")} }`);
|
|
1869
1873
|
const css = typeof w.css === "object" && w.css !== null ? cssRulesToString(w.css, UNSAFE_CSS) : w.css;
|
|
1870
1874
|
if (typeof css === "string" && css && !/<\/?\s*style/i.test(css))
|
|
1871
1875
|
out.push(css.includes("&") ? css.replaceAll("&", sel) : `${sel} { ${css} }`);
|
|
1876
|
+
if (mode === "dark" && w.dark) {
|
|
1877
|
+
const dv = Object.entries(w.dark.vars ?? {}).filter(([k, v2]) => SAFE_NAME.test(k) && !UNSAFE_CSS.test(String(v2)));
|
|
1878
|
+
if (dv.length) out.push(`${sel} { ${dv.map(([k, v2]) => `${k}: ${v2};`).join(" ")} }`);
|
|
1879
|
+
const dc = typeof w.dark.css === "object" && w.dark.css !== null ? cssRulesToString(w.dark.css, UNSAFE_CSS) : w.dark.css;
|
|
1880
|
+
if (typeof dc === "string" && dc && !/<\/?\s*style/i.test(dc))
|
|
1881
|
+
out.push(dc.includes("&") ? dc.replaceAll("&", sel) : `${sel} { ${dc} }`);
|
|
1882
|
+
}
|
|
1872
1883
|
}
|
|
1873
1884
|
return out.join("\n");
|
|
1874
1885
|
}
|
|
1875
1886
|
|
|
1876
1887
|
// src/theme/parts.ts
|
|
1877
1888
|
var SAFE = /^[^;{}<>\\\n\r]*$/;
|
|
1878
|
-
var ok = (
|
|
1879
|
-
var px = (
|
|
1889
|
+
var ok = (v2) => typeof v2 === "number" && Number.isFinite(v2) || typeof v2 === "string" && SAFE.test(v2);
|
|
1890
|
+
var px = (v2) => v2 === void 0 ? void 0 : `${v2}px`;
|
|
1880
1891
|
function decl(map) {
|
|
1881
|
-
return Object.entries(map).filter(([,
|
|
1892
|
+
return Object.entries(map).filter(([, v2]) => v2 !== void 0 && ok(v2)).map(([k, v2]) => `${k}: ${v2};`).join(" ");
|
|
1882
1893
|
}
|
|
1883
|
-
function text(t) {
|
|
1894
|
+
function text(t, c) {
|
|
1884
1895
|
if (!t) return "";
|
|
1885
1896
|
return decl({
|
|
1886
1897
|
"font-family": t.font && ["heading", "body", "data"].includes(t.font) ? `var(--ds-font-${t.font})` : void 0,
|
|
1887
1898
|
"font-size": px(t.size),
|
|
1888
1899
|
"font-weight": t.weight,
|
|
1889
1900
|
"line-height": px(t.lineHeight),
|
|
1890
|
-
color: t.color,
|
|
1901
|
+
color: c(t.color),
|
|
1891
1902
|
"margin-top": px(t.marginTop),
|
|
1892
1903
|
padding: t.padding
|
|
1893
1904
|
});
|
|
1894
1905
|
}
|
|
1895
|
-
function partsCss(theme, scope2) {
|
|
1906
|
+
function partsCss(theme, scope2, mode = "light") {
|
|
1896
1907
|
const p = theme.scale.parts;
|
|
1897
1908
|
if (!p) return "";
|
|
1909
|
+
const c = (v2) => v2 === void 0 || typeof v2 === "string" ? v2 : v2[mode];
|
|
1898
1910
|
const rules = [
|
|
1899
|
-
[".ds-panel-title", text(p.title)],
|
|
1900
|
-
[".ds-panel-subtitle", text(p.subtitle)],
|
|
1901
|
-
[".ds-panel-meta, .ds-live, .ds-chart-legend, .ds-pager, .ds-kpi-foot, .ds-legend", text(p.meta)],
|
|
1902
|
-
[".ds-info", decl({ "font-size": px(p.info?.size), color: p.info?.color })],
|
|
1903
|
-
[".ds-kpi-label, .ds-tile-label", text(p.label)],
|
|
1904
|
-
[".ds-kpi-value, .ds-tile-value", `${text(p.value)}${p.value ? " letter-spacing: 0;" : ""}`],
|
|
1905
|
-
[".ds-kpi-unit", text(p.unit)],
|
|
1906
|
-
[".ds-kpi-note, .ds-kpi-sub, .ds-tile-caption", text(p.caption)],
|
|
1907
|
-
[".ds-state, .ds-kpi-empty", text(p.empty)],
|
|
1908
|
-
[".ds-table th", text(p.tableHead)],
|
|
1909
|
-
[".ds-table td", text(p.tableCell)],
|
|
1911
|
+
[".ds-panel-title", text(p.title, c)],
|
|
1912
|
+
[".ds-panel-subtitle", text(p.subtitle, c)],
|
|
1913
|
+
[".ds-panel-meta, .ds-live, .ds-chart-legend, .ds-pager, .ds-kpi-foot, .ds-legend", text(p.meta, c)],
|
|
1914
|
+
[".ds-info", decl({ "font-size": px(p.info?.size), color: c(p.info?.color) })],
|
|
1915
|
+
[".ds-kpi-label, .ds-tile-label", text(p.label, c)],
|
|
1916
|
+
[".ds-kpi-value, .ds-tile-value", `${text(p.value, c)}${p.value ? " letter-spacing: 0;" : ""}`],
|
|
1917
|
+
[".ds-kpi-unit", text(p.unit, c)],
|
|
1918
|
+
[".ds-kpi-note, .ds-kpi-sub, .ds-tile-caption", text(p.caption, c)],
|
|
1919
|
+
[".ds-state, .ds-kpi-empty", text(p.empty, c)],
|
|
1920
|
+
[".ds-table th", text(p.tableHead, c)],
|
|
1921
|
+
[".ds-table td", text(p.tableCell, c)],
|
|
1910
1922
|
[".ds-table", p.tableCell?.font ? `font-family: var(--ds-font-${p.tableCell.font});` : ""],
|
|
1911
1923
|
[".ds-panel-head", decl({ "align-items": p.header?.align === "start" ? "flex-start" : p.header?.align })],
|
|
1912
1924
|
['.ds-panel[data-kind="Kpi"]', decl({ padding: px(p.kpiCard?.padding), "border-radius": px(p.kpiCard?.radius) })],
|
|
@@ -1924,32 +1936,32 @@ function partsCss(theme, scope2) {
|
|
|
1924
1936
|
padding: px(p.tile?.padding),
|
|
1925
1937
|
"border-radius": px(p.tile?.radius),
|
|
1926
1938
|
gap: px(p.tile?.gap),
|
|
1927
|
-
"border-color": p.tile?.border
|
|
1939
|
+
"border-color": c(p.tile?.border)
|
|
1928
1940
|
})
|
|
1929
1941
|
],
|
|
1930
1942
|
[".ds-tiles", decl({ "--ds-tiles-gap": px(p.tile?.spacing) })],
|
|
1931
|
-
[".ds-tile[data-active] .ds-tile-label", text(p.tile?.activeLabel)],
|
|
1943
|
+
[".ds-tile[data-active] .ds-tile-label", text(p.tile?.activeLabel, c)],
|
|
1932
1944
|
[
|
|
1933
1945
|
".ds-table th, .ds-table td",
|
|
1934
1946
|
decl({
|
|
1935
1947
|
padding: p.table?.cellPadding,
|
|
1936
|
-
"border-bottom-color": p.table?.rowBorder
|
|
1948
|
+
"border-bottom-color": c(p.table?.rowBorder)
|
|
1937
1949
|
})
|
|
1938
1950
|
],
|
|
1939
1951
|
[
|
|
1940
1952
|
".ds-table tfoot td",
|
|
1941
1953
|
decl({
|
|
1942
|
-
background: p.table?.footBackground,
|
|
1954
|
+
background: c(p.table?.footBackground),
|
|
1943
1955
|
"font-weight": p.table?.footWeight,
|
|
1944
1956
|
"border-top": p.table?.footBackground ? "0" : void 0
|
|
1945
1957
|
})
|
|
1946
1958
|
],
|
|
1947
|
-
[".ds-table tr[data-expanded] > td, .ds-row-detail > td", decl({ background: p.table?.openBackground })],
|
|
1959
|
+
[".ds-table tr[data-expanded] > td, .ds-row-detail > td", decl({ background: c(p.table?.openBackground) })],
|
|
1948
1960
|
[
|
|
1949
1961
|
".ds-live > span",
|
|
1950
|
-
decl({ width: px(p.liveDot?.size), height: px(p.liveDot?.size), background: p.liveDot?.color })
|
|
1962
|
+
decl({ width: px(p.liveDot?.size), height: px(p.liveDot?.size), background: c(p.liveDot?.color) })
|
|
1951
1963
|
],
|
|
1952
|
-
[".ds-live[data-stale] > span", decl({ background: p.liveDot?.staleColor })],
|
|
1964
|
+
[".ds-live[data-stale] > span", decl({ background: c(p.liveDot?.staleColor) })],
|
|
1953
1965
|
[".ds-filters", decl({ padding: p.filterBar?.padding, "border-radius": px(p.filterBar?.radius) })],
|
|
1954
1966
|
[".ds-chart-legend", decl({ gap: px(p.legend?.gap) })],
|
|
1955
1967
|
[
|
|
@@ -1987,8 +1999,8 @@ function ThemeScope({ theme, mode, className, style, children }) {
|
|
|
1987
1999
|
const scopeId = useId();
|
|
1988
2000
|
const widgetCss = useMemo(() => {
|
|
1989
2001
|
const scope2 = `[data-ds-scope="${scopeId}"]`;
|
|
1990
|
-
return [partsCss(theme, scope2), widgetThemeCss(theme, scope2)].filter(Boolean).join("\n");
|
|
1991
|
-
}, [theme, scopeId]);
|
|
2002
|
+
return [partsCss(theme, scope2, resolved), widgetThemeCss(theme, scope2, resolved)].filter(Boolean).join("\n");
|
|
2003
|
+
}, [theme, scopeId, resolved]);
|
|
1992
2004
|
return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: ctx, children: /* @__PURE__ */ jsxs(
|
|
1993
2005
|
"div",
|
|
1994
2006
|
{
|
|
@@ -2024,31 +2036,31 @@ function defineWidget(def) {
|
|
|
2024
2036
|
|
|
2025
2037
|
// src/widgets/shared/format.ts
|
|
2026
2038
|
var field = (row, path) => path === void 0 ? row : getPath(row, path);
|
|
2027
|
-
var toNumber = (
|
|
2028
|
-
if (typeof
|
|
2029
|
-
if (typeof
|
|
2039
|
+
var toNumber = (v2) => {
|
|
2040
|
+
if (typeof v2 === "number") return Number.isFinite(v2) ? v2 : void 0;
|
|
2041
|
+
if (typeof v2 === "string" && v2.trim() !== "" && !Number.isNaN(Number(v2))) return Number(v2);
|
|
2030
2042
|
return void 0;
|
|
2031
2043
|
};
|
|
2032
|
-
function formatValue(
|
|
2033
|
-
if (
|
|
2044
|
+
function formatValue(v2, h, format = "number", decimals) {
|
|
2045
|
+
if (v2 === null || v2 === void 0 || v2 === "") return "\u2013";
|
|
2034
2046
|
switch (format) {
|
|
2035
2047
|
case "text":
|
|
2036
|
-
return String(
|
|
2048
|
+
return String(v2);
|
|
2037
2049
|
case "compact":
|
|
2038
|
-
return h.fmt.compact(
|
|
2050
|
+
return h.fmt.compact(v2);
|
|
2039
2051
|
case "percent":
|
|
2040
|
-
return h.fmt.percent(
|
|
2052
|
+
return h.fmt.percent(v2, decimals ?? 0);
|
|
2041
2053
|
case "duration":
|
|
2042
|
-
return h.fmt.duration(
|
|
2054
|
+
return h.fmt.duration(v2);
|
|
2043
2055
|
case "date":
|
|
2044
|
-
return h.fmt.date(
|
|
2056
|
+
return h.fmt.date(v2, "date");
|
|
2045
2057
|
case "datetime":
|
|
2046
|
-
return h.fmt.date(
|
|
2058
|
+
return h.fmt.date(v2, "datetime");
|
|
2047
2059
|
case "time":
|
|
2048
|
-
return h.fmt.date(
|
|
2060
|
+
return h.fmt.date(v2, "time");
|
|
2049
2061
|
default: {
|
|
2050
|
-
const n = toNumber(
|
|
2051
|
-
return n === void 0 ? String(
|
|
2062
|
+
const n = toNumber(v2);
|
|
2063
|
+
return n === void 0 ? String(v2) : h.fmt.number(n, decimals);
|
|
2052
2064
|
}
|
|
2053
2065
|
}
|
|
2054
2066
|
}
|
|
@@ -2066,7 +2078,7 @@ function deepMerge(base, extra) {
|
|
|
2066
2078
|
if (!extra || typeof extra !== "object" || Array.isArray(extra)) return extra ?? base;
|
|
2067
2079
|
if (!base || typeof base !== "object" || Array.isArray(base)) return extra;
|
|
2068
2080
|
const out = { ...base };
|
|
2069
|
-
for (const [k,
|
|
2081
|
+
for (const [k, v2] of Object.entries(extra)) out[k] = k in out ? deepMerge(out[k], v2) : v2;
|
|
2070
2082
|
return out;
|
|
2071
2083
|
}
|
|
2072
2084
|
|
|
@@ -2097,7 +2109,7 @@ var Breakdown = defineWidget({
|
|
|
2097
2109
|
const t = items[i]?.tone;
|
|
2098
2110
|
return t ? `var(--ds-color-status-${t}-solid)` : `var(--ds-series-${i % 8 + 1})`;
|
|
2099
2111
|
};
|
|
2100
|
-
const fmt = (
|
|
2112
|
+
const fmt = (v2) => `${formatValue(v2, helpers, spec.format, spec.decimals)}${spec.unit ? ` ${spec.unit}` : ""}`;
|
|
2101
2113
|
const on = (i, type) => emit(type, "item", { datum: items[i]?.row, value: items[i]?.value, x: items[i]?.label, index: i });
|
|
2102
2114
|
if (spec.mode === "donut") {
|
|
2103
2115
|
let acc = 0;
|
|
@@ -2713,7 +2725,7 @@ function SelectControl({
|
|
|
2713
2725
|
{
|
|
2714
2726
|
id,
|
|
2715
2727
|
options,
|
|
2716
|
-
isSelected: (
|
|
2728
|
+
isSelected: (v2) => v2 === value,
|
|
2717
2729
|
onPick: (o) => {
|
|
2718
2730
|
onChange(o.value);
|
|
2719
2731
|
p.setOpen(false);
|
|
@@ -2786,7 +2798,7 @@ function MultiSelectControl({
|
|
|
2786
2798
|
id,
|
|
2787
2799
|
multiple: true,
|
|
2788
2800
|
options,
|
|
2789
|
-
isSelected: (
|
|
2801
|
+
isSelected: (v2) => chosen.includes(v2),
|
|
2790
2802
|
onPick: (o) => onChange(chosen.includes(o.value) ? chosen.filter((x) => x !== o.value) : [...chosen, o.value])
|
|
2791
2803
|
}
|
|
2792
2804
|
),
|
|
@@ -3088,7 +3100,7 @@ function DateControl({
|
|
|
3088
3100
|
max,
|
|
3089
3101
|
locale,
|
|
3090
3102
|
single: true,
|
|
3091
|
-
onChange: (
|
|
3103
|
+
onChange: (v2) => v2.from && onChange(v2.from)
|
|
3092
3104
|
}
|
|
3093
3105
|
);
|
|
3094
3106
|
if (!stepper) return control;
|
|
@@ -3186,9 +3198,9 @@ function ControlField({
|
|
|
3186
3198
|
const label = def.label;
|
|
3187
3199
|
const locale = runtime.doc.spec.display.locale;
|
|
3188
3200
|
const bound = (key) => {
|
|
3189
|
-
const
|
|
3190
|
-
if (typeof
|
|
3191
|
-
const r =
|
|
3201
|
+
const v2 = def[key];
|
|
3202
|
+
if (typeof v2 !== "string") return void 0;
|
|
3203
|
+
const r = v2 === "today" ? runtime.helpers.today() : interpolate(v2, rootScope(runtime.getTree(), runtime.helpers));
|
|
3192
3204
|
return typeof r === "number" ? new Date(r).toISOString().slice(0, 10) : r || void 0;
|
|
3193
3205
|
};
|
|
3194
3206
|
const [text2, setText] = useState2(typeof value === "string" ? value : "");
|
|
@@ -3203,10 +3215,10 @@ function ControlField({
|
|
|
3203
3215
|
onChange,
|
|
3204
3216
|
options,
|
|
3205
3217
|
text: text2,
|
|
3206
|
-
setText: (
|
|
3207
|
-
setText(
|
|
3218
|
+
setText: (v2) => {
|
|
3219
|
+
setText(v2);
|
|
3208
3220
|
clearTimeout(timer.current);
|
|
3209
|
-
timer.current = setTimeout(() => onChange(
|
|
3221
|
+
timer.current = setTimeout(() => onChange(v2), def.debounce ? parseDuration(def.debounce) : 300);
|
|
3210
3222
|
},
|
|
3211
3223
|
min: bound("min"),
|
|
3212
3224
|
max: bound("max"),
|
|
@@ -3245,7 +3257,7 @@ function ControlField({
|
|
|
3245
3257
|
max: bound("max"),
|
|
3246
3258
|
maxDays: def.maxDays,
|
|
3247
3259
|
locale,
|
|
3248
|
-
onChange: (
|
|
3260
|
+
onChange: (v2) => onChange(v2),
|
|
3249
3261
|
onReject: (m) => runtime.runAction({ do: "toast", message: m, tone: "warn" })
|
|
3250
3262
|
}
|
|
3251
3263
|
);
|
|
@@ -3279,7 +3291,7 @@ function ControlField({
|
|
|
3279
3291
|
case "Chips": {
|
|
3280
3292
|
const multi = Boolean(def.multiple);
|
|
3281
3293
|
const chosen = multi ? Array.isArray(value) ? value : [] : [value];
|
|
3282
|
-
const toggle = (
|
|
3294
|
+
const toggle = (v2) => multi ? onChange(chosen.includes(v2) ? chosen.filter((x) => x !== v2) : [...chosen, v2]) : onChange(value === v2 ? null : v2);
|
|
3283
3295
|
return (
|
|
3284
3296
|
// biome-ignore lint/a11y/useSemanticElements: a chip group, not a form fieldset
|
|
3285
3297
|
/* @__PURE__ */ jsx8("div", { className: "ds-chips", role: "group", "aria-label": label ?? String(def.name), children: options.map((o, k) => /* @__PURE__ */ jsxs6(
|
|
@@ -3315,8 +3327,8 @@ function ControlField({
|
|
|
3315
3327
|
onChange: (e) => {
|
|
3316
3328
|
setText(e.target.value);
|
|
3317
3329
|
clearTimeout(timer.current);
|
|
3318
|
-
const
|
|
3319
|
-
timer.current = setTimeout(() => onChange(
|
|
3330
|
+
const v2 = e.target.value;
|
|
3331
|
+
timer.current = setTimeout(() => onChange(v2), wait);
|
|
3320
3332
|
}
|
|
3321
3333
|
}
|
|
3322
3334
|
)
|
|
@@ -3448,8 +3460,8 @@ function FilterBar() {
|
|
|
3448
3460
|
filters: t.filters,
|
|
3449
3461
|
view: t.view,
|
|
3450
3462
|
visible: variables.filter(
|
|
3451
|
-
(
|
|
3452
|
-
).map((
|
|
3463
|
+
(v2) => typeof v2.visibleWhen !== "string" || Boolean(evaluateSafe(v2.visibleWhen, rootScope(t, runtime.helpers), true))
|
|
3464
|
+
).map((v2) => v2.name).join("\0")
|
|
3453
3465
|
}),
|
|
3454
3466
|
[variables, runtime]
|
|
3455
3467
|
),
|
|
@@ -3458,22 +3470,22 @@ function FilterBar() {
|
|
|
3458
3470
|
const visibleNames = new Set(state.visible.split("\0"));
|
|
3459
3471
|
const [draft, setDraft] = useState2(null);
|
|
3460
3472
|
const bar = runtime.doc.spec.display.filterBar ?? {};
|
|
3461
|
-
const applyMode = (
|
|
3462
|
-
const needsApply = variables.some((
|
|
3473
|
+
const applyMode = (v2) => v2.apply === "button" ? "button" : v2.apply === "immediate" ? "change" : bar.apply ?? "change";
|
|
3474
|
+
const needsApply = variables.some((v2) => applyMode(v2) === "button");
|
|
3463
3475
|
const defaults = () => Object.fromEntries(
|
|
3464
|
-
variables.map((
|
|
3465
|
-
|
|
3466
|
-
initialFilterValue(
|
|
3476
|
+
variables.map((v2) => [
|
|
3477
|
+
v2.name,
|
|
3478
|
+
initialFilterValue(v2, { ...runtime.doc.spec.display, now: runtime.helpers.now })
|
|
3467
3479
|
])
|
|
3468
3480
|
);
|
|
3469
3481
|
const start = defaults();
|
|
3470
|
-
const changed = (
|
|
3482
|
+
const changed = (v2) => JSON.stringify(state.filters[v2.name]) !== JSON.stringify(start[v2.name]);
|
|
3471
3483
|
const isDefault = !variables.some(changed);
|
|
3472
3484
|
const placed = new Set(
|
|
3473
3485
|
Object.values(runtime.doc.spec.panels).filter((p) => p.kind === "Filter").map((p) => p.spec?.variable)
|
|
3474
3486
|
);
|
|
3475
3487
|
const shown = variables.filter(
|
|
3476
|
-
(
|
|
3488
|
+
(v2) => !v2.hidden && !placed.has(v2.name) && visibleNames.has(v2.name)
|
|
3477
3489
|
);
|
|
3478
3490
|
if (shown.length === 0 || bar.show === false) return null;
|
|
3479
3491
|
const values = { ...state.filters, ...draft };
|
|
@@ -3483,16 +3495,16 @@ function FilterBar() {
|
|
|
3483
3495
|
const layouts = runtime.doc.spec.layouts ?? [];
|
|
3484
3496
|
const views = [];
|
|
3485
3497
|
for (const l of layouts)
|
|
3486
|
-
if (l.view && !views.some((
|
|
3487
|
-
const byName = new Map(variables.map((
|
|
3498
|
+
if (l.view && !views.some((v2) => v2.name === l.view)) views.push({ name: l.view, label: l.label ?? l.view });
|
|
3499
|
+
const byName = new Map(variables.map((v2) => [v2.name, v2]));
|
|
3488
3500
|
return /* @__PURE__ */ jsx8(
|
|
3489
3501
|
Custom,
|
|
3490
3502
|
{
|
|
3491
|
-
filters: shown.map((
|
|
3492
|
-
name:
|
|
3493
|
-
kind:
|
|
3494
|
-
...typeof
|
|
3495
|
-
config:
|
|
3503
|
+
filters: shown.map((v2) => ({
|
|
3504
|
+
name: v2.name,
|
|
3505
|
+
kind: v2.kind,
|
|
3506
|
+
...typeof v2.label === "string" ? { label: v2.label } : {},
|
|
3507
|
+
config: v2
|
|
3496
3508
|
})),
|
|
3497
3509
|
values,
|
|
3498
3510
|
setFilter: (name, value) => runtime.store.dispatch(stateActions.setFilter({ name, value })),
|
|
@@ -3536,32 +3548,32 @@ function FilterBar() {
|
|
|
3536
3548
|
/* @__PURE__ */ jsxs6(Track, { segmented: bar.look === "segmented", children: [
|
|
3537
3549
|
bar.icon !== "none" && /* @__PURE__ */ jsx8("span", { className: "ds-filters-icon", "aria-hidden": "true", children: options.ui?.icons?.filterBar ?? BAR_ICONS[bar.icon ?? "sliders"] ?? BAR_ICONS.sliders }),
|
|
3538
3550
|
shown.map(
|
|
3539
|
-
(
|
|
3551
|
+
(v2) => options.onFilterSelect ? (
|
|
3540
3552
|
// Builder: a click selects the filter to configure it instead of opening it.
|
|
3541
3553
|
/* @__PURE__ */ jsx8(
|
|
3542
3554
|
"div",
|
|
3543
3555
|
{
|
|
3544
3556
|
className: "ds-filter-pick",
|
|
3545
|
-
"data-selected": options.selectedFilter ===
|
|
3546
|
-
onPointerDownCapture: () => options.onFilterSelect?.(
|
|
3557
|
+
"data-selected": options.selectedFilter === v2.name || void 0,
|
|
3558
|
+
onPointerDownCapture: () => options.onFilterSelect?.(v2.name),
|
|
3547
3559
|
onClickCapture: (e) => {
|
|
3548
3560
|
e.preventDefault();
|
|
3549
3561
|
e.stopPropagation();
|
|
3550
3562
|
},
|
|
3551
|
-
children: /* @__PURE__ */ jsx8(ControlField, { compact: true, def:
|
|
3563
|
+
children: /* @__PURE__ */ jsx8(ControlField, { compact: true, def: v2, value: values[v2.name], onChange: () => {
|
|
3552
3564
|
} })
|
|
3553
3565
|
},
|
|
3554
|
-
|
|
3566
|
+
v2.name
|
|
3555
3567
|
)
|
|
3556
3568
|
) : /* @__PURE__ */ jsx8(
|
|
3557
3569
|
ControlField,
|
|
3558
3570
|
{
|
|
3559
3571
|
compact: true,
|
|
3560
|
-
def:
|
|
3561
|
-
value: values[
|
|
3562
|
-
onChange: (val) => set(
|
|
3572
|
+
def: v2,
|
|
3573
|
+
value: values[v2.name],
|
|
3574
|
+
onChange: (val) => set(v2.name, val, applyMode(v2) === "change")
|
|
3563
3575
|
},
|
|
3564
|
-
|
|
3576
|
+
v2.name
|
|
3565
3577
|
)
|
|
3566
3578
|
)
|
|
3567
3579
|
] }),
|
|
@@ -3677,7 +3689,7 @@ var Filter = defineWidget({
|
|
|
3677
3689
|
defaults: { variable: "" },
|
|
3678
3690
|
component: function FilterWidget({ spec, mode }) {
|
|
3679
3691
|
const { runtime } = useDashboard();
|
|
3680
|
-
const def = (runtime.doc.spec.variables ?? []).find((
|
|
3692
|
+
const def = (runtime.doc.spec.variables ?? []).find((v2) => v2.name === spec.variable);
|
|
3681
3693
|
const state = useTree(
|
|
3682
3694
|
useCallback3((t) => ({ value: t.filters[spec.variable], tree: t }), [spec.variable]),
|
|
3683
3695
|
(a, b) => a.value === b.value && a.tree.view === b.tree.view && a.tree.filters === b.tree.filters
|
|
@@ -4014,32 +4026,32 @@ function useSize() {
|
|
|
4014
4026
|
}
|
|
4015
4027
|
var DEFERRED = /(^|[^\w.$])(row|item|avg)\b/;
|
|
4016
4028
|
var DEFERRED_IN_ITEM = /(^|[^\w.$])(row|avg)\b/;
|
|
4017
|
-
function interpolateMarkdown(
|
|
4018
|
-
const bodies = placeholders(
|
|
4019
|
-
const whole = bodies.length === 1 &&
|
|
4020
|
-
const r = interpolate(
|
|
4029
|
+
function interpolateMarkdown(v2, scope2) {
|
|
4030
|
+
const bodies = placeholders(v2);
|
|
4031
|
+
const whole = bodies.length === 1 && v2.trim() === `\${${bodies[0]}}`;
|
|
4032
|
+
const r = interpolate(v2, scope2, escapeMarkdown);
|
|
4021
4033
|
if (!whole) return r;
|
|
4022
4034
|
return r === null || r === void 0 ? "" : escapeMarkdown(typeof r === "object" ? JSON.stringify(r) : String(r));
|
|
4023
4035
|
}
|
|
4024
|
-
function resolvePanel(
|
|
4036
|
+
function resolvePanel(v2, scope2, inItem = false, key) {
|
|
4025
4037
|
const deferred = inItem ? DEFERRED_IN_ITEM : DEFERRED;
|
|
4026
|
-
if (typeof
|
|
4027
|
-
if (placeholders(
|
|
4028
|
-
return key === "markdown" ? interpolateMarkdown(
|
|
4038
|
+
if (typeof v2 === "string") {
|
|
4039
|
+
if (placeholders(v2).some((b) => deferred.test(stripStrings(b)))) return v2;
|
|
4040
|
+
return key === "markdown" ? interpolateMarkdown(v2, scope2) : interpolate(v2, scope2);
|
|
4029
4041
|
}
|
|
4030
|
-
if (Array.isArray(
|
|
4031
|
-
if (
|
|
4032
|
-
return Object.fromEntries(Object.entries(
|
|
4033
|
-
return
|
|
4034
|
-
}
|
|
4035
|
-
function withFunctions(
|
|
4036
|
-
if (Array.isArray(
|
|
4037
|
-
if (
|
|
4038
|
-
const o =
|
|
4042
|
+
if (Array.isArray(v2)) return v2.map((x) => resolvePanel(x, scope2, inItem));
|
|
4043
|
+
if (v2 && typeof v2 === "object")
|
|
4044
|
+
return Object.fromEntries(Object.entries(v2).map(([k, x]) => [k, resolvePanel(x, scope2, inItem, k)]));
|
|
4045
|
+
return v2;
|
|
4046
|
+
}
|
|
4047
|
+
function withFunctions(v2, make) {
|
|
4048
|
+
if (Array.isArray(v2)) return v2.map((x) => withFunctions(x, make));
|
|
4049
|
+
if (v2 && typeof v2 === "object") {
|
|
4050
|
+
const o = v2;
|
|
4039
4051
|
if (typeof o.fn === "string" && Object.keys(o).length === 1) return make(o.fn);
|
|
4040
4052
|
return Object.fromEntries(Object.entries(o).map(([k, x]) => [k, withFunctions(x, make)]));
|
|
4041
4053
|
}
|
|
4042
|
-
return
|
|
4054
|
+
return v2;
|
|
4043
4055
|
}
|
|
4044
4056
|
var SHADOWS = {
|
|
4045
4057
|
none: "none",
|
|
@@ -4048,12 +4060,12 @@ var SHADOWS = {
|
|
|
4048
4060
|
lg: "0 14px 36px rgba(13, 13, 13, 0.14)"
|
|
4049
4061
|
};
|
|
4050
4062
|
var PADDING = { none: "0", compact: "8px", roomy: "24px" };
|
|
4051
|
-
var colour = (
|
|
4052
|
-
if (typeof
|
|
4053
|
-
if (/^[a-z]+(-[a-z]+)+$/.test(
|
|
4054
|
-
return /^(#[0-9a-f]{3,8}|rgba?\([\d\s.,%]+\)|hsla?\([\d\s.,%deg]+\)|[a-z]+)$/i.test(
|
|
4063
|
+
var colour = (v2) => {
|
|
4064
|
+
if (typeof v2 !== "string" || !v2) return void 0;
|
|
4065
|
+
if (/^[a-z]+(-[a-z]+)+$/.test(v2) && !v2.includes("(")) return `var(--ds-color-${v2})`;
|
|
4066
|
+
return /^(#[0-9a-f]{3,8}|rgba?\([\d\s.,%]+\)|hsla?\([\d\s.,%deg]+\)|[a-z]+)$/i.test(v2) ? v2 : void 0;
|
|
4055
4067
|
};
|
|
4056
|
-
var size = (
|
|
4068
|
+
var size = (v2) => typeof v2 === "number" ? `${v2}px` : typeof v2 === "string" && /^[\d.]+(px|%|rem|em|vw)?$/.test(v2) ? v2 : void 0;
|
|
4057
4069
|
var PART_CLASSES = [
|
|
4058
4070
|
[".ds-panel-title, .ds-kpi-label", "title"],
|
|
4059
4071
|
[".ds-info", "info"],
|
|
@@ -4526,10 +4538,10 @@ function PanelFrameInner({ id, nested }) {
|
|
|
4526
4538
|
def: c,
|
|
4527
4539
|
compact: true,
|
|
4528
4540
|
value: view.panel.controls?.[c.name],
|
|
4529
|
-
onChange: (
|
|
4541
|
+
onChange: (v2) => runtime.store.dispatch(
|
|
4530
4542
|
stateActions.patchPanel({
|
|
4531
4543
|
id,
|
|
4532
|
-
patch: { controls: { ...view.panel.controls, [c.name]:
|
|
4544
|
+
patch: { controls: { ...view.panel.controls, [c.name]: v2 } }
|
|
4533
4545
|
})
|
|
4534
4546
|
)
|
|
4535
4547
|
},
|
|
@@ -4545,8 +4557,8 @@ function PanelFrameInner({ id, nested }) {
|
|
|
4545
4557
|
) }) });
|
|
4546
4558
|
}
|
|
4547
4559
|
function loadingText(messages) {
|
|
4548
|
-
const
|
|
4549
|
-
return
|
|
4560
|
+
const v2 = messages?.loading;
|
|
4561
|
+
return v2 === void 0 || v2 === null || v2 === "" ? void 0 : String(v2);
|
|
4550
4562
|
}
|
|
4551
4563
|
function LoadingState({ text: text2 }) {
|
|
4552
4564
|
if (!text2) return /* @__PURE__ */ jsx14("div", { className: "ds-skeleton", "aria-busy": "true", "aria-label": "Loading" });
|
|
@@ -4591,8 +4603,8 @@ function useCountUp(target, ms = 700) {
|
|
|
4591
4603
|
let raf = 0;
|
|
4592
4604
|
const step = (now) => {
|
|
4593
4605
|
const t = Math.min(1, (now - start) / ms);
|
|
4594
|
-
const
|
|
4595
|
-
setShown(t === 1 ? target : Number.isInteger(target) ? Math.round(
|
|
4606
|
+
const v2 = a + (target - a) * easeOut(t);
|
|
4607
|
+
setShown(t === 1 ? target : Number.isInteger(target) ? Math.round(v2) : v2);
|
|
4596
4608
|
if (t < 1) raf = requestAnimationFrame(step);
|
|
4597
4609
|
else from.current = target;
|
|
4598
4610
|
};
|
|
@@ -4619,11 +4631,11 @@ var Kpi = defineWidget({
|
|
|
4619
4631
|
component: function KpiWidget({ spec, data, source, emit, helpers, panelId }) {
|
|
4620
4632
|
const clickable = useClickable(panelId, () => {
|
|
4621
4633
|
}).role === "button";
|
|
4622
|
-
const num = (
|
|
4634
|
+
const num = (v2) => typeof v2 === "number" ? v2 : toNumber(field(source, v2));
|
|
4623
4635
|
const value = toNumber(data) ?? data;
|
|
4624
4636
|
const animated = useCountUp(value);
|
|
4625
4637
|
const n = toNumber(value);
|
|
4626
|
-
const fmt = (
|
|
4638
|
+
const fmt = (v2) => formatValue(v2, helpers, spec.format, spec.decimals);
|
|
4627
4639
|
const unit = spec.format === "duration" ? void 0 : spec.unit;
|
|
4628
4640
|
const empty = spec.empty === true || value === void 0 || value === null || value === "";
|
|
4629
4641
|
const hasTarget = spec.target !== void 0;
|
|
@@ -4731,7 +4743,7 @@ function sparkPath(values, w, h, pad = 2) {
|
|
|
4731
4743
|
const max = values.reduce((a, b) => Math.max(a, b));
|
|
4732
4744
|
const span = max - min || 1;
|
|
4733
4745
|
const step = values.length > 1 ? (w - pad * 2) / (values.length - 1) : 0;
|
|
4734
|
-
const pts = values.map((
|
|
4746
|
+
const pts = values.map((v2, i) => [pad + i * step, h - pad - (v2 - min) / span * (h - pad * 2)]);
|
|
4735
4747
|
const line = pts.map(([x, y], i) => `${i ? "L" : "M"}${x.toFixed(1)},${y.toFixed(1)}`).join(" ");
|
|
4736
4748
|
const last = pts[pts.length - 1];
|
|
4737
4749
|
return { line, area: `${line} L${last[0].toFixed(1)},${h} L${pad},${h} Z` };
|
|
@@ -4922,8 +4934,8 @@ function Chips({
|
|
|
4922
4934
|
const shown = chips.filter((c) => c.when === void 0 || Boolean(evalOver(c.when, vars, helpers))).map((c) => {
|
|
4923
4935
|
let text2 = "";
|
|
4924
4936
|
try {
|
|
4925
|
-
const
|
|
4926
|
-
text2 =
|
|
4937
|
+
const v2 = interpolate(c.text, scope(vars, helpers));
|
|
4938
|
+
text2 = v2 === null || v2 === void 0 ? "" : String(v2);
|
|
4927
4939
|
} catch {
|
|
4928
4940
|
}
|
|
4929
4941
|
return { text: text2, tone: toneOf(c.tone, vars, helpers) ?? "neutral" };
|
|
@@ -4960,8 +4972,8 @@ var Table = defineWidget({
|
|
|
4960
4972
|
component: function TableWidget({ spec, data, source, emit, helpers, size: size2, state, setUi, status, renderSlot }) {
|
|
4961
4973
|
const tpl = (t, row, item) => {
|
|
4962
4974
|
try {
|
|
4963
|
-
const
|
|
4964
|
-
return
|
|
4975
|
+
const v2 = interpolate(t, scope({ row, item, datum: row }, helpers));
|
|
4976
|
+
return v2 === null || v2 === void 0 ? "" : String(v2);
|
|
4965
4977
|
} catch {
|
|
4966
4978
|
return "";
|
|
4967
4979
|
}
|
|
@@ -4977,7 +4989,7 @@ var Table = defineWidget({
|
|
|
4977
4989
|
return asRows(field(source, cf.path)).map((c) => {
|
|
4978
4990
|
const key = String(field(c, cf.key));
|
|
4979
4991
|
const label = String(field(c, cf.label) ?? field(c, cf.key));
|
|
4980
|
-
const fill = (
|
|
4992
|
+
const fill = (v2) => typeof v2 === "string" ? v2.replaceAll("{key}", key).replaceAll("{label}", label) : Array.isArray(v2) ? v2.map(fill) : v2 && typeof v2 === "object" ? Object.fromEntries(Object.entries(v2).map(([k, x]) => [k, fill(x)])) : v2;
|
|
4981
4993
|
return {
|
|
4982
4994
|
key,
|
|
4983
4995
|
label,
|
|
@@ -5028,7 +5040,7 @@ var Table = defineWidget({
|
|
|
5028
5040
|
sortKey: next.sortKey,
|
|
5029
5041
|
sortOrder: next.sortKey ? next.sortOrder : void 0,
|
|
5030
5042
|
ordering: next.sortKey ? `${next.sortOrder === "desc" ? "-" : ""}${next.sortKey}` : void 0,
|
|
5031
|
-
filters: Object.fromEntries(Object.entries(next.filters).filter(([,
|
|
5043
|
+
filters: Object.fromEntries(Object.entries(next.filters).filter(([, v2]) => v2 !== ""))
|
|
5032
5044
|
});
|
|
5033
5045
|
};
|
|
5034
5046
|
const [searchText, setSearchText] = useState6(view.search);
|
|
@@ -5040,15 +5052,15 @@ var Table = defineWidget({
|
|
|
5040
5052
|
const rows = useMemo4(() => {
|
|
5041
5053
|
let r = base;
|
|
5042
5054
|
if (fl && !server.filter)
|
|
5043
|
-
for (const [k,
|
|
5044
|
-
if (
|
|
5055
|
+
for (const [k, v2] of Object.entries(view.filters)) {
|
|
5056
|
+
if (v2 === "") continue;
|
|
5045
5057
|
const c = columns.find((x) => x.key === k);
|
|
5046
5058
|
if (c?.filter === "min")
|
|
5047
|
-
r = r.filter((row) => (toNumber(field(row, k)) ?? Number.NEGATIVE_INFINITY) >= Number(
|
|
5048
|
-
else if (c?.filter === "select") r = r.filter((row) => String(field(row, k) ?? "") ===
|
|
5059
|
+
r = r.filter((row) => (toNumber(field(row, k)) ?? Number.NEGATIVE_INFINITY) >= Number(v2));
|
|
5060
|
+
else if (c?.filter === "select") r = r.filter((row) => String(field(row, k) ?? "") === v2);
|
|
5049
5061
|
else
|
|
5050
5062
|
r = r.filter(
|
|
5051
|
-
(row) => String(field(row, k) ?? "").toLowerCase().includes(
|
|
5063
|
+
(row) => String(field(row, k) ?? "").toLowerCase().includes(v2.toLowerCase())
|
|
5052
5064
|
);
|
|
5053
5065
|
}
|
|
5054
5066
|
if (sr && !server.search && view.search) {
|
|
@@ -5056,7 +5068,7 @@ var Table = defineWidget({
|
|
|
5056
5068
|
const fields = sr.mode === "client" && "fields" in sr ? sr.fields : void 0;
|
|
5057
5069
|
r = r.filter(
|
|
5058
5070
|
(row) => (fields ? fields.map((f) => field(row, f)) : Object.values(row)).some(
|
|
5059
|
-
(
|
|
5071
|
+
(v2) => v2 !== null && v2 !== void 0 && typeof v2 !== "object" && String(v2).toLowerCase().includes(q)
|
|
5060
5072
|
)
|
|
5061
5073
|
);
|
|
5062
5074
|
}
|
|
@@ -5088,19 +5100,19 @@ var Table = defineWidget({
|
|
|
5088
5100
|
const busy = status === "loading" && base.length > 0;
|
|
5089
5101
|
const filterChoices = (c) => c.filterOptions ?? [
|
|
5090
5102
|
...new Set(
|
|
5091
|
-
base.map((r) => field(r, c.key)).filter((
|
|
5103
|
+
base.map((r) => field(r, c.key)).filter((v2) => v2 !== null && v2 !== void 0 && v2 !== "").map(String)
|
|
5092
5104
|
)
|
|
5093
5105
|
].sort();
|
|
5094
5106
|
const cell = (c, row) => {
|
|
5095
|
-
const
|
|
5107
|
+
const v2 = field(row, c.key);
|
|
5096
5108
|
if (c.type === "badge") {
|
|
5097
|
-
const text2 = c.template ? tpl(c.template, row) :
|
|
5109
|
+
const text2 = c.template ? tpl(c.template, row) : v2 === null || v2 === void 0 || v2 === "" ? "" : String(v2);
|
|
5098
5110
|
if (!text2) return c.empty ? /* @__PURE__ */ jsx21("span", { className: "ds-cell-empty", children: c.empty }) : "";
|
|
5099
|
-
let t = c.map?.[String(
|
|
5111
|
+
let t = c.map?.[String(v2)] ?? "neutral";
|
|
5100
5112
|
if (c.tone) {
|
|
5101
5113
|
try {
|
|
5102
5114
|
t = String(
|
|
5103
|
-
evaluate(c.tone, scope({ row, value:
|
|
5115
|
+
evaluate(c.tone, scope({ row, value: v2 }, helpers))
|
|
5104
5116
|
);
|
|
5105
5117
|
} catch {
|
|
5106
5118
|
}
|
|
@@ -5109,24 +5121,24 @@ var Table = defineWidget({
|
|
|
5109
5121
|
}
|
|
5110
5122
|
if (c.template) return tpl(c.template, row) || (c.empty ? /* @__PURE__ */ jsx21("span", { className: "ds-cell-empty", children: c.empty }) : "");
|
|
5111
5123
|
if (c.list !== void 0) {
|
|
5112
|
-
const items = Array.isArray(
|
|
5124
|
+
const items = Array.isArray(v2) ? v2 : [];
|
|
5113
5125
|
if (items.length === 0) return c.empty ?? "";
|
|
5114
5126
|
return /* @__PURE__ */ jsx21("span", { className: "ds-cell-list", children: items.map((it, i) => (
|
|
5115
5127
|
// biome-ignore lint/suspicious/noArrayIndexKey: list items have no id and never reorder within a render
|
|
5116
5128
|
/* @__PURE__ */ jsx21("span", { children: tpl(c.list, row, it) }, i)
|
|
5117
5129
|
)) });
|
|
5118
5130
|
}
|
|
5119
|
-
if (
|
|
5131
|
+
if (v2 === null || v2 === void 0 || v2 === "")
|
|
5120
5132
|
return c.empty ? /* @__PURE__ */ jsx21("span", { className: "ds-cell-empty", children: c.empty }) : "";
|
|
5121
5133
|
switch (c.type) {
|
|
5122
5134
|
case "link": {
|
|
5123
|
-
const href = safeLink(c.href ? tpl(c.href, row) : String(
|
|
5124
|
-
return href ? /* @__PURE__ */ jsx21("a", { className: "ds-link", href, onClick: (e) => e.stopPropagation(), children: String(
|
|
5135
|
+
const href = safeLink(c.href ? tpl(c.href, row) : String(v2));
|
|
5136
|
+
return href ? /* @__PURE__ */ jsx21("a", { className: "ds-link", href, onClick: (e) => e.stopPropagation(), children: String(v2) }) : String(v2);
|
|
5125
5137
|
}
|
|
5126
5138
|
case "image":
|
|
5127
|
-
return safeImageSrc(
|
|
5139
|
+
return safeImageSrc(v2) ? /* @__PURE__ */ jsx21("img", { src: v2, alt: "", style: { height: 28, borderRadius: 4 } }) : null;
|
|
5128
5140
|
case "progress": {
|
|
5129
|
-
const n = toNumber(
|
|
5141
|
+
const n = toNumber(v2) ?? 0;
|
|
5130
5142
|
const pct = Math.min(100, n / (c.max ?? 100) * 100);
|
|
5131
5143
|
return /* @__PURE__ */ jsxs16("span", { className: "ds-inline", children: [
|
|
5132
5144
|
/* @__PURE__ */ jsx21("span", { className: "ds-progress", style: { flex: 1, minWidth: 40 }, children: /* @__PURE__ */ jsx21("span", { style: { width: `${pct}%`, background: "var(--ds-series-1)" } }) }),
|
|
@@ -5138,7 +5150,7 @@ var Table = defineWidget({
|
|
|
5138
5150
|
return /* @__PURE__ */ jsx21(
|
|
5139
5151
|
SparkSvg,
|
|
5140
5152
|
{
|
|
5141
|
-
values: (Array.isArray(
|
|
5153
|
+
values: (Array.isArray(v2) ? v2 : []).map(
|
|
5142
5154
|
(x) => toNumber(typeof x === "object" ? field(x, "value") : x) ?? 0
|
|
5143
5155
|
),
|
|
5144
5156
|
height: 24,
|
|
@@ -5146,7 +5158,7 @@ var Table = defineWidget({
|
|
|
5146
5158
|
}
|
|
5147
5159
|
);
|
|
5148
5160
|
default:
|
|
5149
|
-
return `${c.prefix ?? ""}${typeof
|
|
5161
|
+
return `${c.prefix ?? ""}${typeof v2 === "number" || c.format ? formatValue(v2, helpers, c.format, c.decimals) : String(v2)}${c.suffix ?? ""}`;
|
|
5150
5162
|
}
|
|
5151
5163
|
};
|
|
5152
5164
|
const WEIGHT = { regular: 400, medium: 500, semibold: 600, bold: 700 };
|
|
@@ -5170,8 +5182,8 @@ var Table = defineWidget({
|
|
|
5170
5182
|
if (!how) return null;
|
|
5171
5183
|
const nums = rows.map((r) => toNumber(field(r, c.key))).filter((n) => n !== void 0);
|
|
5172
5184
|
if (how !== "count" && nums.length === 0) return "";
|
|
5173
|
-
const
|
|
5174
|
-
return `${c.prefix ?? ""}${formatValue(
|
|
5185
|
+
const v2 = how === "count" ? rows.length : how === "sum" ? nums.reduce((a, b) => a + b, 0) : how === "avg" ? nums.reduce((a, b) => a + b, 0) / (nums.length || 1) : how === "min" ? nums.reduce((a, b) => Math.min(a, b)) : nums.reduce((a, b) => Math.max(a, b));
|
|
5186
|
+
return `${c.prefix ?? ""}${formatValue(v2, helpers, c.format === "date" ? "number" : c.format, c.decimals)}${c.suffix ?? ""}`;
|
|
5175
5187
|
};
|
|
5176
5188
|
const muted = (row) => {
|
|
5177
5189
|
if (!spec.rowMutedWhen) return false;
|
|
@@ -5197,10 +5209,10 @@ var Table = defineWidget({
|
|
|
5197
5209
|
placeholder: "placeholder" in sr && sr.placeholder || "Search",
|
|
5198
5210
|
value: searchText,
|
|
5199
5211
|
onChange: (e) => {
|
|
5200
|
-
const
|
|
5201
|
-
setSearchText(
|
|
5212
|
+
const v2 = e.target.value;
|
|
5213
|
+
setSearchText(v2);
|
|
5202
5214
|
clearTimeout(searchTimer.current);
|
|
5203
|
-
searchTimer.current = setTimeout(() => update({ search:
|
|
5215
|
+
searchTimer.current = setTimeout(() => update({ search: v2, page: 1 }), server.search ? 350 : 120);
|
|
5204
5216
|
}
|
|
5205
5217
|
}
|
|
5206
5218
|
)
|
|
@@ -5259,7 +5271,7 @@ var Table = defineWidget({
|
|
|
5259
5271
|
...filterChoices(c).map((o) => ({ value: o, label: o }))
|
|
5260
5272
|
],
|
|
5261
5273
|
value: view.filters[c.key] ?? "",
|
|
5262
|
-
onChange: (
|
|
5274
|
+
onChange: (v2) => update({ filters: { ...view.filters, [c.key]: String(v2 ?? "") }, page: 1 })
|
|
5263
5275
|
}
|
|
5264
5276
|
) : c.filter ? /* @__PURE__ */ jsx21(
|
|
5265
5277
|
"input",
|
|
@@ -5376,7 +5388,7 @@ var Table = defineWidget({
|
|
|
5376
5388
|
ariaLabel: "Rows per page",
|
|
5377
5389
|
options: (pg?.pageSizes ?? [10, 20, 50, 100]).map((n) => ({ value: n, label: String(n) })),
|
|
5378
5390
|
value: pageSize,
|
|
5379
|
-
onChange: (
|
|
5391
|
+
onChange: (v2) => update({ pageSize: Number(v2), page: 1 })
|
|
5380
5392
|
}
|
|
5381
5393
|
)
|
|
5382
5394
|
] }),
|
|
@@ -5465,13 +5477,13 @@ var Tiles = defineWidget({
|
|
|
5465
5477
|
},
|
|
5466
5478
|
children: rows.map((r, i) => {
|
|
5467
5479
|
const label = field(r, spec.label);
|
|
5468
|
-
const
|
|
5469
|
-
const n = toNumber(
|
|
5480
|
+
const v2 = spec.value.includes("${") ? tplValue(spec.value, r, helpers) : field(r, spec.value);
|
|
5481
|
+
const n = toNumber(v2);
|
|
5470
5482
|
const status = spec.status ? String(field(r, spec.status)) : void 0;
|
|
5471
5483
|
const st = status ? spec.statusMap?.[status] ?? status : void 0;
|
|
5472
5484
|
const vt = n === void 0 || !spec.valueTone ? void 0 : n > 0 ? spec.valueTone.positive : n < 0 ? spec.valueTone.negative : spec.valueTone.zero;
|
|
5473
5485
|
const active = spec.selectable && spec.selected !== void 0 && spec.selected === label;
|
|
5474
|
-
const vars = { row: r, value:
|
|
5486
|
+
const vars = { row: r, value: v2 };
|
|
5475
5487
|
const mutedTile = spec.mutedWhen ? Boolean(evalOver(spec.mutedWhen, vars, helpers)) : false;
|
|
5476
5488
|
const lit = spec.highlightWhen ? Boolean(evalOver(spec.highlightWhen, vars, helpers)) : false;
|
|
5477
5489
|
return /* @__PURE__ */ jsxs17(
|
|
@@ -5497,13 +5509,13 @@ var Tiles = defineWidget({
|
|
|
5497
5509
|
spec.count && /* @__PURE__ */ jsx22("span", { className: "ds-chip-count", children: String(field(r, spec.count) ?? "") })
|
|
5498
5510
|
] }),
|
|
5499
5511
|
(() => {
|
|
5500
|
-
const valueEl =
|
|
5512
|
+
const valueEl = v2 === "" ? null : /* @__PURE__ */ jsxs17(
|
|
5501
5513
|
"span",
|
|
5502
5514
|
{
|
|
5503
5515
|
className: "ds-tile-value",
|
|
5504
5516
|
style: vt ? { color: vt === "muted" ? "var(--ds-color-text-disabled)" : tone(vt).fg } : void 0,
|
|
5505
5517
|
children: [
|
|
5506
|
-
/* @__PURE__ */ jsx22(CountUp, { value:
|
|
5518
|
+
/* @__PURE__ */ jsx22(CountUp, { value: v2, render: (x) => formatValue(x, helpers, spec.format, spec.decimals) }),
|
|
5507
5519
|
spec.unit && /* @__PURE__ */ jsx22("span", { className: "ds-kpi-unit", children: spec.unit })
|
|
5508
5520
|
]
|
|
5509
5521
|
}
|
|
@@ -5558,9 +5570,9 @@ var Text = defineWidget({
|
|
|
5558
5570
|
events: ["click"],
|
|
5559
5571
|
defaults: { text: "Label" },
|
|
5560
5572
|
component: function TextAtom({ spec, data, helpers, emit, panelId }) {
|
|
5561
|
-
const
|
|
5562
|
-
const click = useClickable(panelId, () => emit("click", "text", { value:
|
|
5563
|
-
const shown = spec.text.includes("{value}") && (
|
|
5573
|
+
const v2 = boundValue(data, spec.field);
|
|
5574
|
+
const click = useClickable(panelId, () => emit("click", "text", { value: v2 }));
|
|
5575
|
+
const shown = spec.text.includes("{value}") && (v2 === void 0 || v2 === null || v2 === "") ? spec.emptyText ?? spec.text.replace("{value}", "\u2013") : spec.text.replace("{value}", v2 === void 0 ? "" : formatValue(v2, helpers, "text"));
|
|
5564
5576
|
return /* @__PURE__ */ jsx23(
|
|
5565
5577
|
"span",
|
|
5566
5578
|
{
|
|
@@ -5581,11 +5593,11 @@ var Value = defineWidget({
|
|
|
5581
5593
|
meta: meta("Value", 3, 2),
|
|
5582
5594
|
events: ["click"],
|
|
5583
5595
|
component: function ValueAtom({ spec, data, helpers, emit, panelId }) {
|
|
5584
|
-
const
|
|
5585
|
-
const click = useClickable(panelId, () => emit("click", "value", { value:
|
|
5586
|
-
const n = toNumber(
|
|
5596
|
+
const v2 = boundValue(data, spec.field);
|
|
5597
|
+
const click = useClickable(panelId, () => emit("click", "value", { value: v2 }));
|
|
5598
|
+
const n = toNumber(v2);
|
|
5587
5599
|
const animated = useCountUp(spec.countUp ? n : void 0);
|
|
5588
|
-
const shown = n !== void 0 && spec.countUp ? animated :
|
|
5600
|
+
const shown = n !== void 0 && spec.countUp ? animated : v2;
|
|
5589
5601
|
const target = typeof spec.target === "number" ? spec.target : spec.target ? toNumber(boundValue(data, spec.target)) : void 0;
|
|
5590
5602
|
const met = n !== void 0 && target !== void 0 ? spec.goodWhen === "down" ? n <= target : n >= target : void 0;
|
|
5591
5603
|
const c = spec.color === "byTarget" ? met === void 0 ? void 0 : tone(met ? "good" : "bad").fg : spec.color === "primary" ? "var(--ds-color-action-primary)" : spec.color === "default" ? void 0 : tone(spec.color).fg;
|
|
@@ -5763,7 +5775,7 @@ function echartsTheme(theme, mode) {
|
|
|
5763
5775
|
padding: [8, 10],
|
|
5764
5776
|
textStyle: { color: c.chart.tooltipText, fontFamily: family, fontSize: 12 },
|
|
5765
5777
|
extraCssText: `border-radius: ${s.radius.control}px; box-shadow: none; backdrop-filter: blur(8px);`,
|
|
5766
|
-
axisPointer: { shadowStyle: { color: "rgba(
|
|
5778
|
+
axisPointer: { shadowStyle: { color: "rgba(127, 127, 127, 0.15)" } }
|
|
5767
5779
|
},
|
|
5768
5780
|
categoryAxis,
|
|
5769
5781
|
valueAxis,
|
|
@@ -5973,11 +5985,11 @@ function cartesian(data, source, spec, type, h, colors) {
|
|
|
5973
5985
|
const totals = cats.map((_, i) => series.reduce((a, s) => a + (s.values[i] ?? 0), 0) || 1);
|
|
5974
5986
|
series = series.map((s) => ({
|
|
5975
5987
|
...s,
|
|
5976
|
-
values: s.values.map((
|
|
5988
|
+
values: s.values.map((v2, i) => v2 === null ? null : v2 / totals[i] * 100)
|
|
5977
5989
|
}));
|
|
5978
5990
|
}
|
|
5979
|
-
const labelValue = (
|
|
5980
|
-
const fmt = (
|
|
5991
|
+
const labelValue = (v2) => spec.maxDecimals !== void 0 && typeof v2 === "number" ? formatValue(Math.round(v2 * 10 ** spec.maxDecimals) / 10 ** spec.maxDecimals, h, spec.format, void 0) : formatValue(v2, h, spec.format, spec.decimals ?? 1);
|
|
5992
|
+
const fmt = (v2) => spec.normalized ? h.fmt.percent(v2, 0) : `${formatValue(v2, h, spec.format, spec.decimals)}${spec.unit ? ` ${spec.unit}` : ""}`;
|
|
5981
5993
|
const target = typeof spec.target === "number" ? spec.target : spec.target !== void 0 ? toNumber(field(source, spec.target)) : void 0;
|
|
5982
5994
|
const catAxis = {
|
|
5983
5995
|
type: "category",
|
|
@@ -5987,18 +5999,18 @@ function cartesian(data, source, spec, type, h, colors) {
|
|
|
5987
5999
|
const valAxis = {
|
|
5988
6000
|
type: "value",
|
|
5989
6001
|
axisLabel: {
|
|
5990
|
-
formatter: (
|
|
6002
|
+
formatter: (v2) => spec.normalized ? `${v2}%` : formatValue(v2, h, spec.format === "duration" ? "duration" : "compact")
|
|
5991
6003
|
},
|
|
5992
6004
|
...spec.normalized ? { max: 100 } : {},
|
|
5993
6005
|
...spec.valueAxis?.min !== void 0 ? { min: spec.valueAxis.min } : {},
|
|
5994
|
-
...spec.valueAxis?.max !== void 0 ? { max: spec.valueAxis.max } : spec.valueAxis?.atLeast !== void 0 ? { max: (
|
|
6006
|
+
...spec.valueAxis?.max !== void 0 ? { max: spec.valueAxis.max } : spec.valueAxis?.atLeast !== void 0 ? { max: (v2) => Math.max(spec.valueAxis?.atLeast ?? 0, v2.max) } : {},
|
|
5995
6007
|
...spec.valueAxis?.step !== void 0 ? { interval: spec.valueAxis.step } : {},
|
|
5996
6008
|
...spec.valueAxis?.minStep !== void 0 ? { minInterval: spec.valueAxis.minStep } : {}
|
|
5997
6009
|
};
|
|
5998
6010
|
const stack = spec.stacked || spec.normalized || spec.range ? "total" : void 0;
|
|
5999
6011
|
const single = series.length === 1 && !spec.range;
|
|
6000
6012
|
const isPartial = cats.map((c) => Boolean(spec.partial && field(firstRow.get(String(c)), spec.partial)));
|
|
6001
|
-
const full = single ? (series[0]?.values ?? []).filter((
|
|
6013
|
+
const full = single ? (series[0]?.values ?? []).filter((v2, i) => v2 !== null && !isPartial[i]) : [];
|
|
6002
6014
|
const given = typeof spec.average === "number" ? spec.average : spec.average !== void 0 ? toNumber(field(source, spec.average)) ?? void 0 : void 0;
|
|
6003
6015
|
const avg = given ?? (full.length ? full.reduce((a, b) => a + b, 0) / full.length : void 0);
|
|
6004
6016
|
const toneOf2 = (i) => {
|
|
@@ -6018,18 +6030,18 @@ function cartesian(data, source, spec, type, h, colors) {
|
|
|
6018
6030
|
let sum = 0;
|
|
6019
6031
|
let any = false;
|
|
6020
6032
|
for (const x of series) {
|
|
6021
|
-
const
|
|
6022
|
-
if (typeof
|
|
6023
|
-
sum +=
|
|
6033
|
+
const v2 = x.values[i];
|
|
6034
|
+
if (typeof v2 === "number") {
|
|
6035
|
+
sum += v2;
|
|
6024
6036
|
any = true;
|
|
6025
6037
|
}
|
|
6026
6038
|
}
|
|
6027
6039
|
return any ? sum : null;
|
|
6028
6040
|
};
|
|
6029
6041
|
for (const s of series) {
|
|
6030
|
-
const styled = type === "bar" && single && colors ? s.values.map((
|
|
6031
|
-
value:
|
|
6032
|
-
itemStyle: isPartial[i] ? { color: colors.partial } : toned ? toneOf2(i) ? { color: toneOf2(i) } : void 0 : colourByAvg &&
|
|
6042
|
+
const styled = type === "bar" && single && colors ? s.values.map((v2, i) => ({
|
|
6043
|
+
value: v2,
|
|
6044
|
+
itemStyle: isPartial[i] ? { color: colors.partial } : toned ? toneOf2(i) ? { color: toneOf2(i) } : void 0 : colourByAvg && v2 !== null ? { color: v2 >= avg ? colors.good : colors.bad } : void 0
|
|
6033
6045
|
})) : void 0;
|
|
6034
6046
|
if (s.base)
|
|
6035
6047
|
out.push({
|
|
@@ -6056,9 +6068,9 @@ function cartesian(data, source, spec, type, h, colors) {
|
|
|
6056
6068
|
fontSize: 12,
|
|
6057
6069
|
...colors ? { color: colors.text } : {},
|
|
6058
6070
|
formatter: (p) => {
|
|
6059
|
-
const
|
|
6060
|
-
if (
|
|
6061
|
-
return `${labelValue(
|
|
6071
|
+
const v2 = stackedTotals ? totalAt(p.dataIndex) : p.value;
|
|
6072
|
+
if (v2 === null || v2 === void 0 || spec.hideZeroLabels && Number(v2) === 0) return "";
|
|
6073
|
+
return `${labelValue(v2)}${isPartial[p.dataIndex] ? " so far" : ""}`;
|
|
6062
6074
|
}
|
|
6063
6075
|
}
|
|
6064
6076
|
} : {},
|
|
@@ -6086,7 +6098,7 @@ function cartesian(data, source, spec, type, h, colors) {
|
|
|
6086
6098
|
out[out.length - 1].markLine = {
|
|
6087
6099
|
symbol: "none",
|
|
6088
6100
|
silent: true,
|
|
6089
|
-
lineStyle: { type: [6, 4], width: 1.5, color: "#666666" },
|
|
6101
|
+
lineStyle: { type: [6, 4], width: 1.5, color: colors?.text ?? "#666666", opacity: 0.6 },
|
|
6090
6102
|
label: { show: false },
|
|
6091
6103
|
data: [spec.horizontal ? { xAxis: avg } : { yAxis: avg }]
|
|
6092
6104
|
};
|
|
@@ -6110,7 +6122,7 @@ function cartesian(data, source, spec, type, h, colors) {
|
|
|
6110
6122
|
tooltip: {
|
|
6111
6123
|
trigger: "axis",
|
|
6112
6124
|
axisPointer: { type: type === "bar" ? "shadow" : "line" },
|
|
6113
|
-
valueFormatter: (
|
|
6125
|
+
valueFormatter: (v2) => fmt(v2),
|
|
6114
6126
|
// Your own tooltip: a title and lines, templates over the hovered category's `row`; **bold** marks values.
|
|
6115
6127
|
...spec.tooltip ? {
|
|
6116
6128
|
formatter: (params) => {
|
|
@@ -6118,8 +6130,8 @@ function cartesian(data, source, spec, type, h, colors) {
|
|
|
6118
6130
|
const row = firstRow.get(String(first?.axisValue ?? first?.name)) ?? {};
|
|
6119
6131
|
const fill = (t) => {
|
|
6120
6132
|
try {
|
|
6121
|
-
const
|
|
6122
|
-
return
|
|
6133
|
+
const v2 = interpolate(t, scope({ row }, h));
|
|
6134
|
+
return v2 === null || v2 === void 0 ? "" : String(v2);
|
|
6123
6135
|
} catch {
|
|
6124
6136
|
return "";
|
|
6125
6137
|
}
|
|
@@ -6285,7 +6297,7 @@ var PieChart2 = defineWidget({
|
|
|
6285
6297
|
() => ({
|
|
6286
6298
|
tooltip: {
|
|
6287
6299
|
trigger: "item",
|
|
6288
|
-
valueFormatter: (
|
|
6300
|
+
valueFormatter: (v2) => `${formatValue(v2, helpers, spec.format, spec.decimals)}${spec.unit ? ` ${spec.unit}` : ""}`
|
|
6289
6301
|
},
|
|
6290
6302
|
legend: { type: "scroll", bottom: 0 },
|
|
6291
6303
|
series: [
|
|
@@ -6343,8 +6355,8 @@ var Scatter = defineWidget({
|
|
|
6343
6355
|
name: g,
|
|
6344
6356
|
type: "scatter",
|
|
6345
6357
|
data: rows.filter((r) => !spec.series || String(field(r, spec.series)) === g).map((r) => {
|
|
6346
|
-
const
|
|
6347
|
-
return spec.size ? { value:
|
|
6358
|
+
const v2 = [toNumber(field(r, spec.x)), toNumber(field(r, spec.y))];
|
|
6359
|
+
return spec.size ? { value: v2, symbolSize: 6 + (toNumber(field(r, spec.size)) ?? 0) / max * 24 } : v2;
|
|
6348
6360
|
})
|
|
6349
6361
|
}))
|
|
6350
6362
|
};
|
|
@@ -6402,7 +6414,7 @@ var Gauge = defineWidget({
|
|
|
6402
6414
|
offsetCenter: [0, arc ? "30%" : 0],
|
|
6403
6415
|
fontSize: 22,
|
|
6404
6416
|
color: tokens?.theme[tokens.mode].text.primary,
|
|
6405
|
-
formatter: (
|
|
6417
|
+
formatter: (v2) => `${formatValue(v2, helpers, spec.format, spec.decimals)}${spec.unit ?? ""}`
|
|
6406
6418
|
},
|
|
6407
6419
|
data: [{ value, name: spec.title ?? "" }],
|
|
6408
6420
|
title: { show: false }
|
|
@@ -6452,7 +6464,7 @@ var MatrixChart = defineWidget({
|
|
|
6452
6464
|
option: {
|
|
6453
6465
|
grid: { left: 8, right: 8, top: 8, bottom: 40, containLabel: true },
|
|
6454
6466
|
tooltip: {
|
|
6455
|
-
valueFormatter: (
|
|
6467
|
+
valueFormatter: (v2) => `${formatValue(Array.isArray(v2) ? v2[2] : v2, helpers, spec.format, spec.decimals)}${spec.unit ? ` ${spec.unit}` : ""}`
|
|
6456
6468
|
},
|
|
6457
6469
|
xAxis: { type: "category", data: xs, splitArea: { show: true } },
|
|
6458
6470
|
yAxis: { type: "category", data: ys, splitArea: { show: true } },
|
|
@@ -7027,7 +7039,7 @@ var LISTS = ["designSystems", "widgets", "datasourceTypes", "trustedOrigins"];
|
|
|
7027
7039
|
var MAPS = ["aliases", "actions", "functions", "themes", "context", "data", "connections", "connectionMap"];
|
|
7028
7040
|
function mergeSettings(outer, inner) {
|
|
7029
7041
|
const out = { ...outer };
|
|
7030
|
-
for (const [k,
|
|
7042
|
+
for (const [k, v2] of Object.entries(inner)) if (v2 !== void 0) out[k] = v2;
|
|
7031
7043
|
const o = outer;
|
|
7032
7044
|
const i = inner;
|
|
7033
7045
|
for (const k of LISTS)
|
|
@@ -7040,7 +7052,7 @@ function mergeSettings(outer, inner) {
|
|
|
7040
7052
|
}
|
|
7041
7053
|
return out;
|
|
7042
7054
|
}
|
|
7043
|
-
var isObj = (
|
|
7055
|
+
var isObj = (v2) => v2 !== null && typeof v2 === "object" && !Array.isArray(v2);
|
|
7044
7056
|
var THEME_MODES = /* @__PURE__ */ new Set(["light", "dark", "auto"]);
|
|
7045
7057
|
function pickTheme(name, themes, fallback) {
|
|
7046
7058
|
if (typeof name !== "string" || !name) return { theme: fallback, mode: fallback.mode };
|
|
@@ -7077,12 +7089,12 @@ function TourButton({ steps }) {
|
|
|
7077
7089
|
(t) => {
|
|
7078
7090
|
if (!step) return null;
|
|
7079
7091
|
const sc = rootScope(t, runtime.helpers);
|
|
7080
|
-
const fill = (
|
|
7081
|
-
if (!
|
|
7092
|
+
const fill = (v2) => {
|
|
7093
|
+
if (!v2) return "";
|
|
7082
7094
|
try {
|
|
7083
|
-
return String(interpolate(
|
|
7095
|
+
return String(interpolate(v2, sc) ?? "");
|
|
7084
7096
|
} catch {
|
|
7085
|
-
return
|
|
7097
|
+
return v2;
|
|
7086
7098
|
}
|
|
7087
7099
|
};
|
|
7088
7100
|
return { title: fill(step.title), text: fill(step.text) };
|
|
@@ -7816,22 +7828,22 @@ var RENDERER_CSS = `
|
|
|
7816
7828
|
`;
|
|
7817
7829
|
|
|
7818
7830
|
// src/components/urlSync.ts
|
|
7819
|
-
function encodeValue(kind,
|
|
7820
|
-
if (
|
|
7821
|
-
if (kind === "DateRange" && typeof
|
|
7822
|
-
const r =
|
|
7831
|
+
function encodeValue(kind, v2) {
|
|
7832
|
+
if (v2 === null || v2 === void 0 || v2 === "" || Array.isArray(v2) && v2.length === 0) return null;
|
|
7833
|
+
if (kind === "DateRange" && typeof v2 === "object") {
|
|
7834
|
+
const r = v2;
|
|
7823
7835
|
return r.preset && r.preset !== "custom" ? r.preset : `${r.from}..${r.to}`;
|
|
7824
7836
|
}
|
|
7825
|
-
if (Array.isArray(
|
|
7826
|
-
if (typeof
|
|
7827
|
-
return String(
|
|
7837
|
+
if (Array.isArray(v2)) return v2.map(String).join(",");
|
|
7838
|
+
if (typeof v2 === "object") return JSON.stringify(v2);
|
|
7839
|
+
return String(v2);
|
|
7828
7840
|
}
|
|
7829
7841
|
function matchOption(def, s) {
|
|
7830
7842
|
const opts = def?.options;
|
|
7831
7843
|
if (!Array.isArray(opts)) return s;
|
|
7832
7844
|
for (const o of opts) {
|
|
7833
|
-
const
|
|
7834
|
-
if (String(
|
|
7845
|
+
const v2 = o && typeof o === "object" ? o.value : o;
|
|
7846
|
+
if (String(v2) === s) return v2;
|
|
7835
7847
|
}
|
|
7836
7848
|
return s;
|
|
7837
7849
|
}
|
|
@@ -7849,20 +7861,20 @@ function decodeValue(kind, s, def, time = {}) {
|
|
|
7849
7861
|
function readUrlState(search, variables, prefix, time = {}) {
|
|
7850
7862
|
const params = new URLSearchParams(search);
|
|
7851
7863
|
const filters = {};
|
|
7852
|
-
for (const
|
|
7853
|
-
if ((
|
|
7854
|
-
const raw = params.get(`${prefix}${
|
|
7855
|
-
if (raw !== null) filters[
|
|
7864
|
+
for (const v2 of variables) {
|
|
7865
|
+
if ((v2.persist ?? "url") !== "url") continue;
|
|
7866
|
+
const raw = params.get(`${prefix}${v2.name}`);
|
|
7867
|
+
if (raw !== null) filters[v2.name] = decodeValue(v2.kind, raw, v2, time);
|
|
7856
7868
|
}
|
|
7857
7869
|
const view = params.get(`${prefix}view`);
|
|
7858
7870
|
return { filters, view };
|
|
7859
7871
|
}
|
|
7860
7872
|
function writeUrlState(href, variables, prefix, filters, view) {
|
|
7861
7873
|
const url = new URL(href);
|
|
7862
|
-
for (const
|
|
7863
|
-
if ((
|
|
7864
|
-
const key = `${prefix}${
|
|
7865
|
-
const enc = encodeValue(
|
|
7874
|
+
for (const v2 of variables) {
|
|
7875
|
+
if ((v2.persist ?? "url") !== "url") continue;
|
|
7876
|
+
const key = `${prefix}${v2.name}`;
|
|
7877
|
+
const enc = encodeValue(v2.kind, filters[v2.name]);
|
|
7866
7878
|
if (enc === null) url.searchParams.delete(key);
|
|
7867
7879
|
else url.searchParams.set(key, enc);
|
|
7868
7880
|
}
|
|
@@ -7892,10 +7904,10 @@ function usesScripts(doc) {
|
|
|
7892
7904
|
}
|
|
7893
7905
|
return false;
|
|
7894
7906
|
};
|
|
7895
|
-
const walk = (
|
|
7896
|
-
if (Array.isArray(
|
|
7897
|
-
if (!
|
|
7898
|
-
const o =
|
|
7907
|
+
const walk = (v2) => {
|
|
7908
|
+
if (Array.isArray(v2)) return v2.some(walk);
|
|
7909
|
+
if (!v2 || typeof v2 !== "object") return false;
|
|
7910
|
+
const o = v2;
|
|
7899
7911
|
if (typeof o.fn === "string") return true;
|
|
7900
7912
|
if (o.do === "script" && typeof o.code === "string") return true;
|
|
7901
7913
|
for (const [k, x] of Object.entries(o)) {
|
|
@@ -7935,8 +7947,8 @@ var devWarn = (message) => {
|
|
|
7935
7947
|
function toCsv(rows) {
|
|
7936
7948
|
if (!Array.isArray(rows) || rows.length === 0) return "";
|
|
7937
7949
|
const cols = [...new Set(rows.flatMap((r) => r && typeof r === "object" ? Object.keys(r) : []))];
|
|
7938
|
-
const cell = (
|
|
7939
|
-
const s =
|
|
7950
|
+
const cell = (v2) => {
|
|
7951
|
+
const s = v2 === null || v2 === void 0 ? "" : typeof v2 === "object" ? JSON.stringify(v2) : String(v2);
|
|
7940
7952
|
return /[",\n]/.test(s) ? `"${s.replace(/"/g, '""')}"` : s;
|
|
7941
7953
|
};
|
|
7942
7954
|
return [cols.join(","), ...rows.map((r) => cols.map((c) => cell(r[c])).join(","))].join("\n");
|
|
@@ -8289,7 +8301,7 @@ var DashboardRenderer = forwardRef(
|
|
|
8289
8301
|
breakpoint: props.breakpoint
|
|
8290
8302
|
}
|
|
8291
8303
|
);
|
|
8292
|
-
return /* @__PURE__ */ jsxs23(ThemeScope, { theme: picked.theme, mode: picked.mode, children: [
|
|
8304
|
+
return /* @__PURE__ */ jsxs23(ThemeScope, { theme: picked.theme, mode: props.colorMode ?? picked.mode, children: [
|
|
8293
8305
|
/* @__PURE__ */ jsx31("style", { dangerouslySetInnerHTML: { __html: RENDERER_CSS } }),
|
|
8294
8306
|
/* @__PURE__ */ jsx31(
|
|
8295
8307
|
Boundary,
|
|
@@ -8332,12 +8344,12 @@ function DashboardBody({
|
|
|
8332
8344
|
useCallback9(
|
|
8333
8345
|
(t) => {
|
|
8334
8346
|
const sc = rootScope(t, runtime.helpers);
|
|
8335
|
-
const text2 = (
|
|
8336
|
-
if (!
|
|
8347
|
+
const text2 = (v2) => {
|
|
8348
|
+
if (!v2) return void 0;
|
|
8337
8349
|
try {
|
|
8338
|
-
return String(interpolate(
|
|
8350
|
+
return String(interpolate(v2, sc) ?? "");
|
|
8339
8351
|
} catch {
|
|
8340
|
-
return
|
|
8352
|
+
return v2;
|
|
8341
8353
|
}
|
|
8342
8354
|
};
|
|
8343
8355
|
return {
|
|
@@ -8382,7 +8394,7 @@ function DashboardBody({
|
|
|
8382
8394
|
flowStyle: (id, height) => {
|
|
8383
8395
|
const panel = doc.spec.panels[id];
|
|
8384
8396
|
const st = panel?.style;
|
|
8385
|
-
const px2 = (
|
|
8397
|
+
const px2 = (v2) => typeof v2 === "number" ? `${v2}px` : v2;
|
|
8386
8398
|
return {
|
|
8387
8399
|
flex: st?.flex ?? "1 1 100%",
|
|
8388
8400
|
// Charts and images size themselves to the card, so their card keeps its grid height; anything
|
|
@@ -8418,6 +8430,20 @@ function PartError({ what, error }) {
|
|
|
8418
8430
|
] });
|
|
8419
8431
|
}
|
|
8420
8432
|
|
|
8433
|
+
// src/theme/token.ts
|
|
8434
|
+
var kebab2 = (s) => s.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
|
|
8435
|
+
var v = (prefix, path) => `var(--ds-${prefix}-${path.split(".").map(kebab2).join("-")})`;
|
|
8436
|
+
var token = {
|
|
8437
|
+
/** A colour of the active mode: `token.color("status.good.fg")`. */
|
|
8438
|
+
color: (path) => v("color", path),
|
|
8439
|
+
/** A spacing step: `token.space("md")`. */
|
|
8440
|
+
space: (step) => v("space", step),
|
|
8441
|
+
/** A corner radius: `token.radius("card")`. */
|
|
8442
|
+
radius: (name) => v("radius", name),
|
|
8443
|
+
/** A font family: `token.font("heading")`. */
|
|
8444
|
+
font: (name) => `var(--ds-font-${name})`
|
|
8445
|
+
};
|
|
8446
|
+
|
|
8421
8447
|
// src/widgets/wrap.tsx
|
|
8422
8448
|
import { Suspense, lazy } from "react";
|
|
8423
8449
|
import { z as z17 } from "zod";
|
|
@@ -8587,6 +8613,7 @@ export {
|
|
|
8587
8613
|
themeCssVars,
|
|
8588
8614
|
themeStylesheet,
|
|
8589
8615
|
timeSettingsFor,
|
|
8616
|
+
token,
|
|
8590
8617
|
translator,
|
|
8591
8618
|
trustedRunner,
|
|
8592
8619
|
useDashSpecSettings,
|