vxe-pc-ui 3.0.0 → 3.0.1

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 (331) hide show
  1. package/es/button/src/button.js +3 -0
  2. package/es/carousel/index.js +12 -0
  3. package/es/carousel/src/carousel-item.js +100 -0
  4. package/es/carousel/src/carousel.js +418 -0
  5. package/es/carousel/src/util.js +17 -0
  6. package/es/carousel/style.css +185 -0
  7. package/es/carousel/style.min.css +1 -0
  8. package/es/carousel-item/index.js +12 -0
  9. package/es/carousel-item/style.css +0 -0
  10. package/es/carousel-item/style.min.css +0 -0
  11. package/es/checkbox/index.js +12 -0
  12. package/es/checkbox/src/checkbox.js +159 -0
  13. package/es/checkbox/src/group.js +154 -0
  14. package/es/checkbox/style.css +117 -0
  15. package/es/checkbox/style.min.css +1 -0
  16. package/es/checkbox-group/index.js +12 -0
  17. package/es/checkbox-group/style.css +0 -0
  18. package/es/checkbox-group/style.min.css +0 -0
  19. package/es/components.js +39 -39
  20. package/es/date-picker/src/date-picker.js +3 -0
  21. package/es/icon/style.css +1 -1
  22. package/es/icon-picker/index.js +12 -0
  23. package/es/icon-picker/src/icon-picker.js +668 -0
  24. package/es/icon-picker/style.css +207 -0
  25. package/es/icon-picker/style.min.css +1 -0
  26. package/es/input/index.js +12 -0
  27. package/es/input/src/input.js +2892 -0
  28. package/es/input/style.css +941 -0
  29. package/es/input/style.min.css +1 -0
  30. package/es/layout-footer/src/layout-footer.js +2 -1
  31. package/es/layout-header/src/layout-header.js +2 -1
  32. package/es/optgroup/index.js +12 -0
  33. package/es/optgroup/style.css +0 -0
  34. package/es/optgroup/style.min.css +0 -0
  35. package/es/option/index.js +12 -0
  36. package/es/option/style.css +0 -0
  37. package/es/option/style.min.css +0 -0
  38. package/es/pager/index.js +12 -0
  39. package/es/pager/src/pager.js +687 -0
  40. package/es/password-input/index.js +12 -0
  41. package/es/password-input/src/password-input.js +388 -0
  42. package/es/password-input/style.css +604 -0
  43. package/es/password-input/style.min.css +1 -0
  44. package/es/pulldown/src/pulldown.js +5 -1
  45. package/es/select/index.js +12 -0
  46. package/es/select/src/optgroup.js +90 -0
  47. package/es/select/src/option-info.js +16 -0
  48. package/es/select/src/option.js +86 -0
  49. package/es/select/src/select.js +1269 -0
  50. package/es/select/src/util.js +35 -0
  51. package/es/select/style.css +207 -0
  52. package/es/select/style.min.css +1 -0
  53. package/es/style.css +1 -1
  54. package/es/style.min.css +1 -1
  55. package/es/tab-pane/index.js +12 -0
  56. package/es/tab-pane/style.css +0 -0
  57. package/es/tab-pane/style.min.css +0 -0
  58. package/es/tabs/index.js +12 -0
  59. package/es/tabs/src/tab-pane.js +119 -0
  60. package/es/tabs/src/tabs.js +593 -0
  61. package/es/tabs/src/util.js +17 -0
  62. package/es/tabs/style.css +342 -0
  63. package/es/tabs/style.min.css +1 -0
  64. package/es/ui/index.js +1 -1
  65. package/es/ui/src/log.js +1 -1
  66. package/es/vxe-carousel/index.js +3 -0
  67. package/es/vxe-carousel/style.css +185 -0
  68. package/es/vxe-carousel/style.min.css +1 -0
  69. package/es/vxe-carousel-item/index.js +3 -0
  70. package/es/vxe-carousel-item/style.css +0 -0
  71. package/es/vxe-carousel-item/style.min.css +0 -0
  72. package/es/vxe-checkbox/index.js +3 -0
  73. package/es/vxe-checkbox/style.css +117 -0
  74. package/es/vxe-checkbox/style.min.css +1 -0
  75. package/es/vxe-checkbox-group/index.js +3 -0
  76. package/es/vxe-checkbox-group/style.css +0 -0
  77. package/es/vxe-checkbox-group/style.min.css +0 -0
  78. package/es/vxe-icon-picker/index.js +3 -0
  79. package/es/vxe-icon-picker/style.css +207 -0
  80. package/es/vxe-icon-picker/style.min.css +1 -0
  81. package/es/vxe-input/index.js +3 -0
  82. package/es/vxe-input/style.css +941 -0
  83. package/es/vxe-input/style.min.css +1 -0
  84. package/es/vxe-optgroup/index.js +3 -0
  85. package/es/vxe-optgroup/style.css +0 -0
  86. package/es/vxe-optgroup/style.min.css +0 -0
  87. package/es/vxe-option/index.js +3 -0
  88. package/es/vxe-option/style.css +0 -0
  89. package/es/vxe-option/style.min.css +0 -0
  90. package/es/vxe-password-input/index.js +3 -0
  91. package/es/vxe-password-input/style.css +604 -0
  92. package/es/vxe-password-input/style.min.css +1 -0
  93. package/es/vxe-select/index.js +3 -0
  94. package/es/vxe-select/style.css +207 -0
  95. package/es/vxe-select/style.min.css +1 -0
  96. package/es/vxe-tab-pane/index.js +3 -0
  97. package/es/vxe-tab-pane/style.css +0 -0
  98. package/es/vxe-tab-pane/style.min.css +0 -0
  99. package/es/vxe-tabs/index.js +3 -0
  100. package/es/vxe-tabs/style.css +342 -0
  101. package/es/vxe-tabs/style.min.css +1 -0
  102. package/lib/button/src/button.js +3 -0
  103. package/lib/button/src/button.min.js +1 -1
  104. package/lib/carousel/index.js +19 -0
  105. package/lib/carousel/index.min.js +1 -0
  106. package/lib/carousel/src/carousel-item.js +107 -0
  107. package/lib/carousel/src/carousel-item.min.js +1 -0
  108. package/lib/carousel/src/carousel.js +437 -0
  109. package/lib/carousel/src/carousel.min.js +1 -0
  110. package/lib/carousel/src/util.js +27 -0
  111. package/lib/carousel/src/util.min.js +1 -0
  112. package/lib/carousel/style/index.js +1 -0
  113. package/lib/carousel/style/style.css +185 -0
  114. package/lib/carousel/style/style.min.css +1 -0
  115. package/lib/carousel-item/index.js +19 -0
  116. package/lib/carousel-item/index.min.js +1 -0
  117. package/lib/carousel-item/style/index.js +1 -0
  118. package/lib/carousel-item/style/style.css +0 -0
  119. package/lib/carousel-item/style/style.min.css +0 -0
  120. package/lib/checkbox/index.js +19 -0
  121. package/lib/checkbox/index.min.js +1 -0
  122. package/lib/checkbox/src/checkbox.js +169 -0
  123. package/lib/checkbox/src/checkbox.min.js +1 -0
  124. package/lib/checkbox/src/group.js +164 -0
  125. package/lib/checkbox/src/group.min.js +1 -0
  126. package/lib/checkbox/style/index.js +1 -0
  127. package/lib/checkbox/style/style.css +117 -0
  128. package/lib/checkbox/style/style.min.css +1 -0
  129. package/lib/checkbox-group/index.js +19 -0
  130. package/lib/checkbox-group/index.min.js +1 -0
  131. package/lib/checkbox-group/style/index.js +1 -0
  132. package/lib/checkbox-group/style/style.css +0 -0
  133. package/lib/checkbox-group/style/style.min.css +0 -0
  134. package/lib/components.js +159 -60
  135. package/lib/components.min.js +1 -1
  136. package/lib/date-picker/src/date-picker.js +3 -0
  137. package/lib/date-picker/src/date-picker.min.js +1 -1
  138. package/lib/icon/style/style.css +1 -1
  139. package/lib/icon/style/style.min.css +1 -1
  140. package/lib/icon-picker/index.js +19 -0
  141. package/lib/icon-picker/index.min.js +1 -0
  142. package/lib/icon-picker/src/icon-picker.js +646 -0
  143. package/lib/icon-picker/src/icon-picker.min.js +1 -0
  144. package/lib/icon-picker/style/index.js +1 -0
  145. package/lib/icon-picker/style/style.css +207 -0
  146. package/lib/icon-picker/style/style.min.css +1 -0
  147. package/lib/index.umd.js +15870 -7738
  148. package/lib/index.umd.min.js +1 -1
  149. package/lib/input/index.js +19 -0
  150. package/lib/input/index.min.js +1 -0
  151. package/lib/input/src/input.js +2897 -0
  152. package/lib/input/src/input.min.js +1 -0
  153. package/lib/input/style/index.js +1 -0
  154. package/lib/input/style/style.css +941 -0
  155. package/lib/input/style/style.min.css +1 -0
  156. package/lib/layout-footer/src/layout-footer.js +2 -1
  157. package/lib/layout-header/src/layout-header.js +2 -1
  158. package/lib/optgroup/index.js +19 -0
  159. package/lib/optgroup/index.min.js +1 -0
  160. package/lib/optgroup/style/index.js +1 -0
  161. package/lib/optgroup/style/style.css +0 -0
  162. package/lib/optgroup/style/style.min.css +0 -0
  163. package/lib/option/index.js +19 -0
  164. package/lib/option/index.min.js +1 -0
  165. package/lib/option/style/index.js +1 -0
  166. package/lib/option/style/style.css +0 -0
  167. package/lib/option/style/style.min.css +0 -0
  168. package/lib/pager/index.js +19 -0
  169. package/lib/pager/index.min.js +1 -0
  170. package/lib/pager/src/pager.js +714 -0
  171. package/lib/pager/src/pager.min.js +1 -0
  172. package/lib/password-input/index.js +19 -0
  173. package/lib/password-input/index.min.js +1 -0
  174. package/lib/password-input/src/password-input.js +398 -0
  175. package/lib/password-input/src/password-input.min.js +1 -0
  176. package/lib/password-input/style/index.js +1 -0
  177. package/lib/password-input/style/style.css +604 -0
  178. package/lib/password-input/style/style.min.css +1 -0
  179. package/lib/pulldown/src/pulldown.js +5 -1
  180. package/lib/pulldown/src/pulldown.min.js +1 -1
  181. package/lib/select/index.js +19 -0
  182. package/lib/select/index.min.js +1 -0
  183. package/lib/select/src/optgroup.js +97 -0
  184. package/lib/select/src/optgroup.min.js +1 -0
  185. package/lib/select/src/option-info.js +33 -0
  186. package/lib/select/src/option-info.min.js +1 -0
  187. package/lib/select/src/option.js +93 -0
  188. package/lib/select/src/option.min.js +1 -0
  189. package/lib/select/src/select.js +1315 -0
  190. package/lib/select/src/select.min.js +1 -0
  191. package/lib/select/src/util.js +50 -0
  192. package/lib/select/src/util.min.js +1 -0
  193. package/lib/select/style/index.js +1 -0
  194. package/lib/select/style/style.css +207 -0
  195. package/lib/select/style/style.min.css +1 -0
  196. package/lib/style.css +1 -1
  197. package/lib/style.min.css +1 -1
  198. package/lib/tab-pane/index.js +19 -0
  199. package/lib/tab-pane/index.min.js +1 -0
  200. package/lib/tab-pane/style/index.js +1 -0
  201. package/lib/tab-pane/style/style.css +0 -0
  202. package/lib/tab-pane/style/style.min.css +0 -0
  203. package/lib/tabs/index.js +19 -0
  204. package/lib/tabs/index.min.js +1 -0
  205. package/lib/tabs/src/tab-pane.js +128 -0
  206. package/lib/tabs/src/tab-pane.min.js +1 -0
  207. package/lib/tabs/src/tabs.js +630 -0
  208. package/lib/tabs/src/tabs.min.js +1 -0
  209. package/lib/tabs/src/util.js +29 -0
  210. package/lib/tabs/src/util.min.js +1 -0
  211. package/lib/tabs/style/index.js +1 -0
  212. package/lib/tabs/style/style.css +342 -0
  213. package/lib/tabs/style/style.min.css +1 -0
  214. package/lib/ui/index.js +1 -1
  215. package/lib/ui/index.min.js +1 -1
  216. package/lib/ui/src/log.js +1 -1
  217. package/lib/ui/src/log.min.js +1 -1
  218. package/lib/vxe-carousel/index.js +23 -0
  219. package/lib/vxe-carousel/index.min.js +1 -0
  220. package/lib/vxe-carousel/style/index.js +1 -0
  221. package/lib/vxe-carousel/style/style.css +185 -0
  222. package/lib/vxe-carousel/style/style.min.css +1 -0
  223. package/lib/vxe-carousel-item/index.js +23 -0
  224. package/lib/vxe-carousel-item/index.min.js +1 -0
  225. package/lib/vxe-carousel-item/style/index.js +1 -0
  226. package/lib/vxe-carousel-item/style/style.css +0 -0
  227. package/lib/vxe-carousel-item/style/style.min.css +0 -0
  228. package/lib/vxe-checkbox/index.js +23 -0
  229. package/lib/vxe-checkbox/index.min.js +1 -0
  230. package/lib/vxe-checkbox/style/index.js +1 -0
  231. package/lib/vxe-checkbox/style/style.css +117 -0
  232. package/lib/vxe-checkbox/style/style.min.css +1 -0
  233. package/lib/vxe-checkbox-group/index.js +23 -0
  234. package/lib/vxe-checkbox-group/index.min.js +1 -0
  235. package/lib/vxe-checkbox-group/style/index.js +1 -0
  236. package/lib/vxe-checkbox-group/style/style.css +0 -0
  237. package/lib/vxe-checkbox-group/style/style.min.css +0 -0
  238. package/lib/vxe-icon-picker/index.js +23 -0
  239. package/lib/vxe-icon-picker/index.min.js +1 -0
  240. package/lib/vxe-icon-picker/style/index.js +1 -0
  241. package/lib/vxe-icon-picker/style/style.css +207 -0
  242. package/lib/vxe-icon-picker/style/style.min.css +1 -0
  243. package/lib/vxe-input/index.js +23 -0
  244. package/lib/vxe-input/index.min.js +1 -0
  245. package/lib/vxe-input/style/index.js +1 -0
  246. package/lib/vxe-input/style/style.css +941 -0
  247. package/lib/vxe-input/style/style.min.css +1 -0
  248. package/lib/vxe-optgroup/index.js +23 -0
  249. package/lib/vxe-optgroup/index.min.js +1 -0
  250. package/lib/vxe-optgroup/style/index.js +1 -0
  251. package/lib/vxe-optgroup/style/style.css +0 -0
  252. package/lib/vxe-optgroup/style/style.min.css +0 -0
  253. package/lib/vxe-option/index.js +23 -0
  254. package/lib/vxe-option/index.min.js +1 -0
  255. package/lib/vxe-option/style/index.js +1 -0
  256. package/lib/vxe-option/style/style.css +0 -0
  257. package/lib/vxe-option/style/style.min.css +0 -0
  258. package/lib/vxe-password-input/index.js +23 -0
  259. package/lib/vxe-password-input/index.min.js +1 -0
  260. package/lib/vxe-password-input/style/index.js +1 -0
  261. package/lib/vxe-password-input/style/style.css +604 -0
  262. package/lib/vxe-password-input/style/style.min.css +1 -0
  263. package/lib/vxe-select/index.js +23 -0
  264. package/lib/vxe-select/index.min.js +1 -0
  265. package/lib/vxe-select/style/index.js +1 -0
  266. package/lib/vxe-select/style/style.css +207 -0
  267. package/lib/vxe-select/style/style.min.css +1 -0
  268. package/lib/vxe-tab-pane/index.js +23 -0
  269. package/lib/vxe-tab-pane/index.min.js +1 -0
  270. package/lib/vxe-tab-pane/style/index.js +1 -0
  271. package/lib/vxe-tab-pane/style/style.css +0 -0
  272. package/lib/vxe-tab-pane/style/style.min.css +0 -0
  273. package/lib/vxe-tabs/index.js +23 -0
  274. package/lib/vxe-tabs/index.min.js +1 -0
  275. package/lib/vxe-tabs/style/index.js +1 -0
  276. package/lib/vxe-tabs/style/style.css +342 -0
  277. package/lib/vxe-tabs/style/style.min.css +1 -0
  278. package/package.json +1 -1
  279. package/packages/button/src/button.ts +3 -0
  280. package/packages/carousel/index.ts +16 -0
  281. package/packages/carousel/src/carousel-item.ts +114 -0
  282. package/packages/carousel/src/carousel.ts +449 -0
  283. package/packages/carousel/src/util.ts +21 -0
  284. package/packages/carousel-item/index.ts +16 -0
  285. package/packages/checkbox/index.ts +16 -0
  286. package/packages/checkbox/src/checkbox.ts +176 -0
  287. package/packages/checkbox/src/group.ts +178 -0
  288. package/packages/checkbox-group/index.ts +16 -0
  289. package/packages/components.ts +39 -39
  290. package/packages/date-picker/src/date-picker.ts +3 -0
  291. package/packages/icon-picker/index.ts +16 -0
  292. package/packages/icon-picker/src/icon-picker.ts +711 -0
  293. package/packages/input/index.ts +16 -0
  294. package/packages/input/src/input.ts +2995 -0
  295. package/packages/layout-footer/src/layout-footer.ts +4 -3
  296. package/packages/layout-header/src/layout-header.ts +2 -1
  297. package/packages/optgroup/index.ts +16 -0
  298. package/packages/option/index.ts +16 -0
  299. package/packages/pager/index.ts +16 -0
  300. package/packages/pager/src/pager.ts +743 -0
  301. package/packages/password-input/index.ts +16 -0
  302. package/packages/password-input/src/password-input.ts +427 -0
  303. package/packages/pulldown/src/pulldown.ts +5 -1
  304. package/packages/select/index.ts +16 -0
  305. package/packages/select/src/optgroup.ts +107 -0
  306. package/packages/select/src/option-info.ts +20 -0
  307. package/packages/select/src/option.ts +103 -0
  308. package/packages/select/src/select.ts +1325 -0
  309. package/packages/select/src/util.ts +46 -0
  310. package/packages/tab-pane/index.ts +16 -0
  311. package/packages/tabs/index.ts +16 -0
  312. package/packages/tabs/src/tab-pane.ts +136 -0
  313. package/packages/tabs/src/tabs.ts +630 -0
  314. package/packages/tabs/src/util.ts +21 -0
  315. package/types/components/carousel.d.ts +5 -0
  316. package/types/components/icon-picker.d.ts +4 -0
  317. package/types/components/input.d.ts +9 -1
  318. package/types/components/optgroup.d.ts +10 -4
  319. package/types/components/tabs.d.ts +4 -0
  320. /package/es/icon/style/{iconfont.1725630285930.ttf → iconfont.1725723159302.ttf} +0 -0
  321. /package/es/icon/style/{iconfont.1725630285930.woff → iconfont.1725723159302.woff} +0 -0
  322. /package/es/icon/style/{iconfont.1725630285930.woff2 → iconfont.1725723159302.woff2} +0 -0
  323. /package/es/{iconfont.1725630285930.ttf → iconfont.1725723159302.ttf} +0 -0
  324. /package/es/{iconfont.1725630285930.woff → iconfont.1725723159302.woff} +0 -0
  325. /package/es/{iconfont.1725630285930.woff2 → iconfont.1725723159302.woff2} +0 -0
  326. /package/lib/icon/style/{iconfont.1725630285930.ttf → iconfont.1725723159302.ttf} +0 -0
  327. /package/lib/icon/style/{iconfont.1725630285930.woff → iconfont.1725723159302.woff} +0 -0
  328. /package/lib/icon/style/{iconfont.1725630285930.woff2 → iconfont.1725723159302.woff2} +0 -0
  329. /package/lib/{iconfont.1725630285930.ttf → iconfont.1725723159302.ttf} +0 -0
  330. /package/lib/{iconfont.1725630285930.woff → iconfont.1725723159302.woff} +0 -0
  331. /package/lib/{iconfont.1725630285930.woff2 → iconfont.1725723159302.woff2} +0 -0
