element-sim 1.1.3 → 1.1.5

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 (759) hide show
  1. package/CHANGELOG.en-US.md +2085 -2085
  2. package/CHANGELOG.es.md +2093 -39
  3. package/CHANGELOG.fr-FR.md +2085 -2085
  4. package/CHANGELOG.zh-CN.md +22 -22
  5. package/LICENSE +21 -21
  6. package/README.md +148 -148
  7. package/lib/autocomplete.js +25 -25
  8. package/lib/calendar.js +12 -12
  9. package/lib/carousel-item.js +4 -4
  10. package/lib/carousel.js +4 -4
  11. package/lib/cascader-panel.js +25 -25
  12. package/lib/cascader.js +34 -34
  13. package/lib/checkbox-button.js +4 -4
  14. package/lib/checkbox-group.js +4 -4
  15. package/lib/checkbox.js +4 -4
  16. package/lib/collapse-item.js +8 -8
  17. package/lib/color-picker.js +21 -21
  18. package/lib/date-picker.js +83 -83
  19. package/lib/descriptions.js +2 -2
  20. package/lib/dialog.js +8 -8
  21. package/lib/directives/repeat-click.js +2 -2
  22. package/lib/drawer.js +17 -6
  23. package/lib/dropdown-item.js +4 -4
  24. package/lib/dropdown-menu.js +4 -4
  25. package/lib/dropdown.js +12 -12
  26. package/lib/{element-sim.common.js → element-ui.common.js} +559 -548
  27. package/lib/empty.js +4 -4
  28. package/lib/form-item.js +8 -8
  29. package/lib/form.js +4 -4
  30. package/lib/image.js +19 -19
  31. package/lib/index.js +1 -1
  32. package/lib/infinite-scroll.js +4 -4
  33. package/lib/input-number.js +15 -15
  34. package/lib/input.js +10 -10
  35. package/lib/loading.js +8 -8
  36. package/lib/locale/format.js +11 -11
  37. package/lib/locale/index.js +1 -1
  38. package/lib/menu-item.js +6 -6
  39. package/lib/menu.js +31 -31
  40. package/lib/message-box.js +20 -20
  41. package/lib/message.js +6 -6
  42. package/lib/mixins/locale.js +1 -1
  43. package/lib/mixins/migrating.js +21 -21
  44. package/lib/notification.js +6 -6
  45. package/lib/option-group.js +4 -4
  46. package/lib/option.js +6 -6
  47. package/lib/page-header.js +4 -4
  48. package/lib/pagination.js +10 -10
  49. package/lib/popconfirm.js +8 -8
  50. package/lib/popover.js +8 -8
  51. package/lib/radio-button.js +4 -4
  52. package/lib/radio-group.js +4 -4
  53. package/lib/radio.js +4 -4
  54. package/lib/rate.js +8 -8
  55. package/lib/result.js +8 -8
  56. package/lib/scrollbar.js +8 -8
  57. package/lib/select.js +37 -37
  58. package/lib/slider.js +15 -15
  59. package/lib/statistic.js +4 -4
  60. package/lib/steps.js +4 -4
  61. package/lib/submenu.js +6 -6
  62. package/lib/switch.js +8 -8
  63. package/lib/table-column.js +8 -8
  64. package/lib/table.js +41 -41
  65. package/lib/tabs.js +6 -6
  66. package/lib/theme-chalk/alert.css +1 -1
  67. package/lib/theme-chalk/autocomplete.css +1 -1
  68. package/lib/theme-chalk/avatar.css +1 -1
  69. package/lib/theme-chalk/backtop.css +1 -1
  70. package/lib/theme-chalk/badge.css +1 -1
  71. package/lib/theme-chalk/breadcrumb.css +1 -1
  72. package/lib/theme-chalk/button.css +1 -1
  73. package/lib/theme-chalk/calendar.css +1 -1
  74. package/lib/theme-chalk/card.css +1 -1
  75. package/lib/theme-chalk/carousel.css +1 -1
  76. package/lib/theme-chalk/cascader-panel.css +1 -1
  77. package/lib/theme-chalk/cascader.css +1 -1
  78. package/lib/theme-chalk/checkbox.css +1 -1
  79. package/lib/theme-chalk/collapse.css +1 -1
  80. package/lib/theme-chalk/color-picker.css +1 -1
  81. package/lib/theme-chalk/date-picker.css +1 -1
  82. package/lib/theme-chalk/descriptions-item.css +1 -1
  83. package/lib/theme-chalk/descriptions.css +1 -1
  84. package/lib/theme-chalk/dialog.css +1 -1
  85. package/lib/theme-chalk/divider.css +1 -1
  86. package/lib/theme-chalk/dropdown.css +1 -1
  87. package/lib/theme-chalk/empty.css +1 -1
  88. package/lib/theme-chalk/form.css +1 -1
  89. package/lib/theme-chalk/image.css +1 -1
  90. package/lib/theme-chalk/index.css +1 -1
  91. package/lib/theme-chalk/input-number.css +1 -1
  92. package/lib/theme-chalk/input.css +1 -1
  93. package/lib/theme-chalk/link.css +1 -1
  94. package/lib/theme-chalk/loading.css +1 -1
  95. package/lib/theme-chalk/menu.css +1 -1
  96. package/lib/theme-chalk/message-box.css +1 -1
  97. package/lib/theme-chalk/message.css +1 -1
  98. package/lib/theme-chalk/notification.css +1 -1
  99. package/lib/theme-chalk/option-group.css +1 -1
  100. package/lib/theme-chalk/option.css +1 -1
  101. package/lib/theme-chalk/page-header.css +1 -1
  102. package/lib/theme-chalk/pagination.css +1 -1
  103. package/lib/theme-chalk/popover.css +1 -1
  104. package/lib/theme-chalk/popper.css +1 -1
  105. package/lib/theme-chalk/progress.css +1 -1
  106. package/lib/theme-chalk/radio-button.css +1 -1
  107. package/lib/theme-chalk/radio.css +1 -1
  108. package/lib/theme-chalk/rate.css +1 -1
  109. package/lib/theme-chalk/reset.css +1 -1
  110. package/lib/theme-chalk/result.css +1 -1
  111. package/lib/theme-chalk/scrollbar.css +1 -1
  112. package/lib/theme-chalk/select-dropdown.css +1 -1
  113. package/lib/theme-chalk/select.css +1 -1
  114. package/lib/theme-chalk/skeleton-item.css +1 -1
  115. package/lib/theme-chalk/skeleton.css +1 -1
  116. package/lib/theme-chalk/slider.css +1 -1
  117. package/lib/theme-chalk/statistic.css +1 -1
  118. package/lib/theme-chalk/step.css +1 -1
  119. package/lib/theme-chalk/steps.css +1 -1
  120. package/lib/theme-chalk/switch.css +1 -1
  121. package/lib/theme-chalk/table-column.css +1 -1
  122. package/lib/theme-chalk/table.css +1 -1
  123. package/lib/theme-chalk/tabs.css +1 -1
  124. package/lib/theme-chalk/tag.css +1 -1
  125. package/lib/theme-chalk/time-picker.css +1 -1
  126. package/lib/theme-chalk/time-select.css +1 -1
  127. package/lib/theme-chalk/timeline-item.css +1 -1
  128. package/lib/theme-chalk/tooltip.css +1 -1
  129. package/lib/theme-chalk/transfer.css +1 -1
  130. package/lib/theme-chalk/tree.css +1 -1
  131. package/lib/theme-chalk/upload.css +1 -1
  132. package/lib/time-picker.js +42 -42
  133. package/lib/time-select.js +25 -25
  134. package/lib/tooltip.js +6 -6
  135. package/lib/transfer.js +23 -23
  136. package/lib/transitions/collapse-transition.js +1 -1
  137. package/lib/tree.js +23 -23
  138. package/lib/upload.js +11 -11
  139. package/lib/utils/after-leave.js +7 -7
  140. package/lib/utils/aria-dialog.js +16 -16
  141. package/lib/utils/aria-utils.js +25 -25
  142. package/lib/utils/clickoutside.js +8 -8
  143. package/lib/utils/date-util.js +2 -2
  144. package/lib/utils/date.js +37 -37
  145. package/lib/utils/lodash.js +9292 -9292
  146. package/lib/utils/popper.js +321 -321
  147. package/lib/utils/popup/index.js +2 -2
  148. package/lib/utils/popup/popup-manager.js +1 -1
  149. package/lib/utils/types.js +3 -3
  150. package/lib/utils/util.js +1 -1
  151. package/lib/utils/vdom.js +1 -1
  152. package/lib/utils/vue-popper.js +8 -8
  153. package/package.json +151 -151
  154. package/packages/alert/index.js +8 -8
  155. package/packages/alert/src/main.vue +94 -94
  156. package/packages/aside/index.js +8 -8
  157. package/packages/aside/src/main.vue +20 -20
  158. package/packages/autocomplete/index.js +8 -8
  159. package/packages/autocomplete/src/autocomplete-suggestions.vue +76 -76
  160. package/packages/autocomplete/src/autocomplete.vue +285 -285
  161. package/packages/avatar/index.js +8 -8
  162. package/packages/avatar/src/main.vue +107 -107
  163. package/packages/backtop/index.js +8 -8
  164. package/packages/backtop/src/main.vue +110 -110
  165. package/packages/badge/index.js +8 -8
  166. package/packages/badge/src/main.vue +53 -53
  167. package/packages/breadcrumb/index.js +8 -8
  168. package/packages/breadcrumb/src/breadcrumb-item.vue +41 -41
  169. package/packages/breadcrumb/src/breadcrumb.vue +34 -34
  170. package/packages/breadcrumb-item/index.js +8 -8
  171. package/packages/button/index.js +8 -8
  172. package/packages/button/src/button-group.vue +10 -10
  173. package/packages/button/src/button.vue +78 -78
  174. package/packages/button-group/index.js +8 -8
  175. package/packages/calendar/index.js +8 -8
  176. package/packages/calendar/src/date-table.vue +200 -200
  177. package/packages/calendar/src/main.vue +280 -280
  178. package/packages/card/index.js +8 -8
  179. package/packages/card/src/main.vue +23 -23
  180. package/packages/carousel/index.js +8 -8
  181. package/packages/carousel/src/item.vue +138 -138
  182. package/packages/carousel/src/main.vue +315 -315
  183. package/packages/carousel-item/index.js +8 -8
  184. package/packages/cascader/index.js +8 -8
  185. package/packages/cascader/src/cascader.vue +663 -663
  186. package/packages/cascader-panel/index.js +8 -8
  187. package/packages/cascader-panel/src/cascader-menu.vue +138 -138
  188. package/packages/cascader-panel/src/cascader-node.vue +246 -246
  189. package/packages/cascader-panel/src/cascader-panel.vue +391 -391
  190. package/packages/cascader-panel/src/node.js +166 -166
  191. package/packages/cascader-panel/src/store.js +58 -58
  192. package/packages/checkbox/index.js +8 -8
  193. package/packages/checkbox/src/checkbox-button.vue +199 -199
  194. package/packages/checkbox/src/checkbox-group.vue +48 -48
  195. package/packages/checkbox/src/checkbox.vue +222 -222
  196. package/packages/checkbox-button/index.js +8 -8
  197. package/packages/checkbox-group/index.js +8 -8
  198. package/packages/col/index.js +9 -9
  199. package/packages/col/src/col.js +71 -71
  200. package/packages/collapse/index.js +9 -9
  201. package/packages/collapse/src/collapse-item.vue +114 -114
  202. package/packages/collapse/src/collapse.vue +73 -73
  203. package/packages/collapse-item/index.js +8 -8
  204. package/packages/color-picker/index.js +8 -8
  205. package/packages/color-picker/src/color.js +317 -317
  206. package/packages/color-picker/src/components/alpha-slider.vue +132 -132
  207. package/packages/color-picker/src/components/hue-slider.vue +123 -123
  208. package/packages/color-picker/src/components/picker-dropdown.vue +121 -121
  209. package/packages/color-picker/src/components/predefine.vue +60 -60
  210. package/packages/color-picker/src/components/sv-panel.vue +100 -100
  211. package/packages/color-picker/src/draggable.js +36 -36
  212. package/packages/color-picker/src/main.vue +188 -188
  213. package/packages/container/index.js +8 -8
  214. package/packages/container/src/main.vue +33 -33
  215. package/packages/date-picker/index.js +8 -8
  216. package/packages/date-picker/src/basic/date-table.vue +441 -441
  217. package/packages/date-picker/src/basic/month-table.vue +269 -269
  218. package/packages/date-picker/src/basic/time-spinner.vue +304 -304
  219. package/packages/date-picker/src/basic/year-table.vue +111 -111
  220. package/packages/date-picker/src/panel/date-range.vue +680 -680
  221. package/packages/date-picker/src/panel/date.vue +609 -609
  222. package/packages/date-picker/src/panel/month-range.vue +289 -289
  223. package/packages/date-picker/src/panel/time-range.vue +248 -248
  224. package/packages/date-picker/src/panel/time-select.vue +178 -178
  225. package/packages/date-picker/src/panel/time.vue +186 -186
  226. package/packages/date-picker/src/picker/date-picker.js +43 -43
  227. package/packages/date-picker/src/picker/time-picker.js +39 -39
  228. package/packages/date-picker/src/picker/time-select.js +21 -21
  229. package/packages/date-picker/src/picker.vue +956 -956
  230. package/packages/descriptions/index.js +8 -8
  231. package/packages/descriptions/src/descriptions-item.js +30 -30
  232. package/packages/descriptions/src/descriptions-row.js +116 -116
  233. package/packages/descriptions/src/index.js +180 -180
  234. package/packages/descriptions-item/index.js +8 -8
  235. package/packages/dialog/index.js +8 -8
  236. package/packages/dialog/src/component.vue +212 -212
  237. package/packages/divider/index.js +8 -8
  238. package/packages/divider/src/main.vue +37 -37
  239. package/packages/drawer/index.js +8 -8
  240. package/packages/drawer/src/main.vue +208 -205
  241. package/packages/dropdown/index.js +8 -8
  242. package/packages/dropdown/src/dropdown-item.vue +37 -37
  243. package/packages/dropdown/src/dropdown-menu.vue +63 -63
  244. package/packages/dropdown/src/dropdown.vue +293 -293
  245. package/packages/dropdown-item/index.js +8 -8
  246. package/packages/dropdown-menu/index.js +8 -8
  247. package/packages/empty/index.js +7 -7
  248. package/packages/empty/src/img-empty.vue +132 -132
  249. package/packages/empty/src/index.vue +50 -50
  250. package/packages/footer/index.js +8 -8
  251. package/packages/footer/src/main.vue +20 -20
  252. package/packages/form/index.js +8 -8
  253. package/packages/form/src/form-item.vue +324 -324
  254. package/packages/form/src/form.vue +182 -182
  255. package/packages/form/src/label-wrap.vue +78 -78
  256. package/packages/form-item/index.js +8 -8
  257. package/packages/header/index.js +8 -8
  258. package/packages/header/src/main.vue +20 -20
  259. package/packages/icon/index.js +8 -8
  260. package/packages/icon/src/icon.vue +13 -13
  261. package/packages/image/index.js +8 -8
  262. package/packages/image/src/image-viewer.vue +330 -330
  263. package/packages/image/src/main.vue +249 -249
  264. package/packages/infinite-scroll/index.js +8 -8
  265. package/packages/infinite-scroll/src/main.js +150 -150
  266. package/packages/input/index.js +8 -8
  267. package/packages/input/src/calcTextareaHeight.js +104 -104
  268. package/packages/input/src/input.vue +440 -440
  269. package/packages/input-number/index.js +8 -8
  270. package/packages/input-number/src/input-number.vue +283 -283
  271. package/packages/link/index.js +8 -8
  272. package/packages/link/src/main.vue +53 -53
  273. package/packages/loading/index.js +11 -11
  274. package/packages/loading/src/directive.js +133 -133
  275. package/packages/loading/src/index.js +106 -106
  276. package/packages/loading/src/loading.vue +41 -41
  277. package/packages/main/index.js +8 -8
  278. package/packages/main/src/main.vue +12 -12
  279. package/packages/menu/index.js +8 -8
  280. package/packages/menu/src/menu-item-group.vue +45 -45
  281. package/packages/menu/src/menu-item.vue +112 -112
  282. package/packages/menu/src/menu-mixin.js +44 -44
  283. package/packages/menu/src/menu.vue +325 -325
  284. package/packages/menu/src/submenu.vue +349 -349
  285. package/packages/menu-item/index.js +8 -8
  286. package/packages/menu-item-group/index.js +8 -8
  287. package/packages/message/index.js +2 -2
  288. package/packages/message/src/main.js +91 -91
  289. package/packages/message/src/main.vue +117 -117
  290. package/packages/message-box/index.js +2 -2
  291. package/packages/message-box/src/main.js +216 -216
  292. package/packages/message-box/src/main.vue +332 -332
  293. package/packages/notification/index.js +2 -2
  294. package/packages/notification/src/main.js +94 -94
  295. package/packages/notification/src/main.vue +152 -152
  296. package/packages/option/index.js +8 -8
  297. package/packages/option-group/index.js +8 -8
  298. package/packages/page-header/index.js +8 -8
  299. package/packages/page-header/src/main.vue +30 -30
  300. package/packages/pagination/index.js +8 -8
  301. package/packages/pagination/src/pager.vue +163 -163
  302. package/packages/pagination/src/pagination.js +386 -386
  303. package/packages/popconfirm/index.js +8 -8
  304. package/packages/popconfirm/src/main.vue +104 -104
  305. package/packages/popover/index.js +14 -14
  306. package/packages/popover/src/directive.js +20 -20
  307. package/packages/popover/src/main.vue +237 -237
  308. package/packages/progress/index.js +8 -8
  309. package/packages/progress/src/progress.vue +235 -235
  310. package/packages/radio/index.js +8 -8
  311. package/packages/radio/src/radio-button.vue +115 -115
  312. package/packages/radio/src/radio-group.vue +113 -113
  313. package/packages/radio/src/radio.vue +134 -134
  314. package/packages/radio-button/index.js +8 -8
  315. package/packages/radio-group/index.js +8 -8
  316. package/packages/rate/index.js +8 -8
  317. package/packages/rate/src/main.vue +348 -348
  318. package/packages/result/index.js +8 -8
  319. package/packages/result/src/icon-error.vue +13 -13
  320. package/packages/result/src/icon-info.vue +13 -13
  321. package/packages/result/src/icon-success.vue +13 -13
  322. package/packages/result/src/icon-warning.vue +13 -13
  323. package/packages/result/src/index.vue +65 -65
  324. package/packages/row/index.js +9 -9
  325. package/packages/row/src/row.js +44 -44
  326. package/packages/scrollbar/index.js +8 -8
  327. package/packages/scrollbar/src/bar.js +92 -92
  328. package/packages/scrollbar/src/main.js +130 -130
  329. package/packages/scrollbar/src/util.js +34 -34
  330. package/packages/select/index.js +8 -8
  331. package/packages/select/src/navigation-mixin.js +54 -54
  332. package/packages/select/src/option-group.vue +60 -60
  333. package/packages/select/src/option.vue +168 -168
  334. package/packages/select/src/select-dropdown.vue +74 -74
  335. package/packages/select/src/select.vue +900 -900
  336. package/packages/skeleton/index.js +8 -8
  337. package/packages/skeleton/src/img-placeholder.vue +16 -16
  338. package/packages/skeleton/src/index.vue +76 -76
  339. package/packages/skeleton/src/item.vue +21 -21
  340. package/packages/skeleton-item/index.js +8 -8
  341. package/packages/slider/index.js +8 -8
  342. package/packages/slider/src/button.vue +238 -238
  343. package/packages/slider/src/main.vue +427 -427
  344. package/packages/slider/src/marker.js +18 -18
  345. package/packages/spinner/index.js +8 -8
  346. package/packages/spinner/src/spinner.vue +27 -27
  347. package/packages/statistic/index.js +8 -8
  348. package/packages/statistic/src/main.vue +204 -204
  349. package/packages/step/index.js +8 -8
  350. package/packages/steps/README.md +69 -69
  351. package/packages/steps/index.js +8 -8
  352. package/packages/steps/src/step.vue +184 -184
  353. package/packages/steps/src/steps.vue +68 -68
  354. package/packages/submenu/index.js +8 -8
  355. package/packages/switch/index.js +9 -9
  356. package/packages/switch/src/component.vue +174 -174
  357. package/packages/tab-pane/index.js +8 -8
  358. package/packages/table/index.js +8 -8
  359. package/packages/table/src/config.js +124 -124
  360. package/packages/table/src/dropdown.js +28 -28
  361. package/packages/table/src/filter-panel.vue +194 -194
  362. package/packages/table/src/layout-observer.js +68 -68
  363. package/packages/table/src/store/current.js +76 -76
  364. package/packages/table/src/store/expand.js +65 -65
  365. package/packages/table/src/store/helper.js +41 -41
  366. package/packages/table/src/store/index.js +147 -147
  367. package/packages/table/src/store/tree.js +209 -209
  368. package/packages/table/src/store/watcher.js +381 -381
  369. package/packages/table/src/table-body.js +469 -469
  370. package/packages/table/src/table-column.js +319 -319
  371. package/packages/table/src/table-footer.js +153 -153
  372. package/packages/table/src/table-header.js +511 -511
  373. package/packages/table/src/table-layout.js +249 -249
  374. package/packages/table/src/table-row.js +101 -101
  375. package/packages/table/src/table.vue +712 -712
  376. package/packages/table/src/util.js +273 -273
  377. package/packages/table-column/index.js +8 -8
  378. package/packages/tabs/index.js +8 -8
  379. package/packages/tabs/src/tab-bar.vue +57 -57
  380. package/packages/tabs/src/tab-nav.vue +294 -294
  381. package/packages/tabs/src/tab-pane.vue +56 -56
  382. package/packages/tabs/src/tabs.vue +191 -191
  383. package/packages/tag/index.js +8 -8
  384. package/packages/tag/src/tag.vue +58 -58
  385. package/packages/theme-chalk/README.md +33 -33
  386. package/packages/theme-chalk/lib/alert.css +1 -1
  387. package/packages/theme-chalk/lib/autocomplete.css +1 -1
  388. package/packages/theme-chalk/lib/avatar.css +1 -1
  389. package/packages/theme-chalk/lib/backtop.css +1 -1
  390. package/packages/theme-chalk/lib/badge.css +1 -1
  391. package/packages/theme-chalk/lib/breadcrumb.css +1 -1
  392. package/packages/theme-chalk/lib/button.css +1 -1
  393. package/packages/theme-chalk/lib/calendar.css +1 -1
  394. package/packages/theme-chalk/lib/card.css +1 -1
  395. package/packages/theme-chalk/lib/carousel.css +1 -1
  396. package/packages/theme-chalk/lib/cascader-panel.css +1 -1
  397. package/packages/theme-chalk/lib/cascader.css +1 -1
  398. package/packages/theme-chalk/lib/checkbox.css +1 -1
  399. package/packages/theme-chalk/lib/collapse.css +1 -1
  400. package/packages/theme-chalk/lib/color-picker.css +1 -1
  401. package/packages/theme-chalk/lib/date-picker.css +1 -1
  402. package/packages/theme-chalk/lib/descriptions-item.css +1 -1
  403. package/packages/theme-chalk/lib/descriptions.css +1 -1
  404. package/packages/theme-chalk/lib/dialog.css +1 -1
  405. package/packages/theme-chalk/lib/divider.css +1 -1
  406. package/packages/theme-chalk/lib/dropdown.css +1 -1
  407. package/packages/theme-chalk/lib/empty.css +1 -1
  408. package/packages/theme-chalk/lib/form.css +1 -1
  409. package/packages/theme-chalk/lib/image.css +1 -1
  410. package/packages/theme-chalk/lib/index.css +1 -1
  411. package/packages/theme-chalk/lib/input-number.css +1 -1
  412. package/packages/theme-chalk/lib/input.css +1 -1
  413. package/packages/theme-chalk/lib/link.css +1 -1
  414. package/packages/theme-chalk/lib/loading.css +1 -1
  415. package/packages/theme-chalk/lib/menu.css +1 -1
  416. package/packages/theme-chalk/lib/message-box.css +1 -1
  417. package/packages/theme-chalk/lib/message.css +1 -1
  418. package/packages/theme-chalk/lib/notification.css +1 -1
  419. package/packages/theme-chalk/lib/option-group.css +1 -1
  420. package/packages/theme-chalk/lib/option.css +1 -1
  421. package/packages/theme-chalk/lib/page-header.css +1 -1
  422. package/packages/theme-chalk/lib/pagination.css +1 -1
  423. package/packages/theme-chalk/lib/popover.css +1 -1
  424. package/packages/theme-chalk/lib/popper.css +1 -1
  425. package/packages/theme-chalk/lib/progress.css +1 -1
  426. package/packages/theme-chalk/lib/radio-button.css +1 -1
  427. package/packages/theme-chalk/lib/radio.css +1 -1
  428. package/packages/theme-chalk/lib/rate.css +1 -1
  429. package/packages/theme-chalk/lib/reset.css +1 -1
  430. package/packages/theme-chalk/lib/result.css +1 -1
  431. package/packages/theme-chalk/lib/scrollbar.css +1 -1
  432. package/packages/theme-chalk/lib/select-dropdown.css +1 -1
  433. package/packages/theme-chalk/lib/select.css +1 -1
  434. package/packages/theme-chalk/lib/skeleton-item.css +1 -1
  435. package/packages/theme-chalk/lib/skeleton.css +1 -1
  436. package/packages/theme-chalk/lib/slider.css +1 -1
  437. package/packages/theme-chalk/lib/statistic.css +1 -1
  438. package/packages/theme-chalk/lib/step.css +1 -1
  439. package/packages/theme-chalk/lib/steps.css +1 -1
  440. package/packages/theme-chalk/lib/switch.css +1 -1
  441. package/packages/theme-chalk/lib/table-column.css +1 -1
  442. package/packages/theme-chalk/lib/table.css +1 -1
  443. package/packages/theme-chalk/lib/tabs.css +1 -1
  444. package/packages/theme-chalk/lib/tag.css +1 -1
  445. package/packages/theme-chalk/lib/time-picker.css +1 -1
  446. package/packages/theme-chalk/lib/time-select.css +1 -1
  447. package/packages/theme-chalk/lib/timeline-item.css +1 -1
  448. package/packages/theme-chalk/lib/tooltip.css +1 -1
  449. package/packages/theme-chalk/lib/transfer.css +1 -1
  450. package/packages/theme-chalk/lib/tree.css +1 -1
  451. package/packages/theme-chalk/lib/upload.css +1 -1
  452. package/packages/theme-chalk/package.json +35 -35
  453. package/packages/theme-chalk/src/alert.scss +147 -147
  454. package/packages/theme-chalk/src/aside.scss +7 -7
  455. package/packages/theme-chalk/src/autocomplete.scss +80 -80
  456. package/packages/theme-chalk/src/avatar.scss +51 -51
  457. package/packages/theme-chalk/src/backtop.scss +22 -22
  458. package/packages/theme-chalk/src/badge.scss +57 -57
  459. package/packages/theme-chalk/src/base.scss +2 -2
  460. package/packages/theme-chalk/src/breadcrumb.scss +55 -59
  461. package/packages/theme-chalk/src/button.scss +262 -277
  462. package/packages/theme-chalk/src/calendar.scss +79 -79
  463. package/packages/theme-chalk/src/card.scss +32 -32
  464. package/packages/theme-chalk/src/carousel-item.scss +49 -49
  465. package/packages/theme-chalk/src/carousel.scss +161 -161
  466. package/packages/theme-chalk/src/cascader-panel.scss +120 -120
  467. package/packages/theme-chalk/src/cascader.scss +182 -183
  468. package/packages/theme-chalk/src/checkbox.scss +359 -359
  469. package/packages/theme-chalk/src/col.scss +155 -155
  470. package/packages/theme-chalk/src/collapse.scss +63 -63
  471. package/packages/theme-chalk/src/color-picker.scss +384 -384
  472. package/packages/theme-chalk/src/common/popup.scss +42 -42
  473. package/packages/theme-chalk/src/common/transition.scss +98 -98
  474. package/packages/theme-chalk/src/common/var.scss +1028 -1030
  475. package/packages/theme-chalk/src/container.scss +14 -14
  476. package/packages/theme-chalk/src/date-picker/date-picker.scss +97 -97
  477. package/packages/theme-chalk/src/date-picker/date-range-picker.scss +101 -101
  478. package/packages/theme-chalk/src/date-picker/date-table.scss +151 -151
  479. package/packages/theme-chalk/src/date-picker/month-table.scss +82 -82
  480. package/packages/theme-chalk/src/date-picker/picker-panel.scss +117 -117
  481. package/packages/theme-chalk/src/date-picker/picker.scss +197 -197
  482. package/packages/theme-chalk/src/date-picker/time-picker.scss +85 -85
  483. package/packages/theme-chalk/src/date-picker/time-range-picker.scss +31 -31
  484. package/packages/theme-chalk/src/date-picker/time-spinner.scss +110 -110
  485. package/packages/theme-chalk/src/date-picker/year-table.scss +51 -51
  486. package/packages/theme-chalk/src/date-picker.scss +11 -11
  487. package/packages/theme-chalk/src/descriptions-item.scss +42 -42
  488. package/packages/theme-chalk/src/descriptions.scss +111 -111
  489. package/packages/theme-chalk/src/dialog.scss +123 -123
  490. package/packages/theme-chalk/src/display.scss +12 -12
  491. package/packages/theme-chalk/src/divider.scss +46 -46
  492. package/packages/theme-chalk/src/drawer.scss +219 -219
  493. package/packages/theme-chalk/src/dropdown.scss +182 -182
  494. package/packages/theme-chalk/src/empty.scss +45 -45
  495. package/packages/theme-chalk/src/footer.scss +8 -8
  496. package/packages/theme-chalk/src/form.scss +167 -173
  497. package/packages/theme-chalk/src/header.scss +8 -8
  498. package/packages/theme-chalk/src/icon.scss +1167 -1167
  499. package/packages/theme-chalk/src/image.scss +179 -179
  500. package/packages/theme-chalk/src/input-number.scss +180 -180
  501. package/packages/theme-chalk/src/input.scss +360 -360
  502. package/packages/theme-chalk/src/link.scss +81 -81
  503. package/packages/theme-chalk/src/loading.scss +96 -96
  504. package/packages/theme-chalk/src/main.scss +12 -12
  505. package/packages/theme-chalk/src/menu.scss +289 -289
  506. package/packages/theme-chalk/src/message-box.scss +226 -226
  507. package/packages/theme-chalk/src/message.scss +120 -121
  508. package/packages/theme-chalk/src/mixins/_button.scss +81 -81
  509. package/packages/theme-chalk/src/mixins/config.scss +4 -4
  510. package/packages/theme-chalk/src/mixins/function.scss +44 -44
  511. package/packages/theme-chalk/src/mixins/mixins.scss +190 -190
  512. package/packages/theme-chalk/src/mixins/utils.scss +38 -38
  513. package/packages/theme-chalk/src/notification.scss +99 -99
  514. package/packages/theme-chalk/src/option-group.scss +42 -42
  515. package/packages/theme-chalk/src/option.scss +36 -36
  516. package/packages/theme-chalk/src/page-header.scss +41 -41
  517. package/packages/theme-chalk/src/pagination.scss +295 -312
  518. package/packages/theme-chalk/src/popconfirm.scss +16 -16
  519. package/packages/theme-chalk/src/popover.scss +40 -40
  520. package/packages/theme-chalk/src/popper.scss +100 -100
  521. package/packages/theme-chalk/src/progress.scss +141 -141
  522. package/packages/theme-chalk/src/radio-button.scss +113 -113
  523. package/packages/theme-chalk/src/radio-group.scss +9 -9
  524. package/packages/theme-chalk/src/radio.scss +199 -214
  525. package/packages/theme-chalk/src/rate.scss +49 -49
  526. package/packages/theme-chalk/src/reset.scss +79 -79
  527. package/packages/theme-chalk/src/result.scss +61 -61
  528. package/packages/theme-chalk/src/row.scss +43 -43
  529. package/packages/theme-chalk/src/scrollbar.scss +72 -72
  530. package/packages/theme-chalk/src/select-dropdown.scss +62 -63
  531. package/packages/theme-chalk/src/select.scss +152 -152
  532. package/packages/theme-chalk/src/skeleton-item.scss +84 -84
  533. package/packages/theme-chalk/src/skeleton.scss +40 -40
  534. package/packages/theme-chalk/src/slider.scss +250 -250
  535. package/packages/theme-chalk/src/spinner.scss +44 -44
  536. package/packages/theme-chalk/src/statistic.scss +38 -38
  537. package/packages/theme-chalk/src/step.scss +317 -317
  538. package/packages/theme-chalk/src/steps.scss +20 -20
  539. package/packages/theme-chalk/src/switch.scss +116 -116
  540. package/packages/theme-chalk/src/table-column.scss +96 -96
  541. package/packages/theme-chalk/src/table.scss +564 -580
  542. package/packages/theme-chalk/src/tabs.scss +602 -602
  543. package/packages/theme-chalk/src/tag.scss +163 -163
  544. package/packages/theme-chalk/src/time-picker.scss +8 -8
  545. package/packages/theme-chalk/src/time-select.scss +37 -37
  546. package/packages/theme-chalk/src/timeline-item.scss +86 -86
  547. package/packages/theme-chalk/src/timeline.scss +14 -14
  548. package/packages/theme-chalk/src/tooltip.scss +141 -141
  549. package/packages/theme-chalk/src/transfer.scss +227 -227
  550. package/packages/theme-chalk/src/tree.scss +123 -123
  551. package/packages/theme-chalk/src/upload.scss +603 -603
  552. package/packages/time-picker/index.js +8 -8
  553. package/packages/time-select/index.js +8 -8
  554. package/packages/timeline/index.js +8 -8
  555. package/packages/timeline/src/item.vue +73 -73
  556. package/packages/timeline/src/main.vue +33 -33
  557. package/packages/timeline-item/index.js +8 -8
  558. package/packages/tooltip/index.js +8 -8
  559. package/packages/tooltip/src/main.js +242 -242
  560. package/packages/transfer/index.js +8 -8
  561. package/packages/transfer/src/main.vue +231 -231
  562. package/packages/transfer/src/transfer-panel.vue +251 -251
  563. package/packages/tree/index.js +8 -8
  564. package/packages/tree/src/model/node.js +484 -484
  565. package/packages/tree/src/model/tree-store.js +340 -340
  566. package/packages/tree/src/model/util.js +27 -27
  567. package/packages/tree/src/tree-node.vue +279 -279
  568. package/packages/tree/src/tree.vue +496 -496
  569. package/packages/upload/index.js +8 -8
  570. package/packages/upload/src/ajax.js +85 -85
  571. package/packages/upload/src/index.vue +338 -338
  572. package/packages/upload/src/upload-dragger.vue +70 -70
  573. package/packages/upload/src/upload-list.vue +105 -105
  574. package/packages/upload/src/upload.vue +211 -211
  575. package/src/directives/mousewheel.js +18 -18
  576. package/src/directives/repeat-click.js +26 -26
  577. package/src/index.js +261 -261
  578. package/src/locale/format.js +46 -46
  579. package/src/locale/index.js +48 -48
  580. package/src/locale/lang/af-ZA.js +123 -123
  581. package/src/locale/lang/ar.js +122 -122
  582. package/src/locale/lang/az.js +126 -126
  583. package/src/locale/lang/bg.js +123 -123
  584. package/src/locale/lang/bn.js +126 -126
  585. package/src/locale/lang/ca.js +122 -122
  586. package/src/locale/lang/cs-CZ.js +125 -125
  587. package/src/locale/lang/da.js +122 -122
  588. package/src/locale/lang/de.js +124 -124
  589. package/src/locale/lang/ee.js +123 -123
  590. package/src/locale/lang/el.js +123 -123
  591. package/src/locale/lang/en.js +123 -123
  592. package/src/locale/lang/eo.js +123 -123
  593. package/src/locale/lang/es.js +122 -122
  594. package/src/locale/lang/eu.js +123 -123
  595. package/src/locale/lang/fa.js +123 -123
  596. package/src/locale/lang/fi.js +123 -123
  597. package/src/locale/lang/fr.js +122 -122
  598. package/src/locale/lang/he.js +123 -123
  599. package/src/locale/lang/hr.js +123 -123
  600. package/src/locale/lang/hu.js +122 -122
  601. package/src/locale/lang/hy-AM.js +123 -123
  602. package/src/locale/lang/id.js +123 -123
  603. package/src/locale/lang/is.js +124 -124
  604. package/src/locale/lang/it.js +122 -122
  605. package/src/locale/lang/ja.js +123 -123
  606. package/src/locale/lang/kg.js +123 -123
  607. package/src/locale/lang/km.js +123 -123
  608. package/src/locale/lang/ko.js +123 -123
  609. package/src/locale/lang/ku.js +123 -123
  610. package/src/locale/lang/kz.js +123 -123
  611. package/src/locale/lang/lo-LA.js +126 -126
  612. package/src/locale/lang/lt.js +123 -123
  613. package/src/locale/lang/lv.js +123 -123
  614. package/src/locale/lang/mn.js +123 -123
  615. package/src/locale/lang/ms.js +122 -122
  616. package/src/locale/lang/nb-NO.js +122 -122
  617. package/src/locale/lang/nl.js +123 -123
  618. package/src/locale/lang/pl.js +123 -123
  619. package/src/locale/lang/pt-br.js +123 -123
  620. package/src/locale/lang/pt.js +123 -123
  621. package/src/locale/lang/ro.js +123 -123
  622. package/src/locale/lang/ru-RU.js +123 -123
  623. package/src/locale/lang/si.js +123 -123
  624. package/src/locale/lang/sk.js +125 -125
  625. package/src/locale/lang/sl.js +123 -123
  626. package/src/locale/lang/sr-Latn.js +123 -123
  627. package/src/locale/lang/sr.js +123 -123
  628. package/src/locale/lang/sv-SE.js +123 -123
  629. package/src/locale/lang/sw.js +123 -123
  630. package/src/locale/lang/ta.js +122 -122
  631. package/src/locale/lang/th.js +123 -123
  632. package/src/locale/lang/tk.js +123 -123
  633. package/src/locale/lang/tr-TR.js +123 -123
  634. package/src/locale/lang/ua.js +123 -123
  635. package/src/locale/lang/ug-CN.js +123 -123
  636. package/src/locale/lang/uz-UZ.js +123 -123
  637. package/src/locale/lang/vi.js +123 -123
  638. package/src/locale/lang/zh-CN.js +123 -123
  639. package/src/locale/lang/zh-TW.js +123 -123
  640. package/src/mixins/emitter.js +33 -33
  641. package/src/mixins/focus.js +9 -9
  642. package/src/mixins/locale.js +9 -9
  643. package/src/mixins/migrating.js +54 -54
  644. package/src/transitions/collapse-transition.js +77 -77
  645. package/src/utils/after-leave.js +27 -27
  646. package/src/utils/aria-dialog.js +90 -90
  647. package/src/utils/aria-utils.js +122 -122
  648. package/src/utils/clickoutside.js +76 -76
  649. package/src/utils/date-util.js +282 -282
  650. package/src/utils/date.js +368 -368
  651. package/src/utils/dom.js +227 -227
  652. package/src/utils/lodash.js +18075 -18075
  653. package/src/utils/menu/aria-menubar.js +14 -14
  654. package/src/utils/menu/aria-menuitem.js +49 -49
  655. package/src/utils/menu/aria-submenu.js +59 -59
  656. package/src/utils/merge.js +15 -15
  657. package/src/utils/popper.js +1276 -1276
  658. package/src/utils/popup/index.js +218 -218
  659. package/src/utils/popup/popup-manager.js +194 -194
  660. package/src/utils/resize-event.js +36 -36
  661. package/src/utils/scroll-into-view.js +27 -27
  662. package/src/utils/scrollbar-width.js +29 -29
  663. package/src/utils/shared.js +7 -7
  664. package/src/utils/types.js +40 -40
  665. package/src/utils/util.js +245 -245
  666. package/src/utils/vdom.js +5 -5
  667. package/src/utils/vue-popper.js +198 -198
  668. package/types/alert.d.ts +31 -31
  669. package/types/aside.d.ts +7 -7
  670. package/types/autocomplete.d.ts +78 -78
  671. package/types/avatar.d.ts +20 -20
  672. package/types/backtop.d.ts +16 -16
  673. package/types/badge.d.ts +16 -16
  674. package/types/breadcrumb-item.d.ts +10 -10
  675. package/types/breadcrumb.d.ts +10 -10
  676. package/types/button-group.d.ts +4 -4
  677. package/types/button.d.ts +37 -37
  678. package/types/calendar.d.ts +15 -15
  679. package/types/card.d.ts +26 -26
  680. package/types/carousel-item.d.ts +10 -10
  681. package/types/carousel.d.ts +57 -57
  682. package/types/cascader-panel.d.ts +72 -72
  683. package/types/cascader.d.ts +65 -65
  684. package/types/checkbox-button.d.ts +22 -22
  685. package/types/checkbox-group.d.ts +22 -22
  686. package/types/checkbox.d.ts +34 -34
  687. package/types/col.d.ts +46 -46
  688. package/types/collapse-item.d.ts +26 -26
  689. package/types/collapse.d.ts +10 -10
  690. package/types/color-picker.d.ts +21 -21
  691. package/types/component.d.ts +13 -13
  692. package/types/container.d.ts +7 -7
  693. package/types/date-picker.d.ts +124 -124
  694. package/types/descriptions-item.d.ts +37 -37
  695. package/types/descriptions.d.ts +52 -52
  696. package/types/dialog.d.ts +62 -62
  697. package/types/divider.d.ts +12 -12
  698. package/types/drawer.d.ts +63 -63
  699. package/types/dropdown-item.d.ts +16 -16
  700. package/types/dropdown-menu.d.ts +4 -4
  701. package/types/dropdown.d.ts +38 -38
  702. package/types/{element-sim.d.ts → element-ui.d.ts} +381 -381
  703. package/types/empty.d.ts +31 -31
  704. package/types/footer.d.ts +7 -7
  705. package/types/form-item.d.ts +37 -37
  706. package/types/form.d.ts +82 -82
  707. package/types/header.d.ts +7 -7
  708. package/types/icon.d.ts +7 -7
  709. package/types/image.d.ts +43 -43
  710. package/types/index.d.ts +4 -4
  711. package/types/infinite-scroll.d.ts +5 -5
  712. package/types/input-number.d.ts +47 -47
  713. package/types/input.d.ts +107 -107
  714. package/types/link.d.ts +25 -25
  715. package/types/loading.d.ts +62 -62
  716. package/types/main.d.ts +4 -4
  717. package/types/menu-item-group.d.ts +7 -7
  718. package/types/menu-item.d.ts +10 -10
  719. package/types/menu.d.ts +46 -46
  720. package/types/message-box.d.ts +176 -176
  721. package/types/message.d.ts +90 -90
  722. package/types/notification.d.ts +84 -84
  723. package/types/option-group.d.ts +10 -10
  724. package/types/option.d.ts +13 -13
  725. package/types/page-header.d.ts +10 -10
  726. package/types/pagination.d.ts +43 -43
  727. package/types/popconfirm.d.ts +29 -29
  728. package/types/popover.d.ts +71 -71
  729. package/types/progress.d.ts +37 -37
  730. package/types/radio-button.d.ts +16 -16
  731. package/types/radio-group.d.ts +18 -18
  732. package/types/radio.d.ts +19 -19
  733. package/types/rate.d.ts +64 -64
  734. package/types/result.d.ts +33 -33
  735. package/types/row.d.ts +25 -25
  736. package/types/select.d.ts +90 -90
  737. package/types/skeleton-item.d.ts +7 -7
  738. package/types/skeleton.d.ts +33 -33
  739. package/types/slider.d.ts +68 -68
  740. package/types/spinner.d.ts +16 -16
  741. package/types/statistic.d.ts +37 -37
  742. package/types/step.d.ts +34 -34
  743. package/types/steps.d.ts +28 -28
  744. package/types/submenu.d.ts +22 -22
  745. package/types/switch.d.ts +43 -43
  746. package/types/tab-pane.d.ts +19 -19
  747. package/types/table-column.d.ts +117 -117
  748. package/types/table.d.ts +177 -177
  749. package/types/tabs.d.ts +31 -31
  750. package/types/tag.d.ts +28 -28
  751. package/types/time-picker.d.ts +63 -63
  752. package/types/time-select.d.ts +56 -56
  753. package/types/timeline-item.d.ts +20 -20
  754. package/types/timeline.d.ts +6 -6
  755. package/types/tooltip.d.ts +52 -52
  756. package/types/transfer.d.ts +73 -73
  757. package/types/tree.d.ts +266 -266
  758. package/types/upload.d.ts +124 -124
  759. package/web-types.json +4195 -4195
