@dashspec/renderer 0.1.10 → 0.1.12
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 +37 -1
- package/dist/{chunk-TAOP57T2.js → chunk-2Y6SJ7MU.js} +44 -6
- package/dist/chunk-2Y6SJ7MU.js.map +1 -0
- package/dist/{core-CYeLBFK9.d.ts → core-BEgHX8xR.d.ts} +3 -2
- package/dist/core.d.ts +1 -1
- package/dist/core.js +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +115 -27
- package/dist/index.js.map +1 -1
- package/docs/data.md +1 -1
- package/docs/widgets.md +5 -2
- package/package.json +1 -1
- package/dist/chunk-TAOP57T2.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -116,7 +116,7 @@ import {
|
|
|
116
116
|
translator,
|
|
117
117
|
validateDocument,
|
|
118
118
|
widgetChecks
|
|
119
|
-
} from "./chunk-
|
|
119
|
+
} from "./chunk-2Y6SJ7MU.js";
|
|
120
120
|
import {
|
|
121
121
|
createStateProxy,
|
|
122
122
|
getPath,
|
|
@@ -1827,7 +1827,7 @@ var Breakdown = defineWidget({
|
|
|
1827
1827
|
events: ["click", "hover"],
|
|
1828
1828
|
parts: ["item"],
|
|
1829
1829
|
component: function BreakdownWidget({ spec, data, source, emit, helpers }) {
|
|
1830
|
-
let items = asRows(data).map((r) => ({
|
|
1830
|
+
let items = spec.items ? spec.items.map((it) => ({ row: it, label: it.label, value: toNumber(it.value) ?? 0, tone: it.tone })) : asRows(data).map((r) => ({
|
|
1831
1831
|
row: r,
|
|
1832
1832
|
label: String(field(r, spec.label) ?? ""),
|
|
1833
1833
|
value: toNumber(field(r, spec.value)) ?? 0
|
|
@@ -1840,7 +1840,10 @@ var Breakdown = defineWidget({
|
|
|
1840
1840
|
}
|
|
1841
1841
|
const sum = items.reduce((a, b) => a + b.value, 0) || 1;
|
|
1842
1842
|
const max = Math.max(1, ...items.map((i) => i.value));
|
|
1843
|
-
const color2 = (i) =>
|
|
1843
|
+
const color2 = (i) => {
|
|
1844
|
+
const t = items[i]?.tone;
|
|
1845
|
+
return t ? `var(--ds-color-status-${t}-solid)` : `var(--ds-series-${i % 8 + 1})`;
|
|
1846
|
+
};
|
|
1844
1847
|
const fmt = (v) => `${formatValue(v, helpers, spec.format, spec.decimals)}${spec.unit ? ` ${spec.unit}` : ""}`;
|
|
1845
1848
|
const on = (i, type) => emit(type, "item", { datum: items[i]?.row, value: items[i]?.value, x: items[i]?.label, index: i });
|
|
1846
1849
|
if (spec.mode === "donut") {
|
|
@@ -4032,6 +4035,16 @@ function PanelFrameInner({ id, nested }) {
|
|
|
4032
4035
|
const store = useMemo3(() => widgetStore(runtime), [runtime]);
|
|
4033
4036
|
const [bodyRef, size2] = useSize();
|
|
4034
4037
|
const frameRef = useRef5(null);
|
|
4038
|
+
const specSources = useMemo3(() => {
|
|
4039
|
+
const out = /* @__PURE__ */ new Set();
|
|
4040
|
+
for (const r of collectReferences({ spec: def.spec, messages: def.messages, visibleWhen: def.visibleWhen }))
|
|
4041
|
+
if (r.root === "datasources") out.add(r.name);
|
|
4042
|
+
return [...out];
|
|
4043
|
+
}, [def.spec, def.messages, def.visibleWhen]);
|
|
4044
|
+
const wanted = useMemo3(
|
|
4045
|
+
() => [.../* @__PURE__ */ new Set([...view.source ? [view.source] : [], ...specSources])],
|
|
4046
|
+
[view.source, specSources]
|
|
4047
|
+
);
|
|
4035
4048
|
useEffect4(() => {
|
|
4036
4049
|
if (!view.visible || view.hidden) {
|
|
4037
4050
|
visibility.set(instance, null);
|
|
@@ -4039,19 +4052,18 @@ function PanelFrameInner({ id, nested }) {
|
|
|
4039
4052
|
}
|
|
4040
4053
|
const el = frameRef.current;
|
|
4041
4054
|
if (!el || typeof IntersectionObserver === "undefined") {
|
|
4042
|
-
visibility.set(instance,
|
|
4055
|
+
visibility.set(instance, wanted);
|
|
4043
4056
|
return () => visibility.set(instance, null);
|
|
4044
4057
|
}
|
|
4045
|
-
const io = new IntersectionObserver(
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
);
|
|
4058
|
+
const io = new IntersectionObserver(([e]) => visibility.set(instance, e?.isIntersecting ? wanted : []), {
|
|
4059
|
+
rootMargin: "200px"
|
|
4060
|
+
});
|
|
4049
4061
|
io.observe(el);
|
|
4050
4062
|
return () => {
|
|
4051
4063
|
io.disconnect();
|
|
4052
4064
|
visibility.set(instance, null);
|
|
4053
4065
|
};
|
|
4054
|
-
}, [instance, view.visible, view.hidden,
|
|
4066
|
+
}, [instance, view.visible, view.hidden, wanted, visibility]);
|
|
4055
4067
|
const emit = useCallback4(
|
|
4056
4068
|
(type, part, detail) => {
|
|
4057
4069
|
const event = { type, panel: id, ...part ? { part } : {}, ...detail };
|
|
@@ -5043,8 +5055,47 @@ var Table = defineWidget({
|
|
|
5043
5055
|
]
|
|
5044
5056
|
}
|
|
5045
5057
|
),
|
|
5046
|
-
pageSize && /* @__PURE__ */ jsxs16("div", { className: "ds-pager", children: [
|
|
5047
|
-
/* @__PURE__ */ jsxs16("span", { className: "ds-pager-
|
|
5058
|
+
pageSize && (pg?.layout === "simple" ? /* @__PURE__ */ jsxs16("div", { className: "ds-pager", "data-layout": "simple", children: [
|
|
5059
|
+
/* @__PURE__ */ jsxs16("span", { className: "ds-pager-range", children: [
|
|
5060
|
+
"Showing ",
|
|
5061
|
+
rowTotal === 0 ? 0 : (current - 1) * pageSize + 1,
|
|
5062
|
+
"\u2013",
|
|
5063
|
+
Math.min(current * pageSize, rowTotal),
|
|
5064
|
+
" of",
|
|
5065
|
+
" ",
|
|
5066
|
+
helpers.fmt.number(rowTotal),
|
|
5067
|
+
" rows"
|
|
5068
|
+
] }),
|
|
5069
|
+
/* @__PURE__ */ jsx21(
|
|
5070
|
+
"button",
|
|
5071
|
+
{
|
|
5072
|
+
type: "button",
|
|
5073
|
+
className: "ds-button",
|
|
5074
|
+
"data-size": "sm",
|
|
5075
|
+
disabled: current <= 1,
|
|
5076
|
+
onClick: () => update({ page: current - 1 }),
|
|
5077
|
+
children: "Previous"
|
|
5078
|
+
}
|
|
5079
|
+
),
|
|
5080
|
+
/* @__PURE__ */ jsxs16("span", { className: "ds-pager-of", children: [
|
|
5081
|
+
"Page ",
|
|
5082
|
+
current,
|
|
5083
|
+
" of ",
|
|
5084
|
+
Math.max(1, pages)
|
|
5085
|
+
] }),
|
|
5086
|
+
/* @__PURE__ */ jsx21(
|
|
5087
|
+
"button",
|
|
5088
|
+
{
|
|
5089
|
+
type: "button",
|
|
5090
|
+
className: "ds-button",
|
|
5091
|
+
"data-size": "sm",
|
|
5092
|
+
disabled: current >= pages,
|
|
5093
|
+
onClick: () => update({ page: current + 1 }),
|
|
5094
|
+
children: "Next"
|
|
5095
|
+
}
|
|
5096
|
+
)
|
|
5097
|
+
] }) : /* @__PURE__ */ jsxs16("div", { className: "ds-pager", children: [
|
|
5098
|
+
pg?.sizes !== false && /* @__PURE__ */ jsxs16("span", { className: "ds-pager-size", children: [
|
|
5048
5099
|
"Rows",
|
|
5049
5100
|
/* @__PURE__ */ jsx21(
|
|
5050
5101
|
SelectControl,
|
|
@@ -5100,7 +5151,7 @@ var Table = defineWidget({
|
|
|
5100
5151
|
}
|
|
5101
5152
|
)
|
|
5102
5153
|
] })
|
|
5103
|
-
] })
|
|
5154
|
+
] }))
|
|
5104
5155
|
] });
|
|
5105
5156
|
}
|
|
5106
5157
|
});
|
|
@@ -5116,7 +5167,10 @@ var Tiles = defineWidget({
|
|
|
5116
5167
|
events: ["click", "hover", "select"],
|
|
5117
5168
|
parts: ["tile"],
|
|
5118
5169
|
defaults: { label: "name", value: "value" },
|
|
5119
|
-
component: function TilesWidget({ spec, data, emit, helpers }) {
|
|
5170
|
+
component: function TilesWidget({ spec, data, emit, helpers, panelId }) {
|
|
5171
|
+
const hasClick = useClickable(panelId, () => {
|
|
5172
|
+
}).role === "button";
|
|
5173
|
+
const clickable = spec.selectable || hasClick;
|
|
5120
5174
|
const rows = asRows(data);
|
|
5121
5175
|
const caption = (row) => {
|
|
5122
5176
|
if (!spec.caption) return void 0;
|
|
@@ -5133,6 +5187,7 @@ var Tiles = defineWidget({
|
|
|
5133
5187
|
role: spec.selectable ? "radiogroup" : "list",
|
|
5134
5188
|
"aria-label": spec.title,
|
|
5135
5189
|
"data-wrap": spec.wrap === false ? "off" : void 0,
|
|
5190
|
+
"data-stretch": spec.stretch === false ? "off" : void 0,
|
|
5136
5191
|
style: {
|
|
5137
5192
|
"--ds-tile-min": `${spec.minTileWidth ?? 128}px`,
|
|
5138
5193
|
...spec.columns ? { "--ds-tile-cols": spec.columns } : {}
|
|
@@ -5157,6 +5212,7 @@ var Tiles = defineWidget({
|
|
|
5157
5212
|
"aria-checked": spec.selectable ? active : void 0,
|
|
5158
5213
|
"data-active": active || void 0,
|
|
5159
5214
|
"data-muted": mutedTile || void 0,
|
|
5215
|
+
"data-clickable": clickable || void 0,
|
|
5160
5216
|
"data-highlight": lit ? spec.highlightTone ?? "warn" : void 0,
|
|
5161
5217
|
onClick: () => {
|
|
5162
5218
|
emit("click", "tile", { datum: r, value: label, index: i });
|
|
@@ -5169,18 +5225,28 @@ var Tiles = defineWidget({
|
|
|
5169
5225
|
String(label ?? ""),
|
|
5170
5226
|
spec.count && /* @__PURE__ */ jsx22("span", { className: "ds-chip-count", children: String(field(r, spec.count) ?? "") })
|
|
5171
5227
|
] }),
|
|
5172
|
-
|
|
5173
|
-
"
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5228
|
+
(() => {
|
|
5229
|
+
const valueEl = v === "" ? null : /* @__PURE__ */ jsxs17(
|
|
5230
|
+
"span",
|
|
5231
|
+
{
|
|
5232
|
+
className: "ds-tile-value",
|
|
5233
|
+
style: vt ? { color: vt === "muted" ? "var(--ds-color-text-disabled)" : tone(vt).fg } : void 0,
|
|
5234
|
+
children: [
|
|
5235
|
+
/* @__PURE__ */ jsx22(CountUp, { value: v, render: (x) => formatValue(x, helpers, spec.format, spec.decimals) }),
|
|
5236
|
+
spec.unit && /* @__PURE__ */ jsx22("span", { className: "ds-kpi-unit", children: spec.unit })
|
|
5237
|
+
]
|
|
5238
|
+
}
|
|
5239
|
+
);
|
|
5240
|
+
const cap = spec.caption ? caption(r) : "";
|
|
5241
|
+
const capEl = cap ? /* @__PURE__ */ jsx22("span", { className: "ds-tile-caption", children: cap }) : null;
|
|
5242
|
+
return spec.captionInline ? /* @__PURE__ */ jsxs17("span", { className: "ds-tile-main", children: [
|
|
5243
|
+
valueEl,
|
|
5244
|
+
capEl
|
|
5245
|
+
] }) : /* @__PURE__ */ jsxs17(Fragment6, { children: [
|
|
5246
|
+
valueEl,
|
|
5247
|
+
capEl
|
|
5248
|
+
] });
|
|
5249
|
+
})(),
|
|
5184
5250
|
/* @__PURE__ */ jsx22(Chips, { chips: spec.chips, vars, helpers })
|
|
5185
5251
|
]
|
|
5186
5252
|
},
|
|
@@ -5465,6 +5531,7 @@ function EChart({
|
|
|
5465
5531
|
}) {
|
|
5466
5532
|
const el = useRef8(null);
|
|
5467
5533
|
const chart = useRef8(null);
|
|
5534
|
+
const lastCats = useRef8(void 0);
|
|
5468
5535
|
const tokens = useThemeTokens();
|
|
5469
5536
|
const theme = useMemo5(() => tokens ? echartsTheme(tokens.theme, tokens.mode) : void 0, [tokens]);
|
|
5470
5537
|
const handlers = useRef8({ emit, rows });
|
|
@@ -5524,6 +5591,9 @@ function EChart({
|
|
|
5524
5591
|
const legend = merged.legend ?? {};
|
|
5525
5592
|
merged.legend = { ...legend, selected: Object.fromEntries(hiddenSeries.map((s) => [s, false])) };
|
|
5526
5593
|
}
|
|
5594
|
+
const cats = JSON.stringify(axisCategories(merged));
|
|
5595
|
+
if (lastCats.current !== void 0 && cats !== lastCats.current && !reduce) c.clear();
|
|
5596
|
+
lastCats.current = cats;
|
|
5527
5597
|
c.setOption(merged, { notMerge: true, lazyUpdate: true });
|
|
5528
5598
|
}, [option, extra, hiddenSeries, theme, part]);
|
|
5529
5599
|
useEffect7(() => {
|
|
@@ -5537,6 +5607,14 @@ function EChart({
|
|
|
5537
5607
|
}, [highlightIndex, theme, part]);
|
|
5538
5608
|
return /* @__PURE__ */ jsx24("div", { ref: el, role: "img", "aria-label": ariaLabel, style: { width: "100%", height: Math.max(80, height) } });
|
|
5539
5609
|
}
|
|
5610
|
+
function axisCategories(o) {
|
|
5611
|
+
for (const k of ["xAxis", "yAxis"]) {
|
|
5612
|
+
const a = o[k];
|
|
5613
|
+
const axis = Array.isArray(a) ? a[0] : a;
|
|
5614
|
+
if (axis && axis.type === "category") return axis.data;
|
|
5615
|
+
}
|
|
5616
|
+
return void 0;
|
|
5617
|
+
}
|
|
5540
5618
|
|
|
5541
5619
|
// src/widgets/shared/cartesian.ts
|
|
5542
5620
|
function cartesian(data, source, spec, type, h, colors) {
|
|
@@ -6278,7 +6356,9 @@ function Grid({
|
|
|
6278
6356
|
if (!el || editable || !base.fit.has(panel) || typeof ResizeObserver === "undefined") return;
|
|
6279
6357
|
const ro = new ResizeObserver(() => {
|
|
6280
6358
|
const target2 = el.firstElementChild;
|
|
6359
|
+
el.setAttribute("data-measuring", "");
|
|
6281
6360
|
const px = target2?.offsetHeight ?? 0;
|
|
6361
|
+
el.removeAttribute("data-measuring");
|
|
6282
6362
|
if (!px) return;
|
|
6283
6363
|
const rows = Math.ceil((px + gap) / (rowHeight + gap));
|
|
6284
6364
|
setFitRows((r) => r[panel] === rows ? r : { ...r, [panel]: rows });
|
|
@@ -6947,12 +7027,16 @@ var RENDERER_CSS = `
|
|
|
6947
7027
|
.ds-kpi-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: var(--ds-space-sm); font-size: var(--ds-type-label-size); color: var(--ds-color-text-subtle); min-height: 22px; }
|
|
6948
7028
|
|
|
6949
7029
|
.ds-tiles { --ds-tiles-gap: var(--ds-space-md); gap: var(--ds-tiles-gap); grid-template-columns: repeat(auto-fit, minmax(max(var(--ds-tile-min, 128px), calc((100% - (var(--ds-tile-cols, 12) - 1) * var(--ds-tiles-gap)) / var(--ds-tile-cols, 12))), 1fr)); }
|
|
7030
|
+
.ds-tiles[data-stretch="off"] { grid-template-columns: repeat(auto-fill, minmax(max(var(--ds-tile-min, 128px), calc((100% - (var(--ds-tile-cols, 12) - 1) * var(--ds-tiles-gap)) / var(--ds-tile-cols, 12))), 1fr)); }
|
|
6950
7031
|
.ds-tiles { overflow-y: auto; scrollbar-width: thin; grid-auto-rows: max-content; padding: 5px; margin: -5px; }
|
|
6951
7032
|
.ds-tiles > .ds-tile { min-height: max-content; }
|
|
6952
7033
|
.ds-flow .ds-tiles { height: auto; overflow-y: visible; }
|
|
6953
7034
|
/* Grid items with fit: the panel takes its natural height (at least the cell's), so the grid can measure it. */
|
|
6954
7035
|
[data-fit] > .ds-fit { height: 100%; }
|
|
6955
7036
|
.ds-fit > .ds-panel { height: auto !important; min-height: 100%; }
|
|
7037
|
+
/* While measuring, the panel takes only its content's height (no stretching), then goes back. */
|
|
7038
|
+
.ds-fit[data-measuring] > .ds-panel { min-height: 0 !important; }
|
|
7039
|
+
.ds-fit[data-measuring] .ds-panel-body, .ds-fit[data-measuring] .ds-panel-body > * { flex: none !important; height: auto !important; }
|
|
6956
7040
|
/* The body still fills a taller card, so footers (a KPI's target chip) stay at the bottom. */
|
|
6957
7041
|
[data-fit] .ds-panel-body { flex: 1 0 auto; display: flex; flex-direction: column; }
|
|
6958
7042
|
[data-fit] .ds-panel-body > * { flex: 1 0 auto; }
|
|
@@ -6964,8 +7048,9 @@ var RENDERER_CSS = `
|
|
|
6964
7048
|
.ds-tiles[data-wrap="off"] > * { scroll-snap-align: start; }
|
|
6965
7049
|
.ds-tile { min-width: 0; overflow-wrap: anywhere; }
|
|
6966
7050
|
.ds-tile { display: flex; flex-direction: column; gap: 6px; padding: var(--ds-space-md) var(--ds-space-md) var(--ds-space-md); border: 1px solid var(--ds-color-border-default); border-radius: var(--ds-radius-control); background: var(--ds-color-surface-card); text-align: left; min-height: 0; transition: border-color 120ms, background 120ms; }
|
|
6967
|
-
.ds-tile:hover { border-color: var(--ds-color-action-primary); }
|
|
7051
|
+
.ds-tile[data-clickable]:hover { border-color: var(--ds-color-action-primary); }
|
|
6968
7052
|
.ds-tile[data-active] { border-color: var(--ds-color-action-primary); background: var(--ds-color-surface-selection); box-shadow: none; }
|
|
7053
|
+
.ds-tile-main { display: flex; align-items: baseline; gap: var(--ds-space-xs); flex-wrap: wrap; }
|
|
6969
7054
|
.ds-tile[data-active] .ds-tile-label { color: var(--ds-color-text-primary); font-weight: 600; }
|
|
6970
7055
|
.ds-tile-label { font-size: var(--ds-type-label-size); color: var(--ds-color-text-subtle); text-transform: none; gap: 2px; }
|
|
6971
7056
|
.ds-tile-value { font-family: var(--ds-type-kpi-family); font-size: 24px; line-height: 30px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ds-color-text-primary); }
|
|
@@ -7008,7 +7093,8 @@ var RENDERER_CSS = `
|
|
|
7008
7093
|
.ds-panel-body > :not(.ds-skeleton):not(.ds-loading) { animation: ds-fade 360ms ease both; }
|
|
7009
7094
|
.ds-filters, .ds-header { animation: ds-fade 400ms ease both; }
|
|
7010
7095
|
.ds-tile { transition: border-color 160ms ease, background 160ms ease, transform 160ms ease, box-shadow 160ms ease; }
|
|
7011
|
-
.ds-tile:hover { transform: translateY(-2px); box-shadow: 0 6px 16px
|
|
7096
|
+
.ds-tile[data-clickable]:hover { transform: translateY(-2px); box-shadow: 0 6px 16px color-mix(in srgb, var(--ds-color-action-primary) 10%, transparent); }
|
|
7097
|
+
.ds-tile:not([data-clickable]) { cursor: default; }
|
|
7012
7098
|
.ds-tile:active { transform: translateY(0); }
|
|
7013
7099
|
.ds-kpi-main { transition: opacity 160ms ease; }
|
|
7014
7100
|
.ds-kpi-main[data-clickable]:hover .ds-kpi-value { color: var(--ds-color-action-primary); transition: color 160ms ease; }
|
|
@@ -7266,6 +7352,8 @@ var RENDERER_CSS = `
|
|
|
7266
7352
|
.ds-panel[data-tone="plain"] > .ds-panel-body { container-type: normal; }
|
|
7267
7353
|
/* Slots: nodes inside nodes */
|
|
7268
7354
|
.ds-slot { min-width: 0; }
|
|
7355
|
+
.ds-pager[data-layout="simple"] { display: flex; align-items: center; justify-content: flex-end; gap: var(--ds-space-sm); flex-wrap: wrap; color: var(--ds-color-text-subtle); font-size: var(--ds-type-label-size); }
|
|
7356
|
+
.ds-pager[data-layout="simple"] .ds-pager-range { margin-right: var(--ds-space-xs); }
|
|
7269
7357
|
.ds-slot[data-slot="toolbar"] { display: flex; flex-wrap: wrap; gap: var(--ds-space-sm); align-items: center; margin-bottom: var(--ds-space-sm); }
|
|
7270
7358
|
.ds-button { display: inline-flex; align-items: center; justify-content: center; gap: var(--ds-space-xs); height: var(--ds-control-height, 36px); padding: 0 var(--ds-space-md); border: 1px solid var(--ds-color-border-default); border-radius: var(--ds-radius-control); background: var(--ds-color-surface-card); color: var(--ds-color-text-primary); font: 500 var(--ds-type-label-size)/1 var(--ds-font-body); cursor: pointer; white-space: nowrap; transition: background 140ms ease, border-color 140ms ease, opacity 140ms ease; }
|
|
7271
7359
|
.ds-button[data-size="sm"] { height: calc(var(--ds-control-height, 36px) - 8px); padding: 0 var(--ds-space-sm); }
|