vxe-pc-ui 0.0.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (714) hide show
  1. package/es/anchor/src/anchor.js +1 -1
  2. package/es/anchor-link/index.js +1 -1
  3. package/es/{button-group → button}/src/button-group.js +2 -2
  4. package/es/button/src/button.js +3 -3
  5. package/es/button/style.css +17 -17
  6. package/es/button/style.min.css +1 -1
  7. package/es/button-group/index.js +1 -1
  8. package/es/checkbox/index.js +10 -0
  9. package/es/checkbox/src/checkbox.js +116 -0
  10. package/es/checkbox/src/group.js +108 -0
  11. package/es/checkbox/style.css +107 -0
  12. package/es/checkbox/style.min.css +1 -0
  13. package/es/checkbox-group/index.js +10 -0
  14. package/es/col/index.js +1 -1
  15. package/es/components.js +98 -35
  16. package/es/dynamics/index.js +27 -0
  17. package/es/form/index.js +8 -0
  18. package/es/form/src/form-config-item.js +178 -0
  19. package/es/form/src/form-gather.js +47 -0
  20. package/es/form/src/form-item.js +228 -0
  21. package/es/form/src/form.js +665 -0
  22. package/es/form/src/itemInfo.js +39 -0
  23. package/es/form/src/render.js +68 -0
  24. package/es/form/src/util.js +65 -0
  25. package/es/form/style.css +321 -0
  26. package/es/form/style.min.css +1 -0
  27. package/es/form-design/index.js +8 -0
  28. package/es/form-design/src/form-design.js +79 -0
  29. package/es/form-design/src/setting.js +12 -0
  30. package/es/form-design/src/util.js +8 -0
  31. package/es/form-design/src/view.js +113 -0
  32. package/es/form-design/src/widget.js +104 -0
  33. package/es/form-design/style.css +97 -0
  34. package/es/form-design/style.min.css +1 -0
  35. package/es/form-gather/index.js +8 -0
  36. package/es/form-item/index.js +8 -0
  37. package/es/icon/style.css +540 -1
  38. package/es/icon/style.min.css +1 -1
  39. package/es/input/index.js +10 -0
  40. package/es/input/src/date.js +41 -0
  41. package/es/input/src/input.js +2333 -0
  42. package/es/input/src/number.js +10 -0
  43. package/es/input/style.css +1000 -0
  44. package/es/input/style.min.css +1 -0
  45. package/es/layout-aside/style.css +1 -0
  46. package/es/layout-aside/style.min.css +1 -1
  47. package/es/layout-body/style.css +1 -0
  48. package/es/layout-body/style.min.css +1 -1
  49. package/es/layout-footer/style.css +1 -0
  50. package/es/layout-footer/style.min.css +1 -1
  51. package/es/layout-header/style.css +1 -0
  52. package/es/layout-header/style.min.css +1 -1
  53. package/es/list-design/index.js +8 -0
  54. package/es/{design/src/design.js → list-design/src/list-design.js} +7 -7
  55. package/es/loading/index.js +8 -0
  56. package/es/loading/src/loading.js +53 -0
  57. package/es/loading/style.css +75 -0
  58. package/es/loading/style.min.css +1 -0
  59. package/es/modal/index.js +96 -0
  60. package/es/modal/src/modal.js +876 -0
  61. package/es/modal/style.css +323 -0
  62. package/es/modal/style.min.css +1 -0
  63. package/es/optgroup/index.js +10 -0
  64. package/es/optgroup/style.css +0 -0
  65. package/es/optgroup/style.min.css +0 -0
  66. package/es/option/index.js +10 -0
  67. package/es/option/style.css +0 -0
  68. package/es/option/style.min.css +0 -0
  69. package/es/pager/index.js +10 -0
  70. package/es/pager/src/pager.js +539 -0
  71. package/es/pager/style.css +319 -0
  72. package/es/pager/style.min.css +1 -0
  73. package/es/pulldown/index.js +10 -0
  74. package/es/pulldown/src/pulldown.js +328 -0
  75. package/es/pulldown/style.css +57 -0
  76. package/es/pulldown/style.min.css +1 -0
  77. package/es/radio/index.js +10 -0
  78. package/es/radio/src/button.js +113 -0
  79. package/es/radio/src/group.js +93 -0
  80. package/es/radio/src/radio.js +118 -0
  81. package/es/radio/style.css +143 -0
  82. package/es/radio/style.min.css +1 -0
  83. package/es/radio-button/index.js +10 -0
  84. package/es/radio-button/style.css +0 -0
  85. package/es/radio-button/style.min.css +0 -0
  86. package/es/radio-group/index.js +10 -0
  87. package/es/radio-group/style.css +0 -0
  88. package/es/radio-group/style.min.css +0 -0
  89. package/es/select/index.js +10 -0
  90. package/es/select/src/optgroup.js +31 -0
  91. package/es/select/src/option.js +31 -0
  92. package/es/select/src/optionInfo.js +16 -0
  93. package/es/select/src/select.js +992 -0
  94. package/es/select/src/util.js +36 -0
  95. package/es/select/style.css +201 -0
  96. package/es/select/style.min.css +1 -0
  97. package/es/style.css +1 -1
  98. package/es/style.min.css +1 -1
  99. package/es/switch/index.js +10 -0
  100. package/es/switch/src/switch.js +151 -0
  101. package/es/switch/style.css +97 -0
  102. package/es/switch/style.min.css +1 -0
  103. package/es/textarea/index.js +10 -0
  104. package/es/textarea/src/textarea.js +245 -0
  105. package/es/textarea/style.css +102 -0
  106. package/es/textarea/style.min.css +1 -0
  107. package/es/tooltip/index.js +8 -0
  108. package/es/tooltip/src/tooltip.js +336 -0
  109. package/es/tooltip/style.css +103 -0
  110. package/es/tooltip/style.min.css +1 -0
  111. package/es/ui/src/core.js +12 -2
  112. package/es/ui/src/dom.js +20 -0
  113. package/es/ui/src/globalStore.js +119 -4
  114. package/es/ui/src/i18n.js +7 -0
  115. package/es/ui/src/log.js +2 -2
  116. package/es/ui/src/renderer.js +67 -0
  117. package/es/ui/src/store.js +41 -0
  118. package/es/ui/src/utils.js +10 -0
  119. package/es/ui/src/validators.js +5 -0
  120. package/es/ui/src/vn.js +10 -0
  121. package/es/vxe-button/style.css +17 -17
  122. package/es/vxe-button/style.min.css +1 -1
  123. package/es/vxe-checkbox/index.js +3 -0
  124. package/es/vxe-checkbox/style.css +107 -0
  125. package/es/vxe-checkbox/style.min.css +1 -0
  126. package/es/vxe-checkbox-group/index.js +3 -0
  127. package/es/vxe-checkbox-group/style.css +0 -0
  128. package/es/vxe-checkbox-group/style.min.css +0 -0
  129. package/es/vxe-form/index.js +3 -0
  130. package/es/vxe-form/style.css +321 -0
  131. package/es/vxe-form/style.min.css +1 -0
  132. package/es/vxe-form-design/index.js +3 -0
  133. package/es/vxe-form-design/style.css +97 -0
  134. package/es/vxe-form-design/style.min.css +1 -0
  135. package/es/vxe-form-gather/index.js +3 -0
  136. package/es/vxe-form-gather/style.css +0 -0
  137. package/es/vxe-form-gather/style.min.css +0 -0
  138. package/es/vxe-form-item/index.js +3 -0
  139. package/es/vxe-form-item/style.css +0 -0
  140. package/es/vxe-form-item/style.min.css +0 -0
  141. package/es/vxe-icon/style.css +540 -1
  142. package/es/vxe-icon/style.min.css +1 -1
  143. package/es/vxe-input/index.js +3 -0
  144. package/es/vxe-input/style.css +1000 -0
  145. package/es/vxe-input/style.min.css +1 -0
  146. package/es/vxe-layout-aside/style.css +1 -0
  147. package/es/vxe-layout-aside/style.min.css +1 -1
  148. package/es/vxe-layout-body/style.css +1 -0
  149. package/es/vxe-layout-body/style.min.css +1 -1
  150. package/es/vxe-layout-footer/style.css +1 -0
  151. package/es/vxe-layout-footer/style.min.css +1 -1
  152. package/es/vxe-layout-header/style.css +1 -0
  153. package/es/vxe-layout-header/style.min.css +1 -1
  154. package/es/vxe-list-design/index.js +3 -0
  155. package/es/vxe-list-design/style.css +0 -0
  156. package/es/vxe-list-design/style.min.css +0 -0
  157. package/es/vxe-loading/index.js +3 -0
  158. package/es/vxe-loading/style.css +75 -0
  159. package/es/vxe-loading/style.min.css +1 -0
  160. package/es/vxe-modal/index.js +3 -0
  161. package/es/vxe-modal/style.css +323 -0
  162. package/es/vxe-modal/style.min.css +1 -0
  163. package/es/vxe-optgroup/index.js +3 -0
  164. package/es/vxe-optgroup/style.css +0 -0
  165. package/es/vxe-optgroup/style.min.css +0 -0
  166. package/es/vxe-option/index.js +3 -0
  167. package/es/vxe-option/style.css +0 -0
  168. package/es/vxe-option/style.min.css +0 -0
  169. package/es/vxe-pager/index.js +3 -0
  170. package/es/vxe-pager/style.css +319 -0
  171. package/es/vxe-pager/style.min.css +1 -0
  172. package/es/vxe-pulldown/index.js +3 -0
  173. package/es/vxe-pulldown/style.css +57 -0
  174. package/es/vxe-pulldown/style.min.css +1 -0
  175. package/es/vxe-radio/index.js +3 -0
  176. package/es/vxe-radio/style.css +143 -0
  177. package/es/vxe-radio/style.min.css +1 -0
  178. package/es/vxe-radio-button/index.js +3 -0
  179. package/es/vxe-radio-button/style.css +0 -0
  180. package/es/vxe-radio-button/style.min.css +0 -0
  181. package/es/vxe-radio-group/index.js +3 -0
  182. package/es/vxe-radio-group/style.css +0 -0
  183. package/es/vxe-radio-group/style.min.css +0 -0
  184. package/es/vxe-select/index.js +3 -0
  185. package/es/vxe-select/style.css +201 -0
  186. package/es/vxe-select/style.min.css +1 -0
  187. package/es/vxe-switch/index.js +3 -0
  188. package/es/vxe-switch/style.css +97 -0
  189. package/es/vxe-switch/style.min.css +1 -0
  190. package/es/vxe-textarea/index.js +3 -0
  191. package/es/vxe-textarea/style.css +102 -0
  192. package/es/vxe-textarea/style.min.css +1 -0
  193. package/es/vxe-tooltip/index.js +3 -0
  194. package/es/vxe-tooltip/style.css +103 -0
  195. package/es/vxe-tooltip/style.min.css +1 -0
  196. package/lib/anchor/src/anchor.js +1 -1
  197. package/lib/anchor/src/anchor.min.js +1 -1
  198. package/lib/anchor-link/index.js +1 -1
  199. package/lib/anchor-link/index.min.js +1 -1
  200. package/lib/{button-group → button}/src/button-group.js +2 -2
  201. package/lib/button/src/button-group.min.js +1 -0
  202. package/lib/button/src/button.js +3 -3
  203. package/lib/button/src/button.min.js +1 -1
  204. package/lib/button/style/style.css +17 -17
  205. package/lib/button/style/style.min.css +1 -1
  206. package/lib/button-group/index.js +1 -1
  207. package/lib/button-group/index.min.js +1 -1
  208. package/lib/checkbox/index.js +17 -0
  209. package/lib/checkbox/index.min.js +1 -0
  210. package/lib/checkbox/src/checkbox.js +144 -0
  211. package/lib/checkbox/src/checkbox.min.js +1 -0
  212. package/lib/checkbox/src/group.js +129 -0
  213. package/lib/checkbox/src/group.min.js +1 -0
  214. package/lib/checkbox/style/style.css +107 -0
  215. package/lib/checkbox/style/style.min.css +1 -0
  216. package/lib/checkbox-group/index.js +17 -0
  217. package/lib/checkbox-group/index.min.js +1 -0
  218. package/lib/checkbox-group/style/style.css +0 -0
  219. package/lib/checkbox-group/style/style.min.css +0 -0
  220. package/lib/col/index.js +1 -1
  221. package/lib/col/index.min.js +1 -1
  222. package/lib/components.js +290 -63
  223. package/lib/components.min.js +1 -1
  224. package/lib/dynamics/index.js +36 -0
  225. package/lib/dynamics/index.min.js +1 -0
  226. package/lib/form/index.js +15 -0
  227. package/lib/form/index.min.js +1 -0
  228. package/lib/form/src/form-config-item.js +192 -0
  229. package/lib/form/src/form-config-item.min.js +1 -0
  230. package/lib/form/src/form-gather.js +57 -0
  231. package/lib/form/src/form-gather.min.js +1 -0
  232. package/lib/form/src/form-item.js +247 -0
  233. package/lib/form/src/form-item.min.js +1 -0
  234. package/lib/form/src/form.js +768 -0
  235. package/lib/form/src/form.min.js +1 -0
  236. package/lib/form/src/itemInfo.js +47 -0
  237. package/lib/form/src/itemInfo.min.js +1 -0
  238. package/lib/form/src/render.js +84 -0
  239. package/lib/form/src/render.min.js +1 -0
  240. package/lib/form/src/util.js +108 -0
  241. package/lib/form/src/util.min.js +1 -0
  242. package/lib/form/style/index.js +1 -0
  243. package/lib/form/style/style.css +321 -0
  244. package/lib/form/style/style.min.css +1 -0
  245. package/lib/form-design/index.js +15 -0
  246. package/lib/form-design/index.min.js +1 -0
  247. package/lib/form-design/src/form-design.js +87 -0
  248. package/lib/form-design/src/form-design.min.js +1 -0
  249. package/lib/form-design/src/setting.js +18 -0
  250. package/lib/form-design/src/setting.min.js +1 -0
  251. package/lib/form-design/src/util.js +17 -0
  252. package/lib/form-design/src/util.min.js +1 -0
  253. package/lib/form-design/src/view.js +147 -0
  254. package/lib/form-design/src/view.min.js +1 -0
  255. package/lib/form-design/src/widget.js +114 -0
  256. package/lib/form-design/src/widget.min.js +1 -0
  257. package/lib/form-design/style/index.js +1 -0
  258. package/lib/form-design/style/style.css +97 -0
  259. package/lib/form-design/style/style.min.css +1 -0
  260. package/lib/form-gather/index.js +15 -0
  261. package/lib/form-gather/index.min.js +1 -0
  262. package/lib/form-gather/style/index.js +1 -0
  263. package/lib/form-gather/style/style.css +0 -0
  264. package/lib/form-gather/style/style.min.css +0 -0
  265. package/lib/form-item/index.js +15 -0
  266. package/lib/form-item/index.min.js +1 -0
  267. package/lib/form-item/style/index.js +1 -0
  268. package/lib/form-item/style/style.css +0 -0
  269. package/lib/form-item/style/style.min.css +0 -0
  270. package/lib/icon/style/style.css +540 -1
  271. package/lib/icon/style/style.min.css +1 -1
  272. package/lib/index.umd.js +10741 -782
  273. package/lib/index.umd.min.js +1 -1
  274. package/lib/input/index.js +17 -0
  275. package/lib/input/index.min.js +1 -0
  276. package/lib/input/src/date.js +46 -0
  277. package/lib/input/src/date.min.js +1 -0
  278. package/lib/input/src/input.js +2546 -0
  279. package/lib/input/src/input.min.js +1 -0
  280. package/lib/input/src/number.js +18 -0
  281. package/lib/input/src/number.min.js +1 -0
  282. package/lib/input/style/index.js +1 -0
  283. package/lib/input/style/style.css +1000 -0
  284. package/lib/input/style/style.min.css +1 -0
  285. package/lib/layout-aside/style/style.css +1 -0
  286. package/lib/layout-aside/style/style.min.css +1 -1
  287. package/lib/layout-body/style/style.css +1 -0
  288. package/lib/layout-body/style/style.min.css +1 -1
  289. package/lib/layout-footer/style/style.css +1 -0
  290. package/lib/layout-footer/style/style.min.css +1 -1
  291. package/lib/layout-header/style/style.css +1 -0
  292. package/lib/layout-header/style/style.min.css +1 -1
  293. package/lib/list-design/index.js +15 -0
  294. package/lib/list-design/index.min.js +1 -0
  295. package/lib/{design/src/design.js → list-design/src/list-design.js} +7 -7
  296. package/lib/list-design/src/list-design.min.js +1 -0
  297. package/lib/list-design/style/index.js +1 -0
  298. package/lib/list-design/style/style.css +0 -0
  299. package/lib/list-design/style/style.min.css +0 -0
  300. package/lib/loading/index.js +15 -0
  301. package/lib/loading/index.min.js +1 -0
  302. package/lib/loading/src/loading.js +49 -0
  303. package/lib/loading/src/loading.min.js +1 -0
  304. package/lib/loading/style/index.js +1 -0
  305. package/lib/loading/style/style.css +75 -0
  306. package/lib/loading/style/style.min.css +1 -0
  307. package/lib/modal/index.js +110 -0
  308. package/lib/modal/index.min.js +1 -0
  309. package/lib/modal/src/modal.js +1064 -0
  310. package/lib/modal/src/modal.min.js +1 -0
  311. package/lib/modal/style/index.js +1 -0
  312. package/lib/modal/style/style.css +323 -0
  313. package/lib/modal/style/style.min.css +1 -0
  314. package/lib/optgroup/index.js +17 -0
  315. package/lib/optgroup/index.min.js +1 -0
  316. package/lib/optgroup/style/index.js +1 -0
  317. package/lib/optgroup/style/style.css +0 -0
  318. package/lib/optgroup/style/style.min.css +0 -0
  319. package/lib/option/index.js +17 -0
  320. package/lib/option/index.min.js +1 -0
  321. package/lib/option/style/index.js +1 -0
  322. package/lib/option/style/style.css +0 -0
  323. package/lib/option/style/style.min.css +0 -0
  324. package/lib/pager/index.js +17 -0
  325. package/lib/pager/index.min.js +1 -0
  326. package/lib/pager/src/pager.js +593 -0
  327. package/lib/pager/src/pager.min.js +1 -0
  328. package/lib/pager/style/index.js +1 -0
  329. package/lib/pager/style/style.css +319 -0
  330. package/lib/pager/style/style.min.css +1 -0
  331. package/lib/pulldown/index.js +17 -0
  332. package/lib/pulldown/index.min.js +1 -0
  333. package/lib/pulldown/src/pulldown.js +359 -0
  334. package/lib/pulldown/src/pulldown.min.js +1 -0
  335. package/lib/pulldown/style/index.js +1 -0
  336. package/lib/pulldown/style/style.css +57 -0
  337. package/lib/pulldown/style/style.min.css +1 -0
  338. package/lib/radio/index.js +17 -0
  339. package/lib/radio/index.min.js +1 -0
  340. package/lib/radio/src/button.js +135 -0
  341. package/lib/radio/src/button.min.js +1 -0
  342. package/lib/radio/src/group.js +108 -0
  343. package/lib/radio/src/group.min.js +1 -0
  344. package/lib/radio/src/radio.js +139 -0
  345. package/lib/radio/src/radio.min.js +1 -0
  346. package/lib/radio/style/index.js +1 -0
  347. package/lib/radio/style/style.css +143 -0
  348. package/lib/radio/style/style.min.css +1 -0
  349. package/lib/radio-button/index.js +17 -0
  350. package/lib/radio-button/index.min.js +1 -0
  351. package/lib/radio-button/style/index.js +1 -0
  352. package/lib/radio-button/style/style.css +0 -0
  353. package/lib/radio-button/style/style.min.css +0 -0
  354. package/lib/radio-group/index.js +17 -0
  355. package/lib/radio-group/index.min.js +1 -0
  356. package/lib/radio-group/style/index.js +1 -0
  357. package/lib/radio-group/style/style.css +0 -0
  358. package/lib/radio-group/style/style.min.css +0 -0
  359. package/lib/select/index.js +17 -0
  360. package/lib/select/index.min.js +1 -0
  361. package/lib/select/src/optgroup.js +47 -0
  362. package/lib/select/src/optgroup.min.js +1 -0
  363. package/lib/select/src/option.js +45 -0
  364. package/lib/select/src/option.min.js +1 -0
  365. package/lib/select/src/optionInfo.js +24 -0
  366. package/lib/select/src/optionInfo.min.js +1 -0
  367. package/lib/select/src/select.js +1104 -0
  368. package/lib/select/src/select.min.js +1 -0
  369. package/lib/select/src/util.js +57 -0
  370. package/lib/select/src/util.min.js +1 -0
  371. package/lib/select/style/index.js +1 -0
  372. package/lib/select/style/style.css +201 -0
  373. package/lib/select/style/style.min.css +1 -0
  374. package/lib/style.css +1 -1
  375. package/lib/style.min.css +1 -1
  376. package/lib/switch/index.js +17 -0
  377. package/lib/switch/index.min.js +1 -0
  378. package/lib/switch/src/switch.js +161 -0
  379. package/lib/switch/src/switch.min.js +1 -0
  380. package/lib/switch/style/index.js +1 -0
  381. package/lib/switch/style/style.css +97 -0
  382. package/lib/switch/style/style.min.css +1 -0
  383. package/lib/textarea/index.js +17 -0
  384. package/lib/textarea/index.min.js +1 -0
  385. package/lib/textarea/src/textarea.js +298 -0
  386. package/lib/textarea/src/textarea.min.js +1 -0
  387. package/lib/textarea/style/index.js +1 -0
  388. package/lib/textarea/style/style.css +102 -0
  389. package/lib/textarea/style/style.min.css +1 -0
  390. package/lib/tooltip/index.js +15 -0
  391. package/lib/tooltip/index.min.js +1 -0
  392. package/lib/tooltip/src/tooltip.js +418 -0
  393. package/lib/tooltip/src/tooltip.min.js +1 -0
  394. package/lib/tooltip/style/index.js +1 -0
  395. package/lib/tooltip/style/style.css +103 -0
  396. package/lib/tooltip/style/style.min.css +1 -0
  397. package/lib/ui/src/core.js +49 -2
  398. package/lib/ui/src/core.min.js +1 -1
  399. package/lib/ui/src/dom.js +22 -0
  400. package/lib/ui/src/dom.min.js +1 -1
  401. package/lib/ui/src/globalStore.js +119 -4
  402. package/lib/ui/src/globalStore.min.js +1 -1
  403. package/lib/ui/src/i18n.js +14 -0
  404. package/lib/ui/src/i18n.min.js +1 -0
  405. package/lib/ui/src/log.js +2 -3
  406. package/lib/ui/src/log.min.js +1 -1
  407. package/lib/ui/src/renderer.js +77 -0
  408. package/lib/ui/src/renderer.min.js +1 -0
  409. package/lib/ui/src/store.js +49 -0
  410. package/lib/ui/src/store.min.js +1 -0
  411. package/lib/ui/src/utils.js +12 -0
  412. package/lib/ui/src/utils.min.js +1 -1
  413. package/lib/ui/src/validators.js +14 -0
  414. package/lib/ui/src/validators.min.js +1 -0
  415. package/lib/ui/src/vn.js +18 -0
  416. package/lib/ui/src/vn.min.js +1 -0
  417. package/lib/vxe-button/style/style.css +17 -17
  418. package/lib/vxe-button/style/style.min.css +1 -1
  419. package/lib/vxe-checkbox/index.js +22 -0
  420. package/lib/vxe-checkbox/index.min.js +1 -0
  421. package/lib/vxe-checkbox/style/index.js +1 -0
  422. package/lib/vxe-checkbox/style/style.css +107 -0
  423. package/lib/vxe-checkbox/style/style.min.css +1 -0
  424. package/lib/vxe-checkbox-group/index.js +22 -0
  425. package/lib/vxe-checkbox-group/index.min.js +1 -0
  426. package/lib/vxe-checkbox-group/style/index.js +1 -0
  427. package/lib/vxe-checkbox-group/style/style.css +0 -0
  428. package/lib/vxe-checkbox-group/style/style.min.css +0 -0
  429. package/lib/{vxe-design → vxe-form}/index.js +5 -5
  430. package/lib/vxe-form/index.min.js +1 -0
  431. package/lib/vxe-form/style/index.js +1 -0
  432. package/lib/vxe-form/style/style.css +321 -0
  433. package/lib/vxe-form/style/style.min.css +1 -0
  434. package/lib/vxe-form-design/index.js +22 -0
  435. package/lib/vxe-form-design/index.min.js +1 -0
  436. package/lib/vxe-form-design/style/index.js +1 -0
  437. package/lib/vxe-form-design/style/style.css +97 -0
  438. package/lib/vxe-form-design/style/style.min.css +1 -0
  439. package/lib/vxe-form-gather/index.js +22 -0
  440. package/lib/vxe-form-gather/index.min.js +1 -0
  441. package/lib/vxe-form-gather/style/index.js +1 -0
  442. package/lib/vxe-form-gather/style/style.css +0 -0
  443. package/lib/vxe-form-gather/style/style.min.css +0 -0
  444. package/lib/vxe-form-item/index.js +22 -0
  445. package/lib/vxe-form-item/index.min.js +1 -0
  446. package/lib/vxe-form-item/style/index.js +1 -0
  447. package/lib/vxe-form-item/style/style.css +0 -0
  448. package/lib/vxe-form-item/style/style.min.css +0 -0
  449. package/lib/vxe-icon/style/style.css +540 -1
  450. package/lib/vxe-icon/style/style.min.css +1 -1
  451. package/lib/vxe-input/index.js +22 -0
  452. package/lib/vxe-input/index.min.js +1 -0
  453. package/lib/vxe-input/style/index.js +1 -0
  454. package/lib/vxe-input/style/style.css +1000 -0
  455. package/lib/vxe-input/style/style.min.css +1 -0
  456. package/lib/vxe-layout-aside/style/style.css +1 -0
  457. package/lib/vxe-layout-aside/style/style.min.css +1 -1
  458. package/lib/vxe-layout-body/style/style.css +1 -0
  459. package/lib/vxe-layout-body/style/style.min.css +1 -1
  460. package/lib/vxe-layout-footer/style/style.css +1 -0
  461. package/lib/vxe-layout-footer/style/style.min.css +1 -1
  462. package/lib/vxe-layout-header/style/style.css +1 -0
  463. package/lib/vxe-layout-header/style/style.min.css +1 -1
  464. package/lib/vxe-list-design/index.js +22 -0
  465. package/lib/vxe-list-design/index.min.js +1 -0
  466. package/lib/vxe-list-design/style/index.js +1 -0
  467. package/lib/vxe-list-design/style/style.css +0 -0
  468. package/lib/vxe-list-design/style/style.min.css +0 -0
  469. package/lib/vxe-loading/index.js +22 -0
  470. package/lib/vxe-loading/index.min.js +1 -0
  471. package/lib/vxe-loading/style/index.js +1 -0
  472. package/lib/vxe-loading/style/style.css +75 -0
  473. package/lib/vxe-loading/style/style.min.css +1 -0
  474. package/lib/vxe-modal/index.js +22 -0
  475. package/lib/vxe-modal/index.min.js +1 -0
  476. package/lib/vxe-modal/style/index.js +1 -0
  477. package/lib/vxe-modal/style/style.css +323 -0
  478. package/lib/vxe-modal/style/style.min.css +1 -0
  479. package/lib/vxe-optgroup/index.js +22 -0
  480. package/lib/vxe-optgroup/index.min.js +1 -0
  481. package/lib/vxe-optgroup/style/index.js +1 -0
  482. package/lib/vxe-optgroup/style/style.css +0 -0
  483. package/lib/vxe-optgroup/style/style.min.css +0 -0
  484. package/lib/vxe-option/index.js +22 -0
  485. package/lib/vxe-option/index.min.js +1 -0
  486. package/lib/vxe-option/style/index.js +1 -0
  487. package/lib/vxe-option/style/style.css +0 -0
  488. package/lib/vxe-option/style/style.min.css +0 -0
  489. package/lib/vxe-pager/index.js +22 -0
  490. package/lib/vxe-pager/index.min.js +1 -0
  491. package/lib/vxe-pager/style/index.js +1 -0
  492. package/lib/vxe-pager/style/style.css +319 -0
  493. package/lib/vxe-pager/style/style.min.css +1 -0
  494. package/lib/vxe-pulldown/index.js +22 -0
  495. package/lib/vxe-pulldown/index.min.js +1 -0
  496. package/lib/vxe-pulldown/style/index.js +1 -0
  497. package/lib/vxe-pulldown/style/style.css +57 -0
  498. package/lib/vxe-pulldown/style/style.min.css +1 -0
  499. package/lib/vxe-radio/index.js +22 -0
  500. package/lib/vxe-radio/index.min.js +1 -0
  501. package/lib/vxe-radio/style/index.js +1 -0
  502. package/lib/vxe-radio/style/style.css +143 -0
  503. package/lib/vxe-radio/style/style.min.css +1 -0
  504. package/lib/vxe-radio-button/index.js +22 -0
  505. package/lib/vxe-radio-button/index.min.js +1 -0
  506. package/lib/vxe-radio-button/style/index.js +1 -0
  507. package/lib/vxe-radio-button/style/style.css +0 -0
  508. package/lib/vxe-radio-button/style/style.min.css +0 -0
  509. package/lib/vxe-radio-group/index.js +22 -0
  510. package/lib/vxe-radio-group/index.min.js +1 -0
  511. package/lib/vxe-radio-group/style/index.js +1 -0
  512. package/lib/vxe-radio-group/style/style.css +0 -0
  513. package/lib/vxe-radio-group/style/style.min.css +0 -0
  514. package/lib/vxe-select/index.js +22 -0
  515. package/lib/vxe-select/index.min.js +1 -0
  516. package/lib/vxe-select/style/index.js +1 -0
  517. package/lib/vxe-select/style/style.css +201 -0
  518. package/lib/vxe-select/style/style.min.css +1 -0
  519. package/lib/vxe-switch/index.js +22 -0
  520. package/lib/vxe-switch/index.min.js +1 -0
  521. package/lib/vxe-switch/style/index.js +1 -0
  522. package/lib/vxe-switch/style/style.css +97 -0
  523. package/lib/vxe-switch/style/style.min.css +1 -0
  524. package/lib/vxe-textarea/index.js +22 -0
  525. package/lib/vxe-textarea/index.min.js +1 -0
  526. package/lib/vxe-textarea/style/index.js +1 -0
  527. package/lib/vxe-textarea/style/style.css +102 -0
  528. package/lib/vxe-textarea/style/style.min.css +1 -0
  529. package/lib/vxe-tooltip/index.js +22 -0
  530. package/lib/vxe-tooltip/index.min.js +1 -0
  531. package/lib/vxe-tooltip/style/index.js +1 -0
  532. package/lib/vxe-tooltip/style/style.css +103 -0
  533. package/lib/vxe-tooltip/style/style.min.css +1 -0
  534. package/package.json +1 -1
  535. package/packages/anchor/src/anchor.ts +1 -1
  536. package/packages/anchor-link/index.ts +1 -1
  537. package/packages/{button-group → button}/src/button-group.ts +2 -2
  538. package/packages/button/src/button.ts +3 -3
  539. package/packages/button-group/index.ts +1 -1
  540. package/packages/checkbox/index.ts +15 -0
  541. package/packages/checkbox/src/checkbox.ts +131 -0
  542. package/packages/checkbox/src/group.ts +127 -0
  543. package/packages/checkbox-group/index.ts +15 -0
  544. package/packages/col/index.ts +1 -1
  545. package/packages/components.ts +100 -35
  546. package/packages/dynamics/index.ts +34 -0
  547. package/packages/form/index.ts +11 -0
  548. package/packages/form/src/form-config-item.ts +193 -0
  549. package/packages/form/src/form-gather.ts +60 -0
  550. package/packages/form/src/form-item.ts +253 -0
  551. package/packages/form/src/form.ts +716 -0
  552. package/packages/form/src/itemInfo.ts +43 -0
  553. package/packages/form/src/render.ts +83 -0
  554. package/packages/form/src/util.ts +79 -0
  555. package/packages/form-design/index.ts +11 -0
  556. package/packages/form-design/src/form-design.ts +99 -0
  557. package/packages/form-design/src/setting.ts +13 -0
  558. package/packages/form-design/src/util.ts +10 -0
  559. package/packages/form-design/src/view.ts +125 -0
  560. package/packages/form-design/src/widget.ts +117 -0
  561. package/packages/form-gather/index.ts +11 -0
  562. package/packages/form-item/index.ts +11 -0
  563. package/packages/icon/src/icon.ts +1 -1
  564. package/packages/input/index.ts +15 -0
  565. package/packages/input/src/date.ts +42 -0
  566. package/packages/input/src/input.ts +2480 -0
  567. package/packages/input/src/number.ts +12 -0
  568. package/packages/list-design/index.ts +11 -0
  569. package/packages/list-design/src/list-design.ts +55 -0
  570. package/packages/loading/index.ts +11 -0
  571. package/packages/loading/src/loading.ts +56 -0
  572. package/packages/modal/index.ts +110 -0
  573. package/packages/modal/src/modal.ts +950 -0
  574. package/packages/optgroup/index.ts +15 -0
  575. package/packages/option/index.ts +15 -0
  576. package/packages/pager/index.ts +15 -0
  577. package/packages/pager/src/pager.ts +595 -0
  578. package/packages/pulldown/index.ts +15 -0
  579. package/packages/pulldown/src/pulldown.ts +349 -0
  580. package/packages/radio/index.ts +15 -0
  581. package/packages/radio/src/button.ts +132 -0
  582. package/packages/radio/src/group.ts +110 -0
  583. package/packages/radio/src/radio.ts +137 -0
  584. package/packages/radio-button/index.ts +15 -0
  585. package/packages/radio-group/index.ts +15 -0
  586. package/packages/select/index.ts +15 -0
  587. package/packages/select/src/optgroup.ts +39 -0
  588. package/packages/select/src/option.ts +38 -0
  589. package/packages/select/src/optionInfo.ts +20 -0
  590. package/packages/select/src/select.ts +1034 -0
  591. package/packages/select/src/util.ts +47 -0
  592. package/packages/switch/index.ts +15 -0
  593. package/packages/switch/src/switch.ts +171 -0
  594. package/packages/textarea/index.ts +15 -0
  595. package/packages/textarea/src/textarea.ts +273 -0
  596. package/packages/tooltip/index.ts +11 -0
  597. package/packages/tooltip/src/tooltip.ts +360 -0
  598. package/packages/ui/src/core.ts +13 -1
  599. package/packages/ui/src/dom.ts +23 -0
  600. package/packages/ui/src/globalStore.ts +122 -5
  601. package/packages/ui/src/i18n.ts +8 -0
  602. package/packages/ui/src/log.ts +2 -2
  603. package/packages/ui/src/renderer.ts +71 -0
  604. package/packages/ui/src/store.ts +49 -0
  605. package/packages/ui/src/utils.ts +12 -0
  606. package/packages/ui/src/validators.ts +9 -0
  607. package/packages/ui/src/vn.ts +14 -0
  608. package/styles/all.scss +30 -10
  609. package/styles/base/common.scss +13 -0
  610. package/styles/components/button.scss +8 -8
  611. package/styles/components/checkbox-group.scss +0 -0
  612. package/styles/components/checkbox.scss +91 -0
  613. package/styles/components/form-design.scss +93 -0
  614. package/styles/components/form-gather.scss +0 -0
  615. package/styles/components/form-item.scss +0 -0
  616. package/styles/components/form.scss +339 -0
  617. package/styles/components/icon.scss +3 -1
  618. package/styles/components/input.scss +911 -0
  619. package/styles/components/layout-aside.scss +1 -0
  620. package/styles/components/layout-body.scss +1 -0
  621. package/styles/components/layout-footer.scss +1 -0
  622. package/styles/components/layout-header.scss +1 -0
  623. package/styles/components/list-design.scss +0 -0
  624. package/styles/components/list.scss +26 -0
  625. package/styles/components/loading.scss +84 -0
  626. package/styles/components/modal.scss +383 -0
  627. package/styles/components/old-icon.scss +712 -0
  628. package/styles/components/optgroup.scss +0 -0
  629. package/styles/components/option.scss +0 -0
  630. package/styles/components/pager.scss +287 -0
  631. package/styles/components/pulldown.scss +55 -0
  632. package/styles/components/radio-button.scss +0 -0
  633. package/styles/components/radio-group.scss +0 -0
  634. package/styles/components/radio.scss +149 -0
  635. package/styles/components/select.scss +226 -0
  636. package/styles/components/switch.scss +113 -0
  637. package/styles/components/textarea.scss +102 -0
  638. package/styles/components/tooltip.scss +124 -0
  639. package/styles/helpers/mixin.scss +12 -12
  640. package/styles/theme/base.scss +143 -6
  641. package/types/all.d.ts +66 -33
  642. package/types/{component → components}/anchor-link.d.ts +17 -2
  643. package/types/{component → components}/anchor.d.ts +10 -2
  644. package/types/{component → components}/breadcrumb-item.d.ts +12 -1
  645. package/types/{component → components}/breadcrumb.d.ts +10 -2
  646. package/types/{component → components}/button-group.d.ts +11 -3
  647. package/types/{component → components}/button.d.ts +14 -3
  648. package/types/components/checkbox-group.d.ts +112 -0
  649. package/types/components/checkbox.d.ts +119 -0
  650. package/types/{component → components}/col.d.ts +9 -1
  651. package/types/components/form-design.d.ts +88 -0
  652. package/types/components/form-gather.d.ts +75 -0
  653. package/types/components/form-item.d.ts +231 -0
  654. package/types/components/form.d.ts +349 -0
  655. package/types/{component → components}/icon.d.ts +7 -2
  656. package/types/components/input.d.ts +375 -0
  657. package/types/{component → components}/layout-aside.d.ts +10 -2
  658. package/types/{component → components}/layout-body.d.ts +10 -2
  659. package/types/{component → components}/layout-container.d.ts +10 -2
  660. package/types/{component → components}/layout-footer.d.ts +10 -2
  661. package/types/{component → components}/layout-header.d.ts +7 -1
  662. package/types/components/list-design.d.ts +67 -0
  663. package/types/components/loading.d.ts +66 -0
  664. package/types/components/modal.d.ts +381 -0
  665. package/types/components/optgroup.d.ts +80 -0
  666. package/types/components/option.d.ts +99 -0
  667. package/types/components/pager.d.ts +208 -0
  668. package/types/components/pulldown.d.ts +134 -0
  669. package/types/components/radio-button.d.ts +99 -0
  670. package/types/components/radio-group.d.ts +107 -0
  671. package/types/components/radio.d.ts +119 -0
  672. package/types/{component → components}/row.d.ts +10 -2
  673. package/types/components/select.d.ts +274 -0
  674. package/types/components/switch.d.ts +118 -0
  675. package/types/components/textarea.d.ts +212 -0
  676. package/types/components/tooltip.d.ts +122 -0
  677. package/types/ui/global-config.d.ts +43 -6
  678. package/types/ui/global-icon.d.ts +80 -10
  679. package/types/ui/index.d.ts +25 -2
  680. package/types/ui/renderer.d.ts +239 -0
  681. package/types/ui/validators.d.ts +26 -0
  682. package/es/design/index.js +0 -8
  683. package/es/vxe-design/index.js +0 -3
  684. package/lib/button-group/src/button-group.min.js +0 -1
  685. package/lib/design/index.js +0 -15
  686. package/lib/design/index.min.js +0 -1
  687. package/lib/design/src/design.min.js +0 -1
  688. package/lib/vxe-design/index.min.js +0 -1
  689. package/packages/design/index.ts +0 -11
  690. package/packages/design/src/design.ts +0 -55
  691. package/styles/components/design.scss +0 -1
  692. package/types/component/design.d.ts +0 -63
  693. /package/es/{anchor-link → anchor}/src/anchor-link.js +0 -0
  694. /package/es/{anchor-link → anchor}/src/util.js +0 -0
  695. /package/es/{design → checkbox-group}/style.css +0 -0
  696. /package/es/{design → checkbox-group}/style.min.css +0 -0
  697. /package/es/{vxe-design → form-gather}/style.css +0 -0
  698. /package/es/{vxe-design → form-gather}/style.min.css +0 -0
  699. /package/{lib/design/style → es/form-item}/style.css +0 -0
  700. /package/{lib/design/style → es/form-item}/style.min.css +0 -0
  701. /package/{lib/vxe-design/style → es/list-design}/style.css +0 -0
  702. /package/{lib/vxe-design/style → es/list-design}/style.min.css +0 -0
  703. /package/es/{col → row}/src/col.js +0 -0
  704. /package/lib/{anchor-link → anchor}/src/anchor-link.js +0 -0
  705. /package/lib/{anchor-link → anchor}/src/anchor-link.min.js +0 -0
  706. /package/lib/{anchor-link → anchor}/src/util.js +0 -0
  707. /package/lib/{anchor-link → anchor}/src/util.min.js +0 -0
  708. /package/lib/{vxe-design → checkbox}/style/index.js +0 -0
  709. /package/lib/{design → checkbox-group}/style/index.js +0 -0
  710. /package/lib/{col → row}/src/col.js +0 -0
  711. /package/lib/{col → row}/src/col.min.js +0 -0
  712. /package/packages/{anchor-link → anchor}/src/anchor-link.ts +0 -0
  713. /package/packages/{anchor-link → anchor}/src/util.ts +0 -0
  714. /package/packages/{col → row}/src/col.ts +0 -0
