@dashspec/renderer 0.1.32 → 0.1.33
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 +7 -0
- package/dist/{chunk-6N525TLR.js → chunk-A6ITB5K3.js} +2 -2
- package/dist/{chunk-6N525TLR.js.map → chunk-A6ITB5K3.js.map} +1 -1
- package/dist/{core-Dbb0KZtW.d.ts → core-CQZEoeeW.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 +64 -54
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -116,7 +116,7 @@ import {
|
|
|
116
116
|
translator,
|
|
117
117
|
validateDocument,
|
|
118
118
|
widgetChecks
|
|
119
|
-
} from "./chunk-
|
|
119
|
+
} from "./chunk-A6ITB5K3.js";
|
|
120
120
|
import {
|
|
121
121
|
createStateProxy,
|
|
122
122
|
getPath,
|
|
@@ -164,12 +164,12 @@ function useTree(select, isEqual = shallowEqual) {
|
|
|
164
164
|
import {
|
|
165
165
|
createElement,
|
|
166
166
|
forwardRef,
|
|
167
|
-
useCallback as
|
|
167
|
+
useCallback as useCallback9,
|
|
168
168
|
useEffect as useEffect12,
|
|
169
169
|
useImperativeHandle,
|
|
170
170
|
useMemo as useMemo8,
|
|
171
171
|
useRef as useRef14,
|
|
172
|
-
useState as
|
|
172
|
+
useState as useState11
|
|
173
173
|
} from "react";
|
|
174
174
|
|
|
175
175
|
// src/designSystem.ts
|
|
@@ -5612,7 +5612,8 @@ var Button = defineWidget({
|
|
|
5612
5612
|
});
|
|
5613
5613
|
|
|
5614
5614
|
// src/widgets/builtins/charts.tsx
|
|
5615
|
-
import { useMemo as useMemo6 } from "react";
|
|
5615
|
+
import { useCallback as useCallback5, useMemo as useMemo6, useState as useState7 } from "react";
|
|
5616
|
+
import { createPortal as createPortal3 } from "react-dom";
|
|
5616
5617
|
import "zod";
|
|
5617
5618
|
|
|
5618
5619
|
// src/widgets/shared/EChart.tsx
|
|
@@ -6082,35 +6083,43 @@ var BarChart2 = defineWidget({
|
|
|
6082
6083
|
const avgText = spec.averageLine && c.avg !== void 0 ? typeof spec.averageLine === "string" ? spec.averageLine.replace(/\$\{avg\}/g, helpers.fmt.number(c.avg, 1)) : `Avg: ${helpers.fmt.number(c.avg, 1)}` : void 0;
|
|
6083
6084
|
const series = tokens?.theme[tokens.mode].chart.series ?? [];
|
|
6084
6085
|
const legend = c.coloured || avgText || c.legend.length > 0;
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
|
|
6086
|
+
const [head, setHead] = useState7(null);
|
|
6087
|
+
const findHead = useCallback5(
|
|
6088
|
+
(el) => setHead(
|
|
6089
|
+
spec.legendStyle === "html" ? el?.closest(".ds-panel")?.querySelector(":scope > .ds-panel-head .ds-panel-tools") ?? null : null
|
|
6090
|
+
),
|
|
6091
|
+
[spec.legendStyle]
|
|
6092
|
+
);
|
|
6093
|
+
const list = legend ? /* @__PURE__ */ jsxs19("ul", { className: "ds-chart-legend", children: [
|
|
6094
|
+
c.coloured && /* @__PURE__ */ jsxs19(Fragment8, { children: [
|
|
6095
|
+
/* @__PURE__ */ jsxs19("li", { children: [
|
|
6096
|
+
/* @__PURE__ */ jsx25("span", { className: "ds-swatch", style: { background: colors?.good } }),
|
|
6097
|
+
spec.legendLabels?.above ?? "At or above avg"
|
|
6096
6098
|
] }),
|
|
6097
|
-
|
|
6098
|
-
/* @__PURE__ */ jsx25(
|
|
6099
|
-
|
|
6100
|
-
{
|
|
6101
|
-
className: "ds-swatch",
|
|
6102
|
-
style: {
|
|
6103
|
-
background: (l.key !== void 0 && spec.seriesColors && Object.hasOwn(spec.seriesColors, l.key) ? spec.seriesColors[l.key] : void 0) ?? series[i % Math.max(series.length, 1)]
|
|
6104
|
-
}
|
|
6105
|
-
}
|
|
6106
|
-
),
|
|
6107
|
-
l.name
|
|
6108
|
-
] }, l.name)),
|
|
6109
|
-
avgText && /* @__PURE__ */ jsxs19("li", { children: [
|
|
6110
|
-
/* @__PURE__ */ jsx25("span", { className: "ds-swatch-line" }),
|
|
6111
|
-
avgText
|
|
6099
|
+
/* @__PURE__ */ jsxs19("li", { children: [
|
|
6100
|
+
/* @__PURE__ */ jsx25("span", { className: "ds-swatch", style: { background: colors?.bad } }),
|
|
6101
|
+
spec.legendLabels?.below ?? "Below avg"
|
|
6112
6102
|
] })
|
|
6113
6103
|
] }),
|
|
6104
|
+
c.legend.map((l, i) => /* @__PURE__ */ jsxs19("li", { children: [
|
|
6105
|
+
/* @__PURE__ */ jsx25(
|
|
6106
|
+
"span",
|
|
6107
|
+
{
|
|
6108
|
+
className: "ds-swatch",
|
|
6109
|
+
style: {
|
|
6110
|
+
background: (l.key !== void 0 && spec.seriesColors && Object.hasOwn(spec.seriesColors, l.key) ? spec.seriesColors[l.key] : void 0) ?? series[i % Math.max(series.length, 1)]
|
|
6111
|
+
}
|
|
6112
|
+
}
|
|
6113
|
+
),
|
|
6114
|
+
l.name
|
|
6115
|
+
] }, l.name)),
|
|
6116
|
+
avgText && /* @__PURE__ */ jsxs19("li", { children: [
|
|
6117
|
+
/* @__PURE__ */ jsx25("span", { className: "ds-swatch-line" }),
|
|
6118
|
+
avgText
|
|
6119
|
+
] })
|
|
6120
|
+
] }) : null;
|
|
6121
|
+
return /* @__PURE__ */ jsxs19("div", { className: "ds-chart", ref: findHead, children: [
|
|
6122
|
+
head && list ? createPortal3(list, head) : list,
|
|
6114
6123
|
/* @__PURE__ */ jsx25(
|
|
6115
6124
|
EChart,
|
|
6116
6125
|
{
|
|
@@ -6119,7 +6128,7 @@ var BarChart2 = defineWidget({
|
|
|
6119
6128
|
emit,
|
|
6120
6129
|
part: "bar",
|
|
6121
6130
|
rows: c.rows,
|
|
6122
|
-
height: size2.height - (legend ? 24 : 0),
|
|
6131
|
+
height: size2.height - (legend && !head ? 24 : 0),
|
|
6123
6132
|
hiddenSeries: state.hiddenSeries,
|
|
6124
6133
|
highlightIndex: hi,
|
|
6125
6134
|
ariaLabel: spec.title
|
|
@@ -6495,7 +6504,7 @@ var builtInWidgets = [
|
|
|
6495
6504
|
];
|
|
6496
6505
|
|
|
6497
6506
|
// src/components/Grid.tsx
|
|
6498
|
-
import { useEffect as useEffect8, useMemo as useMemo7, useRef as useRef9, useState as
|
|
6507
|
+
import { useEffect as useEffect8, useMemo as useMemo7, useRef as useRef9, useState as useState8 } from "react";
|
|
6499
6508
|
import { Responsive, WidthProvider } from "react-grid-layout";
|
|
6500
6509
|
import { jsx as jsx27 } from "react/jsx-runtime";
|
|
6501
6510
|
var ResponsiveGrid = WidthProvider(Responsive);
|
|
@@ -6553,8 +6562,8 @@ function Grid({
|
|
|
6553
6562
|
dragOnto
|
|
6554
6563
|
}) {
|
|
6555
6564
|
const bpRef = useRef9("desktop");
|
|
6556
|
-
const [wrapEl, setWrapEl] =
|
|
6557
|
-
const [measured, setMeasured] =
|
|
6565
|
+
const [wrapEl, setWrapEl] = useState8(null);
|
|
6566
|
+
const [measured, setMeasured] = useState8("desktop");
|
|
6558
6567
|
useEffect8(() => {
|
|
6559
6568
|
if (!wrapEl || typeof ResizeObserver === "undefined") return;
|
|
6560
6569
|
const ro = new ResizeObserver(([e]) => {
|
|
@@ -6581,7 +6590,7 @@ function Grid({
|
|
|
6581
6590
|
cols: base.cols
|
|
6582
6591
|
};
|
|
6583
6592
|
}, [base, hidden, editable, exact, unit]);
|
|
6584
|
-
const [fitRows, setFitRows] =
|
|
6593
|
+
const [fitRows, setFitRows] = useState8({});
|
|
6585
6594
|
const fitted = useMemo7(() => {
|
|
6586
6595
|
if (editable || base.fit.size === 0) return rgl;
|
|
6587
6596
|
return Object.fromEntries(
|
|
@@ -6722,7 +6731,7 @@ function Grid({
|
|
|
6722
6731
|
}
|
|
6723
6732
|
|
|
6724
6733
|
// src/components/ModalHost.tsx
|
|
6725
|
-
import { useCallback as
|
|
6734
|
+
import { useCallback as useCallback6, useEffect as useEffect9, useRef as useRef10 } from "react";
|
|
6726
6735
|
import { jsx as jsx28, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
6727
6736
|
var WIDTH = { sm: "420px", md: "720px", lg: "1040px", xl: "1320px", full: "100%" };
|
|
6728
6737
|
var FOCUSABLE2 = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
@@ -6731,11 +6740,11 @@ function ModalHost() {
|
|
|
6731
6740
|
const modals = runtime.doc.spec.modals ?? {};
|
|
6732
6741
|
const open = useTree(
|
|
6733
6742
|
// biome-ignore lint/correctness/useExhaustiveDependencies: modals are fixed per runtime
|
|
6734
|
-
|
|
6743
|
+
useCallback6((t) => t.modal ? { id: t.modal.id, title: titleOf(t, t.modal.id) } : null, [runtime])
|
|
6735
6744
|
);
|
|
6736
6745
|
const byExpression = useTree(
|
|
6737
6746
|
// biome-ignore lint/correctness/useExhaustiveDependencies: modals are fixed per runtime
|
|
6738
|
-
|
|
6747
|
+
useCallback6(
|
|
6739
6748
|
(t) => Object.entries(modals).filter(([, m2]) => {
|
|
6740
6749
|
if (typeof m2.open !== "string") return false;
|
|
6741
6750
|
try {
|
|
@@ -6773,7 +6782,7 @@ function ModalHost() {
|
|
|
6773
6782
|
const dialog = useRef10(null);
|
|
6774
6783
|
const scrim = useRef10(null);
|
|
6775
6784
|
const openId = open?.id;
|
|
6776
|
-
const close =
|
|
6785
|
+
const close = useCallback6(() => {
|
|
6777
6786
|
if (!openId) return;
|
|
6778
6787
|
void runtime.emit({ type: "close", modal: openId });
|
|
6779
6788
|
const on = modals[openId]?.on;
|
|
@@ -6915,7 +6924,7 @@ function pickTheme(name, themes, fallback) {
|
|
|
6915
6924
|
}
|
|
6916
6925
|
|
|
6917
6926
|
// src/components/Tour.tsx
|
|
6918
|
-
import { useCallback as
|
|
6927
|
+
import { useCallback as useCallback7, useEffect as useEffect10, useId as useId5, useLayoutEffect as useLayoutEffect3, useRef as useRef12, useState as useState9 } from "react";
|
|
6919
6928
|
import { Fragment as Fragment10, jsx as jsx30, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
6920
6929
|
var useClientLayoutEffect = typeof window === "undefined" ? useEffect10 : useLayoutEffect3;
|
|
6921
6930
|
function panelElement(root, id) {
|
|
@@ -6926,16 +6935,16 @@ function panelElement(root, id) {
|
|
|
6926
6935
|
}
|
|
6927
6936
|
function TourButton({ steps }) {
|
|
6928
6937
|
const { runtime } = useDashboard();
|
|
6929
|
-
const [at, setAt] =
|
|
6938
|
+
const [at, setAt] = useState9(null);
|
|
6930
6939
|
const button = useRef12(null);
|
|
6931
6940
|
const dialog = useRef12(null);
|
|
6932
6941
|
const next = useRef12(null);
|
|
6933
|
-
const [pos, setPos] =
|
|
6942
|
+
const [pos, setPos] = useState9(null);
|
|
6934
6943
|
const titleId = useId5();
|
|
6935
6944
|
const textId = useId5();
|
|
6936
6945
|
const step = at === null ? void 0 : steps[at];
|
|
6937
6946
|
const text = useTree(
|
|
6938
|
-
|
|
6947
|
+
useCallback7(
|
|
6939
6948
|
(t) => {
|
|
6940
6949
|
if (!step) return null;
|
|
6941
6950
|
const sc = rootScope(t, runtime.helpers);
|
|
@@ -6953,7 +6962,7 @@ function TourButton({ steps }) {
|
|
|
6953
6962
|
),
|
|
6954
6963
|
(a, b) => a?.title === b?.title && a?.text === b?.text
|
|
6955
6964
|
);
|
|
6956
|
-
const close =
|
|
6965
|
+
const close = useCallback7(() => {
|
|
6957
6966
|
setAt(null);
|
|
6958
6967
|
button.current?.focus();
|
|
6959
6968
|
}, []);
|
|
@@ -7055,7 +7064,7 @@ function TourButton({ steps }) {
|
|
|
7055
7064
|
}
|
|
7056
7065
|
|
|
7057
7066
|
// src/components/registryHooks.ts
|
|
7058
|
-
import { useCallback as
|
|
7067
|
+
import { useCallback as useCallback8, useEffect as useEffect11, useRef as useRef13, useState as useState10, useSyncExternalStore as useSyncExternalStore3 } from "react";
|
|
7059
7068
|
var live = /* @__PURE__ */ new Map();
|
|
7060
7069
|
var listeners = /* @__PURE__ */ new Set();
|
|
7061
7070
|
var notify = () => {
|
|
@@ -7083,7 +7092,7 @@ function useRuntimeById(id) {
|
|
|
7083
7092
|
}
|
|
7084
7093
|
function useDashboardState(id, select) {
|
|
7085
7094
|
const rt = useRuntimeById(id);
|
|
7086
|
-
const [value, setValue] =
|
|
7095
|
+
const [value, setValue] = useState10(() => rt ? select(rt.getTree()) : void 0);
|
|
7087
7096
|
const sel = useRef13(select);
|
|
7088
7097
|
sel.current = select;
|
|
7089
7098
|
useEffect11(() => {
|
|
@@ -7098,17 +7107,17 @@ function useDashboardActions(id) {
|
|
|
7098
7107
|
const rt = useRuntimeById(id);
|
|
7099
7108
|
return {
|
|
7100
7109
|
ready: Boolean(rt),
|
|
7101
|
-
setVariable:
|
|
7110
|
+
setVariable: useCallback8(
|
|
7102
7111
|
(name, value) => rt?.store.dispatch(stateActions.setFilter({ name, value })),
|
|
7103
7112
|
[rt]
|
|
7104
7113
|
),
|
|
7105
|
-
setState:
|
|
7114
|
+
setState: useCallback8(
|
|
7106
7115
|
(path, value) => rt?.store.dispatch(stateActions.set({ path, value })),
|
|
7107
7116
|
[rt]
|
|
7108
7117
|
),
|
|
7109
|
-
setView:
|
|
7110
|
-
run:
|
|
7111
|
-
refresh:
|
|
7118
|
+
setView: useCallback8((view) => rt?.store.dispatch(stateActions.setView(view)), [rt]),
|
|
7119
|
+
run: useCallback8((action) => rt?.runAction(action), [rt]),
|
|
7120
|
+
refresh: useCallback8(
|
|
7112
7121
|
(source) => rt?.engine.refresh(source === void 0 ? void 0 : Array.isArray(source) ? source : [source]),
|
|
7113
7122
|
[rt]
|
|
7114
7123
|
)
|
|
@@ -7348,6 +7357,7 @@ var RENDERER_CSS = `
|
|
|
7348
7357
|
|
|
7349
7358
|
.ds-chart { display: flex; flex-direction: column; height: 100%; }
|
|
7350
7359
|
.ds-chart-legend { list-style: none; margin: -38px 0 14px auto; padding: 0; display: flex; gap: var(--ds-space-lg); font-size: var(--ds-type-label-size); color: var(--ds-color-text-subtle); position: relative; z-index: 1; max-width: 70%; flex-wrap: wrap; justify-content: flex-end; }
|
|
7360
|
+
.ds-panel-tools .ds-chart-legend { margin: 0; max-width: none; }
|
|
7351
7361
|
.ds-chart-legend li { display: inline-flex; align-items: center; gap: 6px; }
|
|
7352
7362
|
.ds-swatch { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
|
|
7353
7363
|
.ds-swatch-line { width: 16px; border-top: 2px dashed var(--ds-color-text-subtle); display: inline-block; }
|
|
@@ -7865,8 +7875,8 @@ var DashboardRenderer = forwardRef(
|
|
|
7865
7875
|
const forRuntime = useMemo8(() => loaded, [runtimeKey]);
|
|
7866
7876
|
const mode = props.scripts ?? "sandbox";
|
|
7867
7877
|
const needsSandbox = loaded.status === "valid" && mode === "sandbox" && usesScripts(loaded.document);
|
|
7868
|
-
const [sandbox, setSandbox] =
|
|
7869
|
-
const [sandboxError, setSandboxError] =
|
|
7878
|
+
const [sandbox, setSandbox] = useState11(null);
|
|
7879
|
+
const [sandboxError, setSandboxError] = useState11(null);
|
|
7870
7880
|
useEffect12(() => {
|
|
7871
7881
|
if (!needsSandbox || sandbox) return;
|
|
7872
7882
|
let cancelled = false;
|
|
@@ -8188,7 +8198,7 @@ function DashboardBody({
|
|
|
8188
8198
|
return () => clearInterval(timer);
|
|
8189
8199
|
}, [tv, runtime]);
|
|
8190
8200
|
const head = useTree(
|
|
8191
|
-
|
|
8201
|
+
useCallback9(
|
|
8192
8202
|
(t) => {
|
|
8193
8203
|
const sc = rootScope(t, runtime.helpers);
|
|
8194
8204
|
const text = (v) => {
|