@opentiny/vue-renderless 3.6.8 → 3.8.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.
Files changed (314) hide show
  1. package/action-sheet/index.js +28 -1
  2. package/action-sheet/vue.js +10 -4
  3. package/alert/index.js +24 -2
  4. package/alert/vue.js +15 -11
  5. package/amount/index.js +4 -4
  6. package/anchor/index.js +1 -1
  7. package/autocomplete/vue.js +3 -3
  8. package/autonavi-map/index.js +1 -1
  9. package/badge/vue.js +6 -6
  10. package/baidu-map/index.js +1 -1
  11. package/bulletin-board/index.js +1 -1
  12. package/calendar/index.js +2 -2
  13. package/calendar-bar/index.js +268 -0
  14. package/calendar-bar/vue.js +87 -0
  15. package/card/index.js +84 -0
  16. package/card/vue.js +70 -0
  17. package/card-group/index.js +16 -0
  18. package/card-group/vue.js +21 -0
  19. package/card-template/index.js +1 -1
  20. package/carousel/index.js +89 -2
  21. package/carousel/vue.js +14 -5
  22. package/carousel-item/index.js +8 -0
  23. package/carousel-item/vue.js +7 -3
  24. package/cascader/index.js +6 -6
  25. package/cascader/vue.js +3 -3
  26. package/cascader-menu/vue.js +2 -2
  27. package/cascader-panel/index.js +4 -4
  28. package/cascader-panel/node.js +4 -4
  29. package/cascader-panel/vue.js +2 -2
  30. package/cascader-select/index.js +179 -0
  31. package/cascader-select/vue.js +74 -0
  32. package/cell/vue.js +16 -0
  33. package/chart-bar/index.js +3 -3
  34. package/chart-boxplot/index.js +2 -2
  35. package/chart-candle/index.js +3 -3
  36. package/chart-core/deps/utils.js +7 -7
  37. package/chart-core/index.js +2 -2
  38. package/chart-funnel/index.js +3 -3
  39. package/chart-gauge/index.js +3 -3
  40. package/chart-graph/index.js +1 -1
  41. package/chart-heatmap/index.js +2 -2
  42. package/chart-line/index.js +3 -3
  43. package/chart-liquidfill/index.js +2 -2
  44. package/chart-map/index.js +3 -3
  45. package/chart-pie/index.js +3 -3
  46. package/chart-radar/index.js +3 -3
  47. package/chart-sankey/index.js +3 -3
  48. package/chart-scatter/index.js +4 -4
  49. package/chart-sunburst/index.js +1 -1
  50. package/chart-tree/index.js +2 -2
  51. package/chart-waterfall/index.js +3 -3
  52. package/chart-wordcloud/index.js +2 -2
  53. package/checkbox/index.js +21 -0
  54. package/checkbox/vue.js +16 -3
  55. package/checkbox-button/vue.js +1 -1
  56. package/collapse-item/vue.js +1 -1
  57. package/column-list-group/index.js +0 -0
  58. package/column-list-group/vue.js +14 -0
  59. package/column-list-item/index.js +50 -0
  60. package/column-list-item/vue.js +39 -0
  61. package/common/array.js +3 -3
  62. package/common/bigInt.js +5 -2
  63. package/common/dataset/index.js +3 -3
  64. package/common/date.js +2 -2
  65. package/common/deps/ResizeObserver.js +1 -1
  66. package/common/deps/clickoutside.js +1 -1
  67. package/common/deps/date-util.js +4 -4
  68. package/common/deps/date.js +2 -2
  69. package/common/deps/debounce.js +1 -1
  70. package/common/deps/dom.js +1 -1
  71. package/common/deps/fullscreen/apis.js +3 -3
  72. package/common/deps/fullscreen/screenfull.js +1 -1
  73. package/common/deps/infinite-scroll.js +176 -0
  74. package/common/deps/letter-only.js +1 -1
  75. package/common/deps/number-only.js +1 -1
  76. package/common/deps/observe-visibility.js +106 -0
  77. package/common/deps/popper.js +20 -22
  78. package/common/deps/popup-manager.js +2 -2
  79. package/common/deps/repeat-click.js +1 -1
  80. package/common/deps/resize-event.js +1 -1
  81. package/common/deps/tree-model/node.js +5 -5
  82. package/common/deps/tree-model/tree-store.js +3 -3
  83. package/common/deps/upload-ajax.js +2 -2
  84. package/common/deps/vue-popper.js +4 -4
  85. package/common/deps/vue-popup.js +4 -4
  86. package/common/index.js +2 -2
  87. package/common/object.js +1 -1
  88. package/common/runtime.js +24 -24
  89. package/common/string.js +23 -4
  90. package/common/validate/rules/range.js +2 -2
  91. package/common/validate/rules/required.js +1 -1
  92. package/common/validate/rules/type.js +3 -3
  93. package/common/validate/schema.js +1 -1
  94. package/common/validate/util.js +1 -1
  95. package/common/validate/validations/array.js +1 -1
  96. package/common/validate/validations/date.js +1 -1
  97. package/common/validate/validations/enum.js +1 -1
  98. package/common/validate/validations/float.js +1 -1
  99. package/common/validate/validations/integer.js +1 -1
  100. package/common/validate/validations/method.js +1 -1
  101. package/common/validate/validations/number.js +1 -1
  102. package/common/validate/validations/pattern.js +1 -1
  103. package/common/validate/validations/string.js +1 -1
  104. package/common/validate/validations/type.js +1 -1
  105. package/container/index.js +1 -1
  106. package/crop/index.js +2 -2
  107. package/currency/index.js +2 -2
  108. package/date-panel/index.js +7 -7
  109. package/date-panel/vue.js +3 -2
  110. package/date-picker-mobile/index.js +250 -0
  111. package/date-picker-mobile/vue.js +86 -0
  112. package/date-range/index.js +1 -1
  113. package/date-range/vue.js +1 -1
  114. package/date-table/index.js +3 -3
  115. package/date-table/vue.js +1 -1
  116. package/dialog-box/index.js +6 -4
  117. package/dialog-box/vue.js +1 -1
  118. package/dialog-select/index.js +345 -0
  119. package/dialog-select/vue.js +110 -0
  120. package/drawer/index.js +83 -0
  121. package/drawer/vue.js +51 -0
  122. package/drop-times/index.js +1 -1
  123. package/dropdown/index.js +2 -2
  124. package/dropdown/vue.js +1 -1
  125. package/dropdown-item/index.js +1 -1
  126. package/dropdown-item/mf.js +79 -0
  127. package/dropdown-menu/index.js +30 -1
  128. package/dropdown-menu/vue.js +17 -7
  129. package/dynamic-scroller/index.js +117 -0
  130. package/dynamic-scroller/vue.js +88 -0
  131. package/dynamic-scroller-item/index.js +147 -0
  132. package/dynamic-scroller-item/vue.js +92 -0
  133. package/espace/index.js +1 -1
  134. package/espace/vue.js +1 -1
  135. package/exception/vue.js +3 -1
  136. package/fall-menu/index.js +4 -4
  137. package/file-upload/index.js +872 -408
  138. package/file-upload/vue.js +87 -36
  139. package/filter/index.js +131 -0
  140. package/filter/tag-group.js +43 -0
  141. package/filter/vue.js +73 -0
  142. package/filter-bar/index.js +9 -0
  143. package/filter-bar/vue.js +16 -0
  144. package/filter-box/index.js +17 -0
  145. package/filter-box/vue.js +19 -0
  146. package/filter-panel/index.js +42 -0
  147. package/filter-panel/vue.js +33 -0
  148. package/floatbar/index.js +1 -1
  149. package/flowchart/index.js +721 -0
  150. package/flowchart/vue.js +81 -0
  151. package/form/index.js +15 -1
  152. package/form/vue.js +10 -4
  153. package/form-item/index.js +46 -6
  154. package/form-item/vue.js +27 -3
  155. package/fullscreen/index.js +1 -1
  156. package/fullscreen/vue.js +1 -1
  157. package/grid/plugins/export.js +2 -2
  158. package/grid/plugins/exportExcel.js +2 -2
  159. package/grid/plugins/resize.js +1 -1
  160. package/grid/static/base/helperEqualCompare.js +1 -1
  161. package/grid/static/base/isPlainObject.js +1 -1
  162. package/grid/utils/common.js +3 -3
  163. package/grid/utils/dom.js +3 -3
  164. package/grid/utils/event.js +2 -2
  165. package/guide/index.js +168 -0
  166. package/guide/vue.js +36 -0
  167. package/hrapprover/index.js +1 -1
  168. package/image/index.js +8 -4
  169. package/image/vue.js +12 -6
  170. package/image-viewer/index.js +3 -3
  171. package/image-viewer/vue.js +16 -6
  172. package/input/index.js +34 -1
  173. package/input/vue.js +22 -6
  174. package/ip-address/index.js +1 -1
  175. package/ip-address/vue.js +1 -1
  176. package/link-menu/index.js +2 -2
  177. package/link-menu/vue.js +2 -2
  178. package/loading/index.js +2 -2
  179. package/loading/vue.js +2 -1
  180. package/locales/index.js +1 -1
  181. package/logout/index.js +1 -1
  182. package/milestone/index.js +5 -1
  183. package/modal/index.js +68 -39
  184. package/modal/vue.js +15 -12
  185. package/month-range/index.js +1 -1
  186. package/month-range/vue.js +1 -1
  187. package/month-table/index.js +5 -5
  188. package/month-table/vue.js +1 -1
  189. package/multi-select/index.js +5 -2
  190. package/multi-select/vue.js +4 -5
  191. package/nav-menu/index.js +6 -6
  192. package/notify/index.js +3 -3
  193. package/numeric/index.js +15 -5
  194. package/numeric/vue.js +15 -6
  195. package/option/index.js +1 -1
  196. package/package.json +2 -1
  197. package/pager-item/index.js +1 -1
  198. package/panel/index.js +1 -1
  199. package/picker/index.js +7 -7
  200. package/picker/vue.js +1 -1
  201. package/picker-column/index.js +1 -1
  202. package/popconfirm/index.js +25 -0
  203. package/popconfirm/vue.js +22 -0
  204. package/popeditor/index.js +7 -7
  205. package/popeditor/vue.js +2 -2
  206. package/popover/index.js +11 -3
  207. package/popover/vue.js +33 -10
  208. package/popup/index.js +4 -4
  209. package/pull-refresh/index.js +8 -11
  210. package/pull-refresh/vue.js +7 -7
  211. package/radio/index.js +17 -0
  212. package/radio/vue.js +18 -3
  213. package/radio-button/index.js +8 -0
  214. package/radio-button/vue.js +19 -4
  215. package/radio-group/index.js +1 -1
  216. package/radio-group/vue.js +5 -2
  217. package/rate/index.js +4 -2
  218. package/rate/vue.js +1 -1
  219. package/record/index.js +190 -0
  220. package/record/vue.js +44 -0
  221. package/recycle-scroller/index.js +470 -0
  222. package/recycle-scroller/vue.js +135 -0
  223. package/river/index.js +371 -0
  224. package/river/river.js +352 -0
  225. package/river/vue.js +77 -0
  226. package/roles/index.js +1 -1
  227. package/scrollbar/vue-bar.js +1 -1
  228. package/scrollbar/vue.js +1 -1
  229. package/search/index.js +3 -3
  230. package/select/index.js +17 -14
  231. package/select/vue.js +14 -8
  232. package/select-dropdown/vue.js +1 -1
  233. package/select-mobile/index.js +111 -0
  234. package/select-mobile/vue.js +58 -0
  235. package/select-view/index.js +170 -0
  236. package/select-view/vue.js +82 -0
  237. package/selected-box/index.js +216 -0
  238. package/selected-box/vue.js +98 -0
  239. package/slide-bar/index.js +1 -1
  240. package/slider/index.js +49 -4
  241. package/slider/vue.js +15 -4
  242. package/split/vue.js +1 -1
  243. package/standard-list-item/index.js +18 -0
  244. package/standard-list-item/vue.js +22 -0
  245. package/steps/index.js +30 -0
  246. package/steps/slide-bar.js +122 -0
  247. package/steps/vue.js +15 -3
  248. package/switch/index.js +1 -1
  249. package/switch/vue.js +2 -1
  250. package/tab-bar/index.js +2 -2
  251. package/tab-item/index.js +2 -2
  252. package/tab-item/vue.js +1 -1
  253. package/tab-item-mf/index.js +0 -0
  254. package/tab-item-mf/vue.js +16 -0
  255. package/tab-nav/index.js +78 -4
  256. package/tab-nav/vue.js +11 -3
  257. package/tabbar-item/index.js +1 -1
  258. package/tabbar-item/vue.js +1 -1
  259. package/tabs/index.js +8 -9
  260. package/tabs/vue.js +1 -1
  261. package/tabs-mf/index.js +109 -0
  262. package/tabs-mf/vue-bar.js +49 -0
  263. package/tabs-mf/vue-nav-item.js +22 -0
  264. package/tabs-mf/vue-nav.js +13 -0
  265. package/tabs-mf/vue.js +45 -0
  266. package/tabs-mf/wheel.js +71 -0
  267. package/tag/index.js +8 -2
  268. package/tag/vue.js +13 -5
  269. package/tag-group/index.js +24 -0
  270. package/tag-group/vue.js +29 -0
  271. package/tall-storage/index.js +1 -1
  272. package/tall-storage/vue.js +1 -1
  273. package/time/index.js +1 -1
  274. package/time/vue.js +2 -2
  275. package/time-line/index.js +28 -7
  276. package/time-line/vue.js +9 -4
  277. package/time-panel/index.js +2 -2
  278. package/time-panel/vue.js +1 -1
  279. package/time-picker-mobile/index.js +30 -0
  280. package/time-picker-mobile/vue.js +30 -0
  281. package/time-range/index.js +1 -1
  282. package/time-range/vue.js +1 -1
  283. package/time-spinner/index.js +2 -2
  284. package/time-spinner/vue.js +1 -1
  285. package/toggle-menu/index.js +2 -2
  286. package/toggle-menu/vue.js +1 -1
  287. package/tooltip/index.js +30 -3
  288. package/tooltip/vue.js +33 -12
  289. package/top-box/index.js +3 -3
  290. package/transfer/index.js +1 -1
  291. package/transfer-panel/index.js +2 -2
  292. package/tree/index.js +6 -6
  293. package/tree/vue.js +1 -1
  294. package/tree-node/index.js +1 -1
  295. package/upload/index.js +1 -1
  296. package/upload/vue.js +2 -2
  297. package/upload-dragger/index.js +5 -1
  298. package/upload-dragger/vue.js +9 -3
  299. package/upload-list/index.js +158 -8
  300. package/upload-list/vue.js +77 -25
  301. package/user/index.js +86 -70
  302. package/user/vue.js +15 -5
  303. package/user-account/vue.js +1 -1
  304. package/user-contact/index.js +49 -3
  305. package/user-contact/vue.js +17 -8
  306. package/user-head-group/vue.js +17 -0
  307. package/user-link/index.js +10 -2
  308. package/user-link/vue.js +11 -6
  309. package/wheel/index.js +1 -1
  310. package/wizard/index.js +3 -3
  311. package/year-range/index.js +125 -0
  312. package/year-range/vue.js +88 -0
  313. package/year-table/index.js +175 -11
  314. package/year-table/vue.js +17 -5
