@dashspec/renderer 0.1.5 → 0.1.7

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-7J6WHLG6.js";
118
+ } from "./chunk-RJI35HZD.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
  ] })
@@ -3154,13 +3179,14 @@ function FilterBar() {
3154
3179
  useCallback2(
3155
3180
  (t) => ({
3156
3181
  filters: t.filters,
3182
+ view: t.view,
3157
3183
  visible: variables.filter(
3158
3184
  (v) => typeof v.visibleWhen !== "string" || Boolean(evaluateSafe(v.visibleWhen, rootScope(t, runtime.helpers), true))
3159
3185
  ).map((v) => v.name).join("\0")
3160
3186
  }),
3161
3187
  [variables, runtime]
3162
3188
  ),
3163
- (a, b) => a.filters === b.filters && a.visible === b.visible
3189
+ (a, b) => a.filters === b.filters && a.visible === b.visible && a.view === b.view
3164
3190
  );
3165
3191
  const visibleNames = new Set(state.visible.split("\0"));
3166
3192
  const [draft, setDraft] = useState2(null);
@@ -3185,7 +3211,49 @@ function FilterBar() {
3185
3211
  if (shown.length === 0 || bar.show === false) return null;
3186
3212
  const values = { ...state.filters, ...draft };
3187
3213
  const set = (name, value, apply) => apply ? runtime.store.dispatch(stateActions.setFilter({ name, value })) : setDraft((d) => ({ ...d, [name]: value }));
3188
- const toolbar = /* @__PURE__ */ jsxs5(
3214
+ const Custom = options.ui?.FilterBar;
3215
+ if (Custom && !options.onFilterSelect) {
3216
+ const layouts = runtime.doc.spec.layouts ?? [];
3217
+ const views = [];
3218
+ for (const l of layouts)
3219
+ if (l.view && !views.some((v) => v.name === l.view)) views.push({ name: l.view, label: l.label ?? l.view });
3220
+ const byName = new Map(variables.map((v) => [v.name, v]));
3221
+ return /* @__PURE__ */ jsx8(
3222
+ Custom,
3223
+ {
3224
+ filters: shown.map((v) => ({
3225
+ name: v.name,
3226
+ kind: v.kind,
3227
+ ...typeof v.label === "string" ? { label: v.label } : {},
3228
+ config: v
3229
+ })),
3230
+ values,
3231
+ setFilter: (name, value) => runtime.store.dispatch(stateActions.setFilter({ name, value })),
3232
+ reset: () => {
3233
+ setDraft(null);
3234
+ for (const [name, value] of Object.entries(defaults()))
3235
+ runtime.store.dispatch(stateActions.setFilter({ name, value }));
3236
+ },
3237
+ isDefault,
3238
+ views,
3239
+ view: state.view,
3240
+ setView: (view) => runtime.store.dispatch(stateActions.setView(view)),
3241
+ renderControl: (name) => {
3242
+ const def = byName.get(name);
3243
+ return def ? /* @__PURE__ */ jsx8(
3244
+ ControlField,
3245
+ {
3246
+ compact: true,
3247
+ def,
3248
+ value: values[name],
3249
+ onChange: (val) => set(name, val, applyMode(def) === "change")
3250
+ }
3251
+ ) : null;
3252
+ }
3253
+ }
3254
+ );
3255
+ }
3256
+ const toolbar = /* @__PURE__ */ jsxs6(
3189
3257
  "div",
3190
3258
  {
3191
3259
  className: "ds-filters",
@@ -3198,7 +3266,7 @@ function FilterBar() {
3198
3266
  if (!e.target.closest(".ds-filter-pick")) options.onFilterSelect?.(BAR);
3199
3267
  } : void 0,
3200
3268
  children: [
3201
- /* @__PURE__ */ jsxs5(Track, { segmented: bar.look === "segmented", children: [
3269
+ /* @__PURE__ */ jsxs6(Track, { segmented: bar.look === "segmented", children: [
3202
3270
  bar.icon !== "none" && /* @__PURE__ */ jsx8("span", { className: "ds-filters-icon", "aria-hidden": "true", children: BAR_ICONS[bar.icon ?? "sliders"] ?? BAR_ICONS.sliders }),
3203
3271
  shown.map(
3204
3272
  (v) => options.onFilterSelect ? (
@@ -3271,7 +3339,7 @@ function FilterDrawer({ active, children }) {
3271
3339
  const [open, setOpen] = useState2(false);
3272
3340
  const button = useRef3(null);
3273
3341
  const panel = useRef3(null);
3274
- const id = useId2();
3342
+ const id = useId3();
3275
3343
  useEffect2(() => {
3276
3344
  if (!open) return;
3277
3345
  const first = panel.current?.querySelector(FOCUSABLE);
@@ -3281,8 +3349,8 @@ function FilterDrawer({ active, children }) {
3281
3349
  setOpen(false);
3282
3350
  button.current?.focus();
3283
3351
  };
3284
- return /* @__PURE__ */ jsxs5("div", { className: "ds-filter-drawer", children: [
3285
- /* @__PURE__ */ jsxs5(
3352
+ return /* @__PURE__ */ jsxs6("div", { className: "ds-filter-drawer", children: [
3353
+ /* @__PURE__ */ jsxs6(
3286
3354
  "button",
3287
3355
  {
3288
3356
  ref: button,
@@ -3301,7 +3369,7 @@ function FilterDrawer({ active, children }) {
3301
3369
  }
3302
3370
  ),
3303
3371
  open && // A non-modal <dialog>: the rest of the dashboard stays usable while it is open.
3304
- /* @__PURE__ */ jsxs5(
3372
+ /* @__PURE__ */ jsxs6(
3305
3373
  "dialog",
3306
3374
  {
3307
3375
  open: true,
@@ -3317,7 +3385,7 @@ function FilterDrawer({ active, children }) {
3317
3385
  close();
3318
3386
  },
3319
3387
  children: [
3320
- /* @__PURE__ */ jsxs5("div", { className: "ds-filter-panel-head", children: [
3388
+ /* @__PURE__ */ jsxs6("div", { className: "ds-filter-panel-head", children: [
3321
3389
  /* @__PURE__ */ jsx8("span", { children: "Filters" }),
3322
3390
  /* @__PURE__ */ jsx8("button", { type: "button", className: "ds-close", "aria-label": "Close filters", onClick: close, children: "\xD7" })
3323
3391
  ] }),
@@ -3401,7 +3469,7 @@ var Image = defineWidget({
3401
3469
 
3402
3470
  // src/widgets/builtins/ImageMap.tsx
3403
3471
  import "zod";
3404
- import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
3472
+ import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
3405
3473
  var ImageMap = defineWidget({
3406
3474
  ...ImageMapContract,
3407
3475
  implements: "image-map",
@@ -3419,11 +3487,11 @@ var ImageMap = defineWidget({
3419
3487
  row: r
3420
3488
  })) : [];
3421
3489
  const src = safeImageSrc(spec.src);
3422
- return /* @__PURE__ */ jsxs6("div", { className: "ds-imagemap", children: [
3490
+ return /* @__PURE__ */ jsxs7("div", { className: "ds-imagemap", children: [
3423
3491
  src && /* @__PURE__ */ jsx11("img", { src, alt: spec.alt }),
3424
3492
  markers.map((mk, i) => {
3425
3493
  const t = mk.status ? spec.statusMap?.[mk.status] ?? mk.status : "info";
3426
- return /* @__PURE__ */ jsxs6(
3494
+ return /* @__PURE__ */ jsxs7(
3427
3495
  "button",
3428
3496
  {
3429
3497
  type: "button",
@@ -3439,7 +3507,7 @@ var ImageMap = defineWidget({
3439
3507
  onMouseEnter: () => emit("hover", "marker", { datum: mk.row, value: mk.value, index: i }),
3440
3508
  children: [
3441
3509
  mk.label,
3442
- mk.value !== void 0 && /* @__PURE__ */ jsxs6("strong", { children: [
3510
+ mk.value !== void 0 && /* @__PURE__ */ jsxs7("strong", { children: [
3443
3511
  " ",
3444
3512
  formatValue(mk.value, helpers, spec.format),
3445
3513
  spec.unit ? ` ${spec.unit}` : ""
@@ -3459,7 +3527,7 @@ import "zod";
3459
3527
  // src/widgets/shared/InfoTip.tsx
3460
3528
  import { useLayoutEffect as useLayoutEffect2, useRef as useRef4, useState as useState3 } from "react";
3461
3529
  import { createPortal as createPortal2 } from "react-dom";
3462
- import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
3530
+ import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
3463
3531
  function InfoTip({ text }) {
3464
3532
  const ref = useRef4(null);
3465
3533
  const tip = useRef4(null);
@@ -3472,13 +3540,17 @@ function InfoTip({ text }) {
3472
3540
  const gap = 8;
3473
3541
  const margin = 8;
3474
3542
  const vw = window.innerWidth || document.documentElement.clientWidth;
3475
- 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;
3476
3548
  const centre = a.left + a.width / 2;
3477
- 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));
3478
3550
  setPos({ left, top: below ? a.bottom + gap : a.top - t.height - gap, arrow: centre - left, below });
3479
3551
  }, [open]);
3480
3552
  const root = ref.current?.closest(".ds-root") ?? (typeof document !== "undefined" ? document.body : null);
3481
- return /* @__PURE__ */ jsxs7(
3553
+ return /* @__PURE__ */ jsxs8(
3482
3554
  "button",
3483
3555
  {
3484
3556
  ref,
@@ -3497,7 +3569,7 @@ function InfoTip({ text }) {
3497
3569
  setPos(null);
3498
3570
  },
3499
3571
  children: [
3500
- /* @__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: [
3501
3573
  /* @__PURE__ */ jsx12("circle", { cx: "8", cy: "8", r: "6.5", fill: "none", stroke: "currentColor", strokeWidth: "1" }),
3502
3574
  /* @__PURE__ */ jsx12("path", { d: "M8 7.2v3.6M8 5.2v.1", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round" })
3503
3575
  ] }),
@@ -3529,7 +3601,7 @@ function InfoTip({ text }) {
3529
3601
  import { useContext as useContext4 } from "react";
3530
3602
 
3531
3603
  // src/components/PanelFrame.tsx
3532
- 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";
3533
3605
 
3534
3606
  // src/widgets/parseProps.ts
3535
3607
  function without(value, path) {
@@ -3587,7 +3659,7 @@ var Boundary = class extends Component {
3587
3659
 
3588
3660
  // src/components/Slot.tsx
3589
3661
  import { createContext as createContext3, useContext as useContext3 } from "react";
3590
- 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";
3591
3663
  var NodeScopeContext = createContext3({});
3592
3664
  var useNodeScope = () => useContext3(NodeScopeContext);
3593
3665
  var SlotOwnerContext = createContext3(null);
@@ -3623,7 +3695,7 @@ function Slot({
3623
3695
  item: item !== void 0 ? item : outer.item,
3624
3696
  index: index !== void 0 ? index : outer.index
3625
3697
  };
3626
- return /* @__PURE__ */ jsx13(NodeScopeContext.Provider, { value: scope2, children: /* @__PURE__ */ jsxs8(
3698
+ return /* @__PURE__ */ jsx13(NodeScopeContext.Provider, { value: scope2, children: /* @__PURE__ */ jsxs9(
3627
3699
  "div",
3628
3700
  {
3629
3701
  className: className ? `ds-slot ${className}` : "ds-slot",
@@ -3641,7 +3713,7 @@ function Slot({
3641
3713
  var SlotItem = ({ children }) => /* @__PURE__ */ jsx13(Fragment4, { children });
3642
3714
 
3643
3715
  // src/components/PanelFrame.tsx
3644
- import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
3716
+ import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
3645
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;
3646
3718
  function useSize() {
3647
3719
  const [size2, setSize] = useState4({ width: 0, height: 0 });
@@ -3857,14 +3929,14 @@ function PanelCrash({ id, error }) {
3857
3929
  } catch {
3858
3930
  custom = void 0;
3859
3931
  }
3860
- 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: [
3861
3933
  "This panel could not be shown: ",
3862
3934
  error.message
3863
3935
  ] }) }) });
3864
3936
  }
3865
3937
  function PanelFrameInner({ id, nested }) {
3866
3938
  const { runtime, registry, options, visibility } = useDashboard();
3867
- const instance = `${id}\0${useId3()}`;
3939
+ const instance = `${id}\0${useId4()}`;
3868
3940
  const inherited = useNodeScope();
3869
3941
  const def = findPanel(runtime.doc, id);
3870
3942
  const widget = registry.byKind.get(def.kind);
@@ -4018,7 +4090,7 @@ function PanelFrameInner({ id, nested }) {
4018
4090
  const hideHeader = Boolean(def.style?.hideHeader) || !title && !meta2 && !live2 && drill.length === 0 && controls.length === 0 && !view.stale && headerKids.length === 0;
4019
4091
  const dnd = Boolean(options.onDropOnPanel);
4020
4092
  let body;
4021
- if (!widget) body = /* @__PURE__ */ jsxs9("div", { className: "ds-state", children: [
4093
+ if (!widget) body = /* @__PURE__ */ jsxs10("div", { className: "ds-state", children: [
4022
4094
  "Unknown widget \u201C",
4023
4095
  String(def.kind),
4024
4096
  "\u201D"
@@ -4035,7 +4107,7 @@ function PanelFrameInner({ id, nested }) {
4035
4107
  Boundary,
4036
4108
  {
4037
4109
  resetKeys: [view.data, props],
4038
- 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: [
4039
4111
  "This panel could not be shown: ",
4040
4112
  e.message
4041
4113
  ] }),
@@ -4070,7 +4142,7 @@ function PanelFrameInner({ id, nested }) {
4070
4142
  const name = el?.getAttribute("data-slot") ?? defaultSlot;
4071
4143
  return { slot: name, index: el ? indexIn(el, x, y) : void 0 };
4072
4144
  };
4073
- 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(
4074
4146
  "section",
4075
4147
  {
4076
4148
  ref: frameRef,
@@ -4078,6 +4150,7 @@ function PanelFrameInner({ id, nested }) {
4078
4150
  style: panelStyle(def.style),
4079
4151
  "data-tone": tone2,
4080
4152
  "data-panel": id,
4153
+ "data-kind": def.kind,
4081
4154
  "data-selected": selected || void 0,
4082
4155
  "data-nested": nested || void 0,
4083
4156
  "aria-label": title ?? id,
@@ -4117,15 +4190,15 @@ function PanelFrameInner({ id, nested }) {
4117
4190
  e.stopPropagation();
4118
4191
  } : void 0,
4119
4192
  children: [
4120
- !hideHeader && /* @__PURE__ */ jsxs9("header", { className: "ds-panel-head", children: [
4121
- /* @__PURE__ */ jsxs9("div", { style: { minWidth: 0 }, children: [
4122
- 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: [
4123
4196
  title,
4124
4197
  info && /* @__PURE__ */ jsx14(InfoTip, { text: info })
4125
4198
  ] }),
4126
- 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: [
4127
4200
  /* @__PURE__ */ jsx14("button", { type: "button", onClick: () => runtime.runAction({ do: "drillReset", panel: id }), children: "All" }),
4128
- drill.map((d, i) => /* @__PURE__ */ jsxs9("span", { children: [
4201
+ drill.map((d, i) => /* @__PURE__ */ jsxs10("span", { children: [
4129
4202
  "\u203A",
4130
4203
  " ",
4131
4204
  i < drill.length - 1 ? /* @__PURE__ */ jsx14(
@@ -4141,10 +4214,10 @@ function PanelFrameInner({ id, nested }) {
4141
4214
  ] }, `${d.level}-${i}`))
4142
4215
  ] })
4143
4216
  ] }),
4144
- /* @__PURE__ */ jsxs9("div", { className: "ds-panel-tools", children: [
4217
+ /* @__PURE__ */ jsxs10("div", { className: "ds-panel-tools", children: [
4145
4218
  headerKids.length > 0 && /* @__PURE__ */ jsx14(Slot, { name: "header", className: "ds-panel-addons" }),
4146
4219
  meta2 && /* @__PURE__ */ jsx14("span", { className: "ds-panel-meta", children: meta2 }),
4147
- 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: [
4148
4221
  /* @__PURE__ */ jsx14("span", { "aria-hidden": "true" }),
4149
4222
  "Live, updated ",
4150
4223
  view.updatedAt ? runtime.helpers.fmt.ago(view.updatedAt) : "\u2026"
@@ -4178,7 +4251,7 @@ function loadingText(messages) {
4178
4251
  }
4179
4252
  function LoadingState({ text }) {
4180
4253
  if (!text) return /* @__PURE__ */ jsx14("div", { className: "ds-skeleton", "aria-busy": "true", "aria-label": "Loading" });
4181
- return /* @__PURE__ */ jsxs9("output", { className: "ds-loading", "aria-busy": "true", children: [
4254
+ return /* @__PURE__ */ jsxs10("output", { className: "ds-loading", "aria-busy": "true", children: [
4182
4255
  /* @__PURE__ */ jsx14("div", { className: "ds-skeleton", "aria-hidden": "true" }),
4183
4256
  /* @__PURE__ */ jsx14("span", { className: "ds-loading-text", children: text })
4184
4257
  ] });
@@ -4234,7 +4307,7 @@ function useCountUp(target, ms = 700) {
4234
4307
  }
4235
4308
 
4236
4309
  // src/widgets/builtins/Kpi.tsx
4237
- 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";
4238
4311
  var Kpi = defineWidget({
4239
4312
  ...KpiContract,
4240
4313
  implements: "kpi",
@@ -4268,8 +4341,8 @@ var Kpi = defineWidget({
4268
4341
  const outside = n !== void 0 && (low !== void 0 && n < low || high !== void 0 && n > high);
4269
4342
  const pTarget = spec.progress ? num(spec.progress.target) : void 0;
4270
4343
  const ratio = n !== void 0 && pTarget ? Math.min(spec.progress?.cap ?? Number.POSITIVE_INFINITY, n / pTarget * 100) : void 0;
4271
- return /* @__PURE__ */ jsxs10("div", { className: "ds-kpi", "data-size": spec.size, children: [
4272
- /* @__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: [
4273
4346
  /* @__PURE__ */ jsx15("span", { children: spec.title }),
4274
4347
  spec.info && /* @__PURE__ */ jsx15(InfoTip, { text: spec.info })
4275
4348
  ] }),
@@ -4285,8 +4358,8 @@ var Kpi = defineWidget({
4285
4358
  children: empty ? (
4286
4359
  // No value is not zero: the author's text, else a dash.
4287
4360
  /* @__PURE__ */ jsx15("span", { className: "ds-kpi-empty", children: spec.emptyText || "\u2014" })
4288
- ) : /* @__PURE__ */ jsxs10(Fragment5, { children: [
4289
- /* @__PURE__ */ jsxs10(
4361
+ ) : /* @__PURE__ */ jsxs11(Fragment5, { children: [
4362
+ /* @__PURE__ */ jsxs11(
4290
4363
  "span",
4291
4364
  {
4292
4365
  className: "ds-kpi-value",
@@ -4301,7 +4374,7 @@ var Kpi = defineWidget({
4301
4374
  ] })
4302
4375
  }
4303
4376
  ),
4304
- delta !== void 0 && /* @__PURE__ */ jsxs10(
4377
+ delta !== void 0 && /* @__PURE__ */ jsxs11(
4305
4378
  "span",
4306
4379
  {
4307
4380
  className: "ds-kpi-delta",
@@ -4310,7 +4383,7 @@ var Kpi = defineWidget({
4310
4383
  delta > 0 ? "\u2191" : delta < 0 ? "\u2193" : "\u2192",
4311
4384
  " ",
4312
4385
  spec.format === "duration" ? helpers.fmt.duration(Math.abs(delta)) : `${helpers.fmt.number(Math.abs(ref ? delta / Math.abs(ref) * 100 : 0), 1)}%`,
4313
- 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: [
4314
4387
  " ",
4315
4388
  spec.compare.label
4316
4389
  ] })
@@ -4319,7 +4392,7 @@ var Kpi = defineWidget({
4319
4392
  ),
4320
4393
  spec.note && /* @__PURE__ */ jsx15("span", { className: "ds-kpi-sub", children: spec.note }),
4321
4394
  spec.sublabel && /* @__PURE__ */ jsx15("span", { className: "ds-kpi-sub", children: spec.sublabel }),
4322
- 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: [
4323
4396
  "Expected ",
4324
4397
  fmt(low),
4325
4398
  "\u2013",
@@ -4342,7 +4415,7 @@ var Kpi = defineWidget({
4342
4415
  )
4343
4416
  }
4344
4417
  ),
4345
- (hasTarget || targetText) && /* @__PURE__ */ jsxs10("div", { className: "ds-kpi-foot", children: [
4418
+ (hasTarget || targetText) && /* @__PURE__ */ jsxs11("div", { className: "ds-kpi-foot", children: [
4346
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 }),
4347
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 })
4348
4421
  ] })
@@ -4352,7 +4425,7 @@ var Kpi = defineWidget({
4352
4425
 
4353
4426
  // src/widgets/builtins/Sparkline.tsx
4354
4427
  import "zod";
4355
- import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
4428
+ import { jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
4356
4429
  function sparkPath(values, w, h, pad = 2) {
4357
4430
  if (values.length === 0) return { line: "", area: "" };
4358
4431
  const min = values.reduce((a, b) => Math.min(a, b));
@@ -4372,7 +4445,7 @@ function SparkSvg({
4372
4445
  }) {
4373
4446
  const w = 120;
4374
4447
  const { line, area: fill } = sparkPath(values, w, height);
4375
- 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: [
4376
4449
  area && /* @__PURE__ */ jsx16("path", { d: fill, fill: color2, opacity: 0.15 }),
4377
4450
  /* @__PURE__ */ jsx16("path", { d: line, fill: "none", stroke: color2, strokeWidth: 1.5, vectorEffect: "non-scaling-stroke" })
4378
4451
  ] });
@@ -4401,7 +4474,7 @@ var Sparkline = defineWidget({
4401
4474
 
4402
4475
  // src/widgets/builtins/StageTracker.tsx
4403
4476
  import "zod";
4404
- import { jsx as jsx17, jsxs as jsxs12 } from "react/jsx-runtime";
4477
+ import { jsx as jsx17, jsxs as jsxs13 } from "react/jsx-runtime";
4405
4478
  var StageTracker = defineWidget({
4406
4479
  ...StageTrackerContract,
4407
4480
  implements: "stages",
@@ -4413,7 +4486,7 @@ var StageTracker = defineWidget({
4413
4486
  const idx = typeof raw === "number" ? raw : spec.stages.findIndex((s) => s.toLowerCase() === String(raw ?? "").toLowerCase());
4414
4487
  return /* @__PURE__ */ jsx17("ol", { className: "ds-stages", children: spec.stages.map((s, i) => {
4415
4488
  const state = i < idx ? "done" : i === idx ? "current" : "todo";
4416
- return /* @__PURE__ */ jsx17("li", { "data-state": state, children: /* @__PURE__ */ jsxs12(
4489
+ return /* @__PURE__ */ jsx17("li", { "data-state": state, children: /* @__PURE__ */ jsxs13(
4417
4490
  "button",
4418
4491
  {
4419
4492
  type: "button",
@@ -4431,7 +4504,7 @@ var StageTracker = defineWidget({
4431
4504
 
4432
4505
  // src/widgets/builtins/StateTimeline.tsx
4433
4506
  import "zod";
4434
- import { jsx as jsx18, jsxs as jsxs13 } from "react/jsx-runtime";
4507
+ import { jsx as jsx18, jsxs as jsxs14 } from "react/jsx-runtime";
4435
4508
  var StateTimeline = defineWidget({
4436
4509
  ...StateTimelineContract,
4437
4510
  implements: "timeline",
@@ -4445,7 +4518,7 @@ var StateTimeline = defineWidget({
4445
4518
  const lanes = spec.rows ? [...new Set(all.map((x) => String(field(x.r, spec.rows))))] : [""];
4446
4519
  const span = Math.max(1, end - start);
4447
4520
  const states = /* @__PURE__ */ new Map();
4448
- return /* @__PURE__ */ jsxs13("div", { className: "ds-timeline", children: [
4521
+ return /* @__PURE__ */ jsxs14("div", { className: "ds-timeline", children: [
4449
4522
  lanes.map((lane) => {
4450
4523
  const pts = all.filter((x) => !spec.rows || String(field(x.r, spec.rows)) === lane);
4451
4524
  const segs = pts.map((p, i) => {
@@ -4455,7 +4528,7 @@ var StateTimeline = defineWidget({
4455
4528
  states.set(state, (states.get(state) ?? 0) + Math.max(0, to - from));
4456
4529
  return { p, from, to, state };
4457
4530
  });
4458
- return /* @__PURE__ */ jsxs13("div", { className: "ds-timeline-lane", children: [
4531
+ return /* @__PURE__ */ jsxs14("div", { className: "ds-timeline-lane", children: [
4459
4532
  lane && /* @__PURE__ */ jsx18("span", { className: "ds-timeline-name", children: lane }),
4460
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) => (
4461
4534
  // biome-ignore lint/a11y/useKeyWithClickEvents: the per-state totals below summarise the same data for keyboard users
@@ -4476,11 +4549,11 @@ var StateTimeline = defineWidget({
4476
4549
  )) })
4477
4550
  ] }, lane);
4478
4551
  }),
4479
- /* @__PURE__ */ jsxs13("div", { className: "ds-timeline-axis", children: [
4552
+ /* @__PURE__ */ jsxs14("div", { className: "ds-timeline-axis", children: [
4480
4553
  /* @__PURE__ */ jsx18("span", { children: helpers.fmt.date(start, "time") }),
4481
4554
  /* @__PURE__ */ jsx18("span", { children: spec.endLabel ?? helpers.fmt.date(end, "time") })
4482
4555
  ] }),
4483
- /* @__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: [
4484
4557
  /* @__PURE__ */ jsx18(
4485
4558
  "span",
4486
4559
  {
@@ -4499,7 +4572,7 @@ var StateTimeline = defineWidget({
4499
4572
 
4500
4573
  // src/widgets/builtins/Status.tsx
4501
4574
  import "zod";
4502
- import { jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
4575
+ import { jsx as jsx19, jsxs as jsxs15 } from "react/jsx-runtime";
4503
4576
  var Status = defineWidget({
4504
4577
  ...StatusContract,
4505
4578
  implements: "badge",
@@ -4512,8 +4585,8 @@ var Status = defineWidget({
4512
4585
  const state = String(field(row, spec.state) ?? "unknown");
4513
4586
  const t = spec.text ? spec.tone ?? "info" : spec.stateMap?.[state] ?? spec.tone ?? "neutral";
4514
4587
  const text = spec.text ?? spec.labels?.[state] ?? state.charAt(0).toUpperCase() + state.slice(1);
4515
- return /* @__PURE__ */ jsxs14("button", { type: "button", className: "ds-status", onClick: () => emit("click", "status", { datum: row, value: state }), children: [
4516
- /* @__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: [
4517
4590
  /* @__PURE__ */ jsx19("span", { className: "ds-dot", style: { background: tone(t).solid }, "aria-hidden": "true" }),
4518
4591
  text
4519
4592
  ] }),
@@ -4524,7 +4597,7 @@ var Status = defineWidget({
4524
4597
 
4525
4598
  // src/widgets/builtins/Table.tsx
4526
4599
  import { useEffect as useEffect5, useMemo as useMemo4, useRef as useRef7, useState as useState6 } from "react";
4527
- import { jsx as jsx20, jsxs as jsxs15 } from "react/jsx-runtime";
4600
+ import { jsx as jsx20, jsxs as jsxs16 } from "react/jsx-runtime";
4528
4601
  var ROW_H = 36;
4529
4602
  function pageList(current, pages) {
4530
4603
  if (pages <= 7) return Array.from({ length: pages }, (_, i) => i + 1);
@@ -4703,7 +4776,7 @@ var Table = defineWidget({
4703
4776
  case "progress": {
4704
4777
  const n = toNumber(v) ?? 0;
4705
4778
  const pct = Math.min(100, n / (c.max ?? 100) * 100);
4706
- return /* @__PURE__ */ jsxs15("span", { className: "ds-inline", children: [
4779
+ return /* @__PURE__ */ jsxs16("span", { className: "ds-inline", children: [
4707
4780
  /* @__PURE__ */ jsx20("span", { className: "ds-progress", style: { flex: 1, minWidth: 40 }, children: /* @__PURE__ */ jsx20("span", { style: { width: `${pct}%`, background: "var(--ds-series-1)" } }) }),
4708
4781
  formatValue(n, helpers, c.format, c.decimals),
4709
4782
  c.suffix
@@ -4741,10 +4814,10 @@ var Table = defineWidget({
4741
4814
  }
4742
4815
  };
4743
4816
  const align = (c) => c.align ?? (c.type === "number" || c.format && c.format !== "date" && c.format !== "text" ? "right" : "left");
4744
- return /* @__PURE__ */ jsxs15("div", { className: "ds-table-wrap", "data-density": spec.density, children: [
4745
- sr && /* @__PURE__ */ jsxs15("div", { className: "ds-table-tools", children: [
4746
- /* @__PURE__ */ jsxs15("label", { className: "ds-search", children: [
4747
- /* @__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: [
4748
4821
  /* @__PURE__ */ jsx20("circle", { cx: "7", cy: "7", r: "4.5", fill: "none", stroke: "currentColor", strokeWidth: "1.5" }),
4749
4822
  /* @__PURE__ */ jsx20("path", { d: "m10.5 10.5 3 3", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
4750
4823
  ] }),
@@ -4764,12 +4837,12 @@ var Table = defineWidget({
4764
4837
  }
4765
4838
  )
4766
4839
  ] }),
4767
- /* @__PURE__ */ jsxs15("span", { className: "ds-table-count", children: [
4840
+ /* @__PURE__ */ jsxs16("span", { className: "ds-table-count", children: [
4768
4841
  helpers.fmt.number(rowTotal),
4769
4842
  " rows"
4770
4843
  ] })
4771
4844
  ] }),
4772
- /* @__PURE__ */ jsxs15(
4845
+ /* @__PURE__ */ jsxs16(
4773
4846
  "div",
4774
4847
  {
4775
4848
  className: "ds-table-scroll",
@@ -4779,8 +4852,8 @@ var Table = defineWidget({
4779
4852
  onScroll: windowed ? (e) => setScrollTop(e.currentTarget.scrollTop) : void 0,
4780
4853
  children: [
4781
4854
  busy && /* @__PURE__ */ jsx20("div", { className: "ds-table-busy", "aria-hidden": "true" }),
4782
- /* @__PURE__ */ jsxs15("table", { className: "ds-table", "aria-busy": busy || void 0, children: [
4783
- /* @__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: [
4784
4857
  /* @__PURE__ */ jsx20("tr", { children: columns.map((c, i) => {
4785
4858
  const sorted = sort?.key === c.key ? sort.order : void 0;
4786
4859
  return /* @__PURE__ */ jsx20(
@@ -4789,7 +4862,7 @@ var Table = defineWidget({
4789
4862
  "data-ds-part": `column:${i}`,
4790
4863
  style: { textAlign: align(c), width: c.width },
4791
4864
  "aria-sort": sorted === "asc" ? "ascending" : sorted === "desc" ? "descending" : void 0,
4792
- 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(
4793
4866
  "button",
4794
4867
  {
4795
4868
  type: "button",
@@ -4832,7 +4905,7 @@ var Table = defineWidget({
4832
4905
  }
4833
4906
  ) : null }, `f-${c.key}-${i}`)) })
4834
4907
  ] }),
4835
- /* @__PURE__ */ jsxs15("tbody", { children: [
4908
+ /* @__PURE__ */ jsxs16("tbody", { children: [
4836
4909
  windowed && first > 0 && /* @__PURE__ */ jsx20("tr", { className: "ds-spacer", children: /* @__PURE__ */ jsx20("td", { colSpan: columns.length, style: { height: first * ROW_H, padding: 0 } }) }),
4837
4910
  shown.slice(first, last).map((row, k) => {
4838
4911
  const i = first + k;
@@ -4868,8 +4941,8 @@ var Table = defineWidget({
4868
4941
  ]
4869
4942
  }
4870
4943
  ),
4871
- pageSize && /* @__PURE__ */ jsxs15("div", { className: "ds-pager", children: [
4872
- /* @__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: [
4873
4946
  "Rows",
4874
4947
  /* @__PURE__ */ jsx20(
4875
4948
  SelectControl,
@@ -4883,7 +4956,7 @@ var Table = defineWidget({
4883
4956
  }
4884
4957
  )
4885
4958
  ] }),
4886
- /* @__PURE__ */ jsxs15("span", { children: [
4959
+ /* @__PURE__ */ jsxs16("span", { children: [
4887
4960
  rowTotal === 0 ? 0 : (current - 1) * pageSize + 1,
4888
4961
  "\u2013",
4889
4962
  Math.min(current * pageSize, rowTotal),
@@ -4891,7 +4964,7 @@ var Table = defineWidget({
4891
4964
  " ",
4892
4965
  helpers.fmt.number(rowTotal)
4893
4966
  ] }),
4894
- /* @__PURE__ */ jsxs15("span", { className: "ds-pages", children: [
4967
+ /* @__PURE__ */ jsxs16("span", { className: "ds-pages", children: [
4895
4968
  /* @__PURE__ */ jsx20(
4896
4969
  "button",
4897
4970
  {
@@ -4932,7 +5005,7 @@ var Table = defineWidget({
4932
5005
 
4933
5006
  // src/widgets/builtins/Tiles.tsx
4934
5007
  import "zod";
4935
- 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";
4936
5009
  var Tiles = defineWidget({
4937
5010
  ...TilesContract,
4938
5011
  implements: "tiles",
@@ -4970,7 +5043,7 @@ var Tiles = defineWidget({
4970
5043
  const st = status ? spec.statusMap?.[status] ?? status : void 0;
4971
5044
  const vt = n === void 0 || !spec.valueTone ? void 0 : n > 0 ? spec.valueTone.positive : n < 0 ? spec.valueTone.negative : spec.valueTone.zero;
4972
5045
  const active = spec.selectable && spec.selected !== void 0 && spec.selected === label;
4973
- return /* @__PURE__ */ jsxs16(
5046
+ return /* @__PURE__ */ jsxs17(
4974
5047
  "button",
4975
5048
  {
4976
5049
  type: "button",
@@ -4984,12 +5057,12 @@ var Tiles = defineWidget({
4984
5057
  },
4985
5058
  onMouseEnter: () => emit("hover", "tile", { datum: r, value: label, index: i }),
4986
5059
  children: [
4987
- /* @__PURE__ */ jsxs16("span", { className: "ds-tile-label", children: [
5060
+ /* @__PURE__ */ jsxs17("span", { className: "ds-tile-label", children: [
4988
5061
  st && /* @__PURE__ */ jsx21("span", { className: "ds-dot", style: { background: tone(st).solid }, "aria-hidden": "true" }),
4989
5062
  String(label ?? ""),
4990
5063
  spec.count && /* @__PURE__ */ jsx21("span", { className: "ds-chip-count", children: String(field(r, spec.count) ?? "") })
4991
5064
  ] }),
4992
- /* @__PURE__ */ jsxs16(
5065
+ /* @__PURE__ */ jsxs17(
4993
5066
  "span",
4994
5067
  {
4995
5068
  className: "ds-tile-value",
@@ -5018,7 +5091,7 @@ function CountUp({ value, render }) {
5018
5091
 
5019
5092
  // src/widgets/builtins/atoms.tsx
5020
5093
  import "zod";
5021
- import { jsx as jsx22, jsxs as jsxs17 } from "react/jsx-runtime";
5094
+ import { jsx as jsx22, jsxs as jsxs18 } from "react/jsx-runtime";
5022
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;
5023
5096
  var boundValue = (data, path) => {
5024
5097
  if (path) return field(Array.isArray(data) ? data[0] : data, path);
@@ -5064,7 +5137,7 @@ var Value = defineWidget({
5064
5137
  const target = typeof spec.target === "number" ? spec.target : spec.target ? toNumber(boundValue(data, spec.target)) : void 0;
5065
5138
  const met = n !== void 0 && target !== void 0 ? spec.goodWhen === "down" ? n <= target : n >= target : void 0;
5066
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;
5067
- 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: [
5068
5141
  spec.prefix,
5069
5142
  formatValue(shown, helpers, spec.format, spec.decimals),
5070
5143
  spec.unit && /* @__PURE__ */ jsx22("small", { children: spec.unit })
@@ -5082,7 +5155,7 @@ var Progress = defineWidget({
5082
5155
  const max = typeof spec.max === "number" ? spec.max : toNumber(boundValue(data, spec.max)) ?? 100;
5083
5156
  const pct = max > 0 ? Math.max(0, Math.min(100, n / max * 100)) : 0;
5084
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;
5085
- return /* @__PURE__ */ jsxs17("div", { className: "ds-atom-progress", children: [
5158
+ return /* @__PURE__ */ jsxs18("div", { className: "ds-atom-progress", children: [
5086
5159
  /* @__PURE__ */ jsx22(
5087
5160
  "span",
5088
5161
  {
@@ -5094,7 +5167,7 @@ var Progress = defineWidget({
5094
5167
  children: /* @__PURE__ */ jsx22("span", { style: { width: `${pct}%`, background: fill } })
5095
5168
  }
5096
5169
  ),
5097
- spec.showPercent && /* @__PURE__ */ jsxs17("small", { children: [
5170
+ spec.showPercent && /* @__PURE__ */ jsxs18("small", { children: [
5098
5171
  Math.round(pct),
5099
5172
  "%"
5100
5173
  ] })
@@ -5489,7 +5562,7 @@ function cartesian(data, source, spec, type, h, colors) {
5489
5562
  }
5490
5563
 
5491
5564
  // src/widgets/builtins/charts.tsx
5492
- import { Fragment as Fragment7, jsx as jsx24, jsxs as jsxs18 } from "react/jsx-runtime";
5565
+ import { Fragment as Fragment7, jsx as jsx24, jsxs as jsxs19 } from "react/jsx-runtime";
5493
5566
  var chartEvents = ["click", "doubleClick", "hover", "hoverEnd", "legendClick", "brush", "datazoom"];
5494
5567
  var BarChart2 = defineWidget({
5495
5568
  ...BarChartContract,
@@ -5517,19 +5590,19 @@ var BarChart2 = defineWidget({
5517
5590
  const hi = highlight === void 0 || highlight === null ? void 0 : c.categories.indexOf(String(highlight));
5518
5591
  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;
5519
5592
  const legend = c.coloured || avgText;
5520
- return /* @__PURE__ */ jsxs18("div", { className: "ds-chart", children: [
5521
- legend && /* @__PURE__ */ jsxs18("ul", { className: "ds-chart-legend", children: [
5522
- c.coloured && /* @__PURE__ */ jsxs18(Fragment7, { children: [
5523
- /* @__PURE__ */ jsxs18("li", { children: [
5593
+ return /* @__PURE__ */ jsxs19("div", { className: "ds-chart", children: [
5594
+ legend && /* @__PURE__ */ jsxs19("ul", { className: "ds-chart-legend", children: [
5595
+ c.coloured && /* @__PURE__ */ jsxs19(Fragment7, { children: [
5596
+ /* @__PURE__ */ jsxs19("li", { children: [
5524
5597
  /* @__PURE__ */ jsx24("span", { className: "ds-swatch", style: { background: colors?.good } }),
5525
5598
  spec.legendLabels?.above ?? "At or above avg"
5526
5599
  ] }),
5527
- /* @__PURE__ */ jsxs18("li", { children: [
5600
+ /* @__PURE__ */ jsxs19("li", { children: [
5528
5601
  /* @__PURE__ */ jsx24("span", { className: "ds-swatch", style: { background: colors?.bad } }),
5529
5602
  spec.legendLabels?.below ?? "Below avg"
5530
5603
  ] })
5531
5604
  ] }),
5532
- avgText && /* @__PURE__ */ jsxs18("li", { children: [
5605
+ avgText && /* @__PURE__ */ jsxs19("li", { children: [
5533
5606
  /* @__PURE__ */ jsx24("span", { className: "ds-swatch-line" }),
5534
5607
  avgText
5535
5608
  ] })
@@ -5797,7 +5870,7 @@ var MatrixChart = defineWidget({
5797
5870
  // src/widgets/builtins/layout.tsx
5798
5871
  import { Fragment as Fragment8 } from "react";
5799
5872
  import "zod";
5800
- import { jsx as jsx25, jsxs as jsxs19 } from "react/jsx-runtime";
5873
+ import { jsx as jsx25, jsxs as jsxs20 } from "react/jsx-runtime";
5801
5874
  var Row = defineWidget({
5802
5875
  ...Container,
5803
5876
  ...RowContract,
@@ -5834,7 +5907,7 @@ var Tabs = defineWidget({
5834
5907
  events: ["change"],
5835
5908
  component: function TabsWidget({ spec, state, setUi, emit, renderSlot }) {
5836
5909
  const open = String(state.ui?.tab ?? spec.initial ?? spec.tabs[0]?.key);
5837
- return /* @__PURE__ */ jsxs19("div", { className: "ds-tabs", children: [
5910
+ return /* @__PURE__ */ jsxs20("div", { className: "ds-tabs", children: [
5838
5911
  /* @__PURE__ */ jsx25("div", { className: "ds-tabs-bar", role: "tablist", children: spec.tabs.map((t) => /* @__PURE__ */ jsx25(
5839
5912
  "button",
5840
5913
  {
@@ -6108,7 +6181,7 @@ function Grid({
6108
6181
 
6109
6182
  // src/components/ModalHost.tsx
6110
6183
  import { useCallback as useCallback5, useEffect as useEffect8, useRef as useRef10 } from "react";
6111
- import { jsx as jsx27, jsxs as jsxs20 } from "react/jsx-runtime";
6184
+ import { jsx as jsx27, jsxs as jsxs21 } from "react/jsx-runtime";
6112
6185
  var WIDTH = { sm: "420px", md: "720px", lg: "1040px", xl: "1320px", full: "100%" };
6113
6186
  var FOCUSABLE2 = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
6114
6187
  function ModalHost() {
@@ -6216,7 +6289,7 @@ function ModalHost() {
6216
6289
  className: "ds-scrim",
6217
6290
  "data-presentation": m.presentation ?? "modal",
6218
6291
  onMouseDown: (e) => e.target === e.currentTarget && close(),
6219
- children: /* @__PURE__ */ jsxs20(
6292
+ children: /* @__PURE__ */ jsxs21(
6220
6293
  "dialog",
6221
6294
  {
6222
6295
  open: true,
@@ -6227,7 +6300,7 @@ function ModalHost() {
6227
6300
  ref: dialog,
6228
6301
  style: { ["--ds-dialog-w"]: WIDTH[m.size ?? "md"] ?? WIDTH.md },
6229
6302
  children: [
6230
- /* @__PURE__ */ jsxs20("div", { className: "ds-dialog-head", children: [
6303
+ /* @__PURE__ */ jsxs21("div", { className: "ds-dialog-head", children: [
6231
6304
  /* @__PURE__ */ jsx27("h2", { children: open.title }),
6232
6305
  /* @__PURE__ */ jsx27("button", { type: "button", className: "ds-close", "aria-label": "Close", onClick: close, children: "\xD7" })
6233
6306
  ] }),
@@ -6299,8 +6372,8 @@ function pickTheme(name, themes, fallback) {
6299
6372
  }
6300
6373
 
6301
6374
  // src/components/Tour.tsx
6302
- import { useCallback as useCallback6, useEffect as useEffect9, useId as useId4, useLayoutEffect as useLayoutEffect3, useRef as useRef12, useState as useState8 } from "react";
6303
- import { Fragment as Fragment9, jsx as jsx29, jsxs as jsxs21 } from "react/jsx-runtime";
6375
+ import { useCallback as useCallback6, useEffect as useEffect9, useId as useId5, useLayoutEffect as useLayoutEffect3, useRef as useRef12, useState as useState8 } from "react";
6376
+ import { Fragment as Fragment9, jsx as jsx29, jsxs as jsxs22 } from "react/jsx-runtime";
6304
6377
  var useClientLayoutEffect = typeof window === "undefined" ? useEffect9 : useLayoutEffect3;
6305
6378
  function panelElement(root, id) {
6306
6379
  if (!root || !id) return null;
@@ -6315,8 +6388,8 @@ function TourButton({ steps }) {
6315
6388
  const dialog = useRef12(null);
6316
6389
  const next = useRef12(null);
6317
6390
  const [pos, setPos] = useState8(null);
6318
- const titleId = useId4();
6319
- const textId = useId4();
6391
+ const titleId = useId5();
6392
+ const textId = useId5();
6320
6393
  const step = at === null ? void 0 : steps[at];
6321
6394
  const text = useTree(
6322
6395
  useCallback6(
@@ -6377,7 +6450,7 @@ function TourButton({ steps }) {
6377
6450
  }, [isOpen]);
6378
6451
  if (steps.length === 0) return null;
6379
6452
  const last = at === steps.length - 1;
6380
- return /* @__PURE__ */ jsxs21(Fragment9, { children: [
6453
+ return /* @__PURE__ */ jsxs22(Fragment9, { children: [
6381
6454
  /* @__PURE__ */ jsx29(
6382
6455
  "button",
6383
6456
  {
@@ -6390,7 +6463,7 @@ function TourButton({ steps }) {
6390
6463
  children: "Tour"
6391
6464
  }
6392
6465
  ),
6393
- step && at !== null && /* @__PURE__ */ jsxs21(
6466
+ step && at !== null && /* @__PURE__ */ jsxs22(
6394
6467
  "dialog",
6395
6468
  {
6396
6469
  open: true,
@@ -6408,16 +6481,16 @@ function TourButton({ steps }) {
6408
6481
  close();
6409
6482
  },
6410
6483
  children: [
6411
- /* @__PURE__ */ jsxs21("div", { className: "ds-tour-head", children: [
6484
+ /* @__PURE__ */ jsxs22("div", { className: "ds-tour-head", children: [
6412
6485
  text?.title && /* @__PURE__ */ jsx29("h3", { className: "ds-tour-title", id: titleId, children: text.title }),
6413
- /* @__PURE__ */ jsxs21("span", { className: "ds-tour-count", children: [
6486
+ /* @__PURE__ */ jsxs22("span", { className: "ds-tour-count", children: [
6414
6487
  at + 1,
6415
6488
  " / ",
6416
6489
  steps.length
6417
6490
  ] })
6418
6491
  ] }),
6419
6492
  /* @__PURE__ */ jsx29("p", { className: "ds-tour-text", id: textId, "aria-live": "polite", children: text?.text }),
6420
- /* @__PURE__ */ jsxs21("div", { className: "ds-tour-foot", children: [
6493
+ /* @__PURE__ */ jsxs22("div", { className: "ds-tour-foot", children: [
6421
6494
  /* @__PURE__ */ jsx29("button", { type: "button", className: "ds-tour-skip", onClick: close, children: "Close" }),
6422
6495
  /* @__PURE__ */ jsx29("span", { className: "ds-filters-spacer" }),
6423
6496
  at > 0 && /* @__PURE__ */ jsx29("button", { type: "button", className: "ds-filter-reset", onClick: () => setAt(at - 1), children: "Back" }),
@@ -7077,7 +7150,7 @@ function releaseDefaultPrefix(owner) {
7077
7150
  }
7078
7151
 
7079
7152
  // src/components/DashboardRenderer.tsx
7080
- import { Fragment as Fragment10, jsx as jsx30, jsxs as jsxs22 } from "react/jsx-runtime";
7153
+ import { Fragment as Fragment10, jsx as jsx30, jsxs as jsxs23 } from "react/jsx-runtime";
7081
7154
  function usesScripts(doc) {
7082
7155
  const handler = (h) => {
7083
7156
  if (typeof h === "string") return isCallbackSource(h);
@@ -7148,13 +7221,13 @@ function saveFile(content, filename, type) {
7148
7221
  }
7149
7222
  function InvalidDocument({ problems }) {
7150
7223
  const errors = problems.filter((p) => p.severity === "error");
7151
- return /* @__PURE__ */ jsxs22("div", { className: "ds-invalid", role: "alert", children: [
7152
- /* @__PURE__ */ jsxs22("strong", { children: [
7224
+ return /* @__PURE__ */ jsxs23("div", { className: "ds-invalid", role: "alert", children: [
7225
+ /* @__PURE__ */ jsxs23("strong", { children: [
7153
7226
  "This dashboard can't be shown: its JSON has ",
7154
7227
  errors.length,
7155
7228
  " problem(s)."
7156
7229
  ] }),
7157
- /* @__PURE__ */ jsx30("ul", { children: errors.slice(0, 20).map((p) => /* @__PURE__ */ jsxs22("li", { children: [
7230
+ /* @__PURE__ */ jsx30("ul", { children: errors.slice(0, 20).map((p) => /* @__PURE__ */ jsxs23("li", { children: [
7158
7231
  /* @__PURE__ */ jsx30("code", { children: p.path || "(root)" }),
7159
7232
  " ",
7160
7233
  p.message
@@ -7466,7 +7539,7 @@ var DashboardRenderer = forwardRef(
7466
7539
  if (loaded.status === "invalid")
7467
7540
  content = props.renderError?.({ code: "invalid", message: loaded.problems[0]?.message ?? "Invalid" }) ?? /* @__PURE__ */ jsx30(InvalidDocument, { problems: loaded.problems });
7468
7541
  else if (sandboxError)
7469
- content = /* @__PURE__ */ jsxs22("div", { className: "ds-invalid", children: [
7542
+ content = /* @__PURE__ */ jsxs23("div", { className: "ds-invalid", children: [
7470
7543
  "Could not start the script sandbox: ",
7471
7544
  sandboxError
7472
7545
  ] });
@@ -7485,14 +7558,14 @@ var DashboardRenderer = forwardRef(
7485
7558
  breakpoint: props.breakpoint
7486
7559
  }
7487
7560
  );
7488
- return /* @__PURE__ */ jsxs22(ThemeScope, { theme: picked.theme, mode: picked.mode, children: [
7561
+ return /* @__PURE__ */ jsxs23(ThemeScope, { theme: picked.theme, mode: picked.mode, children: [
7489
7562
  /* @__PURE__ */ jsx30("style", { dangerouslySetInnerHTML: { __html: RENDERER_CSS } }),
7490
7563
  /* @__PURE__ */ jsx30(
7491
7564
  Boundary,
7492
7565
  {
7493
7566
  resetKeys: [loaded, runtime],
7494
7567
  onError: (e) => latest.current.onError?.({ code: "render", message: e.message }),
7495
- fallback: (e) => /* @__PURE__ */ jsxs22("div", { className: "ds-invalid", role: "alert", children: [
7568
+ fallback: (e) => /* @__PURE__ */ jsxs23("div", { className: "ds-invalid", role: "alert", children: [
7496
7569
  "This dashboard could not be shown: ",
7497
7570
  e.message
7498
7571
  ] }),
@@ -7549,8 +7622,8 @@ function DashboardBody({
7549
7622
  const grid = doc.spec.grid;
7550
7623
  const tour = editable ? NO_STEPS : doc.spec.tour ?? NO_STEPS;
7551
7624
  const hidden = useHiddenPanels(Object.keys(doc.spec.panels));
7552
- return /* @__PURE__ */ jsxs22(Fragment10, { children: [
7553
- !hideHeader && (head.title || head.synced || tour.length > 0) && /* @__PURE__ */ jsxs22("div", { className: "ds-header", children: [
7625
+ return /* @__PURE__ */ jsxs23(Fragment10, { children: [
7626
+ !hideHeader && (head.title || head.synced || tour.length > 0) && /* @__PURE__ */ jsxs23("div", { className: "ds-header", children: [
7554
7627
  head.title && /* @__PURE__ */ jsx30("h2", { className: "ds-title", children: head.title }),
7555
7628
  head.description && /* @__PURE__ */ jsx30("p", { className: "ds-desc", children: head.description }),
7556
7629
  head.synced && /* @__PURE__ */ jsx30("span", { className: "ds-synced", children: head.synced }),
@@ -7605,7 +7678,7 @@ function DashboardBody({
7605
7678
  }
7606
7679
  var NO_STEPS = [];
7607
7680
  function PartError({ what, error }) {
7608
- return /* @__PURE__ */ jsxs22("div", { className: "ds-state ds-state-error", role: "alert", children: [
7681
+ return /* @__PURE__ */ jsxs23("div", { className: "ds-state ds-state-error", role: "alert", children: [
7609
7682
  what,
7610
7683
  " could not be shown: ",
7611
7684
  error.message
@@ -7789,6 +7862,7 @@ export {
7789
7862
  useTree,
7790
7863
  validateDocument,
7791
7864
  widgetChecks,
7865
+ widgetThemeCss,
7792
7866
  wrapComponent
7793
7867
  };
7794
7868
  //# sourceMappingURL=index.js.map