@rxflow/base 0.0.2 → 0.0.4-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.
- package/cjs/Flow.d.ts +1 -1
- package/cjs/Flow.d.ts.map +1 -1
- package/cjs/Flow.js +28 -10
- package/cjs/components/Legend/index.d.ts.map +1 -1
- package/cjs/components/Legend/index.js +2 -1
- package/cjs/components/Popover/index.d.ts +1 -9
- package/cjs/components/Popover/index.d.ts.map +1 -1
- package/cjs/components/Popover/index.js +14 -75
- package/cjs/components/Tooltip/index.d.ts +1 -10
- package/cjs/components/Tooltip/index.d.ts.map +1 -1
- package/cjs/components/Tooltip/index.js +11 -83
- package/cjs/edges/manhattan.d.ts.map +1 -1
- package/cjs/edges/manhattan.js +100 -30
- package/cjs/hoc/createFlow.d.ts +30 -4
- package/cjs/hoc/createFlow.d.ts.map +1 -1
- package/cjs/hoc/createFlow.js +45 -18
- package/cjs/hooks/index.d.ts +5 -2
- package/cjs/hooks/index.d.ts.map +1 -1
- package/cjs/hooks/index.js +44 -22
- package/cjs/hooks/props/index.d.ts +12 -0
- package/cjs/hooks/props/index.d.ts.map +1 -0
- package/cjs/hooks/props/index.js +49 -0
- package/cjs/hooks/props/useFlowProps.d.ts +23 -0
- package/cjs/hooks/props/useFlowProps.d.ts.map +1 -0
- package/cjs/hooks/props/useFlowProps.js +34 -0
- package/cjs/hooks/props/useGetFlowProps.d.ts +19 -0
- package/cjs/hooks/props/useGetFlowProps.d.ts.map +1 -0
- package/cjs/hooks/props/useGetFlowProps.js +38 -0
- package/cjs/hooks/props/useGetInputProps.d.ts +18 -0
- package/cjs/hooks/props/useGetInputProps.d.ts.map +1 -0
- package/cjs/hooks/props/useGetInputProps.js +38 -0
- package/cjs/hooks/props/useInputProps.d.ts +14 -0
- package/cjs/hooks/props/useInputProps.d.ts.map +1 -0
- package/cjs/hooks/props/useInputProps.js +33 -0
- package/cjs/hooks/useListenRender.js +4 -4
- package/cjs/hooks/useTheme.d.ts.map +1 -1
- package/cjs/hooks/useTheme.js +3 -2
- package/cjs/index.d.ts +6 -3
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js +46 -14
- package/cjs/providers/FlowProvider.d.ts +7 -1
- package/cjs/providers/FlowProvider.d.ts.map +1 -1
- package/cjs/providers/FlowProvider.js +33 -14
- package/cjs/store/PropsStore.d.ts +11 -6
- package/cjs/store/PropsStore.d.ts.map +1 -1
- package/cjs/store/PropsStore.js +55 -39
- package/cjs/types/props.d.ts +83 -0
- package/cjs/types/props.d.ts.map +1 -0
- package/cjs/types/props.js +5 -0
- package/cjs/types.d.ts +5 -1
- package/cjs/types.d.ts.map +1 -1
- package/cjs/utils/wrapNodeTypes.d.ts +30 -0
- package/cjs/utils/wrapNodeTypes.d.ts.map +1 -0
- package/cjs/utils/wrapNodeTypes.js +56 -0
- package/cjs/workers/manhattan.worker.js +12534 -31
- package/cjs/workers/manhattan.worker.js.map +7 -0
- package/esm/Flow.d.ts +1 -1
- package/esm/Flow.d.ts.map +1 -1
- package/esm/Flow.js +30 -16
- package/esm/components/Legend/index.d.ts.map +1 -1
- package/esm/components/Legend/index.js +3 -2
- package/esm/components/Popover/index.d.ts +1 -9
- package/esm/components/Popover/index.d.ts.map +1 -1
- package/esm/components/Popover/index.js +16 -87
- package/esm/components/Tooltip/index.d.ts +1 -10
- package/esm/components/Tooltip/index.d.ts.map +1 -1
- package/esm/components/Tooltip/index.js +14 -97
- package/esm/edges/manhattan.d.ts.map +1 -1
- package/esm/edges/manhattan.js +95 -23
- package/esm/hoc/createFlow.d.ts +30 -4
- package/esm/hoc/createFlow.d.ts.map +1 -1
- package/esm/hoc/createFlow.js +48 -20
- package/esm/hooks/index.d.ts +5 -2
- package/esm/hooks/index.d.ts.map +1 -1
- package/esm/hooks/index.js +8 -3
- package/esm/hooks/props/index.d.ts +12 -0
- package/esm/hooks/props/index.d.ts.map +1 -0
- package/esm/hooks/props/index.js +12 -0
- package/esm/hooks/props/useFlowProps.d.ts +23 -0
- package/esm/hooks/props/useFlowProps.d.ts.map +1 -0
- package/esm/hooks/props/useFlowProps.js +29 -0
- package/esm/hooks/props/useGetFlowProps.d.ts +19 -0
- package/esm/hooks/props/useGetFlowProps.d.ts.map +1 -0
- package/esm/hooks/props/useGetFlowProps.js +31 -0
- package/esm/hooks/props/useGetInputProps.d.ts +18 -0
- package/esm/hooks/props/useGetInputProps.d.ts.map +1 -0
- package/esm/hooks/props/useGetInputProps.js +31 -0
- package/esm/hooks/props/useInputProps.d.ts +14 -0
- package/esm/hooks/props/useInputProps.d.ts.map +1 -0
- package/esm/hooks/props/useInputProps.js +27 -0
- package/esm/hooks/useListenRender.js +4 -4
- package/esm/hooks/useTheme.d.ts.map +1 -1
- package/esm/hooks/useTheme.js +3 -2
- package/esm/index.d.ts +6 -3
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +22 -3
- package/esm/providers/FlowProvider.d.ts +7 -1
- package/esm/providers/FlowProvider.d.ts.map +1 -1
- package/esm/providers/FlowProvider.js +36 -15
- package/esm/store/PropsStore.d.ts +11 -6
- package/esm/store/PropsStore.d.ts.map +1 -1
- package/esm/store/PropsStore.js +75 -34
- package/esm/types/props.d.ts +83 -0
- package/esm/types/props.d.ts.map +1 -0
- package/esm/types/props.js +1 -0
- package/esm/types.d.ts +5 -1
- package/esm/types.d.ts.map +1 -1
- package/esm/utils/wrapNodeTypes.d.ts +30 -0
- package/esm/utils/wrapNodeTypes.d.ts.map +1 -0
- package/esm/utils/wrapNodeTypes.js +55 -0
- package/esm/workers/manhattan.worker.js +1 -1
- package/esm/workers/manhattan.worker.js.map +7 -0
- package/package.json +5 -3
- package/cjs/hooks/props/useGetProps.d.ts +0 -6
- package/cjs/hooks/props/useGetProps.d.ts.map +0 -1
- package/cjs/hooks/props/useGetProps.js +0 -29
- package/cjs/hooks/props/useProps.d.ts +0 -2
- package/cjs/hooks/props/useProps.d.ts.map +0 -1
- package/cjs/hooks/props/useProps.js +0 -20
- package/cjs/hooks/props/usePropsSelector.d.ts +0 -13
- package/cjs/hooks/props/usePropsSelector.d.ts.map +0 -1
- package/cjs/hooks/props/usePropsSelector.js +0 -37
- package/esm/hooks/props/useGetProps.d.ts +0 -6
- package/esm/hooks/props/useGetProps.d.ts.map +0 -1
- package/esm/hooks/props/useGetProps.js +0 -21
- package/esm/hooks/props/useProps.d.ts +0 -2
- package/esm/hooks/props/useProps.d.ts.map +0 -1
- package/esm/hooks/props/useProps.js +0 -14
- package/esm/hooks/props/usePropsSelector.d.ts +0 -13
- package/esm/hooks/props/usePropsSelector.d.ts.map +0 -1
- package/esm/hooks/props/usePropsSelector.js +0 -31
package/cjs/hoc/createFlow.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.createFlow = createFlow;
|
|
7
7
|
var _antd = require("antd");
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
var
|
|
9
|
+
var _hooks = require("../hooks");
|
|
10
10
|
var _PropsStore = require("../store/PropsStore");
|
|
11
11
|
var _withFlowProvider = require("./withFlowProvider");
|
|
12
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -14,19 +14,21 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
14
14
|
/**
|
|
15
15
|
* @author: yanxianliang
|
|
16
16
|
* @date: 2025-10-15 15:25
|
|
17
|
-
* @modified:2025/
|
|
17
|
+
* @modified:2025/1/17 by yanxianliang
|
|
18
18
|
* @desc: 创建 Flow 组件
|
|
19
19
|
*
|
|
20
|
-
*
|
|
20
|
+
* 提供公共能力封装,支持双层 Props 存储
|
|
21
21
|
*
|
|
22
22
|
* Copyright (c) 2025 by yanxianliang, All Rights Reserved.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
/**
|
|
26
|
+
* 内部组件:从 store 获取 props 并渲染 Flow
|
|
27
|
+
*/const RenderFlowWithProps = ({
|
|
26
28
|
FlowComponent,
|
|
27
29
|
children
|
|
28
30
|
}) => {
|
|
29
|
-
const props = (0,
|
|
31
|
+
const props = (0, _hooks.useFlowProps)();
|
|
30
32
|
if (!props) {
|
|
31
33
|
return null;
|
|
32
34
|
}
|
|
@@ -36,32 +38,57 @@ const RenderFlowWithProp = ({
|
|
|
36
38
|
});
|
|
37
39
|
};
|
|
38
40
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
+
/**
|
|
42
|
+
* 创建 Flow 组件的工厂函数
|
|
43
|
+
*
|
|
44
|
+
* @param FlowComponent - 基础 Flow 组件
|
|
45
|
+
* @param usePropsTransform - Props 转换 hook,将输入 props 转换为 Flow props
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* // 基础用法
|
|
49
|
+
* const MyFlow = createFlow(Flow);
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* // 带 props 转换
|
|
53
|
+
* const BloodlineFlow = createFlow<IBloodlineFlowProps, BloodlineExtendProps>(
|
|
54
|
+
* Flow,
|
|
55
|
+
* (props) => {
|
|
56
|
+
* const { root, nodeTypes } = props;
|
|
57
|
+
* const nodes = useMemo(() => root ? [root] : [], [root]);
|
|
58
|
+
* return {
|
|
59
|
+
* ...props,
|
|
60
|
+
* nodes,
|
|
61
|
+
* nodeTypes: wrapNodeTypes(nodeTypes, BaseNodeWrapper),
|
|
62
|
+
* };
|
|
63
|
+
* }
|
|
64
|
+
* );
|
|
65
|
+
*/
|
|
41
66
|
function createFlow(FlowComponent, usePropsTransform) {
|
|
42
|
-
//
|
|
67
|
+
// 创建包装后的组件
|
|
43
68
|
return (0, _withFlowProvider.withFlowProvider)(props => {
|
|
44
|
-
|
|
69
|
+
// 转换 props
|
|
70
|
+
let flowProps = props;
|
|
45
71
|
if (usePropsTransform) {
|
|
46
|
-
|
|
47
|
-
_props = usePropsTransform(props);
|
|
72
|
+
flowProps = usePropsTransform(props);
|
|
48
73
|
}
|
|
49
74
|
const {
|
|
50
75
|
children,
|
|
51
|
-
...
|
|
52
|
-
} =
|
|
53
|
-
|
|
76
|
+
...flowPropsWithoutChildren
|
|
77
|
+
} = flowProps;
|
|
78
|
+
const {
|
|
79
|
+
children: inputChildren,
|
|
80
|
+
...inputPropsWithoutChildren
|
|
81
|
+
} = props;
|
|
54
82
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.ConfigProvider, {
|
|
55
83
|
prefixCls: 'rxflow',
|
|
56
84
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PropsStore.PropsStore, {
|
|
57
|
-
|
|
58
|
-
|
|
85
|
+
inputProps: inputPropsWithoutChildren,
|
|
86
|
+
flowProps: flowPropsWithoutChildren,
|
|
87
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(RenderFlowWithProps, {
|
|
59
88
|
FlowComponent: FlowComponent,
|
|
60
89
|
children: children
|
|
61
90
|
})
|
|
62
91
|
})
|
|
63
92
|
});
|
|
64
93
|
});
|
|
65
|
-
|
|
66
|
-
// hooks 直接绑定在 Flow 上,是不是更好,可以直接和传入的 nodeType 进行绑定。
|
|
67
94
|
}
|
package/cjs/hooks/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @author: yanxianliang
|
|
3
3
|
* @date: 2025-07-02 21:07
|
|
4
|
+
* @modified:2025/1/17 by yanxianliang
|
|
4
5
|
* @desc: export hooks
|
|
5
6
|
*
|
|
6
7
|
* Copyright (c) 2025 by yanxianliang, All Rights Reserved.
|
|
@@ -11,12 +12,14 @@ export * from './useThemeVars';
|
|
|
11
12
|
export * from './node/useNodeInitialize';
|
|
12
13
|
export * from './node/useNodeTypeMap';
|
|
13
14
|
export * from './useFlowId';
|
|
14
|
-
export * from './props/usePropsSelector';
|
|
15
|
-
export * from './props/useGetProps';
|
|
16
15
|
export * from './node/useNodes';
|
|
17
16
|
export * from './render/useForceUpdate';
|
|
18
17
|
export * from './edges/useOnEdgesChange';
|
|
19
18
|
export * from './state/useSetState';
|
|
20
19
|
export * from './state/useGetState';
|
|
21
20
|
export * from './state/useSelector';
|
|
21
|
+
export * from './props/useInputProps';
|
|
22
|
+
export * from './props/useFlowProps';
|
|
23
|
+
export * from './props/useGetInputProps';
|
|
24
|
+
export * from './props/useGetFlowProps';
|
|
22
25
|
//# sourceMappingURL=index.d.ts.map
|
package/cjs/hooks/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAEhC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AAEzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AAGpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC"}
|
package/cjs/hooks/index.js
CHANGED
|
@@ -69,28 +69,6 @@ Object.keys(_useFlowId).forEach(function (key) {
|
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
});
|
|
72
|
-
var _usePropsSelector = require("./props/usePropsSelector");
|
|
73
|
-
Object.keys(_usePropsSelector).forEach(function (key) {
|
|
74
|
-
if (key === "default" || key === "__esModule") return;
|
|
75
|
-
if (key in exports && exports[key] === _usePropsSelector[key]) return;
|
|
76
|
-
Object.defineProperty(exports, key, {
|
|
77
|
-
enumerable: true,
|
|
78
|
-
get: function () {
|
|
79
|
-
return _usePropsSelector[key];
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
var _useGetProps = require("./props/useGetProps");
|
|
84
|
-
Object.keys(_useGetProps).forEach(function (key) {
|
|
85
|
-
if (key === "default" || key === "__esModule") return;
|
|
86
|
-
if (key in exports && exports[key] === _useGetProps[key]) return;
|
|
87
|
-
Object.defineProperty(exports, key, {
|
|
88
|
-
enumerable: true,
|
|
89
|
-
get: function () {
|
|
90
|
-
return _useGetProps[key];
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
72
|
var _useNodes = require("./node/useNodes");
|
|
95
73
|
Object.keys(_useNodes).forEach(function (key) {
|
|
96
74
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -156,4 +134,48 @@ Object.keys(_useSelector).forEach(function (key) {
|
|
|
156
134
|
return _useSelector[key];
|
|
157
135
|
}
|
|
158
136
|
});
|
|
137
|
+
});
|
|
138
|
+
var _useInputProps = require("./props/useInputProps");
|
|
139
|
+
Object.keys(_useInputProps).forEach(function (key) {
|
|
140
|
+
if (key === "default" || key === "__esModule") return;
|
|
141
|
+
if (key in exports && exports[key] === _useInputProps[key]) return;
|
|
142
|
+
Object.defineProperty(exports, key, {
|
|
143
|
+
enumerable: true,
|
|
144
|
+
get: function () {
|
|
145
|
+
return _useInputProps[key];
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
});
|
|
149
|
+
var _useFlowProps = require("./props/useFlowProps");
|
|
150
|
+
Object.keys(_useFlowProps).forEach(function (key) {
|
|
151
|
+
if (key === "default" || key === "__esModule") return;
|
|
152
|
+
if (key in exports && exports[key] === _useFlowProps[key]) return;
|
|
153
|
+
Object.defineProperty(exports, key, {
|
|
154
|
+
enumerable: true,
|
|
155
|
+
get: function () {
|
|
156
|
+
return _useFlowProps[key];
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
var _useGetInputProps = require("./props/useGetInputProps");
|
|
161
|
+
Object.keys(_useGetInputProps).forEach(function (key) {
|
|
162
|
+
if (key === "default" || key === "__esModule") return;
|
|
163
|
+
if (key in exports && exports[key] === _useGetInputProps[key]) return;
|
|
164
|
+
Object.defineProperty(exports, key, {
|
|
165
|
+
enumerable: true,
|
|
166
|
+
get: function () {
|
|
167
|
+
return _useGetInputProps[key];
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
var _useGetFlowProps = require("./props/useGetFlowProps");
|
|
172
|
+
Object.keys(_useGetFlowProps).forEach(function (key) {
|
|
173
|
+
if (key === "default" || key === "__esModule") return;
|
|
174
|
+
if (key in exports && exports[key] === _useGetFlowProps[key]) return;
|
|
175
|
+
Object.defineProperty(exports, key, {
|
|
176
|
+
enumerable: true,
|
|
177
|
+
get: function () {
|
|
178
|
+
return _useGetFlowProps[key];
|
|
179
|
+
}
|
|
180
|
+
});
|
|
159
181
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author: yanxianliang
|
|
3
|
+
* @date: 2025-01-17
|
|
4
|
+
* @desc: Props hooks 导出
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2025 by yanxianliang, All Rights Reserved.
|
|
7
|
+
*/
|
|
8
|
+
export * from './useInputProps';
|
|
9
|
+
export * from './useFlowProps';
|
|
10
|
+
export * from './useGetInputProps';
|
|
11
|
+
export * from './useGetFlowProps';
|
|
12
|
+
//# 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,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _useInputProps = require("./useInputProps");
|
|
7
|
+
Object.keys(_useInputProps).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _useInputProps[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _useInputProps[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _useFlowProps = require("./useFlowProps");
|
|
18
|
+
Object.keys(_useFlowProps).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _useFlowProps[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _useFlowProps[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _useGetInputProps = require("./useGetInputProps");
|
|
29
|
+
Object.keys(_useGetInputProps).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _useGetInputProps[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _useGetInputProps[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _useGetFlowProps = require("./useGetFlowProps");
|
|
40
|
+
Object.keys(_useGetFlowProps).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _useGetFlowProps[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _useGetFlowProps[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author: yanxianliang
|
|
3
|
+
* @date: 2025-01-17
|
|
4
|
+
* @desc: 获取转换后的 Flow props(传给 Flow 组件的)
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2025 by yanxianliang, All Rights Reserved.
|
|
7
|
+
*/
|
|
8
|
+
import { IBaseFlowProps } from "../../types";
|
|
9
|
+
/**
|
|
10
|
+
* 获取转换后的 Flow props
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* // 获取全部 flow props
|
|
14
|
+
* const flowProps = useFlowProps<IBaseFlowProps>();
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* // 使用 selector 获取特定属性
|
|
18
|
+
* const nodes = useFlowProps(state => state.nodes);
|
|
19
|
+
* const theme = useFlowProps(state => state.theme);
|
|
20
|
+
*/
|
|
21
|
+
export declare function useFlowProps<TFlowProps = IBaseFlowProps>(): TFlowProps;
|
|
22
|
+
export declare function useFlowProps<TFlowProps = IBaseFlowProps, U = unknown>(selector: (state: TFlowProps) => U): U;
|
|
23
|
+
//# sourceMappingURL=useFlowProps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFlowProps.d.ts","sourceRoot":"","sources":["useFlowProps.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,UAAU,GAAG,cAAc,KAAK,UAAU,CAAC;AACxE,wBAAgB,YAAY,CAAC,UAAU,GAAG,cAAc,EAAE,CAAC,GAAG,OAAO,EACnE,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,CAAC,GACjC,CAAC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useFlowProps = useFlowProps;
|
|
7
|
+
var _useSelector = require("../state/useSelector");
|
|
8
|
+
/**
|
|
9
|
+
* @author: yanxianliang
|
|
10
|
+
* @date: 2025-01-17
|
|
11
|
+
* @desc: 获取转换后的 Flow props(传给 Flow 组件的)
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) 2025 by yanxianliang, All Rights Reserved.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 获取转换后的 Flow props
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // 获取全部 flow props
|
|
21
|
+
* const flowProps = useFlowProps<IBaseFlowProps>();
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // 使用 selector 获取特定属性
|
|
25
|
+
* const nodes = useFlowProps(state => state.nodes);
|
|
26
|
+
* const theme = useFlowProps(state => state.theme);
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
function useFlowProps(selector) {
|
|
30
|
+
return (0, _useSelector.useSelector)(state => {
|
|
31
|
+
const flowProps = state.flowProps;
|
|
32
|
+
return selector ? selector(flowProps) : flowProps;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { IBaseFlowProps } from "../../types";
|
|
2
|
+
/**
|
|
3
|
+
* 获取转换后 Flow props 的 getter 函数
|
|
4
|
+
* 用于在回调函数中获取最新的 props,避免闭包问题
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* const getFlowProps = useGetFlowProps<IBaseFlowProps>();
|
|
8
|
+
*
|
|
9
|
+
* const handleClick = () => {
|
|
10
|
+
* const nodes = getFlowProps(state => state.nodes);
|
|
11
|
+
* // 或获取全部
|
|
12
|
+
* const allProps = getFlowProps();
|
|
13
|
+
* };
|
|
14
|
+
*/
|
|
15
|
+
export declare const useGetFlowProps: <TFlowProps = IBaseFlowProps<import("@xyflow/react").Node, import("@xyflow/react").Edge>>() => {
|
|
16
|
+
(): TFlowProps;
|
|
17
|
+
<U>(selector: (state: TFlowProps) => U): U;
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=useGetFlowProps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGetFlowProps.d.ts","sourceRoot":"","sources":["useGetFlowProps.ts"],"names":[],"mappings":"AAQA,OAAO,EAAiB,cAAc,EAAE,MAAM,aAAa,CAAC;AAG5D;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe;QAGP,UAAU;0BACQ,UAAU,KAAK,CAAC,GAAG,CAAC;CAO1D,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useGetFlowProps = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _useGetState = require("../state/useGetState");
|
|
9
|
+
/**
|
|
10
|
+
* @author: yanxianliang
|
|
11
|
+
* @date: 2025-01-17
|
|
12
|
+
* @desc: 获取转换后 Flow props 的 getter 函数(非响应式)
|
|
13
|
+
*
|
|
14
|
+
* Copyright (c) 2025 by yanxianliang, All Rights Reserved.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 获取转换后 Flow props 的 getter 函数
|
|
19
|
+
* 用于在回调函数中获取最新的 props,避免闭包问题
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* const getFlowProps = useGetFlowProps<IBaseFlowProps>();
|
|
23
|
+
*
|
|
24
|
+
* const handleClick = () => {
|
|
25
|
+
* const nodes = getFlowProps(state => state.nodes);
|
|
26
|
+
* // 或获取全部
|
|
27
|
+
* const allProps = getFlowProps();
|
|
28
|
+
* };
|
|
29
|
+
*/
|
|
30
|
+
const useGetFlowProps = () => {
|
|
31
|
+
const getState = (0, _useGetState.useGetState)();
|
|
32
|
+
function getter(selector) {
|
|
33
|
+
const flowProps = getState().flowProps;
|
|
34
|
+
return selector ? selector(flowProps) : flowProps;
|
|
35
|
+
}
|
|
36
|
+
return (0, _react.useCallback)(getter, [getState]);
|
|
37
|
+
};
|
|
38
|
+
exports.useGetFlowProps = useGetFlowProps;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 获取原始输入 props 的 getter 函数
|
|
3
|
+
* 用于在回调函数中获取最新的 props,避免闭包问题
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* const getInputProps = useGetInputProps<IBloodlineFlowProps>();
|
|
7
|
+
*
|
|
8
|
+
* const handleClick = () => {
|
|
9
|
+
* const root = getInputProps(state => state.root);
|
|
10
|
+
* // 或获取全部
|
|
11
|
+
* const allProps = getInputProps();
|
|
12
|
+
* };
|
|
13
|
+
*/
|
|
14
|
+
export declare const useGetInputProps: <TInputProps = Record<string, any>>() => {
|
|
15
|
+
(): TInputProps;
|
|
16
|
+
<U>(selector: (state: TInputProps) => U): U;
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=useGetInputProps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useGetInputProps.d.ts","sourceRoot":"","sources":["useGetInputProps.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,gBAAgB;QAGR,WAAW;0BACO,WAAW,KAAK,CAAC,GAAG,CAAC;CAO3D,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useGetInputProps = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _useGetState = require("../state/useGetState");
|
|
9
|
+
/**
|
|
10
|
+
* @author: yanxianliang
|
|
11
|
+
* @date: 2025-01-17
|
|
12
|
+
* @desc: 获取原始输入 props 的 getter 函数(非响应式)
|
|
13
|
+
*
|
|
14
|
+
* Copyright (c) 2025 by yanxianliang, All Rights Reserved.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 获取原始输入 props 的 getter 函数
|
|
19
|
+
* 用于在回调函数中获取最新的 props,避免闭包问题
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* const getInputProps = useGetInputProps<IBloodlineFlowProps>();
|
|
23
|
+
*
|
|
24
|
+
* const handleClick = () => {
|
|
25
|
+
* const root = getInputProps(state => state.root);
|
|
26
|
+
* // 或获取全部
|
|
27
|
+
* const allProps = getInputProps();
|
|
28
|
+
* };
|
|
29
|
+
*/
|
|
30
|
+
const useGetInputProps = () => {
|
|
31
|
+
const getState = (0, _useGetState.useGetState)();
|
|
32
|
+
function getter(selector) {
|
|
33
|
+
const inputProps = getState().inputProps;
|
|
34
|
+
return selector ? selector(inputProps) : inputProps;
|
|
35
|
+
}
|
|
36
|
+
return (0, _react.useCallback)(getter, [getState]);
|
|
37
|
+
};
|
|
38
|
+
exports.useGetInputProps = useGetInputProps;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 获取原始输入 props
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* // 获取全部原始 props
|
|
6
|
+
* const inputProps = useInputProps<IBloodlineFlowProps>();
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* // 使用 selector 获取特定属性
|
|
10
|
+
* const root = useInputProps<IBloodlineFlowProps, BaseBloodNode>(state => state.root);
|
|
11
|
+
*/
|
|
12
|
+
export declare function useInputProps<TInputProps = Record<string, any>>(): TInputProps;
|
|
13
|
+
export declare function useInputProps<TInputProps = Record<string, any>, U = unknown>(selector: (state: TInputProps) => U): U;
|
|
14
|
+
//# sourceMappingURL=useInputProps.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInputProps.d.ts","sourceRoot":"","sources":["useInputProps.ts"],"names":[],"mappings":"AASA;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,WAAW,CAAC;AAChF,wBAAgB,aAAa,CAAC,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,EAC1E,QAAQ,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,CAAC,GAClC,CAAC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useInputProps = useInputProps;
|
|
7
|
+
var _useSelector = require("../state/useSelector");
|
|
8
|
+
/**
|
|
9
|
+
* @author: yanxianliang
|
|
10
|
+
* @date: 2025-01-17
|
|
11
|
+
* @desc: 获取原始输入 props(用户传入的)
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) 2025 by yanxianliang, All Rights Reserved.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* 获取原始输入 props
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // 获取全部原始 props
|
|
21
|
+
* const inputProps = useInputProps<IBloodlineFlowProps>();
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // 使用 selector 获取特定属性
|
|
25
|
+
* const root = useInputProps<IBloodlineFlowProps, BaseBloodNode>(state => state.root);
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
function useInputProps(selector) {
|
|
29
|
+
return (0, _useSelector.useSelector)(state => {
|
|
30
|
+
const inputProps = state.inputProps;
|
|
31
|
+
return selector ? selector(inputProps) : inputProps;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useListenRender = void 0;
|
|
7
7
|
var _react = require("@xyflow/react");
|
|
8
8
|
var _react2 = require("react");
|
|
9
|
-
var
|
|
9
|
+
var _useGetFlowProps = require("./props/useGetFlowProps");
|
|
10
10
|
/**
|
|
11
11
|
* @author: yanxianliang
|
|
12
12
|
* @date: 2025-08-25 17:49
|
|
@@ -17,8 +17,8 @@ var _ = require("./..");
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
const useListenRender = () => {
|
|
20
|
-
const
|
|
21
|
-
const onRender =
|
|
20
|
+
const getFlowProps = (0, _useGetFlowProps.useGetFlowProps)();
|
|
21
|
+
const onRender = getFlowProps().onRender;
|
|
22
22
|
const nodes = (0, _react.useNodes)();
|
|
23
23
|
const {
|
|
24
24
|
getEdges
|
|
@@ -36,7 +36,7 @@ const useListenRender = () => {
|
|
|
36
36
|
const timing = performance.now() - startRenderTimeRef.current;
|
|
37
37
|
const edges = getEdges();
|
|
38
38
|
onRender?.(nodes, edges, timing);
|
|
39
|
-
if (
|
|
39
|
+
if (getFlowProps().debug) {
|
|
40
40
|
console.log(`初始化节点数:${nodes.length}, 边:${edges.length}, 渲染时长:${timing}`);
|
|
41
41
|
}
|
|
42
42
|
}, 1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["useTheme.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["useTheme.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,QAAQ;;;;;;;CAKpB,CAAC"}
|
package/cjs/hooks/useTheme.js
CHANGED
|
@@ -7,17 +7,18 @@ exports.useTheme = void 0;
|
|
|
7
7
|
var _shallow = require("zustand/react/shallow");
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _getThemeWithDefaultValue = require("../utils/getThemeWithDefaultValue");
|
|
10
|
-
var
|
|
10
|
+
var _useFlowProps = require("./props/useFlowProps");
|
|
11
11
|
/**
|
|
12
12
|
* @author: yanxianliang
|
|
13
13
|
* @date: 2025-06-21 13:16
|
|
14
|
+
* @modified:2025/1/17 by yanxianliang
|
|
14
15
|
* @desc: 节点主题配置
|
|
15
16
|
*
|
|
16
17
|
* Copyright (c) 2025 by yanxianliang, All Rights Reserved.
|
|
17
18
|
*/
|
|
18
19
|
|
|
19
20
|
const useTheme = () => {
|
|
20
|
-
const theme = (0,
|
|
21
|
+
const theme = (0, _useFlowProps.useFlowProps)((0, _shallow.useShallow)(state => state.theme));
|
|
21
22
|
return (0, _react.useMemo)(() => {
|
|
22
23
|
return (0, _getThemeWithDefaultValue.getThemeWithDefaultValue)(theme);
|
|
23
24
|
}, [theme]);
|
package/cjs/index.d.ts
CHANGED
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* @author: yanxianliang
|
|
4
4
|
* @date: 2025-07-02 09:27
|
|
5
|
-
* @
|
|
5
|
+
* @modified:2025/1/17 by yanxianliang
|
|
6
|
+
* @desc: 基础 Graph 组件
|
|
6
7
|
*
|
|
7
8
|
* 提供统一图解决方案底层
|
|
8
9
|
*
|
|
@@ -12,14 +13,16 @@ import { Flow } from "./Flow";
|
|
|
12
13
|
declare const BaseFlow: (props: import("react").PropsWithChildren<import("./types").IBaseFlowProps<import("@xyflow/react").Node, import("@xyflow/react").Edge>>) => import("react/jsx-runtime").JSX.Element;
|
|
13
14
|
export default BaseFlow;
|
|
14
15
|
export * from './types';
|
|
16
|
+
export * from './types/props';
|
|
15
17
|
export * from './hooks';
|
|
16
18
|
export * from './components';
|
|
17
19
|
export * from './utils/parse';
|
|
18
20
|
export * from './utils/dimension';
|
|
19
|
-
export * from './hoc/createFlow';
|
|
20
|
-
export * from './hoc/withFlowProvider';
|
|
21
21
|
export * from './utils/measureText';
|
|
22
22
|
export * from './utils/layouts/mindmap';
|
|
23
|
+
export * from './utils/wrapNodeTypes';
|
|
24
|
+
export * from './hoc/createFlow';
|
|
25
|
+
export * from './hoc/withFlowProvider';
|
|
23
26
|
export * from './constants/NodeRoleType';
|
|
24
27
|
export * from './constants/InnerFlowType';
|
|
25
28
|
export * from './constants/SelectionStrategy';
|
package/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAG9B,QAAA,MAAM,QAAQ,qLAAmB,CAAC;AAElC,eAAe,QAAQ,CAAC;AAGxB,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAG9B,cAAc,SAAS,CAAC;AAGxB,cAAc,cAAc,CAAC;AAG7B,cAAc,eAAe,CAAC;AAC9B,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AAGtC,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AAGvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAG9C,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGrE,OAAO,EAAE,IAAI,EAAE,CAAC"}
|