@rxflow/terminal-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.
@@ -18,10 +18,10 @@ var _state = require("../state");
18
18
 
19
19
  const useToggleExpandState = () => {
20
20
  const setState = (0, _state.useSetState)();
21
- const getProps = (0, _base.useGetProps)();
21
+ const getInputProps = (0, _base.useGetInputProps)();
22
22
  return (0, _react.useCallback)(id => {
23
23
  // 如果仅支持单个呢,直接清空Set
24
- const allowExpandMultiples = getProps().allowExpandMultiples;
24
+ const allowExpandMultiples = getInputProps().allowExpandMultiples;
25
25
  setState(state => {
26
26
  const expandSet = allowExpandMultiples ? state.expandSet || new Set() : new Set();
27
27
  const expand = !state.expandSet?.has(id);
@@ -10,7 +10,7 @@ import { BaseBloodNode } from "../types";
10
10
  export declare const useGetTerminalList: () => () => (BaseBloodNode & {
11
11
  [key: string]: any;
12
12
  collapsed?: boolean | undefined;
13
- nodeList?: (Omit<BaseBloodNode, "upstream" | "downstream"> & {
13
+ nodeList?: (Omit<BaseBloodNode, "downstream" | "upstream"> & {
14
14
  parentIdList: string[];
15
15
  })[] | undefined;
16
16
  })[];
@@ -16,9 +16,9 @@ var _react = require("react");
16
16
  */
17
17
 
18
18
  const useGetTerminalList = () => {
19
- const getProps = (0, _base.useGetProps)();
19
+ const getFlowProps = (0, _base.useGetFlowProps)();
20
20
  return (0, _react.useCallback)(() => {
21
- const nodes = getProps().nodes;
21
+ const nodes = getFlowProps().nodes;
22
22
  if (!nodes || nodes.length == 0) {
23
23
  return [];
24
24
  }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @author: yanxianliang
3
+ * @date: 2025-01-17
4
+ * @desc: Terminal Bloodline Props hooks - 类型化的 props 访问
5
+ *
6
+ * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
7
+ */
8
+ import { IBaseFlowProps } from '@rxflow/base';
9
+ import { TerminalBloodlineFlowProps, TerminalBloodlineExtendProps, BaseBloodNode } from '../types';
10
+ type TerminalBloodlineFullFlowProps = IBaseFlowProps & TerminalBloodlineExtendProps;
11
+ /**
12
+ * 获取原始输入 props
13
+ *
14
+ * @example
15
+ * const inputProps = useTerminalBloodlineInputProps();
16
+ * const root = useTerminalBloodlineInputProps(state => state.root);
17
+ */
18
+ export declare function useTerminalBloodlineInputProps(): TerminalBloodlineFlowProps;
19
+ export declare function useTerminalBloodlineInputProps<U>(selector: (state: TerminalBloodlineFlowProps) => U): U;
20
+ /**
21
+ * 获取转换后的 Flow props
22
+ *
23
+ * @example
24
+ * const flowProps = useTerminalBloodlineFlowProps();
25
+ * const nodes = useTerminalBloodlineFlowProps(state => state.nodes);
26
+ */
27
+ export declare function useTerminalBloodlineFlowProps(): TerminalBloodlineFullFlowProps;
28
+ export declare function useTerminalBloodlineFlowProps<U>(selector: (state: TerminalBloodlineFullFlowProps) => U): U;
29
+ /**
30
+ * 获取原始输入 props 的 getter(非响应式)
31
+ */
32
+ export declare const useGetTerminalBloodlineInputProps: () => {
33
+ (): TerminalBloodlineFlowProps;
34
+ <U>(selector: (state: TerminalBloodlineFlowProps) => U): U;
35
+ };
36
+ /**
37
+ * 获取转换后 Flow props 的 getter(非响应式)
38
+ */
39
+ export declare const useGetTerminalBloodlineFlowProps: () => {
40
+ (): TerminalBloodlineFullFlowProps;
41
+ <U>(selector: (state: TerminalBloodlineFullFlowProps) => U): U;
42
+ };
43
+ /**
44
+ * 获取 root 节点数据
45
+ */
46
+ export declare const useTerminalRoot: () => BaseBloodNode | undefined;
47
+ /**
48
+ * 获取主题配置
49
+ */
50
+ export declare const useTerminalBloodlineTheme: () => import("../types").IBloodlineTheme | undefined;
51
+ /**
52
+ * 获取是否允许展开多个
53
+ */
54
+ export declare const useAllowExpandMultiples: () => boolean | undefined;
55
+ /**
56
+ * 获取过滤函数
57
+ */
58
+ export declare const useOnFilter: () => ((data: Record<string, any>, value: string) => boolean) | undefined;
59
+ export {};
60
+ //# sourceMappingURL=useTerminalBloodlineProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTerminalBloodlineProps.d.ts","sourceRoot":"","sources":["useTerminalBloodlineProps.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAkE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9G,OAAO,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEnG,KAAK,8BAA8B,GAAG,cAAc,GAAG,4BAA4B,CAAC;AAEpF;;;;;;GAMG;AACH,wBAAgB,8BAA8B,IAAI,0BAA0B,CAAC;AAC7E,wBAAgB,8BAA8B,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,0BAA0B,KAAK,CAAC,GAAG,CAAC,CAAC;AAKzG;;;;;;GAMG;AACH,wBAAgB,6BAA6B,IAAI,8BAA8B,CAAC;AAChF,wBAAgB,6BAA6B,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,8BAA8B,KAAK,CAAC,GAAG,CAAC,CAAC;AAK5G;;GAEG;AACH,eAAO,MAAM,iCAAiC;;;CAE7C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gCAAgC;;;CAE5C,CAAC;AAGF;;GAEG;AACH,eAAO,MAAM,eAAe,iCAA4D,CAAC;AAEzF;;GAEG;AACH,eAAO,MAAM,yBAAyB,sDAA6D,CAAC;AAEpG;;GAEG;AACH,eAAO,MAAM,uBAAuB,2BAA4E,CAAC;AAEjH;;GAEG;AACH,eAAO,MAAM,WAAW,2EAAgE,CAAC"}
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useOnFilter = exports.useGetTerminalBloodlineInputProps = exports.useGetTerminalBloodlineFlowProps = exports.useAllowExpandMultiples = void 0;
7
+ exports.useTerminalBloodlineFlowProps = useTerminalBloodlineFlowProps;
8
+ exports.useTerminalBloodlineInputProps = useTerminalBloodlineInputProps;
9
+ exports.useTerminalRoot = exports.useTerminalBloodlineTheme = void 0;
10
+ var _base = require("@rxflow/base");
11
+ /**
12
+ * @author: yanxianliang
13
+ * @date: 2025-01-17
14
+ * @desc: Terminal Bloodline Props hooks - 类型化的 props 访问
15
+ *
16
+ * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
17
+ */
18
+
19
+ /**
20
+ * 获取原始输入 props
21
+ *
22
+ * @example
23
+ * const inputProps = useTerminalBloodlineInputProps();
24
+ * const root = useTerminalBloodlineInputProps(state => state.root);
25
+ */
26
+
27
+ function useTerminalBloodlineInputProps(selector) {
28
+ return (0, _base.useInputProps)(selector);
29
+ }
30
+
31
+ /**
32
+ * 获取转换后的 Flow props
33
+ *
34
+ * @example
35
+ * const flowProps = useTerminalBloodlineFlowProps();
36
+ * const nodes = useTerminalBloodlineFlowProps(state => state.nodes);
37
+ */
38
+
39
+ function useTerminalBloodlineFlowProps(selector) {
40
+ return (0, _base.useFlowProps)(selector);
41
+ }
42
+
43
+ /**
44
+ * 获取原始输入 props 的 getter(非响应式)
45
+ */
46
+ const useGetTerminalBloodlineInputProps = () => {
47
+ return (0, _base.useGetInputProps)();
48
+ };
49
+
50
+ /**
51
+ * 获取转换后 Flow props 的 getter(非响应式)
52
+ */
53
+ exports.useGetTerminalBloodlineInputProps = useGetTerminalBloodlineInputProps;
54
+ const useGetTerminalBloodlineFlowProps = () => {
55
+ return (0, _base.useGetFlowProps)();
56
+ };
57
+
58
+ // 便捷 hooks
59
+ /**
60
+ * 获取 root 节点数据
61
+ */
62
+ exports.useGetTerminalBloodlineFlowProps = useGetTerminalBloodlineFlowProps;
63
+ const useTerminalRoot = () => useTerminalBloodlineInputProps(state => state.root);
64
+
65
+ /**
66
+ * 获取主题配置
67
+ */
68
+ exports.useTerminalRoot = useTerminalRoot;
69
+ const useTerminalBloodlineTheme = () => useTerminalBloodlineInputProps(state => state.theme);
70
+
71
+ /**
72
+ * 获取是否允许展开多个
73
+ */
74
+ exports.useTerminalBloodlineTheme = useTerminalBloodlineTheme;
75
+ const useAllowExpandMultiples = () => useTerminalBloodlineInputProps(state => state.allowExpandMultiples);
76
+
77
+ /**
78
+ * 获取过滤函数
79
+ */
80
+ exports.useAllowExpandMultiples = useAllowExpandMultiples;
81
+ const useOnFilter = () => useTerminalBloodlineInputProps(state => state.onFilter);
82
+ exports.useOnFilter = useOnFilter;
@@ -1 +1 @@
1
- {"version":3,"file":"useTerminalCount.d.ts","sourceRoot":"","sources":["useTerminalCount.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,gBAAgB,cAS5B,CAAA"}
1
+ {"version":3,"file":"useTerminalCount.d.ts","sourceRoot":"","sources":["useTerminalCount.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,gBAAgB,cAS5B,CAAC"}
@@ -8,14 +8,14 @@ var _base = require("@rxflow/base");
8
8
  /**
9
9
  * @author: yanxianliang
10
10
  * @date: 2025-10-19 19:24
11
- * @modified:2025/10/19 19:24 by yanxianliang
11
+ * @modified:2025/1/17 by yanxianliang
12
12
  * @desc: 获取末级节点数量
13
13
  *
14
14
  * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
15
15
  */
16
16
 
17
17
  const useTerminalCount = () => {
18
- return (0, _base.usePropsSelector)(state => {
18
+ return (0, _base.useFlowProps)(state => {
19
19
  const nodes = state.nodes;
20
20
  if (!nodes || nodes.length == 0) {
21
21
  return 0;
package/cjs/index.d.ts CHANGED
@@ -4,4 +4,5 @@ declare const TerminalBloodlineFlow: (props: import("react").PropsWithChildren<T
4
4
  export default TerminalBloodlineFlow;
5
5
  export * from './types';
6
6
  export * from './constants';
7
+ export * from './hooks/useTerminalBloodlineProps';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":";AAmBA,OAAO,EAA+B,0BAA0B,EAAC,MAAM,SAAS,CAAC;AA0BjF,QAAA,MAAM,qBAAqB,mHA8CzB,CAAA;AAGF,eAAe,qBAAqB,CAAC;AAErC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":";AAmBA,OAAO,EAAgC,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAkEnF,QAAA,MAAM,qBAAqB,mHAG1B,CAAC;AAEF,eAAe,qBAAqB,CAAC;AAGrC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAG5B,cAAc,mCAAmC,CAAC"}
package/cjs/index.js CHANGED
@@ -39,11 +39,24 @@ Object.keys(_constants).forEach(function (key) {
39
39
  }
40
40
  });
41
41
  });
42
+ var _useTerminalBloodlineProps = require("./hooks/useTerminalBloodlineProps");
43
+ Object.keys(_useTerminalBloodlineProps).forEach(function (key) {
44
+ if (key === "default" || key === "__esModule") return;
45
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
46
+ if (key in exports && exports[key] === _useTerminalBloodlineProps[key]) return;
47
+ Object.defineProperty(exports, key, {
48
+ enumerable: true,
49
+ get: function () {
50
+ return _useTerminalBloodlineProps[key];
51
+ }
52
+ });
53
+ });
42
54
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
43
55
  /*
44
56
  * @author: yanxianliang
45
57
  * @date: 2025-06-01 18:36
46
- * @desc: 血缘视图
58
+ * @modified:2025/1/17 by yanxianliang
59
+ * @desc: 末级血缘视图
47
60
  *
48
61
  * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
49
62
  */
@@ -53,7 +66,8 @@ const fitViewOptions = {
53
66
  minZoom: 1,
54
67
  maxZoom: 1
55
68
  };
56
- const omitProps = ['root', 'getRelation', 'mode', "allowExpandMultiples", 'onFilter'];
69
+
70
+ // 内置节点类型
57
71
  const innerNodeTypes = [{
58
72
  type: 'search',
59
73
  hideInLegend: true,
@@ -63,7 +77,11 @@ const innerNodeTypes = [{
63
77
  hideInLegend: true,
64
78
  component: _Pagination.Pagination
65
79
  }];
66
- const TerminalBloodlineFlow = (0, _base.createFlow)(_base.Flow, props => {
80
+
81
+ /**
82
+ * Props 转换 hook
83
+ */
84
+ const useTerminalBloodlinePropsTransform = props => {
67
85
  const {
68
86
  root,
69
87
  nodeTypes,
@@ -72,36 +90,40 @@ const TerminalBloodlineFlow = (0, _base.createFlow)(_base.Flow, props => {
72
90
  const setPageIndex = (0, _useSetPageIndex.useSetPageIndex)();
73
91
  const setFilter = (0, _useSetFilter.useSetFilter)();
74
92
  const cleanExpandState = (0, _useCleanExpandState.useCleanExpandState)();
93
+
94
+ // 将 root 转换为 nodes
75
95
  const nodes = (0, _react.useMemo)(() => {
76
96
  setPageIndex(1);
77
97
  setFilter('');
78
- cleanExpandState(); // root 变化,清除所有展开配置
98
+ cleanExpandState();
79
99
  return root ? [(0, _cloneDeep.default)(root)] : [];
80
100
  }, [root]);
81
- const _nodeTypes = (0, _react.useMemo)(() => {
82
- return [...innerNodeTypes, ...(nodeTypes || []).map(nodeType => {
83
- return {
84
- ...nodeType,
85
- _component: nodeType.component,
86
- // 真实的节点组件
87
- component: _BaseNodeWrapper.BaseNodeWrapper
88
- };
89
- })];
101
+
102
+ // 包装 nodeTypes
103
+ const wrappedNodeTypes = (0, _react.useMemo)(() => {
104
+ return [...innerNodeTypes, ...(nodeTypes || []).map(nodeType => ({
105
+ ...nodeType,
106
+ _component: nodeType.component,
107
+ component: _BaseNodeWrapper.BaseNodeWrapper
108
+ }))];
90
109
  }, [nodeTypes]);
110
+
111
+ // 绑定 onFilter 到 layout
91
112
  const layout = (0, _react.useMemo)(() => {
92
113
  return _layoutCells.layoutCells.bind(undefined, onFilter);
93
- }, []);
114
+ }, [onFilter]);
94
115
  return {
95
116
  ...props,
96
117
  edgesFocusable: false,
97
118
  fitViewOptions,
98
119
  autoCenter: true,
99
120
  nodes,
100
- layout: layout,
101
- nodeTypes: _nodeTypes,
102
- omitProps,
121
+ layout,
122
+ nodeTypes: wrappedNodeTypes,
103
123
  selectionOnDrag: false,
104
124
  nodesDraggable: false
105
125
  };
106
- });
107
- var _default = exports.default = TerminalBloodlineFlow;
126
+ };
127
+ const TerminalBloodlineFlow = (0, _base.createFlow)(_base.Flow, useTerminalBloodlinePropsTransform);
128
+ var _default = exports.default = TerminalBloodlineFlow; // 类型导出
129
+ // Hooks 导出
@@ -35,7 +35,7 @@ const Search = () => {
35
35
  const setPageIndex = (0, _useSetPageIndex.useSetPageIndex)();
36
36
  const [open, setOpen] = (0, _react.useState)(false);
37
37
  const getTerminalList = (0, _useGetTerminalList.useGetTerminalList)();
38
- const getProps = (0, _base.useGetProps)();
38
+ const getInputProps = (0, _base.useGetInputProps)();
39
39
  const [messageApi, contextHolder] = _antd.message.useMessage();
40
40
  const count = (0, _useTerminalCount.useTerminalCount)();
41
41
  const showInput = (0, _react.useCallback)(() => {
@@ -43,7 +43,7 @@ const Search = () => {
43
43
  }, []);
44
44
  const onSearch = (0, _react.useCallback)(value => {
45
45
  const list = getTerminalList();
46
- const onFilter = getProps().onFilter || _layoutCells.defaultFilter;
46
+ const onFilter = getInputProps().onFilter || _layoutCells.defaultFilter;
47
47
  const hasItem = list.find(item => {
48
48
  const data = item.data;
49
49
  return onFilter(data, value);
@@ -6,15 +6,15 @@
6
6
  *
7
7
  * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
8
8
  */
9
- import { useGetProps } from "@rxflow/base";
9
+ import { useGetInputProps } from "@rxflow/base";
10
10
  import { useCallback } from "react";
11
11
  import { useSetState } from "../state";
12
12
  export var useToggleExpandState = function useToggleExpandState() {
13
13
  var setState = useSetState();
14
- var getProps = useGetProps();
14
+ var getInputProps = useGetInputProps();
15
15
  return useCallback(function (id) {
16
16
  // 如果仅支持单个呢,直接清空Set
17
- var allowExpandMultiples = getProps().allowExpandMultiples;
17
+ var allowExpandMultiples = getInputProps().allowExpandMultiples;
18
18
  setState(function (state) {
19
19
  var _state$expandSet;
20
20
  var expandSet = allowExpandMultiples ? state.expandSet || new Set() : new Set();
@@ -10,7 +10,7 @@ import { BaseBloodNode } from "../types";
10
10
  export declare const useGetTerminalList: () => () => (BaseBloodNode & {
11
11
  [key: string]: any;
12
12
  collapsed?: boolean | undefined;
13
- nodeList?: (Omit<BaseBloodNode, "upstream" | "downstream"> & {
13
+ nodeList?: (Omit<BaseBloodNode, "downstream" | "upstream"> & {
14
14
  parentIdList: string[];
15
15
  })[] | undefined;
16
16
  })[];
@@ -7,12 +7,12 @@
7
7
  * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
8
8
  */
9
9
 
10
- import { useGetProps } from "@rxflow/base";
10
+ import { useGetFlowProps } from "@rxflow/base";
11
11
  import { useCallback } from "react";
12
12
  export var useGetTerminalList = function useGetTerminalList() {
13
- var getProps = useGetProps();
13
+ var getFlowProps = useGetFlowProps();
14
14
  return useCallback(function () {
15
- var nodes = getProps().nodes;
15
+ var nodes = getFlowProps().nodes;
16
16
  if (!nodes || nodes.length == 0) {
17
17
  return [];
18
18
  }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * @author: yanxianliang
3
+ * @date: 2025-01-17
4
+ * @desc: Terminal Bloodline Props hooks - 类型化的 props 访问
5
+ *
6
+ * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
7
+ */
8
+ import { IBaseFlowProps } from '@rxflow/base';
9
+ import { TerminalBloodlineFlowProps, TerminalBloodlineExtendProps, BaseBloodNode } from '../types';
10
+ type TerminalBloodlineFullFlowProps = IBaseFlowProps & TerminalBloodlineExtendProps;
11
+ /**
12
+ * 获取原始输入 props
13
+ *
14
+ * @example
15
+ * const inputProps = useTerminalBloodlineInputProps();
16
+ * const root = useTerminalBloodlineInputProps(state => state.root);
17
+ */
18
+ export declare function useTerminalBloodlineInputProps(): TerminalBloodlineFlowProps;
19
+ export declare function useTerminalBloodlineInputProps<U>(selector: (state: TerminalBloodlineFlowProps) => U): U;
20
+ /**
21
+ * 获取转换后的 Flow props
22
+ *
23
+ * @example
24
+ * const flowProps = useTerminalBloodlineFlowProps();
25
+ * const nodes = useTerminalBloodlineFlowProps(state => state.nodes);
26
+ */
27
+ export declare function useTerminalBloodlineFlowProps(): TerminalBloodlineFullFlowProps;
28
+ export declare function useTerminalBloodlineFlowProps<U>(selector: (state: TerminalBloodlineFullFlowProps) => U): U;
29
+ /**
30
+ * 获取原始输入 props 的 getter(非响应式)
31
+ */
32
+ export declare const useGetTerminalBloodlineInputProps: () => {
33
+ (): TerminalBloodlineFlowProps;
34
+ <U>(selector: (state: TerminalBloodlineFlowProps) => U): U;
35
+ };
36
+ /**
37
+ * 获取转换后 Flow props 的 getter(非响应式)
38
+ */
39
+ export declare const useGetTerminalBloodlineFlowProps: () => {
40
+ (): TerminalBloodlineFullFlowProps;
41
+ <U>(selector: (state: TerminalBloodlineFullFlowProps) => U): U;
42
+ };
43
+ /**
44
+ * 获取 root 节点数据
45
+ */
46
+ export declare const useTerminalRoot: () => BaseBloodNode | undefined;
47
+ /**
48
+ * 获取主题配置
49
+ */
50
+ export declare const useTerminalBloodlineTheme: () => import("../types").IBloodlineTheme | undefined;
51
+ /**
52
+ * 获取是否允许展开多个
53
+ */
54
+ export declare const useAllowExpandMultiples: () => boolean | undefined;
55
+ /**
56
+ * 获取过滤函数
57
+ */
58
+ export declare const useOnFilter: () => ((data: Record<string, any>, value: string) => boolean) | undefined;
59
+ export {};
60
+ //# sourceMappingURL=useTerminalBloodlineProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useTerminalBloodlineProps.d.ts","sourceRoot":"","sources":["useTerminalBloodlineProps.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAkE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9G,OAAO,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEnG,KAAK,8BAA8B,GAAG,cAAc,GAAG,4BAA4B,CAAC;AAEpF;;;;;;GAMG;AACH,wBAAgB,8BAA8B,IAAI,0BAA0B,CAAC;AAC7E,wBAAgB,8BAA8B,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,0BAA0B,KAAK,CAAC,GAAG,CAAC,CAAC;AAKzG;;;;;;GAMG;AACH,wBAAgB,6BAA6B,IAAI,8BAA8B,CAAC;AAChF,wBAAgB,6BAA6B,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,8BAA8B,KAAK,CAAC,GAAG,CAAC,CAAC;AAK5G;;GAEG;AACH,eAAO,MAAM,iCAAiC;;;CAE7C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gCAAgC;;;CAE5C,CAAC;AAGF;;GAEG;AACH,eAAO,MAAM,eAAe,iCAA4D,CAAC;AAEzF;;GAEG;AACH,eAAO,MAAM,yBAAyB,sDAA6D,CAAC;AAEpG;;GAEG;AACH,eAAO,MAAM,uBAAuB,2BAA4E,CAAC;AAEjH;;GAEG;AACH,eAAO,MAAM,WAAW,2EAAgE,CAAC"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @author: yanxianliang
3
+ * @date: 2025-01-17
4
+ * @desc: Terminal 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 = useTerminalBloodlineInputProps();
15
+ * const root = useTerminalBloodlineInputProps(state => state.root);
16
+ */
17
+
18
+ export function useTerminalBloodlineInputProps(selector) {
19
+ return useInputProps(selector);
20
+ }
21
+
22
+ /**
23
+ * 获取转换后的 Flow props
24
+ *
25
+ * @example
26
+ * const flowProps = useTerminalBloodlineFlowProps();
27
+ * const nodes = useTerminalBloodlineFlowProps(state => state.nodes);
28
+ */
29
+
30
+ export function useTerminalBloodlineFlowProps(selector) {
31
+ return useFlowProps(selector);
32
+ }
33
+
34
+ /**
35
+ * 获取原始输入 props 的 getter(非响应式)
36
+ */
37
+ export var useGetTerminalBloodlineInputProps = function useGetTerminalBloodlineInputProps() {
38
+ return useGetInputProps();
39
+ };
40
+
41
+ /**
42
+ * 获取转换后 Flow props 的 getter(非响应式)
43
+ */
44
+ export var useGetTerminalBloodlineFlowProps = function useGetTerminalBloodlineFlowProps() {
45
+ return useGetFlowProps();
46
+ };
47
+
48
+ // 便捷 hooks
49
+ /**
50
+ * 获取 root 节点数据
51
+ */
52
+ export var useTerminalRoot = function useTerminalRoot() {
53
+ return useTerminalBloodlineInputProps(function (state) {
54
+ return state.root;
55
+ });
56
+ };
57
+
58
+ /**
59
+ * 获取主题配置
60
+ */
61
+ export var useTerminalBloodlineTheme = function useTerminalBloodlineTheme() {
62
+ return useTerminalBloodlineInputProps(function (state) {
63
+ return state.theme;
64
+ });
65
+ };
66
+
67
+ /**
68
+ * 获取是否允许展开多个
69
+ */
70
+ export var useAllowExpandMultiples = function useAllowExpandMultiples() {
71
+ return useTerminalBloodlineInputProps(function (state) {
72
+ return state.allowExpandMultiples;
73
+ });
74
+ };
75
+
76
+ /**
77
+ * 获取过滤函数
78
+ */
79
+ export var useOnFilter = function useOnFilter() {
80
+ return useTerminalBloodlineInputProps(function (state) {
81
+ return state.onFilter;
82
+ });
83
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"useTerminalCount.d.ts","sourceRoot":"","sources":["useTerminalCount.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,gBAAgB,cAS5B,CAAA"}
1
+ {"version":3,"file":"useTerminalCount.d.ts","sourceRoot":"","sources":["useTerminalCount.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,gBAAgB,cAS5B,CAAC"}
@@ -1,14 +1,14 @@
1
1
  /**
2
2
  * @author: yanxianliang
3
3
  * @date: 2025-10-19 19:24
4
- * @modified:2025/10/19 19:24 by yanxianliang
4
+ * @modified:2025/1/17 by yanxianliang
5
5
  * @desc: 获取末级节点数量
6
6
  *
7
7
  * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
8
8
  */
9
- import { usePropsSelector } from "@rxflow/base";
9
+ import { useFlowProps } from "@rxflow/base";
10
10
  export var useTerminalCount = function useTerminalCount() {
11
- return usePropsSelector(function (state) {
11
+ return useFlowProps(function (state) {
12
12
  var nodes = state.nodes;
13
13
  if (!nodes || nodes.length == 0) {
14
14
  return 0;
package/esm/index.d.ts CHANGED
@@ -4,4 +4,5 @@ declare const TerminalBloodlineFlow: (props: import("react").PropsWithChildren<T
4
4
  export default TerminalBloodlineFlow;
5
5
  export * from './types';
6
6
  export * from './constants';
7
+ export * from './hooks/useTerminalBloodlineProps';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":";AAmBA,OAAO,EAA+B,0BAA0B,EAAC,MAAM,SAAS,CAAC;AA0BjF,QAAA,MAAM,qBAAqB,mHA8CzB,CAAA;AAGF,eAAe,qBAAqB,CAAC;AAErC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":";AAmBA,OAAO,EAAgC,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAkEnF,QAAA,MAAM,qBAAqB,mHAG1B,CAAC;AAEF,eAAe,qBAAqB,CAAC;AAGrC,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAG5B,cAAc,mCAAmC,CAAC"}
package/esm/index.js CHANGED
@@ -13,7 +13,8 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
13
13
  /*
14
14
  * @author: yanxianliang
15
15
  * @date: 2025-06-01 18:36
16
- * @desc: 血缘视图
16
+ * @modified:2025/1/17 by yanxianliang
17
+ * @desc: 末级血缘视图
17
18
  *
18
19
  * Copyright (c) 2025 by yanxianliang, All Rights Reserved.
19
20
  */
@@ -33,7 +34,8 @@ var fitViewOptions = {
33
34
  minZoom: 1,
34
35
  maxZoom: 1
35
36
  };
36
- var omitProps = ['root', 'getRelation', 'mode', "allowExpandMultiples", 'onFilter'];
37
+
38
+ // 内置节点类型
37
39
  var innerNodeTypes = [{
38
40
  type: 'search',
39
41
  hideInLegend: true,
@@ -43,43 +45,57 @@ var innerNodeTypes = [{
43
45
  hideInLegend: true,
44
46
  component: Pagination
45
47
  }];
46
- var TerminalBloodlineFlow = createFlow(Flow, function (props) {
48
+
49
+ /**
50
+ * Props 转换 hook
51
+ */
52
+ var useTerminalBloodlinePropsTransform = function useTerminalBloodlinePropsTransform(props) {
47
53
  var root = props.root,
48
54
  nodeTypes = props.nodeTypes,
49
55
  onFilter = props.onFilter;
50
56
  var setPageIndex = useSetPageIndex();
51
57
  var setFilter = useSetFilter();
52
58
  var cleanExpandState = useCleanExpandState();
59
+
60
+ // 将 root 转换为 nodes
53
61
  var nodes = useMemo(function () {
54
62
  setPageIndex(1);
55
63
  setFilter('');
56
- cleanExpandState(); // root 变化,清除所有展开配置
64
+ cleanExpandState();
57
65
  return root ? [cloneDeep(root)] : [];
58
66
  }, [root]);
59
- var _nodeTypes = useMemo(function () {
67
+
68
+ // 包装 nodeTypes
69
+ var wrappedNodeTypes = useMemo(function () {
60
70
  return [].concat(innerNodeTypes, _toConsumableArray((nodeTypes || []).map(function (nodeType) {
61
71
  return _objectSpread(_objectSpread({}, nodeType), {}, {
62
72
  _component: nodeType.component,
63
- // 真实的节点组件
64
73
  component: BaseNodeWrapper
65
74
  });
66
75
  })));
67
76
  }, [nodeTypes]);
77
+
78
+ // 绑定 onFilter 到 layout
68
79
  var layout = useMemo(function () {
69
80
  return layoutCells.bind(undefined, onFilter);
70
- }, []);
81
+ }, [onFilter]);
71
82
  return _objectSpread(_objectSpread({}, props), {}, {
72
83
  edgesFocusable: false,
73
84
  fitViewOptions: fitViewOptions,
74
85
  autoCenter: true,
75
86
  nodes: nodes,
76
87
  layout: layout,
77
- nodeTypes: _nodeTypes,
78
- omitProps: omitProps,
88
+ nodeTypes: wrappedNodeTypes,
79
89
  selectionOnDrag: false,
80
90
  nodesDraggable: false
81
91
  });
82
- });
92
+ };
93
+ var TerminalBloodlineFlow = createFlow(Flow, useTerminalBloodlinePropsTransform);
83
94
  export default TerminalBloodlineFlow;
95
+
96
+ // 类型导出
84
97
  export * from "./types";
85
- export * from "./constants";
98
+ export * from "./constants";
99
+
100
+ // Hooks 导出
101
+ export * from "./hooks/useTerminalBloodlineProps";
@@ -16,7 +16,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
16
  */
17
17
 
18
18
  import SearchOutlined from "@ant-design/icons/lib/icons/SearchOutlined";
19
- import { useGetProps } from "@rxflow/base";
19
+ import { useGetInputProps } from "@rxflow/base";
20
20
  import { Button, Input, message } from 'antd';
21
21
  import "./index.less";
22
22
  import { useCallback, useState } from "react";
@@ -39,7 +39,7 @@ export var Search = function Search() {
39
39
  open = _useState2[0],
40
40
  setOpen = _useState2[1];
41
41
  var getTerminalList = useGetTerminalList();
42
- var getProps = useGetProps();
42
+ var getInputProps = useGetInputProps();
43
43
  var _message$useMessage = message.useMessage(),
44
44
  _message$useMessage2 = _slicedToArray(_message$useMessage, 2),
45
45
  messageApi = _message$useMessage2[0],
@@ -50,7 +50,7 @@ export var Search = function Search() {
50
50
  }, []);
51
51
  var onSearch = useCallback(function (value) {
52
52
  var list = getTerminalList();
53
- var onFilter = getProps().onFilter || defaultFilter;
53
+ var onFilter = getInputProps().onFilter || defaultFilter;
54
54
  var hasItem = list.find(function (item) {
55
55
  var data = item.data;
56
56
  return onFilter(data, value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rxflow/terminal-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/terminal-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
  "antd": "^5.0.0"
36
36
  },
37
37
  "peerDependencies": {