@opentinyvue/vue-flowchart 2.21.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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 - present TinyVue Authors.
4
+ Copyright (c) 2022 - present Huawei Cloud Computing Technologies Co., Ltd.
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import Flowchart from './src/index';
2
+ export default Flowchart;
package/lib/index.js ADDED
@@ -0,0 +1,731 @@
1
+ import { defineComponent, props, directive, setup, emitter, h, isVue3, $prefix, $props, $setup } from '@opentinyvue/vue-common';
2
+ import { renderless, api } from '@opentinyvue/vue-renderless/flowchart/vue';
3
+ import Clickoutside from '@opentinyvue/vue-renderless/common/deps/clickoutside';
4
+ import { IconYes, IconClose, iconNotStartedMini, iconNotStarted, iconOnGoingMini, iconOnGoing, iconExceptionMiniO, iconExceptionO, iconDoneMini, iconDone } from '@opentinyvue/vue-icon';
5
+ import Popover from '@opentinyvue/vue-popover';
6
+ import { renderless as renderless$1, api as api$1 } from '@opentinyvue/vue-renderless/flowchart/node';
7
+ import ResizeObserver from '@opentinyvue/vue-renderless/common/deps/ResizeObserver';
8
+ import '@opentinyvue/vue-theme/flowchart/index.css';
9
+
10
+ function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
11
+ var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
12
+ if (render) {
13
+ options.render = render;
14
+ options.staticRenderFns = staticRenderFns;
15
+ options._compiled = true;
16
+ }
17
+ var hook;
18
+ if (injectStyles) {
19
+ hook = injectStyles;
20
+ }
21
+ if (hook) {
22
+ if (options.functional) {
23
+ options._injectStyles = hook;
24
+ var originalRender = options.render;
25
+ options.render = function renderWithStyleInjection(h, context) {
26
+ hook.call(context);
27
+ return originalRender(h, context);
28
+ };
29
+ } else {
30
+ var existing = options.beforeCreate;
31
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
32
+ }
33
+ }
34
+ return {
35
+ exports: scriptExports,
36
+ options
37
+ };
38
+ }
39
+
40
+ var __vue2_script$2 = defineComponent({
41
+ emits: ["click-node", "click-link", "click-blank"],
42
+ props: [].concat(props, ["data", "config"]),
43
+ directives: directive({
44
+ Clickoutside
45
+ }),
46
+ setup: function setup$1(props2, context) {
47
+ return setup({
48
+ props: props2,
49
+ context,
50
+ renderless,
51
+ api,
52
+ extendOptions: {
53
+ emitter
54
+ }
55
+ });
56
+ },
57
+ render: function render() {
58
+ var slots = this.slots, state = this.state, clearHoverAfterLink = this.clearHoverAfterLink, clickNode = this.clickNode, config = this.config, getVars = this.getVars, omitText = this.omitText;
59
+ var afterData = state.afterData, dropdowns = state.dropdowns, refreshKey = state.refreshKey, wrapperStyle = state.wrapperStyle;
60
+ var afterNodes = afterData.afterNodes, allItem = afterData.allItem;
61
+ var nodes = afterNodes.map(function(afterNode) {
62
+ var ret = getVars(afterNode, config);
63
+ var background = ret.background, borderColor = ret.borderColor, half = ret.half, isCompleteFn = ret.isCompleteFn, isFailFn = ret.isFailFn, isOngoingFn = ret.isOngoingFn, statusName = ret.statusName, white = ret.white;
64
+ var halfIconWrapperSize = half(config.iconWrapperSize);
65
+ var wrapperStyle2 = "left:" + afterNode.x + "px;top:" + afterNode.y + "px;width:" + config.iconWrapperSize + "px;height:" + config.iconWrapperSize + "px;transform:translate(-" + halfIconWrapperSize + "px,-" + halfIconWrapperSize + "px);background:" + config.background + ";";
66
+ var halfIconSize = half(config.iconSize);
67
+ var iconWrapperPadding = halfIconWrapperSize - halfIconSize;
68
+ var iconStyle = "width:" + config.iconSize + "px;height:" + config.iconSize + "px;border-radius:" + halfIconSize + "px;border-color:" + borderColor + ";transform:translate(" + iconWrapperPadding + "px," + iconWrapperPadding + "px);background:" + background + ";";
69
+ var svgFill = isCompleteFn() ? borderColor : isFailFn() ? white : "";
70
+ var svgStyle = "font-size:" + config.iconSvgSize + "px;fill:" + svgFill + ";";
71
+ var iconComp = isCompleteFn() ? IconYes() : isFailFn() ? IconClose() : null;
72
+ var labelWidth = config.labelWidth || afterData.widths[1] - config.labelSpacing;
73
+ var labelHeight = config.labelHeight || afterData.heights[1] - config.labelSpacing;
74
+ var halfLabelWidth = half(labelWidth);
75
+ var labelTransform = config.anchor === "center" ? "translateX(" + (halfIconWrapperSize - halfLabelWidth) + "px)" : "";
76
+ var labelStyle = "width:" + labelWidth + "px;height:" + labelHeight + "px;transform:" + labelTransform + ";";
77
+ var baseStyle = "text-align:" + (config.anchor === "center" ? "center" : "left") + ";";
78
+ var titleStyle = baseStyle + ("color:" + (isOngoingFn() ? config.colors[config.statusOngoing] : "") + ";");
79
+ var dateStyle = baseStyle + ("color:" + config.labelDateColor + ";");
80
+ var valid = function valid2(arr) {
81
+ return Array.isArray(arr) && arr.length > config.listThreshold;
82
+ };
83
+ var showItem = slots.content && valid(afterNode.raw.info.items);
84
+ var itemStyle = "width:" + config.listWidth + "px;height:" + config.iconWrapperSize + "px;background:" + config.background + ";";
85
+ var params = {
86
+ afterNode,
87
+ node: afterNode.raw,
88
+ config,
89
+ allItem,
90
+ dropdowns,
91
+ showPop: dropdowns[afterNode.raw.name]
92
+ };
93
+ var iconVnode, lableVnodes;
94
+ if (slots.icon) {
95
+ iconVnode = slots.icon(params);
96
+ } else {
97
+ iconVnode = h("div", {
98
+ class: "tiny-flow-chart__node-icon " + statusName,
99
+ style: iconStyle
100
+ }, [iconComp ? h(iconComp, {
101
+ class: "tiny-flow-chart__node-svg",
102
+ style: svgStyle
103
+ }) : null]);
104
+ }
105
+ if (slots.label) {
106
+ lableVnodes = [slots.label(params)];
107
+ } else {
108
+ var property = {
109
+ class: "label-item label-title",
110
+ style: titleStyle
111
+ };
112
+ var t = omitText(afterNode.raw.info.label, config.font, labelWidth);
113
+ if (t.o) {
114
+ property.attrs = {
115
+ title: afterNode.raw.info.label
116
+ };
117
+ }
118
+ lableVnodes = [h("div", property, t.t), h("div", {
119
+ class: "label-item label-date",
120
+ style: dateStyle
121
+ }, afterNode.raw.info.date)];
122
+ }
123
+ return h("div", {
124
+ class: "tiny-flow-chart__node-icon-wrapper",
125
+ style: wrapperStyle2,
126
+ on: {
127
+ mousemove: clearHoverAfterLink,
128
+ click: function click(e) {
129
+ return clickNode(params, e);
130
+ }
131
+ }
132
+ }, [iconVnode, h("div", {
133
+ class: "tiny-flow-chart__node-label",
134
+ style: labelStyle
135
+ }, lableVnodes), showItem ? h("div", {
136
+ class: "tiny-flow-chart__node-item",
137
+ style: itemStyle
138
+ }, [slots.content(params)]) : null]);
139
+ });
140
+ return h("div", {
141
+ class: "tiny-flow-chart",
142
+ style: wrapperStyle,
143
+ key: refreshKey,
144
+ directives: [{
145
+ name: "clickoutside",
146
+ expression: "clearDropdown"
147
+ }]
148
+ }, [h("canvas", {
149
+ class: "tiny-flow-chart__canvas",
150
+ attrs: {
151
+ width: config.width,
152
+ height: config.height
153
+ },
154
+ ref: "canvas"
155
+ })].concat(nodes));
156
+ }
157
+ });
158
+ var __vue2_render$1, __vue2_staticRenderFns$1;
159
+ var __cssModules$2 = {};
160
+ var __component__$2 = /* @__PURE__ */ normalizeComponent(__vue2_script$2, __vue2_render$1, __vue2_staticRenderFns$1, false, __vue2_injectStyles$2);
161
+ function __vue2_injectStyles$2(context) {
162
+ for (var o in __cssModules$2) {
163
+ this[o] = __cssModules$2[o];
164
+ }
165
+ }
166
+ var pc = /* @__PURE__ */ function() {
167
+ return __component__$2.exports;
168
+ }();
169
+
170
+ var getRenderLabel = function getRenderLabel2(_ref) {
171
+ var omitText = _ref.omitText, font = _ref.font, width = _ref.width, padding = _ref.padding, popoverProps = _ref.popoverProps;
172
+ return function(label, type) {
173
+ if (!label) return null;
174
+ var t = omitText(label, font, width - padding[1]);
175
+ var fontClass = type === "main" ? "font-semibold text-color-text-primary" : "text-color-text-secondary";
176
+ var labelClass = "w-full text-center whitespace-nowrap overflow-hidden text-ellipsis " + padding[0] + " " + fontClass;
177
+ var lableVnode = h("div", {
178
+ slot: "reference",
179
+ class: labelClass
180
+ }, label);
181
+ if (!t.o) return lableVnode;
182
+ var def = h("span", label);
183
+ var childNodes = isVue3 ? {
184
+ default: function _default() {
185
+ return def;
186
+ },
187
+ reference: function reference() {
188
+ return lableVnode;
189
+ }
190
+ } : [def, lableVnode];
191
+ return h(Popover, popoverProps, childNodes);
192
+ };
193
+ };
194
+ var renderShapeChildren = function renderShapeChildren2(_ref2) {
195
+ var renderInner = _ref2.renderInner, raw = _ref2.raw, renderLabel = _ref2.renderLabel, main = _ref2.main, auxi = _ref2.auxi;
196
+ var shapeVnodeChildren = null;
197
+ if (typeof renderInner === "function") {
198
+ shapeVnodeChildren = [renderInner(h, raw)];
199
+ } else {
200
+ var mainVnode = renderLabel(main, "main");
201
+ var auxiVnode = renderLabel(auxi, "auxi");
202
+ shapeVnodeChildren = [mainVnode, auxiVnode];
203
+ }
204
+ return shapeVnodeChildren;
205
+ };
206
+ var renderShapeVnode = function renderShapeVnode2(args) {
207
+ var renderOuter = args.renderOuter, raw = args.raw, colors = args.colors, status = args.status, statusOngoing = args.statusOngoing, ongoingBackgroundColor = args.ongoingBackgroundColor;
208
+ var shape = args.shape, statusFail = args.statusFail, error = args.error, shapeVnodeChildren = args.shapeVnodeChildren, popoverProps = args.popoverProps;
209
+ var shapeVnode = null;
210
+ if (typeof renderOuter === "function") {
211
+ shapeVnode = renderOuter(h, raw);
212
+ } else {
213
+ var borderColor = "border-color:" + colors[status] + ";";
214
+ var backgroundColor = status === statusOngoing ? "background-color:" + ongoingBackgroundColor + ";" : "";
215
+ var cls = ["w-full h-full border-0.5 sm:border border-solid flex flex-col items-center cursor-pointer", shape === "circle" ? "rounded-full justify-center" : "", shape === "rectangle" ? "rounded justify-evenly" : ""];
216
+ var styl = borderColor + backgroundColor;
217
+ if (status === statusFail && error) {
218
+ var def = h("span", error);
219
+ var ref = h("div", {
220
+ class: cls,
221
+ style: styl,
222
+ slot: "reference"
223
+ }, shapeVnodeChildren);
224
+ var childNodes = isVue3 ? {
225
+ default: function _default() {
226
+ return def;
227
+ },
228
+ reference: function reference() {
229
+ return ref;
230
+ }
231
+ } : [def, ref];
232
+ popoverProps.class = "w-full h-full block";
233
+ shapeVnode = h(Popover, popoverProps, childNodes);
234
+ } else {
235
+ shapeVnode = h("div", {
236
+ class: cls,
237
+ style: styl,
238
+ slot: "reference"
239
+ }, shapeVnodeChildren);
240
+ }
241
+ }
242
+ return shapeVnode;
243
+ };
244
+ var renderCondVnodes = function renderCondVnodes2(_ref3) {
245
+ var isDot = _ref3.isDot, afterLinks = _ref3.afterLinks, afterConfig = _ref3.afterConfig, config = _ref3.config;
246
+ if (!isDot) return [];
247
+ var cfg = afterConfig || config || {};
248
+ var condClass = cfg.condClass, renderCond = cfg.renderCond;
249
+ return afterLinks.filter(function(_ref4) {
250
+ var cond = _ref4.cond;
251
+ return cond;
252
+ }).map(function(afterLink) {
253
+ var rect = afterLink.rect, raw = afterLink.raw;
254
+ var clazz = "absolute flex justify-center items-center";
255
+ var style = "left:" + rect.x + "px;top:" + rect.y + "px;width:" + rect.w + "px;height:" + rect.h + "px;";
256
+ return h("div", {
257
+ class: clazz,
258
+ style
259
+ }, [renderCond ? renderCond(h, afterLink, cfg) : h("div", {
260
+ attrs: {
261
+ title: raw.info.other.title
262
+ },
263
+ class: condClass || ""
264
+ }, raw.info.other.title)]);
265
+ });
266
+ };
267
+ var renderGroupVnodes = function renderGroupVnodes2(_ref5) {
268
+ var afterGroups = _ref5.afterGroups, clickGroup = _ref5.clickGroup;
269
+ if (!afterGroups) return [];
270
+ return afterGroups.map(function(afterGroup) {
271
+ var _afterGroup$raw = afterGroup.raw, title = _afterGroup$raw.title, titleClass = _afterGroup$raw.titleClass;
272
+ var vnode = null;
273
+ if (title) {
274
+ var titlePosition = afterGroup.raw.titlePosition;
275
+ var width = afterGroup.width, height = afterGroup.height;
276
+ var p0 = afterGroup.coords[0];
277
+ var p3 = afterGroup.coords[3];
278
+ var pos = {
279
+ x: 0,
280
+ y: p3.y + 8
281
+ };
282
+ var centerClass = "";
283
+ if (!titlePosition || titlePosition === "top-left") {
284
+ pos.x = p0.x + 8;
285
+ } else {
286
+ pos.x = p3.x - width / 2;
287
+ centerClass = "flex justify-center items-center";
288
+ }
289
+ vnode = h("div", {
290
+ class: "absolute " + centerClass,
291
+ style: {
292
+ left: pos.x + "px",
293
+ top: pos.y + "px",
294
+ width: width + "px",
295
+ height: height + "px"
296
+ },
297
+ on: {
298
+ click: function click(e) {
299
+ return clickGroup(afterGroup, e);
300
+ }
301
+ }
302
+ }, [h("div", {
303
+ class: "truncate",
304
+ attrs: {
305
+ title
306
+ }
307
+ }, [h("span", {
308
+ class: titleClass
309
+ }, title)])]);
310
+ }
311
+ return vnode;
312
+ });
313
+ };
314
+ var __vue2_script$1 = defineComponent({
315
+ emits: ["click-node", "click-link", "click-blank", "click-group"],
316
+ props: [].concat(props, ["data", "config"]),
317
+ setup: function setup$1(props2, context) {
318
+ return setup({
319
+ props: props2,
320
+ context,
321
+ renderless,
322
+ api,
323
+ extendOptions: {
324
+ emitter
325
+ }
326
+ });
327
+ },
328
+ render: function render() {
329
+ var state = this.state, omitText = this.omitText, config = this.config, clickNode = this.clickNode, clickGroup = this.clickGroup;
330
+ var afterData = state.afterData, wrapperStyle = state.wrapperStyle, refreshKey = state.refreshKey;
331
+ var graph = afterData.graph, afterNodes = afterData.afterNodes, afterLinks = afterData.afterLinks, afterGroups = afterData.afterGroups, afterConfig = afterData.afterConfig;
332
+ var font = config.font, popoverPlacement = config.popoverPlacement, colors = config.colors, statusOngoing = config.statusOngoing, statusFail = config.statusFail, ongoingBackgroundColor = config.ongoingBackgroundColor;
333
+ var ratio = graph.thin ? graph.thinValue : 1;
334
+ var padding = ["px-1.5", 12];
335
+ var isDot = config.type === "dot";
336
+ var condVnodes = renderCondVnodes({
337
+ isDot,
338
+ afterLinks,
339
+ afterConfig,
340
+ config
341
+ });
342
+ var groupVnodes = renderGroupVnodes({
343
+ afterGroups,
344
+ clickGroup
345
+ });
346
+ return h("div", {
347
+ attrs: {
348
+ "data-tag": "tiny-flow-chart"
349
+ },
350
+ class: "relative",
351
+ style: wrapperStyle,
352
+ key: refreshKey
353
+ }, [h("canvas", {
354
+ attrs: {
355
+ "data-tag": "tiny-flow-chart__canvas",
356
+ width: graph.width * ratio,
357
+ height: graph.height * ratio
358
+ },
359
+ class: graph.thin ? "scale-50 -translate-x-1/4 -translate-y-1/4" : "absolute top-0 left-0",
360
+ ref: "canvas"
361
+ })].concat(afterNodes.map(function(afterNode) {
362
+ var x = afterNode.x, y = afterNode.y, width = afterNode.width, height = afterNode.height, raw = afterNode.raw;
363
+ var info = raw.info, renderInner = raw.renderInner;
364
+ var renderOuter = raw.renderOuter || config.renderOuter;
365
+ var other = info.other, shape = info.shape, status = info.status;
366
+ var main = other.main, auxi = other.auxi, error = other.error;
367
+ var popoverProps = {
368
+ props: {
369
+ trigger: "hover",
370
+ placement: popoverPlacement
371
+ },
372
+ class: "w-full block"
373
+ };
374
+ var renderLabel = getRenderLabel({
375
+ omitText,
376
+ font,
377
+ width,
378
+ padding,
379
+ popoverProps
380
+ });
381
+ var shapeVnodeChildren = renderShapeChildren({
382
+ renderInner,
383
+ raw,
384
+ renderLabel,
385
+ main,
386
+ auxi
387
+ });
388
+ var args = {
389
+ renderOuter,
390
+ raw,
391
+ colors,
392
+ status,
393
+ statusOngoing,
394
+ ongoingBackgroundColor
395
+ };
396
+ Object.assign(args, {
397
+ shape,
398
+ statusFail,
399
+ error,
400
+ shapeVnodeChildren,
401
+ popoverProps
402
+ });
403
+ var shapeVnode = renderShapeVnode(args);
404
+ var wrapperProps = {
405
+ attrs: {
406
+ "data-tag": "tiny-flow-chart__node"
407
+ },
408
+ style: "left:" + x + "px;top:" + y + "px;width:" + width + "px;height:" + height + "px;",
409
+ class: ["absolute", {
410
+ "flex justify-center items-center": isDot
411
+ }],
412
+ on: {
413
+ click: function click(e) {
414
+ return clickNode({
415
+ afterNode
416
+ }, e);
417
+ }
418
+ }
419
+ };
420
+ var outerClass = ["absolute w-6 h-6", {
421
+ "sm:w-4 sm:h-4": config.nodeSize === "mini",
422
+ "sm:w-8 sm:h-8": config.nodeSize === "medium"
423
+ }];
424
+ return h("div", wrapperProps, [isDot ? h("div", {
425
+ class: outerClass
426
+ }, [shapeVnode]) : shapeVnode]);
427
+ }), condVnodes, groupVnodes));
428
+ }
429
+ });
430
+ var __vue2_render, __vue2_staticRenderFns;
431
+ var __cssModules$1 = {};
432
+ var __component__$1 = /* @__PURE__ */ normalizeComponent(__vue2_script$1, __vue2_render, __vue2_staticRenderFns, false, __vue2_injectStyles$1);
433
+ function __vue2_injectStyles$1(context) {
434
+ for (var o in __cssModules$1) {
435
+ this[o] = __cssModules$1[o];
436
+ }
437
+ }
438
+ var mobileFirst = /* @__PURE__ */ function() {
439
+ return __component__$1.exports;
440
+ }();
441
+
442
+ function _extends() {
443
+ return _extends = Object.assign ? Object.assign.bind() : function(n) {
444
+ for (var e = 1; e < arguments.length; e++) {
445
+ var t = arguments[e];
446
+ for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
447
+ }
448
+ return n;
449
+ }, _extends.apply(null, arguments);
450
+ }
451
+ var template = function template2(mode) {
452
+ var _process$env;
453
+ var tinyMode = typeof process === "object" ? (_process$env = process.env) == null ? void 0 : _process$env.TINY_MODE : null;
454
+ if ("pc" === (tinyMode || mode)) {
455
+ return pc;
456
+ }
457
+ if ("mobile-first" === (tinyMode || mode)) {
458
+ return mobileFirst;
459
+ }
460
+ return pc;
461
+ };
462
+ var $constants = {};
463
+ var createNode = function createNode2(name, status, label, date, items, row, col, other) {
464
+ var info = {
465
+ status,
466
+ label,
467
+ date,
468
+ items,
469
+ row,
470
+ col,
471
+ other
472
+ };
473
+ return {
474
+ name,
475
+ info
476
+ };
477
+ };
478
+ var createLink = function createLink2(from, to, p, status, style, other) {
479
+ var info = {
480
+ status,
481
+ style: style || "solid",
482
+ other
483
+ };
484
+ return {
485
+ from,
486
+ to,
487
+ p,
488
+ info
489
+ };
490
+ };
491
+ var createItem = function createItem2(key, name, role, status, comment, date, other) {
492
+ return {
493
+ key,
494
+ name,
495
+ role,
496
+ status,
497
+ comment,
498
+ date,
499
+ other
500
+ };
501
+ };
502
+ var createConfig = function createConfig2() {
503
+ return {
504
+ width: 1024,
505
+ height: 420,
506
+ rows: 8,
507
+ cols: 8,
508
+ status: {
509
+ 1: "complete",
510
+ 2: "ongoing",
511
+ 3: "pending",
512
+ 4: "fail"
513
+ },
514
+ colors: {
515
+ 1: "#1890ff",
516
+ 2: "#096dd9",
517
+ 3: "#d9d9d9",
518
+ 4: "#f5222d"
519
+ },
520
+ background: "#fff",
521
+ statusComplete: 1,
522
+ statusOngoing: 2,
523
+ statusFail: 4,
524
+ anchor: "center",
525
+ iconWrapperSize: 24,
526
+ iconSize: 20,
527
+ iconSvgSize: 14,
528
+ labelSpacing: 8,
529
+ labelWidth: 80,
530
+ labelHeight: 60,
531
+ labelDateColor: "#999",
532
+ listWidth: 62,
533
+ listThreshold: 1,
534
+ listIconSize: 20,
535
+ listBorderColor: "#d9d9d9",
536
+ listIconColor: "#999",
537
+ headUrl: "",
538
+ headSize: 20,
539
+ drawLink: null,
540
+ styleLink: null,
541
+ styleHoverLink: null,
542
+ hoverHit: 3,
543
+ checkItemStatus: null,
544
+ font: '12px "Microsoft YaHei"',
545
+ delay: 10,
546
+ adjustPos: null,
547
+ radius: 4,
548
+ thin: true
549
+ };
550
+ };
551
+ var Flowchart = defineComponent({
552
+ name: $prefix + "Flowchart",
553
+ props: _extends({}, $props, {
554
+ _constants: {
555
+ type: Object,
556
+ default: function _default() {
557
+ return $constants;
558
+ }
559
+ },
560
+ data: Object,
561
+ config: Object
562
+ }),
563
+ setup: function setup(props2, context) {
564
+ return $setup({
565
+ props: props2,
566
+ context,
567
+ template
568
+ });
569
+ }
570
+ });
571
+ var icons = {
572
+ "not-started": {
573
+ mini: iconNotStartedMini,
574
+ other: iconNotStarted
575
+ },
576
+ "ongoing": {
577
+ mini: iconOnGoingMini,
578
+ other: iconOnGoing
579
+ },
580
+ "fail": {
581
+ mini: iconExceptionMiniO,
582
+ other: iconExceptionO
583
+ },
584
+ "completed": {
585
+ mini: iconDoneMini,
586
+ other: iconDone
587
+ }
588
+ };
589
+ var __vue2_script = defineComponent({
590
+ props: [].concat(props, ["node", "config", "titleClass"]),
591
+ setup: function setup2(props2, context) {
592
+ return setup({
593
+ props: props2,
594
+ context,
595
+ renderless: renderless$1,
596
+ api: api$1,
597
+ mono: true,
598
+ extendOptions: {
599
+ icons
600
+ }
601
+ });
602
+ }
603
+ });
604
+ var render = function render2() {
605
+ var _vm = this;
606
+ var _h = _vm.$createElement;
607
+ var _c = _vm._self._c || _h;
608
+ return _c("div", {
609
+ key: _vm.state.nodeName,
610
+ class: ["layout-" + _vm.state.nodeLayout, "size-" + _vm.state.nodeSize, "status-" + _vm.state.nodeStatus, "absolute z-20 h-6", {
611
+ "sm:h-4": _vm.state.sizeMini,
612
+ "sm:h-8": _vm.state.sizeMedium
613
+ }],
614
+ style: {
615
+ width: _vm.state.nodeWidth + "px"
616
+ },
617
+ attrs: {
618
+ "data-tag": "tiny-flowchart-node"
619
+ }
620
+ }, [_c("div", {
621
+ ref: "icon",
622
+ class: ["w-4 h-4 absolute z-0 rounded-full flex items-center justify-center", "translate-x-1 translate-y-1 text-base cursor-pointer", {
623
+ "sm:w-2 sm:h-2": _vm.state.icon.size === "mini",
624
+ "sm:w-6 sm:h-6": _vm.state.icon.size === "medium"
625
+ }]
626
+ }, [_c(_vm.state.icon.svg(), {
627
+ tag: "component",
628
+ attrs: {
629
+ "custom-class": ["w-4 h-4 inline-block", {
630
+ "sm:w-2 sm:h-2": _vm.state.icon.size === "mini",
631
+ "sm:w-6 sm:h-6": _vm.state.icon.size === "medium"
632
+ }]
633
+ }
634
+ })], 1), _c("div", {
635
+ ref: "title",
636
+ class: _vm.m("absolute z-0 translate-x-1", _vm.state.layUpdown ? "top-6" : "left-6 translate-y-1", _vm.state.layUpdown ? {
637
+ "sm:top-4": _vm.state.sizeMini,
638
+ "sm:top-8": _vm.state.sizeMedium
639
+ } : {
640
+ "sm:left-4": _vm.state.sizeMini,
641
+ "sm:left-8": _vm.state.sizeMedium
642
+ }, _vm.titleClass || ""),
643
+ style: {
644
+ maxWidth: _vm.state.titleMaxWidth + "px",
645
+ left: _vm.state.layUpdown ? "-" + _vm.state.posLeft + "px" : ""
646
+ }
647
+ }, [_vm._l(["title", "subtitle", "auxi"], function(key) {
648
+ return [_vm.state[key].show ? _c("div", {
649
+ key,
650
+ class: ["truncate", _vm.state.layUpdown ? "text-center" : "text-left", key === "title" && _vm.state.sizeMedium ? "text-sm" : "text-xs", _vm.state.isSmall ? {
651
+ "leading-5": key === "title",
652
+ "leading-4": key !== "title"
653
+ } : {
654
+ "leading-6": key === "title" && _vm.state.sizeMedium,
655
+ "leading-5": key !== "title" && _vm.state.sizeMedium || key === "title" && _vm.state.sizeSmall,
656
+ "leading-4": key !== "title" && _vm.state.sizeSmall || _vm.state.sizeMini
657
+ }, {
658
+ "text-color-icon-focus": _vm.state.statOngoing,
659
+ "text-color-text-primary": key === "title" && _vm.state.statCompleted,
660
+ "text-color-error": key === "title" && _vm.state.statFail,
661
+ "text-color-icon-secondary": key === "title" && _vm.state.statNotStarted,
662
+ "text-color-icon-placeholder": key !== "title" && !_vm.state.statOngoing
663
+ }],
664
+ attrs: {
665
+ "title": _vm.state[key].text
666
+ }
667
+ }, [_vm._v(" " + _vm._s(_vm.state[key].text) + " ")]) : _vm._e()];
668
+ })], 2)]);
669
+ };
670
+ var staticRenderFns = [];
671
+ var __cssModules = {};
672
+ var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, render, staticRenderFns, false, __vue2_injectStyles);
673
+ function __vue2_injectStyles(context) {
674
+ for (var o in __cssModules) {
675
+ this[o] = __cssModules[o];
676
+ }
677
+ }
678
+ var Node = /* @__PURE__ */ function() {
679
+ return __component__.exports;
680
+ }();
681
+ var resizeMixin = function resizeMixin2(_ref) {
682
+ var apiPrefix = _ref.apiPrefix, refName = _ref.refName, nodeWrapperSize = _ref.nodeWrapperSize;
683
+ apiPrefix = apiPrefix || "rszmx";
684
+ refName = refName || "chart";
685
+ nodeWrapperSize = nodeWrapperSize || 32;
686
+ var observer = apiPrefix + "ResizeObserver";
687
+ var observed = apiPrefix + "ResizeObserved";
688
+ return {
689
+ mounted: function mounted() {
690
+ var _this = this;
691
+ this.$nextTick(function() {
692
+ var observedElement = _this.$el.parentNode;
693
+ if (observedElement) {
694
+ _this[observer] = new ResizeObserver(function() {
695
+ window.requestAnimationFrame(function() {
696
+ if (_this.$refs[refName]) {
697
+ _this.$refs[refName].refresh({
698
+ graphWidth: observedElement.offsetWidth,
699
+ adjustX: -nodeWrapperSize / 2
700
+ });
701
+ }
702
+ });
703
+ });
704
+ _this[observer].observe(observedElement);
705
+ _this[observed] = observedElement;
706
+ }
707
+ });
708
+ },
709
+ beforeUnmount: function beforeUnmount() {
710
+ if (this[observer]) {
711
+ this[observer].unobserve(this[observed]);
712
+ this[observer].disconnect();
713
+ this[observer] = null;
714
+ this[observed] = null;
715
+ }
716
+ }
717
+ };
718
+ };
719
+ var version = "2.21.0";
720
+ Flowchart.install = function(Vue) {
721
+ Vue.component(Flowchart.name, Flowchart);
722
+ };
723
+ Flowchart.version = version;
724
+ Flowchart.createNode = createNode;
725
+ Flowchart.createLink = createLink;
726
+ Flowchart.createItem = createItem;
727
+ Flowchart.createConfig = createConfig;
728
+ Flowchart.Node = Node;
729
+ Flowchart.resizeMixin = resizeMixin;
730
+
731
+ export { Flowchart as default };
@@ -0,0 +1,307 @@
1
+ import { renderless, api } from '@opentinyvue/vue-renderless/flowchart/vue';
2
+ import { defineComponent, props, setup, emitter, h, isVue3 } from '@opentinyvue/vue-common';
3
+ import Popover from '@opentinyvue/vue-popover';
4
+
5
+ function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
6
+ var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
7
+ if (render) {
8
+ options.render = render;
9
+ options.staticRenderFns = staticRenderFns;
10
+ options._compiled = true;
11
+ }
12
+ var hook;
13
+ if (injectStyles) {
14
+ hook = injectStyles;
15
+ }
16
+ if (hook) {
17
+ if (options.functional) {
18
+ options._injectStyles = hook;
19
+ var originalRender = options.render;
20
+ options.render = function renderWithStyleInjection(h, context) {
21
+ hook.call(context);
22
+ return originalRender(h, context);
23
+ };
24
+ } else {
25
+ var existing = options.beforeCreate;
26
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
27
+ }
28
+ }
29
+ return {
30
+ exports: scriptExports,
31
+ options
32
+ };
33
+ }
34
+
35
+ var getRenderLabel = function getRenderLabel2(_ref) {
36
+ var omitText = _ref.omitText, font = _ref.font, width = _ref.width, padding = _ref.padding, popoverProps = _ref.popoverProps;
37
+ return function(label, type) {
38
+ if (!label) return null;
39
+ var t = omitText(label, font, width - padding[1]);
40
+ var fontClass = type === "main" ? "font-semibold text-color-text-primary" : "text-color-text-secondary";
41
+ var labelClass = "w-full text-center whitespace-nowrap overflow-hidden text-ellipsis " + padding[0] + " " + fontClass;
42
+ var lableVnode = h("div", {
43
+ slot: "reference",
44
+ class: labelClass
45
+ }, label);
46
+ if (!t.o) return lableVnode;
47
+ var def = h("span", label);
48
+ var childNodes = isVue3 ? {
49
+ default: function _default() {
50
+ return def;
51
+ },
52
+ reference: function reference() {
53
+ return lableVnode;
54
+ }
55
+ } : [def, lableVnode];
56
+ return h(Popover, popoverProps, childNodes);
57
+ };
58
+ };
59
+ var renderShapeChildren = function renderShapeChildren2(_ref2) {
60
+ var renderInner = _ref2.renderInner, raw = _ref2.raw, renderLabel = _ref2.renderLabel, main = _ref2.main, auxi = _ref2.auxi;
61
+ var shapeVnodeChildren = null;
62
+ if (typeof renderInner === "function") {
63
+ shapeVnodeChildren = [renderInner(h, raw)];
64
+ } else {
65
+ var mainVnode = renderLabel(main, "main");
66
+ var auxiVnode = renderLabel(auxi, "auxi");
67
+ shapeVnodeChildren = [mainVnode, auxiVnode];
68
+ }
69
+ return shapeVnodeChildren;
70
+ };
71
+ var renderShapeVnode = function renderShapeVnode2(args) {
72
+ var renderOuter = args.renderOuter, raw = args.raw, colors = args.colors, status = args.status, statusOngoing = args.statusOngoing, ongoingBackgroundColor = args.ongoingBackgroundColor;
73
+ var shape = args.shape, statusFail = args.statusFail, error = args.error, shapeVnodeChildren = args.shapeVnodeChildren, popoverProps = args.popoverProps;
74
+ var shapeVnode = null;
75
+ if (typeof renderOuter === "function") {
76
+ shapeVnode = renderOuter(h, raw);
77
+ } else {
78
+ var borderColor = "border-color:" + colors[status] + ";";
79
+ var backgroundColor = status === statusOngoing ? "background-color:" + ongoingBackgroundColor + ";" : "";
80
+ var cls = ["w-full h-full border-0.5 sm:border border-solid flex flex-col items-center cursor-pointer", shape === "circle" ? "rounded-full justify-center" : "", shape === "rectangle" ? "rounded justify-evenly" : ""];
81
+ var styl = borderColor + backgroundColor;
82
+ if (status === statusFail && error) {
83
+ var def = h("span", error);
84
+ var ref = h("div", {
85
+ class: cls,
86
+ style: styl,
87
+ slot: "reference"
88
+ }, shapeVnodeChildren);
89
+ var childNodes = isVue3 ? {
90
+ default: function _default() {
91
+ return def;
92
+ },
93
+ reference: function reference() {
94
+ return ref;
95
+ }
96
+ } : [def, ref];
97
+ popoverProps.class = "w-full h-full block";
98
+ shapeVnode = h(Popover, popoverProps, childNodes);
99
+ } else {
100
+ shapeVnode = h("div", {
101
+ class: cls,
102
+ style: styl,
103
+ slot: "reference"
104
+ }, shapeVnodeChildren);
105
+ }
106
+ }
107
+ return shapeVnode;
108
+ };
109
+ var renderCondVnodes = function renderCondVnodes2(_ref3) {
110
+ var isDot = _ref3.isDot, afterLinks = _ref3.afterLinks, afterConfig = _ref3.afterConfig, config = _ref3.config;
111
+ if (!isDot) return [];
112
+ var cfg = afterConfig || config || {};
113
+ var condClass = cfg.condClass, renderCond = cfg.renderCond;
114
+ return afterLinks.filter(function(_ref4) {
115
+ var cond = _ref4.cond;
116
+ return cond;
117
+ }).map(function(afterLink) {
118
+ var rect = afterLink.rect, raw = afterLink.raw;
119
+ var clazz = "absolute flex justify-center items-center";
120
+ var style = "left:" + rect.x + "px;top:" + rect.y + "px;width:" + rect.w + "px;height:" + rect.h + "px;";
121
+ return h("div", {
122
+ class: clazz,
123
+ style
124
+ }, [renderCond ? renderCond(h, afterLink, cfg) : h("div", {
125
+ attrs: {
126
+ title: raw.info.other.title
127
+ },
128
+ class: condClass || ""
129
+ }, raw.info.other.title)]);
130
+ });
131
+ };
132
+ var renderGroupVnodes = function renderGroupVnodes2(_ref5) {
133
+ var afterGroups = _ref5.afterGroups, clickGroup = _ref5.clickGroup;
134
+ if (!afterGroups) return [];
135
+ return afterGroups.map(function(afterGroup) {
136
+ var _afterGroup$raw = afterGroup.raw, title = _afterGroup$raw.title, titleClass = _afterGroup$raw.titleClass;
137
+ var vnode = null;
138
+ if (title) {
139
+ var titlePosition = afterGroup.raw.titlePosition;
140
+ var width = afterGroup.width, height = afterGroup.height;
141
+ var p0 = afterGroup.coords[0];
142
+ var p3 = afterGroup.coords[3];
143
+ var pos = {
144
+ x: 0,
145
+ y: p3.y + 8
146
+ };
147
+ var centerClass = "";
148
+ if (!titlePosition || titlePosition === "top-left") {
149
+ pos.x = p0.x + 8;
150
+ } else {
151
+ pos.x = p3.x - width / 2;
152
+ centerClass = "flex justify-center items-center";
153
+ }
154
+ vnode = h("div", {
155
+ class: "absolute " + centerClass,
156
+ style: {
157
+ left: pos.x + "px",
158
+ top: pos.y + "px",
159
+ width: width + "px",
160
+ height: height + "px"
161
+ },
162
+ on: {
163
+ click: function click(e) {
164
+ return clickGroup(afterGroup, e);
165
+ }
166
+ }
167
+ }, [h("div", {
168
+ class: "truncate",
169
+ attrs: {
170
+ title
171
+ }
172
+ }, [h("span", {
173
+ class: titleClass
174
+ }, title)])]);
175
+ }
176
+ return vnode;
177
+ });
178
+ };
179
+ var __vue2_script = defineComponent({
180
+ emits: ["click-node", "click-link", "click-blank", "click-group"],
181
+ props: [].concat(props, ["data", "config"]),
182
+ setup: function setup$1(props2, context) {
183
+ return setup({
184
+ props: props2,
185
+ context,
186
+ renderless,
187
+ api,
188
+ extendOptions: {
189
+ emitter
190
+ }
191
+ });
192
+ },
193
+ render: function render() {
194
+ var state = this.state, omitText = this.omitText, config = this.config, clickNode = this.clickNode, clickGroup = this.clickGroup;
195
+ var afterData = state.afterData, wrapperStyle = state.wrapperStyle, refreshKey = state.refreshKey;
196
+ var graph = afterData.graph, afterNodes = afterData.afterNodes, afterLinks = afterData.afterLinks, afterGroups = afterData.afterGroups, afterConfig = afterData.afterConfig;
197
+ var font = config.font, popoverPlacement = config.popoverPlacement, colors = config.colors, statusOngoing = config.statusOngoing, statusFail = config.statusFail, ongoingBackgroundColor = config.ongoingBackgroundColor;
198
+ var ratio = graph.thin ? graph.thinValue : 1;
199
+ var padding = ["px-1.5", 12];
200
+ var isDot = config.type === "dot";
201
+ var condVnodes = renderCondVnodes({
202
+ isDot,
203
+ afterLinks,
204
+ afterConfig,
205
+ config
206
+ });
207
+ var groupVnodes = renderGroupVnodes({
208
+ afterGroups,
209
+ clickGroup
210
+ });
211
+ return h("div", {
212
+ attrs: {
213
+ "data-tag": "tiny-flow-chart"
214
+ },
215
+ class: "relative",
216
+ style: wrapperStyle,
217
+ key: refreshKey
218
+ }, [h("canvas", {
219
+ attrs: {
220
+ "data-tag": "tiny-flow-chart__canvas",
221
+ width: graph.width * ratio,
222
+ height: graph.height * ratio
223
+ },
224
+ class: graph.thin ? "scale-50 -translate-x-1/4 -translate-y-1/4" : "absolute top-0 left-0",
225
+ ref: "canvas"
226
+ })].concat(afterNodes.map(function(afterNode) {
227
+ var x = afterNode.x, y = afterNode.y, width = afterNode.width, height = afterNode.height, raw = afterNode.raw;
228
+ var info = raw.info, renderInner = raw.renderInner;
229
+ var renderOuter = raw.renderOuter || config.renderOuter;
230
+ var other = info.other, shape = info.shape, status = info.status;
231
+ var main = other.main, auxi = other.auxi, error = other.error;
232
+ var popoverProps = {
233
+ props: {
234
+ trigger: "hover",
235
+ placement: popoverPlacement
236
+ },
237
+ class: "w-full block"
238
+ };
239
+ var renderLabel = getRenderLabel({
240
+ omitText,
241
+ font,
242
+ width,
243
+ padding,
244
+ popoverProps
245
+ });
246
+ var shapeVnodeChildren = renderShapeChildren({
247
+ renderInner,
248
+ raw,
249
+ renderLabel,
250
+ main,
251
+ auxi
252
+ });
253
+ var args = {
254
+ renderOuter,
255
+ raw,
256
+ colors,
257
+ status,
258
+ statusOngoing,
259
+ ongoingBackgroundColor
260
+ };
261
+ Object.assign(args, {
262
+ shape,
263
+ statusFail,
264
+ error,
265
+ shapeVnodeChildren,
266
+ popoverProps
267
+ });
268
+ var shapeVnode = renderShapeVnode(args);
269
+ var wrapperProps = {
270
+ attrs: {
271
+ "data-tag": "tiny-flow-chart__node"
272
+ },
273
+ style: "left:" + x + "px;top:" + y + "px;width:" + width + "px;height:" + height + "px;",
274
+ class: ["absolute", {
275
+ "flex justify-center items-center": isDot
276
+ }],
277
+ on: {
278
+ click: function click(e) {
279
+ return clickNode({
280
+ afterNode
281
+ }, e);
282
+ }
283
+ }
284
+ };
285
+ var outerClass = ["absolute w-6 h-6", {
286
+ "sm:w-4 sm:h-4": config.nodeSize === "mini",
287
+ "sm:w-8 sm:h-8": config.nodeSize === "medium"
288
+ }];
289
+ return h("div", wrapperProps, [isDot ? h("div", {
290
+ class: outerClass
291
+ }, [shapeVnode]) : shapeVnode]);
292
+ }), condVnodes, groupVnodes));
293
+ }
294
+ });
295
+ var __vue2_render, __vue2_staticRenderFns;
296
+ var __cssModules = {};
297
+ var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, __vue2_render, __vue2_staticRenderFns, false, __vue2_injectStyles);
298
+ function __vue2_injectStyles(context) {
299
+ for (var o in __cssModules) {
300
+ this[o] = __cssModules[o];
301
+ }
302
+ }
303
+ var mobileFirst = /* @__PURE__ */ function() {
304
+ return __component__.exports;
305
+ }();
306
+
307
+ export { mobileFirst as default };
package/lib/pc.js ADDED
@@ -0,0 +1,166 @@
1
+ import { renderless, api } from '@opentinyvue/vue-renderless/flowchart/vue';
2
+ import Clickoutside from '@opentinyvue/vue-renderless/common/deps/clickoutside';
3
+ import { defineComponent, props, directive, setup, emitter, h } from '@opentinyvue/vue-common';
4
+ import { IconYes, IconClose } from '@opentinyvue/vue-icon';
5
+
6
+ function normalizeComponent(scriptExports, render, staticRenderFns, functionalTemplate, injectStyles, scopeId, moduleIdentifier, shadowMode) {
7
+ var options = typeof scriptExports === "function" ? scriptExports.options : scriptExports;
8
+ if (render) {
9
+ options.render = render;
10
+ options.staticRenderFns = staticRenderFns;
11
+ options._compiled = true;
12
+ }
13
+ var hook;
14
+ if (injectStyles) {
15
+ hook = injectStyles;
16
+ }
17
+ if (hook) {
18
+ if (options.functional) {
19
+ options._injectStyles = hook;
20
+ var originalRender = options.render;
21
+ options.render = function renderWithStyleInjection(h, context) {
22
+ hook.call(context);
23
+ return originalRender(h, context);
24
+ };
25
+ } else {
26
+ var existing = options.beforeCreate;
27
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
28
+ }
29
+ }
30
+ return {
31
+ exports: scriptExports,
32
+ options
33
+ };
34
+ }
35
+
36
+ var __vue2_script = defineComponent({
37
+ emits: ["click-node", "click-link", "click-blank"],
38
+ props: [].concat(props, ["data", "config"]),
39
+ directives: directive({
40
+ Clickoutside
41
+ }),
42
+ setup: function setup$1(props2, context) {
43
+ return setup({
44
+ props: props2,
45
+ context,
46
+ renderless,
47
+ api,
48
+ extendOptions: {
49
+ emitter
50
+ }
51
+ });
52
+ },
53
+ render: function render() {
54
+ var slots = this.slots, state = this.state, clearHoverAfterLink = this.clearHoverAfterLink, clickNode = this.clickNode, config = this.config, getVars = this.getVars, omitText = this.omitText;
55
+ var afterData = state.afterData, dropdowns = state.dropdowns, refreshKey = state.refreshKey, wrapperStyle = state.wrapperStyle;
56
+ var afterNodes = afterData.afterNodes, allItem = afterData.allItem;
57
+ var nodes = afterNodes.map(function(afterNode) {
58
+ var ret = getVars(afterNode, config);
59
+ var background = ret.background, borderColor = ret.borderColor, half = ret.half, isCompleteFn = ret.isCompleteFn, isFailFn = ret.isFailFn, isOngoingFn = ret.isOngoingFn, statusName = ret.statusName, white = ret.white;
60
+ var halfIconWrapperSize = half(config.iconWrapperSize);
61
+ var wrapperStyle2 = "left:" + afterNode.x + "px;top:" + afterNode.y + "px;width:" + config.iconWrapperSize + "px;height:" + config.iconWrapperSize + "px;transform:translate(-" + halfIconWrapperSize + "px,-" + halfIconWrapperSize + "px);background:" + config.background + ";";
62
+ var halfIconSize = half(config.iconSize);
63
+ var iconWrapperPadding = halfIconWrapperSize - halfIconSize;
64
+ var iconStyle = "width:" + config.iconSize + "px;height:" + config.iconSize + "px;border-radius:" + halfIconSize + "px;border-color:" + borderColor + ";transform:translate(" + iconWrapperPadding + "px," + iconWrapperPadding + "px);background:" + background + ";";
65
+ var svgFill = isCompleteFn() ? borderColor : isFailFn() ? white : "";
66
+ var svgStyle = "font-size:" + config.iconSvgSize + "px;fill:" + svgFill + ";";
67
+ var iconComp = isCompleteFn() ? IconYes() : isFailFn() ? IconClose() : null;
68
+ var labelWidth = config.labelWidth || afterData.widths[1] - config.labelSpacing;
69
+ var labelHeight = config.labelHeight || afterData.heights[1] - config.labelSpacing;
70
+ var halfLabelWidth = half(labelWidth);
71
+ var labelTransform = config.anchor === "center" ? "translateX(" + (halfIconWrapperSize - halfLabelWidth) + "px)" : "";
72
+ var labelStyle = "width:" + labelWidth + "px;height:" + labelHeight + "px;transform:" + labelTransform + ";";
73
+ var baseStyle = "text-align:" + (config.anchor === "center" ? "center" : "left") + ";";
74
+ var titleStyle = baseStyle + ("color:" + (isOngoingFn() ? config.colors[config.statusOngoing] : "") + ";");
75
+ var dateStyle = baseStyle + ("color:" + config.labelDateColor + ";");
76
+ var valid = function valid2(arr) {
77
+ return Array.isArray(arr) && arr.length > config.listThreshold;
78
+ };
79
+ var showItem = slots.content && valid(afterNode.raw.info.items);
80
+ var itemStyle = "width:" + config.listWidth + "px;height:" + config.iconWrapperSize + "px;background:" + config.background + ";";
81
+ var params = {
82
+ afterNode,
83
+ node: afterNode.raw,
84
+ config,
85
+ allItem,
86
+ dropdowns,
87
+ showPop: dropdowns[afterNode.raw.name]
88
+ };
89
+ var iconVnode, lableVnodes;
90
+ if (slots.icon) {
91
+ iconVnode = slots.icon(params);
92
+ } else {
93
+ iconVnode = h("div", {
94
+ class: "tiny-flow-chart__node-icon " + statusName,
95
+ style: iconStyle
96
+ }, [iconComp ? h(iconComp, {
97
+ class: "tiny-flow-chart__node-svg",
98
+ style: svgStyle
99
+ }) : null]);
100
+ }
101
+ if (slots.label) {
102
+ lableVnodes = [slots.label(params)];
103
+ } else {
104
+ var property = {
105
+ class: "label-item label-title",
106
+ style: titleStyle
107
+ };
108
+ var t = omitText(afterNode.raw.info.label, config.font, labelWidth);
109
+ if (t.o) {
110
+ property.attrs = {
111
+ title: afterNode.raw.info.label
112
+ };
113
+ }
114
+ lableVnodes = [h("div", property, t.t), h("div", {
115
+ class: "label-item label-date",
116
+ style: dateStyle
117
+ }, afterNode.raw.info.date)];
118
+ }
119
+ return h("div", {
120
+ class: "tiny-flow-chart__node-icon-wrapper",
121
+ style: wrapperStyle2,
122
+ on: {
123
+ mousemove: clearHoverAfterLink,
124
+ click: function click(e) {
125
+ return clickNode(params, e);
126
+ }
127
+ }
128
+ }, [iconVnode, h("div", {
129
+ class: "tiny-flow-chart__node-label",
130
+ style: labelStyle
131
+ }, lableVnodes), showItem ? h("div", {
132
+ class: "tiny-flow-chart__node-item",
133
+ style: itemStyle
134
+ }, [slots.content(params)]) : null]);
135
+ });
136
+ return h("div", {
137
+ class: "tiny-flow-chart",
138
+ style: wrapperStyle,
139
+ key: refreshKey,
140
+ directives: [{
141
+ name: "clickoutside",
142
+ expression: "clearDropdown"
143
+ }]
144
+ }, [h("canvas", {
145
+ class: "tiny-flow-chart__canvas",
146
+ attrs: {
147
+ width: config.width,
148
+ height: config.height
149
+ },
150
+ ref: "canvas"
151
+ })].concat(nodes));
152
+ }
153
+ });
154
+ var __vue2_render, __vue2_staticRenderFns;
155
+ var __cssModules = {};
156
+ var __component__ = /* @__PURE__ */ normalizeComponent(__vue2_script, __vue2_render, __vue2_staticRenderFns, false, __vue2_injectStyles);
157
+ function __vue2_injectStyles(context) {
158
+ for (var o in __cssModules) {
159
+ this[o] = __cssModules[o];
160
+ }
161
+ }
162
+ var pc = /* @__PURE__ */ function() {
163
+ return __component__.exports;
164
+ }();
165
+
166
+ export { pc as default };
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@opentinyvue/vue-flowchart",
3
+ "version": "2.21.0",
4
+ "description": "",
5
+ "main": "./lib/index.js",
6
+ "module": "./lib/index.js",
7
+ "sideEffects": false,
8
+ "type": "module",
9
+ "dependencies": {
10
+ "@opentinyvue/vue-common": "~2.21.0",
11
+ "@opentinyvue/vue-icon": "~2.21.0",
12
+ "@opentinyvue/vue-popover": "~2.21.0",
13
+ "@opentinyvue/vue-renderless": "~3.21.0",
14
+ "@opentinyvue/vue-theme": "~3.21.0"
15
+ },
16
+ "license": "MIT",
17
+ "types": "index.d.ts",
18
+ "scripts": {
19
+ "build": "pnpm -w build:ui $npm_package_name",
20
+ "//postversion": "pnpm build"
21
+ }
22
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,80 @@
1
+ export declare const createNode: (name: any, status: any, label: any, date: any, items: any, row: any, col: any, other: any) => {
2
+ name: any;
3
+ info: {
4
+ status: any;
5
+ label: any;
6
+ date: any;
7
+ items: any;
8
+ row: any;
9
+ col: any;
10
+ other: any;
11
+ };
12
+ };
13
+ export declare const createLink: (from: any, to: any, p: any, status: any, style: any, other: any) => {
14
+ from: any;
15
+ to: any;
16
+ p: any;
17
+ info: {
18
+ status: any;
19
+ style: any;
20
+ other: any;
21
+ };
22
+ };
23
+ export declare const createItem: (key: any, name: any, role: any, status: any, comment: any, date: any, other: any) => {
24
+ key: any;
25
+ name: any;
26
+ role: any;
27
+ status: any;
28
+ comment: any;
29
+ date: any;
30
+ other: any;
31
+ };
32
+ export declare const createConfig: () => {
33
+ width: number;
34
+ height: number;
35
+ rows: number;
36
+ cols: number;
37
+ status: {
38
+ 1: string;
39
+ 2: string;
40
+ 3: string;
41
+ 4: string;
42
+ };
43
+ colors: {
44
+ 1: string;
45
+ 2: string;
46
+ 3: string;
47
+ 4: string;
48
+ };
49
+ background: string;
50
+ statusComplete: number;
51
+ statusOngoing: number;
52
+ statusFail: number;
53
+ anchor: string;
54
+ iconWrapperSize: number;
55
+ iconSize: number;
56
+ iconSvgSize: number;
57
+ labelSpacing: number;
58
+ labelWidth: number;
59
+ labelHeight: number;
60
+ labelDateColor: string;
61
+ listWidth: number;
62
+ listThreshold: number;
63
+ listIconSize: number;
64
+ listBorderColor: string;
65
+ listIconColor: string;
66
+ headUrl: string;
67
+ headSize: number;
68
+ drawLink: null;
69
+ styleLink: null;
70
+ styleHoverLink: null;
71
+ hoverHit: number;
72
+ checkItemStatus: null;
73
+ font: string;
74
+ delay: number;
75
+ adjustPos: null;
76
+ radius: number;
77
+ thin: boolean;
78
+ };
79
+ declare const _default: any;
80
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,9 @@
1
+ declare const resizeMixin: ({ apiPrefix, refName, nodeWrapperSize }: {
2
+ apiPrefix: any;
3
+ refName: any;
4
+ nodeWrapperSize: any;
5
+ }) => {
6
+ mounted(): void;
7
+ beforeUnmount(): void;
8
+ };
9
+ export default resizeMixin;