@logicflow/react-node-registry 1.2.0 → 1.2.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.
- package/README.md +6 -3
- package/dist/index.css +122 -0
- package/es/components/Container.d.ts +9 -0
- package/es/components/Container.js +16 -0
- package/es/components/Container.js.map +1 -0
- package/es/components/TitleBar.d.ts +8 -0
- package/es/components/TitleBar.js +87 -0
- package/es/components/TitleBar.js.map +1 -0
- package/es/index.css +122 -0
- package/es/index.less +1 -0
- package/es/model.d.ts +18 -1
- package/es/model.js +46 -8
- package/es/model.js.map +1 -1
- package/es/style/index.css +122 -0
- package/es/style/index.less +140 -0
- package/es/style/raw.d.ts +4 -0
- package/es/style/raw.js +6 -0
- package/es/style/raw.js.map +1 -0
- package/es/view.d.ts +10 -1
- package/es/view.js +123 -9
- package/es/view.js.map +1 -1
- package/es/wrapper.d.ts +1 -1
- package/es/wrapper.js +4 -2
- package/es/wrapper.js.map +1 -1
- package/lib/components/Container.d.ts +9 -0
- package/lib/components/Container.js +23 -0
- package/lib/components/Container.js.map +1 -0
- package/lib/components/TitleBar.d.ts +8 -0
- package/lib/components/TitleBar.js +114 -0
- package/lib/components/TitleBar.js.map +1 -0
- package/lib/index.css +122 -0
- package/lib/index.less +1 -0
- package/lib/model.d.ts +18 -1
- package/lib/model.js +44 -6
- package/lib/model.js.map +1 -1
- package/lib/style/index.css +122 -0
- package/lib/style/index.less +140 -0
- package/lib/style/raw.d.ts +4 -0
- package/lib/style/raw.js +9 -0
- package/lib/style/raw.js.map +1 -0
- package/lib/view.d.ts +10 -1
- package/lib/view.js +123 -9
- package/lib/view.js.map +1 -1
- package/lib/wrapper.d.ts +1 -1
- package/lib/wrapper.js +7 -2
- package/lib/wrapper.js.map +1 -1
- package/package.json +13 -6
- package/.turbo/turbo-build.log +0 -34
- package/CHANGELOG.md +0 -201
- package/src/index.ts +0 -5
- package/src/model.ts +0 -64
- package/src/portal.ts +0 -79
- package/src/registry.ts +0 -47
- package/src/view.ts +0 -97
- package/src/wrapper.tsx +0 -61
- package/stats.html +0 -4842
- package/tsconfig.json +0 -21
package/lib/view.js
CHANGED
|
@@ -19,13 +19,70 @@ exports.ReactNodeView = void 0;
|
|
|
19
19
|
var react_1 = require("react");
|
|
20
20
|
var client_1 = require("react-dom/client");
|
|
21
21
|
var core_1 = require("@logicflow/core");
|
|
22
|
+
var lodash_es_1 = require("lodash-es");
|
|
22
23
|
var wrapper_1 = require("./wrapper");
|
|
23
24
|
var portal_1 = require("./portal");
|
|
24
25
|
var react_dom_1 = require("react-dom");
|
|
25
26
|
var ReactNodeView = /** @class */ (function (_super) {
|
|
26
27
|
__extends(ReactNodeView, _super);
|
|
27
28
|
function ReactNodeView() {
|
|
28
|
-
|
|
29
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
30
|
+
_this.__throttledUpdate = (0, lodash_es_1.throttle)(function () { return _this.measureAndUpdate(); }, 80);
|
|
31
|
+
_this.measureAndUpdate = function () {
|
|
32
|
+
try {
|
|
33
|
+
var root = _this.containerEl;
|
|
34
|
+
if (!root)
|
|
35
|
+
return;
|
|
36
|
+
var target = root.firstElementChild || root;
|
|
37
|
+
var rect = target.getBoundingClientRect();
|
|
38
|
+
var width = (0, lodash_es_1.round)(rect.width);
|
|
39
|
+
var height = (0, lodash_es_1.round)(rect.height);
|
|
40
|
+
if (width <= 0 || height <= 0)
|
|
41
|
+
return;
|
|
42
|
+
if (width === _this.__lastWidth && height === _this.__lastHeight)
|
|
43
|
+
return;
|
|
44
|
+
_this.__lastWidth = width;
|
|
45
|
+
_this.__lastHeight = height;
|
|
46
|
+
var props = _this.props.model.properties;
|
|
47
|
+
var extra = (0, lodash_es_1.get)(props, '_showTitle')
|
|
48
|
+
? (0, lodash_es_1.isNumber)((0, lodash_es_1.get)(props, '_titleHeight'))
|
|
49
|
+
? (0, lodash_es_1.get)(props, '_titleHeight')
|
|
50
|
+
: 28
|
|
51
|
+
: 0;
|
|
52
|
+
var baseHeight = (0, lodash_es_1.clamp)(height - extra, 1, Number.MAX_SAFE_INTEGER);
|
|
53
|
+
_this.props.model.setProperties({ width: width, height: baseHeight });
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
console.error('measureAndUpdate error', err);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
return _this;
|
|
60
|
+
// TODO: 确认是否需要重写 onMouseDown 方法
|
|
61
|
+
// handleMouseDown(ev: MouseEvent, x: number, y: number) {
|
|
62
|
+
// const target = ev.target as Element
|
|
63
|
+
// const tagName = target.tagName.toLowerCase()
|
|
64
|
+
// if (tagName === 'input') {
|
|
65
|
+
// const type = target.getAttribute('type')
|
|
66
|
+
// if (
|
|
67
|
+
// type == null ||
|
|
68
|
+
// [
|
|
69
|
+
// 'text',
|
|
70
|
+
// 'password',
|
|
71
|
+
// 'number',
|
|
72
|
+
// 'email',
|
|
73
|
+
// 'search',
|
|
74
|
+
// 'tel',
|
|
75
|
+
// 'url',
|
|
76
|
+
// ].includes(type)
|
|
77
|
+
// ) {
|
|
78
|
+
// return
|
|
79
|
+
// }
|
|
80
|
+
// }
|
|
81
|
+
//
|
|
82
|
+
// console.log('pointer position, x:', x, 'y: ', y)
|
|
83
|
+
// // TODO
|
|
84
|
+
// // super.handleMouseDown(ev)
|
|
85
|
+
// }
|
|
29
86
|
}
|
|
30
87
|
ReactNodeView.prototype.targetId = function () {
|
|
31
88
|
return "".concat(this.props.graphModel.flowId, ":").concat(this.props.model.id);
|
|
@@ -35,15 +92,23 @@ var ReactNodeView = /** @class */ (function (_super) {
|
|
|
35
92
|
this.unmount();
|
|
36
93
|
};
|
|
37
94
|
ReactNodeView.prototype.setHtml = function (rootEl) {
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
95
|
+
var existed = rootEl.querySelector('.custom-react-node-content');
|
|
96
|
+
if (existed) {
|
|
97
|
+
this.containerEl = existed;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
var el = document.createElement('div');
|
|
101
|
+
el.className = 'custom-react-node-content';
|
|
102
|
+
this.containerEl = el;
|
|
103
|
+
this.renderReactComponent(el);
|
|
104
|
+
rootEl.appendChild(el);
|
|
105
|
+
}
|
|
106
|
+
this.startResizeObserver();
|
|
46
107
|
};
|
|
108
|
+
// confirmUpdate(_rootEl: SVGForeignObjectElement) {
|
|
109
|
+
// // TODO: 如有需要,可以先通过继承的方式,自定义该节点的更新逻辑;我们后续会根据实际需求,丰富该功能
|
|
110
|
+
// console.log('_rootEl', _rootEl)
|
|
111
|
+
// }
|
|
47
112
|
ReactNodeView.prototype.renderReactComponent = function (container) {
|
|
48
113
|
this.unmountReactComponent();
|
|
49
114
|
var _a = this.props, model = _a.model, graphModel = _a.graphModel;
|
|
@@ -67,6 +132,7 @@ var ReactNodeView = /** @class */ (function (_super) {
|
|
|
67
132
|
};
|
|
68
133
|
ReactNodeView.prototype.unmountReactComponent = function () {
|
|
69
134
|
if (this.rootEl && this.root) {
|
|
135
|
+
this.stopResizeObserver();
|
|
70
136
|
this.root.unmount();
|
|
71
137
|
this.root = undefined;
|
|
72
138
|
this.rootEl.innerHTML = '';
|
|
@@ -76,6 +142,54 @@ var ReactNodeView = /** @class */ (function (_super) {
|
|
|
76
142
|
ReactNodeView.prototype.unmount = function () {
|
|
77
143
|
this.unmountReactComponent();
|
|
78
144
|
};
|
|
145
|
+
ReactNodeView.prototype.startResizeObserver = function () {
|
|
146
|
+
var _this = this;
|
|
147
|
+
var _a;
|
|
148
|
+
var root = this.containerEl;
|
|
149
|
+
if (!root)
|
|
150
|
+
return;
|
|
151
|
+
try {
|
|
152
|
+
if ((0, lodash_es_1.isFunction)(window.ResizeObserver)) {
|
|
153
|
+
this.__resizeObserver = new window.ResizeObserver(function (entries) {
|
|
154
|
+
if (!(0, lodash_es_1.isArray)(entries) || !entries.length)
|
|
155
|
+
return;
|
|
156
|
+
if (_this.__resizeRafId)
|
|
157
|
+
cancelAnimationFrame(_this.__resizeRafId);
|
|
158
|
+
_this.__resizeRafId = requestAnimationFrame(_this.__throttledUpdate);
|
|
159
|
+
});
|
|
160
|
+
var target = root.firstElementChild || root;
|
|
161
|
+
(_a = this.__resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(target);
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
window.addEventListener('resize', function () { return _this.__throttledUpdate(); });
|
|
165
|
+
this.__fallbackUnlisten = function () {
|
|
166
|
+
return window.removeEventListener('resize', function () { return _this.__throttledUpdate(); });
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
catch (err) {
|
|
171
|
+
console.error('startResizeObserver error', err);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
ReactNodeView.prototype.stopResizeObserver = function () {
|
|
175
|
+
try {
|
|
176
|
+
if (this.__resizeObserver) {
|
|
177
|
+
this.__resizeObserver.disconnect();
|
|
178
|
+
this.__resizeObserver = undefined;
|
|
179
|
+
}
|
|
180
|
+
if (this.__resizeRafId) {
|
|
181
|
+
cancelAnimationFrame(this.__resizeRafId);
|
|
182
|
+
this.__resizeRafId = undefined;
|
|
183
|
+
}
|
|
184
|
+
if (this.__fallbackUnlisten) {
|
|
185
|
+
this.__fallbackUnlisten();
|
|
186
|
+
this.__fallbackUnlisten = undefined;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
catch (err) {
|
|
190
|
+
console.error('stopResizeObserver error', err);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
79
193
|
return ReactNodeView;
|
|
80
194
|
}(core_1.HtmlNode));
|
|
81
195
|
exports.ReactNodeView = ReactNodeView;
|
package/lib/view.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.js","sourceRoot":"","sources":["../src/view.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,+BAAkD;AAClD,2CAAmD;AAC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iB,EAAE,EAAxB,CAAwB,CAAC,CAAA;gBACjE,IAAI,CAAC,kBAAkB,GAAG;oBACxB,OAAA,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,cAAM,OAAA,KAAI,CAAC,iBAAiB,EAAE,EAAxB,CAAwB,CAAC;gBAApE,CAAoE,CAAA;YACxE,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAA;QACjD,CAAC;IACH,CAAC;IAEO,0CAAkB,GAA1B;QACE,IAAI,CAAC;YACH,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBAC1B,IAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,CAAA;gBAClC,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAA;YACnC,CAAC;YACD,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;gBACvB,oBAAoB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;gBACxC,IAAI,CAAC,aAAa,GAAG,SAAS,CAAA;YAChC,CAAC;YACD,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC;gBAC5B,IAAI,CAAC,kBAAkB,EAAE,CAAA;gBACzB,IAAI,CAAC,kBAAkB,GAAG,SAAS,CAAA;YACrC,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CAAC,0BAA0B,EAAE,GAAG,CAAC,CAAA;QAChD,CAAC;IACH,CAAC;IA4BH,oBAAC;AAAD,CAAC,AA3KD,CAAmC,eAAQ,GA2K1C;AA3KY,sCAAa;AA6K1B,kBAAe,aAAa,CAAA"}
|
package/lib/wrapper.d.ts
CHANGED
|
@@ -11,6 +11,6 @@ export declare class Wrapper extends PureComponent<IWrapperProps, IWrapperState>
|
|
|
11
11
|
constructor(props: IWrapperProps);
|
|
12
12
|
componentDidMount(): void;
|
|
13
13
|
clone(elem: React.ReactElement): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
14
|
-
render(): React.
|
|
14
|
+
render(): React.JSX.Element | null;
|
|
15
15
|
}
|
|
16
16
|
export default Wrapper;
|
package/lib/wrapper.js
CHANGED
|
@@ -37,11 +37,15 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
37
37
|
__setModuleDefault(result, mod);
|
|
38
38
|
return result;
|
|
39
39
|
};
|
|
40
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
41
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
42
|
+
};
|
|
40
43
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
44
|
exports.Wrapper = void 0;
|
|
42
45
|
var react_1 = __importStar(require("react"));
|
|
43
46
|
var core_1 = require("@logicflow/core");
|
|
44
47
|
var registry_1 = require("./registry");
|
|
48
|
+
var Container_1 = __importDefault(require("./components/Container"));
|
|
45
49
|
var Wrapper = /** @class */ (function (_super) {
|
|
46
50
|
__extends(Wrapper, _super);
|
|
47
51
|
function Wrapper(props) {
|
|
@@ -76,12 +80,13 @@ var Wrapper = /** @class */ (function (_super) {
|
|
|
76
80
|
var content = registry_1.reactNodesMap[node.type];
|
|
77
81
|
if (!content)
|
|
78
82
|
return null;
|
|
83
|
+
var _a = (node.properties || {})._showTitle, _showTitle = _a === void 0 ? false : _a;
|
|
79
84
|
var component = content.component;
|
|
80
85
|
if (react_1.default.isValidElement(component)) {
|
|
81
|
-
return this.clone(component);
|
|
86
|
+
return _showTitle ? (react_1.default.createElement(Container_1.default, { node: this.props.node, graph: this.props.graph }, this.clone(component))) : (this.clone(component));
|
|
82
87
|
}
|
|
83
88
|
var FC = component;
|
|
84
|
-
return this.clone(react_1.default.createElement(FC, null));
|
|
89
|
+
return _showTitle ? (react_1.default.createElement(Container_1.default, { node: this.props.node, graph: this.props.graph }, this.clone(react_1.default.createElement(FC, null)))) : (this.clone(react_1.default.createElement(FC, null)));
|
|
85
90
|
};
|
|
86
91
|
return Wrapper;
|
|
87
92
|
}(react_1.PureComponent));
|
package/lib/wrapper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../src/wrapper.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wrapper.js","sourceRoot":"","sources":["../src/wrapper.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA4C;AAC5C,wCAAsE;AACtE,uCAA0C;AAC1C,qEAA8C;AAW9C;IAA6B,2BAA2C;IACtE,iBAAY,KAAoB;QAC9B,YAAA,MAAK,YAAC,KAAK,CAAC,SAAA;QACZ,KAAI,CAAC,KAAK,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,CAAA;;IAC1B,CAAC;IAED,mCAAiB,GAAjB;QAAA,iBAgBC;QAfC,iCAAiC;QAC3B,IAAA,KAAkB,IAAI,CAAC,KAAK,EAA1B,IAAI,UAAA,EAAE,KAAK,WAAe,CAAA;QAClC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC,gBAAS,CAAC,sBAAsB,EAAE,UAAC,SAAS;YAC/D,IAAM,IAAI,GAAG,SAAS,CAAC,IAAgB,CAAA;YACvC,IAAM,OAAO,GAAG,wBAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAExC,IAAI,OAAO,IAAI,SAAS,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,EAAE,CAAC;gBAChC,IAAA,QAAM,GAAK,OAAO,OAAZ,CAAY;gBAE1B,4DAA4D;gBAC5D,IAAI,CAAC,QAAM,IAAI,IAAI,CAAC,IAAI,CAAC,UAAC,GAAG,IAAK,OAAA,QAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAApB,CAAoB,CAAC,EAAE,CAAC;oBACxD,KAAI,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAI,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC,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AI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,IACtD,IAAI,CAAC,KAAK,CAAC,8BAAC,EAAE,OAAG,CAAC,CACT,CACb,CAAC,CAAC,CAAC,CACF,IAAI,CAAC,KAAK,CAAC,8BAAC,EAAE,OAAG,CAAC,CACnB,CAAA;IACH,CAAC;IACH,cAAC;AAAD,CAAC,AA3DD,CAA6B,qBAAa,GA2DzC;AA3DY,0BAAO;AA6DpB,kBAAe,OAAO,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logicflow/react-node-registry",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "LogicFlow React Shape",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
7
|
-
"unpkg": "dist/index.js",
|
|
8
|
-
"
|
|
7
|
+
"unpkg": "dist/index.min.js",
|
|
8
|
+
"jsdelivr": "dist/index.min.js",
|
|
9
9
|
"types": "lib/index.d.ts",
|
|
10
10
|
"keywords": [
|
|
11
11
|
"@logicflow/react-node-registry",
|
|
@@ -18,16 +18,23 @@
|
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"react": ">= 18.0.0",
|
|
20
20
|
"react-dom": ">= 18.0.0",
|
|
21
|
-
"@logicflow/core": "2.2.
|
|
21
|
+
"@logicflow/core": "2.2.1"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
+
"lodash-es": "^4.17.21"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
24
27
|
"@types/react": "^18.0.25",
|
|
25
28
|
"@types/react-dom": "^18.0.9",
|
|
26
29
|
"react": "^18.0.0",
|
|
27
30
|
"react-dom": "^18.0.0",
|
|
28
|
-
"
|
|
29
|
-
"@logicflow/core": "2.2.0"
|
|
31
|
+
"@logicflow/core": "2.2.1"
|
|
30
32
|
},
|
|
33
|
+
"files": [
|
|
34
|
+
"dist",
|
|
35
|
+
"es",
|
|
36
|
+
"lib"
|
|
37
|
+
],
|
|
31
38
|
"scripts": {
|
|
32
39
|
"clean:turbo": "rss",
|
|
33
40
|
"clean:build": "rss",
|
package/.turbo/turbo-build.log
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
> @logicflow/react-node-registry@1.1.4 prebuild /Users/didi/Desktop/github/LogicFlow/packages/react-node-registry
|
|
3
|
-
> rss
|
|
4
|
-
|
|
5
|
-
> [prebuild] run-s -s clean:build
|
|
6
|
-
> [clean:build] rimraf dist es lib
|
|
7
|
-
|
|
8
|
-
> @logicflow/react-node-registry@1.1.4 build /Users/didi/Desktop/github/LogicFlow/packages/react-node-registry
|
|
9
|
-
> rss
|
|
10
|
-
|
|
11
|
-
> [build] run-p -s build:dev build:umd
|
|
12
|
-
> [build:umd] pnpm run --if-present build:less && rollup -c ../../rollup.config.js --bundleConfigAsCjs
|
|
13
|
-
> [build:dev] pnpm run --if-present build:less && run-p -s build:cjs build:esm
|
|
14
|
-
> [build:less] ./scripts/build-less
|
|
15
|
-
> [build:less] ./scripts/build-less
|
|
16
|
-
[36m
|
|
17
|
-
[1m./src/index.ts[22m → [1mdist/index.min.js[22m...[39m
|
|
18
|
-
+------------------------------------+
|
|
19
|
-
| |
|
|
20
|
-
| [32m[1mBundle Format:[22m[39m [33mumd[39m |
|
|
21
|
-
| [32m[1mBundle Name:[22m[39m [33mReactNodeRegistry[39m |
|
|
22
|
-
| [32m[1mExternal Globals:[22m[39m |
|
|
23
|
-
| [33m @logicflow/core: Core[39m |
|
|
24
|
-
| [33m react: React[39m |
|
|
25
|
-
| [33m react-dom: ReactDom[39m |
|
|
26
|
-
| |
|
|
27
|
-
| [32m[1mDestination:[22m[39m [33mdist/index.min.js[39m |
|
|
28
|
-
| [32m[1mBundle Size:[22m[39m [33m433 B[39m |
|
|
29
|
-
| [32m[1mMinified Size:[22m[39m [33m394 B[39m |
|
|
30
|
-
| [32m[1mGZipped Size:[22m[39m [33m208 B[39m |
|
|
31
|
-
| |
|
|
32
|
-
+------------------------------------+
|
|
33
|
-
[1m[33m(!) [plugin typescript] @rollup/plugin-typescript: Rollup requires that TypeScript produces ES Modules. Unfortunately your configuration specifies a "module" other than "esnext". Unless you know what you're doing, please change "module" to "esnext" in the target tsconfig.json file or plugin options.[39m[22m
|
|
34
|
-
[32mcreated [1mdist/index.min.js[22m in [1m5.3s[22m[39m
|
package/CHANGELOG.md
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
# @logicflow/react-node-registry
|
|
2
|
-
|
|
3
|
-
## 1.2.0
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- Updated dependencies
|
|
8
|
-
- @logicflow/core@2.2.0
|
|
9
|
-
|
|
10
|
-
## 1.1.4
|
|
11
|
-
|
|
12
|
-
### Patch Changes
|
|
13
|
-
|
|
14
|
-
- Updated dependencies
|
|
15
|
-
- @logicflow/core@2.1.4
|
|
16
|
-
|
|
17
|
-
## 1.1.3
|
|
18
|
-
|
|
19
|
-
### Patch Changes
|
|
20
|
-
|
|
21
|
-
- Updated dependencies
|
|
22
|
-
- @logicflow/core@2.1.3
|
|
23
|
-
|
|
24
|
-
## 1.1.2
|
|
25
|
-
|
|
26
|
-
### Patch Changes
|
|
27
|
-
|
|
28
|
-
- Updated dependencies
|
|
29
|
-
- @logicflow/core@2.1.2
|
|
30
|
-
|
|
31
|
-
## 1.1.1
|
|
32
|
-
|
|
33
|
-
### Patch Changes
|
|
34
|
-
|
|
35
|
-
- Updated dependencies
|
|
36
|
-
- @logicflow/core@2.1.1
|
|
37
|
-
|
|
38
|
-
## 1.1.0
|
|
39
|
-
|
|
40
|
-
### Patch Changes
|
|
41
|
-
|
|
42
|
-
- fix: 修复issue反馈的bug&支持小地图展示vue节点
|
|
43
|
-
|
|
44
|
-
## 1.0.18
|
|
45
|
-
|
|
46
|
-
### Patch Changes
|
|
47
|
-
|
|
48
|
-
- Updated dependencies
|
|
49
|
-
- @logicflow/core@2.0.16
|
|
50
|
-
|
|
51
|
-
## 1.0.17
|
|
52
|
-
|
|
53
|
-
### Patch Changes
|
|
54
|
-
|
|
55
|
-
- Updated dependencies
|
|
56
|
-
- @logicflow/core@2.0.15
|
|
57
|
-
|
|
58
|
-
## 1.0.16
|
|
59
|
-
|
|
60
|
-
### Patch Changes
|
|
61
|
-
|
|
62
|
-
- Updated dependencies
|
|
63
|
-
- @logicflow/core@2.0.14
|
|
64
|
-
|
|
65
|
-
## 1.0.15
|
|
66
|
-
|
|
67
|
-
### Patch Changes
|
|
68
|
-
|
|
69
|
-
- fix:(extension): 所有导出方式支持局部导出+修复相对路径导出问题 & 渐进连线+highlight优化
|
|
70
|
-
|
|
71
|
-
## 1.0.14
|
|
72
|
-
|
|
73
|
-
### Patch Changes
|
|
74
|
-
|
|
75
|
-
- Updated dependencies
|
|
76
|
-
- @logicflow/core@2.0.13
|
|
77
|
-
|
|
78
|
-
## 1.0.13
|
|
79
|
-
|
|
80
|
-
### Patch Changes
|
|
81
|
-
|
|
82
|
-
- Updated dependencies
|
|
83
|
-
- @logicflow/core@2.0.12
|
|
84
|
-
|
|
85
|
-
## 1.0.12
|
|
86
|
-
|
|
87
|
-
### Patch Changes
|
|
88
|
-
|
|
89
|
-
- Updated dependencies
|
|
90
|
-
- @logicflow/core@2.0.11
|
|
91
|
-
|
|
92
|
-
## 1.0.11
|
|
93
|
-
|
|
94
|
-
### Patch Changes
|
|
95
|
-
|
|
96
|
-
- fix: 修复issue反馈的bug
|
|
97
|
-
- Updated dependencies
|
|
98
|
-
- @logicflow/core@2.0.10
|
|
99
|
-
|
|
100
|
-
## 1.0.10
|
|
101
|
-
|
|
102
|
-
### Patch Changes
|
|
103
|
-
|
|
104
|
-
- Updated dependencies
|
|
105
|
-
- @logicflow/core@2.0.9
|
|
106
|
-
|
|
107
|
-
## 1.0.9
|
|
108
|
-
|
|
109
|
-
### Patch Changes
|
|
110
|
-
|
|
111
|
-
- release react/vue-node-registry
|
|
112
|
-
|
|
113
|
-
## 1.0.8
|
|
114
|
-
|
|
115
|
-
### Patch Changes
|
|
116
|
-
|
|
117
|
-
- Updated dependencies
|
|
118
|
-
- @logicflow/core@2.0.8
|
|
119
|
-
|
|
120
|
-
## 1.0.7
|
|
121
|
-
|
|
122
|
-
### Patch Changes
|
|
123
|
-
|
|
124
|
-
- fix: 修复一些问题
|
|
125
|
-
- fix: 修复一些问题
|
|
126
|
-
- fix: 修复文本拖拽不符合预期的问题 by ChangeSuger
|
|
127
|
-
- feat: 支持动态修改 Grid 的配置 by ChangeSuger
|
|
128
|
-
- fix: 修复 2.x 与 1.x 下相同的网格线宽,Grid 表现不一致的问题 by ChangeSuger
|
|
129
|
-
- fix: node:dnd-drag 增加事件数据 by HeatonZ
|
|
130
|
-
- fix(extension): 【dynamic-group】修复mousemove和isCollapsed相关问题 by wbccb
|
|
131
|
-
- fix: 修复 windows 系统 node20 环境下样式文件打包失败的问题 by ChangeSuger
|
|
132
|
-
- fix: 修复 node:dnd-drag 事件的类型检查问题 by ChangeSuger
|
|
133
|
-
- fix(example): 修复文档中vue3自定义组件不能正常显示bug by zkt2002
|
|
134
|
-
- fix(core): 在没有拖拽的情况下,Control组件突然销毁,不触发cancelDrag(#1926) by wbccb
|
|
135
|
-
- fix(core): 修复笔记本触摸板点击边事件失效 by wuchenguang1998
|
|
136
|
-
- feat(examples): 添加动画边demo by DymoneLewis
|
|
137
|
-
- fix(core): 类型定义 properties:change 改为 node:properties-change by HeatonZ
|
|
138
|
-
- feat: node-registry 自定义properties类型 by HeatonZ
|
|
139
|
-
- fix(core): 修复 polyline 与多边形节点的交点不正确的问题 by Yuan-ZW
|
|
140
|
-
- Updated dependencies
|
|
141
|
-
- @logicflow/core@2.0.7
|
|
142
|
-
|
|
143
|
-
## 1.0.6
|
|
144
|
-
|
|
145
|
-
### Patch Changes
|
|
146
|
-
|
|
147
|
-
- Release New Version
|
|
148
|
-
- Updated dependencies
|
|
149
|
-
- @logicflow/core@2.0.6
|
|
150
|
-
|
|
151
|
-
## 1.0.5
|
|
152
|
-
|
|
153
|
-
### Patch Changes
|
|
154
|
-
|
|
155
|
-
- Updated dependencies
|
|
156
|
-
- @logicflow/core@2.0.5
|
|
157
|
-
|
|
158
|
-
## 1.0.4
|
|
159
|
-
|
|
160
|
-
### Patch Changes
|
|
161
|
-
|
|
162
|
-
- Updated dependencies
|
|
163
|
-
- Updated dependencies
|
|
164
|
-
- @logicflow/core@2.0.4
|
|
165
|
-
|
|
166
|
-
## 1.0.3
|
|
167
|
-
|
|
168
|
-
### Patch Changes: Release 1.0.3 Version
|
|
169
|
-
|
|
170
|
-
- Updated dependencies
|
|
171
|
-
- @logicflow/core@2.0.3
|
|
172
|
-
|
|
173
|
-
## 1.0.2
|
|
174
|
-
|
|
175
|
-
### Patch Changes
|
|
176
|
-
|
|
177
|
-
- Release New Version,移除多余 console
|
|
178
|
-
|
|
179
|
-
- Updated dependencies
|
|
180
|
-
- @logicflow/core@2.0.2
|
|
181
|
-
|
|
182
|
-
## 1.0.1
|
|
183
|
-
|
|
184
|
-
### Patch Changes
|
|
185
|
-
|
|
186
|
-
- Updated dependencies
|
|
187
|
-
- @logicflow/core@2.0.1
|
|
188
|
-
|
|
189
|
-
## 1.0.0
|
|
190
|
-
|
|
191
|
-
### Patch Changes
|
|
192
|
-
|
|
193
|
-
- Release 2.0 New Version 🎉🎉🎉🎉
|
|
194
|
-
- Updated dependencies
|
|
195
|
-
|
|
196
|
-
- @logicflow/core@2.0.0
|
|
197
|
-
|
|
198
|
-
- feat: 开发 react-node-registry 包用于用户自定义 react 节点
|
|
199
|
-
- 通过监听 properties 变化的事件,触发节点的更新
|
|
200
|
-
- 通过 Portal 的方式,可以获取到宿主系统的数据(比如状态),保持组件渲染和系统同步
|
|
201
|
-
- react-node-registry 包增加 LICENSE 文件
|
package/src/index.ts
DELETED
package/src/model.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import LogicFlow, { HtmlNodeModel, IHtmlNodeProperties } from '@logicflow/core'
|
|
2
|
-
import { cloneDeep } from 'lodash-es'
|
|
3
|
-
|
|
4
|
-
export interface ReactCustomProperties extends IHtmlNodeProperties {
|
|
5
|
-
// 形状属性
|
|
6
|
-
width?: number
|
|
7
|
-
height?: number
|
|
8
|
-
radius?: number
|
|
9
|
-
|
|
10
|
-
// 文字位置属性
|
|
11
|
-
refX?: number
|
|
12
|
-
refY?: number
|
|
13
|
-
|
|
14
|
-
// 样式属性
|
|
15
|
-
style?: LogicFlow.CommonTheme
|
|
16
|
-
textStyle?: LogicFlow.TextNodeTheme
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export class ReactNodeModel<
|
|
20
|
-
P extends ReactCustomProperties = ReactCustomProperties,
|
|
21
|
-
> extends HtmlNodeModel<P> {
|
|
22
|
-
setAttributes() {
|
|
23
|
-
const { width, height, radius } = this.properties
|
|
24
|
-
if (width) {
|
|
25
|
-
this.width = width
|
|
26
|
-
}
|
|
27
|
-
if (height) {
|
|
28
|
-
this.height = height
|
|
29
|
-
}
|
|
30
|
-
if (radius) {
|
|
31
|
-
this.radius = radius
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
getTextStyle(): LogicFlow.TextNodeTheme {
|
|
36
|
-
// const { x, y, width, height } = this
|
|
37
|
-
const { refX = 0, refY = 0, textStyle } = this.properties
|
|
38
|
-
const style = super.getTextStyle()
|
|
39
|
-
|
|
40
|
-
// 通过 transform 重新设置 text 的位置
|
|
41
|
-
return {
|
|
42
|
-
...style,
|
|
43
|
-
...(cloneDeep(textStyle) || {}),
|
|
44
|
-
transform: `matrix(1 0 0 1 ${refX} ${refY})`,
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
getNodeStyle(): LogicFlow.CommonTheme {
|
|
49
|
-
const style = super.getNodeStyle()
|
|
50
|
-
const {
|
|
51
|
-
style: customNodeStyle,
|
|
52
|
-
// radius = 0, // 第二种方式,设置圆角
|
|
53
|
-
} = this.properties
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
...style,
|
|
57
|
-
...(cloneDeep(customNodeStyle) || {}),
|
|
58
|
-
// rx: radius,
|
|
59
|
-
// ry: radius,
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export default ReactNodeModel
|
package/src/portal.ts
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import React, { useReducer } from 'react'
|
|
2
|
-
|
|
3
|
-
export namespace Portal {
|
|
4
|
-
let active = false
|
|
5
|
-
let dispatch: React.Dispatch<Action>
|
|
6
|
-
|
|
7
|
-
interface Action {
|
|
8
|
-
type: 'add' | 'remove'
|
|
9
|
-
payload: Partial<Payload>
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface Payload {
|
|
13
|
-
id: string
|
|
14
|
-
portal: React.ReactPortal
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const reducer = (state: Payload[], action: Action) => {
|
|
18
|
-
const payload = action.payload as Payload
|
|
19
|
-
switch (action.type) {
|
|
20
|
-
case 'add': {
|
|
21
|
-
const index = state.findIndex((item) => item.id === payload.id)
|
|
22
|
-
if (index >= 0) {
|
|
23
|
-
state[index] = payload
|
|
24
|
-
return [...state]
|
|
25
|
-
}
|
|
26
|
-
return [...state, payload]
|
|
27
|
-
}
|
|
28
|
-
case 'remove': {
|
|
29
|
-
const index = state.findIndex((item) => item.id === payload.id)
|
|
30
|
-
if (index >= 0) {
|
|
31
|
-
const result = [...state]
|
|
32
|
-
result.splice(index, 1)
|
|
33
|
-
return result
|
|
34
|
-
}
|
|
35
|
-
break
|
|
36
|
-
}
|
|
37
|
-
default: {
|
|
38
|
-
break
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return state
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function connect(id: string, portal: React.ReactPortal) {
|
|
45
|
-
if (active) {
|
|
46
|
-
dispatch({
|
|
47
|
-
type: 'add',
|
|
48
|
-
payload: {
|
|
49
|
-
id,
|
|
50
|
-
portal,
|
|
51
|
-
},
|
|
52
|
-
})
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function disconnect(id: string) {
|
|
57
|
-
if (active) {
|
|
58
|
-
dispatch({
|
|
59
|
-
type: 'remove',
|
|
60
|
-
payload: { id },
|
|
61
|
-
})
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export function isActive() {
|
|
66
|
-
return active
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export function getProvider() {
|
|
70
|
-
return () => {
|
|
71
|
-
active = true
|
|
72
|
-
const [items, mutate] = useReducer(reducer, [])
|
|
73
|
-
dispatch = mutate
|
|
74
|
-
return React.createElement(React.Fragment, {
|
|
75
|
-
children: items.map((item) => item.portal),
|
|
76
|
-
})
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|