@pipelex/mthds-ui 0.34.0 → 0.35.0

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.
@@ -1,4 +1,8 @@
1
1
  "use client";
2
+ import {
3
+ detectSystemTheme,
4
+ useSystemTheme
5
+ } from "../../chunk-F63A55IE.js";
2
6
  import {
3
7
  GRAPH_STYLES,
4
8
  GRAPH_STYLE_PIPELINES,
@@ -37,7 +41,6 @@ import {
37
41
  GRAPH_DIRECTION,
38
42
  GRAPH_SPEC_MODE,
39
43
  GRAPH_STYLE,
40
- GRAPH_THEME,
41
44
  GRAPH_THEME_MODE,
42
45
  NODE_TYPE_SIMPLE_DECISION,
43
46
  NODE_TYPE_SIMPLE_FRAME,
@@ -68,7 +71,7 @@ import "./viewer/GraphToolbar.css";
68
71
  import "./styles/simple/SimpleStyle.css";
69
72
 
70
73
  // src/graph/react/viewer/GraphViewer.tsx
71
- import React13 from "react";
74
+ import React12 from "react";
72
75
  import {
73
76
  ReactFlow,
74
77
  useNodesState,
@@ -77,53 +80,8 @@ import {
77
80
  BackgroundVariant
78
81
  } from "@xyflow/react";
79
82
 
80
- // src/graph/react/viewer/useSystemTheme.ts
81
- import React from "react";
82
- var PREFERS_DARK_QUERY = "(prefers-color-scheme: dark)";
83
- function prefersDarkToTheme(prefersDark) {
84
- return prefersDark ? GRAPH_THEME.DARK : GRAPH_THEME.LIGHT;
85
- }
86
- function detectSystemTheme() {
87
- if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
88
- return GRAPH_THEME.DARK;
89
- }
90
- return prefersDarkToTheme(window.matchMedia(PREFERS_DARK_QUERY).matches);
91
- }
92
- function subscribeToSystemTheme(onChange) {
93
- if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
94
- return () => {
95
- };
96
- }
97
- const mql = window.matchMedia(PREFERS_DARK_QUERY);
98
- if (typeof mql.addEventListener === "function") {
99
- mql.addEventListener("change", onChange);
100
- return () => mql.removeEventListener("change", onChange);
101
- }
102
- mql.addListener(onChange);
103
- return () => mql.removeListener(onChange);
104
- }
105
- function systemThemeStore(injected) {
106
- if (injected !== void 0) {
107
- return {
108
- subscribe: () => () => {
109
- },
110
- getSnapshot: () => injected,
111
- getServerSnapshot: () => injected
112
- };
113
- }
114
- return {
115
- subscribe: subscribeToSystemTheme,
116
- getSnapshot: detectSystemTheme,
117
- getServerSnapshot: () => GRAPH_THEME.DARK
118
- };
119
- }
120
- function useSystemTheme(injected) {
121
- const store = React.useMemo(() => systemThemeStore(injected), [injected]);
122
- return React.useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot);
123
- }
124
-
125
83
  // src/graph/react/detail/StuffResultPanel.tsx
