@logicflow/vue-node-registry 1.2.0-alpha.2 → 1.2.0-alpha.3

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.
Files changed (59) hide show
  1. package/.turbo/turbo-build$colon$dev.log +2 -2
  2. package/.turbo/turbo-build.log +4 -4
  3. package/CHANGELOG.md +8 -0
  4. package/dist/index.css +122 -0
  5. package/es/components/container.d.ts +19 -0
  6. package/es/components/container.js +27 -0
  7. package/es/components/container.js.map +1 -0
  8. package/es/components/titleBar.d.ts +24 -0
  9. package/es/components/titleBar.js +160 -0
  10. package/es/components/titleBar.js.map +1 -0
  11. package/es/index.css +122 -0
  12. package/es/index.less +1 -0
  13. package/es/model.d.ts +18 -1
  14. package/es/model.js +45 -5
  15. package/es/model.js.map +1 -1
  16. package/es/style/index.css +122 -0
  17. package/es/style/index.less +140 -0
  18. package/es/style/raw.d.ts +4 -0
  19. package/es/style/raw.js +6 -0
  20. package/es/style/raw.js.map +1 -0
  21. package/es/utils/size.d.ts +2 -0
  22. package/es/utils/size.js +14 -0
  23. package/es/utils/size.js.map +1 -0
  24. package/es/view.d.ts +9 -0
  25. package/es/view.js +137 -12
  26. package/es/view.js.map +1 -1
  27. package/lib/components/container.d.ts +19 -0
  28. package/lib/components/container.js +30 -0
  29. package/lib/components/container.js.map +1 -0
  30. package/lib/components/titleBar.d.ts +24 -0
  31. package/lib/components/titleBar.js +163 -0
  32. package/lib/components/titleBar.js.map +1 -0
  33. package/lib/index.css +122 -0
  34. package/lib/index.less +1 -0
  35. package/lib/model.d.ts +18 -1
  36. package/lib/model.js +43 -3
  37. package/lib/model.js.map +1 -1
  38. package/lib/style/index.css +122 -0
  39. package/lib/style/index.less +140 -0
  40. package/lib/style/raw.d.ts +4 -0
  41. package/lib/style/raw.js +9 -0
  42. package/lib/style/raw.js.map +1 -0
  43. package/lib/utils/size.d.ts +2 -0
  44. package/lib/utils/size.js +19 -0
  45. package/lib/utils/size.js.map +1 -0
  46. package/lib/view.d.ts +9 -0
  47. package/lib/view.js +136 -11
  48. package/lib/view.js.map +1 -1
  49. package/package.json +3 -3
  50. package/rollup.config.js +52 -0
  51. package/src/assets/arrow.svg +10 -0
  52. package/src/components/container.ts +36 -0
  53. package/src/components/titleBar.ts +189 -0
  54. package/src/index.less +1 -0
  55. package/src/model.ts +81 -3
  56. package/src/style/index.less +140 -0
  57. package/src/style/raw.ts +129 -0
  58. package/src/utils/size.ts +22 -0
  59. package/src/view.ts +138 -10
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ /* eslint-disable */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.content = void 0;
5
+ /**
6
+ * Auto generated file, do not modify it!
7
+ */
8
+ exports.content = ".lf-vue-node-container {\n position: relative;\n display: flex;\n flex-direction: column;\n box-sizing: border-box;\n padding: 6px;\n color: #474747;\n border-radius: 12px;\n box-shadow: 0 0 10px #cad2e15f;\n}\n.lf-vue-node-content-wrap {\n display: flex;\n flex: 1 1 auto;\n justify-content: center;\n}\n.lf-vue-node-title {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n box-sizing: border-box;\n margin-bottom: 4px;\n padding: 0 8px;\n backdrop-filter: saturate(180%) blur(4px);\n}\n.lf-vue-node-title-expanded {\n margin-bottom: 6px;\n padding-bottom: 8px;\n border-bottom: 1px solid #eaeaea;\n}\n@supports not (backdrop-filter: blur(1px)) {\n .lf-vue-node-title {\n backdrop-filter: none;\n }\n}\n.lf-vue-node-title-left {\n display: flex;\n gap: 6px;\n align-items: center;\n min-width: 0;\n}\n.lf-vue-node-title-icon {\n display: inline-block;\n width: 16px;\n height: 16px;\n color: #666;\n font-style: normal;\n line-height: 16px;\n text-align: center;\n}\n.lf-vue-node-title-text {\n overflow: hidden;\n color: #333;\n font-weight: 500;\n font-size: 14px;\n white-space: nowrap;\n text-overflow: ellipsis;\n}\n.lf-vue-node-title-actions {\n display: flex;\n gap: 6px;\n align-items: center;\n}\n.lf-vue-node-title-expand,\n.lf-vue-node-title-more {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 20px;\n height: 20px;\n padding: 2px;\n background: transparent;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n transition: background 0.15s ease;\n appearance: none;\n}\n.lf-vue-node-title-expand:hover,\n.lf-vue-node-title-more:hover {\n background: rgba(0, 0, 0, 0.06);\n}\n.lf-vue-node-title-expand-icon {\n color: #666;\n font-style: normal;\n transition: transform 0.3s ease;\n}\n.lf-vue-node-title-more-icon {\n color: #666;\n font-style: normal;\n}\n.lf-vue-node-title-tooltip {\n position: absolute;\n top: -50px;\n right: -135px;\n min-width: 120px;\n max-width: 240px;\n padding: 6px 8px;\n background: #fff;\n border: 1px solid rgba(0, 0, 0, 0.1);\n border-radius: 6px;\n box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);\n transform: translateY(calc(100% + 4px));\n transition: opacity 0.15s ease, transform 0.15s ease;\n}\n.lf-vue-node-title-tooltip-list {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n.lf-vue-node-title-tooltip-item {\n display: flex;\n align-items: center;\n justify-content: flex-start;\n padding: 6px;\n color: #333;\n font-size: 12px;\n border-radius: 4px;\n cursor: pointer;\n}\n.lf-vue-node-title-tooltip-item:hover {\n background: rgba(0, 0, 0, 0.05);\n}\n";
9
+ //# sourceMappingURL=raw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"raw.js","sourceRoot":"","sources":["../../src/style/raw.ts"],"names":[],"mappings":";AAAA,oBAAoB;;;AAEpB;;GAEG;AAEU,QAAA,OAAO,GAAG,unFA0HtB,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare function computeBaseHeight(measuredHeight: number, _showTitle?: boolean, _titleHeight?: number): number;
2
+ export declare function shouldUpdateSize(prevW?: number, prevH?: number, w?: number, h?: number): boolean;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.shouldUpdateSize = exports.computeBaseHeight = void 0;
4
+ function computeBaseHeight(measuredHeight, _showTitle, _titleHeight) {
5
+ var extra = _showTitle
6
+ ? typeof _titleHeight === 'number'
7
+ ? _titleHeight
8
+ : 28
9
+ : 0;
10
+ return Math.max(1, Math.round(measuredHeight) - extra);
11
+ }
12
+ exports.computeBaseHeight = computeBaseHeight;
13
+ function shouldUpdateSize(prevW, prevH, w, h) {
14
+ if (!w || !h)
15
+ return false;
16
+ return !(prevW === Math.round(w) && prevH === Math.round(h));
17
+ }
18
+ exports.shouldUpdateSize = shouldUpdateSize;
19
+ //# sourceMappingURL=size.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"size.js","sourceRoot":"","sources":["../../src/utils/size.ts"],"names":[],"mappings":";;;AAAA,SAAgB,iBAAiB,CAC/B,cAAsB,EACtB,UAAoB,EACpB,YAAqB;IAErB,IAAM,KAAK,GAAG,UAAU;QACtB,CAAC,CAAC,OAAO,YAAY,KAAK,QAAQ;YAChC,CAAC,CAAC,YAAY;YACd,CAAC,CAAC,EAAE;QACN,CAAC,CAAC,CAAC,CAAA;IACL,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,KAAK,CAAC,CAAA;AACxD,CAAC;AAXD,8CAWC;AAED,SAAgB,gBAAgB,CAC9B,KAAc,EACd,KAAc,EACd,CAAU,EACV,CAAU;IAEV,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,CAAA;IAC1B,OAAO,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;AAC9D,CAAC;AARD,4CAQC"}
package/lib/view.d.ts CHANGED
@@ -2,12 +2,21 @@ import { HtmlNode } from '@logicflow/core';
2
2
  export declare class VueNodeView extends HtmlNode {
3
3
  root?: any;
4
4
  private vm;
5
+ private __resizeObserver?;
6
+ private __resizeRafId?;
7
+ private __lastWidth?;
8
+ private __lastHeight?;
9
+ private __fallbackUnlisten?;
10
+ private __throttledUpdate;
5
11
  getComponentContainer(): any;
6
12
  protected targetId(): string;
7
13
  componentWillUnmount(): void;
8
14
  setHtml(rootEl: SVGForeignObjectElement): void;
9
15
  confirmUpdate(_rootEl: SVGForeignObjectElement): void;
10
16
  protected renderVueComponent(): void;
17
+ private measureAndUpdate;
18
+ private startResizeObserver;
19
+ private stopResizeObserver;
11
20
  protected unmountVueComponent(): any;
12
21
  unmount(): void;
13
22
  }
