@dashspec/renderer 0.1.43 → 0.1.45
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 +24 -0
- package/dist/{FlowMapView-BSTKU7D4.js → FlowMapView-7ROMAXSY.js} +20 -20
- package/dist/FlowMapView-7ROMAXSY.js.map +1 -0
- package/dist/{chunk-IBSZQEYY.js → chunk-YPHHTC36.js} +4 -2
- package/dist/chunk-YPHHTC36.js.map +1 -0
- package/dist/{core-DJ1ABh7P.d.ts → core-Clqj6_ee.d.ts} +17 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.js +630 -621
- package/dist/index.js.map +1 -1
- package/dist/schema.json +5 -0
- package/docs/json-format.md +1 -0
- package/package.json +1 -1
- package/dist/FlowMapView-BSTKU7D4.js.map +0 -1
- package/dist/chunk-IBSZQEYY.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -102,7 +102,7 @@ import {
|
|
|
102
102
|
translator,
|
|
103
103
|
validateDocument,
|
|
104
104
|
widgetChecks
|
|
105
|
-
} from "./chunk-
|
|
105
|
+
} from "./chunk-YPHHTC36.js";
|
|
106
106
|
import {
|
|
107
107
|
Chips,
|
|
108
108
|
asRows,
|
|
@@ -499,6 +499,8 @@ function createActionRunner(deps) {
|
|
|
499
499
|
deps.dispatch(stateActions.openModal({ id: act.modal, args }));
|
|
500
500
|
const m = doc.spec.modals?.[act.modal];
|
|
501
501
|
if (m?.datasources) deps.engine.want(Object.keys(m.datasources));
|
|
502
|
+
const onOpen = m?.on?.open;
|
|
503
|
+
if (onOpen) await runAction({ do: "sequence", steps: onOpen }, event, key, mode);
|
|
502
504
|
return;
|
|
503
505
|
}
|
|
504
506
|
case "closeModal":
|
|
@@ -1986,7 +1988,7 @@ function partsCss(theme, scope2, mode = "light") {
|
|
|
1986
1988
|
],
|
|
1987
1989
|
[".ds-live[data-stale] > span", decl({ background: c(p.liveDot?.staleColor) })],
|
|
1988
1990
|
[
|
|
1989
|
-
".ds-
|
|
1991
|
+
".ds-flowmap-hover",
|
|
1990
1992
|
decl({
|
|
1991
1993
|
padding: p.popover?.padding,
|
|
1992
1994
|
"border-radius": px(p.popover?.radius),
|
|
@@ -2283,50 +2285,135 @@ var CardGrid = defineWidget({
|
|
|
2283
2285
|
|
|
2284
2286
|
// src/widgets/builtins/Container.tsx
|
|
2285
2287
|
import "zod";
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
component: function ContainerWidget({ spec, renderSlot }) {
|
|
2304
|
-
const style = {
|
|
2305
|
-
display: "flex",
|
|
2306
|
-
flexDirection: spec.direction,
|
|
2307
|
-
flexWrap: spec.wrap ? "wrap" : "nowrap",
|
|
2308
|
-
gap: spec.gap,
|
|
2309
|
-
justifyContent: JUSTIFY[spec.justify],
|
|
2310
|
-
alignItems: ALIGN[spec.align],
|
|
2311
|
-
// An equal split is across a row; in a column, children keep their own height.
|
|
2312
|
-
["--ds-child-flex"]: spec.equal && spec.direction === "row" ? `1 1 ${spec.childMinWidth}px` : "0 0 auto",
|
|
2313
|
-
["--ds-child-min"]: `${spec.direction === "row" ? spec.childMinWidth : 0}px`,
|
|
2314
|
-
overflow: spec.scroll ? "auto" : "visible"
|
|
2315
|
-
};
|
|
2316
|
-
return renderSlot("items", {
|
|
2317
|
-
className: "ds-container",
|
|
2318
|
-
style,
|
|
2319
|
-
empty: /* @__PURE__ */ jsx4("span", { className: "ds-slot-hint", children: "Drop widgets here" })
|
|
2320
|
-
});
|
|
2288
|
+
|
|
2289
|
+
// src/widgets/shared/clickable.ts
|
|
2290
|
+
import { useContext as useContext5 } from "react";
|
|
2291
|
+
|
|
2292
|
+
// src/components/PanelFrame.tsx
|
|
2293
|
+
import { useCallback as useCallback3, useEffect as useEffect4, useId as useId4, useMemo as useMemo3, useRef as useRef5, useState as useState4 } from "react";
|
|
2294
|
+
|
|
2295
|
+
// src/widgets/parseProps.ts
|
|
2296
|
+
function without(value, path) {
|
|
2297
|
+
if (path.length === 0 || value === null || typeof value !== "object") return value;
|
|
2298
|
+
const [head, ...rest] = path;
|
|
2299
|
+
if (Array.isArray(value)) {
|
|
2300
|
+
if (typeof head !== "number" || head < 0 || head >= value.length) return value;
|
|
2301
|
+
const copy2 = [...value];
|
|
2302
|
+
if (rest.length === 0) copy2.splice(head, 1);
|
|
2303
|
+
else copy2[head] = without(copy2[head], rest);
|
|
2304
|
+
return copy2;
|
|
2321
2305
|
}
|
|
2322
|
-
|
|
2306
|
+
if (!Object.hasOwn(value, head)) return value;
|
|
2307
|
+
const copy = { ...value };
|
|
2308
|
+
if (rest.length === 0) delete copy[head];
|
|
2309
|
+
else copy[head] = without(copy[head], rest);
|
|
2310
|
+
return copy;
|
|
2311
|
+
}
|
|
2312
|
+
function parseWidgetProps(schema, props) {
|
|
2313
|
+
let current = props;
|
|
2314
|
+
const dropped = [];
|
|
2315
|
+
for (let round = 0; round < 25; round++) {
|
|
2316
|
+
const r = schema.safeParse(current);
|
|
2317
|
+
if (r.success) return { props: r.data, dropped };
|
|
2318
|
+
const issue = r.error.issues.find((i) => i.path.length > 0);
|
|
2319
|
+
if (!issue) break;
|
|
2320
|
+
const lastIndex = issue.path.reduce((at, k, i) => typeof k === "number" ? i : at, -1);
|
|
2321
|
+
const path = lastIndex >= 0 ? issue.path.slice(0, lastIndex + 1) : issue.path;
|
|
2322
|
+
const next = without(current, path);
|
|
2323
|
+
if (next === current) break;
|
|
2324
|
+
dropped.push(path.join("."));
|
|
2325
|
+
current = next;
|
|
2326
|
+
}
|
|
2327
|
+
return { props, dropped };
|
|
2328
|
+
}
|
|
2323
2329
|
|
|
2324
|
-
// src/widgets/
|
|
2325
|
-
import "
|
|
2330
|
+
// src/widgets/shared/InfoTip.tsx
|
|
2331
|
+
import { useEffect, useLayoutEffect, useRef as useRef2, useState } from "react";
|
|
2332
|
+
import { createPortal } from "react-dom";
|
|
2333
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2334
|
+
function InfoTip({ text: text2 }) {
|
|
2335
|
+
const ref = useRef2(null);
|
|
2336
|
+
const tip = useRef2(null);
|
|
2337
|
+
const [open, setOpen] = useState(false);
|
|
2338
|
+
const [mounted, setMounted] = useState(false);
|
|
2339
|
+
const closing = useRef2(void 0);
|
|
2340
|
+
useEffect(() => () => clearTimeout(closing.current), []);
|
|
2341
|
+
const show = () => {
|
|
2342
|
+
clearTimeout(closing.current);
|
|
2343
|
+
setMounted(true);
|
|
2344
|
+
setOpen(true);
|
|
2345
|
+
};
|
|
2346
|
+
const hide = () => {
|
|
2347
|
+
setOpen(false);
|
|
2348
|
+
clearTimeout(closing.current);
|
|
2349
|
+
closing.current = setTimeout(() => {
|
|
2350
|
+
setMounted(false);
|
|
2351
|
+
setPos(null);
|
|
2352
|
+
}, 160);
|
|
2353
|
+
};
|
|
2354
|
+
const [pos, setPos] = useState(null);
|
|
2355
|
+
useLayoutEffect(() => {
|
|
2356
|
+
if (!mounted || !ref.current || !tip.current) return;
|
|
2357
|
+
const a = ref.current.getBoundingClientRect();
|
|
2358
|
+
const t = tip.current.getBoundingClientRect();
|
|
2359
|
+
const gap = 8;
|
|
2360
|
+
const margin = 8;
|
|
2361
|
+
const vw = window.innerWidth || document.documentElement.clientWidth;
|
|
2362
|
+
const box = ref.current.closest(".ds-root")?.getBoundingClientRect();
|
|
2363
|
+
const minX = Math.max(margin, (box?.left ?? 0) + margin);
|
|
2364
|
+
const maxX = Math.min(vw, box?.right ?? vw) - margin;
|
|
2365
|
+
const minY = Math.max(margin, (box?.top ?? 0) + margin);
|
|
2366
|
+
const below = a.top - t.height - gap < minY;
|
|
2367
|
+
const centre = a.left + a.width / 2;
|
|
2368
|
+
const left = Math.min(Math.max(centre - t.width / 2, minX), Math.max(minX, maxX - t.width));
|
|
2369
|
+
setPos({ left, top: below ? a.bottom + gap : a.top - t.height - gap, arrow: centre - left, below });
|
|
2370
|
+
}, [mounted]);
|
|
2371
|
+
const root = ref.current?.closest(".ds-root") ?? (typeof document !== "undefined" ? document.body : null);
|
|
2372
|
+
return /* @__PURE__ */ jsxs4(
|
|
2373
|
+
"button",
|
|
2374
|
+
{
|
|
2375
|
+
ref,
|
|
2376
|
+
type: "button",
|
|
2377
|
+
className: "ds-info",
|
|
2378
|
+
"aria-label": text2,
|
|
2379
|
+
onClick: (e) => e.stopPropagation(),
|
|
2380
|
+
onMouseEnter: show,
|
|
2381
|
+
onMouseLeave: hide,
|
|
2382
|
+
onFocus: show,
|
|
2383
|
+
onBlur: hide,
|
|
2384
|
+
children: [
|
|
2385
|
+
/* @__PURE__ */ jsxs4("svg", { viewBox: "0 0 16 16", width: "14", height: "14", "aria-hidden": "true", children: [
|
|
2386
|
+
/* @__PURE__ */ jsx4("circle", { cx: "8", cy: "8", r: "6.5", fill: "none", stroke: "currentColor", strokeWidth: "1" }),
|
|
2387
|
+
/* @__PURE__ */ jsx4("path", { d: "M8 7.2v3.6M8 5.2v.1", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round" })
|
|
2388
|
+
] }),
|
|
2389
|
+
mounted && root && createPortal(
|
|
2390
|
+
/* @__PURE__ */ jsx4(
|
|
2391
|
+
"span",
|
|
2392
|
+
{
|
|
2393
|
+
ref: tip,
|
|
2394
|
+
className: "ds-tip",
|
|
2395
|
+
role: "tooltip",
|
|
2396
|
+
"data-below": pos?.below || void 0,
|
|
2397
|
+
"data-open": open && pos ? "" : void 0,
|
|
2398
|
+
style: {
|
|
2399
|
+
left: pos?.left ?? 0,
|
|
2400
|
+
top: pos?.top ?? 0,
|
|
2401
|
+
visibility: pos ? "visible" : "hidden",
|
|
2402
|
+
["--ds-tip-arrow"]: `${pos?.arrow ?? 0}px`
|
|
2403
|
+
},
|
|
2404
|
+
children: text2
|
|
2405
|
+
}
|
|
2406
|
+
),
|
|
2407
|
+
root
|
|
2408
|
+
)
|
|
2409
|
+
]
|
|
2410
|
+
}
|
|
2411
|
+
);
|
|
2412
|
+
}
|
|
2326
2413
|
|
|
2327
2414
|
// src/widgets/shared/Markdown.tsx
|
|
2328
2415
|
import { Fragment } from "react";
|
|
2329
|
-
import { Fragment as Fragment2, jsx as jsx5, jsxs as
|
|
2416
|
+
import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2330
2417
|
function Markdown({ text: text2, onAction }) {
|
|
2331
2418
|
const blocks = text2.replace(/\r\n/g, "\n").split(/\n{2,}/);
|
|
2332
2419
|
return /* @__PURE__ */ jsx5(Fragment2, { children: blocks.map((b, i) => {
|
|
@@ -2342,7 +2429,7 @@ function Markdown({ text: text2, onAction }) {
|
|
|
2342
2429
|
const Tag = `h${level}`;
|
|
2343
2430
|
return /* @__PURE__ */ jsx5(Tag, { className: "ds-md-h", children: inline(h[2], onAction) }, key);
|
|
2344
2431
|
}
|
|
2345
|
-
return /* @__PURE__ */ jsx5("p", { className: "ds-md-p", children: lines.map((l, j) => /* @__PURE__ */
|
|
2432
|
+
return /* @__PURE__ */ jsx5("p", { className: "ds-md-p", children: lines.map((l, j) => /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
2346
2433
|
j > 0 && /* @__PURE__ */ jsx5("br", {}),
|
|
2347
2434
|
inline(l, onAction)
|
|
2348
2435
|
] }, `${j}-${l}`)) }, key);
|
|
@@ -2396,39 +2483,41 @@ function inline(s, onAction) {
|
|
|
2396
2483
|
return out;
|
|
2397
2484
|
}
|
|
2398
2485
|
|
|
2399
|
-
// src/
|
|
2400
|
-
import {
|
|
2401
|
-
var
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
defaults: { markdown: "Write **Markdown** here." },
|
|
2407
|
-
component: function ContentWidget({ spec, run }) {
|
|
2408
|
-
return /* @__PURE__ */ jsx6("div", { className: "ds-content", style: { textAlign: spec.align }, children: /* @__PURE__ */ jsx6(Markdown, { text: spec.markdown, onAction: (name) => run(name) }) });
|
|
2486
|
+
// src/components/Boundary.tsx
|
|
2487
|
+
import { Component } from "react";
|
|
2488
|
+
var sameKeys = (a, b) => a.length === b.length && a.every((x, i) => Object.is(x, b[i]));
|
|
2489
|
+
var Boundary = class extends Component {
|
|
2490
|
+
state = { error: null };
|
|
2491
|
+
static getDerivedStateFromError(error) {
|
|
2492
|
+
return { error };
|
|
2409
2493
|
}
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2494
|
+
componentDidCatch(error, _info) {
|
|
2495
|
+
this.props.onError?.(error);
|
|
2496
|
+
}
|
|
2497
|
+
componentDidUpdate(prev) {
|
|
2498
|
+
if (this.state.error && !sameKeys(prev.resetKeys ?? [], this.props.resetKeys ?? [])) this.setState({ error: null });
|
|
2499
|
+
}
|
|
2500
|
+
render() {
|
|
2501
|
+
return this.state.error ? this.props.fallback(this.state.error) : this.props.children;
|
|
2502
|
+
}
|
|
2503
|
+
};
|
|
2415
2504
|
|
|
2416
2505
|
// src/components/FilterBar.tsx
|
|
2417
|
-
import { useCallback as useCallback2, useEffect as
|
|
2506
|
+
import { useCallback as useCallback2, useEffect as useEffect3, useId as useId3, useRef as useRef4, useState as useState3 } from "react";
|
|
2418
2507
|
|
|
2419
2508
|
// src/components/controls.tsx
|
|
2420
2509
|
import {
|
|
2421
2510
|
useContext as useContext3,
|
|
2422
|
-
useEffect,
|
|
2511
|
+
useEffect as useEffect2,
|
|
2423
2512
|
useId as useId2,
|
|
2424
|
-
useLayoutEffect,
|
|
2513
|
+
useLayoutEffect as useLayoutEffect2,
|
|
2425
2514
|
useMemo as useMemo2,
|
|
2426
|
-
useRef as
|
|
2427
|
-
useState
|
|
2515
|
+
useRef as useRef3,
|
|
2516
|
+
useState as useState2
|
|
2428
2517
|
} from "react";
|
|
2429
|
-
import { createPortal } from "react-dom";
|
|
2430
|
-
import { Fragment as Fragment3, jsx as
|
|
2431
|
-
var Chevron = () => /* @__PURE__ */
|
|
2518
|
+
import { createPortal as createPortal2 } from "react-dom";
|
|
2519
|
+
import { Fragment as Fragment3, jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
2520
|
+
var Chevron = () => /* @__PURE__ */ jsx6("svg", { className: "ds-pill-chev", viewBox: "0 0 16 16", width: "14", height: "14", "aria-hidden": "true", children: /* @__PURE__ */ jsx6(
|
|
2432
2521
|
"path",
|
|
2433
2522
|
{
|
|
2434
2523
|
d: "m4 6 4 4 4-4",
|
|
@@ -2442,9 +2531,9 @@ var Chevron = () => /* @__PURE__ */ jsx7("svg", { className: "ds-pill-chev", vie
|
|
|
2442
2531
|
var Arrow = ({ dir }) => {
|
|
2443
2532
|
const icons = useContext3(DashboardContext)?.options.ui?.icons;
|
|
2444
2533
|
const own = dir === "left" ? icons?.previous : icons?.next;
|
|
2445
|
-
return own ? /* @__PURE__ */
|
|
2534
|
+
return own ? /* @__PURE__ */ jsx6(Fragment3, { children: own }) : /* @__PURE__ */ jsx6(DefaultArrow, { dir });
|
|
2446
2535
|
};
|
|
2447
|
-
var DefaultArrow = ({ dir }) => /* @__PURE__ */
|
|
2536
|
+
var DefaultArrow = ({ dir }) => /* @__PURE__ */ jsx6("svg", { viewBox: "0 0 16 16", width: "15", height: "15", "aria-hidden": "true", children: /* @__PURE__ */ jsx6(
|
|
2448
2537
|
"path",
|
|
2449
2538
|
{
|
|
2450
2539
|
d: dir === "left" ? "M13 8H3m4-4L3 8l4 4" : "M3 8h10M9 4l4 4-4 4",
|
|
@@ -2455,16 +2544,16 @@ var DefaultArrow = ({ dir }) => /* @__PURE__ */ jsx7("svg", { viewBox: "0 0 16 1
|
|
|
2455
2544
|
strokeLinejoin: "round"
|
|
2456
2545
|
}
|
|
2457
2546
|
) });
|
|
2458
|
-
var Calendar = () => /* @__PURE__ */
|
|
2459
|
-
/* @__PURE__ */
|
|
2460
|
-
/* @__PURE__ */
|
|
2547
|
+
var Calendar = () => /* @__PURE__ */ jsxs6("svg", { viewBox: "0 0 16 16", width: "15", height: "15", "aria-hidden": "true", children: [
|
|
2548
|
+
/* @__PURE__ */ jsx6("rect", { x: "2.5", y: "3.5", width: "11", height: "10", rx: "2", fill: "none", stroke: "currentColor", strokeWidth: "1.3" }),
|
|
2549
|
+
/* @__PURE__ */ jsx6("path", { d: "M2.5 6.5h11M5.5 2v3M10.5 2v3", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round" })
|
|
2461
2550
|
] });
|
|
2462
2551
|
function usePopover() {
|
|
2463
|
-
const [open, setOpen] =
|
|
2464
|
-
const root =
|
|
2465
|
-
const trigger =
|
|
2466
|
-
const floating =
|
|
2467
|
-
|
|
2552
|
+
const [open, setOpen] = useState2(false);
|
|
2553
|
+
const root = useRef3(null);
|
|
2554
|
+
const trigger = useRef3(null);
|
|
2555
|
+
const floating = useRef3(null);
|
|
2556
|
+
useEffect2(() => {
|
|
2468
2557
|
if (!open) return;
|
|
2469
2558
|
const inside = (t) => t instanceof Node && Boolean(root.current?.contains(t) || floating.current?.contains(t));
|
|
2470
2559
|
const onDown = (e) => {
|
|
@@ -2501,9 +2590,9 @@ function Floating({
|
|
|
2501
2590
|
role,
|
|
2502
2591
|
label
|
|
2503
2592
|
}) {
|
|
2504
|
-
const [pos, setPos] =
|
|
2593
|
+
const [pos, setPos] = useState2(null);
|
|
2505
2594
|
const host = anchor.current?.closest(".ds-root") ?? (typeof document !== "undefined" ? document.body : null);
|
|
2506
|
-
|
|
2595
|
+
useLayoutEffect2(() => {
|
|
2507
2596
|
const place = () => {
|
|
2508
2597
|
const a = anchor.current?.getBoundingClientRect();
|
|
2509
2598
|
const f = floatingRef.current?.getBoundingClientRect();
|
|
@@ -2527,8 +2616,8 @@ function Floating({
|
|
|
2527
2616
|
};
|
|
2528
2617
|
}, [anchor, floatingRef]);
|
|
2529
2618
|
if (!host) return null;
|
|
2530
|
-
return
|
|
2531
|
-
/* @__PURE__ */
|
|
2619
|
+
return createPortal2(
|
|
2620
|
+
/* @__PURE__ */ jsx6(
|
|
2532
2621
|
"div",
|
|
2533
2622
|
{
|
|
2534
2623
|
ref: floatingRef,
|
|
@@ -2560,7 +2649,7 @@ function PillTrigger({
|
|
|
2560
2649
|
controls,
|
|
2561
2650
|
ariaLabel
|
|
2562
2651
|
}) {
|
|
2563
|
-
return /* @__PURE__ */
|
|
2652
|
+
return /* @__PURE__ */ jsxs6(
|
|
2564
2653
|
"button",
|
|
2565
2654
|
{
|
|
2566
2655
|
ref: triggerRef,
|
|
@@ -2573,16 +2662,16 @@ function PillTrigger({
|
|
|
2573
2662
|
onClick,
|
|
2574
2663
|
children: [
|
|
2575
2664
|
icon2,
|
|
2576
|
-
label ? /* @__PURE__ */
|
|
2665
|
+
label ? /* @__PURE__ */ jsxs6("span", { children: [
|
|
2577
2666
|
label,
|
|
2578
2667
|
" ",
|
|
2579
|
-
/* @__PURE__ */
|
|
2668
|
+
/* @__PURE__ */ jsxs6("span", { className: "ds-pill-value", children: [
|
|
2580
2669
|
"(",
|
|
2581
2670
|
value,
|
|
2582
2671
|
")"
|
|
2583
2672
|
] })
|
|
2584
|
-
] }) : /* @__PURE__ */
|
|
2585
|
-
/* @__PURE__ */
|
|
2673
|
+
] }) : /* @__PURE__ */ jsx6("span", { className: "ds-pill-value ds-pill-value-only", children: value }),
|
|
2674
|
+
/* @__PURE__ */ jsx6(Chevron, {})
|
|
2586
2675
|
]
|
|
2587
2676
|
}
|
|
2588
2677
|
);
|
|
@@ -2594,14 +2683,14 @@ function OptionList({
|
|
|
2594
2683
|
onPick,
|
|
2595
2684
|
multiple
|
|
2596
2685
|
}) {
|
|
2597
|
-
const list =
|
|
2686
|
+
const list = useRef3(null);
|
|
2598
2687
|
const start = Math.max(
|
|
2599
2688
|
0,
|
|
2600
2689
|
options.findIndex((o) => isSelected(o.value))
|
|
2601
2690
|
);
|
|
2602
|
-
const [active, setActive] =
|
|
2603
|
-
const typed =
|
|
2604
|
-
|
|
2691
|
+
const [active, setActive] = useState2(start);
|
|
2692
|
+
const typed = useRef3({ text: "", at: 0 });
|
|
2693
|
+
useEffect2(() => {
|
|
2605
2694
|
list.current?.querySelector(`[data-i="${start}"]`)?.focus();
|
|
2606
2695
|
}, [start]);
|
|
2607
2696
|
const move = (i) => {
|
|
@@ -2622,7 +2711,7 @@ function OptionList({
|
|
|
2622
2711
|
} else return;
|
|
2623
2712
|
e.preventDefault();
|
|
2624
2713
|
};
|
|
2625
|
-
return /* @__PURE__ */
|
|
2714
|
+
return /* @__PURE__ */ jsxs6(
|
|
2626
2715
|
"div",
|
|
2627
2716
|
{
|
|
2628
2717
|
className: "ds-menu",
|
|
@@ -2633,10 +2722,10 @@ function OptionList({
|
|
|
2633
2722
|
onKeyDown: onKey,
|
|
2634
2723
|
tabIndex: -1,
|
|
2635
2724
|
children: [
|
|
2636
|
-
options.length === 0 && /* @__PURE__ */
|
|
2725
|
+
options.length === 0 && /* @__PURE__ */ jsx6("div", { className: "ds-menu-empty", children: "No options" }),
|
|
2637
2726
|
options.map((o, i) => {
|
|
2638
2727
|
const sel = isSelected(o.value);
|
|
2639
|
-
return /* @__PURE__ */
|
|
2728
|
+
return /* @__PURE__ */ jsxs6(
|
|
2640
2729
|
"button",
|
|
2641
2730
|
{
|
|
2642
2731
|
type: "button",
|
|
@@ -2648,10 +2737,10 @@ function OptionList({
|
|
|
2648
2737
|
onClick: () => onPick(o),
|
|
2649
2738
|
onFocus: () => setActive(i),
|
|
2650
2739
|
children: [
|
|
2651
|
-
multiple && /* @__PURE__ */
|
|
2652
|
-
/* @__PURE__ */
|
|
2653
|
-
o.count !== void 0 && /* @__PURE__ */
|
|
2654
|
-
!multiple && sel && /* @__PURE__ */
|
|
2740
|
+
multiple && /* @__PURE__ */ jsx6("span", { className: "ds-check", "data-on": sel || void 0, "aria-hidden": "true" }),
|
|
2741
|
+
/* @__PURE__ */ jsx6("span", { className: "ds-menu-label", children: o.label }),
|
|
2742
|
+
o.count !== void 0 && /* @__PURE__ */ jsx6("span", { className: "ds-menu-count", children: o.count }),
|
|
2743
|
+
!multiple && sel && /* @__PURE__ */ jsx6("svg", { viewBox: "0 0 16 16", width: "14", height: "14", "aria-hidden": "true", className: "ds-menu-tick", children: /* @__PURE__ */ jsx6(
|
|
2655
2744
|
"path",
|
|
2656
2745
|
{
|
|
2657
2746
|
d: "m3.5 8.5 3 3 6-7",
|
|
@@ -2687,7 +2776,7 @@ function SelectControl({
|
|
|
2687
2776
|
const id = useId2();
|
|
2688
2777
|
const i = options.findIndex((o) => o.value === value);
|
|
2689
2778
|
const current = i >= 0 ? options[i].label : value === null || value === void 0 || value === "" ? allLabel : String(value);
|
|
2690
|
-
const pill = /* @__PURE__ */
|
|
2779
|
+
const pill = /* @__PURE__ */ jsxs6(
|
|
2691
2780
|
"div",
|
|
2692
2781
|
{
|
|
2693
2782
|
className: "ds-dd",
|
|
@@ -2696,7 +2785,7 @@ function SelectControl({
|
|
|
2696
2785
|
"data-block": block || void 0,
|
|
2697
2786
|
"data-plain": plain || void 0,
|
|
2698
2787
|
children: [
|
|
2699
|
-
/* @__PURE__ */
|
|
2788
|
+
/* @__PURE__ */ jsx6(
|
|
2700
2789
|
PillTrigger,
|
|
2701
2790
|
{
|
|
2702
2791
|
label: stepper ? void 0 : label,
|
|
@@ -2708,7 +2797,7 @@ function SelectControl({
|
|
|
2708
2797
|
ariaLabel
|
|
2709
2798
|
}
|
|
2710
2799
|
),
|
|
2711
|
-
p.open && /* @__PURE__ */
|
|
2800
|
+
p.open && /* @__PURE__ */ jsx6(Floating, { anchor: p.trigger, floatingRef: p.floating, children: /* @__PURE__ */ jsx6(
|
|
2712
2801
|
OptionList,
|
|
2713
2802
|
{
|
|
2714
2803
|
id,
|
|
@@ -2725,8 +2814,8 @@ function SelectControl({
|
|
|
2725
2814
|
}
|
|
2726
2815
|
);
|
|
2727
2816
|
if (!stepper) return pill;
|
|
2728
|
-
return /* @__PURE__ */
|
|
2729
|
-
/* @__PURE__ */
|
|
2817
|
+
return /* @__PURE__ */ jsxs6("div", { className: "ds-stepper", role: "group", "aria-label": label, children: [
|
|
2818
|
+
/* @__PURE__ */ jsx6(
|
|
2730
2819
|
"button",
|
|
2731
2820
|
{
|
|
2732
2821
|
type: "button",
|
|
@@ -2734,11 +2823,11 @@ function SelectControl({
|
|
|
2734
2823
|
"aria-label": `Previous ${label ?? ""}`,
|
|
2735
2824
|
disabled: i <= 0,
|
|
2736
2825
|
onClick: () => onChange(options[i - 1]?.value),
|
|
2737
|
-
children: /* @__PURE__ */
|
|
2826
|
+
children: /* @__PURE__ */ jsx6(Arrow, { dir: "left" })
|
|
2738
2827
|
}
|
|
2739
2828
|
),
|
|
2740
2829
|
pill,
|
|
2741
|
-
/* @__PURE__ */
|
|
2830
|
+
/* @__PURE__ */ jsx6(
|
|
2742
2831
|
"button",
|
|
2743
2832
|
{
|
|
2744
2833
|
type: "button",
|
|
@@ -2746,7 +2835,7 @@ function SelectControl({
|
|
|
2746
2835
|
"aria-label": `Next ${label ?? ""}`,
|
|
2747
2836
|
disabled: i === -1 || i >= options.length - 1,
|
|
2748
2837
|
onClick: () => onChange(options[i + 1]?.value),
|
|
2749
|
-
children: /* @__PURE__ */
|
|
2838
|
+
children: /* @__PURE__ */ jsx6(Arrow, { dir: "right" })
|
|
2750
2839
|
}
|
|
2751
2840
|
)
|
|
2752
2841
|
] });
|
|
@@ -2766,8 +2855,8 @@ function MultiSelectControl({
|
|
|
2766
2855
|
const chosen = Array.isArray(value) ? value : [];
|
|
2767
2856
|
const names = options.filter((o) => chosen.includes(o.value)).map((o) => o.label);
|
|
2768
2857
|
const text2 = chosen.length === 0 ? emptyLabel : names.length <= 2 ? names.join(", ") : `${chosen.length} selected`;
|
|
2769
|
-
return /* @__PURE__ */
|
|
2770
|
-
/* @__PURE__ */
|
|
2858
|
+
return /* @__PURE__ */ jsxs6("div", { className: "ds-dd", ref: p.root, "data-block": block || void 0, "data-plain": plain || void 0, children: [
|
|
2859
|
+
/* @__PURE__ */ jsx6(
|
|
2771
2860
|
PillTrigger,
|
|
2772
2861
|
{
|
|
2773
2862
|
label,
|
|
@@ -2779,8 +2868,8 @@ function MultiSelectControl({
|
|
|
2779
2868
|
ariaLabel
|
|
2780
2869
|
}
|
|
2781
2870
|
),
|
|
2782
|
-
p.open && /* @__PURE__ */
|
|
2783
|
-
/* @__PURE__ */
|
|
2871
|
+
p.open && /* @__PURE__ */ jsxs6(Floating, { anchor: p.trigger, floatingRef: p.floating, children: [
|
|
2872
|
+
/* @__PURE__ */ jsx6(
|
|
2784
2873
|
OptionList,
|
|
2785
2874
|
{
|
|
2786
2875
|
id,
|
|
@@ -2790,9 +2879,9 @@ function MultiSelectControl({
|
|
|
2790
2879
|
onPick: (o) => onChange(chosen.includes(o.value) ? chosen.filter((x) => x !== o.value) : [...chosen, o.value])
|
|
2791
2880
|
}
|
|
2792
2881
|
),
|
|
2793
|
-
chosen.length > 0 && /* @__PURE__ */
|
|
2794
|
-
/* @__PURE__ */
|
|
2795
|
-
/* @__PURE__ */
|
|
2882
|
+
chosen.length > 0 && /* @__PURE__ */ jsxs6("div", { className: "ds-pop-foot", children: [
|
|
2883
|
+
/* @__PURE__ */ jsx6("button", { type: "button", className: "ds-link", onClick: () => onChange([]), children: "Clear" }),
|
|
2884
|
+
/* @__PURE__ */ jsxs6("span", { children: [
|
|
2796
2885
|
chosen.length,
|
|
2797
2886
|
" selected"
|
|
2798
2887
|
] })
|
|
@@ -2821,8 +2910,8 @@ function Month({
|
|
|
2821
2910
|
onMove,
|
|
2822
2911
|
focusDate
|
|
2823
2912
|
}) {
|
|
2824
|
-
const grid =
|
|
2825
|
-
|
|
2913
|
+
const grid = useRef3(null);
|
|
2914
|
+
useEffect2(() => {
|
|
2826
2915
|
if (focusDate) grid.current?.querySelector(`[data-date="${focusDate}"]`)?.focus();
|
|
2827
2916
|
}, [focusDate]);
|
|
2828
2917
|
const fullDate = (d) => parse2(d).toLocaleDateString(locale, {
|
|
@@ -2852,16 +2941,16 @@ function Month({
|
|
|
2852
2941
|
}),
|
|
2853
2942
|
[locale]
|
|
2854
2943
|
);
|
|
2855
|
-
return /* @__PURE__ */
|
|
2856
|
-
weekdays.map((w) => /* @__PURE__ */
|
|
2857
|
-
lead > 0 && /* @__PURE__ */
|
|
2944
|
+
return /* @__PURE__ */ jsxs6("div", { className: "ds-cal-grid", ref: grid, role: "group", "aria-label": month, onKeyDown: onKey, children: [
|
|
2945
|
+
weekdays.map((w) => /* @__PURE__ */ jsx6("span", { className: "ds-cal-wd", children: w.label }, w.key)),
|
|
2946
|
+
lead > 0 && /* @__PURE__ */ jsx6("span", { style: { gridColumn: `span ${lead}` } }),
|
|
2858
2947
|
Array.from({ length: days }, (_, i) => {
|
|
2859
2948
|
const d = `${month}-${String(i + 1).padStart(2, "0")}`;
|
|
2860
2949
|
const off = min && d < min || max && d > max;
|
|
2861
2950
|
const isStart = d === from;
|
|
2862
2951
|
const isEnd = d === end;
|
|
2863
2952
|
const inRange = from && end && d > from && d < end;
|
|
2864
|
-
return /* @__PURE__ */
|
|
2953
|
+
return /* @__PURE__ */ jsx6(
|
|
2865
2954
|
"button",
|
|
2866
2955
|
{
|
|
2867
2956
|
type: "button",
|
|
@@ -2899,17 +2988,17 @@ function DateRangeControl({
|
|
|
2899
2988
|
const p = usePopover();
|
|
2900
2989
|
const id = useId2();
|
|
2901
2990
|
const short = (d) => parse2(d).toLocaleDateString(locale, { day: "numeric", month: "short", timeZone: "UTC" });
|
|
2902
|
-
const [draft, setDraft] =
|
|
2903
|
-
const [hover, setHover] =
|
|
2904
|
-
const [month, setMonth] =
|
|
2905
|
-
const [focusDate, setFocusDate] =
|
|
2906
|
-
|
|
2991
|
+
const [draft, setDraft] = useState2({});
|
|
2992
|
+
const [hover, setHover] = useState2();
|
|
2993
|
+
const [month, setMonth] = useState2(() => (value.to ?? value.from ?? max ?? iso(/* @__PURE__ */ new Date())).slice(0, 7));
|
|
2994
|
+
const [focusDate, setFocusDate] = useState2();
|
|
2995
|
+
useEffect2(() => {
|
|
2907
2996
|
if (p.open) {
|
|
2908
2997
|
setDraft({ ...value.from ? { from: value.from } : {}, ...value.to ? { to: value.to } : {} });
|
|
2909
2998
|
setMonth((value.to ?? value.from ?? max ?? iso(/* @__PURE__ */ new Date())).slice(0, 7));
|
|
2910
2999
|
} else setFocusDate(void 0);
|
|
2911
3000
|
}, [p.open, value.from, value.to, max]);
|
|
2912
|
-
|
|
3001
|
+
useEffect2(() => {
|
|
2913
3002
|
if (!p.open) return;
|
|
2914
3003
|
const f = p.floating.current;
|
|
2915
3004
|
const target = f?.querySelector(".ds-cal-day[data-start]:not(:disabled)") ?? f?.querySelector(".ds-cal-day:not(:disabled)") ?? f?.querySelector("button:not(:disabled)");
|
|
@@ -2944,8 +3033,8 @@ function DateRangeControl({
|
|
|
2944
3033
|
});
|
|
2945
3034
|
const canPrev = !min || `${month}-01` > min;
|
|
2946
3035
|
const canNext = !max || addDays2(iso(new Date(Date.UTC(Number(month.slice(0, 4)), Number(month.slice(5, 7)), 0))), 1) <= max;
|
|
2947
|
-
return /* @__PURE__ */
|
|
2948
|
-
/* @__PURE__ */
|
|
3036
|
+
return /* @__PURE__ */ jsxs6("div", { className: "ds-dd", ref: p.root, children: [
|
|
3037
|
+
/* @__PURE__ */ jsxs6(
|
|
2949
3038
|
"button",
|
|
2950
3039
|
{
|
|
2951
3040
|
ref: p.trigger,
|
|
@@ -2956,22 +3045,22 @@ function DateRangeControl({
|
|
|
2956
3045
|
"aria-controls": id,
|
|
2957
3046
|
onClick: () => p.setOpen(!p.open),
|
|
2958
3047
|
children: [
|
|
2959
|
-
/* @__PURE__ */
|
|
2960
|
-
/* @__PURE__ */
|
|
3048
|
+
/* @__PURE__ */ jsx6(Calendar, {}),
|
|
3049
|
+
/* @__PURE__ */ jsxs6("span", { children: [
|
|
2961
3050
|
label && !value.preset ? `${label} ` : "",
|
|
2962
3051
|
name,
|
|
2963
3052
|
" ",
|
|
2964
|
-
range && /* @__PURE__ */
|
|
3053
|
+
range && /* @__PURE__ */ jsxs6("span", { className: "ds-pill-value", children: [
|
|
2965
3054
|
"(",
|
|
2966
3055
|
range,
|
|
2967
3056
|
")"
|
|
2968
3057
|
] })
|
|
2969
3058
|
] }),
|
|
2970
|
-
/* @__PURE__ */
|
|
3059
|
+
/* @__PURE__ */ jsx6(Chevron, {})
|
|
2971
3060
|
]
|
|
2972
3061
|
}
|
|
2973
3062
|
),
|
|
2974
|
-
p.open && /* @__PURE__ */
|
|
3063
|
+
p.open && /* @__PURE__ */ jsx6(
|
|
2975
3064
|
Floating,
|
|
2976
3065
|
{
|
|
2977
3066
|
anchor: p.trigger,
|
|
@@ -2980,10 +3069,10 @@ function DateRangeControl({
|
|
|
2980
3069
|
id,
|
|
2981
3070
|
role: "dialog",
|
|
2982
3071
|
label: label ?? "Choose dates",
|
|
2983
|
-
children: /* @__PURE__ */
|
|
2984
|
-
presets.filter((x) => x !== "custom").length > 0 && /* @__PURE__ */
|
|
3072
|
+
children: /* @__PURE__ */ jsxs6("div", { className: "ds-range", children: [
|
|
3073
|
+
presets.filter((x) => x !== "custom").length > 0 && /* @__PURE__ */ jsx6("div", { className: "ds-range-presets", children: presets.filter((x) => x !== "custom").map((x) => {
|
|
2985
3074
|
const r = presetRange2(x);
|
|
2986
|
-
return /* @__PURE__ */
|
|
3075
|
+
return /* @__PURE__ */ jsxs6(
|
|
2987
3076
|
"button",
|
|
2988
3077
|
{
|
|
2989
3078
|
type: "button",
|
|
@@ -2994,16 +3083,16 @@ function DateRangeControl({
|
|
|
2994
3083
|
p.setOpen(false);
|
|
2995
3084
|
},
|
|
2996
3085
|
children: [
|
|
2997
|
-
/* @__PURE__ */
|
|
2998
|
-
/* @__PURE__ */
|
|
3086
|
+
/* @__PURE__ */ jsx6("span", { className: "ds-menu-label", children: presetLabel(x) }),
|
|
3087
|
+
/* @__PURE__ */ jsx6("span", { className: "ds-menu-count", children: r.from === r.to ? short(r.from) : `${short(r.from)} \u2013 ${short(r.to)}` })
|
|
2999
3088
|
]
|
|
3000
3089
|
},
|
|
3001
3090
|
x
|
|
3002
3091
|
);
|
|
3003
3092
|
}) }),
|
|
3004
|
-
/* @__PURE__ */
|
|
3005
|
-
/* @__PURE__ */
|
|
3006
|
-
/* @__PURE__ */
|
|
3093
|
+
/* @__PURE__ */ jsxs6("div", { className: "ds-cal", children: [
|
|
3094
|
+
/* @__PURE__ */ jsxs6("div", { className: "ds-cal-head", children: [
|
|
3095
|
+
/* @__PURE__ */ jsx6(
|
|
3007
3096
|
"button",
|
|
3008
3097
|
{
|
|
3009
3098
|
type: "button",
|
|
@@ -3011,11 +3100,11 @@ function DateRangeControl({
|
|
|
3011
3100
|
"aria-label": "Previous month",
|
|
3012
3101
|
disabled: !canPrev,
|
|
3013
3102
|
onClick: () => shift(-1),
|
|
3014
|
-
children: /* @__PURE__ */
|
|
3103
|
+
children: /* @__PURE__ */ jsx6(Arrow, { dir: "left" })
|
|
3015
3104
|
}
|
|
3016
3105
|
),
|
|
3017
|
-
/* @__PURE__ */
|
|
3018
|
-
/* @__PURE__ */
|
|
3106
|
+
/* @__PURE__ */ jsx6("strong", { children: monthTitle }),
|
|
3107
|
+
/* @__PURE__ */ jsx6(
|
|
3019
3108
|
"button",
|
|
3020
3109
|
{
|
|
3021
3110
|
type: "button",
|
|
@@ -3023,11 +3112,11 @@ function DateRangeControl({
|
|
|
3023
3112
|
"aria-label": "Next month",
|
|
3024
3113
|
disabled: !canNext,
|
|
3025
3114
|
onClick: () => shift(1),
|
|
3026
|
-
children: /* @__PURE__ */
|
|
3115
|
+
children: /* @__PURE__ */ jsx6(Arrow, { dir: "right" })
|
|
3027
3116
|
}
|
|
3028
3117
|
)
|
|
3029
3118
|
] }),
|
|
3030
|
-
/* @__PURE__ */
|
|
3119
|
+
/* @__PURE__ */ jsx6(
|
|
3031
3120
|
Month,
|
|
3032
3121
|
{
|
|
3033
3122
|
month,
|
|
@@ -3043,9 +3132,9 @@ function DateRangeControl({
|
|
|
3043
3132
|
focusDate
|
|
3044
3133
|
}
|
|
3045
3134
|
),
|
|
3046
|
-
!single && /* @__PURE__ */
|
|
3047
|
-
/* @__PURE__ */
|
|
3048
|
-
/* @__PURE__ */
|
|
3135
|
+
!single && /* @__PURE__ */ jsxs6("div", { className: "ds-pop-foot", children: [
|
|
3136
|
+
/* @__PURE__ */ jsx6("span", { className: tooLong ? "ds-cal-error" : void 0, children: tooLong ? `Pick a range of ${maxDays} days or less` : draft.from && draft.to ? `${short(draft.from)} \u2013 ${short(draft.to)} \xB7 ${daysBetween(draft.from, draft.to)} days` : draft.from ? "Now pick the end date" : "Pick the start date" }),
|
|
3137
|
+
/* @__PURE__ */ jsx6(
|
|
3049
3138
|
"button",
|
|
3050
3139
|
{
|
|
3051
3140
|
type: "button",
|
|
@@ -3076,7 +3165,7 @@ function DateControl({
|
|
|
3076
3165
|
locale,
|
|
3077
3166
|
onChange
|
|
3078
3167
|
}) {
|
|
3079
|
-
const control = /* @__PURE__ */
|
|
3168
|
+
const control = /* @__PURE__ */ jsx6(
|
|
3080
3169
|
DateRangeControl,
|
|
3081
3170
|
{
|
|
3082
3171
|
label,
|
|
@@ -3092,8 +3181,8 @@ function DateControl({
|
|
|
3092
3181
|
}
|
|
3093
3182
|
);
|
|
3094
3183
|
if (!stepper) return control;
|
|
3095
|
-
return /* @__PURE__ */
|
|
3096
|
-
/* @__PURE__ */
|
|
3184
|
+
return /* @__PURE__ */ jsxs6("div", { className: "ds-stepper", role: "group", "aria-label": label, children: [
|
|
3185
|
+
/* @__PURE__ */ jsx6(
|
|
3097
3186
|
"button",
|
|
3098
3187
|
{
|
|
3099
3188
|
type: "button",
|
|
@@ -3101,11 +3190,11 @@ function DateControl({
|
|
|
3101
3190
|
"aria-label": "Previous day",
|
|
3102
3191
|
disabled: Boolean(min && value <= min),
|
|
3103
3192
|
onClick: () => onChange(addDays2(value, -1)),
|
|
3104
|
-
children: /* @__PURE__ */
|
|
3193
|
+
children: /* @__PURE__ */ jsx6(Arrow, { dir: "left" })
|
|
3105
3194
|
}
|
|
3106
3195
|
),
|
|
3107
3196
|
control,
|
|
3108
|
-
/* @__PURE__ */
|
|
3197
|
+
/* @__PURE__ */ jsx6(
|
|
3109
3198
|
"button",
|
|
3110
3199
|
{
|
|
3111
3200
|
type: "button",
|
|
@@ -3113,14 +3202,14 @@ function DateControl({
|
|
|
3113
3202
|
"aria-label": "Next day",
|
|
3114
3203
|
disabled: Boolean(max && value >= max),
|
|
3115
3204
|
onClick: () => onChange(addDays2(value, 1)),
|
|
3116
|
-
children: /* @__PURE__ */
|
|
3205
|
+
children: /* @__PURE__ */ jsx6(Arrow, { dir: "right" })
|
|
3117
3206
|
}
|
|
3118
3207
|
)
|
|
3119
3208
|
] });
|
|
3120
3209
|
}
|
|
3121
3210
|
|
|
3122
3211
|
// src/components/FilterBar.tsx
|
|
3123
|
-
import { Fragment as Fragment4, jsx as
|
|
3212
|
+
import { Fragment as Fragment4, jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
3124
3213
|
var PRESET_LABELS = {
|
|
3125
3214
|
today: "Today",
|
|
3126
3215
|
yesterday: "Yesterday",
|
|
@@ -3191,10 +3280,10 @@ function ControlField({
|
|
|
3191
3280
|
const r = v2 === "today" ? runtime.helpers.today() : interpolate(v2, rootScope(runtime.getTree(), runtime.helpers));
|
|
3192
3281
|
return typeof r === "number" ? new Date(r).toISOString().slice(0, 10) : r || void 0;
|
|
3193
3282
|
};
|
|
3194
|
-
const [text2, setText] =
|
|
3195
|
-
const timer =
|
|
3196
|
-
|
|
3197
|
-
|
|
3283
|
+
const [text2, setText] = useState3(typeof value === "string" ? value : "");
|
|
3284
|
+
const timer = useRef4(void 0);
|
|
3285
|
+
useEffect3(() => setText(typeof value === "string" ? value : ""), [value]);
|
|
3286
|
+
useEffect3(() => () => clearTimeout(timer.current), []);
|
|
3198
3287
|
const name = String(def.name);
|
|
3199
3288
|
const own = designSystemControl(def, ui, {
|
|
3200
3289
|
name,
|
|
@@ -3233,7 +3322,7 @@ function ControlField({
|
|
|
3233
3322
|
"thisMonth",
|
|
3234
3323
|
"custom"
|
|
3235
3324
|
];
|
|
3236
|
-
return /* @__PURE__ */
|
|
3325
|
+
return /* @__PURE__ */ jsx7(
|
|
3237
3326
|
DateRangeControl,
|
|
3238
3327
|
{
|
|
3239
3328
|
label,
|
|
@@ -3252,7 +3341,7 @@ function ControlField({
|
|
|
3252
3341
|
);
|
|
3253
3342
|
}
|
|
3254
3343
|
case "Date":
|
|
3255
|
-
return /* @__PURE__ */
|
|
3344
|
+
return /* @__PURE__ */ jsx7(
|
|
3256
3345
|
DateControl,
|
|
3257
3346
|
{
|
|
3258
3347
|
label,
|
|
@@ -3265,7 +3354,7 @@ function ControlField({
|
|
|
3265
3354
|
}
|
|
3266
3355
|
);
|
|
3267
3356
|
case "Select":
|
|
3268
|
-
return /* @__PURE__ */
|
|
3357
|
+
return /* @__PURE__ */ jsx7(
|
|
3269
3358
|
SelectControl,
|
|
3270
3359
|
{
|
|
3271
3360
|
label,
|
|
@@ -3276,14 +3365,14 @@ function ControlField({
|
|
|
3276
3365
|
}
|
|
3277
3366
|
);
|
|
3278
3367
|
case "MultiSelect":
|
|
3279
|
-
return /* @__PURE__ */
|
|
3368
|
+
return /* @__PURE__ */ jsx7(MultiSelectControl, { label, options, value, onChange });
|
|
3280
3369
|
case "Chips": {
|
|
3281
3370
|
const multi = Boolean(def.multiple);
|
|
3282
3371
|
const chosen = multi ? Array.isArray(value) ? value : [] : [value];
|
|
3283
3372
|
const toggle = (v2) => multi ? onChange(chosen.includes(v2) ? chosen.filter((x) => x !== v2) : [...chosen, v2]) : onChange(value === v2 ? null : v2);
|
|
3284
3373
|
return (
|
|
3285
3374
|
// biome-ignore lint/a11y/useSemanticElements: a chip group, not a form fieldset
|
|
3286
|
-
/* @__PURE__ */
|
|
3375
|
+
/* @__PURE__ */ jsx7("div", { className: "ds-chips", role: "group", "aria-label": label ?? String(def.name), children: options.map((o, k) => /* @__PURE__ */ jsxs7(
|
|
3287
3376
|
"button",
|
|
3288
3377
|
{
|
|
3289
3378
|
type: "button",
|
|
@@ -3292,7 +3381,7 @@ function ControlField({
|
|
|
3292
3381
|
onClick: () => toggle(o.value),
|
|
3293
3382
|
children: [
|
|
3294
3383
|
o.label,
|
|
3295
|
-
o.count !== void 0 && /* @__PURE__ */
|
|
3384
|
+
o.count !== void 0 && /* @__PURE__ */ jsx7("span", { className: "ds-chip-count", children: o.count })
|
|
3296
3385
|
]
|
|
3297
3386
|
},
|
|
3298
3387
|
`${String(o.value)}-${k}`
|
|
@@ -3301,12 +3390,12 @@ function ControlField({
|
|
|
3301
3390
|
}
|
|
3302
3391
|
case "Search": {
|
|
3303
3392
|
const wait = def.debounce ? parseDuration(def.debounce) : 300;
|
|
3304
|
-
return /* @__PURE__ */
|
|
3305
|
-
/* @__PURE__ */
|
|
3306
|
-
/* @__PURE__ */
|
|
3307
|
-
/* @__PURE__ */
|
|
3393
|
+
return /* @__PURE__ */ jsxs7("label", { className: "ds-search", children: [
|
|
3394
|
+
/* @__PURE__ */ jsxs7("svg", { viewBox: "0 0 16 16", width: "15", height: "15", "aria-hidden": "true", children: [
|
|
3395
|
+
/* @__PURE__ */ jsx7("circle", { cx: "7", cy: "7", r: "4.5", fill: "none", stroke: "currentColor", strokeWidth: "1.5" }),
|
|
3396
|
+
/* @__PURE__ */ jsx7("path", { d: "m10.5 10.5 3 3", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
|
|
3308
3397
|
] }),
|
|
3309
|
-
/* @__PURE__ */
|
|
3398
|
+
/* @__PURE__ */ jsx7(
|
|
3310
3399
|
"input",
|
|
3311
3400
|
{
|
|
3312
3401
|
type: "search",
|
|
@@ -3324,8 +3413,8 @@ function ControlField({
|
|
|
3324
3413
|
] });
|
|
3325
3414
|
}
|
|
3326
3415
|
case "Toggle":
|
|
3327
|
-
return /* @__PURE__ */
|
|
3328
|
-
/* @__PURE__ */
|
|
3416
|
+
return /* @__PURE__ */ jsxs7("label", { className: "ds-switch", children: [
|
|
3417
|
+
/* @__PURE__ */ jsx7(
|
|
3329
3418
|
"input",
|
|
3330
3419
|
{
|
|
3331
3420
|
type: "checkbox",
|
|
@@ -3335,7 +3424,7 @@ function ControlField({
|
|
|
3335
3424
|
onChange: (e) => onChange(e.target.checked)
|
|
3336
3425
|
}
|
|
3337
3426
|
),
|
|
3338
|
-
/* @__PURE__ */
|
|
3427
|
+
/* @__PURE__ */ jsx7("span", { "aria-hidden": "true" }),
|
|
3339
3428
|
label ?? (compact ? "" : String(def.name))
|
|
3340
3429
|
] });
|
|
3341
3430
|
default:
|
|
@@ -3346,9 +3435,9 @@ function designSystemControl(def, ui, c) {
|
|
|
3346
3435
|
const base = { name: c.name, label: c.label };
|
|
3347
3436
|
switch (def.kind) {
|
|
3348
3437
|
case "Select":
|
|
3349
|
-
return ui.Select ? /* @__PURE__ */
|
|
3438
|
+
return ui.Select ? /* @__PURE__ */ jsx7(ui.Select, { ...base, options: c.options, value: c.value, onChange: c.onChange, stepper: Boolean(def.stepper) }) : null;
|
|
3350
3439
|
case "MultiSelect":
|
|
3351
|
-
return ui.MultiSelect ? /* @__PURE__ */
|
|
3440
|
+
return ui.MultiSelect ? /* @__PURE__ */ jsx7(
|
|
3352
3441
|
ui.MultiSelect,
|
|
3353
3442
|
{
|
|
3354
3443
|
...base,
|
|
@@ -3358,7 +3447,7 @@ function designSystemControl(def, ui, c) {
|
|
|
3358
3447
|
}
|
|
3359
3448
|
) : null;
|
|
3360
3449
|
case "Date":
|
|
3361
|
-
return ui.Date ? /* @__PURE__ */
|
|
3450
|
+
return ui.Date ? /* @__PURE__ */ jsx7(
|
|
3362
3451
|
ui.Date,
|
|
3363
3452
|
{
|
|
3364
3453
|
...base,
|
|
@@ -3370,7 +3459,7 @@ function designSystemControl(def, ui, c) {
|
|
|
3370
3459
|
}
|
|
3371
3460
|
) : null;
|
|
3372
3461
|
case "DateRange":
|
|
3373
|
-
return ui.DateRange ? /* @__PURE__ */
|
|
3462
|
+
return ui.DateRange ? /* @__PURE__ */ jsx7(
|
|
3374
3463
|
ui.DateRange,
|
|
3375
3464
|
{
|
|
3376
3465
|
...base,
|
|
@@ -3383,11 +3472,11 @@ function designSystemControl(def, ui, c) {
|
|
|
3383
3472
|
}
|
|
3384
3473
|
) : null;
|
|
3385
3474
|
case "Search":
|
|
3386
|
-
return ui.Search ? /* @__PURE__ */
|
|
3475
|
+
return ui.Search ? /* @__PURE__ */ jsx7(ui.Search, { ...base, value: c.text, onChange: c.setText, placeholder: def.placeholder }) : null;
|
|
3387
3476
|
case "Toggle":
|
|
3388
|
-
return ui.Toggle ? /* @__PURE__ */
|
|
3477
|
+
return ui.Toggle ? /* @__PURE__ */ jsx7(ui.Toggle, { ...base, value: Boolean(c.value), onChange: c.onChange }) : null;
|
|
3389
3478
|
case "Chips":
|
|
3390
|
-
return ui.Chips ? /* @__PURE__ */
|
|
3479
|
+
return ui.Chips ? /* @__PURE__ */ jsx7(
|
|
3391
3480
|
ui.Chips,
|
|
3392
3481
|
{
|
|
3393
3482
|
...base,
|
|
@@ -3399,12 +3488,12 @@ function designSystemControl(def, ui, c) {
|
|
|
3399
3488
|
) : null;
|
|
3400
3489
|
default: {
|
|
3401
3490
|
const Own = ui.filters?.[String(def.kind)];
|
|
3402
|
-
return Own ? /* @__PURE__ */
|
|
3491
|
+
return Own ? /* @__PURE__ */ jsx7(Own, { ...base, value: c.value, onChange: c.onChange, config: def }) : null;
|
|
3403
3492
|
}
|
|
3404
3493
|
}
|
|
3405
3494
|
}
|
|
3406
3495
|
var BAR = "__filterBar";
|
|
3407
|
-
var icon = (d) => /* @__PURE__ */
|
|
3496
|
+
var icon = (d) => /* @__PURE__ */ jsx7(
|
|
3408
3497
|
"svg",
|
|
3409
3498
|
{
|
|
3410
3499
|
viewBox: "0 0 20 20",
|
|
@@ -3420,23 +3509,23 @@ var icon = (d) => /* @__PURE__ */ jsx8(
|
|
|
3420
3509
|
);
|
|
3421
3510
|
var BAR_ICONS = {
|
|
3422
3511
|
sliders: icon(
|
|
3423
|
-
/* @__PURE__ */
|
|
3424
|
-
/* @__PURE__ */
|
|
3425
|
-
/* @__PURE__ */
|
|
3426
|
-
/* @__PURE__ */
|
|
3512
|
+
/* @__PURE__ */ jsxs7(Fragment4, { children: [
|
|
3513
|
+
/* @__PURE__ */ jsx7("path", { d: "M3 6h9M15 6h2M3 14h3M9 14h8" }),
|
|
3514
|
+
/* @__PURE__ */ jsx7("circle", { cx: "13.5", cy: "6", r: "1.8" }),
|
|
3515
|
+
/* @__PURE__ */ jsx7("circle", { cx: "7.5", cy: "14", r: "1.8" })
|
|
3427
3516
|
] })
|
|
3428
3517
|
),
|
|
3429
|
-
filter: icon(/* @__PURE__ */
|
|
3518
|
+
filter: icon(/* @__PURE__ */ jsx7("path", { d: "M3 4h14l-5.5 6.5V16l-3-1.5v-4z", strokeLinejoin: "round" })),
|
|
3430
3519
|
calendar: icon(
|
|
3431
|
-
/* @__PURE__ */
|
|
3432
|
-
/* @__PURE__ */
|
|
3433
|
-
/* @__PURE__ */
|
|
3520
|
+
/* @__PURE__ */ jsxs7(Fragment4, { children: [
|
|
3521
|
+
/* @__PURE__ */ jsx7("rect", { x: "3", y: "4.5", width: "14", height: "12", rx: "2" }),
|
|
3522
|
+
/* @__PURE__ */ jsx7("path", { d: "M3 8.5h14M7 2.5v4M13 2.5v4" })
|
|
3434
3523
|
] })
|
|
3435
3524
|
),
|
|
3436
3525
|
search: icon(
|
|
3437
|
-
/* @__PURE__ */
|
|
3438
|
-
/* @__PURE__ */
|
|
3439
|
-
/* @__PURE__ */
|
|
3526
|
+
/* @__PURE__ */ jsxs7(Fragment4, { children: [
|
|
3527
|
+
/* @__PURE__ */ jsx7("circle", { cx: "9", cy: "9", r: "5" }),
|
|
3528
|
+
/* @__PURE__ */ jsx7("path", { d: "M13 13l4 4" })
|
|
3440
3529
|
] })
|
|
3441
3530
|
)
|
|
3442
3531
|
};
|
|
@@ -3457,7 +3546,7 @@ function FilterBar() {
|
|
|
3457
3546
|
(a, b) => a.filters === b.filters && a.visible === b.visible && a.view === b.view
|
|
3458
3547
|
);
|
|
3459
3548
|
const visibleNames = new Set(state.visible.split("\0"));
|
|
3460
|
-
const [draft, setDraft] =
|
|
3549
|
+
const [draft, setDraft] = useState3(null);
|
|
3461
3550
|
const bar = runtime.doc.spec.display.filterBar ?? {};
|
|
3462
3551
|
const applyMode = (v2) => v2.apply === "button" ? "button" : v2.apply === "immediate" ? "change" : bar.apply ?? "change";
|
|
3463
3552
|
const needsApply = variables.some((v2) => applyMode(v2) === "button");
|
|
@@ -3486,7 +3575,7 @@ function FilterBar() {
|
|
|
3486
3575
|
for (const l of layouts)
|
|
3487
3576
|
if (l.view && !views.some((v2) => v2.name === l.view)) views.push({ name: l.view, label: l.label ?? l.view });
|
|
3488
3577
|
const byName = new Map(variables.map((v2) => [v2.name, v2]));
|
|
3489
|
-
return /* @__PURE__ */
|
|
3578
|
+
return /* @__PURE__ */ jsx7(
|
|
3490
3579
|
Custom,
|
|
3491
3580
|
{
|
|
3492
3581
|
filters: shown.map((v2) => ({
|
|
@@ -3508,7 +3597,7 @@ function FilterBar() {
|
|
|
3508
3597
|
setView: (view) => runtime.store.dispatch(stateActions.setView(view)),
|
|
3509
3598
|
renderControl: (name) => {
|
|
3510
3599
|
const def = byName.get(name);
|
|
3511
|
-
return def ? /* @__PURE__ */
|
|
3600
|
+
return def ? /* @__PURE__ */ jsx7(
|
|
3512
3601
|
ControlField,
|
|
3513
3602
|
{
|
|
3514
3603
|
compact: true,
|
|
@@ -3521,7 +3610,7 @@ function FilterBar() {
|
|
|
3521
3610
|
}
|
|
3522
3611
|
);
|
|
3523
3612
|
}
|
|
3524
|
-
const toolbar = /* @__PURE__ */
|
|
3613
|
+
const toolbar = /* @__PURE__ */ jsxs7(
|
|
3525
3614
|
"div",
|
|
3526
3615
|
{
|
|
3527
3616
|
className: "ds-filters",
|
|
@@ -3534,12 +3623,12 @@ function FilterBar() {
|
|
|
3534
3623
|
if (!e.target.closest(".ds-filter-pick")) options.onFilterSelect?.(BAR);
|
|
3535
3624
|
} : void 0,
|
|
3536
3625
|
children: [
|
|
3537
|
-
/* @__PURE__ */
|
|
3538
|
-
bar.icon !== "none" && /* @__PURE__ */
|
|
3626
|
+
/* @__PURE__ */ jsxs7(Track, { segmented: bar.look === "segmented", children: [
|
|
3627
|
+
bar.icon !== "none" && /* @__PURE__ */ jsx7("span", { className: "ds-filters-icon", "aria-hidden": "true", children: options.ui?.icons?.filterBar ?? BAR_ICONS[bar.icon ?? "sliders"] ?? BAR_ICONS.sliders }),
|
|
3539
3628
|
shown.map(
|
|
3540
3629
|
(v2) => options.onFilterSelect ? (
|
|
3541
3630
|
// Builder: a click selects the filter to configure it instead of opening it.
|
|
3542
|
-
/* @__PURE__ */
|
|
3631
|
+
/* @__PURE__ */ jsx7(
|
|
3543
3632
|
"div",
|
|
3544
3633
|
{
|
|
3545
3634
|
className: "ds-filter-pick",
|
|
@@ -3549,12 +3638,12 @@ function FilterBar() {
|
|
|
3549
3638
|
e.preventDefault();
|
|
3550
3639
|
e.stopPropagation();
|
|
3551
3640
|
},
|
|
3552
|
-
children: /* @__PURE__ */
|
|
3641
|
+
children: /* @__PURE__ */ jsx7(ControlField, { compact: true, def: v2, value: values[v2.name], onChange: () => {
|
|
3553
3642
|
} })
|
|
3554
3643
|
},
|
|
3555
3644
|
v2.name
|
|
3556
3645
|
)
|
|
3557
|
-
) : /* @__PURE__ */
|
|
3646
|
+
) : /* @__PURE__ */ jsx7(
|
|
3558
3647
|
ControlField,
|
|
3559
3648
|
{
|
|
3560
3649
|
compact: true,
|
|
@@ -3566,8 +3655,8 @@ function FilterBar() {
|
|
|
3566
3655
|
)
|
|
3567
3656
|
)
|
|
3568
3657
|
] }),
|
|
3569
|
-
(needsApply || bar.reset) && /* @__PURE__ */
|
|
3570
|
-
bar.reset && /* @__PURE__ */
|
|
3658
|
+
(needsApply || bar.reset) && /* @__PURE__ */ jsx7("span", { className: "ds-filters-spacer" }),
|
|
3659
|
+
bar.reset && /* @__PURE__ */ jsx7(
|
|
3571
3660
|
"button",
|
|
3572
3661
|
{
|
|
3573
3662
|
type: "button",
|
|
@@ -3581,7 +3670,7 @@ function FilterBar() {
|
|
|
3581
3670
|
children: "Reset"
|
|
3582
3671
|
}
|
|
3583
3672
|
),
|
|
3584
|
-
needsApply && /* @__PURE__ */
|
|
3673
|
+
needsApply && /* @__PURE__ */ jsx7(
|
|
3585
3674
|
"button",
|
|
3586
3675
|
{
|
|
3587
3676
|
type: "button",
|
|
@@ -3599,16 +3688,16 @@ function FilterBar() {
|
|
|
3599
3688
|
}
|
|
3600
3689
|
);
|
|
3601
3690
|
if (runtime.doc.spec.display.filters === "drawer" && !options.onFilterSelect)
|
|
3602
|
-
return /* @__PURE__ */
|
|
3691
|
+
return /* @__PURE__ */ jsx7(FilterDrawer, { active: shown.filter(changed).length, children: toolbar });
|
|
3603
3692
|
return toolbar;
|
|
3604
3693
|
}
|
|
3605
3694
|
var FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
3606
3695
|
function FilterDrawer({ active, children }) {
|
|
3607
|
-
const [open, setOpen] =
|
|
3608
|
-
const button =
|
|
3609
|
-
const panel =
|
|
3696
|
+
const [open, setOpen] = useState3(false);
|
|
3697
|
+
const button = useRef4(null);
|
|
3698
|
+
const panel = useRef4(null);
|
|
3610
3699
|
const id = useId3();
|
|
3611
|
-
|
|
3700
|
+
useEffect3(() => {
|
|
3612
3701
|
if (!open) return;
|
|
3613
3702
|
const first = panel.current?.querySelector(FOCUSABLE);
|
|
3614
3703
|
(first ?? panel.current)?.focus();
|
|
@@ -3617,8 +3706,8 @@ function FilterDrawer({ active, children }) {
|
|
|
3617
3706
|
setOpen(false);
|
|
3618
3707
|
button.current?.focus();
|
|
3619
3708
|
};
|
|
3620
|
-
return /* @__PURE__ */
|
|
3621
|
-
/* @__PURE__ */
|
|
3709
|
+
return /* @__PURE__ */ jsxs7("div", { className: "ds-filter-drawer", children: [
|
|
3710
|
+
/* @__PURE__ */ jsxs7(
|
|
3622
3711
|
"button",
|
|
3623
3712
|
{
|
|
3624
3713
|
ref: button,
|
|
@@ -3631,13 +3720,13 @@ function FilterDrawer({ active, children }) {
|
|
|
3631
3720
|
onClick: () => open ? close() : setOpen(true),
|
|
3632
3721
|
children: [
|
|
3633
3722
|
BAR_ICONS.filter,
|
|
3634
|
-
/* @__PURE__ */
|
|
3635
|
-
active > 0 && /* @__PURE__ */
|
|
3723
|
+
/* @__PURE__ */ jsx7("span", { children: "Filters" }),
|
|
3724
|
+
active > 0 && /* @__PURE__ */ jsx7("span", { className: "ds-filters-count", "aria-hidden": "true", children: active })
|
|
3636
3725
|
]
|
|
3637
3726
|
}
|
|
3638
3727
|
),
|
|
3639
3728
|
open && // A non-modal <dialog>: the rest of the dashboard stays usable while it is open.
|
|
3640
|
-
/* @__PURE__ */
|
|
3729
|
+
/* @__PURE__ */ jsxs7(
|
|
3641
3730
|
"dialog",
|
|
3642
3731
|
{
|
|
3643
3732
|
open: true,
|
|
@@ -3653,9 +3742,9 @@ function FilterDrawer({ active, children }) {
|
|
|
3653
3742
|
close();
|
|
3654
3743
|
},
|
|
3655
3744
|
children: [
|
|
3656
|
-
/* @__PURE__ */
|
|
3657
|
-
/* @__PURE__ */
|
|
3658
|
-
/* @__PURE__ */
|
|
3745
|
+
/* @__PURE__ */ jsxs7("div", { className: "ds-filter-panel-head", children: [
|
|
3746
|
+
/* @__PURE__ */ jsx7("span", { children: "Filters" }),
|
|
3747
|
+
/* @__PURE__ */ jsx7("button", { type: "button", className: "ds-close", "aria-label": "Close filters", onClick: close, children: "\xD7" })
|
|
3659
3748
|
] }),
|
|
3660
3749
|
children
|
|
3661
3750
|
]
|
|
@@ -3664,329 +3753,12 @@ function FilterDrawer({ active, children }) {
|
|
|
3664
3753
|
] });
|
|
3665
3754
|
}
|
|
3666
3755
|
function Track({ segmented, children }) {
|
|
3667
|
-
return segmented ? /* @__PURE__ */
|
|
3756
|
+
return segmented ? /* @__PURE__ */ jsx7("div", { className: "ds-filters-track", children }) : /* @__PURE__ */ jsx7(Fragment4, { children });
|
|
3668
3757
|
}
|
|
3669
3758
|
|
|
3670
|
-
// src/widgets/builtins/Filter.tsx
|
|
3671
|
-
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
3672
|
-
var Filter = defineWidget({
|
|
3673
|
-
...FilterContract,
|
|
3674
|
-
implements: "filter",
|
|
3675
|
-
frame: "plain",
|
|
3676
|
-
meta: { label: "Filter", icon: "filter", category: "Filters", size: { w: 12, h: 2, minW: 2, minH: 2 } },
|
|
3677
|
-
events: [],
|
|
3678
|
-
defaults: { variable: "" },
|
|
3679
|
-
component: function FilterWidget({ spec, mode }) {
|
|
3680
|
-
const { runtime } = useDashboard();
|
|
3681
|
-
const def = (runtime.doc.spec.variables ?? []).find((v2) => v2.name === spec.variable);
|
|
3682
|
-
const state = useTree(
|
|
3683
|
-
useCallback3((t) => ({ value: t.filters[spec.variable], tree: t }), [spec.variable]),
|
|
3684
|
-
(a, b) => a.value === b.value && a.tree.view === b.tree.view && a.tree.filters === b.tree.filters
|
|
3685
|
-
);
|
|
3686
|
-
if (!def)
|
|
3687
|
-
return mode === "edit" ? /* @__PURE__ */ jsx9("div", { className: "ds-filter-missing", children: "Choose a filter in the right panel" }) : null;
|
|
3688
|
-
if (typeof def.visibleWhen === "string" && !evaluateSafe(def.visibleWhen, rootScope(state.tree, runtime.helpers), true))
|
|
3689
|
-
return null;
|
|
3690
|
-
return /* @__PURE__ */ jsx9("div", { className: "ds-filter-widget", "data-fill": spec.fill || void 0, children: /* @__PURE__ */ jsx9(
|
|
3691
|
-
ControlField,
|
|
3692
|
-
{
|
|
3693
|
-
compact: true,
|
|
3694
|
-
def,
|
|
3695
|
-
value: state.value,
|
|
3696
|
-
onChange: (value) => runtime.store.dispatch(stateActions.setFilter({ name: spec.variable, value }))
|
|
3697
|
-
}
|
|
3698
|
-
) });
|
|
3699
|
-
}
|
|
3700
|
-
});
|
|
3701
|
-
|
|
3702
|
-
// src/widgets/wrap.tsx
|
|
3703
|
-
import { Suspense, lazy } from "react";
|
|
3704
|
-
import { z as z6 } from "zod";
|
|
3705
|
-
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
3706
|
-
function wrapComponent(Component2, o) {
|
|
3707
|
-
const schema = o.schema ?? z6.record(z6.unknown());
|
|
3708
|
-
const eventNames = [...new Set(Object.values(o.events ?? {}))];
|
|
3709
|
-
return defineWidget({
|
|
3710
|
-
kind: o.kind,
|
|
3711
|
-
version: o.version ?? 1,
|
|
3712
|
-
meta: o.meta,
|
|
3713
|
-
schema,
|
|
3714
|
-
...o.defaults ? { defaults: o.defaults } : {},
|
|
3715
|
-
...o.implements ? { implements: o.implements } : {},
|
|
3716
|
-
...o.exposes ? { exposes: o.exposes } : {},
|
|
3717
|
-
...o.frame ? { frame: o.frame } : {},
|
|
3718
|
-
...o.small ? { small: true } : {},
|
|
3719
|
-
events: eventNames,
|
|
3720
|
-
...o.slots ? { slots: Object.fromEntries(Object.values(o.slots).map((s) => [s, { label: s }])) } : {},
|
|
3721
|
-
component: function Wrapped(props) {
|
|
3722
|
-
const mapped = o.mapProps ? o.mapProps(props) : { ...props.spec, data: props.data };
|
|
3723
|
-
const handlers = {};
|
|
3724
|
-
for (const [prop, event] of Object.entries(o.events ?? {}))
|
|
3725
|
-
handlers[prop] = (value, ...rest) => props.emit(event, void 0, { value, args: [value, ...rest] });
|
|
3726
|
-
for (const [prop, path] of Object.entries(o.writes ?? {})) {
|
|
3727
|
-
const before = handlers[prop];
|
|
3728
|
-
handlers[prop] = (value, ...rest) => {
|
|
3729
|
-
props.store.set(path, value);
|
|
3730
|
-
before?.(value, ...rest);
|
|
3731
|
-
};
|
|
3732
|
-
}
|
|
3733
|
-
const slotProps = {};
|
|
3734
|
-
for (const [prop, slot] of Object.entries(o.slots ?? {})) slotProps[prop] = props.renderSlot(slot);
|
|
3735
|
-
return /* @__PURE__ */ jsx10(Component2, { ...mapped, ...handlers, ...slotProps });
|
|
3736
|
-
}
|
|
3737
|
-
});
|
|
3738
|
-
}
|
|
3739
|
-
function lazyWidget(def) {
|
|
3740
|
-
const { load, fallback, ...rest } = def;
|
|
3741
|
-
let Comp;
|
|
3742
|
-
return defineWidget({
|
|
3743
|
-
...rest,
|
|
3744
|
-
component: function LazyWidget(props) {
|
|
3745
|
-
Comp ??= lazy(load);
|
|
3746
|
-
return /* @__PURE__ */ jsx10(Suspense, { fallback: fallback ?? /* @__PURE__ */ jsx10("div", { className: "ds-skeleton", "aria-busy": "true" }), children: /* @__PURE__ */ jsx10(Comp, { ...props }) });
|
|
3747
|
-
}
|
|
3748
|
-
});
|
|
3749
|
-
}
|
|
3750
|
-
|
|
3751
|
-
// src/widgets/builtins/FlowMap.tsx
|
|
3752
|
-
var FlowMap = lazyWidget({
|
|
3753
|
-
...FlowMapContract,
|
|
3754
|
-
implements: "flow-map",
|
|
3755
|
-
exposes: { selection: "the clicked step's row" },
|
|
3756
|
-
meta: { label: "Flow map", icon: "flow", category: "Process", size: { w: 12, h: 12, minW: 6, minH: 6 } },
|
|
3757
|
-
events: ["click", "hover", "hoverEnd"],
|
|
3758
|
-
parts: ["step", "chip", "tag"],
|
|
3759
|
-
load: () => import("./FlowMapView-BSTKU7D4.js").then((m) => ({ default: m.FlowMapView }))
|
|
3760
|
-
});
|
|
3761
|
-
|
|
3762
|
-
// src/widgets/builtins/Image.tsx
|
|
3763
|
-
import "zod";
|
|
3764
|
-
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
3765
|
-
var Image = defineWidget({
|
|
3766
|
-
...ImageContract,
|
|
3767
|
-
implements: "image",
|
|
3768
|
-
meta: { label: "Image", icon: "image", category: "Content", size: { w: 4, h: 6, minW: 2, minH: 2 } },
|
|
3769
|
-
events: ["click"],
|
|
3770
|
-
component: function ImageWidget({ spec, data, emit }) {
|
|
3771
|
-
const src = safeImageSrc(spec.src ?? field(data, spec.srcField) ?? (typeof data === "string" ? data : void 0));
|
|
3772
|
-
if (!src) return /* @__PURE__ */ jsx11("div", { className: "ds-state", children: "No image" });
|
|
3773
|
-
return /* @__PURE__ */ jsx11(
|
|
3774
|
-
"button",
|
|
3775
|
-
{
|
|
3776
|
-
type: "button",
|
|
3777
|
-
className: "ds-plain",
|
|
3778
|
-
onClick: () => emit("click", "image", { value: src }),
|
|
3779
|
-
style: { width: "100%", height: "100%" },
|
|
3780
|
-
children: /* @__PURE__ */ jsx11("img", { src, alt: spec.alt, style: { width: "100%", height: "100%", objectFit: spec.fit } })
|
|
3781
|
-
}
|
|
3782
|
-
);
|
|
3783
|
-
}
|
|
3784
|
-
});
|
|
3785
|
-
|
|
3786
|
-
// src/widgets/builtins/ImageMap.tsx
|
|
3787
|
-
import "zod";
|
|
3788
|
-
import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
3789
|
-
var ImageMap = defineWidget({
|
|
3790
|
-
...ImageMapContract,
|
|
3791
|
-
implements: "image-map",
|
|
3792
|
-
meta: { label: "Image map", icon: "map", category: "Content", size: { w: 8, h: 8, minW: 3, minH: 3 } },
|
|
3793
|
-
events: ["click", "hover"],
|
|
3794
|
-
parts: ["marker"],
|
|
3795
|
-
component: function ImageMapWidget({ spec, data, emit, helpers }) {
|
|
3796
|
-
const m = spec.markers;
|
|
3797
|
-
const markers = Array.isArray(m) ? m.map((x) => ({ ...x, row: x })) : m ? asRows(data).map((r) => ({
|
|
3798
|
-
x: Number(field(r, m.x)),
|
|
3799
|
-
y: Number(field(r, m.y)),
|
|
3800
|
-
label: m.label ? String(field(r, m.label) ?? "") : void 0,
|
|
3801
|
-
value: m.value ? field(r, m.value) : void 0,
|
|
3802
|
-
status: m.status ? String(field(r, m.status) ?? "") : void 0,
|
|
3803
|
-
row: r
|
|
3804
|
-
})) : [];
|
|
3805
|
-
const src = safeImageSrc(spec.src);
|
|
3806
|
-
return /* @__PURE__ */ jsxs7("div", { className: "ds-imagemap", children: [
|
|
3807
|
-
src && /* @__PURE__ */ jsx12("img", { src, alt: spec.alt }),
|
|
3808
|
-
markers.map((mk, i) => {
|
|
3809
|
-
const t = mk.status ? spec.statusMap?.[mk.status] ?? mk.status : "info";
|
|
3810
|
-
return /* @__PURE__ */ jsxs7(
|
|
3811
|
-
"button",
|
|
3812
|
-
{
|
|
3813
|
-
type: "button",
|
|
3814
|
-
className: "ds-marker",
|
|
3815
|
-
style: {
|
|
3816
|
-
left: `${mk.x}%`,
|
|
3817
|
-
top: `${mk.y}%`,
|
|
3818
|
-
background: tone(t).bg,
|
|
3819
|
-
color: tone(t).fg,
|
|
3820
|
-
borderColor: tone(t).border
|
|
3821
|
-
},
|
|
3822
|
-
onClick: () => emit("click", "marker", { datum: mk.row, value: mk.value, index: i }),
|
|
3823
|
-
onMouseEnter: () => emit("hover", "marker", { datum: mk.row, value: mk.value, index: i }),
|
|
3824
|
-
children: [
|
|
3825
|
-
mk.label,
|
|
3826
|
-
mk.value !== void 0 && /* @__PURE__ */ jsxs7("strong", { children: [
|
|
3827
|
-
" ",
|
|
3828
|
-
formatValue(mk.value, helpers, spec.format),
|
|
3829
|
-
spec.unit ? ` ${spec.unit}` : ""
|
|
3830
|
-
] })
|
|
3831
|
-
]
|
|
3832
|
-
},
|
|
3833
|
-
`${mk.x}-${mk.y}-${i}`
|
|
3834
|
-
);
|
|
3835
|
-
})
|
|
3836
|
-
] });
|
|
3837
|
-
}
|
|
3838
|
-
});
|
|
3839
|
-
|
|
3840
|
-
// src/widgets/builtins/Kpi.tsx
|
|
3841
|
-
import "zod";
|
|
3842
|
-
|
|
3843
|
-
// src/widgets/shared/InfoTip.tsx
|
|
3844
|
-
import { useEffect as useEffect3, useLayoutEffect as useLayoutEffect2, useRef as useRef4, useState as useState3 } from "react";
|
|
3845
|
-
import { createPortal as createPortal2 } from "react-dom";
|
|
3846
|
-
import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
3847
|
-
function InfoTip({ text: text2 }) {
|
|
3848
|
-
const ref = useRef4(null);
|
|
3849
|
-
const tip = useRef4(null);
|
|
3850
|
-
const [open, setOpen] = useState3(false);
|
|
3851
|
-
const [mounted, setMounted] = useState3(false);
|
|
3852
|
-
const closing = useRef4(void 0);
|
|
3853
|
-
useEffect3(() => () => clearTimeout(closing.current), []);
|
|
3854
|
-
const show = () => {
|
|
3855
|
-
clearTimeout(closing.current);
|
|
3856
|
-
setMounted(true);
|
|
3857
|
-
setOpen(true);
|
|
3858
|
-
};
|
|
3859
|
-
const hide = () => {
|
|
3860
|
-
setOpen(false);
|
|
3861
|
-
clearTimeout(closing.current);
|
|
3862
|
-
closing.current = setTimeout(() => {
|
|
3863
|
-
setMounted(false);
|
|
3864
|
-
setPos(null);
|
|
3865
|
-
}, 160);
|
|
3866
|
-
};
|
|
3867
|
-
const [pos, setPos] = useState3(null);
|
|
3868
|
-
useLayoutEffect2(() => {
|
|
3869
|
-
if (!mounted || !ref.current || !tip.current) return;
|
|
3870
|
-
const a = ref.current.getBoundingClientRect();
|
|
3871
|
-
const t = tip.current.getBoundingClientRect();
|
|
3872
|
-
const gap = 8;
|
|
3873
|
-
const margin = 8;
|
|
3874
|
-
const vw = window.innerWidth || document.documentElement.clientWidth;
|
|
3875
|
-
const box = ref.current.closest(".ds-root")?.getBoundingClientRect();
|
|
3876
|
-
const minX = Math.max(margin, (box?.left ?? 0) + margin);
|
|
3877
|
-
const maxX = Math.min(vw, box?.right ?? vw) - margin;
|
|
3878
|
-
const minY = Math.max(margin, (box?.top ?? 0) + margin);
|
|
3879
|
-
const below = a.top - t.height - gap < minY;
|
|
3880
|
-
const centre = a.left + a.width / 2;
|
|
3881
|
-
const left = Math.min(Math.max(centre - t.width / 2, minX), Math.max(minX, maxX - t.width));
|
|
3882
|
-
setPos({ left, top: below ? a.bottom + gap : a.top - t.height - gap, arrow: centre - left, below });
|
|
3883
|
-
}, [mounted]);
|
|
3884
|
-
const root = ref.current?.closest(".ds-root") ?? (typeof document !== "undefined" ? document.body : null);
|
|
3885
|
-
return /* @__PURE__ */ jsxs8(
|
|
3886
|
-
"button",
|
|
3887
|
-
{
|
|
3888
|
-
ref,
|
|
3889
|
-
type: "button",
|
|
3890
|
-
className: "ds-info",
|
|
3891
|
-
"aria-label": text2,
|
|
3892
|
-
onClick: (e) => e.stopPropagation(),
|
|
3893
|
-
onMouseEnter: show,
|
|
3894
|
-
onMouseLeave: hide,
|
|
3895
|
-
onFocus: show,
|
|
3896
|
-
onBlur: hide,
|
|
3897
|
-
children: [
|
|
3898
|
-
/* @__PURE__ */ jsxs8("svg", { viewBox: "0 0 16 16", width: "14", height: "14", "aria-hidden": "true", children: [
|
|
3899
|
-
/* @__PURE__ */ jsx13("circle", { cx: "8", cy: "8", r: "6.5", fill: "none", stroke: "currentColor", strokeWidth: "1" }),
|
|
3900
|
-
/* @__PURE__ */ jsx13("path", { d: "M8 7.2v3.6M8 5.2v.1", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round" })
|
|
3901
|
-
] }),
|
|
3902
|
-
mounted && root && createPortal2(
|
|
3903
|
-
/* @__PURE__ */ jsx13(
|
|
3904
|
-
"span",
|
|
3905
|
-
{
|
|
3906
|
-
ref: tip,
|
|
3907
|
-
className: "ds-tip",
|
|
3908
|
-
role: "tooltip",
|
|
3909
|
-
"data-below": pos?.below || void 0,
|
|
3910
|
-
"data-open": open && pos ? "" : void 0,
|
|
3911
|
-
style: {
|
|
3912
|
-
left: pos?.left ?? 0,
|
|
3913
|
-
top: pos?.top ?? 0,
|
|
3914
|
-
visibility: pos ? "visible" : "hidden",
|
|
3915
|
-
["--ds-tip-arrow"]: `${pos?.arrow ?? 0}px`
|
|
3916
|
-
},
|
|
3917
|
-
children: text2
|
|
3918
|
-
}
|
|
3919
|
-
),
|
|
3920
|
-
root
|
|
3921
|
-
)
|
|
3922
|
-
]
|
|
3923
|
-
}
|
|
3924
|
-
);
|
|
3925
|
-
}
|
|
3926
|
-
|
|
3927
|
-
// src/widgets/shared/clickable.ts
|
|
3928
|
-
import { useContext as useContext5 } from "react";
|
|
3929
|
-
|
|
3930
|
-
// src/components/PanelFrame.tsx
|
|
3931
|
-
import { useCallback as useCallback4, useEffect as useEffect4, useId as useId4, useMemo as useMemo3, useRef as useRef5, useState as useState4 } from "react";
|
|
3932
|
-
|
|
3933
|
-
// src/widgets/parseProps.ts
|
|
3934
|
-
function without(value, path) {
|
|
3935
|
-
if (path.length === 0 || value === null || typeof value !== "object") return value;
|
|
3936
|
-
const [head, ...rest] = path;
|
|
3937
|
-
if (Array.isArray(value)) {
|
|
3938
|
-
if (typeof head !== "number" || head < 0 || head >= value.length) return value;
|
|
3939
|
-
const copy2 = [...value];
|
|
3940
|
-
if (rest.length === 0) copy2.splice(head, 1);
|
|
3941
|
-
else copy2[head] = without(copy2[head], rest);
|
|
3942
|
-
return copy2;
|
|
3943
|
-
}
|
|
3944
|
-
if (!Object.hasOwn(value, head)) return value;
|
|
3945
|
-
const copy = { ...value };
|
|
3946
|
-
if (rest.length === 0) delete copy[head];
|
|
3947
|
-
else copy[head] = without(copy[head], rest);
|
|
3948
|
-
return copy;
|
|
3949
|
-
}
|
|
3950
|
-
function parseWidgetProps(schema, props) {
|
|
3951
|
-
let current = props;
|
|
3952
|
-
const dropped = [];
|
|
3953
|
-
for (let round = 0; round < 25; round++) {
|
|
3954
|
-
const r = schema.safeParse(current);
|
|
3955
|
-
if (r.success) return { props: r.data, dropped };
|
|
3956
|
-
const issue = r.error.issues.find((i) => i.path.length > 0);
|
|
3957
|
-
if (!issue) break;
|
|
3958
|
-
const lastIndex = issue.path.reduce((at, k, i) => typeof k === "number" ? i : at, -1);
|
|
3959
|
-
const path = lastIndex >= 0 ? issue.path.slice(0, lastIndex + 1) : issue.path;
|
|
3960
|
-
const next = without(current, path);
|
|
3961
|
-
if (next === current) break;
|
|
3962
|
-
dropped.push(path.join("."));
|
|
3963
|
-
current = next;
|
|
3964
|
-
}
|
|
3965
|
-
return { props, dropped };
|
|
3966
|
-
}
|
|
3967
|
-
|
|
3968
|
-
// src/components/Boundary.tsx
|
|
3969
|
-
import { Component } from "react";
|
|
3970
|
-
var sameKeys = (a, b) => a.length === b.length && a.every((x, i) => Object.is(x, b[i]));
|
|
3971
|
-
var Boundary = class extends Component {
|
|
3972
|
-
state = { error: null };
|
|
3973
|
-
static getDerivedStateFromError(error) {
|
|
3974
|
-
return { error };
|
|
3975
|
-
}
|
|
3976
|
-
componentDidCatch(error, _info) {
|
|
3977
|
-
this.props.onError?.(error);
|
|
3978
|
-
}
|
|
3979
|
-
componentDidUpdate(prev) {
|
|
3980
|
-
if (this.state.error && !sameKeys(prev.resetKeys ?? [], this.props.resetKeys ?? [])) this.setState({ error: null });
|
|
3981
|
-
}
|
|
3982
|
-
render() {
|
|
3983
|
-
return this.state.error ? this.props.fallback(this.state.error) : this.props.children;
|
|
3984
|
-
}
|
|
3985
|
-
};
|
|
3986
|
-
|
|
3987
3759
|
// src/components/Slot.tsx
|
|
3988
3760
|
import { createContext as createContext3, useContext as useContext4 } from "react";
|
|
3989
|
-
import { Fragment as Fragment5, jsx as
|
|
3761
|
+
import { Fragment as Fragment5, jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
3990
3762
|
var NodeScopeContext = createContext3({});
|
|
3991
3763
|
var useNodeScope = () => useContext4(NodeScopeContext);
|
|
3992
3764
|
var SlotOwnerContext = createContext3(null);
|
|
@@ -4022,7 +3794,7 @@ function Slot({
|
|
|
4022
3794
|
item: item !== void 0 ? item : outer.item,
|
|
4023
3795
|
index: index !== void 0 ? index : outer.index
|
|
4024
3796
|
};
|
|
4025
|
-
return /* @__PURE__ */
|
|
3797
|
+
return /* @__PURE__ */ jsx8(NodeScopeContext.Provider, { value: scope2, children: /* @__PURE__ */ jsxs8(
|
|
4026
3798
|
"div",
|
|
4027
3799
|
{
|
|
4028
3800
|
className: className ? `ds-slot ${className}` : "ds-slot",
|
|
@@ -4031,21 +3803,21 @@ function Slot({
|
|
|
4031
3803
|
"data-owner": owner.id,
|
|
4032
3804
|
"data-empty": ids.length === 0 || void 0,
|
|
4033
3805
|
children: [
|
|
4034
|
-
ids.map((id) => /* @__PURE__ */
|
|
4035
|
-
ids.length === 0 && editing && (empty ?? /* @__PURE__ */
|
|
3806
|
+
ids.map((id) => /* @__PURE__ */ jsx8(SlotItem, { children: renderChild(id) }, id)),
|
|
3807
|
+
ids.length === 0 && editing && (empty ?? /* @__PURE__ */ jsx8("span", { className: "ds-slot-hint", children: "Drop here" }))
|
|
4036
3808
|
]
|
|
4037
3809
|
}
|
|
4038
3810
|
) });
|
|
4039
3811
|
}
|
|
4040
|
-
var SlotItem = ({ children }) => /* @__PURE__ */
|
|
3812
|
+
var SlotItem = ({ children }) => /* @__PURE__ */ jsx8(Fragment5, { children });
|
|
4041
3813
|
|
|
4042
3814
|
// src/components/PanelFrame.tsx
|
|
4043
|
-
import { jsx as
|
|
3815
|
+
import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
4044
3816
|
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;
|
|
4045
3817
|
function useSize() {
|
|
4046
3818
|
const [size2, setSize] = useState4({ width: 0, height: 0 });
|
|
4047
3819
|
const observer = useRef5(null);
|
|
4048
|
-
const ref =
|
|
3820
|
+
const ref = useCallback3((el) => {
|
|
4049
3821
|
observer.current?.disconnect();
|
|
4050
3822
|
observer.current = null;
|
|
4051
3823
|
if (!el || typeof ResizeObserver === "undefined") return;
|
|
@@ -4172,7 +3944,7 @@ function widgetStore(runtime) {
|
|
|
4172
3944
|
get,
|
|
4173
3945
|
use: function useStoreValue(pathOrSelect) {
|
|
4174
3946
|
return useTree(
|
|
4175
|
-
|
|
3947
|
+
useCallback3(
|
|
4176
3948
|
(t) => typeof pathOrSelect === "string" ? getPath(t, pathOrSelect) : pathOrSelect(t),
|
|
4177
3949
|
[pathOrSelect]
|
|
4178
3950
|
),
|
|
@@ -4207,7 +3979,7 @@ function useHiddenPanels(ids) {
|
|
|
4207
3979
|
const key = ids.join(",");
|
|
4208
3980
|
const list = useTree(
|
|
4209
3981
|
// biome-ignore lint/correctness/useExhaustiveDependencies: ids are compared by key
|
|
4210
|
-
|
|
3982
|
+
useCallback3(
|
|
4211
3983
|
(tree) => ids.filter((id) => {
|
|
4212
3984
|
const def = findPanel(runtime.doc, id);
|
|
4213
3985
|
if (!def) return false;
|
|
@@ -4252,7 +4024,7 @@ function dropIndexAt(panel, x, y) {
|
|
|
4252
4024
|
return { slot: box.getAttribute("data-slot") ?? void 0, index: indexIn(box, x, y) };
|
|
4253
4025
|
}
|
|
4254
4026
|
function PanelFrame({ id, nested = false }) {
|
|
4255
|
-
return /* @__PURE__ */
|
|
4027
|
+
return /* @__PURE__ */ jsx9(Boundary, { resetKeys: [id], fallback: (e) => /* @__PURE__ */ jsx9(PanelCrash, { id, error: e }), children: /* @__PURE__ */ jsx9(PanelFrameInner, { id, nested }) });
|
|
4256
4028
|
}
|
|
4257
4029
|
function PanelCrash({ id, error }) {
|
|
4258
4030
|
const { options } = useDashboard();
|
|
@@ -4262,7 +4034,7 @@ function PanelCrash({ id, error }) {
|
|
|
4262
4034
|
} catch {
|
|
4263
4035
|
custom = void 0;
|
|
4264
4036
|
}
|
|
4265
|
-
return /* @__PURE__ */
|
|
4037
|
+
return /* @__PURE__ */ jsx9("section", { className: "ds-panel", "data-panel": id, "aria-label": id, children: /* @__PURE__ */ jsx9("div", { className: "ds-panel-body", children: custom ?? /* @__PURE__ */ jsxs9("div", { className: "ds-state ds-state-error", role: "alert", children: [
|
|
4266
4038
|
"This panel could not be shown: ",
|
|
4267
4039
|
error.message
|
|
4268
4040
|
] }) }) });
|
|
@@ -4278,7 +4050,7 @@ function PanelFrameInner({ id, nested }) {
|
|
|
4278
4050
|
const drillLevels = def.drill?.levels ?? [];
|
|
4279
4051
|
const view = useTree(
|
|
4280
4052
|
// biome-ignore lint/correctness/useExhaustiveDependencies: the panel definition is fixed for a runtime
|
|
4281
|
-
|
|
4053
|
+
useCallback3(
|
|
4282
4054
|
(tree) => {
|
|
4283
4055
|
const ps = tree.panels[id] ?? {};
|
|
4284
4056
|
const level = drillLevels[(ps.drill ?? []).length];
|
|
@@ -4349,7 +4121,7 @@ function PanelFrameInner({ id, nested }) {
|
|
|
4349
4121
|
),
|
|
4350
4122
|
samePanelView
|
|
4351
4123
|
);
|
|
4352
|
-
const renderNested =
|
|
4124
|
+
const renderNested = useCallback3((child) => /* @__PURE__ */ jsx9(PanelFrame, { id: child, nested: true }, child), []);
|
|
4353
4125
|
const store = useMemo3(() => widgetStore(runtime), [runtime]);
|
|
4354
4126
|
const [bodyRef, size2] = useSize();
|
|
4355
4127
|
const frameRef = useRef5(null);
|
|
@@ -4382,7 +4154,7 @@ function PanelFrameInner({ id, nested }) {
|
|
|
4382
4154
|
visibility.set(instance, null);
|
|
4383
4155
|
};
|
|
4384
4156
|
}, [instance, view.visible, view.hidden, wanted, visibility]);
|
|
4385
|
-
const emit =
|
|
4157
|
+
const emit = useCallback3(
|
|
4386
4158
|
(type, part, detail) => {
|
|
4387
4159
|
const event = { type, panel: id, ...part ? { part } : {}, ...detail };
|
|
4388
4160
|
options.onEvent?.(event);
|
|
@@ -4390,11 +4162,11 @@ function PanelFrameInner({ id, nested }) {
|
|
|
4390
4162
|
},
|
|
4391
4163
|
[id, options, runtime]
|
|
4392
4164
|
);
|
|
4393
|
-
const run =
|
|
4165
|
+
const run = useCallback3(
|
|
4394
4166
|
(action, detail) => void runtime.runAction(action, { type: "click", panel: id, ...detail }),
|
|
4395
4167
|
[runtime, id]
|
|
4396
4168
|
);
|
|
4397
|
-
const setUi =
|
|
4169
|
+
const setUi = useCallback3(
|
|
4398
4170
|
(patch) => runtime.store.dispatch(
|
|
4399
4171
|
stateActions.patchPanel({ id, patch: { ui: { ...runtime.getTree().panels[id]?.ui, ...patch } } })
|
|
4400
4172
|
),
|
|
@@ -4434,28 +4206,28 @@ function PanelFrameInner({ id, nested }) {
|
|
|
4434
4206
|
const hideHeader = Boolean(def.style?.hideHeader) || !title && !subtitle && !meta2 && !live2 && drill.length === 0 && controls.length === 0 && !view.stale && headerKids.length === 0;
|
|
4435
4207
|
const dnd = Boolean(options.onDropOnPanel);
|
|
4436
4208
|
let body;
|
|
4437
|
-
if (!widget) body = /* @__PURE__ */
|
|
4209
|
+
if (!widget) body = /* @__PURE__ */ jsxs9("div", { className: "ds-state", children: [
|
|
4438
4210
|
"Unknown widget \u201C",
|
|
4439
4211
|
String(def.kind),
|
|
4440
4212
|
"\u201D"
|
|
4441
4213
|
] });
|
|
4442
4214
|
else if (view.error && view.data === void 0)
|
|
4443
|
-
body = options.renderError?.(view.error, id) ?? /* @__PURE__ */
|
|
4215
|
+
body = options.renderError?.(view.error, id) ?? /* @__PURE__ */ jsx9("div", { className: "ds-state ds-state-error", role: "alert", children: view.messages?.error ?? view.error.message });
|
|
4444
4216
|
else if (view.source && view.data === void 0 && (view.status === "loading" || view.status === "idle"))
|
|
4445
|
-
body = options.renderLoading?.(id, loadingText(view.messages)) ?? /* @__PURE__ */
|
|
4217
|
+
body = options.renderLoading?.(id, loadingText(view.messages)) ?? /* @__PURE__ */ jsx9(LoadingState, { text: loadingText(view.messages) });
|
|
4446
4218
|
else if (view.source && isEmpty(view.data) && widget.empty !== "widget")
|
|
4447
|
-
body = options.renderEmpty?.(id) ?? /* @__PURE__ */
|
|
4219
|
+
body = options.renderEmpty?.(id) ?? /* @__PURE__ */ jsx9("div", { className: "ds-state", children: view.messages?.empty ?? "No data" });
|
|
4448
4220
|
else {
|
|
4449
4221
|
const W = widget.component;
|
|
4450
|
-
body = /* @__PURE__ */
|
|
4222
|
+
body = /* @__PURE__ */ jsx9(
|
|
4451
4223
|
Boundary,
|
|
4452
4224
|
{
|
|
4453
4225
|
resetKeys: [view.data, props],
|
|
4454
|
-
fallback: (e) => /* @__PURE__ */
|
|
4226
|
+
fallback: (e) => /* @__PURE__ */ jsxs9("div", { className: "ds-state ds-state-error", role: "alert", children: [
|
|
4455
4227
|
"This panel could not be shown: ",
|
|
4456
4228
|
e.message
|
|
4457
4229
|
] }),
|
|
4458
|
-
children: /* @__PURE__ */
|
|
4230
|
+
children: /* @__PURE__ */ jsx9(
|
|
4459
4231
|
W,
|
|
4460
4232
|
{
|
|
4461
4233
|
spec: props,
|
|
@@ -4471,7 +4243,7 @@ function PanelFrameInner({ id, nested }) {
|
|
|
4471
4243
|
mode: options.mode,
|
|
4472
4244
|
helpers: runtime.helpers,
|
|
4473
4245
|
panelId: id,
|
|
4474
|
-
renderSlot: (name, o) => /* @__PURE__ */
|
|
4246
|
+
renderSlot: (name, o) => /* @__PURE__ */ jsx9(Slot, { name, ...o }),
|
|
4475
4247
|
store
|
|
4476
4248
|
}
|
|
4477
4249
|
)
|
|
@@ -4488,7 +4260,7 @@ function PanelFrameInner({ id, nested }) {
|
|
|
4488
4260
|
const name = el?.getAttribute("data-slot") ?? defaultSlot;
|
|
4489
4261
|
return { slot: name, index: el ? indexIn(el, x, y) : void 0 };
|
|
4490
4262
|
};
|
|
4491
|
-
return /* @__PURE__ */
|
|
4263
|
+
return /* @__PURE__ */ jsx9(SlotOwnerContext.Provider, { value: { id, data: view.data, def }, children: /* @__PURE__ */ jsx9(SlotChildContext.Provider, { value: renderNested, children: /* @__PURE__ */ jsxs9(
|
|
4492
4264
|
"section",
|
|
4493
4265
|
{
|
|
4494
4266
|
ref: frameRef,
|
|
@@ -4537,19 +4309,19 @@ function PanelFrameInner({ id, nested }) {
|
|
|
4537
4309
|
e.stopPropagation();
|
|
4538
4310
|
} : void 0,
|
|
4539
4311
|
children: [
|
|
4540
|
-
!hideHeader && /* @__PURE__ */
|
|
4541
|
-
/* @__PURE__ */
|
|
4542
|
-
title && /* @__PURE__ */
|
|
4312
|
+
!hideHeader && /* @__PURE__ */ jsxs9("header", { className: "ds-panel-head", children: [
|
|
4313
|
+
/* @__PURE__ */ jsxs9("div", { style: { minWidth: 0 }, children: [
|
|
4314
|
+
title && /* @__PURE__ */ jsxs9("h3", { className: "ds-panel-title", children: [
|
|
4543
4315
|
title,
|
|
4544
|
-
info && /* @__PURE__ */
|
|
4316
|
+
info && /* @__PURE__ */ jsx9(InfoTip, { text: info })
|
|
4545
4317
|
] }),
|
|
4546
|
-
subtitle && /* @__PURE__ */
|
|
4547
|
-
drill.length > 0 && /* @__PURE__ */
|
|
4548
|
-
/* @__PURE__ */
|
|
4549
|
-
drill.map((d, i) => /* @__PURE__ */
|
|
4318
|
+
subtitle && /* @__PURE__ */ jsx9("p", { className: "ds-panel-subtitle", children: subtitle }),
|
|
4319
|
+
drill.length > 0 && /* @__PURE__ */ jsxs9("nav", { className: "ds-crumbs", "aria-label": "Drill path", children: [
|
|
4320
|
+
/* @__PURE__ */ jsx9("button", { type: "button", onClick: () => runtime.runAction({ do: "drillReset", panel: id }), children: "All" }),
|
|
4321
|
+
drill.map((d, i) => /* @__PURE__ */ jsxs9("span", { children: [
|
|
4550
4322
|
"\u203A",
|
|
4551
4323
|
" ",
|
|
4552
|
-
i < drill.length - 1 ? /* @__PURE__ */
|
|
4324
|
+
i < drill.length - 1 ? /* @__PURE__ */ jsx9(
|
|
4553
4325
|
"button",
|
|
4554
4326
|
{
|
|
4555
4327
|
type: "button",
|
|
@@ -4562,14 +4334,14 @@ function PanelFrameInner({ id, nested }) {
|
|
|
4562
4334
|
] }, `${d.level}-${i}`))
|
|
4563
4335
|
] })
|
|
4564
4336
|
] }),
|
|
4565
|
-
/* @__PURE__ */
|
|
4566
|
-
headerKids.length > 0 && /* @__PURE__ */
|
|
4567
|
-
meta2 && /* @__PURE__ */
|
|
4568
|
-
live2 ? /* @__PURE__ */
|
|
4569
|
-
/* @__PURE__ */
|
|
4337
|
+
/* @__PURE__ */ jsxs9("div", { className: "ds-panel-tools", children: [
|
|
4338
|
+
headerKids.length > 0 && /* @__PURE__ */ jsx9(Slot, { name: "header", className: "ds-panel-addons" }),
|
|
4339
|
+
meta2 && /* @__PURE__ */ jsx9("span", { className: "ds-panel-meta", children: meta2 }),
|
|
4340
|
+
live2 ? /* @__PURE__ */ jsxs9("span", { className: "ds-live", "data-stale": view.stale || void 0, title: view.error?.message, children: [
|
|
4341
|
+
/* @__PURE__ */ jsx9("span", { "aria-hidden": "true" }),
|
|
4570
4342
|
liveLabel(props.liveText, view.updatedAt, runtime.helpers)
|
|
4571
|
-
] }) : view.stale && /* @__PURE__ */
|
|
4572
|
-
controls.map((c) => /* @__PURE__ */
|
|
4343
|
+
] }) : view.stale && /* @__PURE__ */ jsx9("span", { className: "ds-badge ds-badge-stale", title: view.error?.message, children: "Stale" }),
|
|
4344
|
+
controls.map((c) => /* @__PURE__ */ jsx9(
|
|
4573
4345
|
ControlField,
|
|
4574
4346
|
{
|
|
4575
4347
|
def: c,
|
|
@@ -4586,9 +4358,9 @@ function PanelFrameInner({ id, nested }) {
|
|
|
4586
4358
|
))
|
|
4587
4359
|
] })
|
|
4588
4360
|
] }),
|
|
4589
|
-
toolbarKids.length > 0 && /* @__PURE__ */
|
|
4590
|
-
/* @__PURE__ */
|
|
4591
|
-
footerKids.length > 0 && /* @__PURE__ */
|
|
4361
|
+
toolbarKids.length > 0 && /* @__PURE__ */ jsx9(Slot, { name: "toolbar", className: "ds-panel-toolbar" }),
|
|
4362
|
+
/* @__PURE__ */ jsx9("div", { className: "ds-panel-body", ref: bodyRef, children: body }),
|
|
4363
|
+
footerKids.length > 0 && /* @__PURE__ */ jsx9(Slot, { name: "footer", className: "ds-panel-foot" })
|
|
4592
4364
|
]
|
|
4593
4365
|
}
|
|
4594
4366
|
) }) });
|
|
@@ -4598,10 +4370,10 @@ function loadingText(messages) {
|
|
|
4598
4370
|
return v2 === void 0 || v2 === null || v2 === "" ? void 0 : String(v2);
|
|
4599
4371
|
}
|
|
4600
4372
|
function LoadingState({ text: text2 }) {
|
|
4601
|
-
if (!text2) return /* @__PURE__ */
|
|
4602
|
-
return /* @__PURE__ */
|
|
4603
|
-
/* @__PURE__ */
|
|
4604
|
-
/* @__PURE__ */
|
|
4373
|
+
if (!text2) return /* @__PURE__ */ jsx9("div", { className: "ds-skeleton", "aria-busy": "true", "aria-label": "Loading" });
|
|
4374
|
+
return /* @__PURE__ */ jsxs9("output", { className: "ds-loading", "aria-busy": "true", children: [
|
|
4375
|
+
/* @__PURE__ */ jsx9("div", { className: "ds-skeleton", "aria-hidden": "true" }),
|
|
4376
|
+
/* @__PURE__ */ jsx9("span", { className: "ds-loading-text", children: text2 })
|
|
4605
4377
|
] });
|
|
4606
4378
|
}
|
|
4607
4379
|
|
|
@@ -4623,6 +4395,237 @@ function useClickable(panelId, activate) {
|
|
|
4623
4395
|
};
|
|
4624
4396
|
}
|
|
4625
4397
|
|
|
4398
|
+
// src/widgets/builtins/Container.tsx
|
|
4399
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
4400
|
+
var JUSTIFY = {
|
|
4401
|
+
start: "flex-start",
|
|
4402
|
+
center: "center",
|
|
4403
|
+
end: "flex-end",
|
|
4404
|
+
between: "space-between",
|
|
4405
|
+
around: "space-around",
|
|
4406
|
+
evenly: "space-evenly"
|
|
4407
|
+
};
|
|
4408
|
+
var ALIGN = { start: "flex-start", center: "center", end: "flex-end", stretch: "stretch" };
|
|
4409
|
+
var Container = defineWidget({
|
|
4410
|
+
...ContainerContract,
|
|
4411
|
+
implements: "layout",
|
|
4412
|
+
frame: "plain",
|
|
4413
|
+
meta: { label: "Container", icon: "container", category: "Layout", size: { w: 12, h: 5, minW: 2, minH: 2 } },
|
|
4414
|
+
events: ["click"],
|
|
4415
|
+
defaults: { direction: "row", wrap: true, gap: 12 },
|
|
4416
|
+
component: function ContainerWidget({ spec, renderSlot, emit, panelId }) {
|
|
4417
|
+
const click = useClickable(panelId, () => emit("click", void 0, {}));
|
|
4418
|
+
const style = {
|
|
4419
|
+
display: "flex",
|
|
4420
|
+
flexDirection: spec.direction,
|
|
4421
|
+
flexWrap: spec.wrap ? "wrap" : "nowrap",
|
|
4422
|
+
gap: spec.gap,
|
|
4423
|
+
justifyContent: JUSTIFY[spec.justify],
|
|
4424
|
+
alignItems: ALIGN[spec.align],
|
|
4425
|
+
// An equal split is across a row; in a column, children keep their own height.
|
|
4426
|
+
["--ds-child-flex"]: spec.equal && spec.direction === "row" ? `1 1 ${spec.childMinWidth}px` : "0 0 auto",
|
|
4427
|
+
["--ds-child-min"]: `${spec.direction === "row" ? spec.childMinWidth : 0}px`,
|
|
4428
|
+
overflow: spec.scroll ? "auto" : "visible"
|
|
4429
|
+
};
|
|
4430
|
+
const items = renderSlot("items", {
|
|
4431
|
+
className: "ds-container",
|
|
4432
|
+
style,
|
|
4433
|
+
empty: /* @__PURE__ */ jsx10("span", { className: "ds-slot-hint", children: "Drop widgets here" })
|
|
4434
|
+
});
|
|
4435
|
+
if (click.role !== "button") return items;
|
|
4436
|
+
return /* @__PURE__ */ jsx10("div", { className: "ds-container-click", ...click, children: items });
|
|
4437
|
+
}
|
|
4438
|
+
});
|
|
4439
|
+
|
|
4440
|
+
// src/widgets/builtins/Content.tsx
|
|
4441
|
+
import "zod";
|
|
4442
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
4443
|
+
var Content = defineWidget({
|
|
4444
|
+
...ContentContract,
|
|
4445
|
+
implements: "text",
|
|
4446
|
+
meta: { label: "Rich text", icon: "text", category: "Content", size: { w: 4, h: 3, minW: 2, minH: 1 } },
|
|
4447
|
+
events: ["click"],
|
|
4448
|
+
defaults: { markdown: "Write **Markdown** here." },
|
|
4449
|
+
component: function ContentWidget({ spec, run }) {
|
|
4450
|
+
return /* @__PURE__ */ jsx11("div", { className: "ds-content", style: { textAlign: spec.align }, children: /* @__PURE__ */ jsx11(Markdown, { text: spec.markdown, onAction: (name) => run(name) }) });
|
|
4451
|
+
}
|
|
4452
|
+
});
|
|
4453
|
+
|
|
4454
|
+
// src/widgets/builtins/Filter.tsx
|
|
4455
|
+
import { useCallback as useCallback4 } from "react";
|
|
4456
|
+
import "zod";
|
|
4457
|
+
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
4458
|
+
var Filter = defineWidget({
|
|
4459
|
+
...FilterContract,
|
|
4460
|
+
implements: "filter",
|
|
4461
|
+
frame: "plain",
|
|
4462
|
+
meta: { label: "Filter", icon: "filter", category: "Filters", size: { w: 12, h: 2, minW: 2, minH: 2 } },
|
|
4463
|
+
events: [],
|
|
4464
|
+
defaults: { variable: "" },
|
|
4465
|
+
component: function FilterWidget({ spec, mode }) {
|
|
4466
|
+
const { runtime } = useDashboard();
|
|
4467
|
+
const def = (runtime.doc.spec.variables ?? []).find((v2) => v2.name === spec.variable);
|
|
4468
|
+
const state = useTree(
|
|
4469
|
+
useCallback4((t) => ({ value: t.filters[spec.variable], tree: t }), [spec.variable]),
|
|
4470
|
+
(a, b) => a.value === b.value && a.tree.view === b.tree.view && a.tree.filters === b.tree.filters
|
|
4471
|
+
);
|
|
4472
|
+
if (!def)
|
|
4473
|
+
return mode === "edit" ? /* @__PURE__ */ jsx12("div", { className: "ds-filter-missing", children: "Choose a filter in the right panel" }) : null;
|
|
4474
|
+
if (typeof def.visibleWhen === "string" && !evaluateSafe(def.visibleWhen, rootScope(state.tree, runtime.helpers), true))
|
|
4475
|
+
return null;
|
|
4476
|
+
return /* @__PURE__ */ jsx12("div", { className: "ds-filter-widget", "data-fill": spec.fill || void 0, children: /* @__PURE__ */ jsx12(
|
|
4477
|
+
ControlField,
|
|
4478
|
+
{
|
|
4479
|
+
compact: true,
|
|
4480
|
+
def,
|
|
4481
|
+
value: state.value,
|
|
4482
|
+
onChange: (value) => runtime.store.dispatch(stateActions.setFilter({ name: spec.variable, value }))
|
|
4483
|
+
}
|
|
4484
|
+
) });
|
|
4485
|
+
}
|
|
4486
|
+
});
|
|
4487
|
+
|
|
4488
|
+
// src/widgets/wrap.tsx
|
|
4489
|
+
import { Suspense, lazy } from "react";
|
|
4490
|
+
import { z as z6 } from "zod";
|
|
4491
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
4492
|
+
function wrapComponent(Component2, o) {
|
|
4493
|
+
const schema = o.schema ?? z6.record(z6.unknown());
|
|
4494
|
+
const eventNames = [...new Set(Object.values(o.events ?? {}))];
|
|
4495
|
+
return defineWidget({
|
|
4496
|
+
kind: o.kind,
|
|
4497
|
+
version: o.version ?? 1,
|
|
4498
|
+
meta: o.meta,
|
|
4499
|
+
schema,
|
|
4500
|
+
...o.defaults ? { defaults: o.defaults } : {},
|
|
4501
|
+
...o.implements ? { implements: o.implements } : {},
|
|
4502
|
+
...o.exposes ? { exposes: o.exposes } : {},
|
|
4503
|
+
...o.frame ? { frame: o.frame } : {},
|
|
4504
|
+
...o.small ? { small: true } : {},
|
|
4505
|
+
events: eventNames,
|
|
4506
|
+
...o.slots ? { slots: Object.fromEntries(Object.values(o.slots).map((s) => [s, { label: s }])) } : {},
|
|
4507
|
+
component: function Wrapped(props) {
|
|
4508
|
+
const mapped = o.mapProps ? o.mapProps(props) : { ...props.spec, data: props.data };
|
|
4509
|
+
const handlers = {};
|
|
4510
|
+
for (const [prop, event] of Object.entries(o.events ?? {}))
|
|
4511
|
+
handlers[prop] = (value, ...rest) => props.emit(event, void 0, { value, args: [value, ...rest] });
|
|
4512
|
+
for (const [prop, path] of Object.entries(o.writes ?? {})) {
|
|
4513
|
+
const before = handlers[prop];
|
|
4514
|
+
handlers[prop] = (value, ...rest) => {
|
|
4515
|
+
props.store.set(path, value);
|
|
4516
|
+
before?.(value, ...rest);
|
|
4517
|
+
};
|
|
4518
|
+
}
|
|
4519
|
+
const slotProps = {};
|
|
4520
|
+
for (const [prop, slot] of Object.entries(o.slots ?? {})) slotProps[prop] = props.renderSlot(slot);
|
|
4521
|
+
return /* @__PURE__ */ jsx13(Component2, { ...mapped, ...handlers, ...slotProps });
|
|
4522
|
+
}
|
|
4523
|
+
});
|
|
4524
|
+
}
|
|
4525
|
+
function lazyWidget(def) {
|
|
4526
|
+
const { load, fallback, ...rest } = def;
|
|
4527
|
+
let Comp;
|
|
4528
|
+
return defineWidget({
|
|
4529
|
+
...rest,
|
|
4530
|
+
component: function LazyWidget(props) {
|
|
4531
|
+
Comp ??= lazy(load);
|
|
4532
|
+
return /* @__PURE__ */ jsx13(Suspense, { fallback: fallback ?? /* @__PURE__ */ jsx13("div", { className: "ds-skeleton", "aria-busy": "true" }), children: /* @__PURE__ */ jsx13(Comp, { ...props }) });
|
|
4533
|
+
}
|
|
4534
|
+
});
|
|
4535
|
+
}
|
|
4536
|
+
|
|
4537
|
+
// src/widgets/builtins/FlowMap.tsx
|
|
4538
|
+
var FlowMap = lazyWidget({
|
|
4539
|
+
...FlowMapContract,
|
|
4540
|
+
implements: "flow-map",
|
|
4541
|
+
exposes: { selection: "the clicked step's row" },
|
|
4542
|
+
meta: { label: "Flow map", icon: "flow", category: "Process", size: { w: 12, h: 12, minW: 6, minH: 6 } },
|
|
4543
|
+
events: ["click", "hover", "hoverEnd"],
|
|
4544
|
+
parts: ["step", "chip", "tag"],
|
|
4545
|
+
load: () => import("./FlowMapView-7ROMAXSY.js").then((m) => ({ default: m.FlowMapView }))
|
|
4546
|
+
});
|
|
4547
|
+
|
|
4548
|
+
// src/widgets/builtins/Image.tsx
|
|
4549
|
+
import "zod";
|
|
4550
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
4551
|
+
var Image = defineWidget({
|
|
4552
|
+
...ImageContract,
|
|
4553
|
+
implements: "image",
|
|
4554
|
+
meta: { label: "Image", icon: "image", category: "Content", size: { w: 4, h: 6, minW: 2, minH: 2 } },
|
|
4555
|
+
events: ["click"],
|
|
4556
|
+
component: function ImageWidget({ spec, data, emit }) {
|
|
4557
|
+
const src = safeImageSrc(spec.src ?? field(data, spec.srcField) ?? (typeof data === "string" ? data : void 0));
|
|
4558
|
+
if (!src) return /* @__PURE__ */ jsx14("div", { className: "ds-state", children: "No image" });
|
|
4559
|
+
return /* @__PURE__ */ jsx14(
|
|
4560
|
+
"button",
|
|
4561
|
+
{
|
|
4562
|
+
type: "button",
|
|
4563
|
+
className: "ds-plain",
|
|
4564
|
+
onClick: () => emit("click", "image", { value: src }),
|
|
4565
|
+
style: { width: "100%", height: "100%" },
|
|
4566
|
+
children: /* @__PURE__ */ jsx14("img", { src, alt: spec.alt, style: { width: "100%", height: "100%", objectFit: spec.fit } })
|
|
4567
|
+
}
|
|
4568
|
+
);
|
|
4569
|
+
}
|
|
4570
|
+
});
|
|
4571
|
+
|
|
4572
|
+
// src/widgets/builtins/ImageMap.tsx
|
|
4573
|
+
import "zod";
|
|
4574
|
+
import { jsx as jsx15, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
4575
|
+
var ImageMap = defineWidget({
|
|
4576
|
+
...ImageMapContract,
|
|
4577
|
+
implements: "image-map",
|
|
4578
|
+
meta: { label: "Image map", icon: "map", category: "Content", size: { w: 8, h: 8, minW: 3, minH: 3 } },
|
|
4579
|
+
events: ["click", "hover"],
|
|
4580
|
+
parts: ["marker"],
|
|
4581
|
+
component: function ImageMapWidget({ spec, data, emit, helpers }) {
|
|
4582
|
+
const m = spec.markers;
|
|
4583
|
+
const markers = Array.isArray(m) ? m.map((x) => ({ ...x, row: x })) : m ? asRows(data).map((r) => ({
|
|
4584
|
+
x: Number(field(r, m.x)),
|
|
4585
|
+
y: Number(field(r, m.y)),
|
|
4586
|
+
label: m.label ? String(field(r, m.label) ?? "") : void 0,
|
|
4587
|
+
value: m.value ? field(r, m.value) : void 0,
|
|
4588
|
+
status: m.status ? String(field(r, m.status) ?? "") : void 0,
|
|
4589
|
+
row: r
|
|
4590
|
+
})) : [];
|
|
4591
|
+
const src = safeImageSrc(spec.src);
|
|
4592
|
+
return /* @__PURE__ */ jsxs10("div", { className: "ds-imagemap", children: [
|
|
4593
|
+
src && /* @__PURE__ */ jsx15("img", { src, alt: spec.alt }),
|
|
4594
|
+
markers.map((mk, i) => {
|
|
4595
|
+
const t = mk.status ? spec.statusMap?.[mk.status] ?? mk.status : "info";
|
|
4596
|
+
return /* @__PURE__ */ jsxs10(
|
|
4597
|
+
"button",
|
|
4598
|
+
{
|
|
4599
|
+
type: "button",
|
|
4600
|
+
className: "ds-marker",
|
|
4601
|
+
style: {
|
|
4602
|
+
left: `${mk.x}%`,
|
|
4603
|
+
top: `${mk.y}%`,
|
|
4604
|
+
background: tone(t).bg,
|
|
4605
|
+
color: tone(t).fg,
|
|
4606
|
+
borderColor: tone(t).border
|
|
4607
|
+
},
|
|
4608
|
+
onClick: () => emit("click", "marker", { datum: mk.row, value: mk.value, index: i }),
|
|
4609
|
+
onMouseEnter: () => emit("hover", "marker", { datum: mk.row, value: mk.value, index: i }),
|
|
4610
|
+
children: [
|
|
4611
|
+
mk.label,
|
|
4612
|
+
mk.value !== void 0 && /* @__PURE__ */ jsxs10("strong", { children: [
|
|
4613
|
+
" ",
|
|
4614
|
+
formatValue(mk.value, helpers, spec.format),
|
|
4615
|
+
spec.unit ? ` ${spec.unit}` : ""
|
|
4616
|
+
] })
|
|
4617
|
+
]
|
|
4618
|
+
},
|
|
4619
|
+
`${mk.x}-${mk.y}-${i}`
|
|
4620
|
+
);
|
|
4621
|
+
})
|
|
4622
|
+
] });
|
|
4623
|
+
}
|
|
4624
|
+
});
|
|
4625
|
+
|
|
4626
|
+
// src/widgets/builtins/Kpi.tsx
|
|
4627
|
+
import "zod";
|
|
4628
|
+
|
|
4626
4629
|
// src/widgets/shared/motion.ts
|
|
4627
4630
|
import { useEffect as useEffect5, useRef as useRef6, useState as useState5 } from "react";
|
|
4628
4631
|
var reduced = () => typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
|
|
@@ -6815,6 +6818,8 @@ function Grid({
|
|
|
6815
6818
|
style: {
|
|
6816
6819
|
["--ds-i"]: i,
|
|
6817
6820
|
minHeight: o.h * rowHeight + (o.h - 1) * gap,
|
|
6821
|
+
// Narrow layout: one item per line unless the caller sizes it.
|
|
6822
|
+
flex: "1 1 100%",
|
|
6818
6823
|
...flowStyle?.(o.panel, o.h * rowHeight + (o.h - 1) * gap)
|
|
6819
6824
|
},
|
|
6820
6825
|
children: children(o.panel)
|
|
@@ -7024,7 +7029,7 @@ function ModalHost() {
|
|
|
7024
7029
|
view: null,
|
|
7025
7030
|
columns: grid.columns,
|
|
7026
7031
|
rowHeight: grid.rowHeight,
|
|
7027
|
-
gap: grid.gap,
|
|
7032
|
+
gap: m.gap ?? grid.gap,
|
|
7028
7033
|
exactHeights: grid.exactHeights,
|
|
7029
7034
|
children: (pid) => /* @__PURE__ */ jsx28(PanelFrame, { id: pid })
|
|
7030
7035
|
}
|
|
@@ -7076,7 +7081,7 @@ function ModalHost() {
|
|
|
7076
7081
|
view: null,
|
|
7077
7082
|
columns: grid.columns,
|
|
7078
7083
|
rowHeight: grid.rowHeight,
|
|
7079
|
-
gap: grid.gap,
|
|
7084
|
+
gap: m.gap ?? grid.gap,
|
|
7080
7085
|
exactHeights: grid.exactHeights,
|
|
7081
7086
|
children: (id) => /* @__PURE__ */ jsx28(PanelFrame, { id })
|
|
7082
7087
|
}
|
|
@@ -7781,6 +7786,9 @@ var RENDERER_CSS = `
|
|
|
7781
7786
|
|
|
7782
7787
|
/* Container: a flex layout of panels */
|
|
7783
7788
|
.ds-container { height: 100%; min-height: 0; }
|
|
7789
|
+
.ds-container-click { height: 100%; cursor: pointer; outline: none; border-radius: inherit; }
|
|
7790
|
+
.ds-container-click:focus-visible { outline: 2px solid var(--ds-color-border-focus); outline-offset: 2px; }
|
|
7791
|
+
.ds-container-click > .ds-container { height: 100%; }
|
|
7784
7792
|
.ds-container > .ds-panel { flex: var(--ds-child-flex, 1 1 160px); min-width: var(--ds-child-min, 0); height: auto; }
|
|
7785
7793
|
.ds-container[data-direction="column"] > .ds-panel { min-height: 0; }
|
|
7786
7794
|
.ds-container-empty { display: grid; place-items: center; height: 100%; min-height: 80px; border: 1.5px dashed var(--ds-color-border-default); border-radius: var(--ds-radius-card); color: var(--ds-color-text-subtle); font-size: 12px; }
|
|
@@ -7900,44 +7908,44 @@ var RENDERER_CSS = `
|
|
|
7900
7908
|
.ds-repeater-item { display: flex; flex-direction: column; gap: 8px; }
|
|
7901
7909
|
.ds-repeater-item > .ds-panel { height: auto; }
|
|
7902
7910
|
/* FlowMap: a process flow; every colour from the theme, so it works in light and dark */
|
|
7903
|
-
.ds-
|
|
7904
|
-
.ds-
|
|
7905
|
-
.ds-
|
|
7906
|
-
.ds-
|
|
7907
|
-
.ds-
|
|
7908
|
-
.ds-
|
|
7909
|
-
.ds-
|
|
7910
|
-
.ds-
|
|
7911
|
-
.ds-
|
|
7912
|
-
.ds-
|
|
7913
|
-
.ds-
|
|
7914
|
-
.ds-
|
|
7915
|
-
.ds-
|
|
7916
|
-
.ds-
|
|
7917
|
-
.ds-
|
|
7918
|
-
.ds-
|
|
7919
|
-
.ds-
|
|
7920
|
-
.ds-
|
|
7921
|
-
.ds-
|
|
7922
|
-
.ds-
|
|
7923
|
-
.ds-
|
|
7924
|
-
.ds-
|
|
7925
|
-
@keyframes ds-
|
|
7926
|
-
@media (prefers-reduced-motion: reduce) { .ds-
|
|
7927
|
-
.ds-
|
|
7928
|
-
.ds-
|
|
7929
|
-
.ds-
|
|
7930
|
-
.ds-
|
|
7931
|
-
.ds-
|
|
7932
|
-
.ds-
|
|
7933
|
-
.ds-
|
|
7934
|
-
.ds-
|
|
7935
|
-
.ds-
|
|
7936
|
-
.ds-
|
|
7937
|
-
.ds-
|
|
7938
|
-
.ds-panel-tools .ds-
|
|
7939
|
-
.ds-
|
|
7940
|
-
.ds-
|
|
7911
|
+
.ds-flowmap { display: block; min-width: 0; }
|
|
7912
|
+
.ds-flowmap-scroll { flex: none; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
|
|
7913
|
+
.ds-flowmap-svg { display: block; width: 100%; height: auto; margin: 0 auto; }
|
|
7914
|
+
.ds-flowmap-track { fill: none; stroke: var(--ds-flowmap-track, var(--ds-color-border-default)); stroke-width: var(--ds-flowmap-track-width, 6); stroke-linecap: round; stroke-linejoin: round; }
|
|
7915
|
+
.ds-flowmap-track[data-dashed] { stroke-linecap: butt; stroke-dasharray: 5 2.5; }
|
|
7916
|
+
.ds-flowmap-chevron { fill: none; stroke: var(--ds-color-text-subtle); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
|
|
7917
|
+
.ds-flowmap-tag rect { fill: var(--ds-color-status-info-bg); }
|
|
7918
|
+
.ds-flowmap-tag text { font-family: var(--ds-font-heading); font-size: 11px; font-weight: 500; fill: var(--ds-color-status-info-fg); }
|
|
7919
|
+
.ds-flowmap-tag[data-dim] rect { fill: var(--ds-color-surface-table-header); }
|
|
7920
|
+
.ds-flowmap-tag[data-dim] text { fill: var(--ds-color-text-subtle); }
|
|
7921
|
+
.ds-flowmap-step { cursor: pointer; outline: none; }
|
|
7922
|
+
.ds-flowmap-step[data-untracked] { cursor: default; }
|
|
7923
|
+
.ds-flowmap-step:focus-visible .ds-flowmap-hit { stroke: var(--ds-color-border-focus); stroke-width: 2; }
|
|
7924
|
+
.ds-flowmap-hit { fill: transparent; pointer-events: all; }
|
|
7925
|
+
.ds-flowmap-label { font-family: var(--ds-font-heading); font-size: 14px; font-weight: 700; fill: var(--ds-color-text-primary); paint-order: stroke; stroke: var(--ds-color-surface-card); stroke-width: 6px; stroke-linejoin: round; }
|
|
7926
|
+
.ds-flowmap-label[data-selected] { font-size: 16px; }
|
|
7927
|
+
.ds-flowmap-step[data-untracked] .ds-flowmap-label { fill: var(--ds-color-text-disabled); }
|
|
7928
|
+
.ds-flowmap-untracked { fill: var(--ds-color-surface-card); stroke: var(--ds-color-text-disabled); stroke-width: 2; stroke-dasharray: 3 2; }
|
|
7929
|
+
.ds-flowmap-shape { stroke: var(--ds-color-surface-card); stroke-width: 3; paint-order: stroke; }
|
|
7930
|
+
.ds-flowmap-step[data-dim] .ds-flowmap-shape { fill: var(--ds-color-text-subtle); }
|
|
7931
|
+
.ds-flowmap-step[data-dim] image { filter: grayscale(1); }
|
|
7932
|
+
.ds-flowmap-halo { animation: ds-flowmap-pulse 1.2s ease-in-out infinite; }
|
|
7933
|
+
@keyframes ds-flowmap-pulse { 50% { opacity: .7; } }
|
|
7934
|
+
@media (prefers-reduced-motion: reduce) { .ds-flowmap-halo { animation: none; } }
|
|
7935
|
+
.ds-flowmap-chip rect { fill: var(--ds-color-surface-table-header); }
|
|
7936
|
+
.ds-flowmap-chip text { font-family: var(--ds-font-body); fill: var(--ds-color-text-primary); }
|
|
7937
|
+
.ds-flowmap-chip-value { font-size: 14px; font-weight: 700; }
|
|
7938
|
+
.ds-flowmap-chip-unit { font-size: 12px; font-weight: 400; fill: var(--ds-color-text-subtle); }
|
|
7939
|
+
.ds-flowmap-chip[data-tone="good"] rect { fill: var(--ds-color-status-good-bg); }
|
|
7940
|
+
.ds-flowmap-chip[data-tone="good"] text, .ds-flowmap-chip[data-tone="good"] .ds-flowmap-chip-unit { fill: var(--ds-color-status-good-fg); }
|
|
7941
|
+
.ds-flowmap-chip[data-tone="dim"] text, .ds-flowmap-chip[data-tone="dim"] .ds-flowmap-chip-unit { fill: var(--ds-color-text-subtle); }
|
|
7942
|
+
.ds-flowmap-chip[data-tone="selected"] rect { fill: var(--ds-color-surface-selection); }
|
|
7943
|
+
.ds-flowmap-chip[data-tone="selected"] text, .ds-flowmap-chip[data-tone="selected"] .ds-flowmap-chip-unit { fill: var(--ds-color-action-primary); }
|
|
7944
|
+
.ds-flowmap-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 20px; font-family: var(--ds-font-body); font-size: 12px; color: var(--ds-color-text-primary); }
|
|
7945
|
+
.ds-flowmap-legend li { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
|
|
7946
|
+
.ds-panel-tools .ds-flowmap-legend { flex: none; }
|
|
7947
|
+
.ds-flowmap-hover { position: fixed; z-index: var(--ds-z-tooltip); min-width: 220px; max-width: 320px; padding: 12px; border-radius: 12px; background: var(--ds-color-chart-tooltip-bg); color: var(--ds-color-chart-tooltip-text); box-shadow: var(--ds-shadow-overlay); backdrop-filter: blur(16px); }
|
|
7948
|
+
.ds-flowmap-hover > * { margin: 0; }
|
|
7941
7949
|
`;
|
|
7942
7950
|
|
|
7943
7951
|
// src/components/urlSync.ts
|
|
@@ -8096,6 +8104,7 @@ function stateView(C, p) {
|
|
|
8096
8104
|
}
|
|
8097
8105
|
var CONTENT_SIZED = /* @__PURE__ */ new Set([
|
|
8098
8106
|
"Kpi",
|
|
8107
|
+
"FlowMap",
|
|
8099
8108
|
"Tiles",
|
|
8100
8109
|
"Table",
|
|
8101
8110
|
"Breakdown",
|