@dashspec/renderer 0.1.2 → 0.1.4
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 +30 -1
- package/dist/{chunk-T4QLZXX4.js → chunk-2HHYJ5WX.js} +24 -5
- package/dist/chunk-2HHYJ5WX.js.map +1 -0
- package/dist/{core-CIcJ1KNt.d.ts → core-DIU9lTws.d.ts} +81 -23
- package/dist/core.d.ts +1 -1
- package/dist/core.js +3 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.js +219 -89
- package/dist/index.js.map +1 -1
- package/dist/schema.json +5 -1
- package/docs/json-format.md +5 -3
- package/docs/widgets.md +2 -2
- package/package.json +1 -1
- package/dist/chunk-T4QLZXX4.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -110,11 +110,12 @@ import {
|
|
|
110
110
|
safeLink,
|
|
111
111
|
satisfies,
|
|
112
112
|
scope,
|
|
113
|
+
stripStrings,
|
|
113
114
|
templateReferences,
|
|
114
115
|
translator,
|
|
115
116
|
validateDocument,
|
|
116
117
|
widgetChecks
|
|
117
|
-
} from "./chunk-
|
|
118
|
+
} from "./chunk-2HHYJ5WX.js";
|
|
118
119
|
import {
|
|
119
120
|
createStateProxy,
|
|
120
121
|
getPath,
|
|
@@ -166,8 +167,8 @@ import {
|
|
|
166
167
|
useEffect as useEffect11,
|
|
167
168
|
useImperativeHandle,
|
|
168
169
|
useMemo as useMemo8,
|
|
169
|
-
useRef as
|
|
170
|
-
useState as
|
|
170
|
+
useRef as useRef14,
|
|
171
|
+
useState as useState10
|
|
171
172
|
} from "react";
|
|
172
173
|
|
|
173
174
|
// src/designSystem.ts
|
|
@@ -3184,43 +3185,45 @@ function FilterBar() {
|
|
|
3184
3185
|
className: "ds-filters",
|
|
3185
3186
|
role: "toolbar",
|
|
3186
3187
|
"aria-label": "Filters",
|
|
3187
|
-
"data-look": bar.look === "plain"
|
|
3188
|
+
"data-look": bar.look === "plain" || bar.look === "segmented" ? bar.look : void 0,
|
|
3188
3189
|
"data-picked": options.selectedFilter === BAR || void 0,
|
|
3189
3190
|
"data-editable": options.onFilterSelect ? "" : void 0,
|
|
3190
3191
|
onPointerDown: options.onFilterSelect ? (e) => {
|
|
3191
3192
|
if (!e.target.closest(".ds-filter-pick")) options.onFilterSelect?.(BAR);
|
|
3192
3193
|
} : void 0,
|
|
3193
3194
|
children: [
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
e
|
|
3206
|
-
|
|
3195
|
+
/* @__PURE__ */ jsxs5(Track, { segmented: bar.look === "segmented", children: [
|
|
3196
|
+
bar.icon !== "none" && /* @__PURE__ */ jsx8("span", { className: "ds-filters-icon", "aria-hidden": "true", children: BAR_ICONS[bar.icon ?? "sliders"] ?? BAR_ICONS.sliders }),
|
|
3197
|
+
shown.map(
|
|
3198
|
+
(v) => options.onFilterSelect ? (
|
|
3199
|
+
// Builder: a click selects the filter to configure it instead of opening it.
|
|
3200
|
+
/* @__PURE__ */ jsx8(
|
|
3201
|
+
"div",
|
|
3202
|
+
{
|
|
3203
|
+
className: "ds-filter-pick",
|
|
3204
|
+
"data-selected": options.selectedFilter === v.name || void 0,
|
|
3205
|
+
onPointerDownCapture: () => options.onFilterSelect?.(v.name),
|
|
3206
|
+
onClickCapture: (e) => {
|
|
3207
|
+
e.preventDefault();
|
|
3208
|
+
e.stopPropagation();
|
|
3209
|
+
},
|
|
3210
|
+
children: /* @__PURE__ */ jsx8(ControlField, { compact: true, def: v, value: values[v.name], onChange: () => {
|
|
3211
|
+
} })
|
|
3207
3212
|
},
|
|
3208
|
-
|
|
3209
|
-
|
|
3213
|
+
v.name
|
|
3214
|
+
)
|
|
3215
|
+
) : /* @__PURE__ */ jsx8(
|
|
3216
|
+
ControlField,
|
|
3217
|
+
{
|
|
3218
|
+
compact: true,
|
|
3219
|
+
def: v,
|
|
3220
|
+
value: values[v.name],
|
|
3221
|
+
onChange: (val) => set(v.name, val, applyMode(v) === "change")
|
|
3210
3222
|
},
|
|
3211
3223
|
v.name
|
|
3212
3224
|
)
|
|
3213
|
-
) : /* @__PURE__ */ jsx8(
|
|
3214
|
-
ControlField,
|
|
3215
|
-
{
|
|
3216
|
-
compact: true,
|
|
3217
|
-
def: v,
|
|
3218
|
-
value: values[v.name],
|
|
3219
|
-
onChange: (val) => set(v.name, val, applyMode(v) === "change")
|
|
3220
|
-
},
|
|
3221
|
-
v.name
|
|
3222
3225
|
)
|
|
3223
|
-
),
|
|
3226
|
+
] }),
|
|
3224
3227
|
(needsApply || bar.reset) && /* @__PURE__ */ jsx8("span", { className: "ds-filters-spacer" }),
|
|
3225
3228
|
bar.reset && /* @__PURE__ */ jsx8(
|
|
3226
3229
|
"button",
|
|
@@ -3318,6 +3321,9 @@ function FilterDrawer({ active, children }) {
|
|
|
3318
3321
|
)
|
|
3319
3322
|
] });
|
|
3320
3323
|
}
|
|
3324
|
+
function Track({ segmented, children }) {
|
|
3325
|
+
return segmented ? /* @__PURE__ */ jsx8("div", { className: "ds-filters-track", children }) : /* @__PURE__ */ jsx8(Fragment3, { children });
|
|
3326
|
+
}
|
|
3321
3327
|
|
|
3322
3328
|
// src/widgets/builtins/Filter.tsx
|
|
3323
3329
|
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
@@ -3445,21 +3451,81 @@ var ImageMap = defineWidget({
|
|
|
3445
3451
|
import "zod";
|
|
3446
3452
|
|
|
3447
3453
|
// src/widgets/shared/InfoTip.tsx
|
|
3454
|
+
import { useLayoutEffect as useLayoutEffect2, useRef as useRef4, useState as useState3 } from "react";
|
|
3455
|
+
import { createPortal as createPortal2 } from "react-dom";
|
|
3448
3456
|
import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
3449
3457
|
function InfoTip({ text }) {
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3453
|
-
]
|
|
3458
|
+
const ref = useRef4(null);
|
|
3459
|
+
const tip = useRef4(null);
|
|
3460
|
+
const [open, setOpen] = useState3(false);
|
|
3461
|
+
const [pos, setPos] = useState3(null);
|
|
3462
|
+
useLayoutEffect2(() => {
|
|
3463
|
+
if (!open || !ref.current || !tip.current) return;
|
|
3464
|
+
const a = ref.current.getBoundingClientRect();
|
|
3465
|
+
const t = tip.current.getBoundingClientRect();
|
|
3466
|
+
const gap = 8;
|
|
3467
|
+
const margin = 8;
|
|
3468
|
+
const vw = window.innerWidth || document.documentElement.clientWidth;
|
|
3469
|
+
const below = a.top - t.height - gap < margin;
|
|
3470
|
+
const centre = a.left + a.width / 2;
|
|
3471
|
+
const left = Math.min(Math.max(centre - t.width / 2, margin), Math.max(margin, vw - t.width - margin));
|
|
3472
|
+
setPos({ left, top: below ? a.bottom + gap : a.top - t.height - gap, arrow: centre - left, below });
|
|
3473
|
+
}, [open]);
|
|
3474
|
+
const root = ref.current?.closest(".ds-root") ?? (typeof document !== "undefined" ? document.body : null);
|
|
3475
|
+
return /* @__PURE__ */ jsxs7(
|
|
3476
|
+
"button",
|
|
3477
|
+
{
|
|
3478
|
+
ref,
|
|
3479
|
+
type: "button",
|
|
3480
|
+
className: "ds-info",
|
|
3481
|
+
"aria-label": text,
|
|
3482
|
+
onClick: (e) => e.stopPropagation(),
|
|
3483
|
+
onMouseEnter: () => setOpen(true),
|
|
3484
|
+
onMouseLeave: () => {
|
|
3485
|
+
setOpen(false);
|
|
3486
|
+
setPos(null);
|
|
3487
|
+
},
|
|
3488
|
+
onFocus: () => setOpen(true),
|
|
3489
|
+
onBlur: () => {
|
|
3490
|
+
setOpen(false);
|
|
3491
|
+
setPos(null);
|
|
3492
|
+
},
|
|
3493
|
+
children: [
|
|
3494
|
+
/* @__PURE__ */ jsxs7("svg", { viewBox: "0 0 16 16", width: "14", height: "14", "aria-hidden": "true", children: [
|
|
3495
|
+
/* @__PURE__ */ jsx12("circle", { cx: "8", cy: "8", r: "6.5", fill: "none", stroke: "currentColor", strokeWidth: "1" }),
|
|
3496
|
+
/* @__PURE__ */ jsx12("path", { d: "M8 7.2v3.6M8 5.2v.1", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round" })
|
|
3497
|
+
] }),
|
|
3498
|
+
open && root && createPortal2(
|
|
3499
|
+
/* @__PURE__ */ jsx12(
|
|
3500
|
+
"span",
|
|
3501
|
+
{
|
|
3502
|
+
ref: tip,
|
|
3503
|
+
className: "ds-tip",
|
|
3504
|
+
role: "tooltip",
|
|
3505
|
+
"data-below": pos?.below || void 0,
|
|
3506
|
+
style: {
|
|
3507
|
+
left: pos?.left ?? 0,
|
|
3508
|
+
top: pos?.top ?? 0,
|
|
3509
|
+
visibility: pos ? "visible" : "hidden",
|
|
3510
|
+
["--ds-tip-arrow"]: `${pos?.arrow ?? 0}px`
|
|
3511
|
+
},
|
|
3512
|
+
children: text
|
|
3513
|
+
}
|
|
3514
|
+
),
|
|
3515
|
+
root
|
|
3516
|
+
)
|
|
3517
|
+
]
|
|
3518
|
+
}
|
|
3519
|
+
);
|
|
3454
3520
|
}
|
|
3455
3521
|
|
|
3456
3522
|
// src/widgets/shared/motion.ts
|
|
3457
|
-
import { useEffect as useEffect3, useRef as
|
|
3523
|
+
import { useEffect as useEffect3, useRef as useRef5, useState as useState4 } from "react";
|
|
3458
3524
|
var reduced = () => typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
3459
3525
|
var easeOut = (t) => 1 - (1 - t) ** 3;
|
|
3460
3526
|
function useCountUp(target, ms = 700) {
|
|
3461
|
-
const [shown, setShown] =
|
|
3462
|
-
const from =
|
|
3527
|
+
const [shown, setShown] = useState4(() => typeof target === "number" && !reduced() ? 0 : target);
|
|
3528
|
+
const from = useRef5(0);
|
|
3463
3529
|
useEffect3(() => {
|
|
3464
3530
|
if (typeof target !== "number" || !Number.isFinite(target) || reduced()) {
|
|
3465
3531
|
setShown(target);
|
|
@@ -3502,7 +3568,7 @@ var Kpi = defineWidget({
|
|
|
3502
3568
|
const n = toNumber(value);
|
|
3503
3569
|
const fmt = (v) => formatValue(v, helpers, spec.format, spec.decimals);
|
|
3504
3570
|
const unit = spec.format === "duration" ? void 0 : spec.unit;
|
|
3505
|
-
const empty = value === void 0 || value === null || value === "";
|
|
3571
|
+
const empty = spec.empty === true || value === void 0 || value === null || value === "";
|
|
3506
3572
|
const hasTarget = spec.target !== void 0;
|
|
3507
3573
|
const target = hasTarget ? num(spec.target) : void 0;
|
|
3508
3574
|
const op = spec.goodWhen === "down" ? "\u2264 " : spec.goodWhen === "up" ? "\u2265 " : "";
|
|
@@ -3768,7 +3834,7 @@ var Status = defineWidget({
|
|
|
3768
3834
|
});
|
|
3769
3835
|
|
|
3770
3836
|
// src/widgets/builtins/Table.tsx
|
|
3771
|
-
import { useEffect as useEffect4, useMemo as useMemo3, useRef as
|
|
3837
|
+
import { useEffect as useEffect4, useMemo as useMemo3, useRef as useRef6, useState as useState5 } from "react";
|
|
3772
3838
|
import { jsx as jsx18, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
3773
3839
|
var ROW_H = 36;
|
|
3774
3840
|
function pageList(current, pages) {
|
|
@@ -3828,7 +3894,7 @@ var Table = defineWidget({
|
|
|
3828
3894
|
};
|
|
3829
3895
|
const anyServer = server.paging || server.search || server.sort || server.filter;
|
|
3830
3896
|
const ui = state.ui ?? {};
|
|
3831
|
-
const [view, setView] =
|
|
3897
|
+
const [view, setView] = useState5(() => ({
|
|
3832
3898
|
page: Number(ui.page ?? 1),
|
|
3833
3899
|
pageSize: Number(ui.pageSize ?? pg?.pageSize ?? 20),
|
|
3834
3900
|
search: String(ui.search ?? ""),
|
|
@@ -3851,11 +3917,11 @@ var Table = defineWidget({
|
|
|
3851
3917
|
filters: Object.fromEntries(Object.entries(next.filters).filter(([, v]) => v !== ""))
|
|
3852
3918
|
});
|
|
3853
3919
|
};
|
|
3854
|
-
const [searchText, setSearchText] =
|
|
3855
|
-
const searchTimer =
|
|
3920
|
+
const [searchText, setSearchText] = useState5(view.search);
|
|
3921
|
+
const searchTimer = useRef6(void 0);
|
|
3856
3922
|
useEffect4(() => () => clearTimeout(searchTimer.current), []);
|
|
3857
|
-
const [scrollTop, setScrollTop] =
|
|
3858
|
-
const scroller =
|
|
3923
|
+
const [scrollTop, setScrollTop] = useState5(0);
|
|
3924
|
+
const scroller = useRef6(null);
|
|
3859
3925
|
const sort = view.sortKey ? { key: view.sortKey, order: view.sortOrder } : void 0;
|
|
3860
3926
|
const rows = useMemo3(() => {
|
|
3861
3927
|
let r = base;
|
|
@@ -4267,7 +4333,7 @@ import "zod";
|
|
|
4267
4333
|
import { useContext as useContext4 } from "react";
|
|
4268
4334
|
|
|
4269
4335
|
// src/components/PanelFrame.tsx
|
|
4270
|
-
import { useCallback as useCallback4, useEffect as useEffect5, useId as useId3, useMemo as useMemo4, useRef as
|
|
4336
|
+
import { useCallback as useCallback4, useEffect as useEffect5, useId as useId3, useMemo as useMemo4, useRef as useRef7, useState as useState6 } from "react";
|
|
4271
4337
|
|
|
4272
4338
|
// src/widgets/parseProps.ts
|
|
4273
4339
|
function without(value, path) {
|
|
@@ -4382,8 +4448,8 @@ var SlotItem = ({ children }) => /* @__PURE__ */ jsx20(Fragment6, { children });
|
|
|
4382
4448
|
import { jsx as jsx21, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
4383
4449
|
var isEmpty = (d) => d === void 0 || d === null || Array.isArray(d) && d.length === 0 || typeof d === "object" && !Array.isArray(d) && Object.keys(d).length === 0;
|
|
4384
4450
|
function useSize() {
|
|
4385
|
-
const [size2, setSize] =
|
|
4386
|
-
const observer =
|
|
4451
|
+
const [size2, setSize] = useState6({ width: 0, height: 0 });
|
|
4452
|
+
const observer = useRef7(null);
|
|
4387
4453
|
const ref = useCallback4((el) => {
|
|
4388
4454
|
observer.current?.disconnect();
|
|
4389
4455
|
observer.current = null;
|
|
@@ -4412,7 +4478,7 @@ function interpolateMarkdown(v, scope2) {
|
|
|
4412
4478
|
function resolvePanel(v, scope2, inItem = false, key) {
|
|
4413
4479
|
const deferred = inItem ? DEFERRED_IN_ITEM : DEFERRED;
|
|
4414
4480
|
if (typeof v === "string") {
|
|
4415
|
-
if (placeholders(v).some((b) => deferred.test(b))) return v;
|
|
4481
|
+
if (placeholders(v).some((b) => deferred.test(stripStrings(b)))) return v;
|
|
4416
4482
|
return key === "markdown" ? interpolateMarkdown(v, scope2) : interpolate(v, scope2);
|
|
4417
4483
|
}
|
|
4418
4484
|
if (Array.isArray(v)) return v.map((x) => resolvePanel(x, scope2, inItem));
|
|
@@ -4685,7 +4751,7 @@ function PanelFrameInner({ id, nested }) {
|
|
|
4685
4751
|
const renderNested = useCallback4((child) => /* @__PURE__ */ jsx21(PanelFrame, { id: child, nested: true }, child), []);
|
|
4686
4752
|
const store = useMemo4(() => widgetStore(runtime), [runtime]);
|
|
4687
4753
|
const [bodyRef, size2] = useSize();
|
|
4688
|
-
const frameRef =
|
|
4754
|
+
const frameRef = useRef7(null);
|
|
4689
4755
|
useEffect5(() => {
|
|
4690
4756
|
if (!view.visible || view.hidden) {
|
|
4691
4757
|
visibility.set(instance, null);
|
|
@@ -4724,7 +4790,7 @@ function PanelFrameInner({ id, nested }) {
|
|
|
4724
4790
|
),
|
|
4725
4791
|
[runtime, id]
|
|
4726
4792
|
);
|
|
4727
|
-
const dataRef =
|
|
4793
|
+
const dataRef = useRef7(view.data);
|
|
4728
4794
|
dataRef.current = view.data;
|
|
4729
4795
|
const props = useMemo4(() => {
|
|
4730
4796
|
let p = { ...view.props, ...view.panel.props ?? {} };
|
|
@@ -5079,7 +5145,7 @@ import {
|
|
|
5079
5145
|
} from "echarts/components";
|
|
5080
5146
|
import * as echarts from "echarts/core";
|
|
5081
5147
|
import { CanvasRenderer } from "echarts/renderers";
|
|
5082
|
-
import { useEffect as useEffect6, useMemo as useMemo5, useRef as
|
|
5148
|
+
import { useEffect as useEffect6, useMemo as useMemo5, useRef as useRef8 } from "react";
|
|
5083
5149
|
|
|
5084
5150
|
// src/theme/echartsTheme.ts
|
|
5085
5151
|
function echartsTheme(theme, mode) {
|
|
@@ -5153,11 +5219,11 @@ function EChart({
|
|
|
5153
5219
|
height,
|
|
5154
5220
|
ariaLabel
|
|
5155
5221
|
}) {
|
|
5156
|
-
const el =
|
|
5157
|
-
const chart =
|
|
5222
|
+
const el = useRef8(null);
|
|
5223
|
+
const chart = useRef8(null);
|
|
5158
5224
|
const tokens = useThemeTokens();
|
|
5159
5225
|
const theme = useMemo5(() => tokens ? echartsTheme(tokens.theme, tokens.mode) : void 0, [tokens]);
|
|
5160
|
-
const handlers =
|
|
5226
|
+
const handlers = useRef8({ emit, rows });
|
|
5161
5227
|
handlers.current = { emit, rows };
|
|
5162
5228
|
useEffect6(() => {
|
|
5163
5229
|
if (!el.current) return;
|
|
@@ -5291,7 +5357,10 @@ function cartesian(data, source, spec, type, h, colors) {
|
|
|
5291
5357
|
axisLabel: {
|
|
5292
5358
|
formatter: (v) => spec.normalized ? `${v}%` : formatValue(v, h, spec.format === "duration" ? "duration" : "compact")
|
|
5293
5359
|
},
|
|
5294
|
-
...spec.normalized ? { max: 100 } : {}
|
|
5360
|
+
...spec.normalized ? { max: 100 } : {},
|
|
5361
|
+
...spec.valueAxis?.min !== void 0 ? { min: spec.valueAxis.min } : {},
|
|
5362
|
+
...spec.valueAxis?.max !== void 0 ? { max: spec.valueAxis.max } : spec.valueAxis?.atLeast !== void 0 ? { max: (v) => Math.max(spec.valueAxis?.atLeast ?? 0, v.max) } : {},
|
|
5363
|
+
...spec.valueAxis?.step !== void 0 ? { interval: spec.valueAxis.step } : {}
|
|
5295
5364
|
};
|
|
5296
5365
|
const stack = spec.stacked || spec.normalized || spec.range ? "total" : void 0;
|
|
5297
5366
|
const single = series.length === 1 && !spec.range;
|
|
@@ -5837,7 +5906,7 @@ var builtInWidgets = [
|
|
|
5837
5906
|
];
|
|
5838
5907
|
|
|
5839
5908
|
// src/components/Grid.tsx
|
|
5840
|
-
import { useEffect as useEffect7, useMemo as useMemo7, useRef as
|
|
5909
|
+
import { useEffect as useEffect7, useMemo as useMemo7, useRef as useRef9, useState as useState7 } from "react";
|
|
5841
5910
|
import { Responsive, WidthProvider } from "react-grid-layout";
|
|
5842
5911
|
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
5843
5912
|
var ResponsiveGrid = WidthProvider(Responsive);
|
|
@@ -5873,7 +5942,8 @@ function layoutsForView(layouts, view, columns) {
|
|
|
5873
5942
|
} else out[bp] = desktop.map((i) => ({ i: i.panel, x: i.x, y: i.y, w: i.w, h: i.h }));
|
|
5874
5943
|
}
|
|
5875
5944
|
const panels = [...new Set(desktop.map((i) => i.panel))];
|
|
5876
|
-
|
|
5945
|
+
const fit = new Set(forView.flatMap((l) => (l.items ?? []).filter((i) => i.fit).map((i) => i.panel)));
|
|
5946
|
+
return { layouts: out, cols, panels, modes, fit, ordered: ordered.map((i) => ({ panel: i.panel, h: i.h })) };
|
|
5877
5947
|
}
|
|
5878
5948
|
var toItems = (l) => l.filter((i) => i.i !== "__drop__").map((i) => ({ panel: i.i, x: i.x, y: i.y, w: i.w, h: i.h }));
|
|
5879
5949
|
function Grid({
|
|
@@ -5892,9 +5962,9 @@ function Grid({
|
|
|
5892
5962
|
flowStyle,
|
|
5893
5963
|
dragOnto
|
|
5894
5964
|
}) {
|
|
5895
|
-
const bpRef =
|
|
5896
|
-
const [wrapEl, setWrapEl] =
|
|
5897
|
-
const [measured, setMeasured] =
|
|
5965
|
+
const bpRef = useRef9("desktop");
|
|
5966
|
+
const [wrapEl, setWrapEl] = useState7(null);
|
|
5967
|
+
const [measured, setMeasured] = useState7("desktop");
|
|
5898
5968
|
useEffect7(() => {
|
|
5899
5969
|
if (!wrapEl || typeof ResizeObserver === "undefined") return;
|
|
5900
5970
|
const ro = new ResizeObserver(([e]) => {
|
|
@@ -5917,6 +5987,44 @@ function Grid({
|
|
|
5917
5987
|
cols: base.cols
|
|
5918
5988
|
};
|
|
5919
5989
|
}, [base, hidden, editable]);
|
|
5990
|
+
const [fitRows, setFitRows] = useState7({});
|
|
5991
|
+
const fitted = useMemo7(() => {
|
|
5992
|
+
if (editable || base.fit.size === 0) return rgl;
|
|
5993
|
+
return Object.fromEntries(
|
|
5994
|
+
Object.entries(rgl).map(([bp, l]) => [
|
|
5995
|
+
bp,
|
|
5996
|
+
(l ?? []).map((i) => {
|
|
5997
|
+
const want = base.fit.has(i.i) ? fitRows[i.i] : void 0;
|
|
5998
|
+
return want && want > i.h ? { ...i, h: want } : i;
|
|
5999
|
+
})
|
|
6000
|
+
])
|
|
6001
|
+
);
|
|
6002
|
+
}, [rgl, base.fit, fitRows, editable]);
|
|
6003
|
+
const observeFit = (panel) => (el) => {
|
|
6004
|
+
const prev = fitObservers.current.get(panel);
|
|
6005
|
+
if (prev) {
|
|
6006
|
+
prev.disconnect();
|
|
6007
|
+
fitObservers.current.delete(panel);
|
|
6008
|
+
}
|
|
6009
|
+
if (!el || editable || !base.fit.has(panel) || typeof ResizeObserver === "undefined") return;
|
|
6010
|
+
const ro = new ResizeObserver(() => {
|
|
6011
|
+
const target2 = el.firstElementChild;
|
|
6012
|
+
const px = target2?.offsetHeight ?? 0;
|
|
6013
|
+
if (!px) return;
|
|
6014
|
+
const rows = Math.ceil((px + gap) / (rowHeight + gap));
|
|
6015
|
+
setFitRows((r) => r[panel] === rows ? r : { ...r, [panel]: rows });
|
|
6016
|
+
});
|
|
6017
|
+
const target = el.firstElementChild;
|
|
6018
|
+
if (target) ro.observe(target);
|
|
6019
|
+
fitObservers.current.set(panel, ro);
|
|
6020
|
+
};
|
|
6021
|
+
const fitObservers = useRef9(/* @__PURE__ */ new Map());
|
|
6022
|
+
useEffect7(() => {
|
|
6023
|
+
const observers = fitObservers.current;
|
|
6024
|
+
return () => {
|
|
6025
|
+
for (const ro of observers.values()) ro.disconnect();
|
|
6026
|
+
};
|
|
6027
|
+
}, []);
|
|
5920
6028
|
const active = breakpoint ?? measured;
|
|
5921
6029
|
if (base.modes[active] === "flow") {
|
|
5922
6030
|
const hide = editable ? void 0 : hidden;
|
|
@@ -5938,7 +6046,7 @@ function Grid({
|
|
|
5938
6046
|
ResponsiveGrid,
|
|
5939
6047
|
{
|
|
5940
6048
|
className: editable ? "ds-grid ds-grid-edit" : "ds-grid",
|
|
5941
|
-
layouts: breakpoint ? { [breakpoint]: rgl[breakpoint] ?? [] } :
|
|
6049
|
+
layouts: breakpoint ? { [breakpoint]: rgl[breakpoint] ?? [] } : fitted,
|
|
5942
6050
|
breakpoints: breakpoint ? { [breakpoint]: 0 } : BREAKPOINT_MIN,
|
|
5943
6051
|
cols: breakpoint ? { [breakpoint]: cols[breakpoint] } : cols,
|
|
5944
6052
|
rowHeight,
|
|
@@ -5972,13 +6080,16 @@ function Grid({
|
|
|
5972
6080
|
onLayoutChange?.(toItems(current), breakpoint ?? bpRef.current);
|
|
5973
6081
|
},
|
|
5974
6082
|
onResizeStop: (current) => editable && onLayoutChange?.(toItems(current), breakpoint ?? bpRef.current),
|
|
5975
|
-
children: panels.map((p, i) => /* @__PURE__ */ jsx26("div", { style: { ["--ds-i"]: i }, children:
|
|
6083
|
+
children: panels.map((p, i) => /* @__PURE__ */ jsx26("div", { "data-fit": base.fit.has(p) && !editable ? "" : void 0, style: { ["--ds-i"]: i }, children: base.fit.has(p) && !editable ? (
|
|
6084
|
+
// react-grid-layout replaces the ref of its own children, so the measuring ref sits one level down.
|
|
6085
|
+
/* @__PURE__ */ jsx26("div", { className: "ds-fit", ref: observeFit(p), children: children(p) })
|
|
6086
|
+
) : children(p) }, p))
|
|
5976
6087
|
}
|
|
5977
6088
|
) });
|
|
5978
6089
|
}
|
|
5979
6090
|
|
|
5980
6091
|
// src/components/ModalHost.tsx
|
|
5981
|
-
import { useCallback as useCallback5, useEffect as useEffect8, useRef as
|
|
6092
|
+
import { useCallback as useCallback5, useEffect as useEffect8, useRef as useRef10 } from "react";
|
|
5982
6093
|
import { jsx as jsx27, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
5983
6094
|
var WIDTH = { sm: "420px", md: "720px", lg: "1040px", xl: "1320px", full: "100%" };
|
|
5984
6095
|
var FOCUSABLE2 = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
@@ -6004,7 +6115,7 @@ function ModalHost() {
|
|
|
6004
6115
|
),
|
|
6005
6116
|
Object.is
|
|
6006
6117
|
);
|
|
6007
|
-
const latched =
|
|
6118
|
+
const latched = useRef10(/* @__PURE__ */ new Set());
|
|
6008
6119
|
useEffect8(() => {
|
|
6009
6120
|
const now = new Set(byExpression ? byExpression.split("\0") : []);
|
|
6010
6121
|
for (const id of [...latched.current])
|
|
@@ -6026,8 +6137,8 @@ function ModalHost() {
|
|
|
6026
6137
|
return "";
|
|
6027
6138
|
}
|
|
6028
6139
|
}
|
|
6029
|
-
const dialog =
|
|
6030
|
-
const scrim =
|
|
6140
|
+
const dialog = useRef10(null);
|
|
6141
|
+
const scrim = useRef10(null);
|
|
6031
6142
|
const openId = open?.id;
|
|
6032
6143
|
const close = useCallback5(() => {
|
|
6033
6144
|
if (!openId) return;
|
|
@@ -6036,7 +6147,7 @@ function ModalHost() {
|
|
|
6036
6147
|
if (on?.close) void runtime.runAction({ do: "sequence", steps: on.close });
|
|
6037
6148
|
runtime.store.dispatch(stateActions.closeModal());
|
|
6038
6149
|
}, [openId, runtime, modals]);
|
|
6039
|
-
const closeRef =
|
|
6150
|
+
const closeRef = useRef10(close);
|
|
6040
6151
|
closeRef.current = close;
|
|
6041
6152
|
useEffect8(() => {
|
|
6042
6153
|
if (!openId) return;
|
|
@@ -6122,12 +6233,12 @@ function ModalHost() {
|
|
|
6122
6233
|
}
|
|
6123
6234
|
|
|
6124
6235
|
// src/components/Provider.tsx
|
|
6125
|
-
import { createContext as createContext4, useContext as useContext5, useRef as
|
|
6236
|
+
import { createContext as createContext4, useContext as useContext5, useRef as useRef11 } from "react";
|
|
6126
6237
|
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
6127
6238
|
var SettingsContext = createContext4({});
|
|
6128
6239
|
function DashSpecProvider({ children, ...settings }) {
|
|
6129
6240
|
const outer = useContext5(SettingsContext);
|
|
6130
|
-
const last =
|
|
6241
|
+
const last = useRef11(
|
|
6131
6242
|
void 0
|
|
6132
6243
|
);
|
|
6133
6244
|
if (!last.current || last.current.outer !== outer || !shallowEqual2(last.current.settings, settings))
|
|
@@ -6170,9 +6281,9 @@ function pickTheme(name, themes, fallback) {
|
|
|
6170
6281
|
}
|
|
6171
6282
|
|
|
6172
6283
|
// src/components/Tour.tsx
|
|
6173
|
-
import { useCallback as useCallback6, useEffect as useEffect9, useId as useId4, useLayoutEffect as
|
|
6284
|
+
import { useCallback as useCallback6, useEffect as useEffect9, useId as useId4, useLayoutEffect as useLayoutEffect3, useRef as useRef12, useState as useState8 } from "react";
|
|
6174
6285
|
import { Fragment as Fragment9, jsx as jsx29, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
6175
|
-
var useClientLayoutEffect = typeof window === "undefined" ? useEffect9 :
|
|
6286
|
+
var useClientLayoutEffect = typeof window === "undefined" ? useEffect9 : useLayoutEffect3;
|
|
6176
6287
|
function panelElement(root, id) {
|
|
6177
6288
|
if (!root || !id) return null;
|
|
6178
6289
|
for (const el of root.querySelectorAll("[data-panel]"))
|
|
@@ -6181,11 +6292,11 @@ function panelElement(root, id) {
|
|
|
6181
6292
|
}
|
|
6182
6293
|
function TourButton({ steps }) {
|
|
6183
6294
|
const { runtime } = useDashboard();
|
|
6184
|
-
const [at, setAt] =
|
|
6185
|
-
const button =
|
|
6186
|
-
const dialog =
|
|
6187
|
-
const next =
|
|
6188
|
-
const [pos, setPos] =
|
|
6295
|
+
const [at, setAt] = useState8(null);
|
|
6296
|
+
const button = useRef12(null);
|
|
6297
|
+
const dialog = useRef12(null);
|
|
6298
|
+
const next = useRef12(null);
|
|
6299
|
+
const [pos, setPos] = useState8(null);
|
|
6189
6300
|
const titleId = useId4();
|
|
6190
6301
|
const textId = useId4();
|
|
6191
6302
|
const step = at === null ? void 0 : steps[at];
|
|
@@ -6310,7 +6421,7 @@ function TourButton({ steps }) {
|
|
|
6310
6421
|
}
|
|
6311
6422
|
|
|
6312
6423
|
// src/components/registryHooks.ts
|
|
6313
|
-
import { useCallback as useCallback7, useEffect as useEffect10, useRef as
|
|
6424
|
+
import { useCallback as useCallback7, useEffect as useEffect10, useRef as useRef13, useState as useState9, useSyncExternalStore as useSyncExternalStore3 } from "react";
|
|
6314
6425
|
var live = /* @__PURE__ */ new Map();
|
|
6315
6426
|
var listeners = /* @__PURE__ */ new Set();
|
|
6316
6427
|
var notify = () => {
|
|
@@ -6338,8 +6449,8 @@ function useRuntimeById(id) {
|
|
|
6338
6449
|
}
|
|
6339
6450
|
function useDashboardState(id, select) {
|
|
6340
6451
|
const rt = useRuntimeById(id);
|
|
6341
|
-
const [value, setValue] =
|
|
6342
|
-
const sel =
|
|
6452
|
+
const [value, setValue] = useState9(() => rt ? select(rt.getTree()) : void 0);
|
|
6453
|
+
const sel = useRef13(select);
|
|
6343
6454
|
sel.current = select;
|
|
6344
6455
|
useEffect10(() => {
|
|
6345
6456
|
if (!rt) return setValue(void 0);
|
|
@@ -6526,8 +6637,9 @@ var RENDERER_CSS = `
|
|
|
6526
6637
|
.ds-live[data-stale] > span { background: var(--ds-color-status-warn-fg); }
|
|
6527
6638
|
.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; }
|
|
6528
6639
|
.ds-info:hover, .ds-info:focus-visible { color: var(--ds-color-text-subtle); }
|
|
6529
|
-
.ds-
|
|
6530
|
-
.ds-
|
|
6640
|
+
.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; animation: ds-fade 120ms ease both; }
|
|
6641
|
+
.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); }
|
|
6642
|
+
.ds-tip[data-below]::after { top: auto; bottom: 100%; border-top-color: transparent; border-bottom-color: var(--ds-color-chart-tooltip-bg); }
|
|
6531
6643
|
|
|
6532
6644
|
.ds-chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font: 600 11px/1 var(--ds-font-body); white-space: nowrap; background: var(--ds-color-status-neutral-bg); color: var(--ds-color-status-neutral-fg); }
|
|
6533
6645
|
.ds-chip[data-tone="good"] { background: var(--ds-color-status-good-bg); color: var(--ds-color-status-good-fg); }
|
|
@@ -6549,6 +6661,12 @@ var RENDERER_CSS = `
|
|
|
6549
6661
|
.ds-tiles { overflow-y: auto; scrollbar-width: thin; grid-auto-rows: max-content; padding: 5px; margin: -5px; }
|
|
6550
6662
|
.ds-tiles > .ds-tile { min-height: max-content; }
|
|
6551
6663
|
.ds-flow .ds-tiles { height: auto; overflow-y: visible; }
|
|
6664
|
+
/* Grid items with fit: the panel takes its natural height (at least the cell's), so the grid can measure it. */
|
|
6665
|
+
[data-fit] > .ds-fit { height: 100%; }
|
|
6666
|
+
.ds-fit > .ds-panel { height: auto !important; min-height: 100%; }
|
|
6667
|
+
[data-fit] .ds-panel-body { flex: none; }
|
|
6668
|
+
[data-fit] .ds-tiles, [data-fit] .ds-table-wrap { height: auto; max-height: none; overflow-y: visible; }
|
|
6669
|
+
[data-fit] .ds-table-scroll { flex: none; }
|
|
6552
6670
|
.ds-tiles[data-wrap="off"] { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(var(--ds-tile-min, 128px), 1fr); overflow-x: auto; scroll-snap-type: x proximity; padding-bottom: 4px; }
|
|
6553
6671
|
.ds-tiles[data-wrap="off"] > * { scroll-snap-align: start; }
|
|
6554
6672
|
.ds-tile { min-width: 0; overflow-wrap: anywhere; }
|
|
@@ -6618,8 +6736,6 @@ var RENDERER_CSS = `
|
|
|
6618
6736
|
.ds-scrim[data-presentation="drawer"] .ds-dialog { animation: ds-slide-in 300ms cubic-bezier(.2,.7,.2,1) both; }
|
|
6619
6737
|
.ds-select, .ds-input, .ds-btn, .ds-chip, .ds-link { transition: border-color 140ms ease, background 140ms ease, color 140ms ease, box-shadow 140ms ease; }
|
|
6620
6738
|
.ds-select:hover, .ds-input:hover { border-color: var(--ds-color-action-primary); }
|
|
6621
|
-
.ds-info::after { transform: translateX(-50%) translateY(-2px); transition: opacity 140ms ease, transform 140ms ease; }
|
|
6622
|
-
.ds-info:hover::after, .ds-info:focus-visible::after { transform: translateX(-50%) translateY(0); }
|
|
6623
6739
|
.ds-grid-edit .react-grid-item > .ds-panel { animation: none; }
|
|
6624
6740
|
@media (prefers-reduced-motion: reduce) {
|
|
6625
6741
|
.ds-root *, .ds-root *::before, .ds-root *::after { animation: none !important; transition: none !important; }
|
|
@@ -6671,6 +6787,11 @@ var RENDERER_CSS = `
|
|
|
6671
6787
|
|
|
6672
6788
|
.ds-stepper { display: inline-flex; align-items: stretch; gap: 0; }
|
|
6673
6789
|
.ds-stepper .ds-pill-btn { border-radius: 0; border-left: 0; border-right: 0; }
|
|
6790
|
+
/* Between the arrows the select is one piece of the group: no border or ring of its own (square corners would
|
|
6791
|
+
draw a box inside the rounded group); keyboard focus gets an inset ring instead. */
|
|
6792
|
+
.ds-stepper .ds-pill-btn, .ds-stepper .ds-pill-btn:hover, .ds-stepper .ds-pill-btn[aria-expanded="true"] { border-color: transparent; box-shadow: none; }
|
|
6793
|
+
.ds-stepper .ds-pill-btn:focus { outline: none; }
|
|
6794
|
+
.ds-stepper .ds-pill-btn:focus-visible, .ds-stepper .ds-step:focus-visible { outline: 2px solid var(--ds-color-border-focus); outline-offset: -2px; }
|
|
6674
6795
|
.ds-step { display: inline-grid; place-items: center; width: var(--ds-control-height, 36px); height: var(--ds-control-height, 36px); border: 1px solid transparent; background: var(--ds-color-surface-selection); color: var(--ds-color-action-primary); cursor: pointer; transition: background 140ms ease, opacity 140ms ease; }
|
|
6675
6796
|
.ds-stepper > .ds-step:first-child { border-radius: var(--ds-radius-control) 0 0 var(--ds-radius-control); }
|
|
6676
6797
|
.ds-stepper > .ds-step:last-child { border-radius: 0 var(--ds-radius-control) var(--ds-radius-control) 0; }
|
|
@@ -6811,6 +6932,14 @@ var RENDERER_CSS = `
|
|
|
6811
6932
|
.ds-filter-pick[data-selected] { outline-color: var(--ds-color-action-primary); }
|
|
6812
6933
|
.ds-filter-pick * { pointer-events: none; }
|
|
6813
6934
|
.ds-filters[data-look="plain"] { background: transparent; padding-left: 0; padding-right: 0; box-shadow: none; }
|
|
6935
|
+
/* look "segmented": the icon and the filters share one sunken track; each filter is a borderless chip on the card
|
|
6936
|
+
colour, with no leading icon; the page stepper's arrows use the selection colour. */
|
|
6937
|
+
.ds-filters-track { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 2px; border-radius: var(--ds-radius-control); background: var(--ds-color-surface-sunken); }
|
|
6938
|
+
.ds-filters[data-look="segmented"] .ds-filters-icon { border: 0; width: auto; padding: 0 var(--ds-space-sm); }
|
|
6939
|
+
.ds-filters[data-look="segmented"] .ds-pill-btn { border: 0; border-radius: calc(var(--ds-radius-control) / 2); background: var(--ds-color-surface-card); box-shadow: none; padding: 0 var(--ds-space-sm); font-family: var(--ds-font-heading); }
|
|
6940
|
+
.ds-filters[data-look="segmented"] .ds-pill-btn > svg:first-child:not(:last-child) { display: none; }
|
|
6941
|
+
.ds-filters[data-look="segmented"] .ds-stepper { gap: 2px; }
|
|
6942
|
+
.ds-filters[data-look="segmented"] .ds-step { border: 0; border-radius: calc(var(--ds-radius-control) / 2); background: var(--ds-color-surface-selection); width: 32px; }
|
|
6814
6943
|
.ds-filters[data-editable] { cursor: pointer; outline: 1.5px dashed transparent; outline-offset: 2px; transition: outline-color 120ms; }
|
|
6815
6944
|
.ds-filters[data-editable]:hover { outline-color: color-mix(in srgb, var(--ds-color-action-primary) 45%, transparent); }
|
|
6816
6945
|
.ds-filters[data-picked] { outline: 2px solid var(--ds-color-action-primary) !important; }
|
|
@@ -6958,14 +7087,14 @@ function usesScripts(doc) {
|
|
|
6958
7087
|
}
|
|
6959
7088
|
var sameJson = (a, b) => Object.is(a, b) || JSON.stringify(a) === JSON.stringify(b);
|
|
6960
7089
|
function useStableList(list) {
|
|
6961
|
-
const ref =
|
|
7090
|
+
const ref = useRef14(list);
|
|
6962
7091
|
const prev = ref.current;
|
|
6963
7092
|
const same = prev === list || prev && list && prev.length === list.length && prev.every((x, i) => x === list[i]);
|
|
6964
7093
|
if (!same) ref.current = list;
|
|
6965
7094
|
return ref.current;
|
|
6966
7095
|
}
|
|
6967
7096
|
function useStableUi(ui) {
|
|
6968
|
-
const ref =
|
|
7097
|
+
const ref = useRef14(ui);
|
|
6969
7098
|
const prev = ref.current;
|
|
6970
7099
|
const next = ui;
|
|
6971
7100
|
const flat = (a, b) => a === b || !!a && !!b && Object.keys(a).length === Object.keys(b).length && Object.keys(a).every((k) => Object.is(a[k], b[k]));
|
|
@@ -7051,8 +7180,8 @@ var DashboardRenderer = forwardRef(
|
|
|
7051
7180
|
const forRuntime = useMemo8(() => loaded, [runtimeKey]);
|
|
7052
7181
|
const mode = props.scripts ?? "sandbox";
|
|
7053
7182
|
const needsSandbox = loaded.status === "valid" && mode === "sandbox" && usesScripts(loaded.document);
|
|
7054
|
-
const [sandbox, setSandbox] =
|
|
7055
|
-
const [sandboxError, setSandboxError] =
|
|
7183
|
+
const [sandbox, setSandbox] = useState10(null);
|
|
7184
|
+
const [sandboxError, setSandboxError] = useState10(null);
|
|
7056
7185
|
useEffect11(() => {
|
|
7057
7186
|
if (!needsSandbox || sandbox) return;
|
|
7058
7187
|
let cancelled = false;
|
|
@@ -7061,11 +7190,11 @@ var DashboardRenderer = forwardRef(
|
|
|
7061
7190
|
cancelled = true;
|
|
7062
7191
|
};
|
|
7063
7192
|
}, [needsSandbox, sandbox]);
|
|
7064
|
-
const latest =
|
|
7193
|
+
const latest = useRef14(props);
|
|
7065
7194
|
latest.current = props;
|
|
7066
7195
|
const prefix = props.id ? `${props.id}.` : "v.";
|
|
7067
7196
|
const useUrl = (props.urlSync ?? !props.editable) && typeof window !== "undefined";
|
|
7068
|
-
const urlOwner =
|
|
7197
|
+
const urlOwner = useRef14({});
|
|
7069
7198
|
const runtime = useMemo8(() => {
|
|
7070
7199
|
if (forRuntime.status !== "valid") return null;
|
|
7071
7200
|
if (needsSandbox && !sandbox) return null;
|
|
@@ -7174,7 +7303,7 @@ var DashboardRenderer = forwardRef(
|
|
|
7174
7303
|
}, [runtime, stateKey]);
|
|
7175
7304
|
const hostDataKey = props.data ? JSON.stringify(props.data) : "";
|
|
7176
7305
|
const contextKey = props.context ? JSON.stringify(props.context) : "";
|
|
7177
|
-
const hostInputsSeen =
|
|
7306
|
+
const hostInputsSeen = useRef14(null);
|
|
7178
7307
|
useEffect11(() => {
|
|
7179
7308
|
if (!runtime) return;
|
|
7180
7309
|
const seen = hostInputsSeen.current;
|
|
@@ -7622,6 +7751,7 @@ export {
|
|
|
7622
7751
|
safeLink,
|
|
7623
7752
|
satisfies,
|
|
7624
7753
|
scope,
|
|
7754
|
+
stripStrings,
|
|
7625
7755
|
templateReferences,
|
|
7626
7756
|
themeCssVars,
|
|
7627
7757
|
themeStylesheet,
|