@statelyai/flow 0.14.0 → 0.15.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/README.md +2 -1
- package/dist/esm/index.d.ts +5 -2
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +19 -14
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/layout/dagre.d.ts +2 -1
- package/dist/esm/layout/dagre.d.ts.map +1 -0
- package/dist/esm/layout/dagre.js +2 -0
- package/dist/esm/layout/dagre.js.map +1 -0
- package/dist/esm/layout/elk.d.ts +2 -1
- package/dist/esm/layout/elk.d.ts.map +1 -0
- package/dist/esm/layout/elk.js +2 -0
- package/dist/esm/layout/elk.js.map +1 -0
- package/dist/esm/layout/stately.d.ts +2 -1
- package/dist/esm/layout/stately.d.ts.map +1 -0
- package/dist/esm/layout/stately.js +2 -0
- package/dist/esm/layout/stately.js.map +1 -0
- package/dist/esm/shared.d.ts +2 -1
- package/dist/esm/shared.d.ts.map +1 -0
- package/dist/esm/shared.js +2 -0
- package/dist/esm/shared.js.map +1 -0
- package/package.json +4 -3
- package/src/__fixtures__/nested.ts +106 -0
- package/src/appearances.test.ts +428 -0
- package/src/appearances.ts +144 -0
- package/src/authoritative-route.ts +14 -0
- package/src/changeSet.test.ts +132 -0
- package/src/changeSet.ts +337 -0
- package/src/config.ts +41 -0
- package/src/configure.test.ts +212 -0
- package/src/connection-lifetime.ts +1 -0
- package/src/connectionPreview.test.ts +102 -0
- package/src/connectionPreview.ts +82 -0
- package/src/content.ts +203 -0
- package/src/createFlow.fit-frame.test.ts +256 -0
- package/src/createFlow.modern.test.ts +743 -0
- package/src/createFlow.test.ts +632 -0
- package/src/createFlow.ts +3463 -0
- package/src/createFlow.view.test.ts +212 -0
- package/src/createFlow.viewport-controls.test.ts +221 -0
- package/src/edge-geometry.ts +318 -0
- package/src/engine.cache.test.ts +728 -0
- package/src/engine.hierarchy.test.ts +1023 -0
- package/src/engine.test.ts +1965 -0
- package/src/engine.ts +3385 -0
- package/src/entity-changes.test.ts +309 -0
- package/src/entity-changes.ts +395 -0
- package/src/examples/flow-based-math.test.ts +25 -0
- package/src/examples/flow-based-math.ts +210 -0
- package/src/external-edit.test.ts +337 -0
- package/src/external-edit.ts +358 -0
- package/src/factories.test.ts +104 -0
- package/src/factories.ts +70 -0
- package/src/geometry.ts +13 -0
- package/src/graph-index.test.ts +56 -0
- package/src/graph-index.ts +194 -0
- package/src/hierarchy.test.ts +175 -0
- package/src/hierarchy.ts +330 -0
- package/src/highlights.test.ts +130 -0
- package/src/index.ts +469 -0
- package/src/input/index.ts +615 -0
- package/src/input/input.test.ts +2577 -0
- package/src/input/keymap.ts +111 -0
- package/src/input/modes.ts +1715 -0
- package/src/input/reparent.test.ts +214 -0
- package/src/layout/dagre.ts +138 -0
- package/src/layout/elk.ts +1382 -0
- package/src/layout/index.ts +12 -0
- package/src/layout/layout.test.ts +1248 -0
- package/src/layout/shared.ts +260 -0
- package/src/layout/stately-globals.d.ts +9 -0
- package/src/layout/stately.test.ts +246 -0
- package/src/layout/stately.ts +528 -0
- package/src/layout-animation.test.ts +223 -0
- package/src/layout-contract.test.ts +414 -0
- package/src/marker.test.ts +23 -0
- package/src/marker.ts +23 -0
- package/src/measurement-anchor.test.ts +232 -0
- package/src/minimap.test.ts +96 -0
- package/src/minimap.ts +137 -0
- package/src/nested-fixture.test.ts +178 -0
- package/src/port-measurement.test.ts +27 -0
- package/src/port-measurements.test.ts +187 -0
- package/src/profile.ts +124 -0
- package/src/projections.test.ts +103 -0
- package/src/projections.ts +295 -0
- package/src/render-invalidation.test.ts +62 -0
- package/src/render-invalidation.ts +55 -0
- package/src/renderer-geometry.test.ts +356 -0
- package/src/renderer-transactions.test.ts +234 -0
- package/src/routing/avoid.ts +417 -0
- package/src/routing/index.test.ts +361 -0
- package/src/routing/index.ts +366 -0
- package/src/routing/readTracking.test.ts +103 -0
- package/src/routing/readTracking.ts +233 -0
- package/src/selection-commands.test.ts +355 -0
- package/src/serialize.test.ts +167 -0
- package/src/serialize.ts +254 -0
- package/src/shapes/index.test.ts +45 -0
- package/src/shapes/index.ts +142 -0
- package/src/snap.test.ts +123 -0
- package/src/snap.ts +395 -0
- package/src/spatial.test.ts +676 -0
- package/src/spatial.ts +457 -0
- package/src/store/index.ts +4121 -0
- package/src/store.test.ts +2903 -0
- package/src/toolbar.test.ts +31 -0
- package/src/toolbar.ts +62 -0
- package/src/types.test.ts +15 -0
- package/src/types.ts +487 -0
- package/src/validation.ts +558 -0
- package/src/view.ts +172 -0
- package/src/viewport/animate.ts +285 -0
- package/src/viewport/index.ts +296 -0
- package/src/viewport.test.ts +569 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
export type FlowKeyBinding = string | string[] | null;
|
|
2
|
+
|
|
3
|
+
export type FlowMultiSelectModifier = 'shift' | 'meta' | 'ctrl' | 'alt';
|
|
4
|
+
|
|
5
|
+
export type FlowKeymap = {
|
|
6
|
+
delete: FlowKeyBinding;
|
|
7
|
+
undo: FlowKeyBinding;
|
|
8
|
+
redo: FlowKeyBinding;
|
|
9
|
+
selectAll: FlowKeyBinding;
|
|
10
|
+
cancel: FlowKeyBinding;
|
|
11
|
+
nudgeUp: FlowKeyBinding;
|
|
12
|
+
nudgeDown: FlowKeyBinding;
|
|
13
|
+
nudgeLeft: FlowKeyBinding;
|
|
14
|
+
nudgeRight: FlowKeyBinding;
|
|
15
|
+
nudgeLargeModifier: 'shift' | 'meta' | 'ctrl' | 'alt' | null;
|
|
16
|
+
/**
|
|
17
|
+
* Modifier(s) that turn a click into an additive (multi) select. A single
|
|
18
|
+
* modifier or an array of them; multi-select fires when ANY listed modifier
|
|
19
|
+
* is held. `null` disables multi-select entirely. The default is the explicit
|
|
20
|
+
* legacy set `['shift','meta','ctrl']`; set exactly `'shift'` for shift-only.
|
|
21
|
+
*/
|
|
22
|
+
multiSelectModifier:
|
|
23
|
+
| FlowMultiSelectModifier
|
|
24
|
+
| FlowMultiSelectModifier[]
|
|
25
|
+
| null;
|
|
26
|
+
panActivation: FlowKeyBinding;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const defaultKeymap: FlowKeymap = {
|
|
30
|
+
delete: ['Delete', 'Backspace'],
|
|
31
|
+
undo: 'mod+z',
|
|
32
|
+
redo: ['mod+shift+z', 'mod+y'],
|
|
33
|
+
selectAll: 'mod+a',
|
|
34
|
+
cancel: 'Escape',
|
|
35
|
+
nudgeUp: 'ArrowUp',
|
|
36
|
+
nudgeDown: 'ArrowDown',
|
|
37
|
+
nudgeLeft: 'ArrowLeft',
|
|
38
|
+
nudgeRight: 'ArrowRight',
|
|
39
|
+
nudgeLargeModifier: 'shift',
|
|
40
|
+
multiSelectModifier: ['shift', 'meta', 'ctrl'],
|
|
41
|
+
panActivation: ' ',
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export function resolveKeymap(keymap?: Partial<FlowKeymap>): FlowKeymap {
|
|
45
|
+
return { ...defaultKeymap, ...keymap };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type FlowInputModifiers = {
|
|
49
|
+
shift: boolean;
|
|
50
|
+
meta: boolean;
|
|
51
|
+
ctrl: boolean;
|
|
52
|
+
alt: boolean;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Whether the active modifiers satisfy the keymap's `multiSelectModifier`.
|
|
57
|
+
*
|
|
58
|
+
* The field is one modifier or an array of them; multi-select fires when ANY
|
|
59
|
+
* listed modifier is held. `null` disables multi-select entirely (never a multi
|
|
60
|
+
* intent). The default is the explicit legacy set `['shift','meta','ctrl']`.
|
|
61
|
+
*/
|
|
62
|
+
export function matchesMultiSelect(
|
|
63
|
+
modifiers: FlowInputModifiers,
|
|
64
|
+
keymap: FlowKeymap,
|
|
65
|
+
): boolean {
|
|
66
|
+
const modifier = keymap.multiSelectModifier;
|
|
67
|
+
if (modifier === null) return false;
|
|
68
|
+
const list = Array.isArray(modifier) ? modifier : [modifier];
|
|
69
|
+
return list.some((m) => modifiers[m]);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function matchesKeyBinding(
|
|
73
|
+
event: {
|
|
74
|
+
key: string;
|
|
75
|
+
modifiers: { shift: boolean; meta: boolean; ctrl: boolean; alt: boolean };
|
|
76
|
+
},
|
|
77
|
+
binding: FlowKeyBinding,
|
|
78
|
+
): boolean {
|
|
79
|
+
if (binding == null) return false;
|
|
80
|
+
const bindings = Array.isArray(binding) ? binding : [binding];
|
|
81
|
+
return bindings.some((candidate) => matchesOneKeyBinding(event, candidate));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function matchesOneKeyBinding(
|
|
85
|
+
event: {
|
|
86
|
+
key: string;
|
|
87
|
+
modifiers: { shift: boolean; meta: boolean; ctrl: boolean; alt: boolean };
|
|
88
|
+
},
|
|
89
|
+
binding: string,
|
|
90
|
+
): boolean {
|
|
91
|
+
if (binding === ' ') return event.key === ' ';
|
|
92
|
+
const parts = binding.split('+').map((part) => part.trim()).filter(Boolean);
|
|
93
|
+
const key = parts.pop() ?? '';
|
|
94
|
+
const required = new Set(parts.map((part) => part.toLowerCase()));
|
|
95
|
+
if (key.toLowerCase() !== event.key.toLowerCase()) return false;
|
|
96
|
+
const usesMod = required.has('mod');
|
|
97
|
+
if (usesMod && !(event.modifiers.meta || event.modifiers.ctrl)) return false;
|
|
98
|
+
if (required.has('shift') && !event.modifiers.shift) return false;
|
|
99
|
+
if (required.has('meta') && !event.modifiers.meta) return false;
|
|
100
|
+
if (required.has('ctrl') && !event.modifiers.ctrl) return false;
|
|
101
|
+
if (required.has('alt') && !event.modifiers.alt) return false;
|
|
102
|
+
// Reject extra META/CTRL/ALT not required by the binding (e.g. Cmd+Backspace
|
|
103
|
+
// must NOT match a plain Backspace delete). Extra SHIFT is tolerated so a
|
|
104
|
+
// binding without shift still matches when shift is held (large-nudge arrows,
|
|
105
|
+
// Escape mid-box-select, mod+shift+z falling through to mod+z). `mod` counts
|
|
106
|
+
// as covering both meta and ctrl.
|
|
107
|
+
if (event.modifiers.meta && !required.has('meta') && !usesMod) return false;
|
|
108
|
+
if (event.modifiers.ctrl && !required.has('ctrl') && !usesMod) return false;
|
|
109
|
+
if (event.modifiers.alt && !required.has('alt')) return false;
|
|
110
|
+
return true;
|
|
111
|
+
}
|