@dashspec/renderer 0.1.27 → 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.
- package/CHANGELOG.md +13 -0
- package/dist/{chunk-4OUWLEBB.js → chunk-DHZPR7K7.js} +13 -3
- package/dist/{chunk-4OUWLEBB.js.map → chunk-DHZPR7K7.js.map} +1 -1
- package/dist/{core-BHAqRR6L.d.ts → core-CwFVyxKt.d.ts} +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +36 -11
- package/dist/index.js.map +1 -1
- package/docs/widgets.md +2 -2
- package/package.json +1 -1
|
@@ -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.
|
|
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-
|
|
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
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-
|
|
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-
|
|
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-
|
|
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
|
-
|
|
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
|
|
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:
|
|
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:
|
|
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
|
},
|
|
@@ -5856,6 +5863,7 @@ function cartesian(data, source, spec, type, h, colors) {
|
|
|
5856
5863
|
values: s.values.map((v, i) => v === null ? null : v / totals[i] * 100)
|
|
5857
5864
|
}));
|
|
5858
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);
|
|
5859
5867
|
const fmt = (v) => spec.normalized ? h.fmt.percent(v, 0) : `${formatValue(v, h, spec.format, spec.decimals)}${spec.unit ? ` ${spec.unit}` : ""}`;
|
|
5860
5868
|
const target = typeof spec.target === "number" ? spec.target : spec.target !== void 0 ? toNumber(field(source, spec.target)) : void 0;
|
|
5861
5869
|
const catAxis = {
|
|
@@ -5871,7 +5879,8 @@ function cartesian(data, source, spec, type, h, colors) {
|
|
|
5871
5879
|
...spec.normalized ? { max: 100 } : {},
|
|
5872
5880
|
...spec.valueAxis?.min !== void 0 ? { min: spec.valueAxis.min } : {},
|
|
5873
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) } : {},
|
|
5874
|
-
...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 } : {}
|
|
5875
5884
|
};
|
|
5876
5885
|
const stack = spec.stacked || spec.normalized || spec.range ? "total" : void 0;
|
|
5877
5886
|
const single = series.length === 1 && !spec.range;
|
|
@@ -5926,7 +5935,8 @@ function cartesian(data, source, spec, type, h, colors) {
|
|
|
5926
5935
|
...colors ? { color: colors.text } : {},
|
|
5927
5936
|
formatter: (p) => {
|
|
5928
5937
|
const v = stackedTotals ? totalAt(p.dataIndex) : p.value;
|
|
5929
|
-
|
|
5938
|
+
if (v === null || v === void 0 || spec.hideZeroLabels && Number(v) === 0) return "";
|
|
5939
|
+
return `${labelValue(v)}${isPartial[p.dataIndex] ? " so far" : ""}`;
|
|
5930
5940
|
}
|
|
5931
5941
|
}
|
|
5932
5942
|
} : {},
|
|
@@ -5971,7 +5981,7 @@ function cartesian(data, source, spec, type, h, colors) {
|
|
|
5971
5981
|
grid: {
|
|
5972
5982
|
left: 8,
|
|
5973
5983
|
right: 16,
|
|
5974
|
-
top: many ? 32 : 12,
|
|
5984
|
+
top: many && spec.legendStyle !== "html" ? 32 : 12,
|
|
5975
5985
|
bottom: spec.pageSize && cats.length > spec.pageSize ? 36 : 8,
|
|
5976
5986
|
containLabel: true
|
|
5977
5987
|
},
|
|
@@ -5999,7 +6009,7 @@ function cartesian(data, source, spec, type, h, colors) {
|
|
|
5999
6009
|
}
|
|
6000
6010
|
} : {}
|
|
6001
6011
|
},
|
|
6002
|
-
...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) } } : {},
|
|
6003
6013
|
xAxis: spec.horizontal ? valAxis : catAxis,
|
|
6004
6014
|
yAxis: spec.horizontal ? { ...catAxis, inverse: true } : valAxis,
|
|
6005
6015
|
series: out,
|
|
@@ -6022,6 +6032,8 @@ function cartesian(data, source, spec, type, h, colors) {
|
|
|
6022
6032
|
categories: cats.map(String),
|
|
6023
6033
|
avg,
|
|
6024
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 })) : [],
|
|
6025
6037
|
hasPartial: isPartial.some(Boolean)
|
|
6026
6038
|
};
|
|
6027
6039
|
}
|
|
@@ -6054,7 +6066,8 @@ var BarChart2 = defineWidget({
|
|
|
6054
6066
|
);
|
|
6055
6067
|
const hi = highlight === void 0 || highlight === null ? void 0 : c.categories.indexOf(String(highlight));
|
|
6056
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;
|
|
6057
|
-
const
|
|
6069
|
+
const series = tokens?.theme[tokens.mode].chart.series ?? [];
|
|
6070
|
+
const legend = c.coloured || avgText || c.legend.length > 0;
|
|
6058
6071
|
return /* @__PURE__ */ jsxs19("div", { className: "ds-chart", children: [
|
|
6059
6072
|
legend && /* @__PURE__ */ jsxs19("ul", { className: "ds-chart-legend", children: [
|
|
6060
6073
|
c.coloured && /* @__PURE__ */ jsxs19(Fragment7, { children: [
|
|
@@ -6067,6 +6080,18 @@ var BarChart2 = defineWidget({
|
|
|
6067
6080
|
spec.legendLabels?.below ?? "Below avg"
|
|
6068
6081
|
] })
|
|
6069
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)),
|
|
6070
6095
|
avgText && /* @__PURE__ */ jsxs19("li", { children: [
|
|
6071
6096
|
/* @__PURE__ */ jsx25("span", { className: "ds-swatch-line" }),
|
|
6072
6097
|
avgText
|