@nexub/diagram 0.0.0 → 11.6.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.
- package/LICENSE +21 -0
- package/dist/index.d.ts +163 -0
- package/dist/index.js +946 -0
- package/dist/styles.css +2 -0
- package/dist/theme.css +2 -0
- package/package.json +72 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nexub Pte. Ltd.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Node, Edge, ReactFlowProps, NodeProps } from '@xyflow/react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Status colour of a {@link DiagramNodeData | diagram node}. Always paired with a text
|
|
6
|
+
* equivalent for screen readers, and a border style in forced colours.
|
|
7
|
+
* @alpha
|
|
8
|
+
*/
|
|
9
|
+
type DiagramNodeTone = 'default' | 'good' | 'warning' | 'danger';
|
|
10
|
+
/**
|
|
11
|
+
* `data` of a node with `type: 'nexub'` (rendered by `DiagramNode`).
|
|
12
|
+
* @alpha
|
|
13
|
+
*/
|
|
14
|
+
interface DiagramNodeData extends Record<string, unknown> {
|
|
15
|
+
/** The card's heading; also the node's accessible name and its name in the list view. */
|
|
16
|
+
title: string;
|
|
17
|
+
description?: string;
|
|
18
|
+
/** Decorative icon before the title (hidden from screen readers). */
|
|
19
|
+
icon?: React.ReactNode;
|
|
20
|
+
/** @default 'default' */
|
|
21
|
+
tone?: DiagramNodeTone;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A React Flow node rendered by `DiagramNode`.
|
|
25
|
+
* @alpha
|
|
26
|
+
*/
|
|
27
|
+
type DiagramFlowNode = Node<DiagramNodeData, 'nexub'>;
|
|
28
|
+
/**
|
|
29
|
+
* How `DiagramCanvas` positions nodes: `left-right` (layered workflow, or a tidy tree when
|
|
30
|
+
* the graph is a tree), `mind-map` (radial tree), or `none` (use the nodes' own positions).
|
|
31
|
+
* @alpha
|
|
32
|
+
*/
|
|
33
|
+
type DiagramLayout = 'left-right' | 'mind-map' | 'none';
|
|
34
|
+
/**
|
|
35
|
+
* Every user-facing string of `DiagramCanvas`, in English by default. These are not in
|
|
36
|
+
* `@nexub/core` messages yet, so pass translations here.
|
|
37
|
+
* @alpha
|
|
38
|
+
*/
|
|
39
|
+
interface DiagramLabels {
|
|
40
|
+
/** The list view's disclosure. */
|
|
41
|
+
showAsList: string;
|
|
42
|
+
/** In the list view, before a node's outgoing connections. */
|
|
43
|
+
connectsTo: string;
|
|
44
|
+
/** In the list view, before a node's incoming connections. */
|
|
45
|
+
connectedFrom: string;
|
|
46
|
+
/** In the list view, for a node with no connections. */
|
|
47
|
+
noConnections: string;
|
|
48
|
+
/** The button on a focused node, and the Connect menu's name: "Connect Fetch data to…". */
|
|
49
|
+
connectTo: (title: string) => string;
|
|
50
|
+
/** The Connect menu when every other node is already connected. */
|
|
51
|
+
noTargets: string;
|
|
52
|
+
/** Read with every node: how the keyboard works. */
|
|
53
|
+
nodeHint: string;
|
|
54
|
+
/** Read with every node when `readOnly`. */
|
|
55
|
+
nodeHintReadOnly: string;
|
|
56
|
+
/** Live announcements. */
|
|
57
|
+
connected: (source: string, target: string) => string;
|
|
58
|
+
moved: (title: string, x: number, y: number) => string;
|
|
59
|
+
deleted: (count: number) => string;
|
|
60
|
+
/** Text equivalents of the tones (screen readers and the list view). */
|
|
61
|
+
tones: Record<Exclude<DiagramNodeTone, 'default'>, string>;
|
|
62
|
+
/** The zoom controls. */
|
|
63
|
+
controls: string;
|
|
64
|
+
zoomIn: string;
|
|
65
|
+
zoomOut: string;
|
|
66
|
+
fitView: string;
|
|
67
|
+
minimap: string;
|
|
68
|
+
}
|
|
69
|
+
/** @alpha */
|
|
70
|
+
interface DiagramCanvasProps<N extends Node = Node, E extends Edge = Edge> extends Omit<ReactFlowProps<N, E>, 'aria-label' | 'nodeTypes'> {
|
|
71
|
+
/** Names the canvas (role="application"). Required. */
|
|
72
|
+
'aria-label': string;
|
|
73
|
+
/**
|
|
74
|
+
* Positions nodes automatically when nodes or edges change (their ids, sizes or links).
|
|
75
|
+
* Moves made since (drag, Alt+Arrow) are kept until the next change. With uncontrolled
|
|
76
|
+
* `defaultNodes`, the layout is applied once.
|
|
77
|
+
* @default 'none'
|
|
78
|
+
*/
|
|
79
|
+
layout?: DiagramLayout;
|
|
80
|
+
/** View only: no dragging, connecting, deleting or selecting. Arrow keys still move focus. */
|
|
81
|
+
readOnly?: boolean;
|
|
82
|
+
/** Show the minimap. @default false */
|
|
83
|
+
minimap?: boolean;
|
|
84
|
+
/** Show the zoom in, zoom out and fit view buttons. @default true */
|
|
85
|
+
controls?: boolean;
|
|
86
|
+
/** Extra node types; `nexub` (DiagramNode) is always there. */
|
|
87
|
+
nodeTypes?: ReactFlowProps<N, E>['nodeTypes'];
|
|
88
|
+
/** Show the "Show as list" text alternative under the canvas. @default true */
|
|
89
|
+
listView?: boolean;
|
|
90
|
+
/** Translated strings (English by default). */
|
|
91
|
+
labels?: Partial<DiagramLabels>;
|
|
92
|
+
/** Grid step for Alt+Arrow moves, in flow units; Shift moves four steps. Defaults to `snapGrid[0]`, else 16. */
|
|
93
|
+
keyboardStep?: number;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* A themed, keyboard-accessible diagram canvas on React Flow. Takes React Flow's props
|
|
98
|
+
* (controlled `nodes`/`edges` with `onNodesChange`/`onEdgesChange`/`onConnect`, or
|
|
99
|
+
* `defaultNodes`/`defaultEdges`), plus automatic `layout`, `readOnly`, `minimap` and
|
|
100
|
+
* `controls`, and renders a "Show as list" text alternative under the canvas.
|
|
101
|
+
* `className` and `style` size the canvas box (24rem tall by default).
|
|
102
|
+
*
|
|
103
|
+
* Keyboard, on a focused node: arrow keys move focus to the nearest node that way, Home
|
|
104
|
+
* and End to the first and last in reading order; Alt (Option) + arrow moves the node one
|
|
105
|
+
* grid step (Shift: four); C opens the "Connect to…" menu; Delete or Backspace removes
|
|
106
|
+
* the selection (or the focused node). In `readOnly` only focus moves.
|
|
107
|
+
*
|
|
108
|
+
* Uses the ReactFlowProvider above it when there is one, else its own.
|
|
109
|
+
*
|
|
110
|
+
* @alpha
|
|
111
|
+
*/
|
|
112
|
+
declare function DiagramCanvas<N extends Node = Node, E extends Edge = Edge>(props: DiagramCanvasProps<N, E>): React.JSX.Element;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* The Nexub card node: a title, an optional description and icon, and a status tone.
|
|
116
|
+
* Register it as `type: 'nexub'` (DiagramCanvas does). Its handles sit on the sides the
|
|
117
|
+
* layout sets (`targetPosition` / `sourcePosition`), left and right by default, with a
|
|
118
|
+
* 24px hit area.
|
|
119
|
+
*
|
|
120
|
+
* @alpha
|
|
121
|
+
*/
|
|
122
|
+
declare const DiagramNode: React.MemoExoticComponent<({ id, data, sourcePosition, targetPosition, isConnectable }: NodeProps<DiagramFlowNode>) => React.JSX.Element>;
|
|
123
|
+
|
|
124
|
+
/** Card width used when a node has no `measured`, `width` or `height` yet. @alpha */
|
|
125
|
+
declare const DEFAULT_NODE_WIDTH = 240;
|
|
126
|
+
/** Card height used when a node has no `measured`, `width` or `height` yet. @alpha */
|
|
127
|
+
declare const DEFAULT_NODE_HEIGHT = 72;
|
|
128
|
+
/**
|
|
129
|
+
* Options for {@link layoutTree}.
|
|
130
|
+
* @alpha
|
|
131
|
+
*/
|
|
132
|
+
interface LayoutTreeOptions {
|
|
133
|
+
/** `left-right`: a tidy tree, roots at the start, children in the next column. `radial`: roots in the middle, each depth on a ring (mind maps). */
|
|
134
|
+
direction: 'left-right' | 'radial';
|
|
135
|
+
}
|
|
136
|
+
/** The size layouts use for a node: React Flow's measured size, then `width`/`height`, then the default card. @alpha */
|
|
137
|
+
declare function getNodeSize(node: Pick<Node, 'measured' | 'width' | 'height'>): {
|
|
138
|
+
width: number;
|
|
139
|
+
height: number;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Lays nodes out as a tree (or a forest): a tidy left-to-right tree, or a radial one
|
|
143
|
+
* for mind maps. Edges pick the parent; extra edges (a second parent, a cycle) are kept
|
|
144
|
+
* but do not move nodes. Never throws: cycles and disconnected nodes become their own trees.
|
|
145
|
+
*
|
|
146
|
+
* @alpha
|
|
147
|
+
*/
|
|
148
|
+
declare function layoutTree<N extends Node>(nodes: readonly N[], edges: readonly Edge[], options?: LayoutTreeOptions): N[];
|
|
149
|
+
/**
|
|
150
|
+
* Lays a directed graph out in left-to-right layers (workflows, pipelines): longest-path
|
|
151
|
+
* layering, then barycentre ordering within each layer to cut edge crossings. Cycles are
|
|
152
|
+
* broken by ignoring the edges that close them (depth-first back edges); disconnected
|
|
153
|
+
* nodes land in the first layer. Never throws.
|
|
154
|
+
*
|
|
155
|
+
* @alpha
|
|
156
|
+
*/
|
|
157
|
+
declare function layoutLayers<N extends Node>(nodes: readonly N[], edges: readonly Edge[]): N[];
|
|
158
|
+
|
|
159
|
+
/** English defaults for {@link DiagramLabels}. @alpha */
|
|
160
|
+
declare const defaultDiagramLabels: DiagramLabels;
|
|
161
|
+
|
|
162
|
+
export { DEFAULT_NODE_HEIGHT, DEFAULT_NODE_WIDTH, DiagramCanvas, DiagramNode, defaultDiagramLabels, getNodeSize, layoutLayers, layoutTree };
|
|
163
|
+
export type { DiagramCanvasProps, DiagramFlowNode, DiagramLabels, DiagramLayout, DiagramNodeData, DiagramNodeTone, LayoutTreeOptions };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,946 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
// src/DiagramCanvas.tsx
|
|
4
|
+
import * as React5 from "react";
|
|
5
|
+
import {
|
|
6
|
+
Controls,
|
|
7
|
+
MiniMap,
|
|
8
|
+
ReactFlow,
|
|
9
|
+
ReactFlowProvider,
|
|
10
|
+
useReactFlow,
|
|
11
|
+
useStore,
|
|
12
|
+
useStoreApi
|
|
13
|
+
} from "@xyflow/react";
|
|
14
|
+
|
|
15
|
+
// src/ConnectMenu.tsx
|
|
16
|
+
import * as React from "react";
|
|
17
|
+
|
|
18
|
+
// src/cx.ts
|
|
19
|
+
function cx(...parts) {
|
|
20
|
+
return parts.filter(Boolean).join(" ");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// src/ConnectMenu.tsx
|
|
24
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
25
|
+
function ConnectMenu({ label, emptyLabel, options, onPick, onClose }) {
|
|
26
|
+
const listId = React.useId();
|
|
27
|
+
const [active, setActive] = React.useState(0);
|
|
28
|
+
const listRef = React.useRef(null);
|
|
29
|
+
React.useEffect(() => {
|
|
30
|
+
listRef.current?.focus();
|
|
31
|
+
}, []);
|
|
32
|
+
const activeIndex = Math.min(active, Math.max(0, options.length - 1));
|
|
33
|
+
const onKeyDown = (e) => {
|
|
34
|
+
const last = options.length - 1;
|
|
35
|
+
let next;
|
|
36
|
+
if (e.key === "ArrowDown") next = activeIndex >= last ? 0 : activeIndex + 1;
|
|
37
|
+
else if (e.key === "ArrowUp") next = activeIndex <= 0 ? last : activeIndex - 1;
|
|
38
|
+
else if (e.key === "Home") next = 0;
|
|
39
|
+
else if (e.key === "End") next = last;
|
|
40
|
+
else if (e.key === "Enter" || e.key === " ") {
|
|
41
|
+
e.preventDefault();
|
|
42
|
+
e.stopPropagation();
|
|
43
|
+
const o = options[activeIndex];
|
|
44
|
+
if (o) onPick(o.id);
|
|
45
|
+
return;
|
|
46
|
+
} else if (e.key === "Escape" || e.key === "Tab") {
|
|
47
|
+
e.preventDefault();
|
|
48
|
+
e.stopPropagation();
|
|
49
|
+
onClose();
|
|
50
|
+
return;
|
|
51
|
+
} else if (e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey) {
|
|
52
|
+
const ch = e.key.toLowerCase();
|
|
53
|
+
const n = options.length;
|
|
54
|
+
for (let k = 1; k <= n; k++) {
|
|
55
|
+
const i = (activeIndex + k) % n;
|
|
56
|
+
if (options[i].title.toLowerCase().startsWith(ch)) {
|
|
57
|
+
next = i;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (next !== void 0) {
|
|
63
|
+
e.preventDefault();
|
|
64
|
+
e.stopPropagation();
|
|
65
|
+
setActive(Math.max(0, next));
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
return /* @__PURE__ */ jsxs(
|
|
69
|
+
"div",
|
|
70
|
+
{
|
|
71
|
+
"data-diagram-connect-menu": "",
|
|
72
|
+
className: "nx-diagram-menu absolute start-3 top-3 z-10 flex max-h-72 w-64 flex-col gap-1 overflow-hidden rounded-shape-container border border-outline-variant bg-surface-container p-2 text-on-surface shadow-elevation-2",
|
|
73
|
+
children: [
|
|
74
|
+
/* @__PURE__ */ jsx("div", { id: `${listId}-label`, className: "px-2 py-1 text-label-md text-on-surface-variant", children: label }),
|
|
75
|
+
/* @__PURE__ */ jsx(
|
|
76
|
+
"div",
|
|
77
|
+
{
|
|
78
|
+
ref: listRef,
|
|
79
|
+
id: listId,
|
|
80
|
+
role: "listbox",
|
|
81
|
+
tabIndex: 0,
|
|
82
|
+
"aria-labelledby": `${listId}-label`,
|
|
83
|
+
"aria-activedescendant": options.length ? `${listId}-${activeIndex}` : void 0,
|
|
84
|
+
className: "nx-diagram-menu-list flex flex-col overflow-auto",
|
|
85
|
+
onKeyDown,
|
|
86
|
+
onBlur: (e) => {
|
|
87
|
+
if (!e.currentTarget.parentElement?.contains(e.relatedTarget)) onClose(false);
|
|
88
|
+
},
|
|
89
|
+
children: options.length === 0 ? /* @__PURE__ */ jsx("div", { className: "px-2 py-1.5 text-body-sm text-on-surface-variant", children: emptyLabel }) : options.map((o, i) => /* @__PURE__ */ jsx(
|
|
90
|
+
"div",
|
|
91
|
+
{
|
|
92
|
+
id: `${listId}-${i}`,
|
|
93
|
+
role: "option",
|
|
94
|
+
"aria-selected": i === activeIndex,
|
|
95
|
+
"data-active": i === activeIndex ? "" : void 0,
|
|
96
|
+
className: cx("cursor-pointer truncate rounded-shape-field px-2 py-1.5 text-body-md", i === activeIndex && "bg-secondary-container text-on-secondary-container"),
|
|
97
|
+
onPointerDown: (e) => e.preventDefault(),
|
|
98
|
+
onClick: () => onPick(o.id),
|
|
99
|
+
onPointerEnter: () => setActive(i),
|
|
100
|
+
children: o.title
|
|
101
|
+
},
|
|
102
|
+
o.id
|
|
103
|
+
))
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// src/context.ts
|
|
112
|
+
import * as React2 from "react";
|
|
113
|
+
|
|
114
|
+
// src/labels.ts
|
|
115
|
+
var defaultDiagramLabels = {
|
|
116
|
+
showAsList: "Show as list",
|
|
117
|
+
connectsTo: "Connects to",
|
|
118
|
+
connectedFrom: "Connected from",
|
|
119
|
+
noConnections: "No connections",
|
|
120
|
+
connectTo: (title) => `Connect ${title} to\u2026`,
|
|
121
|
+
noTargets: "No other nodes to connect to",
|
|
122
|
+
nodeHint: "Arrow keys move between nodes. Alt and an arrow key moves the node. Press C to connect it to another node, Delete to remove it.",
|
|
123
|
+
nodeHintReadOnly: "Arrow keys move between nodes.",
|
|
124
|
+
connected: (source, target) => `Connected ${source} to ${target}`,
|
|
125
|
+
moved: (title, x, y) => `Moved ${title} to ${x}, ${y}`,
|
|
126
|
+
deleted: (count) => count === 1 ? "Deleted 1 item" : `Deleted ${count} items`,
|
|
127
|
+
tones: { good: "Good", warning: "Warning", danger: "Problem" },
|
|
128
|
+
controls: "Zoom controls",
|
|
129
|
+
zoomIn: "Zoom in",
|
|
130
|
+
zoomOut: "Zoom out",
|
|
131
|
+
fitView: "Fit view",
|
|
132
|
+
minimap: "Minimap"
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// src/context.ts
|
|
136
|
+
var DiagramContext = React2.createContext({
|
|
137
|
+
layout: "none",
|
|
138
|
+
readOnly: false,
|
|
139
|
+
labels: defaultDiagramLabels
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// src/DiagramListView.tsx
|
|
143
|
+
import "react";
|
|
144
|
+
|
|
145
|
+
// src/keyboard.ts
|
|
146
|
+
var arrowDirections = {
|
|
147
|
+
ArrowUp: "up",
|
|
148
|
+
ArrowDown: "down",
|
|
149
|
+
ArrowLeft: "left",
|
|
150
|
+
ArrowRight: "right"
|
|
151
|
+
};
|
|
152
|
+
var ROW_TOLERANCE = 8;
|
|
153
|
+
function readingOrder(boxes, rtl = false) {
|
|
154
|
+
return [...boxes].sort((a, b) => {
|
|
155
|
+
if (Math.abs(a.y - b.y) > ROW_TOLERANCE) return a.y - b.y;
|
|
156
|
+
return rtl ? b.x + b.width - (a.x + a.width) : a.x - b.x;
|
|
157
|
+
}).map((b) => b.id);
|
|
158
|
+
}
|
|
159
|
+
function nearestInDirection(boxes, fromId, direction) {
|
|
160
|
+
const from = boxes.find((b) => b.id === fromId);
|
|
161
|
+
if (!from) return void 0;
|
|
162
|
+
const cx2 = from.x + from.width / 2;
|
|
163
|
+
const cy = from.y + from.height / 2;
|
|
164
|
+
let best;
|
|
165
|
+
let bestScore = Infinity;
|
|
166
|
+
for (const b of boxes) {
|
|
167
|
+
if (b.id === fromId) continue;
|
|
168
|
+
const dx = b.x + b.width / 2 - cx2;
|
|
169
|
+
const dy = b.y + b.height / 2 - cy;
|
|
170
|
+
const [main, side] = direction === "left" ? [-dx, dy] : direction === "right" ? [dx, dy] : direction === "up" ? [-dy, dx] : [dy, dx];
|
|
171
|
+
if (main <= 0) continue;
|
|
172
|
+
const score = main + 2 * Math.abs(side);
|
|
173
|
+
if (score < bestScore) {
|
|
174
|
+
bestScore = score;
|
|
175
|
+
best = b.id;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return best;
|
|
179
|
+
}
|
|
180
|
+
function nodeTitle(node) {
|
|
181
|
+
if (!node) return "";
|
|
182
|
+
const d = node.data;
|
|
183
|
+
if (typeof d?.title === "string" && d.title) return d.title;
|
|
184
|
+
if (typeof d?.label === "string" && d.label) return d.label;
|
|
185
|
+
return node.ariaLabel || node.id;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// src/DiagramListView.tsx
|
|
189
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
190
|
+
function DiagramListView({ nodes, edges, order, labels }) {
|
|
191
|
+
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
192
|
+
const titles = (ids) => ids.map((id) => nodeTitle(byId.get(id))).join(", ");
|
|
193
|
+
return /* @__PURE__ */ jsxs2("details", { "data-diagram-list": "", className: "text-body-sm", children: [
|
|
194
|
+
/* @__PURE__ */ jsx2("summary", { className: "nx-state-layer inline-flex cursor-pointer select-none items-center gap-1 rounded-shape-control px-2 py-1 text-label-md text-primary", children: labels.showAsList }),
|
|
195
|
+
/* @__PURE__ */ jsx2("ul", { className: "mt-2 flex flex-col gap-2 ps-2", children: order.map((id) => {
|
|
196
|
+
const node = byId.get(id);
|
|
197
|
+
if (!node) return null;
|
|
198
|
+
const out = edges.filter((e) => e.source === id && byId.has(e.target)).map((e) => e.target);
|
|
199
|
+
const into = edges.filter((e) => e.target === id && byId.has(e.source)).map((e) => e.source);
|
|
200
|
+
const tone = node.data?.tone;
|
|
201
|
+
return /* @__PURE__ */ jsxs2("li", { className: "text-on-surface", children: [
|
|
202
|
+
/* @__PURE__ */ jsx2("span", { className: "text-label-lg", children: nodeTitle(node) }),
|
|
203
|
+
tone && tone !== "default" && labels.tones[tone] ? /* @__PURE__ */ jsxs2("span", { className: "text-on-surface-variant", children: [
|
|
204
|
+
" (",
|
|
205
|
+
labels.tones[tone],
|
|
206
|
+
")"
|
|
207
|
+
] }) : null,
|
|
208
|
+
/* @__PURE__ */ jsxs2("ul", { className: "ps-4 text-on-surface-variant", children: [
|
|
209
|
+
out.length ? /* @__PURE__ */ jsxs2("li", { children: [
|
|
210
|
+
labels.connectsTo,
|
|
211
|
+
": ",
|
|
212
|
+
titles(out)
|
|
213
|
+
] }) : null,
|
|
214
|
+
into.length ? /* @__PURE__ */ jsxs2("li", { children: [
|
|
215
|
+
labels.connectedFrom,
|
|
216
|
+
": ",
|
|
217
|
+
titles(into)
|
|
218
|
+
] }) : null,
|
|
219
|
+
!out.length && !into.length ? /* @__PURE__ */ jsx2("li", { children: labels.noConnections }) : null
|
|
220
|
+
] })
|
|
221
|
+
] }, id);
|
|
222
|
+
}) })
|
|
223
|
+
] });
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// src/DiagramNode.tsx
|
|
227
|
+
import * as React4 from "react";
|
|
228
|
+
import { Handle, Position } from "@xyflow/react";
|
|
229
|
+
import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
230
|
+
var toneClasses = {
|
|
231
|
+
default: { card: "", chip: "bg-surface-container-high text-on-surface-variant", dot: "" },
|
|
232
|
+
good: { card: "border-s-4 border-s-success", chip: "bg-success-container text-on-success-container", dot: "bg-success" },
|
|
233
|
+
warning: { card: "border-s-4 border-s-warning", chip: "bg-warning-container text-on-warning-container", dot: "bg-warning" },
|
|
234
|
+
danger: { card: "border-s-4 border-s-error", chip: "bg-error-container text-on-error-container", dot: "bg-error" }
|
|
235
|
+
};
|
|
236
|
+
var sides = [Position.Top, Position.Right, Position.Bottom, Position.Left];
|
|
237
|
+
var DiagramNode = React4.memo(function DiagramNode2({ id, data, sourcePosition, targetPosition, isConnectable }) {
|
|
238
|
+
const { readOnly, labels, openConnect, layout } = React4.useContext(DiagramContext);
|
|
239
|
+
const connectable = isConnectable && !readOnly;
|
|
240
|
+
const tone = data.tone ?? "default";
|
|
241
|
+
const t = toneClasses[tone] ?? toneClasses.default;
|
|
242
|
+
const title = data.title ?? id;
|
|
243
|
+
return /* @__PURE__ */ jsxs3(
|
|
244
|
+
"div",
|
|
245
|
+
{
|
|
246
|
+
"data-tone": tone,
|
|
247
|
+
className: cx(
|
|
248
|
+
"nx-diagram-node relative flex w-60 items-start gap-3 rounded-shape-container border border-outline-variant bg-surface-container-low px-4 py-3 text-start text-on-surface",
|
|
249
|
+
t.card
|
|
250
|
+
),
|
|
251
|
+
children: [
|
|
252
|
+
layout === "mind-map" ? (
|
|
253
|
+
// Mind maps: a handle on every side; DiagramCanvas points each edge at the facing pair.
|
|
254
|
+
sides.map((side) => /* @__PURE__ */ jsxs3(React4.Fragment, { children: [
|
|
255
|
+
/* @__PURE__ */ jsx3(Handle, { type: "target", id: `t-${side}`, position: side, isConnectable: connectable, className: "nx-diagram-handle" }),
|
|
256
|
+
/* @__PURE__ */ jsx3(Handle, { type: "source", id: `s-${side}`, position: side, isConnectable: connectable, className: "nx-diagram-handle" })
|
|
257
|
+
] }, side))
|
|
258
|
+
) : /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
259
|
+
/* @__PURE__ */ jsx3(Handle, { type: "target", position: targetPosition ?? Position.Left, isConnectable: connectable, className: "nx-diagram-handle" }),
|
|
260
|
+
/* @__PURE__ */ jsx3(Handle, { type: "source", position: sourcePosition ?? Position.Right, isConnectable: connectable, className: "nx-diagram-handle" })
|
|
261
|
+
] }),
|
|
262
|
+
data.icon ? /* @__PURE__ */ jsx3("span", { "aria-hidden": "true", className: cx("flex size-8 shrink-0 items-center justify-center rounded-shape-control", t.chip), children: data.icon }) : null,
|
|
263
|
+
/* @__PURE__ */ jsxs3("span", { className: "flex min-w-0 flex-1 flex-col gap-0.5", children: [
|
|
264
|
+
/* @__PURE__ */ jsxs3("span", { className: "flex items-center gap-2", children: [
|
|
265
|
+
/* @__PURE__ */ jsx3("span", { className: "truncate text-title-sm", children: title }),
|
|
266
|
+
tone !== "default" ? /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
267
|
+
/* @__PURE__ */ jsx3("span", { "aria-hidden": "true", className: cx("size-2 shrink-0 rounded-full", t.dot) }),
|
|
268
|
+
/* @__PURE__ */ jsx3("span", { className: "sr-only", children: labels.tones[tone] })
|
|
269
|
+
] }) : null
|
|
270
|
+
] }),
|
|
271
|
+
data.description ? /* @__PURE__ */ jsx3("span", { className: "line-clamp-2 text-body-sm text-on-surface-variant", children: data.description }) : null
|
|
272
|
+
] }),
|
|
273
|
+
openConnect && connectable ? /* @__PURE__ */ jsx3(
|
|
274
|
+
"button",
|
|
275
|
+
{
|
|
276
|
+
type: "button",
|
|
277
|
+
tabIndex: -1,
|
|
278
|
+
"aria-label": labels.connectTo(title),
|
|
279
|
+
title: labels.connectTo(title),
|
|
280
|
+
className: "nx-diagram-connect nodrag nopan absolute -bottom-3 end-3 flex size-6 items-center justify-center rounded-full border border-outline-variant bg-surface text-on-surface-variant",
|
|
281
|
+
onClick: (e) => {
|
|
282
|
+
e.stopPropagation();
|
|
283
|
+
openConnect(id);
|
|
284
|
+
},
|
|
285
|
+
children: /* @__PURE__ */ jsx3("svg", { "aria-hidden": "true", viewBox: "0 0 16 16", className: "size-3.5", fill: "none", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", children: /* @__PURE__ */ jsx3("path", { d: "M8 3v10M3 8h10" }) })
|
|
286
|
+
}
|
|
287
|
+
) : null
|
|
288
|
+
]
|
|
289
|
+
}
|
|
290
|
+
);
|
|
291
|
+
});
|
|
292
|
+
|
|
293
|
+
// src/layout.ts
|
|
294
|
+
import { Position as Position2 } from "@xyflow/react";
|
|
295
|
+
var DEFAULT_NODE_WIDTH = 240;
|
|
296
|
+
var DEFAULT_NODE_HEIGHT = 72;
|
|
297
|
+
var SIBLING_GAP = 24;
|
|
298
|
+
var RANK_GAP = 80;
|
|
299
|
+
var TREE_GAP = 48;
|
|
300
|
+
function getNodeSize(node) {
|
|
301
|
+
return {
|
|
302
|
+
width: node.measured?.width ?? node.width ?? DEFAULT_NODE_WIDTH,
|
|
303
|
+
height: node.measured?.height ?? node.height ?? DEFAULT_NODE_HEIGHT
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
function adjacency(nodes, edges) {
|
|
307
|
+
const ids = new Set(nodes.map((n) => n.id));
|
|
308
|
+
const out = /* @__PURE__ */ new Map();
|
|
309
|
+
const into = /* @__PURE__ */ new Map();
|
|
310
|
+
for (const n of nodes) {
|
|
311
|
+
out.set(n.id, []);
|
|
312
|
+
into.set(n.id, []);
|
|
313
|
+
}
|
|
314
|
+
for (const e of edges) {
|
|
315
|
+
if (!ids.has(e.source) || !ids.has(e.target) || e.source === e.target) continue;
|
|
316
|
+
const o = out.get(e.source);
|
|
317
|
+
if (o.includes(e.target)) continue;
|
|
318
|
+
o.push(e.target);
|
|
319
|
+
into.get(e.target).push(e.source);
|
|
320
|
+
}
|
|
321
|
+
return { out, into };
|
|
322
|
+
}
|
|
323
|
+
function spanningForest(nodes, edges) {
|
|
324
|
+
const { out, into } = adjacency(nodes, edges);
|
|
325
|
+
const seen = /* @__PURE__ */ new Set();
|
|
326
|
+
const forest = [];
|
|
327
|
+
const grow = (rootId) => {
|
|
328
|
+
const root = { id: rootId, depth: 0, children: [] };
|
|
329
|
+
seen.add(rootId);
|
|
330
|
+
const queue = [root];
|
|
331
|
+
for (let i = 0; i < queue.length; i++) {
|
|
332
|
+
const t = queue[i];
|
|
333
|
+
for (const c of out.get(t.id)) {
|
|
334
|
+
if (seen.has(c)) continue;
|
|
335
|
+
seen.add(c);
|
|
336
|
+
const child = { id: c, depth: t.depth + 1, children: [] };
|
|
337
|
+
t.children.push(child);
|
|
338
|
+
queue.push(child);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
forest.push(root);
|
|
342
|
+
};
|
|
343
|
+
for (const n of nodes) if (into.get(n.id).length === 0) grow(n.id);
|
|
344
|
+
for (const n of nodes) if (!seen.has(n.id)) grow(n.id);
|
|
345
|
+
return forest;
|
|
346
|
+
}
|
|
347
|
+
function walk(t, fn) {
|
|
348
|
+
fn(t);
|
|
349
|
+
t.children.forEach((c) => walk(c, fn));
|
|
350
|
+
}
|
|
351
|
+
function layoutTree(nodes, edges, options = { direction: "left-right" }) {
|
|
352
|
+
if (nodes.length === 0) return [];
|
|
353
|
+
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
354
|
+
const size = (id) => getNodeSize(byId.get(id));
|
|
355
|
+
const forest = spanningForest(nodes, edges);
|
|
356
|
+
const placed = /* @__PURE__ */ new Map();
|
|
357
|
+
if (options.direction === "radial") {
|
|
358
|
+
let nextX;
|
|
359
|
+
for (const root of forest) {
|
|
360
|
+
const local = radialTree(root, size);
|
|
361
|
+
let minX = Infinity;
|
|
362
|
+
let maxX = -Infinity;
|
|
363
|
+
for (const [id, c] of local) {
|
|
364
|
+
const s = size(id);
|
|
365
|
+
minX = Math.min(minX, c.x - s.width / 2);
|
|
366
|
+
maxX = Math.max(maxX, c.x + s.width / 2);
|
|
367
|
+
}
|
|
368
|
+
const shift = nextX === void 0 ? 0 : nextX - minX;
|
|
369
|
+
const rootCentre = local.get(root.id);
|
|
370
|
+
for (const [id, c] of local) {
|
|
371
|
+
const s = size(id);
|
|
372
|
+
const sides2 = radialSides(c.x - rootCentre.x, c.y - rootCentre.y, id === root.id);
|
|
373
|
+
placed.set(id, { position: { x: c.x + shift - s.width / 2, y: c.y - s.height / 2 }, ...sides2 });
|
|
374
|
+
}
|
|
375
|
+
nextX = maxX + shift + TREE_GAP;
|
|
376
|
+
}
|
|
377
|
+
} else {
|
|
378
|
+
const colWidth = [];
|
|
379
|
+
forest.forEach(
|
|
380
|
+
(r) => walk(r, (t) => {
|
|
381
|
+
colWidth[t.depth] = Math.max(colWidth[t.depth] ?? 0, size(t.id).width);
|
|
382
|
+
})
|
|
383
|
+
);
|
|
384
|
+
const colX = [];
|
|
385
|
+
colWidth.reduce((x, w, d) => (colX[d] = x, x + w + RANK_GAP), 0);
|
|
386
|
+
let cursor = 0;
|
|
387
|
+
const centreY = /* @__PURE__ */ new Map();
|
|
388
|
+
const place = (t) => {
|
|
389
|
+
const h = size(t.id).height;
|
|
390
|
+
let cy;
|
|
391
|
+
if (t.children.length === 0) {
|
|
392
|
+
cy = cursor + h / 2;
|
|
393
|
+
cursor += h + SIBLING_GAP;
|
|
394
|
+
} else {
|
|
395
|
+
const ys = t.children.map(place);
|
|
396
|
+
cy = (ys[0] + ys[ys.length - 1]) / 2;
|
|
397
|
+
cursor = Math.max(cursor, cy + h / 2 + SIBLING_GAP);
|
|
398
|
+
}
|
|
399
|
+
centreY.set(t.id, cy);
|
|
400
|
+
return cy;
|
|
401
|
+
};
|
|
402
|
+
forest.forEach((r, i) => {
|
|
403
|
+
if (i > 0) cursor += TREE_GAP - SIBLING_GAP;
|
|
404
|
+
place(r);
|
|
405
|
+
walk(r, (t) => {
|
|
406
|
+
const s = size(t.id);
|
|
407
|
+
placed.set(t.id, {
|
|
408
|
+
position: { x: colX[t.depth], y: centreY.get(t.id) - s.height / 2 },
|
|
409
|
+
source: Position2.Right,
|
|
410
|
+
target: Position2.Left
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
return nodes.map((n) => {
|
|
416
|
+
const p = placed.get(n.id);
|
|
417
|
+
return { ...n, position: p.position, sourcePosition: p.source, targetPosition: p.target };
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
function radialTree(root, size) {
|
|
421
|
+
const leaves = /* @__PURE__ */ new Map();
|
|
422
|
+
const countLeaves = (t) => {
|
|
423
|
+
const n = t.children.length === 0 ? 1 : t.children.reduce((s, c) => s + countLeaves(c), 0);
|
|
424
|
+
leaves.set(t, n);
|
|
425
|
+
return n;
|
|
426
|
+
};
|
|
427
|
+
countLeaves(root);
|
|
428
|
+
const perDepth = [];
|
|
429
|
+
walk(root, (t) => (perDepth[t.depth] ??= []).push(t));
|
|
430
|
+
const diag = (id) => {
|
|
431
|
+
const s = size(id);
|
|
432
|
+
return Math.hypot(s.width, s.height);
|
|
433
|
+
};
|
|
434
|
+
const radius = [0];
|
|
435
|
+
for (let d = 1; d < perDepth.length; d++) {
|
|
436
|
+
const ring = perDepth[d];
|
|
437
|
+
const maxDiag = Math.max(...ring.map((t) => diag(t.id)));
|
|
438
|
+
const prevDiag = Math.max(...perDepth[d - 1].map((t) => diag(t.id)));
|
|
439
|
+
const step = radius[d - 1] + (prevDiag + maxDiag) / 2 + SIBLING_GAP;
|
|
440
|
+
const around = (ring.reduce((s, t) => s + diag(t.id), 0) + ring.length * SIBLING_GAP) / (2 * Math.PI);
|
|
441
|
+
radius[d] = Math.max(step, around);
|
|
442
|
+
}
|
|
443
|
+
const centres = /* @__PURE__ */ new Map();
|
|
444
|
+
const place = (t, from, to) => {
|
|
445
|
+
const angle = (from + to) / 2;
|
|
446
|
+
const r = radius[t.depth];
|
|
447
|
+
centres.set(t.id, { x: Math.round(r * Math.cos(angle)), y: Math.round(r * Math.sin(angle)) });
|
|
448
|
+
let start2 = from;
|
|
449
|
+
for (const c of t.children) {
|
|
450
|
+
const share = (to - from) * leaves.get(c) / leaves.get(t);
|
|
451
|
+
place(c, start2, start2 + share);
|
|
452
|
+
start2 += share;
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
const first = root.children[0];
|
|
456
|
+
const start = first ? -(Math.PI * leaves.get(first)) / leaves.get(root) : 0;
|
|
457
|
+
place(root, start, start + 2 * Math.PI);
|
|
458
|
+
centres.set(root.id, { x: 0, y: 0 });
|
|
459
|
+
return centres;
|
|
460
|
+
}
|
|
461
|
+
function radialSides(dx, dy, isRoot) {
|
|
462
|
+
if (isRoot) return { source: Position2.Right, target: Position2.Left };
|
|
463
|
+
if (Math.abs(dx) >= Math.abs(dy)) {
|
|
464
|
+
return dx >= 0 ? { source: Position2.Right, target: Position2.Left } : { source: Position2.Left, target: Position2.Right };
|
|
465
|
+
}
|
|
466
|
+
return dy >= 0 ? { source: Position2.Bottom, target: Position2.Top } : { source: Position2.Top, target: Position2.Bottom };
|
|
467
|
+
}
|
|
468
|
+
var SWEEPS = 4;
|
|
469
|
+
function layoutLayers(nodes, edges) {
|
|
470
|
+
if (nodes.length === 0) return [];
|
|
471
|
+
const { out } = adjacency(nodes, edges);
|
|
472
|
+
const state = /* @__PURE__ */ new Map();
|
|
473
|
+
const dagOut = new Map(nodes.map((n) => [n.id, []]));
|
|
474
|
+
const visit = (id) => {
|
|
475
|
+
state.set(id, 1);
|
|
476
|
+
for (const t of out.get(id)) {
|
|
477
|
+
const s = state.get(t);
|
|
478
|
+
if (s === 1) continue;
|
|
479
|
+
dagOut.get(id).push(t);
|
|
480
|
+
if (s === void 0) visit(t);
|
|
481
|
+
}
|
|
482
|
+
state.set(id, 2);
|
|
483
|
+
};
|
|
484
|
+
for (const n of nodes) if (!state.has(n.id)) visit(n.id);
|
|
485
|
+
const dagIn = new Map(nodes.map((n) => [n.id, []]));
|
|
486
|
+
for (const [s, ts] of dagOut) for (const t of ts) dagIn.get(t).push(s);
|
|
487
|
+
const layerOf = /* @__PURE__ */ new Map();
|
|
488
|
+
const indeg = new Map(nodes.map((n) => [n.id, dagIn.get(n.id).length]));
|
|
489
|
+
const queue = nodes.filter((n) => indeg.get(n.id) === 0).map((n) => n.id);
|
|
490
|
+
for (let i = 0; i < queue.length; i++) {
|
|
491
|
+
const id = queue[i];
|
|
492
|
+
const l = Math.max(0, ...dagIn.get(id).map((p) => layerOf.get(p) + 1));
|
|
493
|
+
layerOf.set(id, l);
|
|
494
|
+
for (const t of dagOut.get(id)) {
|
|
495
|
+
indeg.set(t, indeg.get(t) - 1);
|
|
496
|
+
if (indeg.get(t) === 0) queue.push(t);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
const layers = [];
|
|
500
|
+
for (const n of nodes) (layers[layerOf.get(n.id)] ??= []).push(n.id);
|
|
501
|
+
const rank = /* @__PURE__ */ new Map();
|
|
502
|
+
const rerank = () => layers.forEach((layer) => layer.forEach((id, i) => rank.set(id, layer.length > 1 ? i / (layer.length - 1) : 0.5)));
|
|
503
|
+
rerank();
|
|
504
|
+
const sortBy = (layer, neighbours) => {
|
|
505
|
+
const keyed = layer.map((id, i) => {
|
|
506
|
+
const ns = neighbours(id);
|
|
507
|
+
const bc = ns.length ? ns.reduce((s, n) => s + rank.get(n), 0) / ns.length : rank.get(id);
|
|
508
|
+
return { id, bc, i };
|
|
509
|
+
});
|
|
510
|
+
keyed.sort((a, b) => a.bc - b.bc || a.i - b.i);
|
|
511
|
+
keyed.forEach((k, i) => layer[i] = k.id);
|
|
512
|
+
rerank();
|
|
513
|
+
};
|
|
514
|
+
for (let s = 0; s < SWEEPS; s++) {
|
|
515
|
+
for (let l = 1; l < layers.length; l++) sortBy(layers[l], (id) => dagIn.get(id));
|
|
516
|
+
for (let l = layers.length - 2; l >= 0; l--) sortBy(layers[l], (id) => dagOut.get(id));
|
|
517
|
+
}
|
|
518
|
+
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
519
|
+
const size = (id) => getNodeSize(byId.get(id));
|
|
520
|
+
const colHeight = layers.map((layer) => layer.reduce((h, id) => h + size(id).height, 0) + SIBLING_GAP * (layer.length - 1));
|
|
521
|
+
const tallest = Math.max(...colHeight);
|
|
522
|
+
const placed = /* @__PURE__ */ new Map();
|
|
523
|
+
let x = 0;
|
|
524
|
+
layers.forEach((layer, l) => {
|
|
525
|
+
let y = (tallest - colHeight[l]) / 2;
|
|
526
|
+
let width = 0;
|
|
527
|
+
for (const id of layer) {
|
|
528
|
+
const s = size(id);
|
|
529
|
+
placed.set(id, { x, y });
|
|
530
|
+
y += s.height + SIBLING_GAP;
|
|
531
|
+
width = Math.max(width, s.width);
|
|
532
|
+
}
|
|
533
|
+
x += width + RANK_GAP;
|
|
534
|
+
});
|
|
535
|
+
return nodes.map((n) => ({ ...n, position: placed.get(n.id), sourcePosition: Position2.Right, targetPosition: Position2.Left }));
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// src/DiagramCanvas.tsx
|
|
539
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
540
|
+
var builtinNodeTypes = { nexub: DiagramNode };
|
|
541
|
+
var DEFAULT_STEP = 16;
|
|
542
|
+
var NODE_SELECTOR = ".react-flow__node";
|
|
543
|
+
function isForest(nodes, edges) {
|
|
544
|
+
const ids = new Set(nodes.map((n) => n.id));
|
|
545
|
+
const parent = /* @__PURE__ */ new Map();
|
|
546
|
+
for (const e of edges) {
|
|
547
|
+
if (!ids.has(e.source) || !ids.has(e.target)) continue;
|
|
548
|
+
if (e.source === e.target || parent.has(e.target)) return false;
|
|
549
|
+
parent.set(e.target, e.source);
|
|
550
|
+
}
|
|
551
|
+
for (const start of parent.keys()) {
|
|
552
|
+
const seen = /* @__PURE__ */ new Set();
|
|
553
|
+
for (let id = start; id !== void 0; id = parent.get(id)) {
|
|
554
|
+
if (seen.has(id)) return false;
|
|
555
|
+
seen.add(id);
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
return true;
|
|
559
|
+
}
|
|
560
|
+
function runLayout(layout, nodes, edges) {
|
|
561
|
+
const laid = layout === "mind-map" ? layoutTree(nodes, edges, { direction: "radial" }) : isForest(nodes, edges) ? layoutTree(nodes, edges, { direction: "left-right" }) : layoutLayers(nodes, edges);
|
|
562
|
+
return new Map(laid.map((n) => [n.id, { position: n.position, sourcePosition: n.sourcePosition, targetPosition: n.targetPosition }]));
|
|
563
|
+
}
|
|
564
|
+
function layoutSignature(nodes, edges) {
|
|
565
|
+
const n = nodes.map((node) => {
|
|
566
|
+
const s = getNodeSize(node);
|
|
567
|
+
return `${node.id}:${s.width}x${s.height}`;
|
|
568
|
+
});
|
|
569
|
+
const e = edges.map((edge) => `${edge.source}>${edge.target}`);
|
|
570
|
+
return `${n.join("|")}#${e.join("|")}`;
|
|
571
|
+
}
|
|
572
|
+
function withAriaLabel(node) {
|
|
573
|
+
return node.ariaLabel ? node : { ...node, ariaLabel: nodeTitle(node) };
|
|
574
|
+
}
|
|
575
|
+
function withFacingHandles(edges, nodes) {
|
|
576
|
+
if (!edges || !nodes) return edges;
|
|
577
|
+
const byId = new Map(nodes.map((n) => [n.id, n]));
|
|
578
|
+
const centre = (n) => {
|
|
579
|
+
const s = getNodeSize(n);
|
|
580
|
+
return { x: n.position.x + s.width / 2, y: n.position.y + s.height / 2 };
|
|
581
|
+
};
|
|
582
|
+
return edges.map((e) => {
|
|
583
|
+
const a = byId.get(e.source);
|
|
584
|
+
const b = byId.get(e.target);
|
|
585
|
+
if (!a || !b || a.type !== "nexub" || b.type !== "nexub" || e.sourceHandle || e.targetHandle) return e;
|
|
586
|
+
const ca = centre(a);
|
|
587
|
+
const cb = centre(b);
|
|
588
|
+
const dx = cb.x - ca.x;
|
|
589
|
+
const dy = cb.y - ca.y;
|
|
590
|
+
const [from, to] = Math.abs(dx) >= Math.abs(dy) ? dx >= 0 ? ["right", "left"] : ["left", "right"] : dy >= 0 ? ["bottom", "top"] : ["top", "bottom"];
|
|
591
|
+
return { ...e, sourceHandle: `s-${from}`, targetHandle: `t-${to}` };
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
function useHasFlowProvider() {
|
|
595
|
+
try {
|
|
596
|
+
useStoreApi();
|
|
597
|
+
return true;
|
|
598
|
+
} catch {
|
|
599
|
+
return false;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
function usePrefersReducedMotion() {
|
|
603
|
+
const [reduced, setReduced] = React5.useState(false);
|
|
604
|
+
React5.useEffect(() => {
|
|
605
|
+
if (typeof window === "undefined" || !window.matchMedia) return;
|
|
606
|
+
const mq = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
607
|
+
setReduced(mq.matches);
|
|
608
|
+
const on = () => setReduced(mq.matches);
|
|
609
|
+
mq.addEventListener?.("change", on);
|
|
610
|
+
return () => mq.removeEventListener?.("change", on);
|
|
611
|
+
}, []);
|
|
612
|
+
return reduced;
|
|
613
|
+
}
|
|
614
|
+
function DiagramCanvas(props) {
|
|
615
|
+
const { nodes, edges, defaultNodes, layout = "none", onNodesChange } = props;
|
|
616
|
+
const hasProvider = useHasFlowProvider();
|
|
617
|
+
const cache = React5.useRef({ key: "", placement: null });
|
|
618
|
+
const signature = layout !== "none" && nodes ? `${layout}@${layoutSignature(nodes, edges ?? [])}` : "";
|
|
619
|
+
if (cache.current.key !== signature) {
|
|
620
|
+
cache.current = { key: signature, placement: signature && nodes ? runLayout(layout, nodes, edges ?? []) : null };
|
|
621
|
+
}
|
|
622
|
+
const placement = cache.current.placement;
|
|
623
|
+
const [offsets, setOffsets] = React5.useState({ key: "", map: /* @__PURE__ */ new Map() });
|
|
624
|
+
const offsetMap = offsets.key === signature ? offsets.map : null;
|
|
625
|
+
const renderedNodes = React5.useMemo(() => {
|
|
626
|
+
if (!nodes) return void 0;
|
|
627
|
+
return nodes.map((n) => {
|
|
628
|
+
const p = placement?.get(n.id);
|
|
629
|
+
if (!p) return withAriaLabel(n);
|
|
630
|
+
const o = offsetMap?.get(n.id);
|
|
631
|
+
return withAriaLabel({
|
|
632
|
+
...n,
|
|
633
|
+
position: o ? { x: p.position.x + o.x, y: p.position.y + o.y } : p.position,
|
|
634
|
+
sourcePosition: p.sourcePosition,
|
|
635
|
+
targetPosition: p.targetPosition
|
|
636
|
+
});
|
|
637
|
+
});
|
|
638
|
+
}, [nodes, placement, offsetMap]);
|
|
639
|
+
const [initialDefaultNodes] = React5.useState(() => {
|
|
640
|
+
if (!defaultNodes) return void 0;
|
|
641
|
+
if (layout === "none") return defaultNodes.map(withAriaLabel);
|
|
642
|
+
const p = runLayout(layout, defaultNodes, props.defaultEdges ?? []);
|
|
643
|
+
return defaultNodes.map((n) => withAriaLabel({ ...n, ...p.get(n.id) }));
|
|
644
|
+
});
|
|
645
|
+
const renderedEdges = React5.useMemo(() => layout === "mind-map" ? withFacingHandles(edges, renderedNodes) : edges, [layout, edges, renderedNodes]);
|
|
646
|
+
const [initialDefaultEdges] = React5.useState(
|
|
647
|
+
() => layout === "mind-map" ? withFacingHandles(props.defaultEdges, initialDefaultNodes) : props.defaultEdges
|
|
648
|
+
);
|
|
649
|
+
const handleNodesChange = React5.useCallback(
|
|
650
|
+
(changes) => {
|
|
651
|
+
if (placement) {
|
|
652
|
+
const moved = changes.filter((c) => c.type === "position" && c.position && placement.has(c.id));
|
|
653
|
+
if (moved.length) {
|
|
654
|
+
setOffsets((prev) => {
|
|
655
|
+
const map = new Map(prev.key === signature ? prev.map : void 0);
|
|
656
|
+
for (const c of moved) {
|
|
657
|
+
if (c.type !== "position" || !c.position) continue;
|
|
658
|
+
const base = placement.get(c.id).position;
|
|
659
|
+
map.set(c.id, { x: c.position.x - base.x, y: c.position.y - base.y });
|
|
660
|
+
}
|
|
661
|
+
return { key: signature, map };
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
onNodesChange?.(changes);
|
|
666
|
+
},
|
|
667
|
+
[placement, signature, onNodesChange]
|
|
668
|
+
);
|
|
669
|
+
const inner = /* @__PURE__ */ jsx4(
|
|
670
|
+
DiagramCanvasInner,
|
|
671
|
+
{
|
|
672
|
+
...props,
|
|
673
|
+
nodes: renderedNodes,
|
|
674
|
+
edges: renderedEdges,
|
|
675
|
+
defaultNodes: initialDefaultNodes,
|
|
676
|
+
defaultEdges: initialDefaultEdges,
|
|
677
|
+
onNodesChange: handleNodesChange
|
|
678
|
+
}
|
|
679
|
+
);
|
|
680
|
+
if (hasProvider) return inner;
|
|
681
|
+
return /* @__PURE__ */ jsx4(
|
|
682
|
+
ReactFlowProvider,
|
|
683
|
+
{
|
|
684
|
+
initialNodes: renderedNodes,
|
|
685
|
+
initialEdges: renderedEdges,
|
|
686
|
+
defaultNodes: initialDefaultNodes,
|
|
687
|
+
defaultEdges: initialDefaultEdges,
|
|
688
|
+
initialWidth: props.width,
|
|
689
|
+
initialHeight: props.height,
|
|
690
|
+
fitView: props.fitView,
|
|
691
|
+
initialFitViewOptions: props.fitViewOptions,
|
|
692
|
+
initialMinZoom: props.minZoom,
|
|
693
|
+
initialMaxZoom: props.maxZoom,
|
|
694
|
+
nodeOrigin: props.nodeOrigin,
|
|
695
|
+
nodeExtent: props.nodeExtent,
|
|
696
|
+
children: inner
|
|
697
|
+
}
|
|
698
|
+
);
|
|
699
|
+
}
|
|
700
|
+
function DiagramCanvasInner(props) {
|
|
701
|
+
const {
|
|
702
|
+
"aria-label": ariaLabel,
|
|
703
|
+
layout = "none",
|
|
704
|
+
readOnly = false,
|
|
705
|
+
minimap = false,
|
|
706
|
+
controls = true,
|
|
707
|
+
listView = true,
|
|
708
|
+
nodeTypes,
|
|
709
|
+
labels: labelOverrides,
|
|
710
|
+
keyboardStep,
|
|
711
|
+
className,
|
|
712
|
+
style,
|
|
713
|
+
children,
|
|
714
|
+
ariaLabelConfig,
|
|
715
|
+
fitViewOptions,
|
|
716
|
+
deleteKeyCode,
|
|
717
|
+
onConnect,
|
|
718
|
+
isValidConnection,
|
|
719
|
+
nodesConnectable,
|
|
720
|
+
nodesDraggable,
|
|
721
|
+
...flowProps
|
|
722
|
+
} = props;
|
|
723
|
+
const labels = React5.useMemo(() => ({ ...defaultDiagramLabels, ...labelOverrides }), [labelOverrides]);
|
|
724
|
+
const store = useStoreApi();
|
|
725
|
+
const { deleteElements } = useReactFlow();
|
|
726
|
+
const storeNodes = useStore((s) => s.nodes);
|
|
727
|
+
const storeEdges = useStore((s) => s.edges);
|
|
728
|
+
const rootRef = React5.useRef(null);
|
|
729
|
+
const [activeId, setActiveId] = React5.useState(null);
|
|
730
|
+
const [connectFrom, setConnectFrom] = React5.useState(null);
|
|
731
|
+
const [announcement, setAnnouncement] = React5.useState("");
|
|
732
|
+
const pendingFocus = React5.useRef(null);
|
|
733
|
+
const reducedMotion = usePrefersReducedMotion();
|
|
734
|
+
const canConnect = !readOnly && !!onConnect && nodesConnectable !== false;
|
|
735
|
+
const ownDelete = !readOnly && deleteKeyCode === void 0;
|
|
736
|
+
const allNodeTypes = React5.useMemo(() => ({ ...nodeTypes, ...builtinNodeTypes }), [nodeTypes]);
|
|
737
|
+
const isRtl = () => rootRef.current?.closest("[dir]")?.getAttribute("dir") === "rtl";
|
|
738
|
+
const boxes = React5.useCallback(() => {
|
|
739
|
+
const { nodeLookup } = store.getState();
|
|
740
|
+
const out = [];
|
|
741
|
+
for (const n of store.getState().nodes) {
|
|
742
|
+
const internal = nodeLookup.get(n.id);
|
|
743
|
+
if (n.hidden || !internal) continue;
|
|
744
|
+
const s = getNodeSize(internal);
|
|
745
|
+
const p = internal.internals.positionAbsolute;
|
|
746
|
+
out.push({ id: n.id, x: p.x, y: p.y, width: s.width, height: s.height });
|
|
747
|
+
}
|
|
748
|
+
return out;
|
|
749
|
+
}, [store]);
|
|
750
|
+
const order = React5.useMemo(() => readingOrder(boxes(), isRtl()), [boxes, storeNodes]);
|
|
751
|
+
const effectiveActive = activeId && order.includes(activeId) ? activeId : order[0];
|
|
752
|
+
const nodeElement = (id) => Array.from(rootRef.current?.querySelectorAll(NODE_SELECTOR) ?? []).find((el) => el.getAttribute("data-id") === id);
|
|
753
|
+
const focusNode = (id) => {
|
|
754
|
+
setActiveId(id);
|
|
755
|
+
nodeElement(id)?.focus();
|
|
756
|
+
};
|
|
757
|
+
React5.useLayoutEffect(() => {
|
|
758
|
+
rootRef.current?.querySelectorAll(NODE_SELECTOR).forEach((el) => {
|
|
759
|
+
if (el.getAttribute("tabindex") === null) return;
|
|
760
|
+
el.tabIndex = el.getAttribute("data-id") === effectiveActive ? 0 : -1;
|
|
761
|
+
});
|
|
762
|
+
if (pendingFocus.current) {
|
|
763
|
+
const el = nodeElement(pendingFocus.current);
|
|
764
|
+
if (el) {
|
|
765
|
+
pendingFocus.current = null;
|
|
766
|
+
el.focus();
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
});
|
|
770
|
+
const announce = (text) => setAnnouncement(text);
|
|
771
|
+
const titleOf = (id) => nodeTitle(store.getState().nodeLookup.get(id));
|
|
772
|
+
const deleteSelection = (focusedId) => {
|
|
773
|
+
const state = store.getState();
|
|
774
|
+
let nodesToDelete = state.nodes.filter((n) => n.selected && n.deletable !== false);
|
|
775
|
+
const edgesToDelete = state.edges.filter((e) => e.selected && e.deletable !== false);
|
|
776
|
+
if (!nodesToDelete.length && !edgesToDelete.length && focusedId) {
|
|
777
|
+
const focused = state.nodes.find((n) => n.id === focusedId && n.deletable !== false);
|
|
778
|
+
nodesToDelete = focused ? [focused] : [];
|
|
779
|
+
}
|
|
780
|
+
if (!nodesToDelete.length && !edgesToDelete.length) return;
|
|
781
|
+
if (focusedId && nodesToDelete.some((n) => n.id === focusedId)) {
|
|
782
|
+
const gone = new Set(nodesToDelete.map((n) => n.id));
|
|
783
|
+
const i = order.indexOf(focusedId);
|
|
784
|
+
const next = order.slice(i + 1).find((id) => !gone.has(id)) ?? [...order.slice(0, i)].reverse().find((id) => !gone.has(id));
|
|
785
|
+
pendingFocus.current = next ?? null;
|
|
786
|
+
if (next) setActiveId(next);
|
|
787
|
+
}
|
|
788
|
+
void deleteElements({ nodes: nodesToDelete, edges: edgesToDelete }).then(({ deletedNodes, deletedEdges }) => {
|
|
789
|
+
const count = deletedNodes.length + deletedEdges.length;
|
|
790
|
+
if (count) announce(labels.deleted(count));
|
|
791
|
+
});
|
|
792
|
+
};
|
|
793
|
+
const onNodeKeyDown = (e, id) => {
|
|
794
|
+
const direction = arrowDirections[e.key];
|
|
795
|
+
if (direction && !e.altKey && !e.ctrlKey && !e.metaKey) {
|
|
796
|
+
e.preventDefault();
|
|
797
|
+
e.stopPropagation();
|
|
798
|
+
const next = nearestInDirection(boxes(), id, direction);
|
|
799
|
+
if (next) focusNode(next);
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
if ((e.key === "Home" || e.key === "End") && !e.altKey) {
|
|
803
|
+
e.preventDefault();
|
|
804
|
+
e.stopPropagation();
|
|
805
|
+
const target = e.key === "Home" ? order[0] : order[order.length - 1];
|
|
806
|
+
if (target) focusNode(target);
|
|
807
|
+
return;
|
|
808
|
+
}
|
|
809
|
+
if (readOnly) {
|
|
810
|
+
if (direction) e.stopPropagation();
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
813
|
+
if (direction && e.altKey) {
|
|
814
|
+
e.preventDefault();
|
|
815
|
+
e.stopPropagation();
|
|
816
|
+
const state = store.getState();
|
|
817
|
+
const internal = state.nodeLookup.get(id);
|
|
818
|
+
if (!internal) return;
|
|
819
|
+
const draggable = internal.draggable ?? state.nodesDraggable;
|
|
820
|
+
if (!draggable) return;
|
|
821
|
+
const step = (keyboardStep ?? (flowProps.snapToGrid ? flowProps.snapGrid?.[0] : void 0) ?? DEFAULT_STEP) * (e.shiftKey ? 4 : 1);
|
|
822
|
+
const dx = direction === "left" ? -step : direction === "right" ? step : 0;
|
|
823
|
+
const dy = direction === "up" ? -step : direction === "down" ? step : 0;
|
|
824
|
+
const position = { x: internal.position.x + dx, y: internal.position.y + dy };
|
|
825
|
+
state.triggerNodeChanges([{ id, type: "position", position, dragging: false }]);
|
|
826
|
+
announce(labels.moved(nodeTitle(internal), Math.round(position.x), Math.round(position.y)));
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
if ((e.key === "c" || e.key === "C") && !e.altKey && !e.ctrlKey && !e.metaKey && canConnect) {
|
|
830
|
+
const internal = store.getState().nodeLookup.get(id);
|
|
831
|
+
if (internal?.connectable === false) return;
|
|
832
|
+
e.preventDefault();
|
|
833
|
+
e.stopPropagation();
|
|
834
|
+
setConnectFrom(id);
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
if ((e.key === "Delete" || e.key === "Backspace") && ownDelete) {
|
|
838
|
+
e.preventDefault();
|
|
839
|
+
e.stopPropagation();
|
|
840
|
+
deleteSelection(id);
|
|
841
|
+
}
|
|
842
|
+
};
|
|
843
|
+
const onKeyDownCapture = (e) => {
|
|
844
|
+
const target = e.target;
|
|
845
|
+
if (target.closest("[data-diagram-connect-menu]")) return;
|
|
846
|
+
if (target.matches?.(NODE_SELECTOR)) {
|
|
847
|
+
const id = target.getAttribute("data-id");
|
|
848
|
+
if (id) onNodeKeyDown(e, id);
|
|
849
|
+
return;
|
|
850
|
+
}
|
|
851
|
+
if ((e.key === "Delete" || e.key === "Backspace") && ownDelete && target.closest(".react-flow") && !target.closest('input, textarea, [contenteditable="true"]')) {
|
|
852
|
+
e.preventDefault();
|
|
853
|
+
deleteSelection(null);
|
|
854
|
+
}
|
|
855
|
+
};
|
|
856
|
+
const onFocusCapture = (e) => {
|
|
857
|
+
const target = e.target;
|
|
858
|
+
if (target.matches?.(NODE_SELECTOR)) {
|
|
859
|
+
const id = target.getAttribute("data-id");
|
|
860
|
+
if (id && id !== activeId) setActiveId(id);
|
|
861
|
+
}
|
|
862
|
+
};
|
|
863
|
+
const closeConnect = (refocus = true) => {
|
|
864
|
+
const from = connectFrom;
|
|
865
|
+
setConnectFrom(null);
|
|
866
|
+
if (refocus && from) pendingFocus.current = from;
|
|
867
|
+
};
|
|
868
|
+
const pickTarget = (target) => {
|
|
869
|
+
if (!connectFrom) return;
|
|
870
|
+
const connection = { source: connectFrom, target, sourceHandle: null, targetHandle: null };
|
|
871
|
+
if (isValidConnection && !isValidConnection(connection)) return;
|
|
872
|
+
onConnect?.(connection);
|
|
873
|
+
announce(labels.connected(titleOf(connectFrom), titleOf(target)));
|
|
874
|
+
closeConnect();
|
|
875
|
+
};
|
|
876
|
+
const connectOptions = React5.useMemo(() => {
|
|
877
|
+
if (!connectFrom) return [];
|
|
878
|
+
const linked = new Set(storeEdges.filter((e) => e.source === connectFrom).map((e) => e.target));
|
|
879
|
+
const byId = new Map(storeNodes.map((n) => [n.id, n]));
|
|
880
|
+
return order.filter((id) => id !== connectFrom && !linked.has(id)).map((id) => ({ id, title: nodeTitle(byId.get(id)) }));
|
|
881
|
+
}, [connectFrom, storeEdges, storeNodes, order]);
|
|
882
|
+
const context = React5.useMemo(
|
|
883
|
+
() => ({ layout, readOnly, labels, openConnect: canConnect ? (id) => setConnectFrom(id) : void 0 }),
|
|
884
|
+
[layout, readOnly, labels, canConnect]
|
|
885
|
+
);
|
|
886
|
+
const fitOptions = reducedMotion ? { ...fitViewOptions, duration: 0 } : fitViewOptions;
|
|
887
|
+
const hint = readOnly ? labels.nodeHintReadOnly : labels.nodeHint;
|
|
888
|
+
return /* @__PURE__ */ jsx4(DiagramContext.Provider, { value: context, children: /* @__PURE__ */ jsxs4("div", { className: "nx-diagram flex flex-col gap-2", "data-readonly": readOnly ? "" : void 0, "data-layout": layout, children: [
|
|
889
|
+
/* @__PURE__ */ jsxs4("div", { ref: rootRef, className: cx("nx-diagram-canvas relative", className), style, onKeyDownCapture, onFocusCapture, children: [
|
|
890
|
+
/* @__PURE__ */ jsxs4(
|
|
891
|
+
ReactFlow,
|
|
892
|
+
{
|
|
893
|
+
...flowProps,
|
|
894
|
+
"aria-label": ariaLabel,
|
|
895
|
+
nodeTypes: allNodeTypes,
|
|
896
|
+
fitViewOptions: fitOptions,
|
|
897
|
+
onConnect: readOnly ? void 0 : onConnect,
|
|
898
|
+
isValidConnection,
|
|
899
|
+
nodesDraggable: readOnly ? false : nodesDraggable,
|
|
900
|
+
nodesConnectable: readOnly ? false : nodesConnectable,
|
|
901
|
+
elementsSelectable: readOnly ? false : flowProps.elementsSelectable,
|
|
902
|
+
edgesReconnectable: readOnly ? false : flowProps.edgesReconnectable,
|
|
903
|
+
connectOnClick: readOnly ? false : flowProps.connectOnClick,
|
|
904
|
+
deleteKeyCode: readOnly ? null : deleteKeyCode === void 0 ? null : deleteKeyCode,
|
|
905
|
+
ariaLabelConfig: {
|
|
906
|
+
"node.a11yDescription.default": hint,
|
|
907
|
+
"node.a11yDescription.keyboardDisabled": hint,
|
|
908
|
+
"controls.ariaLabel": labels.controls,
|
|
909
|
+
"controls.zoomIn.ariaLabel": labels.zoomIn,
|
|
910
|
+
"controls.zoomOut.ariaLabel": labels.zoomOut,
|
|
911
|
+
"controls.fitView.ariaLabel": labels.fitView,
|
|
912
|
+
"minimap.ariaLabel": labels.minimap,
|
|
913
|
+
...ariaLabelConfig
|
|
914
|
+
},
|
|
915
|
+
children: [
|
|
916
|
+
controls ? /* @__PURE__ */ jsx4(Controls, { showInteractive: false, fitViewOptions: fitOptions }) : null,
|
|
917
|
+
minimap ? /* @__PURE__ */ jsx4(MiniMap, { pannable: true, zoomable: true }) : null,
|
|
918
|
+
children
|
|
919
|
+
]
|
|
920
|
+
}
|
|
921
|
+
),
|
|
922
|
+
connectFrom ? /* @__PURE__ */ jsx4(
|
|
923
|
+
ConnectMenu,
|
|
924
|
+
{
|
|
925
|
+
label: labels.connectTo(titleOf(connectFrom)),
|
|
926
|
+
emptyLabel: labels.noTargets,
|
|
927
|
+
options: connectOptions,
|
|
928
|
+
onPick: pickTarget,
|
|
929
|
+
onClose: closeConnect
|
|
930
|
+
}
|
|
931
|
+
) : null,
|
|
932
|
+
/* @__PURE__ */ jsx4("div", { "aria-live": "polite", "aria-atomic": "true", className: "sr-only", "data-diagram-live": "", children: announcement })
|
|
933
|
+
] }),
|
|
934
|
+
listView ? /* @__PURE__ */ jsx4(DiagramListView, { nodes: storeNodes, edges: storeEdges, order, labels }) : null
|
|
935
|
+
] }) });
|
|
936
|
+
}
|
|
937
|
+
export {
|
|
938
|
+
DEFAULT_NODE_HEIGHT,
|
|
939
|
+
DEFAULT_NODE_WIDTH,
|
|
940
|
+
DiagramCanvas,
|
|
941
|
+
DiagramNode,
|
|
942
|
+
defaultDiagramLabels,
|
|
943
|
+
getNodeSize,
|
|
944
|
+
layoutLayers,
|
|
945
|
+
layoutTree
|
|
946
|
+
};
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! tailwindcss v4.3.5 | MIT License | https://tailwindcss.com */
|
|
2
|
+
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:block))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-border-style:solid;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000}}}@layer theme{:root,:host{--spacing:.25rem}}@layer base{.react-flow{--xy-edge-stroke-default:#b1b1b7;--xy-edge-stroke-width-default:1;--xy-edge-stroke-selected-default:#555;--xy-connectionline-stroke-default:#b1b1b7;--xy-connectionline-stroke-width-default:1;--xy-attribution-background-color-default:#ffffff80;--xy-minimap-background-color-default:#fff;--xy-minimap-mask-background-color-default:#f0f0f099;--xy-minimap-mask-stroke-color-default:transparent;--xy-minimap-mask-stroke-width-default:1;--xy-minimap-node-background-color-default:#e2e2e2;--xy-minimap-node-stroke-color-default:transparent;--xy-minimap-node-stroke-width-default:2;--xy-background-color-default:transparent;--xy-background-pattern-dots-color-default:#91919a;--xy-background-pattern-lines-color-default:#eee;--xy-background-pattern-cross-color-default:#e2e2e2;background-color:var(--xy-background-color,var(--xy-background-color-default));--xy-node-border-default:1px solid #bbb;--xy-node-border-selected-default:1px solid #555;--xy-handle-background-color-default:#333;--xy-selection-background-color-default:#9696b41a;--xy-selection-border-default:1px dotted #9b9b9bcc;--xy-resize-background-color-default:#3367d9;direction:ltr}.react-flow.dark{--xy-edge-stroke-default:#3e3e3e;--xy-edge-stroke-width-default:1;--xy-edge-stroke-selected-default:#727272;--xy-connectionline-stroke-default:#b1b1b7;--xy-connectionline-stroke-width-default:1;--xy-attribution-background-color-default:#96969640;--xy-minimap-background-color-default:#141414;--xy-minimap-mask-background-color-default:#3c3c3c99;--xy-minimap-mask-stroke-color-default:transparent;--xy-minimap-mask-stroke-width-default:1;--xy-minimap-node-background-color-default:#2b2b2b;--xy-minimap-node-stroke-color-default:transparent;--xy-minimap-node-stroke-width-default:2;--xy-background-color-default:#141414;--xy-background-pattern-dots-color-default:#555;--xy-background-pattern-lines-color-default:#333;--xy-background-pattern-cross-color-default:#333;--xy-node-color-default:#f8f8f8}.react-flow__background{background-color:var(--xy-background-color-props,var(--xy-background-color,var(--xy-background-color-default)));pointer-events:none;z-index:-1}.react-flow__container{width:100%;height:100%;position:absolute;top:0;left:0}.react-flow__pane{z-index:1;touch-action:none}.react-flow__pane.draggable{cursor:grab}.react-flow__pane.dragging{cursor:grabbing}.react-flow__pane.selection{cursor:pointer}.react-flow__viewport{transform-origin:0 0;z-index:2;pointer-events:none}.react-flow__renderer{z-index:4}.react-flow__selection{z-index:6}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible{outline:none}.react-flow__edge-path{stroke:var(--xy-edge-stroke,var(--xy-edge-stroke-default));stroke-width:var(--xy-edge-stroke-width,var(--xy-edge-stroke-width-default));fill:none}.react-flow__connection-path{stroke:var(--xy-connectionline-stroke,var(--xy-connectionline-stroke-default));stroke-width:var(--xy-connectionline-stroke-width,var(--xy-connectionline-stroke-width-default));fill:none}.react-flow .react-flow__edges{position:absolute}.react-flow .react-flow__edges svg{pointer-events:none;position:absolute;overflow:visible}.react-flow__edge{pointer-events:visibleStroke}.react-flow__edge.selectable{cursor:pointer}.react-flow__edge.animated path{stroke-dasharray:5;animation:.5s linear infinite dashdraw}.react-flow__edge.animated path.react-flow__edge-interaction{stroke-dasharray:none;animation:none}.react-flow__edge.inactive{pointer-events:none}.react-flow__edge.selected,.react-flow__edge:focus,.react-flow__edge:focus-visible{outline:none}.react-flow__edge.selected .react-flow__edge-path,.react-flow__edge.selectable:focus .react-flow__edge-path,.react-flow__edge.selectable:focus-visible .react-flow__edge-path{stroke:var(--xy-edge-stroke-selected,var(--xy-edge-stroke-selected-default))}.react-flow__edge-textwrapper{pointer-events:all}.react-flow__edge .react-flow__edge-text{pointer-events:none;-webkit-user-select:none;user-select:none}.react-flow__arrowhead polyline{stroke:var(--xy-edge-stroke,var(--xy-edge-stroke-default))}.react-flow__arrowhead polyline.arrowclosed{fill:var(--xy-edge-stroke,var(--xy-edge-stroke-default))}.react-flow__connection{pointer-events:none}.react-flow__connection .animated{stroke-dasharray:5;animation:.5s linear infinite dashdraw}svg.react-flow__connectionline{z-index:1001;position:absolute;overflow:visible}.react-flow__nodes{pointer-events:none;transform-origin:0 0}.react-flow__node{-webkit-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:default;position:absolute}.react-flow__node.selectable{cursor:pointer}.react-flow__node.draggable{cursor:grab;pointer-events:all}.react-flow__node.draggable.dragging{cursor:grabbing}.react-flow__nodesselection{z-index:3;transform-origin:0 0;pointer-events:none}.react-flow__nodesselection-rect{pointer-events:all;cursor:grab;position:absolute}.react-flow__handle{pointer-events:none;background-color:var(--xy-handle-background-color,var(--xy-handle-background-color-default));min-width:5px;min-height:5px;position:absolute}.react-flow__handle.connectingfrom{pointer-events:all}.react-flow__handle.connectionindicator{pointer-events:all;cursor:crosshair}.react-flow__handle-bottom{top:auto;bottom:0;left:50%;transform:translate(-50%,50%)}.react-flow__handle-top{top:0;left:50%;transform:translate(-50%,-50%)}.react-flow__handle-left{top:50%;left:0;transform:translate(-50%,-50%)}.react-flow__handle-right{top:50%;right:0;transform:translate(50%,-50%)}.react-flow__edgeupdater{cursor:move;pointer-events:all}.react-flow__pane.selection .react-flow__panel{pointer-events:none}.react-flow__panel{z-index:5;margin:15px;position:absolute}.react-flow__panel.top{top:0}.react-flow__panel.bottom{bottom:0}.react-flow__panel.top.center,.react-flow__panel.bottom.center{left:50%;transform:translate(-15px)translate(-50%)}.react-flow__panel.left{left:0}.react-flow__panel.right{right:0}.react-flow__panel.left.center,.react-flow__panel.right.center{top:50%;transform:translateY(-15px)translateY(-50%)}.react-flow__attribution{background:var(--xy-attribution-background-color,var(--xy-attribution-background-color-default));margin:0;padding:2px 3px;font-size:10px}.react-flow__attribution a{color:#999;text-decoration:none}@keyframes dashdraw{0%{stroke-dashoffset:10px}}.react-flow__edgelabel-renderer{pointer-events:none;-webkit-user-select:none;user-select:none;width:100%;height:100%;position:absolute;top:0;left:0}.react-flow__viewport-portal{-webkit-user-select:none;user-select:none;width:100%;height:100%;position:absolute;top:0;left:0}.react-flow__minimap{background:var(--xy-minimap-background-color-props,var(--xy-minimap-background-color,var(--xy-minimap-background-color-default)))}.react-flow__minimap-svg{display:block}.react-flow__minimap-mask{fill:var(--xy-minimap-mask-background-color-props,var(--xy-minimap-mask-background-color,var(--xy-minimap-mask-background-color-default)));stroke:var(--xy-minimap-mask-stroke-color-props,var(--xy-minimap-mask-stroke-color,var(--xy-minimap-mask-stroke-color-default)));stroke-width:var(--xy-minimap-mask-stroke-width-props,var(--xy-minimap-mask-stroke-width,var(--xy-minimap-mask-stroke-width-default)))}.react-flow__minimap-node{fill:var(--xy-minimap-node-background-color-props,var(--xy-minimap-node-background-color,var(--xy-minimap-node-background-color-default)));stroke:var(--xy-minimap-node-stroke-color-props,var(--xy-minimap-node-stroke-color,var(--xy-minimap-node-stroke-color-default)));stroke-width:var(--xy-minimap-node-stroke-width-props,var(--xy-minimap-node-stroke-width,var(--xy-minimap-node-stroke-width-default)))}.react-flow__background-pattern.dots{fill:var(--xy-background-pattern-color-props,var(--xy-background-pattern-color,var(--xy-background-pattern-dots-color-default)))}.react-flow__background-pattern.lines{stroke:var(--xy-background-pattern-color-props,var(--xy-background-pattern-color,var(--xy-background-pattern-lines-color-default)))}.react-flow__background-pattern.cross{stroke:var(--xy-background-pattern-color-props,var(--xy-background-pattern-color,var(--xy-background-pattern-cross-color-default)))}.react-flow__controls{flex-direction:column;display:flex}.react-flow__controls.horizontal{flex-direction:row}.react-flow__controls-button{justify-content:center;align-items:center;width:26px;height:26px;padding:4px;display:flex}.react-flow__controls-button svg{fill:currentColor;width:100%;max-width:12px;max-height:12px}.react-flow__node-input,.react-flow__node-default,.react-flow__node-output,.react-flow__node-group{border:var(--xy-node-border,var(--xy-node-border-default));color:var(--xy-node-color,var(--xy-node-color-default))}.react-flow__node-input.selected,.react-flow__node-input:focus,.react-flow__node-input:focus-visible,.react-flow__node-default.selected,.react-flow__node-default:focus,.react-flow__node-default:focus-visible,.react-flow__node-output.selected,.react-flow__node-output:focus,.react-flow__node-output:focus-visible,.react-flow__node-group.selected,.react-flow__node-group:focus,.react-flow__node-group:focus-visible{border:var(--xy-node-border-selected,var(--xy-node-border-selected-default));outline:none}.react-flow__nodesselection-rect,.react-flow__selection{background:var(--xy-selection-background-color,var(--xy-selection-background-color-default));border:var(--xy-selection-border,var(--xy-selection-border-default))}.react-flow__resize-control{position:absolute}.react-flow__resize-control.left,.react-flow__resize-control.right{cursor:ew-resize}.react-flow__resize-control.top,.react-flow__resize-control.bottom{cursor:ns-resize}.react-flow__resize-control.top.left,.react-flow__resize-control.bottom.right{cursor:nwse-resize}.react-flow__resize-control.bottom.left,.react-flow__resize-control.top.right{cursor:nesw-resize}.react-flow__resize-control.handle{background-color:var(--xy-resize-background-color,var(--xy-resize-background-color-default));border:1px solid #fff;border-radius:1px;width:5px;height:5px;translate:-50% -50%}.react-flow__resize-control.handle.left{top:50%;left:0}.react-flow__resize-control.handle.right{top:50%;left:100%}.react-flow__resize-control.handle.top{top:0;left:50%}.react-flow__resize-control.handle.bottom{top:100%;left:50%}.react-flow__resize-control.handle.top.left,.react-flow__resize-control.handle.bottom.left{left:0}.react-flow__resize-control.handle.top.right,.react-flow__resize-control.handle.bottom.right{left:100%}.react-flow__resize-control.line{border-color:var(--xy-resize-background-color,var(--xy-resize-background-color-default));border-style:solid;border-width:0}.react-flow__resize-control.line.left,.react-flow__resize-control.line.right{width:1px;height:100%;top:0;transform:translate(-50%)}.react-flow__resize-control.line.left{border-left-width:1px;left:0}.react-flow__resize-control.line.right{border-right-width:1px;left:100%}.react-flow__resize-control.line.top,.react-flow__resize-control.line.bottom{width:100%;height:1px;left:0;transform:translateY(-50%)}.react-flow__resize-control.line.top{border-top-width:1px;top:0}.react-flow__resize-control.line.bottom{border-bottom-width:1px;top:100%}}@layer components{.nx-diagram-canvas{border:1px solid var(--color-outline-variant);border-radius:var(--shape-container);block-size:24rem;overflow:hidden}.nx-diagram .react-flow{--xy-background-color:var(--color-surface);--xy-background-pattern-color:var(--color-outline-variant);--xy-edge-stroke:var(--color-outline);--xy-edge-stroke-width:1.5;--xy-edge-stroke-selected:var(--color-primary);--xy-connectionline-stroke:var(--color-primary);--xy-connectionline-stroke-width:2;--xy-node-color:var(--color-on-surface);--xy-node-border:1px solid var(--color-outline-variant);--xy-node-border-selected:1px solid var(--color-primary);--xy-handle-background-color:var(--color-outline);--xy-selection-background-color:var(--color-primary)}@supports (color:color-mix(in lab, red, red)){.nx-diagram .react-flow{--xy-selection-background-color:color-mix(in srgb, var(--color-primary) 8%, transparent)}}.nx-diagram .react-flow{--xy-selection-border:1px dashed var(--color-primary);--xy-minimap-background-color:var(--color-surface-container-low);--xy-minimap-mask-background-color:var(--color-scrim)}@supports (color:color-mix(in lab, red, red)){.nx-diagram .react-flow{--xy-minimap-mask-background-color:color-mix(in srgb, var(--color-scrim) 12%, transparent)}}.nx-diagram .react-flow{--xy-minimap-mask-stroke-color:var(--color-outline);--xy-minimap-node-background-color:var(--color-surface-container-highest);--xy-minimap-node-stroke-color:var(--color-outline-variant);--xy-attribution-background-color:var(--color-surface)}@supports (color:color-mix(in lab, red, red)){.nx-diagram .react-flow{--xy-attribution-background-color:color-mix(in srgb, var(--color-surface) 70%, transparent)}}.nx-diagram .react-flow{--xy-resize-background-color:var(--color-primary);color:var(--color-on-surface);font-family:inherit}.nx-diagram .react-flow__edges svg,.nx-diagram svg.react-flow__connectionline{max-width:none;max-height:none}.nx-diagram .react-flow__node-nexub{border-radius:var(--shape-container)}.nx-diagram-node{box-shadow:var(--elevation-1)}.nx-diagram .react-flow__node:focus-visible{outline:3px solid var(--color-ring-default);outline-offset:2px}.nx-diagram .react-flow__node-nexub.selected .nx-diagram-node{box-shadow:0 0 0 2px var(--color-primary), var(--elevation-2)}.nx-diagram .nx-diagram-handle{--nx-handle-dot:.625rem;inline-size:var(--nx-handle-dot);block-size:var(--nx-handle-dot);border:2px solid var(--color-surface);border-radius:var(--shape-full,9999px);background:var(--xy-handle-background-color);min-block-size:0;min-inline-size:0;transition:background-color var(--motion-spring-effects-fast-duration) var(--motion-spring-effects-fast-easing)}.nx-diagram .nx-diagram-handle:after{content:"";inset:calc((var(--nx-handle-dot) - max(var(--spacing-6,1.5rem), 24px)) / 2);border-radius:inherit;position:absolute}.nx-diagram .nx-diagram-handle.connectionindicator:hover,.nx-diagram .nx-diagram-handle.connectingfrom,.nx-diagram .nx-diagram-handle.valid{background:var(--color-primary)}.nx-diagram[data-readonly] .nx-diagram-handle,.nx-diagram[data-layout=mind-map] .react-flow__node:not(:hover,:focus-visible,.selected) .nx-diagram-handle:not(.connectingto,.connectingfrom){opacity:0}.nx-diagram .nx-diagram-connect{opacity:0;pointer-events:none}.nx-diagram .react-flow__node:is(:focus-visible,.selected,:hover) .nx-diagram-connect{opacity:1;pointer-events:all}.nx-diagram .react-flow__edge.selected .react-flow__edge-path,.nx-diagram .react-flow__edge:focus-visible .react-flow__edge-path{stroke-width:2.5px}.nx-diagram .react-flow__edge-text{fill:var(--color-on-surface-variant)}.nx-diagram .react-flow__edge-textbg{fill:var(--color-surface)}.nx-diagram .react-flow__controls{gap:var(--spacing-1,.25rem);padding:var(--spacing-1,.25rem);border-radius:var(--shape-container);background:var(--color-surface-container);box-shadow:var(--elevation-1)}.nx-diagram .react-flow__controls-button{inline-size:max(var(--spacing-8,2rem), 24px);block-size:max(var(--spacing-8,2rem), 24px);padding:var(--spacing-2,.5rem);border-radius:var(--shape-control);color:var(--color-on-surface-variant);cursor:pointer;background:0 0;border:0}.nx-diagram .react-flow__controls-button:hover{background:var(--color-on-surface)}@supports (color:color-mix(in lab, red, red)){.nx-diagram .react-flow__controls-button:hover{background:color-mix(in srgb, var(--color-on-surface) 8%, transparent)}}.nx-diagram .react-flow__controls-button:hover{color:var(--color-on-surface)}.nx-diagram .react-flow__controls-button:disabled{color:var(--color-text-disabled);cursor:default}.nx-diagram .react-flow__controls-button:focus-visible{outline:3px solid var(--color-ring-default);outline-offset:2px}.nx-diagram .react-flow__controls-button svg{max-block-size:.875rem;max-inline-size:.875rem}.nx-diagram .react-flow__minimap{border-radius:var(--shape-container);box-shadow:var(--elevation-1);overflow:hidden}.nx-diagram .react-flow__attribution{font-size:.625rem}.nx-diagram .react-flow__attribution a{color:var(--color-on-surface-variant)}.nx-diagram-menu-list:focus-visible{outline:3px solid var(--color-ring-default);outline-offset:2px}@media (prefers-reduced-motion:reduce){.nx-diagram .react-flow__edge.animated path,.nx-diagram .react-flow__connection .animated{animation:none}.nx-diagram .nx-diagram-handle{transition:none}}}@layer utilities{.visible{visibility:visible}.sr-only{clip-path:inset(50%);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.absolute{position:absolute}.relative{position:relative}.start-3{inset-inline-start:var(--spacing-3)}.end-3{inset-inline-end:var(--spacing-3)}.top-3{top:var(--spacing-3)}.-bottom-3{bottom:calc(var(--spacing-3) * -1)}.z-10{z-index:10}.mt-2{margin-top:var(--spacing-2)}.line-clamp-2{-webkit-line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.flex{display:flex}.grid{display:grid}.hidden{display:none}.inline{display:inline}.inline-flex{display:inline-flex}.size-2{width:var(--spacing-2);height:var(--spacing-2)}.size-3\.5{width:calc(var(--spacing) * 3.5);height:calc(var(--spacing) * 3.5)}.size-6{width:var(--spacing-6);height:var(--spacing-6)}.size-8{width:var(--spacing-8);height:var(--spacing-8)}.max-h-72{max-height:calc(var(--spacing) * 72)}.w-60{width:calc(var(--spacing) * 60)}.w-64{width:var(--spacing-64)}.min-w-0{min-width:var(--spacing-0)}.flex-1{flex:1}.shrink-0{flex-shrink:0}.grow{flex-grow:1}.cursor-pointer{cursor:pointer}.flex-col{flex-direction:column}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-center{justify-content:center}.gap-0\.5{gap:calc(var(--spacing) * .5)}.gap-1{gap:var(--spacing-1)}.gap-2{gap:var(--spacing-2)}.gap-3{gap:var(--spacing-3)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-auto{overflow:auto}.overflow-hidden{overflow:hidden}.rounded-full{border-radius:var(--radius-full)}.rounded-shape-container{border-radius:var(--shape-container)}.rounded-shape-control{border-radius:var(--shape-control)}.rounded-shape-field{border-radius:var(--shape-field)}.border{border-style:var(--tw-border-style);border-width:1px}.border-s-4{border-inline-start-style:var(--tw-border-style);border-inline-start-width:4px}.border-outline-variant{border-color:var(--color-outline-variant)}.border-s-error{border-inline-start-color:var(--color-error)}.border-s-success{border-inline-start-color:var(--color-success)}.border-s-warning{border-inline-start-color:var(--color-warning)}.bg-error{background-color:var(--color-error)}.bg-error-container{background-color:var(--color-error-container)}.bg-secondary-container{background-color:var(--color-secondary-container)}.bg-success{background-color:var(--color-success)}.bg-success-container{background-color:var(--color-success-container)}.bg-surface{background-color:var(--color-surface)}.bg-surface-container{background-color:var(--color-surface-container)}.bg-surface-container-high{background-color:var(--color-surface-container-high)}.bg-surface-container-low{background-color:var(--color-surface-container-low)}.bg-warning{background-color:var(--color-warning)}.bg-warning-container{background-color:var(--color-warning-container)}.p-2{padding:var(--spacing-2)}.px-2{padding-inline:var(--spacing-2)}.px-4{padding-inline:var(--spacing-4)}.py-1{padding-block:var(--spacing-1)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-3{padding-block:var(--spacing-3)}.ps-2{padding-inline-start:var(--spacing-2)}.ps-4{padding-inline-start:var(--spacing-4)}.text-start{text-align:start}.text-body-md{font-size:var(--type-body-md-size);line-height:var(--tw-leading,var(--type-body-md-lineHeight));letter-spacing:var(--tw-tracking,var(--type-body-md-letterSpacing));font-weight:var(--tw-font-weight,var(--type-body-md-weight))}.text-body-sm{font-size:var(--type-body-sm-size);line-height:var(--tw-leading,var(--type-body-sm-lineHeight));letter-spacing:var(--tw-tracking,var(--type-body-sm-letterSpacing));font-weight:var(--tw-font-weight,var(--type-body-sm-weight))}.text-label-lg{font-size:var(--type-label-lg-size);line-height:var(--tw-leading,var(--type-label-lg-lineHeight));letter-spacing:var(--tw-tracking,var(--type-label-lg-letterSpacing));font-weight:var(--tw-font-weight,var(--type-label-lg-weight))}.text-label-md{font-size:var(--type-label-md-size);line-height:var(--tw-leading,var(--type-label-md-lineHeight));letter-spacing:var(--tw-tracking,var(--type-label-md-letterSpacing));font-weight:var(--tw-font-weight,var(--type-label-md-weight))}.text-title-sm{font-size:var(--type-title-sm-size);line-height:var(--tw-leading,var(--type-title-sm-lineHeight));letter-spacing:var(--tw-tracking,var(--type-title-sm-letterSpacing));font-weight:var(--tw-font-weight,var(--type-title-sm-weight))}.text-on-error-container{color:var(--color-on-error-container)}.text-on-secondary-container{color:var(--color-on-secondary-container)}.text-on-success-container{color:var(--color-on-success-container)}.text-on-surface{color:var(--color-on-surface)}.text-on-surface-variant{color:var(--color-on-surface-variant)}.text-on-warning-container{color:var(--color-on-warning-container)}.text-primary{color:var(--color-primary)}.shadow-elevation-2{--tw-shadow:var(--elevation-2);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.ring{--tw-ring-shadow:var(--tw-ring-inset, ) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.select-none{-webkit-user-select:none;user-select:none}@media (forced-colors:active){.nx-diagram .react-flow{--xy-edge-stroke:CanvasText;--xy-edge-stroke-selected:Highlight;--xy-connectionline-stroke:Highlight;--xy-handle-background-color:ButtonText;--xy-minimap-node-background-color:Canvas;--xy-minimap-node-stroke-color:CanvasText;--xy-minimap-mask-stroke-color:Highlight}.nx-diagram .react-flow__edge-path,.nx-diagram .react-flow__connection-path,.nx-diagram .react-flow__arrowhead polyline{forced-color-adjust:none}.nx-diagram .nx-diagram-node{border-color:canvastext}.nx-diagram .react-flow__node-nexub.selected .nx-diagram-node{box-shadow:none;border-color:highlight;outline:2px solid highlight}.nx-diagram .nx-diagram-node[data-tone=warning]{border-inline-start-style:dashed}.nx-diagram .nx-diagram-node[data-tone=danger]{border-inline-start-style:double;border-inline-start-width:6px}.nx-diagram .nx-diagram-handle{forced-color-adjust:none;background:buttontext;border-color:canvas}.nx-diagram .react-flow__node:focus-visible,.nx-diagram .react-flow__controls-button:focus-visible,.nx-diagram-menu-list:focus-visible{outline-color:highlight}.nx-diagram .react-flow__controls-button{border:1px solid buttontext}.nx-diagram .nx-diagram-menu [aria-selected=true]{forced-color-adjust:none;color:highlighttext;background:highlight}}}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}
|
package/dist/theme.css
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! tailwindcss v4.3.5 | MIT License | https://tailwindcss.com */
|
|
2
|
+
@layer theme;@layer base{.react-flow{--xy-edge-stroke-default:#b1b1b7;--xy-edge-stroke-width-default:1;--xy-edge-stroke-selected-default:#555;--xy-connectionline-stroke-default:#b1b1b7;--xy-connectionline-stroke-width-default:1;--xy-attribution-background-color-default:#ffffff80;--xy-minimap-background-color-default:#fff;--xy-minimap-mask-background-color-default:#f0f0f099;--xy-minimap-mask-stroke-color-default:transparent;--xy-minimap-mask-stroke-width-default:1;--xy-minimap-node-background-color-default:#e2e2e2;--xy-minimap-node-stroke-color-default:transparent;--xy-minimap-node-stroke-width-default:2;--xy-background-color-default:transparent;--xy-background-pattern-dots-color-default:#91919a;--xy-background-pattern-lines-color-default:#eee;--xy-background-pattern-cross-color-default:#e2e2e2;background-color:var(--xy-background-color,var(--xy-background-color-default));--xy-node-border-default:1px solid #bbb;--xy-node-border-selected-default:1px solid #555;--xy-handle-background-color-default:#333;--xy-selection-background-color-default:#9696b41a;--xy-selection-border-default:1px dotted #9b9b9bcc;--xy-resize-background-color-default:#3367d9;direction:ltr}.react-flow.dark{--xy-edge-stroke-default:#3e3e3e;--xy-edge-stroke-width-default:1;--xy-edge-stroke-selected-default:#727272;--xy-connectionline-stroke-default:#b1b1b7;--xy-connectionline-stroke-width-default:1;--xy-attribution-background-color-default:#96969640;--xy-minimap-background-color-default:#141414;--xy-minimap-mask-background-color-default:#3c3c3c99;--xy-minimap-mask-stroke-color-default:transparent;--xy-minimap-mask-stroke-width-default:1;--xy-minimap-node-background-color-default:#2b2b2b;--xy-minimap-node-stroke-color-default:transparent;--xy-minimap-node-stroke-width-default:2;--xy-background-color-default:#141414;--xy-background-pattern-dots-color-default:#555;--xy-background-pattern-lines-color-default:#333;--xy-background-pattern-cross-color-default:#333;--xy-node-color-default:#f8f8f8}.react-flow__background{background-color:var(--xy-background-color-props,var(--xy-background-color,var(--xy-background-color-default)));pointer-events:none;z-index:-1}.react-flow__container{width:100%;height:100%;position:absolute;top:0;left:0}.react-flow__pane{z-index:1;touch-action:none}.react-flow__pane.draggable{cursor:grab}.react-flow__pane.dragging{cursor:grabbing}.react-flow__pane.selection{cursor:pointer}.react-flow__viewport{transform-origin:0 0;z-index:2;pointer-events:none}.react-flow__renderer{z-index:4}.react-flow__selection{z-index:6}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible{outline:none}.react-flow__edge-path{stroke:var(--xy-edge-stroke,var(--xy-edge-stroke-default));stroke-width:var(--xy-edge-stroke-width,var(--xy-edge-stroke-width-default));fill:none}.react-flow__connection-path{stroke:var(--xy-connectionline-stroke,var(--xy-connectionline-stroke-default));stroke-width:var(--xy-connectionline-stroke-width,var(--xy-connectionline-stroke-width-default));fill:none}.react-flow .react-flow__edges{position:absolute}.react-flow .react-flow__edges svg{pointer-events:none;position:absolute;overflow:visible}.react-flow__edge{pointer-events:visibleStroke}.react-flow__edge.selectable{cursor:pointer}.react-flow__edge.animated path{stroke-dasharray:5;animation:.5s linear infinite dashdraw}.react-flow__edge.animated path.react-flow__edge-interaction{stroke-dasharray:none;animation:none}.react-flow__edge.inactive{pointer-events:none}.react-flow__edge.selected,.react-flow__edge:focus,.react-flow__edge:focus-visible{outline:none}.react-flow__edge.selected .react-flow__edge-path,.react-flow__edge.selectable:focus .react-flow__edge-path,.react-flow__edge.selectable:focus-visible .react-flow__edge-path{stroke:var(--xy-edge-stroke-selected,var(--xy-edge-stroke-selected-default))}.react-flow__edge-textwrapper{pointer-events:all}.react-flow__edge .react-flow__edge-text{pointer-events:none;-webkit-user-select:none;user-select:none}.react-flow__arrowhead polyline{stroke:var(--xy-edge-stroke,var(--xy-edge-stroke-default))}.react-flow__arrowhead polyline.arrowclosed{fill:var(--xy-edge-stroke,var(--xy-edge-stroke-default))}.react-flow__connection{pointer-events:none}.react-flow__connection .animated{stroke-dasharray:5;animation:.5s linear infinite dashdraw}svg.react-flow__connectionline{z-index:1001;position:absolute;overflow:visible}.react-flow__nodes{pointer-events:none;transform-origin:0 0}.react-flow__node{-webkit-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:default;position:absolute}.react-flow__node.selectable{cursor:pointer}.react-flow__node.draggable{cursor:grab;pointer-events:all}.react-flow__node.draggable.dragging{cursor:grabbing}.react-flow__nodesselection{z-index:3;transform-origin:0 0;pointer-events:none}.react-flow__nodesselection-rect{pointer-events:all;cursor:grab;position:absolute}.react-flow__handle{pointer-events:none;background-color:var(--xy-handle-background-color,var(--xy-handle-background-color-default));min-width:5px;min-height:5px;position:absolute}.react-flow__handle.connectingfrom{pointer-events:all}.react-flow__handle.connectionindicator{pointer-events:all;cursor:crosshair}.react-flow__handle-bottom{top:auto;bottom:0;left:50%;transform:translate(-50%,50%)}.react-flow__handle-top{top:0;left:50%;transform:translate(-50%,-50%)}.react-flow__handle-left{top:50%;left:0;transform:translate(-50%,-50%)}.react-flow__handle-right{top:50%;right:0;transform:translate(50%,-50%)}.react-flow__edgeupdater{cursor:move;pointer-events:all}.react-flow__pane.selection .react-flow__panel{pointer-events:none}.react-flow__panel{z-index:5;margin:15px;position:absolute}.react-flow__panel.top{top:0}.react-flow__panel.bottom{bottom:0}.react-flow__panel.top.center,.react-flow__panel.bottom.center{left:50%;transform:translate(-15px)translate(-50%)}.react-flow__panel.left{left:0}.react-flow__panel.right{right:0}.react-flow__panel.left.center,.react-flow__panel.right.center{top:50%;transform:translateY(-15px)translateY(-50%)}.react-flow__attribution{background:var(--xy-attribution-background-color,var(--xy-attribution-background-color-default));margin:0;padding:2px 3px;font-size:10px}.react-flow__attribution a{color:#999;text-decoration:none}@keyframes dashdraw{0%{stroke-dashoffset:10px}}.react-flow__edgelabel-renderer{pointer-events:none;-webkit-user-select:none;user-select:none;width:100%;height:100%;position:absolute;top:0;left:0}.react-flow__viewport-portal{-webkit-user-select:none;user-select:none;width:100%;height:100%;position:absolute;top:0;left:0}.react-flow__minimap{background:var(--xy-minimap-background-color-props,var(--xy-minimap-background-color,var(--xy-minimap-background-color-default)))}.react-flow__minimap-svg{display:block}.react-flow__minimap-mask{fill:var(--xy-minimap-mask-background-color-props,var(--xy-minimap-mask-background-color,var(--xy-minimap-mask-background-color-default)));stroke:var(--xy-minimap-mask-stroke-color-props,var(--xy-minimap-mask-stroke-color,var(--xy-minimap-mask-stroke-color-default)));stroke-width:var(--xy-minimap-mask-stroke-width-props,var(--xy-minimap-mask-stroke-width,var(--xy-minimap-mask-stroke-width-default)))}.react-flow__minimap-node{fill:var(--xy-minimap-node-background-color-props,var(--xy-minimap-node-background-color,var(--xy-minimap-node-background-color-default)));stroke:var(--xy-minimap-node-stroke-color-props,var(--xy-minimap-node-stroke-color,var(--xy-minimap-node-stroke-color-default)));stroke-width:var(--xy-minimap-node-stroke-width-props,var(--xy-minimap-node-stroke-width,var(--xy-minimap-node-stroke-width-default)))}.react-flow__background-pattern.dots{fill:var(--xy-background-pattern-color-props,var(--xy-background-pattern-color,var(--xy-background-pattern-dots-color-default)))}.react-flow__background-pattern.lines{stroke:var(--xy-background-pattern-color-props,var(--xy-background-pattern-color,var(--xy-background-pattern-lines-color-default)))}.react-flow__background-pattern.cross{stroke:var(--xy-background-pattern-color-props,var(--xy-background-pattern-color,var(--xy-background-pattern-cross-color-default)))}.react-flow__controls{flex-direction:column;display:flex}.react-flow__controls.horizontal{flex-direction:row}.react-flow__controls-button{justify-content:center;align-items:center;width:26px;height:26px;padding:4px;display:flex}.react-flow__controls-button svg{fill:currentColor;width:100%;max-width:12px;max-height:12px}.react-flow__node-input,.react-flow__node-default,.react-flow__node-output,.react-flow__node-group{border:var(--xy-node-border,var(--xy-node-border-default));color:var(--xy-node-color,var(--xy-node-color-default))}.react-flow__node-input.selected,.react-flow__node-input:focus,.react-flow__node-input:focus-visible,.react-flow__node-default.selected,.react-flow__node-default:focus,.react-flow__node-default:focus-visible,.react-flow__node-output.selected,.react-flow__node-output:focus,.react-flow__node-output:focus-visible,.react-flow__node-group.selected,.react-flow__node-group:focus,.react-flow__node-group:focus-visible{border:var(--xy-node-border-selected,var(--xy-node-border-selected-default));outline:none}.react-flow__nodesselection-rect,.react-flow__selection{background:var(--xy-selection-background-color,var(--xy-selection-background-color-default));border:var(--xy-selection-border,var(--xy-selection-border-default))}.react-flow__resize-control{position:absolute}.react-flow__resize-control.left,.react-flow__resize-control.right{cursor:ew-resize}.react-flow__resize-control.top,.react-flow__resize-control.bottom{cursor:ns-resize}.react-flow__resize-control.top.left,.react-flow__resize-control.bottom.right{cursor:nwse-resize}.react-flow__resize-control.bottom.left,.react-flow__resize-control.top.right{cursor:nesw-resize}.react-flow__resize-control.handle{background-color:var(--xy-resize-background-color,var(--xy-resize-background-color-default));border:1px solid #fff;border-radius:1px;width:5px;height:5px;translate:-50% -50%}.react-flow__resize-control.handle.left{top:50%;left:0}.react-flow__resize-control.handle.right{top:50%;left:100%}.react-flow__resize-control.handle.top{top:0;left:50%}.react-flow__resize-control.handle.bottom{top:100%;left:50%}.react-flow__resize-control.handle.top.left,.react-flow__resize-control.handle.bottom.left{left:0}.react-flow__resize-control.handle.top.right,.react-flow__resize-control.handle.bottom.right{left:100%}.react-flow__resize-control.line{border-color:var(--xy-resize-background-color,var(--xy-resize-background-color-default));border-style:solid;border-width:0}.react-flow__resize-control.line.left,.react-flow__resize-control.line.right{width:1px;height:100%;top:0;transform:translate(-50%)}.react-flow__resize-control.line.left{border-left-width:1px;left:0}.react-flow__resize-control.line.right{border-right-width:1px;left:100%}.react-flow__resize-control.line.top,.react-flow__resize-control.line.bottom{width:100%;height:1px;left:0;transform:translateY(-50%)}.react-flow__resize-control.line.top{border-top-width:1px;top:0}.react-flow__resize-control.line.bottom{border-bottom-width:1px;top:100%}}@layer components{.nx-diagram-canvas{border:1px solid var(--color-outline-variant);border-radius:var(--shape-container);block-size:24rem;overflow:hidden}.nx-diagram .react-flow{--xy-background-color:var(--color-surface);--xy-background-pattern-color:var(--color-outline-variant);--xy-edge-stroke:var(--color-outline);--xy-edge-stroke-width:1.5;--xy-edge-stroke-selected:var(--color-primary);--xy-connectionline-stroke:var(--color-primary);--xy-connectionline-stroke-width:2;--xy-node-color:var(--color-on-surface);--xy-node-border:1px solid var(--color-outline-variant);--xy-node-border-selected:1px solid var(--color-primary);--xy-handle-background-color:var(--color-outline);--xy-selection-background-color:var(--color-primary)}@supports (color:color-mix(in lab, red, red)){.nx-diagram .react-flow{--xy-selection-background-color:color-mix(in srgb, var(--color-primary) 8%, transparent)}}.nx-diagram .react-flow{--xy-selection-border:1px dashed var(--color-primary);--xy-minimap-background-color:var(--color-surface-container-low);--xy-minimap-mask-background-color:var(--color-scrim)}@supports (color:color-mix(in lab, red, red)){.nx-diagram .react-flow{--xy-minimap-mask-background-color:color-mix(in srgb, var(--color-scrim) 12%, transparent)}}.nx-diagram .react-flow{--xy-minimap-mask-stroke-color:var(--color-outline);--xy-minimap-node-background-color:var(--color-surface-container-highest);--xy-minimap-node-stroke-color:var(--color-outline-variant);--xy-attribution-background-color:var(--color-surface)}@supports (color:color-mix(in lab, red, red)){.nx-diagram .react-flow{--xy-attribution-background-color:color-mix(in srgb, var(--color-surface) 70%, transparent)}}.nx-diagram .react-flow{--xy-resize-background-color:var(--color-primary);color:var(--color-on-surface);font-family:inherit}.nx-diagram .react-flow__edges svg,.nx-diagram svg.react-flow__connectionline{max-width:none;max-height:none}.nx-diagram .react-flow__node-nexub{border-radius:var(--shape-container)}.nx-diagram-node{box-shadow:var(--elevation-1)}.nx-diagram .react-flow__node:focus-visible{outline:3px solid var(--color-ring-default);outline-offset:2px}.nx-diagram .react-flow__node-nexub.selected .nx-diagram-node{box-shadow:0 0 0 2px var(--color-primary), var(--elevation-2)}.nx-diagram .nx-diagram-handle{--nx-handle-dot:.625rem;inline-size:var(--nx-handle-dot);block-size:var(--nx-handle-dot);border:2px solid var(--color-surface);border-radius:var(--shape-full,9999px);background:var(--xy-handle-background-color);min-block-size:0;min-inline-size:0;transition:background-color var(--motion-spring-effects-fast-duration) var(--motion-spring-effects-fast-easing)}.nx-diagram .nx-diagram-handle:after{content:"";inset:calc((var(--nx-handle-dot) - max(var(--spacing-6,1.5rem), 24px)) / 2);border-radius:inherit;position:absolute}.nx-diagram .nx-diagram-handle.connectionindicator:hover,.nx-diagram .nx-diagram-handle.connectingfrom,.nx-diagram .nx-diagram-handle.valid{background:var(--color-primary)}.nx-diagram[data-readonly] .nx-diagram-handle,.nx-diagram[data-layout=mind-map] .react-flow__node:not(:hover,:focus-visible,.selected) .nx-diagram-handle:not(.connectingto,.connectingfrom){opacity:0}.nx-diagram .nx-diagram-connect{opacity:0;pointer-events:none}.nx-diagram .react-flow__node:is(:focus-visible,.selected,:hover) .nx-diagram-connect{opacity:1;pointer-events:all}.nx-diagram .react-flow__edge.selected .react-flow__edge-path,.nx-diagram .react-flow__edge:focus-visible .react-flow__edge-path{stroke-width:2.5px}.nx-diagram .react-flow__edge-text{fill:var(--color-on-surface-variant)}.nx-diagram .react-flow__edge-textbg{fill:var(--color-surface)}.nx-diagram .react-flow__controls{gap:var(--spacing-1,.25rem);padding:var(--spacing-1,.25rem);border-radius:var(--shape-container);background:var(--color-surface-container);box-shadow:var(--elevation-1)}.nx-diagram .react-flow__controls-button{inline-size:max(var(--spacing-8,2rem), 24px);block-size:max(var(--spacing-8,2rem), 24px);padding:var(--spacing-2,.5rem);border-radius:var(--shape-control);color:var(--color-on-surface-variant);cursor:pointer;background:0 0;border:0}.nx-diagram .react-flow__controls-button:hover{background:var(--color-on-surface)}@supports (color:color-mix(in lab, red, red)){.nx-diagram .react-flow__controls-button:hover{background:color-mix(in srgb, var(--color-on-surface) 8%, transparent)}}.nx-diagram .react-flow__controls-button:hover{color:var(--color-on-surface)}.nx-diagram .react-flow__controls-button:disabled{color:var(--color-text-disabled);cursor:default}.nx-diagram .react-flow__controls-button:focus-visible{outline:3px solid var(--color-ring-default);outline-offset:2px}.nx-diagram .react-flow__controls-button svg{max-block-size:.875rem;max-inline-size:.875rem}.nx-diagram .react-flow__minimap{border-radius:var(--shape-container);box-shadow:var(--elevation-1);overflow:hidden}.nx-diagram .react-flow__attribution{font-size:.625rem}.nx-diagram .react-flow__attribution a{color:var(--color-on-surface-variant)}.nx-diagram-menu-list:focus-visible{outline:3px solid var(--color-ring-default);outline-offset:2px}@media (prefers-reduced-motion:reduce){.nx-diagram .react-flow__edge.animated path,.nx-diagram .react-flow__connection .animated{animation:none}.nx-diagram .nx-diagram-handle{transition:none}}}@layer utilities{@media (forced-colors:active){.nx-diagram .react-flow{--xy-edge-stroke:CanvasText;--xy-edge-stroke-selected:Highlight;--xy-connectionline-stroke:Highlight;--xy-handle-background-color:ButtonText;--xy-minimap-node-background-color:Canvas;--xy-minimap-node-stroke-color:CanvasText;--xy-minimap-mask-stroke-color:Highlight}.nx-diagram .react-flow__edge-path,.nx-diagram .react-flow__connection-path,.nx-diagram .react-flow__arrowhead polyline{forced-color-adjust:none}.nx-diagram .nx-diagram-node{border-color:canvastext}.nx-diagram .react-flow__node-nexub.selected .nx-diagram-node{box-shadow:none;border-color:highlight;outline:2px solid highlight}.nx-diagram .nx-diagram-node[data-tone=warning]{border-inline-start-style:dashed}.nx-diagram .nx-diagram-node[data-tone=danger]{border-inline-start-style:double;border-inline-start-width:6px}.nx-diagram .nx-diagram-handle{forced-color-adjust:none;background:buttontext;border-color:canvas}.nx-diagram .react-flow__node:focus-visible,.nx-diagram .react-flow__controls-button:focus-visible,.nx-diagram-menu-list:focus-visible{outline-color:highlight}.nx-diagram .react-flow__controls-button{border:1px solid buttontext}.nx-diagram .nx-diagram-menu [aria-selected=true]{forced-color-adjust:none;color:highlighttext;background:highlight}}}
|
package/package.json
CHANGED
|
@@ -1 +1,72 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"name": "@nexub/diagram",
|
|
3
|
+
"version": "11.6.0",
|
|
4
|
+
"description": "Themed, keyboard-accessible diagram canvas for Nexub Design System, on React Flow (@xyflow/react, a peer dependency).",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"homepage": "https://github.com/Nexub-AI/nexub-ds#readme",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "https://github.com/Nexub-AI/nexub-ds.git",
|
|
11
|
+
"directory": "packages/diagram"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"react",
|
|
15
|
+
"diagram",
|
|
16
|
+
"react-flow",
|
|
17
|
+
"design-system",
|
|
18
|
+
"nexub"
|
|
19
|
+
],
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"sideEffects": [
|
|
27
|
+
"*.css"
|
|
28
|
+
],
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"default": "./dist/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./styles.css": "./dist/styles.css",
|
|
35
|
+
"./theme.css": "./dist/theme.css",
|
|
36
|
+
"./package.json": "./package.json"
|
|
37
|
+
},
|
|
38
|
+
"main": "./dist/index.js",
|
|
39
|
+
"types": "./dist/index.d.ts",
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@nexub/react": "^11.6.0",
|
|
42
|
+
"@xyflow/react": "^12.10.0",
|
|
43
|
+
"react": ">=19 <20",
|
|
44
|
+
"react-dom": ">=19 <20"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@nexub/react": "11.6.0",
|
|
48
|
+
"@nexub/tokens": "11.6.0",
|
|
49
|
+
"@tailwindcss/cli": "^4.3.5",
|
|
50
|
+
"@testing-library/jest-dom": "^7.0.1",
|
|
51
|
+
"@testing-library/react": "^16.3.3",
|
|
52
|
+
"@testing-library/user-event": "^14.6.8",
|
|
53
|
+
"@types/react": "^19.3.0",
|
|
54
|
+
"@types/react-dom": "^19.3.0",
|
|
55
|
+
"@vitest/coverage-v8": "5.1.0",
|
|
56
|
+
"@xyflow/react": "^12.12.1",
|
|
57
|
+
"jsdom": "^31.0.0",
|
|
58
|
+
"tailwindcss": "^4.3.5",
|
|
59
|
+
"tsup": "^9.0.0",
|
|
60
|
+
"typescript": "~6.0.3",
|
|
61
|
+
"vite": "^8.3.6",
|
|
62
|
+
"vitest": "^5.1.0"
|
|
63
|
+
},
|
|
64
|
+
"scripts": {
|
|
65
|
+
"build": "tsup && tailwindcss -i src/styles.css -o dist/styles.css --minify && tailwindcss -i src/theme.css -o dist/theme.css --minify",
|
|
66
|
+
"dev": "tsup --watch",
|
|
67
|
+
"clean": "rm -rf dist",
|
|
68
|
+
"typecheck": "tsc --noEmit",
|
|
69
|
+
"test": "vitest run --coverage",
|
|
70
|
+
"lint": "eslint src"
|
|
71
|
+
}
|
|
72
|
+
}
|