@@ -1,469 +1,469 @@
1
- import { arrayFindIndex } from 'element-sim/src/utils/util';
2
- import { getCell, getColumnByCell, getRowIdentity, objectEquals } from './util';
3
- import { getStyle, hasClass, removeClass, addClass } from 'element-sim/src/utils/dom';
4
- import ElCheckbox from 'element-sim/packages/checkbox';
5
- import ElTooltip from 'element-sim/packages/tooltip';
6
- import debounce from 'throttle-debounce/debounce';
7
- import LayoutObserver from './layout-observer';
8
- import { mapStates } from './store/helper';
9
- import TableRow from './table-row.js';
10
-
11
- export default {
12
- name: 'ElTableBody',
13
-
14
- mixins: [LayoutObserver],
15
-
16
- components: {
17
- ElCheckbox,
18
- ElTooltip,
19
- TableRow
20
- },
21
-
22
- props: {
23
- store: {
24
- required: true
25
- },
26
- stripe: Boolean,
27
- context: {},
28
- rowClassName: [String, Function],
29
- rowStyle: [Object, Function],
30
- fixed: String,
31
- highlight: Boolean
32
- },
33
-
34
- render(h) {
35
- const data = this.data || [];
36
- return (
37
- <table
38
- class="el-table__body"
39
- cellspacing="0"
40
- cellpadding="0"
41
- border="0">
42
- <colgroup>
43
- {
44
- this.columns.map(column => <col name={column.id} key={column.id} />)
45
- }
46
- </colgroup>
47
- <tbody>
48
- {
49
- data.reduce((acc, row) => {
50
- return acc.concat(this.wrappedRowRender(row, acc.length));
51
- }, [])
52
- }
53
- <el-tooltip effect={this.table.tooltipEffect} placement="top" ref="tooltip" content={this.tooltipContent}></el-tooltip>
54
- </tbody>
55
- </table>
56
- );
57
- },
58
-
59
- computed: {
60
- table() {
61
- return this.$parent;
62
- },
63
-
64
- ...mapStates({
65
- data: 'data',
66
- columns: 'columns',
67
- treeIndent: 'indent',
68
- leftFixedLeafCount: 'fixedLeafColumnsLength',
69
- rightFixedLeafCount: 'rightFixedLeafColumnsLength',
70
- columnsCount: states => states.columns.length,
71
- leftFixedCount: states => states.fixedColumns.length,
72
- rightFixedCount: states => states.rightFixedColumns.length,
73
- hasExpandColumn: states => states.columns.some(({ type }) => type === 'expand')
74
- }),
75
-
76
- columnsHidden() {
77
- return this.columns.map((column, index) => this.isColumnHidden(index));
78
- },
79
-
80
- firstDefaultColumnIndex() {
81
- return arrayFindIndex(this.columns, ({ type }) => type === 'default');
82
- }
83
- },
84
-
85
- watch: {
86
- // don't trigger getter of currentRow in getCellClass. see https://jsfiddle.net/oe2b4hqt/
87
- // update DOM manually. see https://github.com/ElemeFE/element/pull/13954/files#diff-9b450c00d0a9dec0ffad5a3176972e40
88
- 'store.states.hoverRow'(newVal, oldVal) {
89
- if (!this.store.states.isComplex || this.$isServer) return;
90
- let raf = window.requestAnimationFrame;
91
- if (!raf) {
92
- raf = (fn) => setTimeout(fn, 16);
93
- }
94
- raf(() => {
95
- const rows = this.$el.querySelectorAll('.el-table__row');
96
- const oldRow = rows[oldVal];
97
- const newRow = rows[newVal];
98
- if (oldRow) {
99
- removeClass(oldRow, 'hover-row');
100
- }
101
- if (newRow) {
102
- addClass(newRow, 'hover-row');
103
- }
104
- });
105
- }
106
- },
107
-
108
- data() {
109
- return {
110
- tooltipContent: ''
111
- };
112
- },
113
-
114
- created() {
115
- this.activateTooltip = debounce(50, tooltip => tooltip.handleShowPopper());
116
- },
117
-
118
- methods: {
119
- getKeyOfRow(row, index) {
120
- const rowKey = this.table.rowKey;
121
- if (rowKey) {
122
- return getRowIdentity(row, rowKey);
123
- }
124
- return index;
125
- },
126
-
127
- isColumnHidden(index) {
128
- if (this.fixed === true || this.fixed === 'left') {
129
- return index >= this.leftFixedLeafCount;
130
- } else if (this.fixed === 'right') {
131
- return index < this.columnsCount - this.rightFixedLeafCount;
132
- } else {
133
- return (index < this.leftFixedLeafCount) || (index >= this.columnsCount - this.rightFixedLeafCount);
134
- }
135
- },
136
-
137
- getSpan(row, column, rowIndex, columnIndex) {
138
- let rowspan = 1;
139
- let colspan = 1;
140
- const fn = this.table.spanMethod;
141
- if (typeof fn === 'function') {
142
- const result = fn({
143
- row,
144
- column,
145
- rowIndex,
146
- columnIndex
147
- });
148
- if (Array.isArray(result)) {
149
- rowspan = result[0];
150
- colspan = result[1];
151
- } else if (typeof result === 'object') {
152
- rowspan = result.rowspan;
153
- colspan = result.colspan;
154
- }
155
- }
156
- return { rowspan, colspan };
157
- },
158
-
159
- getRowStyle(row, rowIndex) {
160
- const rowStyle = this.table.rowStyle;
161
- if (typeof rowStyle === 'function') {
162
- return rowStyle.call(null, {
163
- row,
164
- rowIndex
165
- });
166
- }
167
- return rowStyle || null;
168
- },
169
-
170
- getRowClass(row, rowIndex) {
171
- let selection = this.store.states.selection;
172
- const classes = ['el-table__row'];
173
- if (this.table.highlightCurrentRow && row === this.store.states.currentRow) {
174
- classes.push('current-row');
175
- }
176
-
177
- if (this.table.highlightSelectionRow) {
178
- for (let i = 0; i < selection.length; i++) {
179
- if (objectEquals(row, selection[i])) {
180
- classes.push('selection-row');
181
- }
182
- };
183
- }
184
-
185
- if (this.stripe && rowIndex % 2 === 1) {
186
- classes.push('el-table__row--striped');
187
- }
188
- const rowClassName = this.table.rowClassName;
189
- if (typeof rowClassName === 'string') {
190
- classes.push(rowClassName);
191
- } else if (typeof rowClassName === 'function') {
192
- classes.push(rowClassName.call(null, {
193
- row,
194
- rowIndex
195
- }));
196
- }
197
-
198
- if (this.store.states.expandRows.indexOf(row) > -1) {
199
- classes.push('expanded');
200
- }
201
-
202
- return classes;
203
- },
204
-
205
- getCellStyle(rowIndex, columnIndex, row, column) {
206
- const cellStyle = this.table.cellStyle;
207
- if (typeof cellStyle === 'function') {
208
- return cellStyle.call(null, {
209
- rowIndex,
210
- columnIndex,
211
- row,
212
- column
213
- });
214
- }
215
- return cellStyle;
216
- },
217
-
218
- getCellClass(rowIndex, columnIndex, row, column) {
219
- const classes = [column.id, column.align, column.className];
220
-
221
- if (this.isColumnHidden(columnIndex)) {
222
- classes.push('is-hidden');
223
- }
224
-
225
- const cellClassName = this.table.cellClassName;
226
- if (typeof cellClassName === 'string') {
227
- classes.push(cellClassName);
228
- } else if (typeof cellClassName === 'function') {
229
- classes.push(cellClassName.call(null, {
230
- rowIndex,
231
- columnIndex,
232
- row,
233
- column
234
- }));
235
- }
236
-
237
- classes.push('el-table__cell');
238
-
239
- return classes.join(' ');
240
- },
241
-
242
- getColspanRealWidth(columns, colspan, index) {
243
- if (colspan < 1) {
244
- return columns[index].realWidth;
245
- }
246
- const widthArr = columns.map(({ realWidth }) => realWidth).slice(index, index + colspan);
247
- return widthArr.reduce((acc, width) => acc + width, -1);
248
- },
249
-
250
- handleCellMouseEnter(event, row) {
251
- const table = this.table;
252
- const cell = getCell(event);
253
-
254
- if (cell) {
255
- const column = getColumnByCell(table, cell);
256
- const hoverState = table.hoverState = { cell, column, row };
257
- table.$emit('cell-mouse-enter', hoverState.row, hoverState.column, hoverState.cell, event);
258
- }
259
-
260
- // 判断是否text-overflow, 如果是就显示tooltip
261
- const cellChild = event.target.querySelector('.cell');
262
- if (!(hasClass(cellChild, 'el-tooltip') && cellChild.childNodes.length)) {
263
- return;
264
- }
265
- // use range width instead of scrollWidth to determine whether the text is overflowing
266
- // to address a potential FireFox bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1074543#c3
267
- const range = document.createRange();
268
- range.setStart(cellChild, 0);
269
- range.setEnd(cellChild, cellChild.childNodes.length);
270
- const rangeWidth = range.getBoundingClientRect().width;
271
- const padding = (parseInt(getStyle(cellChild, 'paddingLeft'), 10) || 0) +
272
- (parseInt(getStyle(cellChild, 'paddingRight'), 10) || 0);
273
- if ((rangeWidth + padding > cellChild.offsetWidth || cellChild.scrollWidth > cellChild.offsetWidth) && this.$refs.tooltip) {
274
- const tooltip = this.$refs.tooltip;
275
- // TODO 会引起整个 Table 的重新渲染,需要优化
276
- this.tooltipContent = cell.innerText || cell.textContent;
277
- tooltip.referenceElm = cell;
278
- tooltip.$refs.popper && (tooltip.$refs.popper.style.display = 'none');
279
- tooltip.doDestroy();
280
- tooltip.setExpectedState(true);
281
- this.activateTooltip(tooltip);
282
- }
283
- },
284
-
285
- handleCellMouseLeave(event) {
286
- const tooltip = this.$refs.tooltip;
287
- if (tooltip) {
288
- tooltip.setExpectedState(false);
289
- tooltip.handleClosePopper();
290
- }
291
- const cell = getCell(event);
292
- if (!cell) return;
293
-
294
- const oldHoverState = this.table.hoverState || {};
295
- this.table.$emit('cell-mouse-leave', oldHoverState.row, oldHoverState.column, oldHoverState.cell, event);
296
- },
297
-
298
- handleMouseEnter: debounce(30, function(index) {
299
- this.store.commit('setHoverRow', index);
300
- }),
301
-
302
- handleMouseLeave: debounce(30, function() {
303
- this.store.commit('setHoverRow', null);
304
- }),
305
-
306
- handleContextMenu(event, row) {
307
- this.handleEvent(event, row, 'contextmenu');
308
- },
309
-
310
- handleDoubleClick(event, row) {
311
- this.handleEvent(event, row, 'dblclick');
312
- },
313
-
314
- handleClick(event, row) {
315
- this.store.commit('setCurrentRow', row);
316
- this.handleEvent(event, row, 'click');
317
- },
318
-
319
- handleEvent(event, row, name) {
320
- const table = this.table;
321
- const cell = getCell(event);
322
- let column;
323
- if (cell) {
324
- column = getColumnByCell(table, cell);
325
- if (column) {
326
- table.$emit(`cell-${name}`, row, column, cell, event);
327
- }
328
- }
329
- table.$emit(`row-${name}`, row, column, event);
330
- },
331
-
332
- rowRender(row, $index, treeRowData) {
333
- const { treeIndent, columns, firstDefaultColumnIndex } = this;
334
- const rowClasses = this.getRowClass(row, $index);
335
- let display = true;
336
- if (treeRowData) {
337
- rowClasses.push('el-table__row--level-' + treeRowData.level);
338
- display = treeRowData.display;
339
- }
340
- // 指令 v-show 会覆盖 row-style 中 display
341
- // 使用 :style 代替 v-show https://github.com/ElemeFE/element/issues/16995
342
- let displayStyle = display ? null : {
343
- display: 'none'
344
- };
345
- return (
346
- <TableRow
347
- style={[displayStyle, this.getRowStyle(row, $index)]}
348
- class={rowClasses}
349
- key={this.getKeyOfRow(row, $index)}
350
- nativeOn-dblclick={($event) => this.handleDoubleClick($event, row)}
351
- nativeOn-click={($event) => this.handleClick($event, row)}
352
- nativeOn-contextmenu={($event) => this.handleContextMenu($event, row)}
353
- nativeOn-mouseenter={_ => this.handleMouseEnter($index)}
354
- nativeOn-mouseleave={this.handleMouseLeave}
355
- columns={columns}
356
- row={row}
357
- index={$index}
358
- store={this.store}
359
- context={this.context || this.table.$vnode.context}
360
- firstDefaultColumnIndex={firstDefaultColumnIndex}
361
- treeRowData={treeRowData}
362
- treeIndent={treeIndent}
363
- columnsHidden={this.columnsHidden}
364
- getSpan={this.getSpan}
365
- getColspanRealWidth={this.getColspanRealWidth}
366
- getCellStyle={this.getCellStyle}
367
- getCellClass={this.getCellClass}
368
- handleCellMouseEnter={this.handleCellMouseEnter}
369
- handleCellMouseLeave={this.handleCellMouseLeave}
370
- isSelected={this.store.isSelected(row)}
371
- isExpanded={this.store.states.expandRows.indexOf(row) > -1}
372
- fixed={this.fixed}
373
- >
374
- </TableRow>
375
- );
376
- },
377
-
378
- wrappedRowRender(row, $index) {
379
- const store = this.store;
380
- const { isRowExpanded, assertRowKey } = store;
381
- const { treeData, lazyTreeNodeMap, childrenColumnName, rowKey } = store.states;
382
- if (this.hasExpandColumn && isRowExpanded(row)) {
383
- const renderExpanded = this.table.renderExpanded;
384
- const tr = this.rowRender(row, $index);
385
- if (!renderExpanded) {
386
- console.error('[Element Error]renderExpanded is required.');
387
- return tr;
388
- }
389
- // 使用二维数组,避免修改 $index
390
- return [[
391
- tr,
392
- <tr key={'expanded-row__' + tr.key}>
393
- <td colspan={ this.columnsCount } class="el-table__cell el-table__expanded-cell">
394
- { renderExpanded(this.$createElement, { row, $index, store: this.store }) }
395
- </td>
396
- </tr>]];
397
- } else if (Object.keys(treeData).length) {
398
- assertRowKey();
399
- // TreeTable 时,rowKey 必须由用户设定,不使用 getKeyOfRow 计算
400
- // 在调用 rowRender 函数时,仍然会计算 rowKey,不太好的操作
401
- const key = getRowIdentity(row, rowKey);
402
- let cur = treeData[key];
403
- let treeRowData = null;
404
- if (cur) {
405
- treeRowData = {
406
- expanded: cur.expanded,
407
- level: cur.level,
408
- display: true
409
- };
410
- if (typeof cur.lazy === 'boolean') {
411
- if (typeof cur.loaded === 'boolean' && cur.loaded) {
412
- treeRowData.noLazyChildren = !(cur.children && cur.children.length);
413
- }
414
- treeRowData.loading = cur.loading;
415
- }
416
- }
417
- const tmp = [this.rowRender(row, $index, treeRowData)];
418
- // 渲染嵌套数据
419
- if (cur) {
420
- // currentRow 记录的是 index,所以还需主动增加 TreeTable 的 index
421
- let i = 0;
422
- const traverse = (children, parent) => {
423
- if (!(children && children.length && parent)) return;
424
- children.forEach(node => {
425
- // 父节点的 display 状态影响子节点的显示状态
426
- const innerTreeRowData = {
427
- display: parent.display && parent.expanded,
428
- level: parent.level + 1
429
- };
430
- const childKey = getRowIdentity(node, rowKey);
431
- if (childKey === undefined || childKey === null) {
432
- throw new Error('for nested data item, row-key is required.');
433
- }
434
- cur = { ...treeData[childKey] };
435
- // 对于当前节点,分成有无子节点两种情况。
436
- // 如果包含子节点的,设置 expanded 属性。
437
- // 对于它子节点的 display 属性由它本身的 expanded 与 display 共同决定。
438
- if (cur) {
439
- innerTreeRowData.expanded = cur.expanded;
440
- // 懒加载的某些节点,level 未知
441
- cur.level = cur.level || innerTreeRowData.level;
442
- cur.display = !!(cur.expanded && innerTreeRowData.display);
443
- if (typeof cur.lazy === 'boolean') {
444
- if (typeof cur.loaded === 'boolean' && cur.loaded) {
445
- innerTreeRowData.noLazyChildren = !(cur.children && cur.children.length);
446
- }
447
- innerTreeRowData.loading = cur.loading;
448
- }
449
- }
450
- i++;
451
- tmp.push(this.rowRender(node, $index + i, innerTreeRowData));
452
- if (cur) {
453
- const nodes = lazyTreeNodeMap[childKey] || node[childrenColumnName];
454
- traverse(nodes, cur);
455
- }
456
- });
457
- };
458
- // 对于 root 节点,display 一定为 true
459
- cur.display = true;
460
- const nodes = lazyTreeNodeMap[key] || row[childrenColumnName];
461
- traverse(nodes, cur);
462
- }
463
- return tmp;
464
- } else {
465
- return this.rowRender(row, $index);
466
- }
467
- }
468
- }
469
- };
1
+ import { arrayFindIndex } from 'element-ui/src/utils/util';
2
+ import { getCell, getColumnByCell, getRowIdentity, objectEquals } from './util';
3
+ import { getStyle, hasClass, removeClass, addClass } from 'element-ui/src/utils/dom';
4
+ import ElCheckbox from 'element-ui/packages/checkbox';
5
+ import ElTooltip from 'element-ui/packages/tooltip';
6
+ import debounce from 'throttle-debounce/debounce';
7
+ import LayoutObserver from './layout-observer';
8
+ import { mapStates } from './store/helper';
9
+ import TableRow from './table-row.js';
10
+
11
+ export default {
12
+ name: 'ElTableBody',
13
+
14
+ mixins: [LayoutObserver],
15
+
16
+ components: {
17
+ ElCheckbox,
18
+ ElTooltip,
19
+ TableRow
20
+ },
21
+
22
+ props: {
23
+ store: {
24
+ required: true
25
+ },
26
+ stripe: Boolean,
27
+ context: {},
28
+ rowClassName: [String, Function],
29
+ rowStyle: [Object, Function],
30
+ fixed: String,
31
+ highlight: Boolean
32
+ },
33
+
34
+ render(h) {
35
+ const data = this.data || [];
36
+ return (
37
+ <table
38
+ class="el-table__body"
39
+ cellspacing="0"
40
+ cellpadding="0"
41
+ border="0">
42
+ <colgroup>
43
+ {
44
+ this.columns.map(column => <col name={column.id} key={column.id} />)
45
+ }
46
+ </colgroup>
47
+ <tbody>
48
+ {
49
+ data.reduce((acc, row) => {
50
+ return acc.concat(this.wrappedRowRender(row, acc.length));
51
+ }, [])
52
+ }
53
+ <el-tooltip effect={this.table.tooltipEffect} placement="top" ref="tooltip" content={this.tooltipContent}></el-tooltip>
54
+ </tbody>
55
+ </table>
56
+ );
57
+ },
58
+
59
+ computed: {
60
+ table() {
61
+ return this.$parent;
62
+ },
63
+
64
+ ...mapStates({
65
+ data: 'data',
66
+ columns: 'columns',
67
+ treeIndent: 'indent',
68
+ leftFixedLeafCount: 'fixedLeafColumnsLength',
69
+ rightFixedLeafCount: 'rightFixedLeafColumnsLength',
70
+ columnsCount: states => states.columns.length,
71
+ leftFixedCount: states => states.fixedColumns.length,
72
+ rightFixedCount: states => states.rightFixedColumns.length,
73
+ hasExpandColumn: states => states.columns.some(({ type }) => type === 'expand')
74
+ }),
75
+
76
+ columnsHidden() {
77
+ return this.columns.map((column, index) => this.isColumnHidden(index));
78
+ },
79
+
80
+ firstDefaultColumnIndex() {
81
+ return arrayFindIndex(this.columns, ({ type }) => type === 'default');
82
+ }
83
+ },
84
+
85
+ watch: {
86
+ // don't trigger getter of currentRow in getCellClass. see https://jsfiddle.net/oe2b4hqt/
87
+ // update DOM manually. see https://github.com/ElemeFE/element/pull/13954/files#diff-9b450c00d0a9dec0ffad5a3176972e40
88
+ 'store.states.hoverRow'(newVal, oldVal) {
89
+ if (!this.store.states.isComplex || this.$isServer) return;
90
+ let raf = window.requestAnimationFrame;
91
+ if (!raf) {
92
+ raf = (fn) => setTimeout(fn, 16);
93
+ }
94
+ raf(() => {
95
+ const rows = this.$el.querySelectorAll('.el-table__row');
96
+ const oldRow = rows[oldVal];
97
+ const newRow = rows[newVal];
98
+ if (oldRow) {
99
+ removeClass(oldRow, 'hover-row');
100
+ }
101
+ if (newRow) {
102
+ addClass(newRow, 'hover-row');
103
+ }
104
+ });
105
+ }
106
+ },
107
+
108
+ data() {
109
+ return {
110
+ tooltipContent: ''
111
+ };
112
+ },
113
+
114
+ created() {
115
+ this.activateTooltip = debounce(50, tooltip => tooltip.handleShowPopper());
116
+ },
117
+
118
+ methods: {
119
+ getKeyOfRow(row, index) {
120
+ const rowKey = this.table.rowKey;
121
+ if (rowKey) {
122
+ return getRowIdentity(row, rowKey);
123
+ }
124
+ return index;
125
+ },
126
+
127
+ isColumnHidden(index) {
128
+ if (this.fixed === true || this.fixed === 'left') {
129
+ return index >= this.leftFixedLeafCount;
130
+ } else if (this.fixed === 'right') {
131
+ return index < this.columnsCount - this.rightFixedLeafCount;
132
+ } else {
133
+ return (index < this.leftFixedLeafCount) || (index >= this.columnsCount - this.rightFixedLeafCount);
134
+ }
135
+ },
136
+
137
+ getSpan(row, column, rowIndex, columnIndex) {
138
+ let rowspan = 1;
139
+ let colspan = 1;
140
+ const fn = this.table.spanMethod;
141
+ if (typeof fn === 'function') {
142
+ const result = fn({
143
+ row,
144
+ column,
145
+ rowIndex,
146
+ columnIndex
147
+ });
148
+ if (Array.isArray(result)) {
149
+ rowspan = result[0];
150
+ colspan = result[1];
151
+ } else if (typeof result === 'object') {
152
+ rowspan = result.rowspan;
153
+ colspan = result.colspan;
154
+ }
155
+ }
156
+ return { rowspan, colspan };
157
+ },
158
+
159
+ getRowStyle(row, rowIndex) {
160
+ const rowStyle = this.table.rowStyle;
161
+ if (typeof rowStyle === 'function') {
162
+ return rowStyle.call(null, {
163
+ row,
164
+ rowIndex
165
+ });
166
+ }
167
+ return rowStyle || null;
168
+ },
169
+
170
+ getRowClass(row, rowIndex) {
171
+ let selection = this.store.states.selection;
172
+ const classes = ['el-table__row'];
173
+ if (this.table.highlightCurrentRow && row === this.store.states.currentRow) {
174
+ classes.push('current-row');
175
+ }
176
+
177
+ if (this.table.highlightSelectionRow) {
178
+ for (let i = 0; i < selection.length; i++) {
179
+ if (objectEquals(row, selection[i])) {
180
+ classes.push('selection-row');
181
+ }
182
+ };
183
+ }
184
+
185
+ if (this.stripe && rowIndex % 2 === 1) {
186
+ classes.push('el-table__row--striped');
187
+ }
188
+ const rowClassName = this.table.rowClassName;
189
+ if (typeof rowClassName === 'string') {
190
+ classes.push(rowClassName);
191
+ } else if (typeof rowClassName === 'function') {
192
+ classes.push(rowClassName.call(null, {
193
+ row,
194
+ rowIndex
195
+ }));
196
+ }
197
+
198
+ if (this.store.states.expandRows.indexOf(row) > -1) {
199
+ classes.push('expanded');
200
+ }
201
+
202
+ return classes;
203
+ },
204
+
205
+ getCellStyle(rowIndex, columnIndex, row, column) {
206
+ const cellStyle = this.table.cellStyle;
207
+ if (typeof cellStyle === 'function') {
208
+ return cellStyle.call(null, {
209
+ rowIndex,
210
+ columnIndex,
211
+ row,
212
+ column
213
+ });
214
+ }
215
+ return cellStyle;
216
+ },
217
+
218
+ getCellClass(rowIndex, columnIndex, row, column) {
219
+ const classes = [column.id, column.align, column.className];
220
+
221
+ if (this.isColumnHidden(columnIndex)) {
222
+ classes.push('is-hidden');
223
+ }
224
+
225
+ const cellClassName = this.table.cellClassName;
226
+ if (typeof cellClassName === 'string') {
227
+ classes.push(cellClassName);
228
+ } else if (typeof cellClassName === 'function') {
229
+ classes.push(cellClassName.call(null, {
230
+ rowIndex,
231
+ columnIndex,
232
+ row,
233
+ column
234
+ }));
235
+ }
236
+
237
+ classes.push('el-table__cell');
238
+
239
+ return classes.join(' ');
240
+ },
241
+
242
+ getColspanRealWidth(columns, colspan, index) {
243
+ if (colspan < 1) {
244
+ return columns[index].realWidth;
245
+ }
246
+ const widthArr = columns.map(({ realWidth }) => realWidth).slice(index, index + colspan);
247
+ return widthArr.reduce((acc, width) => acc + width, -1);
248
+ },
249
+
250
+ handleCellMouseEnter(event, row) {
251
+ const table = this.table;
252
+ const cell = getCell(event);
253
+
254
+ if (cell) {
255
+ const column = getColumnByCell(table, cell);
256
+ const hoverState = table.hoverState = { cell, column, row };
257
+ table.$emit('cell-mouse-enter', hoverState.row, hoverState.column, hoverState.cell, event);
258
+ }
259
+
260
+ // 判断是否text-overflow, 如果是就显示tooltip
261
+ const cellChild = event.target.querySelector('.cell');
262
+ if (!(hasClass(cellChild, 'el-tooltip') && cellChild.childNodes.length)) {
263
+ return;
264
+ }
265
+ // use range width instead of scrollWidth to determine whether the text is overflowing
266
+ // to address a potential FireFox bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1074543#c3
267
+ const range = document.createRange();
268
+ range.setStart(cellChild, 0);
269
+ range.setEnd(cellChild, cellChild.childNodes.length);
270
+ const rangeWidth = range.getBoundingClientRect().width;
271
+ const padding = (parseInt(getStyle(cellChild, 'paddingLeft'), 10) || 0) +
272
+ (parseInt(getStyle(cellChild, 'paddingRight'), 10) || 0);
273
+ if ((rangeWidth + padding > cellChild.offsetWidth || cellChild.scrollWidth > cellChild.offsetWidth) && this.$refs.tooltip) {
274
+ const tooltip = this.$refs.tooltip;
275
+ // TODO 会引起整个 Table 的重新渲染,需要优化
276
+ this.tooltipContent = cell.innerText || cell.textContent;
277
+ tooltip.referenceElm = cell;
278
+ tooltip.$refs.popper && (tooltip.$refs.popper.style.display = 'none');
279
+ tooltip.doDestroy();
280
+ tooltip.setExpectedState(true);
281
+ this.activateTooltip(tooltip);
282
+ }
283
+ },
284
+
285
+ handleCellMouseLeave(event) {
286
+ const tooltip = this.$refs.tooltip;
287
+ if (tooltip) {
288
+ tooltip.setExpectedState(false);
289
+ tooltip.handleClosePopper();
290
+ }
291
+ const cell = getCell(event);
292
+ if (!cell) return;
293
+
294
+ const oldHoverState = this.table.hoverState || {};
295
+ this.table.$emit('cell-mouse-leave', oldHoverState.row, oldHoverState.column, oldHoverState.cell, event);
296
+ },
297
+
298
+ handleMouseEnter: debounce(30, function(index) {
299
+ this.store.commit('setHoverRow', index);
300
+ }),
301
+
302
+ handleMouseLeave: debounce(30, function() {
303
+ this.store.commit('setHoverRow', null);
304
+ }),
305
+
306
+ handleContextMenu(event, row) {
307
+ this.handleEvent(event, row, 'contextmenu');
308
+ },
309
+
310
+ handleDoubleClick(event, row) {
311
+ this.handleEvent(event, row, 'dblclick');
312
+ },
313
+
314
+ handleClick(event, row) {
315
+ this.store.commit('setCurrentRow', row);
316
+ this.handleEvent(event, row, 'click');
317
+ },
318
+
319
+ handleEvent(event, row, name) {
320
+ const table = this.table;
321
+ const cell = getCell(event);
322
+ let column;
323
+ if (cell) {
324
+ column = getColumnByCell(table, cell);
325
+ if (column) {
326
+ table.$emit(`cell-${name}`, row, column, cell, event);
327
+ }
328
+ }
329
+ table.$emit(`row-${name}`, row, column, event);
330
+ },
331
+
332
+ rowRender(row, $index, treeRowData) {
333
+ const { treeIndent, columns, firstDefaultColumnIndex } = this;
334
+ const rowClasses = this.getRowClass(row, $index);
335
+ let display = true;
336
+ if (treeRowData) {
337
+ rowClasses.push('el-table__row--level-' + treeRowData.level);
338
+ display = treeRowData.display;
339
+ }
340
+ // 指令 v-show 会覆盖 row-style 中 display
341
+ // 使用 :style 代替 v-show https://github.com/ElemeFE/element/issues/16995
342
+ let displayStyle = display ? null : {
343
+ display: 'none'
344
+ };
345
+ return (
346
+ <TableRow
347
+ style={[displayStyle, this.getRowStyle(row, $index)]}
348
+ class={rowClasses}
349
+ key={this.getKeyOfRow(row, $index)}
350
+ nativeOn-dblclick={($event) => this.handleDoubleClick($event, row)}
351
+ nativeOn-click={($event) => this.handleClick($event, row)}
352
+ nativeOn-contextmenu={($event) => this.handleContextMenu($event, row)}
353
+ nativeOn-mouseenter={_ => this.handleMouseEnter($index)}
354
+ nativeOn-mouseleave={this.handleMouseLeave}
355
+ columns={columns}
356
+ row={row}
357
+ index={$index}
358
+ store={this.store}
359
+ context={this.context || this.table.$vnode.context}
360
+ firstDefaultColumnIndex={firstDefaultColumnIndex}
361
+ treeRowData={treeRowData}
362
+ treeIndent={treeIndent}
363
+ columnsHidden={this.columnsHidden}
364
+ getSpan={this.getSpan}
365
+ getColspanRealWidth={this.getColspanRealWidth}
366
+ getCellStyle={this.getCellStyle}
367
+ getCellClass={this.getCellClass}
368
+ handleCellMouseEnter={this.handleCellMouseEnter}
369
+ handleCellMouseLeave={this.handleCellMouseLeave}
370
+ isSelected={this.store.isSelected(row)}
371
+ isExpanded={this.store.states.expandRows.indexOf(row) > -1}
372
+ fixed={this.fixed}
373
+ >
374
+ </TableRow>
375
+ );
376
+ },
377
+
378
+ wrappedRowRender(row, $index) {
379
+ const store = this.store;
380
+ const { isRowExpanded, assertRowKey } = store;
381
+ const { treeData, lazyTreeNodeMap, childrenColumnName, rowKey } = store.states;
382
+ if (this.hasExpandColumn && isRowExpanded(row)) {
383
+ const renderExpanded = this.table.renderExpanded;
384
+ const tr = this.rowRender(row, $index);
385
+ if (!renderExpanded) {
386
+ console.error('[Element Error]renderExpanded is required.');
387
+ return tr;
388
+ }
389
+ // 使用二维数组,避免修改 $index
390
+ return [[
391
+ tr,
392
+ <tr key={'expanded-row__' + tr.key}>
393
+ <td colspan={ this.columnsCount } class="el-table__cell el-table__expanded-cell">
394
+ { renderExpanded(this.$createElement, { row, $index, store: this.store }) }
395
+ </td>
396
+ </tr>]];
397
+ } else if (Object.keys(treeData).length) {
398
+ assertRowKey();
399
+ // TreeTable 时,rowKey 必须由用户设定,不使用 getKeyOfRow 计算
400
+ // 在调用 rowRender 函数时,仍然会计算 rowKey,不太好的操作
401
+ const key = getRowIdentity(row, rowKey);
402
+ let cur = treeData[key];
403
+ let treeRowData = null;
404
+ if (cur) {
405
+ treeRowData = {
406
+ expanded: cur.expanded,
407
+ level: cur.level,
408
+ display: true
409
+ };
410
+ if (typeof cur.lazy === 'boolean') {
411
+ if (typeof cur.loaded === 'boolean' && cur.loaded) {
412
+ treeRowData.noLazyChildren = !(cur.children && cur.children.length);
413
+ }
414
+ treeRowData.loading = cur.loading;
415
+ }
416
+ }
417
+ const tmp = [this.rowRender(row, $index, treeRowData)];
418
+ // 渲染嵌套数据
419
+ if (cur) {
420
+ // currentRow 记录的是 index,所以还需主动增加 TreeTable 的 index
421
+ let i = 0;
422
+ const traverse = (children, parent) => {
423
+ if (!(children && children.length && parent)) return;
424
+ children.forEach(node => {
425
+ // 父节点的 display 状态影响子节点的显示状态
426
+ const innerTreeRowData = {
427
+ display: parent.display && parent.expanded,
428
+ level: parent.level + 1
429
+ };
430
+ const childKey = getRowIdentity(node, rowKey);
431
+ if (childKey === undefined || childKey === null) {
432
+ throw new Error('for nested data item, row-key is required.');
433
+ }
434
+ cur = { ...treeData[childKey] };
435
+ // 对于当前节点,分成有无子节点两种情况。
436
+ // 如果包含子节点的,设置 expanded 属性。
437
+ // 对于它子节点的 display 属性由它本身的 expanded 与 display 共同决定。
438
+ if (cur) {
439
+ innerTreeRowData.expanded = cur.expanded;
440
+ // 懒加载的某些节点,level 未知
441
+ cur.level = cur.level || innerTreeRowData.level;
442
+ cur.display = !!(cur.expanded && innerTreeRowData.display);
443
+ if (typeof cur.lazy === 'boolean') {
444
+ if (typeof cur.loaded === 'boolean' && cur.loaded) {
445
+ innerTreeRowData.noLazyChildren = !(cur.children && cur.children.length);
446
+ }
447
+ innerTreeRowData.loading = cur.loading;
448
+ }
449
+ }
450
+ i++;
451
+ tmp.push(this.rowRender(node, $index + i, innerTreeRowData));
452
+ if (cur) {
453
+ const nodes = lazyTreeNodeMap[childKey] || node[childrenColumnName];
454
+ traverse(nodes, cur);
455
+ }
456
+ });
457
+ };
458
+ // 对于 root 节点,display 一定为 true
459
+ cur.display = true;
460
+ const nodes = lazyTreeNodeMap[key] || row[childrenColumnName];
461
+ traverse(nodes, cur);
462
+ }
463
+ return tmp;
464
+ } else {
465
+ return this.rowRender(row, $index);
466
+ }
467
+ }
468
+ }
469
+ };