cy-element-ui 1.0.4 → 1.0.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 (415) hide show
  1. package/README.md +22 -13
  2. package/lib/alert.js +211 -203
  3. package/lib/aside.js +29 -29
  4. package/lib/autocomplete.js +4615 -483
  5. package/lib/avatar.js +152 -126
  6. package/lib/backtop.js +117 -125
  7. package/lib/badge.js +128 -134
  8. package/lib/breadcrumb-item.js +146 -122
  9. package/lib/breadcrumb.js +97 -96
  10. package/lib/button-group.js +68 -65
  11. package/lib/button.js +67 -87
  12. package/lib/calendar.js +2475 -603
  13. package/lib/card.js +101 -100
  14. package/lib/carousel-item.js +854 -210
  15. package/lib/carousel.js +575 -408
  16. package/lib/cascader-panel.js +3546 -1153
  17. package/lib/cascader.js +7376 -970
  18. package/lib/checkbox-button.js +337 -290
  19. package/lib/checkbox-group.js +176 -105
  20. package/lib/checkbox.js +240 -220
  21. package/lib/col.js +113 -68
  22. package/lib/collapse-item.js +1228 -225
  23. package/lib/collapse.js +163 -123
  24. package/lib/color-picker.js +5223 -1251
  25. package/lib/container.js +98 -88
  26. package/lib/date-picker.js +8396 -3945
  27. package/lib/descriptions-item.js +53 -32
  28. package/lib/descriptions.js +697 -334
  29. package/lib/dialog.js +1725 -247
  30. package/lib/directives/mousewheel.js +14 -20
  31. package/lib/directives/repeat-click.js +27 -30
  32. package/lib/divider.js +38 -45
  33. package/lib/drawer.js +1032 -238
  34. package/lib/dropdown-item.js +159 -111
  35. package/lib/dropdown-menu.js +2445 -117
  36. package/lib/dropdown.js +1675 -366
  37. package/lib/element-ui.common.js +49110 -39985
  38. package/lib/empty.js +1084 -203
  39. package/lib/fileUpload.js +3900 -0
  40. package/lib/footer.js +29 -29
  41. package/lib/form-item.js +1236 -467
  42. package/lib/form.js +326 -258
  43. package/lib/header.js +80 -80
  44. package/lib/icon.js +71 -68
  45. package/lib/image.js +2389 -743
  46. package/lib/index.js +1 -1
  47. package/lib/infinite-scroll.js +814 -150
  48. package/lib/input-number.js +2181 -444
  49. package/lib/input.js +1197 -517
  50. package/lib/link.js +117 -135
  51. package/lib/loading.js +1130 -363
  52. package/lib/locale/format.js +38 -49
  53. package/lib/locale/index.js +38 -52
  54. package/lib/locale/lang/af-ZA.js +130 -123
  55. package/lib/locale/lang/ar.js +123 -122
  56. package/lib/locale/lang/az.js +122 -121
  57. package/lib/locale/lang/bg.js +133 -123
  58. package/lib/locale/lang/bn.js +121 -121
  59. package/lib/locale/lang/ca.js +123 -122
  60. package/lib/locale/lang/cs-CZ.js +127 -125
  61. package/lib/locale/lang/da.js +124 -122
  62. package/lib/locale/lang/de.js +126 -124
  63. package/lib/locale/lang/ee.js +125 -123
  64. package/lib/locale/lang/el.js +125 -123
  65. package/lib/locale/lang/en.js +127 -123
  66. package/lib/locale/lang/eo.js +125 -123
  67. package/lib/locale/lang/es.js +123 -122
  68. package/lib/locale/lang/eu.js +128 -123
  69. package/lib/locale/lang/fa.js +125 -123
  70. package/lib/locale/lang/fi.js +125 -123
  71. package/lib/locale/lang/fr.js +125 -122
  72. package/lib/locale/lang/he.js +130 -123
  73. package/lib/locale/lang/hr.js +128 -123
  74. package/lib/locale/lang/hu.js +124 -122
  75. package/lib/locale/lang/hy-AM.js +125 -123
  76. package/lib/locale/lang/id.js +124 -123
  77. package/lib/locale/lang/is.js +124 -123
  78. package/lib/locale/lang/it.js +123 -122
  79. package/lib/locale/lang/ja.js +125 -123
  80. package/lib/locale/lang/kg.js +125 -123
  81. package/lib/locale/lang/km.js +124 -123
  82. package/lib/locale/lang/ko.js +125 -123
  83. package/lib/locale/lang/ku.js +125 -123
  84. package/lib/locale/lang/kz.js +125 -123
  85. package/lib/locale/lang/lo-LA.js +121 -121
  86. package/lib/locale/lang/lt.js +125 -123
  87. package/lib/locale/lang/lv.js +125 -123
  88. package/lib/locale/lang/mn.js +125 -123
  89. package/lib/locale/lang/ms.js +123 -122
  90. package/lib/locale/lang/nb-NO.js +123 -122
  91. package/lib/locale/lang/nl.js +125 -123
  92. package/lib/locale/lang/pl.js +125 -123
  93. package/lib/locale/lang/pt-br.js +124 -123
  94. package/lib/locale/lang/pt.js +133 -123
  95. package/lib/locale/lang/ro.js +125 -123
  96. package/lib/locale/lang/ru-RU.js +124 -123
  97. package/lib/locale/lang/si.js +127 -123
  98. package/lib/locale/lang/sk.js +126 -125
  99. package/lib/locale/lang/sl.js +125 -123
  100. package/lib/locale/lang/sr-Latn.js +124 -123
  101. package/lib/locale/lang/sr.js +128 -123
  102. package/lib/locale/lang/sv-SE.js +128 -123
  103. package/lib/locale/lang/sw.js +127 -123
  104. package/lib/locale/lang/ta.js +130 -122
  105. package/lib/locale/lang/th.js +127 -123
  106. package/lib/locale/lang/tk.js +129 -123
  107. package/lib/locale/lang/tr-TR.js +125 -123
  108. package/lib/locale/lang/ua.js +124 -123
  109. package/lib/locale/lang/ug-CN.js +124 -123
  110. package/lib/locale/lang/uz-UZ.js +124 -123
  111. package/lib/locale/lang/vi.js +124 -123
  112. package/lib/locale/lang/zh-CN.js +124 -123
  113. package/lib/locale/lang/zh-TW.js +128 -123
  114. package/lib/main.js +23 -21
  115. package/lib/menu-item-group.js +105 -111
  116. package/lib/menu-item.js +3558 -253
  117. package/lib/menu.js +1680 -528
  118. package/lib/message-box.js +3427 -684
  119. package/lib/message.js +1677 -229
  120. package/lib/mixins/emitter.js +28 -30
  121. package/lib/mixins/focus.js +10 -11
  122. package/lib/mixins/locale.js +12 -14
  123. package/lib/mixins/migrating.js +38 -45
  124. package/lib/notification.js +1707 -269
  125. package/lib/option-group.js +190 -139
  126. package/lib/option.js +949 -196
  127. package/lib/page-header.js +964 -42
  128. package/lib/pagination.js +6947 -641
  129. package/lib/popconfirm.js +3951 -223
  130. package/lib/popover.js +3247 -369
  131. package/lib/progress.js +254 -244
  132. package/lib/radio-button.js +259 -226
  133. package/lib/radio-group.js +249 -186
  134. package/lib/radio.js +263 -253
  135. package/lib/rate.js +1399 -420
  136. package/lib/result.js +183 -227
  137. package/lib/row.js +58 -41
  138. package/lib/scrollbar.js +1331 -278
  139. package/lib/select.js +5816 -1428
  140. package/lib/skeleton-item.js +133 -145
  141. package/lib/skeleton.js +82 -91
  142. package/lib/slider.js +5157 -702
  143. package/lib/spinner.js +113 -101
  144. package/lib/statistic.js +10205 -254
  145. package/lib/step.js +274 -311
  146. package/lib/steps.js +854 -117
  147. package/lib/subTitle.js +292 -0
  148. package/lib/submenu.js +2867 -429
  149. package/lib/switch.js +1051 -291
  150. package/lib/tab-pane.js +125 -135
  151. package/lib/tabDialog.js +2658 -0
  152. package/lib/table-column.js +1975 -751
  153. package/lib/table.js +8019 -3979
  154. package/lib/tabs.js +1455 -605
  155. package/lib/tag.js +73 -68
  156. package/lib/theme-chalk/src/index.scss +3 -0
  157. package/lib/time-picker.js +6821 -1944
  158. package/lib/time-select.js +6297 -1186
  159. package/lib/timeline-item.js +43 -84
  160. package/lib/timeline.js +43 -39
  161. package/lib/tooltip.js +3185 -287
  162. package/lib/transfer.js +2943 -625
  163. package/lib/transitions/collapse-transition.js +69 -87
  164. package/lib/tree.js +3312 -1791
  165. package/lib/treeSelect.js +4436 -0
  166. package/lib/umd/locale/af-ZA.js +145 -138
  167. package/lib/umd/locale/ar.js +138 -137
  168. package/lib/umd/locale/az.js +139 -137
  169. package/lib/umd/locale/bg.js +148 -138
  170. package/lib/umd/locale/bn.js +138 -137
  171. package/lib/umd/locale/ca.js +138 -137
  172. package/lib/umd/locale/cs-CZ.js +142 -140
  173. package/lib/umd/locale/da.js +139 -137
  174. package/lib/umd/locale/de.js +141 -139
  175. package/lib/umd/locale/ee.js +140 -138
  176. package/lib/umd/locale/el.js +140 -138
  177. package/lib/umd/locale/en.js +142 -138
  178. package/lib/umd/locale/eo.js +140 -138
  179. package/lib/umd/locale/es.js +138 -137
  180. package/lib/umd/locale/eu.js +143 -138
  181. package/lib/umd/locale/fa.js +140 -138
  182. package/lib/umd/locale/fi.js +140 -138
  183. package/lib/umd/locale/fr.js +140 -137
  184. package/lib/umd/locale/he.js +145 -138
  185. package/lib/umd/locale/hr.js +143 -138
  186. package/lib/umd/locale/hu.js +139 -137
  187. package/lib/umd/locale/hy-AM.js +140 -138
  188. package/lib/umd/locale/id.js +139 -138
  189. package/lib/umd/locale/is.js +139 -138
  190. package/lib/umd/locale/it.js +138 -137
  191. package/lib/umd/locale/ja.js +140 -138
  192. package/lib/umd/locale/kg.js +140 -138
  193. package/lib/umd/locale/km.js +139 -138
  194. package/lib/umd/locale/ko.js +140 -138
  195. package/lib/umd/locale/ku.js +140 -138
  196. package/lib/umd/locale/kz.js +140 -138
  197. package/lib/umd/locale/lo-LA.js +138 -137
  198. package/lib/umd/locale/lt.js +140 -138
  199. package/lib/umd/locale/lv.js +140 -138
  200. package/lib/umd/locale/mn.js +140 -138
  201. package/lib/umd/locale/ms.js +138 -137
  202. package/lib/umd/locale/nb-NO.js +138 -137
  203. package/lib/umd/locale/nl.js +140 -138
  204. package/lib/umd/locale/pl.js +140 -138
  205. package/lib/umd/locale/pt-br.js +139 -138
  206. package/lib/umd/locale/pt.js +148 -138
  207. package/lib/umd/locale/ro.js +140 -138
  208. package/lib/umd/locale/ru-RU.js +139 -138
  209. package/lib/umd/locale/si.js +142 -138
  210. package/lib/umd/locale/sk.js +141 -140
  211. package/lib/umd/locale/sl.js +140 -138
  212. package/lib/umd/locale/sr-Latn.js +139 -138
  213. package/lib/umd/locale/sr.js +143 -138
  214. package/lib/umd/locale/sv-SE.js +143 -138
  215. package/lib/umd/locale/sw.js +142 -138
  216. package/lib/umd/locale/ta.js +145 -137
  217. package/lib/umd/locale/th.js +142 -138
  218. package/lib/umd/locale/tk.js +144 -138
  219. package/lib/umd/locale/tr-TR.js +140 -138
  220. package/lib/umd/locale/ua.js +139 -138
  221. package/lib/umd/locale/ug-CN.js +139 -138
  222. package/lib/umd/locale/uz-UZ.js +139 -138
  223. package/lib/umd/locale/vi.js +139 -138
  224. package/lib/umd/locale/zh-CN.js +139 -138
  225. package/lib/umd/locale/zh-TW.js +143 -138
  226. package/lib/upload.js +2377 -987
  227. package/lib/utils/after-leave.js +36 -33
  228. package/lib/utils/aria-dialog.js +55 -73
  229. package/lib/utils/aria-utils.js +67 -76
  230. package/lib/utils/clickoutside.js +52 -60
  231. package/lib/utils/date-util.js +198 -241
  232. package/lib/utils/date.js +6 -368
  233. package/lib/utils/date_source.js +349 -0
  234. package/lib/utils/dom.js +167 -183
  235. package/lib/utils/lodash.js +13 -9421
  236. package/lib/utils/lodash_source.js +9421 -0
  237. package/lib/utils/menu/aria-menubar.js +13 -18
  238. package/lib/utils/menu/aria-menuitem.js +43 -54
  239. package/lib/utils/menu/aria-submenu.js +50 -59
  240. package/lib/utils/merge.js +15 -17
  241. package/lib/utils/popper.js +1141 -1170
  242. package/lib/utils/popup/index.js +186 -230
  243. package/lib/utils/popup/popup-manager.js +159 -191
  244. package/lib/utils/resize-event.js +29 -44
  245. package/lib/utils/scroll-into-view.js +25 -33
  246. package/lib/utils/scrollbar-width.js +25 -36
  247. package/lib/utils/shared.js +3 -3
  248. package/lib/utils/types.js +19 -32
  249. package/lib/utils/util.js +187 -221
  250. package/lib/utils/vdom.js +5 -9
  251. package/lib/utils/vue-popper.js +166 -188
  252. package/package.json +22 -19
  253. package/packages/alert/src/main.vue +63 -63
  254. package/packages/aside/src/main.vue +9 -9
  255. package/packages/autocomplete/src/autocomplete-suggestions.vue +46 -46
  256. package/packages/autocomplete/src/autocomplete.vue +198 -198
  257. package/packages/avatar/src/main.vue +5 -5
  258. package/packages/backtop/src/main.vue +3 -3
  259. package/packages/badge/src/main.vue +1 -1
  260. package/packages/breadcrumb/src/breadcrumb-item.vue +26 -26
  261. package/packages/breadcrumb/src/breadcrumb.vue +22 -22
  262. package/packages/button/src/button-group.vue +3 -3
  263. package/packages/button/src/button.vue +44 -44
  264. package/packages/calendar/src/date-table.vue +3 -3
  265. package/packages/calendar/src/main.vue +7 -7
  266. package/packages/card/src/main.vue +9 -9
  267. package/packages/carousel/src/item.vue +98 -98
  268. package/packages/carousel/src/main.vue +2 -2
  269. package/packages/cascader/src/cascader.vue +4 -4
  270. package/packages/cascader-panel/src/cascader-menu.vue +4 -4
  271. package/packages/cascader-panel/src/cascader-node.vue +232 -232
  272. package/packages/cascader-panel/src/cascader-panel.vue +3 -3
  273. package/packages/cascader-panel/src/node.js +2 -3
  274. package/packages/cascader-panel/src/store.js +0 -1
  275. package/packages/checkbox/src/checkbox-button.vue +139 -139
  276. package/packages/checkbox/src/checkbox-group.vue +33 -33
  277. package/packages/checkbox/src/checkbox.vue +140 -140
  278. package/packages/col/src/col.js +5 -5
  279. package/packages/collapse/src/collapse-item.vue +55 -55
  280. package/packages/collapse/src/collapse.vue +54 -54
  281. package/packages/color-picker/src/color.js +4 -4
  282. package/packages/color-picker/src/components/alpha-slider.vue +100 -100
  283. package/packages/color-picker/src/components/hue-slider.vue +91 -91
  284. package/packages/color-picker/src/components/picker-dropdown.vue +64 -64
  285. package/packages/color-picker/src/components/predefine.vue +43 -43
  286. package/packages/color-picker/src/components/sv-panel.vue +70 -70
  287. package/packages/color-picker/src/main.vue +141 -141
  288. package/packages/container/src/main.vue +20 -20
  289. package/packages/date-picker/src/basic/date-table.vue +360 -360
  290. package/packages/date-picker/src/basic/month-table.vue +222 -223
  291. package/packages/date-picker/src/basic/time-spinner.vue +174 -174
  292. package/packages/date-picker/src/basic/year-table.vue +91 -91
  293. package/packages/date-picker/src/panel/date-range.vue +415 -415
  294. package/packages/date-picker/src/panel/date.vue +423 -423
  295. package/packages/date-picker/src/panel/month-range.vue +177 -177
  296. package/packages/date-picker/src/panel/time-range.vue +173 -173
  297. package/packages/date-picker/src/panel/time-select.vue +131 -131
  298. package/packages/date-picker/src/panel/time.vue +131 -131
  299. package/packages/date-picker/src/picker.vue +7 -7
  300. package/packages/descriptions/src/descriptions-row.js +3 -3
  301. package/packages/descriptions/src/index.js +1 -1
  302. package/packages/dialog/src/component.vue +155 -155
  303. package/packages/divider/src/main.vue +1 -1
  304. package/packages/drawer/src/main.vue +2 -2
  305. package/packages/dropdown/src/dropdown-item.vue +15 -15
  306. package/packages/dropdown/src/dropdown-menu.vue +47 -47
  307. package/packages/dropdown/src/dropdown.vue +260 -260
  308. package/packages/empty/src/index.vue +1 -1
  309. package/packages/fileUpload/index.js +8 -0
  310. package/packages/fileUpload/src/main.vue +430 -0
  311. package/packages/footer/src/main.vue +9 -9
  312. package/packages/form/src/form-item.vue +245 -245
  313. package/packages/form/src/form.vue +154 -154
  314. package/packages/header/src/main.vue +9 -9
  315. package/packages/icon/src/icon.vue +6 -6
  316. package/packages/image/src/image-viewer.vue +9 -9
  317. package/packages/image/src/main.vue +206 -206
  318. package/packages/infinite-scroll/src/main.js +1 -2
  319. package/packages/input/src/calcTextareaHeight.js +2 -2
  320. package/packages/input/src/input.vue +311 -311
  321. package/packages/input-number/src/input-number.vue +205 -205
  322. package/packages/loading/src/loading.vue +19 -19
  323. package/packages/main/src/main.vue +4 -4
  324. package/packages/menu/src/menu-item-group.vue +27 -27
  325. package/packages/menu/src/menu-item.vue +69 -69
  326. package/packages/menu/src/menu.vue +284 -284
  327. package/packages/menu/src/submenu.vue +308 -309
  328. package/packages/message/src/main.js +1 -1
  329. package/packages/message/src/main.vue +72 -72
  330. package/packages/message-box/src/main.vue +216 -216
  331. package/packages/notification/src/main.js +1 -1
  332. package/packages/notification/src/main.vue +93 -93
  333. package/packages/pagination/src/pager.vue +99 -99
  334. package/packages/popconfirm/src/main.vue +28 -28
  335. package/packages/popover/src/main.vue +6 -6
  336. package/packages/progress/src/progress.vue +174 -174
  337. package/packages/radio/src/radio-button.vue +64 -64
  338. package/packages/radio/src/radio-group.vue +88 -88
  339. package/packages/radio/src/radio.vue +74 -74
  340. package/packages/rate/src/main.vue +270 -270
  341. package/packages/row/src/row.js +3 -3
  342. package/packages/scrollbar/src/main.js +2 -2
  343. package/packages/scrollbar/src/util.js +1 -1
  344. package/packages/select/src/option-group.vue +46 -46
  345. package/packages/select/src/option.vue +122 -122
  346. package/packages/select/src/select-dropdown.vue +49 -49
  347. package/packages/select/src/select.vue +676 -676
  348. package/packages/skeleton/src/item.vue +12 -12
  349. package/packages/slider/src/button.vue +191 -191
  350. package/packages/slider/src/main.vue +314 -314
  351. package/packages/spinner/src/spinner.vue +16 -16
  352. package/packages/statistic/src/main.vue +5 -6
  353. package/packages/steps/src/step.vue +2 -2
  354. package/packages/steps/src/steps.vue +4 -4
  355. package/packages/subTitle/index.js +8 -0
  356. package/packages/subTitle/src/main.vue +33 -0
  357. package/packages/switch/src/component.vue +123 -123
  358. package/packages/tabDialog/index.js +23 -0
  359. package/packages/tabDialog/src/dialog/drag.js +63 -0
  360. package/packages/tabDialog/src/dialog/dragHeight.js +34 -0
  361. package/packages/tabDialog/src/dialog/dragWidth.js +30 -0
  362. package/packages/tabDialog/src/main.vue +277 -0
  363. package/packages/table/src/filter-panel.vue +128 -128
  364. package/packages/table/src/store/index.js +1 -1
  365. package/packages/table/src/table-body.js +2 -2
  366. package/packages/table/src/table-column.js +1 -1
  367. package/packages/table/src/table-header.js +1 -1
  368. package/packages/table/src/table-layout.js +1 -1
  369. package/packages/table/src/table.vue +416 -416
  370. package/packages/tabs/src/tab-bar.vue +43 -43
  371. package/packages/tabs/src/tab-nav.vue +250 -250
  372. package/packages/tabs/src/tab-pane.vue +34 -34
  373. package/packages/tabs/src/tabs.vue +165 -165
  374. package/packages/tag/src/tag.vue +52 -52
  375. package/packages/theme-cy/lib/element.css +1 -0
  376. package/packages/theme-cy/lib/fileUpload.css +1 -0
  377. package/packages/theme-cy/lib/index.css +1 -1
  378. package/packages/theme-cy/lib/subTitle.css +1 -0
  379. package/packages/theme-cy/lib/tabDialog.css +1 -0
  380. package/packages/theme-cy/lib/treeselect.css +1 -1
  381. package/packages/theme-cy/src/element.scss +45 -0
  382. package/packages/theme-cy/src/fileUpload.scss +30 -0
  383. package/packages/theme-cy/src/index.scss +4 -0
  384. package/packages/theme-cy/src/subTitle.scss +26 -0
  385. package/packages/theme-cy/src/tabDialog.scss +43 -0
  386. package/packages/theme-cy/src/treeselect.scss +20 -14
  387. package/packages/timeline/src/item.vue +24 -24
  388. package/packages/timeline/src/main.vue +27 -27
  389. package/packages/tooltip/src/main.js +1 -1
  390. package/packages/transfer/src/main.vue +169 -169
  391. package/packages/transfer/src/transfer-panel.vue +164 -164
  392. package/packages/tree/src/tree-node.vue +169 -169
  393. package/packages/tree/src/tree.vue +408 -408
  394. package/packages/treeSelect/index.js +8 -0
  395. package/packages/{treeselect → treeSelect}/src/main.vue +19 -19
  396. package/packages/upload/src/ajax.js +3 -3
  397. package/packages/upload/src/upload-dragger.vue +50 -50
  398. package/packages/upload/src/upload-list.vue +33 -33
  399. package/packages/upload/src/upload.vue +1 -1
  400. package/src/index.js +13 -5
  401. package/src/locale/format.js +0 -1
  402. package/src/mixins/migrating.js +2 -2
  403. package/src/utils/date.js +2 -368
  404. package/src/utils/date_source.js +368 -0
  405. package/src/utils/lodash.js +9 -18075
  406. package/src/utils/lodash_source.js +18075 -0
  407. package/src/utils/types.js +1 -1
  408. package/types/element-ui.d.ts +16 -3
  409. package/types/fileUpload.d.ts +5 -0
  410. package/types/subTitle.d.ts +5 -0
  411. package/types/tabDialog.d.ts +5 -0
  412. package/types/treeSelect.d.ts +5 -0
  413. package/lib/treeselect.js +0 -682
  414. package/packages/treeselect/index.js +0 -8
  415. package/types/treeselect.d.ts +0 -5
