@flowgram.ai/fixed-layout-core 0.1.30 → 0.2.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 CHANGED
@@ -27,7 +27,7 @@ import {
27
27
  FlowScrollLimitLayer
28
28
  } from "@flowgram.ai/renderer";
29
29
  import {
30
- FlowNodeRenderData as FlowNodeRenderData3,
30
+ FlowNodeRenderData as FlowNodeRenderData4,
31
31
  FlowNodeTransformData as FlowNodeTransformData3,
32
32
  FlowNodeTransitionData
33
33
  } from "@flowgram.ai/document";
@@ -166,8 +166,8 @@ var BlockRegistry = {
166
166
  const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
167
167
  if (hasBranchDraggingAdder) {
168
168
  if (isVertical) {
169
- const currentOffsetRightX = currentTransform.firstChild?.bounds?.right || 0;
170
- const nextOffsetLeftX = currentTransform.next?.firstChild?.bounds?.left || 0;
169
+ const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
170
+ const nextOffsetLeftX = (currentTransform.next?.firstChild ? currentTransform.next?.firstChild.bounds?.left : currentTransform.next?.bounds?.left) || 0;
171
171
  const currentInputPointY = currentTransform.inputPoint.y;
172
172
  if (currentTransform?.next) {
173
173
  lines.push({
@@ -181,8 +181,8 @@ var BlockRegistry = {
181
181
  });
182
182
  }
183
183
  } else {
184
- const currentOffsetRightY = currentTransform.firstChild?.bounds?.bottom || 0;
185
- const nextOffsetLeftY = currentTransform.next?.firstChild?.bounds?.top || 0;
184
+ const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
185
+ const nextOffsetTopX = (currentTransform.next?.firstChild ? currentTransform.next?.firstChild.bounds?.top : currentTransform.next?.bounds?.top) || 0;
186
186
  const currentInputPointX = currentTransform.inputPoint.x;
187
187
  if (currentTransform?.next) {
188
188
  lines.push({
@@ -190,7 +190,7 @@ var BlockRegistry = {
190
190
  from: currentTransform.parent.inputPoint,
191
191
  to: {
192
192
  x: currentInputPointX,
193
- y: (currentOffsetRightY + nextOffsetLeftY) / 2
193
+ y: (currentOffsetBottomX + nextOffsetTopX) / 2
194
194
  },
195
195
  side: LABEL_SIDE_TYPE.NORMAL_BRANCH
196
196
  });
@@ -232,8 +232,8 @@ var BlockRegistry = {
232
232
  const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
233
233
  if (hasBranchDraggingAdder) {
234
234
  if (isVertical) {
235
- const currentOffsetRightX = currentTransform.firstChild?.bounds?.right || 0;
236
- const nextOffsetLeftX = currentTransform.next?.firstChild?.bounds?.left || 0;
235
+ const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
236
+ const nextOffsetLeftX = (currentTransform.next?.firstChild ? currentTransform.next.firstChild.bounds?.left : currentTransform.next?.bounds?.left) || 0;
237
237
  const currentInputPointY = currentTransform.inputPoint.y;
238
238
  if (currentTransform?.next) {
239
239
  draggingLabel.push({
@@ -249,17 +249,17 @@ var BlockRegistry = {
249
249
  });
250
250
  }
251
251
  } else {
252
- const currentOffsetRightY = currentTransform.firstChild?.bounds?.bottom || 0;
253
- const nextOffsetLeftY = currentTransform.next?.firstChild?.bounds?.top || 0;
252
+ const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
253
+ const nextOffsetTopX = (currentTransform.next?.firstChild ? currentTransform.next.firstChild.bounds?.top : currentTransform.next?.bounds?.top) || 0;
254
254
  const currentInputPointX = currentTransform.inputPoint.x;
255
255
  if (currentTransform?.next) {
256
256
  draggingLabel.push({
257
257
  offset: {
258
258
  x: currentInputPointX,
259
- y: (currentOffsetRightY + nextOffsetLeftY) / 2
259
+ y: (currentOffsetBottomX + nextOffsetTopX) / 2
260
260
  },
261
261
  type: FlowTransitionLabelEnum2.BRANCH_DRAGGING_LABEL,
262
- width: nextOffsetLeftY - currentOffsetRightY,
262
+ width: nextOffsetTopX - currentOffsetBottomX,
263
263
  props: {
264
264
  side: LABEL_SIDE_TYPE.NORMAL_BRANCH
265
265
  }
@@ -1526,7 +1526,8 @@ var BreakRegistry = {
1526
1526
  import {
1527
1527
  FlowNodeBaseType as FlowNodeBaseType19,
1528
1528
  FlowTransitionLineEnum as FlowTransitionLineEnum6,
1529
- LABEL_SIDE_TYPE as LABEL_SIDE_TYPE2
1529
+ LABEL_SIDE_TYPE as LABEL_SIDE_TYPE2,
1530
+ FlowTransitionLabelEnum as FlowTransitionLabelEnum13
1530
1531
  } from "@flowgram.ai/document";
1531
1532
  var InputRegistry = {
1532
1533
  type: FlowNodeBaseType19.INPUT,
@@ -1534,39 +1535,41 @@ var InputRegistry = {
1534
1535
  meta: {
1535
1536
  hidden: false
1536
1537
  },
1537
- getLines(transition) {
1538
+ getLines(transition, layout) {
1538
1539
  const currentTransform = transition.transform;
1539
1540
  const { isVertical } = transition.entity;
1540
1541
  const lines = [];
1541
1542
  const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
1542
1543
  if (hasBranchDraggingAdder) {
1543
1544
  if (isVertical) {
1544
- const currentOffsetRightX = currentTransform.firstChild?.bounds?.right || 0;
1545
- const nextOffsetLeftX = currentTransform.next?.firstChild?.bounds?.left || 0;
1546
- const currentInputPointY = currentTransform.inputPoint.y;
1545
+ const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
1546
+ const nextOffsetLeftX = (currentTransform.next?.firstChild ? currentTransform.next?.firstChild.bounds?.left : currentTransform.next?.bounds?.left) || 0;
1547
+ const currentInputPointY = currentTransform.outputPoint.y;
1547
1548
  if (currentTransform?.next) {
1548
1549
  lines.push({
1549
- type: FlowTransitionLineEnum6.DRAGGING_LINE,
1550
- from: currentTransform.parent.inputPoint,
1551
- to: {
1550
+ type: FlowTransitionLineEnum6.MERGE_LINE,
1551
+ isDraggingLine: true,
1552
+ from: {
1552
1553
  x: (currentOffsetRightX + nextOffsetLeftX) / 2,
1553
1554
  y: currentInputPointY
1554
1555
  },
1556
+ to: currentTransform.parent.outputPoint,
1555
1557
  side: LABEL_SIDE_TYPE2.NORMAL_BRANCH
1556
1558
  });
1557
1559
  }
1558
1560
  } else {
1559
- const currentOffsetRightY = currentTransform.firstChild?.bounds?.bottom || 0;
1560
- const nextOffsetLeftY = currentTransform.next?.firstChild?.bounds?.top || 0;
1561
- const currentInputPointX = currentTransform.inputPoint.x;
1561
+ const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
1562
+ const nextOffsetTopX = (currentTransform.next?.firstChild ? currentTransform.next?.firstChild.bounds?.top : currentTransform.next?.bounds?.top) || 0;
1563
+ const currentInputPointX = currentTransform.outputPoint.x;
1562
1564
  if (currentTransform?.next) {
1563
1565
  lines.push({
1564
- type: FlowTransitionLineEnum6.DRAGGING_LINE,
1565
- from: currentTransform.parent.inputPoint,
1566
- to: {
1566
+ type: FlowTransitionLineEnum6.MERGE_LINE,
1567
+ isDraggingLine: true,
1568
+ from: {
1567
1569
  x: currentInputPointX,
1568
- y: (currentOffsetRightY + nextOffsetLeftY) / 2
1570
+ y: (currentOffsetBottomX + nextOffsetTopX) / 2
1569
1571
  },
1572
+ to: currentTransform.parent.outputPoint,
1570
1573
  side: LABEL_SIDE_TYPE2.NORMAL_BRANCH
1571
1574
  });
1572
1575
  }
@@ -1582,8 +1585,49 @@ var InputRegistry = {
1582
1585
  }
1583
1586
  return lines;
1584
1587
  },
1585
- getLabels() {
1586
- return [];
1588
+ getLabels(transition) {
1589
+ const currentTransform = transition.transform;
1590
+ const { isVertical } = transition.entity;
1591
+ const draggingLabel = [];
1592
+ const hasBranchDraggingAdder = currentTransform && currentTransform.entity.isInlineBlock && transition.renderData.draggable;
1593
+ if (hasBranchDraggingAdder) {
1594
+ if (isVertical) {
1595
+ const currentOffsetRightX = currentTransform.firstChild ? currentTransform.firstChild.bounds.right : currentTransform.bounds.right;
1596
+ const nextOffsetLeftX = (currentTransform.next?.firstChild ? currentTransform.next.firstChild.bounds?.left : currentTransform.next?.bounds?.left) || 0;
1597
+ const currentInputPointY = currentTransform.outputPoint.y;
1598
+ if (currentTransform?.next) {
1599
+ draggingLabel.push({
1600
+ offset: {
1601
+ x: (currentOffsetRightX + nextOffsetLeftX) / 2,
1602
+ y: currentInputPointY
1603
+ },
1604
+ type: FlowTransitionLabelEnum13.BRANCH_DRAGGING_LABEL,
1605
+ width: nextOffsetLeftX - currentOffsetRightX,
1606
+ props: {
1607
+ side: LABEL_SIDE_TYPE2.NORMAL_BRANCH
1608
+ }
1609
+ });
1610
+ }
1611
+ } else {
1612
+ const currentOffsetBottomX = currentTransform.firstChild ? currentTransform.firstChild.bounds.bottom : currentTransform.bounds.bottom;
1613
+ const nextOffsetTopX = (currentTransform.next?.firstChild ? currentTransform.next.firstChild.bounds?.top : currentTransform.next?.bounds?.top) || 0;
1614
+ const currentInputPointX = currentTransform.outputPoint.x;
1615
+ if (currentTransform?.next) {
1616
+ draggingLabel.push({
1617
+ offset: {
1618
+ x: currentInputPointX,
1619
+ y: (currentOffsetBottomX + nextOffsetTopX) / 2
1620
+ },
1621
+ type: FlowTransitionLabelEnum13.BRANCH_DRAGGING_LABEL,
1622
+ width: nextOffsetTopX - currentOffsetBottomX,
1623
+ props: {
1624
+ side: LABEL_SIDE_TYPE2.NORMAL_BRANCH
1625
+ }
1626
+ });
1627
+ }
1628
+ }
1629
+ }
1630
+ return [...draggingLabel];
1587
1631
  }
1588
1632
  };
1589
1633
 
@@ -1599,20 +1643,62 @@ var OuputRegistry = {
1599
1643
  };
1600
1644
 
1601
1645
  // src/activities/multi-outputs.ts
1602
- import { FlowNodeBaseType as FlowNodeBaseType21, FlowNodeSplitType as FlowNodeSplitType4 } from "@flowgram.ai/document";
1646
+ import {
1647
+ FlowLayoutDefault as FlowLayoutDefault7,
1648
+ FlowNodeSplitType as FlowNodeSplitType4,
1649
+ FlowNodeBaseType as FlowNodeBaseType21
1650
+ } from "@flowgram.ai/document";
1603
1651
  var MultiOuputsRegistry = {
1604
1652
  type: FlowNodeBaseType21.MULTI_OUTPUTS,
1605
1653
  extend: FlowNodeSplitType4.SIMPLE_SPLIT,
1654
+ meta: {
1655
+ isNodeEnd: true
1656
+ },
1606
1657
  getLines: (transition, layout) => {
1607
1658
  if (transition.entity.parent?.flowNodeType === FlowNodeBaseType21.INLINE_BLOCKS) {
1608
1659
  return BlockRegistry.getLines(transition, layout);
1609
1660
  }
1610
1661
  return [];
1611
- }
1662
+ },
1663
+ getLabels: (transition, layout) => [
1664
+ ...DynamicSplitRegistry.getLabels(transition, layout),
1665
+ ...BlockRegistry.getLabels(transition, layout)
1666
+ ],
1667
+ getOutputPoint(transform, layout) {
1668
+ const isVertical = FlowLayoutDefault7.isVertical(layout);
1669
+ const lastChildOutput = transform.lastChild?.outputPoint;
1670
+ if (isVertical) {
1671
+ return {
1672
+ x: lastChildOutput ? lastChildOutput.x : transform.bounds.center.x,
1673
+ y: transform.bounds.bottom
1674
+ };
1675
+ }
1676
+ return {
1677
+ x: transform.bounds.right,
1678
+ y: lastChildOutput ? lastChildOutput.y : transform.bounds.center.y
1679
+ };
1680
+ },
1681
+ extendChildRegistries: [
1682
+ {
1683
+ type: FlowNodeBaseType21.BLOCK_ICON,
1684
+ meta: {
1685
+ // isNodeEnd: true
1686
+ }
1687
+ }
1688
+ ]
1612
1689
  };
1613
1690
 
1614
1691
  // src/activities/multi-inputs.ts
1615
- import { FlowNodeBaseType as FlowNodeBaseType22, FlowNodeSplitType as FlowNodeSplitType5 } from "@flowgram.ai/document";
1692
+ import { Point as Point6 } from "@flowgram.ai/utils";
1693
+ import { FlowRendererKey as FlowRendererKey4 } from "@flowgram.ai/renderer";
1694
+ import {
1695
+ FlowNodeBaseType as FlowNodeBaseType22,
1696
+ FlowNodeRenderData as FlowNodeRenderData3,
1697
+ FlowTransitionLabelEnum as FlowTransitionLabelEnum14,
1698
+ FlowNodeSplitType as FlowNodeSplitType5,
1699
+ getDefaultSpacing as getDefaultSpacing8,
1700
+ ConstantKeys as ConstantKeys7
1701
+ } from "@flowgram.ai/document";
1616
1702
  var MultiInputsRegistry = {
1617
1703
  type: FlowNodeBaseType22.MULTI_INPUTS,
1618
1704
  extend: FlowNodeSplitType5.SIMPLE_SPLIT,
@@ -1620,7 +1706,8 @@ var MultiInputsRegistry = {
1620
1706
  {
1621
1707
  type: FlowNodeBaseType22.BLOCK_ICON,
1622
1708
  meta: {
1623
- hidden: true
1709
+ hidden: true,
1710
+ spacing: 0
1624
1711
  },
1625
1712
  getLines() {
1626
1713
  return [];
@@ -1631,8 +1718,52 @@ var MultiInputsRegistry = {
1631
1718
  },
1632
1719
  {
1633
1720
  type: FlowNodeBaseType22.INLINE_BLOCKS,
1634
- getLabels() {
1635
- return [];
1721
+ meta: {
1722
+ inlineSpacingPre: 0
1723
+ },
1724
+ getLabels(transition) {
1725
+ const isVertical = transition.entity.isVertical;
1726
+ const currentTransform = transition.transform;
1727
+ const spacing = getDefaultSpacing8(
1728
+ transition.entity,
1729
+ ConstantKeys7.INLINE_BLOCKS_PADDING_BOTTOM
1730
+ );
1731
+ if (currentTransform.collapsed || transition.entity.childrenLength === 0) {
1732
+ return [
1733
+ {
1734
+ type: FlowTransitionLabelEnum14.CUSTOM_LABEL,
1735
+ renderKey: FlowRendererKey4.BRANCH_ADDER,
1736
+ offset: Point6.move(
1737
+ currentTransform.outputPoint,
1738
+ isVertical ? { y: spacing } : { x: spacing }
1739
+ ),
1740
+ props: {
1741
+ // 激活状态
1742
+ activated: transition.entity.getData(FlowNodeRenderData3).activated,
1743
+ transform: currentTransform,
1744
+ // 传给外部使用的 node 信息
1745
+ node: currentTransform.originParent?.entity
1746
+ }
1747
+ }
1748
+ ];
1749
+ }
1750
+ return [
1751
+ {
1752
+ type: FlowTransitionLabelEnum14.CUSTOM_LABEL,
1753
+ renderKey: FlowRendererKey4.BRANCH_ADDER,
1754
+ offset: Point6.move(
1755
+ currentTransform.outputPoint,
1756
+ isVertical ? { y: -spacing / 2 } : { x: -spacing / 2 }
1757
+ ),
1758
+ props: {
1759
+ // 激活状态
1760
+ activated: transition.entity.getData(FlowNodeRenderData3).activated,
1761
+ transform: currentTransform,
1762
+ // 传给外部使用的 node 信息
1763
+ node: currentTransform.originParent?.entity
1764
+ }
1765
+ }
1766
+ ];
1636
1767
  }
1637
1768
  }
1638
1769
  ],
@@ -1683,7 +1814,7 @@ var FlowRegisters = class {
1683
1814
  OuputRegistry
1684
1815
  );
1685
1816
  document.registerNodeDatas(
1686
- FlowNodeRenderData3,
1817
+ FlowNodeRenderData4,
1687
1818
  // 渲染节点相关数据
1688
1819
  FlowNodeTransitionData,
1689
1820
  // 线条绘制数据