@dashspec/renderer 0.1.3 → 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 +22 -1
- package/dist/{chunk-HB2WSKUI.js → chunk-2HHYJ5WX.js} +13 -4
- package/dist/chunk-2HHYJ5WX.js.map +1 -0
- package/dist/{core-uvLuoQ3X.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 +215 -88
- package/dist/index.js.map +1 -1
- package/dist/schema.json +5 -1
- package/docs/json-format.md +5 -3
- package/docs/widgets.md +1 -1
- package/package.json +1 -1
- package/dist/chunk-HB2WSKUI.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;
|
|
@@ -5840,7 +5906,7 @@ var builtInWidgets = [
|
|
|
5840
5906
|
];
|
|
5841
5907
|
|
|
5842
5908
|
// src/components/Grid.tsx
|
|
5843
|
-
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";
|
|
5844
5910
|
import { Responsive, WidthProvider } from "react-grid-layout";
|
|
5845
5911
|
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
5846
5912
|
var ResponsiveGrid = WidthProvider(Responsive);
|
|
@@ -5876,7 +5942,8 @@ function layoutsForView(layouts, view, columns) {
|
|
|
5876
5942
|
} else out[bp] = desktop.map((i) => ({ i: i.panel, x: i.x, y: i.y, w: i.w, h: i.h }));
|
|
5877
5943
|
}
|
|
5878
5944
|
const panels = [...new Set(desktop.map((i) => i.panel))];
|
|
5879
|
-
|
|
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 })) };
|
|
5880
5947
|
}
|
|
5881
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 }));
|
|
5882
5949
|
function Grid({
|
|
@@ -5895,9 +5962,9 @@ function Grid({
|
|
|
5895
5962
|
flowStyle,
|
|
5896
5963
|
dragOnto
|
|
5897
5964
|
}) {
|
|
5898
|
-
const bpRef =
|
|
5899
|
-
const [wrapEl, setWrapEl] =
|
|
5900
|
-
const [measured, setMeasured] =
|
|
5965
|
+
const bpRef = useRef9("desktop");
|
|
5966
|
+
const [wrapEl, setWrapEl] = useState7(null);
|
|
5967
|
+
const [measured, setMeasured] = useState7("desktop");
|
|
5901
5968
|
useEffect7(() => {
|
|
5902
5969
|
if (!wrapEl || typeof ResizeObserver === "undefined") return;
|
|
5903
5970
|
const ro = new ResizeObserver(([e]) => {
|
|
@@ -5920,6 +5987,44 @@ function Grid({
|
|
|
5920
5987
|
cols: base.cols
|
|
5921
5988
|
};
|
|
5922
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
|
+
}, []);
|
|
5923
6028
|
const active = breakpoint ?? measured;
|
|
5924
6029
|
if (base.modes[active] === "flow") {
|
|
5925
6030
|
const hide = editable ? void 0 : hidden;
|
|
@@ -5941,7 +6046,7 @@ function Grid({
|
|
|
5941
6046
|
ResponsiveGrid,
|
|
5942
6047
|
{
|
|
5943
6048
|
className: editable ? "ds-grid ds-grid-edit" : "ds-grid",
|
|
5944
|
-
layouts: breakpoint ? { [breakpoint]: rgl[breakpoint] ?? [] } :
|
|
6049
|
+
layouts: breakpoint ? { [breakpoint]: rgl[breakpoint] ?? [] } : fitted,
|
|
5945
6050
|
breakpoints: breakpoint ? { [breakpoint]: 0 } : BREAKPOINT_MIN,
|
|
5946
6051
|
cols: breakpoint ? { [breakpoint]: cols[breakpoint] } : cols,
|
|
5947
6052
|
rowHeight,
|
|
@@ -5975,13 +6080,16 @@ function Grid({
|
|
|
5975
6080
|
onLayoutChange?.(toItems(current), breakpoint ?? bpRef.current);
|
|
5976
6081
|
},
|
|
5977
6082
|
onResizeStop: (current) => editable && onLayoutChange?.(toItems(current), breakpoint ?? bpRef.current),
|
|
5978
|
-
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))
|
|
5979
6087
|
}
|
|
5980
6088
|
) });
|
|
5981
6089
|
}
|
|
5982
6090
|
|
|
5983
6091
|
// src/components/ModalHost.tsx
|
|
5984
|
-
import { useCallback as useCallback5, useEffect as useEffect8, useRef as
|
|
6092
|
+
import { useCallback as useCallback5, useEffect as useEffect8, useRef as useRef10 } from "react";
|
|
5985
6093
|
import { jsx as jsx27, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
5986
6094
|
var WIDTH = { sm: "420px", md: "720px", lg: "1040px", xl: "1320px", full: "100%" };
|
|
5987
6095
|
var FOCUSABLE2 = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
@@ -6007,7 +6115,7 @@ function ModalHost() {
|
|
|
6007
6115
|
),
|
|
6008
6116
|
Object.is
|
|
6009
6117
|
);
|
|
6010
|
-
const latched =
|
|
6118
|
+
const latched = useRef10(/* @__PURE__ */ new Set());
|
|
6011
6119
|
useEffect8(() => {
|
|
6012
6120
|
const now = new Set(byExpression ? byExpression.split("\0") : []);
|
|
6013
6121
|
for (const id of [...latched.current])
|
|
@@ -6029,8 +6137,8 @@ function ModalHost() {
|
|
|
6029
6137
|
return "";
|
|
6030
6138
|
}
|
|
6031
6139
|
}
|
|
6032
|
-
const dialog =
|
|
6033
|
-
const scrim =
|
|
6140
|
+
const dialog = useRef10(null);
|
|
6141
|
+
const scrim = useRef10(null);
|
|
6034
6142
|
const openId = open?.id;
|
|
6035
6143
|
const close = useCallback5(() => {
|
|
6036
6144
|
if (!openId) return;
|
|
@@ -6039,7 +6147,7 @@ function ModalHost() {
|
|
|
6039
6147
|
if (on?.close) void runtime.runAction({ do: "sequence", steps: on.close });
|
|
6040
6148
|
runtime.store.dispatch(stateActions.closeModal());
|
|
6041
6149
|
}, [openId, runtime, modals]);
|
|
6042
|
-
const closeRef =
|
|
6150
|
+
const closeRef = useRef10(close);
|
|
6043
6151
|
closeRef.current = close;
|
|
6044
6152
|
useEffect8(() => {
|
|
6045
6153
|
if (!openId) return;
|
|
@@ -6125,12 +6233,12 @@ function ModalHost() {
|
|
|
6125
6233
|
}
|
|
6126
6234
|
|
|
6127
6235
|
// src/components/Provider.tsx
|
|
6128
|
-
import { createContext as createContext4, useContext as useContext5, useRef as
|
|
6236
|
+
import { createContext as createContext4, useContext as useContext5, useRef as useRef11 } from "react";
|
|
6129
6237
|
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
6130
6238
|
var SettingsContext = createContext4({});
|
|
6131
6239
|
function DashSpecProvider({ children, ...settings }) {
|
|
6132
6240
|
const outer = useContext5(SettingsContext);
|
|
6133
|
-
const last =
|
|
6241
|
+
const last = useRef11(
|
|
6134
6242
|
void 0
|
|
6135
6243
|
);
|
|
6136
6244
|
if (!last.current || last.current.outer !== outer || !shallowEqual2(last.current.settings, settings))
|
|
@@ -6173,9 +6281,9 @@ function pickTheme(name, themes, fallback) {
|
|
|
6173
6281
|
}
|
|
6174
6282
|
|
|
6175
6283
|
// src/components/Tour.tsx
|
|
6176
|
-
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";
|
|
6177
6285
|
import { Fragment as Fragment9, jsx as jsx29, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
6178
|
-
var useClientLayoutEffect = typeof window === "undefined" ? useEffect9 :
|
|
6286
|
+
var useClientLayoutEffect = typeof window === "undefined" ? useEffect9 : useLayoutEffect3;
|
|
6179
6287
|
function panelElement(root, id) {
|
|
6180
6288
|
if (!root || !id) return null;
|
|
6181
6289
|
for (const el of root.querySelectorAll("[data-panel]"))
|
|
@@ -6184,11 +6292,11 @@ function panelElement(root, id) {
|
|
|
6184
6292
|
}
|
|
6185
6293
|
function TourButton({ steps }) {
|
|
6186
6294
|
const { runtime } = useDashboard();
|
|
6187
|
-
const [at, setAt] =
|
|
6188
|
-
const button =
|
|
6189
|
-
const dialog =
|
|
6190
|
-
const next =
|
|
6191
|
-
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);
|
|
6192
6300
|
const titleId = useId4();
|
|
6193
6301
|
const textId = useId4();
|
|
6194
6302
|
const step = at === null ? void 0 : steps[at];
|
|
@@ -6313,7 +6421,7 @@ function TourButton({ steps }) {
|
|
|
6313
6421
|
}
|
|
6314
6422
|
|
|
6315
6423
|
// src/components/registryHooks.ts
|
|
6316
|
-
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";
|
|
6317
6425
|
var live = /* @__PURE__ */ new Map();
|
|
6318
6426
|
var listeners = /* @__PURE__ */ new Set();
|
|
6319
6427
|
var notify = () => {
|
|
@@ -6341,8 +6449,8 @@ function useRuntimeById(id) {
|
|
|
6341
6449
|
}
|
|
6342
6450
|
function useDashboardState(id, select) {
|
|
6343
6451
|
const rt = useRuntimeById(id);
|
|
6344
|
-
const [value, setValue] =
|
|
6345
|
-
const sel =
|
|
6452
|
+
const [value, setValue] = useState9(() => rt ? select(rt.getTree()) : void 0);
|
|
6453
|
+
const sel = useRef13(select);
|
|
6346
6454
|
sel.current = select;
|
|
6347
6455
|
useEffect10(() => {
|
|
6348
6456
|
if (!rt) return setValue(void 0);
|
|
@@ -6529,8 +6637,9 @@ var RENDERER_CSS = `
|
|
|
6529
6637
|
.ds-live[data-stale] > span { background: var(--ds-color-status-warn-fg); }
|
|
6530
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; }
|
|
6531
6639
|
.ds-info:hover, .ds-info:focus-visible { color: var(--ds-color-text-subtle); }
|
|
6532
|
-
.ds-
|
|
6533
|
-
.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); }
|
|
6534
6643
|
|
|
6535
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); }
|
|
6536
6645
|
.ds-chip[data-tone="good"] { background: var(--ds-color-status-good-bg); color: var(--ds-color-status-good-fg); }
|
|
@@ -6552,6 +6661,12 @@ var RENDERER_CSS = `
|
|
|
6552
6661
|
.ds-tiles { overflow-y: auto; scrollbar-width: thin; grid-auto-rows: max-content; padding: 5px; margin: -5px; }
|
|
6553
6662
|
.ds-tiles > .ds-tile { min-height: max-content; }
|
|
6554
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; }
|
|
6555
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; }
|
|
6556
6671
|
.ds-tiles[data-wrap="off"] > * { scroll-snap-align: start; }
|
|
6557
6672
|
.ds-tile { min-width: 0; overflow-wrap: anywhere; }
|
|
@@ -6621,8 +6736,6 @@ var RENDERER_CSS = `
|
|
|
6621
6736
|
.ds-scrim[data-presentation="drawer"] .ds-dialog { animation: ds-slide-in 300ms cubic-bezier(.2,.7,.2,1) both; }
|
|
6622
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; }
|
|
6623
6738
|
.ds-select:hover, .ds-input:hover { border-color: var(--ds-color-action-primary); }
|
|
6624
|
-
.ds-info::after { transform: translateX(-50%) translateY(-2px); transition: opacity 140ms ease, transform 140ms ease; }
|
|
6625
|
-
.ds-info:hover::after, .ds-info:focus-visible::after { transform: translateX(-50%) translateY(0); }
|
|
6626
6739
|
.ds-grid-edit .react-grid-item > .ds-panel { animation: none; }
|
|
6627
6740
|
@media (prefers-reduced-motion: reduce) {
|
|
6628
6741
|
.ds-root *, .ds-root *::before, .ds-root *::after { animation: none !important; transition: none !important; }
|
|
@@ -6674,6 +6787,11 @@ var RENDERER_CSS = `
|
|
|
6674
6787
|
|
|
6675
6788
|
.ds-stepper { display: inline-flex; align-items: stretch; gap: 0; }
|
|
6676
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; }
|
|
6677
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; }
|
|
6678
6796
|
.ds-stepper > .ds-step:first-child { border-radius: var(--ds-radius-control) 0 0 var(--ds-radius-control); }
|
|
6679
6797
|
.ds-stepper > .ds-step:last-child { border-radius: 0 var(--ds-radius-control) var(--ds-radius-control) 0; }
|
|
@@ -6814,6 +6932,14 @@ var RENDERER_CSS = `
|
|
|
6814
6932
|
.ds-filter-pick[data-selected] { outline-color: var(--ds-color-action-primary); }
|
|
6815
6933
|
.ds-filter-pick * { pointer-events: none; }
|
|
6816
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; }
|
|
6817
6943
|
.ds-filters[data-editable] { cursor: pointer; outline: 1.5px dashed transparent; outline-offset: 2px; transition: outline-color 120ms; }
|
|
6818
6944
|
.ds-filters[data-editable]:hover { outline-color: color-mix(in srgb, var(--ds-color-action-primary) 45%, transparent); }
|
|
6819
6945
|
.ds-filters[data-picked] { outline: 2px solid var(--ds-color-action-primary) !important; }
|
|
@@ -6961,14 +7087,14 @@ function usesScripts(doc) {
|
|
|
6961
7087
|
}
|
|
6962
7088
|
var sameJson = (a, b) => Object.is(a, b) || JSON.stringify(a) === JSON.stringify(b);
|
|
6963
7089
|
function useStableList(list) {
|
|
6964
|
-
const ref =
|
|
7090
|
+
const ref = useRef14(list);
|
|
6965
7091
|
const prev = ref.current;
|
|
6966
7092
|
const same = prev === list || prev && list && prev.length === list.length && prev.every((x, i) => x === list[i]);
|
|
6967
7093
|
if (!same) ref.current = list;
|
|
6968
7094
|
return ref.current;
|
|
6969
7095
|
}
|
|
6970
7096
|
function useStableUi(ui) {
|
|
6971
|
-
const ref =
|
|
7097
|
+
const ref = useRef14(ui);
|
|
6972
7098
|
const prev = ref.current;
|
|
6973
7099
|
const next = ui;
|
|
6974
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]));
|
|
@@ -7054,8 +7180,8 @@ var DashboardRenderer = forwardRef(
|
|
|
7054
7180
|
const forRuntime = useMemo8(() => loaded, [runtimeKey]);
|
|
7055
7181
|
const mode = props.scripts ?? "sandbox";
|
|
7056
7182
|
const needsSandbox = loaded.status === "valid" && mode === "sandbox" && usesScripts(loaded.document);
|
|
7057
|
-
const [sandbox, setSandbox] =
|
|
7058
|
-
const [sandboxError, setSandboxError] =
|
|
7183
|
+
const [sandbox, setSandbox] = useState10(null);
|
|
7184
|
+
const [sandboxError, setSandboxError] = useState10(null);
|
|
7059
7185
|
useEffect11(() => {
|
|
7060
7186
|
if (!needsSandbox || sandbox) return;
|
|
7061
7187
|
let cancelled = false;
|
|
@@ -7064,11 +7190,11 @@ var DashboardRenderer = forwardRef(
|
|
|
7064
7190
|
cancelled = true;
|
|
7065
7191
|
};
|
|
7066
7192
|
}, [needsSandbox, sandbox]);
|
|
7067
|
-
const latest =
|
|
7193
|
+
const latest = useRef14(props);
|
|
7068
7194
|
latest.current = props;
|
|
7069
7195
|
const prefix = props.id ? `${props.id}.` : "v.";
|
|
7070
7196
|
const useUrl = (props.urlSync ?? !props.editable) && typeof window !== "undefined";
|
|
7071
|
-
const urlOwner =
|
|
7197
|
+
const urlOwner = useRef14({});
|
|
7072
7198
|
const runtime = useMemo8(() => {
|
|
7073
7199
|
if (forRuntime.status !== "valid") return null;
|
|
7074
7200
|
if (needsSandbox && !sandbox) return null;
|
|
@@ -7177,7 +7303,7 @@ var DashboardRenderer = forwardRef(
|
|
|
7177
7303
|
}, [runtime, stateKey]);
|
|
7178
7304
|
const hostDataKey = props.data ? JSON.stringify(props.data) : "";
|
|
7179
7305
|
const contextKey = props.context ? JSON.stringify(props.context) : "";
|
|
7180
|
-
const hostInputsSeen =
|
|
7306
|
+
const hostInputsSeen = useRef14(null);
|
|
7181
7307
|
useEffect11(() => {
|
|
7182
7308
|
if (!runtime) return;
|
|
7183
7309
|
const seen = hostInputsSeen.current;
|
|
@@ -7625,6 +7751,7 @@ export {
|
|
|
7625
7751
|
safeLink,
|
|
7626
7752
|
satisfies,
|
|
7627
7753
|
scope,
|
|
7754
|
+
stripStrings,
|
|
7628
7755
|
templateReferences,
|
|
7629
7756
|
themeCssVars,
|
|
7630
7757
|
themeStylesheet,
|