@rxflow/bloodline 0.0.3 → 0.0.4-alpha.1

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.
@@ -66,7 +66,7 @@ const Connector = ({
66
66
  }) => {
67
67
  const update = (0, _ahooks.useUpdate)();
68
68
  const triggerLayout = (0, _base.useForceUpdate)();
69
- const getProps = (0, _base.useGetProps)();
69
+ const getInputProps = (0, _base.useGetInputProps)();
70
70
  const config = source[direction];
71
71
  const connectorState = (0, _react2.useMemo)(() => {
72
72
  return getStateWithDefault(config);
@@ -85,7 +85,7 @@ const Connector = ({
85
85
  } = connectorState;
86
86
  const {
87
87
  getRelation
88
- } = getProps();
88
+ } = getInputProps();
89
89
  if (state === 'loading') {
90
90
  return;
91
91
  }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @author: yanxianliang
3
+ * @date: 2025-01-17
4
+ * @desc: Bloodline hooks 导出
5
+ *
6
+ * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
7
+ */
8
+ export * from './useBloodlineProps';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _useBloodlineProps = require("./useBloodlineProps");
7
+ Object.keys(_useBloodlineProps).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _useBloodlineProps[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _useBloodlineProps[key];
14
+ }
15
+ });
16
+ });
@@ -0,0 +1,61 @@
1
+ /**
2
+ * @author: yanxianliang
3
+ * @date: 2025-01-17
4
+ * @desc: Bloodline Props hooks - 类型化的 props 访问
5
+ *
6
+ * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
7
+ */
8
+ import { IBaseFlowProps } from '@rxflow/base';
9
+ import { IBloodlineFlowProps, BloodlineExtendProps, BaseBloodNode, ConnectorState } from '../types';
10
+ import { BloodlineDirection } from '../constants';
11
+ type BloodlineFlowProps = IBaseFlowProps & BloodlineExtendProps;
12
+ /**
13
+ * 获取原始输入 props
14
+ *
15
+ * @example
16
+ * const inputProps = useBloodlineInputProps();
17
+ * const root = useBloodlineInputProps(state => state.root);
18
+ */
19
+ export declare function useBloodlineInputProps(): IBloodlineFlowProps;
20
+ export declare function useBloodlineInputProps<U>(selector: (state: IBloodlineFlowProps) => U): U;
21
+ /**
22
+ * 获取转换后的 Flow props
23
+ *
24
+ * @example
25
+ * const flowProps = useBloodlineFlowProps();
26
+ * const nodes = useBloodlineFlowProps(state => state.nodes);
27
+ */
28
+ export declare function useBloodlineFlowProps(): BloodlineFlowProps;
29
+ export declare function useBloodlineFlowProps<U>(selector: (state: BloodlineFlowProps) => U): U;
30
+ /**
31
+ * 获取原始输入 props 的 getter(非响应式)
32
+ */
33
+ export declare const useGetBloodlineInputProps: () => {
34
+ (): IBloodlineFlowProps;
35
+ <U>(selector: (state: IBloodlineFlowProps) => U): U;
36
+ };
37
+ /**
38
+ * 获取转换后 Flow props 的 getter(非响应式)
39
+ */
40
+ export declare const useGetBloodlineFlowProps: () => {
41
+ (): BloodlineFlowProps;
42
+ <U>(selector: (state: BloodlineFlowProps) => U): U;
43
+ };
44
+ /**
45
+ * 获取 root 节点数据
46
+ */
47
+ export declare const useRoot: () => BaseBloodNode | undefined;
48
+ /**
49
+ * 获取异步加载关联节点的函数
50
+ */
51
+ export declare const useGetRelation: () => ((direction: BloodlineDirection, source: BaseBloodNode) => Promise<Omit<ConnectorState, "state">>) | undefined;
52
+ /**
53
+ * 获取 Bloodline 主题配置
54
+ */
55
+ export declare const useBloodlineTheme: () => import("../types").IBloodlineTheme | undefined;
56
+ /**
57
+ * 获取连线类型
58
+ */
59
+ export declare const useEdgeType: () => string | undefined;
60
+ export {};
61
+ //# sourceMappingURL=useBloodlineProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBloodlineProps.d.ts","sourceRoot":"","sources":["useBloodlineProps.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAkE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9G,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACpG,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,KAAK,kBAAkB,GAAG,cAAc,GAAG,oBAAoB,CAAC;AAEhE;;;;;;GAMG;AACH,wBAAgB,sBAAsB,IAAI,mBAAmB,CAAC;AAC9D,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,CAAC,GAAG,CAAC,CAAC;AAK1F;;;;;;GAMG;AACH,wBAAgB,qBAAqB,IAAI,kBAAkB,CAAC;AAC5D,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,CAAC,GAAG,CAAC,CAAC;AAKxF;;GAEG;AACH,eAAO,MAAM,yBAAyB;;;CAErC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;CAEpC,CAAC;AAGF;;GAEG;AACH,eAAO,MAAM,OAAO,iCAAoD,CAAC;AAEzE;;GAEG;AACH,eAAO,MAAM,cAAc,sHAA2D,CAAC;AAEvF;;GAEG;AACH,eAAO,MAAM,iBAAiB,sDAAqD,CAAC;AAEpF;;GAEG;AACH,eAAO,MAAM,WAAW,0BAAwD,CAAC"}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useBloodlineFlowProps = useBloodlineFlowProps;
7
+ exports.useBloodlineInputProps = useBloodlineInputProps;
8
+ exports.useRoot = exports.useGetRelation = exports.useGetBloodlineInputProps = exports.useGetBloodlineFlowProps = exports.useEdgeType = exports.useBloodlineTheme = void 0;
9
+ var _base = require("@rxflow/base");
10
+ /**
11
+ * @author: yanxianliang
12
+ * @date: 2025-01-17
13
+ * @desc: Bloodline Props hooks - 类型化的 props 访问
14
+ *
15
+ * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
16
+ */
17
+
18
+ /**
19
+ * 获取原始输入 props
20
+ *
21
+ * @example
22
+ * const inputProps = useBloodlineInputProps();
23
+ * const root = useBloodlineInputProps(state => state.root);
24
+ */
25
+
26
+ function useBloodlineInputProps(selector) {
27
+ return (0, _base.useInputProps)(selector);
28
+ }
29
+
30
+ /**
31
+ * 获取转换后的 Flow props
32
+ *
33
+ * @example
34
+ * const flowProps = useBloodlineFlowProps();
35
+ * const nodes = useBloodlineFlowProps(state => state.nodes);
36
+ */
37
+
38
+ function useBloodlineFlowProps(selector) {
39
+ return (0, _base.useFlowProps)(selector);
40
+ }
41
+
42
+ /**
43
+ * 获取原始输入 props 的 getter(非响应式)
44
+ */
45
+ const useGetBloodlineInputProps = () => {
46
+ return (0, _base.useGetInputProps)();
47
+ };
48
+
49
+ /**
50
+ * 获取转换后 Flow props 的 getter(非响应式)
51
+ */
52
+ exports.useGetBloodlineInputProps = useGetBloodlineInputProps;
53
+ const useGetBloodlineFlowProps = () => {
54
+ return (0, _base.useGetFlowProps)();
55
+ };
56
+
57
+ // 便捷 hooks
58
+ /**
59
+ * 获取 root 节点数据
60
+ */
61
+ exports.useGetBloodlineFlowProps = useGetBloodlineFlowProps;
62
+ const useRoot = () => useBloodlineInputProps(state => state.root);
63
+
64
+ /**
65
+ * 获取异步加载关联节点的函数
66
+ */
67
+ exports.useRoot = useRoot;
68
+ const useGetRelation = () => useBloodlineInputProps(state => state.getRelation);
69
+
70
+ /**
71
+ * 获取 Bloodline 主题配置
72
+ */
73
+ exports.useGetRelation = useGetRelation;
74
+ const useBloodlineTheme = () => useBloodlineInputProps(state => state.theme);
75
+
76
+ /**
77
+ * 获取连线类型
78
+ */
79
+ exports.useBloodlineTheme = useBloodlineTheme;
80
+ const useEdgeType = () => useBloodlineInputProps(state => state.edgeType);
81
+ exports.useEdgeType = useEdgeType;
package/cjs/index.d.ts CHANGED
@@ -4,4 +4,5 @@ declare const BloodlineFlow: (props: import("react").PropsWithChildren<IBloodlin
4
4
  export default BloodlineFlow;
5
5
  export * from './types';
6
6
  export * from './constants';
7
+ export * from './hooks';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAuB,mBAAmB,EAAC,MAAM,SAAS,CAAC;AAalE,QAAA,MAAM,aAAa,4GA6BjB,CAAA;AAGF,eAAe,aAAa,CAAC;AAG7B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAwB,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAsCpE,QAAA,MAAM,aAAa,4GAGlB,CAAC;AAEF,eAAe,aAAa,CAAC;AAG7B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAG5B,cAAc,SAAS,CAAC"}
package/cjs/index.js CHANGED
@@ -34,9 +34,22 @@ Object.keys(_constants).forEach(function (key) {
34
34
  }
35
35
  });
