@dou-ui/flow 0.0.0-stage → 0.1.0-alpha.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 +10 -2
- package/dist/collaboration/index.js +360 -0
- package/dist/collaboration/index.js.map +1 -0
- package/dist/collaboration/peers.js +76 -0
- package/dist/collaboration/peers.js.map +1 -0
- package/dist/components/default-node.js +6 -0
- package/dist/components/default-node.js.map +1 -0
- package/dist/components/default-node.vue_vue_type_script_setup_true_lang.js +87 -0
- package/dist/components/default-node.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/default-node2.js +116 -0
- package/dist/components/default-node2.js.map +1 -0
- package/dist/components/flow-controls.js +6 -0
- package/dist/components/flow-controls.js.map +1 -0
- package/dist/components/flow-controls.vue_vue_type_script_setup_true_lang.js +148 -0
- package/dist/components/flow-controls.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/flow-menu.js +6 -0
- package/dist/components/flow-menu.js.map +1 -0
- package/dist/components/flow-menu.vue_vue_type_script_setup_true_lang.js +52 -0
- package/dist/components/flow-menu.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/flow-minimap.js +6 -0
- package/dist/components/flow-minimap.js.map +1 -0
- package/dist/components/flow-minimap.vue_vue_type_script_setup_true_lang.js +238 -0
- package/dist/components/flow-minimap.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/flow-port.js +6 -0
- package/dist/components/flow-port.js.map +1 -0
- package/dist/components/flow-port.vue_vue_type_script_setup_true_lang.js +57 -0
- package/dist/components/flow-port.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/flow-quick-add.js +6 -0
- package/dist/components/flow-quick-add.js.map +1 -0
- package/dist/components/flow-quick-add.vue_vue_type_script_setup_true_lang.js +126 -0
- package/dist/components/flow-quick-add.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/flow-toolbar.js +6 -0
- package/dist/components/flow-toolbar.js.map +1 -0
- package/dist/components/flow-toolbar.vue_vue_type_script_setup_true_lang.js +161 -0
- package/dist/components/flow-toolbar.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/group-node.js +6 -0
- package/dist/components/group-node.js.map +1 -0
- package/dist/components/group-node.vue_vue_type_script_setup_true_lang.js +84 -0
- package/dist/components/group-node.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/group-node2.js +42 -0
- package/dist/components/group-node2.js.map +1 -0
- package/dist/components/node-view.js +6 -0
- package/dist/components/node-view.js.map +1 -0
- package/dist/components/node-view.vue_vue_type_script_setup_true_lang.js +179 -0
- package/dist/components/node-view.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/context.js +13 -0
- package/dist/context.js.map +1 -0
- package/dist/core/clipboard.js +37 -0
- package/dist/core/clipboard.js.map +1 -0
- package/dist/core/connect.js +74 -0
- package/dist/core/connect.js.map +1 -0
- package/dist/core/edge-types.js +240 -0
- package/dist/core/edge-types.js.map +1 -0
- package/dist/core/extension.js +63 -0
- package/dist/core/extension.js.map +1 -0
- package/dist/core/geometry.js +232 -0
- package/dist/core/geometry.js.map +1 -0
- package/dist/core/groups.js +76 -0
- package/dist/core/groups.js.map +1 -0
- package/dist/core/history.js +79 -0
- package/dist/core/history.js.map +1 -0
- package/dist/core/model.js +21 -0
- package/dist/core/model.js.map +1 -0
- package/dist/core/node-types.js +32 -0
- package/dist/core/node-types.js.map +1 -0
- package/dist/core/order.js +42 -0
- package/dist/core/order.js.map +1 -0
- package/dist/core/transaction.js +288 -0
- package/dist/core/transaction.js.map +1 -0
- package/dist/document.js +220 -0
- package/dist/document.js.map +1 -0
- package/dist/export/color.js +38 -0
- package/dist/export/color.js.map +1 -0
- package/dist/export/context.js +223 -0
- package/dist/export/context.js.map +1 -0
- package/dist/export/draw.js +249 -0
- package/dist/export/draw.js.map +1 -0
- package/dist/flow-editor.js +6 -0
- package/dist/flow-editor.js.map +1 -0
- package/dist/flow-editor.vue_vue_type_script_setup_true_lang.js +3721 -0
- package/dist/flow-editor.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/kit.js +234 -0
- package/dist/kit.js.map +1 -0
- package/dist/layers.js +150 -0
- package/dist/layers.js.map +1 -0
- package/dist/locale.js +426 -0
- package/dist/locale.js.map +1 -0
- package/dist/style.css +1 -0
- package/dist/style.d.ts +1 -0
- package/dist/style.js +8 -0
- package/dist/types/collaboration/index.d.ts +42 -0
- package/dist/types/collaboration/peers.d.ts +27 -0
- package/dist/types/components/default-node.d.ts +18 -0
- package/dist/types/components/default-node.vue.d.ts +6 -0
- package/dist/types/components/flow-controls.vue.d.ts +8 -0
- package/dist/types/components/flow-menu.vue.d.ts +29 -0
- package/dist/types/components/flow-minimap.vue.d.ts +8 -0
- package/dist/types/components/flow-port.vue.d.ts +9 -0
- package/dist/types/components/flow-quick-add.vue.d.ts +31 -0
- package/dist/types/components/flow-toolbar.vue.d.ts +25 -0
- package/dist/types/components/group-node.d.ts +13 -0
- package/dist/types/components/group-node.vue.d.ts +6 -0
- package/dist/types/components/node-view.vue.d.ts +28 -0
- package/dist/types/context.d.ts +362 -0
- package/dist/types/core/clipboard.d.ts +9 -0
- package/dist/types/core/connect.d.ts +63 -0
- package/dist/types/core/edge-types.d.ts +50 -0
- package/dist/types/core/extension.d.ts +141 -0
- package/dist/types/core/geometry.d.ts +63 -0
- package/dist/types/core/groups.d.ts +23 -0
- package/dist/types/core/history.d.ts +24 -0
- package/dist/types/core/menu.d.ts +40 -0
- package/dist/types/core/model.d.ts +87 -0
- package/dist/types/core/node-types.d.ts +103 -0
- package/dist/types/core/order.d.ts +7 -0
- package/dist/types/core/transaction.d.ts +97 -0
- package/dist/types/document.d.ts +57 -0
- package/dist/types/export/color.d.ts +7 -0
- package/dist/types/export/context.d.ts +90 -0
- package/dist/types/export/draw.d.ts +72 -0
- package/dist/types/flow-editor.vue.d.ts +63 -0
- package/dist/types/index.d.ts +202 -0
- package/dist/types/kit.d.ts +22 -0
- package/dist/types/layers.d.ts +24 -0
- package/dist/types/locale.d.ts +172 -0
- package/dist/types/whiteboard/board-draft.vue.d.ts +3 -0
- package/dist/types/whiteboard/board-node.vue.d.ts +19 -0
- package/dist/types/whiteboard/connector.d.ts +12 -0
- package/dist/types/whiteboard/draw.d.ts +5 -0
- package/dist/types/whiteboard/image.d.ts +27 -0
- package/dist/types/whiteboard/index.d.ts +6 -0
- package/dist/types/whiteboard/ink.d.ts +30 -0
- package/dist/types/whiteboard/kit.d.ts +36 -0
- package/dist/types/whiteboard/model.d.ts +79 -0
- package/dist/types/whiteboard/pen.d.ts +7 -0
- package/dist/types/whiteboard/state.d.ts +37 -0
- package/dist/types/whiteboard/transform.d.ts +67 -0
- package/dist/types/whiteboard/whiteboard-toolbar.vue.d.ts +3 -0
- package/dist/whiteboard/board-draft.js +6 -0
- package/dist/whiteboard/board-draft.js.map +1 -0
- package/dist/whiteboard/board-draft.vue_vue_type_script_setup_true_lang.js +58 -0
- package/dist/whiteboard/board-draft.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/whiteboard/board-node.js +6 -0
- package/dist/whiteboard/board-node.js.map +1 -0
- package/dist/whiteboard/board-node.vue_vue_type_script_setup_true_lang.js +332 -0
- package/dist/whiteboard/board-node.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/whiteboard/connector.js +180 -0
- package/dist/whiteboard/connector.js.map +1 -0
- package/dist/whiteboard/draw.js +68 -0
- package/dist/whiteboard/draw.js.map +1 -0
- package/dist/whiteboard/image.js +104 -0
- package/dist/whiteboard/image.js.map +1 -0
- package/dist/whiteboard/index.js +5 -0
- package/dist/whiteboard/ink.js +168 -0
- package/dist/whiteboard/ink.js.map +1 -0
- package/dist/whiteboard/kit.js +406 -0
- package/dist/whiteboard/kit.js.map +1 -0
- package/dist/whiteboard/model.js +52 -0
- package/dist/whiteboard/model.js.map +1 -0
- package/dist/whiteboard/pen.js +88 -0
- package/dist/whiteboard/pen.js.map +1 -0
- package/dist/whiteboard/state.js +26 -0
- package/dist/whiteboard/state.js.map +1 -0
- package/dist/whiteboard/transform.js +256 -0
- package/dist/whiteboard/transform.js.map +1 -0
- package/dist/whiteboard/whiteboard-toolbar.js +6 -0
- package/dist/whiteboard/whiteboard-toolbar.js.map +1 -0
- package/dist/whiteboard/whiteboard-toolbar.vue_vue_type_script_setup_true_lang.js +171 -0
- package/dist/whiteboard/whiteboard-toolbar.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/package.json +74 -4
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type NodeViewProps } from '../core/node-types';
|
|
2
|
+
import type { DefaultNodeData } from './default-node';
|
|
3
|
+
type __VLS_Props = NodeViewProps<DefaultNodeData>;
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
5
|
+
declare const _default: typeof __VLS_export;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type FlowControlsProps } from '../context';
|
|
2
|
+
declare const __VLS_export: import("vue").DefineComponent<FlowControlsProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<FlowControlsProps> & Readonly<{}>, {
|
|
3
|
+
tidy: boolean;
|
|
4
|
+
history: boolean;
|
|
5
|
+
placement: import("..").FlowPanelPlacement;
|
|
6
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
declare const _default: typeof __VLS_export;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ContextMenuItem } from 'dou-ui';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
items: ContextMenuItem[];
|
|
4
|
+
};
|
|
5
|
+
type __VLS_ModelProps = {
|
|
6
|
+
'open'?: boolean;
|
|
7
|
+
};
|
|
8
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
9
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
10
|
+
/**
|
|
11
|
+
* `box` makes (x, y) the top left of a box the menu opens beside, e.g. the
|
|
12
|
+
* button that opened it; `focusChecked` puts focus on the option in use,
|
|
13
|
+
* for a menu opened from the keyboard.
|
|
14
|
+
*/
|
|
15
|
+
open(x: number, y: number, { box, focusChecked, }?: {
|
|
16
|
+
box?: {
|
|
17
|
+
width: number;
|
|
18
|
+
height: number;
|
|
19
|
+
};
|
|
20
|
+
focusChecked?: boolean;
|
|
21
|
+
}): void;
|
|
22
|
+
close: () => void | undefined;
|
|
23
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
24
|
+
"update:open": (value: boolean) => any;
|
|
25
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
26
|
+
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
27
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
28
|
+
declare const _default: typeof __VLS_export;
|
|
29
|
+
export default _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type FlowMinimapProps } from '../context';
|
|
2
|
+
declare const __VLS_export: import("vue").DefineComponent<FlowMinimapProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<FlowMinimapProps> & Readonly<{}>, {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
placement: import("..").FlowPanelPlacement;
|
|
6
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
7
|
+
declare const _default: typeof __VLS_export;
|
|
8
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
/** The id of one of the node's ports. */
|
|
3
|
+
id: string;
|
|
4
|
+
/** @internal placed by the editor, not by the node's component */
|
|
5
|
+
auto?: boolean;
|
|
6
|
+
};
|
|
7
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Point } from '../core/model';
|
|
2
|
+
import type { NodeTypeSpec } from '../core/node-types';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
/** Where the edge was dropped, on screen, and the types offered. */
|
|
5
|
+
state: {
|
|
6
|
+
client: Point;
|
|
7
|
+
types: NodeTypeSpec[];
|
|
8
|
+
touch: boolean;
|
|
9
|
+
} | null;
|
|
10
|
+
};
|
|
11
|
+
type __VLS_Slots = {
|
|
12
|
+
/** Replaces the search list. */
|
|
13
|
+
default?: (props: {
|
|
14
|
+
types: NodeTypeSpec[];
|
|
15
|
+
choose: (type: string) => void;
|
|
16
|
+
close: () => void;
|
|
17
|
+
}) => unknown;
|
|
18
|
+
};
|
|
19
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
20
|
+
choose: (type: string | null) => any;
|
|
21
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
22
|
+
onChoose?: ((type: string | null) => any) | undefined;
|
|
23
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
24
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
25
|
+
declare const _default: typeof __VLS_export;
|
|
26
|
+
export default _default;
|
|
27
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
28
|
+
new (): {
|
|
29
|
+
$slots: S;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { FlowToolbarItem } from '../core/menu';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/** Each extension's buttons, with a divider between them. */
|
|
4
|
+
groups: FlowToolbarItem[][];
|
|
5
|
+
/** The selection on screen, in px from the editor's top left. */
|
|
6
|
+
anchor: {
|
|
7
|
+
x: number;
|
|
8
|
+
top: number;
|
|
9
|
+
bottom: number;
|
|
10
|
+
/** Boxes it should rather not cover, e.g. nodes beside selected edges, in the same px. */
|
|
11
|
+
avoid?: {
|
|
12
|
+
left: number;
|
|
13
|
+
top: number;
|
|
14
|
+
right: number;
|
|
15
|
+
bottom: number;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
size: {
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
24
|
+
declare const _default: typeof __VLS_export;
|
|
25
|
+
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface GroupNodeData {
|
|
2
|
+
[key: string]: unknown;
|
|
3
|
+
/** The title. */
|
|
4
|
+
label?: string;
|
|
5
|
+
/** Folded to its title; the nodes inside are hidden and their edges end on it. */
|
|
6
|
+
collapsed?: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A titled frame that holds other nodes: nodes dropped inside move with it,
|
|
10
|
+
* and it folds down to its title. Not in the palette; add
|
|
11
|
+
* `{ ...groupNode, palette: { label } }` to offer it there.
|
|
12
|
+
*/
|
|
13
|
+
export declare const groupNode: import("..").NodeTypeSpec<GroupNodeData>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { NodeViewProps } from '../core/node-types';
|
|
2
|
+
import type { GroupNodeData } from './group-node';
|
|
3
|
+
type __VLS_Props = NodeViewProps<GroupNodeData>;
|
|
4
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
5
|
+
declare const _default: typeof __VLS_export;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type NodeMetrics, type PortState } from '../context';
|
|
2
|
+
import type { FlowNode } from '../core/model';
|
|
3
|
+
import { type NodeTypeSpec } from '../core/node-types';
|
|
4
|
+
type __VLS_Props = {
|
|
5
|
+
node: FlowNode;
|
|
6
|
+
spec: NodeTypeSpec | undefined;
|
|
7
|
+
selected: boolean;
|
|
8
|
+
readonly: boolean;
|
|
9
|
+
dragging: boolean;
|
|
10
|
+
connected: Set<string>;
|
|
11
|
+
portStates: Map<string, PortState> | null;
|
|
12
|
+
roleDescription: string;
|
|
13
|
+
/** The node's accessible name. */
|
|
14
|
+
label: string;
|
|
15
|
+
/** Read out after the name, e.g. the port counts. */
|
|
16
|
+
description: string;
|
|
17
|
+
/** Where the nodes being dragged will be put. */
|
|
18
|
+
dropTarget?: boolean;
|
|
19
|
+
};
|
|
20
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
21
|
+
measure: (id: string, metrics: NodeMetrics) => any;
|
|
22
|
+
update: (id: string, patch: Record<string, unknown>) => any;
|
|
23
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
24
|
+
onMeasure?: ((id: string, metrics: NodeMetrics) => any) | undefined;
|
|
25
|
+
onUpdate?: ((id: string, patch: Record<string, unknown>) => any) | undefined;
|
|
26
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
27
|
+
declare const _default: typeof __VLS_export;
|
|
28
|
+
export default _default;
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
import type { ContextMenuItem } from 'dou-ui';
|
|
2
|
+
import type { FlowExportOptions, FlowImageOptions } from './export/draw';
|
|
3
|
+
import type { FlowTree } from './core/groups';
|
|
4
|
+
import { type ComputedRef, type InjectionKey, type Ref, type ShallowRef } from 'vue';
|
|
5
|
+
import type { FlowMessages, FlowMessagesOverride } from './locale';
|
|
6
|
+
import type { FlowData, FlowDocument, FlowEndpoint, FlowNode, FlowPortSpec, FlowSelection, FlowViewport, Point, PortSide, Rect } from './core/model';
|
|
7
|
+
import type { FlowConnection, PortTypes, PortTypeSpec } from './core/connect';
|
|
8
|
+
import type { EdgeTypeSpec } from './core/edge-types';
|
|
9
|
+
import type { FlowExtension } from './core/extension';
|
|
10
|
+
import type { FlowMenuTarget } from './core/menu';
|
|
11
|
+
import type { NodeTypeSpec } from './core/node-types';
|
|
12
|
+
import type { FlowTransaction, FlowTransactionMeta } from './core/transaction';
|
|
13
|
+
export type FlowPanelPlacement = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
14
|
+
export interface FlowControlsProps {
|
|
15
|
+
/** Corner of the editor to sit in. */
|
|
16
|
+
placement?: FlowPanelPlacement;
|
|
17
|
+
/** Show undo and redo. */
|
|
18
|
+
history?: boolean;
|
|
19
|
+
/** Show the tidy button, which lays the nodes out along their edges. */
|
|
20
|
+
tidy?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface FlowMinimapProps {
|
|
23
|
+
/** Corner of the editor to sit in. */
|
|
24
|
+
placement?: FlowPanelPlacement;
|
|
25
|
+
/** Size of the map in px. */
|
|
26
|
+
width?: number;
|
|
27
|
+
height?: number;
|
|
28
|
+
}
|
|
29
|
+
/** What the find panel looks for: text in the nodes' names. */
|
|
30
|
+
export interface FlowSearchQuery {
|
|
31
|
+
search: string;
|
|
32
|
+
/** Tell capital letters from small ones. */
|
|
33
|
+
caseSensitive?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface FlowEditorProps {
|
|
36
|
+
/**
|
|
37
|
+
* What the editor is made of: node types, port types, rules, keys and
|
|
38
|
+
* layers. `flowKit()` by default.
|
|
39
|
+
*/
|
|
40
|
+
extensions?: (FlowExtension | FlowExtension[])[];
|
|
41
|
+
/** Node types besides the extensions'; they win over an extension's type of the same name. */
|
|
42
|
+
nodeTypes?: NodeTypeSpec<any>[];
|
|
43
|
+
/** Edge types besides the extensions'; they win over an extension's type of the same name. */
|
|
44
|
+
edgeTypes?: EdgeTypeSpec<any>[];
|
|
45
|
+
/** The type of edges without `type`, new ones included. `bezier` by default. */
|
|
46
|
+
edgeType?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Below this zoom nodes are drawn as plain boxes with their names, which
|
|
49
|
+
* keeps a large flow quick; see the `simple` slot. `0` never does. `0.4` by default.
|
|
50
|
+
*/
|
|
51
|
+
simpleZoom?: number;
|
|
52
|
+
/** Grid step for snapping and arrow keys, in px. `0` turns snapping to the grid off. */
|
|
53
|
+
grid?: number;
|
|
54
|
+
/** Line nodes up with their neighbours while dragging. */
|
|
55
|
+
guides?: boolean;
|
|
56
|
+
minZoom?: number;
|
|
57
|
+
maxZoom?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Which way the flow runs: `horizontal` left to right, `vertical` top to
|
|
60
|
+
* bottom. Tidying lays nodes out this way.
|
|
61
|
+
*/
|
|
62
|
+
direction?: 'horizontal' | 'vertical';
|
|
63
|
+
/** Fit all nodes into view once they are measured. */
|
|
64
|
+
fitView?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* The furthest `fit-view` zooms out, so text stays readable; a larger flow
|
|
67
|
+
* starts at its top left and is panned to. `0` always fits everything.
|
|
68
|
+
*/
|
|
69
|
+
fitMinZoom?: number;
|
|
70
|
+
/** View, select and pan, but not change anything. */
|
|
71
|
+
readonly?: boolean;
|
|
72
|
+
/** The built-in find panel (`Ctrl/⌘+F`). Off, the keys are left to the page. On by default. */
|
|
73
|
+
searchable?: boolean;
|
|
74
|
+
/** Scrolling pans the canvas; with Ctrl / ⌘ it zooms. Off, only Ctrl / ⌘ + scroll zooms. */
|
|
75
|
+
panOnScroll?: boolean;
|
|
76
|
+
/** Looks and connection rules of port types, by the name used in `dataType`. */
|
|
77
|
+
portTypes?: PortTypes;
|
|
78
|
+
/** Refuse edges that would close a cycle. */
|
|
79
|
+
acyclic?: boolean;
|
|
80
|
+
/**
|
|
81
|
+
* The last check before an edge is made. Return `false` to refuse it, or a
|
|
82
|
+
* sentence saying why. Called for every port while an edge is dragged.
|
|
83
|
+
*/
|
|
84
|
+
canConnect?: (connection: FlowConnection, doc: FlowDocument) => boolean | string;
|
|
85
|
+
/** Accessible name of the canvas. */
|
|
86
|
+
ariaLabel?: string;
|
|
87
|
+
/** Texts to change; only the ones given are replaced. */
|
|
88
|
+
messages?: FlowMessagesOverride;
|
|
89
|
+
}
|
|
90
|
+
export interface FlowEditorEmits {
|
|
91
|
+
/** Every change to the document, with its steps; `update:modelValue` follows. */
|
|
92
|
+
transaction: [tr: FlowTransaction];
|
|
93
|
+
/**
|
|
94
|
+
* An extension's `transaction` hook cancelled a change; `tr.cancelReason`
|
|
95
|
+
* says why, and the editor shows it and reads it out.
|
|
96
|
+
*/
|
|
97
|
+
transactionCancel: [tr: FlowTransaction];
|
|
98
|
+
nodeClick: [node: FlowNode, event: MouseEvent];
|
|
99
|
+
nodeDblclick: [node: FlowNode, event: MouseEvent];
|
|
100
|
+
nodeContextmenu: [node: FlowNode, event: MouseEvent];
|
|
101
|
+
edgeClick: [edge: FlowDocument['edges'][number], event: MouseEvent];
|
|
102
|
+
edgeContextmenu: [edge: FlowDocument['edges'][number], event: MouseEvent];
|
|
103
|
+
/** Clicking the empty canvas; `point` is in canvas coordinates. */
|
|
104
|
+
canvasClick: [point: Point, event: MouseEvent];
|
|
105
|
+
/**
|
|
106
|
+
* Right click or long press on the empty canvas. The context menu events
|
|
107
|
+
* come before the editor's own menu; `event.preventDefault()` keeps it closed.
|
|
108
|
+
*/
|
|
109
|
+
canvasContextmenu: [point: Point, event: MouseEvent];
|
|
110
|
+
/** An edge was drawn, or moved to another port. */
|
|
111
|
+
connect: [edge: FlowDocument['edges'][number]];
|
|
112
|
+
/**
|
|
113
|
+
* A new edge was dropped on empty canvas; `point` is where, in canvas
|
|
114
|
+
* coordinates. The editor then offers the node types that can take the
|
|
115
|
+
* edge; `event.preventDefault()` handles it yourself instead.
|
|
116
|
+
*/
|
|
117
|
+
connectToCanvas: [from: Required<FlowEndpoint>, point: Point, event: MouseEvent];
|
|
118
|
+
}
|
|
119
|
+
export interface FlowEditorExpose {
|
|
120
|
+
/** Applies changes as one transaction, one undo step. */
|
|
121
|
+
transact: (fn: (tr: FlowTransaction) => void, meta?: FlowTransactionMeta) => FlowTransaction;
|
|
122
|
+
undo: () => boolean;
|
|
123
|
+
redo: () => boolean;
|
|
124
|
+
readonly canUndo: boolean;
|
|
125
|
+
readonly canRedo: boolean;
|
|
126
|
+
/** Shows all nodes, or the given ones. */
|
|
127
|
+
fit: (ids?: string[]) => void;
|
|
128
|
+
zoomTo: (zoom: number) => void;
|
|
129
|
+
zoomIn: () => void;
|
|
130
|
+
zoomOut: () => void;
|
|
131
|
+
/** Centers a node in view without changing the zoom. */
|
|
132
|
+
centerNode: (id: string) => void;
|
|
133
|
+
/** Opens the find panel (`Ctrl/⌘+F`), with a query put in; `false` when `searchable` is off. */
|
|
134
|
+
openSearch: (query?: Partial<FlowSearchQuery>) => boolean;
|
|
135
|
+
/** Closes the find panel; `false` when it was not open. */
|
|
136
|
+
closeSearch: () => boolean;
|
|
137
|
+
/** The ids of the nodes whose names contain the search, in reading order. */
|
|
138
|
+
findNodes: (query: FlowSearchQuery) => string[];
|
|
139
|
+
/**
|
|
140
|
+
* Moves the view like the user's pans do: no further than having the nodes
|
|
141
|
+
* just leave it. `v-model:viewport` goes anywhere.
|
|
142
|
+
*/
|
|
143
|
+
setViewport: (viewport: FlowViewport, animate?: boolean) => void;
|
|
144
|
+
/** Converts a point on screen (client coordinates) to canvas coordinates. */
|
|
145
|
+
toCanvas: (point: Point) => Point;
|
|
146
|
+
/** A node's measured box in canvas coordinates. */
|
|
147
|
+
getNodeRect: (id: string) => Rect | null;
|
|
148
|
+
/**
|
|
149
|
+
* The flow as an SVG document, as it looks now: every node and edge, what
|
|
150
|
+
* is in view, or the selected ones (it throws when nothing is selected). Colors are written as `rgb(…)`, `rgba(…)` or `#rrggbb`, so
|
|
151
|
+
* vector editors read them; nodes are drawn by their type's `draw`.
|
|
152
|
+
*/
|
|
153
|
+
exportSVG: (options?: FlowExportOptions) => string;
|
|
154
|
+
/** The flow as a PNG image, with images embedded where their address can be read. */
|
|
155
|
+
exportPNG: (options?: FlowImageOptions) => Promise<Blob>;
|
|
156
|
+
/**
|
|
157
|
+
* Lays nodes out in columns along their edges, as one undo step: the given
|
|
158
|
+
* ones, the selection when two or more nodes are selected, or all.
|
|
159
|
+
*/
|
|
160
|
+
tidy: (ids?: string[]) => void;
|
|
161
|
+
/**
|
|
162
|
+
* Ids of edges whose ports no longer fit: a port is gone, or the types of
|
|
163
|
+
* its two ends don't match any more. They are drawn red and dashed.
|
|
164
|
+
*/
|
|
165
|
+
readonly staleEdges: string[];
|
|
166
|
+
/** Removes the stale edges as one undo step; returns how many. */
|
|
167
|
+
removeStaleEdges: () => number;
|
|
168
|
+
/**
|
|
169
|
+
* Adds a node of a type with its defaults and selects it, as one undo
|
|
170
|
+
* step; returns its id. See `FlowInsertOptions` for where it goes.
|
|
171
|
+
*/
|
|
172
|
+
insertNode: (type: string, options?: FlowInsertOptions) => string | null;
|
|
173
|
+
/**
|
|
174
|
+
* Starts dragging a new node of a type from `event`, a `pointerdown` on
|
|
175
|
+
* any element on the page; letting go over the canvas adds it there, and
|
|
176
|
+
* Escape cancels. The click that ends a drag is stopped. Returns `false`
|
|
177
|
+
* when nothing was started.
|
|
178
|
+
*/
|
|
179
|
+
startInsertDrag: (type: string, event: PointerEvent) => boolean;
|
|
180
|
+
/** Node types with a `palette` entry, in the order they were given. */
|
|
181
|
+
readonly paletteTypes: NodeTypeSpec[];
|
|
182
|
+
/** Selects an edge and opens the text field on its label. */
|
|
183
|
+
editLabel: (id: string) => void;
|
|
184
|
+
/**
|
|
185
|
+
* Puts nodes, the selected ones by default, into a new container of
|
|
186
|
+
* `type` (`'group'` by default) drawn around them, as one undo step;
|
|
187
|
+
* returns its id, or `null` when nothing was grouped.
|
|
188
|
+
*/
|
|
189
|
+
groupNodes: (ids?: string[], type?: string) => string | null;
|
|
190
|
+
/** Removes a container and keeps the nodes inside, as one undo step. */
|
|
191
|
+
ungroupNode: (id: string) => boolean;
|
|
192
|
+
/**
|
|
193
|
+
* Takes nodes, the selected ones by default, out of their groups and puts
|
|
194
|
+
* them just below, as one undo step; returns how many moved.
|
|
195
|
+
*/
|
|
196
|
+
leaveGroup: (ids?: string[]) => number;
|
|
197
|
+
}
|
|
198
|
+
export interface FlowEditorSlots {
|
|
199
|
+
/** Panels over the canvas, e.g. `DouFlowControls`. */
|
|
200
|
+
default?: () => unknown;
|
|
201
|
+
/** What follows the pointer while a new node is dragged in. */
|
|
202
|
+
ghost?: (props: {
|
|
203
|
+
spec: NodeTypeSpec;
|
|
204
|
+
over: boolean;
|
|
205
|
+
}) => unknown;
|
|
206
|
+
/** Replaces the list offered when an edge is dropped on the empty canvas. */
|
|
207
|
+
quickAdd?: (props: {
|
|
208
|
+
types: NodeTypeSpec[];
|
|
209
|
+
choose: (type: string) => void;
|
|
210
|
+
close: () => void;
|
|
211
|
+
}) => unknown;
|
|
212
|
+
/** A node's content while zoomed out past `simple-zoom`; its name by default. */
|
|
213
|
+
simple?: (props: {
|
|
214
|
+
node: FlowNode;
|
|
215
|
+
}) => unknown;
|
|
216
|
+
}
|
|
217
|
+
export interface FlowInsertOptions {
|
|
218
|
+
/**
|
|
219
|
+
* Where the node goes, in canvas coordinates: its centre, or with `from`,
|
|
220
|
+
* the port that takes the edge. Without it the node goes after the one
|
|
221
|
+
* selected node, connected to it when it can be, or else in the middle
|
|
222
|
+
* of the view; either way clear of other nodes.
|
|
223
|
+
*/
|
|
224
|
+
at?: Point;
|
|
225
|
+
/** Connect the new node to this port, through the first port that can take it. */
|
|
226
|
+
from?: Required<FlowEndpoint>;
|
|
227
|
+
/** Move focus to the new node, so keys such as undo act on it. `true` by default. */
|
|
228
|
+
focus?: boolean;
|
|
229
|
+
/** Merged over the type's `defaults()`. */
|
|
230
|
+
data?: FlowData;
|
|
231
|
+
/** The node's size instead of the type's `size`. */
|
|
232
|
+
size?: {
|
|
233
|
+
width?: number;
|
|
234
|
+
height?: number;
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
/** Where a port's centre is, from its node's top left corner. */
|
|
238
|
+
export interface PortAnchor extends Point {
|
|
239
|
+
side: PortSide;
|
|
240
|
+
}
|
|
241
|
+
export interface NodeMetrics {
|
|
242
|
+
width: number;
|
|
243
|
+
height: number;
|
|
244
|
+
ports: Map<string, PortAnchor>;
|
|
245
|
+
}
|
|
246
|
+
/** What `previewNode` can show changed: the box, and the data. */
|
|
247
|
+
export type FlowNodePreview = Partial<Pick<FlowNode, 'x' | 'y' | 'width' | 'height' | 'data'>>;
|
|
248
|
+
/** How a port shows while an edge is being drawn. */
|
|
249
|
+
export type PortState = 'active' | 'valid' | 'candidate' | 'refused';
|
|
250
|
+
export interface FlowEditorContext {
|
|
251
|
+
doc: Ref<FlowDocument>;
|
|
252
|
+
selection: Ref<FlowSelection>;
|
|
253
|
+
viewport: Ref<FlowViewport>;
|
|
254
|
+
/** See `FlowEditorExpose.setViewport`; writing `viewport` goes anywhere. */
|
|
255
|
+
setViewport: FlowEditorExpose['setViewport'];
|
|
256
|
+
readonly: ComputedRef<boolean>;
|
|
257
|
+
messages: ComputedRef<FlowMessages>;
|
|
258
|
+
minZoom: ComputedRef<number>;
|
|
259
|
+
maxZoom: ComputedRef<number>;
|
|
260
|
+
transact: FlowEditorExpose['transact'];
|
|
261
|
+
undo: () => boolean;
|
|
262
|
+
redo: () => boolean;
|
|
263
|
+
canUndo: Ref<boolean>;
|
|
264
|
+
canRedo: Ref<boolean>;
|
|
265
|
+
fit: FlowEditorExpose['fit'];
|
|
266
|
+
zoomTo: FlowEditorExpose['zoomTo'];
|
|
267
|
+
zoomIn: () => void;
|
|
268
|
+
zoomOut: () => void;
|
|
269
|
+
/** The registered type of a port, if any. */
|
|
270
|
+
portTypeOf: (port: FlowPortSpec) => PortTypeSpec | undefined;
|
|
271
|
+
/** A port type's color as CSS. */
|
|
272
|
+
colorOf: (spec: PortTypeSpec | undefined) => string | undefined;
|
|
273
|
+
getNodeRect: FlowEditorExpose['getNodeRect'];
|
|
274
|
+
exportSVG: FlowEditorExpose['exportSVG'];
|
|
275
|
+
exportPNG: FlowEditorExpose['exportPNG'];
|
|
276
|
+
tidy: FlowEditorExpose['tidy'];
|
|
277
|
+
centerNode: FlowEditorExpose['centerNode'];
|
|
278
|
+
/** Says `text` to screen readers. */
|
|
279
|
+
announce: (text: string) => void;
|
|
280
|
+
/** The editor's size on screen, in px. */
|
|
281
|
+
size: Ref<{
|
|
282
|
+
width: number;
|
|
283
|
+
height: number;
|
|
284
|
+
}>;
|
|
285
|
+
selectedNodes: ComputedRef<Set<string>>;
|
|
286
|
+
insertNode: FlowEditorExpose['insertNode'];
|
|
287
|
+
/** Node types with a `palette` entry, in the order they were given. */
|
|
288
|
+
paletteTypes: ComputedRef<NodeTypeSpec[]>;
|
|
289
|
+
startInsertDrag: FlowEditorExpose['startInsertDrag'];
|
|
290
|
+
editLabel: FlowEditorExpose['editLabel'];
|
|
291
|
+
groupNodes: FlowEditorExpose['groupNodes'];
|
|
292
|
+
ungroupNode: FlowEditorExpose['ungroupNode'];
|
|
293
|
+
leaveGroup: FlowEditorExpose['leaveGroup'];
|
|
294
|
+
/** Which node is inside which, from the nodes' `parent`. */
|
|
295
|
+
tree: ComputedRef<FlowTree>;
|
|
296
|
+
/** Whether the node's type can hold other nodes. */
|
|
297
|
+
isContainer: (node: FlowNode) => boolean;
|
|
298
|
+
/** How far the node is drawn turned about its centre, from its type's `rotation`. */
|
|
299
|
+
nodeRotation: (id: string) => number;
|
|
300
|
+
/**
|
|
301
|
+
* While nodes are moved or resized, or an edge is bent: the document
|
|
302
|
+
* changes on every frame until the pointer is let go.
|
|
303
|
+
*/
|
|
304
|
+
gesturing: ComputedRef<boolean>;
|
|
305
|
+
/**
|
|
306
|
+
* Shows a node as if `patch` were applied, without changing the document:
|
|
307
|
+
* its frame, ports, edges and `getNodeRect` all follow. For handles that
|
|
308
|
+
* change the document once, when let go; `null` shows it as it is again,
|
|
309
|
+
* and must be passed when the drag ends or is cancelled. `patch.data`
|
|
310
|
+
* replaces the node's data, it is not merged. Only this editor shows it:
|
|
311
|
+
* peers see the change once it is committed. A preview is dropped when
|
|
312
|
+
* its node leaves the document.
|
|
313
|
+
*/
|
|
314
|
+
previewNode: (id: string, patch: FlowNodePreview | null) => void;
|
|
315
|
+
/** The edge being drawn, as an SVG path in canvas coordinates. */
|
|
316
|
+
connectingPath: ComputedRef<string | null>;
|
|
317
|
+
/** The editor's element. */
|
|
318
|
+
root: Readonly<ShallowRef<HTMLElement | null>>;
|
|
319
|
+
/**
|
|
320
|
+
* Opens the context menu for a target at a point on screen; `false` when
|
|
321
|
+
* no extension has items for it. Pass the button that opens it as `from`:
|
|
322
|
+
* the menu then opens below the button instead of at the point, or above
|
|
323
|
+
* it when there is no room, and pressing the button again closes it.
|
|
324
|
+
*/
|
|
325
|
+
openMenu: (target: FlowMenuTarget, client: Point, from?: Element) => boolean;
|
|
326
|
+
/** The items the context menu has for a target, as `openMenu` shows them. */
|
|
327
|
+
menuItems: (target: FlowMenuTarget) => ContextMenuItem[];
|
|
328
|
+
/**
|
|
329
|
+
* Opens the editor's menu with these items, e.g. the choices behind a
|
|
330
|
+
* toolbar button; `from` works as in `openMenu`.
|
|
331
|
+
*/
|
|
332
|
+
showMenu: (items: ContextMenuItem[], client: Point, from?: Element, options?: {
|
|
333
|
+
focusChecked?: boolean;
|
|
334
|
+
}) => boolean;
|
|
335
|
+
/** The element that opened the menu, while it is open, e.g. to mark a button expanded. */
|
|
336
|
+
menuFrom: Readonly<ShallowRef<Element | null>>;
|
|
337
|
+
toCanvas: (point: Point) => Point;
|
|
338
|
+
/** Copies the selected nodes to the clipboard; `false` when none are selected. */
|
|
339
|
+
copy: () => boolean;
|
|
340
|
+
cut: () => boolean;
|
|
341
|
+
/** Pastes what was copied, at `at` (canvas coordinates) or next to the original. */
|
|
342
|
+
paste: (at?: Point) => Promise<boolean>;
|
|
343
|
+
/** Adds a copy of the selected nodes next to them. */
|
|
344
|
+
duplicate: () => void;
|
|
345
|
+
/** Deletes the selected nodes and edges, except locked nodes. */
|
|
346
|
+
deleteSelection: () => void;
|
|
347
|
+
selectAll: () => void;
|
|
348
|
+
}
|
|
349
|
+
export declare const flowEditorKey: InjectionKey<FlowEditorContext>;
|
|
350
|
+
/** The surrounding flow editor; for controls and panels placed in its default slot. */
|
|
351
|
+
export declare function useFlowEditor(): FlowEditorContext;
|
|
352
|
+
export interface FlowNodeContext {
|
|
353
|
+
node: ComputedRef<FlowNode>;
|
|
354
|
+
ports: ComputedRef<FlowPortSpec[]>;
|
|
355
|
+
/** Port ids with at least one edge. */
|
|
356
|
+
connected: ComputedRef<Set<string>>;
|
|
357
|
+
/** While an edge is being drawn, how each port shows; `null` otherwise. */
|
|
358
|
+
portStates: ComputedRef<Map<string, PortState> | null>;
|
|
359
|
+
registerPort: (id: string, el: HTMLElement, auto?: boolean) => void;
|
|
360
|
+
unregisterPort: (id: string, auto?: boolean) => void;
|
|
361
|
+
}
|
|
362
|
+
export declare const flowNodeKey: InjectionKey<FlowNodeContext>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { FlowDocument } from './model';
|
|
2
|
+
/** Remembers `data` and returns the text to put on the system clipboard. */
|
|
3
|
+
export declare function writeClipboard(data: FlowDocument): string;
|
|
4
|
+
/**
|
|
5
|
+
* The nodes to paste: from the system clipboard's `text` when it holds a
|
|
6
|
+
* copy, else the last copy made on this page. `null` when `text` is
|
|
7
|
+
* something else.
|
|
8
|
+
*/
|
|
9
|
+
export declare function readClipboard(text?: string | null): FlowDocument | null;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Tone } from 'dou-ui';
|
|
2
|
+
import type { FlowDocument, FlowEndpoint, FlowPortSpec } from './model';
|
|
3
|
+
export type PortShape = 'circle' | 'square' | 'diamond' | 'triangle';
|
|
4
|
+
export interface PortTypeSpec {
|
|
5
|
+
/** Shown to screen readers and in tooltips. */
|
|
6
|
+
label?: string;
|
|
7
|
+
shape?: PortShape;
|
|
8
|
+
/** A theme tone, or any CSS color. Also colors the edges leaving the port. */
|
|
9
|
+
color?: Tone | (string & {});
|
|
10
|
+
/** Edge width in px; 1 by default. */
|
|
11
|
+
edgeWidth?: number;
|
|
12
|
+
/** Draw edges of this type dashed. */
|
|
13
|
+
dashed?: boolean;
|
|
14
|
+
/** Other types a port of this type takes. */
|
|
15
|
+
accepts?: string[];
|
|
16
|
+
}
|
|
17
|
+
export type PortTypes = Record<string, PortTypeSpec>;
|
|
18
|
+
export interface FlowConnection {
|
|
19
|
+
source: Required<FlowEndpoint>;
|
|
20
|
+
target: Required<FlowEndpoint>;
|
|
21
|
+
}
|
|
22
|
+
export interface ConnectOptions {
|
|
23
|
+
portTypes?: PortTypes;
|
|
24
|
+
/** Refuse edges that would close a cycle. */
|
|
25
|
+
acyclic?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* The last check. Return `false` to refuse, or a sentence saying why, which
|
|
28
|
+
* is announced to screen readers. Called for every port while dragging.
|
|
29
|
+
*/
|
|
30
|
+
canConnect?: (connection: FlowConnection, doc: FlowDocument) => boolean | string;
|
|
31
|
+
}
|
|
32
|
+
/** Why two ports can't be joined. */
|
|
33
|
+
export type JoinRefusal = {
|
|
34
|
+
reason: 'direction' | 'self' | 'type' | 'duplicate' | 'cycle';
|
|
35
|
+
} | {
|
|
36
|
+
reason: 'custom';
|
|
37
|
+
message?: string;
|
|
38
|
+
};
|
|
39
|
+
/** The first type of a port, which decides its look. */
|
|
40
|
+
export declare const primaryType: (port: FlowPortSpec) => string | undefined;
|
|
41
|
+
/** Whether data of the output's types may flow into the input. */
|
|
42
|
+
export declare function typesMatch(output: FlowPortSpec, input: FlowPortSpec, portTypes?: PortTypes): boolean;
|
|
43
|
+
/** Whether `to` can be reached from `from` along edges. */
|
|
44
|
+
export declare function reaches(doc: FlowDocument, from: string, to: string): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Checks a connection between two ports and says why it is refused, or
|
|
47
|
+
* `null` when it is fine. `ignore` is an edge being moved, left out. A port
|
|
48
|
+
* that is full still takes the edge: the oldest of its edges makes way.
|
|
49
|
+
*/
|
|
50
|
+
export declare function joinRefusal(doc: FlowDocument, connection: FlowConnection, ports: {
|
|
51
|
+
source: FlowPortSpec;
|
|
52
|
+
target: FlowPortSpec;
|
|
53
|
+
}, options?: ConnectOptions, ignore?: string): JoinRefusal | null;
|
|
54
|
+
/** Whether two ports may be joined; see `joinRefusal`. */
|
|
55
|
+
export declare const canJoin: (...args: Parameters<typeof joinRefusal>) => boolean;
|
|
56
|
+
/**
|
|
57
|
+
* The edges that make way when an edge joins two full ports: the oldest at
|
|
58
|
+
* each end, beyond `max` (1 for inputs, unlimited for outputs by default).
|
|
59
|
+
*/
|
|
60
|
+
export declare function displacedEdges(doc: FlowDocument, connection: FlowConnection, ports: {
|
|
61
|
+
source: FlowPortSpec;
|
|
62
|
+
target: FlowPortSpec;
|
|
63
|
+
}, ignore?: string): string[];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { CSSProperties } from 'vue';
|
|
2
|
+
import type { FlowData, FlowEdge, Point, PortSide } from './model';
|
|
3
|
+
/** Where an edge leaves or enters a node: a point and the side it faces. */
|
|
4
|
+
export interface EdgeAnchor extends Point {
|
|
5
|
+
side: PortSide;
|
|
6
|
+
}
|
|
7
|
+
export interface EdgeRoute {
|
|
8
|
+
/** The SVG path, in canvas coordinates. */
|
|
9
|
+
path: string;
|
|
10
|
+
/** Where the label sits. */
|
|
11
|
+
label: Point;
|
|
12
|
+
/**
|
|
13
|
+
* A handle shown on the selected edge that moves part of it, e.g. the
|
|
14
|
+
* middle of a step edge. `axis` is the way it moves; `move` turns the
|
|
15
|
+
* pointer's canvas point into a patch for `edge.data`.
|
|
16
|
+
*/
|
|
17
|
+
handle?: {
|
|
18
|
+
at: Point;
|
|
19
|
+
axis: 'x' | 'y';
|
|
20
|
+
move: (point: Point) => FlowData;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Marks drawn with the edge's stroke but never dashed, e.g. arrowheads:
|
|
24
|
+
* an SVG path in canvas coordinates.
|
|
25
|
+
*/
|
|
26
|
+
marks?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface EdgeTypeSpec<Data extends FlowData = FlowData> {
|
|
29
|
+
type: string;
|
|
30
|
+
/** The edge's path between two anchors. `edge` is absent while one is being drawn. */
|
|
31
|
+
route: (source: EdgeAnchor, target: EdgeAnchor, edge?: FlowEdge<Data>) => EdgeRoute;
|
|
32
|
+
/** The edge's own look, e.g. `strokeDasharray`, over what its port type gives it. */
|
|
33
|
+
style?: (edge: FlowEdge<Data>) => CSSProperties | undefined;
|
|
34
|
+
}
|
|
35
|
+
/** Declares an edge type, with `edge.data` typed. */
|
|
36
|
+
export declare function defineEdgeType<Data extends FlowData = FlowData>(spec: EdgeTypeSpec<Data>): EdgeTypeSpec<Data>;
|
|
37
|
+
export declare function bezierPath(from: Point, fromSide: PortSide, to: Point, toSide: PortSide, min?: number): string;
|
|
38
|
+
/** The default: a smooth curve out of and into the ports' sides. */
|
|
39
|
+
export declare const bezierEdge: EdgeTypeSpec<FlowData>;
|
|
40
|
+
export declare const straightEdge: EdgeTypeSpec<FlowData>;
|
|
41
|
+
interface StepData extends FlowData {
|
|
42
|
+
/** Where the middle segment sits between the two ends, from 0 to 1. */
|
|
43
|
+
bend?: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Right angles with rounded corners. Between ports that face each other the
|
|
47
|
+
* middle segment can be dragged; its place is kept in `edge.data.bend`.
|
|
48
|
+
*/
|
|
49
|
+
export declare const stepEdge: EdgeTypeSpec<StepData>;
|
|
50
|
+
export {};
|