@dashspec/renderer 0.1.7 → 0.1.9
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 +29 -1
- package/dist/{chunk-RJI35HZD.js → chunk-5EYC4E5K.js} +35 -3
- package/dist/{chunk-RJI35HZD.js.map → chunk-5EYC4E5K.js.map} +1 -1
- package/dist/{core-D93t3WCk.d.ts → core-BBSo3c1f.d.ts} +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +338 -191
- package/dist/index.js.map +1 -1
- package/docs/widgets.md +24 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -115,7 +115,7 @@ import {
|
|
|
115
115
|
translator,
|
|
116
116
|
validateDocument,
|
|
117
117
|
widgetChecks
|
|
118
|
-
} from "./chunk-
|
|
118
|
+
} from "./chunk-5EYC4E5K.js";
|
|
119
119
|
import {
|
|
120
120
|
createStateProxy,
|
|
121
121
|
getPath,
|
|
@@ -164,7 +164,7 @@ import {
|
|
|
164
164
|
createElement,
|
|
165
165
|
forwardRef,
|
|
166
166
|
useCallback as useCallback8,
|
|
167
|
-
useEffect as
|
|
167
|
+
useEffect as useEffect12,
|
|
168
168
|
useImperativeHandle,
|
|
169
169
|
useMemo as useMemo8,
|
|
170
170
|
useRef as useRef14,
|
|
@@ -3525,16 +3525,32 @@ var ImageMap = defineWidget({
|
|
|
3525
3525
|
import "zod";
|
|
3526
3526
|
|
|
3527
3527
|
// src/widgets/shared/InfoTip.tsx
|
|
3528
|
-
import { useLayoutEffect as useLayoutEffect2, useRef as useRef4, useState as useState3 } from "react";
|
|
3528
|
+
import { useEffect as useEffect3, useLayoutEffect as useLayoutEffect2, useRef as useRef4, useState as useState3 } from "react";
|
|
3529
3529
|
import { createPortal as createPortal2 } from "react-dom";
|
|
3530
3530
|
import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
3531
3531
|
function InfoTip({ text }) {
|
|
3532
3532
|
const ref = useRef4(null);
|
|
3533
3533
|
const tip = useRef4(null);
|
|
3534
3534
|
const [open, setOpen] = useState3(false);
|
|
3535
|
+
const [mounted, setMounted] = useState3(false);
|
|
3536
|
+
const closing = useRef4(void 0);
|
|
3537
|
+
useEffect3(() => () => clearTimeout(closing.current), []);
|
|
3538
|
+
const show = () => {
|
|
3539
|
+
clearTimeout(closing.current);
|
|
3540
|
+
setMounted(true);
|
|
3541
|
+
setOpen(true);
|
|
3542
|
+
};
|
|
3543
|
+
const hide = () => {
|
|
3544
|
+
setOpen(false);
|
|
3545
|
+
clearTimeout(closing.current);
|
|
3546
|
+
closing.current = setTimeout(() => {
|
|
3547
|
+
setMounted(false);
|
|
3548
|
+
setPos(null);
|
|
3549
|
+
}, 160);
|
|
3550
|
+
};
|
|
3535
3551
|
const [pos, setPos] = useState3(null);
|
|
3536
3552
|
useLayoutEffect2(() => {
|
|
3537
|
-
if (!
|
|
3553
|
+
if (!mounted || !ref.current || !tip.current) return;
|
|
3538
3554
|
const a = ref.current.getBoundingClientRect();
|
|
3539
3555
|
const t = tip.current.getBoundingClientRect();
|
|
3540
3556
|
const gap = 8;
|
|
@@ -3548,7 +3564,7 @@ function InfoTip({ text }) {
|
|
|
3548
3564
|
const centre = a.left + a.width / 2;
|
|
3549
3565
|
const left = Math.min(Math.max(centre - t.width / 2, minX), Math.max(minX, maxX - t.width));
|
|
3550
3566
|
setPos({ left, top: below ? a.bottom + gap : a.top - t.height - gap, arrow: centre - left, below });
|
|
3551
|
-
}, [
|
|
3567
|
+
}, [mounted]);
|
|
3552
3568
|
const root = ref.current?.closest(".ds-root") ?? (typeof document !== "undefined" ? document.body : null);
|
|
3553
3569
|
return /* @__PURE__ */ jsxs8(
|
|
3554
3570
|
"button",
|
|
@@ -3558,22 +3574,16 @@ function InfoTip({ text }) {
|
|
|
3558
3574
|
className: "ds-info",
|
|
3559
3575
|
"aria-label": text,
|
|
3560
3576
|
onClick: (e) => e.stopPropagation(),
|
|
3561
|
-
onMouseEnter:
|
|
3562
|
-
onMouseLeave:
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
},
|
|
3566
|
-
onFocus: () => setOpen(true),
|
|
3567
|
-
onBlur: () => {
|
|
3568
|
-
setOpen(false);
|
|
3569
|
-
setPos(null);
|
|
3570
|
-
},
|
|
3577
|
+
onMouseEnter: show,
|
|
3578
|
+
onMouseLeave: hide,
|
|
3579
|
+
onFocus: show,
|
|
3580
|
+
onBlur: hide,
|
|
3571
3581
|
children: [
|
|
3572
3582
|
/* @__PURE__ */ jsxs8("svg", { viewBox: "0 0 16 16", width: "14", height: "14", "aria-hidden": "true", children: [
|
|
3573
3583
|
/* @__PURE__ */ jsx12("circle", { cx: "8", cy: "8", r: "6.5", fill: "none", stroke: "currentColor", strokeWidth: "1" }),
|
|
3574
3584
|
/* @__PURE__ */ jsx12("path", { d: "M8 7.2v3.6M8 5.2v.1", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round" })
|
|
3575
3585
|
] }),
|
|
3576
|
-
|
|
3586
|
+
mounted && root && createPortal2(
|
|
3577
3587
|
/* @__PURE__ */ jsx12(
|
|
3578
3588
|
"span",
|
|
3579
3589
|
{
|
|
@@ -3581,6 +3591,7 @@ function InfoTip({ text }) {
|
|
|
3581
3591
|
className: "ds-tip",
|
|
3582
3592
|
role: "tooltip",
|
|
3583
3593
|
"data-below": pos?.below || void 0,
|
|
3594
|
+
"data-open": open && pos ? "" : void 0,
|
|
3584
3595
|
style: {
|
|
3585
3596
|
left: pos?.left ?? 0,
|
|
3586
3597
|
top: pos?.top ?? 0,
|
|
@@ -3601,7 +3612,7 @@ function InfoTip({ text }) {
|
|
|
3601
3612
|
import { useContext as useContext4 } from "react";
|
|
3602
3613
|
|
|
3603
3614
|
// src/components/PanelFrame.tsx
|
|
3604
|
-
import { useCallback as useCallback4, useEffect as
|
|
3615
|
+
import { useCallback as useCallback4, useEffect as useEffect4, useId as useId4, useMemo as useMemo3, useRef as useRef5, useState as useState4 } from "react";
|
|
3605
3616
|
|
|
3606
3617
|
// src/widgets/parseProps.ts
|
|
3607
3618
|
function without(value, path) {
|
|
@@ -4020,7 +4031,7 @@ function PanelFrameInner({ id, nested }) {
|
|
|
4020
4031
|
const store = useMemo3(() => widgetStore(runtime), [runtime]);
|
|
4021
4032
|
const [bodyRef, size2] = useSize();
|
|
4022
4033
|
const frameRef = useRef5(null);
|
|
4023
|
-
|
|
4034
|
+
useEffect4(() => {
|
|
4024
4035
|
if (!view.visible || view.hidden) {
|
|
4025
4036
|
visibility.set(instance, null);
|
|
4026
4037
|
return;
|
|
@@ -4276,13 +4287,13 @@ function useClickable(panelId, activate) {
|
|
|
4276
4287
|
}
|
|
4277
4288
|
|
|
4278
4289
|
// src/widgets/shared/motion.ts
|
|
4279
|
-
import { useEffect as
|
|
4290
|
+
import { useEffect as useEffect5, useRef as useRef6, useState as useState5 } from "react";
|
|
4280
4291
|
var reduced = () => typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
4281
4292
|
var easeOut = (t) => 1 - (1 - t) ** 3;
|
|
4282
4293
|
function useCountUp(target, ms = 700) {
|
|
4283
4294
|
const [shown, setShown] = useState5(() => typeof target === "number" && !reduced() ? 0 : target);
|
|
4284
4295
|
const from = useRef6(0);
|
|
4285
|
-
|
|
4296
|
+
useEffect5(() => {
|
|
4286
4297
|
if (typeof target !== "number" || !Number.isFinite(target) || reduced()) {
|
|
4287
4298
|
setShown(target);
|
|
4288
4299
|
return;
|
|
@@ -4596,8 +4607,48 @@ var Status = defineWidget({
|
|
|
4596
4607
|
});
|
|
4597
4608
|
|
|
4598
4609
|
// src/widgets/builtins/Table.tsx
|
|
4599
|
-
import { useEffect as
|
|
4600
|
-
|
|
4610
|
+
import { useEffect as useEffect6, useMemo as useMemo4, useRef as useRef7, useState as useState6 } from "react";
|
|
4611
|
+
|
|
4612
|
+
// src/widgets/shared/chips.tsx
|
|
4613
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
4614
|
+
var TONES = /* @__PURE__ */ new Set(["good", "warn", "bad", "neutral", "info", "action", "muted"]);
|
|
4615
|
+
function evalOver(expr, vars, helpers) {
|
|
4616
|
+
try {
|
|
4617
|
+
return evaluate(expr, scope(vars, helpers));
|
|
4618
|
+
} catch {
|
|
4619
|
+
return void 0;
|
|
4620
|
+
}
|
|
4621
|
+
}
|
|
4622
|
+
function toneOf(tone2, vars, helpers) {
|
|
4623
|
+
if (!tone2) return void 0;
|
|
4624
|
+
if (TONES.has(tone2)) return tone2;
|
|
4625
|
+
const t = evalOver(tone2, vars, helpers);
|
|
4626
|
+
return typeof t === "string" ? t : void 0;
|
|
4627
|
+
}
|
|
4628
|
+
function Chips({
|
|
4629
|
+
chips,
|
|
4630
|
+
vars,
|
|
4631
|
+
helpers
|
|
4632
|
+
}) {
|
|
4633
|
+
if (!chips?.length) return null;
|
|
4634
|
+
const shown = chips.filter((c) => c.when === void 0 || Boolean(evalOver(c.when, vars, helpers))).map((c) => {
|
|
4635
|
+
let text = "";
|
|
4636
|
+
try {
|
|
4637
|
+
const v = interpolate(c.text, scope(vars, helpers));
|
|
4638
|
+
text = v === null || v === void 0 ? "" : String(v);
|
|
4639
|
+
} catch {
|
|
4640
|
+
}
|
|
4641
|
+
return { text, tone: toneOf(c.tone, vars, helpers) ?? "neutral" };
|
|
4642
|
+
}).filter((c) => c.text);
|
|
4643
|
+
if (shown.length === 0) return null;
|
|
4644
|
+
return /* @__PURE__ */ jsx20("span", { className: "ds-chips", children: shown.map((c, i) => (
|
|
4645
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: chips come from a fixed list in the spec
|
|
4646
|
+
/* @__PURE__ */ jsx20("span", { className: "ds-chip", "data-tone": c.tone, children: c.text }, i)
|
|
4647
|
+
)) });
|
|
4648
|
+
}
|
|
4649
|
+
|
|
4650
|
+
// src/widgets/builtins/Table.tsx
|
|
4651
|
+
import { jsx as jsx21, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
4601
4652
|
var ROW_H = 36;
|
|
4602
4653
|
function pageList(current, pages) {
|
|
4603
4654
|
if (pages <= 7) return Array.from({ length: pages }, (_, i) => i + 1);
|
|
@@ -4618,7 +4669,7 @@ var Table = defineWidget({
|
|
|
4618
4669
|
events: ["rowClick", "cellClick", "hover"],
|
|
4619
4670
|
parts: ["row", "cell"],
|
|
4620
4671
|
rows: (data) => asRows(data),
|
|
4621
|
-
component: function TableWidget({ spec, data, source, emit, helpers, size: size2, state, setUi, status }) {
|
|
4672
|
+
component: function TableWidget({ spec, data, source, emit, helpers, size: size2, state, setUi, status, renderSlot }) {
|
|
4622
4673
|
const tpl = (t, row, item) => {
|
|
4623
4674
|
try {
|
|
4624
4675
|
const v = interpolate(t, scope({ row, item, datum: row }, helpers));
|
|
@@ -4632,16 +4683,29 @@ var Table = defineWidget({
|
|
|
4632
4683
|
return spec.pivot ? applyTransform(rows2, [{ pivot: spec.pivot }], scope()) : rows2;
|
|
4633
4684
|
}, [data, spec.pivot]);
|
|
4634
4685
|
const columns = useMemo4(() => {
|
|
4635
|
-
|
|
4636
|
-
if (spec.columnsFrom) {
|
|
4686
|
+
const generated = () => {
|
|
4637
4687
|
const cf = spec.columnsFrom;
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4688
|
+
if (!cf) return [];
|
|
4689
|
+
return asRows(field(source, cf.path)).map((c) => {
|
|
4690
|
+
const key = String(field(c, cf.key));
|
|
4691
|
+
const label = String(field(c, cf.label) ?? field(c, cf.key));
|
|
4692
|
+
const fill = (v) => typeof v === "string" ? v.replaceAll("{key}", key).replaceAll("{label}", label) : Array.isArray(v) ? v.map(fill) : v && typeof v === "object" ? Object.fromEntries(Object.entries(v).map(([k, x]) => [k, fill(x)])) : v;
|
|
4693
|
+
return {
|
|
4694
|
+
key,
|
|
4695
|
+
label,
|
|
4696
|
+
...cf.type ? { type: cf.type } : {},
|
|
4697
|
+
...cf.format ? { format: cf.format } : {},
|
|
4698
|
+
...fill(cf.column ?? {}) ?? {}
|
|
4699
|
+
};
|
|
4700
|
+
});
|
|
4701
|
+
};
|
|
4702
|
+
if (spec.columns?.length) {
|
|
4703
|
+
if (!spec.columnsFrom) return spec.columns;
|
|
4704
|
+
const gen = generated();
|
|
4705
|
+
const at = spec.columnsFrom.after ? spec.columns.findIndex((c) => c.key === spec.columnsFrom?.after) : -1;
|
|
4706
|
+
return at < 0 ? [...spec.columns, ...gen] : [...spec.columns.slice(0, at + 1), ...gen, ...spec.columns.slice(at + 1)];
|
|
4644
4707
|
}
|
|
4708
|
+
if (spec.columnsFrom) return generated();
|
|
4645
4709
|
return Object.keys(base[0] ?? {}).map((k) => ({ key: k }));
|
|
4646
4710
|
}, [spec.columns, spec.columnsFrom, source, base]);
|
|
4647
4711
|
const pg = spec.pagination && spec.pagination.enabled !== false ? spec.pagination : void 0;
|
|
@@ -4681,7 +4745,7 @@ var Table = defineWidget({
|
|
|
4681
4745
|
};
|
|
4682
4746
|
const [searchText, setSearchText] = useState6(view.search);
|
|
4683
4747
|
const searchTimer = useRef7(void 0);
|
|
4684
|
-
|
|
4748
|
+
useEffect6(() => () => clearTimeout(searchTimer.current), []);
|
|
4685
4749
|
const [scrollTop, setScrollTop] = useState6(0);
|
|
4686
4750
|
const scroller = useRef7(null);
|
|
4687
4751
|
const sort = view.sortKey ? { key: view.sortKey, order: view.sortOrder } : void 0;
|
|
@@ -4743,7 +4807,7 @@ var Table = defineWidget({
|
|
|
4743
4807
|
const v = field(row, c.key);
|
|
4744
4808
|
if (c.type === "badge") {
|
|
4745
4809
|
const text = c.template ? tpl(c.template, row) : v === null || v === void 0 || v === "" ? "" : String(v);
|
|
4746
|
-
if (!text) return c.empty ? /* @__PURE__ */
|
|
4810
|
+
if (!text) return c.empty ? /* @__PURE__ */ jsx21("span", { className: "ds-cell-empty", children: c.empty }) : "";
|
|
4747
4811
|
let t = c.map?.[String(v)] ?? "neutral";
|
|
4748
4812
|
if (c.tone) {
|
|
4749
4813
|
try {
|
|
@@ -4753,37 +4817,37 @@ var Table = defineWidget({
|
|
|
4753
4817
|
} catch {
|
|
4754
4818
|
}
|
|
4755
4819
|
}
|
|
4756
|
-
return /* @__PURE__ */
|
|
4820
|
+
return /* @__PURE__ */ jsx21("span", { className: "ds-chip", "data-tone": t, children: text });
|
|
4757
4821
|
}
|
|
4758
|
-
if (c.template) return tpl(c.template, row) || (c.empty ? /* @__PURE__ */
|
|
4822
|
+
if (c.template) return tpl(c.template, row) || (c.empty ? /* @__PURE__ */ jsx21("span", { className: "ds-cell-empty", children: c.empty }) : "");
|
|
4759
4823
|
if (c.list !== void 0) {
|
|
4760
4824
|
const items = Array.isArray(v) ? v : [];
|
|
4761
4825
|
if (items.length === 0) return c.empty ?? "";
|
|
4762
|
-
return /* @__PURE__ */
|
|
4826
|
+
return /* @__PURE__ */ jsx21("span", { className: "ds-cell-list", children: items.map((it, i) => (
|
|
4763
4827
|
// biome-ignore lint/suspicious/noArrayIndexKey: list items have no id and never reorder within a render
|
|
4764
|
-
/* @__PURE__ */
|
|
4828
|
+
/* @__PURE__ */ jsx21("span", { children: tpl(c.list, row, it) }, i)
|
|
4765
4829
|
)) });
|
|
4766
4830
|
}
|
|
4767
4831
|
if (v === null || v === void 0 || v === "")
|
|
4768
|
-
return c.empty ? /* @__PURE__ */
|
|
4832
|
+
return c.empty ? /* @__PURE__ */ jsx21("span", { className: "ds-cell-empty", children: c.empty }) : "";
|
|
4769
4833
|
switch (c.type) {
|
|
4770
4834
|
case "link": {
|
|
4771
4835
|
const href = safeLink(c.href ? tpl(c.href, row) : String(v));
|
|
4772
|
-
return href ? /* @__PURE__ */
|
|
4836
|
+
return href ? /* @__PURE__ */ jsx21("a", { className: "ds-link", href, onClick: (e) => e.stopPropagation(), children: String(v) }) : String(v);
|
|
4773
4837
|
}
|
|
4774
4838
|
case "image":
|
|
4775
|
-
return safeImageSrc(v) ? /* @__PURE__ */
|
|
4839
|
+
return safeImageSrc(v) ? /* @__PURE__ */ jsx21("img", { src: v, alt: "", style: { height: 28, borderRadius: 4 } }) : null;
|
|
4776
4840
|
case "progress": {
|
|
4777
4841
|
const n = toNumber(v) ?? 0;
|
|
4778
4842
|
const pct = Math.min(100, n / (c.max ?? 100) * 100);
|
|
4779
4843
|
return /* @__PURE__ */ jsxs16("span", { className: "ds-inline", children: [
|
|
4780
|
-
/* @__PURE__ */
|
|
4844
|
+
/* @__PURE__ */ jsx21("span", { className: "ds-progress", style: { flex: 1, minWidth: 40 }, children: /* @__PURE__ */ jsx21("span", { style: { width: `${pct}%`, background: "var(--ds-series-1)" } }) }),
|
|
4781
4845
|
formatValue(n, helpers, c.format, c.decimals),
|
|
4782
4846
|
c.suffix
|
|
4783
4847
|
] });
|
|
4784
4848
|
}
|
|
4785
4849
|
case "sparkline":
|
|
4786
|
-
return /* @__PURE__ */
|
|
4850
|
+
return /* @__PURE__ */ jsx21(
|
|
4787
4851
|
SparkSvg,
|
|
4788
4852
|
{
|
|
4789
4853
|
values: (Array.isArray(v) ? v : []).map(
|
|
@@ -4797,6 +4861,22 @@ var Table = defineWidget({
|
|
|
4797
4861
|
return `${c.prefix ?? ""}${typeof v === "number" || c.format ? formatValue(v, helpers, c.format, c.decimals) : String(v)}${c.suffix ?? ""}`;
|
|
4798
4862
|
}
|
|
4799
4863
|
};
|
|
4864
|
+
const WEIGHT = { regular: 400, medium: 500, semibold: 600, bold: 700 };
|
|
4865
|
+
const decorated = (c, row) => {
|
|
4866
|
+
const content = cell(c, row);
|
|
4867
|
+
if (!c.sub && !c.chips && !c.weight && !c.valueTone) return content;
|
|
4868
|
+
const vars = { row, value: field(row, c.key) };
|
|
4869
|
+
const t = toneOf(c.valueTone, vars, helpers);
|
|
4870
|
+
const color2 = t === "action" ? "var(--ds-color-action-primary)" : t === "muted" ? "var(--ds-color-text-disabled)" : t ? `var(--ds-color-status-${t}-fg)` : void 0;
|
|
4871
|
+
const sub = c.sub ? tpl(c.sub, row) : "";
|
|
4872
|
+
return /* @__PURE__ */ jsxs16("span", { className: "ds-cell", children: [
|
|
4873
|
+
/* @__PURE__ */ jsx21("span", { className: "ds-cell-value", style: { fontWeight: c.weight ? WEIGHT[c.weight] : void 0, color: color2 }, children: content }),
|
|
4874
|
+
sub && /* @__PURE__ */ jsx21("span", { className: "ds-cell-sub", children: sub }),
|
|
4875
|
+
/* @__PURE__ */ jsx21(Chips, { chips: c.chips, vars, helpers })
|
|
4876
|
+
] });
|
|
4877
|
+
};
|
|
4878
|
+
const totalsRow = spec.totalsRow ? field(source, spec.totalsRow.path) : void 0;
|
|
4879
|
+
const expandedKey = spec.expand ? ui.expanded : void 0;
|
|
4800
4880
|
const total = (c) => {
|
|
4801
4881
|
const how = spec.totals?.columns[c.key];
|
|
4802
4882
|
if (!how) return null;
|
|
@@ -4818,10 +4898,10 @@ var Table = defineWidget({
|
|
|
4818
4898
|
sr && /* @__PURE__ */ jsxs16("div", { className: "ds-table-tools", children: [
|
|
4819
4899
|
/* @__PURE__ */ jsxs16("label", { className: "ds-search", children: [
|
|
4820
4900
|
/* @__PURE__ */ jsxs16("svg", { viewBox: "0 0 16 16", width: "15", height: "15", "aria-hidden": "true", children: [
|
|
4821
|
-
/* @__PURE__ */
|
|
4822
|
-
/* @__PURE__ */
|
|
4901
|
+
/* @__PURE__ */ jsx21("circle", { cx: "7", cy: "7", r: "4.5", fill: "none", stroke: "currentColor", strokeWidth: "1.5" }),
|
|
4902
|
+
/* @__PURE__ */ jsx21("path", { d: "m10.5 10.5 3 3", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
|
|
4823
4903
|
] }),
|
|
4824
|
-
/* @__PURE__ */
|
|
4904
|
+
/* @__PURE__ */ jsx21(
|
|
4825
4905
|
"input",
|
|
4826
4906
|
{
|
|
4827
4907
|
type: "search",
|
|
@@ -4851,12 +4931,12 @@ var Table = defineWidget({
|
|
|
4851
4931
|
style: { maxHeight: height },
|
|
4852
4932
|
onScroll: windowed ? (e) => setScrollTop(e.currentTarget.scrollTop) : void 0,
|
|
4853
4933
|
children: [
|
|
4854
|
-
busy && /* @__PURE__ */
|
|
4934
|
+
busy && /* @__PURE__ */ jsx21("div", { className: "ds-table-busy", "aria-hidden": "true" }),
|
|
4855
4935
|
/* @__PURE__ */ jsxs16("table", { className: "ds-table", "aria-busy": busy || void 0, children: [
|
|
4856
4936
|
/* @__PURE__ */ jsxs16("thead", { "data-sticky": spec.sticky || void 0, children: [
|
|
4857
|
-
/* @__PURE__ */
|
|
4937
|
+
/* @__PURE__ */ jsx21("tr", { children: columns.map((c, i) => {
|
|
4858
4938
|
const sorted = sort?.key === c.key ? sort.order : void 0;
|
|
4859
|
-
return /* @__PURE__ */
|
|
4939
|
+
return /* @__PURE__ */ jsx21(
|
|
4860
4940
|
"th",
|
|
4861
4941
|
{
|
|
4862
4942
|
"data-ds-part": `column:${i}`,
|
|
@@ -4871,7 +4951,7 @@ var Table = defineWidget({
|
|
|
4871
4951
|
),
|
|
4872
4952
|
children: [
|
|
4873
4953
|
c.label ?? c.key,
|
|
4874
|
-
/* @__PURE__ */
|
|
4954
|
+
/* @__PURE__ */ jsx21("span", { className: "ds-sort", "data-dir": sorted, "aria-hidden": "true" })
|
|
4875
4955
|
]
|
|
4876
4956
|
}
|
|
4877
4957
|
)
|
|
@@ -4879,7 +4959,7 @@ var Table = defineWidget({
|
|
|
4879
4959
|
`${c.key}-${i}`
|
|
4880
4960
|
);
|
|
4881
4961
|
}) }),
|
|
4882
|
-
hasFilters && /* @__PURE__ */
|
|
4962
|
+
hasFilters && /* @__PURE__ */ jsx21("tr", { className: "ds-filter-row", children: columns.map((c, i) => /* @__PURE__ */ jsx21("th", { children: c.filter === "select" ? /* @__PURE__ */ jsx21(
|
|
4883
4963
|
SelectControl,
|
|
4884
4964
|
{
|
|
4885
4965
|
size: "sm",
|
|
@@ -4893,7 +4973,7 @@ var Table = defineWidget({
|
|
|
4893
4973
|
value: view.filters[c.key] ?? "",
|
|
4894
4974
|
onChange: (v) => update({ filters: { ...view.filters, [c.key]: String(v ?? "") }, page: 1 })
|
|
4895
4975
|
}
|
|
4896
|
-
) : c.filter ? /* @__PURE__ */
|
|
4976
|
+
) : c.filter ? /* @__PURE__ */ jsx21(
|
|
4897
4977
|
"input",
|
|
4898
4978
|
{
|
|
4899
4979
|
className: "ds-cell-filter",
|
|
@@ -4906,37 +4986,54 @@ var Table = defineWidget({
|
|
|
4906
4986
|
) : null }, `f-${c.key}-${i}`)) })
|
|
4907
4987
|
] }),
|
|
4908
4988
|
/* @__PURE__ */ jsxs16("tbody", { children: [
|
|
4909
|
-
windowed && first > 0 && /* @__PURE__ */
|
|
4989
|
+
windowed && first > 0 && /* @__PURE__ */ jsx21("tr", { className: "ds-spacer", children: /* @__PURE__ */ jsx21("td", { colSpan: columns.length, style: { height: first * ROW_H, padding: 0 } }) }),
|
|
4910
4990
|
shown.slice(first, last).map((row, k) => {
|
|
4911
4991
|
const i = first + k;
|
|
4912
4992
|
const key = spec.rowKey ? String(field(row, spec.rowKey)) : String(i);
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
{
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4993
|
+
const open = expandedKey !== void 0 && expandedKey === key;
|
|
4994
|
+
const toggle = () => {
|
|
4995
|
+
if (spec.expand) setUi({ expanded: open ? void 0 : key, expandedRow: open ? void 0 : row });
|
|
4996
|
+
};
|
|
4997
|
+
return [
|
|
4998
|
+
/* @__PURE__ */ jsx21(
|
|
4999
|
+
"tr",
|
|
5000
|
+
{
|
|
5001
|
+
"data-muted": muted(row) || void 0,
|
|
5002
|
+
"data-expanded": open || void 0,
|
|
5003
|
+
"aria-expanded": spec.expand ? open : void 0,
|
|
5004
|
+
onClick: () => {
|
|
5005
|
+
toggle();
|
|
5006
|
+
emit("rowClick", "row", { datum: row, index: i });
|
|
5007
|
+
},
|
|
5008
|
+
onMouseEnter: () => emit("hover", "row", { datum: row, index: i }),
|
|
5009
|
+
tabIndex: 0,
|
|
5010
|
+
onKeyDown: (e) => {
|
|
5011
|
+
if (e.key !== "Enter") return;
|
|
5012
|
+
toggle();
|
|
5013
|
+
emit("rowClick", "row", { datum: row, index: i });
|
|
5014
|
+
},
|
|
5015
|
+
children: columns.map((c, j) => (
|
|
5016
|
+
// biome-ignore lint/a11y/useKeyWithClickEvents: rows are focusable and open with Enter; cell clicks add detail for pointer users
|
|
5017
|
+
/* @__PURE__ */ jsx21(
|
|
5018
|
+
"td",
|
|
5019
|
+
{
|
|
5020
|
+
style: { textAlign: align(c) },
|
|
5021
|
+
onClick: () => emit("cellClick", "cell", { datum: row, index: i, value: field(row, c.key), column: c.key }),
|
|
5022
|
+
children: decorated(c, row)
|
|
5023
|
+
},
|
|
5024
|
+
`${c.key}-${j}`
|
|
5025
|
+
)
|
|
5026
|
+
))
|
|
5027
|
+
},
|
|
5028
|
+
key
|
|
5029
|
+
),
|
|
5030
|
+
open ? /* @__PURE__ */ jsx21("tr", { className: "ds-row-detail", children: /* @__PURE__ */ jsx21("td", { colSpan: columns.length, children: renderSlot("detail", { item: row, data: row }) }) }, `${key}-detail`) : null
|
|
5031
|
+
];
|
|
4936
5032
|
}),
|
|
4937
|
-
windowed && last < shown.length && /* @__PURE__ */
|
|
5033
|
+
windowed && last < shown.length && /* @__PURE__ */ jsx21("tr", { className: "ds-spacer", children: /* @__PURE__ */ jsx21("td", { colSpan: columns.length, style: { height: (shown.length - last) * ROW_H, padding: 0 } }) })
|
|
4938
5034
|
] }),
|
|
4939
|
-
spec.totals && /* @__PURE__ */
|
|
5035
|
+
totalsRow && !spec.totals && /* @__PURE__ */ jsx21("tfoot", { children: /* @__PURE__ */ jsx21("tr", { children: columns.map((c, j) => /* @__PURE__ */ jsx21("td", { style: { textAlign: align(c) }, children: j === 0 && spec.totalsRow?.label ? tpl(spec.totalsRow.label, totalsRow) : decorated(c, totalsRow) }, `${c.key}-${j}`)) }) }),
|
|
5036
|
+
spec.totals && /* @__PURE__ */ jsx21("tfoot", { children: /* @__PURE__ */ jsx21("tr", { children: columns.map((c, j) => /* @__PURE__ */ jsx21("td", { style: { textAlign: align(c) }, children: j === 0 && !spec.totals?.columns[c.key] ? spec.totals?.label : total(c) }, `${c.key}-${j}`)) }) })
|
|
4940
5037
|
] })
|
|
4941
5038
|
]
|
|
4942
5039
|
}
|
|
@@ -4944,7 +5041,7 @@ var Table = defineWidget({
|
|
|
4944
5041
|
pageSize && /* @__PURE__ */ jsxs16("div", { className: "ds-pager", children: [
|
|
4945
5042
|
/* @__PURE__ */ jsxs16("span", { className: "ds-pager-size", children: [
|
|
4946
5043
|
"Rows",
|
|
4947
|
-
/* @__PURE__ */
|
|
5044
|
+
/* @__PURE__ */ jsx21(
|
|
4948
5045
|
SelectControl,
|
|
4949
5046
|
{
|
|
4950
5047
|
size: "sm",
|
|
@@ -4965,7 +5062,7 @@ var Table = defineWidget({
|
|
|
4965
5062
|
helpers.fmt.number(rowTotal)
|
|
4966
5063
|
] }),
|
|
4967
5064
|
/* @__PURE__ */ jsxs16("span", { className: "ds-pages", children: [
|
|
4968
|
-
/* @__PURE__ */
|
|
5065
|
+
/* @__PURE__ */ jsx21(
|
|
4969
5066
|
"button",
|
|
4970
5067
|
{
|
|
4971
5068
|
type: "button",
|
|
@@ -4976,7 +5073,7 @@ var Table = defineWidget({
|
|
|
4976
5073
|
}
|
|
4977
5074
|
),
|
|
4978
5075
|
pageList(current, pages).map(
|
|
4979
|
-
(n, i) => n === 0 ? /* @__PURE__ */
|
|
5076
|
+
(n, i) => n === 0 ? /* @__PURE__ */ jsx21("span", { className: "ds-page-gap", children: "\u2026" }, `gap-${i < 3 ? "a" : "b"}`) : /* @__PURE__ */ jsx21(
|
|
4980
5077
|
"button",
|
|
4981
5078
|
{
|
|
4982
5079
|
type: "button",
|
|
@@ -4987,7 +5084,7 @@ var Table = defineWidget({
|
|
|
4987
5084
|
n
|
|
4988
5085
|
)
|
|
4989
5086
|
),
|
|
4990
|
-
/* @__PURE__ */
|
|
5087
|
+
/* @__PURE__ */ jsx21(
|
|
4991
5088
|
"button",
|
|
4992
5089
|
{
|
|
4993
5090
|
type: "button",
|
|
@@ -5005,7 +5102,7 @@ var Table = defineWidget({
|
|
|
5005
5102
|
|
|
5006
5103
|
// src/widgets/builtins/Tiles.tsx
|
|
5007
5104
|
import "zod";
|
|
5008
|
-
import { Fragment as Fragment6, jsx as
|
|
5105
|
+
import { Fragment as Fragment6, jsx as jsx22, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
5009
5106
|
var Tiles = defineWidget({
|
|
5010
5107
|
...TilesContract,
|
|
5011
5108
|
implements: "tiles",
|
|
@@ -5024,7 +5121,7 @@ var Tiles = defineWidget({
|
|
|
5024
5121
|
return spec.caption;
|
|
5025
5122
|
}
|
|
5026
5123
|
};
|
|
5027
|
-
return /* @__PURE__ */
|
|
5124
|
+
return /* @__PURE__ */ jsx22(
|
|
5028
5125
|
"div",
|
|
5029
5126
|
{
|
|
5030
5127
|
className: "ds-tiles",
|
|
@@ -5037,12 +5134,15 @@ var Tiles = defineWidget({
|
|
|
5037
5134
|
},
|
|
5038
5135
|
children: rows.map((r, i) => {
|
|
5039
5136
|
const label = field(r, spec.label);
|
|
5040
|
-
const v = field(r, spec.value);
|
|
5137
|
+
const v = spec.value.includes("${") ? tplValue(spec.value, r, helpers) : field(r, spec.value);
|
|
5041
5138
|
const n = toNumber(v);
|
|
5042
5139
|
const status = spec.status ? String(field(r, spec.status)) : void 0;
|
|
5043
5140
|
const st = status ? spec.statusMap?.[status] ?? status : void 0;
|
|
5044
5141
|
const vt = n === void 0 || !spec.valueTone ? void 0 : n > 0 ? spec.valueTone.positive : n < 0 ? spec.valueTone.negative : spec.valueTone.zero;
|
|
5045
5142
|
const active = spec.selectable && spec.selected !== void 0 && spec.selected === label;
|
|
5143
|
+
const vars = { row: r, value: v };
|
|
5144
|
+
const mutedTile = spec.mutedWhen ? Boolean(evalOver(spec.mutedWhen, vars, helpers)) : false;
|
|
5145
|
+
const lit = spec.highlightWhen ? Boolean(evalOver(spec.highlightWhen, vars, helpers)) : false;
|
|
5046
5146
|
return /* @__PURE__ */ jsxs17(
|
|
5047
5147
|
"button",
|
|
5048
5148
|
{
|
|
@@ -5051,6 +5151,8 @@ var Tiles = defineWidget({
|
|
|
5051
5151
|
role: spec.selectable ? "radio" : "listitem",
|
|
5052
5152
|
"aria-checked": spec.selectable ? active : void 0,
|
|
5053
5153
|
"data-active": active || void 0,
|
|
5154
|
+
"data-muted": mutedTile || void 0,
|
|
5155
|
+
"data-highlight": lit ? spec.highlightTone ?? "warn" : void 0,
|
|
5054
5156
|
onClick: () => {
|
|
5055
5157
|
emit("click", "tile", { datum: r, value: label, index: i });
|
|
5056
5158
|
if (spec.selectable) emit("select", "tile", { datum: r, value: label, index: i });
|
|
@@ -5058,9 +5160,9 @@ var Tiles = defineWidget({
|
|
|
5058
5160
|
onMouseEnter: () => emit("hover", "tile", { datum: r, value: label, index: i }),
|
|
5059
5161
|
children: [
|
|
5060
5162
|
/* @__PURE__ */ jsxs17("span", { className: "ds-tile-label", children: [
|
|
5061
|
-
st && /* @__PURE__ */
|
|
5163
|
+
st && /* @__PURE__ */ jsx22("span", { className: "ds-dot", style: { background: tone(st).solid }, "aria-hidden": "true" }),
|
|
5062
5164
|
String(label ?? ""),
|
|
5063
|
-
spec.count && /* @__PURE__ */
|
|
5165
|
+
spec.count && /* @__PURE__ */ jsx22("span", { className: "ds-chip-count", children: String(field(r, spec.count) ?? "") })
|
|
5064
5166
|
] }),
|
|
5065
5167
|
/* @__PURE__ */ jsxs17(
|
|
5066
5168
|
"span",
|
|
@@ -5068,12 +5170,13 @@ var Tiles = defineWidget({
|
|
|
5068
5170
|
className: "ds-tile-value",
|
|
5069
5171
|
style: vt ? { color: vt === "muted" ? "var(--ds-color-text-disabled)" : tone(vt).fg } : void 0,
|
|
5070
5172
|
children: [
|
|
5071
|
-
/* @__PURE__ */
|
|
5072
|
-
spec.unit && /* @__PURE__ */
|
|
5173
|
+
/* @__PURE__ */ jsx22(CountUp, { value: v, render: (x) => formatValue(x, helpers, spec.format, spec.decimals) }),
|
|
5174
|
+
spec.unit && /* @__PURE__ */ jsx22("span", { className: "ds-kpi-unit", children: spec.unit })
|
|
5073
5175
|
]
|
|
5074
5176
|
}
|
|
5075
5177
|
),
|
|
5076
|
-
spec.caption && /* @__PURE__ */
|
|
5178
|
+
spec.caption && /* @__PURE__ */ jsx22("span", { className: "ds-tile-caption", children: caption(r) }),
|
|
5179
|
+
/* @__PURE__ */ jsx22(Chips, { chips: spec.chips, vars, helpers })
|
|
5077
5180
|
]
|
|
5078
5181
|
},
|
|
5079
5182
|
`${String(label)}-${i}`
|
|
@@ -5086,12 +5189,19 @@ var Tiles = defineWidget({
|
|
|
5086
5189
|
function CountUp({ value, render }) {
|
|
5087
5190
|
const n = toNumber(value);
|
|
5088
5191
|
const shown = useCountUp(n ?? value);
|
|
5089
|
-
return /* @__PURE__ */
|
|
5192
|
+
return /* @__PURE__ */ jsx22(Fragment6, { children: render(n === void 0 ? value : shown) });
|
|
5193
|
+
}
|
|
5194
|
+
function tplValue(t, row, helpers) {
|
|
5195
|
+
try {
|
|
5196
|
+
return interpolate(t, scope({ row }, helpers));
|
|
5197
|
+
} catch {
|
|
5198
|
+
return void 0;
|
|
5199
|
+
}
|
|
5090
5200
|
}
|
|
5091
5201
|
|
|
5092
5202
|
// src/widgets/builtins/atoms.tsx
|
|
5093
5203
|
import "zod";
|
|
5094
|
-
import { jsx as
|
|
5204
|
+
import { jsx as jsx23, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
5095
5205
|
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;
|
|
5096
5206
|
var boundValue = (data, path) => {
|
|
5097
5207
|
if (path) return field(Array.isArray(data) ? data[0] : data, path);
|
|
@@ -5109,7 +5219,7 @@ var Text = defineWidget({
|
|
|
5109
5219
|
const v = boundValue(data, spec.field);
|
|
5110
5220
|
const click = useClickable(panelId, () => emit("click", "text", { value: v }));
|
|
5111
5221
|
const shown = spec.text.includes("{value}") && (v === void 0 || v === null || v === "") ? spec.emptyText ?? spec.text.replace("{value}", "\u2013") : spec.text.replace("{value}", v === void 0 ? "" : formatValue(v, helpers, "text"));
|
|
5112
|
-
return /* @__PURE__ */
|
|
5222
|
+
return /* @__PURE__ */ jsx23(
|
|
5113
5223
|
"span",
|
|
5114
5224
|
{
|
|
5115
5225
|
className: "ds-atom-text",
|
|
@@ -5140,7 +5250,7 @@ var Value = defineWidget({
|
|
|
5140
5250
|
return /* @__PURE__ */ jsxs18("span", { className: "ds-atom-value", "data-size": spec.size, style: { color: c }, ...click, children: [
|
|
5141
5251
|
spec.prefix,
|
|
5142
5252
|
formatValue(shown, helpers, spec.format, spec.decimals),
|
|
5143
|
-
spec.unit && /* @__PURE__ */
|
|
5253
|
+
spec.unit && /* @__PURE__ */ jsx23("small", { children: spec.unit })
|
|
5144
5254
|
] });
|
|
5145
5255
|
}
|
|
5146
5256
|
});
|
|
@@ -5156,7 +5266,7 @@ var Progress = defineWidget({
|
|
|
5156
5266
|
const pct = max > 0 ? Math.max(0, Math.min(100, n / max * 100)) : 0;
|
|
5157
5267
|
const fill = spec.color === "primary" ? "var(--ds-color-action-primary)" : spec.color === "byTarget" ? tone(pct >= spec.goodFrom ? "good" : "bad").solid : tone(spec.color).solid;
|
|
5158
5268
|
return /* @__PURE__ */ jsxs18("div", { className: "ds-atom-progress", children: [
|
|
5159
|
-
/* @__PURE__ */
|
|
5269
|
+
/* @__PURE__ */ jsx23(
|
|
5160
5270
|
"span",
|
|
5161
5271
|
{
|
|
5162
5272
|
role: "progressbar",
|
|
@@ -5164,7 +5274,7 @@ var Progress = defineWidget({
|
|
|
5164
5274
|
"aria-valuemin": 0,
|
|
5165
5275
|
"aria-valuemax": 100,
|
|
5166
5276
|
style: { height: spec.thickness },
|
|
5167
|
-
children: /* @__PURE__ */
|
|
5277
|
+
children: /* @__PURE__ */ jsx23("span", { style: { width: `${pct}%`, background: fill } })
|
|
5168
5278
|
}
|
|
5169
5279
|
),
|
|
5170
5280
|
spec.showPercent && /* @__PURE__ */ jsxs18("small", { children: [
|
|
@@ -5184,7 +5294,7 @@ var Icon = defineWidget({
|
|
|
5184
5294
|
const click = useClickable(panelId, () => emit("click", "icon", {}));
|
|
5185
5295
|
const c = color(spec.color) ?? "var(--ds-color-text-primary)";
|
|
5186
5296
|
const style = spec.background ? { color: c, background: `color-mix(in srgb, ${c} 12%, transparent)`, padding: spec.size / 4 } : { color: c };
|
|
5187
|
-
return /* @__PURE__ */
|
|
5297
|
+
return /* @__PURE__ */ jsx23("span", { className: "ds-atom-icon", style, ...click, children: /* @__PURE__ */ jsx23(
|
|
5188
5298
|
"svg",
|
|
5189
5299
|
{
|
|
5190
5300
|
viewBox: "0 0 24 24",
|
|
@@ -5196,7 +5306,7 @@ var Icon = defineWidget({
|
|
|
5196
5306
|
strokeLinecap: "round",
|
|
5197
5307
|
strokeLinejoin: "round",
|
|
5198
5308
|
"aria-hidden": "true",
|
|
5199
|
-
children: /* @__PURE__ */
|
|
5309
|
+
children: /* @__PURE__ */ jsx23("path", { d: ICONS[spec.icon] ?? ICONS.bolt })
|
|
5200
5310
|
}
|
|
5201
5311
|
) });
|
|
5202
5312
|
}
|
|
@@ -5208,7 +5318,7 @@ var Divider = defineWidget({
|
|
|
5208
5318
|
meta: meta("Divider", 4, 1),
|
|
5209
5319
|
events: [],
|
|
5210
5320
|
component: function DividerAtom({ spec }) {
|
|
5211
|
-
return /* @__PURE__ */
|
|
5321
|
+
return /* @__PURE__ */ jsx23("hr", { className: "ds-atom-divider", "data-dir": spec.direction, "data-dashed": spec.dashed || void 0 });
|
|
5212
5322
|
}
|
|
5213
5323
|
});
|
|
5214
5324
|
|
|
@@ -5229,7 +5339,7 @@ import {
|
|
|
5229
5339
|
} from "echarts/components";
|
|
5230
5340
|
import * as echarts from "echarts/core";
|
|
5231
5341
|
import { CanvasRenderer } from "echarts/renderers";
|
|
5232
|
-
import { useEffect as
|
|
5342
|
+
import { useEffect as useEffect7, useMemo as useMemo5, useRef as useRef8 } from "react";
|
|
5233
5343
|
|
|
5234
5344
|
// src/theme/echartsTheme.ts
|
|
5235
5345
|
function echartsTheme(theme, mode) {
|
|
@@ -5274,7 +5384,7 @@ function echartsTheme(theme, mode) {
|
|
|
5274
5384
|
}
|
|
5275
5385
|
|
|
5276
5386
|
// src/widgets/shared/EChart.tsx
|
|
5277
|
-
import { jsx as
|
|
5387
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
5278
5388
|
echarts.use([
|
|
5279
5389
|
BarChart,
|
|
5280
5390
|
LineChart,
|
|
@@ -5309,7 +5419,7 @@ function EChart({
|
|
|
5309
5419
|
const theme = useMemo5(() => tokens ? echartsTheme(tokens.theme, tokens.mode) : void 0, [tokens]);
|
|
5310
5420
|
const handlers = useRef8({ emit, rows });
|
|
5311
5421
|
handlers.current = { emit, rows };
|
|
5312
|
-
|
|
5422
|
+
useEffect7(() => {
|
|
5313
5423
|
if (!el.current) return;
|
|
5314
5424
|
const c = echarts.init(el.current, theme, { renderer: "canvas" });
|
|
5315
5425
|
chart.current = c;
|
|
@@ -5348,7 +5458,7 @@ function EChart({
|
|
|
5348
5458
|
chart.current = null;
|
|
5349
5459
|
};
|
|
5350
5460
|
}, [theme, part]);
|
|
5351
|
-
|
|
5461
|
+
useEffect7(() => {
|
|
5352
5462
|
const c = chart.current;
|
|
5353
5463
|
if (!c) return;
|
|
5354
5464
|
const reduce = typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
@@ -5366,16 +5476,16 @@ function EChart({
|
|
|
5366
5476
|
}
|
|
5367
5477
|
c.setOption(merged, { notMerge: true, lazyUpdate: true });
|
|
5368
5478
|
}, [option, extra, hiddenSeries, theme, part]);
|
|
5369
|
-
|
|
5479
|
+
useEffect7(() => {
|
|
5370
5480
|
chart.current?.resize();
|
|
5371
5481
|
});
|
|
5372
|
-
|
|
5482
|
+
useEffect7(() => {
|
|
5373
5483
|
const c = chart.current;
|
|
5374
5484
|
if (!c) return;
|
|
5375
5485
|
if (highlightIndex === void 0 || highlightIndex < 0) c.dispatchAction({ type: "hideTip" });
|
|
5376
5486
|
else c.dispatchAction({ type: "showTip", seriesIndex: 0, dataIndex: highlightIndex });
|
|
5377
5487
|
}, [highlightIndex, theme, part]);
|
|
5378
|
-
return /* @__PURE__ */
|
|
5488
|
+
return /* @__PURE__ */ jsx24("div", { ref: el, role: "img", "aria-label": ariaLabel, style: { width: "100%", height: Math.max(80, height) } });
|
|
5379
5489
|
}
|
|
5380
5490
|
|
|
5381
5491
|
// src/widgets/shared/cartesian.ts
|
|
@@ -5454,6 +5564,20 @@ function cartesian(data, source, spec, type, h, colors) {
|
|
|
5454
5564
|
const colourByAvg = spec.colorBy === "average" && single && avg !== void 0 && full.length >= 3 && colors;
|
|
5455
5565
|
const showValues = spec.valueLabels === true || spec.valueLabels !== false && spec.valueLabels === "auto" && cats.length <= 7;
|
|
5456
5566
|
const out = [];
|
|
5567
|
+
const stackedTotals = type === "bar" && stack && !spec.normalized && !spec.range && series.length > 1;
|
|
5568
|
+
const lastSeries = series[series.length - 1];
|
|
5569
|
+
const totalAt = (i) => {
|
|
5570
|
+
let sum = 0;
|
|
5571
|
+
let any = false;
|
|
5572
|
+
for (const x of series) {
|
|
5573
|
+
const v = x.values[i];
|
|
5574
|
+
if (typeof v === "number") {
|
|
5575
|
+
sum += v;
|
|
5576
|
+
any = true;
|
|
5577
|
+
}
|
|
5578
|
+
}
|
|
5579
|
+
return any ? sum : null;
|
|
5580
|
+
};
|
|
5457
5581
|
for (const s of series) {
|
|
5458
5582
|
const styled = type === "bar" && single && colors ? s.values.map((v, i) => ({
|
|
5459
5583
|
value: v,
|
|
@@ -5474,14 +5598,17 @@ function cartesian(data, source, spec, type, h, colors) {
|
|
|
5474
5598
|
name: s.name,
|
|
5475
5599
|
type,
|
|
5476
5600
|
data: styled ?? s.values,
|
|
5477
|
-
...showValues ? {
|
|
5601
|
+
...showValues && (!stackedTotals || s === lastSeries) ? {
|
|
5478
5602
|
label: {
|
|
5479
5603
|
show: true,
|
|
5480
5604
|
position: spec.horizontal ? "right" : "top",
|
|
5481
5605
|
fontWeight: 600,
|
|
5482
5606
|
fontSize: 12,
|
|
5483
5607
|
...colors ? { color: colors.text } : {},
|
|
5484
|
-
formatter: (p) =>
|
|
5608
|
+
formatter: (p) => {
|
|
5609
|
+
const v = stackedTotals ? totalAt(p.dataIndex) : p.value;
|
|
5610
|
+
return v === null || v === void 0 ? "" : `${formatValue(v, h, spec.format, spec.decimals ?? 1)}${isPartial[p.dataIndex] ? " so far" : ""}`;
|
|
5611
|
+
}
|
|
5485
5612
|
}
|
|
5486
5613
|
} : {},
|
|
5487
5614
|
...stack ? { stack } : {},
|
|
@@ -5562,7 +5689,7 @@ function cartesian(data, source, spec, type, h, colors) {
|
|
|
5562
5689
|
}
|
|
5563
5690
|
|
|
5564
5691
|
// src/widgets/builtins/charts.tsx
|
|
5565
|
-
import { Fragment as Fragment7, jsx as
|
|
5692
|
+
import { Fragment as Fragment7, jsx as jsx25, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
5566
5693
|
var chartEvents = ["click", "doubleClick", "hover", "hoverEnd", "legendClick", "brush", "datazoom"];
|
|
5567
5694
|
var BarChart2 = defineWidget({
|
|
5568
5695
|
...BarChartContract,
|
|
@@ -5594,20 +5721,20 @@ var BarChart2 = defineWidget({
|
|
|
5594
5721
|
legend && /* @__PURE__ */ jsxs19("ul", { className: "ds-chart-legend", children: [
|
|
5595
5722
|
c.coloured && /* @__PURE__ */ jsxs19(Fragment7, { children: [
|
|
5596
5723
|
/* @__PURE__ */ jsxs19("li", { children: [
|
|
5597
|
-
/* @__PURE__ */
|
|
5724
|
+
/* @__PURE__ */ jsx25("span", { className: "ds-swatch", style: { background: colors?.good } }),
|
|
5598
5725
|
spec.legendLabels?.above ?? "At or above avg"
|
|
5599
5726
|
] }),
|
|
5600
5727
|
/* @__PURE__ */ jsxs19("li", { children: [
|
|
5601
|
-
/* @__PURE__ */
|
|
5728
|
+
/* @__PURE__ */ jsx25("span", { className: "ds-swatch", style: { background: colors?.bad } }),
|
|
5602
5729
|
spec.legendLabels?.below ?? "Below avg"
|
|
5603
5730
|
] })
|
|
5604
5731
|
] }),
|
|
5605
5732
|
avgText && /* @__PURE__ */ jsxs19("li", { children: [
|
|
5606
|
-
/* @__PURE__ */
|
|
5733
|
+
/* @__PURE__ */ jsx25("span", { className: "ds-swatch-line" }),
|
|
5607
5734
|
avgText
|
|
5608
5735
|
] })
|
|
5609
5736
|
] }),
|
|
5610
|
-
/* @__PURE__ */
|
|
5737
|
+
/* @__PURE__ */ jsx25(
|
|
5611
5738
|
EChart,
|
|
5612
5739
|
{
|
|
5613
5740
|
option: c.option,
|
|
@@ -5635,7 +5762,7 @@ var LineChart2 = defineWidget({
|
|
|
5635
5762
|
component: function LineChartWidget({ spec, data, source, emit, helpers, size: size2, state, highlight }) {
|
|
5636
5763
|
const c = useMemo6(() => cartesian(data, source, spec, "line", helpers), [data, source, spec, helpers]);
|
|
5637
5764
|
const hi = highlight === void 0 || highlight === null ? void 0 : c.categories.indexOf(String(highlight));
|
|
5638
|
-
return /* @__PURE__ */
|
|
5765
|
+
return /* @__PURE__ */ jsx25(
|
|
5639
5766
|
EChart,
|
|
5640
5767
|
{
|
|
5641
5768
|
option: c.option,
|
|
@@ -5684,7 +5811,7 @@ var PieChart2 = defineWidget({
|
|
|
5684
5811
|
}),
|
|
5685
5812
|
[rows, spec, helpers]
|
|
5686
5813
|
);
|
|
5687
|
-
return /* @__PURE__ */
|
|
5814
|
+
return /* @__PURE__ */ jsx25(
|
|
5688
5815
|
EChart,
|
|
5689
5816
|
{
|
|
5690
5817
|
option,
|
|
@@ -5729,7 +5856,7 @@ var Scatter = defineWidget({
|
|
|
5729
5856
|
}))
|
|
5730
5857
|
};
|
|
5731
5858
|
}, [rows, spec]);
|
|
5732
|
-
return /* @__PURE__ */
|
|
5859
|
+
return /* @__PURE__ */ jsx25(
|
|
5733
5860
|
EChart,
|
|
5734
5861
|
{
|
|
5735
5862
|
option,
|
|
@@ -5790,7 +5917,7 @@ var Gauge = defineWidget({
|
|
|
5790
5917
|
]
|
|
5791
5918
|
};
|
|
5792
5919
|
}, [value, spec, helpers, tokens]);
|
|
5793
|
-
return /* @__PURE__ */
|
|
5920
|
+
return /* @__PURE__ */ jsx25(
|
|
5794
5921
|
EChart,
|
|
5795
5922
|
{
|
|
5796
5923
|
option,
|
|
@@ -5849,7 +5976,7 @@ var MatrixChart = defineWidget({
|
|
|
5849
5976
|
}
|
|
5850
5977
|
};
|
|
5851
5978
|
}, [rows, spec, helpers]);
|
|
5852
|
-
return /* @__PURE__ */
|
|
5979
|
+
return /* @__PURE__ */ jsx25(
|
|
5853
5980
|
EChart,
|
|
5854
5981
|
{
|
|
5855
5982
|
option,
|
|
@@ -5870,7 +5997,7 @@ var MatrixChart = defineWidget({
|
|
|
5870
5997
|
// src/widgets/builtins/layout.tsx
|
|
5871
5998
|
import { Fragment as Fragment8 } from "react";
|
|
5872
5999
|
import "zod";
|
|
5873
|
-
import { jsx as
|
|
6000
|
+
import { jsx as jsx26, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
5874
6001
|
var Row = defineWidget({
|
|
5875
6002
|
...Container,
|
|
5876
6003
|
...RowContract,
|
|
@@ -5895,7 +6022,7 @@ var Card = defineWidget({
|
|
|
5895
6022
|
return renderSlot("body", {
|
|
5896
6023
|
className: "ds-card-body",
|
|
5897
6024
|
style: { display: "flex", flexDirection: spec.direction, gap: spec.gap, alignItems: align },
|
|
5898
|
-
empty: /* @__PURE__ */
|
|
6025
|
+
empty: /* @__PURE__ */ jsx26("span", { className: "ds-slot-hint", children: "Drop a label, a value, a badge\u2026" })
|
|
5899
6026
|
});
|
|
5900
6027
|
}
|
|
5901
6028
|
});
|
|
@@ -5908,7 +6035,7 @@ var Tabs = defineWidget({
|
|
|
5908
6035
|
component: function TabsWidget({ spec, state, setUi, emit, renderSlot }) {
|
|
5909
6036
|
const open = String(state.ui?.tab ?? spec.initial ?? spec.tabs[0]?.key);
|
|
5910
6037
|
return /* @__PURE__ */ jsxs20("div", { className: "ds-tabs", children: [
|
|
5911
|
-
/* @__PURE__ */
|
|
6038
|
+
/* @__PURE__ */ jsx26("div", { className: "ds-tabs-bar", role: "tablist", children: spec.tabs.map((t) => /* @__PURE__ */ jsx26(
|
|
5912
6039
|
"button",
|
|
5913
6040
|
{
|
|
5914
6041
|
type: "button",
|
|
@@ -5924,7 +6051,7 @@ var Tabs = defineWidget({
|
|
|
5924
6051
|
)) }),
|
|
5925
6052
|
renderSlot(open, {
|
|
5926
6053
|
className: "ds-tabs-panel",
|
|
5927
|
-
empty: /* @__PURE__ */
|
|
6054
|
+
empty: /* @__PURE__ */ jsx26("span", { className: "ds-slot-hint", children: "Drop widgets into this tab" })
|
|
5928
6055
|
})
|
|
5929
6056
|
] });
|
|
5930
6057
|
}
|
|
@@ -5943,14 +6070,14 @@ var Repeater = defineWidget({
|
|
|
5943
6070
|
gridTemplateColumns: `repeat(auto-fill, minmax(${spec.minItemWidth}px, 1fr))`
|
|
5944
6071
|
} : { display: "flex", flexDirection: "column", gap: spec.gap };
|
|
5945
6072
|
if (rows.length === 0)
|
|
5946
|
-
return mode === "edit" ? /* @__PURE__ */
|
|
6073
|
+
return mode === "edit" ? /* @__PURE__ */ jsx26("div", { className: "ds-repeater", children: renderSlot("item", {
|
|
5947
6074
|
item: {},
|
|
5948
6075
|
index: 0,
|
|
5949
|
-
empty: /* @__PURE__ */
|
|
5950
|
-
}) }) : /* @__PURE__ */
|
|
5951
|
-
return /* @__PURE__ */
|
|
6076
|
+
empty: /* @__PURE__ */ jsx26("span", { className: "ds-slot-hint", children: "Drop the item design here" })
|
|
6077
|
+
}) }) : /* @__PURE__ */ jsx26("div", { className: "ds-state", children: spec.emptyText });
|
|
6078
|
+
return /* @__PURE__ */ jsx26("div", { className: "ds-repeater", style, children: rows.map((row, i) => (
|
|
5952
6079
|
// biome-ignore lint/suspicious/noArrayIndexKey: rows have no guaranteed id
|
|
5953
|
-
/* @__PURE__ */
|
|
6080
|
+
/* @__PURE__ */ jsx26(Fragment8, { children: renderSlot("item", { item: row, index: i, className: "ds-repeater-item" }) }, i)
|
|
5954
6081
|
)) });
|
|
5955
6082
|
}
|
|
5956
6083
|
});
|
|
@@ -5990,9 +6117,9 @@ var builtInWidgets = [
|
|
|
5990
6117
|
];
|
|
5991
6118
|
|
|
5992
6119
|
// src/components/Grid.tsx
|
|
5993
|
-
import { useEffect as
|
|
6120
|
+
import { useEffect as useEffect8, useMemo as useMemo7, useRef as useRef9, useState as useState7 } from "react";
|
|
5994
6121
|
import { Responsive, WidthProvider } from "react-grid-layout";
|
|
5995
|
-
import { jsx as
|
|
6122
|
+
import { jsx as jsx27 } from "react/jsx-runtime";
|
|
5996
6123
|
var ResponsiveGrid = WidthProvider(Responsive);
|
|
5997
6124
|
var BREAKPOINT_MIN = { tv: 1800, desktop: 1100, tablet: 700, mobile: 0 };
|
|
5998
6125
|
function layoutsForView(layouts, view, columns) {
|
|
@@ -6049,7 +6176,7 @@ function Grid({
|
|
|
6049
6176
|
const bpRef = useRef9("desktop");
|
|
6050
6177
|
const [wrapEl, setWrapEl] = useState7(null);
|
|
6051
6178
|
const [measured, setMeasured] = useState7("desktop");
|
|
6052
|
-
|
|
6179
|
+
useEffect8(() => {
|
|
6053
6180
|
if (!wrapEl || typeof ResizeObserver === "undefined") return;
|
|
6054
6181
|
const ro = new ResizeObserver(([e]) => {
|
|
6055
6182
|
const w = e?.contentRect.width ?? 0;
|
|
@@ -6110,7 +6237,7 @@ function Grid({
|
|
|
6110
6237
|
fitObservers.current.set(panel, ro);
|
|
6111
6238
|
};
|
|
6112
6239
|
const fitObservers = useRef9(/* @__PURE__ */ new Map());
|
|
6113
|
-
|
|
6240
|
+
useEffect8(() => {
|
|
6114
6241
|
const observers = fitObservers.current;
|
|
6115
6242
|
return () => {
|
|
6116
6243
|
for (const ro of observers.values()) ro.disconnect();
|
|
@@ -6119,7 +6246,7 @@ function Grid({
|
|
|
6119
6246
|
const active = breakpoint ?? measured;
|
|
6120
6247
|
if (base.modes[active] === "flow") {
|
|
6121
6248
|
const hide = editable ? void 0 : hidden;
|
|
6122
|
-
return /* @__PURE__ */
|
|
6249
|
+
return /* @__PURE__ */ jsx27("div", { ref: setWrapEl, className: editable ? "ds-flow ds-flow-edit" : "ds-flow", style: { gap }, children: base.ordered.filter((o) => !hide?.has(o.panel)).map((o, i) => /* @__PURE__ */ jsx27(
|
|
6123
6250
|
"div",
|
|
6124
6251
|
{
|
|
6125
6252
|
className: "ds-flow-item",
|
|
@@ -6133,7 +6260,7 @@ function Grid({
|
|
|
6133
6260
|
o.panel
|
|
6134
6261
|
)) });
|
|
6135
6262
|
}
|
|
6136
|
-
return /* @__PURE__ */
|
|
6263
|
+
return /* @__PURE__ */ jsx27("div", { ref: setWrapEl, children: /* @__PURE__ */ jsx27(
|
|
6137
6264
|
ResponsiveGrid,
|
|
6138
6265
|
{
|
|
6139
6266
|
className: editable ? "ds-grid ds-grid-edit" : "ds-grid",
|
|
@@ -6171,17 +6298,17 @@ function Grid({
|
|
|
6171
6298
|
onLayoutChange?.(toItems(current), breakpoint ?? bpRef.current);
|
|
6172
6299
|
},
|
|
6173
6300
|
onResizeStop: (current) => editable && onLayoutChange?.(toItems(current), breakpoint ?? bpRef.current),
|
|
6174
|
-
children: panels.map((p, i) => /* @__PURE__ */
|
|
6301
|
+
children: panels.map((p, i) => /* @__PURE__ */ jsx27("div", { "data-fit": base.fit.has(p) && !editable ? "" : void 0, style: { ["--ds-i"]: i }, children: base.fit.has(p) && !editable ? (
|
|
6175
6302
|
// react-grid-layout replaces the ref of its own children, so the measuring ref sits one level down.
|
|
6176
|
-
/* @__PURE__ */
|
|
6303
|
+
/* @__PURE__ */ jsx27("div", { className: "ds-fit", ref: observeFit(p), children: children(p) })
|
|
6177
6304
|
) : children(p) }, p))
|
|
6178
6305
|
}
|
|
6179
6306
|
) });
|
|
6180
6307
|
}
|
|
6181
6308
|
|
|
6182
6309
|
// src/components/ModalHost.tsx
|
|
6183
|
-
import { useCallback as useCallback5, useEffect as
|
|
6184
|
-
import { jsx as
|
|
6310
|
+
import { useCallback as useCallback5, useEffect as useEffect9, useRef as useRef10 } from "react";
|
|
6311
|
+
import { jsx as jsx28, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
6185
6312
|
var WIDTH = { sm: "420px", md: "720px", lg: "1040px", xl: "1320px", full: "100%" };
|
|
6186
6313
|
var FOCUSABLE2 = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
6187
6314
|
function ModalHost() {
|
|
@@ -6207,7 +6334,7 @@ function ModalHost() {
|
|
|
6207
6334
|
Object.is
|
|
6208
6335
|
);
|
|
6209
6336
|
const latched = useRef10(/* @__PURE__ */ new Set());
|
|
6210
|
-
|
|
6337
|
+
useEffect9(() => {
|
|
6211
6338
|
const now = new Set(byExpression ? byExpression.split("\0") : []);
|
|
6212
6339
|
for (const id of [...latched.current])
|
|
6213
6340
|
if (!now.has(id)) {
|
|
@@ -6240,7 +6367,7 @@ function ModalHost() {
|
|
|
6240
6367
|
}, [openId, runtime, modals]);
|
|
6241
6368
|
const closeRef = useRef10(close);
|
|
6242
6369
|
closeRef.current = close;
|
|
6243
|
-
|
|
6370
|
+
useEffect9(() => {
|
|
6244
6371
|
if (!openId) return;
|
|
6245
6372
|
const prev = document.activeElement;
|
|
6246
6373
|
dialog.current?.focus();
|
|
@@ -6282,7 +6409,7 @@ function ModalHost() {
|
|
|
6282
6409
|
const m = modals[open.id];
|
|
6283
6410
|
if (!m) return null;
|
|
6284
6411
|
const grid = runtime.doc.spec.grid;
|
|
6285
|
-
return /* @__PURE__ */
|
|
6412
|
+
return /* @__PURE__ */ jsx28(
|
|
6286
6413
|
"div",
|
|
6287
6414
|
{
|
|
6288
6415
|
ref: scrim,
|
|
@@ -6301,10 +6428,10 @@ function ModalHost() {
|
|
|
6301
6428
|
style: { ["--ds-dialog-w"]: WIDTH[m.size ?? "md"] ?? WIDTH.md },
|
|
6302
6429
|
children: [
|
|
6303
6430
|
/* @__PURE__ */ jsxs21("div", { className: "ds-dialog-head", children: [
|
|
6304
|
-
/* @__PURE__ */
|
|
6305
|
-
/* @__PURE__ */
|
|
6431
|
+
/* @__PURE__ */ jsx28("h2", { children: open.title }),
|
|
6432
|
+
/* @__PURE__ */ jsx28("button", { type: "button", className: "ds-close", "aria-label": "Close", onClick: close, children: "\xD7" })
|
|
6306
6433
|
] }),
|
|
6307
|
-
/* @__PURE__ */
|
|
6434
|
+
/* @__PURE__ */ jsx28(
|
|
6308
6435
|
Grid,
|
|
6309
6436
|
{
|
|
6310
6437
|
layouts: [{ items: m.layout }],
|
|
@@ -6313,7 +6440,7 @@ function ModalHost() {
|
|
|
6313
6440
|
columns: grid.columns,
|
|
6314
6441
|
rowHeight: grid.rowHeight,
|
|
6315
6442
|
gap: grid.gap,
|
|
6316
|
-
children: (id) => /* @__PURE__ */
|
|
6443
|
+
children: (id) => /* @__PURE__ */ jsx28(PanelFrame, { id })
|
|
6317
6444
|
}
|
|
6318
6445
|
)
|
|
6319
6446
|
]
|
|
@@ -6325,7 +6452,7 @@ function ModalHost() {
|
|
|
6325
6452
|
|
|
6326
6453
|
// src/components/Provider.tsx
|
|
6327
6454
|
import { createContext as createContext4, useContext as useContext5, useRef as useRef11 } from "react";
|
|
6328
|
-
import { jsx as
|
|
6455
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
6329
6456
|
var SettingsContext = createContext4({});
|
|
6330
6457
|
function DashSpecProvider({ children, ...settings }) {
|
|
6331
6458
|
const outer = useContext5(SettingsContext);
|
|
@@ -6334,7 +6461,7 @@ function DashSpecProvider({ children, ...settings }) {
|
|
|
6334
6461
|
);
|
|
6335
6462
|
if (!last.current || last.current.outer !== outer || !shallowEqual2(last.current.settings, settings))
|
|
6336
6463
|
last.current = { outer, settings, value: mergeSettings(outer, settings) };
|
|
6337
|
-
return /* @__PURE__ */
|
|
6464
|
+
return /* @__PURE__ */ jsx29(SettingsContext.Provider, { value: last.current.value, children });
|
|
6338
6465
|
}
|
|
6339
6466
|
function shallowEqual2(a, b) {
|
|
6340
6467
|
const ka = Object.keys(a);
|
|
@@ -6372,9 +6499,9 @@ function pickTheme(name, themes, fallback) {
|
|
|
6372
6499
|
}
|
|
6373
6500
|
|
|
6374
6501
|
// src/components/Tour.tsx
|
|
6375
|
-
import { useCallback as useCallback6, useEffect as
|
|
6376
|
-
import { Fragment as Fragment9, jsx as
|
|
6377
|
-
var useClientLayoutEffect = typeof window === "undefined" ?
|
|
6502
|
+
import { useCallback as useCallback6, useEffect as useEffect10, useId as useId5, useLayoutEffect as useLayoutEffect3, useRef as useRef12, useState as useState8 } from "react";
|
|
6503
|
+
import { Fragment as Fragment9, jsx as jsx30, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
6504
|
+
var useClientLayoutEffect = typeof window === "undefined" ? useEffect10 : useLayoutEffect3;
|
|
6378
6505
|
function panelElement(root, id) {
|
|
6379
6506
|
if (!root || !id) return null;
|
|
6380
6507
|
for (const el of root.querySelectorAll("[data-panel]"))
|
|
@@ -6445,13 +6572,13 @@ function TourButton({ steps }) {
|
|
|
6445
6572
|
};
|
|
6446
6573
|
}, [step]);
|
|
6447
6574
|
const isOpen = at !== null;
|
|
6448
|
-
|
|
6575
|
+
useEffect10(() => {
|
|
6449
6576
|
if (isOpen) (next.current ?? dialog.current)?.focus();
|
|
6450
6577
|
}, [isOpen]);
|
|
6451
6578
|
if (steps.length === 0) return null;
|
|
6452
6579
|
const last = at === steps.length - 1;
|
|
6453
6580
|
return /* @__PURE__ */ jsxs22(Fragment9, { children: [
|
|
6454
|
-
/* @__PURE__ */
|
|
6581
|
+
/* @__PURE__ */ jsx30(
|
|
6455
6582
|
"button",
|
|
6456
6583
|
{
|
|
6457
6584
|
ref: button,
|
|
@@ -6482,19 +6609,19 @@ function TourButton({ steps }) {
|
|
|
6482
6609
|
},
|
|
6483
6610
|
children: [
|
|
6484
6611
|
/* @__PURE__ */ jsxs22("div", { className: "ds-tour-head", children: [
|
|
6485
|
-
text?.title && /* @__PURE__ */
|
|
6612
|
+
text?.title && /* @__PURE__ */ jsx30("h3", { className: "ds-tour-title", id: titleId, children: text.title }),
|
|
6486
6613
|
/* @__PURE__ */ jsxs22("span", { className: "ds-tour-count", children: [
|
|
6487
6614
|
at + 1,
|
|
6488
6615
|
" / ",
|
|
6489
6616
|
steps.length
|
|
6490
6617
|
] })
|
|
6491
6618
|
] }),
|
|
6492
|
-
/* @__PURE__ */
|
|
6619
|
+
/* @__PURE__ */ jsx30("p", { className: "ds-tour-text", id: textId, "aria-live": "polite", children: text?.text }),
|
|
6493
6620
|
/* @__PURE__ */ jsxs22("div", { className: "ds-tour-foot", children: [
|
|
6494
|
-
/* @__PURE__ */
|
|
6495
|
-
/* @__PURE__ */
|
|
6496
|
-
at > 0 && /* @__PURE__ */
|
|
6497
|
-
/* @__PURE__ */
|
|
6621
|
+
/* @__PURE__ */ jsx30("button", { type: "button", className: "ds-tour-skip", onClick: close, children: "Close" }),
|
|
6622
|
+
/* @__PURE__ */ jsx30("span", { className: "ds-filters-spacer" }),
|
|
6623
|
+
at > 0 && /* @__PURE__ */ jsx30("button", { type: "button", className: "ds-filter-reset", onClick: () => setAt(at - 1), children: "Back" }),
|
|
6624
|
+
/* @__PURE__ */ jsx30(
|
|
6498
6625
|
"button",
|
|
6499
6626
|
{
|
|
6500
6627
|
ref: next,
|
|
@@ -6512,7 +6639,7 @@ function TourButton({ steps }) {
|
|
|
6512
6639
|
}
|
|
6513
6640
|
|
|
6514
6641
|
// src/components/registryHooks.ts
|
|
6515
|
-
import { useCallback as useCallback7, useEffect as
|
|
6642
|
+
import { useCallback as useCallback7, useEffect as useEffect11, useRef as useRef13, useState as useState9, useSyncExternalStore as useSyncExternalStore3 } from "react";
|
|
6516
6643
|
var live = /* @__PURE__ */ new Map();
|
|
6517
6644
|
var listeners = /* @__PURE__ */ new Set();
|
|
6518
6645
|
var notify = () => {
|
|
@@ -6543,7 +6670,7 @@ function useDashboardState(id, select) {
|
|
|
6543
6670
|
const [value, setValue] = useState9(() => rt ? select(rt.getTree()) : void 0);
|
|
6544
6671
|
const sel = useRef13(select);
|
|
6545
6672
|
sel.current = select;
|
|
6546
|
-
|
|
6673
|
+
useEffect11(() => {
|
|
6547
6674
|
if (!rt) return setValue(void 0);
|
|
6548
6675
|
const update = () => setValue(() => sel.current(rt.getTree()));
|
|
6549
6676
|
update();
|
|
@@ -6715,6 +6842,23 @@ var RENDERER_CSS = `
|
|
|
6715
6842
|
.ds-table tbody tr { cursor: pointer; }
|
|
6716
6843
|
.ds-table tbody tr:hover, .ds-table tbody tr:focus-visible { background: var(--ds-color-surface-selection); outline: none; }
|
|
6717
6844
|
.ds-table tfoot td { font-weight: 600; border-top: 2px solid var(--ds-color-border-default); }
|
|
6845
|
+
/* Rich cells (sub line, chips), expandable rows and their detail. */
|
|
6846
|
+
.ds-cell { display: inline-flex; flex-direction: column; align-items: flex-start; gap: var(--ds-space-xxs); }
|
|
6847
|
+
.ds-table td[style*="right"] .ds-cell { align-items: flex-end; }
|
|
6848
|
+
.ds-cell-sub { color: var(--ds-color-text-secondary); font-size: var(--ds-type-caption-size); font-weight: 600; }
|
|
6849
|
+
.ds-chips { display: inline-flex; flex-wrap: wrap; gap: var(--ds-space-xxs); }
|
|
6850
|
+
.ds-table tr[aria-expanded] { cursor: pointer; }
|
|
6851
|
+
.ds-table tr[data-expanded] > td, .ds-row-detail > td { background: var(--ds-color-surface-sunken); }
|
|
6852
|
+
.ds-row-detail > td { padding: var(--ds-space-md); }
|
|
6853
|
+
/* Tiles: muted (dashed, greyed) and highlighted (accent border). */
|
|
6854
|
+
.ds-tile[data-muted] { border-style: dashed; color: var(--ds-color-text-disabled); background: transparent; }
|
|
6855
|
+
.ds-tile[data-muted] .ds-tile-label, .ds-tile[data-muted] .ds-tile-value, .ds-tile[data-muted] .ds-tile-caption { color: var(--ds-color-text-disabled); }
|
|
6856
|
+
.ds-tile[data-highlight] { border-width: 2px; }
|
|
6857
|
+
.ds-tile[data-highlight="warn"] { border-color: var(--ds-color-status-warn-border); }
|
|
6858
|
+
.ds-tile[data-highlight="bad"] { border-color: var(--ds-color-status-bad-border); }
|
|
6859
|
+
.ds-tile[data-highlight="good"] { border-color: var(--ds-color-status-good-border); }
|
|
6860
|
+
.ds-tile[data-highlight="info"] { border-color: var(--ds-color-status-info-border); }
|
|
6861
|
+
.ds-tile[data-highlight="neutral"] { border-color: var(--ds-color-status-neutral-border); }
|
|
6718
6862
|
.ds-cell-list { display: grid; gap: 2px; }
|
|
6719
6863
|
.ds-pager { display: flex; justify-content: flex-end; align-items: center; gap: var(--ds-space-sm); padding-top: var(--ds-space-xs); font-size: var(--ds-type-label-size); color: var(--ds-color-text-subtle); }
|
|
6720
6864
|
|
|
@@ -6728,7 +6872,10 @@ var RENDERER_CSS = `
|
|
|
6728
6872
|
.ds-live[data-stale] > span { background: var(--ds-color-status-warn-fg); }
|
|
6729
6873
|
.ds-info { position: relative; display: inline-flex; color: var(--ds-color-text-disabled); cursor: help; outline: none; background: none; border: 0; padding: 0; font: inherit; }
|
|
6730
6874
|
.ds-info:hover, .ds-info:focus-visible { color: var(--ds-color-text-subtle); }
|
|
6731
|
-
.ds-tip { position: fixed; z-index: var(--ds-z-tooltip); width: max-content; max-width: 320px; padding: var(--ds-space-sm) var(--ds-space-md); border-radius: var(--ds-radius-control); background: var(--ds-color-chart-tooltip-bg); color: var(--ds-color-chart-tooltip-text); font: 500 var(--ds-type-caption-size)/1.5 var(--ds-font-body); text-align: left; white-space: normal; pointer-events: none;
|
|
6875
|
+
.ds-tip { position: fixed; z-index: var(--ds-z-tooltip); width: max-content; max-width: 320px; padding: var(--ds-space-sm) var(--ds-space-md); border-radius: var(--ds-radius-control); background: var(--ds-color-chart-tooltip-bg); color: var(--ds-color-chart-tooltip-text); font: 500 var(--ds-type-caption-size)/1.5 var(--ds-font-body); text-align: left; white-space: normal; pointer-events: none; opacity: 0; transform: translateY(4px); transition: opacity 140ms ease, transform 140ms ease; }
|
|
6876
|
+
.ds-tip[data-below] { transform: translateY(-4px); }
|
|
6877
|
+
.ds-tip[data-open] { opacity: 1; transform: none; }
|
|
6878
|
+
@media (prefers-reduced-motion: reduce) { .ds-tip { transition: none; } }
|
|
6732
6879
|
.ds-tip::after { content: ""; position: absolute; left: var(--ds-tip-arrow); top: 100%; transform: translateX(-50%); border: 6px solid transparent; border-top-color: var(--ds-color-chart-tooltip-bg); }
|
|
6733
6880
|
.ds-tip[data-below]::after { top: auto; bottom: 100%; border-top-color: transparent; border-bottom-color: var(--ds-color-chart-tooltip-bg); }
|
|
6734
6881
|
|
|
@@ -7150,7 +7297,7 @@ function releaseDefaultPrefix(owner) {
|
|
|
7150
7297
|
}
|
|
7151
7298
|
|
|
7152
7299
|
// src/components/DashboardRenderer.tsx
|
|
7153
|
-
import { Fragment as Fragment10, jsx as
|
|
7300
|
+
import { Fragment as Fragment10, jsx as jsx31, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
7154
7301
|
function usesScripts(doc) {
|
|
7155
7302
|
const handler = (h) => {
|
|
7156
7303
|
if (typeof h === "string") return isCallbackSource(h);
|
|
@@ -7227,8 +7374,8 @@ function InvalidDocument({ problems }) {
|
|
|
7227
7374
|
errors.length,
|
|
7228
7375
|
" problem(s)."
|
|
7229
7376
|
] }),
|
|
7230
|
-
/* @__PURE__ */
|
|
7231
|
-
/* @__PURE__ */
|
|
7377
|
+
/* @__PURE__ */ jsx31("ul", { children: errors.slice(0, 20).map((p) => /* @__PURE__ */ jsxs23("li", { children: [
|
|
7378
|
+
/* @__PURE__ */ jsx31("code", { children: p.path || "(root)" }),
|
|
7232
7379
|
" ",
|
|
7233
7380
|
p.message
|
|
7234
7381
|
] }, `${p.path}-${p.message}`)) })
|
|
@@ -7277,7 +7424,7 @@ var DashboardRenderer = forwardRef(
|
|
|
7277
7424
|
const needsSandbox = loaded.status === "valid" && mode === "sandbox" && usesScripts(loaded.document);
|
|
7278
7425
|
const [sandbox, setSandbox] = useState10(null);
|
|
7279
7426
|
const [sandboxError, setSandboxError] = useState10(null);
|
|
7280
|
-
|
|
7427
|
+
useEffect12(() => {
|
|
7281
7428
|
if (!needsSandbox || sandbox) return;
|
|
7282
7429
|
let cancelled = false;
|
|
7283
7430
|
import("./sandbox-WEMG76LE.js").then((m) => m.createSandboxRunner()).then((r) => !cancelled && setSandbox(r)).catch((e) => !cancelled && setSandboxError(String(e?.message ?? e)));
|
|
@@ -7337,7 +7484,7 @@ var DashboardRenderer = forwardRef(
|
|
|
7337
7484
|
};
|
|
7338
7485
|
return createDashboardRuntime(doc, { ...options, autoStart: false });
|
|
7339
7486
|
}, [forRuntime, sandbox, needsSandbox, mode]);
|
|
7340
|
-
|
|
7487
|
+
useEffect12(() => {
|
|
7341
7488
|
if (!runtime || !useUrl) return;
|
|
7342
7489
|
const owner = urlOwner.current;
|
|
7343
7490
|
if (!props.id && !claimDefaultPrefix(owner)) {
|
|
@@ -7372,24 +7519,24 @@ var DashboardRenderer = forwardRef(
|
|
|
7372
7519
|
if (!props.id) releaseDefaultPrefix(owner);
|
|
7373
7520
|
};
|
|
7374
7521
|
}, [runtime, useUrl, prefix, props.id]);
|
|
7375
|
-
|
|
7522
|
+
useEffect12(() => {
|
|
7376
7523
|
runtime?.start();
|
|
7377
7524
|
return () => runtime?.stop();
|
|
7378
7525
|
}, [runtime]);
|
|
7379
|
-
|
|
7380
|
-
|
|
7526
|
+
useEffect12(() => runtime && props.id ? registerRuntime(props.id, runtime) : void 0, [runtime, props.id]);
|
|
7527
|
+
useEffect12(() => {
|
|
7381
7528
|
if (runtime) latest.current.onLoad?.();
|
|
7382
7529
|
}, [runtime]);
|
|
7383
7530
|
const variablesKey = props.variables ? JSON.stringify(props.variables) : "";
|
|
7384
7531
|
const stateKey = props.state ? JSON.stringify(props.state) : "";
|
|
7385
|
-
|
|
7532
|
+
useEffect12(() => {
|
|
7386
7533
|
const vars = latest.current.variables;
|
|
7387
7534
|
if (!runtime || !vars) return;
|
|
7388
7535
|
for (const [name, value] of Object.entries(vars))
|
|
7389
7536
|
if (!sameJson(runtime.getTree().filters[name], value))
|
|
7390
7537
|
runtime.store.dispatch(stateActions.setFilter({ name, value }));
|
|
7391
7538
|
}, [runtime, variablesKey]);
|
|
7392
|
-
|
|
7539
|
+
useEffect12(() => {
|
|
7393
7540
|
const st = latest.current.state;
|
|
7394
7541
|
if (!runtime || !st) return;
|
|
7395
7542
|
for (const [path, value] of Object.entries(st))
|
|
@@ -7399,7 +7546,7 @@ var DashboardRenderer = forwardRef(
|
|
|
7399
7546
|
const hostDataKey = props.data ? JSON.stringify(props.data) : "";
|
|
7400
7547
|
const contextKey = props.context ? JSON.stringify(props.context) : "";
|
|
7401
7548
|
const hostInputsSeen = useRef14(null);
|
|
7402
|
-
|
|
7549
|
+
useEffect12(() => {
|
|
7403
7550
|
if (!runtime) return;
|
|
7404
7551
|
const seen = hostInputsSeen.current;
|
|
7405
7552
|
hostInputsSeen.current = { runtime, data: hostDataKey, context: contextKey };
|
|
@@ -7407,12 +7554,12 @@ var DashboardRenderer = forwardRef(
|
|
|
7407
7554
|
if (seen.data !== hostDataKey) runtime.setHostData(latest.current.data);
|
|
7408
7555
|
if (seen.context !== contextKey) runtime.setContext(latest.current.context);
|
|
7409
7556
|
}, [runtime, hostDataKey, contextKey]);
|
|
7410
|
-
|
|
7557
|
+
useEffect12(() => {
|
|
7411
7558
|
if (!runtime) return;
|
|
7412
7559
|
if (props.view !== void 0 && props.view !== runtime.getTree().view)
|
|
7413
7560
|
runtime.store.dispatch(stateActions.setView(props.view));
|
|
7414
7561
|
}, [runtime, props.view]);
|
|
7415
|
-
|
|
7562
|
+
useEffect12(() => {
|
|
7416
7563
|
if (!runtime) return;
|
|
7417
7564
|
let prev = runtime.getTree();
|
|
7418
7565
|
return runtime.store.subscribe(() => {
|
|
@@ -7528,7 +7675,7 @@ var DashboardRenderer = forwardRef(
|
|
|
7528
7675
|
props.themes,
|
|
7529
7676
|
props.theme ?? ds.theme ?? DEFAULT_THEME
|
|
7530
7677
|
);
|
|
7531
|
-
|
|
7678
|
+
useEffect12(() => {
|
|
7532
7679
|
if (picked.unknown)
|
|
7533
7680
|
latest.current.onError?.({
|
|
7534
7681
|
code: "unknown-theme",
|
|
@@ -7537,16 +7684,16 @@ var DashboardRenderer = forwardRef(
|
|
|
7537
7684
|
}, [picked.unknown]);
|
|
7538
7685
|
let content;
|
|
7539
7686
|
if (loaded.status === "invalid")
|
|
7540
|
-
content = props.renderError?.({ code: "invalid", message: loaded.problems[0]?.message ?? "Invalid" }) ?? /* @__PURE__ */
|
|
7687
|
+
content = props.renderError?.({ code: "invalid", message: loaded.problems[0]?.message ?? "Invalid" }) ?? /* @__PURE__ */ jsx31(InvalidDocument, { problems: loaded.problems });
|
|
7541
7688
|
else if (sandboxError)
|
|
7542
7689
|
content = /* @__PURE__ */ jsxs23("div", { className: "ds-invalid", children: [
|
|
7543
7690
|
"Could not start the script sandbox: ",
|
|
7544
7691
|
sandboxError
|
|
7545
7692
|
] });
|
|
7546
7693
|
else if (!ctx)
|
|
7547
|
-
content = /* @__PURE__ */
|
|
7694
|
+
content = /* @__PURE__ */ jsx31("div", { className: "ds-skeleton", style: { height: 200 }, "aria-busy": "true", "aria-label": "Loading dashboard" });
|
|
7548
7695
|
else
|
|
7549
|
-
content = /* @__PURE__ */
|
|
7696
|
+
content = /* @__PURE__ */ jsx31(
|
|
7550
7697
|
DashboardBody,
|
|
7551
7698
|
{
|
|
7552
7699
|
doc: loaded.document,
|
|
@@ -7559,8 +7706,8 @@ var DashboardRenderer = forwardRef(
|
|
|
7559
7706
|
}
|
|
7560
7707
|
);
|
|
7561
7708
|
return /* @__PURE__ */ jsxs23(ThemeScope, { theme: picked.theme, mode: picked.mode, children: [
|
|
7562
|
-
/* @__PURE__ */
|
|
7563
|
-
/* @__PURE__ */
|
|
7709
|
+
/* @__PURE__ */ jsx31("style", { dangerouslySetInnerHTML: { __html: RENDERER_CSS } }),
|
|
7710
|
+
/* @__PURE__ */ jsx31(
|
|
7564
7711
|
Boundary,
|
|
7565
7712
|
{
|
|
7566
7713
|
resetKeys: [loaded, runtime],
|
|
@@ -7569,7 +7716,7 @@ var DashboardRenderer = forwardRef(
|
|
|
7569
7716
|
"This dashboard could not be shown: ",
|
|
7570
7717
|
e.message
|
|
7571
7718
|
] }),
|
|
7572
|
-
children: ctx ? /* @__PURE__ */
|
|
7719
|
+
children: ctx ? /* @__PURE__ */ jsx31(DashboardContext.Provider, { value: ctx, children: content }) : content
|
|
7573
7720
|
}
|
|
7574
7721
|
)
|
|
7575
7722
|
] });
|
|
@@ -7586,7 +7733,7 @@ function DashboardBody({
|
|
|
7586
7733
|
}) {
|
|
7587
7734
|
const { runtime, options } = useDashboard();
|
|
7588
7735
|
const tv = options.mode === "tv" ? doc.spec.display.tv : void 0;
|
|
7589
|
-
|
|
7736
|
+
useEffect12(() => {
|
|
7590
7737
|
const views = tv?.rotateViews ?? [];
|
|
7591
7738
|
if (views.length < 2) return;
|
|
7592
7739
|
const every = tv?.every ? parseDuration(tv.every) : 6e4;
|
|
@@ -7624,14 +7771,14 @@ function DashboardBody({
|
|
|
7624
7771
|
const hidden = useHiddenPanels(Object.keys(doc.spec.panels));
|
|
7625
7772
|
return /* @__PURE__ */ jsxs23(Fragment10, { children: [
|
|
7626
7773
|
!hideHeader && (head.title || head.synced || tour.length > 0) && /* @__PURE__ */ jsxs23("div", { className: "ds-header", children: [
|
|
7627
|
-
head.title && /* @__PURE__ */
|
|
7628
|
-
head.description && /* @__PURE__ */
|
|
7629
|
-
head.synced && /* @__PURE__ */
|
|
7630
|
-
tour.length > 0 && /* @__PURE__ */
|
|
7774
|
+
head.title && /* @__PURE__ */ jsx31("h2", { className: "ds-title", children: head.title }),
|
|
7775
|
+
head.description && /* @__PURE__ */ jsx31("p", { className: "ds-desc", children: head.description }),
|
|
7776
|
+
head.synced && /* @__PURE__ */ jsx31("span", { className: "ds-synced", children: head.synced }),
|
|
7777
|
+
tour.length > 0 && /* @__PURE__ */ jsx31(TourButton, { steps: tour })
|
|
7631
7778
|
] }),
|
|
7632
7779
|
!tv?.hideToolbar && // A control that throws (a design system's, a custom filter kind) costs the bar, not the dashboard.
|
|
7633
|
-
/* @__PURE__ */
|
|
7634
|
-
/* @__PURE__ */
|
|
7780
|
+
/* @__PURE__ */ jsx31(Boundary, { resetKeys: [doc], fallback: (e) => /* @__PURE__ */ jsx31(PartError, { what: "The filters", error: e }), children: /* @__PURE__ */ jsx31(FilterBar, {}) }),
|
|
7781
|
+
/* @__PURE__ */ jsx31(
|
|
7635
7782
|
Grid,
|
|
7636
7783
|
{
|
|
7637
7784
|
layouts: doc.spec.layouts,
|
|
@@ -7670,10 +7817,10 @@ function DashboardBody({
|
|
|
7670
7817
|
...breakpoint ? { breakpoint } : {},
|
|
7671
7818
|
...onLayoutChange ? { onLayoutChange: (items, bp) => onLayoutChange(items, bp, head.view) } : {},
|
|
7672
7819
|
...onDropWidget ? { onDrop: (at, bp) => onDropWidget(at, bp, head.view), dropSize } : {},
|
|
7673
|
-
children: (id) => /* @__PURE__ */
|
|
7820
|
+
children: (id) => /* @__PURE__ */ jsx31(PanelFrame, { id })
|
|
7674
7821
|
}
|
|
7675
7822
|
),
|
|
7676
|
-
/* @__PURE__ */
|
|
7823
|
+
/* @__PURE__ */ jsx31(Boundary, { resetKeys: [doc], fallback: (e) => /* @__PURE__ */ jsx31(PartError, { what: "The pop-up", error: e }), children: /* @__PURE__ */ jsx31(ModalHost, {}) })
|
|
7677
7824
|
] });
|
|
7678
7825
|
}
|
|
7679
7826
|
var NO_STEPS = [];
|
|
@@ -7688,7 +7835,7 @@ function PartError({ what, error }) {
|
|
|
7688
7835
|
// src/widgets/wrap.tsx
|
|
7689
7836
|
import { Suspense, lazy } from "react";
|
|
7690
7837
|
import { z as z17 } from "zod";
|
|
7691
|
-
import { jsx as
|
|
7838
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
7692
7839
|
function wrapComponent(Component2, o) {
|
|
7693
7840
|
const schema = o.schema ?? z17.record(z17.unknown());
|
|
7694
7841
|
const eventNames = [...new Set(Object.values(o.events ?? {}))];
|
|
@@ -7718,7 +7865,7 @@ function wrapComponent(Component2, o) {
|
|
|
7718
7865
|
}
|
|
7719
7866
|
const slotProps = {};
|
|
7720
7867
|
for (const [prop, slot] of Object.entries(o.slots ?? {})) slotProps[prop] = props.renderSlot(slot);
|
|
7721
|
-
return /* @__PURE__ */
|
|
7868
|
+
return /* @__PURE__ */ jsx32(Component2, { ...mapped, ...handlers, ...slotProps });
|
|
7722
7869
|
}
|
|
7723
7870
|
});
|
|
7724
7871
|
}
|
|
@@ -7729,7 +7876,7 @@ function lazyWidget(def) {
|
|
|
7729
7876
|
...rest,
|
|
7730
7877
|
component: function LazyWidget(props) {
|
|
7731
7878
|
Comp ??= lazy(load);
|
|
7732
|
-
return /* @__PURE__ */
|
|
7879
|
+
return /* @__PURE__ */ jsx32(Suspense, { fallback: fallback ?? /* @__PURE__ */ jsx32("div", { className: "ds-skeleton", "aria-busy": "true" }), children: /* @__PURE__ */ jsx32(Comp, { ...props }) });
|
|
7733
7880
|
}
|
|
7734
7881
|
});
|
|
7735
7882
|
}
|