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