@rxflow/bloodline 0.0.1-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.
Files changed (60) hide show
  1. package/README.md +41 -0
  2. package/cjs/BaseNodeWrapper/index.d.ts +18 -0
  3. package/cjs/BaseNodeWrapper/index.d.ts.map +1 -0
  4. package/cjs/BaseNodeWrapper/index.js +51 -0
  5. package/cjs/GroupNodeWrapper/index.d.ts +15 -0
  6. package/cjs/GroupNodeWrapper/index.d.ts.map +1 -0
  7. package/cjs/GroupNodeWrapper/index.js +64 -0
  8. package/cjs/components/Connector.d.ts +8 -0
  9. package/cjs/components/Connector.d.ts.map +1 -0
  10. package/cjs/components/Connector.js +147 -0
  11. package/cjs/constants.d.ts +26 -0
  12. package/cjs/constants.d.ts.map +1 -0
  13. package/cjs/constants.js +35 -0
  14. package/cjs/index.d.ts +7 -0
  15. package/cjs/index.d.ts.map +1 -0
  16. package/cjs/index.js +82 -0
  17. package/cjs/style/index.less +1 -0
  18. package/cjs/style/theme.less +16 -0
  19. package/cjs/types.d.ts +49 -0
  20. package/cjs/types.d.ts.map +1 -0
  21. package/cjs/types.js +3 -0
  22. package/cjs/utils/_layoutCells.d.ts +14 -0
  23. package/cjs/utils/_layoutCells.d.ts.map +1 -0
  24. package/cjs/utils/_layoutCells.js +483 -0
  25. package/cjs/utils/keys.d.ts +3 -0
  26. package/cjs/utils/keys.d.ts.map +1 -0
  27. package/cjs/utils/keys.js +18 -0
  28. package/cjs/utils/layoutCells.d.ts +14 -0
  29. package/cjs/utils/layoutCells.d.ts.map +1 -0
  30. package/cjs/utils/layoutCells.js +308 -0
  31. package/esm/BaseNodeWrapper/index.d.ts +18 -0
  32. package/esm/BaseNodeWrapper/index.d.ts.map +1 -0
  33. package/esm/BaseNodeWrapper/index.js +44 -0
  34. package/esm/GroupNodeWrapper/index.d.ts +15 -0
  35. package/esm/GroupNodeWrapper/index.d.ts.map +1 -0
  36. package/esm/GroupNodeWrapper/index.js +56 -0
  37. package/esm/components/Connector.d.ts +8 -0
  38. package/esm/components/Connector.d.ts.map +1 -0
  39. package/esm/components/Connector.js +162 -0
  40. package/esm/constants.d.ts +26 -0
  41. package/esm/constants.d.ts.map +1 -0
  42. package/esm/constants.js +30 -0
  43. package/esm/index.d.ts +7 -0
  44. package/esm/index.d.ts.map +1 -0
  45. package/esm/index.js +55 -0
  46. package/esm/style/index.less +1 -0
  47. package/esm/style/theme.less +16 -0
  48. package/esm/types.d.ts +49 -0
  49. package/esm/types.d.ts.map +1 -0
  50. package/esm/types.js +13 -0
  51. package/esm/utils/_layoutCells.d.ts +14 -0
  52. package/esm/utils/_layoutCells.d.ts.map +1 -0
  53. package/esm/utils/_layoutCells.js +477 -0
  54. package/esm/utils/keys.d.ts +3 -0
  55. package/esm/utils/keys.d.ts.map +1 -0
  56. package/esm/utils/keys.js +11 -0
  57. package/esm/utils/layoutCells.d.ts +14 -0
  58. package/esm/utils/layoutCells.d.ts.map +1 -0
  59. package/esm/utils/layoutCells.js +305 -0
  60. package/package.json +47 -0
