@rxflow/base 0.0.4-alpha.6 → 0.0.4-alpha.7
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.map +1 -1
- package/cjs/Flow.js +6 -1
- package/cjs/components/Nodes/DefaultNode.d.ts +1 -1
- package/cjs/components/Nodes/DefaultNode.d.ts.map +1 -1
- package/cjs/components/Nodes/DefaultNode.js +0 -3
- package/cjs/components/Nodes/GroupNode.d.ts +1 -1
- package/cjs/components/Nodes/GroupNode.d.ts.map +1 -1
- package/cjs/components/Nodes/GroupNode.js +1 -5
- package/cjs/components/Nodes/InputNode.d.ts +1 -1
- package/cjs/components/Nodes/InputNode.d.ts.map +1 -1
- package/cjs/components/Nodes/InputNode.js +0 -3
- package/cjs/components/Nodes/OutputNode.d.ts +1 -1
- package/cjs/components/Nodes/OutputNode.d.ts.map +1 -1
- package/cjs/components/Nodes/OutputNode.js +0 -3
- package/cjs/hoc/createFlow.d.ts +1 -3
- package/cjs/hoc/createFlow.d.ts.map +1 -1
- package/cjs/hoc/createFlow.js +3 -10
- package/cjs/hoc/withFlowProvider.d.ts +2 -1
- package/cjs/hoc/withFlowProvider.d.ts.map +1 -1
- package/cjs/hoc/withFlowProvider.js +1 -0
- package/cjs/hooks/index.d.ts +0 -3
- package/cjs/hooks/index.d.ts.map +1 -1
- package/cjs/hooks/index.js +0 -33
- package/cjs/hooks/props/index.d.ts +0 -2
- package/cjs/hooks/props/index.d.ts.map +1 -1
- package/cjs/hooks/props/index.js +0 -22
- package/cjs/hooks/props/useFlowProps.d.ts +9 -6
- package/cjs/hooks/props/useFlowProps.d.ts.map +1 -1
- package/cjs/hooks/props/useFlowProps.js +7 -4
- package/cjs/hooks/props/useGetFlowProps.d.ts +10 -8
- package/cjs/hooks/props/useGetFlowProps.d.ts.map +1 -1
- package/cjs/hooks/props/useGetFlowProps.js +8 -8
- package/cjs/hooks/useNodeTypes.d.ts.map +1 -1
- package/cjs/hooks/useNodeTypes.js +3 -5
- package/cjs/index.d.ts +1 -1
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js +8 -1
- package/cjs/providers/FlowProvider/Context.d.ts +16 -0
- package/cjs/providers/FlowProvider/Context.d.ts.map +1 -0
- package/cjs/providers/FlowProvider/Context.js +19 -0
- package/cjs/providers/FlowProvider/Provider.d.ts +6 -0
- package/cjs/providers/FlowProvider/Provider.d.ts.map +1 -0
- package/cjs/providers/FlowProvider/Provider.js +39 -0
- package/cjs/providers/FlowProvider/index.d.ts +9 -0
- package/cjs/providers/FlowProvider/index.d.ts.map +1 -0
- package/cjs/providers/FlowProvider/index.js +50 -0
- package/cjs/providers/FlowProvider/initialState.d.ts +21 -0
- package/cjs/providers/FlowProvider/initialState.d.ts.map +1 -0
- package/cjs/providers/FlowProvider/initialState.js +36 -0
- package/cjs/store/PropsStore/InjectStyle.d.ts +13 -0
- package/cjs/store/PropsStore/InjectStyle.d.ts.map +1 -0
- package/cjs/store/PropsStore/InjectStyle.js +42 -0
- package/cjs/store/PropsStore/index.d.ts +9 -0
- package/cjs/store/PropsStore/index.d.ts.map +1 -0
- package/cjs/store/PropsStore/index.js +77 -0
- package/cjs/types.d.ts +11 -7
- package/cjs/types.d.ts.map +1 -1
- package/esm/Flow.d.ts.map +1 -1
- package/esm/Flow.js +6 -2
- package/esm/components/Nodes/DefaultNode.d.ts +1 -1
- package/esm/components/Nodes/DefaultNode.d.ts.map +1 -1
- package/esm/components/Nodes/DefaultNode.js +1 -4
- package/esm/components/Nodes/GroupNode.d.ts +1 -1
- package/esm/components/Nodes/GroupNode.d.ts.map +1 -1
- package/esm/components/Nodes/GroupNode.js +2 -3
- package/esm/components/Nodes/InputNode.d.ts +1 -1
- package/esm/components/Nodes/InputNode.d.ts.map +1 -1
- package/esm/components/Nodes/InputNode.js +1 -4
- package/esm/components/Nodes/OutputNode.d.ts +1 -1
- package/esm/components/Nodes/OutputNode.d.ts.map +1 -1
- package/esm/components/Nodes/OutputNode.js +1 -4
- package/esm/hoc/createFlow.d.ts +1 -3
- package/esm/hoc/createFlow.d.ts.map +1 -1
- package/esm/hoc/createFlow.js +4 -10
- package/esm/hoc/withFlowProvider.d.ts +2 -1
- package/esm/hoc/withFlowProvider.d.ts.map +1 -1
- package/esm/hoc/withFlowProvider.js +1 -0
- package/esm/hooks/index.d.ts +0 -3
- package/esm/hooks/index.d.ts.map +1 -1
- package/esm/hooks/index.js +0 -3
- package/esm/hooks/props/index.d.ts +0 -2
- package/esm/hooks/props/index.d.ts.map +1 -1
- package/esm/hooks/props/index.js +0 -2
- package/esm/hooks/props/useFlowProps.d.ts +9 -6
- package/esm/hooks/props/useFlowProps.d.ts.map +1 -1
- package/esm/hooks/props/useFlowProps.js +7 -4
- package/esm/hooks/props/useGetFlowProps.d.ts +10 -8
- package/esm/hooks/props/useGetFlowProps.d.ts.map +1 -1
- package/esm/hooks/props/useGetFlowProps.js +8 -9
- package/esm/hooks/useNodeTypes.d.ts.map +1 -1
- package/esm/hooks/useNodeTypes.js +3 -5
- package/esm/index.d.ts +1 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -1
- package/esm/providers/FlowProvider/Context.d.ts +16 -0
- package/esm/providers/FlowProvider/Context.d.ts.map +1 -0
- package/esm/providers/FlowProvider/Context.js +12 -0
- package/esm/providers/FlowProvider/Provider.d.ts +6 -0
- package/esm/providers/FlowProvider/Provider.d.ts.map +1 -0
- package/esm/providers/FlowProvider/Provider.js +34 -0
- package/esm/providers/FlowProvider/index.d.ts +9 -0
- package/esm/providers/FlowProvider/index.d.ts.map +1 -0
- package/esm/providers/FlowProvider/index.js +29 -0
- package/esm/providers/FlowProvider/initialState.d.ts +21 -0
- package/esm/providers/FlowProvider/initialState.d.ts.map +1 -0
- package/esm/{components/NodeRenderFactory.js → providers/FlowProvider/initialState.js} +21 -11
- package/esm/store/PropsStore/InjectStyle.d.ts +13 -0
- package/esm/store/PropsStore/InjectStyle.d.ts.map +1 -0
- package/esm/store/PropsStore/InjectStyle.js +48 -0
- package/esm/store/PropsStore/index.d.ts +9 -0
- package/esm/store/PropsStore/index.d.ts.map +1 -0
- package/esm/store/{PropsStore.js → PropsStore/index.js} +16 -66
- package/esm/types.d.ts +11 -7
- package/esm/types.d.ts.map +1 -1
- package/package.json +2 -2
- package/cjs/components/NodeRenderFactory.d.ts +0 -11
- package/cjs/components/NodeRenderFactory.d.ts.map +0 -1
- package/cjs/components/NodeRenderFactory.js +0 -26
- package/cjs/hooks/node/useInitialized.d.ts +0 -2
- package/cjs/hooks/node/useInitialized.d.ts.map +0 -1
- package/cjs/hooks/node/useInitialized.js +0 -20
- package/cjs/hooks/node/useNodeInitialize.d.ts +0 -2
- package/cjs/hooks/node/useNodeInitialize.d.ts.map +0 -1
- package/cjs/hooks/node/useNodeInitialize.js +0 -23
- package/cjs/hooks/props/useGetInputProps.d.ts +0 -18
- package/cjs/hooks/props/useGetInputProps.d.ts.map +0 -1
- package/cjs/hooks/props/useGetInputProps.js +0 -38
- package/cjs/hooks/props/useInputProps.d.ts +0 -14
- package/cjs/hooks/props/useInputProps.d.ts.map +0 -1
- package/cjs/hooks/props/useInputProps.js +0 -33
- package/cjs/providers/FlowProvider.d.ts +0 -24
- package/cjs/providers/FlowProvider.d.ts.map +0 -1
- package/cjs/providers/FlowProvider.js +0 -110
- package/cjs/store/PropsStore.d.ts +0 -21
- package/cjs/store/PropsStore.d.ts.map +0 -1
- package/cjs/store/PropsStore.js +0 -110
- package/esm/components/NodeRenderFactory.d.ts +0 -11
- package/esm/components/NodeRenderFactory.d.ts.map +0 -1
- package/esm/hooks/node/useInitialized.d.ts +0 -2
- package/esm/hooks/node/useInitialized.d.ts.map +0 -1
- package/esm/hooks/node/useInitialized.js +0 -12
- package/esm/hooks/node/useNodeInitialize.d.ts +0 -2
- package/esm/hooks/node/useNodeInitialize.d.ts.map +0 -1
- package/esm/hooks/node/useNodeInitialize.js +0 -15
- package/esm/hooks/props/useGetInputProps.d.ts +0 -18
- package/esm/hooks/props/useGetInputProps.d.ts.map +0 -1
- package/esm/hooks/props/useGetInputProps.js +0 -31
- package/esm/hooks/props/useInputProps.d.ts +0 -14
- package/esm/hooks/props/useInputProps.d.ts.map +0 -1
- package/esm/hooks/props/useInputProps.js +0 -27
- package/esm/providers/FlowProvider.d.ts +0 -24
- package/esm/providers/FlowProvider.d.ts.map +0 -1
- package/esm/providers/FlowProvider.js +0 -110
- package/esm/store/PropsStore.d.ts +0 -21
- package/esm/store/PropsStore.d.ts.map +0 -1
package/esm/hoc/createFlow.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
var _excluded = ["children"]
|
|
2
|
-
_excluded2 = ["children"];
|
|
1
|
+
var _excluded = ["children"];
|
|
3
2
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
3
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
5
4
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
@@ -11,11 +10,9 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
11
10
|
/**
|
|
12
11
|
* @author: yanxianliang
|
|
13
12
|
* @date: 2025-10-15 15:25
|
|
14
|
-
* @modified:2025/1/
|
|
13
|
+
* @modified:2025/1/25 by yanxianliang
|
|
15
14
|
* @desc: 创建 Flow 组件
|
|
16
15
|
*
|
|
17
|
-
* 提供公共能力封装,支持双层 Props 存储
|
|
18
|
-
*
|
|
19
16
|
* Copyright (c) 2025 by yanxianliang, All Rights Reserved.
|
|
20
17
|
*/
|
|
21
18
|
|
|
@@ -76,14 +73,11 @@ export function createFlow(FlowComponent, usePropsTransform) {
|
|
|
76
73
|
}
|
|
77
74
|
var _flowProps = flowProps,
|
|
78
75
|
children = _flowProps.children,
|
|
79
|
-
|
|
80
|
-
var inputChildren = props.children,
|
|
81
|
-
inputPropsWithoutChildren = _objectWithoutProperties(props, _excluded2);
|
|
76
|
+
propsWithoutChildren = _objectWithoutProperties(_flowProps, _excluded);
|
|
82
77
|
return /*#__PURE__*/_jsx(ConfigProvider, {
|
|
83
78
|
prefixCls: 'rxflow',
|
|
84
79
|
children: /*#__PURE__*/_jsx(PropsStore, {
|
|
85
|
-
|
|
86
|
-
flowProps: flowPropsWithoutChildren,
|
|
80
|
+
props: propsWithoutChildren,
|
|
87
81
|
children: /*#__PURE__*/_jsx(RenderFlowWithProps, {
|
|
88
82
|
FlowComponent: FlowComponent,
|
|
89
83
|
children: children
|
|
@@ -7,5 +7,6 @@
|
|
|
7
7
|
* Copyright (c) 2025 by yanxianliang, All Rights Reserved.
|
|
8
8
|
*/
|
|
9
9
|
import React from "react";
|
|
10
|
-
|
|
10
|
+
import { IBaseFlowProps } from "../types";
|
|
11
|
+
export declare const withFlowProvider: <P extends IBaseFlowProps<import("@xyflow/react").Node, import("@xyflow/react").Edge> = Record<string, any>>(ComponentType: React.ComponentType<P>) => (props: P) => import("react/jsx-runtime").JSX.Element;
|
|
11
12
|
//# sourceMappingURL=withFlowProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withFlowProvider.d.ts","sourceRoot":"","sources":["withFlowProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"withFlowProvider.d.ts","sourceRoot":"","sources":["withFlowProvider.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,cAAc,EAAC,MAAM,UAAU,CAAC;AAExC,eAAO,MAAM,gBAAgB,iKACX,CAAC,4CAOlB,CAAA"}
|
|
@@ -18,6 +18,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
18
18
|
export var withFlowProvider = function withFlowProvider(ComponentType) {
|
|
19
19
|
return function (props) {
|
|
20
20
|
return /*#__PURE__*/_jsx(FlowProvider, {
|
|
21
|
+
id: props.id,
|
|
21
22
|
children: /*#__PURE__*/_jsx(ComponentType, _objectSpread({}, props))
|
|
22
23
|
});
|
|
23
24
|
};
|
package/esm/hooks/index.d.ts
CHANGED
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
export * from './useNodeTypes';
|
|
10
10
|
export * from './useTheme';
|
|
11
11
|
export * from './useThemeVars';
|
|
12
|
-
export * from './node/useNodeInitialize';
|
|
13
12
|
export * from './node/useNodeTypeMap';
|
|
14
13
|
export * from './useFlowId';
|
|
15
14
|
export * from './node/useNodes';
|
|
@@ -18,8 +17,6 @@ export * from './edges/useOnEdgesChange';
|
|
|
18
17
|
export * from './state/useSetState';
|
|
19
18
|
export * from './state/useGetState';
|
|
20
19
|
export * from './state/useSelector';
|
|
21
|
-
export * from './props/useInputProps';
|
|
22
20
|
export * from './props/useFlowProps';
|
|
23
|
-
export * from './props/useGetInputProps';
|
|
24
21
|
export * from './props/useGetFlowProps';
|
|
25
22
|
//# sourceMappingURL=index.d.ts.map
|
package/esm/hooks/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,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,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC"}
|
package/esm/hooks/index.js
CHANGED
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
export * from "./useNodeTypes";
|
|
11
11
|
export * from "./useTheme";
|
|
12
12
|
export * from "./useThemeVars";
|
|
13
|
-
export * from "./node/useNodeInitialize";
|
|
14
13
|
export * from "./node/useNodeTypeMap";
|
|
15
14
|
export * from "./useFlowId";
|
|
16
15
|
export * from "./node/useNodes";
|
|
@@ -21,7 +20,5 @@ export * from "./state/useGetState";
|
|
|
21
20
|
export * from "./state/useSelector";
|
|
22
21
|
|
|
23
22
|
// Props hooks
|
|
24
|
-
export * from "./props/useInputProps";
|
|
25
23
|
export * from "./props/useFlowProps";
|
|
26
|
-
export * from "./props/useGetInputProps";
|
|
27
24
|
export * from "./props/useGetFlowProps";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC"}
|
package/esm/hooks/props/index.js
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @author: yanxianliang
|
|
3
3
|
* @date: 2025-01-17
|
|
4
|
-
* @desc:
|
|
4
|
+
* @desc: 获取 Flow props
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) 2025 by yanxianliang, All Rights Reserved.
|
|
7
7
|
*/
|
|
8
8
|
import { IBaseFlowProps } from "../../types";
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* 获取 Flow props
|
|
11
|
+
*
|
|
12
|
+
* 注意:虽然 flowProps 包含函数属性,但只有数据属性变化才会触发更新。
|
|
13
|
+
* 函数属性变化不会触发组件重渲染,但通过 useGetFlowProps 可以获取最新的函数引用。
|
|
11
14
|
*
|
|
12
15
|
* @example
|
|
13
|
-
* // 获取全部
|
|
14
|
-
* const
|
|
16
|
+
* // 获取全部 props
|
|
17
|
+
* const props = useFlowProps<IBloodlineFlowProps>();
|
|
15
18
|
*
|
|
16
19
|
* @example
|
|
17
20
|
* // 使用 selector 获取特定属性
|
|
18
21
|
* const nodes = useFlowProps(state => state.nodes);
|
|
19
22
|
* const theme = useFlowProps(state => state.theme);
|
|
20
23
|
*/
|
|
21
|
-
export declare function useFlowProps<
|
|
22
|
-
export declare function useFlowProps<
|
|
24
|
+
export declare function useFlowProps<TProps = IBaseFlowProps>(): TProps;
|
|
25
|
+
export declare function useFlowProps<TProps = IBaseFlowProps, U = unknown>(selector: (state: TProps) => U): U;
|
|
23
26
|
//# sourceMappingURL=useFlowProps.d.ts.map
|
|
@@ -1 +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
|
|
1
|
+
{"version":3,"file":"useFlowProps.d.ts","sourceRoot":"","sources":["useFlowProps.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAG7C;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAAC,MAAM,GAAG,cAAc,KAAK,MAAM,CAAC;AAChE,wBAAgB,YAAY,CAAC,MAAM,GAAG,cAAc,EAAE,CAAC,GAAG,OAAO,EAC/D,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,GAC7B,CAAC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @author: yanxianliang
|
|
3
3
|
* @date: 2025-01-17
|
|
4
|
-
* @desc:
|
|
4
|
+
* @desc: 获取 Flow props
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) 2025 by yanxianliang, All Rights Reserved.
|
|
7
7
|
*/
|
|
@@ -9,11 +9,14 @@
|
|
|
9
9
|
import { useSelector } from "../state/useSelector";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* 获取 Flow props
|
|
13
|
+
*
|
|
14
|
+
* 注意:虽然 flowProps 包含函数属性,但只有数据属性变化才会触发更新。
|
|
15
|
+
* 函数属性变化不会触发组件重渲染,但通过 useGetFlowProps 可以获取最新的函数引用。
|
|
13
16
|
*
|
|
14
17
|
* @example
|
|
15
|
-
* // 获取全部
|
|
16
|
-
* const
|
|
18
|
+
* // 获取全部 props
|
|
19
|
+
* const props = useFlowProps<IBloodlineFlowProps>();
|
|
17
20
|
*
|
|
18
21
|
* @example
|
|
19
22
|
* // 使用 selector 获取特定属性
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import { IBaseFlowProps } from "../../types";
|
|
2
|
+
type GetterFn<TProps> = {
|
|
3
|
+
(): TProps;
|
|
4
|
+
<U>(selector: (state: TProps) => U): U;
|
|
5
|
+
};
|
|
2
6
|
/**
|
|
3
|
-
*
|
|
7
|
+
* 获取 Flow props 的 getter 函数
|
|
4
8
|
* 用于在回调函数中获取最新的 props,避免闭包问题
|
|
5
9
|
*
|
|
6
10
|
* @example
|
|
7
|
-
* const
|
|
11
|
+
* const getProps = useGetFlowProps<IBloodlineFlowProps>();
|
|
8
12
|
*
|
|
9
13
|
* const handleClick = () => {
|
|
10
|
-
* const nodes =
|
|
14
|
+
* const nodes = getProps(state => state.nodes);
|
|
11
15
|
* // 或获取全部
|
|
12
|
-
* const allProps =
|
|
16
|
+
* const allProps = getProps();
|
|
13
17
|
* };
|
|
14
18
|
*/
|
|
15
|
-
export declare const useGetFlowProps: <
|
|
16
|
-
|
|
17
|
-
<U>(selector: (state: TFlowProps) => U): U;
|
|
18
|
-
};
|
|
19
|
+
export declare const useGetFlowProps: <TProps = IBaseFlowProps<import("@xyflow/react").Node, import("@xyflow/react").Edge>>() => GetterFn<TProps>;
|
|
20
|
+
export {};
|
|
19
21
|
//# sourceMappingURL=useGetFlowProps.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGetFlowProps.d.ts","sourceRoot":"","sources":["useGetFlowProps.ts"],"names":[],"mappings":"AAQA,OAAO,EAAiB,cAAc,EAAE,MAAM,aAAa,CAAC;AAG5D
|
|
1
|
+
{"version":3,"file":"useGetFlowProps.d.ts","sourceRoot":"","sources":["useGetFlowProps.ts"],"names":[],"mappings":"AAQA,OAAO,EAAiB,cAAc,EAAE,MAAM,aAAa,CAAC;AAG5D,KAAK,QAAQ,CAAC,MAAM,IAAI;IACtB,IAAI,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;CACxC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe,6FAAgC,SAAS,MAAM,CAS1E,CAAC"}
|
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @author: yanxianliang
|
|
3
3
|
* @date: 2025-01-17
|
|
4
|
-
* @desc:
|
|
4
|
+
* @desc: 获取 Flow props 的 getter 函数(非响应式)
|
|
5
5
|
*
|
|
6
6
|
* Copyright (c) 2025 by yanxianliang, All Rights Reserved.
|
|
7
7
|
*/
|
|
8
8
|
import { useCallback } from "react";
|
|
9
9
|
import { useGetState } from "../state/useGetState";
|
|
10
|
-
|
|
11
10
|
/**
|
|
12
|
-
*
|
|
11
|
+
* 获取 Flow props 的 getter 函数
|
|
13
12
|
* 用于在回调函数中获取最新的 props,避免闭包问题
|
|
14
13
|
*
|
|
15
14
|
* @example
|
|
16
|
-
* const
|
|
15
|
+
* const getProps = useGetFlowProps<IBloodlineFlowProps>();
|
|
17
16
|
*
|
|
18
17
|
* const handleClick = () => {
|
|
19
|
-
* const nodes =
|
|
18
|
+
* const nodes = getProps(state => state.nodes);
|
|
20
19
|
* // 或获取全部
|
|
21
|
-
* const allProps =
|
|
20
|
+
* const allProps = getProps();
|
|
22
21
|
* };
|
|
23
22
|
*/
|
|
24
23
|
export var useGetFlowProps = function useGetFlowProps() {
|
|
25
24
|
var getState = useGetState();
|
|
26
|
-
|
|
25
|
+
var getter = useCallback(function (selector) {
|
|
27
26
|
var flowProps = getState().flowProps;
|
|
28
27
|
return selector ? selector(flowProps) : flowProps;
|
|
29
|
-
}
|
|
30
|
-
return
|
|
28
|
+
}, [getState]);
|
|
29
|
+
return getter;
|
|
31
30
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNodeTypes.d.ts","sourceRoot":"","sources":["useNodeTypes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAC,IAAI,EAAE,IAAI,EAAC,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAC,cAAc,EAAE,iBAAiB,EAAC,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"useNodeTypes.d.ts","sourceRoot":"","sources":["useNodeTypes.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAC,IAAI,EAAE,IAAI,EAAC,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAC,cAAc,EAAE,iBAAiB,EAAC,MAAM,UAAU,CAAC;AAM3D;;GAEG;AACH,eAAO,MAAM,YAAY,6EAA8E,eAAe,QAAQ,EAAE,QAAQ,CAAC,CAAC,WAAW,CAAC,sCAwBrJ,CAAA"}
|
|
@@ -11,7 +11,6 @@ import { InputNode } from "../components/Nodes/InputNode";
|
|
|
11
11
|
import { DefaultNode } from "../components/Nodes/DefaultNode";
|
|
12
12
|
import { OutputNode } from "../components/Nodes/OutputNode";
|
|
13
13
|
import { GroupNode } from "../components/Nodes/GroupNode";
|
|
14
|
-
import { nodeRenderFactory } from "../components/NodeRenderFactory";
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* 将外部节点定义解析成 reactflow 需要的结构
|
|
@@ -33,11 +32,10 @@ export var useNodeTypes = function useNodeTypes(nodeTypeList) {
|
|
|
33
32
|
component = item.component,
|
|
34
33
|
defaultSize = item.defaultSize,
|
|
35
34
|
measureHandles = item.measureHandles;
|
|
36
|
-
var nodeType = nodeRenderFactory(component);
|
|
37
35
|
// defaultSize 和 measureHandles绑定
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
nodeTypes[type] =
|
|
36
|
+
component.defaultSize = defaultSize;
|
|
37
|
+
component.measureHandles = measureHandles;
|
|
38
|
+
nodeTypes[type] = component; // 高阶组件
|
|
41
39
|
}
|
|
42
40
|
}
|
|
43
41
|
}
|
package/esm/index.d.ts
CHANGED
|
@@ -26,6 +26,6 @@ export * from './hoc/withFlowProvider';
|
|
|
26
26
|
export * from './constants/NodeRoleType';
|
|
27
27
|
export * from './constants/InnerFlowType';
|
|
28
28
|
export * from './constants/SelectionStrategy';
|
|
29
|
-
export { FlowContext, FlowProvider } from './providers/FlowProvider';
|
|
29
|
+
export { FlowContext, FlowProvider, setInitialState } from './providers/FlowProvider';
|
|
30
30
|
export { Flow };
|
|
31
31
|
//# sourceMappingURL=index.d.ts.map
|
package/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;
|
|
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,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAGtF,OAAO,EAAE,IAAI,EAAE,CAAC"}
|
package/esm/index.js
CHANGED
|
@@ -40,7 +40,7 @@ export * from "./constants/InnerFlowType";
|
|
|
40
40
|
export * from "./constants/SelectionStrategy";
|
|
41
41
|
|
|
42
42
|
// Provider 导出
|
|
43
|
-
export { FlowContext, FlowProvider } from "./providers/FlowProvider";
|
|
43
|
+
export { FlowContext, FlowProvider, setInitialState } from "./providers/FlowProvider";
|
|
44
44
|
|
|
45
45
|
// Flow 组件导出
|
|
46
46
|
export { Flow };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author: yanxianliang
|
|
3
|
+
* @date: 2026-01-25 09:36
|
|
4
|
+
* @modified:2026/1/25 09:36 by yanxianliang
|
|
5
|
+
* @desc: Context管理
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2026 by yanxianliang, All Rights Reserved.
|
|
8
|
+
*/
|
|
9
|
+
import React from "react";
|
|
10
|
+
import { UseBoundStore } from "zustand";
|
|
11
|
+
import type { StoreApi } from "zustand/vanilla";
|
|
12
|
+
import { BaseStateType } from "../../types";
|
|
13
|
+
export declare const FlowContext: React.Context<{
|
|
14
|
+
useStore?: UseBoundStore<StoreApi<BaseStateType>> | undefined;
|
|
15
|
+
}>;
|
|
16
|
+
//# sourceMappingURL=Context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["Context.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAO5C,eAAO,MAAM,WAAW;;EAEe,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author: yanxianliang
|
|
3
|
+
* @date: 2026-01-25 09:36
|
|
4
|
+
* @modified:2026/1/25 09:36 by yanxianliang
|
|
5
|
+
* @desc: Context管理
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2026 by yanxianliang, All Rights Reserved.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import React from "react";
|
|
11
|
+
// Context 外部提供,支持 inner hooks
|
|
12
|
+
export var FlowContext = /*#__PURE__*/React.createContext(null);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["Provider.tsx"],"names":[],"mappings":"AAUA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,eAAO,MAAM,QAAQ;cAKP,MAAM,SAAS;;6CAkB5B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author: yanxianliang
|
|
3
|
+
* @date: 2026-01-25 09:45
|
|
4
|
+
* @modified:2026/1/25 09:45 by yanxianliang
|
|
5
|
+
* @desc: Provider
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2026 by yanxianliang, All Rights Reserved.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { useCreation } from "ahooks";
|
|
11
|
+
import React from "react";
|
|
12
|
+
import { create } from "zustand";
|
|
13
|
+
import { devtools } from "zustand/middleware";
|
|
14
|
+
import { getInitialState } from "./initialState";
|
|
15
|
+
import { FlowContext } from "./Context";
|
|
16
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
+
export var Provider = function Provider(_ref) {
|
|
18
|
+
var children = _ref.children,
|
|
19
|
+
id = _ref.id;
|
|
20
|
+
var useStore = useCreation(function () {
|
|
21
|
+
return create()(devtools(function () {
|
|
22
|
+
return getInitialState(id);
|
|
23
|
+
}, {
|
|
24
|
+
name: "rxflow",
|
|
25
|
+
enabled: process.env.NODE_ENV === 'development'
|
|
26
|
+
}));
|
|
27
|
+
}, []);
|
|
28
|
+
return /*#__PURE__*/_jsx(FlowContext.Provider, {
|
|
29
|
+
value: {
|
|
30
|
+
useStore: useStore
|
|
31
|
+
},
|
|
32
|
+
children: children
|
|
33
|
+
});
|
|
34
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FlowContext } from "./Context";
|
|
3
|
+
import { setInitialState } from './initialState';
|
|
4
|
+
export { FlowContext, setInitialState };
|
|
5
|
+
export declare const FlowProvider: React.ComponentType<{
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
id?: string;
|
|
8
|
+
}>;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AASA,OAAO,KAAyB,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAC,WAAW,EAAC,MAAM,WAAW,CAAC;AACtC,OAAO,EAAC,eAAe,EAAC,MAAM,gBAAgB,CAAC;AAG/C,OAAO,EAAC,WAAW,EAAE,eAAe,EAAC,CAAC;AAGtC,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,aAAa,CAAC;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,CAcvF,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author: yanxianliang
|
|
3
|
+
* @date: 2025-10-16 17:28
|
|
4
|
+
* @modified:2025/1/17 by yanxianliang
|
|
5
|
+
* @desc: 全局状态管理器 - 支持双层 Props 存储
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2025 by yanxianliang, All Rights Reserved.
|
|
8
|
+
*/
|
|
9
|
+
import { ReactFlowProvider } from "@xyflow/react";
|
|
10
|
+
import React, { memo, useContext } from "react";
|
|
11
|
+
import { FlowContext } from "./Context";
|
|
12
|
+
import { setInitialState } from "./initialState";
|
|
13
|
+
import { Provider } from "./Provider";
|
|
14
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
+
export { FlowContext, setInitialState };
|
|
16
|
+
export var FlowProvider = /*#__PURE__*/memo(function (_ref) {
|
|
17
|
+
var children = _ref.children,
|
|
18
|
+
id = _ref.id;
|
|
19
|
+
var hasWrapped = useContext(FlowContext);
|
|
20
|
+
if (hasWrapped) {
|
|
21
|
+
return children;
|
|
22
|
+
}
|
|
23
|
+
return /*#__PURE__*/_jsx(ReactFlowProvider, {
|
|
24
|
+
children: /*#__PURE__*/_jsx(Provider, {
|
|
25
|
+
id: id,
|
|
26
|
+
children: children
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author: yanxianliang
|
|
3
|
+
* @date: 2026-01-25 09:38
|
|
4
|
+
* @modified:2026/1/25 09:38 by yanxianliang
|
|
5
|
+
* @desc: 默认State 值
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2026 by yanxianliang, All Rights Reserved.
|
|
8
|
+
*/
|
|
9
|
+
import { BaseStateType } from "../..";
|
|
10
|
+
export declare const setInitialState: (initialState: Partial<BaseStateType>) => void;
|
|
11
|
+
export declare const getInitialState: (id?: string) => {
|
|
12
|
+
id: string;
|
|
13
|
+
flowProps?: Record<string, any> | undefined;
|
|
14
|
+
onEdgesChangeHandlers?: import("@xyflow/react").OnEdgesChange<any>[] | undefined;
|
|
15
|
+
isNodeDragging?: boolean | undefined;
|
|
16
|
+
forceRenderTimes?: number | undefined;
|
|
17
|
+
nodeTypeMap?: Map<string, import("../..").INodeDefinition<Record<string, unknown>>> | undefined;
|
|
18
|
+
smartEdges?: Record<string, boolean> | undefined;
|
|
19
|
+
edgeStore?: Record<string, any> | undefined;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=initialState.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"initialState.d.ts","sourceRoot":"","sources":["initialState.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAC,aAAa,EAAC,cAAqB;AAY3C,eAAO,MAAM,eAAe,iBAAkB,QAAQ,aAAa,CAAC,SAEnE,CAAA;AAED,eAAO,MAAM,eAAe,QAAS,MAAM;;;;;;;;;CAE1C,CAAA"}
|
|
@@ -6,18 +6,28 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
6
6
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
7
|
/**
|
|
8
8
|
* @author: yanxianliang
|
|
9
|
-
* @date:
|
|
10
|
-
* @
|
|
9
|
+
* @date: 2026-01-25 09:38
|
|
10
|
+
* @modified:2026/1/25 09:38 by yanxianliang
|
|
11
|
+
* @desc: 默认State 值
|
|
11
12
|
*
|
|
12
|
-
* Copyright (c)
|
|
13
|
+
* Copyright (c) 2026 by yanxianliang, All Rights Reserved.
|
|
13
14
|
*/
|
|
14
15
|
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
16
|
+
import { v4 as uuid } from "uuid";
|
|
17
|
+
var $initialState = {
|
|
18
|
+
flowProps: undefined,
|
|
19
|
+
// Flow props
|
|
20
|
+
onEdgesChangeHandlers: [],
|
|
21
|
+
forceRenderTimes: 0,
|
|
22
|
+
nodeTypeMap: new Map(),
|
|
23
|
+
smartEdges: {},
|
|
24
|
+
edgeStore: {}
|
|
25
|
+
};
|
|
26
|
+
export var setInitialState = function setInitialState(initialState) {
|
|
27
|
+
$initialState = initialState || {};
|
|
28
|
+
};
|
|
29
|
+
export var getInitialState = function getInitialState(id) {
|
|
30
|
+
return _objectSpread(_objectSpread({}, $initialState), {}, {
|
|
31
|
+
id: id || uuid()
|
|
32
|
+
});
|
|
23
33
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author: yanxianliang
|
|
3
|
+
* @date: 2026-01-25 14:09
|
|
4
|
+
* @modified:2026/1/25 14:09 by yanxianliang
|
|
5
|
+
* @desc: 样式Inject
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) 2026 by yanxianliang, All Rights Reserved.
|
|
8
|
+
*/
|
|
9
|
+
import { INodeDefinition } from "../..";
|
|
10
|
+
export declare const InjectStyle: ({ nodeTypes }: {
|
|
11
|
+
nodeTypes?: INodeDefinition<Record<string, unknown>>[] | undefined;
|
|
12
|
+
}) => "" | import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=InjectStyle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InjectStyle.d.ts","sourceRoot":"","sources":["InjectStyle.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAC,eAAe,EAAe,cAAqB;AAqB3D,eAAO,MAAM,WAAW;;kDAMvB,CAAA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
3
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
4
|
+
/**
|
|
5
|
+
* @author: yanxianliang
|
|
6
|
+
* @date: 2026-01-25 14:09
|
|
7
|
+
* @modified:2026/1/25 14:09 by yanxianliang
|
|
8
|
+
* @desc: 样式Inject
|
|
9
|
+
*
|
|
10
|
+
* Copyright (c) 2026 by yanxianliang, All Rights Reserved.
|
|
11
|
+
*/
|
|
12
|
+
import { NodeRoleType } from "../..";
|
|
13
|
+
import { useMemo } from "react";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 生成 SubFlow 样式
|
|
17
|
+
*/
|
|
18
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
+
var generateSubFlowStyles = function generateSubFlowStyles(nodeTypes) {
|
|
20
|
+
var styles = [];
|
|
21
|
+
if (nodeTypes) {
|
|
22
|
+
var _iterator = _createForOfIteratorHelper(nodeTypes),
|
|
23
|
+
_step;
|
|
24
|
+
try {
|
|
25
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
26
|
+
var _definition$allowCont;
|
|
27
|
+
var definition = _step.value;
|
|
28
|
+
if (definition.nodeRoleType === NodeRoleType.SubFlow && ((_definition$allowCont = definition.allowContentSelection) !== null && _definition$allowCont !== void 0 ? _definition$allowCont : true)) {
|
|
29
|
+
styles.push(".react-flow__node-".concat(definition.type, " {pointer-events: none!important;}"));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
} catch (err) {
|
|
33
|
+
_iterator.e(err);
|
|
34
|
+
} finally {
|
|
35
|
+
_iterator.f();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return styles;
|
|
39
|
+
};
|
|
40
|
+
export var InjectStyle = function InjectStyle(_ref) {
|
|
41
|
+
var nodeTypes = _ref.nodeTypes;
|
|
42
|
+
var styleContent = useMemo(function () {
|
|
43
|
+
return generateSubFlowStyles(nodeTypes).join('');
|
|
44
|
+
}, [nodeTypes]);
|
|
45
|
+
return styleContent && /*#__PURE__*/_jsx("style", {
|
|
46
|
+
children: styleContent
|
|
47
|
+
});
|
|
48
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { IBaseFlowProps } from "../../types";
|
|
3
|
+
export interface PropsStoreProps<TProps extends IBaseFlowProps = IBaseFlowProps> {
|
|
4
|
+
/** Flow props */
|
|
5
|
+
props: TProps;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare const PropsStore: <TProps extends IBaseFlowProps<import("@xyflow/react").Node, import("@xyflow/react").Edge> = IBaseFlowProps<import("@xyflow/react").Node, import("@xyflow/react").Edge>>({ props, children }: PropsStoreProps<TProps>) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAC,SAAS,EAAU,MAAM,OAAO,CAAC;AACzC,OAAO,EAAC,cAAc,EAAkB,MAAM,aAAa,CAAC;AAiB5D,MAAM,WAAW,eAAe,CAAC,MAAM,SAAS,cAAc,GAAG,cAAc;IAC7E,iBAAiB;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,CAAC;CACrB;AAgBD,eAAO,MAAM,UAAU,gMAGpB,gBAAgB,MAAM,CAAC,4CA2BzB,CAAC"}
|