@dudousxd/nestjs-catalog-react 0.17.0 → 0.19.0-preview.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.
Files changed (54) hide show
  1. package/README.md +39 -13
  2. package/dist/CatalogManager.d.ts +23 -1
  3. package/dist/CatalogManager.js +76 -13
  4. package/dist/ConnectionPanel.d.ts +11 -7
  5. package/dist/ConnectionPanel.js +78 -149
  6. package/dist/LoadedBySection.d.ts +39 -0
  7. package/dist/LoadedBySection.js +143 -0
  8. package/dist/PipelineConsole.d.ts +23 -126
  9. package/dist/PipelineConsole.js +39 -551
  10. package/dist/WorkflowCanvas.d.ts +16 -0
  11. package/dist/WorkflowCanvas.js +1064 -64
  12. package/dist/connection-form.d.ts +241 -0
  13. package/dist/connection-form.js +235 -0
  14. package/dist/context.d.ts +236 -38
  15. package/dist/context.js +46 -11
  16. package/dist/index.d.ts +10 -3
  17. package/dist/index.js +63 -14
  18. package/dist/routes.d.ts +84 -13
  19. package/dist/routes.js +7 -4
  20. package/dist/schema-discovery.d.ts +232 -0
  21. package/dist/schema-discovery.js +225 -0
  22. package/dist/source-connection.d.ts +82 -0
  23. package/dist/source-connection.js +176 -0
  24. package/dist/source-fields.d.ts +16 -14
  25. package/dist/source-fields.js +28 -18
  26. package/dist/ui/code-editor.d.ts +44 -2
  27. package/dist/ui/code-editor.js +10 -2
  28. package/dist/ui/combobox.d.ts +97 -0
  29. package/dist/ui/combobox.js +80 -0
  30. package/dist/ui/dialog.d.ts +13 -1
  31. package/dist/ui/dialog.js +13 -2
  32. package/dist/workflow/edges.d.ts +110 -0
  33. package/dist/workflow/edges.js +112 -0
  34. package/dist/workflow/graph.d.ts +39 -1
  35. package/dist/workflow/graph.js +212 -52
  36. package/dist/workflow/index.d.ts +8 -0
  37. package/dist/workflow/index.js +12 -0
  38. package/dist/workflow/lifecycle.d.ts +135 -0
  39. package/dist/workflow/lifecycle.js +216 -0
  40. package/dist/workflow/model.d.ts +17 -3
  41. package/dist/workflow/model.js +7 -2
  42. package/dist/workflow/nodes.d.ts +4 -1
  43. package/dist/workflow/nodes.js +198 -10
  44. package/dist/workflow/runs.d.ts +38 -0
  45. package/dist/workflow/runs.js +101 -0
  46. package/dist/workflow/shape.d.ts +169 -0
  47. package/dist/workflow/shape.js +249 -0
  48. package/dist/workflow/templates.d.ts +623 -0
  49. package/dist/workflow/templates.js +1102 -0
  50. package/dist/workflow/validate.d.ts +20 -1
  51. package/dist/workflow/validate.js +52 -3
  52. package/dist/workflow/wiring.d.ts +84 -0
  53. package/dist/workflow/wiring.js +254 -0
  54. package/package.json +9 -9
