@dudousxd/nestjs-catalog-react 0.21.0 → 0.22.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/dist/WorkflowCanvas.js +306 -263
- package/dist/workflow/canvas-menu.d.ts +161 -0
- package/dist/workflow/canvas-menu.js +359 -0
- package/dist/workflow/create.d.ts +127 -0
- package/dist/workflow/create.js +238 -0
- package/dist/workflow/menu.d.ts +73 -0
- package/dist/workflow/menu.js +174 -0
- package/dist/workflow/place.d.ts +79 -0
- package/dist/workflow/place.js +89 -0
- package/dist/workflow/removal.d.ts +27 -0
- package/dist/workflow/removal.js +81 -0
- package/package.json +1 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type WorkflowEdge, type WorkflowNode } from './model';
|
|
2
|
+
/**
|
|
3
|
+
* The graph without those nodes, and what that cost, in one sentence.
|
|
4
|
+
*
|
|
5
|
+
* The edges are counted before the nodes are dropped, because an edge goes for
|
|
6
|
+
* touching a removed node *at either end* — and a caller working from the
|
|
7
|
+
* filtered graph could no longer tell which ones those were.
|
|
8
|
+
*
|
|
9
|
+
* The nodes are named and the wires are counted, deliberately in that
|
|
10
|
+
* proportion. "1 node removed" sends somebody looking at the canvas to work out
|
|
11
|
+
* which; a node with six wires named one at a time is a sentence nobody
|
|
12
|
+
* finishes. The count is what answers the question this sentence exists for:
|
|
13
|
+
* *did anything else just change?*
|
|
14
|
+
*/
|
|
15
|
+
export declare function removeNodes(nodes: WorkflowNode[], edges: WorkflowEdge[], ids: readonly string[]): {
|
|
16
|
+
nodes: WorkflowNode[];
|
|
17
|
+
edges: WorkflowEdge[];
|
|
18
|
+
said: string;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* How many wires a removal would take, for a warning written before the click.
|
|
22
|
+
*
|
|
23
|
+
* The same count {@link removeNodes} reports afterwards, asked in advance —
|
|
24
|
+
* which is where it does the most good: on the menu item, and on the tooltip of
|
|
25
|
+
* a delete button that does not stop to ask.
|
|
26
|
+
*/
|
|
27
|
+
export declare function wiresOn(edges: WorkflowEdge[], ids: readonly string[]): number;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { nodeName } from './model';
|
|
2
|
+
/**
|
|
3
|
+
* Taking nodes out, and saying what went with them.
|
|
4
|
+
*
|
|
5
|
+
* ## Why this is not an undo
|
|
6
|
+
*
|
|
7
|
+
* It was, for about an hour. Deleting a node became a one-click control on the
|
|
8
|
+
* node's hover toolbar and an item on its right-click menu — both asked for,
|
|
9
|
+
* both right — and a one-click delete with no way back is a bad trade on a
|
|
10
|
+
* canvas where the unsaved draft is *everything* somebody has done since their
|
|
11
|
+
* last save. So this file grew a ten-second "removed · undo" window.
|
|
12
|
+
*
|
|
13
|
+
* A real per-action undo stack landed while that was being written, and it is a
|
|
14
|
+
* better answer to the same problem in every respect: it covers every gesture
|
|
15
|
+
* rather than the destructive two, it has a Reset beside it, and it guards the
|
|
16
|
+
* tab against being closed on unsaved work. Shipping a second, narrower
|
|
17
|
+
* mechanism next to it would give the canvas two things called undo that behave
|
|
18
|
+
* differently — which is precisely the failure this whole change exists to fix,
|
|
19
|
+
* since the reason a context menu was needed at all is that the canvas had two
|
|
20
|
+
* things called "wire". So the window went, and `history.tsx` is the way back.
|
|
21
|
+
*
|
|
22
|
+
* ## What is left, and why it is worth a module
|
|
23
|
+
*
|
|
24
|
+
* One fact that the undo stack does not state and nothing else on the screen
|
|
25
|
+
* does either: **a node takes its wires with it.** Removing a box silently
|
|
26
|
+
* unwires up to two other boxes, and a canvas that reports "node removed" leaves
|
|
27
|
+
* somebody to discover half an hour later that their graph no longer reaches its
|
|
28
|
+
* sink. Undo makes that recoverable; it does not make it visible.
|
|
29
|
+
*
|
|
30
|
+
* So this is the filter and the sentence, together, so that every gesture that
|
|
31
|
+
* removes a node says the same thing about what it cost — and so the menu item
|
|
32
|
+
* and the delete button can say it *before* the click as well as after.
|
|
33
|
+
*/
|
|
34
|
+
/** "1 connection" / "3 connections", with the plural not left to the reader. */
|
|
35
|
+
function count(n, noun) {
|
|
36
|
+
return `${n} ${noun}${n === 1 ? '' : 's'}`;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The graph without those nodes, and what that cost, in one sentence.
|
|
40
|
+
*
|
|
41
|
+
* The edges are counted before the nodes are dropped, because an edge goes for
|
|
42
|
+
* touching a removed node *at either end* — and a caller working from the
|
|
43
|
+
* filtered graph could no longer tell which ones those were.
|
|
44
|
+
*
|
|
45
|
+
* The nodes are named and the wires are counted, deliberately in that
|
|
46
|
+
* proportion. "1 node removed" sends somebody looking at the canvas to work out
|
|
47
|
+
* which; a node with six wires named one at a time is a sentence nobody
|
|
48
|
+
* finishes. The count is what answers the question this sentence exists for:
|
|
49
|
+
* *did anything else just change?*
|
|
50
|
+
*/
|
|
51
|
+
export function removeNodes(nodes, edges, ids) {
|
|
52
|
+
const going = new Set(ids);
|
|
53
|
+
const removed = nodes.filter((node) => going.has(node.id));
|
|
54
|
+
const cut = wiresOn(edges, ids);
|
|
55
|
+
return {
|
|
56
|
+
nodes: nodes.filter((node) => !going.has(node.id)),
|
|
57
|
+
edges: edges.filter((edge) => !going.has(edge.from) && !going.has(edge.to)),
|
|
58
|
+
said: describeRemoval(removed, cut),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function describeRemoval(removed, wires) {
|
|
62
|
+
if (removed.length === 0)
|
|
63
|
+
return 'Nothing was removed.';
|
|
64
|
+
const named = removed.length <= 3
|
|
65
|
+
? removed.map((node) => `"${nodeName(node)}"`).join(', ')
|
|
66
|
+
: count(removed.length, 'node');
|
|
67
|
+
if (wires === 0)
|
|
68
|
+
return `${named} removed. Nothing was wired to it.`;
|
|
69
|
+
return `${named} removed, and the ${count(wires, 'connection')} it was part of went with it.`;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* How many wires a removal would take, for a warning written before the click.
|
|
73
|
+
*
|
|
74
|
+
* The same count {@link removeNodes} reports afterwards, asked in advance —
|
|
75
|
+
* which is where it does the most good: on the menu item, and on the tooltip of
|
|
76
|
+
* a delete button that does not stop to ask.
|
|
77
|
+
*/
|
|
78
|
+
export function wiresOn(edges, ids) {
|
|
79
|
+
const going = new Set(ids);
|
|
80
|
+
return edges.filter((edge) => going.has(edge.from) || going.has(edge.to)).length;
|
|
81
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dudousxd/nestjs-catalog-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"description": "Ready-made React screens for @dudousxd/nestjs-catalog — a model manager and a generic object explorer you can drop into your own app shell.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Davide Carvalho",
|