@flowgram.ai/fixed-layout-core 0.3.5 → 0.4.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/esm/index.js +153 -35
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +32 -1
- package/dist/index.d.ts +32 -1
- package/dist/index.js +149 -32
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.d.mts
CHANGED
|
@@ -8,6 +8,37 @@ import { ContainerModule } from 'inversify';
|
|
|
8
8
|
|
|
9
9
|
declare const FixedLayoutContainerModule: ContainerModule;
|
|
10
10
|
|
|
11
|
+
declare const SlotSpacingKey: {
|
|
12
|
+
/**
|
|
13
|
+
* = Next Node - Slot END
|
|
14
|
+
*/
|
|
15
|
+
SLOT_SPACING: string;
|
|
16
|
+
/**
|
|
17
|
+
* = Slot Start Line - Slot Icon Right
|
|
18
|
+
*/
|
|
19
|
+
SLOT_START_DISTANCE: string;
|
|
20
|
+
/**
|
|
21
|
+
* = Slot Radius
|
|
22
|
+
*/
|
|
23
|
+
SLOT_RADIUS: string;
|
|
24
|
+
/**
|
|
25
|
+
* = Slot Port - Slot Start
|
|
26
|
+
*/
|
|
27
|
+
SLOT_PORT_DISTANCE: string;
|
|
28
|
+
/**
|
|
29
|
+
* = Slot Label - Slot Start
|
|
30
|
+
*/
|
|
31
|
+
SLOT_LABEL_DISTANCE: string;
|
|
32
|
+
/**
|
|
33
|
+
* = Slot Block - Slot Port
|
|
34
|
+
*/
|
|
35
|
+
SLOT_BLOCK_PORT_DISTANCE: string;
|
|
36
|
+
/**
|
|
37
|
+
* Vertical Layout: Slot Block - Slot Block
|
|
38
|
+
*/
|
|
39
|
+
SLOT_BLOCK_VERTICAL_SPACING: string;
|
|
40
|
+
};
|
|
41
|
+
|
|
11
42
|
declare const FixedLayoutRegistries: {
|
|
12
43
|
BlockIconRegistry: _flowgram_ai_document.FlowNodeRegistry<_flowgram_ai_document.FlowNodeMeta>;
|
|
13
44
|
BlockOrderIconRegistry: _flowgram_ai_document.FlowNodeRegistry<_flowgram_ai_document.FlowNodeMeta>;
|
|
@@ -24,4 +55,4 @@ declare const FixedLayoutRegistries: {
|
|
|
24
55
|
SlotRegistry: _flowgram_ai_document.FlowNodeRegistry<_flowgram_ai_document.FlowNodeMeta>;
|
|
25
56
|
};
|
|
26
57
|
|
|
27
|
-
export { FixedLayoutContainerModule, FixedLayoutRegistries };
|
|
58
|
+
export { FixedLayoutContainerModule, FixedLayoutRegistries, SlotSpacingKey };
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,37 @@ import { ContainerModule } from 'inversify';
|
|
|
8
8
|
|
|
9
9
|
declare const FixedLayoutContainerModule: ContainerModule;
|
|
10
10
|
|
|
11
|
+
declare const SlotSpacingKey: {
|
|
12
|
+
/**
|
|
13
|
+
* = Next Node - Slot END
|
|
14
|
+
*/
|
|
15
|
+
SLOT_SPACING: string;
|
|
16
|
+
/**
|
|
17
|
+
* = Slot Start Line - Slot Icon Right
|
|
18
|
+
*/
|
|
19
|
+
SLOT_START_DISTANCE: string;
|
|
20
|
+
/**
|
|
21
|
+
* = Slot Radius
|
|
22
|
+
*/
|
|
23
|
+
SLOT_RADIUS: string;
|
|
24
|
+
/**
|
|
25
|
+
* = Slot Port - Slot Start
|
|
26
|
+
*/
|
|
27
|
+
SLOT_PORT_DISTANCE: string;
|
|
28
|
+
/**
|
|
29
|
+
* = Slot Label - Slot Start
|
|
30
|
+
*/
|
|
31
|
+
SLOT_LABEL_DISTANCE: string;
|
|
32
|
+
/**
|
|
33
|
+
* = Slot Block - Slot Port
|
|
34
|
+
*/
|
|
35
|
+
SLOT_BLOCK_PORT_DISTANCE: string;
|
|
36
|
+
/**
|
|
37
|
+
* Vertical Layout: Slot Block - Slot Block
|
|
38
|
+
*/
|
|
39
|
+
SLOT_BLOCK_VERTICAL_SPACING: string;
|
|
40
|
+
};
|
|
41
|
+
|
|
11
42
|
declare const FixedLayoutRegistries: {
|
|
12
43
|
BlockIconRegistry: _flowgram_ai_document.FlowNodeRegistry<_flowgram_ai_document.FlowNodeMeta>;
|
|
13
44
|
BlockOrderIconRegistry: _flowgram_ai_document.FlowNodeRegistry<_flowgram_ai_document.FlowNodeMeta>;
|
|
@@ -24,4 +55,4 @@ declare const FixedLayoutRegistries: {
|
|
|
24
55
|
SlotRegistry: _flowgram_ai_document.FlowNodeRegistry<_flowgram_ai_document.FlowNodeMeta>;
|
|
25
56
|
};
|
|
26
57
|
|
|
27
|
-
export { FixedLayoutContainerModule, FixedLayoutRegistries };
|
|
58
|
+
export { FixedLayoutContainerModule, FixedLayoutRegistries, SlotSpacingKey };
|
package/dist/index.js
CHANGED
|
@@ -29,7 +29,8 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
29
29
|
var src_exports = {};
|
|
30
30
|
__export(src_exports, {
|
|
31
31
|
FixedLayoutContainerModule: () => FixedLayoutContainerModule,
|
|
32
|
-
FixedLayoutRegistries: () => FixedLayoutRegistries
|
|
32
|
+
FixedLayoutRegistries: () => FixedLayoutRegistries,
|
|
33
|
+
SlotSpacingKey: () => SlotSpacingKey
|
|
33
34
|
});
|
|
34
35
|
module.exports = __toCommonJS(src_exports);
|
|
35
36
|
|
|
@@ -1720,12 +1721,46 @@ var import_document30 = require("@flowgram.ai/document");
|
|
|
1720
1721
|
// src/activities/slot/constants.ts
|
|
1721
1722
|
var import_renderer7 = require("@flowgram.ai/renderer");
|
|
1722
1723
|
var RENDER_SLOT_ADDER_KEY = import_renderer7.FlowRendererKey.SLOT_ADDER;
|
|
1723
|
-
var
|
|
1724
|
-
var
|
|
1725
|
-
var
|
|
1724
|
+
var RENDER_SLOT_LABEL_KEY = import_renderer7.FlowRendererKey.SLOT_LABEL;
|
|
1725
|
+
var RENDER_SLOT_COLLAPSE_KEY = import_renderer7.FlowRendererKey.SLOT_COLLAPSE;
|
|
1726
|
+
var SlotSpacingKey = {
|
|
1727
|
+
/**
|
|
1728
|
+
* = Next Node - Slot END
|
|
1729
|
+
*/
|
|
1730
|
+
SLOT_SPACING: "SLOT_SPACING",
|
|
1731
|
+
/**
|
|
1732
|
+
* = Slot Start Line - Slot Icon Right
|
|
1733
|
+
*/
|
|
1734
|
+
SLOT_START_DISTANCE: "SLOT_START_DISTANCE",
|
|
1735
|
+
/**
|
|
1736
|
+
* = Slot Radius
|
|
1737
|
+
*/
|
|
1738
|
+
SLOT_RADIUS: "SLOT_RADIUS",
|
|
1739
|
+
/**
|
|
1740
|
+
* = Slot Port - Slot Start
|
|
1741
|
+
*/
|
|
1742
|
+
SLOT_PORT_DISTANCE: "SLOT_PORT_DISTANCE",
|
|
1743
|
+
/**
|
|
1744
|
+
* = Slot Label - Slot Start
|
|
1745
|
+
*/
|
|
1746
|
+
SLOT_LABEL_DISTANCE: "SLOT_LABEL_DISTANCE",
|
|
1747
|
+
/**
|
|
1748
|
+
* = Slot Block - Slot Port
|
|
1749
|
+
*/
|
|
1750
|
+
SLOT_BLOCK_PORT_DISTANCE: "SLOT_BLOCK_PORT_DISTANCE",
|
|
1751
|
+
/**
|
|
1752
|
+
* Vertical Layout: Slot Block - Slot Block
|
|
1753
|
+
*/
|
|
1754
|
+
SLOT_BLOCK_VERTICAL_SPACING: "SLOT_BLOCK_VERTICAL_SPACING"
|
|
1755
|
+
};
|
|
1756
|
+
var SLOT_START_DISTANCE = 16;
|
|
1757
|
+
var SLOT_PORT_DISTANCE = 100;
|
|
1758
|
+
var SLOT_LABEL_DISTANCE = 32;
|
|
1759
|
+
var SLOT_BLOCK_PORT_DISTANCE = 32.5;
|
|
1760
|
+
var SLOT_RADIUS = 16;
|
|
1726
1761
|
var SLOT_SPACING = 32;
|
|
1762
|
+
var SLOT_BLOCK_VERTICAL_SPACING = 32.5;
|
|
1727
1763
|
var SLOT_NODE_LAST_SPACING = 10;
|
|
1728
|
-
var SLOT_INLINE_BLOCKS_DELTA = SLOT_COLLAPSE_MARGIN + SLOT_BLOCK_DISTANCE * 2;
|
|
1729
1764
|
|
|
1730
1765
|
// src/activities/slot/typings.ts
|
|
1731
1766
|
var import_document29 = require("@flowgram.ai/document");
|
|
@@ -1752,14 +1787,19 @@ var getSlotChildLineStartPoint = (iconTransform) => {
|
|
|
1752
1787
|
if (!iconTransform) {
|
|
1753
1788
|
return { x: 0, y: 0 };
|
|
1754
1789
|
}
|
|
1790
|
+
const startDistance = (0, import_document30.getDefaultSpacing)(
|
|
1791
|
+
iconTransform.entity,
|
|
1792
|
+
SlotSpacingKey.SLOT_START_DISTANCE,
|
|
1793
|
+
SLOT_START_DISTANCE
|
|
1794
|
+
);
|
|
1755
1795
|
if (!iconTransform.entity.isVertical) {
|
|
1756
1796
|
return {
|
|
1757
1797
|
x: iconTransform?.bounds.center.x,
|
|
1758
|
-
y: iconTransform?.bounds.bottom +
|
|
1798
|
+
y: iconTransform?.bounds.bottom + startDistance
|
|
1759
1799
|
};
|
|
1760
1800
|
}
|
|
1761
1801
|
return {
|
|
1762
|
-
x: iconTransform?.bounds.right +
|
|
1802
|
+
x: iconTransform?.bounds.right + startDistance,
|
|
1763
1803
|
y: iconTransform?.bounds.center.y
|
|
1764
1804
|
};
|
|
1765
1805
|
};
|
|
@@ -1846,19 +1886,26 @@ var drawCollapseLabel = (transition) => {
|
|
|
1846
1886
|
}
|
|
1847
1887
|
];
|
|
1848
1888
|
};
|
|
1849
|
-
var drawCollapseLine = (transition) =>
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1889
|
+
var drawCollapseLine = (transition) => {
|
|
1890
|
+
const startDistance = (0, import_document30.getDefaultSpacing)(
|
|
1891
|
+
transition.transform.entity,
|
|
1892
|
+
SlotSpacingKey.SLOT_START_DISTANCE,
|
|
1893
|
+
SLOT_START_DISTANCE
|
|
1894
|
+
);
|
|
1895
|
+
return [
|
|
1896
|
+
{
|
|
1897
|
+
type: import_document30.FlowTransitionLineEnum.STRAIGHT_LINE,
|
|
1898
|
+
from: getSlotChildLineStartPoint(transition.transform),
|
|
1899
|
+
to: import_utils7.Point.move(
|
|
1900
|
+
getSlotChildLineStartPoint(transition.transform),
|
|
1901
|
+
transition.entity.isVertical ? { x: -startDistance, y: 0 } : { x: 0, y: -startDistance }
|
|
1902
|
+
),
|
|
1903
|
+
style: {
|
|
1904
|
+
strokeDasharray: "5 5"
|
|
1905
|
+
}
|
|
1859
1906
|
}
|
|
1860
|
-
|
|
1861
|
-
|
|
1907
|
+
];
|
|
1908
|
+
};
|
|
1862
1909
|
var drawStraightAdder = (transition) => {
|
|
1863
1910
|
const toPoint = getTransitionToPoint(transition);
|
|
1864
1911
|
const fromPoint = transition.transform.firstChild.outputPoint;
|
|
@@ -2019,21 +2066,37 @@ var SlotInlineBlocksRegistry = {
|
|
|
2019
2066
|
if (!icon) {
|
|
2020
2067
|
return { x: 0, y: 0 };
|
|
2021
2068
|
}
|
|
2069
|
+
const startDistance = (0, import_document33.getDefaultSpacing)(
|
|
2070
|
+
transform.entity,
|
|
2071
|
+
SlotSpacingKey.SLOT_START_DISTANCE,
|
|
2072
|
+
SLOT_START_DISTANCE
|
|
2073
|
+
);
|
|
2074
|
+
const portDistance = (0, import_document33.getDefaultSpacing)(
|
|
2075
|
+
transform.entity,
|
|
2076
|
+
SlotSpacingKey.SLOT_PORT_DISTANCE,
|
|
2077
|
+
SLOT_PORT_DISTANCE
|
|
2078
|
+
);
|
|
2079
|
+
const portBlockDistance = (0, import_document33.getDefaultSpacing)(
|
|
2080
|
+
transform.entity,
|
|
2081
|
+
SlotSpacingKey.SLOT_BLOCK_PORT_DISTANCE,
|
|
2082
|
+
SLOT_BLOCK_PORT_DISTANCE
|
|
2083
|
+
);
|
|
2022
2084
|
if (!transform.entity.isVertical) {
|
|
2023
2085
|
const noChildren = transform?.children?.every?.((_port) => !_port.children.length);
|
|
2024
2086
|
if (noChildren) {
|
|
2025
2087
|
return {
|
|
2026
|
-
x:
|
|
2027
|
-
y: icon.localBounds.bottom +
|
|
2088
|
+
x: portDistance - icon.localBounds.width / 2,
|
|
2089
|
+
y: icon.localBounds.bottom + startDistance
|
|
2028
2090
|
};
|
|
2029
2091
|
}
|
|
2030
2092
|
return {
|
|
2031
|
-
x:
|
|
2032
|
-
y: icon.localBounds.bottom +
|
|
2093
|
+
x: portDistance + portBlockDistance - icon.localBounds.width / 2,
|
|
2094
|
+
y: icon.localBounds.bottom + startDistance
|
|
2033
2095
|
};
|
|
2034
2096
|
}
|
|
2097
|
+
const slotInlineBlockDelta = startDistance + portDistance + portBlockDistance;
|
|
2035
2098
|
return {
|
|
2036
|
-
x: icon.localBounds.right +
|
|
2099
|
+
x: icon.localBounds.right + slotInlineBlockDelta,
|
|
2037
2100
|
y: -icon.localBounds.height
|
|
2038
2101
|
};
|
|
2039
2102
|
}
|
|
@@ -2053,7 +2116,11 @@ var SlotBlockRegistry = {
|
|
|
2053
2116
|
if (!transform.entity.isVertical && transform.size.width === 0) {
|
|
2054
2117
|
return 90;
|
|
2055
2118
|
}
|
|
2056
|
-
return
|
|
2119
|
+
return (0, import_document35.getDefaultSpacing)(
|
|
2120
|
+
transform.entity,
|
|
2121
|
+
SlotSpacingKey.SLOT_BLOCK_VERTICAL_SPACING,
|
|
2122
|
+
SLOT_BLOCK_VERTICAL_SPACING
|
|
2123
|
+
);
|
|
2057
2124
|
},
|
|
2058
2125
|
isInlineBlocks: (node) => !node.isVertical
|
|
2059
2126
|
},
|
|
@@ -2061,22 +2128,53 @@ var SlotBlockRegistry = {
|
|
|
2061
2128
|
const icon = transition.transform.parent?.pre;
|
|
2062
2129
|
const start = getSlotChildLineStartPoint(icon);
|
|
2063
2130
|
const portPoint = transition.transform.inputPoint;
|
|
2131
|
+
const radius = (0, import_document35.getDefaultSpacing)(
|
|
2132
|
+
transition.transform.entity,
|
|
2133
|
+
SlotSpacingKey.SLOT_RADIUS,
|
|
2134
|
+
SLOT_RADIUS
|
|
2135
|
+
);
|
|
2136
|
+
let startPortVertices = [{ x: start.x, y: portPoint.y }];
|
|
2137
|
+
if (transition.entity.isVertical) {
|
|
2138
|
+
const deltaY = Math.abs(portPoint.y - start.y);
|
|
2139
|
+
let deltaX = radius;
|
|
2140
|
+
let isTruncated = false;
|
|
2141
|
+
if (deltaY < radius * 2) {
|
|
2142
|
+
isTruncated = true;
|
|
2143
|
+
if (deltaY < radius) {
|
|
2144
|
+
deltaX = Math.sqrt(radius ** 2 - (radius - deltaY) ** 2);
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
startPortVertices = [
|
|
2148
|
+
{
|
|
2149
|
+
x: start.x + deltaX,
|
|
2150
|
+
y: start.y,
|
|
2151
|
+
radiusX: radius,
|
|
2152
|
+
radiusY: radius,
|
|
2153
|
+
radiusOverflow: "truncate"
|
|
2154
|
+
},
|
|
2155
|
+
{
|
|
2156
|
+
x: start.x + deltaX,
|
|
2157
|
+
y: portPoint.y,
|
|
2158
|
+
...isTruncated ? { radiusX: 0, radiusY: 0 } : {}
|
|
2159
|
+
}
|
|
2160
|
+
];
|
|
2161
|
+
}
|
|
2064
2162
|
return [
|
|
2065
2163
|
{
|
|
2066
2164
|
type: import_document35.FlowTransitionLineEnum.ROUNDED_LINE,
|
|
2067
2165
|
from: start,
|
|
2068
2166
|
to: portPoint,
|
|
2069
|
-
vertices:
|
|
2167
|
+
vertices: startPortVertices,
|
|
2070
2168
|
style: {
|
|
2071
2169
|
strokeDasharray: "5 5"
|
|
2072
2170
|
},
|
|
2073
|
-
radius
|
|
2171
|
+
radius
|
|
2074
2172
|
},
|
|
2075
2173
|
...transition.transform.children.map((_child) => {
|
|
2076
2174
|
const childInput = getPortChildInput(_child);
|
|
2077
2175
|
return {
|
|
2078
2176
|
type: import_document35.FlowTransitionLineEnum.ROUNDED_LINE,
|
|
2079
|
-
radius
|
|
2177
|
+
radius,
|
|
2080
2178
|
from: portPoint,
|
|
2081
2179
|
to: childInput,
|
|
2082
2180
|
vertices: [{ x: portPoint.x, y: childInput.y }],
|
|
@@ -2088,6 +2186,8 @@ var SlotBlockRegistry = {
|
|
|
2088
2186
|
];
|
|
2089
2187
|
},
|
|
2090
2188
|
getLabels(transition) {
|
|
2189
|
+
const icon = transition.transform.parent?.pre;
|
|
2190
|
+
const start = getSlotChildLineStartPoint(icon);
|
|
2091
2191
|
const portPoint = transition.transform.inputPoint;
|
|
2092
2192
|
return [
|
|
2093
2193
|
{
|
|
@@ -2097,6 +2197,22 @@ var SlotBlockRegistry = {
|
|
|
2097
2197
|
node: transition.entity
|
|
2098
2198
|
},
|
|
2099
2199
|
offset: portPoint
|
|
2200
|
+
},
|
|
2201
|
+
{
|
|
2202
|
+
type: import_document35.FlowTransitionLabelEnum.CUSTOM_LABEL,
|
|
2203
|
+
renderKey: RENDER_SLOT_LABEL_KEY,
|
|
2204
|
+
props: {
|
|
2205
|
+
node: transition.entity
|
|
2206
|
+
},
|
|
2207
|
+
offset: {
|
|
2208
|
+
x: start.x + (0, import_document35.getDefaultSpacing)(
|
|
2209
|
+
transition.entity,
|
|
2210
|
+
SlotSpacingKey.SLOT_LABEL_DISTANCE,
|
|
2211
|
+
SLOT_LABEL_DISTANCE
|
|
2212
|
+
),
|
|
2213
|
+
y: portPoint.y
|
|
2214
|
+
},
|
|
2215
|
+
origin: [0, 0.5]
|
|
2100
2216
|
}
|
|
2101
2217
|
];
|
|
2102
2218
|
},
|
|
@@ -2111,7 +2227,7 @@ var SlotBlockRegistry = {
|
|
|
2111
2227
|
]);
|
|
2112
2228
|
}
|
|
2113
2229
|
return {
|
|
2114
|
-
x: start.x +
|
|
2230
|
+
x: start.x + (0, import_document35.getDefaultSpacing)(transform.entity, SlotSpacingKey.SLOT_PORT_DISTANCE, SLOT_PORT_DISTANCE),
|
|
2115
2231
|
y: inputY
|
|
2116
2232
|
};
|
|
2117
2233
|
},
|
|
@@ -2154,10 +2270,10 @@ var SlotRegistry = {
|
|
|
2154
2270
|
// Slot 节点内部暂时不允许拖拽
|
|
2155
2271
|
draggable: (node) => !insideSlot(node),
|
|
2156
2272
|
hidden: true,
|
|
2157
|
-
spacing: SLOT_SPACING,
|
|
2273
|
+
spacing: (node) => (0, import_document37.getDefaultSpacing)(node.entity, SlotSpacingKey.SLOT_SPACING, SLOT_SPACING),
|
|
2158
2274
|
padding: (node) => ({
|
|
2159
2275
|
left: 0,
|
|
2160
|
-
right: node.collapsed ?
|
|
2276
|
+
right: node.collapsed ? (0, import_document37.getDefaultSpacing)(node.entity, SlotSpacingKey.SLOT_START_DISTANCE, SLOT_START_DISTANCE) : 0,
|
|
2161
2277
|
bottom: !insideSlot(node.entity) && node.isLast ? SLOT_NODE_LAST_SPACING : 0,
|
|
2162
2278
|
top: 0
|
|
2163
2279
|
}),
|
|
@@ -2333,6 +2449,7 @@ var FixedLayoutRegistries = {
|
|
|
2333
2449
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2334
2450
|
0 && (module.exports = {
|
|
2335
2451
|
FixedLayoutContainerModule,
|
|
2336
|
-
FixedLayoutRegistries
|
|
2452
|
+
FixedLayoutRegistries,
|
|
2453
|
+
SlotSpacingKey
|
|
2337
2454
|
});
|
|
2338
2455
|
//# sourceMappingURL=index.js.map
|