@@ -0,0 +1,80 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Autocomplete } from '@base-ui/react/autocomplete';
3
+ import { Check, ChevronsUpDown } from 'lucide-react';
4
+ import { useState } from 'react';
5
+ import { cn } from '../cn';
6
+ const CONTROL = cn('w-full rounded-md border py-1.5 pl-2 pr-7 text-xs outline-none', 'border-zinc-200 bg-white text-zinc-900 placeholder:text-zinc-400', 'dark:border-zinc-800 dark:bg-zinc-900 dark:text-zinc-100 dark:placeholder:text-zinc-600', 'focus-visible:border-sky-500 focus-visible:ring-2 focus-visible:ring-sky-500/15', 'disabled:opacity-40');
7
+ export function Combobox({ value, onValueChange, onSelect, options, emptyMessage = 'Nothing here matches that.', placeholder, disabled, ariaLabel, className, }) {
8
+ /**
9
+ * The query, which is NOT the value.
10
+ *
11
+ * `undefined` means "nothing has been typed since this opened", and the whole
12
+ * list shows. That distinction is the difference between a usable field and
13
+ * an infuriating one: the box holds a committed value, so filtering by it
14
+ * would open the popup onto the single row somebody already chose, and the
15
+ * only way to see the other versions would be to delete what is there.
16
+ */
17
+ const [query, setQuery] = useState(undefined);
18
+ const filtered = query === undefined ? options : options.filter((o) => matches(o, query));
19
+ return (_jsxs(Autocomplete.Root
20
+ // `items` is what `Autocomplete.Empty` counts, and `filteredItems` is
21
+ // what the list navigates. Both are given the SAME array, because the
22
+ // filtering above is ours: Base UI's own is a collator over the label,
23
+ // and it cannot see `keywords`.
24
+ , {
25
+ // `items` is what `Autocomplete.Empty` counts, and `filteredItems` is
26
+ // what the list navigates. Both are given the SAME array, because the
27
+ // filtering above is ours: Base UI's own is a collator over the label,
28
+ // and it cannot see `keywords`.
29
+ items: filtered, filteredItems: filtered, value: value, onValueChange: (next, details) => {
30
+ // See the docblock: Base UI fills the input on an item press, and that
31
+ // arrives here as though somebody had typed it. `onSelect` has already
32
+ // told the caller, in full, what the row meant.
33
+ if (details.reason === 'item-press')
34
+ return;
35
+ setQuery(next);
36
+ onValueChange(next);
37
+ },
38
+ // Re-arm the "show everything" state on open AND on close, so the next
39
+ // opening is not still filtered by the last thing typed into it.
40
+ onOpenChange: () => setQuery(undefined), openOnInputClick: true, disabled: disabled, children: [_jsxs("div", { className: cn('relative', className), children: [_jsx(Autocomplete.Input, { "aria-label": ariaLabel, placeholder: placeholder, spellCheck: false, className: CONTROL }), _jsx(Autocomplete.Icon, { className: "pointer-events-none absolute inset-y-0 right-2 flex items-center", children: _jsx(ChevronsUpDown, { size: 12, className: "shrink-0 text-zinc-400" }) })] }), _jsx(Autocomplete.Portal, { children: _jsx(Autocomplete.Positioner, { sideOffset: 4, className: "z-50", children: _jsxs(Autocomplete.Popup, { className: cn('max-h-72 w-[var(--anchor-width)] overflow-y-auto rounded-md border p-1 shadow-md', 'border-zinc-200 bg-white dark:border-zinc-800 dark:bg-zinc-900',
41
+ // The house animation, and then the fallback. `motion-reduce` is
42
+ // the ceiling for people who asked for less, not for everyone.
43
+ 'origin-[var(--transform-origin)] transition-[opacity,transform] duration-100 ease-out', 'data-[starting-style]:scale-95 data-[starting-style]:opacity-0', 'data-[ending-style]:scale-95 data-[ending-style]:opacity-0', 'motion-reduce:transition-none motion-reduce:data-[starting-style]:scale-100 motion-reduce:data-[ending-style]:scale-100'), children: [_jsx(Autocomplete.Empty, { className: "px-2 py-1.5 text-[11px] leading-relaxed text-zinc-400 dark:text-zinc-500", children: filtered.length === 0 ? emptyMessage : null }), _jsx(Autocomplete.List, { children: filtered.map((option) => (_jsxs(Autocomplete.Item, { value: option, disabled: option.disabled, onClick: () => {
44
+ // The rendering says a row is disabled; this says it again
45
+ // at the moment of commit. A `disabled` attribute is a
46
+ // rendering decision and the rule about what may be
47
+ // committed is not one.
48
+ if (option.disabled)
49
+ return;
50
+ onSelect?.(option);
51
+ }, className: cn('flex cursor-default items-start gap-2 rounded-sm px-2 py-1.5 text-xs outline-none', 'data-[highlighted]:bg-zinc-100 dark:data-[highlighted]:bg-zinc-800', 'data-[disabled]:opacity-40'), children: [_jsx("span", { className: "mt-0.5 w-3 shrink-0", children: option.value === value && !option.disabled && (_jsx(Check, { size: 11, className: "text-sky-600" })) }), _jsxs("span", { className: "min-w-0 flex-1", children: [_jsx("span", { className: "block truncate", title: option.label, children: option.label }), option.hint && (_jsx("span", { className: "mt-0.5 block truncate font-mono text-[10px] text-zinc-400 dark:text-zinc-500", children: option.hint }))] })] }, option.value))) })] }) }) })] }));
52
+ }
53
+ /**
54
+ * Case-insensitive substring, over the label and whatever else the row said to
55
+ * search.
56
+ *
57
+ * Substring rather than prefix on purpose: workflow names are dotted and
58
+ * namespaced, and somebody looking for `billing.reconcile` types `reconcile`
59
+ * about as often as they type `billing`.
60
+ */
61
+ function matches(option, query) {
62
+ const needle = query.trim().toLowerCase();
63
+ if (needle.length === 0)
64
+ return true;
65
+ const haystack = `${option.label} ${option.keywords ?? ''}`.toLowerCase();
66
+ return haystack.includes(needle);
67
+ }
68
+ /**
69
+ * A {@link Combobox} with a label above it, matching `TextField` — and a real
70
+ * `<label>`, because unlike `Select` this renders an `<input>` and a label
71
+ * therefore names it natively.
72
+ */
73
+ export function ComboboxField({ label, hint, ...props }) {
74
+ return (
75
+ // `Combobox` renders a real `<input>`, so wrapping it names it natively and
76
+ // no `aria-label` is needed — unlike `SelectField`, whose control is a
77
+ // button. Biome cannot see the input through the component boundary.
78
+ // biome-ignore lint/a11y/noLabelWithoutControl: see above
79
+ _jsxs("label", { className: "block", children: [_jsx("span", { className: "mb-1 block font-mono text-[10px] uppercase tracking-[0.14em] text-zinc-400 dark:text-zinc-500", children: label }), _jsx(Combobox, { ...props }), hint && (_jsx("span", { className: "mt-1 block text-[11px] leading-relaxed text-zinc-400 dark:text-zinc-500", children: hint }))] }));
80
+ }
@@ -12,7 +12,18 @@ import type { ReactNode } from 'react';
12
12
  * these screens need is "are you sure, and here is what you would break", and a