126
- import * as React2 from "react";
84
+ import * as React from "react";
127
85
  import {
128
86
  buildResultField,
129
87
  getPipeInputForm,
@@ -149,7 +107,7 @@ function StuffResultPanel({
149
107
  saveFiles,
150
108
  downloads
151
109
  }) {
152
- const field = React2.useMemo(
110
+ const field = React.useMemo(
153
111
  () => {
154
112
  var _a;
155
113
  return (_a = fromProducer(pipeIoContracts, outputForm, producerPipeRef)) != null ? _a : fromConsumer(pipeIoContracts, inputForm, consumer);
@@ -223,7 +181,7 @@ function resultDescriptors(graph) {
223
181
  }
224
182
 
225
183
  // src/graph/react/detail/DetailPanel.tsx
226
- import React3 from "react";
184
+ import React2 from "react";
227
185
  import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
228
186
  function DetailPanel({
229
187
  isOpen,
@@ -234,7 +192,7 @@ function DetailPanel({
234
192
  onResizeHandleMouseDown,
235
193
  closeOnEscape = true
236
194
  }) {
237
- React3.useEffect(() => {
195
+ React2.useEffect(() => {
238
196
  if (!isOpen || !closeOnEscape) return;
239
197
  const onKeyDown = (e) => {
240
198
  if (e.key === "Escape") onClose();
@@ -266,7 +224,7 @@ function DetailPanel({
266
224
  }
267
225
 
268
226
  // src/graph/react/detail/useResizable.ts
269
- import React4 from "react";
227
+ import React3 from "react";
270
228
  var MAX_WIDTH_RATIO = 0.6;
271
229
  function useResizable({
272
230
  defaultWidth,
@@ -274,11 +232,11 @@ function useResizable({
274
232
  maxWidth,
275
233
  containerRef
276
234
  }) {
277
- const [width, setWidth] = React4.useState(defaultWidth);
278
- const [isDragging, setIsDragging] = React4.useState(false);
279
- const dragRef = React4.useRef({ startX: 0, startWidth: 0, maxAllowed: maxWidth });
280
- const rafRef = React4.useRef(null);
281
- const handleMouseDown = React4.useCallback(
235
+ const [width, setWidth] = React3.useState(defaultWidth);
236
+ const [isDragging, setIsDragging] = React3.useState(false);
237
+ const dragRef = React3.useRef({ startX: 0, startWidth: 0, maxAllowed: maxWidth });
238
+ const rafRef = React3.useRef(null);
239
+ const handleMouseDown = React3.useCallback(
282
240
  (e) => {
283
241
  var _a;
284
242
  e.preventDefault();
@@ -292,7 +250,7 @@ function useResizable({
292
250
  },
293
251
  [width, maxWidth, containerRef]
294
252
  );
295
- React4.useEffect(() => {
253
+ React3.useEffect(() => {
296
254
  if (!isDragging) return;
297
255
  const onMouseMove = (e) => {
298
256
  if (rafRef.current !== null) cancelAnimationFrame(rafRef.current);
@@ -330,7 +288,7 @@ function useResizable({
330
288
  }
331
289
 
332
290
  // src/graph/react/detail/PipeDetailPanel.tsx
333
- import React6 from "react";
291
+ import React5 from "react";
334
292
 
335
293
  // src/graph/react/detail/sections/shared.tsx
336
294
  import { useState } from "react";
@@ -1244,8 +1202,8 @@ function PipeDetailPanel({ node, spec, onConceptClick }) {
1244
1202
  const badge = PIPE_TYPE_BADGES[pipeType];
1245
1203
  const status = node.status;
1246
1204
  const statusColor = (_a = STATUS_COLORS[status]) != null ? _a : "#6272a4";
1247
- const blueprint = React6.useMemo(() => resolveNodeBlueprint(spec, node), [spec, node]);
1248
- const [usageExpanded, setUsageExpanded] = React6.useState(false);
1205
+ const blueprint = React5.useMemo(() => resolveNodeBlueprint(spec, node), [spec, node]);
1206
+ const [usageExpanded, setUsageExpanded] = React5.useState(false);
1249
1207
  const inputs = (_c = (_b = node.io) == null ? void 0 : _b.inputs) != null ? _c : [];
1250
1208
  const outputs = (_e = (_d = node.io) == null ? void 0 : _d.outputs) != null ? _e : [];
1251
1209
  const description = (_f = blueprint == null ? void 0 : blueprint.description) != null ? _f : node.description;
@@ -1470,7 +1428,7 @@ function GenericExecutionData({ entries }) {
1470
1428
  }
1471
1429
 
1472
1430
  // src/graph/react/detail/ConceptDetailPanel.tsx
1473
- import React7 from "react";
1431
+ import React6 from "react";
1474
1432
  import { Fragment as Fragment12, jsx as jsx18, jsxs as jsxs18 } from "react/jsx-runtime";
1475
1433
  function ConceptDetailPanel({
1476
1434
  concept,
@@ -1507,8 +1465,8 @@ function ConceptDetailPanel({
1507
1465
  function ConceptBody({ concept, ioData, isDryRun, renderData }) {
1508
1466
  const dataView = ioData && !isDryRun ? renderData == null ? void 0 : renderData() : void 0;
1509
1467
  const hasData = Boolean(dataView);
1510
- const [activeTab, setActiveTab] = React7.useState(hasData ? "data" : "structure");
1511
- const baseId = React7.useId();
1468
+ const [activeTab, setActiveTab] = React6.useState(hasData ? "data" : "structure");
1469
+ const baseId = React6.useId();
1512
1470
  const tabId = (tab) => `${baseId}-tab-${tab}`;
1513
1471
  const panelId = (tab) => `${baseId}-tabpanel-${tab}`;
1514
1472
  const structure = concept.json_schema ? /* @__PURE__ */ jsxs18("div", { children: [
@@ -1730,7 +1688,7 @@ function hydrateLabels(nodes) {
1730
1688
  }
1731
1689
 
1732
1690
  // src/graph/react/viewer/GraphToolbar.tsx
1733
- import React10 from "react";
1691
+ import React9 from "react";
1734
1692
  import { Panel } from "@xyflow/react";
1735
1693
 
1736
1694
  // src/graph/react/viewer/ValidationPanel.tsx
@@ -1850,14 +1808,14 @@ function ValidationPanel({
1850
1808
  }
1851
1809
 
1852
1810
  // src/graph/react/viewer/StyleMenu.tsx
1853
- import React9 from "react";
1811
+ import React8 from "react";
1854
1812
 
1855
1813
  // src/graph/react/viewer/usePopoverDismiss.ts
1856
- import React8 from "react";
1814
+ import React7 from "react";
1857
1815
  function usePopoverDismiss(open, wrapperRef, onDismiss) {
1858
- const onDismissRef = React8.useRef(onDismiss);
1816
+ const onDismissRef = React7.useRef(onDismiss);
1859
1817
  onDismissRef.current = onDismiss;
1860
- React8.useEffect(() => {
1818
+ React7.useEffect(() => {
1861
1819
  if (!open) return;
1862
1820
  const onPointerDown = (event) => {
1863
1821
  const wrapper = wrapperRef.current;
@@ -1914,18 +1872,18 @@ function styleMenuLabel(style) {
1914
1872
  return `Graph style: ${GRAPH_STYLES[style].name} \u2014 choose how the graph is drawn`;
1915
1873
  }
1916
1874
  function StyleMenu({ value, options, onChange, placement }) {
1917
- const [open, setOpen] = React9.useState(false);
1918
- const [activeIndex, setActiveIndex] = React9.useState(0);
1919
- const wrapperRef = React9.useRef(null);
1920
- const buttonRef = React9.useRef(null);
1921
- const itemRefs = React9.useRef([]);
1922
- const menuId = React9.useId();
1875
+ const [open, setOpen] = React8.useState(false);
1876
+ const [activeIndex, setActiveIndex] = React8.useState(0);
1877
+ const wrapperRef = React8.useRef(null);
1878
+ const buttonRef = React8.useRef(null);
1879
+ const itemRefs = React8.useRef([]);
1880
+ const menuId = React8.useId();
1923
1881
  usePopoverDismiss(open, wrapperRef, (reason) => {
1924
1882
  var _a;
1925
1883
  setOpen(false);
1926
1884
  if (reason === "escape") (_a = buttonRef.current) == null ? void 0 : _a.focus();
1927
1885
  });
1928
- React9.useEffect(() => {
1886
+ React8.useEffect(() => {
1929
1887
  var _a;
1930
1888
  if (!open) return;
1931
1889
  const index = Math.max(0, options.indexOf(value));
@@ -2396,11 +2354,11 @@ function GraphToolbar({
2396
2354
  const orientation = toolbarOrientation(position);
2397
2355
  const setValidationOpen = onValidationOpenChange != null ? onValidationOpenChange : (() => {
2398
2356
  });
2399
- const setValidationOpenRef = React10.useRef(setValidationOpen);
2357
+ const setValidationOpenRef = React9.useRef(setValidationOpen);
2400
2358
  setValidationOpenRef.current = setValidationOpen;
2401
- const validationRef = React10.useRef(null);
2402
- const validationPanelId = React10.useId();
2403
- React10.useEffect(() => {
2359
+ const validationRef = React9.useRef(null);
2360
+ const validationPanelId = React9.useId();
2361
+ React9.useEffect(() => {
2404
2362
  if (validationState === void 0) setValidationOpenRef.current(false);
2405
2363
  }, [validationState]);
2406
2364
  usePopoverDismiss(validationOpen, validationRef, () => setValidationOpenRef.current(false));
@@ -2413,151 +2371,159 @@ function GraphToolbar({
2413
2371
  const foldAllSection = onFoldAll || onExpandAll;
2414
2372
  const foldAllTitle = foldAllDisabled ? "Fold all controllers (nothing to fold)" : "Fold all controllers";
2415
2373
  const expandAllTitle = expandAllDisabled ? "Expand all controllers (nothing to expand)" : "Expand all controllers";
2416
- return /* @__PURE__ */ jsx22(Panel, { position, className: "graph-toolbar-panel", style: panelStyle, children: /* @__PURE__ */ jsxs22("div", { className: `graph-toolbar graph-toolbar--${orientation}`, children: [
2417
- validationState !== void 0 && /* @__PURE__ */ jsxs22(Fragment13, { children: [
2418
- /* @__PURE__ */ jsxs22("div", { className: "graph-toolbar-validation", ref: validationRef, children: [
2419
- /* @__PURE__ */ jsxs22(
2374
+ return /* @__PURE__ */ jsx22(
2375
+ Panel,
2376
+ {
2377
+ position,
2378
+ className: `graph-toolbar-panel graph-toolbar-panel--${orientation}`,
2379
+ style: panelStyle,
2380
+ children: /* @__PURE__ */ jsxs22("div", { className: `graph-toolbar graph-toolbar--${orientation}`, children: [
2381
+ validationState !== void 0 && /* @__PURE__ */ jsxs22(Fragment13, { children: [
2382
+ /* @__PURE__ */ jsxs22("div", { className: "graph-toolbar-validation", ref: validationRef, children: [
2383
+ /* @__PURE__ */ jsxs22(
2384
+ "button",
2385
+ {
2386
+ type: "button",
2387
+ className: `graph-toolbar-btn graph-toolbar-validation-btn graph-toolbar-validation-btn--${validationState}`,
2388
+ onClick: () => setValidationOpen(!validationOpen),
2389
+ title: validationLabel(validationState, validationIssues.length),
2390
+ "aria-label": validationLabel(validationState, validationIssues.length),
2391
+ "aria-expanded": validationOpen,
2392
+ "aria-haspopup": "true",
2393
+ "aria-controls": validationPanelId,
2394
+ children: [
2395
+ validationIcon(validationState),
2396
+ validationIssues.length > 0 && /* @__PURE__ */ jsx22("span", { className: "graph-toolbar-validation-badge", children: validationIssues.length > 99 ? "99+" : validationIssues.length })
2397
+ ]
2398
+ }
2399
+ ),
2400
+ validationOpen && /* @__PURE__ */ jsx22(
2401
+ ValidationPanel,
2402
+ {
2403
+ id: validationPanelId,
2404
+ state: validationState,
2405
+ issues: validationIssues,
2406
+ onIssueClick: onValidationIssueClick,
2407
+ placement: validationPanelPlacement(position)
2408
+ }
2409
+ )
2410
+ ] }),
2411
+ /* @__PURE__ */ jsx22("div", { className: "graph-toolbar-separator" })
2412
+ ] }),
2413
+ styleMenuEnabled && /* @__PURE__ */ jsxs22(Fragment13, { children: [
2414
+ /* @__PURE__ */ jsx22(
2415
+ StyleMenu,
2416
+ {
2417
+ value: graphStyle,
2418
+ options: styleMenuOptions,
2419
+ onChange: onGraphStyleChange,
2420
+ placement: validationPanelPlacement(position)
2421
+ }
2422
+ ),
2423
+ /* @__PURE__ */ jsx22("div", { className: "graph-toolbar-separator" })
2424
+ ] }),
2425
+ onFoldAll && /* @__PURE__ */ jsx22(
2420
2426
  "button",
2421
2427
  {
2422
2428
  type: "button",
2423
- className: `graph-toolbar-btn graph-toolbar-validation-btn graph-toolbar-validation-btn--${validationState}`,
2424
- onClick: () => setValidationOpen(!validationOpen),
2425
- title: validationLabel(validationState, validationIssues.length),
2426
- "aria-label": validationLabel(validationState, validationIssues.length),
2427
- "aria-expanded": validationOpen,
2428
- "aria-haspopup": "true",
2429
- "aria-controls": validationPanelId,
2430
- children: [
2431
- validationIcon(validationState),
2432
- validationIssues.length > 0 && /* @__PURE__ */ jsx22("span", { className: "graph-toolbar-validation-badge", children: validationIssues.length > 99 ? "99+" : validationIssues.length })
2433
- ]
2429
+ className: "graph-toolbar-btn",
2430
+ onClick: onFoldAll,
2431
+ disabled: foldAllDisabled,
2432
+ title: foldAllTitle,
2433
+ "aria-label": foldAllTitle,
2434
+ children: FOLD_ALL_ICON
2434
2435
  }
2435
2436
  ),
2436
- validationOpen && /* @__PURE__ */ jsx22(
2437
- ValidationPanel,
2437
+ onExpandAll && /* @__PURE__ */ jsx22(
2438
+ "button",
2438
2439
  {
2439
- id: validationPanelId,
2440
- state: validationState,
2441
- issues: validationIssues,
2442
- onIssueClick: onValidationIssueClick,
2443
- placement: validationPanelPlacement(position)
2440
+ type: "button",
2441
+ className: "graph-toolbar-btn",
2442
+ onClick: onExpandAll,
2443
+ disabled: expandAllDisabled,
2444
+ title: expandAllTitle,
2445
+ "aria-label": expandAllTitle,
2446
+ children: EXPAND_ALL_ICON
2444
2447
  }
2445
- )
2446
- ] }),
2447
- /* @__PURE__ */ jsx22("div", { className: "graph-toolbar-separator" })
2448
- ] }),
2449
- styleMenuEnabled && /* @__PURE__ */ jsxs22(Fragment13, { children: [
2450
- /* @__PURE__ */ jsx22(
2451
- StyleMenu,
2452
- {
2453
- value: graphStyle,
2454
- options: styleMenuOptions,
2455
- onChange: onGraphStyleChange,
2456
- placement: validationPanelPlacement(position)
2457
- }
2458
- ),
2459
- /* @__PURE__ */ jsx22("div", { className: "graph-toolbar-separator" })
2460
- ] }),
2461
- onFoldAll && /* @__PURE__ */ jsx22(
2462
- "button",
2463
- {
2464
- type: "button",
2465
- className: "graph-toolbar-btn",
2466
- onClick: onFoldAll,
2467
- disabled: foldAllDisabled,
2468
- title: foldAllTitle,
2469
- "aria-label": foldAllTitle,
2470
- children: FOLD_ALL_ICON
2471
- }
2472
- ),
2473
- onExpandAll && /* @__PURE__ */ jsx22(
2474
- "button",
2475
- {
2476
- type: "button",
2477
- className: "graph-toolbar-btn",
2478
- onClick: onExpandAll,
2479
- disabled: expandAllDisabled,
2480
- title: expandAllTitle,
2481
- "aria-label": expandAllTitle,
2482
- children: EXPAND_ALL_ICON
2483
- }
2484
- ),
2485
- foldAllSection && /* @__PURE__ */ jsx22("div", { className: "graph-toolbar-separator" }),
2486
- onShowControllersChange && /* @__PURE__ */ jsx22(
2487
- "button",
2488
- {
2489
- type: "button",
2490
- className: `graph-toolbar-btn${showControllers ? " graph-toolbar-btn--active" : ""}`,
2491
- onClick: () => onShowControllersChange(!showControllers),
2492
- title: controllersLabel,
2493
- "aria-label": controllersLabel,
2494
- children: BOXES_ICON
2495
- }
2496
- ),
2497
- /* @__PURE__ */ jsx22(
2498
- "button",
2499
- {
2500
- type: "button",
2501
- className: "graph-toolbar-btn",
2502
- onClick: () => onDirectionChange(isVertical ? GRAPH_DIRECTION.LR : GRAPH_DIRECTION.TB),
2503
- title: directionLabel,
2504
- "aria-label": directionLabel,
2505
- children: isVertical ? ARROW_RIGHT_ICON : ARROW_DOWN_ICON
2506
- }
2507
- ),
2508
- (onZoomOut || onZoomIn || onFitView) && /* @__PURE__ */ jsx22("div", { className: "graph-toolbar-separator" }),
2509
- onZoomOut && /* @__PURE__ */ jsx22(
2510
- "button",
2511
- {
2512
- type: "button",
2513
- className: "graph-toolbar-btn",
2514
- onClick: onZoomOut,
2515
- title: "Zoom out",
2516
- "aria-label": "Zoom out",
2517
- children: MINUS_ICON
2518
- }
2519
- ),
2520
- onZoomIn && /* @__PURE__ */ jsx22(
2521
- "button",
2522
- {
2523
- type: "button",
2524
- className: "graph-toolbar-btn",
2525
- onClick: onZoomIn,
2526
- title: "Zoom in",
2527
- "aria-label": "Zoom in",
2528
- children: PLUS_ICON
2529
- }
2530
- ),
2531
- onFitView && /* @__PURE__ */ jsx22(
2532
- "button",
2533
- {
2534
- type: "button",
2535
- className: "graph-toolbar-btn",
2536
- onClick: onFitView,
2537
- title: "Fit view",
2538
- "aria-label": "Fit view",
2539
- children: FIT_VIEW_ICON
2540
- }
2541
- ),
2542
- themeToggleEnabled && /* @__PURE__ */ jsxs22(Fragment13, { children: [
2543
- /* @__PURE__ */ jsx22("div", { className: "graph-toolbar-separator" }),
2544
- /* @__PURE__ */ jsx22(
2545
- "button",
2546
- {
2547
- type: "button",
2548
- className: "graph-toolbar-btn",
2549
- onClick: () => onThemeModeChange(nextThemeMode(themeMode)),
2550
- title: themeModeLabel(themeMode),
2551
- "aria-label": themeModeLabel(themeMode),
2552
- children: themeModeIcon(themeMode)
2553
- }
2554
- )
2555
- ] })
2556
- ] }) });
2448
+ ),
2449
+ foldAllSection && /* @__PURE__ */ jsx22("div", { className: "graph-toolbar-separator" }),
2450
+ onShowControllersChange && /* @__PURE__ */ jsx22(
2451
+ "button",
2452
+ {
2453
+ type: "button",
2454
+ className: `graph-toolbar-btn${showControllers ? " graph-toolbar-btn--active" : ""}`,
2455
+ onClick: () => onShowControllersChange(!showControllers),
2456
+ title: controllersLabel,
2457
+ "aria-label": controllersLabel,
2458
+ children: BOXES_ICON
2459
+ }
2460
+ ),
2461
+ /* @__PURE__ */ jsx22(
2462
+ "button",
2463
+ {
2464
+ type: "button",
2465
+ className: "graph-toolbar-btn",
2466
+ onClick: () => onDirectionChange(isVertical ? GRAPH_DIRECTION.LR : GRAPH_DIRECTION.TB),
2467
+ title: directionLabel,
2468
+ "aria-label": directionLabel,
2469
+ children: isVertical ? ARROW_RIGHT_ICON : ARROW_DOWN_ICON
2470
+ }
2471
+ ),
2472
+ (onZoomOut || onZoomIn || onFitView) && /* @__PURE__ */ jsx22("div", { className: "graph-toolbar-separator" }),
2473
+ onZoomOut && /* @__PURE__ */ jsx22(
2474
+ "button",
2475
+ {
2476
+ type: "button",
2477
+ className: "graph-toolbar-btn",
2478
+ onClick: onZoomOut,
2479
+ title: "Zoom out",
2480
+ "aria-label": "Zoom out",
2481
+ children: MINUS_ICON
2482
+ }
2483
+ ),
2484
+ onZoomIn && /* @__PURE__ */ jsx22(
2485
+ "button",
2486
+ {
2487
+ type: "button",
2488
+ className: "graph-toolbar-btn",
2489
+ onClick: onZoomIn,
2490
+ title: "Zoom in",
2491
+ "aria-label": "Zoom in",
2492
+ children: PLUS_ICON
2493
+ }
2494
+ ),
2495
+ onFitView && /* @__PURE__ */ jsx22(
2496
+ "button",
2497
+ {
2498
+ type: "button",
2499
+ className: "graph-toolbar-btn",
2500
+ onClick: onFitView,
2501
+ title: "Fit view",
2502
+ "aria-label": "Fit view",
2503
+ children: FIT_VIEW_ICON
2504
+ }
2505
+ ),
2506
+ themeToggleEnabled && /* @__PURE__ */ jsxs22(Fragment13, { children: [
2507
+ /* @__PURE__ */ jsx22("div", { className: "graph-toolbar-separator" }),
2508
+ /* @__PURE__ */ jsx22(
2509
+ "button",
2510
+ {
2511
+ type: "button",
2512
+ className: "graph-toolbar-btn",
2513
+ onClick: () => onThemeModeChange(nextThemeMode(themeMode)),
2514
+ title: themeModeLabel(themeMode),
2515
+ "aria-label": themeModeLabel(themeMode),
2516
+ children: themeModeIcon(themeMode)
2517
+ }
2518
+ )
2519
+ ] })
2520
+ ] })
2521
+ }
2522
+ );
2557
2523
  }
2558
2524
 
2559
2525
  // src/graph/react/viewer/StillFit.tsx
2560
- import React11 from "react";
2526
+ import React10 from "react";
2561
2527
  import { useEdges, useNodes, useNodesInitialized, useReactFlow, useStore } from "@xyflow/react";
2562
2528
 
2563
2529
  // src/graph/react/viewer/stillViewport.ts
@@ -2604,7 +2570,7 @@ function StillFit({ onHeight }) {
2604
2570
  const nodes = useNodes();
2605
2571
  const edges = useEdges();
2606
2572
  const { getNodesBounds, setViewport } = useReactFlow();
2607
- React11.useLayoutEffect(() => {
2573
+ React10.useLayoutEffect(() => {
2608
2574
  if (!nodesInitialized || nodes.length === 0) return;
2609
2575
  const bounds = stillContentBounds(
2610
2576
  getNodesBounds(nodes),
@@ -3419,20 +3385,20 @@ function GraphViewer(props) {
3419
3385
  onValidationIssueClick
3420
3386
  } = props;
3421
3387
  const graphspecProp = (_a = graph == null ? void 0 : graph.graphSpec) != null ? _a : null;
3422
- const graphspec = React13.useMemo(
3388
+ const graphspec = React12.useMemo(
3423
3389
  () => graphspecProp === null ? null : validateGraphSpec(graphspecProp),
3424
3390
  [graphspecProp]
3425
3391
  );
3426
- const [direction, setDirection] = React13.useState(
3392
+ const [direction, setDirection] = React12.useState(
3427
3393
  () => {
3428
3394
  var _a2, _b2;
3429
3395
  return (_b2 = (_a2 = initialDirection != null ? initialDirection : config.direction) != null ? _a2 : DEFAULT_GRAPH_CONFIG.direction) != null ? _b2 : GRAPH_DIRECTION.TB;
3430
3396
  }
3431
3397
  );
3432
3398
  const externalMode = resolveExternalThemeMode(themeProp, config.theme);
3433
- const [mode, setMode] = React13.useState(externalMode);
3434
- const prevExternalModeRef = React13.useRef(externalMode);
3435
- React13.useEffect(() => {
3399
+ const [mode, setMode] = React12.useState(externalMode);
3400
+ const prevExternalModeRef = React12.useRef(externalMode);
3401
+ React12.useEffect(() => {
3436
3402
  if (externalMode !== prevExternalModeRef.current) {
3437
3403
  prevExternalModeRef.current = externalMode;
3438
3404
  setMode(externalMode);
@@ -3440,13 +3406,13 @@ function GraphViewer(props) {
3440
3406
  }, [externalMode]);
3441
3407
  const systemTheme = useSystemTheme(systemThemeProp);
3442
3408
  const resolvedTheme = resolveActiveTheme(mode, systemTheme);
3443
- const onThemeChangeRef = React13.useRef(onThemeChange);
3409
+ const onThemeChangeRef = React12.useRef(onThemeChange);
3444
3410
  onThemeChangeRef.current = onThemeChange;
3445
- const prevReportedRef = React13.useRef({
3411
+ const prevReportedRef = React12.useRef({
3446
3412
  mode,
3447
3413
  resolvedTheme
3448
3414
  });
3449
- React13.useEffect(() => {
3415
+ React12.useEffect(() => {
3450
3416
  var _a2;
3451
3417
  const prev = prevReportedRef.current;
3452
3418
  if (prev.mode !== mode || prev.resolvedTheme !== resolvedTheme) {
@@ -3455,48 +3421,48 @@ function GraphViewer(props) {
3455
3421
  }
3456
3422
  }, [mode, resolvedTheme]);
3457
3423
  const externalStyle = resolveGraphStyle(graphStyleProp, config.graphStyle);
3458
- const [graphStyle, setGraphStyle] = React13.useState(externalStyle);
3459
- const prevExternalStyleRef = React13.useRef(externalStyle);
3460
- React13.useEffect(() => {
3424
+ const [graphStyle, setGraphStyle] = React12.useState(externalStyle);
3425
+ const prevExternalStyleRef = React12.useRef(externalStyle);
3426
+ React12.useEffect(() => {
3461
3427
  if (externalStyle !== prevExternalStyleRef.current) {
3462
3428
  prevExternalStyleRef.current = externalStyle;
3463
3429
  setGraphStyle(externalStyle);
3464
3430
  }
3465
3431
  }, [externalStyle]);
3466
- const onGraphStyleChangeRef = React13.useRef(onGraphStyleChange);
3432
+ const onGraphStyleChangeRef = React12.useRef(onGraphStyleChange);
3467
3433
  onGraphStyleChangeRef.current = onGraphStyleChange;
3468
- const prevReportedStyleRef = React13.useRef(graphStyle);
3469
- React13.useEffect(() => {
3434
+ const prevReportedStyleRef = React12.useRef(graphStyle);
3435
+ React12.useEffect(() => {
3470
3436
  var _a2;
3471
3437
  if (prevReportedStyleRef.current !== graphStyle) {
3472
3438
  prevReportedStyleRef.current = graphStyle;
3473
3439
  (_a2 = onGraphStyleChangeRef.current) == null ? void 0 : _a2.call(onGraphStyleChangeRef, graphStyle);
3474
3440
  }
3475
3441
  }, [graphStyle]);
3476
- const graphStyleRef = React13.useRef(graphStyle);
3442
+ const graphStyleRef = React12.useRef(graphStyle);
3477
3443
  graphStyleRef.current = graphStyle;
3478
3444
  const styleCapabilities = GRAPH_STYLES[graphStyle].capabilities;
3479
3445
  const effectiveFoldMode = (_c = (_b = initialFoldMode != null ? initialFoldMode : config.foldMode) != null ? _b : DEFAULT_GRAPH_CONFIG.foldMode) != null ? _c : FOLD_MODE.EXPANDED;
3480
- const [showControllers, setShowControllers] = React13.useState(() => {
3446
+ const [showControllers, setShowControllers] = React12.useState(() => {
3481
3447
  var _a2, _b2;
3482
3448
  if (effectiveFoldMode === FOLD_MODE.FOLDED) return true;
3483
3449
  return (_b2 = (_a2 = initialShowControllers != null ? initialShowControllers : config.showControllers) != null ? _a2 : DEFAULT_GRAPH_CONFIG.showControllers) != null ? _b2 : false;
3484
3450
  });
3485
- const foldModeRef = React13.useRef(effectiveFoldMode);
3451
+ const foldModeRef = React12.useRef(effectiveFoldMode);
3486
3452
  foldModeRef.current = effectiveFoldMode;
3487
- const containerRef = React13.useRef(null);
3488
- const [detailSelection, setDetailSelection] = React13.useState(null);
3489
- const [conceptOverride, setConceptOverride] = React13.useState(null);
3453
+ const containerRef = React12.useRef(null);
3454
+ const [detailSelection, setDetailSelection] = React12.useState(null);
3455
+ const [conceptOverride, setConceptOverride] = React12.useState(null);
3490
3456
  const {
3491
3457
  width: panelWidth,
3492
3458
  isDragging: isPanelDragging,
3493
3459
  handleMouseDown: onResizeMouseDown
3494
3460
  } = useResizable({ defaultWidth: 380, minWidth: 280, maxWidth: 800, containerRef });
3495
- React13.useEffect(() => {
3461
+ React12.useEffect(() => {
3496
3462
  setDetailSelection(null);
3497
3463
  setConceptOverride(null);
3498
3464
  }, [graphspec]);
3499
- React13.useEffect(() => {
3465
+ React12.useEffect(() => {
3500
3466
  const el = containerRef.current;
3501
3467
  if (!el) return;
3502
3468
  const themePalette = getPaletteForTheme(resolvedTheme);
@@ -3511,15 +3477,15 @@ function GraphViewer(props) {
3511
3477
  }
3512
3478
  };
3513
3479
  }, [config.paletteColors, resolvedTheme]);
3514
- const [stillHeight, setStillHeight] = React13.useState(STILL_PLACEHOLDER_HEIGHT_PX);
3480
+ const [stillHeight, setStillHeight] = React12.useState(STILL_PLACEHOLDER_HEIGHT_PX);
3515
3481
  const [nodes, setNodes, onNodesChange] = useNodesState([]);
3516
3482
  const [edges, setEdges, onEdgesChange] = useEdgesState([]);
3517
- const reactFlowRef = React13.useRef(null);
3518
- const initialDataRef = React13.useRef(null);
3519
- const rawGraphDataRef = React13.useRef(null);
3520
- const layoutCacheRef = React13.useRef(null);
3521
- const [expandedControllers, setExpandedControllers] = React13.useState(/* @__PURE__ */ new Set());
3522
- const toggleCollapse = React13.useCallback((controllerId) => {
3483
+ const reactFlowRef = React12.useRef(null);
3484
+ const initialDataRef = React12.useRef(null);
3485
+ const rawGraphDataRef = React12.useRef(null);
3486
+ const layoutCacheRef = React12.useRef(null);
3487
+ const [expandedControllers, setExpandedControllers] = React12.useState(/* @__PURE__ */ new Set());
3488
+ const toggleCollapse = React12.useCallback((controllerId) => {
3523
3489
  setExpandedControllers((prev) => {
3524
3490
  const next = new Set(prev);
3525
3491
  if (next.has(controllerId)) next.delete(controllerId);
@@ -3527,17 +3493,17 @@ function GraphViewer(props) {
3527
3493
  return next;
3528
3494
  });
3529
3495
  }, []);
3530
- const [foldedControllers, setFoldedControllers] = React13.useState(/* @__PURE__ */ new Set());
3531
- const styleDefaultFoldsRef = React13.useRef(/* @__PURE__ */ new Set());
3532
- const readerOpenedRef = React13.useRef(/* @__PURE__ */ new Set());
3533
- const markReaderFolds = React13.useCallback((ids, folded) => {
3496
+ const [foldedControllers, setFoldedControllers] = React12.useState(/* @__PURE__ */ new Set());
3497
+ const styleDefaultFoldsRef = React12.useRef(/* @__PURE__ */ new Set());
3498
+ const readerOpenedRef = React12.useRef(/* @__PURE__ */ new Set());
3499
+ const markReaderFolds = React12.useCallback((ids, folded) => {
3534
3500
  for (const id of ids) {
3535
3501
  styleDefaultFoldsRef.current.delete(id);
3536
3502
  if (folded) readerOpenedRef.current.delete(id);
3537
3503
  else readerOpenedRef.current.add(id);
3538
3504
  }
3539
3505
  }, []);
3540
- const toggleFold = React13.useCallback(
3506
+ const toggleFold = React12.useCallback(
3541
3507
  (controllerId, options) => {
3542
3508
  setFoldedControllers((prev) => {
3543
3509
  const next = new Set(prev);
@@ -3555,45 +3521,45 @@ function GraphViewer(props) {
3555
3521
  [markReaderFolds]
3556
3522
  );
3557
3523
  const edgeType = config.edgeType || EDGE_TYPE.DEFAULT;
3558
- const layoutConfig = React13.useMemo(
3524
+ const layoutConfig = React12.useMemo(
3559
3525
  () => ({ nodesep: config.nodesep, ranksep: config.ranksep }),
3560
3526
  [config.nodesep, config.ranksep]
3561
3527
  );
3562
- const showControllersRef = React13.useRef(showControllers);
3528
+ const showControllersRef = React12.useRef(showControllers);
3563
3529
  showControllersRef.current = showControllers;
3564
- const directionRef = React13.useRef(direction);
3530
+ const directionRef = React12.useRef(direction);
3565
3531
  directionRef.current = direction;
3566
- const layoutConfigRef = React13.useRef(layoutConfig);
3532
+ const layoutConfigRef = React12.useRef(layoutConfig);
3567
3533
  layoutConfigRef.current = layoutConfig;
3568
- const initialZoomRef = React13.useRef(config.initialZoom);
3534
+ const initialZoomRef = React12.useRef(config.initialZoom);
3569
3535
  initialZoomRef.current = config.initialZoom;
3570
- const panToTopRef = React13.useRef(config.panToTop);
3536
+ const panToTopRef = React12.useRef(config.panToTop);
3571
3537
  panToTopRef.current = config.panToTop;
3572
- const interactiveRef = React13.useRef(interactive);
3538
+ const interactiveRef = React12.useRef(interactive);
3573
3539
  interactiveRef.current = interactive;
3574
- const expandedRef = React13.useRef(expandedControllers);
3540
+ const expandedRef = React12.useRef(expandedControllers);
3575
3541
  expandedRef.current = expandedControllers;
3576
- const toggleCollapseRef = React13.useRef(toggleCollapse);
3542
+ const toggleCollapseRef = React12.useRef(toggleCollapse);
3577
3543
  toggleCollapseRef.current = toggleCollapse;
3578
- const foldedRef = React13.useRef(foldedControllers);
3544
+ const foldedRef = React12.useRef(foldedControllers);
3579
3545
  foldedRef.current = foldedControllers;
3580
- const toggleFoldRef = React13.useRef(toggleFold);
3546
+ const toggleFoldRef = React12.useRef(toggleFold);
3581
3547
  toggleFoldRef.current = toggleFold;
3582
- const isFirstFoldEffect = React13.useRef(true);
3583
- const prevFoldSizeRef = React13.useRef(0);
3584
- const skipNextFoldEffectRef = React13.useRef(false);
3585
- const statusMapRef = React13.useRef(statusMap);
3548
+ const isFirstFoldEffect = React12.useRef(true);
3549
+ const prevFoldSizeRef = React12.useRef(0);
3550
+ const skipNextFoldEffectRef = React12.useRef(false);
3551
+ const statusMapRef = React12.useRef(statusMap);
3586
3552
  statusMapRef.current = statusMap;
3587
- const validationIssuesRef = React13.useRef(validationIssues);
3553
+ const validationIssuesRef = React12.useRef(validationIssues);
3588
3554
  validationIssuesRef.current = validationIssues;
3589
- const selectedNodeIdRef = React13.useRef(null);
3555
+ const selectedNodeIdRef = React12.useRef(null);
3590
3556
  selectedNodeIdRef.current = (_d = detailSelection == null ? void 0 : detailSelection.nodeId) != null ? _d : null;
3591
- const [validationOpen, setValidationOpen] = React13.useState(false);
3592
- const openValidationPanel = React13.useCallback(() => setValidationOpen(true), []);
3557
+ const [validationOpen, setValidationOpen] = React12.useState(false);
3558
+ const openValidationPanel = React12.useCallback(() => setValidationOpen(true), []);
3593
3559
  const validationWidgetAvailable = validationState !== void 0 && !hideToolbar && interactive;
3594
- const validationWidgetAvailableRef = React13.useRef(validationWidgetAvailable);
3560
+ const validationWidgetAvailableRef = React12.useRef(validationWidgetAvailable);
3595
3561
  validationWidgetAvailableRef.current = validationWidgetAvailable;
3596
- const decorateNodes = React13.useCallback(
3562
+ const decorateNodes = React12.useCallback(
3597
3563
  (nodes2) => {
3598
3564
  var _a2, _b2, _c2;
3599
3565
  const raw = rawGraphDataRef.current;
@@ -3614,7 +3580,7 @@ function GraphViewer(props) {
3614
3580
  },
3615
3581
  [openValidationPanel]
3616
3582
  );
3617
- const frameLayout = React13.useCallback(
3583
+ const frameLayout = React12.useCallback(
3618
3584
  (style, layout, graphspec2, analysis) => GRAPH_STYLE_PIPELINES[style].frame({
3619
3585
  nodes: cloneCachedNodes(layout.nodes),
3620
3586
  edges: layout.edges,
@@ -3633,18 +3599,18 @@ function GraphViewer(props) {
3633
3599
  const data = initialDataRef.current;
3634
3600
  return cache !== null && data !== null && cache.graphspec === data._graphspec && cache.graphStyle === data._graphStyle;
3635
3601
  };
3636
- const nodesRef = React13.useRef([]);
3602
+ const nodesRef = React12.useRef([]);
3637
3603
  nodesRef.current = nodes;
3638
- const onValidationIssueClickRef = React13.useRef(onValidationIssueClick);
3604
+ const onValidationIssueClickRef = React12.useRef(onValidationIssueClick);
3639
3605
  onValidationIssueClickRef.current = onValidationIssueClick;
3640
- const flashTimeoutRef = React13.useRef(null);
3641
- React13.useEffect(
3606
+ const flashTimeoutRef = React12.useRef(null);
3607
+ React12.useEffect(
3642
3608
  () => () => {
3643
3609
  if (flashTimeoutRef.current) clearTimeout(flashTimeoutRef.current);
3644
3610
  },
3645
3611
  []
3646
3612
  );
3647
- const handleValidationIssueClick = React13.useCallback(
3613
+ const handleValidationIssueClick = React12.useCallback(
3648
3614
  (index, issue) => {
3649
3615
  var _a2, _b2, _c2;
3650
3616
  (_a2 = onValidationIssueClickRef.current) == null ? void 0 : _a2.call(onValidationIssueClickRef, index, issue);
@@ -3687,7 +3653,7 @@ function GraphViewer(props) {
3687
3653
  },
3688
3654
  [setNodes]
3689
3655
  );
3690
- React13.useEffect(() => {
3656
+ React12.useEffect(() => {
3691
3657
  if (!initialDataRef.current) return;
3692
3658
  let cancelled = false;
3693
3659
  void (async () => {
@@ -3732,7 +3698,7 @@ function GraphViewer(props) {
3732
3698
  cancelled = true;
3733
3699
  };
3734
3700
  }, [direction, layoutConfig]);
3735
- React13.useEffect(() => {
3701
+ React12.useEffect(() => {
3736
3702
  const cache = layoutCacheRef.current;
3737
3703
  const data = initialDataRef.current;
3738
3704
  if (!cache || !data || !cacheMatchesData()) return;
@@ -3740,7 +3706,7 @@ function GraphViewer(props) {
3740
3706
  setNodes(decorateNodes(withControllers.nodes));
3741
3707
  setEdges(toAppEdges(withControllers.edges));
3742
3708
  }, [showControllers, expandedControllers, toggleCollapse, toggleFold, decorateNodes]);
3743
- React13.useEffect(() => {
3709
+ React12.useEffect(() => {
3744
3710
  var _a2;
3745
3711
  if (!graphspec) {
3746
3712
  initialDataRef.current = null;
@@ -3859,7 +3825,7 @@ function GraphViewer(props) {
3859
3825
  cancelled = true;
3860
3826
  };
3861
3827
  }, [graphspec, edgeType, graphStyle]);
3862
- React13.useEffect(() => {
3828
+ React12.useEffect(() => {
3863
3829
  if (isFirstFoldEffect.current) {
3864
3830
  isFirstFoldEffect.current = false;
3865
3831
  prevFoldSizeRef.current = foldedControllers.size;
@@ -3936,7 +3902,7 @@ function GraphViewer(props) {
3936
3902
  cancelled = true;
3937
3903
  };
3938
3904
  }, [foldedControllers, toggleFold]);
3939
- React13.useEffect(() => {
3905
+ React12.useEffect(() => {
3940
3906
  const cache = layoutCacheRef.current;
3941
3907
  const data = initialDataRef.current;
3942
3908
  if (!cache || !data || !cacheMatchesData()) return;
@@ -3944,14 +3910,14 @@ function GraphViewer(props) {
3944
3910
  setNodes(decorateNodes(withControllers.nodes));
3945
3911
  setEdges(toAppEdges(withControllers.edges));
3946
3912
  }, [statusMap, decorateNodes]);
3947
- React13.useEffect(() => {
3913
+ React12.useEffect(() => {
3948
3914
  const cache = layoutCacheRef.current;
3949
3915
  const data = initialDataRef.current;
3950
3916
  if (!cache || !data || !cacheMatchesData()) return;
3951
3917
  const withControllers = frameLayout(cache.graphStyle, cache, data._graphspec, data._analysis);
3952
3918
  setNodes(decorateNodes(withControllers.nodes));
3953
3919
  }, [validationIssues, validationWidgetAvailable, decorateNodes]);
3954
- const onNodeClick = React13.useCallback(
3920
+ const onNodeClick = React12.useCallback(
3955
3921
  (event, node) => {
3956
3922
  const nodeData = node.data;
3957
3923
  onNodeSelect == null ? void 0 : onNodeSelect(node.id, nodeData, event);
@@ -3992,7 +3958,7 @@ function GraphViewer(props) {
3992
3958
  conceptOverride
3993
3959
  ]
3994
3960
  );
3995
- const onInit = React13.useCallback(
3961
+ const onInit = React12.useCallback(
3996
3962
  (reactFlowInstance) => {
3997
3963
  reactFlowRef.current = reactFlowInstance;
3998
3964
  if (onReactFlowInit) {
@@ -4001,8 +3967,8 @@ function GraphViewer(props) {
4001
3967
  },
4002
3968
  [onReactFlowInit]
4003
3969
  );
4004
- const prevInteractiveRef = React13.useRef(interactive);
4005
- React13.useEffect(() => {
3970
+ const prevInteractiveRef = React12.useRef(interactive);
3971
+ React12.useEffect(() => {
4006
3972
  if (prevInteractiveRef.current === interactive) return;
4007
3973
  prevInteractiveRef.current = interactive;
4008
3974
  if (!interactive) {
@@ -4017,12 +3983,12 @@ function GraphViewer(props) {
4017
3983
  }, 50);
4018
3984
  return () => clearTimeout(timer);
4019
3985
  }, [interactive]);
4020
- const handlePaneClick = React13.useCallback(() => {
3986
+ const handlePaneClick = React12.useCallback(() => {
4021
3987
  setDetailSelection(null);
4022
3988
  setConceptOverride(null);
4023
3989
  onPaneClick == null ? void 0 : onPaneClick();
4024
3990
  }, [onPaneClick]);
4025
- const handleConceptClick = React13.useCallback(
3991
+ const handleConceptClick = React12.useCallback(
4026
3992
  (conceptCode) => {
4027
3993
  if (!graphspec) return;
4028
3994
  const info = resolveConceptRef(graphspec, conceptCode);
@@ -4039,7 +4005,7 @@ function GraphViewer(props) {
4039
4005
  const rawAnalysis = (_e = rawGraphDataRef.current) == null ? void 0 : _e.analysis;
4040
4006
  const allControllerIds = rawAnalysis == null ? void 0 : rawAnalysis.controllerNodeIds;
4041
4007
  const foldControlsAvailable = styleCapabilities.foldAll && (!styleCapabilities.controllerFrameToggle || showControllers);
4042
- const foldAllProps = React13.useMemo(() => {
4008
+ const foldAllProps = React12.useMemo(() => {
4043
4009
  if (!foldControlsAvailable || !allControllerIds || allControllerIds.size === 0) {
4044
4010
  return {
4045
4011
  onFoldAll: void 0,
@@ -4061,7 +4027,7 @@ function GraphViewer(props) {
4061
4027
  expandAllDisabled: foldedControllers.size === 0
4062
4028
  };
4063
4029
  }, [foldControlsAvailable, allControllerIds, foldedControllers, markReaderFolds]);
4064
- const styleMenuOptions = React13.useMemo(() => resolveStyleMenu(styleMenu), [styleMenu]);
4030
+ const styleMenuOptions = React12.useMemo(() => resolveStyleMenu(styleMenu), [styleMenu]);
4065
4031
  return /* @__PURE__ */ jsxs27(
4066
4032
  "div",
4067
4033
  {