@@ -136,765 +136,765 @@
136
136
  </template>
137
137
 
138
138
  <script type="text/babel">
139
- import Emitter from 'element-ui/src/mixins/emitter';
140
- import Focus from 'element-ui/src/mixins/focus';
141
- import Locale from 'element-ui/src/mixins/locale';
142
- import ElInput from 'element-ui/packages/input';
143
- import ElSelectMenu from './select-dropdown.vue';
144
- import ElOption from './option.vue';
145
- import ElTag from 'element-ui/packages/tag';
146
- import ElScrollbar from 'element-ui/packages/scrollbar';
147
- import debounce from 'throttle-debounce/debounce';
148
- import Clickoutside from 'element-ui/src/utils/clickoutside';
149
- import { addResizeListener, removeResizeListener } from 'element-ui/src/utils/resize-event';
150
- import scrollIntoView from 'element-ui/src/utils/scroll-into-view';
151
- import { getValueByPath, valueEquals, isIE, isEdge } from 'element-ui/src/utils/util';
152
- import NavigationMixin from './navigation-mixin';
153
- import { isKorean } from 'element-ui/src/utils/shared';
154
-
155
- export default {
156
- mixins: [Emitter, Locale, Focus('reference'), NavigationMixin],
157
-
158
- name: 'ElSelect',
159
-
160
- componentName: 'ElSelect',
161
-
162
- inject: {
163
- elForm: {
164
- default: ''
165
- },
166
-
167
- elFormItem: {
168
- default: ''
169
- }
170
- },
171
-
172
- provide() {
173
- return {
174
- 'select': this
175
- };
139
+ import Emitter from 'element-ui/src/mixins/emitter';
140
+ import Focus from 'element-ui/src/mixins/focus';
141
+ import Locale from 'element-ui/src/mixins/locale';
142
+ import ElInput from 'element-ui/packages/input';
143
+ import ElSelectMenu from './select-dropdown.vue';
144
+ import ElOption from './option.vue';
145
+ import ElTag from 'element-ui/packages/tag';
146
+ import ElScrollbar from 'element-ui/packages/scrollbar';
147
+ import debounce from 'throttle-debounce/debounce';
148
+ import Clickoutside from 'element-ui/src/utils/clickoutside';
149
+ import { addResizeListener, removeResizeListener } from 'element-ui/src/utils/resize-event';
150
+ import scrollIntoView from 'element-ui/src/utils/scroll-into-view';
151
+ import { getValueByPath, valueEquals, isIE, isEdge } from 'element-ui/src/utils/util';
152
+ import NavigationMixin from './navigation-mixin';
153
+ import { isKorean } from 'element-ui/src/utils/shared';
154
+
155
+ export default {
156
+ mixins: [Emitter, Locale, Focus('reference'), NavigationMixin],
157
+
158
+ name: 'ElSelect',
159
+
160
+ componentName: 'ElSelect',
161
+
162
+ inject: {
163
+ elForm: {
164
+ default: ''
176
165
  },
177
166
 
178
- computed: {
179
- _elFormItemSize() {
180
- return (this.elFormItem || {}).elFormItemSize;
181
- },
182
-
183
- readonly() {
184
- return !this.filterable || this.multiple || (!isIE() && !isEdge() && !this.visible);
185
- },
186
-
187
- showClose() {
188
- let hasValue = this.multiple
189
- ? Array.isArray(this.value) && this.value.length > 0
190
- : this.value !== undefined && this.value !== null && this.value !== '';
191
- let criteria = this.clearable &&
192
- !this.selectDisabled &&
193
- this.inputHovering &&
194
- hasValue;
195
- return criteria;
196
- },
197
-
198
- iconClass() {
199
- return this.remote && this.filterable ? '' : (this.visible ? 'arrow-up is-reverse' : 'arrow-up');
200
- },
201
-
202
- debounce() {
203
- return this.remote ? 300 : 0;
204
- },
205
-
206
- emptyText() {
207
- if (this.loading) {
208
- return this.loadingText || this.t('el.select.loading');
209
- } else {
210
- if (this.remote && this.query === '' && this.options.length === 0) return false;
211
- if (this.filterable && this.query && this.options.length > 0 && this.filteredOptionsCount === 0) {
212
- return this.noMatchText || this.t('el.select.noMatch');
213
- }
214
- if (this.options.length === 0) {
215
- return this.noDataText || this.t('el.select.noData');
216
- }
167
+ elFormItem: {
168
+ default: ''
169
+ }
170
+ },
171
+
172
+ provide() {
173
+ return {
174
+ 'select': this
175
+ };
176
+ },
177
+
178
+ computed: {
179
+ _elFormItemSize() {
180
+ return (this.elFormItem || {}).elFormItemSize;
181
+ },
182
+
183
+ readonly() {
184
+ return !this.filterable || this.multiple || (!isIE() && !isEdge() && !this.visible);
185
+ },
186
+
187
+ showClose() {
188
+ let hasValue = this.multiple
189
+ ? Array.isArray(this.value) && this.value.length > 0
190
+ : this.value !== undefined && this.value !== null && this.value !== '';
191
+ let criteria = this.clearable &&
192
+ !this.selectDisabled &&
193
+ this.inputHovering &&
194
+ hasValue;
195
+ return criteria;
196
+ },
197
+
198
+ iconClass() {
199
+ return this.remote && this.filterable ? '' : (this.visible ? 'arrow-up is-reverse' : 'arrow-up');
200
+ },
201
+
202
+ debounce() {
203
+ return this.remote ? 300 : 0;
204
+ },
205
+
206
+ emptyText() {
207
+ if (this.loading) {
208
+ return this.loadingText || this.t('el.select.loading');
209
+ } else {
210
+ if (this.remote && this.query === '' && this.options.length === 0) return false;
211
+ if (this.filterable && this.query && this.options.length > 0 && this.filteredOptionsCount === 0) {
212
+ return this.noMatchText || this.t('el.select.noMatch');
217
213
  }
218
- return null;
219
- },
220
-
221
- showNewOption() {
222
- let hasExistingOption = this.options.filter(option => !option.created)
223
- .some(option => option.currentLabel === this.query);
224
- return this.filterable && this.allowCreate && this.query !== '' && !hasExistingOption;
225
- },
226
-
227
- selectSize() {
228
- return this.size || this._elFormItemSize || (this.$ELEMENT || {}).size;
229
- },
230
-
231
- selectDisabled() {
232
- return this.disabled || (this.elForm || {}).disabled;
233
- },
234
-
235
- collapseTagSize() {
236
- return ['small', 'mini'].indexOf(this.selectSize) > -1
237
- ? 'mini'
238
- : 'small';
239
- },
240
- propPlaceholder() {
241
- return typeof this.placeholder !== 'undefined' ? this.placeholder : this.t('el.select.placeholder');
242
- }
243
- },
244
-
245
- components: {
246
- ElInput,
247
- ElSelectMenu,
248
- ElOption,
249
- ElTag,
250
- ElScrollbar
251
- },
252
-
253
- directives: { Clickoutside },
254
-
255
- props: {
256
- name: String,
257
- id: String,
258
- value: {
259
- required: true
260
- },
261
- autocomplete: {
262
- type: String,
263
- default: 'off'
264
- },
265
- /** @Deprecated in next major version */
266
- autoComplete: {
267
- type: String,
268
- validator(val) {
269
- process.env.NODE_ENV !== 'production' &&
270
- console.warn('[Element Warn][Select]\'auto-complete\' property will be deprecated in next major version. please use \'autocomplete\' instead.');
271
- return true;
214
+ if (this.options.length === 0) {
215
+ return this.noDataText || this.t('el.select.noData');
272
216
  }
273
- },
274
- automaticDropdown: Boolean,
275
- size: String,
276
- disabled: Boolean,
277
- clearable: Boolean,
278
- filterable: Boolean,
279
- allowCreate: Boolean,
280
- loading: Boolean,
281
- popperClass: String,
282
- remote: Boolean,
283
- loadingText: String,
284
- noMatchText: String,
285
- noDataText: String,
286
- remoteMethod: Function,
287
- filterMethod: Function,
288
- multiple: Boolean,
289
- multipleLimit: {
290
- type: Number,
291
- default: 0
292
- },
293
- placeholder: {
294
- type: String,
295
- required: false
296
- },
297
- defaultFirstOption: Boolean,
298
- reserveKeyword: Boolean,
299
- valueKey: {
300
- type: String,
301
- default: 'value'
302
- },
303
- collapseTags: Boolean,
304
- popperAppendToBody: {
305
- type: Boolean,
306
- default: true
307
- }
308
- },
309
-
310
- data() {
311
- return {
312
- options: [],
313
- cachedOptions: [],
314
- createdLabel: null,
315
- createdSelected: false,
316
- selected: this.multiple ? [] : {},
317
- inputLength: 20,
318
- inputWidth: 0,
319
- initialInputHeight: 0,
320
- cachedPlaceHolder: '',
321
- optionsCount: 0,
322
- filteredOptionsCount: 0,
323
- visible: false,
324
- softFocus: false,
325
- selectedLabel: '',
326
- hoverIndex: -1,
327
- query: '',
328
- previousQuery: null,
329
- inputHovering: false,
330
- currentPlaceholder: '',
331
- menuVisibleOnFocus: false,
332
- isOnComposition: false,
333
- isSilentBlur: false
334
- };
217
+ }
218
+ return null;
335
219
  },
336
220
 
337
- watch: {
338
- selectDisabled() {
339
- this.$nextTick(() => {
340
- this.resetInputHeight();
341
- });
342
- },
221
+ showNewOption() {
222
+ let hasExistingOption = this.options.filter(option => !option.created)
223
+ .some(option => option.currentLabel === this.query);
224
+ return this.filterable && this.allowCreate && this.query !== '' && !hasExistingOption;
225
+ },
343
226
 
344
- propPlaceholder(val) {
345
- this.cachedPlaceHolder = this.currentPlaceholder = val;
346
- },
227
+ selectSize() {
228
+ return this.size || this._elFormItemSize || (this.$ELEMENT || {}).size;
229
+ },
347
230
 
348
- value(val, oldVal) {
349
- if (this.multiple) {
350
- this.resetInputHeight();
351
- if ((val && val.length > 0) || (this.$refs.input && this.query !== '')) {
352
- this.currentPlaceholder = '';
353
- } else {
354
- this.currentPlaceholder = this.cachedPlaceHolder;
355
- }
356
- if (this.filterable && !this.reserveKeyword) {
357
- this.query = '';
358
- this.handleQueryChange(this.query);
359
- }
360
- }
361
- this.setSelected();
362
- if (this.filterable && !this.multiple) {
363
- this.inputLength = 20;
231
+ selectDisabled() {
232
+ return this.disabled || (this.elForm || {}).disabled;
233
+ },
234
+
235
+ collapseTagSize() {
236
+ return ['small', 'mini'].indexOf(this.selectSize) > -1
237
+ ? 'mini'
238
+ : 'small';
239
+ },
240
+ propPlaceholder() {
241
+ return typeof this.placeholder !== 'undefined' ? this.placeholder : this.t('el.select.placeholder');
242
+ }
243
+ },
244
+
245
+ components: {
246
+ ElInput,
247
+ ElSelectMenu,
248
+ ElOption,
249
+ ElTag,
250
+ ElScrollbar
251
+ },
252
+
253
+ directives: { Clickoutside },
254
+
255
+ props: {
256
+ name: String,
257
+ id: String,
258
+ value: {
259
+ required: true
260
+ },
261
+ autocomplete: {
262
+ type: String,
263
+ default: 'off'
264
+ },
265
+ /** @Deprecated in next major version */
266
+ autoComplete: {
267
+ type: String,
268
+ validator(val) {
269
+ process.env.NODE_ENV !== 'production' &&
270
+ console.warn('[Element Warn][Select]\'auto-complete\' property will be deprecated in next major version. please use \'autocomplete\' instead.');
271
+ return true;
272
+ }
273
+ },
274
+ automaticDropdown: Boolean,
275
+ size: String,
276
+ disabled: Boolean,
277
+ clearable: Boolean,
278
+ filterable: Boolean,
279
+ allowCreate: Boolean,
280
+ loading: Boolean,
281
+ popperClass: String,
282
+ remote: Boolean,
283
+ loadingText: String,
284
+ noMatchText: String,
285
+ noDataText: String,
286
+ remoteMethod: Function,
287
+ filterMethod: Function,
288
+ multiple: Boolean,
289
+ multipleLimit: {
290
+ type: Number,
291
+ default: 0
292
+ },
293
+ placeholder: {
294
+ type: String,
295
+ required: false
296
+ },
297
+ defaultFirstOption: Boolean,
298
+ reserveKeyword: Boolean,
299
+ valueKey: {
300
+ type: String,
301
+ default: 'value'
302
+ },
303
+ collapseTags: Boolean,
304
+ popperAppendToBody: {
305
+ type: Boolean,
306
+ default: true
307
+ }
308
+ },
309
+
310
+ data() {
311
+ return {
312
+ options: [],
313
+ cachedOptions: [],
314
+ createdLabel: null,
315
+ createdSelected: false,
316
+ selected: this.multiple ? [] : {},
317
+ inputLength: 20,
318
+ inputWidth: 0,
319
+ initialInputHeight: 0,
320
+ cachedPlaceHolder: '',
321
+ optionsCount: 0,
322
+ filteredOptionsCount: 0,
323
+ visible: false,
324
+ softFocus: false,
325
+ selectedLabel: '',
326
+ hoverIndex: -1,
327
+ query: '',
328
+ previousQuery: null,
329
+ inputHovering: false,
330
+ currentPlaceholder: '',
331
+ menuVisibleOnFocus: false,
332
+ isOnComposition: false,
333
+ isSilentBlur: false
334
+ };
335
+ },
336
+
337
+ watch: {
338
+ selectDisabled() {
339
+ this.$nextTick(() => {
340
+ this.resetInputHeight();
341
+ });
342
+ },
343
+
344
+ propPlaceholder(val) {
345
+ this.cachedPlaceHolder = this.currentPlaceholder = val;
346
+ },
347
+
348
+ value(val, oldVal) {
349
+ if (this.multiple) {
350
+ this.resetInputHeight();
351
+ if ((val && val.length > 0) || (this.$refs.input && this.query !== '')) {
352
+ this.currentPlaceholder = '';
353
+ } else {
354
+ this.currentPlaceholder = this.cachedPlaceHolder;
364
355
  }
365
- if (!valueEquals(val, oldVal)) {
366
- this.dispatch('ElFormItem', 'el.form.change', val);
356
+ if (this.filterable && !this.reserveKeyword) {
357
+ this.query = '';
358
+ this.handleQueryChange(this.query);
367
359
  }
368
- },
360
+ }
361
+ this.setSelected();
362
+ if (this.filterable && !this.multiple) {
363
+ this.inputLength = 20;
364
+ }
365
+ if (!valueEquals(val, oldVal)) {
366
+ this.dispatch('ElFormItem', 'el.form.change', val);
367
+ }
368
+ },
369
369
 
370
- visible(val) {
371
- if (!val) {
372
- this.broadcast('ElSelectDropdown', 'destroyPopper');
373
- if (this.$refs.input) {
374
- this.$refs.input.blur();
370
+ visible(val) {
371
+ if (!val) {
372
+ this.broadcast('ElSelectDropdown', 'destroyPopper');
373
+ if (this.$refs.input) {
374
+ this.$refs.input.blur();
375
+ }
376
+ this.query = '';
377
+ this.previousQuery = null;
378
+ this.selectedLabel = '';
379
+ this.inputLength = 20;
380
+ this.menuVisibleOnFocus = false;
381
+ this.resetHoverIndex();
382
+ this.$nextTick(() => {
383
+ if (this.$refs.input &&
384
+ this.$refs.input.value === '' &&
385
+ this.selected.length === 0) {
386
+ this.currentPlaceholder = this.cachedPlaceHolder;
375
387
  }
376
- this.query = '';
377
- this.previousQuery = null;
378
- this.selectedLabel = '';
379
- this.inputLength = 20;
380
- this.menuVisibleOnFocus = false;
381
- this.resetHoverIndex();
382
- this.$nextTick(() => {
383
- if (this.$refs.input &&
384
- this.$refs.input.value === '' &&
385
- this.selected.length === 0) {
386
- this.currentPlaceholder = this.cachedPlaceHolder;
387
- }
388
- });
389
- if (!this.multiple) {
390
- if (this.selected) {
391
- if (this.filterable && this.allowCreate &&
392
- this.createdSelected && this.createdLabel) {
393
- this.selectedLabel = this.createdLabel;
394
- } else {
395
- this.selectedLabel = this.selected.currentLabel;
396
- }
397
- if (this.filterable) this.query = this.selectedLabel;
398
- }
399
-
400
- if (this.filterable) {
401
- this.currentPlaceholder = this.cachedPlaceHolder;
388
+ });
389
+ if (!this.multiple) {
390
+ if (this.selected) {
391
+ if (this.filterable && this.allowCreate &&
392
+ this.createdSelected && this.createdLabel) {
393
+ this.selectedLabel = this.createdLabel;
394
+ } else {
395
+ this.selectedLabel = this.selected.currentLabel;
402
396
  }
397
+ if (this.filterable) this.query = this.selectedLabel;
403
398
  }
404
- } else {
405
- this.broadcast('ElSelectDropdown', 'updatePopper');
399
+
406
400
  if (this.filterable) {
407
- this.query = this.remote ? '' : this.selectedLabel;
408
- this.handleQueryChange(this.query);
409
- if (this.multiple) {
410
- this.$refs.input.focus();
411
- } else {
412
- if (!this.remote) {
413
- this.broadcast('ElOption', 'queryChange', '');
414
- this.broadcast('ElOptionGroup', 'queryChange');
415
- }
416
-
417
- if (this.selectedLabel) {
418
- this.currentPlaceholder = this.selectedLabel;
419
- this.selectedLabel = '';
420
- }
421
- }
401
+ this.currentPlaceholder = this.cachedPlaceHolder;
422
402
  }
423
403
  }
424
- this.$emit('visible-change', val);
425
- },
404
+ } else {
405
+ this.broadcast('ElSelectDropdown', 'updatePopper');
406
+ if (this.filterable) {
407
+ this.query = this.remote ? '' : this.selectedLabel;
408
+ this.handleQueryChange(this.query);
409
+ if (this.multiple) {
410
+ this.$refs.input.focus();
411
+ } else {
412
+ if (!this.remote) {
413
+ this.broadcast('ElOption', 'queryChange', '');
414
+ this.broadcast('ElOptionGroup', 'queryChange');
415
+ }
426
416
 
427
- options() {
428
- if (this.$isServer) return;
429
- this.$nextTick(() => {
430
- this.broadcast('ElSelectDropdown', 'updatePopper');
431
- });
432
- if (this.multiple) {
433
- this.resetInputHeight();
434
- }
435
- let inputs = this.$el.querySelectorAll('input');
436
- if ([].indexOf.call(inputs, document.activeElement) === -1) {
437
- this.setSelected();
438
- }
439
- if (this.defaultFirstOption && (this.filterable || this.remote) && this.filteredOptionsCount) {
440
- this.checkDefaultFirstOption();
417
+ if (this.selectedLabel) {
418
+ this.currentPlaceholder = this.selectedLabel;
419
+ this.selectedLabel = '';
420
+ }
421
+ }
441
422
  }
442
423
  }
424
+ this.$emit('visible-change', val);
443
425
  },
444
426
 
445
- methods: {
446
- handleNavigate(direction) {
447
- if (this.isOnComposition) return;
427
+ options() {
428
+ if (this.$isServer) return;
429
+ this.$nextTick(() => {
430
+ this.broadcast('ElSelectDropdown', 'updatePopper');
431
+ });
432
+ if (this.multiple) {
433
+ this.resetInputHeight();
434
+ }
435
+ let inputs = this.$el.querySelectorAll('input');
436
+ if ([].indexOf.call(inputs, document.activeElement) === -1) {
437
+ this.setSelected();
438
+ }
439
+ if (this.defaultFirstOption && (this.filterable || this.remote) && this.filteredOptionsCount) {
440
+ this.checkDefaultFirstOption();
441
+ }
442
+ }
443
+ },
448
444
 
449
- this.navigateOptions(direction);
450
- },
451
- handleComposition(event) {
452
- const text = event.target.value;
453
- if (event.type === 'compositionend') {
454
- this.isOnComposition = false;
455
- this.$nextTick(_ => this.handleQueryChange(text));
456
- } else {
457
- const lastCharacter = text[text.length - 1] || '';
458
- this.isOnComposition = !isKorean(lastCharacter);
459
- }
460
- },
461
- handleQueryChange(val) {
462
- if (this.previousQuery === val || this.isOnComposition) return;
463
- if (
464
- this.previousQuery === null &&
465
- (typeof this.filterMethod === 'function' || typeof this.remoteMethod === 'function')
466
- ) {
467
- this.previousQuery = val;
468
- return;
469
- }
445
+ methods: {
446
+ handleNavigate(direction) {
447
+ if (this.isOnComposition) return;
448
+
449
+ this.navigateOptions(direction);
450
+ },
451
+ handleComposition(event) {
452
+ const text = event.target.value;
453
+ if (event.type === 'compositionend') {
454
+ this.isOnComposition = false;
455
+ this.$nextTick(_ => this.handleQueryChange(text));
456
+ } else {
457
+ const lastCharacter = text[text.length - 1] || '';
458
+ this.isOnComposition = !isKorean(lastCharacter);
459
+ }
460
+ },
461
+ handleQueryChange(val) {
462
+ if (this.previousQuery === val || this.isOnComposition) return;
463
+ if (
464
+ this.previousQuery === null &&
465
+ (typeof this.filterMethod === 'function' || typeof this.remoteMethod === 'function')
466
+ ) {
470
467
  this.previousQuery = val;
468
+ return;
469
+ }
470
+ this.previousQuery = val;
471
+ this.$nextTick(() => {
472
+ if (this.visible) this.broadcast('ElSelectDropdown', 'updatePopper');
473
+ });
474
+ this.hoverIndex = -1;
475
+ if (this.multiple && this.filterable) {
471
476
  this.$nextTick(() => {
472
- if (this.visible) this.broadcast('ElSelectDropdown', 'updatePopper');
477
+ const length = this.$refs.input.value.length * 15 + 20;
478
+ this.inputLength = this.collapseTags ? Math.min(50, length) : length;
479
+ this.managePlaceholder();
480
+ this.resetInputHeight();
473
481
  });
482
+ }
483
+ if (this.remote && typeof this.remoteMethod === 'function') {
474
484
  this.hoverIndex = -1;
475
- if (this.multiple && this.filterable) {
476
- this.$nextTick(() => {
477
- const length = this.$refs.input.value.length * 15 + 20;
478
- this.inputLength = this.collapseTags ? Math.min(50, length) : length;
479
- this.managePlaceholder();
480
- this.resetInputHeight();
481
- });
482
- }
483
- if (this.remote && typeof this.remoteMethod === 'function') {
484
- this.hoverIndex = -1;
485
- this.remoteMethod(val);
486
- } else if (typeof this.filterMethod === 'function') {
487
- this.filterMethod(val);
488
- this.broadcast('ElOptionGroup', 'queryChange');
489
- } else {
490
- this.filteredOptionsCount = this.optionsCount;
491
- this.broadcast('ElOption', 'queryChange', val);
492
- this.broadcast('ElOptionGroup', 'queryChange');
493
- }
494
- if (this.defaultFirstOption && (this.filterable || this.remote) && this.filteredOptionsCount) {
495
- this.checkDefaultFirstOption();
496
- }
497
- },
485
+ this.remoteMethod(val);
486
+ } else if (typeof this.filterMethod === 'function') {
487
+ this.filterMethod(val);
488
+ this.broadcast('ElOptionGroup', 'queryChange');
489
+ } else {
490
+ this.filteredOptionsCount = this.optionsCount;
491
+ this.broadcast('ElOption', 'queryChange', val);
492
+ this.broadcast('ElOptionGroup', 'queryChange');
493
+ }
494
+ if (this.defaultFirstOption && (this.filterable || this.remote) && this.filteredOptionsCount) {
495
+ this.checkDefaultFirstOption();
496
+ }
497
+ },
498
498
 
499
- scrollToOption(option) {
500
- const target = Array.isArray(option) && option[0] ? option[0].$el : option.$el;
501
- if (this.$refs.popper && target) {
502
- const menu = this.$refs.popper.$el.querySelector('.el-select-dropdown__wrap');
503
- scrollIntoView(menu, target);
504
- }
505
- this.$refs.scrollbar && this.$refs.scrollbar.handleScroll();
506
- },
499
+ scrollToOption(option) {
500
+ const target = Array.isArray(option) && option[0] ? option[0].$el : option.$el;
501
+ if (this.$refs.popper && target) {
502
+ const menu = this.$refs.popper.$el.querySelector('.el-select-dropdown__wrap');
503
+ scrollIntoView(menu, target);
504
+ }
505
+ this.$refs.scrollbar && this.$refs.scrollbar.handleScroll();
506
+ },
507
507
 
508
- handleMenuEnter() {
509
- this.$nextTick(() => this.scrollToOption(this.selected));
510
- },
508
+ handleMenuEnter() {
509
+ this.$nextTick(() => this.scrollToOption(this.selected));
510
+ },
511
511
 
512
- emitChange(val) {
513
- if (!valueEquals(this.value, val)) {
514
- this.$emit('change', val);
515
- }
516
- },
517
-
518
- getOption(value) {
519
- let option;
520
- const isObject = Object.prototype.toString.call(value).toLowerCase() === '[object object]';
521
- const isNull = Object.prototype.toString.call(value).toLowerCase() === '[object null]';
522
- const isUndefined = Object.prototype.toString.call(value).toLowerCase() === '[object undefined]';
523
-
524
- for (let i = this.cachedOptions.length - 1; i >= 0; i--) {
525
- const cachedOption = this.cachedOptions[i];
526
- const isEqual = isObject
527
- ? getValueByPath(cachedOption.value, this.valueKey) === getValueByPath(value, this.valueKey)
528
- : cachedOption.value === value;
529
- if (isEqual) {
530
- option = cachedOption;
531
- break;
532
- }
533
- }
534
- if (option) return option;
535
- const label = (!isObject && !isNull && !isUndefined)
536
- ? String(value) : '';
537
- let newOption = {
538
- value: value,
539
- currentLabel: label
540
- };
541
- if (this.multiple) {
542
- newOption.hitState = false;
543
- }
544
- return newOption;
545
- },
512
+ emitChange(val) {
513
+ if (!valueEquals(this.value, val)) {
514
+ this.$emit('change', val);
515
+ }
516
+ },
546
517
 
547
- setSelected() {
548
- if (!this.multiple) {
549
- let option = this.getOption(this.value);
550
- if (option.created) {
551
- this.createdLabel = option.currentLabel;
552
- this.createdSelected = true;
553
- } else {
554
- this.createdSelected = false;
555
- }
556
- this.selectedLabel = option.currentLabel;
557
- this.selected = option;
558
- if (this.filterable) this.query = this.selectedLabel;
559
- return;
518
+ getOption(value) {
519
+ let option;
520
+ const isObject = Object.prototype.toString.call(value).toLowerCase() === '[object object]';
521
+ const isNull = Object.prototype.toString.call(value).toLowerCase() === '[object null]';
522
+ const isUndefined = Object.prototype.toString.call(value).toLowerCase() === '[object undefined]';
523
+
524
+ for (let i = this.cachedOptions.length - 1; i >= 0; i--) {
525
+ const cachedOption = this.cachedOptions[i];
526
+ const isEqual = isObject
527
+ ? getValueByPath(cachedOption.value, this.valueKey) === getValueByPath(value, this.valueKey)
528
+ : cachedOption.value === value;
529
+ if (isEqual) {
530
+ option = cachedOption;
531
+ break;
560
532
  }
561
- let result = [];
562
- if (Array.isArray(this.value)) {
563
- this.value.forEach(value => {
564
- result.push(this.getOption(value));
565
- });
533
+ }
534
+ if (option) return option;
535
+ const label = (!isObject && !isNull && !isUndefined)
536
+ ? String(value) : '';
537
+ let newOption = {
538
+ value: value,
539
+ currentLabel: label
540
+ };
541
+ if (this.multiple) {
542
+ newOption.hitState = false;
543
+ }
544
+ return newOption;
545
+ },
546
+
547
+ setSelected() {
548
+ if (!this.multiple) {
549
+ let option = this.getOption(this.value);
550
+ if (option.created) {
551
+ this.createdLabel = option.currentLabel;
552
+ this.createdSelected = true;
553
+ } else {
554
+ this.createdSelected = false;
566
555
  }
567
- this.selected = result;
568
- this.$nextTick(() => {
569
- this.resetInputHeight();
556
+ this.selectedLabel = option.currentLabel;
557
+ this.selected = option;
558
+ if (this.filterable) this.query = this.selectedLabel;
559
+ return;
560
+ }
561
+ let result = [];
562
+ if (Array.isArray(this.value)) {
563
+ this.value.forEach(value => {
564
+ result.push(this.getOption(value));
570
565
  });
571
- },
566
+ }
567
+ this.selected = result;
568
+ this.$nextTick(() => {
569
+ this.resetInputHeight();
570
+ });
571
+ },
572
572
 
573
- handleFocus(event) {
574
- if (!this.softFocus) {
575
- if (this.automaticDropdown || this.filterable) {
576
- if (this.filterable && !this.visible) {
577
- this.menuVisibleOnFocus = true;
578
- }
579
- this.visible = true;
573
+ handleFocus(event) {
574
+ if (!this.softFocus) {
575
+ if (this.automaticDropdown || this.filterable) {
576
+ if (this.filterable && !this.visible) {
577
+ this.menuVisibleOnFocus = true;
580
578
  }
581
- this.$emit('focus', event);
582
- } else {
583
- this.softFocus = false;
579
+ this.visible = true;
584
580
  }
585
- },
581
+ this.$emit('focus', event);
582
+ } else {
583
+ this.softFocus = false;
584
+ }
585
+ },
586
586
 
587
- blur() {
588
- this.visible = false;
589
- this.$refs.reference.blur();
590
- },
587
+ blur() {
588
+ this.visible = false;
589
+ this.$refs.reference.blur();
590
+ },
591
591
 
592
- handleBlur(event) {
593
- setTimeout(() => {
594
- if (this.isSilentBlur) {
595
- this.isSilentBlur = false;
596
- } else {
597
- this.$emit('blur', event);
598
- }
599
- }, 50);
600
- this.softFocus = false;
601
- },
592
+ handleBlur(event) {
593
+ setTimeout(() => {
594
+ if (this.isSilentBlur) {
595
+ this.isSilentBlur = false;
596
+ } else {
597
+ this.$emit('blur', event);
598
+ }
599
+ }, 50);
600
+ this.softFocus = false;
601
+ },
602
602
 
603
- handleClearClick(event) {
604
- this.deleteSelected(event);
605
- },
603
+ handleClearClick(event) {
604
+ this.deleteSelected(event);
605
+ },
606
606
 
607
- doDestroy() {
608
- this.$refs.popper && this.$refs.popper.doDestroy();
609
- },
607
+ doDestroy() {
608
+ this.$refs.popper && this.$refs.popper.doDestroy();
609
+ },
610
610
 
611
- handleClose() {
612
- this.visible = false;
613
- },
611
+ handleClose() {
612
+ this.visible = false;
613
+ },
614
614
 
615
- toggleLastOptionHitState(hit) {
616
- if (!Array.isArray(this.selected)) return;
617
- const option = this.selected[this.selected.length - 1];
618
- if (!option) return;
615
+ toggleLastOptionHitState(hit) {
616
+ if (!Array.isArray(this.selected)) return;
617
+ const option = this.selected[this.selected.length - 1];
618
+ if (!option) return;
619
619
 
620
- if (hit === true || hit === false) {
621
- option.hitState = hit;
622
- return hit;
623
- }
620
+ if (hit === true || hit === false) {
621
+ option.hitState = hit;
622
+ return hit;
623
+ }
624
624
 
625
- option.hitState = !option.hitState;
626
- return option.hitState;
627
- },
625
+ option.hitState = !option.hitState;
626
+ return option.hitState;
627
+ },
628
628
 
629
- deletePrevTag(e) {
630
- if (e.target.value.length <= 0 && !this.toggleLastOptionHitState()) {
631
- const value = this.value.slice();
632
- value.pop();
633
- this.$emit('input', value);
634
- this.emitChange(value);
635
- }
636
- },
629
+ deletePrevTag(e) {
630
+ if (e.target.value.length <= 0 && !this.toggleLastOptionHitState()) {
631
+ const value = this.value.slice();
632
+ value.pop();
633
+ this.$emit('input', value);
634
+ this.emitChange(value);
635
+ }
636
+ },
637
637
 
638
- managePlaceholder() {
639
- if (this.currentPlaceholder !== '') {
640
- this.currentPlaceholder = this.$refs.input.value ? '' : this.cachedPlaceHolder;
641
- }
642
- },
638
+ managePlaceholder() {
639
+ if (this.currentPlaceholder !== '') {
640
+ this.currentPlaceholder = this.$refs.input.value ? '' : this.cachedPlaceHolder;
641
+ }
642
+ },
643
643
 
644
- resetInputState(e) {
645
- if (e.keyCode !== 8) this.toggleLastOptionHitState(false);
646
- this.inputLength = this.$refs.input.value.length * 15 + 20;
647
- this.resetInputHeight();
648
- },
644
+ resetInputState(e) {
645
+ if (e.keyCode !== 8) this.toggleLastOptionHitState(false);
646
+ this.inputLength = this.$refs.input.value.length * 15 + 20;
647
+ this.resetInputHeight();
648
+ },
649
649
 
650
- resetInputHeight() {
651
- if (this.collapseTags && !this.filterable) return;
652
- this.$nextTick(() => {
653
- if (!this.$refs.reference) return;
654
- let inputChildNodes = this.$refs.reference.$el.childNodes;
655
- let input = [].filter.call(inputChildNodes, item => item.tagName === 'INPUT')[0];
656
- const tags = this.$refs.tags;
657
- const tagsHeight = tags ? Math.round(tags.getBoundingClientRect().height) : 0;
658
- const sizeInMap = this.initialInputHeight || 40;
659
- input.style.height = this.selected.length === 0
660
- ? sizeInMap + 'px'
661
- : Math.max(
662
- tags ? (tagsHeight + (tagsHeight > sizeInMap ? 6 : 0)) : 0,
663
- sizeInMap
664
- ) + 'px';
665
- if (this.visible && this.emptyText !== false) {
666
- this.broadcast('ElSelectDropdown', 'updatePopper');
667
- }
668
- });
669
- },
650
+ resetInputHeight() {
651
+ if (this.collapseTags && !this.filterable) return;
652
+ this.$nextTick(() => {
653
+ if (!this.$refs.reference) return;
654
+ let inputChildNodes = this.$refs.reference.$el.childNodes;
655
+ let input = [].filter.call(inputChildNodes, item => item.tagName === 'INPUT')[0];
656
+ const tags = this.$refs.tags;
657
+ const tagsHeight = tags ? Math.round(tags.getBoundingClientRect().height) : 0;
658
+ const sizeInMap = this.initialInputHeight || 40;
659
+ input.style.height = this.selected.length === 0
660
+ ? sizeInMap + 'px'
661
+ : Math.max(
662
+ tags ? (tagsHeight + (tagsHeight > sizeInMap ? 6 : 0)) : 0,
663
+ sizeInMap
664
+ ) + 'px';
665
+ if (this.visible && this.emptyText !== false) {
666
+ this.broadcast('ElSelectDropdown', 'updatePopper');
667
+ }
668
+ });
669
+ },
670
670
 
671
- resetHoverIndex() {
672
- setTimeout(() => {
673
- if (!this.multiple) {
674
- this.hoverIndex = this.options.indexOf(this.selected);
671
+ resetHoverIndex() {
672
+ setTimeout(() => {
673
+ if (!this.multiple) {
674
+ this.hoverIndex = this.options.indexOf(this.selected);
675
+ } else {
676
+ if (this.selected.length > 0) {
677
+ this.hoverIndex = Math.min.apply(null, this.selected.map(item => this.options.indexOf(item)));
675
678
  } else {
676
- if (this.selected.length > 0) {
677
- this.hoverIndex = Math.min.apply(null, this.selected.map(item => this.options.indexOf(item)));
678
- } else {
679
- this.hoverIndex = -1;
680
- }
681
- }
682
- }, 300);
683
- },
684
-
685
- handleOptionSelect(option, byClick) {
686
- if (this.multiple) {
687
- const value = (this.value || []).slice();
688
- const optionIndex = this.getValueIndex(value, option.value);
689
- if (optionIndex > -1) {
690
- value.splice(optionIndex, 1);
691
- } else if (this.multipleLimit <= 0 || value.length < this.multipleLimit) {
692
- value.push(option.value);
679
+ this.hoverIndex = -1;
693
680
  }
694
- this.$emit('input', value);
695
- this.emitChange(value);
696
- if (option.created) {
697
- this.query = '';
698
- this.handleQueryChange('');
699
- this.inputLength = 20;
700
- }
701
- if (this.filterable) this.$refs.input.focus();
702
- } else {
703
- this.$emit('input', option.value);
704
- this.emitChange(option.value);
705
- this.visible = false;
706
681
  }
707
- this.isSilentBlur = byClick;
708
- this.setSoftFocus();
709
- if (this.visible) return;
710
- this.$nextTick(() => {
711
- this.scrollToOption(option);
712
- });
713
- },
682
+ }, 300);
683
+ },
714
684
 
715
- setSoftFocus() {
716
- this.softFocus = true;
717
- const input = this.$refs.input || this.$refs.reference;
718
- if (input) {
719
- input.focus();
685
+ handleOptionSelect(option, byClick) {
686
+ if (this.multiple) {
687
+ const value = (this.value || []).slice();
688
+ const optionIndex = this.getValueIndex(value, option.value);
689
+ if (optionIndex > -1) {
690
+ value.splice(optionIndex, 1);
691
+ } else if (this.multipleLimit <= 0 || value.length < this.multipleLimit) {
692
+ value.push(option.value);
720
693
  }
721
- },
722
-
723
- getValueIndex(arr = [], value) {
724
- const isObject = Object.prototype.toString.call(value).toLowerCase() === '[object object]';
725
- if (!isObject) {
726
- return arr.indexOf(value);
727
- } else {
728
- const valueKey = this.valueKey;
729
- let index = -1;
730
- arr.some((item, i) => {
731
- if (getValueByPath(item, valueKey) === getValueByPath(value, valueKey)) {
732
- index = i;
733
- return true;
734
- }
735
- return false;
736
- });
737
- return index;
694
+ this.$emit('input', value);
695
+ this.emitChange(value);
696
+ if (option.created) {
697
+ this.query = '';
698
+ this.handleQueryChange('');
699
+ this.inputLength = 20;
738
700
  }
739
- },
701
+ if (this.filterable) this.$refs.input.focus();
702
+ } else {
703
+ this.$emit('input', option.value);
704
+ this.emitChange(option.value);
705
+ this.visible = false;
706
+ }
707
+ this.isSilentBlur = byClick;
708
+ this.setSoftFocus();
709
+ if (this.visible) return;
710
+ this.$nextTick(() => {
711
+ this.scrollToOption(option);
712
+ });
713
+ },
740
714
 
741
- toggleMenu() {
742
- if (!this.selectDisabled) {
743
- if (this.menuVisibleOnFocus) {
744
- this.menuVisibleOnFocus = false;
745
- } else {
746
- this.visible = !this.visible;
747
- }
748
- if (this.visible) {
749
- (this.$refs.input || this.$refs.reference).focus();
715
+ setSoftFocus() {
716
+ this.softFocus = true;
717
+ const input = this.$refs.input || this.$refs.reference;
718
+ if (input) {
719
+ input.focus();
720
+ }
721
+ },
722
+
723
+ getValueIndex(arr = [], value) {
724
+ const isObject = Object.prototype.toString.call(value).toLowerCase() === '[object object]';
725
+ if (!isObject) {
726
+ return arr.indexOf(value);
727
+ } else {
728
+ const valueKey = this.valueKey;
729
+ let index = -1;
730
+ arr.some((item, i) => {
731
+ if (getValueByPath(item, valueKey) === getValueByPath(value, valueKey)) {
732
+ index = i;
733
+ return true;
750
734
  }
751
- }
752
- },
735
+ return false;
736
+ });
737
+ return index;
738
+ }
739
+ },
753
740
 
754
- selectOption() {
755
- if (!this.visible) {
756
- this.toggleMenu();
741
+ toggleMenu() {
742
+ if (!this.selectDisabled) {
743
+ if (this.menuVisibleOnFocus) {
744
+ this.menuVisibleOnFocus = false;
757
745
  } else {
758
- if (this.options[this.hoverIndex]) {
759
- this.handleOptionSelect(this.options[this.hoverIndex]);
760
- }
746
+ this.visible = !this.visible;
747
+ }
748
+ if (this.visible) {
749
+ (this.$refs.input || this.$refs.reference).focus();
750
+ }
751
+ }
752
+ },
753
+
754
+ selectOption() {
755
+ if (!this.visible) {
756
+ this.toggleMenu();
757
+ } else {
758
+ if (this.options[this.hoverIndex]) {
759
+ this.handleOptionSelect(this.options[this.hoverIndex]);
761
760
  }
762
- },
761
+ }
762
+ },
763
763
 
764
- deleteSelected(event) {
765
- event.stopPropagation();
766
- const value = this.multiple ? [] : '';
764
+ deleteSelected(event) {
765
+ event.stopPropagation();
766
+ const value = this.multiple ? [] : '';
767
+ this.$emit('input', value);
768
+ this.emitChange(value);
769
+ this.visible = false;
770
+ this.$emit('clear');
771
+ },
772
+
773
+ deleteTag(event, tag) {
774
+ let index = this.selected.indexOf(tag);
775
+ if (index > -1 && !this.selectDisabled) {
776
+ const value = this.value.slice();
777
+ value.splice(index, 1);
767
778
  this.$emit('input', value);
768
779
  this.emitChange(value);
769
- this.visible = false;
770
- this.$emit('clear');
771
- },
772
-
773
- deleteTag(event, tag) {
774
- let index = this.selected.indexOf(tag);
775
- if (index > -1 && !this.selectDisabled) {
776
- const value = this.value.slice();
777
- value.splice(index, 1);
778
- this.$emit('input', value);
779
- this.emitChange(value);
780
- this.$emit('remove-tag', tag.value);
781
- }
782
- event.stopPropagation();
783
- },
780
+ this.$emit('remove-tag', tag.value);
781
+ }
782
+ event.stopPropagation();
783
+ },
784
784
 
785
- onInputChange() {
786
- if (this.filterable && this.query !== this.selectedLabel) {
787
- this.query = this.selectedLabel;
788
- this.handleQueryChange(this.query);
789
- }
790
- },
785
+ onInputChange() {
786
+ if (this.filterable && this.query !== this.selectedLabel) {
787
+ this.query = this.selectedLabel;
788
+ this.handleQueryChange(this.query);
789
+ }
790
+ },
791
791
 
792
- onOptionDestroy(index) {
793
- if (index > -1) {
794
- this.optionsCount--;
795
- this.filteredOptionsCount--;
796
- this.options.splice(index, 1);
797
- }
798
- },
792
+ onOptionDestroy(index) {
793
+ if (index > -1) {
794
+ this.optionsCount--;
795
+ this.filteredOptionsCount--;
796
+ this.options.splice(index, 1);
797
+ }
798
+ },
799
799
 
800
- resetInputWidth() {
801
- this.inputWidth = this.$refs.reference.$el.getBoundingClientRect().width;
802
- },
800
+ resetInputWidth() {
801
+ this.inputWidth = this.$refs.reference.$el.getBoundingClientRect().width;
802
+ },
803
803
 
804
- handleResize() {
805
- this.resetInputWidth();
806
- if (this.multiple) this.resetInputHeight();
807
- },
804
+ handleResize() {
805
+ this.resetInputWidth();
806
+ if (this.multiple) this.resetInputHeight();
807
+ },
808
808
 
809
- checkDefaultFirstOption() {
810
- this.hoverIndex = -1;
811
- // highlight the created option
812
- let hasCreated = false;
813
- for (let i = this.options.length - 1; i >= 0; i--) {
814
- if (this.options[i].created) {
815
- hasCreated = true;
809
+ checkDefaultFirstOption() {
810
+ this.hoverIndex = -1;
811
+ // highlight the created option
812
+ let hasCreated = false;
813
+ for (let i = this.options.length - 1; i >= 0; i--) {
814
+ if (this.options[i].created) {
815
+ hasCreated = true;
816
+ this.hoverIndex = i;
817
+ break;
818
+ }
819
+ }
820
+ if (hasCreated) return;
821
+ for (let i = 0; i !== this.options.length; ++i) {
822
+ const option = this.options[i];
823
+ if (this.query) {
824
+ // highlight first options that passes the filter
825
+ if (!option.disabled && !option.groupDisabled && option.visible) {
816
826
  this.hoverIndex = i;
817
827
  break;
818
828
  }
819
- }
820
- if (hasCreated) return;
821
- for (let i = 0; i !== this.options.length; ++i) {
822
- const option = this.options[i];
823
- if (this.query) {
824
- // highlight first options that passes the filter
825
- if (!option.disabled && !option.groupDisabled && option.visible) {
826
- this.hoverIndex = i;
827
- break;
828
- }
829
- } else {
830
- // highlight currently selected option
831
- if (option.itemSelected) {
832
- this.hoverIndex = i;
833
- break;
834
- }
835
- }
836
- }
837
- },
838
-
839
- getValueKey(item) {
840
- if (Object.prototype.toString.call(item.value).toLowerCase() !== '[object object]') {
841
- return item.value;
842
829
  } else {
843
- return getValueByPath(item.value, this.valueKey);
830
+ // highlight currently selected option
831
+ if (option.itemSelected) {
832
+ this.hoverIndex = i;
833
+ break;
834
+ }
844
835
  }
845
836
  }
846
837
  },
847
838
 
848
- created() {
849
- this.cachedPlaceHolder = this.currentPlaceholder = this.propPlaceholder;
850
- if (this.multiple && !Array.isArray(this.value)) {
851
- this.$emit('input', []);
852
- }
853
- if (!this.multiple && Array.isArray(this.value)) {
854
- this.$emit('input', '');
839
+ getValueKey(item) {
840
+ if (Object.prototype.toString.call(item.value).toLowerCase() !== '[object object]') {
841
+ return item.value;
842
+ } else {
843
+ return getValueByPath(item.value, this.valueKey);
855
844
  }
845
+ }
846
+ },
856
847
 
857
- this.debouncedOnInputChange = debounce(this.debounce, () => {
858
- this.onInputChange();
859
- });
848
+ created() {
849
+ this.cachedPlaceHolder = this.currentPlaceholder = this.propPlaceholder;
850
+ if (this.multiple && !Array.isArray(this.value)) {
851
+ this.$emit('input', []);
852
+ }
853
+ if (!this.multiple && Array.isArray(this.value)) {
854
+ this.$emit('input', '');
855
+ }
860
856
 
861
- this.debouncedQueryChange = debounce(this.debounce, (e) => {
862
- this.handleQueryChange(e.target.value);
863
- });
857
+ this.debouncedOnInputChange = debounce(this.debounce, () => {
858
+ this.onInputChange();
859
+ });
864
860
 
865
- this.$on('handleOptionClick', this.handleOptionSelect);
866
- this.$on('setSelected', this.setSelected);
867
- },
861
+ this.debouncedQueryChange = debounce(this.debounce, (e) => {
862
+ this.handleQueryChange(e.target.value);
863
+ });
868
864
 
869
- mounted() {
870
- if (this.multiple && Array.isArray(this.value) && this.value.length > 0) {
871
- this.currentPlaceholder = '';
872
- }
873
- addResizeListener(this.$el, this.handleResize);
865
+ this.$on('handleOptionClick', this.handleOptionSelect);
866
+ this.$on('setSelected', this.setSelected);
867
+ },
874
868
 
875
- const reference = this.$refs.reference;
869
+ mounted() {
870
+ if (this.multiple && Array.isArray(this.value) && this.value.length > 0) {
871
+ this.currentPlaceholder = '';
872
+ }
873
+ addResizeListener(this.$el, this.handleResize);
874
+
875
+ const reference = this.$refs.reference;
876
+ if (reference && reference.$el) {
877
+ const sizeMap = {
878
+ medium: 36,
879
+ small: 32,
880
+ mini: 28
881
+ };
882
+ const input = reference.$el.querySelector('input');
883
+ this.initialInputHeight = input.getBoundingClientRect().height || sizeMap[this.selectSize];
884
+ }
885
+ if (this.remote && this.multiple) {
886
+ this.resetInputHeight();
887
+ }
888
+ this.$nextTick(() => {
876
889
  if (reference && reference.$el) {
877
- const sizeMap = {
878
- medium: 36,
879
- small: 32,
880
- mini: 28
881
- };
882
- const input = reference.$el.querySelector('input');
883
- this.initialInputHeight = input.getBoundingClientRect().height || sizeMap[this.selectSize];
884
- }
885
- if (this.remote && this.multiple) {
886
- this.resetInputHeight();
890
+ this.inputWidth = reference.$el.getBoundingClientRect().width;
887
891
  }
888
- this.$nextTick(() => {
889
- if (reference && reference.$el) {
890
- this.inputWidth = reference.$el.getBoundingClientRect().width;
891
- }
892
- });
893
- this.setSelected();
894
- },
895
-
896
- beforeDestroy() {
897
- if (this.$el && this.handleResize) removeResizeListener(this.$el, this.handleResize);
898
- }
899
- };
892
+ });
893
+ this.setSelected();
894
+ },
895
+
896
+ beforeDestroy() {
897
+ if (this.$el && this.handleResize) removeResizeListener(this.$el, this.handleResize);
898
+ }
899
+ };
900
900
  </script>