@fragiola/flow 0.0.0-stage → 0.0.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/README.md +12 -2
- package/dist/connect-session-nyEp02_P.js +375 -0
- package/dist/connect-session-nyEp02_P.js.map +1 -0
- package/dist/connection.d.ts +31 -0
- package/dist/connection.js +60 -0
- package/dist/connection.js.map +1 -0
- package/dist/core-queries-BPNbcM6k.js +452 -0
- package/dist/core-queries-BPNbcM6k.js.map +1 -0
- package/dist/document-schema-CPK5xkyO.js +369 -0
- package/dist/document-schema-CPK5xkyO.js.map +1 -0
- package/dist/drag.d.ts +19 -0
- package/dist/drag.js +175 -0
- package/dist/drag.js.map +1 -0
- package/dist/index.d.ts +876 -0
- package/dist/index.js +5711 -0
- package/dist/index.js.map +1 -0
- package/dist/keyboard-links-CVaTtlZg.js +8 -0
- package/dist/keyboard-links-CVaTtlZg.js.map +1 -0
- package/dist/keyboard.d.ts +40 -0
- package/dist/keyboard.js +342 -0
- package/dist/keyboard.js.map +1 -0
- package/dist/minimap.d.ts +26 -0
- package/dist/minimap.js +206 -0
- package/dist/minimap.js.map +1 -0
- package/dist/node-moves-DyWe-4dj.js +36 -0
- package/dist/node-moves-DyWe-4dj.js.map +1 -0
- package/dist/part-attributes-DuBltA__.js +71 -0
- package/dist/part-attributes-DuBltA__.js.map +1 -0
- package/dist/path-format-2OU7Eiyy.js +43 -0
- package/dist/path-format-2OU7Eiyy.js.map +1 -0
- package/dist/reconnection.d.ts +15 -0
- package/dist/reconnection.js +138 -0
- package/dist/reconnection.js.map +1 -0
- package/dist/rect-CmoREaR6.js +92 -0
- package/dist/rect-CmoREaR6.js.map +1 -0
- package/dist/resize.d.ts +33 -0
- package/dist/resize.js +316 -0
- package/dist/resize.js.map +1 -0
- package/dist/rules-DLOMrPBG.js +102 -0
- package/dist/rules-DLOMrPBG.js.map +1 -0
- package/dist/selection.d.ts +38 -0
- package/dist/selection.js +392 -0
- package/dist/selection.js.map +1 -0
- package/dist/subflows.d.ts +9 -0
- package/dist/subflows.js +237 -0
- package/dist/subflows.js.map +1 -0
- package/dist/types-CLHcZVCb.d.ts +2660 -0
- package/dist/viewport-math-B-9Pn2kN.js +69 -0
- package/dist/viewport-math-B-9Pn2kN.js.map +1 -0
- package/package.json +93 -3
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { f as FlowFeature } from "./types-CLHcZVCb.js";
|
|
2
|
+
/** How a box selection takes nodes: those it touches (`"partial"`) or those it holds whole (`"full"`). */
|
|
3
|
+
type BoxSelectionMode = "partial" | "full";
|
|
4
|
+
/**
|
|
5
|
+
* When the rectangle around the selected nodes (`selection-rect`, the `nodes-selection` part)
|
|
6
|
+
* shows: after a box selected two or more nodes, until the selection changes otherwise (`"box"`),
|
|
7
|
+
* or whenever two or more nodes are selected (`"always"`).
|
|
8
|
+
*/
|
|
9
|
+
type SelectionRectMode = "box" | "always";
|
|
10
|
+
/**
|
|
11
|
+
* A key a gesture reads while it is held (`KeyboardEvent.key` or `.code`; `Meta`, `Control`, `Alt`
|
|
12
|
+
* and `Shift` from the pointer event's flags), several (any of them), or `null` for none.
|
|
13
|
+
*/
|
|
14
|
+
type SelectionKey = string | readonly string[] | null;
|
|
15
|
+
/** Options of {@link selection}: read by its engine side. */
|
|
16
|
+
interface SelectionOptions {
|
|
17
|
+
/** how a box selection takes nodes; default `"full"` */
|
|
18
|
+
readonly boxMode: BoxSelectionMode;
|
|
19
|
+
/** whether a click with the multi-selection key adds to the selection; default true */
|
|
20
|
+
readonly multiple: boolean;
|
|
21
|
+
/** whether any drag on the pane draws a selection box (instead of panning); default false: the box key + drag */
|
|
22
|
+
readonly boxOnDrag: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* the key that, held, makes a click toggle a node or an edge in the selection; default
|
|
25
|
+
* `["Meta", "Control", "Shift"]`; `null` for none
|
|
26
|
+
*/
|
|
27
|
+
readonly multiKey: SelectionKey;
|
|
28
|
+
/** the key that, held, makes a drag on the pane draw a selection box; default `"Shift"`; `null` for none */
|
|
29
|
+
readonly boxKey: SelectionKey;
|
|
30
|
+
/** when the rectangle around the selected nodes shows (`selection-rect`); default `"box"` */
|
|
31
|
+
readonly rect: SelectionRectMode;
|
|
32
|
+
}
|
|
33
|
+
/** The selection feature, as `selection()` makes it. */
|
|
34
|
+
type SelectionFeature = FlowFeature<"selection", SelectionOptions>;
|
|
35
|
+
/** Selecting nodes and edges: `features: [selection()]` (`@fragiola/flow/selection`). */
|
|
36
|
+
export declare function selection(options?: Partial<SelectionOptions>): SelectionFeature;
|
|
37
|
+
export type { BoxSelectionMode, SelectionFeature, SelectionKey, SelectionOptions, SelectionRectMode };
|
|
38
|
+
//# sourceMappingURL=selection.d.ts.map
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import { a as removalOf, c as nodeFlag, d as fail, o as removeAll, p as ok, s as edgeFlag, u as defineCommand } from "./rules-DLOMrPBG.js";
|
|
2
|
+
import { r as stringOf } from "./core-queries-BPNbcM6k.js";
|
|
3
|
+
import { f as flag } from "./part-attributes-DuBltA__.js";
|
|
4
|
+
import { n as contains, o as overlaps, s as rectFromCorners, t as boundsOf } from "./rect-CmoREaR6.js";
|
|
5
|
+
import { a as toScreen } from "./viewport-math-B-9Pn2kN.js";
|
|
6
|
+
// src/selection/commands.ts
|
|
7
|
+
const ids = (description) => ({
|
|
8
|
+
type: "array",
|
|
9
|
+
items: {
|
|
10
|
+
type: "string",
|
|
11
|
+
minLength: 1
|
|
12
|
+
},
|
|
13
|
+
description
|
|
14
|
+
});
|
|
15
|
+
const selectionResult = {
|
|
16
|
+
type: "object",
|
|
17
|
+
properties: {
|
|
18
|
+
nodeIds: ids("the nodes, in drawing order"),
|
|
19
|
+
edgeIds: ids("the edges, in drawing order")
|
|
20
|
+
},
|
|
21
|
+
required: ["nodeIds", "edgeIds"],
|
|
22
|
+
additionalProperties: false
|
|
23
|
+
};
|
|
24
|
+
/** An entity with its `selected` field set (removed when false). */
|
|
25
|
+
function withSelected(entity, selected) {
|
|
26
|
+
if (entity.selected === true === selected) return entity;
|
|
27
|
+
const { selected: _was, ...rest } = entity;
|
|
28
|
+
return selected ? {
|
|
29
|
+
...rest,
|
|
30
|
+
selected: true
|
|
31
|
+
} : rest;
|
|
32
|
+
}
|
|
33
|
+
/** The selected node and edge ids of a draft, in drawing order. */
|
|
34
|
+
function selectedIds(draft) {
|
|
35
|
+
return {
|
|
36
|
+
nodeIds: draft.nodes().filter((node) => node.selected === true).map((node) => node.id),
|
|
37
|
+
edgeIds: draft.edges().filter((edge) => edge.selected === true).map((edge) => edge.id)
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/** Sets the selection of every node and edge by `selected`, writing only those that change. */
|
|
41
|
+
function applySelection(draft, nodeSelected, edgeSelected) {
|
|
42
|
+
for (const node of draft.nodes()) {
|
|
43
|
+
const next = withSelected(node, nodeSelected(node));
|
|
44
|
+
if (next !== node) draft.putNode(next);
|
|
45
|
+
}
|
|
46
|
+
for (const edge of draft.edges()) {
|
|
47
|
+
const next = withSelected(edge, edgeSelected(edge));
|
|
48
|
+
if (next !== edge) draft.putEdge(next);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const selectionSet = defineCommand({
|
|
52
|
+
name: "selection.set",
|
|
53
|
+
description: "Selects nodes and edges: `\"replace\"` (the default) makes them the whole selection, `\"add\"` adds them, `\"toggle\"` flips each one. Refused when one is not selectable.",
|
|
54
|
+
payloadSchema: {
|
|
55
|
+
type: "object",
|
|
56
|
+
properties: {
|
|
57
|
+
nodeIds: ids("the nodes; none: no node"),
|
|
58
|
+
edgeIds: ids("the edges; none: no edge"),
|
|
59
|
+
mode: {
|
|
60
|
+
enum: [
|
|
61
|
+
"replace",
|
|
62
|
+
"add",
|
|
63
|
+
"toggle"
|
|
64
|
+
],
|
|
65
|
+
description: "how they combine with the selection: \"replace\" (default), \"add\" or \"toggle\""
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
additionalProperties: false
|
|
69
|
+
},
|
|
70
|
+
resultSchema: {
|
|
71
|
+
...selectionResult,
|
|
72
|
+
description: "the selection after the command"
|
|
73
|
+
},
|
|
74
|
+
transient: true,
|
|
75
|
+
reduce: ({ nodeIds = [], edgeIds = [], mode = "replace" }, { draft }) => {
|
|
76
|
+
for (const [i, id] of nodeIds.entries()) {
|
|
77
|
+
const node = draft.node(id);
|
|
78
|
+
if (!node) return fail("not_found", `no node "${id}"`, `/nodeIds/${i}`);
|
|
79
|
+
if (!nodeFlag(node, "selectable")) return fail("refused", `node "${id}" is not selectable`, `/nodeIds/${i}`);
|
|
80
|
+
}
|
|
81
|
+
for (const [i, id] of edgeIds.entries()) {
|
|
82
|
+
const edge = draft.edge(id);
|
|
83
|
+
if (!edge) return fail("not_found", `no edge "${id}"`, `/edgeIds/${i}`);
|
|
84
|
+
if (!edgeFlag(edge, "selectable")) return fail("refused", `edge "${id}" is not selectable`, `/edgeIds/${i}`);
|
|
85
|
+
}
|
|
86
|
+
const nodes = new Set(nodeIds);
|
|
87
|
+
const edges = new Set(edgeIds);
|
|
88
|
+
const rule = (given) => (entity) => {
|
|
89
|
+
const was = entity.selected === true;
|
|
90
|
+
if (mode === "replace") return given.has(entity.id);
|
|
91
|
+
if (mode === "add") return was || given.has(entity.id);
|
|
92
|
+
return given.has(entity.id) ? !was : was;
|
|
93
|
+
};
|
|
94
|
+
applySelection(draft, rule(nodes), rule(edges));
|
|
95
|
+
return ok(selectedIds(draft));
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
const selectionClear = defineCommand({
|
|
99
|
+
name: "selection.clear",
|
|
100
|
+
description: "Deselects every node and edge.",
|
|
101
|
+
payloadSchema: {
|
|
102
|
+
type: "object",
|
|
103
|
+
properties: {},
|
|
104
|
+
additionalProperties: false
|
|
105
|
+
},
|
|
106
|
+
resultSchema: {
|
|
107
|
+
...selectionResult,
|
|
108
|
+
description: "what was selected before"
|
|
109
|
+
},
|
|
110
|
+
transient: false,
|
|
111
|
+
reduce: (_payload, { draft }) => {
|
|
112
|
+
const before = selectedIds(draft);
|
|
113
|
+
applySelection(draft, () => false, () => false);
|
|
114
|
+
return ok(before);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
const selectionRemove = defineCommand({
|
|
118
|
+
name: "selection.remove",
|
|
119
|
+
description: "Removes the selected nodes and edges that are deletable, in one step: a node takes its edges with it and, with sub-flows, its children (a node holding one that is not deletable stays).",
|
|
120
|
+
payloadSchema: {
|
|
121
|
+
type: "object",
|
|
122
|
+
properties: {},
|
|
123
|
+
additionalProperties: false
|
|
124
|
+
},
|
|
125
|
+
resultSchema: {
|
|
126
|
+
type: "object",
|
|
127
|
+
properties: {
|
|
128
|
+
removedNodeIds: ids("the nodes removed, in drawing order"),
|
|
129
|
+
removedEdgeIds: ids("the edges removed: the selected ones and those that touched a removed node")
|
|
130
|
+
},
|
|
131
|
+
required: ["removedNodeIds", "removedEdgeIds"],
|
|
132
|
+
additionalProperties: false
|
|
133
|
+
},
|
|
134
|
+
transient: false,
|
|
135
|
+
reduce: (_payload, { draft, features }) => {
|
|
136
|
+
const nodeIds = /* @__PURE__ */ new Set();
|
|
137
|
+
for (const node of draft.nodes()) {
|
|
138
|
+
if (node.selected !== true || !nodeFlag(node, "deletable")) continue;
|
|
139
|
+
const goes = removalOf(draft, features, node.id);
|
|
140
|
+
if (![...goes].some((id) => {
|
|
141
|
+
const held = draft.node(id);
|
|
142
|
+
return held !== void 0 && !nodeFlag(held, "deletable");
|
|
143
|
+
})) for (const id of goes) nodeIds.add(id);
|
|
144
|
+
}
|
|
145
|
+
const edgeIds = new Set(draft.edges().filter((edge) => edge.selected === true && edgeFlag(edge, "deletable")).map((edge) => edge.id));
|
|
146
|
+
return ok(removeAll(draft, nodeIds, edgeIds));
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
// src/selection/selection-engine.ts
|
|
150
|
+
/** The engine side of `selection()`. */
|
|
151
|
+
function selectionEngine(host, options) {
|
|
152
|
+
const { model } = host;
|
|
153
|
+
let box;
|
|
154
|
+
/** the nodes the last box selected (two or more), while they are still the selection */
|
|
155
|
+
let boxed;
|
|
156
|
+
/** Whether one of `keys` is held during `event`. */
|
|
157
|
+
const holds = (keys, event) => keys === null ? false : typeof keys === "string" ? host.held(keys, event) : keys.some((key) => host.held(key, event));
|
|
158
|
+
const selected = () => ({
|
|
159
|
+
nodeIds: model.get("selected-nodes").map((node) => node.id),
|
|
160
|
+
edgeIds: model.get("selected-edges").map((edge) => edge.id)
|
|
161
|
+
});
|
|
162
|
+
/** What the box holds now: its nodes, and the edges between two of them. */
|
|
163
|
+
const inBox = (current) => {
|
|
164
|
+
const a = current.anchor;
|
|
165
|
+
const b = host.toFlow(current.current);
|
|
166
|
+
const area = rectFromCorners(a, b);
|
|
167
|
+
const nodeIds = model.get("all-nodes").filter((node) => {
|
|
168
|
+
if (node.hidden === true) return false;
|
|
169
|
+
if (!model.is("node-selectable", { nodeId: node.id })) return false;
|
|
170
|
+
if (!host.measured(node.id)) return false;
|
|
171
|
+
const rect = host.nodeRect(node.id);
|
|
172
|
+
if (!rect) return false;
|
|
173
|
+
return options.boxMode === "partial" ? overlaps(area, rect) : contains(area, rect);
|
|
174
|
+
}).map((node) => node.id);
|
|
175
|
+
const set = new Set(nodeIds);
|
|
176
|
+
return {
|
|
177
|
+
nodeIds,
|
|
178
|
+
edgeIds: model.get("all-edges").filter((edge) => set.has(edge.source) && set.has(edge.target) && model.is("edge-selectable", { edgeId: edge.id })).map((edge) => edge.id)
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
const same = (a, b) => a.length === b.length && a.every((id, i) => id === b[i]);
|
|
182
|
+
/** Whether two lists hold the same ids, in any order. */
|
|
183
|
+
const sameSet = (a, b) => {
|
|
184
|
+
if (a.length !== b.length) return false;
|
|
185
|
+
const set = new Set(a);
|
|
186
|
+
return b.every((id) => set.has(id));
|
|
187
|
+
};
|
|
188
|
+
const stopWatching = model.subscribe(() => {
|
|
189
|
+
if (boxed && !sameSet(boxed, selected().nodeIds)) boxed = void 0;
|
|
190
|
+
});
|
|
191
|
+
/** The flow-space bounds of the selected nodes, when the rectangle shows. */
|
|
192
|
+
const selectionRect = () => {
|
|
193
|
+
if (box?.active) return null;
|
|
194
|
+
const { nodeIds } = selected();
|
|
195
|
+
if (nodeIds.length < 2) return null;
|
|
196
|
+
if (options.rect === "box" && !boxed) return null;
|
|
197
|
+
const rects = nodeIds.filter((id) => host.measured(id) && model.get("node-by", { id })?.hidden !== true).map((id) => host.nodeRect(id)).filter((rect) => rect !== void 0);
|
|
198
|
+
return boundsOf(rects) ?? null;
|
|
199
|
+
};
|
|
200
|
+
return {
|
|
201
|
+
get: {
|
|
202
|
+
"selection-rect": selectionRect,
|
|
203
|
+
"selection-box": () => {
|
|
204
|
+
if (!box?.active) return null;
|
|
205
|
+
return rectFromCorners(toScreen(host.viewport(), box.anchor), host.toRoot(box.current));
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
is: { "box-selecting": () => box?.active === true },
|
|
209
|
+
pointerdown: (event, target) => {
|
|
210
|
+
if (target.kind !== "pane" || !host.allows("select") || !(options.boxOnDrag || holds(options.boxKey, event))) return;
|
|
211
|
+
const start = {
|
|
212
|
+
x: event.clientX,
|
|
213
|
+
y: event.clientY
|
|
214
|
+
};
|
|
215
|
+
const before = selected();
|
|
216
|
+
box = {
|
|
217
|
+
start,
|
|
218
|
+
anchor: host.toFlow(start),
|
|
219
|
+
current: start,
|
|
220
|
+
before,
|
|
221
|
+
nodeIds: [],
|
|
222
|
+
edgeIds: [],
|
|
223
|
+
active: false
|
|
224
|
+
};
|
|
225
|
+
return {
|
|
226
|
+
autoPan: "selection",
|
|
227
|
+
kind: "select",
|
|
228
|
+
move: (moved) => {
|
|
229
|
+
const current = box;
|
|
230
|
+
if (!current) return;
|
|
231
|
+
current.current = {
|
|
232
|
+
x: moved.clientX,
|
|
233
|
+
y: moved.clientY
|
|
234
|
+
};
|
|
235
|
+
if (!current.active) {
|
|
236
|
+
if (Math.hypot(current.current.x - start.x, current.current.y - start.y) < 1) return;
|
|
237
|
+
current.active = true;
|
|
238
|
+
host.emit({
|
|
239
|
+
type: "box-select-start",
|
|
240
|
+
client: start,
|
|
241
|
+
point: current.anchor
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
const held = inBox(current);
|
|
245
|
+
if (!same(held.nodeIds, current.nodeIds) || !same(held.edgeIds, current.edgeIds)) {
|
|
246
|
+
current.nodeIds = held.nodeIds;
|
|
247
|
+
current.edgeIds = held.edgeIds;
|
|
248
|
+
model.run("selection.set", {
|
|
249
|
+
...held,
|
|
250
|
+
mode: "replace"
|
|
251
|
+
}, { transient: true });
|
|
252
|
+
}
|
|
253
|
+
host.changed();
|
|
254
|
+
},
|
|
255
|
+
end: () => {
|
|
256
|
+
const current = box;
|
|
257
|
+
box = void 0;
|
|
258
|
+
if (!current?.active) return;
|
|
259
|
+
boxed = model.run("selection.set", {
|
|
260
|
+
nodeIds: current.nodeIds,
|
|
261
|
+
edgeIds: current.edgeIds,
|
|
262
|
+
mode: "replace"
|
|
263
|
+
}).ok && current.nodeIds.length >= 2 && sameSet(current.nodeIds, selected().nodeIds) ? current.nodeIds : void 0;
|
|
264
|
+
host.changed();
|
|
265
|
+
host.emit({
|
|
266
|
+
type: "box-select",
|
|
267
|
+
nodeIds: current.nodeIds,
|
|
268
|
+
edgeIds: current.edgeIds
|
|
269
|
+
});
|
|
270
|
+
},
|
|
271
|
+
cancel: () => {
|
|
272
|
+
const current = box;
|
|
273
|
+
box = void 0;
|
|
274
|
+
if (!current?.active) return;
|
|
275
|
+
model.run("selection.set", {
|
|
276
|
+
...current.before,
|
|
277
|
+
mode: "replace"
|
|
278
|
+
});
|
|
279
|
+
host.changed();
|
|
280
|
+
},
|
|
281
|
+
active: () => box?.active === true
|
|
282
|
+
};
|
|
283
|
+
},
|
|
284
|
+
tap: (event, target) => {
|
|
285
|
+
if (!host.allows("select")) return false;
|
|
286
|
+
const toggle = options.multiple && holds(options.multiKey, event);
|
|
287
|
+
const mode = toggle ? "toggle" : "replace";
|
|
288
|
+
if (target.kind === "node" && target.nodeId !== void 0) {
|
|
289
|
+
if (!model.is("node-selectable", { nodeId: target.nodeId })) return false;
|
|
290
|
+
return model.run("selection.set", {
|
|
291
|
+
nodeIds: [target.nodeId],
|
|
292
|
+
mode
|
|
293
|
+
}).ok;
|
|
294
|
+
}
|
|
295
|
+
if (target.kind === "edge" && target.edgeId !== void 0) {
|
|
296
|
+
if (!model.is("edge-selectable", { edgeId: target.edgeId })) return false;
|
|
297
|
+
return model.run("selection.set", {
|
|
298
|
+
edgeIds: [target.edgeId],
|
|
299
|
+
mode
|
|
300
|
+
}).ok;
|
|
301
|
+
}
|
|
302
|
+
if (target.kind === "pane" && !toggle) {
|
|
303
|
+
const now = selected();
|
|
304
|
+
if (now.nodeIds.length === 0 && now.edgeIds.length === 0) return false;
|
|
305
|
+
return model.run("selection.clear", {}).ok;
|
|
306
|
+
}
|
|
307
|
+
return false;
|
|
308
|
+
},
|
|
309
|
+
attributes: (part, _payload, into) => {
|
|
310
|
+
if (part === "selection-box" || part === "root") into["data-selecting"] = flag(box?.active === true);
|
|
311
|
+
},
|
|
312
|
+
detached: () => {
|
|
313
|
+
box = void 0;
|
|
314
|
+
},
|
|
315
|
+
destroy: () => {
|
|
316
|
+
stopWatching();
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
// src/selection/selection.ts
|
|
321
|
+
const UNSELECTABLE = "is selected, but not selectable";
|
|
322
|
+
/** A key option as given (frozen), or its default when left out. */
|
|
323
|
+
function keyOption(value, fallback) {
|
|
324
|
+
const key = value === void 0 ? fallback : value;
|
|
325
|
+
return typeof key === "string" || key === null ? key : Object.freeze([...key]);
|
|
326
|
+
}
|
|
327
|
+
/** Selecting nodes and edges: `features: [selection()]` (`@fragiola/flow/selection`). */
|
|
328
|
+
function selection(options = {}) {
|
|
329
|
+
const resolved = Object.freeze({
|
|
330
|
+
boxMode: options.boxMode ?? "full",
|
|
331
|
+
multiple: options.multiple ?? true,
|
|
332
|
+
boxOnDrag: options.boxOnDrag ?? false,
|
|
333
|
+
multiKey: keyOption(options.multiKey, [
|
|
334
|
+
"Meta",
|
|
335
|
+
"Control",
|
|
336
|
+
"Shift"
|
|
337
|
+
]),
|
|
338
|
+
boxKey: keyOption(options.boxKey, "Shift"),
|
|
339
|
+
rect: options.rect ?? "box"
|
|
340
|
+
});
|
|
341
|
+
return Object.freeze({
|
|
342
|
+
name: "selection",
|
|
343
|
+
options: resolved,
|
|
344
|
+
engine: (host) => selectionEngine(host, resolved),
|
|
345
|
+
commands: [
|
|
346
|
+
selectionSet,
|
|
347
|
+
selectionClear,
|
|
348
|
+
selectionRemove
|
|
349
|
+
],
|
|
350
|
+
get: {
|
|
351
|
+
"selected-nodes": (reader) => reader.nodes().filter((node) => node.selected === true),
|
|
352
|
+
"selected-edges": (reader) => reader.edges().filter((edge) => edge.selected === true)
|
|
353
|
+
},
|
|
354
|
+
is: {
|
|
355
|
+
"node-selected": (reader, payload) => {
|
|
356
|
+
const id = stringOf(payload, "nodeId");
|
|
357
|
+
return id !== void 0 && reader.node(id)?.selected === true;
|
|
358
|
+
},
|
|
359
|
+
"edge-selected": (reader, payload) => {
|
|
360
|
+
const id = stringOf(payload, "edgeId");
|
|
361
|
+
return id !== void 0 && reader.edge(id)?.selected === true;
|
|
362
|
+
}
|
|
363
|
+
},
|
|
364
|
+
documentIssues: (reader) => [...reader.nodes().flatMap((node, i) => node.selected === true && !nodeFlag(node, "selectable") ? [{
|
|
365
|
+
path: `/nodes/${i}/selected`,
|
|
366
|
+
message: UNSELECTABLE
|
|
367
|
+
}] : []), ...reader.edges().flatMap((edge, i) => edge.selected === true && !edgeFlag(edge, "selectable") ? [{
|
|
368
|
+
path: `/edges/${i}/selected`,
|
|
369
|
+
message: UNSELECTABLE
|
|
370
|
+
}] : [])],
|
|
371
|
+
checkNode: (_draft, node, path) => node.selected === true && !nodeFlag(node, "selectable") ? fail("refused", UNSELECTABLE, `${path}/selected`) : void 0,
|
|
372
|
+
checkEdge: (_draft, edge, path) => edge.selected === true && !edgeFlag(edge, "selectable") ? fail("refused", UNSELECTABLE, `${path}/selected`) : void 0,
|
|
373
|
+
flagsChanged: (draft, kind, id) => {
|
|
374
|
+
if (kind === "node") {
|
|
375
|
+
const node = draft.node(id);
|
|
376
|
+
if (node?.selected === true && !nodeFlag(node, "selectable")) {
|
|
377
|
+
const { selected: _was, ...rest } = node;
|
|
378
|
+
draft.putNode(rest);
|
|
379
|
+
}
|
|
380
|
+
} else {
|
|
381
|
+
const edge = draft.edge(id);
|
|
382
|
+
if (edge?.selected === true && !edgeFlag(edge, "selectable")) {
|
|
383
|
+
const { selected: _was, ...rest } = edge;
|
|
384
|
+
draft.putEdge(rest);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
export { selection };
|
|
391
|
+
|
|
392
|
+
//# sourceMappingURL=selection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection.js","names":[],"sources":["../src/selection/commands.ts","../src/selection/selection-engine.ts","../src/selection/selection.ts"],"sourcesContent":["// The selection's commands (D6). Being selected is a field of the node or edge itself\n// (`selected: true`, absent when not), so the document stays the single source of truth and\n// `get(\"flow-json\")` writes the selection back. A node or edge that is not selectable is refused;\n// `selection.remove` (the Delete key's) removes what is selected and deletable, with their edges and\n// (with sub-flows) their children, skipping what is not deletable.\nimport { defineCommand, fail, ok } from \"../commands/define\";\nimport { removalOf, removeAll } from \"../commands/rules\";\nimport type { SelectionResult } from \"../commands/types\";\nimport { edgeFlag, nodeFlag } from \"../document/flags\";\nimport type { FlowEdge, FlowNode } from \"../document/types\";\nimport type { Draft } from \"../state/draft\";\n\nconst ids = (description: string) =>\n ({\n type: \"array\",\n items: { type: \"string\", minLength: 1 },\n description,\n }) as const;\n\nconst selectionResult = {\n type: \"object\",\n properties: {\n nodeIds: ids(\"the nodes, in drawing order\"),\n edgeIds: ids(\"the edges, in drawing order\"),\n },\n required: [\"nodeIds\", \"edgeIds\"],\n additionalProperties: false,\n} as const;\n\n/** An entity with its `selected` field set (removed when false). */\nfunction withSelected<E extends FlowNode | FlowEdge>(\n entity: E,\n selected: boolean,\n): E {\n if ((entity.selected === true) === selected) {\n return entity;\n }\n const { selected: _was, ...rest } = entity;\n return (selected ? { ...rest, selected: true } : rest) as E;\n}\n\n/** The selected node and edge ids of a draft, in drawing order. */\nexport function selectedIds(draft: Draft): SelectionResult {\n return {\n nodeIds: draft\n .nodes()\n .filter((node) => node.selected === true)\n .map((node) => node.id),\n edgeIds: draft\n .edges()\n .filter((edge) => edge.selected === true)\n .map((edge) => edge.id),\n };\n}\n\n/** Sets the selection of every node and edge by `selected`, writing only those that change. */\nfunction applySelection(\n draft: Draft,\n nodeSelected: (node: FlowNode) => boolean,\n edgeSelected: (edge: FlowEdge) => boolean,\n): void {\n for (const node of draft.nodes()) {\n const next = withSelected(node, nodeSelected(node));\n if (next !== node) draft.putNode(next);\n }\n for (const edge of draft.edges()) {\n const next = withSelected(edge, edgeSelected(edge));\n if (next !== edge) draft.putEdge(next);\n }\n}\n\nexport const selectionSet = defineCommand({\n name: \"selection.set\",\n description:\n 'Selects nodes and edges: `\"replace\"` (the default) makes them the whole selection, `\"add\"` adds them, `\"toggle\"` flips each one. Refused when one is not selectable.',\n payloadSchema: {\n type: \"object\",\n properties: {\n nodeIds: ids(\"the nodes; none: no node\"),\n edgeIds: ids(\"the edges; none: no edge\"),\n mode: {\n enum: [\"replace\", \"add\", \"toggle\"],\n description:\n 'how they combine with the selection: \"replace\" (default), \"add\" or \"toggle\"',\n },\n },\n additionalProperties: false,\n },\n resultSchema: {\n ...selectionResult,\n description: \"the selection after the command\",\n },\n transient: true,\n reduce: ({ nodeIds = [], edgeIds = [], mode = \"replace\" }, { draft }) => {\n for (const [i, id] of nodeIds.entries()) {\n const node = draft.node(id);\n if (!node) {\n return fail(\"not_found\", `no node \"${id}\"`, `/nodeIds/${i}`);\n }\n if (!nodeFlag(node, \"selectable\")) {\n return fail(\n \"refused\",\n `node \"${id}\" is not selectable`,\n `/nodeIds/${i}`,\n );\n }\n }\n for (const [i, id] of edgeIds.entries()) {\n const edge = draft.edge(id);\n if (!edge) {\n return fail(\"not_found\", `no edge \"${id}\"`, `/edgeIds/${i}`);\n }\n if (!edgeFlag(edge, \"selectable\")) {\n return fail(\n \"refused\",\n `edge \"${id}\" is not selectable`,\n `/edgeIds/${i}`,\n );\n }\n }\n const nodes = new Set(nodeIds);\n const edges = new Set(edgeIds);\n const rule = (given: Set<string>) => (entity: FlowNode | FlowEdge) => {\n const was = entity.selected === true;\n if (mode === \"replace\") return given.has(entity.id);\n if (mode === \"add\") return was || given.has(entity.id);\n return given.has(entity.id) ? !was : was;\n };\n applySelection(draft, rule(nodes), rule(edges));\n return ok(selectedIds(draft));\n },\n});\n\nexport const selectionClear = defineCommand({\n name: \"selection.clear\",\n description: \"Deselects every node and edge.\",\n payloadSchema: {\n type: \"object\",\n properties: {},\n additionalProperties: false,\n },\n resultSchema: {\n ...selectionResult,\n description: \"what was selected before\",\n },\n transient: false,\n reduce: (_payload, { draft }) => {\n const before = selectedIds(draft);\n applySelection(\n draft,\n () => false,\n () => false,\n );\n return ok(before);\n },\n});\n\nexport const selectionRemove = defineCommand({\n name: \"selection.remove\",\n description:\n \"Removes the selected nodes and edges that are deletable, in one step: a node takes its edges with it and, with sub-flows, its children (a node holding one that is not deletable stays).\",\n payloadSchema: {\n type: \"object\",\n properties: {},\n additionalProperties: false,\n },\n resultSchema: {\n type: \"object\",\n properties: {\n removedNodeIds: ids(\"the nodes removed, in drawing order\"),\n removedEdgeIds: ids(\n \"the edges removed: the selected ones and those that touched a removed node\",\n ),\n },\n required: [\"removedNodeIds\", \"removedEdgeIds\"],\n additionalProperties: false,\n },\n transient: false,\n reduce: (_payload, { draft, features }) => {\n const nodeIds = new Set<string>();\n for (const node of draft.nodes()) {\n if (node.selected !== true || !nodeFlag(node, \"deletable\"))\n continue;\n const goes = removalOf(draft, features, node.id);\n const kept = [...goes].some((id) => {\n const held = draft.node(id);\n return held !== undefined && !nodeFlag(held, \"deletable\");\n });\n if (!kept) for (const id of goes) nodeIds.add(id);\n }\n const edgeIds = new Set(\n draft\n .edges()\n .filter(\n (edge) =>\n edge.selected === true && edgeFlag(edge, \"deletable\"),\n )\n .map((edge) => edge.id),\n );\n return ok(removeAll(draft, nodeIds, edgeIds));\n },\n});\n","// The selection feature's engine side: a tap on a node or an edge selects it (with the\n// multi-selection key, Ctrl, ⌘ or Shift by default, it toggles, when `multiple`), a tap on the pane\n// clears the selection, and a drag on the pane with the box key (Shift by default; any drag with\n// `boxOnDrag`) draws a selection box that selects the nodes it holds (`\"full\"`) or touches\n// (`\"partial\"`), with the edges between them. Each box step is a\n// transient `selection.set`, the release the final one; a cancel puts the selection back. Two or\n// more nodes a box selected get a rectangle around them (`selection-rect`, the `nodes-selection`\n// part: `drag()` drags it) until the selection changes otherwise (`rect: \"always\"`: whenever two\n// or more are selected).\nimport { flag } from \"../attributes/part-attributes\";\nimport type { FlowEdge, FlowNode, XY } from \"../document/types\";\nimport type { FeatureEngine, FeatureEngineHost } from \"../features/types\";\nimport {\n boundsOf,\n contains,\n overlaps,\n rectFromCorners,\n} from \"../geometry/rect\";\nimport type { Rect } from \"../geometry/types\";\nimport { toScreen } from \"../geometry/viewport-math\";\nimport type { SelectionKey, SelectionOptions } from \"./selection\";\n\ninterface Box {\n /** where it started, in client coordinates (its travel) and in flow coordinates (its corner) */\n readonly start: XY;\n readonly anchor: XY;\n current: XY;\n readonly before: { nodeIds: string[]; edgeIds: string[] };\n nodeIds: string[];\n edgeIds: string[];\n active: boolean;\n}\n\n/** The engine side of `selection()`. */\nexport function selectionEngine(\n host: FeatureEngineHost,\n options: SelectionOptions,\n): FeatureEngine {\n const { model } = host;\n let box: Box | undefined;\n /** the nodes the last box selected (two or more), while they are still the selection */\n let boxed: readonly string[] | undefined;\n\n /** Whether one of `keys` is held during `event`. */\n const holds = (keys: SelectionKey, event: MouseEvent): boolean =>\n keys === null\n ? false\n : typeof keys === \"string\"\n ? host.held(keys, event)\n : keys.some((key) => host.held(key, event));\n\n const selected = () => ({\n nodeIds: (model.get(\"selected-nodes\") as readonly FlowNode[]).map(\n (node) => node.id,\n ),\n edgeIds: (model.get(\"selected-edges\") as readonly FlowEdge[]).map(\n (edge) => edge.id,\n ),\n });\n\n /** What the box holds now: its nodes, and the edges between two of them. */\n const inBox = (current: Box) => {\n const a = current.anchor;\n const b = host.toFlow(current.current);\n const area = rectFromCorners(a, b);\n const nodeIds = (model.get(\"all-nodes\") as readonly FlowNode[])\n .filter((node) => {\n if (node.hidden === true) return false;\n if (!model.is(\"node-selectable\", { nodeId: node.id }))\n return false;\n if (!host.measured(node.id)) return false;\n const rect = host.nodeRect(node.id);\n if (!rect) return false;\n return options.boxMode === \"partial\"\n ? overlaps(area, rect)\n : contains(area, rect);\n })\n .map((node) => node.id);\n const set = new Set(nodeIds);\n const edgeIds = (model.get(\"all-edges\") as readonly FlowEdge[])\n .filter(\n (edge) =>\n set.has(edge.source) &&\n set.has(edge.target) &&\n model.is(\"edge-selectable\", { edgeId: edge.id }),\n )\n .map((edge) => edge.id);\n return { nodeIds, edgeIds };\n };\n\n const same = (a: readonly string[], b: readonly string[]) =>\n a.length === b.length && a.every((id, i) => id === b[i]);\n\n /** Whether two lists hold the same ids, in any order. */\n const sameSet = (a: readonly string[], b: readonly string[]) => {\n if (a.length !== b.length) return false;\n const set = new Set(a);\n return b.every((id) => set.has(id));\n };\n\n // the box's rectangle goes once the selection is anything else (a click, a key, a sync)\n const stopWatching = model.subscribe(() => {\n if (boxed && !sameSet(boxed, selected().nodeIds)) boxed = undefined;\n });\n\n /** The flow-space bounds of the selected nodes, when the rectangle shows. */\n const selectionRect = (): Rect | null => {\n if (box?.active) return null;\n const { nodeIds } = selected();\n if (nodeIds.length < 2) return null;\n if (options.rect === \"box\" && !boxed) return null;\n const rects = nodeIds\n .filter(\n (id) =>\n host.measured(id) &&\n (model.get(\"node-by\", { id }) as FlowNode | undefined)\n ?.hidden !== true,\n )\n .map((id) => host.nodeRect(id))\n .filter((rect): rect is Rect => rect !== undefined);\n return boundsOf(rects) ?? null;\n };\n\n return {\n get: {\n \"selection-rect\": selectionRect,\n \"selection-box\": () => {\n if (!box?.active) return null;\n // the corner stays on its flow point when the view pans or zooms under it\n return rectFromCorners(\n toScreen(host.viewport(), box.anchor),\n host.toRoot(box.current),\n );\n },\n },\n is: {\n \"box-selecting\": () => box?.active === true,\n },\n pointerdown: (event, target) => {\n if (\n target.kind !== \"pane\" ||\n !host.allows(\"select\") ||\n !(options.boxOnDrag || holds(options.boxKey, event))\n ) {\n return undefined;\n }\n const start = { x: event.clientX, y: event.clientY };\n const before = selected();\n box = {\n start,\n anchor: host.toFlow(start),\n current: start,\n before,\n nodeIds: [],\n edgeIds: [],\n active: false,\n };\n return {\n autoPan: \"selection\",\n kind: \"select\",\n move: (moved) => {\n const current = box;\n if (!current) return;\n current.current = { x: moved.clientX, y: moved.clientY };\n if (!current.active) {\n const travel = Math.hypot(\n current.current.x - start.x,\n current.current.y - start.y,\n );\n if (travel < 1) return;\n current.active = true;\n host.emit({\n type: \"box-select-start\",\n client: start,\n point: current.anchor,\n });\n }\n const held = inBox(current);\n if (\n !same(held.nodeIds, current.nodeIds) ||\n !same(held.edgeIds, current.edgeIds)\n ) {\n current.nodeIds = held.nodeIds;\n current.edgeIds = held.edgeIds;\n model.run(\n \"selection.set\",\n { ...held, mode: \"replace\" },\n { transient: true },\n );\n }\n host.changed();\n },\n end: () => {\n const current = box;\n box = undefined;\n if (!current?.active) return;\n const result = model.run(\"selection.set\", {\n nodeIds: current.nodeIds,\n edgeIds: current.edgeIds,\n mode: \"replace\",\n });\n // the rectangle only for the box's own selection (not one a middleware vetoed\n // or changed)\n boxed =\n result.ok &&\n current.nodeIds.length >= 2 &&\n sameSet(current.nodeIds, selected().nodeIds)\n ? current.nodeIds\n : undefined;\n host.changed();\n host.emit({\n type: \"box-select\",\n nodeIds: current.nodeIds,\n edgeIds: current.edgeIds,\n });\n },\n cancel: () => {\n const current = box;\n box = undefined;\n if (!current?.active) return;\n model.run(\"selection.set\", {\n ...current.before,\n mode: \"replace\",\n });\n host.changed();\n },\n active: () => box?.active === true,\n };\n },\n tap: (event, target) => {\n if (!host.allows(\"select\")) return false;\n const toggle = options.multiple && holds(options.multiKey, event);\n const mode = toggle ? \"toggle\" : \"replace\";\n if (target.kind === \"node\" && target.nodeId !== undefined) {\n if (!model.is(\"node-selectable\", { nodeId: target.nodeId }))\n return false;\n return model.run(\"selection.set\", {\n nodeIds: [target.nodeId],\n mode,\n }).ok;\n }\n if (target.kind === \"edge\" && target.edgeId !== undefined) {\n if (!model.is(\"edge-selectable\", { edgeId: target.edgeId }))\n return false;\n return model.run(\"selection.set\", {\n edgeIds: [target.edgeId],\n mode,\n }).ok;\n }\n if (target.kind === \"pane\" && !toggle) {\n const now = selected();\n if (now.nodeIds.length === 0 && now.edgeIds.length === 0)\n return false;\n return model.run(\"selection.clear\", {}).ok;\n }\n return false;\n },\n attributes: (part, _payload, into) => {\n if (part === \"selection-box\" || part === \"root\") {\n into[\"data-selecting\"] = flag(box?.active === true);\n }\n },\n detached: () => {\n box = undefined;\n },\n destroy: () => {\n stopWatching();\n },\n };\n}\n","// The selection feature (D2, `@fragiola/flow/selection`): nodes and edges are selected. Its model\n// side is here: the `selection.*` commands, the `selected-*` and `*-selected` keys, the `selected`\n// field of a node and an edge, and its rule (a node or edge made unselectable is deselected). Its\n// engine side (`selection-engine.ts`: click, modifier multi-select, box selection) reads `options`.\nimport { fail } from \"../commands/define\";\nimport { edgeFlag, nodeFlag } from \"../document/flags\";\nimport type { FlowFeature, FlowReader } from \"../features/types\";\nimport { stringOf } from \"../state/core-queries\";\nimport { selectionClear, selectionRemove, selectionSet } from \"./commands\";\nimport { selectionEngine } from \"./selection-engine\";\n\n/** How a box selection takes nodes: those it touches (`\"partial\"`) or those it holds whole (`\"full\"`). */\nexport type BoxSelectionMode = \"partial\" | \"full\";\n\n/**\n * When the rectangle around the selected nodes (`selection-rect`, the `nodes-selection` part)\n * shows: after a box selected two or more nodes, until the selection changes otherwise (`\"box\"`),\n * or whenever two or more nodes are selected (`\"always\"`).\n */\nexport type SelectionRectMode = \"box\" | \"always\";\n\n/**\n * A key a gesture reads while it is held (`KeyboardEvent.key` or `.code`; `Meta`, `Control`, `Alt`\n * and `Shift` from the pointer event's flags), several (any of them), or `null` for none.\n */\nexport type SelectionKey = string | readonly string[] | null;\n\n/** Options of {@link selection}: read by its engine side. */\nexport interface SelectionOptions {\n /** how a box selection takes nodes; default `\"full\"` */\n readonly boxMode: BoxSelectionMode;\n /** whether a click with the multi-selection key adds to the selection; default true */\n readonly multiple: boolean;\n /** whether any drag on the pane draws a selection box (instead of panning); default false: the box key + drag */\n readonly boxOnDrag: boolean;\n /**\n * the key that, held, makes a click toggle a node or an edge in the selection; default\n * `[\"Meta\", \"Control\", \"Shift\"]`; `null` for none\n */\n readonly multiKey: SelectionKey;\n /** the key that, held, makes a drag on the pane draw a selection box; default `\"Shift\"`; `null` for none */\n readonly boxKey: SelectionKey;\n /** when the rectangle around the selected nodes shows (`selection-rect`); default `\"box\"` */\n readonly rect: SelectionRectMode;\n}\n\n/** The selection feature, as `selection()` makes it. */\nexport type SelectionFeature = FlowFeature<\"selection\", SelectionOptions>;\n\nconst UNSELECTABLE = \"is selected, but not selectable\";\n\n/** A key option as given (frozen), or its default when left out. */\nfunction keyOption(\n value: SelectionKey | undefined,\n fallback: SelectionKey,\n): SelectionKey {\n const key = value === undefined ? fallback : value;\n return typeof key === \"string\" || key === null\n ? key\n : Object.freeze([...key]);\n}\n\n/** Selecting nodes and edges: `features: [selection()]` (`@fragiola/flow/selection`). */\nexport function selection(\n options: Partial<SelectionOptions> = {},\n): SelectionFeature {\n const resolved: SelectionOptions = Object.freeze({\n boxMode: options.boxMode ?? \"full\",\n multiple: options.multiple ?? true,\n boxOnDrag: options.boxOnDrag ?? false,\n multiKey: keyOption(options.multiKey, [\"Meta\", \"Control\", \"Shift\"]),\n boxKey: keyOption(options.boxKey, \"Shift\"),\n rect: options.rect ?? \"box\",\n });\n return Object.freeze({\n name: \"selection\",\n options: resolved,\n engine: (host) => selectionEngine(host, resolved),\n commands: [selectionSet, selectionClear, selectionRemove],\n get: {\n \"selected-nodes\": (reader: FlowReader) =>\n reader.nodes().filter((node) => node.selected === true),\n \"selected-edges\": (reader: FlowReader) =>\n reader.edges().filter((edge) => edge.selected === true),\n },\n is: {\n \"node-selected\": (reader: FlowReader, payload: unknown) => {\n const id = stringOf(payload, \"nodeId\");\n return id !== undefined && reader.node(id)?.selected === true;\n },\n \"edge-selected\": (reader: FlowReader, payload: unknown) => {\n const id = stringOf(payload, \"edgeId\");\n return id !== undefined && reader.edge(id)?.selected === true;\n },\n },\n documentIssues: (reader: FlowReader) => [\n ...reader.nodes().flatMap((node, i) =>\n node.selected === true && !nodeFlag(node, \"selectable\")\n ? [\n {\n path: `/nodes/${i}/selected`,\n message: UNSELECTABLE,\n },\n ]\n : [],\n ),\n ...reader.edges().flatMap((edge, i) =>\n edge.selected === true && !edgeFlag(edge, \"selectable\")\n ? [\n {\n path: `/edges/${i}/selected`,\n message: UNSELECTABLE,\n },\n ]\n : [],\n ),\n ],\n checkNode: (_draft, node, path) =>\n node.selected === true && !nodeFlag(node, \"selectable\")\n ? fail(\"refused\", UNSELECTABLE, `${path}/selected`)\n : undefined,\n checkEdge: (_draft, edge, path) =>\n edge.selected === true && !edgeFlag(edge, \"selectable\")\n ? fail(\"refused\", UNSELECTABLE, `${path}/selected`)\n : undefined,\n flagsChanged: (draft, kind, id) => {\n if (kind === \"node\") {\n const node = draft.node(id);\n if (node?.selected === true && !nodeFlag(node, \"selectable\")) {\n const { selected: _was, ...rest } = node;\n draft.putNode(rest as typeof node);\n }\n } else {\n const edge = draft.edge(id);\n if (edge?.selected === true && !edgeFlag(edge, \"selectable\")) {\n const { selected: _was, ...rest } = edge;\n draft.putEdge(rest as typeof edge);\n }\n }\n },\n } satisfies SelectionFeature);\n}\n"],"mappings":";;;;;;AAYA,MAAM,OAAO,iBACR;CACG,MAAM;CACN,OAAO;EAAE,MAAM;EAAU,WAAW;CAAE;CACtC;AACJ;AAEJ,MAAM,kBAAkB;CACpB,MAAM;CACN,YAAY;EACR,SAAS,IAAI,6BAA6B;EAC1C,SAAS,IAAI,6BAA6B;CAC9C;CACA,UAAU,CAAC,WAAW,SAAS;CAC/B,sBAAsB;AAC1B;;AAGA,SAAS,aACL,QACA,UACC;CACD,IAAK,OAAO,aAAa,SAAU,UAC/B,OAAO;CAEX,MAAM,EAAE,UAAU,MAAM,GAAG,SAAS;CACpC,OAAQ,WAAW;EAAE,GAAG;EAAM,UAAU;CAAK,IAAI;AACrD;;AAGA,SAAgB,YAAY,OAA+B;CACvD,OAAO;EACH,SAAS,MACJ,MAAM,CAAC,CACP,QAAQ,SAAS,KAAK,aAAa,IAAI,CAAC,CACxC,KAAK,SAAS,KAAK,EAAE;EAC1B,SAAS,MACJ,MAAM,CAAC,CACP,QAAQ,SAAS,KAAK,aAAa,IAAI,CAAC,CACxC,KAAK,SAAS,KAAK,EAAE;CAC9B;AACJ;;AAGA,SAAS,eACL,OACA,cACA,cACI;CACJ,KAAK,MAAM,QAAQ,MAAM,MAAM,GAAG;EAC9B,MAAM,OAAO,aAAa,MAAM,aAAa,IAAI,CAAC;EAClD,IAAI,SAAS,MAAM,MAAM,QAAQ,IAAI;CACzC;CACA,KAAK,MAAM,QAAQ,MAAM,MAAM,GAAG;EAC9B,MAAM,OAAO,aAAa,MAAM,aAAa,IAAI,CAAC;EAClD,IAAI,SAAS,MAAM,MAAM,QAAQ,IAAI;CACzC;AACJ;AAEA,MAAa,eAAe,cAAc;CACtC,MAAM;CACN,aACI;CACJ,eAAe;EACX,MAAM;EACN,YAAY;GACR,SAAS,IA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AAa,QAAQ,CAAC,SAAS,MAAM,YAAY,IAChD,CACI;GACI,MAAM,UAAU,EAAE;GAClB,SAAS;EACb,CACJ,IACA,CAAC,CACX,CACJ;EACA,YAAY,QAAQ,MAAM,SACtB,KAAK,aAAa,QAAQ,CAAC,SAAS,MAAM,YAAY,IAChD,KAAK,WAAW,cAAc,GAAG,KAAK,UAAU,IAChD,KAAA;EACV,YAAY,QAAQ,MAAM,SACtB,KAAK,aAAa,QAAQ,CAAC,SAAS,MAAM,YAAY,IAChD,KAAK,WAAW,cAAc,GAAG,KAAK,UAAU,IAChD,KAAA;EACV,eAAe,OAAO,MAAM,OAAO;GAC/B,IAAI,SAAS,QAAQ;IACjB,MAAM,OAAO,MAAM,KAAK,EAAE;IAC1B,IAAI,MAAM,aAAa,QAAQ,CAAC,SAAS,MAAM,YAAY,GAAG;KAC1D,MAAM,EAAE,UAAU,MAAM,GAAG,SAAS;KACpC,MAAM,QAAQ,IAAmB;IACrC;GACJ,OAAO;IACH,MAAM,OAAO,MAAM,KAAK,EAAE;IAC1B,IAAI,MAAM,aAAa,QAAQ,CAAC,SAAS,MAAM,YAAY,GAAG;KAC1D,MAAM,EAAE,UAAU,MAAM,GAAG,SAAS;KACpC,MAAM,QAAQ,IAAmB;IACrC;GACJ;EACJ;CACJ,CAA4B;AAChC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { f as FlowFeature } from "./types-CLHcZVCb.js";
|
|
2
|
+
/** Options of {@link subflows}: none yet. */
|
|
3
|
+
type SubflowsOptions = Record<never, never>;
|
|
4
|
+
/** The sub-flows feature, as `subflows()` makes it. */
|
|
5
|
+
type SubflowsFeature = FlowFeature<"subflows", SubflowsOptions>;
|
|
6
|
+
/** Nodes inside nodes: `features: [subflows()]` (`@fragiola/flow/subflows`). */
|
|
7
|
+
export declare function subflows(): SubflowsFeature;
|
|
8
|
+
export type { SubflowsFeature, SubflowsOptions };
|
|
9
|
+
//# sourceMappingURL=subflows.d.ts.map
|