@@ -0,0 +1,1269 @@
1
+ import { defineVxeComponent } from '../../ui/src/comp';
2
+ import XEUtils from 'xe-utils';
3
+ import { getConfig, getIcon, getI18n, globalEvents, GLOBAL_EVENT_KEYS, createEvent, globalMixins, renderEmptyElement } from '../../ui';
4
+ import { getEventTargetNode, getAbsolutePos } from '../../ui/src/dom';
5
+ import { getLastZIndex, nextZIndex, getFuncText } from '../../ui/src/utils';
6
+ import VxeInputComponent from '../../input/src/input';
7
+ import { getSlotVNs } from '../../ui/src/vn';
8
+ function isOptionVisible(option) {
9
+ return option.visible !== false;
10
+ }
11
+ function getOptUniqueId() {
12
+ return XEUtils.uniqueId('opt_');
13
+ }
14
+ export default defineVxeComponent({
15
+ name: 'VxeSelect',
16
+ mixins: [
17
+ globalMixins.sizeMixin
18
+ ],
19
+ model: {
20
+ prop: 'value',
21
+ event: 'modelValue'
22
+ },
23
+ props: {
24
+ value: [String, Number, Boolean, Array],
25
+ clearable: Boolean,
26
+ placeholder: String,
27
+ readonly: {
28
+ type: Boolean,
29
+ default: null
30
+ },
31
+ loading: Boolean,
32
+ disabled: {
33
+ type: Boolean,
34
+ default: null
35
+ },
36
+ multiple: Boolean,
37
+ multiCharOverflow: {
38
+ type: [Number, String],
39
+ default: () => getConfig().select.multiCharOverflow
40
+ },
41
+ prefixIcon: String,
42
+ placement: String,
43
+ options: Array,
44
+ optionProps: Object,
45
+ optionGroups: Array,
46
+ optionGroupProps: Object,
47
+ optionConfig: Object,
48
+ className: [String, Function],
49
+ popupClassName: [String, Function],
50
+ max: {
51
+ type: [String, Number],
52
+ default: null
53
+ },
54
+ size: {
55
+ type: String,
56
+ default: () => getConfig().select.size || getConfig().size
57
+ },
58
+ filterable: Boolean,
59
+ filterMethod: Function,
60
+ remote: Boolean,
61
+ remoteMethod: Function,
62
+ emptyText: String,
63
+ transfer: {
64
+ type: Boolean,
65
+ default: null
66
+ },
67
+ // 已废弃,被 option-config.keyField 替换
68
+ optionId: {
69
+ type: String,
70
+ default: () => getConfig().select.optionId
71
+ },
72
+ // 已废弃,被 option-config.useKey 替换
73
+ optionKey: Boolean
74
+ },
75
+ inject: {
76
+ $xeModal: {
77
+ default: null
78
+ },
79
+ $xeDrawer: {
80
+ default: null
81
+ },
82
+ $xeTable: {
83
+ default: null
84
+ },
85
+ $xeForm: {
86
+ default: null
87
+ },
88
+ formItemInfo: {
89
+ from: 'xeFormItemInfo',
90
+ default: null
91
+ }
92
+ },
93
+ provide() {
94
+ const $xeSelect = this;
95
+ return {
96
+ $xeSelect
97
+ };
98
+ },
99
+ data() {
100
+ const xID = XEUtils.uniqueId();
101
+ const reactData = {
102
+ initialized: false,
103
+ staticOptions: [],
104
+ fullGroupList: [],
105
+ fullOptionList: [],
106
+ visibleGroupList: [],
107
+ visibleOptionList: [],
108
+ remoteValueList: [],
109
+ panelIndex: 0,
110
+ panelStyle: {},
111
+ panelPlacement: null,
112
+ currentOption: null,
113
+ currentValue: null,
114
+ triggerFocusPanel: false,
115
+ visiblePanel: false,
116
+ isAniVisible: false,
117
+ isActivated: false,
118
+ searchValue: '',
119
+ searchLoading: false
120
+ };
121
+ const internalData = {
122
+ hpTimeout: undefined
123
+ };
124
+ return {
125
+ xID,
126
+ reactData,
127
+ internalData
128
+ };
129
+ },
130
+ computed: Object.assign(Object.assign({}, {}), { computeFormReadonly() {
131
+ const $xeSelect = this;
132
+ const props = $xeSelect;
133
+ const $xeForm = $xeSelect.$xeForm;
134
+ const { readonly } = props;
135
+ if (readonly === null) {
136
+ if ($xeForm) {
137
+ return $xeForm.readonly;
138
+ }
139
+ return false;
140
+ }
141
+ return readonly;
142
+ },
143
+ computeIsDisabled() {
144
+ const $xeSelect = this;
145
+ const props = $xeSelect;
146
+ const $xeForm = $xeSelect.$xeForm;
147
+ const { disabled } = props;
148
+ if (disabled === null) {
149
+ if ($xeForm) {
150
+ return $xeForm.disabled;
151
+ }
152
+ return false;
153
+ }
154
+ return disabled;
155
+ },
156
+ computeBtnTransfer() {
157
+ const $xeSelect = this;
158
+ const props = $xeSelect;
159
+ const $xeTable = $xeSelect.$xeTable;
160
+ const $xeModal = $xeSelect.$xeModal;
161
+ const $xeDrawer = $xeSelect.$xeDrawer;
162
+ const $xeForm = $xeSelect.$xeForm;
163
+ const { transfer } = props;
164
+ if (transfer === null) {
165
+ const globalTransfer = getConfig().select.transfer;
166
+ if (XEUtils.isBoolean(globalTransfer)) {
167
+ return globalTransfer;
168
+ }
169
+ if ($xeTable || $xeModal || $xeDrawer || $xeForm) {
170
+ return true;
171
+ }
172
+ }
173
+ return transfer;
174
+ },
175
+ computeInpPlaceholder() {
176
+ const $xeSelect = this;
177
+ const props = $xeSelect;
178
+ const { placeholder } = props;
179
+ if (placeholder) {
180
+ return getFuncText(placeholder);
181
+ }
182
+ const globalPlaceholder = getConfig().select.placeholder;
183
+ if (globalPlaceholder) {
184
+ return getFuncText(globalPlaceholder);
185
+ }
186
+ return getI18n('vxe.base.pleaseSelect');
187
+ },
188
+ computePropsOpts() {
189
+ const $xeSelect = this;
190
+ const props = $xeSelect;
191
+ return Object.assign({}, props.optionProps);
192
+ },
193
+ computeGroupPropsOpts() {
194
+ const $xeSelect = this;
195
+ const props = $xeSelect;
196
+ return Object.assign({}, props.optionGroupProps);
197
+ },
198
+ computeLabelField() {
199
+ const $xeSelect = this;
200
+ const propsOpts = $xeSelect.computePropsOpts;
201
+ return propsOpts.label || 'label';
202
+ },
203
+ computeValueField() {
204
+ const $xeSelect = this;
205
+ const propsOpts = $xeSelect.computePropsOpts;
206
+ return propsOpts.value || 'value';
207
+ },
208
+ computeGroupLabelField() {
209
+ const $xeSelect = this;
210
+ const groupPropsOpts = $xeSelect.computeGroupPropsOpts;
211
+ return groupPropsOpts.label || 'label';
212
+ },
213
+ computeGroupOptionsField() {
214
+ const $xeSelect = this;
215
+ const groupPropsOpts = $xeSelect.computeGroupPropsOpts;
216
+ return groupPropsOpts.options || 'options';
217
+ },
218
+ computeIsMaximize() {
219
+ const $xeSelect = this;
220
+ const props = $xeSelect;
221
+ const { value, multiple, max } = props;
222
+ if (multiple && max) {
223
+ return (XEUtils.isArray(value) ? value.length : (XEUtils.eqNull(value) ? 0 : 1)) >= XEUtils.toNumber(max);
224
+ }
225
+ return false;
226
+ },
227
+ computeOptionOpts() {
228
+ const $xeSelect = this;
229
+ const props = $xeSelect;
230
+ return Object.assign({}, getConfig().select.optionConfig, props.optionConfig);
231
+ },
232
+ computeIsGroup() {
233
+ const $xeSelect = this;
234
+ const reactData = $xeSelect.reactData;
235
+ return reactData.fullGroupList.some((item) => item.options && item.options.length);
236
+ },
237
+ computeMultiMaxCharNum() {
238
+ const $xeSelect = this;
239
+ const props = $xeSelect;
240
+ return XEUtils.toNumber(props.multiCharOverflow);
241
+ },
242
+ computeSelectLabel() {
243
+ const $xeSelect = this;
244
+ const props = $xeSelect;
245
+ const { value, multiple, remote } = props;
246
+ const multiMaxCharNum = $xeSelect.computeMultiMaxCharNum;
247
+ if (value && multiple) {
248
+ const vals = XEUtils.isArray(value) ? value : [value];
249
+ if (remote) {
250
+ return vals.map(val => $xeSelect.getRemoteSelectLabel(val)).join(', ');
251
+ }
252
+ return vals.map((val) => {
253
+ const label = $xeSelect.getSelectLabel(val);
254
+ if (multiMaxCharNum > 0 && label.length > multiMaxCharNum) {
255
+ return `${label.substring(0, multiMaxCharNum)}...`;
256
+ }
257
+ return label;
258
+ }).join(', ');
259
+ }
260
+ if (remote) {
261
+ return $xeSelect.getRemoteSelectLabel(value);
262
+ }
263
+ return $xeSelect.getSelectLabel(value);
264
+ } }),
265
+ methods: {
266
+ //
267
+ // Method
268
+ //
269
+ dispatchEvent(type, params, evnt) {
270
+ const $xeSelect = this;
271
+ $xeSelect.$emit(type, createEvent(evnt, { $select: $xeSelect }, params));
272
+ },
273
+ isPanelVisible() {
274
+ const $xeSelect = this;
275
+ const reactData = $xeSelect.reactData;
276
+ return reactData.visiblePanel;
277
+ },
278
+ togglePanel() {
279
+ const $xeSelect = this;
280
+ const reactData = $xeSelect.reactData;
281
+ if (reactData.visiblePanel) {
282
+ $xeSelect.hideOptionPanel();
283
+ }
284
+ else {
285
+ $xeSelect.showOptionPanel();
286
+ }
287
+ return $xeSelect.$nextTick();
288
+ },
289
+ hidePanel() {
290
+ const $xeSelect = this;
291
+ const reactData = $xeSelect.reactData;
292
+ if (reactData.visiblePanel) {
293
+ $xeSelect.hideOptionPanel();
294
+ }
295
+ return $xeSelect.$nextTick();
296
+ },
297
+ showPanel() {
298
+ const $xeSelect = this;
299
+ const reactData = $xeSelect.reactData;
300
+ if (!reactData.visiblePanel) {
301
+ $xeSelect.showOptionPanel();
302
+ }
303
+ return $xeSelect.$nextTick();
304
+ },
305
+ focus() {
306
+ const $xeSelect = this;
307
+ const reactData = $xeSelect.reactData;
308
+ const $input = $xeSelect.$refs.refInput;
309
+ reactData.isActivated = true;
310
+ $input.blur();
311
+ return $xeSelect.$nextTick();
312
+ },
313
+ blur() {
314
+ const $xeSelect = this;
315
+ const reactData = $xeSelect.reactData;
316
+ const $input = $xeSelect.$refs.refInput;
317
+ $input.blur();
318
+ reactData.isActivated = false;
319
+ return $xeSelect.$nextTick();
320
+ },
321
+ callSlot(slotFunc, params) {
322
+ const $xeSelect = this;
323
+ const slots = $xeSelect.$scopedSlots;
324
+ if (slotFunc) {
325
+ if (XEUtils.isString(slotFunc)) {
326
+ slotFunc = slots[slotFunc] || null;
327
+ }
328
+ if (XEUtils.isFunction(slotFunc)) {
329
+ return getSlotVNs(slotFunc(params));
330
+ }
331
+ }
332
+ return [];
333
+ },
334
+ findOption(optionValue) {
335
+ const $xeSelect = this;
336
+ const reactData = $xeSelect.reactData;
337
+ const { fullOptionList, fullGroupList } = reactData;
338
+ const isGroup = $xeSelect.computeIsGroup;
339
+ const valueField = $xeSelect.computeValueField;
340
+ if (isGroup) {
341
+ for (let gIndex = 0; gIndex < fullGroupList.length; gIndex++) {
342
+ const group = fullGroupList[gIndex];
343
+ if (group.options) {
344
+ for (let index = 0; index < group.options.length; index++) {
345
+ const option = group.options[index];
346
+ if (optionValue === option[valueField]) {
347
+ return option;
348
+ }
349
+ }
350
+ }
351
+ }
352
+ }
353
+ return fullOptionList.find((item) => optionValue === item[valueField]);
354
+ },
355
+ findVisibleOption(optionValue) {
356
+ const $xeSelect = this;
357
+ const reactData = $xeSelect.reactData;
358
+ const { visibleOptionList, visibleGroupList } = reactData;
359
+ const isGroup = $xeSelect.computeIsGroup;
360
+ const valueField = $xeSelect.computeValueField;
361
+ if (isGroup) {
362
+ for (let gIndex = 0; gIndex < visibleGroupList.length; gIndex++) {
363
+ const group = visibleGroupList[gIndex];
364
+ if (group.options) {
365
+ for (let index = 0; index < group.options.length; index++) {
366
+ const option = group.options[index];
367
+ if (optionValue === option[valueField]) {
368
+ return option;
369
+ }
370
+ }
371
+ }
372
+ }
373
+ }
374
+ return visibleOptionList.find((item) => optionValue === item[valueField]);
375
+ },
376
+ getRemoteSelectLabel(value) {
377
+ const $xeSelect = this;
378
+ const reactData = $xeSelect.reactData;
379
+ const { remoteValueList } = reactData;
380
+ const labelField = $xeSelect.computeLabelField;
381
+ const remoteItem = remoteValueList.find(item => value === item.key);
382
+ const item = remoteItem ? remoteItem.result : null;
383
+ return XEUtils.toValueString(item ? item[labelField] : value);
384
+ },
385
+ getSelectLabel(value) {
386
+ const $xeSelect = this;
387
+ const labelField = $xeSelect.computeLabelField;
388
+ const item = $xeSelect.findOption(value);
389
+ return XEUtils.toValueString(item ? item[labelField] : value);
390
+ },
391
+ getOptkey() {
392
+ const $xeSelect = this;
393
+ const props = $xeSelect;
394
+ const optionOpts = $xeSelect.computeOptionOpts;
395
+ return optionOpts.keyField || props.optionId || '_X_OPTION_KEY';
396
+ },
397
+ getOptid(option) {
398
+ const $xeSelect = this;
399
+ const optid = option[$xeSelect.getOptkey()];
400
+ return optid ? encodeURIComponent(optid) : '';
401
+ },
402
+ /**
403
+ * 刷新选项,当选项被动态显示/隐藏时可能会用到
404
+ */
405
+ refreshOption() {
406
+ const $xeSelect = this;
407
+ const props = $xeSelect;
408
+ const reactData = $xeSelect.reactData;
409
+ const { filterable, filterMethod } = props;
410
+ const { fullOptionList, fullGroupList, searchValue } = reactData;
411
+ const isGroup = $xeSelect.computeIsGroup;
412
+ const groupLabelField = $xeSelect.computeGroupLabelField;
413
+ const labelField = $xeSelect.computeLabelField;
414
+ const searchStr = `${searchValue || ''}`.toLowerCase();
415
+ if (isGroup) {
416
+ if (filterable && filterMethod) {
417
+ reactData.visibleGroupList = fullGroupList.filter(group => isOptionVisible(group) && filterMethod({ group, option: null, searchValue: searchStr }));
418
+ }
419
+ else if (filterable) {
420
+ reactData.visibleGroupList = fullGroupList.filter(group => isOptionVisible(group) && (!searchStr || `${group[groupLabelField]}`.toLowerCase().indexOf(searchStr) > -1));
421
+ }
422
+ else {
423
+ reactData.visibleGroupList = fullGroupList.filter(isOptionVisible);
424
+ }
425
+ }
426
+ else {
427
+ if (filterable && filterMethod) {
428
+ reactData.visibleOptionList = fullOptionList.filter(option => isOptionVisible(option) && filterMethod({ group: null, option, searchValue: searchStr }));
429
+ }
430
+ else if (filterable) {
431
+ reactData.visibleOptionList = fullOptionList.filter(option => isOptionVisible(option) && (!searchStr || `${option[labelField]}`.toLowerCase().indexOf(searchStr) > -1));
432
+ }
433
+ else {
434
+ reactData.visibleOptionList = fullOptionList.filter(isOptionVisible);
435
+ }
436
+ }
437
+ return $xeSelect.$nextTick();
438
+ },
439
+ cacheItemMap() {
440
+ const $xeSelect = this;
441
+ const reactData = $xeSelect.reactData;
442
+ const { fullOptionList, fullGroupList } = reactData;
443
+ const groupOptionsField = $xeSelect.computeGroupOptionsField;
444
+ const key = $xeSelect.getOptkey();
445
+ const handleOptis = (item) => {
446
+ if (!$xeSelect.getOptid(item)) {
447
+ item[key] = getOptUniqueId();
448
+ }
449
+ };
450
+ if (fullGroupList.length) {
451
+ fullGroupList.forEach((group) => {
452
+ handleOptis(group);
453
+ if (group[groupOptionsField]) {
454
+ group[groupOptionsField].forEach(handleOptis);
455
+ }
456
+ });
457
+ }
458
+ else if (fullOptionList.length) {
459
+ fullOptionList.forEach(handleOptis);
460
+ }
461
+ $xeSelect.refreshOption();
462
+ },
463
+ setCurrentOption(option) {
464
+ const $xeSelect = this;
465
+ const reactData = $xeSelect.reactData;
466
+ const valueField = $xeSelect.computeValueField;
467
+ if (option) {
468
+ reactData.currentOption = option;
469
+ reactData.currentValue = option[valueField];
470
+ }
471
+ },
472
+ scrollToOption(option, isAlignBottom) {
473
+ const $xeSelect = this;
474
+ return $xeSelect.$nextTick().then(() => {
475
+ if (option) {
476
+ const optWrapperElem = $xeSelect.$refs.refOptionWrapper;
477
+ const panelElem = $xeSelect.$refs.refOptionPanel;
478
+ const optElem = panelElem.querySelector(`[optid='${$xeSelect.getOptid(option)}']`);
479
+ if (optWrapperElem && optElem) {
480
+ const wrapperHeight = optWrapperElem.offsetHeight;
481
+ const offsetPadding = 5;
482
+ if (isAlignBottom) {
483
+ if (optElem.offsetTop + optElem.offsetHeight - optWrapperElem.scrollTop > wrapperHeight) {
484
+ optWrapperElem.scrollTop = optElem.offsetTop + optElem.offsetHeight - wrapperHeight;
485
+ }
486
+ }
487
+ else {
488
+ if (optElem.offsetTop + offsetPadding < optWrapperElem.scrollTop || optElem.offsetTop + offsetPadding > optWrapperElem.scrollTop + optWrapperElem.clientHeight) {
489
+ optWrapperElem.scrollTop = optElem.offsetTop - offsetPadding;
490
+ }
491
+ }
492
+ }
493
+ }
494
+ });
495
+ },
496
+ updateZindex() {
497
+ const $xeSelect = this;
498
+ const reactData = $xeSelect.reactData;
499
+ if (reactData.panelIndex < getLastZIndex()) {
500
+ reactData.panelIndex = nextZIndex();
501
+ }
502
+ },
503
+ updatePlacement() {
504
+ const $xeSelect = this;
505
+ const props = $xeSelect;
506
+ const reactData = $xeSelect.reactData;
507
+ return $xeSelect.$nextTick().then(() => {
508
+ const { placement } = props;
509
+ const { panelIndex } = reactData;
510
+ const el = $xeSelect.$refs.refElem;
511
+ const panelElem = $xeSelect.$refs.refOptionPanel;
512
+ const btnTransfer = $xeSelect.computeBtnTransfer;
513
+ if (panelElem && el) {
514
+ const targetHeight = el.offsetHeight;
515
+ const targetWidth = el.offsetWidth;
516
+ const panelHeight = panelElem.offsetHeight;
517
+ const panelWidth = panelElem.offsetWidth;
518
+ const marginSize = 5;
519
+ const panelStyle = {
520
+ zIndex: panelIndex
521
+ };
522
+ const { boundingTop, boundingLeft, visibleHeight, visibleWidth } = getAbsolutePos(el);
523
+ let panelPlacement = 'bottom';
524
+ if (btnTransfer) {
525
+ let left = boundingLeft;
526
+ let top = boundingTop + targetHeight;
527
+ if (placement === 'top') {
528
+ panelPlacement = 'top';
529
+ top = boundingTop - panelHeight;
530
+ }
531
+ else if (!placement) {
532
+ // 如果下面不够放,则向上
533
+ if (top + panelHeight + marginSize > visibleHeight) {
534
+ panelPlacement = 'top';
535
+ top = boundingTop - panelHeight;
536
+ }
537
+ // 如果上面不够放,则向下(优先)
538
+ if (top < marginSize) {
539
+ panelPlacement = 'bottom';
540
+ top = boundingTop + targetHeight;
541
+ }
542
+ }
543
+ // 如果溢出右边
544
+ if (left + panelWidth + marginSize > visibleWidth) {
545
+ left -= left + panelWidth + marginSize - visibleWidth;
546
+ }
547
+ // 如果溢出左边
548
+ if (left < marginSize) {
549
+ left = marginSize;
550
+ }
551
+ Object.assign(panelStyle, {
552
+ left: `${left}px`,
553
+ top: `${top}px`,
554
+ minWidth: `${targetWidth}px`
555
+ });
556
+ }
557
+ else {
558
+ if (placement === 'top') {
559
+ panelPlacement = 'top';
560
+ panelStyle.bottom = `${targetHeight}px`;
561
+ }
562
+ else if (!placement) {
563
+ // 如果下面不够放,则向上
564
+ if (boundingTop + targetHeight + panelHeight > visibleHeight) {
565
+ // 如果上面不够放,则向下(优先)
566
+ if (boundingTop - targetHeight - panelHeight > marginSize) {
567
+ panelPlacement = 'top';
568
+ panelStyle.bottom = `${targetHeight}px`;
569
+ }
570
+ }
571
+ }
572
+ }
573
+ reactData.panelStyle = panelStyle;
574
+ reactData.panelPlacement = panelPlacement;
575
+ return $xeSelect.$nextTick();
576
+ }
577
+ });
578
+ },
579
+ showOptionPanel() {
580
+ const $xeSelect = this;
581
+ const props = $xeSelect;
582
+ const reactData = $xeSelect.reactData;
583
+ const internalData = $xeSelect.internalData;
584
+ const { loading, filterable } = props;
585
+ const { hpTimeout } = internalData;
586
+ const isDisabled = $xeSelect.computeIsDisabled;
587
+ if (!loading && !isDisabled) {
588
+ if (hpTimeout) {
589
+ clearTimeout(hpTimeout);
590
+ internalData.hpTimeout = undefined;
591
+ }
592
+ if (!reactData.initialized) {
593
+ reactData.initialized = true;
594
+ }
595
+ reactData.isActivated = true;
596
+ reactData.isAniVisible = true;
597
+ if (filterable) {
598
+ $xeSelect.refreshOption();
599
+ }
600
+ setTimeout(() => {
601
+ const { value } = props;
602
+ const currOption = $xeSelect.findOption(XEUtils.isArray(value) ? value[0] : value);
603
+ reactData.visiblePanel = true;
604
+ if (currOption) {
605
+ $xeSelect.setCurrentOption(currOption);
606
+ $xeSelect.scrollToOption(currOption);
607
+ }
608
+ $xeSelect.handleFocusSearch();
609
+ }, 10);
610
+ $xeSelect.updateZindex();
611
+ $xeSelect.updatePlacement();
612
+ }
613
+ },
614
+ hideOptionPanel() {
615
+ const $xeSelect = this;
616
+ const reactData = $xeSelect.reactData;
617
+ const internalData = $xeSelect.internalData;
618
+ reactData.searchValue = '';
619
+ reactData.searchLoading = false;
620
+ reactData.visiblePanel = false;
621
+ internalData.hpTimeout = window.setTimeout(() => {
622
+ reactData.isAniVisible = false;
623
+ }, 350);
624
+ },
625
+ changeEvent(evnt, selectValue) {
626
+ const $xeSelect = this;
627
+ const props = $xeSelect;
628
+ const $xeForm = $xeSelect.$xeForm;
629
+ const formItemInfo = $xeSelect.formItemInfo;
630
+ if (selectValue !== props.value) {
631
+ $xeSelect.$emit('modelValue', selectValue);
632
+ $xeSelect.dispatchEvent('change', { value: selectValue }, evnt);
633
+ // 自动更新校验状态
634
+ if ($xeForm && formItemInfo) {
635
+ $xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, selectValue);
636
+ }
637
+ }
638
+ },
639
+ clearValueEvent(evnt, selectValue) {
640
+ const $xeSelect = this;
641
+ const reactData = $xeSelect.reactData;
642
+ reactData.remoteValueList = [];
643
+ $xeSelect.changeEvent(evnt, selectValue);
644
+ $xeSelect.dispatchEvent('clear', { value: selectValue }, evnt);
645
+ },
646
+ clearEvent(params, evnt) {
647
+ const $xeSelect = this;
648
+ $xeSelect.clearValueEvent(evnt, null);
649
+ $xeSelect.hideOptionPanel();
650
+ },
651
+ changeOptionEvent(evnt, selectValue, option) {
652
+ const $xeSelect = this;
653
+ const props = $xeSelect;
654
+ const reactData = $xeSelect.reactData;
655
+ const { value, multiple } = props;
656
+ const { remoteValueList } = reactData;
657
+ if (multiple) {
658
+ let multipleValue = [];
659
+ const selectVals = XEUtils.eqNull(value) ? [] : (XEUtils.isArray(value) ? value : [value]);
660
+ const index = XEUtils.findIndexOf(selectVals, val => val === selectValue);
661
+ if (index === -1) {
662
+ multipleValue = selectVals.concat([selectValue]);
663
+ }
664
+ else {
665
+ multipleValue = selectVals.filter((val) => val !== selectValue);
666
+ }
667
+ const remoteItem = remoteValueList.find(item => item.key === selectValue);
668
+ if (remoteItem) {
669
+ remoteItem.result = option;
670
+ }
671
+ else {
672
+ remoteValueList.push({ key: selectValue, result: option });
673
+ }
674
+ $xeSelect.changeEvent(evnt, multipleValue);
675
+ }
676
+ else {
677
+ reactData.remoteValueList = [{ key: selectValue, result: option }];
678
+ $xeSelect.changeEvent(evnt, selectValue);
679
+ $xeSelect.hideOptionPanel();
680
+ }
681
+ },
682
+ handleGlobalMousewheelEvent(evnt) {
683
+ const $xeSelect = this;
684
+ const reactData = $xeSelect.reactData;
685
+ const { visiblePanel } = reactData;
686
+ const isDisabled = $xeSelect.computeIsDisabled;
687
+ if (!isDisabled) {
688
+ if (visiblePanel) {
689
+ const panelElem = $xeSelect.$refs.refOptionPanel;
690
+ if (getEventTargetNode(evnt, panelElem).flag) {
691
+ $xeSelect.updatePlacement();
692
+ }
693
+ else {
694
+ $xeSelect.hideOptionPanel();
695
+ }
696
+ }
697
+ }
698
+ },
699
+ handleGlobalMousedownEvent(evnt) {
700
+ const $xeSelect = this;
701
+ const reactData = $xeSelect.reactData;
702
+ const { visiblePanel } = reactData;
703
+ const isDisabled = $xeSelect.computeIsDisabled;
704
+ if (!isDisabled) {
705
+ const el = $xeSelect.$refs.refElem;
706
+ const panelElem = $xeSelect.$refs.refOptionPanel;
707
+ reactData.isActivated = getEventTargetNode(evnt, el).flag || getEventTargetNode(evnt, panelElem).flag;
708
+ if (visiblePanel && !reactData.isActivated) {
709
+ $xeSelect.hideOptionPanel();
710
+ }
711
+ }
712
+ },
713
+ findOffsetOption(optionValue, isUpArrow) {
714
+ const $xeSelect = this;
715
+ const reactData = $xeSelect.reactData;
716
+ const { visibleOptionList, visibleGroupList } = reactData;
717
+ const isGroup = $xeSelect.computeIsGroup;
718
+ const valueField = $xeSelect.computeValueField;
719
+ const groupOptionsField = $xeSelect.computeGroupOptionsField;
720
+ let firstOption;
721
+ let prevOption;
722
+ let nextOption;
723
+ let currOption;
724
+ if (isGroup) {
725
+ for (let gIndex = 0; gIndex < visibleGroupList.length; gIndex++) {
726
+ const group = visibleGroupList[gIndex];
727
+ const groupOptionList = group[groupOptionsField];
728
+ const isGroupDisabled = group.disabled;
729
+ if (groupOptionList) {
730
+ for (let index = 0; index < groupOptionList.length; index++) {
731
+ const option = groupOptionList[index];
732
+ const isVisible = isOptionVisible(option);
733
+ const isDisabled = isGroupDisabled || option.disabled;
734
+ if (!firstOption && !isDisabled) {
735
+ firstOption = option;
736
+ }
737
+ if (currOption) {
738
+ if (isVisible && !isDisabled) {
739
+ nextOption = option;
740
+ if (!isUpArrow) {
741
+ return { offsetOption: nextOption };
742
+ }
743
+ }
744
+ }
745
+ if (optionValue === option[valueField]) {
746
+ currOption = option;
747
+ if (isUpArrow) {
748
+ return { offsetOption: prevOption };
749
+ }
750
+ }
751
+ else {
752
+ if (isVisible && !isDisabled) {
753
+ prevOption = option;
754
+ }
755
+ }
756
+ }
757
+ }
758
+ }
759
+ }
760
+ else {
761
+ for (let index = 0; index < visibleOptionList.length; index++) {
762
+ const option = visibleOptionList[index];
763
+ const isDisabled = option.disabled;
764
+ if (!firstOption && !isDisabled) {
765
+ firstOption = option;
766
+ }
767
+ if (currOption) {
768
+ if (!isDisabled) {
769
+ nextOption = option;
770
+ if (!isUpArrow) {
771
+ return { offsetOption: nextOption };
772
+ }
773
+ }
774
+ }
775
+ if (optionValue === option[valueField]) {
776
+ currOption = option;
777
+ if (isUpArrow) {
778
+ return { offsetOption: prevOption };
779
+ }
780
+ }
781
+ else {
782
+ if (!isDisabled) {
783
+ prevOption = option;
784
+ }
785
+ }
786
+ }
787
+ }
788
+ return { firstOption };
789
+ },
790
+ handleGlobalKeydownEvent(evnt) {
791
+ const $xeSelect = this;
792
+ const props = $xeSelect;
793
+ const reactData = $xeSelect.reactData;
794
+ const { clearable } = props;
795
+ const { visiblePanel, currentValue, currentOption } = reactData;
796
+ const isDisabled = $xeSelect.computeIsDisabled;
797
+ if (!isDisabled) {
798
+ const isTab = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.TAB);
799
+ const isEnter = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ENTER);
800
+ const isEsc = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ESCAPE);
801
+ const isUpArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_UP);
802
+ const isDwArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_DOWN);
803
+ const isDel = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.DELETE);
804
+ const isSpacebar = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.SPACEBAR);
805
+ if (isTab) {
806
+ reactData.isActivated = false;
807
+ }
808
+ if (visiblePanel) {
809
+ if (isEsc || isTab) {
810
+ $xeSelect.hideOptionPanel();
811
+ }
812
+ else if (isEnter) {
813
+ evnt.preventDefault();
814
+ evnt.stopPropagation();
815
+ $xeSelect.changeOptionEvent(evnt, currentValue, currentOption);
816
+ }
817
+ else if (isUpArrow || isDwArrow) {
818
+ evnt.preventDefault();
819
+ let { firstOption, offsetOption } = $xeSelect.findOffsetOption(currentValue, isUpArrow);
820
+ if (!offsetOption && !$xeSelect.findVisibleOption(currentValue)) {
821
+ offsetOption = firstOption;
822
+ }
823
+ $xeSelect.setCurrentOption(offsetOption);
824
+ $xeSelect.scrollToOption(offsetOption, isDwArrow);
825
+ }
826
+ else if (isSpacebar) {
827
+ evnt.preventDefault();
828
+ }
829
+ }
830
+ else if ((isUpArrow || isDwArrow || isEnter || isSpacebar) && reactData.isActivated) {
831
+ evnt.preventDefault();
832
+ $xeSelect.showOptionPanel();
833
+ }
834
+ if (reactData.isActivated) {
835
+ if (isDel && clearable) {
836
+ $xeSelect.clearValueEvent(evnt, null);
837
+ }
838
+ }
839
+ }
840
+ },
841
+ handleGlobalBlurEvent() {
842
+ const $xeSelect = this;
843
+ $xeSelect.hideOptionPanel();
844
+ },
845
+ handleFocusSearch() {
846
+ const $xeSelect = this;
847
+ const props = $xeSelect;
848
+ if (props.filterable) {
849
+ $xeSelect.$nextTick(() => {
850
+ const inpSearch = $xeSelect.$refs.refInpSearch;
851
+ if (inpSearch) {
852
+ inpSearch.focus();
853
+ }
854
+ });
855
+ }
856
+ },
857
+ focusEvent(evnt) {
858
+ const $xeSelect = this;
859
+ const reactData = $xeSelect.reactData;
860
+ const isDisabled = $xeSelect.computeIsDisabled;
861
+ if (!isDisabled) {
862
+ if (!reactData.visiblePanel) {
863
+ reactData.triggerFocusPanel = true;
864
+ $xeSelect.showOptionPanel();
865
+ setTimeout(() => {
866
+ reactData.triggerFocusPanel = false;
867
+ }, 150);
868
+ }
869
+ }
870
+ $xeSelect.dispatchEvent('focus', {}, evnt);
871
+ },
872
+ clickEvent(evnt) {
873
+ const $xeSelect = this;
874
+ $xeSelect.togglePanelEvent(evnt);
875
+ $xeSelect.dispatchEvent('click', {}, evnt);
876
+ },
877
+ blurEvent(evnt) {
878
+ const $xeSelect = this;
879
+ const reactData = $xeSelect.reactData;
880
+ reactData.isActivated = false;
881
+ $xeSelect.dispatchEvent('blur', {}, evnt);
882
+ },
883
+ modelSearchEvent(value) {
884
+ const $xeSelect = this;
885
+ const reactData = $xeSelect.reactData;
886
+ reactData.searchValue = value;
887
+ },
888
+ focusSearchEvent() {
889
+ const $xeSelect = this;
890
+ const reactData = $xeSelect.reactData;
891
+ reactData.isActivated = true;
892
+ },
893
+ handleSearchEvent() {
894
+ const $xeSelect = this;
895
+ const props = $xeSelect;
896
+ const reactData = $xeSelect.reactData;
897
+ const { remote, remoteMethod } = props;
898
+ const { searchValue } = reactData;
899
+ if (remote && remoteMethod) {
900
+ reactData.searchLoading = true;
901
+ Promise.resolve(remoteMethod({ searchValue })).then(() => $xeSelect.$nextTick())
902
+ .catch(() => $xeSelect.$nextTick())
903
+ .finally(() => {
904
+ reactData.searchLoading = false;
905
+ $xeSelect.refreshOption();
906
+ });
907
+ }
908
+ else {
909
+ $xeSelect.refreshOption();
910
+ }
911
+ },
912
+ triggerSearchEvent: XEUtils.debounce(function () {
913
+ const $xeSelect = this;
914
+ $xeSelect.handleSearchEvent();
915
+ }, 350, { trailing: true }),
916
+ togglePanelEvent(params) {
917
+ const $xeSelect = this;
918
+ const reactData = $xeSelect.reactData;
919
+ const { $event } = params;
920
+ $event.preventDefault();
921
+ if (reactData.triggerFocusPanel) {
922
+ reactData.triggerFocusPanel = false;
923
+ }
924
+ else {
925
+ if (reactData.visiblePanel) {
926
+ $xeSelect.hideOptionPanel();
927
+ }
928
+ else {
929
+ $xeSelect.showOptionPanel();
930
+ }
931
+ }
932
+ },
933
+ checkOptionDisabled(isSelected, option, group) {
934
+ const $xeSelect = this;
935
+ if (option.disabled) {
936
+ return true;
937
+ }
938
+ if (group && group.disabled) {
939
+ return true;
940
+ }
941
+ const isMaximize = $xeSelect.computeIsMaximize;
942
+ if (isMaximize && !isSelected) {
943
+ return true;
944
+ }
945
+ return false;
946
+ },
947
+ //
948
+ // Render
949
+ //
950
+ renderOption(h, list, group) {
951
+ const $xeSelect = this;
952
+ const props = $xeSelect;
953
+ const slots = $xeSelect.$scopedSlots;
954
+ const reactData = $xeSelect.reactData;
955
+ const { optionKey, value } = props;
956
+ const { currentValue } = reactData;
957
+ const optionOpts = $xeSelect.computeOptionOpts;
958
+ const labelField = $xeSelect.computeLabelField;
959
+ const valueField = $xeSelect.computeValueField;
960
+ const isGroup = $xeSelect.computeIsGroup;
961
+ const { useKey } = optionOpts;
962
+ const optionSlot = slots.option;
963
+ return list.map((option, cIndex) => {
964
+ const { slots, className } = option;
965
+ const optionValue = option[valueField];
966
+ const isSelected = XEUtils.isArray(value) ? value.indexOf(optionValue) > -1 : value === optionValue;
967
+ const isVisible = !isGroup || isOptionVisible(option);
968
+ const isDisabled = $xeSelect.checkOptionDisabled(isSelected, option, group);
969
+ const optid = $xeSelect.getOptid(option);
970
+ const defaultSlot = slots ? slots.default : null;
971
+ const optParams = { option, group: null, $select: $xeSelect };
972
+ return isVisible
973
+ ? h('div', {
974
+ key: useKey || optionKey ? optid : cIndex,
975
+ class: ['vxe-select-option', className ? (XEUtils.isFunction(className) ? className(optParams) : className) : '', {
976
+ 'is--disabled': isDisabled,
977
+ 'is--selected': isSelected,
978
+ 'is--hover': currentValue === optionValue
979
+ }],
980
+ attrs: {
981
+ optid: optid
982
+ },
983
+ on: {
984
+ mousedown: (evnt) => {
985
+ const isLeftBtn = evnt.button === 0;
986
+ if (isLeftBtn) {
987
+ evnt.stopPropagation();
988
+ }
989
+ },
990
+ click: (evnt) => {
991
+ if (!isDisabled) {
992
+ $xeSelect.changeOptionEvent(evnt, optionValue, option);
993
+ }
994
+ },
995
+ mouseenter: () => {
996
+ if (!isDisabled) {
997
+ $xeSelect.setCurrentOption(option);
998
+ }
999
+ }
1000
+ }
1001
+ }, optionSlot ? $xeSelect.callSlot(optionSlot, optParams) : (defaultSlot ? $xeSelect.callSlot(defaultSlot, optParams) : getFuncText(option[labelField])))
1002
+ : renderEmptyElement($xeSelect);
1003
+ });
1004
+ },
1005
+ renderOptgroup(h) {
1006
+ const $xeSelect = this;
1007
+ const props = $xeSelect;
1008
+ const slots = $xeSelect.$scopedSlots;
1009
+ const reactData = $xeSelect.reactData;
1010
+ const { optionKey } = props;
1011
+ const { visibleGroupList } = reactData;
1012
+ const optionOpts = $xeSelect.computeOptionOpts;
1013
+ const groupLabelField = $xeSelect.computeGroupLabelField;
1014
+ const groupOptionsField = $xeSelect.computeGroupOptionsField;
1015
+ const { useKey } = optionOpts;
1016
+ const optionSlot = slots.option;
1017
+ return visibleGroupList.map((group, gIndex) => {
1018
+ const { slots, className } = group;
1019
+ const optid = $xeSelect.getOptid(group);
1020
+ const isGroupDisabled = group.disabled;
1021
+ const defaultSlot = slots ? slots.default : null;
1022
+ const optParams = { option: group, group, $select: $xeSelect };
1023
+ return h('div', {
1024
+ key: useKey || optionKey ? optid : gIndex,
1025
+ class: ['vxe-optgroup', className ? (XEUtils.isFunction(className) ? className(optParams) : className) : '', {
1026
+ 'is--disabled': isGroupDisabled
1027
+ }],
1028
+ attrs: {
1029
+ optid: optid
1030
+ }
1031
+ }, [
1032
+ h('div', {
1033
+ class: 'vxe-optgroup--title'
1034
+ }, optionSlot ? $xeSelect.callSlot(optionSlot, optParams) : (defaultSlot ? $xeSelect.callSlot(defaultSlot, optParams) : getFuncText(group[groupLabelField]))),
1035
+ h('div', {
1036
+ class: 'vxe-optgroup--wrapper'
1037
+ }, $xeSelect.renderOption(h, group[groupOptionsField] || [], group))
1038
+ ]);
1039
+ });
1040
+ },
1041
+ renderOpts(h) {
1042
+ const $xeSelect = this;
1043
+ const props = $xeSelect;
1044
+ const reactData = $xeSelect.reactData;
1045
+ const { visibleGroupList, visibleOptionList, searchLoading } = reactData;
1046
+ const isGroup = $xeSelect.computeIsGroup;
1047
+ if (searchLoading) {
1048
+ return [
1049
+ h('div', {
1050
+ class: 'vxe-select--search-loading'
1051
+ }, [
1052
+ h('i', {
1053
+ class: ['vxe-select--search-icon', getIcon().SELECT_LOADED]
1054
+ }),
1055
+ h('span', {
1056
+ class: 'vxe-select--search-text'
1057
+ }, getI18n('vxe.select.loadingText'))
1058
+ ])
1059
+ ];
1060
+ }
1061
+ if (isGroup) {
1062
+ if (visibleGroupList.length) {
1063
+ return $xeSelect.renderOptgroup(h);
1064
+ }
1065
+ }
1066
+ else {
1067
+ if (visibleOptionList.length) {
1068
+ return $xeSelect.renderOption(h, visibleOptionList);
1069
+ }
1070
+ }
1071
+ return [
1072
+ h('div', {
1073
+ class: 'vxe-select--empty-placeholder'
1074
+ }, props.emptyText || getI18n('vxe.select.emptyText'))
1075
+ ];
1076
+ },
1077
+ renderVN(h) {
1078
+ const $xeSelect = this;
1079
+ const props = $xeSelect;
1080
+ const slots = $xeSelect.$scopedSlots;
1081
+ const reactData = $xeSelect.reactData;
1082
+ const { className, popupClassName, loading, filterable } = props;
1083
+ const { initialized, isActivated, visiblePanel } = reactData;
1084
+ const vSize = $xeSelect.computeSize;
1085
+ const isDisabled = $xeSelect.computeIsDisabled;
1086
+ const selectLabel = $xeSelect.computeSelectLabel;
1087
+ const btnTransfer = $xeSelect.computeBtnTransfer;
1088
+ const formReadonly = $xeSelect.computeFormReadonly;
1089
+ const inpPlaceholder = $xeSelect.computeInpPlaceholder;
1090
+ const defaultSlot = slots.default;
1091
+ const headerSlot = slots.header;
1092
+ const footerSlot = slots.footer;
1093
+ const prefixSlot = slots.prefix;
1094
+ if (formReadonly) {
1095
+ return h('div', {
1096
+ ref: 'refElem',
1097
+ class: ['vxe-select--readonly', className]
1098
+ }, [
1099
+ h('div', {
1100
+ class: 'vxe-select-slots',
1101
+ ref: 'hideOption'
1102
+ }, defaultSlot ? defaultSlot({}) : []),
1103
+ h('span', {
1104
+ class: 'vxe-select-label'
1105
+ }, [selectLabel])
1106
+ ]);
1107
+ }
1108
+ return h('div', {
1109
+ ref: 'refElem',
1110
+ class: ['vxe-select', className ? (XEUtils.isFunction(className) ? className({ $select: $xeSelect }) : className) : '', {
1111
+ [`size--${vSize}`]: vSize,
1112
+ 'is--visible': visiblePanel,
1113
+ 'is--disabled': isDisabled,
1114
+ 'is--filter': filterable,
1115
+ 'is--loading': loading,
1116
+ 'is--active': isActivated
1117
+ }]
1118
+ }, [
1119
+ h('div', {
1120
+ class: 'vxe-select-slots',
1121
+ ref: 'hideOption'
1122
+ }, defaultSlot ? defaultSlot({}) : []),
1123
+ h(VxeInputComponent, {
1124
+ ref: 'refInput',
1125
+ props: {
1126
+ clearable: props.clearable,
1127
+ placeholder: inpPlaceholder,
1128
+ readonly: true,
1129
+ disabled: isDisabled,
1130
+ type: 'text',
1131
+ prefixIcon: props.prefixIcon,
1132
+ suffixIcon: loading ? getIcon().SELECT_LOADED : (visiblePanel ? getIcon().SELECT_OPEN : getIcon().SELECT_CLOSE),
1133
+ value: selectLabel
1134
+ },
1135
+ on: {
1136
+ clear: $xeSelect.clearEvent,
1137
+ click: $xeSelect.clickEvent,
1138
+ focus: $xeSelect.focusEvent,
1139
+ blur: $xeSelect.blurEvent,
1140
+ suffixClick: $xeSelect.togglePanelEvent
1141
+ },
1142
+ scopedSlots: prefixSlot
1143
+ ? {
1144
+ prefix: () => prefixSlot({})
1145
+ }
1146
+ : {}
1147
+ }),
1148
+ h('div', {
1149
+ ref: 'refOptionPanel',
1150
+ class: ['vxe-table--ignore-clear vxe-select--panel', popupClassName ? (XEUtils.isFunction(popupClassName) ? popupClassName({ $select: $xeSelect }) : popupClassName) : '', {
1151
+ [`size--${vSize}`]: vSize,
1152
+ 'is--transfer': btnTransfer,
1153
+ 'ani--leave': !loading && reactData.isAniVisible,
1154
+ 'ani--enter': !loading && visiblePanel
1155
+ }],
1156
+ attrs: {
1157
+ placement: reactData.panelPlacement
1158
+ },
1159
+ style: reactData.panelStyle
1160
+ }, initialized
1161
+ ? [
1162
+ filterable
1163
+ ? h('div', {
1164
+ class: 'vxe-select--panel-search'
1165
+ }, [
1166
+ h(VxeInputComponent, {
1167
+ ref: 'refInpSearch',
1168
+ class: 'vxe-select-search--input',
1169
+ props: {
1170
+ value: reactData.searchValue,
1171
+ clearable: true,
1172
+ placeholder: getI18n('vxe.select.search'),
1173
+ prefixIcon: getIcon().INPUT_SEARCH
1174
+ },
1175
+ on: {
1176
+ modelValue: $xeSelect.modelSearchEvent,
1177
+ focus: $xeSelect.focusSearchEvent,
1178
+ change: $xeSelect.triggerSearchEvent,
1179
+ search: $xeSelect.triggerSearchEvent
1180
+ }
1181
+ })
1182
+ ])
1183
+ : renderEmptyElement($xeSelect),
1184
+ h('div', {
1185
+ class: 'vxe-select--panel-wrapper'
1186
+ }, [
1187
+ headerSlot
1188
+ ? h('div', {
1189
+ class: 'vxe-select--panel-header'
1190
+ }, headerSlot({}))
1191
+ : renderEmptyElement($xeSelect),
1192
+ h('div', {
1193
+ class: 'vxe-select--panel-body'
1194
+ }, [
1195
+ h('div', {
1196
+ ref: 'refOptionWrapper',
1197
+ class: 'vxe-select-option--wrapper'
1198
+ }, $xeSelect.renderOpts(h))
1199
+ ]),
1200
+ footerSlot
1201
+ ? h('div', {
1202
+ class: 'vxe-select--panel-footer'
1203
+ }, footerSlot({}))
1204
+ : renderEmptyElement($xeSelect)
1205
+ ])
1206
+ ]
1207
+ : [])
1208
+ ]);
1209
+ }
1210
+ },
1211
+ watch: {
1212
+ 'reactData.staticOptions'(val) {
1213
+ const $xeSelect = this;
1214
+ const reactData = $xeSelect.reactData;
1215
+ if (val.some((item) => item.options && item.options.length)) {
1216
+ reactData.fullOptionList = [];
1217
+ reactData.fullGroupList = val;
1218
+ }
1219
+ else {
1220
+ reactData.fullGroupList = [];
1221
+ reactData.fullOptionList = val || [];
1222
+ }
1223
+ $xeSelect.cacheItemMap();
1224
+ },
1225
+ options(val) {
1226
+ const $xeSelect = this;
1227
+ const reactData = $xeSelect.reactData;
1228
+ reactData.fullGroupList = [];
1229
+ reactData.fullOptionList = val || [];
1230
+ $xeSelect.cacheItemMap();
1231
+ },
1232
+ optionGroups(val) {
1233
+ const $xeSelect = this;
1234
+ const reactData = $xeSelect.reactData;
1235
+ reactData.fullOptionList = [];
1236
+ reactData.fullGroupList = val || [];
1237
+ $xeSelect.cacheItemMap();
1238
+ }
1239
+ },
1240
+ mounted() {
1241
+ const $xeSelect = this;
1242
+ const props = $xeSelect;
1243
+ const reactData = $xeSelect.reactData;
1244
+ $xeSelect.$nextTick(() => {
1245
+ const { options, optionGroups } = props;
1246
+ if (optionGroups) {
1247
+ reactData.fullGroupList = optionGroups;
1248
+ }
1249
+ else if (options) {
1250
+ reactData.fullOptionList = options;
1251
+ }
1252
+ $xeSelect.cacheItemMap();
1253
+ });
1254
+ globalEvents.on($xeSelect, 'mousewheel', $xeSelect.handleGlobalMousewheelEvent);
1255
+ globalEvents.on($xeSelect, 'mousedown', $xeSelect.handleGlobalMousedownEvent);
1256
+ globalEvents.on($xeSelect, 'keydown', $xeSelect.handleGlobalKeydownEvent);
1257
+ globalEvents.on($xeSelect, 'blur', $xeSelect.handleGlobalBlurEvent);
1258
+ },
1259
+ beforeDestroy() {
1260
+ const $xeSelect = this;
1261
+ globalEvents.off($xeSelect, 'mousewheel');
1262
+ globalEvents.off($xeSelect, 'mousedown');
1263
+ globalEvents.off($xeSelect, 'keydown');
1264
+ globalEvents.off($xeSelect, 'blur');
1265
+ },
1266
+ render(h) {
1267
+ return this.renderVN(h);
1268
+ }
1269
+ });