package/river/index.js ADDED
@@ -0,0 +1,371 @@
1
+ import {
2
+ __spreadProps,
3
+ __spreadValues
4
+ } from "../chunk-PKUHTIDK.js";
5
+ import { layout, bpath, txt, hexToRgba } from "./river";
6
+ const buildOption = ({ api, emit, props, state, vm }) => () => {
7
+ const WIDTH = state.canvasWidth = api.getContainerWidth() || props.config.canvasWidth;
8
+ const {
9
+ statusYes: STATUS_YES,
10
+ statusNo: STATUS_NO,
11
+ canvasHeight: HEIGHT,
12
+ statusColor: STATUS_COLOR,
13
+ tooltip: userTooltip,
14
+ title: userTitle
15
+ } = props.config;
16
+ const chartData = layout(props.data, __spreadProps(__spreadValues({}, props.config), { canvasWidth: WIDTH }), vm.$el);
17
+ const chartNodeData = chartData.filter((item) => item.type === "node");
18
+ const chartLinkData = chartData.filter((item) => item.type === "link");
19
+ const chartIconData = chartData.filter((item) => item.type === "icon");
20
+ const chartLegeData = chartData.filter((item) => item.type === "lege");
21
+ state.nameInfo = chartData.find((item) => item.type === "name");
22
+ emit("paths", JSON.parse(JSON.stringify(state.nameInfo.paths)));
23
+ const renderNode = api.getRenderNode(chartNodeData);
24
+ const renderLink = api.getRenderLink(chartLinkData);
25
+ const renderIcon = api.getRenderIcon({ chartIconData, STATUS_COLOR, STATUS_YES, STATUS_NO });
26
+ const renderLege = api.getRenderLege(chartLegeData);
27
+ const serieLine = api.getMarkLine(HEIGHT);
28
+ const tooltip = api.getTooltip({ userTooltip, chartData });
29
+ const option = {
30
+ grid: { left: "0%", right: "0%", bottom: "0%", top: "0%" },
31
+ xAxis: { min: 0, max: WIDTH, show: false },
32
+ yAxis: { min: 0, max: HEIGHT, show: false },
33
+ series: [
34
+ { type: "custom", name: "1", renderItem: renderNode, data: chartNodeData, zlevel: 1 },
35
+ { type: "custom", name: "2", renderItem: renderLink, data: chartLinkData, zlevel: 2 },
36
+ { type: "custom", name: "3", renderItem: renderIcon, data: chartIconData, zlevel: 3 },
37
+ { type: "custom", name: "4", renderItem: renderLege, data: chartLegeData, zlevel: 4 },
38
+ serieLine
39
+ ],
40
+ tooltip: { formatter: tooltip },
41
+ title: userTitle
42
+ };
43
+ return option;
44
+ };
45
+ const getRenderNode = ({ api: api0, echarts }) => (chartNodeData) => {
46
+ const so = api0.setRiverRgbaOpacity;
47
+ return (params, api) => {
48
+ const { dataIndex, coordSys } = params;
49
+ const { x: sx, y: sy, width: sw, height: sh } = coordSys;
50
+ const data = chartNodeData[dataIndex];
51
+ const { x, y, width, height, g, lp, data: dataNode } = data;
52
+ const rectShape = echarts.graphic.clipRectByRect({ x, y, width, height }, { x: sx, y: sy, width: sw, height: sh });
53
+ const lg = g[0].map((stop, i) => ({ offset: stop, color: so(dataNode, g[1][i]) }));
54
+ const nodeLabel = txt(dataNode.label, api.font({}), lp[2]);
55
+ return {
56
+ type: "group",
57
+ name: "node-group",
58
+ children: [
59
+ {
60
+ type: "rect",
61
+ transition: ["shape"],
62
+ shape: rectShape,
63
+ style: { fill: new echarts.graphic.LinearGradient(0, 0, 1, 0, lg) }
64
+ },
65
+ {
66
+ type: "text",
67
+ style: {
68
+ x: lp[0],
69
+ y: lp[1],
70
+ text: nodeLabel.t,
71
+ textFill: so(dataNode, "rgba(0,0,0,1)")
72
+ }
73
+ }
74
+ ]
75
+ };
76
+ };
77
+ };
78
+ const getRenderLink = ({ api, echarts }) => (chartLinkData) => {
79
+ const so = api.setRiverRgbaOpacity;
80
+ return (params) => {
81
+ const { dataIndex } = params;
82
+ const data = chartLinkData[dataIndex];
83
+ const { lb, g, data: dataLink } = data;
84
+ const [posX, posY] = lb;
85
+ const p = bpath(data);
86
+ const lg = g[0].map((stop, i) => ({ offset: stop, color: so(dataLink, g[1][i]) }));
87
+ return {
88
+ type: "group",
89
+ name: "link-group",
90
+ position: [posX, posY],
91
+ children: [
92
+ {
93
+ type: "path",
94
+ transition: ["shape"],
95
+ shape: { d: p },
96
+ style: { fill: new echarts.graphic.LinearGradient(0, 0, 1, 0, lg) }
97
+ }
98
+ ]
99
+ };
100
+ };
101
+ };
102
+ const getRenderIcon = ({ api: api0 }) => ({ chartIconData, STATUS_COLOR, STATUS_YES, STATUS_NO }) => {
103
+ const so = api0.setRiverRgbaOpacity;
104
+ const si = api0.setRiverIconStyle;
105
+ return (params, api) => {
106
+ const { dataIndex } = params;
107
+ const data = chartIconData[dataIndex];
108
+ const { x, y, radius, lp, data: dataIcon } = data;
109
+ const { status, text, skip } = dataIcon;
110
+ if (skip)
111
+ return null;
112
+ const circleFill = STATUS_COLOR[String(status)];
113
+ const labelText = txt(dataIcon.label, api.font({}), lp[2]);
114
+ const labelTextX = labelText.o ? lp[0] - x : lp[0] + lp[2] / 2 - x;
115
+ const labelTextTa = labelText.o ? "" : "center";
116
+ const iconText = getIconText({ status, STATUS_YES, STATUS_NO, text, api, si, dataIcon });
117
+ return {
118
+ type: "group",
119
+ position: [x, y],
120
+ children: [
121
+ {
122
+ type: "circle",
123
+ transition: ["shape"],
124
+ shape: { cx: 0, cy: 0, r: si(dataIcon, "radius", radius) },
125
+ style: { fill: so(dataIcon, hexToRgba(si(dataIcon, "fill", circleFill))) }
126
+ },
127
+ {
128
+ type: "text",
129
+ style: {
130
+ x: labelTextX,
131
+ y: lp[1] - y,
132
+ text: labelText.t,
133
+ textFill: so(dataIcon, hexToRgba(si(dataIcon, "labelColor", "#000"))),
134
+ textAlign: labelTextTa
135
+ }
136
+ },
137
+ iconText
138
+ ]
139
+ };
140
+ };
141
+ };
142
+ const getIconText = ({ status, STATUS_YES, STATUS_NO, text, api, si, dataIcon }) => {
143
+ let tmp = { type: "path", transition: ["shape"], shape: {}, style: { fill: si(dataIcon, "color", "#fff") } };
144
+ if (status === STATUS_YES) {
145
+ tmp.shape.d = "M-1.7 4.5l9.4-9.4c.4-.4 1-.4 1.4 0 .4.4.4 1 0 1.4l-10 10.1c-.4.4-1 .4-1.";
146
+ tmp.shape.d += "4 0-.1 0-.1-.1-.2-.1l-5.8-5.8c-.4-.4-.4-1 0-1.4.4-.4 1-.4 1.4 0l5.2 5.2z";
147
+ } else if (status === STATUS_NO) {
148
+ tmp.shape.d = "M19.1 1.6H-6.9c-.5 0-.9-.4-.9-1s.4-1 .9-1h14.2c.5 0 .9.4.9 1s-.4 1-.9 1z";
149
+ } else {
150
+ tmp = {
151
+ type: "text",
152
+ style: {
153
+ x: 0,
154
+ y: 1,
155
+ text,
156
+ textVerticalAlign: "middle",
157
+ textAlign: "center",
158
+ textFill: si(dataIcon, "color", "#fff"),
159
+ textFont: api.font({ fontSize: 14 })
160
+ }
161
+ };
162
+ }
163
+ return tmp;
164
+ };
165
+ const getRenderLege = () => (chartLegeData) => {
166
+ return (params, api) => {
167
+ const { dataIndex } = params;
168
+ const data = chartLegeData[dataIndex];
169
+ const { cx, cy, radius, color, x, y, t, tw } = data;
170
+ const legeLabel = txt(t, api.font({}), tw);
171
+ return {
172
+ type: "group",
173
+ name: "lege-group",
174
+ children: [
175
+ { type: "circle", transition: ["shape"], shape: { cx, cy, r: radius }, style: { fill: color } },
176
+ {
177
+ type: "text",
178
+ style: { x, y, text: legeLabel.t, textVerticalAlign: "middle", textAlign: "left", textFill: color }
179
+ }
180
+ ]
181
+ };
182
+ };
183
+ };
184
+ const getTooltip = () => ({ userTooltip, chartData }) => {
185
+ return (params) => {
186
+ const { data } = params;
187
+ const { data: dataItem, type, t: legeLabel, color: legeColor } = data;
188
+ if (typeof userTooltip === "function") {
189
+ return userTooltip(params, chartData);
190
+ } else if (type === "node") {
191
+ return dataItem.label;
192
+ } else if (type === "icon") {
193
+ return `
194
+ <div>Status: ${dataItem.status}</div>
195
+ <div>Label: ${dataItem.label}</div>
196
+ `;
197
+ } else if (type === "link") {
198
+ const riverNodes = chartData.filter((item) => item.type === "node");
199
+ const sourceRiverNode = riverNodes.find((riverNode) => riverNode.data.name === dataItem.source);
200
+ const targetRiverNode = riverNodes.find((riverNode) => riverNode.data.name === dataItem.target);
201
+ return `
202
+ <div>From: ${sourceRiverNode.data.label}</div>
203
+ <div>To: ${targetRiverNode.data.label}</div>
204
+ <div>Val: ${dataItem.value}</div>
205
+ `;
206
+ } else if (type === "lege") {
207
+ return `<div style="background:${legeColor};color:#fff">${legeLabel}</div>`;
208
+ }
209
+ };
210
+ };
211
+ const getMarkLine = () => (h) => ({
212
+ type: "line",
213
+ symbol: "none",
214
+ data: [
215
+ [0, 0],
216
+ [0, h]
217
+ ],
218
+ lineStyle: { width: 1, type: [2, 6], color: "#fff" },
219
+ zlevel: 0
220
+ });
221
+ const setChartOption = (state) => (option) => state.myChart.setOption(option);
222
+ const setListeners = ({ api, emit, state }) => (option) => {
223
+ const modifyOption = (option2, riverIcon) => {
224
+ const serieLine = option2.series.find((serie) => serie.type === "line");
225
+ if (riverIcon) {
226
+ const { x } = riverIcon;
227
+ serieLine.data[0][0] = serieLine.data[1][0] = x;
228
+ serieLine.lineStyle.color = "#000";
229
+ } else {
230
+ serieLine.lineStyle.color = "#fff";
231
+ }
232
+ return option2;
233
+ };
234
+ state.myChart.on("mousemove", { seriesName: "3" }, (params) => {
235
+ if (!state.markLineShow) {
236
+ api.setChartOption(modifyOption(option, params.data));
237
+ state.markLineShow = true;
238
+ }
239
+ });
240
+ state.myChart.getZr().on("mousemove", (event) => {
241
+ const notIcon = (parent = event.target) => {
242
+ do {
243
+ if (~["link-group", "node-group"].indexOf(parent.name))
244
+ return true;
245
+ } while (parent = parent.parent);
246
+ };
247
+ if (state.markLineShow && (!event.target || notIcon())) {
248
+ api.setChartOption(modifyOption(option));
249
+ state.markLineShow = false;
250
+ }
251
+ });
252
+ state.myChart.on("click", { seriesName: "1" }, (params) => emit("click-node", params));
253
+ state.myChart.on("click", { seriesName: "2" }, (params) => emit("click-link", params));
254
+ state.myChart.on("click", { seriesName: "3" }, (params) => emit("click-icon", params));
255
+ state.myChart.on("click", { seriesName: "4" }, (params) => emit("click-lege", params));
256
+ };
257
+ const setRiverRgbaOpacity = ({ props, state }) => (data, rgba) => {
258
+ const { config } = props;
259
+ const { nameInfo, lighting } = state;
260
+ const { nameField } = nameInfo;
261
+ const { grayOpcity, lightOpcity } = config;
262
+ const isw = (arr, name) => arr.find((item) => !name.indexOf(`${item}/`));
263
+ if (lighting && lighting.length) {
264
+ const ci = rgba.lastIndexOf(",");
265
+ const bi = rgba.lastIndexOf(")");
266
+ const dataName = data[nameField];
267
+ if (~lighting.indexOf(dataName)) {
268
+ return rgba.slice(0, ci + 1) + lightOpcity + rgba.slice(bi);
269
+ } else if (isw(lighting, dataName)) {
270
+ return rgba.slice(0, ci + 1) + 1 + rgba.slice(bi);
271
+ } else {
272
+ return rgba.slice(0, ci + 1) + grayOpcity + rgba.slice(bi);
273
+ }
274
+ } else {
275
+ return rgba;
276
+ }
277
+ };
278
+ const lightUp = ({ api, state }) => (param) => {
279
+ const { nameInfo } = state;
280
+ const { paths, nameSplit } = nameInfo;
281
+ const getIndexVal = (i) => i >= 0 && i < paths.length ? paths[i].split(nameSplit) : [];
282
+ const getPathVal = (path) => path ? path.split(nameSplit) : [];
283
+ const getArrayVal = (arr) => {
284
+ let res = [];
285
+ arr.forEach((item) => {
286
+ if (typeof item === "number")
287
+ res = res.concat(getIndexVal(item));
288
+ else if (typeof item === "string")
289
+ res = res.concat(getPathVal(item));
290
+ res = [...new Set(res)];
291
+ });
292
+ return res;
293
+ };
294
+ if (typeof param === "number") {
295
+ state.lighting = getIndexVal(param);
296
+ } else if (typeof param === "string") {
297
+ state.lighting = getPathVal(param);
298
+ } else if (Array.isArray(param) && param.length) {
299
+ state.lighting = getArrayVal(param);
300
+ } else {
301
+ state.lighting = [];
302
+ }
303
+ api.setChartOption(state.option);
304
+ };
305
+ const setRiverIconStyle = (state) => (data, type, oldValue) => {
306
+ const { styling, nameInfo } = state;
307
+ const { nameField } = nameInfo;
308
+ const dataName = data[nameField];
309
+ if (styling && styling.length) {
310
+ for (let i = 0; i < styling.length; i++) {
311
+ const stl = styling[i];
312
+ if (stl.name && dataName === stl.name && type && stl[type])
313
+ return stl[type];
314
+ }
315
+ }
316
+ return oldValue;
317
+ };
318
+ const style = ({ api, state }) => (param) => {
319
+ const styl = (obj) => {
320
+ const { nodeName, iconIndex, styles } = obj;
321
+ return Object.assign({}, styles, { name: `n${nodeName}/${iconIndex}`.toLowerCase() });
322
+ };
323
+ if (Array.isArray(param)) {
324
+ const styling = [];
325
+ param.forEach((item) => styling.push(styl(item)));
326
+ state.styling = styling;
327
+ } else if (typeof param === "object") {
328
+ state.styling = [styl(param)];
329
+ } else {
330
+ state.styling = [];
331
+ }
332
+ api.setChartOption(state.option);
333
+ };
334
+ const computeCanvasStyle = ({ props, state }) => () => {
335
+ const { canvasWidth, canvasTransformOrigin, canvasTransform } = state;
336
+ const { canvasHeight } = props.config;
337
+ const res = {};
338
+ if (canvasWidth)
339
+ res.width = canvasWidth + "px";
340
+ if (canvasHeight)
341
+ res.height = canvasHeight + "px";
342
+ if (canvasTransformOrigin)
343
+ res.transformOrigin = canvasTransformOrigin;
344
+ if (canvasTransform)
345
+ res.transform = canvasTransform;
346
+ return res;
347
+ };
348
+ const getContainerWidth = (state) => () => state.containerEl && state.containerEl.getBoundingClientRect().width;
349
+ const resizeListener = ({ props, state }) => () => {
350
+ const { ignoreZoom = true } = props.config;
351
+ const ratio = ignoreZoom ? window.innerWidth / window.outerWidth : 1;
352
+ state.canvasTransform = "scale(" + ratio + ")";
353
+ };
354
+ export {
355
+ buildOption,
356
+ computeCanvasStyle,
357
+ getContainerWidth,
358
+ getMarkLine,
359
+ getRenderIcon,
360
+ getRenderLege,
361
+ getRenderLink,
362
+ getRenderNode,
363
+ getTooltip,
364
+ lightUp,
365
+ resizeListener,
366
+ setChartOption,
367
+ setListeners,
368
+ setRiverIconStyle,
369
+ setRiverRgbaOpacity,
370
+ style
371
+ };