vxe-pc-ui 4.14.4 → 4.14.6

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 (480) hide show
  1. package/LICENSE +21 -21
  2. package/README.en.md +72 -72
  3. package/README.ja-JP.md +72 -72
  4. package/README.md +364 -364
  5. package/README.zh-TW.md +73 -73
  6. package/es/tree/src/tree.js +31 -2
  7. package/es/tree-select/src/tree-select.js +2 -0
  8. package/es/ui/index.js +1 -1
  9. package/es/ui/src/log.js +1 -1
  10. package/lib/index.umd.js +2359 -2257
  11. package/lib/index.umd.min.js +1 -1
  12. package/lib/tree/src/tree.js +27 -2
  13. package/lib/tree/src/tree.min.js +1 -1
  14. package/lib/tree-select/src/tree-select.js +2 -0
  15. package/lib/tree-select/src/tree-select.min.js +1 -1
  16. package/lib/ui/index.js +1 -1
  17. package/lib/ui/index.min.js +1 -1
  18. package/lib/ui/src/log.js +1 -1
  19. package/lib/ui/src/log.min.js +1 -1
  20. package/package.json +88 -88
  21. package/packages/alert/index.ts +16 -16
  22. package/packages/alert/src/alert.ts +124 -124
  23. package/packages/anchor/index.ts +16 -16
  24. package/packages/anchor/src/anchor-link.ts +121 -121
  25. package/packages/anchor/src/anchor.ts +237 -237
  26. package/packages/anchor/src/util.ts +23 -23
  27. package/packages/anchor-link/index.ts +16 -16
  28. package/packages/avatar/index.ts +16 -16
  29. package/packages/avatar/src/avatar.ts +149 -149
  30. package/packages/backtop/index.ts +16 -16
  31. package/packages/backtop/src/backtop.ts +314 -314
  32. package/packages/badge/index.ts +16 -16
  33. package/packages/badge/src/badge.ts +100 -100
  34. package/packages/breadcrumb/index.ts +16 -16
  35. package/packages/breadcrumb/src/breadcrumb-item.ts +106 -106
  36. package/packages/breadcrumb/src/breadcrumb.ts +92 -92
  37. package/packages/breadcrumb-item/index.ts +16 -16
  38. package/packages/button/index.ts +16 -16
  39. package/packages/button/src/button-group.ts +110 -110
  40. package/packages/button/src/button.ts +841 -841
  41. package/packages/button-group/index.ts +16 -16
  42. package/packages/calendar/index.ts +16 -16
  43. package/packages/calendar/src/calendar.ts +1351 -1351
  44. package/packages/card/index.ts +16 -16
  45. package/packages/card/src/card.ts +175 -175
  46. package/packages/carousel/index.ts +16 -16
  47. package/packages/carousel/src/carousel-item.ts +102 -102
  48. package/packages/carousel/src/carousel.ts +414 -414
  49. package/packages/carousel/src/util.ts +21 -21
  50. package/packages/carousel-item/index.ts +16 -16
  51. package/packages/cascader/index.ts +16 -16
  52. package/packages/cascader/src/cascader.ts +741 -741
  53. package/packages/checkbox/index.ts +16 -16
  54. package/packages/checkbox/src/button.ts +144 -144
  55. package/packages/checkbox/src/checkbox.ts +154 -154
  56. package/packages/checkbox/src/group.ts +222 -222
  57. package/packages/checkbox-button/index.ts +16 -16
  58. package/packages/checkbox-group/index.ts +16 -16
  59. package/packages/col/index.ts +16 -16
  60. package/packages/collapse/index.ts +16 -16
  61. package/packages/collapse/src/collapse-pane.ts +114 -114
  62. package/packages/collapse/src/collapse.ts +284 -284
  63. package/packages/collapse/src/util.ts +21 -21
  64. package/packages/collapse-pane/index.ts +16 -16
  65. package/packages/color-picker/index.ts +16 -16
  66. package/packages/color-picker/src/color-picker.ts +1109 -1109
  67. package/packages/color-picker/src/util.ts +198 -198
  68. package/packages/components.ts +307 -307
  69. package/packages/context-menu/index.ts +54 -54
  70. package/packages/context-menu/src/context-menu.ts +681 -681
  71. package/packages/countdown/index.ts +16 -16
  72. package/packages/countdown/src/countdown.ts +262 -262
  73. package/packages/date-panel/index.ts +16 -16
  74. package/packages/date-panel/src/date-panel.ts +1809 -1809
  75. package/packages/date-panel/src/util.ts +244 -244
  76. package/packages/date-picker/index.ts +16 -16
  77. package/packages/date-picker/src/date-picker.ts +1071 -1071
  78. package/packages/date-range-picker/index.ts +16 -16
  79. package/packages/date-range-picker/src/date-range-picker.ts +1280 -1280
  80. package/packages/drawer/index.ts +77 -77
  81. package/packages/drawer/src/drawer.ts +657 -657
  82. package/packages/dynamics/index.ts +89 -89
  83. package/packages/empty/index.ts +16 -16
  84. package/packages/empty/src/empty.ts +100 -100
  85. package/packages/form/index.ts +16 -16
  86. package/packages/form/render/index.ts +598 -598
  87. package/packages/form/src/form-config-item.ts +72 -72
  88. package/packages/form/src/form-group.ts +86 -86
  89. package/packages/form/src/form-item.ts +174 -174
  90. package/packages/form/src/form.ts +987 -987
  91. package/packages/form/src/itemInfo.ts +80 -80
  92. package/packages/form/src/render.ts +387 -387
  93. package/packages/form/src/util.ts +93 -93
  94. package/packages/form-gather/index.ts +26 -26
  95. package/packages/form-group/index.ts +16 -16
  96. package/packages/form-item/index.ts +16 -16
  97. package/packages/icon/index.ts +16 -16
  98. package/packages/icon/src/icon.ts +75 -75
  99. package/packages/icon-picker/index.ts +16 -16
  100. package/packages/icon-picker/src/icon-picker.ts +626 -626
  101. package/packages/image/index.ts +16 -16
  102. package/packages/image/src/group.ts +153 -153
  103. package/packages/image/src/image.ts +298 -298
  104. package/packages/image/src/preview.ts +672 -672
  105. package/packages/image/src/util.ts +59 -59
  106. package/packages/image-group/index.ts +16 -16
  107. package/packages/image-preview/index.ts +19 -19
  108. package/packages/index.ts +4 -4
  109. package/packages/input/index.ts +16 -16
  110. package/packages/input/src/input.ts +2788 -2788
  111. package/packages/language/ar-EG.ts +840 -840
  112. package/packages/language/de-DE.ts +840 -840
  113. package/packages/language/en-US.ts +840 -840
  114. package/packages/language/es-ES.ts +840 -840
  115. package/packages/language/fr-FR.ts +840 -840
  116. package/packages/language/hu-HU.ts +840 -840
  117. package/packages/language/hy-AM.ts +840 -840
  118. package/packages/language/id-ID.ts +840 -840
  119. package/packages/language/it-IT.ts +840 -840
  120. package/packages/language/ja-JP.ts +840 -840
  121. package/packages/language/ko-KR.ts +840 -840
  122. package/packages/language/ms-MY.ts +840 -840
  123. package/packages/language/nb-NO.ts +840 -840
  124. package/packages/language/pt-BR.ts +840 -840
  125. package/packages/language/ru-RU.ts +840 -840
  126. package/packages/language/th-TH.ts +840 -840
  127. package/packages/language/ug-CN.ts +840 -840
  128. package/packages/language/uk-UA.ts +840 -840
  129. package/packages/language/uz-UZ.ts +840 -840
  130. package/packages/language/vi-VN.ts +840 -840
  131. package/packages/language/zh-CHT.ts +840 -840
  132. package/packages/language/zh-CN.ts +840 -840
  133. package/packages/language/zh-HK.ts +3 -3
  134. package/packages/language/zh-MO.ts +3 -3
  135. package/packages/language/zh-TC.ts +3 -3
  136. package/packages/language/zh-TW.ts +3 -3
  137. package/packages/layout-aside/index.ts +16 -16
  138. package/packages/layout-aside/src/layout-aside.ts +123 -123
  139. package/packages/layout-body/index.ts +16 -16
  140. package/packages/layout-body/src/layout-body.ts +142 -142
  141. package/packages/layout-container/index.ts +16 -16
  142. package/packages/layout-container/src/layout-container.ts +82 -82
  143. package/packages/layout-footer/index.ts +16 -16
  144. package/packages/layout-footer/src/layout-footer.ts +74 -74
  145. package/packages/layout-header/index.ts +16 -16
  146. package/packages/layout-header/src/layout-header.ts +73 -73
  147. package/packages/link/index.ts +16 -16
  148. package/packages/link/src/link.ts +161 -161
  149. package/packages/list/index.ts +16 -16
  150. package/packages/list/src/list.ts +442 -442
  151. package/packages/loading/index.ts +34 -34
  152. package/packages/loading/src/loading.ts +152 -152
  153. package/packages/mention/index.ts +16 -16
  154. package/packages/mention/src/mention.ts +71 -71
  155. package/packages/menu/index.ts +16 -16
  156. package/packages/menu/src/menu.ts +581 -581
  157. package/packages/modal/index.ts +136 -136
  158. package/packages/modal/src/modal.ts +1494 -1494
  159. package/packages/notice-bar/index.ts +16 -16
  160. package/packages/notice-bar/src/notice-bar.ts +181 -181
  161. package/packages/number-input/index.ts +16 -16
  162. package/packages/number-input/src/number-input.ts +1096 -1096
  163. package/packages/number-input/src/util.ts +12 -12
  164. package/packages/optgroup/index.ts +16 -16
  165. package/packages/option/index.ts +16 -16
  166. package/packages/pager/index.ts +16 -16
  167. package/packages/pager/src/pager.ts +769 -769
  168. package/packages/password-input/index.ts +16 -16
  169. package/packages/password-input/src/password-input.ts +378 -378
  170. package/packages/print/index.ts +18 -18
  171. package/packages/print/src/page-break.ts +92 -92
  172. package/packages/print/src/print.ts +272 -272
  173. package/packages/print/src/util.ts +284 -284
  174. package/packages/print-page-break/index.ts +16 -16
  175. package/packages/pulldown/index.ts +16 -16
  176. package/packages/pulldown/src/pulldown.ts +457 -457
  177. package/packages/radio/index.ts +16 -16
  178. package/packages/radio/src/button.ts +173 -173
  179. package/packages/radio/src/group.ts +213 -213
  180. package/packages/radio/src/radio.ts +180 -180
  181. package/packages/radio-button/index.ts +16 -16
  182. package/packages/radio-group/index.ts +16 -16
  183. package/packages/rate/index.ts +16 -16
  184. package/packages/rate/src/rate.ts +192 -192
  185. package/packages/result/index.ts +16 -16
  186. package/packages/result/src/result.ts +112 -112
  187. package/packages/row/index.ts +16 -16
  188. package/packages/row/src/col.ts +136 -136
  189. package/packages/row/src/row.ts +119 -119
  190. package/packages/segmented/index.ts +16 -16
  191. package/packages/segmented/src/segmented.ts +264 -264
  192. package/packages/select/index.ts +16 -16
  193. package/packages/select/src/optgroup.ts +49 -49
  194. package/packages/select/src/option-info.ts +20 -20
  195. package/packages/select/src/option.ts +47 -47
  196. package/packages/select/src/select.ts +1699 -1699
  197. package/packages/select/src/util.ts +47 -47
  198. package/packages/slider/index.ts +16 -16
  199. package/packages/slider/src/slider.ts +304 -304
  200. package/packages/split/index.ts +16 -16
  201. package/packages/split-pane/index.ts +17 -17
  202. package/packages/splitter/index.ts +16 -16
  203. package/packages/splitter/src/splitter-panel.ts +145 -145
  204. package/packages/splitter/src/splitter.ts +1009 -1009
  205. package/packages/splitter/src/util.ts +21 -21
  206. package/packages/splitter-panel/index.ts +16 -16
  207. package/packages/steps/index.ts +16 -16
  208. package/packages/steps/src/steps.ts +68 -68
  209. package/packages/switch/index.ts +16 -16
  210. package/packages/switch/src/switch.ts +237 -237
  211. package/packages/tab-pane/index.ts +16 -16
  212. package/packages/table-select/index.ts +16 -16
  213. package/packages/table-select/src/table-select.ts +800 -800
  214. package/packages/tabs/index.ts +16 -16
  215. package/packages/tabs/src/tab-pane.ts +117 -117
  216. package/packages/tabs/src/tabs.ts +940 -940
  217. package/packages/tabs/src/util.ts +21 -21
  218. package/packages/tag/index.ts +16 -16
  219. package/packages/tag/src/tag.ts +187 -187
  220. package/packages/text/index.ts +16 -16
  221. package/packages/text/src/text.ts +260 -260
  222. package/packages/text-ellipsis/index.ts +16 -16
  223. package/packages/text-ellipsis/src/text-ellipsis.ts +282 -282
  224. package/packages/textarea/index.ts +16 -16
  225. package/packages/textarea/src/textarea.ts +373 -373
  226. package/packages/timeline/index.ts +16 -16
  227. package/packages/timeline/src/timeline-item.ts +67 -67
  228. package/packages/timeline/src/timeline.ts +71 -71
  229. package/packages/timeline-item/index.ts +16 -16
  230. package/packages/tip/index.ts +19 -19
  231. package/packages/tip/src/tip.ts +129 -129
  232. package/packages/tooltip/index.ts +16 -16
  233. package/packages/tooltip/src/tooltip.ts +589 -589
  234. package/packages/tour/index.ts +16 -16
  235. package/packages/tour/src/tour.ts +71 -71
  236. package/packages/tree/index.ts +16 -16
  237. package/packages/tree/src/store.ts +14 -14
  238. package/packages/tree/src/tree.ts +2825 -2795
  239. package/packages/tree/src/util.ts +45 -45
  240. package/packages/tree-select/index.ts +16 -16
  241. package/packages/tree-select/src/tree-select.ts +979 -977
  242. package/packages/ui/index.ts +697 -697
  243. package/packages/ui/src/anime.ts +52 -52
  244. package/packages/ui/src/comp.ts +3 -3
  245. package/packages/ui/src/dom.ts +279 -279
  246. package/packages/ui/src/log.ts +6 -6
  247. package/packages/ui/src/utils.ts +49 -49
  248. package/packages/ui/src/vn.ts +39 -39
  249. package/packages/upload/index.ts +20 -20
  250. package/packages/upload/src/upload.ts +1919 -1919
  251. package/packages/upload/src/util.ts +109 -109
  252. package/packages/watermark/index.ts +31 -31
  253. package/packages/watermark/src/util.ts +176 -176
  254. package/packages/watermark/src/watermark.ts +168 -168
  255. package/styles/all.scss +90 -90
  256. package/styles/base.scss +16 -16
  257. package/styles/components/alert.scss +101 -101
  258. package/styles/components/anchor.scss +44 -44
  259. package/styles/components/avatar.scss +115 -115
  260. package/styles/components/backtop.scss +82 -82
  261. package/styles/components/badge.scss +45 -45
  262. package/styles/components/breadcrumb.scss +29 -29
  263. package/styles/components/button-group.scss +30 -30
  264. package/styles/components/button.scss +415 -415
  265. package/styles/components/calendar.scss +471 -471
  266. package/styles/components/card.scss +121 -121
  267. package/styles/components/carousel.scss +184 -184
  268. package/styles/components/cascader.scss +140 -140
  269. package/styles/components/checkbox-button.scss +57 -57
  270. package/styles/components/checkbox.scss +81 -81
  271. package/styles/components/collapse.scss +56 -56
  272. package/styles/components/color-picker.scss +409 -409
  273. package/styles/components/context-menu.scss +102 -102
  274. package/styles/components/countdown.scss +35 -35
  275. package/styles/components/date-panel.scss +505 -505
  276. package/styles/components/date-picker.scss +247 -247
  277. package/styles/components/date-range-picker.scss +252 -252
  278. package/styles/components/drawer.scss +298 -298
  279. package/styles/components/empty.scss +79 -79
  280. package/styles/components/form.scss +668 -668
  281. package/styles/components/icon-picker.scss +211 -211
  282. package/styles/components/icon.scss +1048 -1048
  283. package/styles/components/image-group.scss +2 -2
  284. package/styles/components/image-preview.scss +215 -215
  285. package/styles/components/image.scss +16 -16
  286. package/styles/components/input.scss +846 -846
  287. package/styles/components/layout-aside.scss +22 -22
  288. package/styles/components/layout-body.scss +14 -14
  289. package/styles/components/layout-container.scss +13 -13
  290. package/styles/components/layout-footer.scss +14 -14
  291. package/styles/components/layout-header.scss +11 -11
  292. package/styles/components/link.scss +115 -115
  293. package/styles/components/list.scss +40 -40
  294. package/styles/components/loading.scss +137 -137
  295. package/styles/components/menu.scss +150 -150
  296. package/styles/components/modal.scss +480 -480
  297. package/styles/components/notice-bar.scss +91 -91
  298. package/styles/components/number-input.scss +283 -283
  299. package/styles/components/old-icon.scss +4 -4
  300. package/styles/components/pager.scss +282 -282
  301. package/styles/components/password-input.scss +374 -374
  302. package/styles/components/print.scss +3 -3
  303. package/styles/components/pulldown.scss +75 -75
  304. package/styles/components/radio-button.scss +57 -57
  305. package/styles/components/radio.scss +79 -79
  306. package/styles/components/rate.scss +76 -76
  307. package/styles/components/result.scss +91 -91
  308. package/styles/components/row.scss +69 -69
  309. package/styles/components/segmented.scss +215 -215
  310. package/styles/components/select.scss +244 -244
  311. package/styles/components/slider.scss +139 -139
  312. package/styles/components/split.scss +1 -1
  313. package/styles/components/splitter.scss +318 -318
  314. package/styles/components/switch.scss +128 -128
  315. package/styles/components/table-select.scss +105 -105
  316. package/styles/components/tabs.scss +745 -745
  317. package/styles/components/tag.scss +184 -184
  318. package/styles/components/text-ellipsis.scss +130 -130
  319. package/styles/components/text.scss +123 -123
  320. package/styles/components/textarea.scss +106 -106
  321. package/styles/components/tip.scss +97 -97
  322. package/styles/components/tooltip.scss +141 -141
  323. package/styles/components/tree-select.scss +166 -166
  324. package/styles/components/tree.scss +294 -294
  325. package/styles/components/upload.scss +497 -497
  326. package/styles/components/watermark.scss +26 -26
  327. package/styles/helpers/baseMixin.scss +95 -95
  328. package/styles/helpers/baseVar.scss +3 -3
  329. package/styles/helpers/placement.scss +38 -38
  330. package/styles/theme/base.scss +214 -214
  331. package/styles/theme/dark.scss +119 -119
  332. package/styles/theme/light.scss +118 -118
  333. package/styles/variable.scss +111 -111
  334. package/types/all.d.ts +327 -327
  335. package/types/components/alert.d.ts +87 -87
  336. package/types/components/anchor-link.d.ts +91 -91
  337. package/types/components/anchor.d.ts +104 -104
  338. package/types/components/avatar.d.ts +88 -88
  339. package/types/components/backtop.d.ts +122 -122
  340. package/types/components/badge.d.ts +76 -76
  341. package/types/components/breadcrumb-item.d.ts +80 -80
  342. package/types/components/breadcrumb.d.ts +87 -87
  343. package/types/components/button-group.d.ts +120 -120
  344. package/types/components/button.d.ts +323 -323
  345. package/types/components/calendar.d.ts +264 -264
  346. package/types/components/card.d.ts +93 -93
  347. package/types/components/carousel-item.d.ts +75 -75
  348. package/types/components/carousel.d.ts +134 -134
  349. package/types/components/cascader.d.ts +263 -263
  350. package/types/components/checkbox-button.d.ts +103 -103
  351. package/types/components/checkbox-group.d.ts +143 -143
  352. package/types/components/checkbox.d.ts +123 -123
  353. package/types/components/col.d.ts +80 -80
  354. package/types/components/colgroup.d.ts +137 -137
  355. package/types/components/collapse-pane.d.ts +89 -89
  356. package/types/components/collapse.d.ts +121 -121
  357. package/types/components/color-picker.d.ts +176 -176
  358. package/types/components/column.d.ts +841 -841
  359. package/types/components/context-menu.d.ts +289 -289
  360. package/types/components/countdown.d.ts +112 -112
  361. package/types/components/date-panel.d.ts +280 -280
  362. package/types/components/date-picker.d.ts +332 -332
  363. package/types/components/date-range-picker.d.ts +352 -352
  364. package/types/components/drawer.d.ts +299 -299
  365. package/types/components/empty.d.ts +78 -78
  366. package/types/components/flow-design.d.ts +85 -85
  367. package/types/components/flow-view.d.ts +85 -85
  368. package/types/components/form-design.d.ts +376 -376
  369. package/types/components/form-gather.d.ts +124 -124
  370. package/types/components/form-group.d.ts +77 -77
  371. package/types/components/form-item.d.ts +411 -411
  372. package/types/components/form-view.d.ts +183 -183
  373. package/types/components/form.d.ts +468 -468
  374. package/types/components/gantt-module/gantt-view.d.ts +177 -177
  375. package/types/components/gantt-module/index.d.ts +1 -1
  376. package/types/components/gantt-plugins/extend-gantt-chart.d.ts +131 -131
  377. package/types/components/gantt-plugins/index.d.ts +1 -1
  378. package/types/components/gantt.d.ts +1194 -1185
  379. package/types/components/grid.d.ts +1040 -1040
  380. package/types/components/icon-picker.d.ts +196 -196
  381. package/types/components/icon.d.ts +87 -87
  382. package/types/components/image-group.d.ts +127 -127
  383. package/types/components/image-preview.d.ts +167 -167
  384. package/types/components/image.d.ts +173 -173
  385. package/types/components/input.d.ts +435 -435
  386. package/types/components/layout-aside.d.ts +80 -80
  387. package/types/components/layout-body.d.ts +91 -91
  388. package/types/components/layout-container.d.ts +73 -73
  389. package/types/components/layout-footer.d.ts +73 -73
  390. package/types/components/layout-header.d.ts +69 -69
  391. package/types/components/link.d.ts +111 -111
  392. package/types/components/list-design.d.ts +190 -190
  393. package/types/components/list-view.d.ts +199 -199
  394. package/types/components/list.d.ts +204 -204
  395. package/types/components/loading.d.ts +103 -103
  396. package/types/components/mention.d.ts +77 -77
  397. package/types/components/menu.d.ts +211 -211
  398. package/types/components/modal.d.ts +542 -542
  399. package/types/components/notice-bar.d.ts +102 -102
  400. package/types/components/number-input.d.ts +309 -309
  401. package/types/components/optgroup.d.ts +88 -88
  402. package/types/components/option.d.ts +103 -103
  403. package/types/components/pager.d.ts +335 -335
  404. package/types/components/password-input.d.ts +142 -142
  405. package/types/components/print-page-break.d.ts +69 -69
  406. package/types/components/print.d.ts +206 -206
  407. package/types/components/pulldown.d.ts +231 -231
  408. package/types/components/radio-button.d.ts +114 -114
  409. package/types/components/radio-group.d.ts +144 -144
  410. package/types/components/radio.d.ts +129 -129
  411. package/types/components/rate.d.ts +88 -88
  412. package/types/components/result.d.ts +84 -84
  413. package/types/components/row.d.ts +79 -79
  414. package/types/components/segmented.d.ts +123 -123
  415. package/types/components/select.d.ts +527 -527
  416. package/types/components/slider.d.ts +126 -126
  417. package/types/components/split-pane.d.ts +133 -133
  418. package/types/components/split.d.ts +312 -312
  419. package/types/components/splitter-panel.d.ts +105 -105
  420. package/types/components/splitter.d.ts +288 -288
  421. package/types/components/steps.d.ts +68 -68
  422. package/types/components/switch.d.ts +133 -133
  423. package/types/components/tab-pane.d.ts +114 -114
  424. package/types/components/table-module/custom.d.ts +123 -123
  425. package/types/components/table-module/edit.d.ts +243 -243
  426. package/types/components/table-module/export.d.ts +96 -96
  427. package/types/components/table-module/filter.d.ts +140 -140
  428. package/types/components/table-module/index.d.ts +7 -7
  429. package/types/components/table-module/keyboard.d.ts +26 -26
  430. package/types/components/table-module/menu.d.ts +28 -28
  431. package/types/components/table-module/validator.d.ts +53 -53
  432. package/types/components/table-plugins/extend-cell-area.d.ts +770 -770
  433. package/types/components/table-plugins/extend-pivot-table.d.ts +58 -58
  434. package/types/components/table-plugins/filters-combination.d.ts +15 -15
  435. package/types/components/table-plugins/filters-complex-input.d.ts +9 -9
  436. package/types/components/table-plugins/index.d.ts +4 -4
  437. package/types/components/table-select.d.ts +219 -219
  438. package/types/components/table.d.ts +7465 -7465
  439. package/types/components/tabs.d.ts +332 -332
  440. package/types/components/tag.d.ts +114 -114
  441. package/types/components/text-ellipsis.d.ts +112 -112
  442. package/types/components/text.d.ts +122 -122
  443. package/types/components/textarea.d.ts +247 -247
  444. package/types/components/timeline-item.d.ts +75 -75
  445. package/types/components/timeline.d.ts +77 -77
  446. package/types/components/tip.d.ts +83 -83
  447. package/types/components/toolbar.d.ts +336 -336
  448. package/types/components/tooltip.d.ts +180 -180
  449. package/types/components/tour.d.ts +77 -77
  450. package/types/components/tree-select.d.ts +310 -310
  451. package/types/components/tree.d.ts +843 -833
  452. package/types/components/upload.d.ts +437 -437
  453. package/types/components/watermark.d.ts +120 -120
  454. package/types/handles/form-design.d.ts +50 -50
  455. package/types/handles/index.d.ts +3 -3
  456. package/types/handles/list-design.d.ts +2 -2
  457. package/types/handles/table.d.ts +15 -15
  458. package/types/index.d.ts +8 -8
  459. package/types/ui/commands.d.ts +57 -57
  460. package/types/ui/formats.d.ts +62 -62
  461. package/types/ui/global-config.d.ts +254 -254
  462. package/types/ui/global-icon.d.ts +292 -292
  463. package/types/ui/hooks.d.ts +13 -13
  464. package/types/ui/index.d.ts +96 -96
  465. package/types/ui/interceptor.d.ts +52 -52
  466. package/types/ui/menus.d.ts +77 -77
  467. package/types/ui/renderer.d.ts +1041 -1041
  468. package/types/ui/validators.d.ts +38 -38
  469. /package/es/icon/{iconfont.1778169084473.ttf → iconfont.1778317220469.ttf} +0 -0
  470. /package/es/icon/{iconfont.1778169084473.woff → iconfont.1778317220469.woff} +0 -0
  471. /package/es/icon/{iconfont.1778169084473.woff2 → iconfont.1778317220469.woff2} +0 -0
  472. /package/es/{iconfont.1778169084473.ttf → iconfont.1778317220469.ttf} +0 -0
  473. /package/es/{iconfont.1778169084473.woff → iconfont.1778317220469.woff} +0 -0
  474. /package/es/{iconfont.1778169084473.woff2 → iconfont.1778317220469.woff2} +0 -0
  475. /package/lib/icon/style/{iconfont.1778169084473.ttf → iconfont.1778317220469.ttf} +0 -0
  476. /package/lib/icon/style/{iconfont.1778169084473.woff → iconfont.1778317220469.woff} +0 -0
  477. /package/lib/icon/style/{iconfont.1778169084473.woff2 → iconfont.1778317220469.woff2} +0 -0
  478. /package/lib/{iconfont.1778169084473.ttf → iconfont.1778317220469.ttf} +0 -0
  479. /package/lib/{iconfont.1778169084473.woff → iconfont.1778317220469.woff} +0 -0
  480. /package/lib/{iconfont.1778169084473.woff2 → iconfont.1778317220469.woff2} +0 -0
