@dashspec/renderer 0.1.26 → 0.1.28

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.
@@ -7553,7 +7553,7 @@ declare class TransformError extends Error {
7553
7553
  declare function applyTransform(data: unknown, steps: readonly Step[], root: Scope, opts?: TransformOptions): unknown;
7554
7554
 
7555
7555
  /** This package's version. A test keeps it equal to package.json's; bump both together. */
7556
- declare const RENDERER_VERSION = "0.1.26";
7556
+ declare const RENDERER_VERSION = "0.1.28";
7557
7557
  /**
7558
7558
  * Whether `version` satisfies `range`. Supports what documents need: "1.2.3" (that or newer within the major, like
7559
7559
  * "^"), ">=1.2", ">1.2.3", "<2", "<=2.1", "^1.2", "~1.2.3", and several of them separated by spaces (all must hold).
package/dist/core.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { f as ACTION_KINDS, g as ACTION_SCHEMAS, h as API_VERSION, i as Action, j as ActionRef, k as Auth, B as BREAKPOINTS, l as BUILT_IN_DATASOURCE_TYPES, C as Callback, m as Connection, n as ConnectionSpec, o as DATE_PRESETS, D as Dashboard, p as DashboardInput, q as DataBinding, r as DataError, s as DataErrorCode, t as Datasource, u as DateRange, v as Display, w as Drill, x as Duration, y as EventHandler, z as EventMap, F as Expression, G as ExpressionError, I as FnProp, a$ as Grid, K as Handler, L as HelperSettings, M as Helpers, H as HttpClient, O as HttpClientInternals, P as Id, J as JsonValue, Q as Layout, U as LayoutItem, V as LoadOptions, X as LoadResult, Y as Metadata, Z as MigrateResult, _ as MigrationError, $ as Modal, a0 as NamedAction, N as NetworkOptions, a1 as Node, a2 as Panel, a3 as PanelControl, a4 as PanelMigration, a6 as Problem, a7 as RENDERER_VERSION, a8 as RESERVED_STATE_KEYS, a9 as RefRoot, aa as Reference, ab as Requires, R as ResolvedRequest, ac as SCHEMA_URL, S as Scope, ad as Severity, ae as Spec, b0 as StatusTone, af as Template, a as TimeSettings, ag as TokenSource, ah as TransformError, ai as TransformOptions, aj as TransformStep, ak as Translations, al as VARIABLE_KINDS, am as ValidateOptions, an as ValidationResult, ao as Variable, ap as WidgetCheck, aq as WidgetMigrations, as as applyTransform, at as buildRequestUrl, au as buildUrl, av as builtInWidgetChecks, aw as collectReferences, ax as compile, ay as createHelpers, az as createHttpClient, aA as dashboardJsonSchema, aB as evaluate, aC as evaluateSafe, aD as expressionReferences, aE as graphqlData, aF as interpolate, aG as interpolateUrl, aH as isCallbackSource, aI as isSafeUrl, aJ as loadDocument, aK as mergeConnections, aL as migrateDocument, aM as parse, aN as parseDuration, aO as placeholders, aP as plantDate, aQ as plantDayStart, aR as resolve, aS as resolveBaseUrl, aT as resolveRequest, aU as safeLink, aV as satisfies, aW as scope, aX as stripStrings, aY as templateReferences, aZ as translator, a_ as validateDocument } from './core-CM3wqmfR.js';
1
+ export { f as ACTION_KINDS, g as ACTION_SCHEMAS, h as API_VERSION, i as Action, j as ActionRef, k as Auth, B as BREAKPOINTS, l as BUILT_IN_DATASOURCE_TYPES, C as Callback, m as Connection, n as ConnectionSpec, o as DATE_PRESETS, D as Dashboard, p as DashboardInput, q as DataBinding, r as DataError, s as DataErrorCode, t as Datasource, u as DateRange, v as Display, w as Drill, x as Duration, y as EventHandler, z as EventMap, F as Expression, G as ExpressionError, I as FnProp, a$ as Grid, K as Handler, L as HelperSettings, M as Helpers, H as HttpClient, O as HttpClientInternals, P as Id, J as JsonValue, Q as Layout, U as LayoutItem, V as LoadOptions, X as LoadResult, Y as Metadata, Z as MigrateResult, _ as MigrationError, $ as Modal, a0 as NamedAction, N as NetworkOptions, a1 as Node, a2 as Panel, a3 as PanelControl, a4 as PanelMigration, a6 as Problem, a7 as RENDERER_VERSION, a8 as RESERVED_STATE_KEYS, a9 as RefRoot, aa as Reference, ab as Requires, R as ResolvedRequest, ac as SCHEMA_URL, S as Scope, ad as Severity, ae as Spec, b0 as StatusTone, af as Template, a as TimeSettings, ag as TokenSource, ah as TransformError, ai as TransformOptions, aj as TransformStep, ak as Translations, al as VARIABLE_KINDS, am as ValidateOptions, an as ValidationResult, ao as Variable, ap as WidgetCheck, aq as WidgetMigrations, as as applyTransform, at as buildRequestUrl, au as buildUrl, av as builtInWidgetChecks, aw as collectReferences, ax as compile, ay as createHelpers, az as createHttpClient, aA as dashboardJsonSchema, aB as evaluate, aC as evaluateSafe, aD as expressionReferences, aE as graphqlData, aF as interpolate, aG as interpolateUrl, aH as isCallbackSource, aI as isSafeUrl, aJ as loadDocument, aK as mergeConnections, aL as migrateDocument, aM as parse, aN as parseDuration, aO as placeholders, aP as plantDate, aQ as plantDayStart, aR as resolve, aS as resolveBaseUrl, aT as resolveRequest, aU as safeLink, aV as satisfies, aW as scope, aX as stripStrings, aY as templateReferences, aZ as translator, a_ as validateDocument } from './core-CwFVyxKt.js';
2
2
  import 'zod';
3
3
  import 'react';
package/dist/core.js CHANGED
@@ -81,7 +81,7 @@ import {
81
81
  templateReferences,
82
82
  translator,
83
83
  validateDocument
84
- } from "./chunk-IMQSGBGY.js";
84
+ } from "./chunk-DHZPR7K7.js";
85
85
  export {
86
86
  ACTION_KINDS,
87
87
  ACTION_SCHEMAS,
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { A as AnyWidgetDefinition, T as TreeState, H as HttpClient, R as ResolvedRequest, a as TimeSettings, D as Dashboard, N as NetworkOptions, J as JsonValue, S as Scope, W as WidgetDefinition, b as SlotDefinition, c as SlotRenderOptions, d as WidgetMeta, e as WidgetProps } from './core-CM3wqmfR.js';
2
- export { f as ACTION_KINDS, g as ACTION_SCHEMAS, h as API_VERSION, i as Action, j as ActionRef, k as Auth, B as BREAKPOINTS, l as BUILT_IN_DATASOURCE_TYPES, C as Callback, m as Connection, n as ConnectionSpec, o as DATE_PRESETS, p as DashboardInput, q as DataBinding, r as DataError, s as DataErrorCode, t as Datasource, u as DateRange, v as Display, w as Drill, x as Duration, E as Emit, y as EventHandler, z as EventMap, F as Expression, G as ExpressionError, I as FnProp, K as Handler, L as HelperSettings, M as Helpers, O as HttpClientInternals, P as Id, Q as Layout, U as LayoutItem, V as LoadOptions, X as LoadResult, Y as Metadata, Z as MigrateResult, _ as MigrationError, $ as Modal, a0 as NamedAction, a1 as Node, a2 as Panel, a3 as PanelControl, a4 as PanelMigration, a5 as PanelState, a6 as Problem, a7 as RENDERER_VERSION, a8 as RESERVED_STATE_KEYS, a9 as RefRoot, aa as Reference, ab as Requires, ac as SCHEMA_URL, ad as Severity, ae as Spec, af as Template, ag as TokenSource, ah as TransformError, ai as TransformOptions, aj as TransformStep, ak as Translations, al as VARIABLE_KINDS, am as ValidateOptions, an as ValidationResult, ao as Variable, ap as WidgetCheck, aq as WidgetMigrations, ar as WidgetStore, as as applyTransform, at as buildRequestUrl, au as buildUrl, av as builtInWidgetChecks, aw as collectReferences, ax as compile, ay as createHelpers, az as createHttpClient, aA as dashboardJsonSchema, aB as evaluate, aC as evaluateSafe, aD as expressionReferences, aE as graphqlData, aF as interpolate, aG as interpolateUrl, aH as isCallbackSource, aI as isSafeUrl, aJ as loadDocument, aK as mergeConnections, aL as migrateDocument, aM as parse, aN as parseDuration, aO as placeholders, aP as plantDate, aQ as plantDayStart, aR as resolve, aS as resolveBaseUrl, aT as resolveRequest, aU as safeLink, aV as satisfies, aW as scope, aX as stripStrings, aY as templateReferences, aZ as translator, a_ as validateDocument } from './core-CM3wqmfR.js';
1
+ import { A as AnyWidgetDefinition, T as TreeState, H as HttpClient, R as ResolvedRequest, a as TimeSettings, D as Dashboard, N as NetworkOptions, J as JsonValue, S as Scope, W as WidgetDefinition, b as SlotDefinition, c as SlotRenderOptions, d as WidgetMeta, e as WidgetProps } from './core-CwFVyxKt.js';
2
+ export { f as ACTION_KINDS, g as ACTION_SCHEMAS, h as API_VERSION, i as Action, j as ActionRef, k as Auth, B as BREAKPOINTS, l as BUILT_IN_DATASOURCE_TYPES, C as Callback, m as Connection, n as ConnectionSpec, o as DATE_PRESETS, p as DashboardInput, q as DataBinding, r as DataError, s as DataErrorCode, t as Datasource, u as DateRange, v as Display, w as Drill, x as Duration, E as Emit, y as EventHandler, z as EventMap, F as Expression, G as ExpressionError, I as FnProp, K as Handler, L as HelperSettings, M as Helpers, O as HttpClientInternals, P as Id, Q as Layout, U as LayoutItem, V as LoadOptions, X as LoadResult, Y as Metadata, Z as MigrateResult, _ as MigrationError, $ as Modal, a0 as NamedAction, a1 as Node, a2 as Panel, a3 as PanelControl, a4 as PanelMigration, a5 as PanelState, a6 as Problem, a7 as RENDERER_VERSION, a8 as RESERVED_STATE_KEYS, a9 as RefRoot, aa as Reference, ab as Requires, ac as SCHEMA_URL, ad as Severity, ae as Spec, af as Template, ag as TokenSource, ah as TransformError, ai as TransformOptions, aj as TransformStep, ak as Translations, al as VARIABLE_KINDS, am as ValidateOptions, an as ValidationResult, ao as Variable, ap as WidgetCheck, aq as WidgetMigrations, ar as WidgetStore, as as applyTransform, at as buildRequestUrl, au as buildUrl, av as builtInWidgetChecks, aw as collectReferences, ax as compile, ay as createHelpers, az as createHttpClient, aA as dashboardJsonSchema, aB as evaluate, aC as evaluateSafe, aD as expressionReferences, aE as graphqlData, aF as interpolate, aG as interpolateUrl, aH as isCallbackSource, aI as isSafeUrl, aJ as loadDocument, aK as mergeConnections, aL as migrateDocument, aM as parse, aN as parseDuration, aO as placeholders, aP as plantDate, aQ as plantDayStart, aR as resolve, aS as resolveBaseUrl, aT as resolveRequest, aU as safeLink, aV as satisfies, aW as scope, aX as stripStrings, aY as templateReferences, aZ as translator, a_ as validateDocument } from './core-CwFVyxKt.js';
3
3
  import * as react from 'react';
4
4
  import { CSSProperties, ReactNode, ComponentType } from 'react';
5
5
  import * as react_jsx_runtime from 'react/jsx-runtime';
package/dist/index.js CHANGED
@@ -116,7 +116,7 @@ import {
116
116
  translator,
117
117
  validateDocument,
118
118
  widgetChecks
119
- } from "./chunk-IMQSGBGY.js";
119
+ } from "./chunk-DHZPR7K7.js";
120
120
  import {
121
121
  createStateProxy,
122
122
  getPath,
@@ -3976,6 +3976,12 @@ function markPart(frame, node) {
3976
3976
  for (const n of root?.querySelectorAll(".ds-part-selected") ?? []) n.classList.remove("ds-part-selected");
3977
3977
  node?.classList.add("ds-part-selected");
3978
3978
  }
3979
+ function liveLabel(text, at, h) {
3980
+ const ago = at ? h.fmt.ago(at) : "\u2026";
3981
+ if (typeof text !== "string") return `Live, updated ${ago}`;
3982
+ const time = at ? h.fmt.date(at, { hour: "2-digit", minute: "2-digit", hourCycle: "h23" }) : "\u2026";
3983
+ return text.replaceAll("{time}", time).replaceAll("{ago}", ago);
3984
+ }
3979
3985
  function panelStyle(s) {
3980
3986
  if (!s) return void 0;
3981
3987
  const out = {};
@@ -4400,8 +4406,7 @@ function PanelFrameInner({ id, nested }) {
4400
4406
  meta2 && /* @__PURE__ */ jsx14("span", { className: "ds-panel-meta", children: meta2 }),
4401
4407
  live2 ? /* @__PURE__ */ jsxs10("span", { className: "ds-live", "data-stale": view.stale || void 0, title: view.error?.message, children: [
4402
4408
  /* @__PURE__ */ jsx14("span", { "aria-hidden": "true" }),
4403
- "Live, updated ",
4404
- view.updatedAt ? runtime.helpers.fmt.ago(view.updatedAt) : "\u2026"
4409
+ liveLabel(props.liveText, view.updatedAt, runtime.helpers)
4405
4410
  ] }) : view.stale && /* @__PURE__ */ jsx14("span", { className: "ds-badge ds-badge-stale", title: view.error?.message, children: "Stale" }),
4406
4411
  controls.map((c) => /* @__PURE__ */ jsx14(
4407
4412
  ControlField,
@@ -5615,7 +5620,9 @@ import { useEffect as useEffect7, useMemo as useMemo5, useRef as useRef8 } from
5615
5620
  function echartsTheme(theme, mode) {
5616
5621
  const c = theme[mode];
5617
5622
  const s = theme.scale;
5618
- const label = { color: c.chart.axis, fontFamily: s.font.body, fontSize: 12 };
5623
+ const role = s.font.roles?.label?.family;
5624
+ const family = (role && Object.hasOwn(s.font, role) ? s.font[role] : void 0) ?? s.font.body;
5625
+ const label = { color: c.chart.axis, fontFamily: family, fontSize: 12 };
5619
5626
  const categoryAxis = {
5620
5627
  axisLine: { show: true, lineStyle: { color: c.chart.grid } },
5621
5628
  axisTick: { show: false },
@@ -5634,14 +5641,14 @@ function echartsTheme(theme, mode) {
5634
5641
  return {
5635
5642
  color: c.chart.series,
5636
5643
  backgroundColor: "transparent",
5637
- textStyle: { fontFamily: s.font.body, color: c.text.secondary },
5644
+ textStyle: { fontFamily: family, color: c.text.secondary },
5638
5645
  title: { textStyle: { color: c.text.primary, fontFamily: s.font.heading } },
5639
5646
  legend: { textStyle: { color: c.text.secondary } },
5640
5647
  tooltip: {
5641
5648
  backgroundColor: c.chart.tooltipBg,
5642
5649
  borderWidth: 0,
5643
5650
  padding: [8, 10],
5644
- textStyle: { color: c.chart.tooltipText, fontFamily: s.font.body, fontSize: 12 },
5651
+ textStyle: { color: c.chart.tooltipText, fontFamily: family, fontSize: 12 },
5645
5652
  extraCssText: `border-radius: ${s.radius.control}px; box-shadow: none; backdrop-filter: blur(8px);`,
5646
5653
  axisPointer: { shadowStyle: { color: "rgba(128, 199, 148, 0.18)" } }
5647
5654
  },
@@ -5757,11 +5764,14 @@ function EChart({
5757
5764
  const cats = JSON.stringify(axisCategories(merged));
5758
5765
  const replay = lastCats.current !== void 0 && cats !== lastCats.current && !reduce;
5759
5766
  lastCats.current = cats;
5767
+ const replace = {
5768
+ replaceMerge: ["series", "xAxis", "yAxis", "dataset", "visualMap", "dataZoom"].filter((k) => k in merged)
5769
+ };
5760
5770
  if (!replay) {
5761
- c.setOption(merged, { notMerge: true, lazyUpdate: true });
5771
+ c.setOption(merged, { ...replace, lazyUpdate: true });
5762
5772
  return;
5763
5773
  }
5764
- c.setOption(atZero(merged), { notMerge: true });
5774
+ c.setOption(atZero(merged), replace);
5765
5775
  const raf = requestAnimationFrame(() => {
5766
5776
  if (!c.isDisposed()) c.setOption(merged, { notMerge: false, lazyUpdate: true });
5767
5777
  });
@@ -5853,6 +5863,7 @@ function cartesian(data, source, spec, type, h, colors) {
5853
5863
  values: s.values.map((v, i) => v === null ? null : v / totals[i] * 100)
5854
5864
  }));
5855
5865
  }
5866
+ const labelValue = (v) => spec.maxDecimals !== void 0 && typeof v === "number" ? formatValue(Math.round(v * 10 ** spec.maxDecimals) / 10 ** spec.maxDecimals, h, spec.format, void 0) : formatValue(v, h, spec.format, spec.decimals ?? 1);
5856
5867
  const fmt = (v) => spec.normalized ? h.fmt.percent(v, 0) : `${formatValue(v, h, spec.format, spec.decimals)}${spec.unit ? ` ${spec.unit}` : ""}`;
5857
5868
  const target = typeof spec.target === "number" ? spec.target : spec.target !== void 0 ? toNumber(field(source, spec.target)) : void 0;
5858
5869
  const catAxis = {
@@ -5868,7 +5879,8 @@ function cartesian(data, source, spec, type, h, colors) {
5868
5879
  ...spec.normalized ? { max: 100 } : {},
5869
5880
  ...spec.valueAxis?.min !== void 0 ? { min: spec.valueAxis.min } : {},
5870
5881
  ...spec.valueAxis?.max !== void 0 ? { max: spec.valueAxis.max } : spec.valueAxis?.atLeast !== void 0 ? { max: (v) => Math.max(spec.valueAxis?.atLeast ?? 0, v.max) } : {},
5871
- ...spec.valueAxis?.step !== void 0 ? { interval: spec.valueAxis.step } : {}
5882
+ ...spec.valueAxis?.step !== void 0 ? { interval: spec.valueAxis.step } : {},
5883
+ ...spec.valueAxis?.minStep !== void 0 ? { minInterval: spec.valueAxis.minStep } : {}
5872
5884
  };
5873
5885
  const stack = spec.stacked || spec.normalized || spec.range ? "total" : void 0;
5874
5886
  const single = series.length === 1 && !spec.range;
@@ -5923,7 +5935,8 @@ function cartesian(data, source, spec, type, h, colors) {
5923
5935
  ...colors ? { color: colors.text } : {},
5924
5936
  formatter: (p) => {
5925
5937
  const v = stackedTotals ? totalAt(p.dataIndex) : p.value;
5926
- return v === null || v === void 0 ? "" : `${formatValue(v, h, spec.format, spec.decimals ?? 1)}${isPartial[p.dataIndex] ? " so far" : ""}`;
5938
+ if (v === null || v === void 0 || spec.hideZeroLabels && Number(v) === 0) return "";
5939
+ return `${labelValue(v)}${isPartial[p.dataIndex] ? " so far" : ""}`;
5927
5940
  }
5928
5941
  }
5929
5942
  } : {},
@@ -5968,7 +5981,7 @@ function cartesian(data, source, spec, type, h, colors) {
5968
5981
  grid: {
5969
5982
  left: 8,
5970
5983
  right: 16,
5971
- top: many ? 32 : 12,
5984
+ top: many && spec.legendStyle !== "html" ? 32 : 12,
5972
5985
  bottom: spec.pageSize && cats.length > spec.pageSize ? 36 : 8,
5973
5986
  containLabel: true
5974
5987
  },
@@ -5996,7 +6009,7 @@ function cartesian(data, source, spec, type, h, colors) {
5996
6009
  }
5997
6010
  } : {}
5998
6011
  },
5999
- ...many ? { legend: { top: 0, right: 0, icon: "rect", itemWidth: 10, itemHeight: 10, data: series.map((s) => s.name) } } : {},
6012
+ ...many && spec.legendStyle !== "html" ? { legend: { top: 0, right: 0, icon: "rect", itemWidth: 10, itemHeight: 10, data: series.map((s) => s.name) } } : {},
6000
6013
  xAxis: spec.horizontal ? valAxis : catAxis,
6001
6014
  yAxis: spec.horizontal ? { ...catAxis, inverse: true } : valAxis,
6002
6015
  series: out,
@@ -6019,6 +6032,8 @@ function cartesian(data, source, spec, type, h, colors) {
6019
6032
  categories: cats.map(String),
6020
6033
  avg,
6021
6034
  coloured: Boolean(colourByAvg),
6035
+ /** The series names and colours, for an HTML legend (`legendStyle: "html"`). */
6036
+ legend: many && spec.legendStyle === "html" ? series.map((x) => ({ name: x.name, key: x.key })) : [],
6022
6037
  hasPartial: isPartial.some(Boolean)
6023
6038
  };
6024
6039
  }
@@ -6051,7 +6066,8 @@ var BarChart2 = defineWidget({
6051
6066
  );
6052
6067
  const hi = highlight === void 0 || highlight === null ? void 0 : c.categories.indexOf(String(highlight));
6053
6068
  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;
6054
- const legend = c.coloured || avgText;
6069
+ const series = tokens?.theme[tokens.mode].chart.series ?? [];
6070
+ const legend = c.coloured || avgText || c.legend.length > 0;
6055
6071
  return /* @__PURE__ */ jsxs19("div", { className: "ds-chart", children: [
6056
6072
  legend && /* @__PURE__ */ jsxs19("ul", { className: "ds-chart-legend", children: [
6057
6073
  c.coloured && /* @__PURE__ */ jsxs19(Fragment7, { children: [
@@ -6064,6 +6080,18 @@ var BarChart2 = defineWidget({
6064
6080
  spec.legendLabels?.below ?? "Below avg"
6065
6081
  ] })
6066
6082
  ] }),
6083
+ c.legend.map((l, i) => /* @__PURE__ */ jsxs19("li", { children: [
6084
+ /* @__PURE__ */ jsx25(
6085
+ "span",
6086
+ {
6087
+ className: "ds-swatch",
6088
+ style: {
6089
+ background: (l.key !== void 0 && spec.seriesColors && Object.hasOwn(spec.seriesColors, l.key) ? spec.seriesColors[l.key] : void 0) ?? series[i % Math.max(series.length, 1)]
6090
+ }
6091
+ }
6092
+ ),
6093
+ l.name
6094
+ ] }, l.name)),
6067
6095
  avgText && /* @__PURE__ */ jsxs19("li", { children: [
6068
6096
  /* @__PURE__ */ jsx25("span", { className: "ds-swatch-line" }),
6069
6097
  avgText