36
36
  });
37
+ var _hooks = require("./hooks");
38
+ Object.keys(_hooks).forEach(function (key) {
39
+ if (key === "default" || key === "__esModule") return;
40
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
41
+ if (key in exports && exports[key] === _hooks[key]) return;
42
+ Object.defineProperty(exports, key, {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _hooks[key];
46
+ }
47
+ });
48
+ });
37
49
  /*
38
50
  * @author: yanxianliang
39
51
  * @date: 2025-06-01 18:36
52
+ * @modified:2025/1/17 by yanxianliang
40
53
  * @desc: 血缘视图
41
54
  *
42
55
  * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
@@ -47,24 +60,28 @@ const fitViewOptions = {
47
60
  minZoom: 1,
48
61
  maxZoom: 1
49
62
  };
50
- const omitProps = ['root', 'getRelation', 'mode', 'edgeType'];
51
- const BloodlineFlow = (0, _base.createFlow)(_base.Flow, props => {
63
+
64
+ /**
65
+ * Props 转换 hook
66
+ */
67
+ const useBloodlinePropsTransform = props => {
52
68
  const {
53
69
  root,
54
70
  nodeTypes
55
71
  } = props;
72
+
73
+ // 将 root 转换为 nodes
56
74
  const nodes = (0, _react.useMemo)(() => {
57
75
  return root ? [root] : [];
58
76
  }, [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
- });
77
+
78
+ // 包装 nodeTypes
79
+ const wrappedNodeTypes = (0, _react.useMemo)(() => {
80
+ return nodeTypes?.map(nodeType => ({
81
+ ...nodeType,
82
+ _component: nodeType.component,
83
+ component: nodeType.type === 'fields' ? _GroupNodeWrapper.GroupWrapper : _BaseNodeWrapper.BaseNodeWrapper
84
+ }));
68
85
  }, [nodeTypes]);
69
86
  return {
70
87
  ...props,
@@ -73,10 +90,11 @@ const BloodlineFlow = (0, _base.createFlow)(_base.Flow, props => {
73
90
  autoCenter: true,
74
91
  nodes,
75
92
  layout: _layoutCells.layoutCells,
76
- nodeTypes: _nodeTypes,
77
- omitProps,
93
+ nodeTypes: wrappedNodeTypes,
78
94
  selectionOnDrag: false,
79
95
  nodesDraggable: false
80
96
  };
81
- });
82
- var _default = exports.default = BloodlineFlow;
97
+ };
98
+ const BloodlineFlow = (0, _base.createFlow)(_base.Flow, useBloodlinePropsTransform);
99
+ var _default = exports.default = BloodlineFlow; // 类型导出
100
+ // Hooks 导出
@@ -17,7 +17,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
17
17
  *