@@ -1,1009 +1,1009 @@
1
- import { PropType, ref, h, reactive, provide, VNode, computed, watch, nextTick, onMounted, onUnmounted, onActivated } from 'vue'
2
- import { defineVxeComponent } from '../../ui/src/comp'
3
- import { getConfig, getIcon, createEvent, globalEvents, globalResize, useSize, renderEmptyElement } from '../../ui'
4
- import { getSlotVNs } from '../../ui/src/vn'
5
- import { toCssUnit, isScale, addClass, removeClass } from '../../ui/src/dom'
6
- import { getGlobalDefaultConfig } from '../../ui/src/utils'
7
- import { warnLog, errLog } from '../../ui/src/log'
8
- import XEUtils from 'xe-utils'
9
-
10
- import type { SplitterReactData, SplitterPrivateRef, VxeSplitterPropTypes, SplitterInternalData, SplitterMethods, VxeSplitterPanelPropTypes, VxeSplitterDefines, VxeSplitterPanelProps, VxeSplitterPrivateComputed, SplitterPrivateMethods, VxeSplitterEmits, VxeSplitterConstructor, ValueOf, VxeSplitterPrivateMethods } from '../../../types'
11
-
12
- export default defineVxeComponent({
13
- name: 'VxeSplitter',
14
- props: {
15
- width: [Number, String] as PropType<VxeSplitterPropTypes.Width>,
16
- height: [Number, String] as PropType<VxeSplitterPropTypes.Height>,
17
- vertical: {
18
- type: Boolean as PropType<VxeSplitterPropTypes.Vertical>,
19
- default: () => getConfig().splitter.vertical
20
- },
21
- border: {
22
- type: Boolean as PropType<VxeSplitterPropTypes.Border>,
23
- default: () => getConfig().splitter.border
24
- },
25
- padding: {
26
- type: Boolean as PropType<VxeSplitterPropTypes.Padding>,
27
- default: () => getConfig().splitter.padding
28
- },
29
- resize: {
30
- type: Boolean as PropType<VxeSplitterPropTypes.Resize>,
31
- default: () => getConfig().splitter.resize
32
- },
33
- items: Array as PropType<VxeSplitterPropTypes.Items>,
34
- itemConfig: Object as PropType<VxeSplitterPropTypes.ItemConfig>,
35
- barConfig: Object as PropType<VxeSplitterPropTypes.BarConfig>,
36
- resizeConfig: Object as PropType<VxeSplitterPropTypes.ResizeConfig>,
37
- actionConfig: Object as PropType<VxeSplitterPropTypes.ActionConfig>,
38
- size: {
39
- type: String as PropType<VxeSplitterPropTypes.Size>,
40
- default: () => getConfig().splitter.size || getConfig().size
41
- }
42
- },
43
- emits: [
44
- 'action-dblclick',
45
- 'action-click',
46
- 'toggle-expand',
47
- 'resize-start',
48
- 'resize-drag',
49
- 'resize-end'
50
- ] as VxeSplitterEmits,
51
- setup (props, context) {
52
- const { emit, slots } = context
53
-
54
- const xID = XEUtils.uniqueId()
55
-
56
- const refElem = ref<HTMLDivElement>()
57
- const refBarInfoElem = ref<HTMLDivElement>()
58
- const refResizableSplitterTip = ref<HTMLDivElement>()
59
-
60
- const { computeSize } = useSize(props)
61
-
62
- const reactData = reactive<SplitterReactData>({
63
- staticItems: [],
64
- itemList: [],
65
- barWidth: 0,
66
- barHeight: 0
67
- })
68
-
69
- const internalData: SplitterInternalData = {
70
- wrapperWidth: 0,
71
- wrapperHeight: 0
72
- }
73
-
74
- const computeItemOpts = computed(() => {
75
- return Object.assign({}, getConfig().splitter.itemConfig, props.itemConfig)
76
- })
77
-
78
- const computeBarOpts = computed(() => {
79
- return Object.assign({}, getConfig().splitter.barConfig, props.barConfig)
80
- })
81
-
82
- const computeResizeOpts = computed(() => {
83
- return Object.assign({}, getConfig().splitter.resizeConfig, props.resizeConfig)
84
- })
85
-
86
- const computeActionOpts = computed(() => {
87
- return Object.assign({}, getConfig().splitter.actionConfig, props.actionConfig)
88
- })
89
-
90
- const computeVisibleItems = computed(() => {
91
- return reactData.itemList.filter(item => item.isExpand)
92
- })
93
-
94
- const computeAutoItems = computed(() => {
95
- const { vertical } = props
96
- const autoItems: VxeSplitterDefines.PaneConfig[] = []
97
- let heightCount = 0
98
- let widthCount = 0
99
- reactData.itemList.forEach(vertical
100
- ? item => {
101
- const { renderHeight, resizeHeight, foldHeight, isExpand, height } = item
102
- const itemHeight = isExpand ? (foldHeight || resizeHeight || renderHeight) : 0
103
- if (!height) {
104
- autoItems.push(item)
105
- }
106
- heightCount += itemHeight
107
- }
108
- : item => {
109
- const { renderWidth, resizeWidth, foldWidth, isExpand, width } = item
110
- const itemWidth = isExpand ? (foldWidth || resizeWidth || renderWidth) : 0
111
- if (!width) {
112
- autoItems.push(item)
113
- }
114
- widthCount += itemWidth
115
- })
116
- return {
117
- autoItems,
118
- heightCount,
119
- heightRatio: heightCount / 100,
120
- widthCount,
121
- widthRatio: widthCount / 100
122
- }
123
- })
124
-
125
- const computeBarStyle = computed(() => {
126
- const barOpts = computeBarOpts.value
127
- const { width, height } = barOpts
128
- const stys: Record<string, string | number> = {}
129
- if (height) {
130
- stys.height = toCssUnit(height)
131
- }
132
- if (width) {
133
- stys.width = toCssUnit(width)
134
- }
135
- return stys
136
- })
137
-
138
- const computeMaps: VxeSplitterPrivateComputed = {
139
- computeItemOpts,
140
- computeBarOpts,
141
- computeActionOpts
142
- }
143
-
144
- const refMaps: SplitterPrivateRef = {
145
- refElem
146
- }
147
-
148
- const $xeSplitter = {
149
- xID,
150
- props,
151
- context,
152
- reactData,
153
- internalData,
154
-
155
- getRefMaps: () => refMaps,
156
- getComputeMaps: () => computeMaps
157
- } as unknown as VxeSplitterConstructor & VxeSplitterPrivateMethods
158
-
159
- const dispatchEvent = (type: ValueOf<VxeSplitterEmits>, params: Record<string, any>, evnt: Event | null) => {
160
- emit(type, createEvent(evnt, { $splitter: $xeSplitter }, params))
161
- }
162
-
163
- const callSlot = (slotFunc: any, params: any) => {
164
- if (slotFunc) {
165
- if (XEUtils.isString(slotFunc)) {
166
- slotFunc = slots[slotFunc] || null
167
- }
168
- if (XEUtils.isFunction(slotFunc)) {
169
- return getSlotVNs(slotFunc(params))
170
- }
171
- }
172
- return []
173
- }
174
-
175
- const getActionIcon = (prevItem: VxeSplitterDefines.PaneConfig, nextItem: VxeSplitterDefines.PaneConfig, isNext: boolean) => {
176
- const { vertical } = props
177
- const topIcon = 'SPLIT_TOP_ACTION'
178
- const bottomIcon = 'SPLIT_BOTTOM_ACTION'
179
- const leftIcon = 'SPLIT_LEFT_ACTION'
180
- const rightIcon = 'SPLIT_RIGHT_ACTION'
181
- let iconName: 'SPLIT_TOP_ACTION' | 'SPLIT_BOTTOM_ACTION' | 'SPLIT_LEFT_ACTION' | 'SPLIT_RIGHT_ACTION' | '' = ''
182
- if (vertical) {
183
- if (isNext) {
184
- iconName = nextItem.isExpand ? bottomIcon : topIcon
185
- } else {
186
- iconName = prevItem.isExpand ? topIcon : bottomIcon
187
- }
188
- } else {
189
- if (isNext) {
190
- iconName = nextItem.isExpand ? rightIcon : leftIcon
191
- } else {
192
- iconName = prevItem.isExpand ? leftIcon : rightIcon
193
- }
194
- }
195
- if (iconName) {
196
- return getIcon()[iconName]
197
- }
198
- return ''
199
- }
200
-
201
- const reset = () => {
202
- const { itemList } = reactData
203
- itemList.forEach(item => {
204
- item.isExpand = true
205
- item.foldHeight = 0
206
- item.foldWidth = 0
207
- item.resizeHeight = 0
208
- item.resizeWidth = 0
209
- })
210
- return nextTick()
211
- }
212
-
213
- const handleLoadItem = (list: VxeSplitterPanelProps[], isReset: boolean) => {
214
- const { staticItems } = reactData
215
- const actionOpts = computeActionOpts.value
216
- const { showPrevButton, showNextButton } = actionOpts
217
- const itemDef = {
218
- isExpand: true,
219
- renderWidth: 0,
220
- resizeWidth: 0,
221
- foldWidth: 0,
222
- renderHeight: 0,
223
- resizeHeight: 0,
224
- foldHeight: 0
225
- }
226
- reactData.itemList = list.map(item => {
227
- if (item.showAction) {
228
- warnLog('vxe.error.removeProp', ['[splitter] show-action'])
229
- }
230
- if (item.slots) {
231
- XEUtils.each(item.slots, (func) => {
232
- if (!XEUtils.isFunction(func)) {
233
- if (!slots[func]) {
234
- errLog('vxe.error.notSlot', [`[splitter] ${func}`])
235
- }
236
- }
237
- })
238
- }
239
- return Object.assign({}, isReset ? null : itemDef, item, isReset ? itemDef : null, {
240
- id: XEUtils.uniqueId()
241
- })
242
- })
243
- if (staticItems.length) {
244
- errLog('vxe.error.errConflicts', ['<vxe-splitter-panel ...>', 'items'])
245
- }
246
- if ((showPrevButton || showNextButton) && reactData.itemList.length > 2) {
247
- errLog('vxe.error.errConflicts', ['action-config.showPrevButton | action-config.showNextButton', 'Only supports 2 item'])
248
- }
249
- return recalculate()
250
- }
251
-
252
- const loadItem = (list: VxeSplitterPanelProps[]) => {
253
- return handleLoadItem(list || [], false)
254
- }
255
-
256
- const reloadItem = (list: VxeSplitterPanelProps[]) => {
257
- return handleLoadItem(list || [], true)
258
- }
259
-
260
- const handleItemByName = (name: VxeSplitterPanelPropTypes.Name) => {
261
- const { itemList } = reactData
262
- let index = -1
263
- let currItem: VxeSplitterDefines.PaneConfig | null = null
264
- let prevItem: VxeSplitterDefines.PaneConfig | null = null
265
- let nextItem: VxeSplitterDefines.PaneConfig | null = null
266
- for (let i = 0; i < itemList.length; i++) {
267
- const item = itemList[i]
268
- if (item.name === name) {
269
- index = i
270
- currItem = item
271
- prevItem = itemList[i - 1] || null
272
- nextItem = itemList[i + 1] || null
273
- break
274
- }
275
- }
276
- return {
277
- index,
278
- currItem,
279
- prevItem,
280
- nextItem
281
- }
282
- }
283
-
284
- const setItemExpand = (name: VxeSplitterPanelPropTypes.Name, expanded: boolean) => {
285
- const restItem = handleItemByName(name)
286
- if (restItem) {
287
- const { currItem, prevItem, nextItem } = restItem
288
- if (currItem) {
289
- if (expanded ? !currItem.isExpand : currItem.isExpand) {
290
- if (nextItem) {
291
- if (nextItem.isExpand) {
292
- handleItemActionEvent(null, currItem, nextItem, false)
293
- }
294
- } else if (prevItem) {
295
- if (prevItem.isExpand) {
296
- handleItemActionEvent(null, prevItem, currItem, true)
297
- }
298
- }
299
- }
300
- }
301
- }
302
- return nextTick()
303
- }
304
-
305
- const toggleItemExpand = (name: VxeSplitterPanelPropTypes.Name) => {
306
- const restItem = handleItemByName(name)
307
- if (restItem) {
308
- const { currItem } = restItem
309
- if (currItem) {
310
- return setItemExpand(name, !currItem.isExpand)
311
- }
312
- }
313
- return nextTick()
314
- }
315
-
316
- const getItemExpand = (name: VxeSplitterPanelPropTypes.Name) => {
317
- const restItem = handleItemByName(name)
318
- if (restItem) {
319
- const { currItem } = restItem
320
- if (currItem) {
321
- return currItem.isExpand
322
- }
323
- }
324
- return false
325
- }
326
-
327
- const recalculate = () => {
328
- return nextTick().then(() => {
329
- const { vertical } = props
330
- const { itemList } = reactData
331
- const el = refElem.value
332
- const barInfoElem = refBarInfoElem.value
333
- if (!el) {
334
- return
335
- }
336
- const wWidth = el.clientWidth
337
- const wHeight = el.clientHeight
338
- if (!wWidth || !wHeight) {
339
- return
340
- }
341
- if (barInfoElem) {
342
- reactData.barWidth = barInfoElem.offsetWidth
343
- reactData.barHeight = barInfoElem.offsetHeight
344
- }
345
- const contentWidth = wWidth - (vertical ? 0 : reactData.barWidth * (itemList.length - 1))
346
- const contentHeight = wHeight - (vertical ? reactData.barHeight * (itemList.length - 1) : 0)
347
- const itemOpts = computeItemOpts.value
348
- const allMinWidth = XEUtils.toNumber(itemOpts.minWidth)
349
- const allMinHeight = XEUtils.toNumber(itemOpts.minHeight)
350
- const residueItems: VxeSplitterDefines.PaneConfig[] = []
351
- if (vertical) {
352
- let countHeight = 0
353
- itemList.forEach(item => {
354
- const { height } = item
355
- let itemHeight = 0
356
- if (height) {
357
- if (isScale(height)) {
358
- itemHeight = contentHeight * XEUtils.toNumber(height) / 100
359
- } else {
360
- itemHeight = XEUtils.toNumber(height)
361
- }
362
- item.renderHeight = itemHeight
363
- } else {
364
- residueItems.push(item)
365
- }
366
- countHeight += itemHeight
367
- })
368
- if (residueItems.length) {
369
- const reMeanHeight = (contentHeight - countHeight) / residueItems.length
370
- residueItems.forEach(item => {
371
- item.renderHeight = Math.max(XEUtils.toNumber(getGlobalDefaultConfig(item.minHeight, allMinHeight)), reMeanHeight)
372
- })
373
- }
374
- } else {
375
- let countWidth = 0
376
- itemList.forEach(item => {
377
- const { width } = item
378
- let itemWidth = 0
379
- if (width) {
380
- if (isScale(width)) {
381
- itemWidth = contentWidth * XEUtils.toNumber(width) / 100
382
- } else {
383
- itemWidth = XEUtils.toNumber(width)
384
- }
385
- item.renderWidth = itemWidth
386
- } else {
387
- residueItems.push(item)
388
- }
389
- countWidth += itemWidth
390
- })
391
- if (residueItems.length) {
392
- const reMeanWidth = (contentWidth - countWidth) / residueItems.length
393
- residueItems.forEach(item => {
394
- item.renderWidth = Math.max(XEUtils.toNumber(getGlobalDefaultConfig(item.minWidth, allMinWidth)), reMeanWidth)
395
- })
396
- }
397
- }
398
- internalData.wrapperWidth = contentWidth
399
- internalData.wrapperHeight = contentHeight
400
- })
401
- }
402
-
403
- const dragEvent = (evnt: MouseEvent) => {
404
- const { resize, vertical } = props
405
- const { itemList } = reactData
406
- if (!resize) {
407
- return
408
- }
409
- evnt.preventDefault()
410
- const barEl = evnt.currentTarget as HTMLDivElement
411
- const handleEl = barEl.parentElement as HTMLDivElement
412
- const el = refElem.value
413
- if (!el) {
414
- return
415
- }
416
- const prevEl = handleEl.previousElementSibling as HTMLDivElement
417
- const nextEl = handleEl.nextElementSibling as HTMLDivElement
418
- if (!prevEl || !nextEl) {
419
- return
420
- }
421
- const prevId = prevEl.getAttribute('itemid')
422
- const nextId = nextEl.getAttribute('itemid')
423
- const prevItem = itemList.find(item => item.id === prevId)
424
- const nextItem = itemList.find(item => item.id === nextId)
425
- if (!prevItem || !nextItem) {
426
- return
427
- }
428
- const containerRect = el.getBoundingClientRect()
429
- const barRect = barEl.getBoundingClientRect()
430
- const rsSplitterLineEl = refResizableSplitterTip.value
431
- const rsSplitterTipEl = rsSplitterLineEl ? rsSplitterLineEl.children[0] as HTMLDivElement : null
432
- const itemOpts = computeItemOpts.value
433
- const resizeOpts = computeResizeOpts.value
434
- const { immediate } = resizeOpts
435
- const allMinWidth = XEUtils.toNumber(itemOpts.minWidth)
436
- const allMinHeight = XEUtils.toNumber(itemOpts.minHeight)
437
-
438
- const barOffsetX = Math.ceil(barRect.width - (evnt.clientX - barRect.left))
439
- const barOffsetY = Math.ceil(evnt.clientY - barRect.top)
440
-
441
- const prevWidth = prevEl.offsetWidth
442
- const nextWidth = nextEl.offsetWidth
443
- const prevMinWidth = XEUtils.toNumber(prevItem ? getGlobalDefaultConfig(prevItem.minWidth, allMinWidth) : allMinWidth)
444
- const nextMinWidth = XEUtils.toNumber(nextItem ? getGlobalDefaultConfig(nextItem.minWidth, allMinWidth) : allMinWidth)
445
- const minOffsetLeft = prevEl.offsetLeft + prevMinWidth - barOffsetX
446
- const maxOffsetLeft = nextEl.offsetLeft + nextEl.offsetWidth - nextMinWidth - barOffsetX
447
- const startOffsetLeft = evnt.clientX - containerRect.left
448
- let targetOffsetWidth = -1
449
- let prevResizeWidth = 0
450
- let nextResizeWidth = 0
451
- let offsetLeft = startOffsetLeft
452
-
453
- const prevHeight = prevEl.offsetHeight
454
- const nextHeight = nextEl.offsetHeight
455
- const prevMinHeight = XEUtils.toNumber(prevItem ? getGlobalDefaultConfig(prevItem.minHeight, allMinHeight) : allMinHeight)
456
- const nextMinHeight = XEUtils.toNumber(nextItem ? getGlobalDefaultConfig(nextItem.minHeight, allMinHeight) : allMinHeight)
457
- const minOffsetTop = prevEl.offsetTop + prevMinHeight + barOffsetY
458
- const maxOffsetTop = nextEl.offsetTop + nextEl.offsetHeight - nextMinHeight + barOffsetY
459
- const startOffsetTop = evnt.clientY - containerRect.top
460
- let targetOffsetHeight = -1
461
- let prevResizeHeight = 0
462
- let nextResizeHeight = 0
463
- let offsetTop = startOffsetTop
464
-
465
- const handleReStyle = (evnt: MouseEvent) => {
466
- if (!rsSplitterLineEl) {
467
- return
468
- }
469
- const rsNumPrevEl = rsSplitterTipEl ? rsSplitterTipEl.children[0] as HTMLDivElement : null
470
- const rsNumNextEl = rsSplitterTipEl ? rsSplitterTipEl.children[1] as HTMLDivElement : null
471
- if (vertical) {
472
- let tipWidth = 0
473
- if (rsNumPrevEl) {
474
- if (targetOffsetHeight < 0) {
475
- rsNumPrevEl.style.display = 'none'
476
- } else {
477
- rsNumPrevEl.textContent = `${Math.floor(prevResizeHeight)}px`
478
- rsNumPrevEl.style.display = 'block'
479
- tipWidth = rsNumPrevEl.offsetWidth
480
- }
481
- }
482
- if (rsNumNextEl) {
483
- if (targetOffsetHeight < 0) {
484
- rsNumNextEl.textContent = `${Math.floor(nextResizeHeight)}px`
485
- rsNumNextEl.style.display = 'block'
486
- tipWidth = rsNumNextEl.offsetWidth
487
- } else {
488
- rsNumNextEl.style.display = 'none'
489
- }
490
- }
491
- let rsLeft = Math.max(1, evnt.clientX - containerRect.left - tipWidth / 2)
492
- if (rsLeft > containerRect.width - tipWidth - 1) {
493
- rsLeft = containerRect.width - tipWidth - 1
494
- }
495
- rsSplitterLineEl.style.left = '0'
496
- rsSplitterLineEl.style.top = `${offsetTop}px`
497
- if (rsSplitterTipEl) {
498
- rsSplitterTipEl.style.left = `${rsLeft}px`
499
- }
500
- } else {
501
- let tipHeight = 0
502
- if (rsNumPrevEl) {
503
- if (targetOffsetWidth < 0) {
504
- rsNumPrevEl.style.display = 'none'
505
- } else {
506
- rsNumPrevEl.textContent = `${Math.floor(prevResizeWidth)}px`
507
- rsNumPrevEl.style.display = 'block'
508
- tipHeight = rsNumPrevEl.offsetHeight
509
- }
510
- }
511
- if (rsNumNextEl) {
512
- if (targetOffsetWidth < 0) {
513
- rsNumNextEl.textContent = `${Math.floor(nextResizeWidth)}px`
514
- rsNumNextEl.style.display = 'block'
515
- tipHeight = rsNumNextEl.offsetHeight
516
- } else {
517
- rsNumNextEl.style.display = 'none'
518
- }
519
- }
520
- let rsTop = Math.max(1, evnt.clientY - containerRect.top - tipHeight / 2)
521
- if (rsTop > containerRect.height - tipHeight - 1) {
522
- rsTop = containerRect.height - tipHeight - 1
523
- }
524
- rsSplitterLineEl.style.top = '0'
525
- rsSplitterLineEl.style.left = `${offsetLeft}px`
526
- if (rsSplitterTipEl) {
527
- rsSplitterTipEl.style.top = `${rsTop}px`
528
- }
529
- }
530
- }
531
-
532
- const handleUpdate = () => {
533
- if (vertical) {
534
- prevItem.resizeHeight = prevResizeHeight
535
- nextItem.resizeHeight = nextResizeHeight
536
- } else {
537
- prevItem.resizeWidth = prevResizeWidth
538
- nextItem.resizeWidth = nextResizeWidth
539
- }
540
- }
541
-
542
- const handleDrag = (evnt: MouseEvent) => {
543
- if (vertical) {
544
- offsetTop = evnt.clientY - containerRect.top
545
- if (offsetTop < minOffsetTop) {
546
- offsetTop = minOffsetTop
547
- }
548
- if (offsetTop > maxOffsetTop) {
549
- offsetTop = maxOffsetTop
550
- }
551
- targetOffsetHeight = offsetTop - startOffsetTop
552
- prevResizeHeight = prevHeight + targetOffsetHeight
553
- nextResizeHeight = nextHeight - targetOffsetHeight
554
- } else {
555
- offsetLeft = evnt.clientX - containerRect.left
556
- if (offsetLeft < minOffsetLeft) {
557
- offsetLeft = minOffsetLeft
558
- }
559
- if (offsetLeft > maxOffsetLeft) {
560
- offsetLeft = maxOffsetLeft
561
- }
562
- targetOffsetWidth = offsetLeft - startOffsetLeft
563
- prevResizeWidth = prevWidth + targetOffsetWidth
564
- nextResizeWidth = nextWidth - targetOffsetWidth
565
- }
566
- if (immediate) {
567
- if (vertical) {
568
- prevEl.style.height = toCssUnit(prevResizeHeight)
569
- nextEl.style.height = toCssUnit(nextResizeHeight)
570
- } else {
571
- prevEl.style.width = toCssUnit(prevResizeWidth)
572
- nextEl.style.width = toCssUnit(nextResizeWidth)
573
- }
574
- }
575
- if (rsSplitterLineEl) {
576
- handleReStyle(evnt)
577
- }
578
- dispatchEvent('resize-drag', { prevItem, nextItem, offsetHeight: targetOffsetHeight, offsetWidth: targetOffsetWidth }, evnt)
579
- }
580
-
581
- document.onmousemove = (evnt) => {
582
- evnt.preventDefault()
583
- handleDrag(evnt)
584
- }
585
- document.onmouseup = (evnt) => {
586
- document.onmousemove = null
587
- document.onmouseup = null
588
- if (rsSplitterLineEl) {
589
- rsSplitterLineEl.style.display = ''
590
- }
591
- handleUpdate()
592
- removeClass(el, 'is--drag')
593
- dispatchEvent('resize-end', { prevItem, nextItem, offsetHeight: targetOffsetHeight, offsetWidth: targetOffsetWidth }, evnt)
594
- recalculate()
595
- }
596
-
597
- if (rsSplitterLineEl) {
598
- rsSplitterLineEl.style.display = 'block'
599
- handleReStyle(evnt)
600
- }
601
- handleDrag(evnt)
602
- addClass(el, 'is--drag')
603
- dispatchEvent('resize-start', { prevItem, nextItem }, evnt)
604
- }
605
-
606
- const handleItemActionEvent = (evnt: MouseEvent | null, prevItem: VxeSplitterDefines.PaneConfig, nextItem: VxeSplitterDefines.PaneConfig, isNext: boolean) => {
607
- const { vertical } = props
608
- let expanded = false
609
- let item = prevItem
610
- if (isNext) {
611
- item = nextItem
612
- expanded = !nextItem.isExpand
613
- nextItem.isExpand = expanded
614
- } else {
615
- expanded = !prevItem.isExpand
616
- prevItem.isExpand = expanded
617
- }
618
- if (vertical) {
619
- if (prevItem.isExpand && nextItem.isExpand) {
620
- prevItem.foldHeight = 0
621
- nextItem.foldHeight = 0
622
- } else if (prevItem.isExpand) {
623
- nextItem.foldHeight = 0
624
- prevItem.foldHeight = (prevItem.resizeHeight || prevItem.renderHeight) + (nextItem.resizeHeight || nextItem.renderHeight)
625
- } else {
626
- prevItem.foldHeight = 0
627
- nextItem.foldHeight = (prevItem.resizeHeight || prevItem.renderHeight) + (nextItem.resizeHeight || nextItem.renderHeight)
628
- }
629
- } else {
630
- if (prevItem.isExpand && nextItem.isExpand) {
631
- prevItem.foldWidth = 0
632
- nextItem.foldWidth = 0
633
- } else if (prevItem.isExpand) {
634
- nextItem.foldWidth = 0
635
- prevItem.foldWidth = (prevItem.resizeWidth || prevItem.renderWidth) + (nextItem.resizeWidth || nextItem.renderWidth)
636
- } else {
637
- prevItem.foldWidth = 0
638
- nextItem.foldWidth = (prevItem.resizeWidth || prevItem.renderWidth) + (nextItem.resizeWidth || nextItem.renderWidth)
639
- }
640
- }
641
- if (evnt) {
642
- dispatchEvent('toggle-expand', { prevItem, nextItem, expanded, item }, evnt)
643
- }
644
- recalculate()
645
- }
646
-
647
- const handlePrevActionDblclickEvent = (evnt: MouseEvent) => {
648
- const { itemList } = reactData
649
- const actionOpts = computeActionOpts.value
650
- const btnEl = evnt.currentTarget as HTMLDivElement
651
- const btnWrapperEl = btnEl.parentElement as HTMLDivElement
652
- const handleEl = btnWrapperEl.parentElement as HTMLDivElement
653
- const prevEl = handleEl.previousElementSibling as HTMLDivElement
654
- const prevId = prevEl.getAttribute('itemid')
655
- const prevItem = itemList.find(item => item.id === prevId)
656
- const nextEl = handleEl.nextElementSibling as HTMLDivElement
657
- const nextId = nextEl.getAttribute('itemid')
658
- const nextItem = itemList.find(item => item.id === nextId)
659
-
660
- if (actionOpts.trigger === 'dblclick') {
661
- if (prevItem && nextItem && nextItem.isExpand) {
662
- handleItemActionEvent(evnt, prevItem, nextItem, false)
663
- }
664
- }
665
- dispatchEvent('action-dblclick', { prevItem, nextItem }, evnt)
666
- }
667
-
668
- const handlePrevActionClickEvent = (evnt: MouseEvent) => {
669
- const { itemList } = reactData
670
- const actionOpts = computeActionOpts.value
671
- const btnEl = evnt.currentTarget as HTMLDivElement
672
- const btnWrapperEl = btnEl.parentElement as HTMLDivElement
673
- const handleEl = btnWrapperEl.parentElement as HTMLDivElement
674
- const prevEl = handleEl.previousElementSibling as HTMLDivElement
675
- const prevId = prevEl.getAttribute('itemid')
676
- const prevItem = itemList.find(item => item.id === prevId)
677
- const nextEl = handleEl.nextElementSibling as HTMLDivElement
678
- const nextId = nextEl.getAttribute('itemid')
679
- const nextItem = itemList.find(item => item.id === nextId)
680
-
681
- if (actionOpts.trigger !== 'dblclick') {
682
- if (prevItem && nextItem && nextItem.isExpand) {
683
- handleItemActionEvent(evnt, prevItem, nextItem, false)
684
- }
685
- }
686
- dispatchEvent('action-click', { prevItem, nextItem }, evnt)
687
- }
688
-
689
- const handleNextActionDblclickEvent = (evnt: MouseEvent) => {
690
- const { itemList } = reactData
691
- const actionOpts = computeActionOpts.value
692
- const btnEl = evnt.currentTarget as HTMLDivElement
693
- const btnWrapperEl = btnEl.parentElement as HTMLDivElement
694
- const handleEl = btnWrapperEl.parentElement as HTMLDivElement
695
- const prevEl = handleEl.previousElementSibling as HTMLDivElement
696
- const prevId = prevEl.getAttribute('itemid')
697
- const prevItem = itemList.find(item => item.id === prevId)
698
- const nextEl = handleEl.nextElementSibling as HTMLDivElement
699
- const nextId = nextEl.getAttribute('itemid')
700
- const nextItem = itemList.find(item => item.id === nextId)
701
-
702
- if (actionOpts.trigger === 'dblclick') {
703
- if (prevItem && nextItem && prevItem.isExpand) {
704
- handleItemActionEvent(evnt, prevItem, nextItem, true)
705
- }
706
- }
707
- dispatchEvent('action-dblclick', { prevItem, nextItem }, evnt)
708
- }
709
-
710
- const handleNextActionClickEvent = (evnt: MouseEvent) => {
711
- const { itemList } = reactData
712
- const actionOpts = computeActionOpts.value
713
- const btnEl = evnt.currentTarget as HTMLDivElement
714
- const btnWrapperEl = btnEl.parentElement as HTMLDivElement
715
- const handleEl = btnWrapperEl.parentElement as HTMLDivElement
716
- const prevEl = handleEl.previousElementSibling as HTMLDivElement
717
- const prevId = prevEl.getAttribute('itemid')
718
- const prevItem = itemList.find(item => item.id === prevId)
719
- const nextEl = handleEl.nextElementSibling as HTMLDivElement
720
- const nextId = nextEl.getAttribute('itemid')
721
- const nextItem = itemList.find(item => item.id === nextId)
722
-
723
- if (actionOpts.trigger !== 'dblclick') {
724
- if (prevItem && nextItem && prevItem.isExpand) {
725
- handleItemActionEvent(evnt, prevItem, nextItem, true)
726
- }
727
- }
728
- dispatchEvent('action-click', { prevItem, nextItem }, evnt)
729
- }
730
-
731
- const handleGlobalResizeEvent = () => {
732
- recalculate()
733
- }
734
-
735
- const splitterMethods: SplitterMethods = {
736
- dispatchEvent,
737
- setItemExpand,
738
- toggleItemExpand,
739
- getItemExpand,
740
- recalculate,
741
- reset,
742
- loadItem,
743
- reloadItem
744
- }
745
-
746
- const splitterPrivateMethods: SplitterPrivateMethods = {
747
- }
748
-
749
- Object.assign($xeSplitter, splitterMethods, splitterPrivateMethods)
750
-
751
- const renderHandleBar = (prevItem: VxeSplitterDefines.PaneConfig, nextItem: VxeSplitterDefines.PaneConfig) => {
752
- const { border, resize, vertical } = props
753
- const { itemList } = reactData
754
- const barStyle = computeBarStyle.value
755
- const actionOpts = computeActionOpts.value
756
- const { direction } = actionOpts
757
- const showPrevButton = XEUtils.isBoolean(actionOpts.showPrevButton) ? actionOpts.showPrevButton : (itemList.some(item => item.showAction))
758
- const showNextButton = XEUtils.isBoolean(actionOpts.showNextButton) ? actionOpts.showNextButton : (direction === 'next' && itemList.some(item => item.showAction))
759
- const resizeOpts = computeResizeOpts.value
760
- const { immediate } = resizeOpts
761
- return h('div', {
762
- class: ['vxe-splitter-panel-handle', vertical ? 'is--vertical' : 'is--horizontal', immediate ? 'is-resize--immediate' : 'is-resize--lazy', {
763
- 'is--resize': resize,
764
- 'is--border': border
765
- }]
766
- }, [
767
- h('div', {
768
- class: 'vxe-splitter-panel-handle-bar',
769
- style: barStyle,
770
- onMousedown: dragEvent
771
- }),
772
- itemList.length === 2
773
- ? h('div', {
774
- class: 'vxe-splitter-panel-action-btn-wrapper'
775
- }, [
776
- showPrevButton && nextItem.isExpand
777
- ? h('div', {
778
- class: 'vxe-splitter-panel-action-btn',
779
- onDblclick: handlePrevActionDblclickEvent,
780
- onClick: handlePrevActionClickEvent
781
- }, [
782
- h('i', {
783
- class: getActionIcon(prevItem, nextItem, false)
784
- })
785
- ])
786
- : renderEmptyElement($xeSplitter),
787
- showNextButton && prevItem.isExpand
788
- ? h('div', {
789
- class: 'vxe-splitter-panel-action-btn',
790
- onDblclick: handleNextActionDblclickEvent,
791
- onClick: handleNextActionClickEvent
792
- }, [
793
- h('i', {
794
- class: getActionIcon(prevItem, nextItem, true)
795
- })
796
- ])
797
- : renderEmptyElement($xeSplitter)
798
- ])
799
- : renderEmptyElement($xeSplitter)
800
- ])
801
- }
802
-
803
- const renderItems = () => {
804
- const { border, padding, resize, vertical } = props
805
- const { itemList } = reactData
806
- const vSize = computeSize.value
807
- const resizeOpts = computeResizeOpts.value
808
- const { immediate } = resizeOpts
809
- const visibleItems = computeVisibleItems.value
810
- const { autoItems } = computeAutoItems.value
811
- const itemVNs: VNode[] = []
812
- itemList.forEach((prevItem, index) => {
813
- const { id, name, slots, renderHeight, resizeHeight, foldHeight, renderWidth, resizeWidth, foldWidth, isExpand } = prevItem
814
- const nextItem = itemList[index + 1]
815
- const defaultSlot = slots ? slots.default : null
816
- const stys: Record<string, string | number> = {}
817
- let itemWidth = isExpand ? (foldWidth || resizeWidth || renderWidth) : 0
818
- let itemHeight = isExpand ? (foldHeight || resizeHeight || renderHeight) : 0
819
- // 至少存在一个自适应
820
- if (autoItems.length === 1) {
821
- if (vertical) {
822
- if (!prevItem.height) {
823
- itemHeight = 0
824
- }
825
- } else {
826
- if (!prevItem.width) {
827
- itemWidth = 0
828
- }
829
- }
830
- }
831
- let isFill = true
832
- if (vertical) {
833
- if (itemHeight && visibleItems.length > 1) {
834
- isFill = false
835
- stys.height = toCssUnit(itemHeight)
836
- }
837
- } else {
838
- if (itemWidth && visibleItems.length > 1) {
839
- isFill = false
840
- stys.width = toCssUnit(itemWidth)
841
- }
842
- }
843
-
844
- itemVNs.push(
845
- h('div', {
846
- itemid: id,
847
- class: ['vxe-splitter-panel', vertical ? 'is--vertical' : 'is--horizontal', immediate ? 'is-resize--immediate' : 'is-resize--lazy', {
848
- [`size--${vSize}`]: vSize,
849
- 'is--resize': resize,
850
- 'is--padding': padding,
851
- 'is--border': border,
852
- 'is--height': itemHeight,
853
- 'is--width': itemWidth,
854
- 'is--visible': isExpand,
855
- 'is--hidden': !isExpand,
856
- 'is--fill': isExpand && isFill
857
- }],
858
- style: stys
859
- }, [
860
- h('div', {
861
- itemid: id,
862
- class: 'vxe-splitter-panel--wrapper'
863
- }, [
864
- h('div', {
865
- class: 'vxe-splitter-panel--inner'
866
- }, defaultSlot ? callSlot(defaultSlot, { name, isExpand }) : [])
867
- ])
868
- ])
869
- )
870
-
871
- if (nextItem) {
872
- itemVNs.push(renderHandleBar(prevItem, nextItem))
873
- }
874
- })
875
- return h('div', {
876
- class: 'vxe-splitter-wrapper'
877
- }, itemVNs)
878
- }
879
-
880
- const renderVN = () => {
881
- const { vertical, width, height } = props
882
- const vSize = computeSize.value
883
- const resizeOpts = computeResizeOpts.value
884
- const { immediate, showTip } = resizeOpts
885
- const defaultSlot = slots.default
886
- const stys: Record<string, string | number> = {}
887
- if (height) {
888
- stys.height = toCssUnit(height)
889
- }
890
- if (width) {
891
- stys.width = toCssUnit(width)
892
- }
893
- return h('div', {
894
- ref: refElem,
895
- class: ['vxe-splitter', vertical ? 'is--vertical' : 'is--horizontal', immediate ? 'is-resize--immediate' : 'is-resize--lazy', {
896
- [`size--${vSize}`]: vSize
897
- }],
898
- style: stys
899
- }, [
900
- h('div', {
901
- class: 'vxe-splitter-slots'
902
- }, defaultSlot ? defaultSlot({}) : []),
903
- renderItems(),
904
- h('div', {
905
- ref: refResizableSplitterTip,
906
- class: ['vxe-splitter--resizable-splitter-tip', vertical ? 'is--vertical' : 'is--horizontal', immediate ? 'is-resize--immediate' : 'is-resize--lazy']
907
- }, showTip
908
- ? [
909
- h('div', {
910
- class: 'vxe-splitter--resizable-splitter-tip-number'
911
- }, [
912
- h('div', {
913
- class: 'vxe-splitter--resizable-splitter-number-prev'
914
- }),
915
- h('div', {
916
- class: 'vxe-splitter--resizable-splitter-number-next'
917
- })
918
- ])
919
- ]
920
- : []),
921
- h('div', {
922
- class: 'vxe-splitter--render-vars'
923
- }, [
924
- h('div', {
925
- ref: refBarInfoElem,
926
- class: 'vxe-splitter--handle-bar-info'
927
- })
928
- ])
929
- ])
930
- }
931
-
932
- const itemFlag = ref(0)
933
- watch(() => props.items ? props.items.length : -1, () => {
934
- itemFlag.value++
935
- })
936
- watch(() => props.items, () => {
937
- itemFlag.value++
938
- })
939
- watch(itemFlag, () => {
940
- loadItem(props.items || [])
941
- })
942
-
943
- watch(() => reactData.staticItems, (val) => {
944
- const actionOpts = computeActionOpts.value
945
- const { showPrevButton, showNextButton } = actionOpts
946
- if (props.items && props.items.length) {
947
- errLog('vxe.error.errConflicts', ['<vxe-splitter-panel ...>', 'items'])
948
- }
949
- reactData.itemList = val || []
950
-
951
- if ((showPrevButton || showNextButton) && reactData.itemList.length > 2) {
952
- errLog('vxe.error.modelConflicts', ['[splitter] action-config.showPrevButton | action-config.showNextButton', '<vxe-splitter-panel ...> Only supports 2 panel'])
953
- }
954
- reactData.itemList.forEach(item => {
955
- if (item.showAction) {
956
- warnLog('vxe.error.removeProp', ['[splitter] showAction'])
957
- }
958
- })
959
- recalculate()
960
- })
961
-
962
- let resizeObserver: ResizeObserver
963
-
964
- onMounted(() => {
965
- nextTick(() => {
966
- recalculate()
967
- })
968
-
969
- const el = refElem.value
970
- if (el) {
971
- resizeObserver = globalResize.create(() => {
972
- recalculate()
973
- })
974
- resizeObserver.observe(el)
975
- }
976
-
977
- const actionOpts = computeActionOpts.value
978
- if (actionOpts.direction) {
979
- errLog('vxe.error.delProp', ['[splitter] action-config.direction', 'action-config.showPrevButton | action-config.showNextButton'])
980
- }
981
-
982
- globalEvents.on($xeSplitter, 'resize', handleGlobalResizeEvent)
983
- })
984
-
985
- onUnmounted(() => {
986
- if (resizeObserver) {
987
- resizeObserver.disconnect()
988
- }
989
- globalEvents.off($xeSplitter, 'resize')
990
- })
991
-
992
- onActivated(() => {
993
- recalculate()
994
- })
995
-
996
- if (props.items) {
997
- loadItem(props.items)
998
- }
999
-
1000
- provide('$xeSplitter', $xeSplitter)
1001
-
1002
- $xeSplitter.renderVN = renderVN
1003
-
1004
- return $xeSplitter
1005
- },
1006
- render () {
1007
- return this.renderVN()
1008
- }
1009
- })
1
+ import { PropType, ref, h, reactive, provide, VNode, computed, watch, nextTick, onMounted, onUnmounted, onActivated } from 'vue'
2
+ import { defineVxeComponent } from '../../ui/src/comp'
3
+ import { getConfig, getIcon, createEvent, globalEvents, globalResize, useSize, renderEmptyElement } from '../../ui'
4
+ import { getSlotVNs } from '../../ui/src/vn'
5
+ import { toCssUnit, isScale, addClass, removeClass } from '../../ui/src/dom'
6
+ import { getGlobalDefaultConfig } from '../../ui/src/utils'
7
+ import { warnLog, errLog } from '../../ui/src/log'
8
+ import XEUtils from 'xe-utils'
9
+
10
+ import type { SplitterReactData, SplitterPrivateRef, VxeSplitterPropTypes, SplitterInternalData, SplitterMethods, VxeSplitterPanelPropTypes, VxeSplitterDefines, VxeSplitterPanelProps, VxeSplitterPrivateComputed, SplitterPrivateMethods, VxeSplitterEmits, VxeSplitterConstructor, ValueOf, VxeSplitterPrivateMethods } from '../../../types'
11
+
12
+ export default defineVxeComponent({
13
+ name: 'VxeSplitter',
14
+ props: {
15
+ width: [Number, String] as PropType<VxeSplitterPropTypes.Width>,
16
+ height: [Number, String] as PropType<VxeSplitterPropTypes.Height>,
17
+ vertical: {
18
+ type: Boolean as PropType<VxeSplitterPropTypes.Vertical>,
19
+ default: () => getConfig().splitter.vertical
20
+ },
21
+ border: {
22
+ type: Boolean as PropType<VxeSplitterPropTypes.Border>,
23
+ default: () => getConfig().splitter.border
24
+ },
25
+ padding: {
26
+ type: Boolean as PropType<VxeSplitterPropTypes.Padding>,
27
+ default: () => getConfig().splitter.padding
28
+ },
29
+ resize: {
30
+ type: Boolean as PropType<VxeSplitterPropTypes.Resize>,
31
+ default: () => getConfig().splitter.resize
32
+ },
33
+ items: Array as PropType<VxeSplitterPropTypes.Items>,
34
+ itemConfig: Object as PropType<VxeSplitterPropTypes.ItemConfig>,
35
+ barConfig: Object as PropType<VxeSplitterPropTypes.BarConfig>,
36
+ resizeConfig: Object as PropType<VxeSplitterPropTypes.ResizeConfig>,
37
+ actionConfig: Object as PropType<VxeSplitterPropTypes.ActionConfig>,
38
+ size: {
39
+ type: String as PropType<VxeSplitterPropTypes.Size>,
40
+ default: () => getConfig().splitter.size || getConfig().size
41
+ }
42
+ },
43
+ emits: [
44
+ 'action-dblclick',
45
+ 'action-click',
46
+ 'toggle-expand',
47
+ 'resize-start',
48
+ 'resize-drag',
49
+ 'resize-end'
50
+ ] as VxeSplitterEmits,
51
+ setup (props, context) {
52
+ const { emit, slots } = context
53
+
54
+ const xID = XEUtils.uniqueId()
55
+
56
+ const refElem = ref<HTMLDivElement>()
57
+ const refBarInfoElem = ref<HTMLDivElement>()
58
+ const refResizableSplitterTip = ref<HTMLDivElement>()
59
+
60
+ const { computeSize } = useSize(props)
61
+
62
+ const reactData = reactive<SplitterReactData>({
63
+ staticItems: [],
64
+ itemList: [],
65
+ barWidth: 0,
66
+ barHeight: 0
67
+ })
68
+
69
+ const internalData: SplitterInternalData = {
70
+ wrapperWidth: 0,
71
+ wrapperHeight: 0
72
+ }
73
+
74
+ const computeItemOpts = computed(() => {
75
+ return Object.assign({}, getConfig().splitter.itemConfig, props.itemConfig)
76
+ })
77
+
78
+ const computeBarOpts = computed(() => {
79
+ return Object.assign({}, getConfig().splitter.barConfig, props.barConfig)
80
+ })
81
+
82
+ const computeResizeOpts = computed(() => {
83
+ return Object.assign({}, getConfig().splitter.resizeConfig, props.resizeConfig)
84
+ })
85
+
86
+ const computeActionOpts = computed(() => {
87
+ return Object.assign({}, getConfig().splitter.actionConfig, props.actionConfig)
88
+ })
89
+
90
+ const computeVisibleItems = computed(() => {
91
+ return reactData.itemList.filter(item => item.isExpand)
92
+ })
93
+
94
+ const computeAutoItems = computed(() => {
95
+ const { vertical } = props
96
+ const autoItems: VxeSplitterDefines.PaneConfig[] = []
97
+ let heightCount = 0
98
+ let widthCount = 0
99
+ reactData.itemList.forEach(vertical
100
+ ? item => {
101
+ const { renderHeight, resizeHeight, foldHeight, isExpand, height } = item
102
+ const itemHeight = isExpand ? (foldHeight || resizeHeight || renderHeight) : 0
103
+ if (!height) {
104
+ autoItems.push(item)
105
+ }
106
+ heightCount += itemHeight
107
+ }
108
+ : item => {
109
+ const { renderWidth, resizeWidth, foldWidth, isExpand, width } = item
110
+ const itemWidth = isExpand ? (foldWidth || resizeWidth || renderWidth) : 0
111
+ if (!width) {
112
+ autoItems.push(item)
113
+ }
114
+ widthCount += itemWidth
115
+ })
116
+ return {
117
+ autoItems,
118
+ heightCount,
119
+ heightRatio: heightCount / 100,
120
+ widthCount,
121
+ widthRatio: widthCount / 100
122
+ }
123
+ })
124
+
125
+ const computeBarStyle = computed(() => {
126
+ const barOpts = computeBarOpts.value
127
+ const { width, height } = barOpts
128
+ const stys: Record<string, string | number> = {}
129
+ if (height) {
130
+ stys.height = toCssUnit(height)
131
+ }
132
+ if (width) {
133
+ stys.width = toCssUnit(width)
134
+ }
135
+ return stys
136
+ })
137
+
138
+ const computeMaps: VxeSplitterPrivateComputed = {
139
+ computeItemOpts,
140
+ computeBarOpts,
141
+ computeActionOpts
142
+ }
143
+
144
+ const refMaps: SplitterPrivateRef = {
145
+ refElem
146
+ }
147
+
148
+ const $xeSplitter = {
149
+ xID,
150
+ props,
151
+ context,
152
+ reactData,
153
+ internalData,
154
+
155
+ getRefMaps: () => refMaps,
156
+ getComputeMaps: () => computeMaps
157
+ } as unknown as VxeSplitterConstructor & VxeSplitterPrivateMethods
158
+
159
+ const dispatchEvent = (type: ValueOf<VxeSplitterEmits>, params: Record<string, any>, evnt: Event | null) => {
160
+ emit(type, createEvent(evnt, { $splitter: $xeSplitter }, params))
161
+ }
162
+
163
+ const callSlot = (slotFunc: any, params: any) => {
164
+ if (slotFunc) {
165
+ if (XEUtils.isString(slotFunc)) {
166
+ slotFunc = slots[slotFunc] || null
167
+ }
168
+ if (XEUtils.isFunction(slotFunc)) {
169
+ return getSlotVNs(slotFunc(params))
170
+ }
171
+ }
172
+ return []
173
+ }
174
+
175
+ const getActionIcon = (prevItem: VxeSplitterDefines.PaneConfig, nextItem: VxeSplitterDefines.PaneConfig, isNext: boolean) => {
176
+ const { vertical } = props
177
+ const topIcon = 'SPLIT_TOP_ACTION'
178
+ const bottomIcon = 'SPLIT_BOTTOM_ACTION'
179
+ const leftIcon = 'SPLIT_LEFT_ACTION'
180
+ const rightIcon = 'SPLIT_RIGHT_ACTION'
181
+ let iconName: 'SPLIT_TOP_ACTION' | 'SPLIT_BOTTOM_ACTION' | 'SPLIT_LEFT_ACTION' | 'SPLIT_RIGHT_ACTION' | '' = ''
182
+ if (vertical) {
183
+ if (isNext) {
184
+ iconName = nextItem.isExpand ? bottomIcon : topIcon
185
+ } else {
186
+ iconName = prevItem.isExpand ? topIcon : bottomIcon
187
+ }
188
+ } else {
189
+ if (isNext) {
190
+ iconName = nextItem.isExpand ? rightIcon : leftIcon
191
+ } else {
192
+ iconName = prevItem.isExpand ? leftIcon : rightIcon
193
+ }
194
+ }
195
+ if (iconName) {
196
+ return getIcon()[iconName]
197
+ }
198
+ return ''
199
+ }
200
+
201
+ const reset = () => {
202
+ const { itemList } = reactData
203
+ itemList.forEach(item => {
204
+ item.isExpand = true
205
+ item.foldHeight = 0
206
+ item.foldWidth = 0
207
+ item.resizeHeight = 0
208
+ item.resizeWidth = 0
209
+ })
210
+ return nextTick()
211
+ }
212
+
213
+ const handleLoadItem = (list: VxeSplitterPanelProps[], isReset: boolean) => {
214
+ const { staticItems } = reactData
215
+ const actionOpts = computeActionOpts.value
216
+ const { showPrevButton, showNextButton } = actionOpts
217
+ const itemDef = {
218
+ isExpand: true,
219
+ renderWidth: 0,
220
+ resizeWidth: 0,
221
+ foldWidth: 0,
222
+ renderHeight: 0,
223
+ resizeHeight: 0,
224
+ foldHeight: 0
225
+ }
226
+ reactData.itemList = list.map(item => {
227
+ if (item.showAction) {
228
+ warnLog('vxe.error.removeProp', ['[splitter] show-action'])
229
+ }
230
+ if (item.slots) {
231
+ XEUtils.each(item.slots, (func) => {
232
+ if (!XEUtils.isFunction(func)) {
233
+ if (!slots[func]) {
234
+ errLog('vxe.error.notSlot', [`[splitter] ${func}`])
235
+ }
236
+ }
237
+ })
238
+ }
239
+ return Object.assign({}, isReset ? null : itemDef, item, isReset ? itemDef : null, {
240
+ id: XEUtils.uniqueId()
241
+ })
242
+ })
243
+ if (staticItems.length) {
244
+ errLog('vxe.error.errConflicts', ['<vxe-splitter-panel ...>', 'items'])
245
+ }
246
+ if ((showPrevButton || showNextButton) && reactData.itemList.length > 2) {
247
+ errLog('vxe.error.errConflicts', ['action-config.showPrevButton | action-config.showNextButton', 'Only supports 2 item'])
248
+ }
249
+ return recalculate()
250
+ }
251
+
252
+ const loadItem = (list: VxeSplitterPanelProps[]) => {
253
+ return handleLoadItem(list || [], false)
254
+ }
255
+
256
+ const reloadItem = (list: VxeSplitterPanelProps[]) => {
257
+ return handleLoadItem(list || [], true)
258
+ }
259
+
260
+ const handleItemByName = (name: VxeSplitterPanelPropTypes.Name) => {
261
+ const { itemList } = reactData
262
+ let index = -1
263
+ let currItem: VxeSplitterDefines.PaneConfig | null = null
264
+ let prevItem: VxeSplitterDefines.PaneConfig | null = null
265
+ let nextItem: VxeSplitterDefines.PaneConfig | null = null
266
+ for (let i = 0; i < itemList.length; i++) {
267
+ const item = itemList[i]
268
+ if (item.name === name) {
269
+ index = i
270
+ currItem = item
271
+ prevItem = itemList[i - 1] || null
272
+ nextItem = itemList[i + 1] || null
273
+ break
274
+ }
275
+ }
276
+ return {
277
+ index,
278
+ currItem,
279
+ prevItem,
280
+ nextItem
281
+ }
282
+ }
283
+
284
+ const setItemExpand = (name: VxeSplitterPanelPropTypes.Name, expanded: boolean) => {
285
+ const restItem = handleItemByName(name)
286
+ if (restItem) {
287
+ const { currItem, prevItem, nextItem } = restItem
288
+ if (currItem) {
289
+ if (expanded ? !currItem.isExpand : currItem.isExpand) {
290
+ if (nextItem) {
291
+ if (nextItem.isExpand) {
292
+ handleItemActionEvent(null, currItem, nextItem, false)
293
+ }
294
+ } else if (prevItem) {
295
+ if (prevItem.isExpand) {
296
+ handleItemActionEvent(null, prevItem, currItem, true)
297
+ }
298
+ }
299
+ }
300
+ }
301
+ }
302
+ return nextTick()
303
+ }
304
+
305
+ const toggleItemExpand = (name: VxeSplitterPanelPropTypes.Name) => {
306
+ const restItem = handleItemByName(name)
307
+ if (restItem) {
308
+ const { currItem } = restItem
309
+ if (currItem) {
310
+ return setItemExpand(name, !currItem.isExpand)
311
+ }
312
+ }
313
+ return nextTick()
314
+ }
315
+
316
+ const getItemExpand = (name: VxeSplitterPanelPropTypes.Name) => {
317
+ const restItem = handleItemByName(name)
318
+ if (restItem) {
319
+ const { currItem } = restItem
320
+ if (currItem) {
321
+ return currItem.isExpand
322
+ }
323
+ }
324
+ return false
325
+ }
326
+
327
+ const recalculate = () => {
328
+ return nextTick().then(() => {
329
+ const { vertical } = props
330
+ const { itemList } = reactData
331
+ const el = refElem.value
332
+ const barInfoElem = refBarInfoElem.value
333
+ if (!el) {
334
+ return
335
+ }
336
+ const wWidth = el.clientWidth
337
+ const wHeight = el.clientHeight
338
+ if (!wWidth || !wHeight) {
339
+ return
340
+ }
341
+ if (barInfoElem) {
342
+ reactData.barWidth = barInfoElem.offsetWidth
343
+ reactData.barHeight = barInfoElem.offsetHeight
344
+ }
345
+ const contentWidth = wWidth - (vertical ? 0 : reactData.barWidth * (itemList.length - 1))
346
+ const contentHeight = wHeight - (vertical ? reactData.barHeight * (itemList.length - 1) : 0)
347
+ const itemOpts = computeItemOpts.value
348
+ const allMinWidth = XEUtils.toNumber(itemOpts.minWidth)
349
+ const allMinHeight = XEUtils.toNumber(itemOpts.minHeight)
350
+ const residueItems: VxeSplitterDefines.PaneConfig[] = []
351
+ if (vertical) {
352
+ let countHeight = 0
353
+ itemList.forEach(item => {
354
+ const { height } = item
355
+ let itemHeight = 0
356
+ if (height) {
357
+ if (isScale(height)) {
358
+ itemHeight = contentHeight * XEUtils.toNumber(height) / 100
359
+ } else {
360
+ itemHeight = XEUtils.toNumber(height)
361
+ }
362
+ item.renderHeight = itemHeight
363
+ } else {
364
+ residueItems.push(item)
365
+ }
366
+ countHeight += itemHeight
367
+ })
368
+ if (residueItems.length) {
369
+ const reMeanHeight = (contentHeight - countHeight) / residueItems.length
370
+ residueItems.forEach(item => {
371
+ item.renderHeight = Math.max(XEUtils.toNumber(getGlobalDefaultConfig(item.minHeight, allMinHeight)), reMeanHeight)
372
+ })
373
+ }
374
+ } else {
375
+ let countWidth = 0
376
+ itemList.forEach(item => {
377
+ const { width } = item
378
+ let itemWidth = 0
379
+ if (width) {
380
+ if (isScale(width)) {
381
+ itemWidth = contentWidth * XEUtils.toNumber(width) / 100
382
+ } else {
383
+ itemWidth = XEUtils.toNumber(width)
384
+ }
385
+ item.renderWidth = itemWidth
386
+ } else {
387
+ residueItems.push(item)
388
+ }
389
+ countWidth += itemWidth
390
+ })
391
+ if (residueItems.length) {
392
+ const reMeanWidth = (contentWidth - countWidth) / residueItems.length
393
+ residueItems.forEach(item => {
394
+ item.renderWidth = Math.max(XEUtils.toNumber(getGlobalDefaultConfig(item.minWidth, allMinWidth)), reMeanWidth)
395
+ })
396
+ }
397
+ }
398
+ internalData.wrapperWidth = contentWidth
399
+ internalData.wrapperHeight = contentHeight
400
+ })
401
+ }
402
+
403
+ const dragEvent = (evnt: MouseEvent) => {
404
+ const { resize, vertical } = props
405
+ const { itemList } = reactData
406
+ if (!resize) {
407
+ return
408
+ }
409
+ evnt.preventDefault()
410
+ const barEl = evnt.currentTarget as HTMLDivElement
411
+ const handleEl = barEl.parentElement as HTMLDivElement
412
+ const el = refElem.value
413
+ if (!el) {
414
+ return
415
+ }
416
+ const prevEl = handleEl.previousElementSibling as HTMLDivElement
417
+ const nextEl = handleEl.nextElementSibling as HTMLDivElement
418
+ if (!prevEl || !nextEl) {
419
+ return
420
+ }
421
+ const prevId = prevEl.getAttribute('itemid')
422
+ const nextId = nextEl.getAttribute('itemid')
423
+ const prevItem = itemList.find(item => item.id === prevId)
424
+ const nextItem = itemList.find(item => item.id === nextId)
425
+ if (!prevItem || !nextItem) {
426
+ return
427
+ }
428
+ const containerRect = el.getBoundingClientRect()
429
+ const barRect = barEl.getBoundingClientRect()
430
+ const rsSplitterLineEl = refResizableSplitterTip.value
431
+ const rsSplitterTipEl = rsSplitterLineEl ? rsSplitterLineEl.children[0] as HTMLDivElement : null
432
+ const itemOpts = computeItemOpts.value
433
+ const resizeOpts = computeResizeOpts.value
434
+ const { immediate } = resizeOpts
435
+ const allMinWidth = XEUtils.toNumber(itemOpts.minWidth)
436
+ const allMinHeight = XEUtils.toNumber(itemOpts.minHeight)
437
+
438
+ const barOffsetX = Math.ceil(barRect.width - (evnt.clientX - barRect.left))
439
+ const barOffsetY = Math.ceil(evnt.clientY - barRect.top)
440
+
441
+ const prevWidth = prevEl.offsetWidth
442
+ const nextWidth = nextEl.offsetWidth
443
+ const prevMinWidth = XEUtils.toNumber(prevItem ? getGlobalDefaultConfig(prevItem.minWidth, allMinWidth) : allMinWidth)
444
+ const nextMinWidth = XEUtils.toNumber(nextItem ? getGlobalDefaultConfig(nextItem.minWidth, allMinWidth) : allMinWidth)
445
+ const minOffsetLeft = prevEl.offsetLeft + prevMinWidth - barOffsetX
446
+ const maxOffsetLeft = nextEl.offsetLeft + nextEl.offsetWidth - nextMinWidth - barOffsetX
447
+ const startOffsetLeft = evnt.clientX - containerRect.left
448
+ let targetOffsetWidth = -1
449
+ let prevResizeWidth = 0
450
+ let nextResizeWidth = 0
451
+ let offsetLeft = startOffsetLeft
452
+
453
+ const prevHeight = prevEl.offsetHeight
454
+ const nextHeight = nextEl.offsetHeight
455
+ const prevMinHeight = XEUtils.toNumber(prevItem ? getGlobalDefaultConfig(prevItem.minHeight, allMinHeight) : allMinHeight)
456
+ const nextMinHeight = XEUtils.toNumber(nextItem ? getGlobalDefaultConfig(nextItem.minHeight, allMinHeight) : allMinHeight)
457
+ const minOffsetTop = prevEl.offsetTop + prevMinHeight + barOffsetY
458
+ const maxOffsetTop = nextEl.offsetTop + nextEl.offsetHeight - nextMinHeight + barOffsetY
459
+ const startOffsetTop = evnt.clientY - containerRect.top
460
+ let targetOffsetHeight = -1
461
+ let prevResizeHeight = 0
462
+ let nextResizeHeight = 0
463
+ let offsetTop = startOffsetTop
464
+
465
+ const handleReStyle = (evnt: MouseEvent) => {
466
+ if (!rsSplitterLineEl) {
467
+ return
468
+ }
469
+ const rsNumPrevEl = rsSplitterTipEl ? rsSplitterTipEl.children[0] as HTMLDivElement : null
470
+ const rsNumNextEl = rsSplitterTipEl ? rsSplitterTipEl.children[1] as HTMLDivElement : null
471
+ if (vertical) {
472
+ let tipWidth = 0
473
+ if (rsNumPrevEl) {
474
+ if (targetOffsetHeight < 0) {
475
+ rsNumPrevEl.style.display = 'none'
476
+ } else {
477
+ rsNumPrevEl.textContent = `${Math.floor(prevResizeHeight)}px`
478
+ rsNumPrevEl.style.display = 'block'
479
+ tipWidth = rsNumPrevEl.offsetWidth
480
+ }
481
+ }
482
+ if (rsNumNextEl) {
483
+ if (targetOffsetHeight < 0) {
484
+ rsNumNextEl.textContent = `${Math.floor(nextResizeHeight)}px`
485
+ rsNumNextEl.style.display = 'block'
486
+ tipWidth = rsNumNextEl.offsetWidth
487
+ } else {
488
+ rsNumNextEl.style.display = 'none'
489
+ }
490
+ }
491
+ let rsLeft = Math.max(1, evnt.clientX - containerRect.left - tipWidth / 2)
492
+ if (rsLeft > containerRect.width - tipWidth - 1) {
493
+ rsLeft = containerRect.width - tipWidth - 1
494
+ }
495
+ rsSplitterLineEl.style.left = '0'
496
+ rsSplitterLineEl.style.top = `${offsetTop}px`
497
+ if (rsSplitterTipEl) {
498
+ rsSplitterTipEl.style.left = `${rsLeft}px`
499
+ }
500
+ } else {
501
+ let tipHeight = 0
502
+ if (rsNumPrevEl) {
503
+ if (targetOffsetWidth < 0) {
504
+ rsNumPrevEl.style.display = 'none'
505
+ } else {
506
+ rsNumPrevEl.textContent = `${Math.floor(prevResizeWidth)}px`
507
+ rsNumPrevEl.style.display = 'block'
508
+ tipHeight = rsNumPrevEl.offsetHeight
509
+ }
510
+ }
511
+ if (rsNumNextEl) {
512
+ if (targetOffsetWidth < 0) {
513
+ rsNumNextEl.textContent = `${Math.floor(nextResizeWidth)}px`
514
+ rsNumNextEl.style.display = 'block'
515
+ tipHeight = rsNumNextEl.offsetHeight
516
+ } else {
517
+ rsNumNextEl.style.display = 'none'
518
+ }
519
+ }
520
+ let rsTop = Math.max(1, evnt.clientY - containerRect.top - tipHeight / 2)
521
+ if (rsTop > containerRect.height - tipHeight - 1) {
522
+ rsTop = containerRect.height - tipHeight - 1
523
+ }
524
+ rsSplitterLineEl.style.top = '0'
525
+ rsSplitterLineEl.style.left = `${offsetLeft}px`
526
+ if (rsSplitterTipEl) {
527
+ rsSplitterTipEl.style.top = `${rsTop}px`
528
+ }
529
+ }
530
+ }
531
+
532
+ const handleUpdate = () => {
533
+ if (vertical) {
534
+ prevItem.resizeHeight = prevResizeHeight
535
+ nextItem.resizeHeight = nextResizeHeight
536
+ } else {
537
+ prevItem.resizeWidth = prevResizeWidth
538
+ nextItem.resizeWidth = nextResizeWidth
539
+ }
540
+ }
541
+
542
+ const handleDrag = (evnt: MouseEvent) => {
543
+ if (vertical) {
544
+ offsetTop = evnt.clientY - containerRect.top
545
+ if (offsetTop < minOffsetTop) {
546
+ offsetTop = minOffsetTop
547
+ }
548
+ if (offsetTop > maxOffsetTop) {
549
+ offsetTop = maxOffsetTop
550
+ }
551
+ targetOffsetHeight = offsetTop - startOffsetTop
552
+ prevResizeHeight = prevHeight + targetOffsetHeight
553
+ nextResizeHeight = nextHeight - targetOffsetHeight
554
+ } else {
555
+ offsetLeft = evnt.clientX - containerRect.left
556
+ if (offsetLeft < minOffsetLeft) {
557
+ offsetLeft = minOffsetLeft
558
+ }
559
+ if (offsetLeft > maxOffsetLeft) {
560
+ offsetLeft = maxOffsetLeft
561
+ }
562
+ targetOffsetWidth = offsetLeft - startOffsetLeft
563
+ prevResizeWidth = prevWidth + targetOffsetWidth
564
+ nextResizeWidth = nextWidth - targetOffsetWidth
565
+ }
566
+ if (immediate) {
567
+ if (vertical) {
568
+ prevEl.style.height = toCssUnit(prevResizeHeight)
569
+ nextEl.style.height = toCssUnit(nextResizeHeight)
570
+ } else {
571
+ prevEl.style.width = toCssUnit(prevResizeWidth)
572
+ nextEl.style.width = toCssUnit(nextResizeWidth)
573
+ }
574
+ }
575
+ if (rsSplitterLineEl) {
576
+ handleReStyle(evnt)
577
+ }
578
+ dispatchEvent('resize-drag', { prevItem, nextItem, offsetHeight: targetOffsetHeight, offsetWidth: targetOffsetWidth }, evnt)
579
+ }
580
+
581
+ document.onmousemove = (evnt) => {
582
+ evnt.preventDefault()
583
+ handleDrag(evnt)
584
+ }
585
+ document.onmouseup = (evnt) => {
586
+ document.onmousemove = null
587
+ document.onmouseup = null
588
+ if (rsSplitterLineEl) {
589
+ rsSplitterLineEl.style.display = ''
590
+ }
591
+ handleUpdate()
592
+ removeClass(el, 'is--drag')
593
+ dispatchEvent('resize-end', { prevItem, nextItem, offsetHeight: targetOffsetHeight, offsetWidth: targetOffsetWidth }, evnt)
594
+ recalculate()
595
+ }
596
+
597
+ if (rsSplitterLineEl) {
598
+ rsSplitterLineEl.style.display = 'block'
599
+ handleReStyle(evnt)
600
+ }
601
+ handleDrag(evnt)
602
+ addClass(el, 'is--drag')
603
+ dispatchEvent('resize-start', { prevItem, nextItem }, evnt)
604
+ }
605
+
606
+ const handleItemActionEvent = (evnt: MouseEvent | null, prevItem: VxeSplitterDefines.PaneConfig, nextItem: VxeSplitterDefines.PaneConfig, isNext: boolean) => {
607
+ const { vertical } = props
608
+ let expanded = false
609
+ let item = prevItem
610
+ if (isNext) {
611
+ item = nextItem
612
+ expanded = !nextItem.isExpand
613
+ nextItem.isExpand = expanded
614
+ } else {
615
+ expanded = !prevItem.isExpand
616
+ prevItem.isExpand = expanded
617
+ }
618
+ if (vertical) {
619
+ if (prevItem.isExpand && nextItem.isExpand) {
620
+ prevItem.foldHeight = 0
621
+ nextItem.foldHeight = 0
622
+ } else if (prevItem.isExpand) {
623
+ nextItem.foldHeight = 0
624
+ prevItem.foldHeight = (prevItem.resizeHeight || prevItem.renderHeight) + (nextItem.resizeHeight || nextItem.renderHeight)
625
+ } else {
626
+ prevItem.foldHeight = 0
627
+ nextItem.foldHeight = (prevItem.resizeHeight || prevItem.renderHeight) + (nextItem.resizeHeight || nextItem.renderHeight)
628
+ }
629
+ } else {
630
+ if (prevItem.isExpand && nextItem.isExpand) {
631
+ prevItem.foldWidth = 0
632
+ nextItem.foldWidth = 0
633
+ } else if (prevItem.isExpand) {
634
+ nextItem.foldWidth = 0
635
+ prevItem.foldWidth = (prevItem.resizeWidth || prevItem.renderWidth) + (nextItem.resizeWidth || nextItem.renderWidth)
636
+ } else {
637
+ prevItem.foldWidth = 0
638
+ nextItem.foldWidth = (prevItem.resizeWidth || prevItem.renderWidth) + (nextItem.resizeWidth || nextItem.renderWidth)
639
+ }
640
+ }
641
+ if (evnt) {
642
+ dispatchEvent('toggle-expand', { prevItem, nextItem, expanded, item }, evnt)
643
+ }
644
+ recalculate()
645
+ }
646
+
647
+ const handlePrevActionDblclickEvent = (evnt: MouseEvent) => {
648
+ const { itemList } = reactData
649
+ const actionOpts = computeActionOpts.value
650
+ const btnEl = evnt.currentTarget as HTMLDivElement
651
+ const btnWrapperEl = btnEl.parentElement as HTMLDivElement
652
+ const handleEl = btnWrapperEl.parentElement as HTMLDivElement
653
+ const prevEl = handleEl.previousElementSibling as HTMLDivElement
654
+ const prevId = prevEl.getAttribute('itemid')
655
+ const prevItem = itemList.find(item => item.id === prevId)
656
+ const nextEl = handleEl.nextElementSibling as HTMLDivElement
657
+ const nextId = nextEl.getAttribute('itemid')
658
+ const nextItem = itemList.find(item => item.id === nextId)
659
+
660
+ if (actionOpts.trigger === 'dblclick') {
661
+ if (prevItem && nextItem && nextItem.isExpand) {
662
+ handleItemActionEvent(evnt, prevItem, nextItem, false)
663
+ }
664
+ }
665
+ dispatchEvent('action-dblclick', { prevItem, nextItem }, evnt)
666
+ }
667
+
668
+ const handlePrevActionClickEvent = (evnt: MouseEvent) => {
669
+ const { itemList } = reactData
670
+ const actionOpts = computeActionOpts.value
671
+ const btnEl = evnt.currentTarget as HTMLDivElement
672
+ const btnWrapperEl = btnEl.parentElement as HTMLDivElement
673
+ const handleEl = btnWrapperEl.parentElement as HTMLDivElement
674
+ const prevEl = handleEl.previousElementSibling as HTMLDivElement
675
+ const prevId = prevEl.getAttribute('itemid')
676
+ const prevItem = itemList.find(item => item.id === prevId)
677
+ const nextEl = handleEl.nextElementSibling as HTMLDivElement
678
+ const nextId = nextEl.getAttribute('itemid')
679
+ const nextItem = itemList.find(item => item.id === nextId)
680
+
681
+ if (actionOpts.trigger !== 'dblclick') {
682
+ if (prevItem && nextItem && nextItem.isExpand) {
683
+ handleItemActionEvent(evnt, prevItem, nextItem, false)
684
+ }
685
+ }
686
+ dispatchEvent('action-click', { prevItem, nextItem }, evnt)
687
+ }
688
+
689
+ const handleNextActionDblclickEvent = (evnt: MouseEvent) => {
690
+ const { itemList } = reactData
691
+ const actionOpts = computeActionOpts.value
692
+ const btnEl = evnt.currentTarget as HTMLDivElement
693
+ const btnWrapperEl = btnEl.parentElement as HTMLDivElement
694
+ const handleEl = btnWrapperEl.parentElement as HTMLDivElement
695
+ const prevEl = handleEl.previousElementSibling as HTMLDivElement
696
+ const prevId = prevEl.getAttribute('itemid')
697
+ const prevItem = itemList.find(item => item.id === prevId)
698
+ const nextEl = handleEl.nextElementSibling as HTMLDivElement
699
+ const nextId = nextEl.getAttribute('itemid')
700
+ const nextItem = itemList.find(item => item.id === nextId)
701
+
702
+ if (actionOpts.trigger === 'dblclick') {
703
+ if (prevItem && nextItem && prevItem.isExpand) {
704
+ handleItemActionEvent(evnt, prevItem, nextItem, true)
705
+ }
706
+ }
707
+ dispatchEvent('action-dblclick', { prevItem, nextItem }, evnt)
708
+ }
709
+
710
+ const handleNextActionClickEvent = (evnt: MouseEvent) => {
711
+ const { itemList } = reactData
712
+ const actionOpts = computeActionOpts.value
713
+ const btnEl = evnt.currentTarget as HTMLDivElement
714
+ const btnWrapperEl = btnEl.parentElement as HTMLDivElement
715
+ const handleEl = btnWrapperEl.parentElement as HTMLDivElement
716
+ const prevEl = handleEl.previousElementSibling as HTMLDivElement
717
+ const prevId = prevEl.getAttribute('itemid')
718
+ const prevItem = itemList.find(item => item.id === prevId)
719
+ const nextEl = handleEl.nextElementSibling as HTMLDivElement
720
+ const nextId = nextEl.getAttribute('itemid')
721
+ const nextItem = itemList.find(item => item.id === nextId)
722
+
723
+ if (actionOpts.trigger !== 'dblclick') {
724
+ if (prevItem && nextItem && prevItem.isExpand) {
725
+ handleItemActionEvent(evnt, prevItem, nextItem, true)
726
+ }
727
+ }
728
+ dispatchEvent('action-click', { prevItem, nextItem }, evnt)
729
+ }
730
+
731
+ const handleGlobalResizeEvent = () => {
732
+ recalculate()
733
+ }
734
+
735
+ const splitterMethods: SplitterMethods = {
736
+ dispatchEvent,
737
+ setItemExpand,
738
+ toggleItemExpand,
739
+ getItemExpand,
740
+ recalculate,
741
+ reset,
742
+ loadItem,
743
+ reloadItem
744
+ }
745
+
746
+ const splitterPrivateMethods: SplitterPrivateMethods = {
747
+ }
748
+
749
+ Object.assign($xeSplitter, splitterMethods, splitterPrivateMethods)
750
+
751
+ const renderHandleBar = (prevItem: VxeSplitterDefines.PaneConfig, nextItem: VxeSplitterDefines.PaneConfig) => {
752
+ const { border, resize, vertical } = props
753
+ const { itemList } = reactData
754
+ const barStyle = computeBarStyle.value
755
+ const actionOpts = computeActionOpts.value
756
+ const { direction } = actionOpts
757
+ const showPrevButton = XEUtils.isBoolean(actionOpts.showPrevButton) ? actionOpts.showPrevButton : (itemList.some(item => item.showAction))
758
+ const showNextButton = XEUtils.isBoolean(actionOpts.showNextButton) ? actionOpts.showNextButton : (direction === 'next' && itemList.some(item => item.showAction))
759
+ const resizeOpts = computeResizeOpts.value
760
+ const { immediate } = resizeOpts
761
+ return h('div', {
762
+ class: ['vxe-splitter-panel-handle', vertical ? 'is--vertical' : 'is--horizontal', immediate ? 'is-resize--immediate' : 'is-resize--lazy', {
763
+ 'is--resize': resize,
764
+ 'is--border': border
765
+ }]
766
+ }, [
767
+ h('div', {
768
+ class: 'vxe-splitter-panel-handle-bar',
769
+ style: barStyle,
770
+ onMousedown: dragEvent
771
+ }),
772
+ itemList.length === 2
773
+ ? h('div', {
774
+ class: 'vxe-splitter-panel-action-btn-wrapper'
775
+ }, [
776
+ showPrevButton && nextItem.isExpand
777
+ ? h('div', {
778
+ class: 'vxe-splitter-panel-action-btn',
779
+ onDblclick: handlePrevActionDblclickEvent,
780
+ onClick: handlePrevActionClickEvent
781
+ }, [
782
+ h('i', {
783
+ class: getActionIcon(prevItem, nextItem, false)
784
+ })
785
+ ])
786
+ : renderEmptyElement($xeSplitter),
787
+ showNextButton && prevItem.isExpand
788
+ ? h('div', {
789
+ class: 'vxe-splitter-panel-action-btn',
790
+ onDblclick: handleNextActionDblclickEvent,
791
+ onClick: handleNextActionClickEvent
792
+ }, [
793
+ h('i', {
794
+ class: getActionIcon(prevItem, nextItem, true)
795
+ })
796
+ ])
797
+ : renderEmptyElement($xeSplitter)
798
+ ])
799
+ : renderEmptyElement($xeSplitter)
800
+ ])
801
+ }
802
+
803
+ const renderItems = () => {
804
+ const { border, padding, resize, vertical } = props
805
+ const { itemList } = reactData
806
+ const vSize = computeSize.value
807
+ const resizeOpts = computeResizeOpts.value
808
+ const { immediate } = resizeOpts
809
+ const visibleItems = computeVisibleItems.value
810
+ const { autoItems } = computeAutoItems.value
811
+ const itemVNs: VNode[] = []
812
+ itemList.forEach((prevItem, index) => {
813
+ const { id, name, slots, renderHeight, resizeHeight, foldHeight, renderWidth, resizeWidth, foldWidth, isExpand } = prevItem
814
+ const nextItem = itemList[index + 1]
815
+ const defaultSlot = slots ? slots.default : null
816
+ const stys: Record<string, string | number> = {}
817
+ let itemWidth = isExpand ? (foldWidth || resizeWidth || renderWidth) : 0
818
+ let itemHeight = isExpand ? (foldHeight || resizeHeight || renderHeight) : 0
819
+ // 至少存在一个自适应
820
+ if (autoItems.length === 1) {
821
+ if (vertical) {
822
+ if (!prevItem.height) {
823
+ itemHeight = 0
824
+ }
825
+ } else {
826
+ if (!prevItem.width) {
827
+ itemWidth = 0
828
+ }
829
+ }
830
+ }
831
+ let isFill = true
832
+ if (vertical) {
833
+ if (itemHeight && visibleItems.length > 1) {
834
+ isFill = false
835
+ stys.height = toCssUnit(itemHeight)
836
+ }
837
+ } else {
838
+ if (itemWidth && visibleItems.length > 1) {
839
+ isFill = false
840
+ stys.width = toCssUnit(itemWidth)
841
+ }
842
+ }
843
+
844
+ itemVNs.push(
845
+ h('div', {
846
+ itemid: id,
847
+ class: ['vxe-splitter-panel', vertical ? 'is--vertical' : 'is--horizontal', immediate ? 'is-resize--immediate' : 'is-resize--lazy', {
848
+ [`size--${vSize}`]: vSize,
849
+ 'is--resize': resize,
850
+ 'is--padding': padding,
851
+ 'is--border': border,
852
+ 'is--height': itemHeight,
853
+ 'is--width': itemWidth,
854
+ 'is--visible': isExpand,
855
+ 'is--hidden': !isExpand,
856
+ 'is--fill': isExpand && isFill
857
+ }],
858
+ style: stys
859
+ }, [
860
+ h('div', {
861
+ itemid: id,
862
+ class: 'vxe-splitter-panel--wrapper'
863
+ }, [
864
+ h('div', {
865
+ class: 'vxe-splitter-panel--inner'
866
+ }, defaultSlot ? callSlot(defaultSlot, { name, isExpand }) : [])
867
+ ])
868
+ ])
869
+ )
870
+
871
+ if (nextItem) {
872
+ itemVNs.push(renderHandleBar(prevItem, nextItem))
873
+ }
874
+ })
875
+ return h('div', {
876
+ class: 'vxe-splitter-wrapper'
877
+ }, itemVNs)
878
+ }
879
+
880
+ const renderVN = () => {
881
+ const { vertical, width, height } = props
882
+ const vSize = computeSize.value
883
+ const resizeOpts = computeResizeOpts.value
884
+ const { immediate, showTip } = resizeOpts
885
+ const defaultSlot = slots.default
886
+ const stys: Record<string, string | number> = {}
887
+ if (height) {
888
+ stys.height = toCssUnit(height)
889
+ }
890
+ if (width) {
891
+ stys.width = toCssUnit(width)
892
+ }
893
+ return h('div', {
894
+ ref: refElem,
895
+ class: ['vxe-splitter', vertical ? 'is--vertical' : 'is--horizontal', immediate ? 'is-resize--immediate' : 'is-resize--lazy', {
896
+ [`size--${vSize}`]: vSize
897
+ }],
898
+ style: stys
899
+ }, [
900
+ h('div', {
901
+ class: 'vxe-splitter-slots'
902
+ }, defaultSlot ? defaultSlot({}) : []),
903
+ renderItems(),
904
+ h('div', {
905
+ ref: refResizableSplitterTip,
906
+ class: ['vxe-splitter--resizable-splitter-tip', vertical ? 'is--vertical' : 'is--horizontal', immediate ? 'is-resize--immediate' : 'is-resize--lazy']
907
+ }, showTip
908
+ ? [
909
+ h('div', {
910
+ class: 'vxe-splitter--resizable-splitter-tip-number'
911
+ }, [
912
+ h('div', {
913
+ class: 'vxe-splitter--resizable-splitter-number-prev'
914
+ }),
915
+ h('div', {
916
+ class: 'vxe-splitter--resizable-splitter-number-next'
917
+ })
918
+ ])
919
+ ]
920
+ : []),
921
+ h('div', {
922
+ class: 'vxe-splitter--render-vars'
923
+ }, [
924
+ h('div', {
925
+ ref: refBarInfoElem,
926
+ class: 'vxe-splitter--handle-bar-info'
927
+ })
928
+ ])
929
+ ])
930
+ }
931
+
932
+ const itemFlag = ref(0)
933
+ watch(() => props.items ? props.items.length : -1, () => {
934
+ itemFlag.value++
935
+ })
936
+ watch(() => props.items, () => {
937
+ itemFlag.value++
938
+ })
939
+ watch(itemFlag, () => {
940
+ loadItem(props.items || [])
941
+ })
942
+
943
+ watch(() => reactData.staticItems, (val) => {
944
+ const actionOpts = computeActionOpts.value
945
+ const { showPrevButton, showNextButton } = actionOpts
946
+ if (props.items && props.items.length) {
947
+ errLog('vxe.error.errConflicts', ['<vxe-splitter-panel ...>', 'items'])
948
+ }
949
+ reactData.itemList = val || []
950
+
951
+ if ((showPrevButton || showNextButton) && reactData.itemList.length > 2) {
952
+ errLog('vxe.error.modelConflicts', ['[splitter] action-config.showPrevButton | action-config.showNextButton', '<vxe-splitter-panel ...> Only supports 2 panel'])
953
+ }
954
+ reactData.itemList.forEach(item => {
955
+ if (item.showAction) {
956
+ warnLog('vxe.error.removeProp', ['[splitter] showAction'])
957
+ }
958
+ })
959
+ recalculate()
960
+ })
961
+
962
+ let resizeObserver: ResizeObserver
963
+
964
+ onMounted(() => {
965
+ nextTick(() => {
966
+ recalculate()
967
+ })
968
+
969
+ const el = refElem.value
970
+ if (el) {
971
+ resizeObserver = globalResize.create(() => {
972
+ recalculate()
973
+ })
974
+ resizeObserver.observe(el)
975
+ }
976
+
977
+ const actionOpts = computeActionOpts.value
978
+ if (actionOpts.direction) {
979
+ errLog('vxe.error.delProp', ['[splitter] action-config.direction', 'action-config.showPrevButton | action-config.showNextButton'])
980
+ }
981
+
982
+ globalEvents.on($xeSplitter, 'resize', handleGlobalResizeEvent)
983
+ })
984
+
985
+ onUnmounted(() => {
986
+ if (resizeObserver) {
987
+ resizeObserver.disconnect()
988
+ }
989
+ globalEvents.off($xeSplitter, 'resize')
990
+ })
991
+
992
+ onActivated(() => {
993
+ recalculate()
994
+ })
995
+
996
+ if (props.items) {
997
+ loadItem(props.items)
998
+ }
999
+
1000
+ provide('$xeSplitter', $xeSplitter)
1001
+
1002
+ $xeSplitter.renderVN = renderVN
1003
+
1004
+ return $xeSplitter
1005
+ },
1006
+ render () {
1007
+ return this.renderVN()
1008
+ }
1009
+ })