package/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # @rxflow/bloodline
2
+
3
+ 通用血缘关系图组件,用于展示数据血缘关系。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install @rxflow/bloodline @rxflow/base
9
+ # or
10
+ pnpm add @rxflow/bloodline @rxflow/base
11
+ ```
12
+
13
+ ## 使用
14
+
15
+ ```tsx
16
+ import BloodlineFlow from '@rxflow/bloodline';
17
+
18
+ function App() {
19
+ return (
20
+ <BloodlineFlow
21
+ data={bloodlineData}
22
+ // ... other props
23
+ />
24
+ );
25
+ }
26
+ ```
27
+
28
+ ## 特性
29
+
30
+ - 自动布局
31
+ - 血缘关系可视化
32
+ - 节点展开/折叠
33
+ - 主题定制
34
+
35
+ ## API 文档
36
+
37
+ 访问 [完整文档](https://tree-graph.publib.cn/bloodline/examples) 查看详细 API。
38
+
39
+ ## License
40
+
41
+ MIT
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @author: yanxianliang
3
+ * @date: 2025-09-18 14:16
4
+ * @modified:2025/9/18 14:16 by yanxianliang
5
+ * @desc: 节点的外层组件,实现内置的折叠、加载功能
6
+ *
7
+ * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
8
+ */
9
+ import { NodeTypeComponent } from '@rxflow/base';
10
+ import { BloodlineDirection } from "..";
11
+ import { BaseBloodNode } from "../types";
12
+ export declare const BaseNodeWrapper: NodeTypeComponent<{
13
+ direction: BloodlineDirection;
14
+ origin: BaseBloodNode;
15
+ isRoot?: boolean;
16
+ depth: number;
17
+ }>;
18
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAC,iBAAiB,EAAiB,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAC,kBAAkB,EAAC,WAA0B;AAGrD,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAC;AAIvC,eAAO,MAAM,eAAe,EAAE,iBAAiB,CAAC;IAC9C,SAAS,EAAE,kBAAkB,CAAC;IAC9B,MAAM,EAAE,aAAa,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf,CAyBA,CAAA"}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.BaseNodeWrapper = void 0;
7
+ var _base = require("@rxflow/base");
8
+ var _ = require("./..");
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _Connector = require("../components/Connector");
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
+ /**
15
+ * @author: yanxianliang
16
+ * @date: 2025-09-18 14:16
17
+ * @modified:2025/9/18 14:16 by yanxianliang
18
+ * @desc: 节点的外层组件,实现内置的折叠、加载功能
19
+ *
20
+ * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
21
+ */
22
+
23
+ // 末级叶子节点,前面显示折叠器
24
+ const BaseNodeWrapper = props => {
25
+ const {
26
+ type,
27
+ data
28
+ } = props;
29
+ const nodeTypeMap = (0, _base.useNodeTypeMap)();
30
+ const Component = (0, _react.useMemo)(() => {
31
+ return nodeTypeMap.get(type)?._component;
32
+ }, [nodeTypeMap]);
33
+ const {
34
+ origin
35
+ } = data;
36
+
37
+ // 创建更多的占位连接桩,当出现重复时可以使用上下进行链接
38
+
39
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
40
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Connector.Connector, {
41
+ source: origin,
42
+ direction: _.BloodlineDirection.upstream
43
+ }), Component ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
44
+ ...props
45
+ }) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(_Connector.Connector, {
46
+ source: origin,
47
+ direction: _.BloodlineDirection.downstream
48
+ })]
49
+ });
50
+ };
51
+ exports.BaseNodeWrapper = BaseNodeWrapper;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @author: yanxianliang
3
+ * @date: 2025-09-25 10:16
4
+ * @modified:2025/9/25 10:16 by yanxianliang
5
+ * @desc: 组合节点,支持多个连接桩
6
+ *
7
+ * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
8
+ */
9
+ import { type NodeTypeComponent } from '@rxflow/base';
10
+ import { BaseBloodNode, BloodlineDirection } from "..";
11
+ export declare const GroupWrapper: NodeTypeComponent<{
12
+ direction: BloodlineDirection;
13
+ origin: BaseBloodNode;
14
+ }>;
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAiB,KAAK,iBAAiB,EAAC,MAAM,cAAc,CAAC;AAEpE,OAAO,EAAC,aAAa,EAAE,kBAAkB,EAAC,WAA0B;AAIpE,eAAO,MAAM,YAAY,EAAE,iBAAiB,CAAC;IAC3C,SAAS,EAAE,kBAAkB,CAAC;IAC9B,MAAM,EAAE,aAAa,CAAC;CACvB,CAsCA,CAAA"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.GroupWrapper = void 0;
7
+ var _base = require("@rxflow/base");
8
+ var _ = require("./..");
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _Connector = require("../components/Connector");
11
+ var _jsxRuntime = require("react/jsx-runtime");
12
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
+ /**
15
+ * @author: yanxianliang
16
+ * @date: 2025-09-25 10:16
17
+ * @modified:2025/9/25 10:16 by yanxianliang
18
+ * @desc: 组合节点,支持多个连接桩
19
+ *
20
+ * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
21
+ */
22
+
23
+ const GroupWrapper = props => {
24
+ const {
25
+ type,
26
+ data
27
+ } = props;
28
+ const nodeTypeMap = (0, _base.useNodeTypeMap)();
29
+ const Component = (0, _react.useMemo)(() => {
30
+ return nodeTypeMap.get(type)?._component;
31
+ }, [nodeTypeMap]);
32
+ const {
33
+ origin,
34
+ direction
35
+ } = data;
36
+ const innerNodes = origin?.innerNodes || [];
37
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
38
+ children: [Component ? /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
39
+ ...props
40
+ }) : null, innerNodes?.map(node => {
41
+ const NodeComponent = nodeTypeMap.get(node.type)?._component;
42
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
43
+ style: {
44
+ position: 'relative'
45
+ },
46
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_Connector.Connector, {
47
+ source: node,
48
+ direction: _.BloodlineDirection.upstream
49
+ }), NodeComponent ? /*#__PURE__*/(0, _jsxRuntime.jsx)(NodeComponent, {
50
+ ...props,
51
+ ...node,
52
+ data: {
53
+ direction,
54
+ origin: node
55
+ }
56
+ }) : null, /*#__PURE__*/(0, _jsxRuntime.jsx)(_Connector.Connector, {
57
+ source: node,
58
+ direction: _.BloodlineDirection.downstream
59
+ })]
60
+ }, node.id);
61
+ })]
62
+ });
63
+ };
64
+ exports.GroupWrapper = GroupWrapper;
@@ -0,0 +1,8 @@
1
+ import { BloodlineDirection } from "../constants";
2
+ import { BaseBloodNode } from "../types";
3
+ export declare const Connector: ({ direction, source, disabled }: {
4
+ direction: BloodlineDirection;
5
+ source: BaseBloodNode;
6
+ disabled?: boolean | undefined;
7
+ }) => import("react/jsx-runtime").JSX.Element;
8
+ //# sourceMappingURL=Connector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Connector.d.ts","sourceRoot":"","sources":["Connector.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAC,kBAAkB,EAAoB,MAAM,cAAc,CAAC;AACnE,OAAO,EAAC,aAAa,EAAsC,MAAM,UAAU,CAAC;AAwC5E,eAAO,MAAM,SAAS;eAMP,kBAAkB;YACrB,aAAa;;6CAyFxB,CAAA"}
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Connector = void 0;
7
+ var _base = require("@rxflow/base");
8
+ var _react = require("@xyflow/react");
9
+ var _ahooks = require("ahooks");
10
+ var _react2 = _interopRequireWildcard(require("react"));
11
+ var _constants = require("../constants");
12
+ var _keys = require("../utils/keys");
13
+ var _jsxRuntime = require("react/jsx-runtime");
14
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
15
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
+ /**
17
+ * @author: yanxianliang
18
+ * @date: 2025-07-05 15:19
19
+ * @desc: 连接器
20
+ *
21
+ * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
22
+ */
23
+
24
+ function collapseVersionsNode(direction, node) {
25
+ for (const version of node.versions) {
26
+ version[direction] && (version[direction].state = 'collapsed');
27
+ }
28
+ }
29
+ function collapseGroup(direction, node) {
30
+ const list = node.state?.list;
31
+ if (list) {
32
+ collapseSiblings(direction, list);
33
+ }
34
+ }
35
+ function collapseSiblings(direction, siblings) {
36
+ for (const sibling of siblings) {
37
+ const {
38
+ type
39
+ } = sibling;
40
+ switch (type) {
41
+ case _constants.BloodlineNodeType.Service:
42
+ collapseVersionsNode(direction, sibling);
43
+ break;
44
+ case _constants.BloodlineNodeType.ServiceGroup:
45
+ collapseGroup(direction, sibling);
46
+ break;
47
+ }
48
+ }
49
+ }
50
+ function getStateWithDefault(config) {
51
+ const {
52
+ state = 'collapsed',
53
+ list,
54
+ ...extra
55
+ } = config || {};
56
+ return {
57
+ ...extra,
58
+ state,
59
+ list
60
+ };
61
+ }
62
+ const Connector = ({
63
+ direction,
64
+ source,
65
+ disabled = false
66
+ }) => {
67
+ const update = (0, _ahooks.useUpdate)();
68
+ const triggerLayout = (0, _base.useForceUpdate)();
69
+ const getProps = (0, _base.useGetProps)();
70
+ const config = source[direction];
71
+ const connectorState = (0, _react2.useMemo)(() => {
72
+ return getStateWithDefault(config);
73
+ }, [config?.state]);
74
+ const {
75
+ count,
76
+ state,
77
+ disableCollapse = false
78
+ } = connectorState;
79
+ const notShow = !config || config.count === 0 || disabled;
80
+ const position = direction === _constants.BloodlineDirection.upstream ? _react.Position.Left : _react.Position.Right;
81
+ const onClick = (0, _ahooks.useMemoizedFn)(() => {
82
+ const {
83
+ state,
84
+ list
85
+ } = connectorState;
86
+ const {
87
+ getRelation
88
+ } = getProps();
89
+ if (state === 'loading') {
90
+ return;
91
+ }
92
+ if (state === 'collapsed') {
93
+ if (list || !getRelation) {
94
+ // 数据已经缓存了,不需要再次加载
95
+ config.state = 'expanded'; // 展开状态,关联的节点需要显示,在布局函数中处理
96
+ triggerLayout();
97
+ } else {
98
+ config.state = 'loading';
99
+ update(); // 变成加载状态
100
+ getRelation(direction, source).then(({
101
+ count,
102
+ list
103
+ }) => {
104
+ // 执行互斥逻辑,将同级所有节点展开项全部关闭
105
+ if (config.state === 'loading') {
106
+ // 可能已经被收起来了
107
+ config.state = 'expanded';
108
+ config.count = count;
109
+ config.list = list;
110
+ triggerLayout();
111
+ } else {
112
+ config.count = count;
113
+ config.list = list;
114
+ update();
115
+ }
116
+ }).catch(() => {
117
+ // 异常兜底,
118
+ config.state = 'collapsed'; // 支持重试
119
+ update();
120
+ });
121
+ }
122
+ } else {
123
+ config.state = 'collapsed';
124
+ triggerLayout();
125
+ }
126
+ });
127
+ const handleType = direction === _constants.BloodlineDirection.upstream ? 'target' : 'source';
128
+ const handle = /*#__PURE__*/(0, _jsxRuntime.jsx)(_base.HiddenHandle, {
129
+ type: handleType,
130
+ position: position,
131
+ id: (0, _keys.getConnectorId)(direction, source.id)
132
+ });
133
+ if (notShow) {
134
+ return handle;
135
+ }
136
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
137
+ children: [handle, disableCollapse ? null : /*#__PURE__*/(0, _jsxRuntime.jsx)(_base.CollapseButton, {
138
+ direction: 'vertical',
139
+ collapsed: state === 'collapsed',
140
+ position: position,
141
+ loading: state === 'loading',
142
+ onCollapse: onClick,
143
+ count: count
144
+ })]
145
+ });
146
+ };
147
+ exports.Connector = Connector;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @author: yanxianliang
3
+ * @date: 2025-07-05 15:48
4
+ * @desc: 常量
5
+ *
6
+ * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
7
+ */
8
+ export declare enum BloodlineDirection {
9
+ upstream = "upstream",
10
+ downstream = "downstream"
11
+ }
12
+ export declare enum BloodlineNodeType {
13
+ Service = "service",// 服务节点,支持单版本和多版本。
14
+ ServiceGroup = "service-group"
15
+ }
16
+ export declare enum Align {
17
+ center = "center",
18
+ top = "top"
19
+ }
20
+ export declare const sideSymbol: unique symbol;
21
+ export declare const parentIdSymbol: unique symbol;
22
+ export declare enum SplitSide {
23
+ left = "left",
24
+ right = "right"
25
+ }
26
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,oBAAY,kBAAkB;IAC5B,QAAQ,aAAa;IACrB,UAAU,eAAe;CAC1B;AAGD,oBAAY,iBAAiB;IAC3B,OAAO,YAAY,CAAE,kBAAkB;IACvC,YAAY,kBAAkB;CAC/B;AAGD,oBAAY,KAAK;IACf,MAAM,WAAW;IACjB,GAAG,QAAQ;CACZ;AAGD,eAAO,MAAM,UAAU,eAA8B,CAAC;AACtD,eAAO,MAAM,cAAc,eAA8B,CAAC;AAE1D,oBAAY,SAAS;IACnB,IAAI,SAAS;IACb,KAAK,UAAU;CAChB"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.sideSymbol = exports.parentIdSymbol = exports.SplitSide = exports.BloodlineNodeType = exports.BloodlineDirection = exports.Align = void 0;
7
+ /**
8
+ * @author: yanxianliang
9
+ * @date: 2025-07-05 15:48
10
+ * @desc: 常量
11
+ *
12
+ * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
13
+ */
14
+ let BloodlineDirection = exports.BloodlineDirection = /*#__PURE__*/function (BloodlineDirection) {
15
+ BloodlineDirection["upstream"] = "upstream";
16
+ BloodlineDirection["downstream"] = "downstream";
17
+ return BloodlineDirection;
18
+ }({});
19
+ let BloodlineNodeType = exports.BloodlineNodeType = /*#__PURE__*/function (BloodlineNodeType) {
20
+ BloodlineNodeType["Service"] = "service";
21
+ BloodlineNodeType["ServiceGroup"] = "service-group";
22
+ return BloodlineNodeType;
23
+ }({});
24
+ let Align = exports.Align = /*#__PURE__*/function (Align) {
25
+ Align["center"] = "center";
26
+ Align["top"] = "top";
27
+ return Align;
28
+ }({});
29
+ const sideSymbol = exports.sideSymbol = Symbol.for('__node_side__');
30
+ const parentIdSymbol = exports.parentIdSymbol = Symbol.for('__parent_id__');
31
+ let SplitSide = exports.SplitSide = /*#__PURE__*/function (SplitSide) {
32
+ SplitSide["left"] = "left";
33
+ SplitSide["right"] = "right";
34
+ return SplitSide;
35
+ }({});
package/cjs/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import { IBloodlineFlowProps } from "./types";
3
+ declare const BloodlineFlow: (props: import("react").PropsWithChildren<IBloodlineFlowProps>) => import("react/jsx-runtime").JSX.Element;
4
+ export default BloodlineFlow;
5
+ export * from './types';
6
+ export * from './constants';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAuB,mBAAmB,EAAC,MAAM,SAAS,CAAC;AAYlE,QAAA,MAAM,aAAa,4GA6BjB,CAAA;AAGF,eAAe,aAAa,CAAC;AAG7B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
package/cjs/index.js ADDED
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {};
7
+ exports.default = void 0;
8
+ var _base = require("@rxflow/base");
9
+ var _react = require("react");
10
+ var _BaseNodeWrapper = require("./BaseNodeWrapper");
11
+ var _GroupNodeWrapper = require("./GroupNodeWrapper");
12
+ var _layoutCells = require("./utils/layoutCells");
13
+ var _types = require("./types");
14
+ Object.keys(_types).forEach(function (key) {
15
+ if (key === "default" || key === "__esModule") return;
16
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
17
+ if (key in exports && exports[key] === _types[key]) return;
18
+ Object.defineProperty(exports, key, {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _types[key];
22
+ }
23
+ });
24
+ });
25
+ var _constants = require("./constants");
26
+ Object.keys(_constants).forEach(function (key) {
27
+ if (key === "default" || key === "__esModule") return;
28
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
29
+ if (key in exports && exports[key] === _constants[key]) return;
30
+ Object.defineProperty(exports, key, {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _constants[key];
34
+ }
35
+ });
36
+ });
37
+ /*
38
+ * @author: yanxianliang
39
+ * @date: 2025-06-01 18:36
40
+ * @desc: 血缘视图
41
+ *
42
+ * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
43
+ */
44
+
45
+ const fitViewOptions = {
46
+ padding: 2,
47
+ minZoom: 1,
48
+ maxZoom: 1
49
+ };
50
+ const omitProps = ['root', 'getRelation', 'mode'];
51
+ const BloodlineFlow = (0, _base.createFlow)(_base.Flow, props => {
52
+ const {
53
+ root,
54
+ nodeTypes
55
+ } = props;
56
+ const nodes = (0, _react.useMemo)(() => {
57
+ return root ? [root] : [];
58
+ }, [root]);
59
+ const _nodeTypes = (0, _react.useMemo)(() => {
60
+ return nodeTypes?.map(nodeType => {
61
+ return {
62
+ ...nodeType,
63
+ _component: nodeType.component,
64
+ // 真实的节点组件
65
+ component: nodeType.type === 'fields' ? _GroupNodeWrapper.GroupWrapper : _BaseNodeWrapper.BaseNodeWrapper
66
+ };
67
+ });
68
+ }, [nodeTypes]);
69
+ return {
70
+ ...props,
71
+ edgesFocusable: false,
72
+ fitViewOptions,
73
+ autoCenter: true,
74
+ nodes,
75
+ layout: _layoutCells.layoutCells,
76
+ nodeTypes: _nodeTypes,
77
+ omitProps,
78
+ selectionOnDrag: false,
79
+ nodesDraggable: false
80
+ };
81
+ });
82
+ var _default = exports.default = BloodlineFlow;
@@ -0,0 +1 @@
1
+ @import "theme";
@@ -0,0 +1,16 @@
1
+ @padding-left: 18px;
2
+ @main-color: #69b1ff;
3
+ @border-color: #E8E8E8;
4
+ @hit-border-color: #69b1ff;
5
+
6
+ @second-border-color: #BBBBBB;
7
+
8
+ @changed-color: #ff4d4f;
9
+
10
+ @txt-color: rgba(0,0,0,0.88);
11
+
12
+ @text-second-color: rgba(0, 0, 0, 0.45);
13
+
14
+ @root-node-ng: #E8F0FD;
15
+
16
+ @text-space: 12px;
package/cjs/types.d.ts ADDED
@@ -0,0 +1,49 @@
1
+ import { BaseThemeConfig, IBaseFlowProps } from "@rxflow/base";
2
+ import { Align, BloodlineDirection, parentIdSymbol, sideSymbol, SplitSide } from "./constants";
3
+ export interface IBloodlineTheme extends BaseThemeConfig {
4
+ /**
5
+ * @description 对齐方式
6
+ * @default 'top'
7
+ */
8
+ align?: Align;
9
+ /**
10
+ * @description 布局方式
11
+ * @default 'compactBox'
12
+ */
13
+ layout?: 'compactBox' | 'mindmap';
14
+ }
15
+ export type BloodlineExtendProps = {
16
+ root?: BaseBloodNode;
17
+ theme?: IBloodlineTheme;
18
+ /**
19
+ * 异步加载关联节点
20
+ * @param direction
21
+ * @param source
22
+ */
23
+ getRelation?: (direction: BloodlineDirection, source: BaseBloodNode) => Promise<Omit<ConnectorState, 'state'>>;
24
+ };
25
+ export type IBloodlineFlowProps = Omit<IBaseFlowProps, 'nodes' | 'edges' | 'theme' | 'defaultNodes' | 'defaultEdges'> & BloodlineExtendProps;
26
+ export type BaseBloodNode = {
27
+ relationLabel?: string;
28
+ id: string;
29
+ type: string;
30
+ width?: number;
31
+ height?: number;
32
+ upstream?: ConnectorState;
33
+ downstream?: ConnectorState;
34
+ innerNodes?: BaseBloodNode[];
35
+ [sideSymbol]?: SplitSide;
36
+ [parentIdSymbol]?: string;
37
+ [key: string]: any;
38
+ };
39
+ export type ConnectorState = {
40
+ state?: 'expanded' | 'loading' | 'collapsed';
41
+ count?: number;
42
+ disableCollapse?: boolean;
43
+ list?: Array<BaseBloodNode>;
44
+ };
45
+ export type InnerNodeData = {
46
+ isRoot: boolean;
47
+ depth: number;
48
+ };
49
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AASA,OAAO,EAAC,eAAe,EAAE,cAAc,EAAC,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAC,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAC,MAAM,aAAa,CAAC;AAI7F,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD;;;OAGG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;IAEd;;;OAGG;IACH,MAAM,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;CACnC;AAGD,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,CAAC,EAAE,aAAa,CAAC;IACrB,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB;;;;OAIG;IACH,WAAW,CAAC,EAAE,CAAC,SAAS,EAAE,kBAAkB,EAAE,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC;CAChH,CAAA;AAGD,MAAM,MAAM,mBAAmB,GAAG,IAAI,CAAC,cAAc,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,cAAc,GAAG,cAAc,CAAC,GAAG,oBAAoB,CAAC;AAE7I,MAAM,MAAM,aAAa,GAAG;IAC1B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAE1B,UAAU,CAAC,EAAE,cAAc,CAAC;IAE5B,UAAU,CAAC,EAAE,aAAa,EAAE,CAAC;IAE7B,CAAC,UAAU,CAAC,CAAC,EAAE,SAAS,CAAC;IAEzB,CAAC,cAAc,CAAC,CAAC,EAAE,MAAM,CAAC;IAE1B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,CAAA;AAGD,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,CAAC,EAAE,UAAU,GAAG,SAAS,GAAG,WAAW,CAAC;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,IAAI,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;CAC7B,CAAA;AAID,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf,CAAA"}
package/cjs/types.js ADDED
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+
3
+ var _constants = require("./constants");
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @author: yanxianliang
3
+ * @date: 2025-07-03 13:20
4
+ * @desc: 血缘布局
5
+ *
6
+ * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
7
+ */
8
+ import { LayoutConfig } from "@rxflow/base";
9
+ import { Edge, Node } from "@xyflow/react";
10
+ export declare const layoutCells: <NodeType extends Node = Node, EdgeType extends Edge = Edge>(config: LayoutConfig<NodeType, EdgeType>) => {
11
+ nodes: NodeType[];
12
+ edges: EdgeType[];
13
+ };
14
+ //# sourceMappingURL=_layoutCells.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_layoutCells.d.ts","sourceRoot":"","sources":["_layoutCells.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAA8B,YAAY,EAAe,MAAM,cAAc,CAAC;AAErF,OAAO,EAAC,IAAI,EAAE,IAAI,EAAC,MAAM,eAAe,CAAC;AAoGzC,eAAO,MAAM,WAAW,uEACd,aAAa,QAAQ,EAAE,QAAQ,CAAC;;;CA6WzC,CAAA"}