@dashspec/renderer 0.1.6 → 0.1.8

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/dist/index.js CHANGED
@@ -115,7 +115,7 @@ import {
115
115
  translator,
116
116
  validateDocument,
117
117
  widgetChecks
118
- } from "./chunk-U4JCC3MX.js";
118
+ } from "./chunk-CLT55JEM.js";
119
119
  import {
120
120
  createStateProxy,
121
121
  getPath,
@@ -1465,7 +1465,13 @@ function createDashboardRuntime(doc, options = {}) {
1465
1465
  }
1466
1466
 
1467
1467
  // src/theme/ThemeScope.tsx
1468
- import { createContext as createContext2, useContext as useContext2, useMemo, useSyncExternalStore as useSyncExternalStore2 } from "react";
1468
+ import {
1469
+ createContext as createContext2,
1470
+ useContext as useContext2,
1471
+ useId,
1472
+ useMemo,
1473
+ useSyncExternalStore as useSyncExternalStore2
1474
+ } from "react";
1469
1475
 
1470
1476
  // src/theme/defaultTheme.ts
1471
1477
  var scale = {
@@ -1606,7 +1612,8 @@ function createTheme(input = {}) {
1606
1612
  mode: input.mode ?? base.mode,
1607
1613
  scale: scale2,
1608
1614
  light: mergeDeep(mergeDeep(base.light, shortcut), input.light),
1609
- dark: mergeDeep(mergeDeep(base.dark, shortcut), input.dark)
1615
+ dark: mergeDeep(mergeDeep(base.dark, shortcut), input.dark),
1616
+ ...base.widgets || input.widgets ? { widgets: mergeDeep(base.widgets ?? {}, input.widgets) } : {}
1610
1617
  };
1611
1618
  }
1612
1619
  function resolveMode(theme, prefersDark) {
@@ -1691,9 +1698,21 @@ ${Object.entries(vars).filter(([k, v]) => SAFE_NAME.test(k) && !UNSAFE_CSS.test(
1691
1698
  block(`${selector}[data-ds-theme="dark"]`, themeCssVars(theme, "dark"))
1692
1699
  ].join("\n\n");
1693
1700
  }
1701
+ function widgetThemeCss(theme, scope2) {
1702
+ const out = [];
1703
+ for (const [kind, w] of Object.entries(theme.widgets ?? {})) {
1704
+ if (!/^[A-Za-z][\w.-]*$/.test(kind) || !w) continue;
1705
+ const sel = `${scope2} .ds-panel[data-kind="${kind}"]`;
1706
+ const vars = Object.entries(w.vars ?? {}).filter(([k, v]) => SAFE_NAME.test(k) && !UNSAFE_CSS.test(String(v)));
1707
+ if (vars.length) out.push(`${sel} { ${vars.map(([k, v]) => `${k}: ${v};`).join(" ")} }`);
1708
+ if (w.css && !/<\/?\s*style/i.test(w.css))
1709
+ out.push(w.css.includes("&") ? w.css.replaceAll("&", sel) : `${sel} { ${w.css} }`);
1710
+ }
1711
+ return out.join("\n");
1712
+ }
1694
1713
 
1695
1714
  // src/theme/ThemeScope.tsx
1696
- import { jsx } from "react/jsx-runtime";
1715
+ import { jsx, jsxs } from "react/jsx-runtime";
1697
1716
  var DARK_QUERY = "(prefers-color-scheme: dark)";
1698
1717
  var subscribeDark = (onChange) => {
1699
1718
  const mq = typeof window !== "undefined" ? window.matchMedia?.(DARK_QUERY) : void 0;
@@ -1714,11 +1733,14 @@ function ThemeScope({ theme, mode, className, style, children }) {
1714
1733
  const resolved = resolveMode(mode ? { ...theme, mode } : theme, prefersDark);
1715
1734
  const vars = useMemo(() => themeCssVars(theme, resolved), [theme, resolved]);
1716
1735
  const ctx = useMemo(() => ({ theme, mode: resolved }), [theme, resolved]);
1717
- return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx(
1736
+ const scopeId = useId();
1737
+ const widgetCss = useMemo(() => widgetThemeCss(theme, `[data-ds-scope="${scopeId}"]`), [theme, scopeId]);
1738
+ return /* @__PURE__ */ jsx(ThemeContext.Provider, { value: ctx, children: /* @__PURE__ */ jsxs(
1718
1739
  "div",
1719
1740
  {
1720
1741
  className: className ? `ds-root ${className}` : "ds-root",
1721
1742
  "data-ds-theme": resolved,
1743
+ "data-ds-scope": widgetCss ? scopeId : void 0,
1722
1744
  style: {
1723
1745
  ...vars,
1724
1746
  background: "var(--ds-color-surface-backdrop)",
@@ -1726,7 +1748,10 @@ function ThemeScope({ theme, mode, className, style, children }) {
1726
1748
  fontFamily: "var(--ds-font-body)",
1727
1749
  ...style
1728
1750
  },
1729
- children
1751
+ children: [
1752
+ widgetCss && /* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: { __html: widgetCss } }),
1753
+ children
1754
+ ]
1730
1755
  }
1731
1756
  ) });
1732
1757
  }
@@ -1792,7 +1817,7 @@ function deepMerge(base, extra) {
1792
1817
  }
1793
1818
 
1794
1819
  // src/widgets/builtins/Breakdown.tsx
1795
- import { jsx as jsx2, jsxs } from "react/jsx-runtime";
1820
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
1796
1821
  var Breakdown = defineWidget({
1797
1822
  ...BreakdownContract,
1798
1823
  implements: "breakdown",
@@ -1821,7 +1846,7 @@ var Breakdown = defineWidget({
1821
1846
  let acc = 0;
1822
1847
  const r = 40;
1823
1848
  const c = 2 * Math.PI * r;
1824
- return /* @__PURE__ */ jsxs("div", { className: "ds-donut", children: [
1849
+ return /* @__PURE__ */ jsxs2("div", { className: "ds-donut", children: [
1825
1850
  /* @__PURE__ */ jsx2("svg", { viewBox: "0 0 100 100", role: "img", "aria-label": spec.title, children: items.map((it, i) => {
1826
1851
  const len = it.value / sum * c;
1827
1852
  const el = (
@@ -1864,7 +1889,7 @@ var Breakdown = defineWidget({
1864
1889
  ] });
1865
1890
  }
1866
1891
  if (spec.mode === "segmented")
1867
- return /* @__PURE__ */ jsxs("div", { children: [
1892
+ return /* @__PURE__ */ jsxs2("div", { children: [
1868
1893
  /* @__PURE__ */ jsx2("div", { className: "ds-segbar", role: "img", "aria-label": spec.title, children: items.map((it, i) => /* @__PURE__ */ jsx2(
1869
1894
  "button",
1870
1895
  {
@@ -1890,12 +1915,12 @@ var Breakdown = defineWidget({
1890
1915
  }
1891
1916
  )
1892
1917
  ] });
1893
- return /* @__PURE__ */ jsx2("ul", { className: "ds-meters", children: items.map((it, i) => /* @__PURE__ */ jsx2("li", { children: /* @__PURE__ */ jsxs("button", { type: "button", onClick: () => on(i, "click"), onMouseEnter: () => on(i, "hover"), children: [
1894
- /* @__PURE__ */ jsxs("span", { className: "ds-meter-head", children: [
1918
+ return /* @__PURE__ */ jsx2("ul", { className: "ds-meters", children: items.map((it, i) => /* @__PURE__ */ jsx2("li", { children: /* @__PURE__ */ jsxs2("button", { type: "button", onClick: () => on(i, "click"), onMouseEnter: () => on(i, "hover"), children: [
1919
+ /* @__PURE__ */ jsxs2("span", { className: "ds-meter-head", children: [
1895
1920
  /* @__PURE__ */ jsx2("span", { children: it.label }),
1896
- /* @__PURE__ */ jsxs("span", { className: "ds-meter-value", children: [
1921
+ /* @__PURE__ */ jsxs2("span", { className: "ds-meter-value", children: [
1897
1922
  fmt(it.value),
1898
- spec.showPercent && /* @__PURE__ */ jsxs("span", { className: "ds-kpi-sub", children: [
1923
+ spec.showPercent && /* @__PURE__ */ jsxs2("span", { className: "ds-kpi-sub", children: [
1899
1924
  " \xB7 ",
1900
1925
  helpers.fmt.percent(it.value / sum * 100)
1901
1926
  ] })
@@ -1914,12 +1939,12 @@ function Legend({
1914
1939
  helpers,
1915
1940
  onClick
1916
1941
  }) {
1917
- return /* @__PURE__ */ jsx2("ul", { className: "ds-legend", children: items.map((it, i) => /* @__PURE__ */ jsx2("li", { children: /* @__PURE__ */ jsxs("button", { type: "button", onClick: () => onClick(i), children: [
1942
+ return /* @__PURE__ */ jsx2("ul", { className: "ds-legend", children: items.map((it, i) => /* @__PURE__ */ jsx2("li", { children: /* @__PURE__ */ jsxs2("button", { type: "button", onClick: () => onClick(i), children: [
1918
1943
  /* @__PURE__ */ jsx2("span", { className: "ds-dot", style: { background: color2(i) }, "aria-hidden": "true" }),
1919
1944
  it.label,
1920
1945
  " ",
1921
1946
  /* @__PURE__ */ jsx2("strong", { children: fmt(it.value) }),
1922
- showPercent && /* @__PURE__ */ jsxs("span", { className: "ds-kpi-sub", children: [
1947
+ showPercent && /* @__PURE__ */ jsxs2("span", { className: "ds-kpi-sub", children: [
1923
1948
  " ",
1924
1949
  helpers.fmt.percent(it.value / sum * 100)
1925
1950
  ] })
@@ -1928,7 +1953,7 @@ function Legend({
1928
1953
 
1929
1954
  // src/widgets/builtins/CardGrid.tsx
1930
1955
  import "zod";
1931
- import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
1956
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1932
1957
  var CardGrid = defineWidget({
1933
1958
  ...CardGridContract,
1934
1959
  implements: "cards",
@@ -1951,7 +1976,7 @@ var CardGrid = defineWidget({
1951
1976
  const pv = spec.progress ? toNumber(field(r, spec.progress.value)) : void 0;
1952
1977
  const pmax = spec.progress ? typeof spec.progress.max === "number" ? spec.progress.max : toNumber(field(r, spec.progress.max)) : void 0;
1953
1978
  const active = spec.selectable && spec.selected !== void 0 && spec.selected === key;
1954
- return /* @__PURE__ */ jsxs2(
1979
+ return /* @__PURE__ */ jsxs3(
1955
1980
  "button",
1956
1981
  {
1957
1982
  type: "button",
@@ -1963,7 +1988,7 @@ var CardGrid = defineWidget({
1963
1988
  if (spec.selectable) emit("select", "card", { datum: r, value: key, index: i });
1964
1989
  },
1965
1990
  children: [
1966
- /* @__PURE__ */ jsxs2("span", { className: "ds-card-head", children: [
1991
+ /* @__PURE__ */ jsxs3("span", { className: "ds-card-head", children: [
1967
1992
  /* @__PURE__ */ jsx3("strong", { children: String(field(r, spec.cardTitle) ?? "") }),
1968
1993
  status && /* @__PURE__ */ jsx3(
1969
1994
  "span",
@@ -1975,9 +2000,9 @@ var CardGrid = defineWidget({
1975
2000
  ),
1976
2001
  spec.badge && /* @__PURE__ */ jsx3("span", { className: "ds-chip-count", children: String(field(r, spec.badge) ?? "") })
1977
2002
  ] }),
1978
- /* @__PURE__ */ jsx3("dl", { className: "ds-card-fields", children: spec.fields.map((f) => /* @__PURE__ */ jsxs2("div", { children: [
2003
+ /* @__PURE__ */ jsx3("dl", { className: "ds-card-fields", children: spec.fields.map((f) => /* @__PURE__ */ jsxs3("div", { children: [
1979
2004
  /* @__PURE__ */ jsx3("dt", { children: f.label ?? f.key }),
1980
- /* @__PURE__ */ jsxs2("dd", { children: [
2005
+ /* @__PURE__ */ jsxs3("dd", { children: [
1981
2006
  formatValue(field(r, f.key), helpers, f.format, f.decimals),
1982
2007
  f.unit ? ` ${f.unit}` : ""
1983
2008
  ] })
@@ -2042,7 +2067,7 @@ import "zod";
2042
2067
 
2043
2068
  // src/widgets/shared/Markdown.tsx
2044
2069
  import { Fragment } from "react";
2045
- import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
2070
+ import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
2046
2071
  function Markdown({ text, onAction }) {
2047
2072
  const blocks = text.replace(/\r\n/g, "\n").split(/\n{2,}/);
2048
2073
  return /* @__PURE__ */ jsx5(Fragment2, { children: blocks.map((b, i) => {
@@ -2058,7 +2083,7 @@ function Markdown({ text, onAction }) {
2058
2083
  const Tag = `h${level}`;
2059
2084
  return /* @__PURE__ */ jsx5(Tag, { className: "ds-md-h", children: inline(h[2], onAction) }, key);
2060
2085
  }
2061
- return /* @__PURE__ */ jsx5("p", { className: "ds-md-p", children: lines.map((l, j) => /* @__PURE__ */ jsxs3(Fragment, { children: [
2086
+ return /* @__PURE__ */ jsx5("p", { className: "ds-md-p", children: lines.map((l, j) => /* @__PURE__ */ jsxs4(Fragment, { children: [
2062
2087
  j > 0 && /* @__PURE__ */ jsx5("br", {}),
2063
2088
  inline(l, onAction)
2064
2089
  ] }, `${j}-${l}`)) }, key);
@@ -2130,19 +2155,19 @@ import { useCallback as useCallback3 } from "react";
2130
2155
  import "zod";
2131
2156
 
2132
2157
  // src/components/FilterBar.tsx
2133
- import { useCallback as useCallback2, useEffect as useEffect2, useId as useId2, useRef as useRef3, useState as useState2 } from "react";
2158
+ import { useCallback as useCallback2, useEffect as useEffect2, useId as useId3, useRef as useRef3, useState as useState2 } from "react";
2134
2159
 
2135
2160
  // src/components/controls.tsx
2136
2161
  import {
2137
2162
  useEffect,
2138
- useId,
2163
+ useId as useId2,
2139
2164
  useLayoutEffect,
2140
2165
  useMemo as useMemo2,
2141
2166
  useRef as useRef2,
2142
2167
  useState
2143
2168
  } from "react";
2144
2169
  import { createPortal } from "react-dom";
2145
- import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
2170
+ import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
2146
2171
  var Chevron = () => /* @__PURE__ */ jsx7("svg", { className: "ds-pill-chev", viewBox: "0 0 16 16", width: "14", height: "14", "aria-hidden": "true", children: /* @__PURE__ */ jsx7(
2147
2172
  "path",
2148
2173
  {
@@ -2165,7 +2190,7 @@ var Arrow = ({ dir }) => /* @__PURE__ */ jsx7("svg", { viewBox: "0 0 16 16", wid
2165
2190
  strokeLinejoin: "round"
2166
2191
  }
2167
2192
  ) });
2168
- var Calendar = () => /* @__PURE__ */ jsxs4("svg", { viewBox: "0 0 16 16", width: "15", height: "15", "aria-hidden": "true", children: [
2193
+ var Calendar = () => /* @__PURE__ */ jsxs5("svg", { viewBox: "0 0 16 16", width: "15", height: "15", "aria-hidden": "true", children: [
2169
2194
  /* @__PURE__ */ jsx7("rect", { x: "2.5", y: "3.5", width: "11", height: "10", rx: "2", fill: "none", stroke: "currentColor", strokeWidth: "1.3" }),
2170
2195
  /* @__PURE__ */ jsx7("path", { d: "M2.5 6.5h11M5.5 2v3M10.5 2v3", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round" })
2171
2196
  ] });
@@ -2268,7 +2293,7 @@ function PillTrigger({
2268
2293
  controls,
2269
2294
  ariaLabel
2270
2295
  }) {
2271
- return /* @__PURE__ */ jsxs4(
2296
+ return /* @__PURE__ */ jsxs5(
2272
2297
  "button",
2273
2298
  {
2274
2299
  ref: triggerRef,
@@ -2281,10 +2306,10 @@ function PillTrigger({
2281
2306
  onClick,
2282
2307
  children: [
2283
2308
  icon2,
2284
- label ? /* @__PURE__ */ jsxs4("span", { children: [
2309
+ label ? /* @__PURE__ */ jsxs5("span", { children: [
2285
2310
  label,
2286
2311
  " ",
2287
- /* @__PURE__ */ jsxs4("span", { className: "ds-pill-value", children: [
2312
+ /* @__PURE__ */ jsxs5("span", { className: "ds-pill-value", children: [
2288
2313
  "(",
2289
2314
  value,
2290
2315
  ")"
@@ -2330,7 +2355,7 @@ function OptionList({
2330
2355
  } else return;
2331
2356
  e.preventDefault();
2332
2357
  };
2333
- return /* @__PURE__ */ jsxs4(
2358
+ return /* @__PURE__ */ jsxs5(
2334
2359
  "div",
2335
2360
  {
2336
2361
  className: "ds-menu",
@@ -2344,7 +2369,7 @@ function OptionList({
2344
2369
  options.length === 0 && /* @__PURE__ */ jsx7("div", { className: "ds-menu-empty", children: "No options" }),
2345
2370
  options.map((o, i) => {
2346
2371
  const sel = isSelected(o.value);
2347
- return /* @__PURE__ */ jsxs4(
2372
+ return /* @__PURE__ */ jsxs5(
2348
2373
  "button",
2349
2374
  {
2350
2375
  type: "button",
@@ -2392,10 +2417,10 @@ function SelectControl({
2392
2417
  ariaLabel
2393
2418
  }) {
2394
2419
  const p = usePopover();
2395
- const id = useId();
2420
+ const id = useId2();
2396
2421
  const i = options.findIndex((o) => o.value === value);
2397
2422
  const current = i >= 0 ? options[i].label : value === null || value === void 0 || value === "" ? allLabel : String(value);
2398
- const pill = /* @__PURE__ */ jsxs4(
2423
+ const pill = /* @__PURE__ */ jsxs5(
2399
2424
  "div",
2400
2425
  {
2401
2426
  className: "ds-dd",
@@ -2433,7 +2458,7 @@ function SelectControl({
2433
2458
  }
2434
2459
  );
2435
2460
  if (!stepper) return pill;
2436
- return /* @__PURE__ */ jsxs4("div", { className: "ds-stepper", role: "group", "aria-label": label, children: [
2461
+ return /* @__PURE__ */ jsxs5("div", { className: "ds-stepper", role: "group", "aria-label": label, children: [
2437
2462
  /* @__PURE__ */ jsx7(
2438
2463
  "button",
2439
2464
  {
@@ -2470,11 +2495,11 @@ function MultiSelectControl({
2470
2495
  ariaLabel
2471
2496
  }) {
2472
2497
  const p = usePopover();
2473
- const id = useId();
2498
+ const id = useId2();
2474
2499
  const chosen = Array.isArray(value) ? value : [];
2475
2500
  const names = options.filter((o) => chosen.includes(o.value)).map((o) => o.label);
2476
2501
  const text = chosen.length === 0 ? emptyLabel : names.length <= 2 ? names.join(", ") : `${chosen.length} selected`;
2477
- return /* @__PURE__ */ jsxs4("div", { className: "ds-dd", ref: p.root, "data-block": block || void 0, "data-plain": plain || void 0, children: [
2502
+ return /* @__PURE__ */ jsxs5("div", { className: "ds-dd", ref: p.root, "data-block": block || void 0, "data-plain": plain || void 0, children: [
2478
2503
  /* @__PURE__ */ jsx7(
2479
2504
  PillTrigger,
2480
2505
  {
@@ -2487,7 +2512,7 @@ function MultiSelectControl({
2487
2512
  ariaLabel
2488
2513
  }
2489
2514
  ),
2490
- p.open && /* @__PURE__ */ jsxs4(Floating, { anchor: p.trigger, floatingRef: p.floating, children: [
2515
+ p.open && /* @__PURE__ */ jsxs5(Floating, { anchor: p.trigger, floatingRef: p.floating, children: [
2491
2516
  /* @__PURE__ */ jsx7(
2492
2517
  OptionList,
2493
2518
  {
@@ -2498,9 +2523,9 @@ function MultiSelectControl({
2498
2523
  onPick: (o) => onChange(chosen.includes(o.value) ? chosen.filter((x) => x !== o.value) : [...chosen, o.value])
2499
2524
  }
2500
2525
  ),
2501
- chosen.length > 0 && /* @__PURE__ */ jsxs4("div", { className: "ds-pop-foot", children: [
2526
+ chosen.length > 0 && /* @__PURE__ */ jsxs5("div", { className: "ds-pop-foot", children: [
2502
2527
  /* @__PURE__ */ jsx7("button", { type: "button", className: "ds-link", onClick: () => onChange([]), children: "Clear" }),
2503
- /* @__PURE__ */ jsxs4("span", { children: [
2528
+ /* @__PURE__ */ jsxs5("span", { children: [
2504
2529
  chosen.length,
2505
2530
  " selected"
2506
2531
  ] })
@@ -2560,7 +2585,7 @@ function Month({
2560
2585
  }),
2561
2586
  [locale]
2562
2587
  );
2563
- return /* @__PURE__ */ jsxs4("div", { className: "ds-cal-grid", ref: grid, role: "group", "aria-label": month, onKeyDown: onKey, children: [
2588
+ return /* @__PURE__ */ jsxs5("div", { className: "ds-cal-grid", ref: grid, role: "group", "aria-label": month, onKeyDown: onKey, children: [
2564
2589
  weekdays.map((w) => /* @__PURE__ */ jsx7("span", { className: "ds-cal-wd", children: w.label }, w.key)),
2565
2590
  lead > 0 && /* @__PURE__ */ jsx7("span", { style: { gridColumn: `span ${lead}` } }),
2566
2591
  Array.from({ length: days }, (_, i) => {
@@ -2605,7 +2630,7 @@ function DateRangeControl({
2605
2630
  onReject
2606
2631
  }) {
2607
2632
  const p = usePopover();
2608
- const id = useId();
2633
+ const id = useId2();
2609
2634
  const short = (d) => parse2(d).toLocaleDateString(locale, { day: "numeric", month: "short", timeZone: "UTC" });
2610
2635
  const [draft, setDraft] = useState({});
2611
2636
  const [hover, setHover] = useState();
@@ -2652,8 +2677,8 @@ function DateRangeControl({
2652
2677
  });
2653
2678
  const canPrev = !min || `${month}-01` > min;
2654
2679
  const canNext = !max || addDays2(iso(new Date(Date.UTC(Number(month.slice(0, 4)), Number(month.slice(5, 7)), 0))), 1) <= max;
2655
- return /* @__PURE__ */ jsxs4("div", { className: "ds-dd", ref: p.root, children: [
2656
- /* @__PURE__ */ jsxs4(
2680
+ return /* @__PURE__ */ jsxs5("div", { className: "ds-dd", ref: p.root, children: [
2681
+ /* @__PURE__ */ jsxs5(
2657
2682
  "button",
2658
2683
  {
2659
2684
  ref: p.trigger,
@@ -2665,11 +2690,11 @@ function DateRangeControl({
2665
2690
  onClick: () => p.setOpen(!p.open),
2666
2691
  children: [
2667
2692
  /* @__PURE__ */ jsx7(Calendar, {}),
2668
- /* @__PURE__ */ jsxs4("span", { children: [
2693
+ /* @__PURE__ */ jsxs5("span", { children: [
2669
2694
  label && !value.preset ? `${label} ` : "",
2670
2695
  name,
2671
2696
  " ",
2672
- range && /* @__PURE__ */ jsxs4("span", { className: "ds-pill-value", children: [
2697
+ range && /* @__PURE__ */ jsxs5("span", { className: "ds-pill-value", children: [
2673
2698
  "(",
2674
2699
  range,
2675
2700
  ")"
@@ -2688,10 +2713,10 @@ function DateRangeControl({
2688
2713
  id,
2689
2714
  role: "dialog",
2690
2715
  label: label ?? "Choose dates",
2691
- children: /* @__PURE__ */ jsxs4("div", { className: "ds-range", children: [
2716
+ children: /* @__PURE__ */ jsxs5("div", { className: "ds-range", children: [
2692
2717
  presets.filter((x) => x !== "custom").length > 0 && /* @__PURE__ */ jsx7("div", { className: "ds-range-presets", children: presets.filter((x) => x !== "custom").map((x) => {
2693
2718
  const r = presetRange2(x);
2694
- return /* @__PURE__ */ jsxs4(
2719
+ return /* @__PURE__ */ jsxs5(
2695
2720
  "button",
2696
2721
  {
2697
2722
  type: "button",
@@ -2709,8 +2734,8 @@ function DateRangeControl({
2709
2734
  x
2710
2735
  );
2711
2736
  }) }),
2712
- /* @__PURE__ */ jsxs4("div", { className: "ds-cal", children: [
2713
- /* @__PURE__ */ jsxs4("div", { className: "ds-cal-head", children: [
2737
+ /* @__PURE__ */ jsxs5("div", { className: "ds-cal", children: [
2738
+ /* @__PURE__ */ jsxs5("div", { className: "ds-cal-head", children: [
2714
2739
  /* @__PURE__ */ jsx7(
2715
2740
  "button",
2716
2741
  {
@@ -2751,7 +2776,7 @@ function DateRangeControl({
2751
2776
  focusDate
2752
2777
  }
2753
2778
  ),
2754
- !single && /* @__PURE__ */ jsxs4("div", { className: "ds-pop-foot", children: [
2779
+ !single && /* @__PURE__ */ jsxs5("div", { className: "ds-pop-foot", children: [
2755
2780
  /* @__PURE__ */ jsx7("span", { className: tooLong ? "ds-cal-error" : void 0, children: tooLong ? `Pick a range of ${maxDays} days or less` : draft.from && draft.to ? `${short(draft.from)} \u2013 ${short(draft.to)} \xB7 ${daysBetween(draft.from, draft.to)} days` : draft.from ? "Now pick the end date" : "Pick the start date" }),
2756
2781
  /* @__PURE__ */ jsx7(
2757
2782
  "button",
@@ -2800,7 +2825,7 @@ function DateControl({
2800
2825
  }
2801
2826
  );
2802
2827
  if (!stepper) return control;
2803
- return /* @__PURE__ */ jsxs4("div", { className: "ds-stepper", role: "group", "aria-label": label, children: [
2828
+ return /* @__PURE__ */ jsxs5("div", { className: "ds-stepper", role: "group", "aria-label": label, children: [
2804
2829
  /* @__PURE__ */ jsx7(
2805
2830
  "button",
2806
2831
  {
@@ -2828,7 +2853,7 @@ function DateControl({
2828
2853
  }
2829
2854
 
2830
2855
  // src/components/FilterBar.tsx
2831
- import { Fragment as Fragment3, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
2856
+ import { Fragment as Fragment3, jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
2832
2857
  var PRESET_LABELS = {
2833
2858
  today: "Today",
2834
2859
  yesterday: "Yesterday",
@@ -2990,7 +3015,7 @@ function ControlField({
2990
3015
  const toggle = (v) => multi ? onChange(chosen.includes(v) ? chosen.filter((x) => x !== v) : [...chosen, v]) : onChange(value === v ? null : v);
2991
3016
  return (
2992
3017
  // biome-ignore lint/a11y/useSemanticElements: a chip group, not a form fieldset
2993
- /* @__PURE__ */ jsx8("div", { className: "ds-chips", role: "group", "aria-label": label ?? String(def.name), children: options.map((o, k) => /* @__PURE__ */ jsxs5(
3018
+ /* @__PURE__ */ jsx8("div", { className: "ds-chips", role: "group", "aria-label": label ?? String(def.name), children: options.map((o, k) => /* @__PURE__ */ jsxs6(
2994
3019
  "button",
2995
3020
  {
2996
3021
  type: "button",
@@ -3008,8 +3033,8 @@ function ControlField({
3008
3033
  }
3009
3034
  case "Search": {
3010
3035
  const wait = def.debounce ? parseDuration(def.debounce) : 300;
3011
- return /* @__PURE__ */ jsxs5("label", { className: "ds-search", children: [
3012
- /* @__PURE__ */ jsxs5("svg", { viewBox: "0 0 16 16", width: "15", height: "15", "aria-hidden": "true", children: [
3036
+ return /* @__PURE__ */ jsxs6("label", { className: "ds-search", children: [
3037
+ /* @__PURE__ */ jsxs6("svg", { viewBox: "0 0 16 16", width: "15", height: "15", "aria-hidden": "true", children: [
3013
3038
  /* @__PURE__ */ jsx8("circle", { cx: "7", cy: "7", r: "4.5", fill: "none", stroke: "currentColor", strokeWidth: "1.5" }),
3014
3039
  /* @__PURE__ */ jsx8("path", { d: "m10.5 10.5 3 3", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
3015
3040
  ] }),
@@ -3031,7 +3056,7 @@ function ControlField({
3031
3056
  ] });
3032
3057
  }
3033
3058
  case "Toggle":
3034
- return /* @__PURE__ */ jsxs5("label", { className: "ds-switch", children: [
3059
+ return /* @__PURE__ */ jsxs6("label", { className: "ds-switch", children: [
3035
3060
  /* @__PURE__ */ jsx8(
3036
3061
  "input",
3037
3062
  {
@@ -3127,7 +3152,7 @@ var icon = (d) => /* @__PURE__ */ jsx8(
3127
3152
  );
3128
3153
  var BAR_ICONS = {
3129
3154
  sliders: icon(
3130
- /* @__PURE__ */ jsxs5(Fragment3, { children: [
3155
+ /* @__PURE__ */ jsxs6(Fragment3, { children: [
3131
3156
  /* @__PURE__ */ jsx8("path", { d: "M3 6h9M15 6h2M3 14h3M9 14h8" }),
3132
3157
  /* @__PURE__ */ jsx8("circle", { cx: "13.5", cy: "6", r: "1.8" }),
3133
3158
  /* @__PURE__ */ jsx8("circle", { cx: "7.5", cy: "14", r: "1.8" })
@@ -3135,13 +3160,13 @@ var BAR_ICONS = {
3135
3160
  ),
3136
3161
  filter: icon(/* @__PURE__ */ jsx8("path", { d: "M3 4h14l-5.5 6.5V16l-3-1.5v-4z", strokeLinejoin: "round" })),
3137
3162
  calendar: icon(
3138
- /* @__PURE__ */ jsxs5(Fragment3, { children: [
3163
+ /* @__PURE__ */ jsxs6(Fragment3, { children: [
3139
3164
  /* @__PURE__ */ jsx8("rect", { x: "3", y: "4.5", width: "14", height: "12", rx: "2" }),
3140
3165
  /* @__PURE__ */ jsx8("path", { d: "M3 8.5h14M7 2.5v4M13 2.5v4" })
3141
3166
  ] })
3142
3167
  ),
3143
3168
  search: icon(
3144
- /* @__PURE__ */ jsxs5(Fragment3, { children: [
3169
+ /* @__PURE__ */ jsxs6(Fragment3, { children: [
3145
3170
  /* @__PURE__ */ jsx8("circle", { cx: "9", cy: "9", r: "5" }),
3146
3171
  /* @__PURE__ */ jsx8("path", { d: "M13 13l4 4" })
3147
3172
  ] })
@@ -3228,7 +3253,7 @@ function FilterBar() {
3228
3253
  }
3229
3254
  );
3230
3255
  }
3231
- const toolbar = /* @__PURE__ */ jsxs5(
3256
+ const toolbar = /* @__PURE__ */ jsxs6(
3232
3257
  "div",
3233
3258
  {
3234
3259
  className: "ds-filters",
@@ -3241,7 +3266,7 @@ function FilterBar() {
3241
3266
  if (!e.target.closest(".ds-filter-pick")) options.onFilterSelect?.(BAR);
3242
3267
  } : void 0,
3243
3268
  children: [
3244
- /* @__PURE__ */ jsxs5(Track, { segmented: bar.look === "segmented", children: [
3269
+ /* @__PURE__ */ jsxs6(Track, { segmented: bar.look === "segmented", children: [
3245
3270
  bar.icon !== "none" && /* @__PURE__ */ jsx8("span", { className: "ds-filters-icon", "aria-hidden": "true", children: BAR_ICONS[bar.icon ?? "sliders"] ?? BAR_ICONS.sliders }),
3246
3271
  shown.map(
3247
3272
  (v) => options.onFilterSelect ? (
@@ -3314,7 +3339,7 @@ function FilterDrawer({ active, children }) {
3314
3339
  const [open, setOpen] = useState2(false);
3315
3340
  const button = useRef3(null);
3316
3341
  const panel = useRef3(null);
3317
- const id = useId2();
3342
+ const id = useId3();
3318
3343
  useEffect2(() => {
3319
3344
  if (!open) return;
3320
3345
  const first = panel.current?.querySelector(FOCUSABLE);
@@ -3324,8 +3349,8 @@ function FilterDrawer({ active, children }) {
3324
3349
  setOpen(false);
3325
3350
  button.current?.focus();
3326
3351
  };
3327
- return /* @__PURE__ */ jsxs5("div", { className: "ds-filter-drawer", children: [
3328
- /* @__PURE__ */ jsxs5(
3352
+ return /* @__PURE__ */ jsxs6("div", { className: "ds-filter-drawer", children: [
3353
+ /* @__PURE__ */ jsxs6(
3329
3354
  "button",
3330
3355
  {
3331
3356
  ref: button,
@@ -3344,7 +3369,7 @@ function FilterDrawer({ active, children }) {
3344
3369
  }
3345
3370
  ),
3346
3371
  open && // A non-modal <dialog>: the rest of the dashboard stays usable while it is open.
3347
- /* @__PURE__ */ jsxs5(
3372
+ /* @__PURE__ */ jsxs6(
3348
3373
  "dialog",
3349
3374
  {
3350
3375
  open: true,
@@ -3360,7 +3385,7 @@ function FilterDrawer({ active, children }) {
3360
3385
  close();
3361
3386
  },
3362
3387
  children: [
3363
- /* @__PURE__ */ jsxs5("div", { className: "ds-filter-panel-head", children: [
3388
+ /* @__PURE__ */ jsxs6("div", { className: "ds-filter-panel-head", children: [
3364
3389
  /* @__PURE__ */ jsx8("span", { children: "Filters" }),
3365
3390
  /* @__PURE__ */ jsx8("button", { type: "button", className: "ds-close", "aria-label": "Close filters", onClick: close, children: "\xD7" })
3366
3391
  ] }),
@@ -3444,7 +3469,7 @@ var Image = defineWidget({
3444
3469
 
3445
3470
  // src/widgets/builtins/ImageMap.tsx
3446
3471
  import "zod";
3447
- import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
3472
+ import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
3448
3473
  var ImageMap = defineWidget({
3449
3474
  ...ImageMapContract,
3450
3475
  implements: "image-map",
@@ -3462,11 +3487,11 @@ var ImageMap = defineWidget({
3462
3487
  row: r
3463
3488
  })) : [];
3464
3489
  const src = safeImageSrc(spec.src);
3465
- return /* @__PURE__ */ jsxs6("div", { className: "ds-imagemap", children: [
3490
+ return /* @__PURE__ */ jsxs7("div", { className: "ds-imagemap", children: [
3466
3491
  src && /* @__PURE__ */ jsx11("img", { src, alt: spec.alt }),
3467
3492
  markers.map((mk, i) => {
3468
3493
  const t = mk.status ? spec.statusMap?.[mk.status] ?? mk.status : "info";
3469
- return /* @__PURE__ */ jsxs6(
3494
+ return /* @__PURE__ */ jsxs7(
3470
3495
  "button",
3471
3496
  {
3472
3497
  type: "button",
@@ -3482,7 +3507,7 @@ var ImageMap = defineWidget({
3482
3507
  onMouseEnter: () => emit("hover", "marker", { datum: mk.row, value: mk.value, index: i }),
3483
3508
  children: [
3484
3509
  mk.label,
3485
- mk.value !== void 0 && /* @__PURE__ */ jsxs6("strong", { children: [
3510
+ mk.value !== void 0 && /* @__PURE__ */ jsxs7("strong", { children: [
3486
3511
  " ",
3487
3512
  formatValue(mk.value, helpers, spec.format),
3488
3513
  spec.unit ? ` ${spec.unit}` : ""
@@ -3502,7 +3527,7 @@ import "zod";
3502
3527
  // src/widgets/shared/InfoTip.tsx
3503
3528
  import { useLayoutEffect as useLayoutEffect2, useRef as useRef4, useState as useState3 } from "react";
3504
3529
  import { createPortal as createPortal2 } from "react-dom";
3505
- import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
3530
+ import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
3506
3531
  function InfoTip({ text }) {
3507
3532
  const ref = useRef4(null);
3508
3533
  const tip = useRef4(null);
@@ -3515,13 +3540,17 @@ function InfoTip({ text }) {
3515
3540
  const gap = 8;
3516
3541
  const margin = 8;
3517
3542
  const vw = window.innerWidth || document.documentElement.clientWidth;
3518
- const below = a.top - t.height - gap < margin;
3543
+ const box = ref.current.closest(".ds-root")?.getBoundingClientRect();
3544
+ const minX = Math.max(margin, (box?.left ?? 0) + margin);
3545
+ const maxX = Math.min(vw, box?.right ?? vw) - margin;
3546
+ const minY = Math.max(margin, (box?.top ?? 0) + margin);
3547
+ const below = a.top - t.height - gap < minY;
3519
3548
  const centre = a.left + a.width / 2;
3520
- const left = Math.min(Math.max(centre - t.width / 2, margin), Math.max(margin, vw - t.width - margin));
3549
+ const left = Math.min(Math.max(centre - t.width / 2, minX), Math.max(minX, maxX - t.width));
3521
3550
  setPos({ left, top: below ? a.bottom + gap : a.top - t.height - gap, arrow: centre - left, below });
3522
3551
  }, [open]);
3523
3552
  const root = ref.current?.closest(".ds-root") ?? (typeof document !== "undefined" ? document.body : null);
3524
- return /* @__PURE__ */ jsxs7(
3553
+ return /* @__PURE__ */ jsxs8(
3525
3554
  "button",
3526
3555
  {
3527
3556
  ref,
@@ -3540,7 +3569,7 @@ function InfoTip({ text }) {
3540
3569
  setPos(null);
3541
3570
  },
3542
3571
  children: [
3543
- /* @__PURE__ */ jsxs7("svg", { viewBox: "0 0 16 16", width: "14", height: "14", "aria-hidden": "true", children: [
3572
+ /* @__PURE__ */ jsxs8("svg", { viewBox: "0 0 16 16", width: "14", height: "14", "aria-hidden": "true", children: [
3544
3573
  /* @__PURE__ */ jsx12("circle", { cx: "8", cy: "8", r: "6.5", fill: "none", stroke: "currentColor", strokeWidth: "1" }),
3545
3574
  /* @__PURE__ */ jsx12("path", { d: "M8 7.2v3.6M8 5.2v.1", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round" })
3546
3575
  ] }),
@@ -3572,7 +3601,7 @@ function InfoTip({ text }) {
3572
3601
  import { useContext as useContext4 } from "react";
3573
3602
 
3574
3603
  // src/components/PanelFrame.tsx
3575
- import { useCallback as useCallback4, useEffect as useEffect3, useId as useId3, useMemo as useMemo3, useRef as useRef5, useState as useState4 } from "react";
3604
+ import { useCallback as useCallback4, useEffect as useEffect3, useId as useId4, useMemo as useMemo3, useRef as useRef5, useState as useState4 } from "react";
3576
3605
 
3577
3606
  // src/widgets/parseProps.ts
3578
3607
  function without(value, path) {
@@ -3630,7 +3659,7 @@ var Boundary = class extends Component {
3630
3659
 
3631
3660
  // src/components/Slot.tsx
3632
3661
  import { createContext as createContext3, useContext as useContext3 } from "react";
3633
- import { Fragment as Fragment4, jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
3662
+ import { Fragment as Fragment4, jsx as jsx13, jsxs as jsxs9 } from "react/jsx-runtime";
3634
3663
  var NodeScopeContext = createContext3({});
3635
3664
  var useNodeScope = () => useContext3(NodeScopeContext);
3636
3665
  var SlotOwnerContext = createContext3(null);
@@ -3666,7 +3695,7 @@ function Slot({
3666
3695
  item: item !== void 0 ? item : outer.item,
3667
3696
  index: index !== void 0 ? index : outer.index
3668
3697
  };
3669
- return /* @__PURE__ */ jsx13(NodeScopeContext.Provider, { value: scope2, children: /* @__PURE__ */ jsxs8(
3698
+ return /* @__PURE__ */ jsx13(NodeScopeContext.Provider, { value: scope2, children: /* @__PURE__ */ jsxs9(
3670
3699
  "div",
3671
3700
  {
3672
3701
  className: className ? `ds-slot ${className}` : "ds-slot",
@@ -3684,7 +3713,7 @@ function Slot({
3684
3713
  var SlotItem = ({ children }) => /* @__PURE__ */ jsx13(Fragment4, { children });
3685
3714
 
3686
3715
  // src/components/PanelFrame.tsx
3687
- import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
3716
+ import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
3688
3717
  var isEmpty = (d) => d === void 0 || d === null || Array.isArray(d) && d.length === 0 || typeof d === "object" && !Array.isArray(d) && Object.keys(d).length === 0;
3689
3718
  function useSize() {
3690
3719
  const [size2, setSize] = useState4({ width: 0, height: 0 });
@@ -3900,14 +3929,14 @@ function PanelCrash({ id, error }) {
3900
3929
  } catch {
3901
3930
  custom = void 0;
3902
3931
  }
3903
- return /* @__PURE__ */ jsx14("section", { className: "ds-panel", "data-panel": id, "aria-label": id, children: /* @__PURE__ */ jsx14("div", { className: "ds-panel-body", children: custom ?? /* @__PURE__ */ jsxs9("div", { className: "ds-state ds-state-error", role: "alert", children: [
3932
+ return /* @__PURE__ */ jsx14("section", { className: "ds-panel", "data-panel": id, "aria-label": id, children: /* @__PURE__ */ jsx14("div", { className: "ds-panel-body", children: custom ?? /* @__PURE__ */ jsxs10("div", { className: "ds-state ds-state-error", role: "alert", children: [
3904
3933
  "This panel could not be shown: ",
3905
3934
  error.message
3906
3935
  ] }) }) });
3907
3936
  }
3908
3937
  function PanelFrameInner({ id, nested }) {
3909
3938
  const { runtime, registry, options, visibility } = useDashboard();
3910
- const instance = `${id}\0${useId3()}`;
3939
+ const instance = `${id}\0${useId4()}`;
3911
3940
  const inherited = useNodeScope();
3912
3941
  const def = findPanel(runtime.doc, id);
3913
3942
  const widget = registry.byKind.get(def.kind);
@@ -4061,7 +4090,7 @@ function PanelFrameInner({ id, nested }) {
4061
4090
  const hideHeader = Boolean(def.style?.hideHeader) || !title && !meta2 && !live2 && drill.length === 0 && controls.length === 0 && !view.stale && headerKids.length === 0;
4062
4091
  const dnd = Boolean(options.onDropOnPanel);
4063
4092
  let body;
4064
- if (!widget) body = /* @__PURE__ */ jsxs9("div", { className: "ds-state", children: [
4093
+ if (!widget) body = /* @__PURE__ */ jsxs10("div", { className: "ds-state", children: [
4065
4094
  "Unknown widget \u201C",
4066
4095
  String(def.kind),
4067
4096
  "\u201D"
@@ -4078,7 +4107,7 @@ function PanelFrameInner({ id, nested }) {
4078
4107
  Boundary,
4079
4108
  {
4080
4109
  resetKeys: [view.data, props],
4081
- fallback: (e) => /* @__PURE__ */ jsxs9("div", { className: "ds-state ds-state-error", role: "alert", children: [
4110
+ fallback: (e) => /* @__PURE__ */ jsxs10("div", { className: "ds-state ds-state-error", role: "alert", children: [
4082
4111
  "This panel could not be shown: ",
4083
4112
  e.message
4084
4113
  ] }),
@@ -4113,7 +4142,7 @@ function PanelFrameInner({ id, nested }) {
4113
4142
  const name = el?.getAttribute("data-slot") ?? defaultSlot;
4114
4143
  return { slot: name, index: el ? indexIn(el, x, y) : void 0 };
4115
4144
  };
4116
- return /* @__PURE__ */ jsx14(SlotOwnerContext.Provider, { value: { id, data: view.data, def }, children: /* @__PURE__ */ jsx14(SlotChildContext.Provider, { value: renderNested, children: /* @__PURE__ */ jsxs9(
4145
+ return /* @__PURE__ */ jsx14(SlotOwnerContext.Provider, { value: { id, data: view.data, def }, children: /* @__PURE__ */ jsx14(SlotChildContext.Provider, { value: renderNested, children: /* @__PURE__ */ jsxs10(
4117
4146
  "section",
4118
4147
  {
4119
4148
  ref: frameRef,
@@ -4121,6 +4150,7 @@ function PanelFrameInner({ id, nested }) {
4121
4150
  style: panelStyle(def.style),
4122
4151
  "data-tone": tone2,
4123
4152
  "data-panel": id,
4153
+ "data-kind": def.kind,
4124
4154
  "data-selected": selected || void 0,
4125
4155
  "data-nested": nested || void 0,
4126
4156
  "aria-label": title ?? id,
@@ -4160,15 +4190,15 @@ function PanelFrameInner({ id, nested }) {
4160
4190
  e.stopPropagation();
4161
4191
  } : void 0,
4162
4192
  children: [
4163
- !hideHeader && /* @__PURE__ */ jsxs9("header", { className: "ds-panel-head", children: [
4164
- /* @__PURE__ */ jsxs9("div", { style: { minWidth: 0 }, children: [
4165
- title && /* @__PURE__ */ jsxs9("h3", { className: "ds-panel-title", children: [
4193
+ !hideHeader && /* @__PURE__ */ jsxs10("header", { className: "ds-panel-head", children: [
4194
+ /* @__PURE__ */ jsxs10("div", { style: { minWidth: 0 }, children: [
4195
+ title && /* @__PURE__ */ jsxs10("h3", { className: "ds-panel-title", children: [
4166
4196
  title,
4167
4197
  info && /* @__PURE__ */ jsx14(InfoTip, { text: info })
4168
4198
  ] }),
4169
- drill.length > 0 && /* @__PURE__ */ jsxs9("nav", { className: "ds-crumbs", "aria-label": "Drill path", children: [
4199
+ drill.length > 0 && /* @__PURE__ */ jsxs10("nav", { className: "ds-crumbs", "aria-label": "Drill path", children: [
4170
4200
  /* @__PURE__ */ jsx14("button", { type: "button", onClick: () => runtime.runAction({ do: "drillReset", panel: id }), children: "All" }),
4171
- drill.map((d, i) => /* @__PURE__ */ jsxs9("span", { children: [
4201
+ drill.map((d, i) => /* @__PURE__ */ jsxs10("span", { children: [
4172
4202
  "\u203A",
4173
4203
  " ",
4174
4204
  i < drill.length - 1 ? /* @__PURE__ */ jsx14(
@@ -4184,10 +4214,10 @@ function PanelFrameInner({ id, nested }) {
4184
4214
  ] }, `${d.level}-${i}`))
4185
4215
  ] })
4186
4216
  ] }),
4187
- /* @__PURE__ */ jsxs9("div", { className: "ds-panel-tools", children: [
4217
+ /* @__PURE__ */ jsxs10("div", { className: "ds-panel-tools", children: [
4188
4218
  headerKids.length > 0 && /* @__PURE__ */ jsx14(Slot, { name: "header", className: "ds-panel-addons" }),
4189
4219
  meta2 && /* @__PURE__ */ jsx14("span", { className: "ds-panel-meta", children: meta2 }),
4190
- live2 ? /* @__PURE__ */ jsxs9("span", { className: "ds-live", "data-stale": view.stale || void 0, title: view.error?.message, children: [
4220
+ live2 ? /* @__PURE__ */ jsxs10("span", { className: "ds-live", "data-stale": view.stale || void 0, title: view.error?.message, children: [
4191
4221
  /* @__PURE__ */ jsx14("span", { "aria-hidden": "true" }),
4192
4222
  "Live, updated ",
4193
4223
  view.updatedAt ? runtime.helpers.fmt.ago(view.updatedAt) : "\u2026"
@@ -4221,7 +4251,7 @@ function loadingText(messages) {
4221
4251
  }
4222
4252
  function LoadingState({ text }) {
4223
4253
  if (!text) return /* @__PURE__ */ jsx14("div", { className: "ds-skeleton", "aria-busy": "true", "aria-label": "Loading" });
4224
- return /* @__PURE__ */ jsxs9("output", { className: "ds-loading", "aria-busy": "true", children: [
4254
+ return /* @__PURE__ */ jsxs10("output", { className: "ds-loading", "aria-busy": "true", children: [
4225
4255
  /* @__PURE__ */ jsx14("div", { className: "ds-skeleton", "aria-hidden": "true" }),
4226
4256
  /* @__PURE__ */ jsx14("span", { className: "ds-loading-text", children: text })
4227
4257
  ] });
@@ -4277,7 +4307,7 @@ function useCountUp(target, ms = 700) {
4277
4307
  }
4278
4308
 
4279
4309
  // src/widgets/builtins/Kpi.tsx
4280
- import { Fragment as Fragment5, jsx as jsx15, jsxs as jsxs10 } from "react/jsx-runtime";
4310
+ import { Fragment as Fragment5, jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
4281
4311
  var Kpi = defineWidget({
4282
4312
  ...KpiContract,
4283
4313
  implements: "kpi",
@@ -4311,8 +4341,8 @@ var Kpi = defineWidget({
4311
4341
  const outside = n !== void 0 && (low !== void 0 && n < low || high !== void 0 && n > high);
4312
4342
  const pTarget = spec.progress ? num(spec.progress.target) : void 0;
4313
4343
  const ratio = n !== void 0 && pTarget ? Math.min(spec.progress?.cap ?? Number.POSITIVE_INFINITY, n / pTarget * 100) : void 0;
4314
- return /* @__PURE__ */ jsxs10("div", { className: "ds-kpi", "data-size": spec.size, children: [
4315
- /* @__PURE__ */ jsxs10("div", { className: "ds-kpi-label", children: [
4344
+ return /* @__PURE__ */ jsxs11("div", { className: "ds-kpi", "data-size": spec.size, children: [
4345
+ /* @__PURE__ */ jsxs11("div", { className: "ds-kpi-label", children: [
4316
4346
  /* @__PURE__ */ jsx15("span", { children: spec.title }),
4317
4347
  spec.info && /* @__PURE__ */ jsx15(InfoTip, { text: spec.info })
4318
4348
  ] }),
@@ -4328,8 +4358,8 @@ var Kpi = defineWidget({
4328
4358
  children: empty ? (
4329
4359
  // No value is not zero: the author's text, else a dash.
4330
4360
  /* @__PURE__ */ jsx15("span", { className: "ds-kpi-empty", children: spec.emptyText || "\u2014" })
4331
- ) : /* @__PURE__ */ jsxs10(Fragment5, { children: [
4332
- /* @__PURE__ */ jsxs10(
4361
+ ) : /* @__PURE__ */ jsxs11(Fragment5, { children: [
4362
+ /* @__PURE__ */ jsxs11(
4333
4363
  "span",
4334
4364
  {
4335
4365
  className: "ds-kpi-value",
@@ -4344,7 +4374,7 @@ var Kpi = defineWidget({
4344
4374
  ] })
4345
4375
  }
4346
4376
  ),
4347
- delta !== void 0 && /* @__PURE__ */ jsxs10(
4377
+ delta !== void 0 && /* @__PURE__ */ jsxs11(
4348
4378
  "span",
4349
4379
  {
4350
4380
  className: "ds-kpi-delta",
@@ -4353,7 +4383,7 @@ var Kpi = defineWidget({
4353
4383
  delta > 0 ? "\u2191" : delta < 0 ? "\u2193" : "\u2192",
4354
4384
  " ",
4355
4385
  spec.format === "duration" ? helpers.fmt.duration(Math.abs(delta)) : `${helpers.fmt.number(Math.abs(ref ? delta / Math.abs(ref) * 100 : 0), 1)}%`,
4356
- typeof spec.compare === "object" && spec.compare.label && /* @__PURE__ */ jsxs10("span", { className: "ds-kpi-sub", children: [
4386
+ typeof spec.compare === "object" && spec.compare.label && /* @__PURE__ */ jsxs11("span", { className: "ds-kpi-sub", children: [
4357
4387
  " ",
4358
4388
  spec.compare.label
4359
4389
  ] })
@@ -4362,7 +4392,7 @@ var Kpi = defineWidget({
4362
4392
  ),
4363
4393
  spec.note && /* @__PURE__ */ jsx15("span", { className: "ds-kpi-sub", children: spec.note }),
4364
4394
  spec.sublabel && /* @__PURE__ */ jsx15("span", { className: "ds-kpi-sub", children: spec.sublabel }),
4365
- low !== void 0 && high !== void 0 && /* @__PURE__ */ jsxs10("span", { className: "ds-kpi-sub", children: [
4395
+ low !== void 0 && high !== void 0 && /* @__PURE__ */ jsxs11("span", { className: "ds-kpi-sub", children: [
4366
4396
  "Expected ",
4367
4397
  fmt(low),
4368
4398
  "\u2013",
@@ -4385,7 +4415,7 @@ var Kpi = defineWidget({
4385
4415
  )
4386
4416
  }
4387
4417
  ),
4388
- (hasTarget || targetText) && /* @__PURE__ */ jsxs10("div", { className: "ds-kpi-foot", children: [
4418
+ (hasTarget || targetText) && /* @__PURE__ */ jsxs11("div", { className: "ds-kpi-foot", children: [
4389
4419
  hasTarget && target === void 0 ? /* @__PURE__ */ jsx15("span", { className: "ds-chip", "data-tone": "bad", children: spec.targetMissing }) : /* @__PURE__ */ jsx15("span", { "data-ds-part": "target", children: targetText }),
4390
4420
  spec.badge !== false && met !== void 0 && !empty && /* @__PURE__ */ jsx15("span", { className: "ds-chip", "data-tone": met ? "good" : "bad", "data-ds-part": "badge", children: met ? labels.good : labels.bad })
4391
4421
  ] })
@@ -4395,7 +4425,7 @@ var Kpi = defineWidget({
4395
4425
 
4396
4426
  // src/widgets/builtins/Sparkline.tsx
4397
4427
  import "zod";
4398
- import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
4428
+ import { jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
4399
4429
  function sparkPath(values, w, h, pad = 2) {
4400
4430
  if (values.length === 0) return { line: "", area: "" };
4401
4431
  const min = values.reduce((a, b) => Math.min(a, b));
@@ -4415,7 +4445,7 @@ function SparkSvg({
4415
4445
  }) {
4416
4446
  const w = 120;
4417
4447
  const { line, area: fill } = sparkPath(values, w, height);
4418
- return /* @__PURE__ */ jsxs11("svg", { viewBox: `0 0 ${w} ${height}`, preserveAspectRatio: "none", style: { width: "100%", height }, "aria-hidden": "true", children: [
4448
+ return /* @__PURE__ */ jsxs12("svg", { viewBox: `0 0 ${w} ${height}`, preserveAspectRatio: "none", style: { width: "100%", height }, "aria-hidden": "true", children: [
4419
4449
  area && /* @__PURE__ */ jsx16("path", { d: fill, fill: color2, opacity: 0.15 }),
4420
4450
  /* @__PURE__ */ jsx16("path", { d: line, fill: "none", stroke: color2, strokeWidth: 1.5, vectorEffect: "non-scaling-stroke" })
4421
4451
  ] });
@@ -4444,7 +4474,7 @@ var Sparkline = defineWidget({
4444
4474
 
4445
4475
  // src/widgets/builtins/StageTracker.tsx
4446
4476
  import "zod";
4447
- import { jsx as jsx17, jsxs as jsxs12 } from "react/jsx-runtime";
4477
+ import { jsx as jsx17, jsxs as jsxs13 } from "react/jsx-runtime";
4448
4478
  var StageTracker = defineWidget({
4449
4479
  ...StageTrackerContract,
4450
4480
  implements: "stages",
@@ -4456,7 +4486,7 @@ var StageTracker = defineWidget({
4456
4486
  const idx = typeof raw === "number" ? raw : spec.stages.findIndex((s) => s.toLowerCase() === String(raw ?? "").toLowerCase());
4457
4487
  return /* @__PURE__ */ jsx17("ol", { className: "ds-stages", children: spec.stages.map((s, i) => {
4458
4488
  const state = i < idx ? "done" : i === idx ? "current" : "todo";
4459
- return /* @__PURE__ */ jsx17("li", { "data-state": state, children: /* @__PURE__ */ jsxs12(
4489
+ return /* @__PURE__ */ jsx17("li", { "data-state": state, children: /* @__PURE__ */ jsxs13(
4460
4490
  "button",
4461
4491
  {
4462
4492
  type: "button",
@@ -4474,7 +4504,7 @@ var StageTracker = defineWidget({
4474
4504
 
4475
4505
  // src/widgets/builtins/StateTimeline.tsx
4476
4506
  import "zod";
4477
- import { jsx as jsx18, jsxs as jsxs13 } from "react/jsx-runtime";
4507
+ import { jsx as jsx18, jsxs as jsxs14 } from "react/jsx-runtime";
4478
4508
  var StateTimeline = defineWidget({
4479
4509
  ...StateTimelineContract,
4480
4510
  implements: "timeline",
@@ -4488,7 +4518,7 @@ var StateTimeline = defineWidget({
4488
4518
  const lanes = spec.rows ? [...new Set(all.map((x) => String(field(x.r, spec.rows))))] : [""];
4489
4519
  const span = Math.max(1, end - start);
4490
4520
  const states = /* @__PURE__ */ new Map();
4491
- return /* @__PURE__ */ jsxs13("div", { className: "ds-timeline", children: [
4521
+ return /* @__PURE__ */ jsxs14("div", { className: "ds-timeline", children: [
4492
4522
  lanes.map((lane) => {
4493
4523
  const pts = all.filter((x) => !spec.rows || String(field(x.r, spec.rows)) === lane);
4494
4524
  const segs = pts.map((p, i) => {
@@ -4498,7 +4528,7 @@ var StateTimeline = defineWidget({
4498
4528
  states.set(state, (states.get(state) ?? 0) + Math.max(0, to - from));
4499
4529
  return { p, from, to, state };
4500
4530
  });
4501
- return /* @__PURE__ */ jsxs13("div", { className: "ds-timeline-lane", children: [
4531
+ return /* @__PURE__ */ jsxs14("div", { className: "ds-timeline-lane", children: [
4502
4532
  lane && /* @__PURE__ */ jsx18("span", { className: "ds-timeline-name", children: lane }),
4503
4533
  /* @__PURE__ */ jsx18("div", { className: "ds-timeline-bar", role: "img", "aria-label": `${spec.title ?? "Timeline"} ${lane}`, children: segs.filter((s) => s.to > s.from).map((s) => (
4504
4534
  // biome-ignore lint/a11y/useKeyWithClickEvents: the per-state totals below summarise the same data for keyboard users
@@ -4519,11 +4549,11 @@ var StateTimeline = defineWidget({
4519
4549
  )) })
4520
4550
  ] }, lane);
4521
4551
  }),
4522
- /* @__PURE__ */ jsxs13("div", { className: "ds-timeline-axis", children: [
4552
+ /* @__PURE__ */ jsxs14("div", { className: "ds-timeline-axis", children: [
4523
4553
  /* @__PURE__ */ jsx18("span", { children: helpers.fmt.date(start, "time") }),
4524
4554
  /* @__PURE__ */ jsx18("span", { children: spec.endLabel ?? helpers.fmt.date(end, "time") })
4525
4555
  ] }),
4526
- /* @__PURE__ */ jsx18("ul", { className: "ds-legend", children: [...states.entries()].map(([s, ms]) => /* @__PURE__ */ jsxs13("li", { children: [
4556
+ /* @__PURE__ */ jsx18("ul", { className: "ds-legend", children: [...states.entries()].map(([s, ms]) => /* @__PURE__ */ jsxs14("li", { children: [
4527
4557
  /* @__PURE__ */ jsx18(
4528
4558
  "span",
4529
4559
  {
@@ -4542,7 +4572,7 @@ var StateTimeline = defineWidget({
4542
4572
 
4543
4573
  // src/widgets/builtins/Status.tsx
4544
4574
  import "zod";
4545
- import { jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
4575
+ import { jsx as jsx19, jsxs as jsxs15 } from "react/jsx-runtime";
4546
4576
  var Status = defineWidget({
4547
4577
  ...StatusContract,
4548
4578
  implements: "badge",
@@ -4555,8 +4585,8 @@ var Status = defineWidget({
4555
4585
  const state = String(field(row, spec.state) ?? "unknown");
4556
4586
  const t = spec.text ? spec.tone ?? "info" : spec.stateMap?.[state] ?? spec.tone ?? "neutral";
4557
4587
  const text = spec.text ?? spec.labels?.[state] ?? state.charAt(0).toUpperCase() + state.slice(1);
4558
- return /* @__PURE__ */ jsxs14("button", { type: "button", className: "ds-status", onClick: () => emit("click", "status", { datum: row, value: state }), children: [
4559
- /* @__PURE__ */ jsxs14("span", { className: "ds-pill", style: { background: tone(t).bg, color: tone(t).fg, borderColor: tone(t).border }, children: [
4588
+ return /* @__PURE__ */ jsxs15("button", { type: "button", className: "ds-status", onClick: () => emit("click", "status", { datum: row, value: state }), children: [
4589
+ /* @__PURE__ */ jsxs15("span", { className: "ds-pill", style: { background: tone(t).bg, color: tone(t).fg, borderColor: tone(t).border }, children: [
4560
4590
  /* @__PURE__ */ jsx19("span", { className: "ds-dot", style: { background: tone(t).solid }, "aria-hidden": "true" }),
4561
4591
  text
4562
4592
  ] }),
@@ -4567,7 +4597,7 @@ var Status = defineWidget({
4567
4597
 
4568
4598
  // src/widgets/builtins/Table.tsx
4569
4599
  import { useEffect as useEffect5, useMemo as useMemo4, useRef as useRef7, useState as useState6 } from "react";
4570
- import { jsx as jsx20, jsxs as jsxs15 } from "react/jsx-runtime";
4600
+ import { jsx as jsx20, jsxs as jsxs16 } from "react/jsx-runtime";
4571
4601
  var ROW_H = 36;
4572
4602
  function pageList(current, pages) {
4573
4603
  if (pages <= 7) return Array.from({ length: pages }, (_, i) => i + 1);
@@ -4746,7 +4776,7 @@ var Table = defineWidget({
4746
4776
  case "progress": {
4747
4777
  const n = toNumber(v) ?? 0;
4748
4778
  const pct = Math.min(100, n / (c.max ?? 100) * 100);
4749
- return /* @__PURE__ */ jsxs15("span", { className: "ds-inline", children: [
4779
+ return /* @__PURE__ */ jsxs16("span", { className: "ds-inline", children: [
4750
4780
  /* @__PURE__ */ jsx20("span", { className: "ds-progress", style: { flex: 1, minWidth: 40 }, children: /* @__PURE__ */ jsx20("span", { style: { width: `${pct}%`, background: "var(--ds-series-1)" } }) }),
4751
4781
  formatValue(n, helpers, c.format, c.decimals),
4752
4782
  c.suffix
@@ -4784,10 +4814,10 @@ var Table = defineWidget({
4784
4814
  }
4785
4815
  };
4786
4816
  const align = (c) => c.align ?? (c.type === "number" || c.format && c.format !== "date" && c.format !== "text" ? "right" : "left");
4787
- return /* @__PURE__ */ jsxs15("div", { className: "ds-table-wrap", "data-density": spec.density, children: [
4788
- sr && /* @__PURE__ */ jsxs15("div", { className: "ds-table-tools", children: [
4789
- /* @__PURE__ */ jsxs15("label", { className: "ds-search", children: [
4790
- /* @__PURE__ */ jsxs15("svg", { viewBox: "0 0 16 16", width: "15", height: "15", "aria-hidden": "true", children: [
4817
+ return /* @__PURE__ */ jsxs16("div", { className: "ds-table-wrap", "data-density": spec.density, children: [
4818
+ sr && /* @__PURE__ */ jsxs16("div", { className: "ds-table-tools", children: [
4819
+ /* @__PURE__ */ jsxs16("label", { className: "ds-search", children: [
4820
+ /* @__PURE__ */ jsxs16("svg", { viewBox: "0 0 16 16", width: "15", height: "15", "aria-hidden": "true", children: [
4791
4821
  /* @__PURE__ */ jsx20("circle", { cx: "7", cy: "7", r: "4.5", fill: "none", stroke: "currentColor", strokeWidth: "1.5" }),
4792
4822
  /* @__PURE__ */ jsx20("path", { d: "m10.5 10.5 3 3", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
4793
4823
  ] }),
@@ -4807,12 +4837,12 @@ var Table = defineWidget({
4807
4837
  }
4808
4838
  )
4809
4839
  ] }),
4810
- /* @__PURE__ */ jsxs15("span", { className: "ds-table-count", children: [
4840
+ /* @__PURE__ */ jsxs16("span", { className: "ds-table-count", children: [
4811
4841
  helpers.fmt.number(rowTotal),
4812
4842
  " rows"
4813
4843
  ] })
4814
4844
  ] }),
4815
- /* @__PURE__ */ jsxs15(
4845
+ /* @__PURE__ */ jsxs16(
4816
4846
  "div",
4817
4847
  {
4818
4848
  className: "ds-table-scroll",
@@ -4822,8 +4852,8 @@ var Table = defineWidget({
4822
4852
  onScroll: windowed ? (e) => setScrollTop(e.currentTarget.scrollTop) : void 0,
4823
4853
  children: [
4824
4854
  busy && /* @__PURE__ */ jsx20("div", { className: "ds-table-busy", "aria-hidden": "true" }),
4825
- /* @__PURE__ */ jsxs15("table", { className: "ds-table", "aria-busy": busy || void 0, children: [
4826
- /* @__PURE__ */ jsxs15("thead", { "data-sticky": spec.sticky || void 0, children: [
4855
+ /* @__PURE__ */ jsxs16("table", { className: "ds-table", "aria-busy": busy || void 0, children: [
4856
+ /* @__PURE__ */ jsxs16("thead", { "data-sticky": spec.sticky || void 0, children: [
4827
4857
  /* @__PURE__ */ jsx20("tr", { children: columns.map((c, i) => {
4828
4858
  const sorted = sort?.key === c.key ? sort.order : void 0;
4829
4859
  return /* @__PURE__ */ jsx20(
@@ -4832,7 +4862,7 @@ var Table = defineWidget({
4832
4862
  "data-ds-part": `column:${i}`,
4833
4863
  style: { textAlign: align(c), width: c.width },
4834
4864
  "aria-sort": sorted === "asc" ? "ascending" : sorted === "desc" ? "descending" : void 0,
4835
- children: so.enabled === false || c.sortable === false || c.list !== void 0 ? c.label ?? c.key : /* @__PURE__ */ jsxs15(
4865
+ children: so.enabled === false || c.sortable === false || c.list !== void 0 ? c.label ?? c.key : /* @__PURE__ */ jsxs16(
4836
4866
  "button",
4837
4867
  {
4838
4868
  type: "button",
@@ -4875,7 +4905,7 @@ var Table = defineWidget({
4875
4905
  }
4876
4906
  ) : null }, `f-${c.key}-${i}`)) })
4877
4907
  ] }),
4878
- /* @__PURE__ */ jsxs15("tbody", { children: [
4908
+ /* @__PURE__ */ jsxs16("tbody", { children: [
4879
4909
  windowed && first > 0 && /* @__PURE__ */ jsx20("tr", { className: "ds-spacer", children: /* @__PURE__ */ jsx20("td", { colSpan: columns.length, style: { height: first * ROW_H, padding: 0 } }) }),
4880
4910
  shown.slice(first, last).map((row, k) => {
4881
4911
  const i = first + k;
@@ -4911,8 +4941,8 @@ var Table = defineWidget({
4911
4941
  ]
4912
4942
  }
4913
4943
  ),
4914
- pageSize && /* @__PURE__ */ jsxs15("div", { className: "ds-pager", children: [
4915
- /* @__PURE__ */ jsxs15("span", { className: "ds-pager-size", children: [
4944
+ pageSize && /* @__PURE__ */ jsxs16("div", { className: "ds-pager", children: [
4945
+ /* @__PURE__ */ jsxs16("span", { className: "ds-pager-size", children: [
4916
4946
  "Rows",
4917
4947
  /* @__PURE__ */ jsx20(
4918
4948
  SelectControl,
@@ -4926,7 +4956,7 @@ var Table = defineWidget({
4926
4956
  }
4927
4957
  )
4928
4958
  ] }),
4929
- /* @__PURE__ */ jsxs15("span", { children: [
4959
+ /* @__PURE__ */ jsxs16("span", { children: [
4930
4960
  rowTotal === 0 ? 0 : (current - 1) * pageSize + 1,
4931
4961
  "\u2013",
4932
4962
  Math.min(current * pageSize, rowTotal),
@@ -4934,7 +4964,7 @@ var Table = defineWidget({
4934
4964
  " ",
4935
4965
  helpers.fmt.number(rowTotal)
4936
4966
  ] }),
4937
- /* @__PURE__ */ jsxs15("span", { className: "ds-pages", children: [
4967
+ /* @__PURE__ */ jsxs16("span", { className: "ds-pages", children: [
4938
4968
  /* @__PURE__ */ jsx20(
4939
4969
  "button",
4940
4970
  {
@@ -4975,7 +5005,7 @@ var Table = defineWidget({
4975
5005
 
4976
5006
  // src/widgets/builtins/Tiles.tsx
4977
5007
  import "zod";
4978
- import { Fragment as Fragment6, jsx as jsx21, jsxs as jsxs16 } from "react/jsx-runtime";
5008
+ import { Fragment as Fragment6, jsx as jsx21, jsxs as jsxs17 } from "react/jsx-runtime";
4979
5009
  var Tiles = defineWidget({
4980
5010
  ...TilesContract,
4981
5011
  implements: "tiles",
@@ -5013,7 +5043,7 @@ var Tiles = defineWidget({
5013
5043
  const st = status ? spec.statusMap?.[status] ?? status : void 0;
5014
5044
  const vt = n === void 0 || !spec.valueTone ? void 0 : n > 0 ? spec.valueTone.positive : n < 0 ? spec.valueTone.negative : spec.valueTone.zero;
5015
5045
  const active = spec.selectable && spec.selected !== void 0 && spec.selected === label;
5016
- return /* @__PURE__ */ jsxs16(
5046
+ return /* @__PURE__ */ jsxs17(
5017
5047
  "button",
5018
5048
  {
5019
5049
  type: "button",
@@ -5027,12 +5057,12 @@ var Tiles = defineWidget({
5027
5057
  },
5028
5058
  onMouseEnter: () => emit("hover", "tile", { datum: r, value: label, index: i }),
5029
5059
  children: [
5030
- /* @__PURE__ */ jsxs16("span", { className: "ds-tile-label", children: [
5060
+ /* @__PURE__ */ jsxs17("span", { className: "ds-tile-label", children: [
5031
5061
  st && /* @__PURE__ */ jsx21("span", { className: "ds-dot", style: { background: tone(st).solid }, "aria-hidden": "true" }),
5032
5062
  String(label ?? ""),
5033
5063
  spec.count && /* @__PURE__ */ jsx21("span", { className: "ds-chip-count", children: String(field(r, spec.count) ?? "") })
5034
5064
  ] }),
5035
- /* @__PURE__ */ jsxs16(
5065
+ /* @__PURE__ */ jsxs17(
5036
5066
  "span",
5037
5067
  {
5038
5068
  className: "ds-tile-value",
@@ -5061,7 +5091,7 @@ function CountUp({ value, render }) {
5061
5091
 
5062
5092
  // src/widgets/builtins/atoms.tsx
5063
5093
  import "zod";
5064
- import { jsx as jsx22, jsxs as jsxs17 } from "react/jsx-runtime";
5094
+ import { jsx as jsx22, jsxs as jsxs18 } from "react/jsx-runtime";
5065
5095
  var color = (t) => t === "subtle" ? "var(--ds-color-text-subtle)" : t === "primary" ? "var(--ds-color-action-primary)" : t && t !== "default" ? tone(t).fg : void 0;
5066
5096
  var boundValue = (data, path) => {
5067
5097
  if (path) return field(Array.isArray(data) ? data[0] : data, path);
@@ -5107,7 +5137,7 @@ var Value = defineWidget({
5107
5137
  const target = typeof spec.target === "number" ? spec.target : spec.target ? toNumber(boundValue(data, spec.target)) : void 0;
5108
5138
  const met = n !== void 0 && target !== void 0 ? spec.goodWhen === "down" ? n <= target : n >= target : void 0;
5109
5139
  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;
5110
- return /* @__PURE__ */ jsxs17("span", { className: "ds-atom-value", "data-size": spec.size, style: { color: c }, ...click, children: [
5140
+ return /* @__PURE__ */ jsxs18("span", { className: "ds-atom-value", "data-size": spec.size, style: { color: c }, ...click, children: [
5111
5141
  spec.prefix,
5112
5142
  formatValue(shown, helpers, spec.format, spec.decimals),
5113
5143
  spec.unit && /* @__PURE__ */ jsx22("small", { children: spec.unit })
@@ -5125,7 +5155,7 @@ var Progress = defineWidget({
5125
5155
  const max = typeof spec.max === "number" ? spec.max : toNumber(boundValue(data, spec.max)) ?? 100;
5126
5156
  const pct = max > 0 ? Math.max(0, Math.min(100, n / max * 100)) : 0;
5127
5157
  const fill = spec.color === "primary" ? "var(--ds-color-action-primary)" : spec.color === "byTarget" ? tone(pct >= spec.goodFrom ? "good" : "bad").solid : tone(spec.color).solid;
5128
- return /* @__PURE__ */ jsxs17("div", { className: "ds-atom-progress", children: [
5158
+ return /* @__PURE__ */ jsxs18("div", { className: "ds-atom-progress", children: [
5129
5159
  /* @__PURE__ */ jsx22(
5130
5160
  "span",
5131
5161
  {
@@ -5137,7 +5167,7 @@ var Progress = defineWidget({
5137
5167
  children: /* @__PURE__ */ jsx22("span", { style: { width: `${pct}%`, background: fill } })
5138
5168
  }
5139
5169
  ),
5140
- spec.showPercent && /* @__PURE__ */ jsxs17("small", { children: [
5170
+ spec.showPercent && /* @__PURE__ */ jsxs18("small", { children: [
5141
5171
  Math.round(pct),
5142
5172
  "%"
5143
5173
  ] })
@@ -5424,6 +5454,20 @@ function cartesian(data, source, spec, type, h, colors) {
5424
5454
  const colourByAvg = spec.colorBy === "average" && single && avg !== void 0 && full.length >= 3 && colors;
5425
5455
  const showValues = spec.valueLabels === true || spec.valueLabels !== false && spec.valueLabels === "auto" && cats.length <= 7;
5426
5456
  const out = [];
5457
+ const stackedTotals = type === "bar" && stack && !spec.normalized && !spec.range && series.length > 1;
5458
+ const lastSeries = series[series.length - 1];
5459
+ const totalAt = (i) => {
5460
+ let sum = 0;
5461
+ let any = false;
5462
+ for (const x of series) {
5463
+ const v = x.values[i];
5464
+ if (typeof v === "number") {
5465
+ sum += v;
5466
+ any = true;
5467
+ }
5468
+ }
5469
+ return any ? sum : null;
5470
+ };
5427
5471
  for (const s of series) {
5428
5472
  const styled = type === "bar" && single && colors ? s.values.map((v, i) => ({
5429
5473
  value: v,
@@ -5444,14 +5488,17 @@ function cartesian(data, source, spec, type, h, colors) {
5444
5488
  name: s.name,
5445
5489
  type,
5446
5490
  data: styled ?? s.values,
5447
- ...showValues ? {
5491
+ ...showValues && (!stackedTotals || s === lastSeries) ? {
5448
5492
  label: {
5449
5493
  show: true,
5450
5494
  position: spec.horizontal ? "right" : "top",
5451
5495
  fontWeight: 600,
5452
5496
  fontSize: 12,
5453
5497
  ...colors ? { color: colors.text } : {},
5454
- formatter: (p) => p.value === null || p.value === void 0 ? "" : `${formatValue(p.value, h, spec.format, spec.decimals ?? 1)}${isPartial[p.dataIndex] ? " so far" : ""}`
5498
+ formatter: (p) => {
5499
+ const v = stackedTotals ? totalAt(p.dataIndex) : p.value;
5500
+ return v === null || v === void 0 ? "" : `${formatValue(v, h, spec.format, spec.decimals ?? 1)}${isPartial[p.dataIndex] ? " so far" : ""}`;
5501
+ }
5455
5502
  }
5456
5503
  } : {},
5457
5504
  ...stack ? { stack } : {},
@@ -5532,7 +5579,7 @@ function cartesian(data, source, spec, type, h, colors) {
5532
5579
  }
5533
5580
 
5534
5581
  // src/widgets/builtins/charts.tsx
5535
- import { Fragment as Fragment7, jsx as jsx24, jsxs as jsxs18 } from "react/jsx-runtime";
5582
+ import { Fragment as Fragment7, jsx as jsx24, jsxs as jsxs19 } from "react/jsx-runtime";
5536
5583
  var chartEvents = ["click", "doubleClick", "hover", "hoverEnd", "legendClick", "brush", "datazoom"];
5537
5584
  var BarChart2 = defineWidget({
5538
5585
  ...BarChartContract,
@@ -5560,19 +5607,19 @@ var BarChart2 = defineWidget({
5560
5607
  const hi = highlight === void 0 || highlight === null ? void 0 : c.categories.indexOf(String(highlight));
5561
5608
  const avgText = spec.averageLine && c.avg !== void 0 ? typeof spec.averageLine === "string" ? spec.averageLine.replace(/\$\{avg\}/g, helpers.fmt.number(c.avg, 1)) : `Avg: ${helpers.fmt.number(c.avg, 1)}` : void 0;
5562
5609
  const legend = c.coloured || avgText;
5563
- return /* @__PURE__ */ jsxs18("div", { className: "ds-chart", children: [
5564
- legend && /* @__PURE__ */ jsxs18("ul", { className: "ds-chart-legend", children: [
5565
- c.coloured && /* @__PURE__ */ jsxs18(Fragment7, { children: [
5566
- /* @__PURE__ */ jsxs18("li", { children: [
5610
+ return /* @__PURE__ */ jsxs19("div", { className: "ds-chart", children: [
5611
+ legend && /* @__PURE__ */ jsxs19("ul", { className: "ds-chart-legend", children: [
5612
+ c.coloured && /* @__PURE__ */ jsxs19(Fragment7, { children: [
5613
+ /* @__PURE__ */ jsxs19("li", { children: [
5567
5614
  /* @__PURE__ */ jsx24("span", { className: "ds-swatch", style: { background: colors?.good } }),
5568
5615
  spec.legendLabels?.above ?? "At or above avg"
5569
5616
  ] }),
5570
- /* @__PURE__ */ jsxs18("li", { children: [
5617
+ /* @__PURE__ */ jsxs19("li", { children: [
5571
5618
  /* @__PURE__ */ jsx24("span", { className: "ds-swatch", style: { background: colors?.bad } }),
5572
5619
  spec.legendLabels?.below ?? "Below avg"
5573
5620
  ] })
5574
5621
  ] }),
5575
- avgText && /* @__PURE__ */ jsxs18("li", { children: [
5622
+ avgText && /* @__PURE__ */ jsxs19("li", { children: [
5576
5623
  /* @__PURE__ */ jsx24("span", { className: "ds-swatch-line" }),
5577
5624
  avgText
5578
5625
  ] })
@@ -5840,7 +5887,7 @@ var MatrixChart = defineWidget({
5840
5887
  // src/widgets/builtins/layout.tsx
5841
5888
  import { Fragment as Fragment8 } from "react";
5842
5889
  import "zod";
5843
- import { jsx as jsx25, jsxs as jsxs19 } from "react/jsx-runtime";
5890
+ import { jsx as jsx25, jsxs as jsxs20 } from "react/jsx-runtime";
5844
5891
  var Row = defineWidget({
5845
5892
  ...Container,
5846
5893
  ...RowContract,
@@ -5877,7 +5924,7 @@ var Tabs = defineWidget({
5877
5924
  events: ["change"],
5878
5925
  component: function TabsWidget({ spec, state, setUi, emit, renderSlot }) {
5879
5926
  const open = String(state.ui?.tab ?? spec.initial ?? spec.tabs[0]?.key);
5880
- return /* @__PURE__ */ jsxs19("div", { className: "ds-tabs", children: [
5927
+ return /* @__PURE__ */ jsxs20("div", { className: "ds-tabs", children: [
5881
5928
  /* @__PURE__ */ jsx25("div", { className: "ds-tabs-bar", role: "tablist", children: spec.tabs.map((t) => /* @__PURE__ */ jsx25(
5882
5929
  "button",
5883
5930
  {
@@ -6151,7 +6198,7 @@ function Grid({
6151
6198
 
6152
6199
  // src/components/ModalHost.tsx
6153
6200
  import { useCallback as useCallback5, useEffect as useEffect8, useRef as useRef10 } from "react";
6154
- import { jsx as jsx27, jsxs as jsxs20 } from "react/jsx-runtime";
6201
+ import { jsx as jsx27, jsxs as jsxs21 } from "react/jsx-runtime";
6155
6202
  var WIDTH = { sm: "420px", md: "720px", lg: "1040px", xl: "1320px", full: "100%" };
6156
6203
  var FOCUSABLE2 = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
6157
6204
  function ModalHost() {
@@ -6259,7 +6306,7 @@ function ModalHost() {
6259
6306
  className: "ds-scrim",
6260
6307
  "data-presentation": m.presentation ?? "modal",
6261
6308
  onMouseDown: (e) => e.target === e.currentTarget && close(),
6262
- children: /* @__PURE__ */ jsxs20(
6309
+ children: /* @__PURE__ */ jsxs21(
6263
6310
  "dialog",
6264
6311
  {
6265
6312
  open: true,
@@ -6270,7 +6317,7 @@ function ModalHost() {
6270
6317
  ref: dialog,
6271
6318
  style: { ["--ds-dialog-w"]: WIDTH[m.size ?? "md"] ?? WIDTH.md },
6272
6319
  children: [
6273
- /* @__PURE__ */ jsxs20("div", { className: "ds-dialog-head", children: [
6320
+ /* @__PURE__ */ jsxs21("div", { className: "ds-dialog-head", children: [
6274
6321
  /* @__PURE__ */ jsx27("h2", { children: open.title }),
6275
6322
  /* @__PURE__ */ jsx27("button", { type: "button", className: "ds-close", "aria-label": "Close", onClick: close, children: "\xD7" })
6276
6323
  ] }),
@@ -6342,8 +6389,8 @@ function pickTheme(name, themes, fallback) {
6342
6389
  }
6343
6390
 
6344
6391
  // src/components/Tour.tsx
6345
- import { useCallback as useCallback6, useEffect as useEffect9, useId as useId4, useLayoutEffect as useLayoutEffect3, useRef as useRef12, useState as useState8 } from "react";
6346
- import { Fragment as Fragment9, jsx as jsx29, jsxs as jsxs21 } from "react/jsx-runtime";
6392
+ import { useCallback as useCallback6, useEffect as useEffect9, useId as useId5, useLayoutEffect as useLayoutEffect3, useRef as useRef12, useState as useState8 } from "react";
6393
+ import { Fragment as Fragment9, jsx as jsx29, jsxs as jsxs22 } from "react/jsx-runtime";
6347
6394
  var useClientLayoutEffect = typeof window === "undefined" ? useEffect9 : useLayoutEffect3;
6348
6395
  function panelElement(root, id) {
6349
6396
  if (!root || !id) return null;
@@ -6358,8 +6405,8 @@ function TourButton({ steps }) {
6358
6405
  const dialog = useRef12(null);
6359
6406
  const next = useRef12(null);
6360
6407
  const [pos, setPos] = useState8(null);
6361
- const titleId = useId4();
6362
- const textId = useId4();
6408
+ const titleId = useId5();
6409
+ const textId = useId5();
6363
6410
  const step = at === null ? void 0 : steps[at];
6364
6411
  const text = useTree(
6365
6412
  useCallback6(
@@ -6420,7 +6467,7 @@ function TourButton({ steps }) {
6420
6467
  }, [isOpen]);
6421
6468
  if (steps.length === 0) return null;
6422
6469
  const last = at === steps.length - 1;
6423
- return /* @__PURE__ */ jsxs21(Fragment9, { children: [
6470
+ return /* @__PURE__ */ jsxs22(Fragment9, { children: [
6424
6471
  /* @__PURE__ */ jsx29(
6425
6472
  "button",
6426
6473
  {
@@ -6433,7 +6480,7 @@ function TourButton({ steps }) {
6433
6480
  children: "Tour"
6434
6481
  }
6435
6482
  ),
6436
- step && at !== null && /* @__PURE__ */ jsxs21(
6483
+ step && at !== null && /* @__PURE__ */ jsxs22(
6437
6484
  "dialog",
6438
6485
  {
6439
6486
  open: true,
@@ -6451,16 +6498,16 @@ function TourButton({ steps }) {
6451
6498
  close();
6452
6499
  },
6453
6500
  children: [
6454
- /* @__PURE__ */ jsxs21("div", { className: "ds-tour-head", children: [
6501
+ /* @__PURE__ */ jsxs22("div", { className: "ds-tour-head", children: [
6455
6502
  text?.title && /* @__PURE__ */ jsx29("h3", { className: "ds-tour-title", id: titleId, children: text.title }),
6456
- /* @__PURE__ */ jsxs21("span", { className: "ds-tour-count", children: [
6503
+ /* @__PURE__ */ jsxs22("span", { className: "ds-tour-count", children: [
6457
6504
  at + 1,
6458
6505
  " / ",
6459
6506
  steps.length
6460
6507
  ] })
6461
6508
  ] }),
6462
6509
  /* @__PURE__ */ jsx29("p", { className: "ds-tour-text", id: textId, "aria-live": "polite", children: text?.text }),
6463
- /* @__PURE__ */ jsxs21("div", { className: "ds-tour-foot", children: [
6510
+ /* @__PURE__ */ jsxs22("div", { className: "ds-tour-foot", children: [
6464
6511
  /* @__PURE__ */ jsx29("button", { type: "button", className: "ds-tour-skip", onClick: close, children: "Close" }),
6465
6512
  /* @__PURE__ */ jsx29("span", { className: "ds-filters-spacer" }),
6466
6513
  at > 0 && /* @__PURE__ */ jsx29("button", { type: "button", className: "ds-filter-reset", onClick: () => setAt(at - 1), children: "Back" }),
@@ -7120,7 +7167,7 @@ function releaseDefaultPrefix(owner) {
7120
7167
  }
7121
7168
 
7122
7169
  // src/components/DashboardRenderer.tsx
7123
- import { Fragment as Fragment10, jsx as jsx30, jsxs as jsxs22 } from "react/jsx-runtime";
7170
+ import { Fragment as Fragment10, jsx as jsx30, jsxs as jsxs23 } from "react/jsx-runtime";
7124
7171
  function usesScripts(doc) {
7125
7172
  const handler = (h) => {
7126
7173
  if (typeof h === "string") return isCallbackSource(h);
@@ -7191,13 +7238,13 @@ function saveFile(content, filename, type) {
7191
7238
  }
7192
7239
  function InvalidDocument({ problems }) {
7193
7240
  const errors = problems.filter((p) => p.severity === "error");
7194
- return /* @__PURE__ */ jsxs22("div", { className: "ds-invalid", role: "alert", children: [
7195
- /* @__PURE__ */ jsxs22("strong", { children: [
7241
+ return /* @__PURE__ */ jsxs23("div", { className: "ds-invalid", role: "alert", children: [
7242
+ /* @__PURE__ */ jsxs23("strong", { children: [
7196
7243
  "This dashboard can't be shown: its JSON has ",
7197
7244
  errors.length,
7198
7245
  " problem(s)."
7199
7246
  ] }),
7200
- /* @__PURE__ */ jsx30("ul", { children: errors.slice(0, 20).map((p) => /* @__PURE__ */ jsxs22("li", { children: [
7247
+ /* @__PURE__ */ jsx30("ul", { children: errors.slice(0, 20).map((p) => /* @__PURE__ */ jsxs23("li", { children: [
7201
7248
  /* @__PURE__ */ jsx30("code", { children: p.path || "(root)" }),
7202
7249
  " ",
7203
7250
  p.message
@@ -7509,7 +7556,7 @@ var DashboardRenderer = forwardRef(
7509
7556
  if (loaded.status === "invalid")
7510
7557
  content = props.renderError?.({ code: "invalid", message: loaded.problems[0]?.message ?? "Invalid" }) ?? /* @__PURE__ */ jsx30(InvalidDocument, { problems: loaded.problems });
7511
7558
  else if (sandboxError)
7512
- content = /* @__PURE__ */ jsxs22("div", { className: "ds-invalid", children: [
7559
+ content = /* @__PURE__ */ jsxs23("div", { className: "ds-invalid", children: [
7513
7560
  "Could not start the script sandbox: ",
7514
7561
  sandboxError
7515
7562
  ] });
@@ -7528,14 +7575,14 @@ var DashboardRenderer = forwardRef(
7528
7575
  breakpoint: props.breakpoint
7529
7576
  }
7530
7577
  );
7531
- return /* @__PURE__ */ jsxs22(ThemeScope, { theme: picked.theme, mode: picked.mode, children: [
7578
+ return /* @__PURE__ */ jsxs23(ThemeScope, { theme: picked.theme, mode: picked.mode, children: [
7532
7579
  /* @__PURE__ */ jsx30("style", { dangerouslySetInnerHTML: { __html: RENDERER_CSS } }),
7533
7580
  /* @__PURE__ */ jsx30(
7534
7581
  Boundary,
7535
7582
  {
7536
7583
  resetKeys: [loaded, runtime],
7537
7584
  onError: (e) => latest.current.onError?.({ code: "render", message: e.message }),
7538
- fallback: (e) => /* @__PURE__ */ jsxs22("div", { className: "ds-invalid", role: "alert", children: [
7585
+ fallback: (e) => /* @__PURE__ */ jsxs23("div", { className: "ds-invalid", role: "alert", children: [
7539
7586
  "This dashboard could not be shown: ",
7540
7587
  e.message
7541
7588
  ] }),
@@ -7592,8 +7639,8 @@ function DashboardBody({
7592
7639
  const grid = doc.spec.grid;
7593
7640
  const tour = editable ? NO_STEPS : doc.spec.tour ?? NO_STEPS;
7594
7641
  const hidden = useHiddenPanels(Object.keys(doc.spec.panels));
7595
- return /* @__PURE__ */ jsxs22(Fragment10, { children: [
7596
- !hideHeader && (head.title || head.synced || tour.length > 0) && /* @__PURE__ */ jsxs22("div", { className: "ds-header", children: [
7642
+ return /* @__PURE__ */ jsxs23(Fragment10, { children: [
7643
+ !hideHeader && (head.title || head.synced || tour.length > 0) && /* @__PURE__ */ jsxs23("div", { className: "ds-header", children: [
7597
7644
  head.title && /* @__PURE__ */ jsx30("h2", { className: "ds-title", children: head.title }),
7598
7645
  head.description && /* @__PURE__ */ jsx30("p", { className: "ds-desc", children: head.description }),
7599
7646
  head.synced && /* @__PURE__ */ jsx30("span", { className: "ds-synced", children: head.synced }),
@@ -7648,7 +7695,7 @@ function DashboardBody({
7648
7695
  }
7649
7696
  var NO_STEPS = [];
7650
7697
  function PartError({ what, error }) {
7651
- return /* @__PURE__ */ jsxs22("div", { className: "ds-state ds-state-error", role: "alert", children: [
7698
+ return /* @__PURE__ */ jsxs23("div", { className: "ds-state ds-state-error", role: "alert", children: [
7652
7699
  what,
7653
7700
  " could not be shown: ",
7654
7701
  error.message
@@ -7832,6 +7879,7 @@ export {
7832
7879
  useTree,
7833
7880
  validateDocument,
7834
7881
  widgetChecks,
7882
+ widgetThemeCss,
7835
7883
  wrapComponent
7836
7884
  };
7837
7885
  //# sourceMappingURL=index.js.map