18
18
  * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
19
19
  */
20
- import { CollapseButton, HiddenHandle, useForceUpdate, useGetProps } from "@rxflow/base";
20
+ import { CollapseButton, HiddenHandle, useForceUpdate, useGetInputProps } from "@rxflow/base";
21
21
  import { Position } from "@xyflow/react";
22
22
  import { useMemoizedFn, useUpdate } from "ahooks";
23
23
  import React, { useMemo } from "react";
@@ -87,7 +87,7 @@ export var Connector = function Connector(_ref2) {
87
87
  disabled = _ref2$disabled === void 0 ? false : _ref2$disabled;
88
88
  var update = useUpdate();
89
89
  var triggerLayout = useForceUpdate();
90
- var getProps = useGetProps();
90
+ var getInputProps = useGetInputProps();
91
91
  var config = source[direction];
92
92
  var connectorState = useMemo(function () {
93
93
  return getStateWithDefault(config);
@@ -101,8 +101,8 @@ export var Connector = function Connector(_ref2) {
101
101
  var onClick = useMemoizedFn(function () {
102
102
  var state = connectorState.state,
103
103
  list = connectorState.list;
104
- var _getProps = getProps(),
105
- getRelation = _getProps.getRelation;
104
+ var _getInputProps = getInputProps(),
105
+ getRelation = _getInputProps.getRelation;
106
106
  if (state === 'loading') {
107
107
  return;
108
108
  }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @author: yanxianliang
3
+ * @date: 2025-01-17
4
+ * @desc: Bloodline hooks 导出
5
+ *
6
+ * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
7
+ */
8
+ export * from './useBloodlineProps';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @author: yanxianliang
3
+ * @date: 2025-01-17
4
+ * @desc: Bloodline hooks 导出
5
+ *
6
+ * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
7
+ */
8
+
9
+ export * from "./useBloodlineProps";
@@ -0,0 +1,61 @@
1
+ /**
2
+ * @author: yanxianliang
3
+ * @date: 2025-01-17
4
+ * @desc: Bloodline Props hooks - 类型化的 props 访问
5
+ *
6
+ * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
7
+ */
8
+ import { IBaseFlowProps } from '@rxflow/base';
9
+ import { IBloodlineFlowProps, BloodlineExtendProps, BaseBloodNode, ConnectorState } from '../types';
10
+ import { BloodlineDirection } from '../constants';
11
+ type BloodlineFlowProps = IBaseFlowProps & BloodlineExtendProps;
12
+ /**
13
+ * 获取原始输入 props
14
+ *
15
+ * @example
16
+ * const inputProps = useBloodlineInputProps();
17
+ * const root = useBloodlineInputProps(state => state.root);
18
+ */
19
+ export declare function useBloodlineInputProps(): IBloodlineFlowProps;
20
+ export declare function useBloodlineInputProps<U>(selector: (state: IBloodlineFlowProps) => U): U;
21
+ /**
22
+ * 获取转换后的 Flow props
23
+ *
24
+ * @example
25
+ * const flowProps = useBloodlineFlowProps();
26
+ * const nodes = useBloodlineFlowProps(state => state.nodes);
27
+ */
28
+ export declare function useBloodlineFlowProps(): BloodlineFlowProps;
29
+ export declare function useBloodlineFlowProps<U>(selector: (state: BloodlineFlowProps) => U): U;
30
+ /**
31
+ * 获取原始输入 props 的 getter(非响应式)
32
+ */
33
+ export declare const useGetBloodlineInputProps: () => {
34
+ (): IBloodlineFlowProps;
35
+ <U>(selector: (state: IBloodlineFlowProps) => U): U;
36
+ };
37
+ /**
38
+ * 获取转换后 Flow props 的 getter(非响应式)
39
+ */
40
+ export declare const useGetBloodlineFlowProps: () => {
41
+ (): BloodlineFlowProps;
42
+ <U>(selector: (state: BloodlineFlowProps) => U): U;
43
+ };
44
+ /**
45
+ * 获取 root 节点数据
46
+ */
47
+ export declare const useRoot: () => BaseBloodNode | undefined;
48
+ /**
49
+ * 获取异步加载关联节点的函数
50
+ */
51
+ export declare const useGetRelation: () => ((direction: BloodlineDirection, source: BaseBloodNode) => Promise<Omit<ConnectorState, "state">>) | undefined;
52
+ /**
53
+ * 获取 Bloodline 主题配置
54
+ */
55
+ export declare const useBloodlineTheme: () => import("../types").IBloodlineTheme | undefined;
56
+ /**
57
+ * 获取连线类型
58
+ */
59
+ export declare const useEdgeType: () => string | undefined;
60
+ export {};
61
+ //# sourceMappingURL=useBloodlineProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useBloodlineProps.d.ts","sourceRoot":"","sources":["useBloodlineProps.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAkE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9G,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACpG,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,KAAK,kBAAkB,GAAG,cAAc,GAAG,oBAAoB,CAAC;AAEhE;;;;;;GAMG;AACH,wBAAgB,sBAAsB,IAAI,mBAAmB,CAAC;AAC9D,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,CAAC,GAAG,CAAC,CAAC;AAK1F;;;;;;GAMG;AACH,wBAAgB,qBAAqB,IAAI,kBAAkB,CAAC;AAC5D,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,CAAC,GAAG,CAAC,CAAC;AAKxF;;GAEG;AACH,eAAO,MAAM,yBAAyB;;;CAErC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;CAEpC,CAAC;AAGF;;GAEG;AACH,eAAO,MAAM,OAAO,iCAAoD,CAAC;AAEzE;;GAEG;AACH,eAAO,MAAM,cAAc,sHAA2D,CAAC;AAEvF;;GAEG;AACH,eAAO,MAAM,iBAAiB,sDAAqD,CAAC;AAEpF;;GAEG;AACH,eAAO,MAAM,WAAW,0BAAwD,CAAC"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @author: yanxianliang
3
+ * @date: 2025-01-17
4
+ * @desc: Bloodline Props hooks - 类型化的 props 访问
5
+ *
6
+ * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
7
+ */
8
+ import { useInputProps, useFlowProps, useGetInputProps, useGetFlowProps } from '@rxflow/base';
9
+
10
+ /**
11
+ * 获取原始输入 props
12
+ *
13
+ * @example
14
+ * const inputProps = useBloodlineInputProps();
15
+ * const root = useBloodlineInputProps(state => state.root);
16
+ */
17
+
18
+ export function useBloodlineInputProps(selector) {
19
+ return useInputProps(selector);
20
+ }
21
+
22
+ /**
23
+ * 获取转换后的 Flow props
24
+ *
25
+ * @example
26
+ * const flowProps = useBloodlineFlowProps();
27
+ * const nodes = useBloodlineFlowProps(state => state.nodes);
28
+ */
29
+
30
+ export function useBloodlineFlowProps(selector) {
31
+ return useFlowProps(selector);
32
+ }
33
+
34
+ /**
35
+ * 获取原始输入 props 的 getter(非响应式)
36
+ */
37
+ export var useGetBloodlineInputProps = function useGetBloodlineInputProps() {
38
+ return useGetInputProps();
39
+ };
40
+
41
+ /**
42
+ * 获取转换后 Flow props 的 getter(非响应式)
43
+ */
44
+ export var useGetBloodlineFlowProps = function useGetBloodlineFlowProps() {
45
+ return useGetFlowProps();
46
+ };
47
+
48
+ // 便捷 hooks
49
+ /**
50
+ * 获取 root 节点数据
51
+ */
52
+ export var useRoot = function useRoot() {
53
+ return useBloodlineInputProps(function (state) {
54
+ return state.root;
55
+ });
56
+ };
57
+
58
+ /**
59
+ * 获取异步加载关联节点的函数
60
+ */
61
+ export var useGetRelation = function useGetRelation() {
62
+ return useBloodlineInputProps(function (state) {
63
+ return state.getRelation;
64
+ });
65
+ };
66
+
67
+ /**
68
+ * 获取 Bloodline 主题配置
69
+ */
70
+ export var useBloodlineTheme = function useBloodlineTheme() {
71
+ return useBloodlineInputProps(function (state) {
72
+ return state.theme;
73
+ });
74
+ };
75
+
76
+ /**
77
+ * 获取连线类型
78
+ */
79
+ export var useEdgeType = function useEdgeType() {
80
+ return useBloodlineInputProps(function (state) {
81
+ return state.edgeType;
82
+ });
83
+ };
package/esm/index.d.ts CHANGED
@@ -4,4 +4,5 @@ declare const BloodlineFlow: (props: import("react").PropsWithChildren<IBloodlin
4
4
  export default BloodlineFlow;
5
5
  export * from './types';
6
6
  export * from './constants';
7
+ export * from './hooks';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":";AAaA,OAAO,EAAuB,mBAAmB,EAAC,MAAM,SAAS,CAAC;AAalE,QAAA,MAAM,aAAa,4GA6BjB,CAAA;AAGF,eAAe,aAAa,CAAC;AAG7B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAwB,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAsCpE,QAAA,MAAM,aAAa,4GAGlB,CAAC;AAEF,eAAe,aAAa,CAAC;AAG7B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAG5B,cAAc,SAAS,CAAC"}
package/esm/index.js CHANGED
@@ -7,6 +7,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
7
7
  /*
8
8
  * @author: yanxianliang
9
9
  * @date: 2025-06-01 18:36
10
+ * @modified:2025/1/17 by yanxianliang
10
11
  * @desc: 血缘视图
11
12
  *
12
13
  * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
@@ -22,18 +23,24 @@ var fitViewOptions = {
22
23
  minZoom: 1,
23
24
  maxZoom: 1
24
25
  };
25
- var omitProps = ['root', 'getRelation', 'mode', 'edgeType'];
26
- var BloodlineFlow = createFlow(Flow, function (props) {
26
+
27
+ /**
28
+ * Props 转换 hook
29
+ */
30
+ var useBloodlinePropsTransform = function useBloodlinePropsTransform(props) {
27
31
  var root = props.root,
28
32
  nodeTypes = props.nodeTypes;
33
+
34
+ // 将 root 转换为 nodes
29
35
  var nodes = useMemo(function () {
30
36
  return root ? [root] : [];
31
37
  }, [root]);
32
- var _nodeTypes = useMemo(function () {
38
+
39
+ // 包装 nodeTypes
40
+ var wrappedNodeTypes = useMemo(function () {
33
41
  return nodeTypes === null || nodeTypes === void 0 ? void 0 : nodeTypes.map(function (nodeType) {
34
42
  return _objectSpread(_objectSpread({}, nodeType), {}, {
35
43
  _component: nodeType.component,
36
- // 真实的节点组件
37
44
  component: nodeType.type === 'fields' ? GroupWrapper : BaseNodeWrapper
38
45
  });
39
46
  });
@@ -44,12 +51,17 @@ var BloodlineFlow = createFlow(Flow, function (props) {
44
51
  autoCenter: true,
45
52
  nodes: nodes,
46
53
  layout: layoutCells,
47
- nodeTypes: _nodeTypes,
48
- omitProps: omitProps,
54
+ nodeTypes: wrappedNodeTypes,
49
55
  selectionOnDrag: false,
50
56
  nodesDraggable: false
51
57
  });
52
- });
58
+ };
59
+ var BloodlineFlow = createFlow(Flow, useBloodlinePropsTransform);
53
60
  export default BloodlineFlow;
61
+
62
+ // 类型导出
54
63
  export * from "./types";
55
- export * from "./constants";
64
+ export * from "./constants";
65
+
66
+ // Hooks 导出
67
+ export * from "./hooks";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rxflow/bloodline",
3
- "version": "0.0.3",
3
+ "version": "0.0.4-alpha.1",
4
4
  "description": "通用血缘关系图",
5
5
  "homepage": "https://tree-graph.publib.cn/packages/bloodline",
6
6
  "repository": {
@@ -31,7 +31,7 @@
31
31
  "build": "father build"
32
32
  },
33
33
  "dependencies": {
34
- "@rxflow/base": "^0.0.3"
34
+ "@rxflow/base": "^0.0.4-alpha.1"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "@antv/hierarchy": ">=0.6.14",