@flowgram.ai/fixed-layout-core 0.2.22 → 0.2.24
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/esm/index.js +524 -4
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +530 -17
- package/dist/index.js.map +1 -1
- package/package.json +9 -7
package/dist/esm/index.js
CHANGED
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
} from "@flowgram.ai/renderer";
|
|
27
27
|
import {
|
|
28
28
|
FlowNodeRenderData as FlowNodeRenderData4,
|
|
29
|
-
FlowNodeTransformData as
|
|
29
|
+
FlowNodeTransformData as FlowNodeTransformData5,
|
|
30
30
|
FlowNodeTransitionData
|
|
31
31
|
} from "@flowgram.ai/document";
|
|
32
32
|
import { PlaygroundLayer } from "@flowgram.ai/core";
|
|
@@ -1780,6 +1780,523 @@ var MultiInputsRegistry = {
|
|
|
1780
1780
|
}
|
|
1781
1781
|
};
|
|
1782
1782
|
|
|
1783
|
+
// src/activities/slot/slot.ts
|
|
1784
|
+
import { FlowNodeBaseType as FlowNodeBaseType28 } from "@flowgram.ai/document";
|
|
1785
|
+
|
|
1786
|
+
// src/activities/slot/utils/transition.ts
|
|
1787
|
+
import { Point as Point7 } from "@flowgram.ai/utils";
|
|
1788
|
+
import {
|
|
1789
|
+
FlowTransitionLineEnum as FlowTransitionLineEnum7,
|
|
1790
|
+
FlowTransitionLabelEnum as FlowTransitionLabelEnum15
|
|
1791
|
+
} from "@flowgram.ai/document";
|
|
1792
|
+
|
|
1793
|
+
// src/activities/slot/constants.ts
|
|
1794
|
+
import { FlowRendererKey as FlowRendererKey5 } from "@flowgram.ai/renderer";
|
|
1795
|
+
var RENDER_SLOT_ADDER_KEY = FlowRendererKey5.SLOT_ADDER;
|
|
1796
|
+
var RENDER_SLOT_COLLAPSE_KEY = FlowRendererKey5.SLOT_COLLPASE;
|
|
1797
|
+
var SLOT_BLOCK_DISTANCE = 60;
|
|
1798
|
+
var SLOT_COLLAPSE_MARGIN = 20;
|
|
1799
|
+
var SLOT_SPACING = 32;
|
|
1800
|
+
var SLOT_NODE_LAST_SPACING = 10;
|
|
1801
|
+
var SLOT_INLINE_BLOCKS_DELTA = SLOT_COLLAPSE_MARGIN + SLOT_BLOCK_DISTANCE * 2;
|
|
1802
|
+
|
|
1803
|
+
// src/activities/slot/typings.ts
|
|
1804
|
+
import { FlowNodeBaseType as FlowNodeBaseType23 } from "@flowgram.ai/document";
|
|
1805
|
+
var SlotNodeType = ((SlotNodeType2) => {
|
|
1806
|
+
SlotNodeType2[SlotNodeType2["Slot"] = FlowNodeBaseType23.SLOT] = "Slot";
|
|
1807
|
+
SlotNodeType2[SlotNodeType2["SlotBlock"] = FlowNodeBaseType23.SLOT_BLOCK] = "SlotBlock";
|
|
1808
|
+
SlotNodeType2["SlotInlineBlocks"] = "slotInlineBlocks";
|
|
1809
|
+
SlotNodeType2["SlotBlockInlineBlocks"] = "slotBlockInlineBlocks";
|
|
1810
|
+
return SlotNodeType2;
|
|
1811
|
+
})(SlotNodeType || {});
|
|
1812
|
+
|
|
1813
|
+
// src/activities/slot/utils/node.ts
|
|
1814
|
+
var canSlotDrilldown = (Slot) => !!Slot?.lastCollapsedChild?.blocks.length;
|
|
1815
|
+
var insideSlot = (entity) => !!entity?.parent?.isTypeOrExtendType(SlotNodeType.SlotBlock);
|
|
1816
|
+
var getDisplayFirstChildTransform = (transform) => {
|
|
1817
|
+
if (transform.firstChild) {
|
|
1818
|
+
return getDisplayFirstChildTransform(transform.firstChild);
|
|
1819
|
+
}
|
|
1820
|
+
return transform;
|
|
1821
|
+
};
|
|
1822
|
+
|
|
1823
|
+
// src/activities/slot/utils/transition.ts
|
|
1824
|
+
var getSlotChildLineStartPoint = (iconTransform) => {
|
|
1825
|
+
if (!iconTransform) {
|
|
1826
|
+
return { x: 0, y: 0 };
|
|
1827
|
+
}
|
|
1828
|
+
if (!iconTransform.entity.isVertical) {
|
|
1829
|
+
return {
|
|
1830
|
+
x: iconTransform?.bounds.center.x,
|
|
1831
|
+
y: iconTransform?.bounds.bottom + SLOT_COLLAPSE_MARGIN
|
|
1832
|
+
};
|
|
1833
|
+
}
|
|
1834
|
+
return {
|
|
1835
|
+
x: iconTransform?.bounds.right + SLOT_COLLAPSE_MARGIN,
|
|
1836
|
+
y: iconTransform?.bounds.center.y
|
|
1837
|
+
};
|
|
1838
|
+
};
|
|
1839
|
+
var getOutputPoint = (transform) => {
|
|
1840
|
+
const icon = transform.firstChild;
|
|
1841
|
+
if (!icon) {
|
|
1842
|
+
return { x: 0, y: 0 };
|
|
1843
|
+
}
|
|
1844
|
+
if (!transform.entity.isVertical) {
|
|
1845
|
+
return {
|
|
1846
|
+
x: transform.bounds.right,
|
|
1847
|
+
y: icon.outputPoint.y
|
|
1848
|
+
};
|
|
1849
|
+
}
|
|
1850
|
+
return {
|
|
1851
|
+
x: icon.outputPoint.x,
|
|
1852
|
+
y: transform.bounds.bottom
|
|
1853
|
+
};
|
|
1854
|
+
};
|
|
1855
|
+
var getInputPoint = (transform) => {
|
|
1856
|
+
const icon = transform.firstChild;
|
|
1857
|
+
if (!icon) {
|
|
1858
|
+
return { x: 0, y: 0 };
|
|
1859
|
+
}
|
|
1860
|
+
if (!transform.entity.isVertical) {
|
|
1861
|
+
return {
|
|
1862
|
+
x: transform.bounds.left,
|
|
1863
|
+
y: icon.outputPoint.y
|
|
1864
|
+
};
|
|
1865
|
+
}
|
|
1866
|
+
return icon.inputPoint;
|
|
1867
|
+
};
|
|
1868
|
+
var getTransitionToPoint = (transition) => {
|
|
1869
|
+
let toPoint = transition.transform.next?.inputPoint;
|
|
1870
|
+
const icon = transition.transform.firstChild;
|
|
1871
|
+
const parent = transition.transform.parent;
|
|
1872
|
+
if (!icon || !parent) {
|
|
1873
|
+
return { x: 0, y: 0 };
|
|
1874
|
+
}
|
|
1875
|
+
if (!transition.transform.next) {
|
|
1876
|
+
if (!transition.entity.isVertical) {
|
|
1877
|
+
toPoint = {
|
|
1878
|
+
x: parent.outputPoint.x,
|
|
1879
|
+
y: icon.outputPoint.y
|
|
1880
|
+
};
|
|
1881
|
+
} else {
|
|
1882
|
+
toPoint = {
|
|
1883
|
+
x: icon.outputPoint.x,
|
|
1884
|
+
y: parent.outputPoint.y
|
|
1885
|
+
};
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
return toPoint || { x: 0, y: 0 };
|
|
1889
|
+
};
|
|
1890
|
+
var drawStraightLine = (transition) => {
|
|
1891
|
+
const icon = transition.transform.firstChild;
|
|
1892
|
+
const toPoint = getTransitionToPoint(transition);
|
|
1893
|
+
if (!icon) {
|
|
1894
|
+
return [];
|
|
1895
|
+
}
|
|
1896
|
+
return [
|
|
1897
|
+
{
|
|
1898
|
+
type: FlowTransitionLineEnum7.STRAIGHT_LINE,
|
|
1899
|
+
from: icon.outputPoint,
|
|
1900
|
+
to: toPoint
|
|
1901
|
+
},
|
|
1902
|
+
{
|
|
1903
|
+
type: FlowTransitionLineEnum7.STRAIGHT_LINE,
|
|
1904
|
+
from: icon.inputPoint,
|
|
1905
|
+
to: transition.transform.inputPoint
|
|
1906
|
+
}
|
|
1907
|
+
];
|
|
1908
|
+
};
|
|
1909
|
+
var drawCollapseLabel = (transition) => {
|
|
1910
|
+
const icon = transition.transform;
|
|
1911
|
+
return [
|
|
1912
|
+
{
|
|
1913
|
+
type: FlowTransitionLabelEnum15.CUSTOM_LABEL,
|
|
1914
|
+
renderKey: RENDER_SLOT_COLLAPSE_KEY,
|
|
1915
|
+
offset: getSlotChildLineStartPoint(icon),
|
|
1916
|
+
props: {
|
|
1917
|
+
node: transition.entity.parent
|
|
1918
|
+
}
|
|
1919
|
+
}
|
|
1920
|
+
];
|
|
1921
|
+
};
|
|
1922
|
+
var drawCollapseLine = (transition) => [
|
|
1923
|
+
{
|
|
1924
|
+
type: FlowTransitionLineEnum7.STRAIGHT_LINE,
|
|
1925
|
+
from: getSlotChildLineStartPoint(transition.transform),
|
|
1926
|
+
to: Point7.move(
|
|
1927
|
+
getSlotChildLineStartPoint(transition.transform),
|
|
1928
|
+
transition.entity.isVertical ? { x: -SLOT_COLLAPSE_MARGIN, y: 0 } : { x: 0, y: -SLOT_COLLAPSE_MARGIN }
|
|
1929
|
+
),
|
|
1930
|
+
style: {
|
|
1931
|
+
strokeDasharray: "5 5"
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1934
|
+
];
|
|
1935
|
+
var drawStraightAdder = (transition) => {
|
|
1936
|
+
const toPoint = getTransitionToPoint(transition);
|
|
1937
|
+
const fromPoint = transition.transform.firstChild.outputPoint;
|
|
1938
|
+
const hoverProps = transition.entity.isVertical ? {
|
|
1939
|
+
hoverHeight: toPoint.y - fromPoint.y,
|
|
1940
|
+
hoverWidth: transition.transform.firstChild?.bounds.width
|
|
1941
|
+
} : {
|
|
1942
|
+
hoverHeight: transition.transform.firstChild?.bounds.height,
|
|
1943
|
+
hoverWidth: toPoint.x - fromPoint.x
|
|
1944
|
+
};
|
|
1945
|
+
return [
|
|
1946
|
+
{
|
|
1947
|
+
offset: Point7.getMiddlePoint(fromPoint, toPoint),
|
|
1948
|
+
type: FlowTransitionLabelEnum15.ADDER_LABEL,
|
|
1949
|
+
props: hoverProps
|
|
1950
|
+
}
|
|
1951
|
+
];
|
|
1952
|
+
};
|
|
1953
|
+
var getPortChildInput = (_child) => {
|
|
1954
|
+
if (!_child) {
|
|
1955
|
+
return { x: 0, y: 0 };
|
|
1956
|
+
}
|
|
1957
|
+
const firstChild = getDisplayFirstChildTransform(_child);
|
|
1958
|
+
return { x: _child.bounds.left, y: firstChild.bounds.center.y };
|
|
1959
|
+
};
|
|
1960
|
+
|
|
1961
|
+
// src/activities/slot/utils/layout.ts
|
|
1962
|
+
import { mean } from "lodash";
|
|
1963
|
+
var getDisplayFirstChildTop = (transform) => {
|
|
1964
|
+
if (transform.firstChild) {
|
|
1965
|
+
return transform.localBounds.top + getDisplayFirstChildTop(transform.firstChild);
|
|
1966
|
+
}
|
|
1967
|
+
return transform.localBounds.center.y;
|
|
1968
|
+
};
|
|
1969
|
+
var getPortMiddle = (_port) => {
|
|
1970
|
+
if (!_port.children.length) {
|
|
1971
|
+
return _port.localBounds.top;
|
|
1972
|
+
}
|
|
1973
|
+
const portChildInputs = [_port.firstChild, _port.lastChild].map(
|
|
1974
|
+
(_portChild) => getDisplayFirstChildTop(_portChild)
|
|
1975
|
+
);
|
|
1976
|
+
return _port.localBounds.top + mean(portChildInputs);
|
|
1977
|
+
};
|
|
1978
|
+
var getAllPortsMiddle = (inlineBlocks) => {
|
|
1979
|
+
if (!inlineBlocks.children.length) {
|
|
1980
|
+
return inlineBlocks.localBounds.height / 2;
|
|
1981
|
+
}
|
|
1982
|
+
const portInputs = [inlineBlocks.firstChild, inlineBlocks.lastChild].map(
|
|
1983
|
+
(_port) => getPortMiddle(_port)
|
|
1984
|
+
);
|
|
1985
|
+
return mean(portInputs);
|
|
1986
|
+
};
|
|
1987
|
+
|
|
1988
|
+
// src/activities/slot/utils/create.ts
|
|
1989
|
+
import { FlowNodeBaseType as FlowNodeBaseType24 } from "@flowgram.ai/document";
|
|
1990
|
+
var createSlotFromJSON = (node, json) => {
|
|
1991
|
+
const { document } = node;
|
|
1992
|
+
const addedNodes = [];
|
|
1993
|
+
const blockIconNode = document.addNode({
|
|
1994
|
+
id: `$slotIcon$${node.id}`,
|
|
1995
|
+
type: FlowNodeBaseType24.BLOCK_ICON,
|
|
1996
|
+
originParent: node,
|
|
1997
|
+
parent: node
|
|
1998
|
+
});
|
|
1999
|
+
const inlineBlocksNode = document.addNode({
|
|
2000
|
+
id: `$slotInlineBlocks$${node.id}`,
|
|
2001
|
+
type: "slotInlineBlocks" /* SlotInlineBlocks */,
|
|
2002
|
+
originParent: node,
|
|
2003
|
+
parent: node
|
|
2004
|
+
});
|
|
2005
|
+
addedNodes.push(blockIconNode);
|
|
2006
|
+
addedNodes.push(inlineBlocksNode);
|
|
2007
|
+
const portJSONList = json.blocks || [];
|
|
2008
|
+
portJSONList.forEach((_portJSON) => {
|
|
2009
|
+
const port = document.addNode({
|
|
2010
|
+
type: SlotNodeType.SlotBlock,
|
|
2011
|
+
..._portJSON,
|
|
2012
|
+
originParent: node,
|
|
2013
|
+
parent: inlineBlocksNode
|
|
2014
|
+
});
|
|
2015
|
+
addedNodes.push(port);
|
|
2016
|
+
(_portJSON.blocks || []).forEach((_portChild) => {
|
|
2017
|
+
document.addNode(
|
|
2018
|
+
{
|
|
2019
|
+
type: SlotNodeType.Slot,
|
|
2020
|
+
..._portChild,
|
|
2021
|
+
parent: port
|
|
2022
|
+
},
|
|
2023
|
+
addedNodes
|
|
2024
|
+
);
|
|
2025
|
+
});
|
|
2026
|
+
});
|
|
2027
|
+
return addedNodes;
|
|
2028
|
+
};
|
|
2029
|
+
|
|
2030
|
+
// src/activities/slot/extends/slot-icon.ts
|
|
2031
|
+
import { FlowNodeBaseType as FlowNodeBaseType25 } from "@flowgram.ai/document";
|
|
2032
|
+
var SlotIconRegistry = {
|
|
2033
|
+
type: FlowNodeBaseType25.BLOCK_ICON,
|
|
2034
|
+
meta: {
|
|
2035
|
+
defaultExpanded: false,
|
|
2036
|
+
spacing: 0
|
|
2037
|
+
},
|
|
2038
|
+
getLines: (transition) => [
|
|
2039
|
+
...canSlotDrilldown(transition.entity.parent) ? drawCollapseLine(transition) : []
|
|
2040
|
+
],
|
|
2041
|
+
getLabels: (transition) => [
|
|
2042
|
+
...canSlotDrilldown(transition.entity.parent) ? drawCollapseLabel(transition) : []
|
|
2043
|
+
],
|
|
2044
|
+
getDelta: (transform) => {
|
|
2045
|
+
if (insideSlot(transform.entity.parent)) {
|
|
2046
|
+
return transform.entity.isVertical ? { x: -transform.originDeltaX, y: 0 } : { x: 0, y: -transform.originDeltaY };
|
|
2047
|
+
}
|
|
2048
|
+
return { x: 0, y: 0 };
|
|
2049
|
+
}
|
|
2050
|
+
};
|
|
2051
|
+
|
|
2052
|
+
// src/activities/slot/extends/slot-inline-blocks.ts
|
|
2053
|
+
import { FlowNodeBaseType as FlowNodeBaseType26 } from "@flowgram.ai/document";
|
|
2054
|
+
import { FlowNodeTransformData as FlowNodeTransformData3 } from "@flowgram.ai/document";
|
|
2055
|
+
var SlotInlineBlocksRegistry = {
|
|
2056
|
+
type: "slotInlineBlocks" /* SlotInlineBlocks */,
|
|
2057
|
+
extend: FlowNodeBaseType26.BLOCK,
|
|
2058
|
+
meta: {
|
|
2059
|
+
spacing: 0,
|
|
2060
|
+
inlineSpacingPre: 0,
|
|
2061
|
+
inlineSpacingAfter: 0,
|
|
2062
|
+
isInlineBlocks: (node) => !node.isVertical
|
|
2063
|
+
},
|
|
2064
|
+
getLines() {
|
|
2065
|
+
return [];
|
|
2066
|
+
},
|
|
2067
|
+
getLabels() {
|
|
2068
|
+
return [];
|
|
2069
|
+
},
|
|
2070
|
+
getChildDelta(child, layout) {
|
|
2071
|
+
if (child.entity.isVertical) {
|
|
2072
|
+
return { x: 0, y: 0 };
|
|
2073
|
+
}
|
|
2074
|
+
const preTransform = child.entity.pre?.getData(FlowNodeTransformData3);
|
|
2075
|
+
if (preTransform) {
|
|
2076
|
+
const { localBounds: preBounds } = preTransform;
|
|
2077
|
+
return {
|
|
2078
|
+
x: 0,
|
|
2079
|
+
y: preBounds.bottom + 30
|
|
2080
|
+
};
|
|
2081
|
+
}
|
|
2082
|
+
return { x: 0, y: 0 };
|
|
2083
|
+
},
|
|
2084
|
+
/**
|
|
2085
|
+
* 控制条件分支居右布局
|
|
2086
|
+
*/
|
|
2087
|
+
getDelta(transform) {
|
|
2088
|
+
if (!transform.children.length) {
|
|
2089
|
+
return { x: 0, y: 0 };
|
|
2090
|
+
}
|
|
2091
|
+
const icon = transform.pre;
|
|
2092
|
+
if (!icon) {
|
|
2093
|
+
return { x: 0, y: 0 };
|
|
2094
|
+
}
|
|
2095
|
+
if (!transform.entity.isVertical) {
|
|
2096
|
+
const noChildren = transform?.children?.every?.((_port) => !_port.children.length);
|
|
2097
|
+
if (noChildren) {
|
|
2098
|
+
return {
|
|
2099
|
+
x: SLOT_BLOCK_DISTANCE - icon.localBounds.width / 2,
|
|
2100
|
+
y: icon.localBounds.bottom + SLOT_COLLAPSE_MARGIN
|
|
2101
|
+
};
|
|
2102
|
+
}
|
|
2103
|
+
return {
|
|
2104
|
+
x: 2 * SLOT_BLOCK_DISTANCE - icon.localBounds.width / 2,
|
|
2105
|
+
y: icon.localBounds.bottom + SLOT_COLLAPSE_MARGIN
|
|
2106
|
+
};
|
|
2107
|
+
}
|
|
2108
|
+
return {
|
|
2109
|
+
x: icon.localBounds.right + SLOT_INLINE_BLOCKS_DELTA,
|
|
2110
|
+
y: -icon.localBounds.height
|
|
2111
|
+
};
|
|
2112
|
+
}
|
|
2113
|
+
};
|
|
2114
|
+
|
|
2115
|
+
// src/activities/slot/extends/slot-block.ts
|
|
2116
|
+
import { mean as mean2 } from "lodash";
|
|
2117
|
+
import {
|
|
2118
|
+
FlowNodeBaseType as FlowNodeBaseType27,
|
|
2119
|
+
FlowTransitionLabelEnum as FlowTransitionLabelEnum16,
|
|
2120
|
+
FlowTransitionLineEnum as FlowTransitionLineEnum8
|
|
2121
|
+
} from "@flowgram.ai/document";
|
|
2122
|
+
import { FlowNodeTransformData as FlowNodeTransformData4 } from "@flowgram.ai/document";
|
|
2123
|
+
var SlotBlockRegistry = {
|
|
2124
|
+
type: SlotNodeType.SlotBlock,
|
|
2125
|
+
extend: FlowNodeBaseType27.BLOCK,
|
|
2126
|
+
meta: {
|
|
2127
|
+
inlineSpacingAfter: 0,
|
|
2128
|
+
inlineSpacingPre: 0,
|
|
2129
|
+
spacing: (transform) => {
|
|
2130
|
+
if (!transform.entity.isVertical && transform.size.width === 0) {
|
|
2131
|
+
return 90;
|
|
2132
|
+
}
|
|
2133
|
+
return 30;
|
|
2134
|
+
},
|
|
2135
|
+
isInlineBlocks: (node) => !node.isVertical
|
|
2136
|
+
},
|
|
2137
|
+
getLines(transition) {
|
|
2138
|
+
const icon = transition.transform.parent?.pre;
|
|
2139
|
+
const start = getSlotChildLineStartPoint(icon);
|
|
2140
|
+
const portPoint = transition.transform.inputPoint;
|
|
2141
|
+
return [
|
|
2142
|
+
{
|
|
2143
|
+
type: FlowTransitionLineEnum8.ROUNDED_LINE,
|
|
2144
|
+
from: start,
|
|
2145
|
+
to: portPoint,
|
|
2146
|
+
vertices: [{ x: start.x, y: portPoint.y }],
|
|
2147
|
+
style: {
|
|
2148
|
+
strokeDasharray: "5 5"
|
|
2149
|
+
},
|
|
2150
|
+
radius: 5
|
|
2151
|
+
},
|
|
2152
|
+
...transition.transform.children.map((_child) => {
|
|
2153
|
+
const childInput = getPortChildInput(_child);
|
|
2154
|
+
return {
|
|
2155
|
+
type: FlowTransitionLineEnum8.ROUNDED_LINE,
|
|
2156
|
+
radius: 5,
|
|
2157
|
+
from: portPoint,
|
|
2158
|
+
to: childInput,
|
|
2159
|
+
vertices: [{ x: portPoint.x, y: childInput.y }],
|
|
2160
|
+
style: {
|
|
2161
|
+
strokeDasharray: "5 5"
|
|
2162
|
+
}
|
|
2163
|
+
};
|
|
2164
|
+
})
|
|
2165
|
+
];
|
|
2166
|
+
},
|
|
2167
|
+
getLabels(transition) {
|
|
2168
|
+
const portPoint = transition.transform.inputPoint;
|
|
2169
|
+
return [
|
|
2170
|
+
{
|
|
2171
|
+
type: FlowTransitionLabelEnum16.CUSTOM_LABEL,
|
|
2172
|
+
renderKey: RENDER_SLOT_ADDER_KEY,
|
|
2173
|
+
props: {
|
|
2174
|
+
node: transition.entity
|
|
2175
|
+
},
|
|
2176
|
+
offset: portPoint
|
|
2177
|
+
}
|
|
2178
|
+
];
|
|
2179
|
+
},
|
|
2180
|
+
getInputPoint(transform) {
|
|
2181
|
+
const icon = transform.parent?.pre;
|
|
2182
|
+
const start = getSlotChildLineStartPoint(icon);
|
|
2183
|
+
let inputY = transform.bounds.center.y;
|
|
2184
|
+
if (transform.children.length) {
|
|
2185
|
+
inputY = mean2([
|
|
2186
|
+
getPortChildInput(transform.firstChild).y,
|
|
2187
|
+
getPortChildInput(transform.lastChild).y
|
|
2188
|
+
]);
|
|
2189
|
+
}
|
|
2190
|
+
return {
|
|
2191
|
+
x: start.x + SLOT_BLOCK_DISTANCE,
|
|
2192
|
+
y: inputY
|
|
2193
|
+
};
|
|
2194
|
+
},
|
|
2195
|
+
getChildDelta(child, layout) {
|
|
2196
|
+
const hasChild = !!child.firstChild;
|
|
2197
|
+
if (child.entity.isVertical) {
|
|
2198
|
+
let deltaX = hasChild ? 0 : -child.originDeltaX;
|
|
2199
|
+
return { x: deltaX, y: 0 };
|
|
2200
|
+
}
|
|
2201
|
+
let deltaY = hasChild ? 0 : -child.originDeltaY;
|
|
2202
|
+
const preTransform = child.entity.pre?.getData(FlowNodeTransformData4);
|
|
2203
|
+
if (preTransform) {
|
|
2204
|
+
const { localBounds: preBounds } = preTransform;
|
|
2205
|
+
return {
|
|
2206
|
+
x: 0,
|
|
2207
|
+
y: preBounds.bottom + 30 + deltaY
|
|
2208
|
+
};
|
|
2209
|
+
}
|
|
2210
|
+
return { x: 0, y: deltaY };
|
|
2211
|
+
},
|
|
2212
|
+
getChildLabels() {
|
|
2213
|
+
return [];
|
|
2214
|
+
},
|
|
2215
|
+
getChildLines() {
|
|
2216
|
+
return [];
|
|
2217
|
+
},
|
|
2218
|
+
getDelta(transform) {
|
|
2219
|
+
return {
|
|
2220
|
+
x: 0,
|
|
2221
|
+
y: 0
|
|
2222
|
+
};
|
|
2223
|
+
}
|
|
2224
|
+
};
|
|
2225
|
+
|
|
2226
|
+
// src/activities/slot/slot.ts
|
|
2227
|
+
var SlotRegistry = {
|
|
2228
|
+
type: FlowNodeBaseType28.SLOT,
|
|
2229
|
+
extend: "block",
|
|
2230
|
+
meta: {
|
|
2231
|
+
// Slot 节点内部暂时不允许拖拽
|
|
2232
|
+
draggable: (node) => !insideSlot(node),
|
|
2233
|
+
hidden: true,
|
|
2234
|
+
spacing: SLOT_SPACING,
|
|
2235
|
+
padding: (node) => ({
|
|
2236
|
+
left: 0,
|
|
2237
|
+
right: node.collapsed ? SLOT_COLLAPSE_MARGIN : 0,
|
|
2238
|
+
bottom: !insideSlot(node.entity) && node.isLast ? SLOT_NODE_LAST_SPACING : 0,
|
|
2239
|
+
top: 0
|
|
2240
|
+
}),
|
|
2241
|
+
copyDisable: false,
|
|
2242
|
+
defaultExpanded: false
|
|
2243
|
+
},
|
|
2244
|
+
/**
|
|
2245
|
+
* 业务通常需要重载方法
|
|
2246
|
+
*/
|
|
2247
|
+
onCreate: createSlotFromJSON,
|
|
2248
|
+
getLines: (transition) => [
|
|
2249
|
+
...!insideSlot(transition.entity) ? drawStraightLine(transition) : []
|
|
2250
|
+
],
|
|
2251
|
+
getLabels: (transition) => [
|
|
2252
|
+
...!insideSlot(transition.entity) ? drawStraightAdder(transition) : []
|
|
2253
|
+
],
|
|
2254
|
+
getInputPoint,
|
|
2255
|
+
getOutputPoint,
|
|
2256
|
+
onAfterUpdateLocalTransform(transform) {
|
|
2257
|
+
const { isVertical } = transform.entity;
|
|
2258
|
+
if (!isVertical) {
|
|
2259
|
+
return;
|
|
2260
|
+
}
|
|
2261
|
+
const icon = transform.firstChild;
|
|
2262
|
+
const inlineBlocks = transform.lastChild;
|
|
2263
|
+
if (!icon || !inlineBlocks) {
|
|
2264
|
+
return;
|
|
2265
|
+
}
|
|
2266
|
+
const iconSize = icon.localBounds.height;
|
|
2267
|
+
const inlineBlocksSize = inlineBlocks.localBounds.height;
|
|
2268
|
+
if (transform.collapsed || !inlineBlocks) {
|
|
2269
|
+
return;
|
|
2270
|
+
}
|
|
2271
|
+
const portsMiddle = getAllPortsMiddle(inlineBlocks);
|
|
2272
|
+
icon.entity.clearMemoLocal();
|
|
2273
|
+
inlineBlocks.entity.clearMemoLocal();
|
|
2274
|
+
if (iconSize / 2 + portsMiddle > inlineBlocksSize || !inlineBlocks.children.length) {
|
|
2275
|
+
icon.transform.update({
|
|
2276
|
+
position: { x: icon.transform.position.x, y: 0 }
|
|
2277
|
+
});
|
|
2278
|
+
inlineBlocks.transform.update({
|
|
2279
|
+
position: {
|
|
2280
|
+
x: inlineBlocks.transform.position.x,
|
|
2281
|
+
y: Math.max(iconSize / 2 - inlineBlocksSize / 2, 0)
|
|
2282
|
+
}
|
|
2283
|
+
});
|
|
2284
|
+
return;
|
|
2285
|
+
}
|
|
2286
|
+
inlineBlocks.transform.update({
|
|
2287
|
+
position: { x: inlineBlocks.transform.position.x, y: 0 }
|
|
2288
|
+
});
|
|
2289
|
+
icon?.transform.update({
|
|
2290
|
+
position: {
|
|
2291
|
+
x: icon.transform.position.x,
|
|
2292
|
+
y: Math.max(portsMiddle - iconSize / 2, 0)
|
|
2293
|
+
// 所有 port 的中间点
|
|
2294
|
+
}
|
|
2295
|
+
});
|
|
2296
|
+
},
|
|
2297
|
+
extendChildRegistries: [SlotIconRegistry, SlotInlineBlocksRegistry]
|
|
2298
|
+
};
|
|
2299
|
+
|
|
1783
2300
|
// src/flow-registers.ts
|
|
1784
2301
|
var FlowRegisters = class {
|
|
1785
2302
|
/**
|
|
@@ -1819,14 +2336,16 @@ var FlowRegisters = class {
|
|
|
1819
2336
|
MultiOuputsRegistry,
|
|
1820
2337
|
MultiInputsRegistry,
|
|
1821
2338
|
InputRegistry,
|
|
1822
|
-
OuputRegistry
|
|
2339
|
+
OuputRegistry,
|
|
2340
|
+
SlotRegistry,
|
|
2341
|
+
SlotBlockRegistry
|
|
1823
2342
|
);
|
|
1824
2343
|
document.registerNodeDatas(
|
|
1825
2344
|
FlowNodeRenderData4,
|
|
1826
2345
|
// 渲染节点相关数据
|
|
1827
2346
|
FlowNodeTransitionData,
|
|
1828
2347
|
// 线条绘制数据
|
|
1829
|
-
|
|
2348
|
+
FlowNodeTransformData5
|
|
1830
2349
|
// 坐标计算数据
|
|
1831
2350
|
);
|
|
1832
2351
|
}
|
|
@@ -1885,7 +2404,8 @@ var FixedLayoutRegistries = {
|
|
|
1885
2404
|
StartRegistry,
|
|
1886
2405
|
RootRegistry,
|
|
1887
2406
|
InlineBlocksRegistry,
|
|
1888
|
-
EndRegistry
|
|
2407
|
+
EndRegistry,
|
|
2408
|
+
SlotRegistry
|
|
1889
2409
|
};
|
|
1890
2410
|
export {
|
|
1891
2411
|
FixedLayoutContainerModule,
|