package/lib/view.js CHANGED
@@ -17,14 +17,50 @@ var __extends = (this && this.__extends) || (function () {
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.VueNodeView = void 0;
19
19
  var vue_demi_1 = require("vue-demi");
20
+ // Vue2/3 兼容 API;使用 vue-demi 保持两端一致
21
+ var lodash_es_1 = require("lodash-es");
20
22
  var core_1 = require("@logicflow/core");
21
23
  var registry_1 = require("./registry");
22
24
  var teleport_1 = require("./teleport");
25
+ var container_1 = require("./components/container");
23
26
  var VueNodeView = /** @class */ (function (_super) {
24
27
  __extends(VueNodeView, _super);
25
28
  function VueNodeView() {
26
- return _super !== null && _super.apply(this, arguments) || this;
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
+ // 读取子组件(或容器本身)的实际尺寸并更新模型属性
34
+ var root = _this.getComponentContainer();
35
+ if (!root)
36
+ return;
37
+ var target = root.firstElementChild || root;
38
+ var rect = target.getBoundingClientRect();
39
+ var width = (0, lodash_es_1.round)(rect.width);
40
+ var height = (0, lodash_es_1.round)(rect.height);
41
+ if (width <= 0 || height <= 0)
42
+ return;
43
+ if (width === _this.__lastWidth && height === _this.__lastHeight)
44
+ return;
45
+ _this.__lastWidth = width;
46
+ _this.__lastHeight = height;
47
+ var props = _this.props.model.properties;
48
+ var extra = (0, lodash_es_1.get)(props, '_showTitle')
49
+ ? (0, lodash_es_1.isNumber)((0, lodash_es_1.get)(props, '_titleHeight'))
50
+ ? (0, lodash_es_1.get)(props, '_titleHeight')
51
+ : 28
52
+ : 0;
53
+ // 去掉标题占用的高度,保证内容区域与模型高度一致
54
+ var baseHeight = (0, lodash_es_1.clamp)(height - extra, 1, Number.MAX_SAFE_INTEGER);
55
+ _this.props.model.setProperties({ width: width, height: baseHeight });
56
+ }
57
+ catch (err) {
58
+ // swallow error
59
+ }
60
+ };
61
+ return _this;
27
62
  }
63
+ // private isMounted: boolean = false
28
64
  VueNodeView.prototype.getComponentContainer = function () {
29
65
  return this.root;
30
66
  };
@@ -36,31 +72,61 @@ var VueNodeView = /** @class */ (function (_super) {
36
72
  this.unmount();
37
73
  };
38
74
  VueNodeView.prototype.setHtml = function (rootEl) {
39
- var el = document.createElement('div');
40
- el.className = 'custom-vue-node-content';
41
- this.root = el;
42
- rootEl.appendChild(el);
75
+ // 创建节点内容容器并注入到 foreignObject(若已存在则复用)
76
+ var existed = rootEl.querySelector('.custom-vue-node-content');
77
+ if (!existed) {
78
+ var el = document.createElement('div');
79
+ el.className = 'custom-vue-node-content';
80
+ this.root = el;
81
+ rootEl.appendChild(el);
82
+ }
83
+ // 渲染 Vue 组件并启用尺寸监听
43
84
  this.renderVueComponent();
85
+ this.startResizeObserver();
44
86
  };
45
87
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
46
88
  VueNodeView.prototype.confirmUpdate = function (_rootEl) {
47
89
  // TODO: 如有需要,可以先通过继承的方式,自定义该节点的更新逻辑;我们后续会根据实际需求,丰富该功能
48
- // console.log('_rootEl', _rootEl)
90
+ var model = this.props.model;
91
+ var _a = (model.properties || {})._showTitle, _showTitle = _a === void 0 ? false : _a;
92
+ if (_showTitle) {
93
+ this.setHtml(_rootEl);
94
+ }
49
95
  };
50
96
  VueNodeView.prototype.renderVueComponent = function () {
51
97
  var _a;
52
98
  this.unmountVueComponent();
53
99
  var root = this.getComponentContainer();
54
100
  var _b = this.props, model = _b.model, graphModel = _b.graphModel;
101
+ var _c = (model.properties || {})._showTitle, _showTitle = _c === void 0 ? false : _c;
102
+ var wrapWithContainer = function (child) {
103
+ return (0, vue_demi_1.defineComponent)({
104
+ name: 'LFVueNodeContainerWrapper',
105
+ props: {
106
+ node: { type: Object, required: true },
107
+ graph: { type: Object, required: true },
108
+ },
109
+ render: function () {
110
+ // 根据 _showTitle 决定是否用 Container 包裹,避免无标题时额外结构
111
+ if (!_showTitle) {
112
+ return (0, vue_demi_1.h)(child, { node: this.node, graph: this.graph });
113
+ }
114
+ return (0, vue_demi_1.h)(container_1.Container, { node: this.node, graph: this.graph }, [
115
+ (0, vue_demi_1.h)(child, { node: this.node, graph: this.graph }),
116
+ ]);
117
+ },
118
+ });
119
+ };
55
120
  if (root) {
56
- var component_1 = registry_1.vueNodesMap[model.type].component;
57
- if (component_1) {
121
+ var component = registry_1.vueNodesMap[model.type].component;
122
+ if (component) {
58
123
  if (vue_demi_1.isVue2) {
59
124
  var Vue = vue_demi_1.Vue2;
125
+ var Composed_1 = wrapWithContainer(component);
60
126
  this.vm = new Vue({
61
127
  el: root,
62
128
  render: function (h) {
63
- return h(component_1, {
129
+ return h(Composed_1, {
64
130
  node: model,
65
131
  graph: graphModel,
66
132
  });
@@ -74,13 +140,16 @@ var VueNodeView = /** @class */ (function (_super) {
74
140
  });
75
141
  }
76
142
  else if (vue_demi_1.isVue3) {
143
+ console.log('isActive', (0, teleport_1.isActive)());
77
144
  if ((0, teleport_1.isActive)()) {
78
- (0, teleport_1.connect)(this.targetId(), component_1, root, model, graphModel);
145
+ var Composed = wrapWithContainer(component);
146
+ (0, teleport_1.connect)(this.targetId(), Composed, root, model, graphModel);
79
147
  }
80
148
  else {
149
+ var Composed_2 = wrapWithContainer(component);
81
150
  this.vm = (0, vue_demi_1.createApp)({
82
151
  render: function () {
83
- return (0, vue_demi_1.h)(component_1, {
152
+ return (0, vue_demi_1.h)(Composed_2, {
84
153
  node: model,
85
154
  graph: graphModel,
86
155
  });
@@ -93,13 +162,68 @@ var VueNodeView = /** @class */ (function (_super) {
93
162
  },
94
163
  });
95
164
  (_a = this.vm) === null || _a === void 0 ? void 0 : _a.mount(root);
165
+ // this.isMounted = true
96
166
  }
97
167
  }
98
168
  }
99
169
  }
100
170
  };
171
+ VueNodeView.prototype.startResizeObserver = function () {
172
+ var _this = this;
173
+ var _a;
174
+ // 启动尺寸监听:优先使用 ResizeObserver,退化到 window.resize
175
+ var root = this.getComponentContainer();
176
+ if (!root)
177
+ return;
178
+ try {
179
+ if ((0, lodash_es_1.isFunction)(window.ResizeObserver)) {
180
+ this.__resizeObserver = new window.ResizeObserver(function (entries) {
181
+ if (!(0, lodash_es_1.isArray)(entries) || !entries.length)
182
+ return;
183
+ if (_this.__resizeRafId)
184
+ cancelAnimationFrame(_this.__resizeRafId);
185
+ // 使用 RAF 对齐绘制帧,再用节流函数合并频繁变更
186
+ _this.__resizeRafId = requestAnimationFrame(_this.__throttledUpdate);
187
+ });
188
+ var target = root.firstElementChild || root;
189
+ (_a = this.__resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(target);
190
+ }
191
+ else {
192
+ // 退化监听:在窗口尺寸变化时尝试更新
193
+ window.addEventListener('resize', function () { return _this.__throttledUpdate(); });
194
+ this.__fallbackUnlisten = function () {
195
+ return window.removeEventListener('resize', function () { return _this.__throttledUpdate(); });
196
+ };
197
+ }
198
+ }
199
+ catch (err) {
200
+ // swallow error
201
+ }
202
+ };
203
+ VueNodeView.prototype.stopResizeObserver = function () {
204
+ try {
205
+ // 停止所有监听与异步回调,避免内存泄漏
206
+ if (this.__resizeObserver) {
207
+ this.__resizeObserver.disconnect();
208
+ this.__resizeObserver = undefined;
209
+ }
210
+ if (this.__resizeRafId) {
211
+ cancelAnimationFrame(this.__resizeRafId);
212
+ this.__resizeRafId = undefined;
213
+ }
214
+ if (this.__fallbackUnlisten) {
215
+ this.__fallbackUnlisten();
216
+ this.__fallbackUnlisten = undefined;
217
+ }
218
+ }
219
+ catch (err) {
220
+ // swallow error
221
+ }
222
+ };
101
223
  VueNodeView.prototype.unmountVueComponent = function () {
102
224
  var root = this.getComponentContainer();
225
+ // 在卸载 Vue 实例前先停止尺寸监听
226
+ this.stopResizeObserver();
103
227
  if (this.vm) {
104
228
  vue_demi_1.isVue2 && this.vm.$destroy();
105
229
  vue_demi_1.isVue3 && this.vm.unmount();
@@ -111,6 +235,7 @@ var VueNodeView = /** @class */ (function (_super) {
111
235
  return root;
112
236
  };
113
237
  VueNodeView.prototype.unmount = function () {
238
+ // Teleport 模式下断开连接,并清理视图与监听
114
239
  if ((0, teleport_1.isActive)()) {
115
240
  (0, teleport_1.disconnect)(this.targetId(), this.props.graphModel.flowId);
116
241
  }
package/lib/view.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"view.js","sourceRoot":"","sources":["../src/view.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,qCAA6D;AAC7D,wCAA0C;AAC1C,uCAAwC;AACxC,uCAA0D;AAE1D;IAAiC,+BAAQ;IAAzC;;IAqGA,CAAC;IAjGC,2CAAqB,GAArB;QACE,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;IAES,8BAAQ,GAAlB;QACE,OAAO,UAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,cAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAE,CAAA;IACjE,CAAC;IAED,0CAAoB,GAApB;QACE,gBAAK,CAAC,oBAAoB,WAAE,CAAA;QAC5B,IAAI,CAAC,OAAO,EAAE,CAAA;IAChB,CAAC;IAED,6BAAO,GAAP,UAAQ,MAA+B;QACrC,IAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;QACxC,EAAE,CAAC,SAAS,GAAG,yBAAyB,CAAA;QACxC,IAAI,CAAC,IAAI,GAAG,EAAE,CAAA;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AAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAA;YAC5B,iBAAM,IAAI,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,CAAA;YAC3B,IAAI,CAAC,EAAE,GAAG,IAAI,CAAA;QAChB,CAAC;QACD,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,SAAS,GAAG,EAAE,CAAA;QACrB,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,6BAAO,GAAP;QACE,4BAA4B;QAC5B,IAAI,IAAA,mBAAQ,GAAE,EAAE,CAAC;YACf,IAAA,qBAAU,EAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,MAAgB,CAAC,CAAA;QACrE,CAAC;QACD,IAAI,CAAC,mBAAmB,EAAE,CAAA;IAC5B,CAAC;IACH,kBAAC;AAAD,CAAC,AA1ND,CAAiC,eAAQ,GA0NxC;AA1NY,kCAAW;AA4NxB,kBAAe,WAAW,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logicflow/vue-node-registry",
3
- "version": "1.2.0-alpha.2",
3
+ "version": "1.2.0-alpha.3",
4
4
  "description": "LogicFlow Vue Component Node Registry",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -20,7 +20,7 @@
20
20
  "peerDependencies": {
21
21
  "@vue/composition-api": "^1.0.0-rc.10",
22
22
  "vue": "^2.0.0 || >=3.0.0",
23
- "@logicflow/core": "2.2.0-alpha.2"
23
+ "@logicflow/core": "2.2.0-alpha.3"
24
24
  },
25
25
  "peerDependenciesMeta": {
26
26
  "@vue/composition-api": {
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "devDependencies": {
31
31
  "vue": "^3.0.0",
32
- "@logicflow/core": "2.2.0-alpha.2"
32
+ "@logicflow/core": "2.2.0-alpha.3"
33
33
  },
34
34
  "author": {
35
35
  "name": "boyongjiong",
@@ -0,0 +1,52 @@
1
+ import path from 'node:path'
2
+ import postcss from 'rollup-plugin-postcss'
3
+ import postcssUrl from 'postcss-url'
4
+ import postcssImport from 'postcss-import'
5
+ import { rollupConfig } from '../../rollup.config'
6
+
7
+ export default [
8
+ {
9
+ input: 'src/index.less',
10
+ output: [
11
+ {
12
+ file: 'dist/index.css',
13
+ },
14
+ {
15
+ file: 'lib/index.css',
16
+ },
17
+ {
18
+ file: 'lib/style/index.css',
19
+ },
20
+ {
21
+ file: 'es/index.css',
22
+ },
23
+ {
24
+ file: 'es/style/index.css',
25
+ },
26
+ ],
27
+ plugins: [
28
+ postcss({
29
+ plugins: [
30
+ postcssImport({
31
+ resolve: (id) => {
32
+ if (id.startsWith('~')) {
33
+ return path.resolve('node_modules', id.slice(1))
34
+ }
35
+ return id
36
+ },
37
+ }),
38
+ postcssUrl({
39
+ url: 'inline', // 选择 'inline' 选项将外部资源内联到最终的 CSS 文件中
40
+ // maxSize: 10, // 以KB为单位的最大文件大小,超过此大小的文件将不会被内联
41
+ }),
42
+ ],
43
+ use: [['less', { javascriptEnabled: true }]],
44
+ extract: true,
45
+ // extract: 'index.css', // 提取到一个单独的 CSS 文件
46
+ // extract: path.resolve('dist/index.css'), // 提取到一个单独的 CSS 文件
47
+ minimize: true,
48
+ }),
49
+ ],
50
+ },
51
+ rollupConfig(),
52
+ ]
@@ -0,0 +1,10 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="14" height="12.5" viewBox="0 0 14 12.5">
2
+ <g>
3
+ <g>
4
+ <path d="M0.5201124,5.47988755C0.23603013,5.7639699,0.24460429,6.2271326,0.53900635,6.5005059L6.3195491,11.8681526C6.7032304,12.2244282,7.2967696,12.2244282,7.6804514,11.8681526L13.460994,6.5005059C13.755396,6.2271326,13.76397,5.7639699,13.479888,5.47988755C13.211547,5.21154633,12.779465,5.20215771,12.499721,5.45858961L7.3378625,10.1902928C7.1467018,10.3655233,6.8532982,10.3655233,6.6621375,10.1902928L1.5002797,5.45858967C1.2205358,5.20215771,0.78845364,5.21154633,0.5201124,5.47988755Z" fill="#474747" fill-opacity="1"/>
5
+ </g>
6
+ <g>
7
+ <path d="M0.5201124,0.47988755C0.23603013,0.7639699,0.24460429,1.2271326,0.53900635,1.5005059L6.3195491,6.8681526C6.7032304,7.2244282,7.2967696,7.2244282,7.6804514,6.8681526L13.460994,1.5005059C13.755396,1.2271326,13.76397,0.7639699,13.479888,0.47988755C13.211547,0.21154633,12.779465,0.20215771,12.499721,0.45858961L7.3378625,5.1902928C7.1467018,5.3655233,6.8532982,5.3655233,6.6621375,5.1902928L1.5002797,0.45858967C1.2205358,0.20215771,0.78845364,0.21154633,0.5201124,0.47988755Z" fill="#9B9B9B" fill-opacity="1"/>
8
+ </g>
9
+ </g>
10
+ </svg>
@@ -0,0 +1,36 @@
1
+ import { defineComponent, h } from 'vue-demi'
2
+ import { TitleBar } from './titleBar'
3
+
4
+ export const Container = defineComponent({
5
+ name: 'LFVueNodeContainer',
6
+ props: {
7
+ node: { type: Object, required: true },
8
+ graph: { type: Object, required: true },
9
+ },
10
+ render(this: any) {
11
+ const props = this.node?.properties || {}
12
+ const children: any[] = []
13
+ const titleColor = props.style.titleColor || '#E5EEFC'
14
+ if (props._showTitle) {
15
+ children.push(h(TitleBar, { node: this.node, graph: this.graph }))
16
+ }
17
+ console.log('props._expanded', props._expanded)
18
+ if (props._expanded === true) {
19
+ children.push(
20
+ h(
21
+ 'div',
22
+ { class: 'lf-vue-node-content-wrap' },
23
+ this.$slots?.default ? this.$slots.default() : [],
24
+ ),
25
+ )
26
+ }
27
+ return h(
28
+ 'div',
29
+ {
30
+ class: 'lf-vue-node-container',
31
+ style: ` background: linear-gradient(180deg, ${titleColor} 0%, #FFFFFF 24px)`,
32
+ },
33
+ children,
34
+ )
35
+ },
36
+ })
@@ -0,0 +1,189 @@
1
+ import { defineComponent, h } from 'vue-demi'
2
+ import { isNumber, isEmpty } from 'lodash-es'
3
+
4
+ export const TitleBar = defineComponent({
5
+ name: 'LFVueNodeTitleBar',
6
+ props: {
7
+ node: { type: Object, required: true },
8
+ graph: { type: Object, required: true },
9
+ },
10
+ data() {
11
+ return {
12
+ showTooltip: false as boolean,
13
+ }
14
+ },
15
+ mounted() {
16
+ const trigger =
17
+ (this as any).node?.properties?.titleTrigger === 'hover'
18
+ ? 'hover'
19
+ : 'click'
20
+ const moreBtn: HTMLElement | null = (this.$refs as any).moreBtn || null
21
+ const tooltip: HTMLElement | null = (this.$refs as any).tooltip || null
22
+ const onDoc = (e: MouseEvent) => {
23
+ if (!tooltip || !moreBtn) return
24
+ const t = e.target as Node
25
+ if (this.showTooltip && !tooltip.contains(t) && !moreBtn.contains(t)) {
26
+ this.showTooltip = false
27
+ }
28
+ }
29
+ if (trigger === 'hover' && moreBtn && tooltip) {
30
+ moreBtn.addEventListener('mouseenter', () => {
31
+ this.showTooltip = true
32
+ })
33
+ moreBtn.addEventListener('mouseleave', () => {
34
+ this.showTooltip = false
35
+ })
36
+ } else if (trigger === 'click' && moreBtn) {
37
+ moreBtn.addEventListener('click', (e) => {
38
+ e.stopPropagation()
39
+ this.showTooltip = !this.showTooltip
40
+ })
41
+ document.addEventListener('click', onDoc)
42
+ ;(this as any).$once &&
43
+ (this as any).$once('hook:beforeDestroy', () => {
44
+ document.removeEventListener('click', onDoc)
45
+ })
46
+ }
47
+ },
48
+ methods: {
49
+ toggleExpand() {
50
+ const cur = !!this.node?.properties?._expanded
51
+ this.node?.setProperty('_expanded', !cur)
52
+ },
53
+ runAction(act: any) {
54
+ try {
55
+ typeof act?.callback === 'function' &&
56
+ act.callback((this as any).node, (this as any).graph)
57
+ } finally {
58
+ this.showTooltip = false
59
+ }
60
+ },
61
+ },
62
+ render(this: any) {
63
+ const props = this.node?.properties || {}
64
+ const icon = props._icon
65
+ const title = props._title || ''
66
+ const expanded = !!props._expanded
67
+ const _titleHeight = isNumber(props._titleHeight) ? props._titleHeight : 28
68
+ const actions = (this as any).node?.__actions || []
69
+ const showMoreAction = !isEmpty(actions)
70
+ console.log('showMoreAction', actions, props._titleActions)
71
+ const bar = h(
72
+ 'div',
73
+ {
74
+ class: expanded
75
+ ? 'lf-vue-node-title lf-vue-node-title-expanded'
76
+ : 'lf-vue-node-title',
77
+ style: `height:${expanded ? _titleHeight : 18}px;`,
78
+ title,
79
+ },
80
+ [
81
+ h('div', { class: 'lf-vue-node-title-left' }, [
82
+ icon
83
+ ? h(
84
+ 'i',
85
+ {
86
+ class: 'lf-vue-node-title-icon',
87
+ },
88
+ icon,
89
+ )
90
+ : null,
91
+ h(
92
+ 'span',
93
+ {
94
+ class: 'lf-vue-node-title-text',
95
+ },
96
+ title,
97
+ ),
98
+ ]),
99
+ h('div', { class: 'lf-vue-node-title-actions' }, [
100
+ h(
101
+ 'button',
102
+ {
103
+ ref: 'expandBtn',
104
+ class: 'lf-vue-node-title-expand',
105
+ onClick: (e: MouseEvent) => {
106
+ console.log('expandClicked')
107
+ e.stopPropagation()
108
+ this.toggleExpand()
109
+ },
110
+ on: {
111
+ click: (e: MouseEvent) => {
112
+ console.log('expandClicked')
113
+ e.stopPropagation()
114
+ this.toggleExpand()
115
+ },
116
+ },
117
+ },
118
+ [
119
+ h(
120
+ 'svg',
121
+ {
122
+ width: 14,
123
+ height: 12,
124
+ viewBox: '0 0 14 12',
125
+ xmlns: 'http://www.w3.org/2000/svg',
126
+ class: 'lf-vue-node-title-expand-icon',
127
+ style: `transform:${expanded ? 'rotate(180deg)' : 'rotate(0deg)'};`,
128
+ },
129
+ [
130
+ h('path', {
131
+ d: 'M0.5201124,5.47988755C0.23603013,5.7639699,0.24460429,6.2271326,0.53900635,6.5005059L6.3195491,11.8681526C6.7032304,12.2244282,7.2967696,12.2244282,7.6804514,11.8681526L13.460994,6.5005059C13.755396,6.2271326,13.76397,5.7639699,13.479888,5.47988755C13.211547,5.21154633,12.779465,5.20215771,12.499721,5.45858961L7.3378625,10.1902928C7.1467018,10.3655233,6.8532982,10.3655233,6.6621375,10.1902928L1.5002797,5.45858967C1.2205358,5.20215771,0.78845364,5.21154633,0.5201124,5.47988755Z',
132
+ fill: '#474747',
133
+ }),
134
+ h('path', {
135
+ d: 'M0.5201124,0.47988755C0.23603013,0.7639699,0.24460429,1.2271326,0.53900635,1.5005059L6.3195491,6.8681526C6.7032304,7.2244282,7.2967696,7.2244282,7.6804514,6.8681526L13.460994,1.5005059C13.755396,1.2271326,13.76397,0.7639699,13.479888,0.47988755C13.211547,0.21154633,12.779465,0.20215771,12.499721,0.45858961L7.3378625,5.1902928C7.1467018,5.3655233,6.8532982,5.3655233,6.6621375,5.1902928L1.5002797,0.45858967C1.2205358,0.20215771,0.78845364,0.21154633,0.5201124,0.47988755Z',
136
+ fill: '#9B9B9B',
137
+ }),
138
+ ],
139
+ ),
140
+ ],
141
+ ),
142
+ showMoreAction &&
143
+ h(
144
+ 'button',
145
+ {
146
+ ref: 'moreBtn',
147
+ class: 'lf-vue-node-title-more',
148
+ },
149
+ [h('i', { class: 'lf-vue-node-title-more-icon' }, '⋯')],
150
+ ),
151
+ h(
152
+ 'div',
153
+ {
154
+ ref: 'tooltip',
155
+ class: 'lf-vue-node-title-tooltip',
156
+ style: `opacity:${this.showTooltip ? 1 : 0};pointer-events:${this.showTooltip ? 'auto' : 'none'};`,
157
+ },
158
+ [
159
+ h(
160
+ 'div',
161
+ { class: 'lf-vue-node-title-tooltip-list' },
162
+ actions.map((act: any) =>
163
+ h(
164
+ 'div',
165
+ {
166
+ class: 'lf-vue-node-title-tooltip-item',
167
+ onClick: (e: MouseEvent) => {
168
+ e.stopPropagation()
169
+ this.runAction(act)
170
+ },
171
+ on: {
172
+ click: (e: MouseEvent) => {
173
+ e.stopPropagation()
174
+ this.runAction(act)
175
+ },
176
+ },
177
+ },
178
+ act?.name || '',
179
+ ),
180
+ ),
181
+ ),
182
+ ],
183
+ ),
184
+ ]),
185
+ ],
186
+ )
187
+ return bar
188
+ },
189
+ })
package/src/index.less ADDED
@@ -0,0 +1 @@
1
+ @import url('./style/index.less');