@@ -0,0 +1,2480 @@
1
+ import { defineComponent, h, Teleport, ref, Ref, computed, reactive, inject, nextTick, watch, onUnmounted, PropType } from 'vue'
2
+ import XEUtils from 'xe-utils'
3
+ import globalConfigStore from '../../ui/src/globalStore'
4
+ import iconConfigStore from '../../ui/src/iconStore'
5
+ import { useSize } from '../../hooks/size'
6
+ import { getFuncText, getLastZIndex, nextZIndex } from '../../ui/src/utils'
7
+ import { hasClass, getAbsolutePos, getEventTargetNode } from '../../ui/src/dom'
8
+ import { GlobalEvent, hasEventKey, EVENT_KEYS } from '../../ui/src/event'
9
+ import { getI18n } from '../../ui/src/i18n'
10
+ import { toStringTimeDate, getDateQuarter } from './date'
11
+ import { handleNumber, toFloatValueFixed } from './number'
12
+
13
+ import { VxeComponentStyle, VxeInputConstructor, VxeInputEmits, InputReactData, InputMethods, VxeInputPropTypes, InputPrivateRef, VxeFormConstructor, VxeFormPrivateMethods, VxeFormDefines } from '../../../types'
14
+
15
+ interface DateYearItem {
16
+ date: Date;
17
+ isPrev: boolean;
18
+ isCurrent: boolean;
19
+ isNow: boolean;
20
+ isNext: boolean;
21
+ year: number;
22
+ }
23
+
24
+ interface DateMonthItem {
25
+ date: Date;
26
+ isPrev: boolean;
27
+ isCurrent: boolean;
28
+ isNow: boolean;
29
+ isNext: boolean;
30
+ month: number;
31
+ }
32
+
33
+ interface DateQuarterItem {
34
+ date: Date;
35
+ isPrev: boolean;
36
+ isCurrent: boolean;
37
+ isNow: boolean;
38
+ isNext: boolean;
39
+ quarter: number;
40
+ }
41
+
42
+ interface DateDayItem {
43
+ date: Date;
44
+ isWeekNumber?: boolean;
45
+ isPrev: boolean;
46
+ isCurrent: boolean;
47
+ isNow: boolean;
48
+ isNext: boolean;
49
+ label: number;
50
+ }
51
+
52
+ interface DateHourMinuteSecondItem {
53
+ value: number;
54
+ label: string;
55
+ }
56
+
57
+ const yearSize = 12
58
+ const monthSize = 20
59
+ const quarterSize = 8
60
+
61
+ export default defineComponent({
62
+ name: 'VxeInput',
63
+ props: {
64
+ modelValue: [String, Number, Date] as PropType<VxeInputPropTypes.ModelValue>,
65
+ immediate: { type: Boolean as PropType<VxeInputPropTypes.Immediate>, default: true },
66
+ name: String as PropType<VxeInputPropTypes.Name>,
67
+ type: { type: String as PropType<VxeInputPropTypes.Type>, default: 'text' },
68
+ clearable: { type: Boolean as PropType<VxeInputPropTypes.Clearable>, default: () => globalConfigStore.input.clearable },
69
+ readonly: Boolean as PropType<VxeInputPropTypes.Readonly>,
70
+ disabled: Boolean as PropType<VxeInputPropTypes.Disabled>,
71
+ placeholder: {
72
+ type: String as PropType<VxeInputPropTypes.Placeholder>,
73
+ default: () => XEUtils.eqNull(globalConfigStore.input.placeholder) ? getI18n('vxe.base.pleaseInput') : globalConfigStore.input.placeholder
74
+ },
75
+ maxlength: [String, Number] as PropType<VxeInputPropTypes.Maxlength>,
76
+ autocomplete: { type: String as PropType<VxeInputPropTypes.Autocomplete>, default: 'off' },
77
+ align: String as PropType<VxeInputPropTypes.Align>,
78
+ form: String as PropType<VxeInputPropTypes.Form>,
79
+ className: String as PropType<VxeInputPropTypes.ClassName>,
80
+ size: { type: String as PropType<VxeInputPropTypes.Size>, default: () => globalConfigStore.input.size || globalConfigStore.size },
81
+ multiple: Boolean as PropType<VxeInputPropTypes.Multiple>,
82
+
83
+ // text
84
+ showWordCount: Boolean as PropType<VxeInputPropTypes.ShowWordCount>,
85
+ countMethod: Function as PropType<VxeInputPropTypes.CountMethod>,
86
+
87
+ // number、integer、float
88
+ min: { type: [String, Number] as PropType<VxeInputPropTypes.Min>, default: null },
89
+ max: { type: [String, Number] as PropType<VxeInputPropTypes.Max>, default: null },
90
+ step: [String, Number] as PropType<VxeInputPropTypes.Step>,
91
+ exponential: { type: Boolean as PropType<VxeInputPropTypes.Exponential>, default: () => globalConfigStore.input.exponential },
92
+
93
+ // number、integer、float、password
94
+ controls: { type: Boolean as PropType<VxeInputPropTypes.Controls>, default: () => globalConfigStore.input.controls },
95
+
96
+ // float
97
+ digits: { type: [String, Number] as PropType<VxeInputPropTypes.Digits>, default: () => globalConfigStore.input.digits },
98
+
99
+ // date、week、month、quarter、year
100
+ startDate: { type: [String, Number, Date] as PropType<VxeInputPropTypes.MinDate>, default: () => globalConfigStore.input.startDate },
101
+ endDate: { type: [String, Number, Date] as PropType<VxeInputPropTypes.MaxDate>, default: () => globalConfigStore.input.endDate },
102
+ minDate: [String, Number, Date] as PropType<VxeInputPropTypes.MinDate>,
103
+ maxDate: [String, Number, Date] as PropType<VxeInputPropTypes.MaxDate>,
104
+ // 已废弃 startWeek,被 startDay 替换
105
+ startWeek: Number as PropType<VxeInputPropTypes.StartDay>,
106
+ startDay: { type: [String, Number] as PropType<VxeInputPropTypes.StartDay>, default: () => globalConfigStore.input.startDay },
107
+ labelFormat: { type: String as PropType<VxeInputPropTypes.LabelFormat>, default: () => globalConfigStore.input.labelFormat },
108
+ valueFormat: { type: String as PropType<VxeInputPropTypes.ValueFormat>, default: () => globalConfigStore.input.valueFormat },
109
+ editable: { type: Boolean as PropType<VxeInputPropTypes.Editable>, default: true },
110
+ festivalMethod: { type: Function as PropType<VxeInputPropTypes.FestivalMethod>, default: () => globalConfigStore.input.festivalMethod },
111
+ disabledMethod: { type: Function as PropType<VxeInputPropTypes.DisabledMethod>, default: () => globalConfigStore.input.disabledMethod },
112
+
113
+ // week
114
+ selectDay: { type: [String, Number] as PropType<VxeInputPropTypes.SelectDay>, default: () => globalConfigStore.input.selectDay },
115
+
116
+ prefixIcon: String as PropType<VxeInputPropTypes.PrefixIcon>,
117
+ suffixIcon: String as PropType<VxeInputPropTypes.SuffixIcon>,
118
+ placement: String as PropType<VxeInputPropTypes.Placement>,
119
+ transfer: { type: Boolean as PropType<VxeInputPropTypes.Transfer>, default: () => globalConfigStore.input.transfer }
120
+ },
121
+ emits: [
122
+ 'update:modelValue',
123
+ 'input',
124
+ 'change',
125
+ 'keydown',
126
+ 'keyup',
127
+ 'wheel',
128
+ 'click',
129
+ 'focus',
130
+ 'blur',
131
+ 'clear',
132
+ 'search-click',
133
+ 'toggle-visible',
134
+ 'prev-number',
135
+ 'next-number',
136
+ 'prefix-click',
137
+ 'suffix-click',
138
+ 'date-prev',
139
+ 'date-today',
140
+ 'date-next'
141
+ ] as VxeInputEmits,
142
+ setup (props, context) {
143
+ const { slots, emit } = context
144
+ const $xeform = inject<VxeFormConstructor & VxeFormPrivateMethods | null>('$xeForm', null)
145
+ const $xeformiteminfo = inject<VxeFormDefines.ProvideItemInfo | null>('$xeFormItemInfo', null)
146
+
147
+ const xID = XEUtils.uniqueId()
148
+
149
+ const computeSize = useSize(props)
150
+
151
+ const reactData = reactive<InputReactData>({
152
+ inited: false,
153
+ panelIndex: 0,
154
+ showPwd: false,
155
+ visiblePanel: false,
156
+ animatVisible: false,
157
+ panelStyle: null,
158
+ panelPlacement: '',
159
+ isActivated: false,
160
+ inputValue: props.modelValue,
161
+ datetimePanelValue: null,
162
+ datePanelValue: null,
163
+ datePanelLabel: '',
164
+ datePanelType: 'day',
165
+ selectMonth: null,
166
+ currentDate: null
167
+ })
168
+
169
+ const refElem = ref() as Ref<HTMLDivElement>
170
+ const refInputTarget = ref() as Ref<HTMLInputElement>
171
+ const refInputPanel = ref() as Ref<HTMLDivElement>
172
+ const refInputTimeBody = ref() as Ref<HTMLDivElement>
173
+
174
+ const refMaps: InputPrivateRef = {
175
+ refElem,
176
+ refInput: refInputTarget
177
+ }
178
+
179
+ const $xeinput = {
180
+ xID,
181
+ props,
182
+ context,
183
+ reactData,
184
+ getRefMaps: () => refMaps
185
+ } as unknown as VxeInputConstructor
186
+
187
+ let inputMethods = {} as InputMethods
188
+
189
+ const parseDate = (value: VxeInputPropTypes.ModelValue, format: string) => {
190
+ const { type } = props
191
+ if (type === 'time') {
192
+ return toStringTimeDate(value)
193
+ }
194
+ return XEUtils.toStringDate(value, format)
195
+ }
196
+
197
+ const computeIsDateTimeType = computed(() => {
198
+ const { type } = props
199
+ return type === 'time' || type === 'datetime'
200
+ })
201
+
202
+ const computeIsNumType = computed(() => {
203
+ return ['number', 'integer', 'float'].indexOf(props.type) > -1
204
+ })
205
+
206
+ const computeInputCount = computed(() => {
207
+ return XEUtils.getSize(reactData.inputValue)
208
+ })
209
+
210
+ const computeIsCountError = computed(() => {
211
+ const inputCount = computeInputCount.value
212
+ return props.maxlength && inputCount > XEUtils.toNumber(props.maxlength)
213
+ })
214
+
215
+ const computeIsDatePickerType = computed(() => {
216
+ const isDateTimeType = computeIsDateTimeType.value
217
+ return isDateTimeType || ['date', 'week', 'month', 'quarter', 'year'].indexOf(props.type) > -1
218
+ })
219
+
220
+ const computeIsPawdType = computed(() => {
221
+ return props.type === 'password'
222
+ })
223
+
224
+ const computeIsSearchType = computed(() => {
225
+ return props.type === 'search'
226
+ })
227
+
228
+ const computeDigitsValue = computed(() => {
229
+ return XEUtils.toInteger(props.digits) || 1
230
+ })
231
+
232
+ const computeStepValue = computed(() => {
233
+ const { type } = props
234
+ const digitsValue = computeDigitsValue.value
235
+ const step = props.step
236
+ if (type === 'integer') {
237
+ return XEUtils.toInteger(step) || 1
238
+ } else if (type === 'float') {
239
+ return XEUtils.toNumber(step) || (1 / Math.pow(10, digitsValue))
240
+ }
241
+ return XEUtils.toNumber(step) || 1
242
+ })
243
+
244
+ const computeIsClearable = computed(() => {
245
+ const { type } = props
246
+ const isNumType = computeIsNumType.value
247
+ const isDatePickerType = computeIsDatePickerType.value
248
+ const isPawdType = computeIsPawdType.value
249
+ return props.clearable && (isPawdType || isNumType || isDatePickerType || type === 'text' || type === 'search')
250
+ })
251
+
252
+ const computeDateStartTime = computed(() => {
253
+ return props.startDate ? XEUtils.toStringDate(props.startDate) : null
254
+ })
255
+
256
+ const computeDateEndTime = computed(() => {
257
+ return props.endDate ? XEUtils.toStringDate(props.endDate) : null
258
+ })
259
+
260
+ const computeSupportMultiples = computed(() => {
261
+ return ['date', 'week', 'month', 'quarter', 'year'].includes(props.type)
262
+ })
263
+
264
+ const computeDateListValue = computed(() => {
265
+ const { modelValue, multiple } = props
266
+ const isDatePickerType = computeIsDatePickerType.value
267
+ const dateValueFormat = computeDateValueFormat.value
268
+ if (multiple && modelValue && isDatePickerType) {
269
+ return XEUtils.toValueString(modelValue).split(',').map(item => {
270
+ const date = parseDate(item, dateValueFormat)
271
+ if (XEUtils.isValidDate(date)) {
272
+ return date
273
+ }
274
+ return null
275
+ })
276
+ }
277
+ return []
278
+ })
279
+
280
+ const computeDateMultipleValue = computed(() => {
281
+ const dateListValue = computeDateListValue.value
282
+ const dateValueFormat = computeDateValueFormat.value
283
+ return dateListValue.map(date => XEUtils.toDateString(date, dateValueFormat))
284
+ })
285
+
286
+ const computeDateMultipleLabel = computed(() => {
287
+ const dateListValue = computeDateListValue.value
288
+ const dateLabelFormat = computeDateLabelFormat.value
289
+ return dateListValue.map(date => XEUtils.toDateString(date, dateLabelFormat)).join(', ')
290
+ })
291
+
292
+ const computeDateValueFormat = computed(() => {
293
+ const { type } = props
294
+ return type === 'time' ? 'HH:mm:ss' : (props.valueFormat || (type === 'datetime' ? 'yyyy-MM-dd HH:mm:ss' : 'yyyy-MM-dd'))
295
+ })
296
+
297
+ const computeDateValue = computed(() => {
298
+ const { modelValue } = props
299
+ const isDatePickerType = computeIsDatePickerType.value
300
+ const dateValueFormat = computeDateValueFormat.value
301
+ let val = null
302
+ if (modelValue && isDatePickerType) {
303
+ const date = parseDate(modelValue, dateValueFormat)
304
+ if (XEUtils.isValidDate(date)) {
305
+ val = date
306
+ }
307
+ }
308
+ return val
309
+ })
310
+
311
+ const computeIsDisabledPrevDateBtn = computed(() => {
312
+ const dateStartTime = computeDateStartTime.value
313
+ const { selectMonth } = reactData
314
+ if (selectMonth && dateStartTime) {
315
+ return selectMonth <= dateStartTime
316
+ }
317
+ return false
318
+ })
319
+
320
+ const computeIsDisabledNextDateBtn = computed(() => {
321
+ const dateEndTime = computeDateEndTime.value
322
+ const { selectMonth } = reactData
323
+ if (selectMonth && dateEndTime) {
324
+ return selectMonth >= dateEndTime
325
+ }
326
+ return false
327
+ })
328
+
329
+ const computeDateTimeLabel = computed(() => {
330
+ const { datetimePanelValue } = reactData
331
+ if (datetimePanelValue) {
332
+ return XEUtils.toDateString(datetimePanelValue, 'HH:mm:ss')
333
+ }
334
+ return ''
335
+ })
336
+
337
+ const computeDateHMSTime = computed(() => {
338
+ const dateValue = computeDateValue.value
339
+ const isDateTimeType = computeIsDateTimeType.value
340
+ return dateValue && isDateTimeType ? (dateValue.getHours() * 3600 + dateValue.getMinutes() * 60 + dateValue.getSeconds()) * 1000 : 0
341
+ })
342
+
343
+ const computeDateLabelFormat = computed(() => {
344
+ const isDatePickerType = computeIsDatePickerType.value
345
+ if (isDatePickerType) {
346
+ return props.labelFormat || getI18n(`vxe.input.date.labelFormat.${props.type}`)
347
+ }
348
+ return null
349
+ })
350
+
351
+ const computeYearList = computed(() => {
352
+ const { selectMonth, currentDate } = reactData
353
+ const years: DateYearItem[] = []
354
+ if (selectMonth && currentDate) {
355
+ const currFullYear = currentDate.getFullYear()
356
+ const selectFullYear = selectMonth.getFullYear()
357
+ const startYearDate = new Date(selectFullYear - selectFullYear % yearSize, 0, 1)
358
+ for (let index = -4; index < yearSize + 4; index++) {
359
+ const date = XEUtils.getWhatYear(startYearDate, index, 'first')
360
+ const itemFullYear = date.getFullYear()
361
+ years.push({
362
+ date,
363
+ isCurrent: true,
364
+ isPrev: index < 0,
365
+ isNow: currFullYear === itemFullYear,
366
+ isNext: index >= yearSize,
367
+ year: itemFullYear
368
+ })
369
+ }
370
+ }
371
+ return years
372
+ })
373
+
374
+ const computeSelectDatePanelLabel = computed(() => {
375
+ const isDatePickerType = computeIsDatePickerType.value
376
+ if (isDatePickerType) {
377
+ const { datePanelType, selectMonth } = reactData
378
+ const yearList = computeYearList.value
379
+ let year = ''
380
+ let month
381
+ if (selectMonth) {
382
+ year = selectMonth.getFullYear()
383
+ month = selectMonth.getMonth() + 1
384
+ }
385
+ if (datePanelType === 'quarter') {
386
+ return getI18n('vxe.input.date.quarterLabel', [year])
387
+ } else if (datePanelType === 'month') {
388
+ return getI18n('vxe.input.date.monthLabel', [year])
389
+ } else if (datePanelType === 'year') {
390
+ return yearList.length ? `${yearList[0].year} - ${yearList[yearList.length - 1].year}` : ''
391
+ }
392
+ return getI18n('vxe.input.date.dayLabel', [year, month ? getI18n(`vxe.input.date.m${month}`) : '-'])
393
+ }
394
+ return ''
395
+ })
396
+
397
+ const computeFirstDayOfWeek = computed(() => {
398
+ const { startDay, startWeek } = props
399
+ return XEUtils.toNumber(XEUtils.isNumber(startDay) || XEUtils.isString(startDay) ? startDay : startWeek) as VxeInputPropTypes.StartDay
400
+ })
401
+
402
+ const computeWeekDatas = computed(() => {
403
+ const weeks = []
404
+ const isDatePickerType = computeIsDatePickerType.value
405
+ if (isDatePickerType) {
406
+ let sWeek = computeFirstDayOfWeek.value
407
+ weeks.push(sWeek)
408
+ for (let index = 0; index < 6; index++) {
409
+ if (sWeek >= 6) {
410
+ sWeek = 0
411
+ } else {
412
+ sWeek++
413
+ }
414
+ weeks.push(sWeek)
415
+ }
416
+ }
417
+ return weeks
418
+ })
419
+
420
+ const computeDateHeaders = computed(() => {
421
+ const isDatePickerType = computeIsDatePickerType.value
422
+ if (isDatePickerType) {
423
+ const weekDatas = computeWeekDatas.value
424
+ return weekDatas.map((day) => {
425
+ return {
426
+ value: day,
427
+ label: getI18n(`vxe.input.date.weeks.w${day}`)
428
+ }
429
+ })
430
+ }
431
+ return []
432
+ })
433
+
434
+ const computeWeekHeaders = computed(() => {
435
+ const isDatePickerType = computeIsDatePickerType.value
436
+ if (isDatePickerType) {
437
+ const dateHeaders = computeDateHeaders.value
438
+ return [{ label: getI18n('vxe.input.date.weeks.w') }].concat(dateHeaders)
439
+ }
440
+ return []
441
+ })
442
+
443
+ const computeYearDatas = computed(() => {
444
+ const yearList = computeYearList.value
445
+ return XEUtils.chunk(yearList, 4)
446
+ })
447
+
448
+ const computeQuarterList = computed(() => {
449
+ const { selectMonth, currentDate } = reactData
450
+ const quarters: DateQuarterItem[] = []
451
+ if (selectMonth && currentDate) {
452
+ const currFullYear = currentDate.getFullYear()
453
+ const currQuarter = getDateQuarter(currentDate)
454
+ const firstYear = XEUtils.getWhatYear(selectMonth, 0, 'first')
455
+ const selFullYear = firstYear.getFullYear()
456
+ for (let index = -2; index < quarterSize - 2; index++) {
457
+ const date = XEUtils.getWhatQuarter(firstYear, index)
458
+ const itemFullYear = date.getFullYear()
459
+ const itemQuarter = getDateQuarter(date)
460
+ const isPrev = itemFullYear < selFullYear
461
+ quarters.push({
462
+ date,
463
+ isPrev,
464
+ isCurrent: itemFullYear === selFullYear,
465
+ isNow: itemFullYear === currFullYear && itemQuarter === currQuarter,
466
+ isNext: !isPrev && itemFullYear > selFullYear,
467
+ quarter: itemQuarter
468
+ })
469
+ }
470
+ }
471
+ return quarters
472
+ })
473
+
474
+ const computeQuarterDatas = computed(() => {
475
+ const quarterList = computeQuarterList.value
476
+ return XEUtils.chunk(quarterList, 2)
477
+ })
478
+
479
+ const computeMonthList = computed(() => {
480
+ const { selectMonth, currentDate } = reactData
481
+ const months: DateMonthItem[] = []
482
+ if (selectMonth && currentDate) {
483
+ const currFullYear = currentDate.getFullYear()
484
+ const currMonth = currentDate.getMonth()
485
+ const selFullYear = XEUtils.getWhatYear(selectMonth, 0, 'first').getFullYear()
486
+ for (let index = -4; index < monthSize - 4; index++) {
487
+ const date = XEUtils.getWhatYear(selectMonth, 0, index)
488
+ const itemFullYear = date.getFullYear()
489
+ const itemMonth = date.getMonth()
490
+ const isPrev = itemFullYear < selFullYear
491
+ months.push({
492
+ date,
493
+ isPrev,
494
+ isCurrent: itemFullYear === selFullYear,
495
+ isNow: itemFullYear === currFullYear && itemMonth === currMonth,
496
+ isNext: !isPrev && itemFullYear > selFullYear,
497
+ month: itemMonth
498
+ })
499
+ }
500
+ }
501
+ return months
502
+ })
503
+
504
+ const computeMonthDatas = computed(() => {
505
+ const monthList = computeMonthList.value
506
+ return XEUtils.chunk(monthList, 4)
507
+ })
508
+
509
+ const computeDayList = computed(() => {
510
+ const { selectMonth, currentDate } = reactData
511
+ const days: DateDayItem[] = []
512
+ if (selectMonth && currentDate) {
513
+ const dateHMSTime = computeDateHMSTime.value
514
+ const weekDatas = computeWeekDatas.value
515
+ const currFullYear = currentDate.getFullYear()
516
+ const currMonth = currentDate.getMonth()
517
+ const currDate = currentDate.getDate()
518
+ const selFullYear = selectMonth.getFullYear()
519
+ const selMonth = selectMonth.getMonth()
520
+ const selDay = selectMonth.getDay()
521
+ const prevOffsetDate = -weekDatas.indexOf(selDay)
522
+ const startDayDate = new Date(XEUtils.getWhatDay(selectMonth, prevOffsetDate).getTime() + dateHMSTime)
523
+ for (let index = 0; index < 42; index++) {
524
+ const date = XEUtils.getWhatDay(startDayDate, index)
525
+ const itemFullYear = date.getFullYear()
526
+ const itemMonth = date.getMonth()
527
+ const itemDate = date.getDate()
528
+ const isPrev = date < selectMonth
529
+ days.push({
530
+ date,
531
+ isPrev,
532
+ isCurrent: itemFullYear === selFullYear && itemMonth === selMonth,
533
+ isNow: itemFullYear === currFullYear && itemMonth === currMonth && itemDate === currDate,
534
+ isNext: !isPrev && selMonth !== itemMonth,
535
+ label: itemDate
536
+ })
537
+ }
538
+ }
539
+ return days
540
+ })
541
+
542
+ const computeDayDatas = computed(() => {
543
+ const dayList = computeDayList.value
544
+ return XEUtils.chunk(dayList, 7)
545
+ })
546
+
547
+ const computeWeekDates = computed(() => {
548
+ const dayDatas = computeDayDatas.value
549
+ const firstDayOfWeek = computeFirstDayOfWeek.value
550
+ return dayDatas.map((list) => {
551
+ const firstItem = list[0]
552
+ const item: DateDayItem = {
553
+ date: firstItem.date,
554
+ isWeekNumber: true,
555
+ isPrev: false,
556
+ isCurrent: false,
557
+ isNow: false,
558
+ isNext: false,
559
+ label: XEUtils.getYearWeek(firstItem.date, firstDayOfWeek)
560
+ }
561
+ return [item].concat(list)
562
+ })
563
+ })
564
+
565
+ const computeHourList = computed(() => {
566
+ const list: DateHourMinuteSecondItem[] = []
567
+ const isDateTimeType = computeIsDateTimeType.value
568
+ if (isDateTimeType) {
569
+ for (let index = 0; index < 24; index++) {
570
+ list.push({
571
+ value: index,
572
+ label: ('' + index).padStart(2, '0')
573
+ })
574
+ }
575
+ }
576
+ return list
577
+ })
578
+
579
+ const computeMinuteList = computed(() => {
580
+ const list: DateHourMinuteSecondItem[] = []
581
+ const isDateTimeType = computeIsDateTimeType.value
582
+ if (isDateTimeType) {
583
+ for (let index = 0; index < 60; index++) {
584
+ list.push({
585
+ value: index,
586
+ label: ('' + index).padStart(2, '0')
587
+ })
588
+ }
589
+ }
590
+ return list
591
+ })
592
+
593
+ const computeSecondList = computed(() => {
594
+ const minuteList = computeMinuteList.value
595
+ return minuteList
596
+ })
597
+
598
+ const computeInpReadonly = computed(() => {
599
+ const { type, readonly, editable, multiple } = props
600
+ return readonly || multiple || !editable || type === 'week' || type === 'quarter'
601
+ })
602
+
603
+ const computeInputType = computed(() => {
604
+ const { type } = props
605
+ const { showPwd } = reactData
606
+ const isNumType = computeIsNumType.value
607
+ const isDatePickerType = computeIsDatePickerType.value
608
+ const isPawdType = computeIsPawdType.value
609
+ if (isDatePickerType || isNumType || (isPawdType && showPwd) || type === 'number') {
610
+ return 'text'
611
+ }
612
+ return type
613
+ })
614
+
615
+ const computeInpPlaceholder = computed(() => {
616
+ const { placeholder } = props
617
+ if (placeholder) {
618
+ return getFuncText(placeholder)
619
+ }
620
+ return ''
621
+ })
622
+
623
+ const computeInpMaxlength = computed(() => {
624
+ const { maxlength } = props
625
+ const isNumType = computeIsNumType.value
626
+ // 数值最大长度限制 16 位,包含小数
627
+ return isNumType && !XEUtils.toNumber(maxlength) ? 16 : maxlength
628
+ })
629
+
630
+ const computeInpImmediate = computed(() => {
631
+ const { type, immediate } = props
632
+ return immediate || !(type === 'text' || type === 'number' || type === 'integer' || type === 'float')
633
+ })
634
+
635
+ const computeNumValue = computed(() => {
636
+ const { type } = props
637
+ const { inputValue } = reactData
638
+ const isNumType = computeIsNumType.value
639
+ if (isNumType) {
640
+ return type === 'integer' ? XEUtils.toInteger(handleNumber(inputValue)) : XEUtils.toNumber(handleNumber(inputValue))
641
+ }
642
+ return 0
643
+ })
644
+
645
+ const computeIsDisabledSubtractNumber = computed(() => {
646
+ const { min } = props
647
+ const { inputValue } = reactData
648
+ const isNumType = computeIsNumType.value
649
+ const numValue = computeNumValue.value
650
+ // 当有值时再进行判断
651
+ if ((inputValue || inputValue === 0) && isNumType && min !== null) {
652
+ return numValue <= XEUtils.toNumber(min)
653
+ }
654
+ return false
655
+ })
656
+
657
+ const computeIsDisabledAddNumber = computed(() => {
658
+ const { max } = props
659
+ const { inputValue } = reactData
660
+ const isNumType = computeIsNumType.value
661
+ const numValue = computeNumValue.value
662
+ // 当有值时再进行判断
663
+ if ((inputValue || inputValue === 0) && isNumType && max !== null) {
664
+ return numValue >= XEUtils.toNumber(max)
665
+ }
666
+ return false
667
+ })
668
+
669
+ const getNumberValue = (val: any) => {
670
+ const { type, exponential } = props
671
+ const inpMaxlength = computeInpMaxlength.value
672
+ const digitsValue = computeDigitsValue.value
673
+ const restVal = (type === 'float' ? toFloatValueFixed(val, digitsValue) : XEUtils.toValueString(val))
674
+ if (exponential && (val === restVal || XEUtils.toValueString(val).toLowerCase() === XEUtils.toNumber(restVal).toExponential())) {
675
+ return val
676
+ }
677
+ return restVal.slice(0, inpMaxlength)
678
+ }
679
+
680
+ const triggerEvent = (evnt: Event & { type: 'input' | 'change' | 'keydown' | 'keyup' | 'wheel' | 'click' | 'focus' | 'blur' }) => {
681
+ const { inputValue } = reactData
682
+ inputMethods.dispatchEvent(evnt.type, { value: inputValue }, evnt)
683
+ }
684
+
685
+ const emitModel = (value: string, evnt: Event | { type: string }) => {
686
+ reactData.inputValue = value
687
+ emit('update:modelValue', value)
688
+ inputMethods.dispatchEvent('input', { value }, evnt)
689
+ if (XEUtils.toValueString(props.modelValue) !== value) {
690
+ inputMethods.dispatchEvent('change', { value }, evnt)
691
+ // 自动更新校验状态
692
+ if ($xeform && $xeformiteminfo) {
693
+ $xeform.triggerItemEvent(evnt, $xeformiteminfo.itemConfig.field, value)
694
+ }
695
+ }
696
+ }
697
+
698
+ const emitInputEvent = (value: any, evnt: Event) => {
699
+ const isDatePickerType = computeIsDatePickerType.value
700
+ const inpImmediate = computeInpImmediate.value
701
+ reactData.inputValue = value
702
+ if (!isDatePickerType) {
703
+ if (inpImmediate) {
704
+ emitModel(value, evnt)
705
+ } else {
706
+ inputMethods.dispatchEvent('input', { value }, evnt)
707
+ }
708
+ }
709
+ }
710
+
711
+ const inputEvent = (evnt: Event & { type: 'input' }) => {
712
+ const inputElem = evnt.target as HTMLInputElement
713
+ const value = inputElem.value
714
+ emitInputEvent(value, evnt)
715
+ }
716
+
717
+ const changeEvent = (evnt: Event & { type: 'change' }) => {
718
+ const inpImmediate = computeInpImmediate.value
719
+ if (!inpImmediate) {
720
+ triggerEvent(evnt)
721
+ }
722
+ }
723
+
724
+ const focusEvent = (evnt: Event & { type: 'focus' }) => {
725
+ reactData.isActivated = true
726
+ const isDatePickerType = computeIsDatePickerType.value
727
+ if (isDatePickerType) {
728
+ datePickerOpenEvent(evnt)
729
+ }
730
+ triggerEvent(evnt)
731
+ }
732
+
733
+ const clickPrefixEvent = (evnt: Event) => {
734
+ const { disabled } = props
735
+ if (!disabled) {
736
+ const { inputValue } = reactData
737
+ inputMethods.dispatchEvent('prefix-click', { value: inputValue }, evnt)
738
+ }
739
+ }
740
+
741
+ let hidePanelTimeout: number
742
+
743
+ const hidePanel = (): Promise<void> => {
744
+ return new Promise(resolve => {
745
+ reactData.visiblePanel = false
746
+ hidePanelTimeout = window.setTimeout(() => {
747
+ reactData.animatVisible = false
748
+ resolve()
749
+ }, 350)
750
+ })
751
+ }
752
+
753
+ const clearValueEvent = (evnt: Event, value: VxeInputPropTypes.ModelValue) => {
754
+ const { type } = props
755
+ const isNumType = computeIsNumType.value
756
+ const isDatePickerType = computeIsDatePickerType.value
757
+ if (isDatePickerType) {
758
+ hidePanel()
759
+ }
760
+ if (isNumType || ['text', 'search', 'password'].indexOf(type) > -1) {
761
+ focus()
762
+ }
763
+ inputMethods.dispatchEvent('clear', { value }, evnt)
764
+ }
765
+
766
+ const clickSuffixEvent = (evnt: Event) => {
767
+ const { disabled } = props
768
+ if (!disabled) {
769
+ if (hasClass(evnt.currentTarget, 'is--clear')) {
770
+ emitModel('', evnt)
771
+ clearValueEvent(evnt, '')
772
+ } else {
773
+ const { inputValue } = reactData
774
+ inputMethods.dispatchEvent('suffix-click', { value: inputValue }, evnt)
775
+ }
776
+ }
777
+ }
778
+
779
+ const dateParseValue = (value?: VxeInputPropTypes.ModelValue) => {
780
+ const { type } = props
781
+ const { valueFormat } = props
782
+ const dateLabelFormat = computeDateLabelFormat.value
783
+ const firstDayOfWeek = computeFirstDayOfWeek.value
784
+ let dValue: Date | null = null
785
+ let dLabel = ''
786
+ if (value) {
787
+ dValue = parseDate(value, valueFormat)
788
+ }
789
+ if (XEUtils.isValidDate(dValue)) {
790
+ dLabel = XEUtils.toDateString(dValue, dateLabelFormat, { firstDay: firstDayOfWeek })
791
+ // 由于年份和第几周是冲突的行为,所以需要特殊处理,判断是否跨年
792
+ if (dateLabelFormat && type === 'week') {
793
+ const firstWeekDate = XEUtils.getWhatWeek(dValue, 0, firstDayOfWeek, firstDayOfWeek)
794
+ if (firstWeekDate.getFullYear() < dValue.getFullYear()) {
795
+ const yyIndex = dateLabelFormat.indexOf('yyyy')
796
+ if (yyIndex > -1) {
797
+ const yyNum = Number(dLabel.substring(yyIndex, yyIndex + 4))
798
+ if (yyNum && !isNaN(yyNum)) {
799
+ dLabel = dLabel.replace(`${yyNum}`, `${yyNum - 1}`)
800
+ }
801
+ }
802
+ }
803
+ }
804
+ } else {
805
+ dValue = null
806
+ }
807
+ reactData.datePanelValue = dValue
808
+ reactData.datePanelLabel = dLabel
809
+ }
810
+
811
+ /**
812
+ * 值变化时处理
813
+ */
814
+ const changeValue = () => {
815
+ const isDatePickerType = computeIsDatePickerType.value
816
+ const { inputValue } = reactData
817
+ if (isDatePickerType) {
818
+ dateParseValue(inputValue)
819
+ reactData.inputValue = props.multiple ? computeDateMultipleLabel.value : reactData.datePanelLabel
820
+ }
821
+ }
822
+
823
+ /**
824
+ * 检查初始值
825
+ */
826
+ const initValue = () => {
827
+ const { type } = props
828
+ const { inputValue } = reactData
829
+ const isDatePickerType = computeIsDatePickerType.value
830
+ const digitsValue = computeDigitsValue.value
831
+ if (isDatePickerType) {
832
+ changeValue()
833
+ } else if (type === 'float') {
834
+ if (inputValue) {
835
+ const validValue = toFloatValueFixed(inputValue, digitsValue)
836
+ if (inputValue !== validValue) {
837
+ emitModel(validValue, { type: 'init' })
838
+ }
839
+ }
840
+ }
841
+ }
842
+
843
+ const vaildMaxNum = (num: number | string) => {
844
+ return props.max === null || XEUtils.toNumber(num) <= XEUtils.toNumber(props.max)
845
+ }
846
+
847
+ const vaildMinNum = (num: number | string) => {
848
+ return props.min === null || XEUtils.toNumber(num) >= XEUtils.toNumber(props.min)
849
+ }
850
+
851
+ const dateRevert = () => {
852
+ reactData.inputValue = props.multiple ? computeDateMultipleLabel.value : reactData.datePanelLabel
853
+ }
854
+
855
+ const dateCheckMonth = (date: Date) => {
856
+ const month = XEUtils.getWhatMonth(date, 0, 'first')
857
+ if (!XEUtils.isEqual(month, reactData.selectMonth)) {
858
+ reactData.selectMonth = month
859
+ }
860
+ }
861
+
862
+ const dateChange = (date: Date) => {
863
+ const { modelValue, multiple } = props
864
+ const { datetimePanelValue } = reactData
865
+ const isDateTimeType = computeIsDateTimeType.value
866
+ const dateValueFormat = computeDateValueFormat.value
867
+ const firstDayOfWeek = computeFirstDayOfWeek.value
868
+ if (props.type === 'week') {
869
+ const sWeek = XEUtils.toNumber(props.selectDay) as VxeInputPropTypes.SelectDay
870
+ date = XEUtils.getWhatWeek(date, 0, sWeek, firstDayOfWeek)
871
+ } else if (isDateTimeType) {
872
+ date.setHours(datetimePanelValue.getHours())
873
+ date.setMinutes(datetimePanelValue.getMinutes())
874
+ date.setSeconds(datetimePanelValue.getSeconds())
875
+ }
876
+ const inpVal = XEUtils.toDateString(date, dateValueFormat, { firstDay: firstDayOfWeek })
877
+ dateCheckMonth(date)
878
+ if (multiple) {
879
+ // 如果为多选
880
+ const dateMultipleValue = computeDateMultipleValue.value
881
+ if (isDateTimeType) {
882
+ // 如果是datetime特殊类型
883
+ const dateListValue = [...computeDateListValue.value]
884
+ const datetimeRest: Date[] = []
885
+ const eqIndex = XEUtils.findIndexOf(dateListValue, val => XEUtils.isDateSame(date, val, 'yyyyMMdd'))
886
+ if (eqIndex === -1) {
887
+ dateListValue.push(date)
888
+ } else {
889
+ dateListValue.splice(eqIndex, 1)
890
+ }
891
+ dateListValue.forEach(item => {
892
+ if (item) {
893
+ item.setHours(datetimePanelValue.getHours())
894
+ item.setMinutes(datetimePanelValue.getMinutes())
895
+ item.setSeconds(datetimePanelValue.getSeconds())
896
+ datetimeRest.push(item)
897
+ }
898
+ })
899
+ emitModel(datetimeRest.map(date => XEUtils.toDateString(date, dateValueFormat)).join(','), { type: 'update' })
900
+ } else {
901
+ // 如果是日期类型
902
+ if (dateMultipleValue.some(val => XEUtils.isEqual(val, inpVal))) {
903
+ emitModel(dateMultipleValue.filter(val => !XEUtils.isEqual(val, inpVal)).join(','), { type: 'update' })
904
+ } else {
905
+ emitModel(dateMultipleValue.concat([inpVal]).join(','), { type: 'update' })
906
+ }
907
+ }
908
+ } else {
909
+ // 如果为单选
910
+ if (!XEUtils.isEqual(modelValue, inpVal)) {
911
+ emitModel(inpVal, { type: 'update' })
912
+ }
913
+ }
914
+ }
915
+
916
+ const afterCheckValue = () => {
917
+ const { type, min, max, exponential } = props
918
+ const { inputValue, datetimePanelValue } = reactData
919
+ const isNumType = computeIsNumType.value
920
+ const isDatePickerType = computeIsDatePickerType.value
921
+ const dateLabelFormat = computeDateLabelFormat.value
922
+ const inpReadonly = computeInpReadonly.value
923
+ if (!inpReadonly) {
924
+ if (isNumType) {
925
+ if (inputValue) {
926
+ let inpNumVal: number | string = type === 'integer' ? XEUtils.toInteger(handleNumber(inputValue)) : XEUtils.toNumber(handleNumber(inputValue))
927
+ if (!vaildMinNum(inpNumVal)) {
928
+ inpNumVal = min
929
+ } else if (!vaildMaxNum(inpNumVal)) {
930
+ inpNumVal = max
931
+ }
932
+ if (exponential) {
933
+ const inpStringVal = XEUtils.toValueString(inputValue).toLowerCase()
934
+ if (inpStringVal === XEUtils.toNumber(inpNumVal).toExponential()) {
935
+ inpNumVal = inpStringVal
936
+ }
937
+ }
938
+ emitModel(getNumberValue(inpNumVal), { type: 'check' })
939
+ }
940
+ } else if (isDatePickerType) {
941
+ if (inputValue) {
942
+ let inpDateVal: VxeInputPropTypes.ModelValue = parseDate(inputValue, dateLabelFormat as string)
943
+ if (XEUtils.isValidDate(inpDateVal)) {
944
+ if (type === 'time') {
945
+ inpDateVal = XEUtils.toDateString(inpDateVal, dateLabelFormat)
946
+ if (inputValue !== inpDateVal) {
947
+ emitModel(inpDateVal, { type: 'check' })
948
+ }
949
+ reactData.inputValue = inpDateVal
950
+ } else {
951
+ let isChange = false
952
+ const firstDayOfWeek = computeFirstDayOfWeek.value
953
+ if (type === 'datetime') {
954
+ const dateValue = computeDateValue.value
955
+ if (inputValue !== XEUtils.toDateString(dateValue, dateLabelFormat) || inputValue !== XEUtils.toDateString(inpDateVal, dateLabelFormat)) {
956
+ isChange = true
957
+ datetimePanelValue.setHours(inpDateVal.getHours())
958
+ datetimePanelValue.setMinutes(inpDateVal.getMinutes())
959
+ datetimePanelValue.setSeconds(inpDateVal.getSeconds())
960
+ }
961
+ } else {
962
+ isChange = true
963
+ }
964
+ reactData.inputValue = XEUtils.toDateString(inpDateVal, dateLabelFormat, { firstDay: firstDayOfWeek })
965
+ if (isChange) {
966
+ dateChange(inpDateVal)
967
+ }
968
+ }
969
+ } else {
970
+ dateRevert()
971
+ }
972
+ } else {
973
+ emitModel('', { type: 'check' })
974
+ }
975
+ }
976
+ }
977
+ }
978
+
979
+ const blurEvent = (evnt: Event & { type: 'blur' }) => {
980
+ const { inputValue } = reactData
981
+ const inpImmediate = computeInpImmediate.value
982
+ if (!inpImmediate) {
983
+ emitModel(inputValue, evnt)
984
+ }
985
+ afterCheckValue()
986
+ if (!reactData.visiblePanel) {
987
+ reactData.isActivated = false
988
+ }
989
+ inputMethods.dispatchEvent('blur', { value: inputValue }, evnt)
990
+ }
991
+
992
+ // 密码
993
+ const passwordToggleEvent = (evnt: Event) => {
994
+ const { readonly, disabled } = props
995
+ const { showPwd } = reactData
996
+ if (!disabled && !readonly) {
997
+ reactData.showPwd = !showPwd
998
+ }
999
+ inputMethods.dispatchEvent('toggle-visible', { visible: reactData.showPwd }, evnt)
1000
+ }
1001
+ // 密码
1002
+
1003
+ // 搜索
1004
+ const searchEvent = (evnt: Event) => {
1005
+ inputMethods.dispatchEvent('search-click', {}, evnt)
1006
+ }
1007
+ // 搜索
1008
+
1009
+ // 数值
1010
+ const numberChange = (isPlus: boolean, evnt: Event) => {
1011
+ const { min, max, type } = props
1012
+ const { inputValue } = reactData
1013
+ const stepValue = computeStepValue.value
1014
+ const numValue = type === 'integer' ? XEUtils.toInteger(handleNumber(inputValue)) : XEUtils.toNumber(handleNumber(inputValue))
1015
+ const newValue = isPlus ? XEUtils.add(numValue, stepValue) : XEUtils.subtract(numValue, stepValue)
1016
+ let restNum: number | string
1017
+ if (!vaildMinNum(newValue)) {
1018
+ restNum = min
1019
+ } else if (!vaildMaxNum(newValue)) {
1020
+ restNum = max
1021
+ } else {
1022
+ restNum = newValue
1023
+ }
1024
+ emitInputEvent(getNumberValue(restNum), evnt as (Event & { type: 'input' }))
1025
+ }
1026
+
1027
+ let downbumTimeout: number
1028
+
1029
+ const numberNextEvent = (evnt: Event) => {
1030
+ const { readonly, disabled } = props
1031
+ const isDisabledSubtractNumber = computeIsDisabledSubtractNumber.value
1032
+ clearTimeout(downbumTimeout)
1033
+ if (!disabled && !readonly && !isDisabledSubtractNumber) {
1034
+ numberChange(false, evnt)
1035
+ }
1036
+ inputMethods.dispatchEvent('next-number', {}, evnt)
1037
+ }
1038
+
1039
+ const numberDownNextEvent = (evnt: Event) => {
1040
+ downbumTimeout = window.setTimeout(() => {
1041
+ numberNextEvent(evnt)
1042
+ numberDownNextEvent(evnt)
1043
+ }, 60)
1044
+ }
1045
+
1046
+ const numberPrevEvent = (evnt: Event) => {
1047
+ const { readonly, disabled } = props
1048
+ const isDisabledAddNumber = computeIsDisabledAddNumber.value
1049
+ clearTimeout(downbumTimeout)
1050
+ if (!disabled && !readonly && !isDisabledAddNumber) {
1051
+ numberChange(true, evnt)
1052
+ }
1053
+ inputMethods.dispatchEvent('prev-number', {}, evnt)
1054
+ }
1055
+
1056
+ const numberKeydownEvent = (evnt: KeyboardEvent) => {
1057
+ const isUpArrow = hasEventKey(evnt, EVENT_KEYS.ARROW_UP)
1058
+ const isDwArrow = hasEventKey(evnt, EVENT_KEYS.ARROW_DOWN)
1059
+ if (isUpArrow || isDwArrow) {
1060
+ evnt.preventDefault()
1061
+ if (isUpArrow) {
1062
+ numberPrevEvent(evnt)
1063
+ } else {
1064
+ numberNextEvent(evnt)
1065
+ }
1066
+ }
1067
+ }
1068
+
1069
+ const keydownEvent = (evnt: KeyboardEvent & { type: 'keydown' }) => {
1070
+ const { exponential, controls } = props
1071
+ const isNumType = computeIsNumType.value
1072
+ if (isNumType) {
1073
+ const isCtrlKey = evnt.ctrlKey
1074
+ const isShiftKey = evnt.shiftKey
1075
+ const isAltKey = evnt.altKey
1076
+ const keyCode = evnt.keyCode
1077
+ if (!isCtrlKey && !isShiftKey && !isAltKey && (hasEventKey(evnt, EVENT_KEYS.SPACEBAR) || ((!exponential || keyCode !== 69) && (keyCode >= 65 && keyCode <= 90)) || (keyCode >= 186 && keyCode <= 188) || keyCode >= 191)) {
1078
+ evnt.preventDefault()
1079
+ }
1080
+ if (controls) {
1081
+ numberKeydownEvent(evnt)
1082
+ }
1083
+ }
1084
+ triggerEvent(evnt)
1085
+ }
1086
+
1087
+ const keyupEvent = (evnt: KeyboardEvent & { type: 'keyup' }) => {
1088
+ triggerEvent(evnt)
1089
+ }
1090
+
1091
+ // 数值
1092
+
1093
+ const numberStopDown = () => {
1094
+ clearTimeout(downbumTimeout)
1095
+ }
1096
+
1097
+ const numberDownPrevEvent = (evnt: Event) => {
1098
+ downbumTimeout = window.setTimeout(() => {
1099
+ numberPrevEvent(evnt)
1100
+ numberDownPrevEvent(evnt)
1101
+ }, 60)
1102
+ }
1103
+
1104
+ const numberMousedownEvent = (evnt: MouseEvent) => {
1105
+ numberStopDown()
1106
+ if (evnt.button === 0) {
1107
+ const isPrevNumber = hasClass(evnt.currentTarget, 'is--prev')
1108
+ if (isPrevNumber) {
1109
+ numberPrevEvent(evnt)
1110
+ } else {
1111
+ numberNextEvent(evnt)
1112
+ }
1113
+ downbumTimeout = window.setTimeout(() => {
1114
+ if (isPrevNumber) {
1115
+ numberDownPrevEvent(evnt)
1116
+ } else {
1117
+ numberDownNextEvent(evnt)
1118
+ }
1119
+ }, 500)
1120
+ }
1121
+ }
1122
+
1123
+ const wheelEvent = (evnt: WheelEvent & {
1124
+ type: 'wheel';
1125
+ wheelDelta: number;
1126
+ }) => {
1127
+ const isNumType = computeIsNumType.value
1128
+ if (isNumType && props.controls) {
1129
+ if (reactData.isActivated) {
1130
+ const delta = evnt.deltaY
1131
+ if (delta > 0) {
1132
+ numberNextEvent(evnt)
1133
+ } else if (delta < 0) {
1134
+ numberPrevEvent(evnt)
1135
+ }
1136
+ evnt.preventDefault()
1137
+ }
1138
+ }
1139
+ triggerEvent(evnt)
1140
+ }
1141
+
1142
+ // 日期
1143
+ const dateMonthHandle = (date: Date, offsetMonth: number) => {
1144
+ reactData.selectMonth = XEUtils.getWhatMonth(date, offsetMonth, 'first')
1145
+ }
1146
+
1147
+ const dateNowHandle = () => {
1148
+ const currentDate = XEUtils.getWhatDay(Date.now(), 0, 'first')
1149
+ reactData.currentDate = currentDate
1150
+ dateMonthHandle(currentDate, 0)
1151
+ }
1152
+
1153
+ const dateToggleTypeEvent = () => {
1154
+ let { datePanelType } = reactData
1155
+ if (datePanelType === 'month' || datePanelType === 'quarter') {
1156
+ datePanelType = 'year'
1157
+ } else {
1158
+ datePanelType = 'month'
1159
+ }
1160
+ reactData.datePanelType = datePanelType
1161
+ }
1162
+
1163
+ const datePrevEvent = (evnt: Event) => {
1164
+ const { type } = props
1165
+ const { datePanelType, selectMonth } = reactData
1166
+ const isDisabledPrevDateBtn = computeIsDisabledPrevDateBtn.value
1167
+ if (!isDisabledPrevDateBtn) {
1168
+ if (type === 'year') {
1169
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, -yearSize, 'first')
1170
+ } else if (type === 'month' || type === 'quarter') {
1171
+ if (datePanelType === 'year') {
1172
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, -yearSize, 'first')
1173
+ } else {
1174
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, -1, 'first')
1175
+ }
1176
+ } else {
1177
+ if (datePanelType === 'year') {
1178
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, -yearSize, 'first')
1179
+ } else if (datePanelType === 'month') {
1180
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, -1, 'first')
1181
+ } else {
1182
+ reactData.selectMonth = XEUtils.getWhatMonth(selectMonth, -1, 'first')
1183
+ }
1184
+ }
1185
+ inputMethods.dispatchEvent('date-prev', { type }, evnt)
1186
+ }
1187
+ }
1188
+
1189
+ const dateTodayMonthEvent = (evnt: Event) => {
1190
+ dateNowHandle()
1191
+ if (!props.multiple) {
1192
+ dateChange(reactData.currentDate)
1193
+ hidePanel()
1194
+ }
1195
+ inputMethods.dispatchEvent('date-today', { type: props.type }, evnt)
1196
+ }
1197
+
1198
+ const dateNextEvent = (evnt: Event) => {
1199
+ const { type } = props
1200
+ const { datePanelType, selectMonth } = reactData
1201
+ const isDisabledNextDateBtn = computeIsDisabledNextDateBtn.value
1202
+ if (!isDisabledNextDateBtn) {
1203
+ if (type === 'year') {
1204
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, yearSize, 'first')
1205
+ } else if (type === 'month' || type === 'quarter') {
1206
+ if (datePanelType === 'year') {
1207
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, yearSize, 'first')
1208
+ } else {
1209
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, 1, 'first')
1210
+ }
1211
+ } else {
1212
+ if (datePanelType === 'year') {
1213
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, yearSize, 'first')
1214
+ } else if (datePanelType === 'month') {
1215
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, 1, 'first')
1216
+ } else {
1217
+ reactData.selectMonth = XEUtils.getWhatMonth(selectMonth, 1, 'first')
1218
+ }
1219
+ }
1220
+ inputMethods.dispatchEvent('date-next', { type }, evnt)
1221
+ }
1222
+ }
1223
+
1224
+ const isDateDisabled = (item: { date: Date }) => {
1225
+ const { disabledMethod } = props
1226
+ const { datePanelType } = reactData
1227
+ return disabledMethod && disabledMethod({ type: datePanelType, viewType: datePanelType, date: item.date, $input: $xeinput })
1228
+ }
1229
+
1230
+ const dateSelectItem = (date: Date) => {
1231
+ const { type, multiple } = props
1232
+ const { datePanelType } = reactData
1233
+ if (type === 'month') {
1234
+ if (datePanelType === 'year') {
1235
+ reactData.datePanelType = 'month'
1236
+ dateCheckMonth(date)
1237
+ } else {
1238
+ dateChange(date)
1239
+ if (!multiple) {
1240
+ hidePanel()
1241
+ }
1242
+ }
1243
+ } else if (type === 'year') {
1244
+ dateChange(date)
1245
+ if (!multiple) {
1246
+ hidePanel()
1247
+ }
1248
+ } else if (type === 'quarter') {
1249
+ if (datePanelType === 'year') {
1250
+ reactData.datePanelType = 'quarter'
1251
+ dateCheckMonth(date)
1252
+ } else {
1253
+ dateChange(date)
1254
+ if (!multiple) {
1255
+ hidePanel()
1256
+ }
1257
+ }
1258
+ } else {
1259
+ if (datePanelType === 'month') {
1260
+ reactData.datePanelType = type === 'week' ? type : 'day'
1261
+ dateCheckMonth(date)
1262
+ } else if (datePanelType === 'year') {
1263
+ reactData.datePanelType = 'month'
1264
+ dateCheckMonth(date)
1265
+ } else {
1266
+ dateChange(date)
1267
+ if (type === 'datetime') {
1268
+ // 日期带时间
1269
+ } else {
1270
+ if (!multiple) {
1271
+ hidePanel()
1272
+ }
1273
+ }
1274
+ }
1275
+ }
1276
+ }
1277
+
1278
+ const dateSelectEvent = (item: DateYearItem | DateQuarterItem | DateMonthItem | DateDayItem) => {
1279
+ if (!isDateDisabled(item)) {
1280
+ dateSelectItem(item.date)
1281
+ }
1282
+ }
1283
+
1284
+ const dateMoveDay = (offsetDay: Date) => {
1285
+ if (!isDateDisabled({ date: offsetDay })) {
1286
+ const dayList = computeDayList.value
1287
+ if (!dayList.some((item) => XEUtils.isDateSame(item.date, offsetDay, 'yyyyMMdd'))) {
1288
+ dateCheckMonth(offsetDay)
1289
+ }
1290
+ dateParseValue(offsetDay)
1291
+ }
1292
+ }
1293
+
1294
+ const dateMoveYear = (offsetYear: Date) => {
1295
+ if (!isDateDisabled({ date: offsetYear })) {
1296
+ const yearList = computeYearList.value
1297
+ if (!yearList.some((item) => XEUtils.isDateSame(item.date, offsetYear, 'yyyy'))) {
1298
+ dateCheckMonth(offsetYear)
1299
+ }
1300
+ dateParseValue(offsetYear)
1301
+ }
1302
+ }
1303
+
1304
+ const dateMoveQuarter = (offsetQuarter: Date) => {
1305
+ if (!isDateDisabled({ date: offsetQuarter })) {
1306
+ const quarterList = computeQuarterList.value
1307
+ if (!quarterList.some((item) => XEUtils.isDateSame(item.date, offsetQuarter, 'yyyyq'))) {
1308
+ dateCheckMonth(offsetQuarter)
1309
+ }
1310
+ dateParseValue(offsetQuarter)
1311
+ }
1312
+ }
1313
+
1314
+ const dateMoveMonth = (offsetMonth: Date) => {
1315
+ if (!isDateDisabled({ date: offsetMonth })) {
1316
+ const monthList = computeMonthList.value
1317
+ if (!monthList.some((item) => XEUtils.isDateSame(item.date, offsetMonth, 'yyyyMM'))) {
1318
+ dateCheckMonth(offsetMonth)
1319
+ }
1320
+ dateParseValue(offsetMonth)
1321
+ }
1322
+ }
1323
+
1324
+ const dateMouseenterEvent = (item: DateYearItem | DateQuarterItem | DateMonthItem | DateDayItem) => {
1325
+ if (!isDateDisabled(item)) {
1326
+ const { datePanelType } = reactData
1327
+ if (datePanelType === 'month') {
1328
+ dateMoveMonth(item.date)
1329
+ } else if (datePanelType === 'quarter') {
1330
+ dateMoveQuarter(item.date)
1331
+ } else if (datePanelType === 'year') {
1332
+ dateMoveYear(item.date)
1333
+ } else {
1334
+ dateMoveDay(item.date)
1335
+ }
1336
+ }
1337
+ }
1338
+
1339
+ const updateTimePos = (liElem: Element) => {
1340
+ if (liElem) {
1341
+ const height = (liElem as HTMLElement).offsetHeight
1342
+ const ulElem = liElem.parentNode as HTMLElement
1343
+ ulElem.scrollTop = (liElem as HTMLElement).offsetTop - height * 4
1344
+ }
1345
+ }
1346
+
1347
+ const dateTimeChangeEvent = (evnt: Event) => {
1348
+ reactData.datetimePanelValue = new Date(reactData.datetimePanelValue.getTime())
1349
+ updateTimePos(evnt.currentTarget as HTMLLIElement)
1350
+ }
1351
+
1352
+ const dateHourEvent = (evnt: MouseEvent, item: DateHourMinuteSecondItem) => {
1353
+ reactData.datetimePanelValue.setHours(item.value)
1354
+ dateTimeChangeEvent(evnt)
1355
+ }
1356
+
1357
+ const dateConfirmEvent = () => {
1358
+ const { multiple } = props
1359
+ const { datetimePanelValue } = reactData
1360
+ const dateValue = computeDateValue.value
1361
+ const isDateTimeType = computeIsDateTimeType.value
1362
+ if (isDateTimeType) {
1363
+ const dateValueFormat = computeDateValueFormat.value
1364
+ if (multiple) {
1365
+ // 如果为多选
1366
+ const dateMultipleValue = computeDateMultipleValue.value
1367
+ if (isDateTimeType) {
1368
+ // 如果是datetime特殊类型
1369
+ const dateListValue = [...computeDateListValue.value]
1370
+ const datetimeRest: Date[] = []
1371
+ dateListValue.forEach(item => {
1372
+ if (item) {
1373
+ item.setHours(datetimePanelValue.getHours())
1374
+ item.setMinutes(datetimePanelValue.getMinutes())
1375
+ item.setSeconds(datetimePanelValue.getSeconds())
1376
+ datetimeRest.push(item)
1377
+ }
1378
+ })
1379
+ emitModel(datetimeRest.map(date => XEUtils.toDateString(date, dateValueFormat)).join(','), { type: 'update' })
1380
+ } else {
1381
+ // 如果是日期类型
1382
+ emitModel(dateMultipleValue.join(','), { type: 'update' })
1383
+ }
1384
+ } else {
1385
+ dateChange(dateValue || reactData.currentDate)
1386
+ }
1387
+ }
1388
+ hidePanel()
1389
+ }
1390
+
1391
+ const dateMinuteEvent = (evnt: MouseEvent, item: DateHourMinuteSecondItem) => {
1392
+ reactData.datetimePanelValue.setMinutes(item.value)
1393
+ dateTimeChangeEvent(evnt)
1394
+ }
1395
+
1396
+ const dateSecondEvent = (evnt: MouseEvent, item: DateHourMinuteSecondItem) => {
1397
+ reactData.datetimePanelValue.setSeconds(item.value)
1398
+ dateTimeChangeEvent(evnt)
1399
+ }
1400
+
1401
+ const dateOffsetEvent = (evnt: KeyboardEvent) => {
1402
+ const { isActivated, datePanelValue, datePanelType } = reactData
1403
+ if (isActivated) {
1404
+ evnt.preventDefault()
1405
+ const isLeftArrow = hasEventKey(evnt, EVENT_KEYS.ARROW_LEFT)
1406
+ const isUpArrow = hasEventKey(evnt, EVENT_KEYS.ARROW_UP)
1407
+ const isRightArrow = hasEventKey(evnt, EVENT_KEYS.ARROW_RIGHT)
1408
+ const isDwArrow = hasEventKey(evnt, EVENT_KEYS.ARROW_DOWN)
1409
+ if (datePanelType === 'year') {
1410
+ let offsetYear = XEUtils.getWhatYear(datePanelValue || Date.now(), 0, 'first')
1411
+ if (isLeftArrow) {
1412
+ offsetYear = XEUtils.getWhatYear(offsetYear, -1)
1413
+ } else if (isUpArrow) {
1414
+ offsetYear = XEUtils.getWhatYear(offsetYear, -4)
1415
+ } else if (isRightArrow) {
1416
+ offsetYear = XEUtils.getWhatYear(offsetYear, 1)
1417
+ } else if (isDwArrow) {
1418
+ offsetYear = XEUtils.getWhatYear(offsetYear, 4)
1419
+ }
1420
+ dateMoveYear(offsetYear)
1421
+ } else if (datePanelType === 'quarter') {
1422
+ let offsetQuarter = XEUtils.getWhatQuarter(datePanelValue || Date.now(), 0, 'first')
1423
+ if (isLeftArrow) {
1424
+ offsetQuarter = XEUtils.getWhatQuarter(offsetQuarter, -1)
1425
+ } else if (isUpArrow) {
1426
+ offsetQuarter = XEUtils.getWhatQuarter(offsetQuarter, -2)
1427
+ } else if (isRightArrow) {
1428
+ offsetQuarter = XEUtils.getWhatQuarter(offsetQuarter, 1)
1429
+ } else if (isDwArrow) {
1430
+ offsetQuarter = XEUtils.getWhatQuarter(offsetQuarter, 2)
1431
+ }
1432
+ dateMoveQuarter(offsetQuarter)
1433
+ } else if (datePanelType === 'month') {
1434
+ let offsetMonth = XEUtils.getWhatMonth(datePanelValue || Date.now(), 0, 'first')
1435
+ if (isLeftArrow) {
1436
+ offsetMonth = XEUtils.getWhatMonth(offsetMonth, -1)
1437
+ } else if (isUpArrow) {
1438
+ offsetMonth = XEUtils.getWhatMonth(offsetMonth, -4)
1439
+ } else if (isRightArrow) {
1440
+ offsetMonth = XEUtils.getWhatMonth(offsetMonth, 1)
1441
+ } else if (isDwArrow) {
1442
+ offsetMonth = XEUtils.getWhatMonth(offsetMonth, 4)
1443
+ }
1444
+ dateMoveMonth(offsetMonth)
1445
+ } else {
1446
+ let offsetDay = datePanelValue || XEUtils.getWhatDay(Date.now(), 0, 'first')
1447
+ const firstDayOfWeek = computeFirstDayOfWeek.value
1448
+ if (isLeftArrow) {
1449
+ offsetDay = XEUtils.getWhatDay(offsetDay, -1)
1450
+ } else if (isUpArrow) {
1451
+ offsetDay = XEUtils.getWhatWeek(offsetDay, -1, firstDayOfWeek)
1452
+ } else if (isRightArrow) {
1453
+ offsetDay = XEUtils.getWhatDay(offsetDay, 1)
1454
+ } else if (isDwArrow) {
1455
+ offsetDay = XEUtils.getWhatWeek(offsetDay, 1, firstDayOfWeek)
1456
+ }
1457
+ dateMoveDay(offsetDay)
1458
+ }
1459
+ }
1460
+ }
1461
+
1462
+ const datePgOffsetEvent = (evnt: KeyboardEvent) => {
1463
+ const { isActivated } = reactData
1464
+ if (isActivated) {
1465
+ const isPgUp = hasEventKey(evnt, EVENT_KEYS.PAGE_UP)
1466
+ evnt.preventDefault()
1467
+ if (isPgUp) {
1468
+ datePrevEvent(evnt)
1469
+ } else {
1470
+ dateNextEvent(evnt)
1471
+ }
1472
+ }
1473
+ }
1474
+
1475
+ const dateOpenPanel = () => {
1476
+ const { type } = props
1477
+ const isDateTimeType = computeIsDateTimeType.value
1478
+ const dateValue = computeDateValue.value
1479
+ if (['year', 'quarter', 'month', 'week'].indexOf(type) > -1) {
1480
+ reactData.datePanelType = type as 'year' | 'quarter' | 'month' | 'week'
1481
+ } else {
1482
+ reactData.datePanelType = 'day'
1483
+ }
1484
+ reactData.currentDate = XEUtils.getWhatDay(Date.now(), 0, 'first')
1485
+ if (dateValue) {
1486
+ dateMonthHandle(dateValue, 0)
1487
+ dateParseValue(dateValue)
1488
+ } else {
1489
+ dateNowHandle()
1490
+ }
1491
+ if (isDateTimeType) {
1492
+ reactData.datetimePanelValue = reactData.datePanelValue || XEUtils.getWhatDay(Date.now(), 0, 'first')
1493
+ nextTick(() => {
1494
+ const timeBodyElem = refInputTimeBody.value
1495
+ XEUtils.arrayEach(timeBodyElem.querySelectorAll('li.is--selected'), updateTimePos)
1496
+ })
1497
+ }
1498
+ }
1499
+
1500
+ // 日期
1501
+
1502
+ // 弹出面板
1503
+ const updateZindex = () => {
1504
+ if (reactData.panelIndex < getLastZIndex()) {
1505
+ reactData.panelIndex = nextZIndex()
1506
+ }
1507
+ }
1508
+
1509
+ const updatePlacement = () => {
1510
+ return nextTick().then(() => {
1511
+ const { transfer, placement } = props
1512
+ const { panelIndex } = reactData
1513
+ const targetElem = refInputTarget.value
1514
+ const panelElem = refInputPanel.value
1515
+ if (targetElem && panelElem) {
1516
+ const targetHeight = targetElem.offsetHeight
1517
+ const targetWidth = targetElem.offsetWidth
1518
+ const panelHeight = panelElem.offsetHeight
1519
+ const panelWidth = panelElem.offsetWidth
1520
+ const marginSize = 5
1521
+ const panelStyle: VxeComponentStyle = {
1522
+ zIndex: panelIndex
1523
+ }
1524
+ const { boundingTop, boundingLeft, visibleHeight, visibleWidth } = getAbsolutePos(targetElem)
1525
+ let panelPlacement: VxeInputPropTypes.Placement = 'bottom'
1526
+ console.log(getAbsolutePos(targetElem))
1527
+ if (transfer) {
1528
+ let left = boundingLeft
1529
+ let top = boundingTop + targetHeight
1530
+ if (placement === 'top') {
1531
+ panelPlacement = 'top'
1532
+ top = boundingTop - panelHeight
1533
+ } else if (!placement) {
1534
+ // 如果下面不够放,则向上
1535
+ if (top + panelHeight + marginSize > visibleHeight) {
1536
+ panelPlacement = 'top'
1537
+ top = boundingTop - panelHeight
1538
+ }
1539
+ // 如果上面不够放,则向下(优先)
1540
+ if (top < marginSize) {
1541
+ panelPlacement = 'bottom'
1542
+ top = boundingTop + targetHeight
1543
+ }
1544
+ }
1545
+ // 如果溢出右边
1546
+ if (left + panelWidth + marginSize > visibleWidth) {
1547
+ left -= left + panelWidth + marginSize - visibleWidth
1548
+ }
1549
+ // 如果溢出左边
1550
+ if (left < marginSize) {
1551
+ left = marginSize
1552
+ }
1553
+ Object.assign(panelStyle, {
1554
+ left: `${left}px`,
1555
+ top: `${top}px`,
1556
+ minWidth: `${targetWidth}px`
1557
+ })
1558
+ } else {
1559
+ if (placement === 'top') {
1560
+ panelPlacement = 'top'
1561
+ panelStyle.bottom = `${targetHeight}px`
1562
+ } else if (!placement) {
1563
+ // 如果下面不够放,则向上
1564
+ if (boundingTop + targetHeight + panelHeight > visibleHeight) {
1565
+ // 如果上面不够放,则向下(优先)
1566
+ if (boundingTop - targetHeight - panelHeight > marginSize) {
1567
+ panelPlacement = 'top'
1568
+ panelStyle.bottom = `${targetHeight}px`
1569
+ }
1570
+ }
1571
+ }
1572
+ }
1573
+ reactData.panelStyle = panelStyle
1574
+ reactData.panelPlacement = panelPlacement
1575
+ return nextTick()
1576
+ }
1577
+ })
1578
+ }
1579
+
1580
+ const showPanel = () => {
1581
+ const { disabled } = props
1582
+ const { visiblePanel } = reactData
1583
+ const isDatePickerType = computeIsDatePickerType.value
1584
+ if (!disabled && !visiblePanel) {
1585
+ if (!reactData.inited) {
1586
+ reactData.inited = true
1587
+ }
1588
+ clearTimeout(hidePanelTimeout)
1589
+ reactData.isActivated = true
1590
+ reactData.animatVisible = true
1591
+ if (isDatePickerType) {
1592
+ dateOpenPanel()
1593
+ }
1594
+ setTimeout(() => {
1595
+ reactData.visiblePanel = true
1596
+ }, 10)
1597
+ updateZindex()
1598
+ return updatePlacement()
1599
+ }
1600
+ return nextTick()
1601
+ }
1602
+
1603
+ const datePickerOpenEvent = (evnt: Event) => {
1604
+ const { readonly } = props
1605
+ if (!readonly) {
1606
+ evnt.preventDefault()
1607
+ showPanel()
1608
+ }
1609
+ }
1610
+
1611
+ const clickEvent = (evnt: Event & { type: 'click' }) => {
1612
+ triggerEvent(evnt)
1613
+ }
1614
+
1615
+ // 弹出面板
1616
+
1617
+ // 全局事件
1618
+ const handleGlobalMousedownEvent = (evnt: Event) => {
1619
+ const { disabled } = props
1620
+ const { visiblePanel, isActivated } = reactData
1621
+ const isDatePickerType = computeIsDatePickerType.value
1622
+ const el = refElem.value
1623
+ const panelElem = refInputPanel.value
1624
+ if (!disabled && isActivated) {
1625
+ reactData.isActivated = getEventTargetNode(evnt, el).flag || getEventTargetNode(evnt, panelElem).flag
1626
+ if (!reactData.isActivated) {
1627
+ // 如果是日期类型
1628
+ if (isDatePickerType) {
1629
+ if (visiblePanel) {
1630
+ hidePanel()
1631
+ afterCheckValue()
1632
+ }
1633
+ } else {
1634
+ afterCheckValue()
1635
+ }
1636
+ }
1637
+ }
1638
+ }
1639
+
1640
+ const handleGlobalKeydownEvent = (evnt: KeyboardEvent) => {
1641
+ const { clearable, disabled } = props
1642
+ const { visiblePanel } = reactData
1643
+ const isDatePickerType = computeIsDatePickerType.value
1644
+ if (!disabled) {
1645
+ const isTab = hasEventKey(evnt, EVENT_KEYS.TAB)
1646
+ const isDel = hasEventKey(evnt, EVENT_KEYS.DELETE)
1647
+ const isEsc = hasEventKey(evnt, EVENT_KEYS.ESCAPE)
1648
+ const isEnter = hasEventKey(evnt, EVENT_KEYS.ENTER)
1649
+ const isLeftArrow = hasEventKey(evnt, EVENT_KEYS.ARROW_LEFT)
1650
+ const isUpArrow = hasEventKey(evnt, EVENT_KEYS.ARROW_UP)
1651
+ const isRightArrow = hasEventKey(evnt, EVENT_KEYS.ARROW_RIGHT)
1652
+ const isDwArrow = hasEventKey(evnt, EVENT_KEYS.ARROW_DOWN)
1653
+ const isPgUp = hasEventKey(evnt, EVENT_KEYS.PAGE_UP)
1654
+ const isPgDn = hasEventKey(evnt, EVENT_KEYS.PAGE_DOWN)
1655
+ const operArrow = isLeftArrow || isUpArrow || isRightArrow || isDwArrow
1656
+ let isActivated = reactData.isActivated
1657
+ if (isTab) {
1658
+ if (isActivated) {
1659
+ afterCheckValue()
1660
+ }
1661
+ isActivated = false
1662
+ reactData.isActivated = isActivated
1663
+ } else if (operArrow) {
1664
+ if (isDatePickerType) {
1665
+ if (isActivated) {
1666
+ if (visiblePanel) {
1667
+ dateOffsetEvent(evnt)
1668
+ } else if (isUpArrow || isDwArrow) {
1669
+ datePickerOpenEvent(evnt)
1670
+ }
1671
+ }
1672
+ }
1673
+ } else if (isEnter) {
1674
+ if (isDatePickerType) {
1675
+ if (visiblePanel) {
1676
+ if (reactData.datePanelValue) {
1677
+ dateSelectItem(reactData.datePanelValue)
1678
+ } else {
1679
+ hidePanel()
1680
+ }
1681
+ } else if (isActivated) {
1682
+ datePickerOpenEvent(evnt)
1683
+ }
1684
+ }
1685
+ } else if (isPgUp || isPgDn) {
1686
+ if (isDatePickerType) {
1687
+ if (isActivated) {
1688
+ datePgOffsetEvent(evnt)
1689
+ }
1690
+ }
1691
+ }
1692
+ if (isTab || isEsc) {
1693
+ if (visiblePanel) {
1694
+ hidePanel()
1695
+ }
1696
+ } else if (isDel && clearable) {
1697
+ if (isActivated) {
1698
+ clearValueEvent(evnt, null)
1699
+ }
1700
+ }
1701
+ }
1702
+ }
1703
+
1704
+ const handleGlobalMousewheelEvent = (evnt: Event) => {
1705
+ const { disabled } = props
1706
+ const { visiblePanel } = reactData
1707
+ if (!disabled) {
1708
+ if (visiblePanel) {
1709
+ const panelElem = refInputPanel.value
1710
+ if (getEventTargetNode(evnt, panelElem).flag) {
1711
+ updatePlacement()
1712
+ } else {
1713
+ hidePanel()
1714
+ afterCheckValue()
1715
+ }
1716
+ }
1717
+ }
1718
+ }
1719
+
1720
+ const handleGlobalBlurEvent = () => {
1721
+ const { isActivated, visiblePanel } = reactData
1722
+ if (visiblePanel) {
1723
+ hidePanel()
1724
+ afterCheckValue()
1725
+ } else if (isActivated) {
1726
+ afterCheckValue()
1727
+ }
1728
+ }
1729
+
1730
+ const renderDateLabel = (item: DateYearItem | DateQuarterItem | DateMonthItem | DateDayItem, label: string | number) => {
1731
+ const { festivalMethod } = props
1732
+ if (festivalMethod) {
1733
+ const { datePanelType } = reactData
1734
+ const festivalRest = festivalMethod({ type: datePanelType, viewType: datePanelType, date: item.date, $input: $xeinput })
1735
+ const festivalItem = festivalRest ? (XEUtils.isString(festivalRest) ? { label: festivalRest } : festivalRest) : {}
1736
+ const extraItem = festivalItem.extra ? (XEUtils.isString(festivalItem.extra) ? { label: festivalItem.extra } : festivalItem.extra) : null
1737
+ const labels = [
1738
+ h('span', {
1739
+ class: ['vxe-input--date-label', {
1740
+ 'is-notice': festivalItem.notice
1741
+ }]
1742
+ }, extraItem && extraItem.label
1743
+ ? [
1744
+ h('span', label),
1745
+ h('span', {
1746
+ class: ['vxe-input--date-label--extra', extraItem.important ? 'is-important' : '', extraItem.className],
1747
+ style: extraItem.style
1748
+ }, XEUtils.toValueString(extraItem.label))
1749
+ ]
1750
+ : label)
1751
+ ]
1752
+ const festivalLabel = festivalItem.label
1753
+ if (festivalLabel) {
1754
+ // 默认最多支持3个节日重叠
1755
+ const festivalLabels = XEUtils.toValueString(festivalLabel).split(',')
1756
+ labels.push(
1757
+ h('span', {
1758
+ class: ['vxe-input--date-festival', festivalItem.important ? 'is-important' : '', festivalItem.className],
1759
+ style: festivalItem.style
1760
+ }, [
1761
+ festivalLabels.length > 1
1762
+ ? h('span', {
1763
+ class: ['vxe-input--date-festival--overlap', `overlap--${festivalLabels.length}`]
1764
+ }, festivalLabels.map(label => h('span', label.substring(0, 3))))
1765
+ : h('span', {
1766
+ class: 'vxe-input--date-festival--label'
1767
+ }, festivalLabels[0].substring(0, 3))
1768
+ ])
1769
+ )
1770
+ }
1771
+ return labels
1772
+ }
1773
+ return label
1774
+ }
1775
+
1776
+ const renderDateDayTable = () => {
1777
+ const { multiple } = props
1778
+ const { datePanelType, datePanelValue } = reactData
1779
+ const dateValue = computeDateValue.value
1780
+ const dateHeaders = computeDateHeaders.value
1781
+ const dayDatas = computeDayDatas.value
1782
+ const dateListValue = computeDateListValue.value
1783
+ const matchFormat = 'yyyyMMdd'
1784
+ return [
1785
+ h('table', {
1786
+ class: `vxe-input--date-${datePanelType}-view`,
1787
+ cellspacing: 0,
1788
+ cellpadding: 0,
1789
+ border: 0
1790
+ }, [
1791
+ h('thead', [
1792
+ h('tr', dateHeaders.map((item) => {
1793
+ return h('th', item.label)
1794
+ }))
1795
+ ]),
1796
+ h('tbody', dayDatas.map((rows) => {
1797
+ return h('tr', rows.map((item) => {
1798
+ return h('td', {
1799
+ class: {
1800
+ 'is--prev': item.isPrev,
1801
+ 'is--current': item.isCurrent,
1802
+ 'is--now': item.isNow,
1803
+ 'is--next': item.isNext,
1804
+ 'is--disabled': isDateDisabled(item),
1805
+ 'is--selected': multiple ? dateListValue.some(val => XEUtils.isDateSame(val, item.date, matchFormat)) : XEUtils.isDateSame(dateValue, item.date, matchFormat),
1806
+ 'is--hover': XEUtils.isDateSame(datePanelValue, item.date, matchFormat)
1807
+ },
1808
+ onClick: () => dateSelectEvent(item),
1809
+ onMouseenter: () => dateMouseenterEvent(item)
1810
+ }, renderDateLabel(item, item.label))
1811
+ }))
1812
+ }))
1813
+ ])
1814
+ ]
1815
+ }
1816
+
1817
+ const renderDateWeekTable = () => {
1818
+ const { multiple } = props
1819
+ const { datePanelType, datePanelValue } = reactData
1820
+ const dateValue = computeDateValue.value
1821
+ const weekHeaders = computeWeekHeaders.value
1822
+ const weekDates = computeWeekDates.value
1823
+ const dateListValue = computeDateListValue.value
1824
+ const matchFormat = 'yyyyMMdd'
1825
+ return [
1826
+ h('table', {
1827
+ class: `vxe-input--date-${datePanelType}-view`,
1828
+ cellspacing: 0,
1829
+ cellpadding: 0,
1830
+ border: 0
1831
+ }, [
1832
+ h('thead', [
1833
+ h('tr', weekHeaders.map((item) => {
1834
+ return h('th', item.label)
1835
+ }))
1836
+ ]),
1837
+ h('tbody', weekDates.map((rows) => {
1838
+ const isSelected = multiple ? rows.some((item) => dateListValue.some(val => XEUtils.isDateSame(val, item.date, matchFormat))) : rows.some((item) => XEUtils.isDateSame(dateValue, item.date, matchFormat))
1839
+ const isHover = rows.some((item) => XEUtils.isDateSame(datePanelValue, item.date, matchFormat))
1840
+ return h('tr', rows.map((item) => {
1841
+ return h('td', {
1842
+ class: {
1843
+ 'is--prev': item.isPrev,
1844
+ 'is--current': item.isCurrent,
1845
+ 'is--now': item.isNow,
1846
+ 'is--next': item.isNext,
1847
+ 'is--disabled': isDateDisabled(item),
1848
+ 'is--selected': isSelected,
1849
+ 'is--hover': isHover
1850
+ },
1851
+ // event
1852
+ onClick: () => dateSelectEvent(item),
1853
+ onMouseenter: () => dateMouseenterEvent(item)
1854
+ }, renderDateLabel(item, item.label))
1855
+ }))
1856
+ }))
1857
+ ])
1858
+ ]
1859
+ }
1860
+
1861
+ const renderDateMonthTable = () => {
1862
+ const { multiple } = props
1863
+ const { datePanelType, datePanelValue } = reactData
1864
+ const dateValue = computeDateValue.value
1865
+ const monthDatas = computeMonthDatas.value
1866
+ const dateListValue = computeDateListValue.value
1867
+ const matchFormat = 'yyyyMM'
1868
+ return [
1869
+ h('table', {
1870
+ class: `vxe-input--date-${datePanelType}-view`,
1871
+ cellspacing: 0,
1872
+ cellpadding: 0,
1873
+ border: 0
1874
+ }, [
1875
+ h('tbody', monthDatas.map((rows) => {
1876
+ return h('tr', rows.map((item) => {
1877
+ return h('td', {
1878
+ class: {
1879
+ 'is--prev': item.isPrev,
1880
+ 'is--current': item.isCurrent,
1881
+ 'is--now': item.isNow,
1882
+ 'is--next': item.isNext,
1883
+ 'is--disabled': isDateDisabled(item),
1884
+ 'is--selected': multiple ? dateListValue.some(val => XEUtils.isDateSame(val, item.date, matchFormat)) : XEUtils.isDateSame(dateValue, item.date, matchFormat),
1885
+ 'is--hover': XEUtils.isDateSame(datePanelValue, item.date, matchFormat)
1886
+ },
1887
+ onClick: () => dateSelectEvent(item),
1888
+ onMouseenter: () => dateMouseenterEvent(item)
1889
+ }, renderDateLabel(item, getI18n(`vxe.input.date.months.m${item.month}`)))
1890
+ }))
1891
+ }))
1892
+ ])
1893
+ ]
1894
+ }
1895
+
1896
+ const renderDateQuarterTable = () => {
1897
+ const { multiple } = props
1898
+ const { datePanelType, datePanelValue } = reactData
1899
+ const dateValue = computeDateValue.value
1900
+ const quarterDatas = computeQuarterDatas.value
1901
+ const dateListValue = computeDateListValue.value
1902
+ const matchFormat = 'yyyyq'
1903
+ return [
1904
+ h('table', {
1905
+ class: `vxe-input--date-${datePanelType}-view`,
1906
+ cellspacing: 0,
1907
+ cellpadding: 0,
1908
+ border: 0
1909
+ }, [
1910
+ h('tbody', quarterDatas.map((rows) => {
1911
+ return h('tr', rows.map((item) => {
1912
+ return h('td', {
1913
+ class: {
1914
+ 'is--prev': item.isPrev,
1915
+ 'is--current': item.isCurrent,
1916
+ 'is--now': item.isNow,
1917
+ 'is--next': item.isNext,
1918
+ 'is--disabled': isDateDisabled(item),
1919
+ 'is--selected': multiple ? dateListValue.some(val => XEUtils.isDateSame(val, item.date, matchFormat)) : XEUtils.isDateSame(dateValue, item.date, matchFormat),
1920
+ 'is--hover': XEUtils.isDateSame(datePanelValue, item.date, matchFormat)
1921
+ },
1922
+ onClick: () => dateSelectEvent(item),
1923
+ onMouseenter: () => dateMouseenterEvent(item)
1924
+ }, renderDateLabel(item, getI18n(`vxe.input.date.quarters.q${item.quarter}`)))
1925
+ }))
1926
+ }))
1927
+ ])
1928
+ ]
1929
+ }
1930
+
1931
+ const renderDateYearTable = () => {
1932
+ const { multiple } = props
1933
+ const { datePanelType, datePanelValue } = reactData
1934
+ const dateValue = computeDateValue.value
1935
+ const yearDatas = computeYearDatas.value
1936
+ const dateListValue = computeDateListValue.value
1937
+ const matchFormat = 'yyyy'
1938
+ return [
1939
+ h('table', {
1940
+ class: `vxe-input--date-${datePanelType}-view`,
1941
+ cellspacing: 0,
1942
+ cellpadding: 0,
1943
+ border: 0
1944
+ }, [
1945
+ h('tbody', yearDatas.map((rows) => {
1946
+ return h('tr', rows.map((item) => {
1947
+ return h('td', {
1948
+ class: {
1949
+ 'is--prev': item.isPrev,
1950
+ 'is--current': item.isCurrent,
1951
+ 'is--now': item.isNow,
1952
+ 'is--next': item.isNext,
1953
+ 'is--disabled': isDateDisabled(item),
1954
+ 'is--selected': multiple ? dateListValue.some(val => XEUtils.isDateSame(val, item.date, matchFormat)) : XEUtils.isDateSame(dateValue, item.date, matchFormat),
1955
+ 'is--hover': XEUtils.isDateSame(datePanelValue, item.date, matchFormat)
1956
+ },
1957
+ onClick: () => dateSelectEvent(item),
1958
+ onMouseenter: () => dateMouseenterEvent(item)
1959
+ }, renderDateLabel(item, item.year))
1960
+ }))
1961
+ }))
1962
+ ])
1963
+ ]
1964
+ }
1965
+
1966
+ const renderDateTable = () => {
1967
+ const { datePanelType } = reactData
1968
+ switch (datePanelType) {
1969
+ case 'week' :
1970
+ return renderDateWeekTable()
1971
+ case 'month' :
1972
+ return renderDateMonthTable()
1973
+ case 'quarter' :
1974
+ return renderDateQuarterTable()
1975
+ case 'year' :
1976
+ return renderDateYearTable()
1977
+ }
1978
+ return renderDateDayTable()
1979
+ }
1980
+
1981
+ const renderDatePanel = () => {
1982
+ const { multiple } = props
1983
+ const { datePanelType } = reactData
1984
+ const isDisabledPrevDateBtn = computeIsDisabledPrevDateBtn.value
1985
+ const isDisabledNextDateBtn = computeIsDisabledNextDateBtn.value
1986
+ const selectDatePanelLabel = computeSelectDatePanelLabel.value
1987
+ return [
1988
+ h('div', {
1989
+ class: 'vxe-input--date-picker-header'
1990
+ }, [
1991
+ h('div', {
1992
+ class: 'vxe-input--date-picker-type-wrapper'
1993
+ }, [
1994
+ datePanelType === 'year'
1995
+ ? h('span', {
1996
+ class: 'vxe-input--date-picker-label'
1997
+ }, selectDatePanelLabel)
1998
+ : h('span', {
1999
+ class: 'vxe-input--date-picker-btn',
2000
+ onClick: dateToggleTypeEvent
2001
+ }, selectDatePanelLabel)
2002
+ ]),
2003
+ h('div', {
2004
+ class: 'vxe-input--date-picker-btn-wrapper'
2005
+ }, [
2006
+ h('span', {
2007
+ class: ['vxe-input--date-picker-btn vxe-input--date-picker-prev-btn', {
2008
+ 'is--disabled': isDisabledPrevDateBtn
2009
+ }],
2010
+ onClick: datePrevEvent
2011
+ }, [
2012
+ h('i', {
2013
+ class: 'vxe-icon-caret-left'
2014
+ })
2015
+ ]),
2016
+ h('span', {
2017
+ class: 'vxe-input--date-picker-btn vxe-input--date-picker-current-btn',
2018
+ onClick: dateTodayMonthEvent
2019
+ }, [
2020
+ h('i', {
2021
+ class: 'vxe-icon-dot'
2022
+ })
2023
+ ]),
2024
+ h('span', {
2025
+ class: ['vxe-input--date-picker-btn vxe-input--date-picker-next-btn', {
2026
+ 'is--disabled': isDisabledNextDateBtn
2027
+ }],
2028
+ onClick: dateNextEvent
2029
+ }, [
2030
+ h('i', {
2031
+ class: 'vxe-icon-caret-right'
2032
+ })
2033
+ ]),
2034
+ multiple && computeSupportMultiples.value
2035
+ ? h('span', {
2036
+ class: 'vxe-input--date-picker-btn vxe-input--date-picker-confirm-btn'
2037
+ }, [
2038
+ h('button', {
2039
+ class: 'vxe-input--date-picker-confirm',
2040
+ type: 'button',
2041
+ onClick: dateConfirmEvent
2042
+ }, getI18n('vxe.button.confirm'))
2043
+ ])
2044
+ : null
2045
+ ])
2046
+ ]),
2047
+ h('div', {
2048
+ class: 'vxe-input--date-picker-body'
2049
+ }, renderDateTable())
2050
+ ]
2051
+ }
2052
+
2053
+ const renderTimePanel = () => {
2054
+ const { datetimePanelValue } = reactData
2055
+ const dateTimeLabel = computeDateTimeLabel.value
2056
+ const hourList = computeHourList.value
2057
+ const minuteList = computeMinuteList.value
2058
+ const secondList = computeSecondList.value
2059
+ return [
2060
+ h('div', {
2061
+ class: 'vxe-input--time-picker-header'
2062
+ }, [
2063
+ h('span', {
2064
+ class: 'vxe-input--time-picker-title'
2065
+ }, dateTimeLabel),
2066
+ h('button', {
2067
+ class: 'vxe-input--time-picker-confirm',
2068
+ type: 'button',
2069
+ onClick: dateConfirmEvent
2070
+ }, getI18n('vxe.button.confirm'))
2071
+ ]),
2072
+ h('div', {
2073
+ ref: refInputTimeBody,
2074
+ class: 'vxe-input--time-picker-body'
2075
+ }, [
2076
+ h('ul', {
2077
+ class: 'vxe-input--time-picker-hour-list'
2078
+ }, hourList.map((item, index) => {
2079
+ return h('li', {
2080
+ key: index,
2081
+ class: {
2082
+ 'is--selected': datetimePanelValue && datetimePanelValue.getHours() === item.value
2083
+ },
2084
+ onClick: (evnt: MouseEvent) => dateHourEvent(evnt, item)
2085
+ }, item.label)
2086
+ })),
2087
+ h('ul', {
2088
+ class: 'vxe-input--time-picker-minute-list'
2089
+ }, minuteList.map((item, index) => {
2090
+ return h('li', {
2091
+ key: index,
2092
+ class: {
2093
+ 'is--selected': datetimePanelValue && datetimePanelValue.getMinutes() === item.value
2094
+ },
2095
+ onClick: (evnt: MouseEvent) => dateMinuteEvent(evnt, item)
2096
+ }, item.label)
2097
+ })),
2098
+ h('ul', {
2099
+ class: 'vxe-input--time-picker-second-list'
2100
+ }, secondList.map((item, index) => {
2101
+ return h('li', {
2102
+ key: index,
2103
+ class: {
2104
+ 'is--selected': datetimePanelValue && datetimePanelValue.getSeconds() === item.value
2105
+ },
2106
+ onClick: (evnt: MouseEvent) => dateSecondEvent(evnt, item)
2107
+ }, item.label)
2108
+ }))
2109
+ ])
2110
+ ]
2111
+ }
2112
+
2113
+ const renderPanel = () => {
2114
+ const { type, transfer } = props
2115
+ const { inited, animatVisible, visiblePanel, panelPlacement, panelStyle } = reactData
2116
+ const vSize = computeSize.value
2117
+ const isDatePickerType = computeIsDatePickerType.value
2118
+ const renders = []
2119
+ if (isDatePickerType) {
2120
+ if (type === 'datetime') {
2121
+ renders.push(
2122
+ h('div', {
2123
+ class: 'vxe-input--panel-layout-wrapper'
2124
+ }, [
2125
+ h('div', {
2126
+ class: 'vxe-input--panel-left-wrapper'
2127
+ }, renderDatePanel()),
2128
+ h('div', {
2129
+ class: 'vxe-input--panel-right-wrapper'
2130
+ }, renderTimePanel())
2131
+ ])
2132
+ )
2133
+ } else if (type === 'time') {
2134
+ renders.push(
2135
+ h('div', {
2136
+ class: 'vxe-input--panel-wrapper'
2137
+ }, renderTimePanel())
2138
+ )
2139
+ } else {
2140
+ renders.push(
2141
+ h('div', {
2142
+ class: 'vxe-input--panel-wrapper'
2143
+ }, renderDatePanel())
2144
+ )
2145
+ }
2146
+ return h(Teleport, {
2147
+ to: 'body',
2148
+ disabled: transfer ? !inited : true
2149
+ }, [
2150
+ h('div', {
2151
+ ref: refInputPanel,
2152
+ class: ['vxe-table--ignore-clear vxe-input--panel', `type--${type}`, {
2153
+ [`size--${vSize}`]: vSize,
2154
+ 'is--transfer': transfer,
2155
+ 'animat--leave': animatVisible,
2156
+ 'animat--enter': visiblePanel
2157
+ }],
2158
+ placement: panelPlacement,
2159
+ style: panelStyle
2160
+ }, renders)
2161
+ ])
2162
+ }
2163
+ return null
2164
+ }
2165
+
2166
+ const renderNumberIcon = () => {
2167
+ const isDisabledAddNumber = computeIsDisabledAddNumber.value
2168
+ const isDisabledSubtractNumber = computeIsDisabledSubtractNumber.value
2169
+ return h('span', {
2170
+ class: 'vxe-input--number-suffix'
2171
+ }, [
2172
+ h('span', {
2173
+ class: ['vxe-input--number-prev is--prev', {
2174
+ 'is--disabled': isDisabledAddNumber
2175
+ }],
2176
+ onMousedown: numberMousedownEvent,
2177
+ onMouseup: numberStopDown,
2178
+ onMouseleave: numberStopDown
2179
+ }, [
2180
+ h('i', {
2181
+ class: ['vxe-input--number-prev-icon', iconConfigStore.INPUT_PREV_NUM]
2182
+ })
2183
+ ]),
2184
+ h('span', {
2185
+ class: ['vxe-input--number-next is--next', {
2186
+ 'is--disabled': isDisabledSubtractNumber
2187
+ }],
2188
+ onMousedown: numberMousedownEvent,
2189
+ onMouseup: numberStopDown,
2190
+ onMouseleave: numberStopDown
2191
+ }, [
2192
+ h('i', {
2193
+ class: ['vxe-input--number-next-icon', iconConfigStore.INPUT_NEXT_NUM]
2194
+ })
2195
+ ])
2196
+ ])
2197
+ }
2198
+
2199
+ const renderDatePickerIcon = () => {
2200
+ return h('span', {
2201
+ class: 'vxe-input--date-picker-suffix',
2202
+ onClick: datePickerOpenEvent
2203
+ }, [
2204
+ h('i', {
2205
+ class: ['vxe-input--date-picker-icon', iconConfigStore.INPUT_DATE]
2206
+ })
2207
+ ])
2208
+ }
2209
+
2210
+ const renderSearchIcon = () => {
2211
+ return h('span', {
2212
+ class: 'vxe-input--search-suffix',
2213
+ onClick: searchEvent
2214
+ }, [
2215
+ h('i', {
2216
+ class: ['vxe-input--search-icon', iconConfigStore.INPUT_SEARCH]
2217
+ })
2218
+ ])
2219
+ }
2220
+
2221
+ const renderPasswordIcon = () => {
2222
+ const { showPwd } = reactData
2223
+ return h('span', {
2224
+ class: 'vxe-input--password-suffix',
2225
+ onClick: passwordToggleEvent
2226
+ }, [
2227
+ h('i', {
2228
+ class: ['vxe-input--password-icon', showPwd ? iconConfigStore.INPUT_SHOW_PWD : iconConfigStore.INPUT_PWD]
2229
+ })
2230
+ ])
2231
+ }
2232
+
2233
+ const rendePrefixIcon = () => {
2234
+ const { prefixIcon } = props
2235
+ const prefixSlot = slots.prefix
2236
+ const icons = []
2237
+ if (prefixSlot) {
2238
+ icons.push(
2239
+ h('span', {
2240
+ class: 'vxe-input--prefix-icon'
2241
+ }, prefixSlot({}))
2242
+ )
2243
+ } else if (prefixIcon) {
2244
+ icons.push(
2245
+ h('i', {
2246
+ class: ['vxe-input--prefix-icon', prefixIcon]
2247
+ })
2248
+ )
2249
+ }
2250
+ return icons.length
2251
+ ? h('span', {
2252
+ class: 'vxe-input--prefix',
2253
+ onClick: clickPrefixEvent
2254
+ }, icons)
2255
+ : null
2256
+ }
2257
+
2258
+ const renderSuffixIcon = () => {
2259
+ const { disabled, suffixIcon } = props
2260
+ const { inputValue } = reactData
2261
+ const suffixSlot = slots.suffix
2262
+ const isClearable = computeIsClearable.value
2263
+ const icons = []
2264
+ if (suffixSlot) {
2265
+ icons.push(
2266
+ h('span', {
2267
+ class: 'vxe-input--suffix-icon'
2268
+ }, suffixSlot({}))
2269
+ )
2270
+ } else if (suffixIcon) {
2271
+ icons.push(
2272
+ h('i', {
2273
+ class: ['vxe-input--suffix-icon', suffixIcon]
2274
+ })
2275
+ )
2276
+ }
2277
+ if (isClearable) {
2278
+ icons.push(
2279
+ h('i', {
2280
+ class: ['vxe-input--clear-icon', iconConfigStore.INPUT_CLEAR]
2281
+ })
2282
+ )
2283
+ }
2284
+ return icons.length
2285
+ ? h('span', {
2286
+ class: ['vxe-input--suffix', {
2287
+ 'is--clear': isClearable && !disabled && !(inputValue === '' || XEUtils.eqNull(inputValue))
2288
+ }],
2289
+ onClick: clickSuffixEvent
2290
+ }, icons)
2291
+ : null
2292
+ }
2293
+
2294
+ const renderExtraSuffixIcon = () => {
2295
+ const { controls } = props
2296
+ const isNumType = computeIsNumType.value
2297
+ const isDatePickerType = computeIsDatePickerType.value
2298
+ const isPawdType = computeIsPawdType.value
2299
+ const isSearchType = computeIsSearchType.value
2300
+ let icons
2301
+ if (isPawdType) {
2302
+ icons = renderPasswordIcon()
2303
+ } else if (isNumType) {
2304
+ if (controls) {
2305
+ icons = renderNumberIcon()
2306
+ }
2307
+ } else if (isDatePickerType) {
2308
+ icons = renderDatePickerIcon()
2309
+ } else if (isSearchType) {
2310
+ icons = renderSearchIcon()
2311
+ }
2312
+ return icons
2313
+ ? h('span', {
2314
+ class: 'vxe-input--extra-suffix'
2315
+ }, [icons])
2316
+ : null
2317
+ }
2318
+
2319
+ inputMethods = {
2320
+ dispatchEvent (type, params, evnt) {
2321
+ emit(type, Object.assign({ $input: $xeinput, $event: evnt }, params))
2322
+ },
2323
+
2324
+ focus () {
2325
+ const inputElem = refInputTarget.value
2326
+ reactData.isActivated = true
2327
+ inputElem.focus()
2328
+ return nextTick()
2329
+ },
2330
+ blur () {
2331
+ const inputElem = refInputTarget.value
2332
+ inputElem.blur()
2333
+ reactData.isActivated = false
2334
+ return nextTick()
2335
+ },
2336
+ select () {
2337
+ const inputElem = refInputTarget.value
2338
+ inputElem.select()
2339
+ reactData.isActivated = false
2340
+ return nextTick()
2341
+ },
2342
+ showPanel,
2343
+ hidePanel,
2344
+ updatePlacement
2345
+ }
2346
+
2347
+ Object.assign($xeinput, inputMethods)
2348
+
2349
+ watch(() => props.modelValue, (val) => {
2350
+ reactData.inputValue = val
2351
+ changeValue()
2352
+ })
2353
+
2354
+ watch(() => props.type, () => {
2355
+ // 切换类型是重置内置变量
2356
+ Object.assign(reactData, {
2357
+ inputValue: props.modelValue,
2358
+ datetimePanelValue: null,
2359
+ datePanelValue: null,
2360
+ datePanelLabel: '',
2361
+ datePanelType: 'day',
2362
+ selectMonth: null,
2363
+ currentDate: null
2364
+ })
2365
+ initValue()
2366
+ })
2367
+
2368
+ watch(computeDateLabelFormat, () => {
2369
+ const isDatePickerType = computeIsDatePickerType.value
2370
+ if (isDatePickerType) {
2371
+ dateParseValue(reactData.datePanelValue)
2372
+ reactData.inputValue = props.multiple ? computeDateMultipleLabel.value : reactData.datePanelLabel
2373
+ }
2374
+ })
2375
+
2376
+ nextTick(() => {
2377
+ GlobalEvent.on($xeinput, 'mousewheel', handleGlobalMousewheelEvent)
2378
+ GlobalEvent.on($xeinput, 'mousedown', handleGlobalMousedownEvent)
2379
+ GlobalEvent.on($xeinput, 'keydown', handleGlobalKeydownEvent)
2380
+ GlobalEvent.on($xeinput, 'blur', handleGlobalBlurEvent)
2381
+ })
2382
+
2383
+ onUnmounted(() => {
2384
+ numberStopDown()
2385
+ GlobalEvent.off($xeinput, 'mousewheel')
2386
+ GlobalEvent.off($xeinput, 'mousedown')
2387
+ GlobalEvent.off($xeinput, 'keydown')
2388
+ GlobalEvent.off($xeinput, 'blur')
2389
+ })
2390
+
2391
+ initValue()
2392
+
2393
+ const renderVN = () => {
2394
+ const { className, controls, type, align, showWordCount, countMethod, name, disabled, readonly, autocomplete } = props
2395
+ const { inputValue, visiblePanel, isActivated } = reactData
2396
+ const vSize = computeSize.value
2397
+ const isCountError = computeIsCountError.value
2398
+ const inputCount = computeInputCount.value
2399
+ const isDatePickerType = computeIsDatePickerType.value
2400
+ const inpReadonly = computeInpReadonly.value
2401
+ const inpMaxlength = computeInpMaxlength.value
2402
+ const inputType = computeInputType.value
2403
+ const inpPlaceholder = computeInpPlaceholder.value
2404
+ const childs = []
2405
+ const prefix = rendePrefixIcon()
2406
+ const suffix = renderSuffixIcon()
2407
+ // 前缀图标
2408
+ if (prefix) {
2409
+ childs.push(prefix)
2410
+ }
2411
+ // 输入框
2412
+ childs.push(
2413
+ h('input', {
2414
+ ref: refInputTarget,
2415
+ class: 'vxe-input--inner',
2416
+ value: inputValue,
2417
+ name,
2418
+ type: inputType,
2419
+ placeholder: inpPlaceholder,
2420
+ maxlength: inpMaxlength,
2421
+ readonly: inpReadonly,
2422
+ disabled,
2423
+ autocomplete,
2424
+ onKeydown: keydownEvent,
2425
+ onKeyup: keyupEvent,
2426
+ onWheel: wheelEvent,
2427
+ onClick: clickEvent,
2428
+ onInput: inputEvent,
2429
+ onChange: changeEvent,
2430
+ onFocus: focusEvent,
2431
+ onBlur: blurEvent
2432
+ })
2433
+ )
2434
+ // 后缀图标
2435
+ if (suffix) {
2436
+ childs.push(suffix)
2437
+ }
2438
+ // 特殊功能图标
2439
+ childs.push(renderExtraSuffixIcon())
2440
+ // 面板容器
2441
+ if (isDatePickerType) {
2442
+ childs.push(renderPanel())
2443
+ }
2444
+ let isWordCount = false
2445
+ // 统计字数
2446
+ if (showWordCount && ['text', 'search'].includes(type)) {
2447
+ isWordCount = true
2448
+ childs.push(
2449
+ h('span', {
2450
+ class: ['vxe-input--count', {
2451
+ 'is--error': isCountError
2452
+ }]
2453
+ }, countMethod ? `${countMethod({ value: inputValue })}` : `${inputCount}${inpMaxlength ? `/${inpMaxlength}` : ''}`)
2454
+ )
2455
+ }
2456
+ return h('div', {
2457
+ ref: refElem,
2458
+ class: ['vxe-input', `type--${type}`, className, {
2459
+ [`size--${vSize}`]: vSize,
2460
+ [`is--${align}`]: align,
2461
+ 'is--controls': controls,
2462
+ 'is--prefix': !!prefix,
2463
+ 'is--suffix': !!suffix,
2464
+ 'is--readonly': readonly,
2465
+ 'is--visivle': visiblePanel,
2466
+ 'is--count': isWordCount,
2467
+ 'is--disabled': disabled,
2468
+ 'is--active': isActivated
2469
+ }]
2470
+ }, childs)
2471
+ }
2472
+
2473
+ $xeinput.renderVN = renderVN
2474
+
2475
+ return $xeinput
2476
+ },
2477
+ render () {
2478
+ return this.renderVN()
2479
+ }
2480
+ })