13
13
  * generic Dialog would have every call site rebuild that.
14
14
  */
15
- export declare function ConfirmDialog({ open, onOpenChange, title, description, confirmLabel, onConfirm, pending, error,
15
+ export declare function ConfirmDialog({ open, onOpenChange, title, description, confirmLabel, onConfirm, pending,
16
+ /**
17
+ * Held back for a reason that is not "a request is in flight".
18
+ *
19
+ * Separate from `pending` because the two look different and mean different
20
+ * things: `pending` spins, and this simply does not act. A dialog whose
21
+ * description contains a field the action needs — the acknowledgement a
22
+ * shrinking load has to carry a reason for — would otherwise have to fake it
23
+ * by passing `pending`, which puts a spinner beside an empty box and implies
24
+ * something is happening.
25
+ */
26
+ confirmDisabled, error,
16
27
  /** Set for anything unrecoverable. Colours the action, and nothing else. */
17
28
  destructive, }: {
18
29
  open: boolean;
@@ -22,6 +33,7 @@ destructive, }: {
22
33
  confirmLabel: string;
23
34
  onConfirm: () => void;
24
35
  pending?: boolean;
36
+ confirmDisabled?: boolean;
25
37
  error?: ReactNode;
26
38
  destructive?: boolean;
27
39
  }): import("react/jsx-runtime").JSX.Element;
package/dist/ui/dialog.js CHANGED
@@ -15,10 +15,21 @@ import { cn } from '../cn';
15
15
  * these screens need is "are you sure, and here is what you would break", and a
16
16
  * generic Dialog would have every call site rebuild that.
17
17
  */
18
- export function ConfirmDialog({ open, onOpenChange, title, description, confirmLabel, onConfirm, pending, error,
18
+ export function ConfirmDialog({ open, onOpenChange, title, description, confirmLabel, onConfirm, pending,
19
+ /**
20
+ * Held back for a reason that is not "a request is in flight".
21
+ *
22
+ * Separate from `pending` because the two look different and mean different
23
+ * things: `pending` spins, and this simply does not act. A dialog whose
24
+ * description contains a field the action needs — the acknowledgement a
25
+ * shrinking load has to carry a reason for — would otherwise have to fake it
26
+ * by passing `pending`, which puts a spinner beside an empty box and implies
27
+ * something is happening.
28
+ */
29
+ confirmDisabled, error,
19
30
  /** Set for anything unrecoverable. Colours the action, and nothing else. */
20
31
  destructive = true, }) {
21
- return (_jsx(BaseDialog.Root, { open: open, onOpenChange: onOpenChange, children: _jsxs(BaseDialog.Portal, { children: [_jsx(BaseDialog.Backdrop, { className: cn('fixed inset-0 z-50 bg-zinc-950/30 backdrop-blur-[1px] dark:bg-zinc-950/60', 'transition-opacity duration-150', 'data-[starting-style]:opacity-0 data-[ending-style]:opacity-0') }), _jsxs(BaseDialog.Popup, { className: cn('fixed left-1/2 top-1/2 z-50 w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2', 'rounded-lg border p-5 shadow-lg outline-none', 'border-zinc-200 bg-white dark:border-zinc-800 dark:bg-zinc-900', 'transition-[opacity,transform] duration-150 ease-out', 'data-[starting-style]:scale-95 data-[starting-style]:opacity-0', 'data-[ending-style]:scale-95 data-[ending-style]:opacity-0'), children: [_jsx(BaseDialog.Title, { className: "text-sm font-semibold tracking-tight", children: title }), _jsx(BaseDialog.Description, { className: "mt-1.5 text-xs leading-relaxed text-zinc-500 dark:text-zinc-400", children: description }), error && (_jsx("p", { className: "mt-3 rounded-md border border-red-200 bg-red-50 px-2.5 py-1.5 text-[11px] text-red-700 dark:border-red-900 dark:bg-red-950/40 dark:text-red-300", children: error })), _jsxs("div", { className: "mt-5 flex justify-end gap-2", children: [_jsx(BaseDialog.Close, { className: cn('rounded-md border px-3 py-1.5 text-xs', 'border-zinc-200 hover:bg-zinc-50', 'dark:border-zinc-800 dark:hover:bg-zinc-800'), children: "Cancel" }), _jsxs("button", { type: "button", onClick: onConfirm, disabled: pending, className: cn('flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs text-white disabled:opacity-40', destructive
32
+ return (_jsx(BaseDialog.Root, { open: open, onOpenChange: onOpenChange, children: _jsxs(BaseDialog.Portal, { children: [_jsx(BaseDialog.Backdrop, { className: cn('fixed inset-0 z-50 bg-zinc-950/30 backdrop-blur-[1px] dark:bg-zinc-950/60', 'transition-opacity duration-150', 'data-[starting-style]:opacity-0 data-[ending-style]:opacity-0') }), _jsxs(BaseDialog.Popup, { className: cn('fixed left-1/2 top-1/2 z-50 w-[min(28rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2', 'rounded-lg border p-5 shadow-lg outline-none', 'border-zinc-200 bg-white dark:border-zinc-800 dark:bg-zinc-900', 'transition-[opacity,transform] duration-150 ease-out', 'data-[starting-style]:scale-95 data-[starting-style]:opacity-0', 'data-[ending-style]:scale-95 data-[ending-style]:opacity-0'), children: [_jsx(BaseDialog.Title, { className: "text-sm font-semibold tracking-tight", children: title }), _jsx(BaseDialog.Description, { className: "mt-1.5 text-xs leading-relaxed text-zinc-500 dark:text-zinc-400", children: description }), error && (_jsx("p", { className: "mt-3 rounded-md border border-red-200 bg-red-50 px-2.5 py-1.5 text-[11px] text-red-700 dark:border-red-900 dark:bg-red-950/40 dark:text-red-300", children: error })), _jsxs("div", { className: "mt-5 flex justify-end gap-2", children: [_jsx(BaseDialog.Close, { className: cn('rounded-md border px-3 py-1.5 text-xs', 'border-zinc-200 hover:bg-zinc-50', 'dark:border-zinc-800 dark:hover:bg-zinc-800'), children: "Cancel" }), _jsxs("button", { type: "button", onClick: onConfirm, disabled: pending || confirmDisabled, className: cn('flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs text-white disabled:opacity-40', destructive
22
33
  ? 'bg-red-600 hover:bg-red-700'
23
34
  : 'bg-zinc-950 hover:bg-zinc-800 dark:bg-zinc-100 dark:text-zinc-950'), children: [pending && _jsx(Loader2, { size: 12, className: "animate-spin" }), confirmLabel] })] })] })] }) }));
24
35
  }
@@ -0,0 +1,110 @@
1
+ import { type EdgeProps } from '@xyflow/react';
2
+ import { type ReactNode } from 'react';
3
+ import type { WorkflowEdge } from './model';
4
+ /**
5
+ * The edge, and the one gesture it was missing.
6
+ *
7
+ * ## Why this file exists
8
+ *
9
+ * Removing a connection was already wired — `onDisconnect(edge)` has been on the
10
+ * canvas since the wiring menu was added — but every way of *reaching* it went
11
+ * through something else: a menu hanging off a node, a row in the wiring rail,
12
+ * or selecting the line and knowing that Delete is a key. The thing somebody
13
+ * reaches for first is the connection itself, and clicking it did nothing
14
+ * visible. So this is not a new capability; it is the missing gesture on one
15
+ * that already existed.
16
+ *
17
+ * ## Selection, not hover
18
+ *
19
+ * The × appears when the edge is **selected**, which React Flow does on click
20
+ * and also on Enter or Space when the edge has keyboard focus. Hover would have
21
+ * been fractionally quicker with a mouse and unreachable without one, and it
22
+ * would put a delete button under the pointer of somebody who is only tracing
23
+ * where a line goes. Selection is a decision; hover is a coincidence.
24
+ *
25
+ * ## What the keyboard gets
26
+ *
27
+ * All of it, by two routes. React Flow renders the edge as a focusable element
28
+ * with `edgesFocusable`, so Tab reaches it and Enter or Space selects it — at
29
+ * which point the × exists in the document and is an ordinary `<button>` in the
30
+ * tab order. And the route that predates this is untouched: the wiring rail
31
+ * beside the canvas lists every connection as a row with its own Disconnect
32
+ * button, reachable without going near the canvas at all. The × is an
33
+ * affordance, never the only way through, and `workflow-edge-delete.spec.tsx`
34
+ * holds both halves of that so neither can quietly become the other.
35
+ *
36
+ * ## What reduced motion gets
37
+ *
38
+ * The same button, in the same place, doing the same thing — it simply arrives
39
+ * without the scale-and-fade. Nothing here is revealed *by* an animation: the ×
40
+ * is mounted by `selected`, and `AnimatePresence` only decides how it comes and
41
+ * goes. Somebody with `prefers-reduced-motion` loses a flourish, not a control.
42
+ *
43
+ * ## Why the placement and the animation are on two different elements
44
+ *
45
+ * They used to be on one, and that is the bug this file was reopened for. The ×
46
+ * was a `motion.div` that both carried
47
+ * `transform: translate(-50%, -140%) translate(Xpx, Ypx)` in its `style` and
48
+ * animated `scale`. Motion owns the WHOLE `transform` property of anything it
49
+ * animates a transform component of: it composes the property from its own
50
+ * values every frame and writes the result, so the hand-written translate was
51
+ * overwritten — and at rest, with `scale: 1` and nothing else to compose, what
52
+ * it wrote was `transform: none`. The control then sat at the untranslated
53
+ * origin of `.react-flow__edgelabel-renderer`, which is the top-left of the
54
+ * graph, underneath the first node. Measured in a browser: the button 414px
55
+ * left and 42px above the line's midpoint, and `elementFromPoint` at its centre
56
+ * returning the source node's header. It was present, labelled, opacity 1, and
57
+ * unreachable.
58
+ *
59
+ * So the two jobs are split. A plain `<div>` does the positioning and Motion
60
+ * never touches it; the `motion.div` inside it animates opacity and scale only,
61
+ * about an origin the outer div has already put in the right place. The outer
62
+ * div stays mounted whether or not the × is offered, because it is what
63
+ * `AnimatePresence` needs to be rendered inside for the exit to play at all.
64
+ * `workflow-edge-delete.spec.tsx` pins the translate onto that outer element.
65
+ */
66
+ /**
67
+ * What an edge can reach without being handed a callback through `data`.
68
+ *
69
+ * A context for the same reason `WorkflowNodeContext` is one: React Flow
70
+ * compares an edge's `data` between renders, and a function in there is a new
71
+ * identity every time the screen renders, which invalidates every edge at once.
72
+ *
73
+ * The default throws rather than no-oping. An edge rendered outside the canvas
74
+ * would otherwise look entirely normal and quietly ignore every click on its ×,
75
+ * which is a far worse bug to find than an error naming the missing provider.
76
+ */
77
+ interface WorkflowEdgeHandlers {
78
+ /** Remove this connection. Same callback the wiring menu and the rail use. */
79
+ onDisconnect(edge: WorkflowEdge): void;
80
+ /** Whether editing is offered at all. Read-only viewers get no ×. */
81
+ canEdit: boolean;
82
+ }
83
+ export declare function WorkflowEdgeProvider({ handlers, children, }: {
84
+ handlers: WorkflowEdgeHandlers;
85
+ children: ReactNode;
86
+ }): import("react/jsx-runtime").JSX.Element;
87
+ /**
88
+ * What an edge carries for its own sake, beyond the two node ids.
89
+ *
90
+ * The labels rather than the ids, because the accessible name of the delete
91
+ * button has to say which connection it removes in the words on the canvas —
92
+ * "Remove the connection from src_1 to snk_1" names two things nobody can see.
93
+ */
94
+ export interface WorkflowEdgeData extends Record<string, unknown> {
95
+ fromLabel: string;
96
+ toLabel: string;
97
+ }
98
+ export declare function WorkflowEdgeBody({ id, source, target, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, markerEnd, style, selected, data, }: EdgeProps): import("react/jsx-runtime").JSX.Element;
99
+ /**
100
+ * Declared once, at module scope, for the same reason `workflowNodeTypes` is.
101
+ *
102
+ * React Flow compares `edgeTypes` by identity and warns — then remounts every
103
+ * edge — when it changes. An object literal written inline in the screen is a new
104
+ * object on every render, so the canvas would tear down and rebuild every
105
+ * connection on each keystroke in the name field.
106
+ */
107
+ export declare const workflowEdgeTypes: {
108
+ workflowEdge: typeof WorkflowEdgeBody;
109
+ };
110
+ export {};
@@ -0,0 +1,112 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { BaseEdge, EdgeLabelRenderer, getSmoothStepPath, useReactFlow, } from '@xyflow/react';
3
+ import { X } from 'lucide-react';
4
+ import { AnimatePresence, motion, useReducedMotion } from 'motion/react';
5
+ import { createContext, useContext } from 'react';
6
+ import { Button } from '../ui/button';
7
+ const WorkflowEdgeContext = createContext(null);
8
+ export function WorkflowEdgeProvider({ handlers, children, }) {
9
+ return _jsx(WorkflowEdgeContext.Provider, { value: handlers, children: children });
10
+ }
11
+ function useWorkflowEdgeHandlers() {
12
+ const handlers = useContext(WorkflowEdgeContext);
13
+ if (!handlers) {
14
+ throw new Error('A workflow edge was rendered outside <WorkflowEdgeProvider>.');
15
+ }
16
+ return handlers;
17
+ }
18
+ function readLabels(data) {
19
+ // Narrowed rather than asserted: `data` is React Flow's open bag, and an edge
20
+ // built by anything other than `toFlowEdges` would otherwise render a button
21
+ // whose accessible name is the word "undefined".
22
+ if (typeof data === 'object' && data !== null && 'fromLabel' in data && 'toLabel' in data) {
23
+ const { fromLabel, toLabel } = data;
24
+ if (typeof fromLabel === 'string' && typeof toLabel === 'string')
25
+ return { fromLabel, toLabel };
26
+ }
27
+ return { fromLabel: '', toLabel: '' };
28
+ }
29
+ /**
30
+ * How the × comes and goes.
31
+ *
32
+ * A spring rather than a tween, so it settles rather than stopping — the control
33
+ * is appearing at a point somebody just clicked, and a linear pop reads as a
34
+ * tooltip rather than as something they summoned. Short and stiff enough that it
35
+ * is finished before the hand moves.
36
+ */
37
+ const APPEAR = { type: 'spring', stiffness: 520, damping: 30, mass: 0.6 };
38
+ export function WorkflowEdgeBody({ id, source, target, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, markerEnd, style, selected, data, }) {
39
+ const { onDisconnect, canEdit } = useWorkflowEdgeHandlers();
40
+ const reduced = useReducedMotion();
41
+ const { setEdges } = useReactFlow();
42
+ const { fromLabel, toLabel } = readLabels(data);
43
+ const [path, labelX, labelY] = getSmoothStepPath({
44
+ sourceX,
45
+ sourceY,
46
+ targetX,
47
+ targetY,
48
+ sourcePosition,
49
+ targetPosition,
50
+ // Rounder than React Flow's 5px default. The corners are the only part of a
51
+ // smoothstep edge with any character, and at 5px they read as a mitre.
52
+ borderRadius: 12,
53
+ });
54
+ const offered = Boolean(selected) && canEdit;
55
+ return (_jsxs(_Fragment, { children: [selected && (_jsx("path", { d: path, fill: "none", stroke: "var(--xy-edge-stroke-selected)", strokeWidth: 10, strokeOpacity: 0.18, strokeLinecap: "round",
56
+ // Never a click target: the interaction path below is what catches
57
+ // the pointer, and a second wide path that also did would make the
58
+ // selected edge harder to click *past* than an unselected one.
59
+ style: { pointerEvents: 'none' } })), _jsx(BaseEdge, { id: id, path: path, markerEnd: markerEnd, style: {
60
+ ...style,
61
+ // Only the width is set here. The colour stays on React Flow's own
62
+ // `--xy-edge-stroke` variables, which `CANVAS_THEME` already themes for
63
+ // light and dark — restating a hex here would be a third place for the
64
+ // canvas's palette to live, and the one that forgets dark mode.
65
+ strokeWidth: selected ? 2.5 : (style?.strokeWidth ?? 1.5),
66
+ },
67
+ // Wider than the 20px default. This is the invisible path that catches
68
+ // the click, and the whole complaint was that clicking the line did
69
+ // nothing — which is at least as often "missed it" as "nothing happened".
70
+ interactionWidth: 26 }), _jsx(EdgeLabelRenderer, { children: _jsx("div", { className: "nodrag nopan", style: {
71
+ position: 'absolute',
72
+ transform: `translate(-50%, -140%) translate(${labelX}px, ${labelY}px)`,
73
+ // The label layer has no pointer events by default, which is what
74
+ // keeps edge labels from eating drags. This wrapper does not want
75
+ // them either — only the button inside it does.
76
+ pointerEvents: 'none',
77
+ }, children: _jsx(AnimatePresence, { children: offered && (_jsx(motion.div
78
+ // Opacity and scale ONLY. Motion composes the entire `transform`
79
+ // property from the values it animates, so a translate written
80
+ // here would be overwritten the moment `scale` moves — which is
81
+ // exactly how this control ended up at the origin, under a node.
82
+ // The translate lives on the parent, where nothing composes it.
83
+ , {
84
+ // Opacity and scale ONLY. Motion composes the entire `transform`
85
+ // property from the values it animates, so a translate written
86
+ // here would be overwritten the moment `scale` moves — which is
87
+ // exactly how this control ended up at the origin, under a node.
88
+ // The translate lives on the parent, where nothing composes it.
89
+ style: { pointerEvents: 'all' }, initial: reduced ? false : { opacity: 0, scale: 0.6 }, animate: { opacity: 1, scale: 1 }, exit: reduced ? { opacity: 1, scale: 1 } : { opacity: 0, scale: 0.6 }, transition: reduced ? { duration: 0 } : APPEAR, children: _jsx(Button, { variant: "outline", size: "icon",
90
+ // Round, small, and red on hover — the shape says "close this
91
+ // one thing" and the colour arrives only once the pointer has
92
+ // committed, so a row of edges is not a row of red buttons.
93
+ className: "h-6 w-6 rounded-full shadow-sm transition-colors hover:border-rose-400 hover:bg-rose-50 hover:text-rose-600 dark:hover:border-rose-800 dark:hover:bg-rose-950 dark:hover:text-rose-400", "aria-label": `Remove the connection from ${fromLabel || source} to ${toLabel || target}`, onClick: () => {
94
+ // Deselected first, so the button is gone by the time the
95
+ // graph re-renders. Without this the id stays in React
96
+ // Flow's selection and a *new* edge later given the same id
97
+ // — same two nodes rewired — would come back already
98
+ // selected, with an × floating over a connection nobody
99
+ // clicked.
100
+ setEdges((edges) => edges.map((edge) => (edge.id === id ? { ...edge, selected: false } : edge)));
101
+ onDisconnect({ from: source, to: target });
102
+ }, children: _jsx(X, { size: 12 }) }) })) }) }) })] }));
103
+ }
104
+ /**
105
+ * Declared once, at module scope, for the same reason `workflowNodeTypes` is.
106
+ *
107
+ * React Flow compares `edgeTypes` by identity and warns — then remounts every
108
+ * edge — when it changes. An object literal written inline in the screen is a new
109
+ * object on every render, so the canvas would tear down and rebuild every
110
+ * connection on each keystroke in the name field.
111
+ */
112
+ export const workflowEdgeTypes = { workflowEdge: WorkflowEdgeBody };
@@ -18,6 +18,15 @@ import { type WorkflowProblem } from './validate';
18
18
  * measured anything — on a graph loaded from the server, or one somebody just
19
19
  * pasted — and a layout that waits for measurements draws every node stacked at
20
20
  * the origin for one frame, which reads as a broken canvas.
21
+ *
22
+ * **Re-exported from core rather than declared here**, and that is the point of
23
+ * the change that moved them. The server also writes positions —
24
+ * `adoptConnector` wraps a connector into a graph and has to space its columns —
25
+ * and while these numbers lived only in this file it had nothing to derive from,
26
+ * so it used a literal that was four pixels narrower than the node. Every
27
+ * adopted graph drew its boxes overlapping. Sharing the constant is what stops
28
+ * the two from being able to disagree; the names stay `NODE_WIDTH`/`NODE_HEIGHT`
29
+ * because they are part of this package's published `/workflow` surface.
21
30
  */
22
31
  export declare const NODE_WIDTH = 224;
23
32
  export declare const NODE_HEIGHT = 80;
@@ -53,7 +62,17 @@ export interface NodeDescriptions {
53
62
  }
54
63
  export declare function toFlowNodes(nodes: WorkflowNode[], edges: WorkflowEdge[], describe: NodeDescriptions, problemsFor: Map<string, WorkflowProblem[]>, runFor: Map<string, WorkflowRunNode>): WorkflowFlowNode[];
55
64
  export declare function defaultLabel(kind: WorkflowNodeKind): string;
56
- export declare function toFlowEdges(edges: WorkflowEdge[], nodes: WorkflowNode[], brokenEdgeIds: ReadonlySet<string>): WorkflowFlowEdge[];
65
+ /**
66
+ * The stored edges, as React Flow draws them.
67
+ *
68
+ * `flowing` is the set of edge ids whose upstream node is running right now, and
69
+ * it is a parameter rather than something derived here because this module knows
70
+ * nothing about runs. It is also **the caller's job to pass an empty set when
71
+ * motion is unwanted** — see `WorkflowCanvas`, which reads `prefers-reduced-motion`
72
+ * — because React Flow's `animated` flag is a CSS keyframe in its own stylesheet
73
+ * and there is nothing this package can turn off from the outside.
74
+ */
75
+ export declare function toFlowEdges(edges: WorkflowEdge[], nodes: WorkflowNode[], brokenEdgeIds: ReadonlySet<string>, flowing?: ReadonlySet<string>): WorkflowFlowEdge[];
57
76
  /**
58
77
  * Lay the graph out left to right, one column per dependency depth.
59
78
  *
@@ -99,6 +118,25 @@ export declare function layout(nodes: WorkflowNode[], edges: WorkflowEdge[]): Wo
99
118
  * who then drags a node has authored a layout, and that one is saved.
100
119
  */
101
120
  export declare function layoutIfUnarranged(nodes: WorkflowNode[], edges: WorkflowEdge[]): WorkflowNode[];
121
+ /**
122
+ * Which edges should show their work moving, and when that is none of them.
123
+ *
124
+ * An edge flows while the node feeding it is running. That is the one thing a
125
+ * picture can say about a run which the per-node status list cannot: not what
126
+ * each step's outcome was, but where the work *is* right now.
127
+ *
128
+ * `reducedMotion` short-circuits to the empty set, and this function exists
129
+ * largely so that decision is a value rather than a branch inside a render.
130
+ * React Flow's `animated` is a CSS keyframe in its own stylesheet — there is no
131
+ * prop to soften it and no way to reach it from here — so the only honest
132
+ * accommodation is not to mark the edge at all. Nothing is lost by it: a running
133
+ * node still spins its own badge and the run panel still lists every step, which
134
+ * is the test for whether an animation was carrying information or decorating
135
+ * it.
136
+ */
137
+ export declare function flowingEdgeIds(edges: WorkflowEdge[], runNodes: readonly WorkflowRunNode[], options: {
138
+ reducedMotion: boolean;
139
+ }): ReadonlySet<string>;
102
140
  /**
103
141
  * Where to drop a node somebody just added.
104
142
  *