@dashspec/renderer 0.1.8 → 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 +21 -1
- package/dist/{chunk-CLT55JEM.js → chunk-5EYC4E5K.js} +35 -3
- package/dist/{chunk-CLT55JEM.js.map → chunk-5EYC4E5K.js.map} +1 -1
- package/dist/{core-CKNOs-JN.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 +319 -189
- 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
|
|
@@ -5579,7 +5689,7 @@ function cartesian(data, source, spec, type, h, colors) {
|
|
|
5579
5689
|
}
|
|
5580
5690
|
|
|
5581
5691
|
// src/widgets/builtins/charts.tsx
|
|
5582
|
-
import { Fragment as Fragment7, jsx as
|
|
5692
|
+
import { Fragment as Fragment7, jsx as jsx25, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
5583
5693
|
var chartEvents = ["click", "doubleClick", "hover", "hoverEnd", "legendClick", "brush", "datazoom"];
|
|
5584
5694
|
var BarChart2 = defineWidget({
|
|
5585
5695
|
...BarChartContract,
|
|
@@ -5611,20 +5721,20 @@ var BarChart2 = defineWidget({
|
|
|
5611
5721
|
legend && /* @__PURE__ */ jsxs19("ul", { className: "ds-chart-legend", children: [
|
|
5612
5722
|
c.coloured && /* @__PURE__ */ jsxs19(Fragment7, { children: [
|
|
5613
5723
|
/* @__PURE__ */ jsxs19("li", { children: [
|
|
5614
|
-
/* @__PURE__ */
|
|
5724
|
+
/* @__PURE__ */ jsx25("span", { className: "ds-swatch", style: { background: colors?.good } }),
|
|
5615
5725
|
spec.legendLabels?.above ?? "At or above avg"
|
|
5616
5726
|
] }),
|
|
5617
5727
|
/* @__PURE__ */ jsxs19("li", { children: [
|
|
5618
|
-
/* @__PURE__ */
|
|
5728
|
+
/* @__PURE__ */ jsx25("span", { className: "ds-swatch", style: { background: colors?.bad } }),
|
|
5619
5729
|
spec.legendLabels?.below ?? "Below avg"
|
|
5620
5730
|
] })
|
|
5621
5731
|
] }),
|
|
5622
5732
|
avgText && /* @__PURE__ */ jsxs19("li", { children: [
|
|
5623
|
-
/* @__PURE__ */
|
|
5733
|
+
/* @__PURE__ */ jsx25("span", { className: "ds-swatch-line" }),
|
|
5624
5734
|
avgText
|
|
5625
5735
|
] })
|
|
5626
5736
|
] }),
|
|
5627
|
-
/* @__PURE__ */
|
|
5737
|
+
/* @__PURE__ */ jsx25(
|
|
5628
5738
|
EChart,
|
|
5629
5739
|
{
|
|
5630
5740
|
option: c.option,
|
|
@@ -5652,7 +5762,7 @@ var LineChart2 = defineWidget({
|
|
|
5652
5762
|
component: function LineChartWidget({ spec, data, source, emit, helpers, size: size2, state, highlight }) {
|
|
5653
5763
|
const c = useMemo6(() => cartesian(data, source, spec, "line", helpers), [data, source, spec, helpers]);
|
|
5654
5764
|
const hi = highlight === void 0 || highlight === null ? void 0 : c.categories.indexOf(String(highlight));
|
|
5655
|
-
return /* @__PURE__ */
|
|
5765
|
+
return /* @__PURE__ */ jsx25(
|
|
5656
5766
|
EChart,
|
|
5657
5767
|
{
|
|
5658
5768
|
option: c.option,
|
|
@@ -5701,7 +5811,7 @@ var PieChart2 = defineWidget({
|
|
|
5701
5811
|
}),
|
|
5702
5812
|
[rows, spec, helpers]
|
|
5703
5813
|
);
|
|
5704
|
-
return /* @__PURE__ */
|
|
5814
|
+
return /* @__PURE__ */ jsx25(
|
|
5705
5815
|
EChart,
|
|
5706
5816
|
{
|
|
5707
5817
|
option,
|
|
@@ -5746,7 +5856,7 @@ var Scatter = defineWidget({
|
|
|
5746
5856
|
}))
|
|
5747
5857
|
};
|
|
5748
5858
|
}, [rows, spec]);
|
|
5749
|
-
return /* @__PURE__ */
|
|
5859
|
+
return /* @__PURE__ */ jsx25(
|
|
5750
5860
|
EChart,
|
|
5751
5861
|
{
|
|
5752
5862
|
option,
|
|
@@ -5807,7 +5917,7 @@ var Gauge = defineWidget({
|
|
|
5807
5917
|
]
|
|
5808
5918
|
};
|
|
5809
5919
|
}, [value, spec, helpers, tokens]);
|
|
5810
|
-
return /* @__PURE__ */
|
|
5920
|
+
return /* @__PURE__ */ jsx25(
|
|
5811
5921
|
EChart,
|
|
5812
5922
|
{
|
|
5813
5923
|
option,
|
|
@@ -5866,7 +5976,7 @@ var MatrixChart = defineWidget({
|
|
|
5866
5976
|
}
|
|
5867
5977
|
};
|
|
5868
5978
|
}, [rows, spec, helpers]);
|
|
5869
|
-
return /* @__PURE__ */
|
|
5979
|
+
return /* @__PURE__ */ jsx25(
|
|
5870
5980
|
EChart,
|
|
5871
5981
|
{
|
|
5872
5982
|
option,
|
|
@@ -5887,7 +5997,7 @@ var MatrixChart = defineWidget({
|
|
|
5887
5997
|
// src/widgets/builtins/layout.tsx
|
|
5888
5998
|
import { Fragment as Fragment8 } from "react";
|
|
5889
5999
|
import "zod";
|
|
5890
|
-
import { jsx as
|
|
6000
|
+
import { jsx as jsx26, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
5891
6001
|
var Row = defineWidget({
|
|
5892
6002
|
...Container,
|
|
5893
6003
|
...RowContract,
|
|
@@ -5912,7 +6022,7 @@ var Card = defineWidget({
|
|
|
5912
6022
|
return renderSlot("body", {
|
|
5913
6023
|
className: "ds-card-body",
|
|
5914
6024
|
style: { display: "flex", flexDirection: spec.direction, gap: spec.gap, alignItems: align },
|
|
5915
|
-
empty: /* @__PURE__ */
|
|
6025
|
+
empty: /* @__PURE__ */ jsx26("span", { className: "ds-slot-hint", children: "Drop a label, a value, a badge\u2026" })
|
|
5916
6026
|
});
|
|
5917
6027
|
}
|
|
5918
6028
|
});
|
|
@@ -5925,7 +6035,7 @@ var Tabs = defineWidget({
|
|
|
5925
6035
|
component: function TabsWidget({ spec, state, setUi, emit, renderSlot }) {
|
|
5926
6036
|
const open = String(state.ui?.tab ?? spec.initial ?? spec.tabs[0]?.key);
|
|
5927
6037
|
return /* @__PURE__ */ jsxs20("div", { className: "ds-tabs", children: [
|
|
5928
|
-
/* @__PURE__ */
|
|
6038
|
+
/* @__PURE__ */ jsx26("div", { className: "ds-tabs-bar", role: "tablist", children: spec.tabs.map((t) => /* @__PURE__ */ jsx26(
|
|
5929
6039
|
"button",
|
|
5930
6040
|
{
|
|
5931
6041
|
type: "button",
|
|
@@ -5941,7 +6051,7 @@ var Tabs = defineWidget({
|
|
|
5941
6051
|
)) }),
|
|
5942
6052
|
renderSlot(open, {
|
|
5943
6053
|
className: "ds-tabs-panel",
|
|
5944
|
-
empty: /* @__PURE__ */
|
|
6054
|
+
empty: /* @__PURE__ */ jsx26("span", { className: "ds-slot-hint", children: "Drop widgets into this tab" })
|
|
5945
6055
|
})
|
|
5946
6056
|
] });
|
|
5947
6057
|
}
|
|
@@ -5960,14 +6070,14 @@ var Repeater = defineWidget({
|
|
|
5960
6070
|
gridTemplateColumns: `repeat(auto-fill, minmax(${spec.minItemWidth}px, 1fr))`
|
|
5961
6071
|
} : { display: "flex", flexDirection: "column", gap: spec.gap };
|
|
5962
6072
|
if (rows.length === 0)
|
|
5963
|
-
return mode === "edit" ? /* @__PURE__ */
|
|
6073
|
+
return mode === "edit" ? /* @__PURE__ */ jsx26("div", { className: "ds-repeater", children: renderSlot("item", {
|
|
5964
6074
|
item: {},
|
|
5965
6075
|
index: 0,
|
|
5966
|
-
empty: /* @__PURE__ */
|
|
5967
|
-
}) }) : /* @__PURE__ */
|
|
5968
|
-
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) => (
|
|
5969
6079
|
// biome-ignore lint/suspicious/noArrayIndexKey: rows have no guaranteed id
|
|
5970
|
-
/* @__PURE__ */
|
|
6080
|
+
/* @__PURE__ */ jsx26(Fragment8, { children: renderSlot("item", { item: row, index: i, className: "ds-repeater-item" }) }, i)
|
|
5971
6081
|
)) });
|
|
5972
6082
|
}
|
|
5973
6083
|
});
|
|
@@ -6007,9 +6117,9 @@ var builtInWidgets = [
|
|
|
6007
6117
|
];
|
|
6008
6118
|
|
|
6009
6119
|
// src/components/Grid.tsx
|
|
6010
|
-
import { useEffect as
|
|
6120
|
+
import { useEffect as useEffect8, useMemo as useMemo7, useRef as useRef9, useState as useState7 } from "react";
|
|
6011
6121
|
import { Responsive, WidthProvider } from "react-grid-layout";
|
|
6012
|
-
import { jsx as
|
|
6122
|
+
import { jsx as jsx27 } from "react/jsx-runtime";
|
|
6013
6123
|
var ResponsiveGrid = WidthProvider(Responsive);
|
|
6014
6124
|
var BREAKPOINT_MIN = { tv: 1800, desktop: 1100, tablet: 700, mobile: 0 };
|
|
6015
6125
|
function layoutsForView(layouts, view, columns) {
|
|
@@ -6066,7 +6176,7 @@ function Grid({
|
|
|
6066
6176
|
const bpRef = useRef9("desktop");
|
|
6067
6177
|
const [wrapEl, setWrapEl] = useState7(null);
|
|
6068
6178
|
const [measured, setMeasured] = useState7("desktop");
|
|
6069
|
-
|
|
6179
|
+
useEffect8(() => {
|
|
6070
6180
|
if (!wrapEl || typeof ResizeObserver === "undefined") return;
|
|
6071
6181
|
const ro = new ResizeObserver(([e]) => {
|
|
6072
6182
|
const w = e?.contentRect.width ?? 0;
|
|
@@ -6127,7 +6237,7 @@ function Grid({
|
|
|
6127
6237
|
fitObservers.current.set(panel, ro);
|
|
6128
6238
|
};
|
|
6129
6239
|
const fitObservers = useRef9(/* @__PURE__ */ new Map());
|
|
6130
|
-
|
|
6240
|
+
useEffect8(() => {
|
|
6131
6241
|
const observers = fitObservers.current;
|
|
6132
6242
|
return () => {
|
|
6133
6243
|
for (const ro of observers.values()) ro.disconnect();
|
|
@@ -6136,7 +6246,7 @@ function Grid({
|
|
|
6136
6246
|
const active = breakpoint ?? measured;
|
|
6137
6247
|
if (base.modes[active] === "flow") {
|
|
6138
6248
|
const hide = editable ? void 0 : hidden;
|
|
6139
|
-
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(
|
|
6140
6250
|
"div",
|
|
6141
6251
|
{
|
|
6142
6252
|
className: "ds-flow-item",
|
|
@@ -6150,7 +6260,7 @@ function Grid({
|
|
|
6150
6260
|
o.panel
|
|
6151
6261
|
)) });
|
|
6152
6262
|
}
|
|
6153
|
-
return /* @__PURE__ */
|
|
6263
|
+
return /* @__PURE__ */ jsx27("div", { ref: setWrapEl, children: /* @__PURE__ */ jsx27(
|
|
6154
6264
|
ResponsiveGrid,
|
|
6155
6265
|
{
|
|
6156
6266
|
className: editable ? "ds-grid ds-grid-edit" : "ds-grid",
|
|
@@ -6188,17 +6298,17 @@ function Grid({
|
|
|
6188
6298
|
onLayoutChange?.(toItems(current), breakpoint ?? bpRef.current);
|
|
6189
6299
|
},
|
|
6190
6300
|
onResizeStop: (current) => editable && onLayoutChange?.(toItems(current), breakpoint ?? bpRef.current),
|
|
6191
|
-
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 ? (
|
|
6192
6302
|
// react-grid-layout replaces the ref of its own children, so the measuring ref sits one level down.
|
|
6193
|
-
/* @__PURE__ */
|
|
6303
|
+
/* @__PURE__ */ jsx27("div", { className: "ds-fit", ref: observeFit(p), children: children(p) })
|
|
6194
6304
|
) : children(p) }, p))
|
|
6195
6305
|
}
|
|
6196
6306
|
) });
|
|
6197
6307
|
}
|
|
6198
6308
|
|
|
6199
6309
|
// src/components/ModalHost.tsx
|
|
6200
|
-
import { useCallback as useCallback5, useEffect as
|
|
6201
|
-
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";
|
|
6202
6312
|
var WIDTH = { sm: "420px", md: "720px", lg: "1040px", xl: "1320px", full: "100%" };
|
|
6203
6313
|
var FOCUSABLE2 = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
6204
6314
|
function ModalHost() {
|
|
@@ -6224,7 +6334,7 @@ function ModalHost() {
|
|
|
6224
6334
|
Object.is
|
|
6225
6335
|
);
|
|
6226
6336
|
const latched = useRef10(/* @__PURE__ */ new Set());
|
|
6227
|
-
|
|
6337
|
+
useEffect9(() => {
|
|
6228
6338
|
const now = new Set(byExpression ? byExpression.split("\0") : []);
|
|
6229
6339
|
for (const id of [...latched.current])
|
|
6230
6340
|
if (!now.has(id)) {
|
|
@@ -6257,7 +6367,7 @@ function ModalHost() {
|
|
|
6257
6367
|
}, [openId, runtime, modals]);
|
|
6258
6368
|
const closeRef = useRef10(close);
|
|
6259
6369
|
closeRef.current = close;
|
|
6260
|
-
|
|
6370
|
+
useEffect9(() => {
|
|
6261
6371
|
if (!openId) return;
|
|
6262
6372
|
const prev = document.activeElement;
|
|
6263
6373
|
dialog.current?.focus();
|
|
@@ -6299,7 +6409,7 @@ function ModalHost() {
|
|
|
6299
6409
|
const m = modals[open.id];
|
|
6300
6410
|
if (!m) return null;
|
|
6301
6411
|
const grid = runtime.doc.spec.grid;
|
|
6302
|
-
return /* @__PURE__ */
|
|
6412
|
+
return /* @__PURE__ */ jsx28(
|
|
6303
6413
|
"div",
|
|
6304
6414
|
{
|
|
6305
6415
|
ref: scrim,
|
|
@@ -6318,10 +6428,10 @@ function ModalHost() {
|
|
|
6318
6428
|
style: { ["--ds-dialog-w"]: WIDTH[m.size ?? "md"] ?? WIDTH.md },
|
|
6319
6429
|
children: [
|
|
6320
6430
|
/* @__PURE__ */ jsxs21("div", { className: "ds-dialog-head", children: [
|
|
6321
|
-
/* @__PURE__ */
|
|
6322
|
-
/* @__PURE__ */
|
|
6431
|
+
/* @__PURE__ */ jsx28("h2", { children: open.title }),
|
|
6432
|
+
/* @__PURE__ */ jsx28("button", { type: "button", className: "ds-close", "aria-label": "Close", onClick: close, children: "\xD7" })
|
|
6323
6433
|
] }),
|
|
6324
|
-
/* @__PURE__ */
|
|
6434
|
+
/* @__PURE__ */ jsx28(
|
|
6325
6435
|
Grid,
|
|
6326
6436
|
{
|
|
6327
6437
|
layouts: [{ items: m.layout }],
|
|
@@ -6330,7 +6440,7 @@ function ModalHost() {
|
|
|
6330
6440
|
columns: grid.columns,
|
|
6331
6441
|
rowHeight: grid.rowHeight,
|
|
6332
6442
|
gap: grid.gap,
|
|
6333
|
-
children: (id) => /* @__PURE__ */
|
|
6443
|
+
children: (id) => /* @__PURE__ */ jsx28(PanelFrame, { id })
|
|
6334
6444
|
}
|
|
6335
6445
|
)
|
|
6336
6446
|
]
|
|
@@ -6342,7 +6452,7 @@ function ModalHost() {
|
|
|
6342
6452
|
|
|
6343
6453
|
// src/components/Provider.tsx
|
|
6344
6454
|
import { createContext as createContext4, useContext as useContext5, useRef as useRef11 } from "react";
|
|
6345
|
-
import { jsx as
|
|
6455
|
+
import { jsx as jsx29 } from "react/jsx-runtime";
|
|
6346
6456
|
var SettingsContext = createContext4({});
|
|
6347
6457
|
function DashSpecProvider({ children, ...settings }) {
|
|
6348
6458
|
const outer = useContext5(SettingsContext);
|
|
@@ -6351,7 +6461,7 @@ function DashSpecProvider({ children, ...settings }) {
|
|
|
6351
6461
|
);
|
|
6352
6462
|
if (!last.current || last.current.outer !== outer || !shallowEqual2(last.current.settings, settings))
|
|
6353
6463
|
last.current = { outer, settings, value: mergeSettings(outer, settings) };
|
|
6354
|
-
return /* @__PURE__ */
|
|
6464
|
+
return /* @__PURE__ */ jsx29(SettingsContext.Provider, { value: last.current.value, children });
|
|
6355
6465
|
}
|
|
6356
6466
|
function shallowEqual2(a, b) {
|
|
6357
6467
|
const ka = Object.keys(a);
|
|
@@ -6389,9 +6499,9 @@ function pickTheme(name, themes, fallback) {
|
|
|
6389
6499
|
}
|
|
6390
6500
|
|
|
6391
6501
|
// src/components/Tour.tsx
|
|
6392
|
-
import { useCallback as useCallback6, useEffect as
|
|
6393
|
-
import { Fragment as Fragment9, jsx as
|
|
6394
|
-
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;
|
|
6395
6505
|
function panelElement(root, id) {
|
|
6396
6506
|
if (!root || !id) return null;
|
|
6397
6507
|
for (const el of root.querySelectorAll("[data-panel]"))
|
|
@@ -6462,13 +6572,13 @@ function TourButton({ steps }) {
|
|
|
6462
6572
|
};
|
|
6463
6573
|
}, [step]);
|
|
6464
6574
|
const isOpen = at !== null;
|
|
6465
|
-
|
|
6575
|
+
useEffect10(() => {
|
|
6466
6576
|
if (isOpen) (next.current ?? dialog.current)?.focus();
|
|
6467
6577
|
}, [isOpen]);
|
|
6468
6578
|
if (steps.length === 0) return null;
|
|
6469
6579
|
const last = at === steps.length - 1;
|
|
6470
6580
|
return /* @__PURE__ */ jsxs22(Fragment9, { children: [
|
|
6471
|
-
/* @__PURE__ */
|
|
6581
|
+
/* @__PURE__ */ jsx30(
|
|
6472
6582
|
"button",
|
|
6473
6583
|
{
|
|
6474
6584
|
ref: button,
|
|
@@ -6499,19 +6609,19 @@ function TourButton({ steps }) {
|
|
|
6499
6609
|
},
|
|
6500
6610
|
children: [
|
|
6501
6611
|
/* @__PURE__ */ jsxs22("div", { className: "ds-tour-head", children: [
|
|
6502
|
-
text?.title && /* @__PURE__ */
|
|
6612
|
+
text?.title && /* @__PURE__ */ jsx30("h3", { className: "ds-tour-title", id: titleId, children: text.title }),
|
|
6503
6613
|
/* @__PURE__ */ jsxs22("span", { className: "ds-tour-count", children: [
|
|
6504
6614
|
at + 1,
|
|
6505
6615
|
" / ",
|
|
6506
6616
|
steps.length
|
|
6507
6617
|
] })
|
|
6508
6618
|
] }),
|
|
6509
|
-
/* @__PURE__ */
|
|
6619
|
+
/* @__PURE__ */ jsx30("p", { className: "ds-tour-text", id: textId, "aria-live": "polite", children: text?.text }),
|
|
6510
6620
|
/* @__PURE__ */ jsxs22("div", { className: "ds-tour-foot", children: [
|
|
6511
|
-
/* @__PURE__ */
|
|
6512
|
-
/* @__PURE__ */
|
|
6513
|
-
at > 0 && /* @__PURE__ */
|
|
6514
|
-
/* @__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(
|
|
6515
6625
|
"button",
|
|
6516
6626
|
{
|
|
6517
6627
|
ref: next,
|
|
@@ -6529,7 +6639,7 @@ function TourButton({ steps }) {
|
|
|
6529
6639
|
}
|
|
6530
6640
|
|
|
6531
6641
|
// src/components/registryHooks.ts
|
|
6532
|
-
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";
|
|
6533
6643
|
var live = /* @__PURE__ */ new Map();
|
|
6534
6644
|
var listeners = /* @__PURE__ */ new Set();
|
|
6535
6645
|
var notify = () => {
|
|
@@ -6560,7 +6670,7 @@ function useDashboardState(id, select) {
|
|
|
6560
6670
|
const [value, setValue] = useState9(() => rt ? select(rt.getTree()) : void 0);
|
|
6561
6671
|
const sel = useRef13(select);
|
|
6562
6672
|
sel.current = select;
|
|
6563
|
-
|
|
6673
|
+
useEffect11(() => {
|
|
6564
6674
|
if (!rt) return setValue(void 0);
|
|
6565
6675
|
const update = () => setValue(() => sel.current(rt.getTree()));
|
|
6566
6676
|
update();
|
|
@@ -6732,6 +6842,23 @@ var RENDERER_CSS = `
|
|
|
6732
6842
|
.ds-table tbody tr { cursor: pointer; }
|
|
6733
6843
|
.ds-table tbody tr:hover, .ds-table tbody tr:focus-visible { background: var(--ds-color-surface-selection); outline: none; }
|
|
6734
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); }
|
|
6735
6862
|
.ds-cell-list { display: grid; gap: 2px; }
|
|
6736
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); }
|
|
6737
6864
|
|
|
@@ -6745,7 +6872,10 @@ var RENDERER_CSS = `
|
|
|
6745
6872
|
.ds-live[data-stale] > span { background: var(--ds-color-status-warn-fg); }
|
|
6746
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; }
|
|
6747
6874
|
.ds-info:hover, .ds-info:focus-visible { color: var(--ds-color-text-subtle); }
|
|
6748
|
-
.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; } }
|
|
6749
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); }
|
|
6750
6880
|
.ds-tip[data-below]::after { top: auto; bottom: 100%; border-top-color: transparent; border-bottom-color: var(--ds-color-chart-tooltip-bg); }
|
|
6751
6881
|
|
|
@@ -7167,7 +7297,7 @@ function releaseDefaultPrefix(owner) {
|
|
|
7167
7297
|
}
|
|
7168
7298
|
|
|
7169
7299
|
// src/components/DashboardRenderer.tsx
|
|
7170
|
-
import { Fragment as Fragment10, jsx as
|
|
7300
|
+
import { Fragment as Fragment10, jsx as jsx31, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
7171
7301
|
function usesScripts(doc) {
|
|
7172
7302
|
const handler = (h) => {
|
|
7173
7303
|
if (typeof h === "string") return isCallbackSource(h);
|
|
@@ -7244,8 +7374,8 @@ function InvalidDocument({ problems }) {
|
|
|
7244
7374
|
errors.length,
|
|
7245
7375
|
" problem(s)."
|
|
7246
7376
|
] }),
|
|
7247
|
-
/* @__PURE__ */
|
|
7248
|
-
/* @__PURE__ */
|
|
7377
|
+
/* @__PURE__ */ jsx31("ul", { children: errors.slice(0, 20).map((p) => /* @__PURE__ */ jsxs23("li", { children: [
|
|
7378
|
+
/* @__PURE__ */ jsx31("code", { children: p.path || "(root)" }),
|
|
7249
7379
|
" ",
|
|
7250
7380
|
p.message
|
|
7251
7381
|
] }, `${p.path}-${p.message}`)) })
|
|
@@ -7294,7 +7424,7 @@ var DashboardRenderer = forwardRef(
|
|
|
7294
7424
|
const needsSandbox = loaded.status === "valid" && mode === "sandbox" && usesScripts(loaded.document);
|
|
7295
7425
|
const [sandbox, setSandbox] = useState10(null);
|
|
7296
7426
|
const [sandboxError, setSandboxError] = useState10(null);
|
|
7297
|
-
|
|
7427
|
+
useEffect12(() => {
|
|
7298
7428
|
if (!needsSandbox || sandbox) return;
|
|
7299
7429
|
let cancelled = false;
|
|
7300
7430
|
import("./sandbox-WEMG76LE.js").then((m) => m.createSandboxRunner()).then((r) => !cancelled && setSandbox(r)).catch((e) => !cancelled && setSandboxError(String(e?.message ?? e)));
|
|
@@ -7354,7 +7484,7 @@ var DashboardRenderer = forwardRef(
|
|
|
7354
7484
|
};
|
|
7355
7485
|
return createDashboardRuntime(doc, { ...options, autoStart: false });
|
|
7356
7486
|
}, [forRuntime, sandbox, needsSandbox, mode]);
|
|
7357
|
-
|
|
7487
|
+
useEffect12(() => {
|
|
7358
7488
|
if (!runtime || !useUrl) return;
|
|
7359
7489
|
const owner = urlOwner.current;
|
|
7360
7490
|
if (!props.id && !claimDefaultPrefix(owner)) {
|
|
@@ -7389,24 +7519,24 @@ var DashboardRenderer = forwardRef(
|
|
|
7389
7519
|
if (!props.id) releaseDefaultPrefix(owner);
|
|
7390
7520
|
};
|
|
7391
7521
|
}, [runtime, useUrl, prefix, props.id]);
|
|
7392
|
-
|
|
7522
|
+
useEffect12(() => {
|
|
7393
7523
|
runtime?.start();
|
|
7394
7524
|
return () => runtime?.stop();
|
|
7395
7525
|
}, [runtime]);
|
|
7396
|
-
|
|
7397
|
-
|
|
7526
|
+
useEffect12(() => runtime && props.id ? registerRuntime(props.id, runtime) : void 0, [runtime, props.id]);
|
|
7527
|
+
useEffect12(() => {
|
|
7398
7528
|
if (runtime) latest.current.onLoad?.();
|
|
7399
7529
|
}, [runtime]);
|
|
7400
7530
|
const variablesKey = props.variables ? JSON.stringify(props.variables) : "";
|
|
7401
7531
|
const stateKey = props.state ? JSON.stringify(props.state) : "";
|
|
7402
|
-
|
|
7532
|
+
useEffect12(() => {
|
|
7403
7533
|
const vars = latest.current.variables;
|
|
7404
7534
|
if (!runtime || !vars) return;
|
|
7405
7535
|
for (const [name, value] of Object.entries(vars))
|
|
7406
7536
|
if (!sameJson(runtime.getTree().filters[name], value))
|
|
7407
7537
|
runtime.store.dispatch(stateActions.setFilter({ name, value }));
|
|
7408
7538
|
}, [runtime, variablesKey]);
|
|
7409
|
-
|
|
7539
|
+
useEffect12(() => {
|
|
7410
7540
|
const st = latest.current.state;
|
|
7411
7541
|
if (!runtime || !st) return;
|
|
7412
7542
|
for (const [path, value] of Object.entries(st))
|
|
@@ -7416,7 +7546,7 @@ var DashboardRenderer = forwardRef(
|
|
|
7416
7546
|
const hostDataKey = props.data ? JSON.stringify(props.data) : "";
|
|
7417
7547
|
const contextKey = props.context ? JSON.stringify(props.context) : "";
|
|
7418
7548
|
const hostInputsSeen = useRef14(null);
|
|
7419
|
-
|
|
7549
|
+
useEffect12(() => {
|
|
7420
7550
|
if (!runtime) return;
|
|
7421
7551
|
const seen = hostInputsSeen.current;
|
|
7422
7552
|
hostInputsSeen.current = { runtime, data: hostDataKey, context: contextKey };
|
|
@@ -7424,12 +7554,12 @@ var DashboardRenderer = forwardRef(
|
|
|
7424
7554
|
if (seen.data !== hostDataKey) runtime.setHostData(latest.current.data);
|
|
7425
7555
|
if (seen.context !== contextKey) runtime.setContext(latest.current.context);
|
|
7426
7556
|
}, [runtime, hostDataKey, contextKey]);
|
|
7427
|
-
|
|
7557
|
+
useEffect12(() => {
|
|
7428
7558
|
if (!runtime) return;
|
|
7429
7559
|
if (props.view !== void 0 && props.view !== runtime.getTree().view)
|
|
7430
7560
|
runtime.store.dispatch(stateActions.setView(props.view));
|
|
7431
7561
|
}, [runtime, props.view]);
|
|
7432
|
-
|
|
7562
|
+
useEffect12(() => {
|
|
7433
7563
|
if (!runtime) return;
|
|
7434
7564
|
let prev = runtime.getTree();
|
|
7435
7565
|
return runtime.store.subscribe(() => {
|
|
@@ -7545,7 +7675,7 @@ var DashboardRenderer = forwardRef(
|
|
|
7545
7675
|
props.themes,
|
|
7546
7676
|
props.theme ?? ds.theme ?? DEFAULT_THEME
|
|
7547
7677
|
);
|
|
7548
|
-
|
|
7678
|
+
useEffect12(() => {
|
|
7549
7679
|
if (picked.unknown)
|
|
7550
7680
|
latest.current.onError?.({
|
|
7551
7681
|
code: "unknown-theme",
|
|
@@ -7554,16 +7684,16 @@ var DashboardRenderer = forwardRef(
|
|
|
7554
7684
|
}, [picked.unknown]);
|
|
7555
7685
|
let content;
|
|
7556
7686
|
if (loaded.status === "invalid")
|
|
7557
|
-
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 });
|
|
7558
7688
|
else if (sandboxError)
|
|
7559
7689
|
content = /* @__PURE__ */ jsxs23("div", { className: "ds-invalid", children: [
|
|
7560
7690
|
"Could not start the script sandbox: ",
|
|
7561
7691
|
sandboxError
|
|
7562
7692
|
] });
|
|
7563
7693
|
else if (!ctx)
|
|
7564
|
-
content = /* @__PURE__ */
|
|
7694
|
+
content = /* @__PURE__ */ jsx31("div", { className: "ds-skeleton", style: { height: 200 }, "aria-busy": "true", "aria-label": "Loading dashboard" });
|
|
7565
7695
|
else
|
|
7566
|
-
content = /* @__PURE__ */
|
|
7696
|
+
content = /* @__PURE__ */ jsx31(
|
|
7567
7697
|
DashboardBody,
|
|
7568
7698
|
{
|
|
7569
7699
|
doc: loaded.document,
|
|
@@ -7576,8 +7706,8 @@ var DashboardRenderer = forwardRef(
|
|
|
7576
7706
|
}
|
|
7577
7707
|
);
|
|
7578
7708
|
return /* @__PURE__ */ jsxs23(ThemeScope, { theme: picked.theme, mode: picked.mode, children: [
|
|
7579
|
-
/* @__PURE__ */
|
|
7580
|
-
/* @__PURE__ */
|
|
7709
|
+
/* @__PURE__ */ jsx31("style", { dangerouslySetInnerHTML: { __html: RENDERER_CSS } }),
|
|
7710
|
+
/* @__PURE__ */ jsx31(
|
|
7581
7711
|
Boundary,
|
|
7582
7712
|
{
|
|
7583
7713
|
resetKeys: [loaded, runtime],
|
|
@@ -7586,7 +7716,7 @@ var DashboardRenderer = forwardRef(
|
|
|
7586
7716
|
"This dashboard could not be shown: ",
|
|
7587
7717
|
e.message
|
|
7588
7718
|
] }),
|
|
7589
|
-
children: ctx ? /* @__PURE__ */
|
|
7719
|
+
children: ctx ? /* @__PURE__ */ jsx31(DashboardContext.Provider, { value: ctx, children: content }) : content
|
|
7590
7720
|
}
|
|
7591
7721
|
)
|
|
7592
7722
|
] });
|
|
@@ -7603,7 +7733,7 @@ function DashboardBody({
|
|
|
7603
7733
|
}) {
|
|
7604
7734
|
const { runtime, options } = useDashboard();
|
|
7605
7735
|
const tv = options.mode === "tv" ? doc.spec.display.tv : void 0;
|
|
7606
|
-
|
|
7736
|
+
useEffect12(() => {
|
|
7607
7737
|
const views = tv?.rotateViews ?? [];
|
|
7608
7738
|
if (views.length < 2) return;
|
|
7609
7739
|
const every = tv?.every ? parseDuration(tv.every) : 6e4;
|
|
@@ -7641,14 +7771,14 @@ function DashboardBody({
|
|
|
7641
7771
|
const hidden = useHiddenPanels(Object.keys(doc.spec.panels));
|
|
7642
7772
|
return /* @__PURE__ */ jsxs23(Fragment10, { children: [
|
|
7643
7773
|
!hideHeader && (head.title || head.synced || tour.length > 0) && /* @__PURE__ */ jsxs23("div", { className: "ds-header", children: [
|
|
7644
|
-
head.title && /* @__PURE__ */
|
|
7645
|
-
head.description && /* @__PURE__ */
|
|
7646
|
-
head.synced && /* @__PURE__ */
|
|
7647
|
-
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 })
|
|
7648
7778
|
] }),
|
|
7649
7779
|
!tv?.hideToolbar && // A control that throws (a design system's, a custom filter kind) costs the bar, not the dashboard.
|
|
7650
|
-
/* @__PURE__ */
|
|
7651
|
-
/* @__PURE__ */
|
|
7780
|
+
/* @__PURE__ */ jsx31(Boundary, { resetKeys: [doc], fallback: (e) => /* @__PURE__ */ jsx31(PartError, { what: "The filters", error: e }), children: /* @__PURE__ */ jsx31(FilterBar, {}) }),
|
|
7781
|
+
/* @__PURE__ */ jsx31(
|
|
7652
7782
|
Grid,
|
|
7653
7783
|
{
|
|
7654
7784
|
layouts: doc.spec.layouts,
|
|
@@ -7687,10 +7817,10 @@ function DashboardBody({
|
|
|
7687
7817
|
...breakpoint ? { breakpoint } : {},
|
|
7688
7818
|
...onLayoutChange ? { onLayoutChange: (items, bp) => onLayoutChange(items, bp, head.view) } : {},
|
|
7689
7819
|
...onDropWidget ? { onDrop: (at, bp) => onDropWidget(at, bp, head.view), dropSize } : {},
|
|
7690
|
-
children: (id) => /* @__PURE__ */
|
|
7820
|
+
children: (id) => /* @__PURE__ */ jsx31(PanelFrame, { id })
|
|
7691
7821
|
}
|
|
7692
7822
|
),
|
|
7693
|
-
/* @__PURE__ */
|
|
7823
|
+
/* @__PURE__ */ jsx31(Boundary, { resetKeys: [doc], fallback: (e) => /* @__PURE__ */ jsx31(PartError, { what: "The pop-up", error: e }), children: /* @__PURE__ */ jsx31(ModalHost, {}) })
|
|
7694
7824
|
] });
|
|
7695
7825
|
}
|
|
7696
7826
|
var NO_STEPS = [];
|
|
@@ -7705,7 +7835,7 @@ function PartError({ what, error }) {
|
|
|
7705
7835
|
// src/widgets/wrap.tsx
|
|
7706
7836
|
import { Suspense, lazy } from "react";
|
|
7707
7837
|
import { z as z17 } from "zod";
|
|
7708
|
-
import { jsx as
|
|
7838
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
7709
7839
|
function wrapComponent(Component2, o) {
|
|
7710
7840
|
const schema = o.schema ?? z17.record(z17.unknown());
|
|
7711
7841
|
const eventNames = [...new Set(Object.values(o.events ?? {}))];
|
|
@@ -7735,7 +7865,7 @@ function wrapComponent(Component2, o) {
|
|
|
7735
7865
|
}
|
|
7736
7866
|
const slotProps = {};
|
|
7737
7867
|
for (const [prop, slot] of Object.entries(o.slots ?? {})) slotProps[prop] = props.renderSlot(slot);
|
|
7738
|
-
return /* @__PURE__ */
|
|
7868
|
+
return /* @__PURE__ */ jsx32(Component2, { ...mapped, ...handlers, ...slotProps });
|
|
7739
7869
|
}
|
|
7740
7870
|
});
|
|
7741
7871
|
}
|
|
@@ -7746,7 +7876,7 @@ function lazyWidget(def) {
|
|
|
7746
7876
|
...rest,
|
|
7747
7877
|
component: function LazyWidget(props) {
|
|
7748
7878
|
Comp ??= lazy(load);
|
|
7749
|
-
return /* @__PURE__ */
|
|
7879
|
+
return /* @__PURE__ */ jsx32(Suspense, { fallback: fallback ?? /* @__PURE__ */ jsx32("div", { className: "ds-skeleton", "aria-busy": "true" }), children: /* @__PURE__ */ jsx32(Comp, { ...props }) });
|
|
7750
7880
|
}
|
|
7751
7881
|
});
|
|
7752
7882
|
}
|