vxe-pc-ui 4.14.6 → 4.14.7

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 (611) hide show
  1. package/LICENSE +21 -21
  2. package/README.en.md +72 -72
  3. package/README.ja-JP.md +72 -72
  4. package/README.md +364 -364
  5. package/README.zh-TW.md +73 -73
  6. package/es/checkbox/src/button.js +26 -5
  7. package/es/checkbox/src/checkbox.js +26 -5
  8. package/es/checkbox/src/group.js +23 -3
  9. package/es/checkbox/style.css +6 -3
  10. package/es/checkbox/style.min.css +1 -1
  11. package/es/language/ar-EG.js +4 -0
  12. package/es/language/de-DE.js +4 -0
  13. package/es/language/en-US.js +4 -0
  14. package/es/language/es-ES.js +4 -0
  15. package/es/language/fr-FR.js +4 -0
  16. package/es/language/hu-HU.js +4 -0
  17. package/es/language/hy-AM.js +4 -0
  18. package/es/language/id-ID.js +4 -0
  19. package/es/language/it-IT.js +4 -0
  20. package/es/language/ja-JP.js +4 -0
  21. package/es/language/ko-KR.js +4 -0
  22. package/es/language/ms-MY.js +4 -0
  23. package/es/language/nb-NO.js +4 -0
  24. package/es/language/pt-BR.js +4 -0
  25. package/es/language/ru-RU.js +4 -0
  26. package/es/language/th-TH.js +4 -0
  27. package/es/language/ug-CN.js +4 -0
  28. package/es/language/uk-UA.js +4 -0
  29. package/es/language/uz-UZ.js +4 -0
  30. package/es/language/vi-VN.js +4 -0
  31. package/es/language/zh-CHT.js +4 -0
  32. package/es/language/zh-CN.js +4 -0
  33. package/es/radio/src/button.js +27 -5
  34. package/es/radio/src/group.js +17 -2
  35. package/es/radio/src/radio.js +27 -5
  36. package/es/radio/style.css +5 -3
  37. package/es/radio/style.min.css +1 -1
  38. package/es/style.css +1 -1
  39. package/es/style.min.css +1 -1
  40. package/es/switch/src/switch.js +19 -11
  41. package/es/tree/style.css +11 -6
  42. package/es/tree/style.min.css +1 -1
  43. package/es/ui/index.js +1 -1
  44. package/es/ui/src/log.js +1 -1
  45. package/es/vxe-checkbox/style.css +6 -3
  46. package/es/vxe-checkbox/style.min.css +1 -1
  47. package/es/vxe-radio/style.css +5 -3
  48. package/es/vxe-radio/style.min.css +1 -1
  49. package/es/vxe-tree/style.css +11 -6
  50. package/es/vxe-tree/style.min.css +1 -1
  51. package/lib/checkbox/src/button.js +26 -3
  52. package/lib/checkbox/src/button.min.js +1 -1
  53. package/lib/checkbox/src/checkbox.js +26 -3
  54. package/lib/checkbox/src/checkbox.min.js +1 -1
  55. package/lib/checkbox/src/group.js +25 -3
  56. package/lib/checkbox/src/group.min.js +1 -1
  57. package/lib/checkbox/style/style.css +6 -3
  58. package/lib/checkbox/style/style.min.css +1 -1
  59. package/lib/index.umd.js +2446 -2376
  60. package/lib/index.umd.min.js +1 -1
  61. package/lib/language/ar-EG.js +4 -0
  62. package/lib/language/ar-EG.min.js +1 -1
  63. package/lib/language/ar-EG.umd.js +4 -0
  64. package/lib/language/de-DE.js +4 -0
  65. package/lib/language/de-DE.min.js +1 -1
  66. package/lib/language/de-DE.umd.js +4 -0
  67. package/lib/language/en-US.js +4 -0
  68. package/lib/language/en-US.min.js +1 -1
  69. package/lib/language/en-US.umd.js +4 -0
  70. package/lib/language/es-ES.js +4 -0
  71. package/lib/language/es-ES.min.js +1 -1
  72. package/lib/language/es-ES.umd.js +4 -0
  73. package/lib/language/fr-FR.js +4 -0
  74. package/lib/language/fr-FR.min.js +1 -1
  75. package/lib/language/fr-FR.umd.js +4 -0
  76. package/lib/language/hu-HU.js +4 -0
  77. package/lib/language/hu-HU.min.js +1 -1
  78. package/lib/language/hu-HU.umd.js +4 -0
  79. package/lib/language/hy-AM.js +4 -0
  80. package/lib/language/hy-AM.min.js +1 -1
  81. package/lib/language/hy-AM.umd.js +4 -0
  82. package/lib/language/id-ID.js +4 -0
  83. package/lib/language/id-ID.min.js +1 -1
  84. package/lib/language/id-ID.umd.js +4 -0
  85. package/lib/language/it-IT.js +4 -0
  86. package/lib/language/it-IT.min.js +1 -1
  87. package/lib/language/it-IT.umd.js +4 -0
  88. package/lib/language/ja-JP.js +4 -0
  89. package/lib/language/ja-JP.min.js +1 -1
  90. package/lib/language/ja-JP.umd.js +4 -0
  91. package/lib/language/ko-KR.js +4 -0
  92. package/lib/language/ko-KR.min.js +1 -1
  93. package/lib/language/ko-KR.umd.js +4 -0
  94. package/lib/language/ms-MY.js +4 -0
  95. package/lib/language/ms-MY.min.js +1 -1
  96. package/lib/language/ms-MY.umd.js +4 -0
  97. package/lib/language/nb-NO.js +4 -0
  98. package/lib/language/nb-NO.min.js +1 -1
  99. package/lib/language/nb-NO.umd.js +4 -0
  100. package/lib/language/pt-BR.js +4 -0
  101. package/lib/language/pt-BR.min.js +1 -1
  102. package/lib/language/pt-BR.umd.js +4 -0
  103. package/lib/language/ru-RU.js +4 -0
  104. package/lib/language/ru-RU.min.js +1 -1
  105. package/lib/language/ru-RU.umd.js +4 -0
  106. package/lib/language/th-TH.js +4 -0
  107. package/lib/language/th-TH.min.js +1 -1
  108. package/lib/language/th-TH.umd.js +4 -0
  109. package/lib/language/ug-CN.js +4 -0
  110. package/lib/language/ug-CN.min.js +1 -1
  111. package/lib/language/ug-CN.umd.js +4 -0
  112. package/lib/language/uk-UA.js +4 -0
  113. package/lib/language/uk-UA.min.js +1 -1
  114. package/lib/language/uk-UA.umd.js +4 -0
  115. package/lib/language/uz-UZ.js +4 -0
  116. package/lib/language/uz-UZ.min.js +1 -1
  117. package/lib/language/uz-UZ.umd.js +4 -0
  118. package/lib/language/vi-VN.js +4 -0
  119. package/lib/language/vi-VN.min.js +1 -1
  120. package/lib/language/vi-VN.umd.js +4 -0
  121. package/lib/language/zh-CHT.js +4 -0
  122. package/lib/language/zh-CHT.min.js +1 -1
  123. package/lib/language/zh-CHT.umd.js +4 -0
  124. package/lib/language/zh-CN.js +4 -0
  125. package/lib/language/zh-CN.min.js +1 -1
  126. package/lib/language/zh-CN.umd.js +4 -0
  127. package/lib/radio/src/button.js +27 -3
  128. package/lib/radio/src/button.min.js +1 -1
  129. package/lib/radio/src/group.js +19 -2
  130. package/lib/radio/src/group.min.js +1 -1
  131. package/lib/radio/src/radio.js +27 -3
  132. package/lib/radio/src/radio.min.js +1 -1
  133. package/lib/radio/style/style.css +5 -3
  134. package/lib/radio/style/style.min.css +1 -1
  135. package/lib/style.css +1 -1
  136. package/lib/style.min.css +1 -1
  137. package/lib/switch/src/switch.js +18 -10
  138. package/lib/switch/src/switch.min.js +1 -1
  139. package/lib/tree/style/style.css +11 -6
  140. package/lib/tree/style/style.min.css +1 -1
  141. package/lib/ui/index.js +1 -1
  142. package/lib/ui/index.min.js +1 -1
  143. package/lib/ui/src/log.js +1 -1
  144. package/lib/ui/src/log.min.js +1 -1
  145. package/lib/vxe-checkbox/style/style.css +6 -3
  146. package/lib/vxe-checkbox/style/style.min.css +1 -1
  147. package/lib/vxe-radio/style/style.css +5 -3
  148. package/lib/vxe-radio/style/style.min.css +1 -1
  149. package/lib/vxe-tree/style/style.css +11 -6
  150. package/lib/vxe-tree/style/style.min.css +1 -1
  151. package/package.json +88 -88
  152. package/packages/alert/index.ts +16 -16
  153. package/packages/alert/src/alert.ts +124 -124
  154. package/packages/anchor/index.ts +16 -16
  155. package/packages/anchor/src/anchor-link.ts +121 -121
  156. package/packages/anchor/src/anchor.ts +237 -237
  157. package/packages/anchor/src/util.ts +23 -23
  158. package/packages/anchor-link/index.ts +16 -16
  159. package/packages/avatar/index.ts +16 -16
  160. package/packages/avatar/src/avatar.ts +149 -149
  161. package/packages/backtop/index.ts +16 -16
  162. package/packages/backtop/src/backtop.ts +314 -314
  163. package/packages/badge/index.ts +16 -16
  164. package/packages/badge/src/badge.ts +100 -100
  165. package/packages/breadcrumb/index.ts +16 -16
  166. package/packages/breadcrumb/src/breadcrumb-item.ts +106 -106
  167. package/packages/breadcrumb/src/breadcrumb.ts +92 -92
  168. package/packages/breadcrumb-item/index.ts +16 -16
  169. package/packages/button/index.ts +16 -16
  170. package/packages/button/src/button-group.ts +110 -110
  171. package/packages/button/src/button.ts +841 -841
  172. package/packages/button-group/index.ts +16 -16
  173. package/packages/calendar/index.ts +16 -16
  174. package/packages/calendar/src/calendar.ts +1351 -1351
  175. package/packages/card/index.ts +16 -16
  176. package/packages/card/src/card.ts +175 -175
  177. package/packages/carousel/index.ts +16 -16
  178. package/packages/carousel/src/carousel-item.ts +102 -102
  179. package/packages/carousel/src/carousel.ts +414 -414
  180. package/packages/carousel/src/util.ts +21 -21
  181. package/packages/carousel-item/index.ts +16 -16
  182. package/packages/cascader/index.ts +16 -16
  183. package/packages/cascader/src/cascader.ts +741 -741
  184. package/packages/checkbox/index.ts +16 -16
  185. package/packages/checkbox/src/button.ts +165 -144
  186. package/packages/checkbox/src/checkbox.ts +176 -154
  187. package/packages/checkbox/src/group.ts +243 -222
  188. package/packages/checkbox-button/index.ts +16 -16
  189. package/packages/checkbox-group/index.ts +16 -16
  190. package/packages/col/index.ts +16 -16
  191. package/packages/collapse/index.ts +16 -16
  192. package/packages/collapse/src/collapse-pane.ts +114 -114
  193. package/packages/collapse/src/collapse.ts +284 -284
  194. package/packages/collapse/src/util.ts +21 -21
  195. package/packages/collapse-pane/index.ts +16 -16
  196. package/packages/color-picker/index.ts +16 -16
  197. package/packages/color-picker/src/color-picker.ts +1109 -1109
  198. package/packages/color-picker/src/util.ts +198 -198
  199. package/packages/components.ts +307 -307
  200. package/packages/context-menu/index.ts +54 -54
  201. package/packages/context-menu/src/context-menu.ts +681 -681
  202. package/packages/countdown/index.ts +16 -16
  203. package/packages/countdown/src/countdown.ts +262 -262
  204. package/packages/date-panel/index.ts +16 -16
  205. package/packages/date-panel/src/date-panel.ts +1809 -1809
  206. package/packages/date-panel/src/util.ts +244 -244
  207. package/packages/date-picker/index.ts +16 -16
  208. package/packages/date-picker/src/date-picker.ts +1071 -1071
  209. package/packages/date-range-picker/index.ts +16 -16
  210. package/packages/date-range-picker/src/date-range-picker.ts +1280 -1280
  211. package/packages/drawer/index.ts +77 -77
  212. package/packages/drawer/src/drawer.ts +657 -657
  213. package/packages/dynamics/index.ts +89 -89
  214. package/packages/empty/index.ts +16 -16
  215. package/packages/empty/src/empty.ts +100 -100
  216. package/packages/form/index.ts +16 -16
  217. package/packages/form/render/index.ts +598 -598
  218. package/packages/form/src/form-config-item.ts +72 -72
  219. package/packages/form/src/form-group.ts +86 -86
  220. package/packages/form/src/form-item.ts +174 -174
  221. package/packages/form/src/form.ts +987 -987
  222. package/packages/form/src/itemInfo.ts +80 -80
  223. package/packages/form/src/render.ts +387 -387
  224. package/packages/form/src/util.ts +93 -93
  225. package/packages/form-gather/index.ts +26 -26
  226. package/packages/form-group/index.ts +16 -16
  227. package/packages/form-item/index.ts +16 -16
  228. package/packages/icon/index.ts +16 -16
  229. package/packages/icon/src/icon.ts +75 -75
  230. package/packages/icon-picker/index.ts +16 -16
  231. package/packages/icon-picker/src/icon-picker.ts +626 -626
  232. package/packages/image/index.ts +16 -16
  233. package/packages/image/src/group.ts +153 -153
  234. package/packages/image/src/image.ts +298 -298
  235. package/packages/image/src/preview.ts +672 -672
  236. package/packages/image/src/util.ts +59 -59
  237. package/packages/image-group/index.ts +16 -16
  238. package/packages/image-preview/index.ts +19 -19
  239. package/packages/index.ts +4 -4
  240. package/packages/input/index.ts +16 -16
  241. package/packages/input/src/input.ts +2788 -2788
  242. package/packages/language/ar-EG.ts +844 -840
  243. package/packages/language/de-DE.ts +844 -840
  244. package/packages/language/en-US.ts +844 -840
  245. package/packages/language/es-ES.ts +844 -840
  246. package/packages/language/fr-FR.ts +844 -840
  247. package/packages/language/hu-HU.ts +844 -840
  248. package/packages/language/hy-AM.ts +844 -840
  249. package/packages/language/id-ID.ts +844 -840
  250. package/packages/language/it-IT.ts +844 -840
  251. package/packages/language/ja-JP.ts +844 -840
  252. package/packages/language/ko-KR.ts +844 -840
  253. package/packages/language/ms-MY.ts +844 -840
  254. package/packages/language/nb-NO.ts +844 -840
  255. package/packages/language/pt-BR.ts +844 -840
  256. package/packages/language/ru-RU.ts +844 -840
  257. package/packages/language/th-TH.ts +844 -840
  258. package/packages/language/ug-CN.ts +844 -840
  259. package/packages/language/uk-UA.ts +844 -840
  260. package/packages/language/uz-UZ.ts +844 -840
  261. package/packages/language/vi-VN.ts +844 -840
  262. package/packages/language/zh-CHT.ts +844 -840
  263. package/packages/language/zh-CN.ts +844 -840
  264. package/packages/language/zh-HK.ts +3 -3
  265. package/packages/language/zh-MO.ts +3 -3
  266. package/packages/language/zh-TC.ts +3 -3
  267. package/packages/language/zh-TW.ts +3 -3
  268. package/packages/layout-aside/index.ts +16 -16
  269. package/packages/layout-aside/src/layout-aside.ts +123 -123
  270. package/packages/layout-body/index.ts +16 -16
  271. package/packages/layout-body/src/layout-body.ts +142 -142
  272. package/packages/layout-container/index.ts +16 -16
  273. package/packages/layout-container/src/layout-container.ts +82 -82
  274. package/packages/layout-footer/index.ts +16 -16
  275. package/packages/layout-footer/src/layout-footer.ts +74 -74
  276. package/packages/layout-header/index.ts +16 -16
  277. package/packages/layout-header/src/layout-header.ts +73 -73
  278. package/packages/link/index.ts +16 -16
  279. package/packages/link/src/link.ts +161 -161
  280. package/packages/list/index.ts +16 -16
  281. package/packages/list/src/list.ts +442 -442
  282. package/packages/loading/index.ts +34 -34
  283. package/packages/loading/src/loading.ts +152 -152
  284. package/packages/mention/index.ts +16 -16
  285. package/packages/mention/src/mention.ts +71 -71
  286. package/packages/menu/index.ts +16 -16
  287. package/packages/menu/src/menu.ts +581 -581
  288. package/packages/modal/index.ts +136 -136
  289. package/packages/modal/src/modal.ts +1494 -1494
  290. package/packages/notice-bar/index.ts +16 -16
  291. package/packages/notice-bar/src/notice-bar.ts +181 -181
  292. package/packages/number-input/index.ts +16 -16
  293. package/packages/number-input/src/number-input.ts +1096 -1096
  294. package/packages/number-input/src/util.ts +12 -12
  295. package/packages/optgroup/index.ts +16 -16
  296. package/packages/option/index.ts +16 -16
  297. package/packages/pager/index.ts +16 -16
  298. package/packages/pager/src/pager.ts +769 -769
  299. package/packages/password-input/index.ts +16 -16
  300. package/packages/password-input/src/password-input.ts +378 -378
  301. package/packages/print/index.ts +18 -18
  302. package/packages/print/src/page-break.ts +92 -92
  303. package/packages/print/src/print.ts +272 -272
  304. package/packages/print/src/util.ts +284 -284
  305. package/packages/print-page-break/index.ts +16 -16
  306. package/packages/pulldown/index.ts +16 -16
  307. package/packages/pulldown/src/pulldown.ts +457 -457
  308. package/packages/radio/index.ts +16 -16
  309. package/packages/radio/src/button.ts +195 -173
  310. package/packages/radio/src/group.ts +229 -213
  311. package/packages/radio/src/radio.ts +203 -180
  312. package/packages/radio-button/index.ts +16 -16
  313. package/packages/radio-group/index.ts +16 -16
  314. package/packages/rate/index.ts +16 -16
  315. package/packages/rate/src/rate.ts +192 -192
  316. package/packages/result/index.ts +16 -16
  317. package/packages/result/src/result.ts +112 -112
  318. package/packages/row/index.ts +16 -16
  319. package/packages/row/src/col.ts +136 -136
  320. package/packages/row/src/row.ts +119 -119
  321. package/packages/segmented/index.ts +16 -16
  322. package/packages/segmented/src/segmented.ts +264 -264
  323. package/packages/select/index.ts +16 -16
  324. package/packages/select/src/optgroup.ts +49 -49
  325. package/packages/select/src/option-info.ts +20 -20
  326. package/packages/select/src/option.ts +47 -47
  327. package/packages/select/src/select.ts +1699 -1699
  328. package/packages/select/src/util.ts +47 -47
  329. package/packages/slider/index.ts +16 -16
  330. package/packages/slider/src/slider.ts +304 -304
  331. package/packages/split/index.ts +16 -16
  332. package/packages/split-pane/index.ts +17 -17
  333. package/packages/splitter/index.ts +16 -16
  334. package/packages/splitter/src/splitter-panel.ts +145 -145
  335. package/packages/splitter/src/splitter.ts +1009 -1009
  336. package/packages/splitter/src/util.ts +21 -21
  337. package/packages/splitter-panel/index.ts +16 -16
  338. package/packages/steps/index.ts +16 -16
  339. package/packages/steps/src/steps.ts +68 -68
  340. package/packages/switch/index.ts +16 -16
  341. package/packages/switch/src/switch.ts +245 -237
  342. package/packages/tab-pane/index.ts +16 -16
  343. package/packages/table-select/index.ts +16 -16
  344. package/packages/table-select/src/table-select.ts +800 -800
  345. package/packages/tabs/index.ts +16 -16
  346. package/packages/tabs/src/tab-pane.ts +117 -117
  347. package/packages/tabs/src/tabs.ts +940 -940
  348. package/packages/tabs/src/util.ts +21 -21
  349. package/packages/tag/index.ts +16 -16
  350. package/packages/tag/src/tag.ts +187 -187
  351. package/packages/text/index.ts +16 -16
  352. package/packages/text/src/text.ts +260 -260
  353. package/packages/text-ellipsis/index.ts +16 -16
  354. package/packages/text-ellipsis/src/text-ellipsis.ts +282 -282
  355. package/packages/textarea/index.ts +16 -16
  356. package/packages/textarea/src/textarea.ts +373 -373
  357. package/packages/timeline/index.ts +16 -16
  358. package/packages/timeline/src/timeline-item.ts +67 -67
  359. package/packages/timeline/src/timeline.ts +71 -71
  360. package/packages/timeline-item/index.ts +16 -16
  361. package/packages/tip/index.ts +19 -19
  362. package/packages/tip/src/tip.ts +129 -129
  363. package/packages/tooltip/index.ts +16 -16
  364. package/packages/tooltip/src/tooltip.ts +589 -589
  365. package/packages/tour/index.ts +16 -16
  366. package/packages/tour/src/tour.ts +71 -71
  367. package/packages/tree/index.ts +16 -16
  368. package/packages/tree/src/store.ts +14 -14
  369. package/packages/tree/src/tree.ts +2825 -2825
  370. package/packages/tree/src/util.ts +45 -45
  371. package/packages/tree-select/index.ts +16 -16
  372. package/packages/tree-select/src/tree-select.ts +979 -979
  373. package/packages/ui/index.ts +697 -697
  374. package/packages/ui/src/anime.ts +52 -52
  375. package/packages/ui/src/comp.ts +3 -3
  376. package/packages/ui/src/dom.ts +279 -279
  377. package/packages/ui/src/log.ts +6 -6
  378. package/packages/ui/src/utils.ts +49 -49
  379. package/packages/ui/src/vn.ts +39 -39
  380. package/packages/upload/index.ts +20 -20
  381. package/packages/upload/src/upload.ts +1919 -1919
  382. package/packages/upload/src/util.ts +109 -109
  383. package/packages/watermark/index.ts +31 -31
  384. package/packages/watermark/src/util.ts +176 -176
  385. package/packages/watermark/src/watermark.ts +168 -168
  386. package/styles/all.scss +90 -90
  387. package/styles/base.scss +16 -16
  388. package/styles/components/alert.scss +101 -101
  389. package/styles/components/anchor.scss +44 -44
  390. package/styles/components/avatar.scss +115 -115
  391. package/styles/components/backtop.scss +82 -82
  392. package/styles/components/badge.scss +45 -45
  393. package/styles/components/breadcrumb.scss +29 -29
  394. package/styles/components/button-group.scss +30 -30
  395. package/styles/components/button.scss +415 -415
  396. package/styles/components/calendar.scss +471 -471
  397. package/styles/components/card.scss +121 -121
  398. package/styles/components/carousel.scss +184 -184
  399. package/styles/components/cascader.scss +140 -140
  400. package/styles/components/checkbox-button.scss +57 -57
  401. package/styles/components/checkbox.scss +81 -81
  402. package/styles/components/collapse.scss +56 -56
  403. package/styles/components/color-picker.scss +409 -409
  404. package/styles/components/context-menu.scss +102 -102
  405. package/styles/components/countdown.scss +35 -35
  406. package/styles/components/date-panel.scss +505 -505
  407. package/styles/components/date-picker.scss +247 -247
  408. package/styles/components/date-range-picker.scss +252 -252
  409. package/styles/components/drawer.scss +298 -298
  410. package/styles/components/empty.scss +79 -79
  411. package/styles/components/form.scss +668 -668
  412. package/styles/components/icon-picker.scss +211 -211
  413. package/styles/components/icon.scss +1048 -1048
  414. package/styles/components/image-group.scss +2 -2
  415. package/styles/components/image-preview.scss +215 -215
  416. package/styles/components/image.scss +16 -16
  417. package/styles/components/input.scss +846 -846
  418. package/styles/components/layout-aside.scss +22 -22
  419. package/styles/components/layout-body.scss +14 -14
  420. package/styles/components/layout-container.scss +13 -13
  421. package/styles/components/layout-footer.scss +14 -14
  422. package/styles/components/layout-header.scss +11 -11
  423. package/styles/components/link.scss +115 -115
  424. package/styles/components/list.scss +40 -40
  425. package/styles/components/loading.scss +137 -137
  426. package/styles/components/menu.scss +150 -150
  427. package/styles/components/modal.scss +480 -480
  428. package/styles/components/notice-bar.scss +91 -91
  429. package/styles/components/number-input.scss +283 -283
  430. package/styles/components/old-icon.scss +4 -4
  431. package/styles/components/pager.scss +282 -282
  432. package/styles/components/password-input.scss +374 -374
  433. package/styles/components/print.scss +3 -3
  434. package/styles/components/pulldown.scss +75 -75
  435. package/styles/components/radio-button.scss +57 -57
  436. package/styles/components/radio.scss +79 -79
  437. package/styles/components/rate.scss +76 -76
  438. package/styles/components/result.scss +91 -91
  439. package/styles/components/row.scss +69 -69
  440. package/styles/components/segmented.scss +215 -215
  441. package/styles/components/select.scss +244 -244
  442. package/styles/components/slider.scss +139 -139
  443. package/styles/components/split.scss +1 -1
  444. package/styles/components/splitter.scss +318 -318
  445. package/styles/components/switch.scss +128 -128
  446. package/styles/components/table-select.scss +105 -105
  447. package/styles/components/tabs.scss +745 -745
  448. package/styles/components/tag.scss +184 -184
  449. package/styles/components/text-ellipsis.scss +130 -130
  450. package/styles/components/text.scss +123 -123
  451. package/styles/components/textarea.scss +106 -106
  452. package/styles/components/tip.scss +97 -97
  453. package/styles/components/tooltip.scss +141 -141
  454. package/styles/components/tree-select.scss +166 -166
  455. package/styles/components/tree.scss +294 -294
  456. package/styles/components/upload.scss +497 -497
  457. package/styles/components/watermark.scss +26 -26
  458. package/styles/helpers/baseMixin.scss +104 -95
  459. package/styles/helpers/baseVar.scss +3 -3
  460. package/styles/helpers/placement.scss +38 -38
  461. package/styles/theme/base.scss +214 -214
  462. package/styles/theme/dark.scss +119 -119
  463. package/styles/theme/light.scss +118 -118
  464. package/styles/variable.scss +111 -111
  465. package/types/all.d.ts +327 -327
  466. package/types/components/alert.d.ts +87 -87
  467. package/types/components/anchor-link.d.ts +91 -91
  468. package/types/components/anchor.d.ts +104 -104
  469. package/types/components/avatar.d.ts +88 -88
  470. package/types/components/backtop.d.ts +122 -122
  471. package/types/components/badge.d.ts +76 -76
  472. package/types/components/breadcrumb-item.d.ts +80 -80
  473. package/types/components/breadcrumb.d.ts +87 -87
  474. package/types/components/button-group.d.ts +120 -120
  475. package/types/components/button.d.ts +323 -323
  476. package/types/components/calendar.d.ts +264 -264
  477. package/types/components/card.d.ts +93 -93
  478. package/types/components/carousel-item.d.ts +75 -75
  479. package/types/components/carousel.d.ts +134 -134
  480. package/types/components/cascader.d.ts +263 -263
  481. package/types/components/checkbox-button.d.ts +103 -103
  482. package/types/components/checkbox-group.d.ts +146 -143
  483. package/types/components/checkbox.d.ts +123 -123
  484. package/types/components/col.d.ts +80 -80
  485. package/types/components/colgroup.d.ts +137 -137
  486. package/types/components/collapse-pane.d.ts +89 -89
  487. package/types/components/collapse.d.ts +121 -121
  488. package/types/components/color-picker.d.ts +176 -176
  489. package/types/components/column.d.ts +841 -841
  490. package/types/components/context-menu.d.ts +289 -289
  491. package/types/components/countdown.d.ts +112 -112
  492. package/types/components/date-panel.d.ts +280 -280
  493. package/types/components/date-picker.d.ts +332 -332
  494. package/types/components/date-range-picker.d.ts +352 -352
  495. package/types/components/drawer.d.ts +299 -299
  496. package/types/components/empty.d.ts +78 -78
  497. package/types/components/flow-design.d.ts +85 -85
  498. package/types/components/flow-view.d.ts +85 -85
  499. package/types/components/form-design.d.ts +376 -376
  500. package/types/components/form-gather.d.ts +124 -124
  501. package/types/components/form-group.d.ts +77 -77
  502. package/types/components/form-item.d.ts +411 -411
  503. package/types/components/form-view.d.ts +183 -183
  504. package/types/components/form.d.ts +468 -468
  505. package/types/components/gantt-module/gantt-view.d.ts +177 -177
  506. package/types/components/gantt-module/index.d.ts +1 -1
  507. package/types/components/gantt-plugins/extend-gantt-chart.d.ts +131 -131
  508. package/types/components/gantt-plugins/index.d.ts +1 -1
  509. package/types/components/gantt.d.ts +1194 -1194
  510. package/types/components/grid.d.ts +1040 -1040
  511. package/types/components/icon-picker.d.ts +196 -196
  512. package/types/components/icon.d.ts +87 -87
  513. package/types/components/image-group.d.ts +127 -127
  514. package/types/components/image-preview.d.ts +167 -167
  515. package/types/components/image.d.ts +173 -173
  516. package/types/components/input.d.ts +435 -435
  517. package/types/components/layout-aside.d.ts +80 -80
  518. package/types/components/layout-body.d.ts +91 -91
  519. package/types/components/layout-container.d.ts +73 -73
  520. package/types/components/layout-footer.d.ts +73 -73
  521. package/types/components/layout-header.d.ts +69 -69
  522. package/types/components/link.d.ts +111 -111
  523. package/types/components/list-design.d.ts +190 -190
  524. package/types/components/list-view.d.ts +199 -199
  525. package/types/components/list.d.ts +204 -204
  526. package/types/components/loading.d.ts +103 -103
  527. package/types/components/mention.d.ts +77 -77
  528. package/types/components/menu.d.ts +211 -211
  529. package/types/components/modal.d.ts +542 -542
  530. package/types/components/notice-bar.d.ts +102 -102
  531. package/types/components/number-input.d.ts +309 -309
  532. package/types/components/optgroup.d.ts +88 -88
  533. package/types/components/option.d.ts +103 -103
  534. package/types/components/pager.d.ts +335 -335
  535. package/types/components/password-input.d.ts +142 -142
  536. package/types/components/print-page-break.d.ts +69 -69
  537. package/types/components/print.d.ts +206 -206
  538. package/types/components/pulldown.d.ts +231 -231
  539. package/types/components/radio-button.d.ts +114 -114
  540. package/types/components/radio-group.d.ts +147 -144
  541. package/types/components/radio.d.ts +129 -129
  542. package/types/components/rate.d.ts +88 -88
  543. package/types/components/result.d.ts +84 -84
  544. package/types/components/row.d.ts +79 -79
  545. package/types/components/segmented.d.ts +123 -123
  546. package/types/components/select.d.ts +527 -527
  547. package/types/components/slider.d.ts +126 -126
  548. package/types/components/split-pane.d.ts +133 -133
  549. package/types/components/split.d.ts +312 -312
  550. package/types/components/splitter-panel.d.ts +105 -105
  551. package/types/components/splitter.d.ts +288 -288
  552. package/types/components/steps.d.ts +68 -68
  553. package/types/components/switch.d.ts +133 -133
  554. package/types/components/tab-pane.d.ts +114 -114
  555. package/types/components/table-module/custom.d.ts +123 -123
  556. package/types/components/table-module/edit.d.ts +243 -243
  557. package/types/components/table-module/export.d.ts +96 -96
  558. package/types/components/table-module/filter.d.ts +140 -140
  559. package/types/components/table-module/index.d.ts +7 -7
  560. package/types/components/table-module/keyboard.d.ts +26 -26
  561. package/types/components/table-module/menu.d.ts +28 -28
  562. package/types/components/table-module/validator.d.ts +53 -53
  563. package/types/components/table-plugins/extend-cell-area.d.ts +770 -770
  564. package/types/components/table-plugins/extend-pivot-table.d.ts +58 -58
  565. package/types/components/table-plugins/filters-combination.d.ts +15 -15
  566. package/types/components/table-plugins/filters-complex-input.d.ts +9 -9
  567. package/types/components/table-plugins/index.d.ts +4 -4
  568. package/types/components/table-select.d.ts +219 -219
  569. package/types/components/table.d.ts +7465 -7465
  570. package/types/components/tabs.d.ts +332 -332
  571. package/types/components/tag.d.ts +114 -114
  572. package/types/components/text-ellipsis.d.ts +112 -112
  573. package/types/components/text.d.ts +122 -122
  574. package/types/components/textarea.d.ts +247 -247
  575. package/types/components/timeline-item.d.ts +75 -75
  576. package/types/components/timeline.d.ts +77 -77
  577. package/types/components/tip.d.ts +83 -83
  578. package/types/components/toolbar.d.ts +336 -336
  579. package/types/components/tooltip.d.ts +180 -180
  580. package/types/components/tour.d.ts +77 -77
  581. package/types/components/tree-select.d.ts +310 -310
  582. package/types/components/tree.d.ts +843 -843
  583. package/types/components/upload.d.ts +437 -437
  584. package/types/components/watermark.d.ts +120 -120
  585. package/types/handles/form-design.d.ts +50 -50
  586. package/types/handles/index.d.ts +3 -3
  587. package/types/handles/list-design.d.ts +2 -2
  588. package/types/handles/table.d.ts +15 -15
  589. package/types/index.d.ts +8 -8
  590. package/types/ui/commands.d.ts +57 -57
  591. package/types/ui/formats.d.ts +62 -62
  592. package/types/ui/global-config.d.ts +254 -254
  593. package/types/ui/global-icon.d.ts +292 -292
  594. package/types/ui/hooks.d.ts +13 -13
  595. package/types/ui/index.d.ts +96 -96
  596. package/types/ui/interceptor.d.ts +52 -52
  597. package/types/ui/menus.d.ts +77 -77
  598. package/types/ui/renderer.d.ts +1041 -1041
  599. package/types/ui/validators.d.ts +38 -38
  600. /package/es/icon/{iconfont.1778317220469.ttf → iconfont.1778465063324.ttf} +0 -0
  601. /package/es/icon/{iconfont.1778317220469.woff → iconfont.1778465063324.woff} +0 -0
  602. /package/es/icon/{iconfont.1778317220469.woff2 → iconfont.1778465063324.woff2} +0 -0
  603. /package/es/{iconfont.1778317220469.ttf → iconfont.1778465063324.ttf} +0 -0
  604. /package/es/{iconfont.1778317220469.woff → iconfont.1778465063324.woff} +0 -0
  605. /package/es/{iconfont.1778317220469.woff2 → iconfont.1778465063324.woff2} +0 -0
  606. /package/lib/icon/style/{iconfont.1778317220469.ttf → iconfont.1778465063324.ttf} +0 -0
  607. /package/lib/icon/style/{iconfont.1778317220469.woff → iconfont.1778465063324.woff} +0 -0
  608. /package/lib/icon/style/{iconfont.1778317220469.woff2 → iconfont.1778465063324.woff2} +0 -0
  609. /package/lib/{iconfont.1778317220469.ttf → iconfont.1778465063324.ttf} +0 -0
  610. /package/lib/{iconfont.1778317220469.woff → iconfont.1778465063324.woff} +0 -0
  611. /package/lib/{iconfont.1778317220469.woff2 → iconfont.1778465063324.woff2} +0 -0
@@ -1,1096 +1,1096 @@
1
- import { h, ref, Ref, computed, reactive, inject, nextTick, watch, onMounted, onBeforeUnmount, PropType } from 'vue'
2
- import { defineVxeComponent } from '../../ui/src/comp'
3
- import XEUtils from 'xe-utils'
4
- import { getConfig, getIcon, getI18n, globalEvents, GLOBAL_EVENT_KEYS, createEvent, useSize, renderEmptyElement } from '../../ui'
5
- import { getFuncText, eqEmptyValue, isEnableConf } from '../../ui/src/utils'
6
- import { hasClass, getEventTargetNode, hasControlKey } from '../../ui/src/dom'
7
- import { getSlotVNs } from '../../ui/src/vn'
8
- import { handleNumber, toFloatValueFixed } from './util'
9
-
10
- import type { VxeNumberInputConstructor, NumberInputInternalData, VxeNumberInputEmits, VxeNumberInputPrivateComputed, NumberInputReactData, NumberInputMethods, VxeNumberInputPropTypes, InputPrivateRef, VxeFormConstructor, VxeFormPrivateMethods, VxeFormDefines, ValueOf } from '../../../types'
11
-
12
- export default defineVxeComponent({
13
- name: 'VxeNumberInput',
14
- props: {
15
- modelValue: [String, Number] as PropType<VxeNumberInputPropTypes.ModelValue>,
16
- immediate: {
17
- type: Boolean as PropType<VxeNumberInputPropTypes.Immediate>,
18
- default: true
19
- },
20
- name: String as PropType<VxeNumberInputPropTypes.Name>,
21
- type: {
22
- type: String as PropType<VxeNumberInputPropTypes.Type>,
23
- default: 'number'
24
- },
25
- clearable: {
26
- type: Boolean as PropType<VxeNumberInputPropTypes.Clearable>,
27
- default: () => getConfig().numberInput.clearable
28
- },
29
- readonly: {
30
- type: Boolean as PropType<VxeNumberInputPropTypes.Readonly>,
31
- default: null
32
- },
33
- disabled: {
34
- type: Boolean as PropType<VxeNumberInputPropTypes.Disabled>,
35
- default: null
36
- },
37
- placeholder: String as PropType<VxeNumberInputPropTypes.Placeholder>,
38
- maxLength: {
39
- type: [String, Number] as PropType<VxeNumberInputPropTypes.MaxLength>,
40
- default: () => getConfig().numberInput.maxLength
41
- },
42
- autoComplete: {
43
- type: String as PropType<VxeNumberInputPropTypes.AutoComplete>,
44
- default: 'off'
45
- },
46
- align: String as PropType<VxeNumberInputPropTypes.Align>,
47
- form: String as PropType<VxeNumberInputPropTypes.Form>,
48
- className: String as PropType<VxeNumberInputPropTypes.ClassName>,
49
- size: {
50
- type: String as PropType<VxeNumberInputPropTypes.Size>,
51
- default: () => getConfig().numberInput.size || getConfig().size
52
- },
53
-
54
- // number、integer、float
55
- min: {
56
- type: [String, Number] as PropType<VxeNumberInputPropTypes.Min>,
57
- default: null
58
- },
59
- max: {
60
- type: [String, Number] as PropType<VxeNumberInputPropTypes.Max>,
61
- default: null
62
- },
63
- step: [String, Number] as PropType<VxeNumberInputPropTypes.Step>,
64
- exponential: {
65
- type: Boolean as PropType<VxeNumberInputPropTypes.Exponential>,
66
- default: () => getConfig().numberInput.exponential
67
- },
68
- showCurrency: {
69
- type: Boolean as PropType<VxeNumberInputPropTypes.ShowCurrency>,
70
- default: () => getConfig().numberInput.showCurrency
71
- },
72
- currencySymbol: {
73
- type: String as PropType<VxeNumberInputPropTypes.CurrencySymbol>,
74
- default: () => getConfig().numberInput.currencySymbol
75
- },
76
- controlConfig: Object as PropType<VxeNumberInputPropTypes.ControlConfig>,
77
-
78
- // float
79
- digits: {
80
- type: [String, Number] as PropType<VxeNumberInputPropTypes.Digits>,
81
- default: null
82
- },
83
- autoFill: {
84
- type: Boolean as PropType<VxeNumberInputPropTypes.AutoFill>,
85
- default: () => getConfig().numberInput.autoFill
86
- },
87
- editable: {
88
- type: Boolean as PropType<VxeNumberInputPropTypes.Editable>,
89
- default: true
90
- },
91
-
92
- plusIcon: String as PropType<VxeNumberInputPropTypes.PlusIcon>,
93
- minusIcon: String as PropType<VxeNumberInputPropTypes.MinusIcon>,
94
- prefixIcon: String as PropType<VxeNumberInputPropTypes.PrefixIcon>,
95
- prefixConfig: Object as PropType<VxeNumberInputPropTypes.PrefixConfig>,
96
- suffixIcon: String as PropType<VxeNumberInputPropTypes.SuffixIcon>,
97
- suffixConfig: Object as PropType<VxeNumberInputPropTypes.SuffixConfig>,
98
-
99
- // 已废弃
100
- controls: {
101
- type: Boolean as PropType<VxeNumberInputPropTypes.Controls>,
102
- default: null
103
- },
104
- // 已废弃
105
- maxlength: [String, Number] as PropType<VxeNumberInputPropTypes.Maxlength>,
106
- // 已废弃
107
- autocomplete: String as PropType<VxeNumberInputPropTypes.Autocomplete>
108
- },
109
- emits: [
110
- 'update:modelValue',
111
- 'input',
112
- 'change',
113
- 'keydown',
114
- 'keyup',
115
- 'wheel',
116
- 'click',
117
- 'focus',
118
- 'blur',
119
- 'clear',
120
- 'lazy-change',
121
- 'plus-number',
122
- 'minus-number',
123
- 'prefix-click',
124
- 'suffix-click',
125
-
126
- // 已废弃
127
- 'prev-number',
128
- 'next-number'
129
- ] as VxeNumberInputEmits,
130
-
131
- setup (props, context) {
132
- const { slots, emit } = context
133
- const $xeForm = inject<VxeFormConstructor & VxeFormPrivateMethods | null>('$xeForm', null)
134
- const formItemInfo = inject<VxeFormDefines.ProvideItemInfo | null>('xeFormItemInfo', null)
135
-
136
- const xID = XEUtils.uniqueId()
137
-
138
- const { computeSize } = useSize(props)
139
-
140
- const reactData = reactive<NumberInputReactData>({
141
- isFocus: false,
142
- isActivated: false,
143
- inputValue: ''
144
- })
145
-
146
- const internalData: NumberInputInternalData = {
147
- // dnTimeout: undefined,
148
- // ainTimeout: undefined,
149
- // isMouseDown: undefined,
150
- // isUM: undefined
151
- }
152
-
153
- const refElem = ref() as Ref<HTMLDivElement>
154
- const refInputTarget = ref() as Ref<HTMLInputElement>
155
- const refInputPanel = ref() as Ref<HTMLDivElement>
156
-
157
- const computeFormReadonly = computed(() => {
158
- const { readonly } = props
159
- if (readonly === null) {
160
- if ($xeForm) {
161
- return $xeForm.props.readonly
162
- }
163
- return false
164
- }
165
- return readonly
166
- })
167
-
168
- const computeIsDisabled = computed(() => {
169
- const { disabled } = props
170
- if (disabled === null) {
171
- if ($xeForm) {
172
- return $xeForm.props.disabled
173
- }
174
- return false
175
- }
176
- return disabled
177
- })
178
-
179
- const computeDigitsValue = computed(() => {
180
- const { type, digits } = props
181
- let defDigits: any = digits
182
- if (defDigits === null) {
183
- defDigits = getConfig().numberInput.digits
184
- if (defDigits === null) {
185
- if (type === 'amount') {
186
- defDigits = 2
187
- }
188
- }
189
- }
190
- return XEUtils.toInteger(defDigits) || 1
191
- })
192
-
193
- const computeControlOpts = computed(() => {
194
- return Object.assign({}, getConfig().numberInput.controlConfig, props.controlConfig)
195
- })
196
-
197
- const computePrefixOpts = computed(() => {
198
- return Object.assign({}, getConfig().numberInput.prefixConfig, props.prefixConfig)
199
- })
200
-
201
- const computeSuffixOpts = computed(() => {
202
- return Object.assign({}, getConfig().numberInput.suffixConfig, props.suffixConfig)
203
- })
204
-
205
- const computeDecimalsType = computed(() => {
206
- const { type } = props
207
- return type === 'float' || type === 'amount'
208
- })
209
-
210
- const computeStepValue = computed(() => {
211
- const { type } = props
212
- const digitsValue = computeDigitsValue.value
213
- const decimalsType = computeDecimalsType.value
214
- const step = props.step
215
- if (type === 'integer') {
216
- return XEUtils.toInteger(step) || 1
217
- } else if (decimalsType) {
218
- return XEUtils.toNumber(step) || (1 / Math.pow(10, digitsValue))
219
- }
220
- return XEUtils.toNumber(step) || 1
221
- })
222
-
223
- const computeIsClearable = computed(() => {
224
- return props.clearable
225
- })
226
-
227
- const computeInputReadonly = computed(() => {
228
- const { editable } = props
229
- const formReadonly = computeFormReadonly.value
230
- return formReadonly || !editable
231
- })
232
-
233
- const computeInpPlaceholder = computed(() => {
234
- const { placeholder } = props
235
- if (placeholder) {
236
- return getFuncText(placeholder)
237
- }
238
- const globalPlaceholder = getConfig().numberInput.placeholder
239
- if (globalPlaceholder) {
240
- return getFuncText(globalPlaceholder)
241
- }
242
- return getI18n('vxe.base.pleaseInput')
243
- })
244
-
245
- const computeInpMaxLength = computed(() => {
246
- const { type, maxLength, maxlength, min, max } = props
247
- const digitsValue = computeDigitsValue.value
248
- // 数值最大长度默认限制 16 位,包含小数
249
- const maxDefLen = 16
250
- if (!eqEmptyValue(min) && !eqEmptyValue(max)) {
251
- return `${max}`.length + (type === 'integer' ? 0 : (digitsValue + 1)) + (XEUtils.toNumber(min) >= 0 ? 0 : 1)
252
- }
253
- if (maxLength || maxlength) {
254
- return XEUtils.toNumber(maxLength || maxlength)
255
- }
256
- return maxDefLen
257
- })
258
-
259
- const computeInpImmediate = computed(() => {
260
- const { immediate } = props
261
- return immediate
262
- })
263
-
264
- const computeNumValue = computed(() => {
265
- const { type } = props
266
- const { inputValue } = reactData
267
- return type === 'integer' ? XEUtils.toInteger(handleNumber(inputValue)) : XEUtils.toNumber(handleNumber(inputValue))
268
- })
269
-
270
- const computeNumLabel = computed(() => {
271
- const { type, showCurrency, currencySymbol, autoFill } = props
272
- const { inputValue } = reactData
273
- const digitsValue = computeDigitsValue.value
274
- if (type === 'amount') {
275
- const num = XEUtils.toNumber(inputValue)
276
- let amountLabel = XEUtils.commafy(num, { digits: digitsValue })
277
- if (!autoFill) {
278
- const [iStr, dStr] = amountLabel.split('.')
279
- if (dStr) {
280
- const dRest = dStr.replace(/0+$/, '')
281
- amountLabel = dRest ? [iStr, '.', dRest].join('') : iStr
282
- }
283
- }
284
- if (showCurrency) {
285
- return `${currencySymbol || getI18n('vxe.numberInput.currencySymbol') || ''}${amountLabel}`
286
- }
287
- return amountLabel
288
- }
289
- return XEUtils.toString(inputValue)
290
- })
291
-
292
- const computeIsDisabledSubtractNumber = computed(() => {
293
- const { min } = props
294
- const { inputValue } = reactData
295
- const numValue = computeNumValue.value
296
- // 当有值时再进行判断
297
- if ((inputValue || inputValue === 0) && min !== null) {
298
- return numValue <= XEUtils.toNumber(min)
299
- }
300
- return false
301
- })
302
-
303
- const computeIsDisabledAddNumber = computed(() => {
304
- const { max } = props
305
- const { inputValue } = reactData
306
- const numValue = computeNumValue.value
307
- // 当有值时再进行判断
308
- if ((inputValue || inputValue === 0) && max !== null) {
309
- return numValue >= XEUtils.toNumber(max)
310
- }
311
- return false
312
- })
313
-
314
- const refMaps: InputPrivateRef = {
315
- refElem,
316
- refInput: refInputTarget
317
- }
318
-
319
- const computeMaps: VxeNumberInputPrivateComputed = {
320
- computeControlOpts
321
- }
322
-
323
- const $xeNumberInput = {
324
- xID,
325
- props,
326
- context,
327
- reactData,
328
- internalData,
329
- getRefMaps: () => refMaps,
330
- getComputeMaps: () => computeMaps
331
- } as unknown as VxeNumberInputConstructor
332
-
333
- let numberInputMethods = {} as NumberInputMethods
334
-
335
- const handleNumberString = (val: any) => {
336
- if (XEUtils.eqNull(val)) {
337
- return ''
338
- }
339
- return `${val}`
340
- }
341
-
342
- const getNumberValue = (val: any) => {
343
- const { exponential, autoFill } = props
344
- const inpMaxLength = computeInpMaxLength.value
345
- const digitsValue = computeDigitsValue.value
346
- const decimalsType = computeDecimalsType.value
347
- let restVal = ''
348
- if (decimalsType) {
349
- restVal = toFloatValueFixed(val, digitsValue)
350
- if (!autoFill) {
351
- restVal = handleNumberString(XEUtils.toNumber(restVal))
352
- }
353
- } else {
354
- restVal = handleNumberString(val)
355
- }
356
- if (exponential && (val === restVal || handleNumberString(val).toLowerCase() === XEUtils.toNumber(restVal).toExponential())) {
357
- return val
358
- }
359
- return restVal.slice(0, inpMaxLength)
360
- }
361
-
362
- const triggerEvent = (evnt: Event & { type: 'input' | 'change' | 'keydown' | 'keyup' | 'wheel' | 'click' | 'focus' | 'blur' }) => {
363
- const { inputValue } = reactData
364
- numberInputMethods.dispatchEvent(evnt.type, { value: inputValue }, evnt)
365
- }
366
-
367
- const handleChange = (val: number | null, inputValue: string, evnt: Event | { type: string }) => {
368
- const value = eqEmptyValue(val) ? null : Number(val)
369
- const isChange = value !== props.modelValue
370
- if (isChange) {
371
- internalData.isUM = true
372
- emit('update:modelValue', value)
373
- }
374
- if (reactData.inputValue !== inputValue) {
375
- nextTick(() => {
376
- reactData.inputValue = inputValue || ''
377
- })
378
- }
379
- numberInputMethods.dispatchEvent('input', { value }, evnt as Event)
380
- if (isChange) {
381
- numberInputMethods.dispatchEvent('change', { value }, evnt as Event)
382
- // 自动更新校验状态
383
- if ($xeForm && formItemInfo) {
384
- $xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, value)
385
- }
386
- }
387
- }
388
-
389
- const emitInputEvent = (inputValue: any, evnt: Event) => {
390
- const inpImmediate = computeInpImmediate.value
391
- const value = eqEmptyValue(inputValue) ? null : XEUtils.toNumber(inputValue)
392
- reactData.inputValue = inputValue
393
- if (inpImmediate) {
394
- handleChange(value, inputValue, evnt)
395
- } else {
396
- numberInputMethods.dispatchEvent('input', { value }, evnt)
397
- }
398
- }
399
-
400
- const inputEvent = (evnt: Event & { type: 'input' }) => {
401
- const inputElem = evnt.target as HTMLInputElement
402
- const value = inputElem.value
403
- emitInputEvent(value, evnt)
404
- }
405
-
406
- const changeEvent = (evnt: Event & { type: 'change' }) => {
407
- const inpImmediate = computeInpImmediate.value
408
- if (!inpImmediate) {
409
- triggerEvent(evnt)
410
- }
411
- $xeNumberInput.dispatchEvent('lazy-change', { value: reactData.inputValue }, evnt)
412
- }
413
-
414
- const focusEvent = (evnt: Event & { type: 'focus' }) => {
415
- const inputReadonly = computeInputReadonly.value
416
- if (!inputReadonly) {
417
- const { inputValue } = reactData
418
- reactData.inputValue = eqEmptyValue(inputValue) ? '' : `${XEUtils.toNumber(inputValue)}`
419
- reactData.isFocus = true
420
- reactData.isActivated = true
421
- triggerEvent(evnt)
422
- }
423
- }
424
-
425
- const clickPrefixEvent = (evnt: Event) => {
426
- const isDisabled = computeIsDisabled.value
427
- if (!isDisabled) {
428
- const { inputValue } = reactData
429
- numberInputMethods.dispatchEvent('prefix-click', { value: inputValue }, evnt)
430
- }
431
- }
432
-
433
- const clearValueEvent = (evnt: Event, value: VxeNumberInputPropTypes.ModelValue) => {
434
- focus()
435
- handleChange(null, '', evnt)
436
- numberInputMethods.dispatchEvent('clear', { value }, evnt)
437
- $xeNumberInput.dispatchEvent('lazy-change', { value }, evnt)
438
- }
439
-
440
- const clickSuffixEvent = (evnt: Event) => {
441
- const isDisabled = computeIsDisabled.value
442
- if (!isDisabled) {
443
- const { inputValue } = reactData
444
- numberInputMethods.dispatchEvent('suffix-click', { value: inputValue }, evnt)
445
- }
446
- }
447
-
448
- const updateModel = (val: any) => {
449
- const { autoFill } = props
450
- const { inputValue } = reactData
451
- const digitsValue = computeDigitsValue.value
452
- const decimalsType = computeDecimalsType.value
453
- if (eqEmptyValue(val)) {
454
- reactData.inputValue = ''
455
- } else {
456
- let textValue = `${val}`
457
- if (decimalsType) {
458
- textValue = toFloatValueFixed(val, digitsValue)
459
- if (!autoFill) {
460
- textValue = `${XEUtils.toNumber(textValue)}`
461
- }
462
- }
463
- if (textValue !== inputValue) {
464
- reactData.inputValue = textValue
465
- }
466
- }
467
- }
468
-
469
- /**
470
- * 检查初始值
471
- */
472
- const initValue = () => {
473
- const { autoFill } = props
474
- const { inputValue } = reactData
475
- const digitsValue = computeDigitsValue.value
476
- const decimalsType = computeDecimalsType.value
477
- if (decimalsType) {
478
- if (inputValue) {
479
- let textValue = ''
480
- let validValue: number | null = null
481
- if (inputValue) {
482
- textValue = toFloatValueFixed(inputValue, digitsValue)
483
- validValue = XEUtils.toNumber(textValue)
484
- if (!autoFill) {
485
- textValue = `${validValue}`
486
- }
487
- }
488
- if (inputValue !== validValue) {
489
- handleChange(validValue, textValue, { type: 'init' })
490
- } else {
491
- reactData.inputValue = textValue
492
- }
493
- }
494
- }
495
- }
496
-
497
- const validMaxNum = (num: number | string) => {
498
- return props.max === null || props.max === '' || XEUtils.toNumber(num) <= XEUtils.toNumber(props.max)
499
- }
500
-
501
- const validMinNum = (num: number | string) => {
502
- return props.min === null || props.min === '' || XEUtils.toNumber(num) >= XEUtils.toNumber(props.min)
503
- }
504
-
505
- const afterCheckValue = () => {
506
- const { type, min, max, exponential } = props
507
- const { inputValue } = reactData
508
- const inputReadonly = computeInputReadonly.value
509
- if (!inputReadonly) {
510
- if (eqEmptyValue(inputValue)) {
511
- let inpNumVal = null
512
- let inpValue = inputValue
513
- if (min || min === 0) {
514
- inpNumVal = XEUtils.toNumber(min)
515
- inpValue = `${inpNumVal}`
516
- }
517
- handleChange(inpNumVal, `${inpValue || ''}`, { type: 'check' })
518
- return
519
- }
520
- if (inputValue || (min || max)) {
521
- let inpNumVal: number | string = type === 'integer' ? XEUtils.toInteger(handleNumber(inputValue)) : XEUtils.toNumber(handleNumber(inputValue))
522
- if (!validMinNum(inpNumVal)) {
523
- inpNumVal = min as number
524
- } else if (!validMaxNum(inpNumVal)) {
525
- inpNumVal = max as number
526
- }
527
- if (exponential) {
528
- const inpStringVal = handleNumberString(inputValue).toLowerCase()
529
- if (inpStringVal === XEUtils.toNumber(inpNumVal).toExponential()) {
530
- inpNumVal = inpStringVal
531
- }
532
- }
533
- const inpValue = getNumberValue(inpNumVal)
534
- handleChange(eqEmptyValue(inpValue) ? null : Number(inpValue), inpValue, { type: 'check' })
535
- }
536
- }
537
- }
538
-
539
- const blurEvent = (evnt: Event & { type: 'blur' }) => {
540
- const { inputValue } = reactData
541
- const inpImmediate = computeInpImmediate.value
542
- const value = inputValue ? Number(inputValue) : null
543
- if (!inpImmediate) {
544
- handleChange(value, handleNumberString(inputValue), evnt)
545
- }
546
- afterCheckValue()
547
- reactData.isFocus = false
548
- reactData.isActivated = false
549
- numberInputMethods.dispatchEvent('blur', { value }, evnt)
550
- // 自动更新校验状态
551
- if ($xeForm && formItemInfo) {
552
- $xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, value)
553
- }
554
- }
555
-
556
- // 数值
557
- const numberChange = (isPlus: boolean, evnt: Event) => {
558
- const { min, max, type } = props
559
- const { inputValue } = reactData
560
- const stepValue = computeStepValue.value
561
- const numValue = type === 'integer' ? XEUtils.toInteger(handleNumber(inputValue)) : XEUtils.toNumber(handleNumber(inputValue))
562
- const newValue = isPlus ? XEUtils.add(numValue, stepValue) : XEUtils.subtract(numValue, stepValue)
563
- let restNum: number | string
564
- if (!validMinNum(newValue)) {
565
- restNum = min as number
566
- } else if (!validMaxNum(newValue)) {
567
- restNum = max as number
568
- } else {
569
- restNum = newValue
570
- }
571
- emitInputEvent(getNumberValue(restNum), evnt as (Event & { type: 'input' }))
572
- }
573
-
574
- const numberPlusEvent = (evnt: Event) => {
575
- const isDisabled = computeIsDisabled.value
576
- const formReadonly = computeFormReadonly.value
577
- const isDisabledAddNumber = computeIsDisabledAddNumber.value
578
- if (!isDisabled && !formReadonly && !isDisabledAddNumber) {
579
- numberChange(true, evnt)
580
- }
581
- reactData.isActivated = true
582
- numberInputMethods.dispatchEvent('plus-number', { value: reactData.inputValue }, evnt)
583
- $xeNumberInput.dispatchEvent('lazy-change', { value: reactData.inputValue }, evnt)
584
- // 已废弃
585
- numberInputMethods.dispatchEvent('next-number', { value: reactData.inputValue }, evnt)
586
- }
587
-
588
- const numberMinusEvent = (evnt: Event) => {
589
- const isDisabled = computeIsDisabled.value
590
- const formReadonly = computeFormReadonly.value
591
- const isDisabledSubtractNumber = computeIsDisabledSubtractNumber.value
592
- if (!isDisabled && !formReadonly && !isDisabledSubtractNumber) {
593
- numberChange(false, evnt)
594
- }
595
- reactData.isActivated = true
596
- numberInputMethods.dispatchEvent('minus-number', { value: reactData.inputValue }, evnt)
597
- $xeNumberInput.dispatchEvent('lazy-change', { value: reactData.inputValue }, evnt)
598
- // 已废弃
599
- numberInputMethods.dispatchEvent('prev-number', { value: reactData.inputValue }, evnt)
600
- }
601
-
602
- const numberKeydownEvent = (evnt: KeyboardEvent) => {
603
- const isUpArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_UP)
604
- const isDwArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_DOWN)
605
- if (isUpArrow || isDwArrow) {
606
- evnt.preventDefault()
607
- if (isUpArrow) {
608
- numberPlusEvent(evnt)
609
- } else {
610
- numberMinusEvent(evnt)
611
- }
612
- }
613
- }
614
-
615
- const keydownEvent = (evnt: KeyboardEvent & { type: 'keydown' }) => {
616
- const { type, exponential, controls } = props
617
- const controlOpts = computeControlOpts.value
618
- const { isArrow } = controlOpts
619
- const inputReadonly = computeInputReadonly.value
620
- const isControlKey = hasControlKey(evnt)
621
- const isShiftKey = evnt.shiftKey
622
- const isAltKey = evnt.altKey
623
- const keyCode = evnt.keyCode
624
- const isEsc = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ESCAPE)
625
- const isUpArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_UP)
626
- const isDwArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_DOWN)
627
- if (!isControlKey && !isShiftKey && !isAltKey) {
628
- if (globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.SPACEBAR) || (type === 'integer' && keyCode === 110) || ((!exponential || keyCode !== 69) && (keyCode >= 65 && keyCode <= 90)) || (keyCode >= 186 && keyCode <= 188) || keyCode >= 191) {
629
- evnt.preventDefault()
630
- }
631
- }
632
- if (isEsc) {
633
- afterCheckValue()
634
- } else if (isUpArrow || isDwArrow) {
635
- if (isEnableConf(controlOpts) && (controls === false ? controls : isArrow) && !inputReadonly) {
636
- numberKeydownEvent(evnt)
637
- }
638
- }
639
- triggerEvent(evnt)
640
- }
641
-
642
- const keyupEvent = (evnt: KeyboardEvent & { type: 'keyup' }) => {
643
- triggerEvent(evnt)
644
- }
645
-
646
- // 数值
647
- const stopDown = () => {
648
- const { dnTimeout } = internalData
649
- if (dnTimeout) {
650
- clearTimeout(dnTimeout)
651
- internalData.dnTimeout = undefined
652
- }
653
- }
654
-
655
- const stopAutoIncrement = () => {
656
- const { ainTimeout } = internalData
657
- if (ainTimeout) {
658
- clearTimeout(ainTimeout)
659
- internalData.ainTimeout = undefined
660
- }
661
- }
662
-
663
- const numberDownMinusEvent = (evnt: Event) => {
664
- numberStopAll()
665
- internalData.ainTimeout = setTimeout(() => {
666
- numberMinusEvent(evnt)
667
- numberDownMinusEvent(evnt)
668
- }, 60)
669
- }
670
-
671
- const numberDownPlusEvent = (evnt: Event) => {
672
- numberStopAll()
673
- internalData.ainTimeout = setTimeout(() => {
674
- numberPlusEvent(evnt)
675
- numberDownPlusEvent(evnt)
676
- }, 60)
677
- }
678
-
679
- const numberStopAll = () => {
680
- stopDown()
681
- stopAutoIncrement()
682
- }
683
-
684
- const numberClickEvent = (evnt: MouseEvent) => {
685
- if (internalData.isMouseDown) {
686
- internalData.isMouseDown = false
687
- } else {
688
- numberStopAll()
689
- const isAddNumber = hasClass(evnt.currentTarget, 'is--plus')
690
- if (isAddNumber) {
691
- numberPlusEvent(evnt)
692
- } else {
693
- numberMinusEvent(evnt)
694
- }
695
- }
696
- }
697
-
698
- const numberMousedownEvent = (evnt: MouseEvent) => {
699
- numberStopAll()
700
- internalData.isMouseDown = true
701
- if (evnt.button === 0) {
702
- const isAddNumber = hasClass(evnt.currentTarget, 'is--plus')
703
- if (isAddNumber) {
704
- numberPlusEvent(evnt)
705
- } else {
706
- numberMinusEvent(evnt)
707
- }
708
- internalData.dnTimeout = setTimeout(() => {
709
- if (isAddNumber) {
710
- numberDownPlusEvent(evnt)
711
- } else {
712
- numberDownMinusEvent(evnt)
713
- }
714
- }, 500)
715
- }
716
- }
717
-
718
- const wheelEvent = (evnt: WheelEvent) => {
719
- const { controls } = props
720
- const controlOpts = computeControlOpts.value
721
- const { isWheel } = controlOpts
722
- const inputReadonly = computeInputReadonly.value
723
- if (isEnableConf(controlOpts) && (controls === false ? controls : isWheel) && !inputReadonly) {
724
- if (reactData.isActivated) {
725
- evnt.stopPropagation()
726
- evnt.preventDefault()
727
- const delta = evnt.deltaY
728
- if (delta > 0) {
729
- // 向下
730
- numberMinusEvent(evnt)
731
- } else if (delta < 0) {
732
- // 向上
733
- numberPlusEvent(evnt)
734
- }
735
- }
736
- }
737
- triggerEvent(evnt as WheelEvent & { type: 'wheel' })
738
- }
739
-
740
- const clickEvent = (evnt: Event & { type: 'click' }) => {
741
- triggerEvent(evnt)
742
- }
743
-
744
- // 全局事件
745
- const handleGlobalMousedownEvent = (evnt: Event) => {
746
- const { isActivated } = reactData
747
- const el = refElem.value
748
- const panelElem = refInputPanel.value
749
- const isDisabled = computeIsDisabled.value
750
- const inputReadonly = computeInputReadonly.value
751
- const inpImmediate = computeInpImmediate.value
752
- if (!isDisabled && !inputReadonly && isActivated) {
753
- reactData.isActivated = getEventTargetNode(evnt, el).flag || getEventTargetNode(evnt, panelElem).flag
754
- if (!reactData.isActivated) {
755
- if (!inpImmediate) {
756
- const { inputValue } = reactData
757
- const value = inputValue ? Number(inputValue) : null
758
- handleChange(value, handleNumberString(inputValue), evnt)
759
- }
760
- afterCheckValue()
761
- }
762
- }
763
- }
764
-
765
- const handleGlobalKeydownEvent = (evnt: KeyboardEvent) => {
766
- const { clearable } = props
767
- const isDisabled = computeIsDisabled.value
768
- const inputReadonly = computeInputReadonly.value
769
- if (!isDisabled && !inputReadonly) {
770
- const isTab = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.TAB)
771
- const isDel = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.DELETE)
772
- let isActivated = reactData.isActivated
773
- if (isTab) {
774
- if (isActivated) {
775
- afterCheckValue()
776
- }
777
- isActivated = false
778
- reactData.isActivated = isActivated
779
- }
780
- if (isDel && clearable) {
781
- if (isActivated) {
782
- clearValueEvent(evnt, null)
783
- }
784
- }
785
- }
786
- }
787
-
788
- const handleGlobalBlurEvent = () => {
789
- const { isActivated } = reactData
790
- if (isActivated) {
791
- afterCheckValue()
792
- }
793
- }
794
-
795
- const dispatchEvent = (type: ValueOf<VxeNumberInputEmits>, params: Record<string, any>, evnt: Event | null) => {
796
- emit(type, createEvent(evnt, { $numberInput: $xeNumberInput }, params))
797
- }
798
-
799
- numberInputMethods = {
800
- dispatchEvent,
801
-
802
- focus () {
803
- const inputReadonly = computeInputReadonly.value
804
- if (!inputReadonly) {
805
- const inputElem = refInputTarget.value
806
- reactData.isActivated = true
807
- inputElem.focus()
808
- }
809
- return nextTick()
810
- },
811
- blur () {
812
- const inputElem = refInputTarget.value
813
- inputElem.blur()
814
- reactData.isActivated = false
815
- return nextTick()
816
- },
817
- select () {
818
- const inputElem = refInputTarget.value
819
- inputElem.select()
820
- reactData.isActivated = false
821
- return nextTick()
822
- }
823
- }
824
-
825
- Object.assign($xeNumberInput, numberInputMethods)
826
-
827
- const renderPrefixIcon = () => {
828
- const { prefixIcon } = props
829
- const prefixOpts = computePrefixOpts.value
830
- const prefixSlot = slots.prefix
831
- const preIcon = prefixIcon || prefixOpts.icon
832
- const sufContent = prefixOpts.content
833
- return prefixSlot || preIcon || sufContent
834
- ? h('div', {
835
- class: 'vxe-number-input--prefix',
836
- onClick: clickPrefixEvent
837
- }, [
838
- h('div', {
839
- class: 'vxe-number-input--prefix-icon'
840
- }, prefixSlot
841
- ? getSlotVNs(prefixSlot({}))
842
- : [
843
- preIcon
844
- ? h('i', {
845
- class: preIcon
846
- })
847
- : renderEmptyElement($xeNumberInput),
848
- sufContent
849
- ? h('span', {
850
- class: 'vxe-prefix-input--suffix-text'
851
- }, `${sufContent}`)
852
- : renderEmptyElement($xeNumberInput)
853
- ])
854
- ])
855
- : renderEmptyElement($xeNumberInput)
856
- }
857
-
858
- const renderSuffixIcon = () => {
859
- const { suffixIcon } = props
860
- const { inputValue } = reactData
861
- const suffixSlot = slots.suffix
862
- const suffixOpts = computeSuffixOpts.value
863
- const isDisabled = computeIsDisabled.value
864
- const isClearable = computeIsClearable.value
865
- const sufIcon = suffixIcon || suffixOpts.icon
866
- const sufContent = suffixOpts.content
867
- return h('div', {
868
- class: ['vxe-number-input--suffix', {
869
- 'is--clear': isClearable && !isDisabled && !(inputValue === '' || XEUtils.eqNull(inputValue))
870
- }]
871
- }, [
872
- isClearable
873
- ? h('div', {
874
- class: 'vxe-number-input--clear-icon',
875
- onClick: clearValueEvent
876
- }, [
877
- h('i', {
878
- class: getIcon().INPUT_CLEAR
879
- })
880
- ])
881
- : renderEmptyElement($xeNumberInput),
882
- suffixSlot || sufIcon || sufContent
883
- ? h('div', {
884
- class: 'vxe-number-input--suffix-icon',
885
- onClick: clickSuffixEvent
886
- }, suffixSlot
887
- ? getSlotVNs(suffixSlot({}))
888
- : [
889
- sufIcon
890
- ? h('i', {
891
- class: sufIcon
892
- })
893
- : renderEmptyElement($xeNumberInput),
894
- sufContent
895
- ? h('span', {
896
- class: 'vxe-number-input--suffix-text'
897
- }, `${sufContent}`)
898
- : renderEmptyElement($xeNumberInput)
899
- ])
900
- : renderEmptyElement($xeNumberInput)
901
- ])
902
- }
903
-
904
- const renderInput = () => {
905
- const { type, name, autocomplete, autoComplete } = props
906
- const { inputValue, isFocus } = reactData
907
- const isDisabled = computeIsDisabled.value
908
- const numLabel = computeNumLabel.value
909
- const inputReadonly = computeInputReadonly.value
910
- const inpMaxLength = computeInpMaxLength.value
911
- const inpPlaceholder = computeInpPlaceholder.value
912
- return h('div', {
913
- key: 'ni',
914
- class: 'vxe-number-input--input-wrapper'
915
- }, [
916
- renderPrefixIcon(),
917
- h('div', {
918
- class: 'vxe-number-input--input-inner'
919
- }, [
920
- h('input', {
921
- ref: refInputTarget,
922
- class: 'vxe-number-input--input',
923
- value: !isFocus && type === 'amount' ? numLabel : inputValue,
924
- name,
925
- type: 'text',
926
- placeholder: inpPlaceholder,
927
- maxlength: inpMaxLength,
928
- readonly: inputReadonly,
929
- disabled: isDisabled,
930
- autocomplete: autoComplete || autocomplete,
931
- onKeydown: keydownEvent,
932
- onKeyup: keyupEvent,
933
- onClick: clickEvent,
934
- onInput: inputEvent,
935
- onChange: changeEvent,
936
- onFocus: focusEvent,
937
- onBlur: blurEvent
938
- })
939
- ]),
940
- renderSuffixIcon()
941
- ])
942
- }
943
-
944
- const renderMinusBtn = () => {
945
- const { minusIcon } = props
946
- const isDisabledSubtractNumber = computeIsDisabledSubtractNumber.value
947
- return h('button', {
948
- key: 'prev',
949
- class: ['vxe-number-input--minus-btn is--minus', {
950
- 'is--disabled': isDisabledSubtractNumber
951
- }],
952
- type: 'button',
953
- onClick: numberClickEvent,
954
- onMousedown: numberMousedownEvent,
955
- onMouseup: numberStopAll,
956
- onMouseleave: numberStopAll
957
- }, [
958
- h('i', {
959
- class: minusIcon || getIcon().NUMBER_INPUT_MINUS_NUM
960
- })
961
- ])
962
- }
963
-
964
- const renderPlusBtn = () => {
965
- const { plusIcon } = props
966
- const isDisabledAddNumber = computeIsDisabledAddNumber.value
967
- return h('button', {
968
- key: 'next',
969
- class: ['vxe-number-input--plus-btn is--plus', {
970
- 'is--disabled': isDisabledAddNumber
971
- }],
972
- type: 'button',
973
- onClick: numberClickEvent,
974
- onMousedown: numberMousedownEvent,
975
- onMouseup: numberStopAll,
976
- onMouseleave: numberStopAll
977
- }, [
978
- h('i', {
979
- class: plusIcon || getIcon().NUMBER_INPUT_PLUS_NUM
980
- })
981
- ])
982
- }
983
-
984
- const renderSideControl = () => {
985
- return h('div', {
986
- key: 'cplr',
987
- class: 'vxe-number-input--side-control'
988
- }, [
989
- renderPlusBtn(),
990
- renderMinusBtn()
991
- ])
992
- }
993
-
994
- const renderVN = () => {
995
- const { className, controls, type, align, prefixIcon, suffixIcon } = props
996
- const { inputValue, isActivated } = reactData
997
- const vSize = computeSize.value
998
- const controlOpts = computeControlOpts.value
999
- const { layout, showButton } = controlOpts
1000
- const isDisabled = computeIsDisabled.value
1001
- const formReadonly = computeFormReadonly.value
1002
- const numLabel = computeNumLabel.value
1003
- const prefixSlot = slots.prefix
1004
- const suffixSlot = slots.suffix
1005
- if (formReadonly) {
1006
- return h('div', {
1007
- ref: refElem,
1008
- class: ['vxe-number-input--readonly', `type--${type}`, className]
1009
- }, numLabel)
1010
- }
1011
- const inputReadonly = computeInputReadonly.value
1012
- const isClearable = computeIsClearable.value
1013
- const isControls = isEnableConf(controlOpts) && (controls === false ? controls : showButton)
1014
- return h('div', {
1015
- ref: refElem,
1016
- class: ['vxe-number-input', `type--${type}`, `ctl--${layout === 'right' || layout === 'left' ? layout : 'default'}`, className, {
1017
- [`size--${vSize}`]: vSize,
1018
- [`is--${align}`]: align,
1019
- 'is--controls': isControls && !inputReadonly,
1020
- 'is--prefix': !!prefixSlot || prefixIcon,
1021
- 'is--suffix': !!suffixSlot || suffixIcon,
1022
- 'is--disabled': isDisabled,
1023
- 'is--active': isActivated,
1024
- 'show--clear': isClearable && !isDisabled && !(inputValue === '' || XEUtils.eqNull(inputValue))
1025
- }],
1026
- spellcheck: false
1027
- }, isControls
1028
- ? (layout === 'right'
1029
- ? [
1030
- renderInput(),
1031
- renderSideControl()
1032
- ]
1033
- : (layout === 'left'
1034
- ? [
1035
- renderSideControl(),
1036
- renderInput()
1037
- ]
1038
- : [
1039
- renderMinusBtn(),
1040
- renderInput(),
1041
- renderPlusBtn()
1042
- ]))
1043
- : [
1044
- renderInput()
1045
- ])
1046
- }
1047
-
1048
- $xeNumberInput.renderVN = renderVN
1049
-
1050
- watch(() => props.modelValue, (val) => {
1051
- if (!internalData.isUM) {
1052
- updateModel(val)
1053
- }
1054
- internalData.isUM = false
1055
- })
1056
-
1057
- watch(() => props.type, () => {
1058
- // 切换类型是重置内置变量
1059
- Object.assign(reactData, {
1060
- inputValue: props.modelValue
1061
- })
1062
- initValue()
1063
- })
1064
-
1065
- onMounted(() => {
1066
- updateModel(props.modelValue)
1067
- const targetElem = refInputTarget.value
1068
- if (targetElem) {
1069
- targetElem.addEventListener('wheel', wheelEvent, { passive: false })
1070
- }
1071
- globalEvents.on($xeNumberInput, 'mousedown', handleGlobalMousedownEvent)
1072
- globalEvents.on($xeNumberInput, 'keydown', handleGlobalKeydownEvent)
1073
- globalEvents.on($xeNumberInput, 'blur', handleGlobalBlurEvent)
1074
- })
1075
-
1076
- onBeforeUnmount(() => {
1077
- reactData.isFocus = false
1078
- numberStopAll()
1079
- afterCheckValue()
1080
- const targetElem = refInputTarget.value
1081
- if (targetElem) {
1082
- targetElem.removeEventListener('wheel', wheelEvent)
1083
- }
1084
- globalEvents.off($xeNumberInput, 'mousedown')
1085
- globalEvents.off($xeNumberInput, 'keydown')
1086
- globalEvents.off($xeNumberInput, 'blur')
1087
- })
1088
-
1089
- initValue()
1090
-
1091
- return $xeNumberInput
1092
- },
1093
- render () {
1094
- return this.renderVN()
1095
- }
1096
- })
1
+ import { h, ref, Ref, computed, reactive, inject, nextTick, watch, onMounted, onBeforeUnmount, PropType } from 'vue'
2
+ import { defineVxeComponent } from '../../ui/src/comp'
3
+ import XEUtils from 'xe-utils'
4
+ import { getConfig, getIcon, getI18n, globalEvents, GLOBAL_EVENT_KEYS, createEvent, useSize, renderEmptyElement } from '../../ui'
5
+ import { getFuncText, eqEmptyValue, isEnableConf } from '../../ui/src/utils'
6
+ import { hasClass, getEventTargetNode, hasControlKey } from '../../ui/src/dom'
7
+ import { getSlotVNs } from '../../ui/src/vn'
8
+ import { handleNumber, toFloatValueFixed } from './util'
9
+
10
+ import type { VxeNumberInputConstructor, NumberInputInternalData, VxeNumberInputEmits, VxeNumberInputPrivateComputed, NumberInputReactData, NumberInputMethods, VxeNumberInputPropTypes, InputPrivateRef, VxeFormConstructor, VxeFormPrivateMethods, VxeFormDefines, ValueOf } from '../../../types'
11
+
12
+ export default defineVxeComponent({
13
+ name: 'VxeNumberInput',
14
+ props: {
15
+ modelValue: [String, Number] as PropType<VxeNumberInputPropTypes.ModelValue>,
16
+ immediate: {
17
+ type: Boolean as PropType<VxeNumberInputPropTypes.Immediate>,
18
+ default: true
19
+ },
20
+ name: String as PropType<VxeNumberInputPropTypes.Name>,
21
+ type: {
22
+ type: String as PropType<VxeNumberInputPropTypes.Type>,
23
+ default: 'number'
24
+ },
25
+ clearable: {
26
+ type: Boolean as PropType<VxeNumberInputPropTypes.Clearable>,
27
+ default: () => getConfig().numberInput.clearable
28
+ },
29
+ readonly: {
30
+ type: Boolean as PropType<VxeNumberInputPropTypes.Readonly>,
31
+ default: null
32
+ },
33
+ disabled: {
34
+ type: Boolean as PropType<VxeNumberInputPropTypes.Disabled>,
35
+ default: null
36
+ },
37
+ placeholder: String as PropType<VxeNumberInputPropTypes.Placeholder>,
38
+ maxLength: {
39
+ type: [String, Number] as PropType<VxeNumberInputPropTypes.MaxLength>,
40
+ default: () => getConfig().numberInput.maxLength
41
+ },
42
+ autoComplete: {
43
+ type: String as PropType<VxeNumberInputPropTypes.AutoComplete>,
44
+ default: 'off'
45
+ },
46
+ align: String as PropType<VxeNumberInputPropTypes.Align>,
47
+ form: String as PropType<VxeNumberInputPropTypes.Form>,
48
+ className: String as PropType<VxeNumberInputPropTypes.ClassName>,
49
+ size: {
50
+ type: String as PropType<VxeNumberInputPropTypes.Size>,
51
+ default: () => getConfig().numberInput.size || getConfig().size
52
+ },
53
+
54
+ // number、integer、float
55
+ min: {
56
+ type: [String, Number] as PropType<VxeNumberInputPropTypes.Min>,
57
+ default: null
58
+ },
59
+ max: {
60
+ type: [String, Number] as PropType<VxeNumberInputPropTypes.Max>,
61
+ default: null
62
+ },
63
+ step: [String, Number] as PropType<VxeNumberInputPropTypes.Step>,
64
+ exponential: {
65
+ type: Boolean as PropType<VxeNumberInputPropTypes.Exponential>,
66
+ default: () => getConfig().numberInput.exponential
67
+ },
68
+ showCurrency: {
69
+ type: Boolean as PropType<VxeNumberInputPropTypes.ShowCurrency>,
70
+ default: () => getConfig().numberInput.showCurrency
71
+ },
72
+ currencySymbol: {
73
+ type: String as PropType<VxeNumberInputPropTypes.CurrencySymbol>,
74
+ default: () => getConfig().numberInput.currencySymbol
75
+ },
76
+ controlConfig: Object as PropType<VxeNumberInputPropTypes.ControlConfig>,
77
+
78
+ // float
79
+ digits: {
80
+ type: [String, Number] as PropType<VxeNumberInputPropTypes.Digits>,
81
+ default: null
82
+ },
83
+ autoFill: {
84
+ type: Boolean as PropType<VxeNumberInputPropTypes.AutoFill>,
85
+ default: () => getConfig().numberInput.autoFill
86
+ },
87
+ editable: {
88
+ type: Boolean as PropType<VxeNumberInputPropTypes.Editable>,
89
+ default: true
90
+ },
91
+
92
+ plusIcon: String as PropType<VxeNumberInputPropTypes.PlusIcon>,
93
+ minusIcon: String as PropType<VxeNumberInputPropTypes.MinusIcon>,
94
+ prefixIcon: String as PropType<VxeNumberInputPropTypes.PrefixIcon>,
95
+ prefixConfig: Object as PropType<VxeNumberInputPropTypes.PrefixConfig>,
96
+ suffixIcon: String as PropType<VxeNumberInputPropTypes.SuffixIcon>,
97
+ suffixConfig: Object as PropType<VxeNumberInputPropTypes.SuffixConfig>,
98
+
99
+ // 已废弃
100
+ controls: {
101
+ type: Boolean as PropType<VxeNumberInputPropTypes.Controls>,
102
+ default: null
103
+ },
104
+ // 已废弃
105
+ maxlength: [String, Number] as PropType<VxeNumberInputPropTypes.Maxlength>,
106
+ // 已废弃
107
+ autocomplete: String as PropType<VxeNumberInputPropTypes.Autocomplete>
108
+ },
109
+ emits: [
110
+ 'update:modelValue',
111
+ 'input',
112
+ 'change',
113
+ 'keydown',
114
+ 'keyup',
115
+ 'wheel',
116
+ 'click',
117
+ 'focus',
118
+ 'blur',
119
+ 'clear',
120
+ 'lazy-change',
121
+ 'plus-number',
122
+ 'minus-number',
123
+ 'prefix-click',
124
+ 'suffix-click',
125
+
126
+ // 已废弃
127
+ 'prev-number',
128
+ 'next-number'
129
+ ] as VxeNumberInputEmits,
130
+
131
+ setup (props, context) {
132
+ const { slots, emit } = context
133
+ const $xeForm = inject<VxeFormConstructor & VxeFormPrivateMethods | null>('$xeForm', null)
134
+ const formItemInfo = inject<VxeFormDefines.ProvideItemInfo | null>('xeFormItemInfo', null)
135
+
136
+ const xID = XEUtils.uniqueId()
137
+
138
+ const { computeSize } = useSize(props)
139
+
140
+ const reactData = reactive<NumberInputReactData>({
141
+ isFocus: false,
142
+ isActivated: false,
143
+ inputValue: ''
144
+ })
145
+
146
+ const internalData: NumberInputInternalData = {
147
+ // dnTimeout: undefined,
148
+ // ainTimeout: undefined,
149
+ // isMouseDown: undefined,
150
+ // isUM: undefined
151
+ }
152
+
153
+ const refElem = ref() as Ref<HTMLDivElement>
154
+ const refInputTarget = ref() as Ref<HTMLInputElement>
155
+ const refInputPanel = ref() as Ref<HTMLDivElement>
156
+
157
+ const computeFormReadonly = computed(() => {
158
+ const { readonly } = props
159
+ if (readonly === null) {
160
+ if ($xeForm) {
161
+ return $xeForm.props.readonly
162
+ }
163
+ return false
164
+ }
165
+ return readonly
166
+ })
167
+
168
+ const computeIsDisabled = computed(() => {
169
+ const { disabled } = props
170
+ if (disabled === null) {
171
+ if ($xeForm) {
172
+ return $xeForm.props.disabled
173
+ }
174
+ return false
175
+ }
176
+ return disabled
177
+ })
178
+
179
+ const computeDigitsValue = computed(() => {
180
+ const { type, digits } = props
181
+ let defDigits: any = digits
182
+ if (defDigits === null) {
183
+ defDigits = getConfig().numberInput.digits
184
+ if (defDigits === null) {
185
+ if (type === 'amount') {
186
+ defDigits = 2
187
+ }
188
+ }
189
+ }
190
+ return XEUtils.toInteger(defDigits) || 1
191
+ })
192
+
193
+ const computeControlOpts = computed(() => {
194
+ return Object.assign({}, getConfig().numberInput.controlConfig, props.controlConfig)
195
+ })
196
+
197
+ const computePrefixOpts = computed(() => {
198
+ return Object.assign({}, getConfig().numberInput.prefixConfig, props.prefixConfig)
199
+ })
200
+
201
+ const computeSuffixOpts = computed(() => {
202
+ return Object.assign({}, getConfig().numberInput.suffixConfig, props.suffixConfig)
203
+ })
204
+
205
+ const computeDecimalsType = computed(() => {
206
+ const { type } = props
207
+ return type === 'float' || type === 'amount'
208
+ })
209
+
210
+ const computeStepValue = computed(() => {
211
+ const { type } = props
212
+ const digitsValue = computeDigitsValue.value
213
+ const decimalsType = computeDecimalsType.value
214
+ const step = props.step
215
+ if (type === 'integer') {
216
+ return XEUtils.toInteger(step) || 1
217
+ } else if (decimalsType) {
218
+ return XEUtils.toNumber(step) || (1 / Math.pow(10, digitsValue))
219
+ }
220
+ return XEUtils.toNumber(step) || 1
221
+ })
222
+
223
+ const computeIsClearable = computed(() => {
224
+ return props.clearable
225
+ })
226
+
227
+ const computeInputReadonly = computed(() => {
228
+ const { editable } = props
229
+ const formReadonly = computeFormReadonly.value
230
+ return formReadonly || !editable
231
+ })
232
+
233
+ const computeInpPlaceholder = computed(() => {
234
+ const { placeholder } = props
235
+ if (placeholder) {
236
+ return getFuncText(placeholder)
237
+ }
238
+ const globalPlaceholder = getConfig().numberInput.placeholder
239
+ if (globalPlaceholder) {
240
+ return getFuncText(globalPlaceholder)
241
+ }
242
+ return getI18n('vxe.base.pleaseInput')
243
+ })
244
+
245
+ const computeInpMaxLength = computed(() => {
246
+ const { type, maxLength, maxlength, min, max } = props
247
+ const digitsValue = computeDigitsValue.value
248
+ // 数值最大长度默认限制 16 位,包含小数
249
+ const maxDefLen = 16
250
+ if (!eqEmptyValue(min) && !eqEmptyValue(max)) {
251
+ return `${max}`.length + (type === 'integer' ? 0 : (digitsValue + 1)) + (XEUtils.toNumber(min) >= 0 ? 0 : 1)
252
+ }
253
+ if (maxLength || maxlength) {
254
+ return XEUtils.toNumber(maxLength || maxlength)
255
+ }
256
+ return maxDefLen
257
+ })
258
+
259
+ const computeInpImmediate = computed(() => {
260
+ const { immediate } = props
261
+ return immediate
262
+ })
263
+
264
+ const computeNumValue = computed(() => {
265
+ const { type } = props
266
+ const { inputValue } = reactData
267
+ return type === 'integer' ? XEUtils.toInteger(handleNumber(inputValue)) : XEUtils.toNumber(handleNumber(inputValue))
268
+ })
269
+
270
+ const computeNumLabel = computed(() => {
271
+ const { type, showCurrency, currencySymbol, autoFill } = props
272
+ const { inputValue } = reactData
273
+ const digitsValue = computeDigitsValue.value
274
+ if (type === 'amount') {
275
+ const num = XEUtils.toNumber(inputValue)
276
+ let amountLabel = XEUtils.commafy(num, { digits: digitsValue })
277
+ if (!autoFill) {
278
+ const [iStr, dStr] = amountLabel.split('.')
279
+ if (dStr) {
280
+ const dRest = dStr.replace(/0+$/, '')
281
+ amountLabel = dRest ? [iStr, '.', dRest].join('') : iStr
282
+ }
283
+ }
284
+ if (showCurrency) {
285
+ return `${currencySymbol || getI18n('vxe.numberInput.currencySymbol') || ''}${amountLabel}`
286
+ }
287
+ return amountLabel
288
+ }
289
+ return XEUtils.toString(inputValue)
290
+ })
291
+
292
+ const computeIsDisabledSubtractNumber = computed(() => {
293
+ const { min } = props
294
+ const { inputValue } = reactData
295
+ const numValue = computeNumValue.value
296
+ // 当有值时再进行判断
297
+ if ((inputValue || inputValue === 0) && min !== null) {
298
+ return numValue <= XEUtils.toNumber(min)
299
+ }
300
+ return false
301
+ })
302
+
303
+ const computeIsDisabledAddNumber = computed(() => {
304
+ const { max } = props
305
+ const { inputValue } = reactData
306
+ const numValue = computeNumValue.value
307
+ // 当有值时再进行判断
308
+ if ((inputValue || inputValue === 0) && max !== null) {
309
+ return numValue >= XEUtils.toNumber(max)
310
+ }
311
+ return false
312
+ })
313
+
314
+ const refMaps: InputPrivateRef = {
315
+ refElem,
316
+ refInput: refInputTarget
317
+ }
318
+
319
+ const computeMaps: VxeNumberInputPrivateComputed = {
320
+ computeControlOpts
321
+ }
322
+
323
+ const $xeNumberInput = {
324
+ xID,
325
+ props,
326
+ context,
327
+ reactData,
328
+ internalData,
329
+ getRefMaps: () => refMaps,
330
+ getComputeMaps: () => computeMaps
331
+ } as unknown as VxeNumberInputConstructor
332
+
333
+ let numberInputMethods = {} as NumberInputMethods
334
+
335
+ const handleNumberString = (val: any) => {
336
+ if (XEUtils.eqNull(val)) {
337
+ return ''
338
+ }
339
+ return `${val}`
340
+ }
341
+
342
+ const getNumberValue = (val: any) => {
343
+ const { exponential, autoFill } = props
344
+ const inpMaxLength = computeInpMaxLength.value
345
+ const digitsValue = computeDigitsValue.value
346
+ const decimalsType = computeDecimalsType.value
347
+ let restVal = ''
348
+ if (decimalsType) {
349
+ restVal = toFloatValueFixed(val, digitsValue)
350
+ if (!autoFill) {
351
+ restVal = handleNumberString(XEUtils.toNumber(restVal))
352
+ }
353
+ } else {
354
+ restVal = handleNumberString(val)
355
+ }
356
+ if (exponential && (val === restVal || handleNumberString(val).toLowerCase() === XEUtils.toNumber(restVal).toExponential())) {
357
+ return val
358
+ }
359
+ return restVal.slice(0, inpMaxLength)
360
+ }
361
+
362
+ const triggerEvent = (evnt: Event & { type: 'input' | 'change' | 'keydown' | 'keyup' | 'wheel' | 'click' | 'focus' | 'blur' }) => {
363
+ const { inputValue } = reactData
364
+ numberInputMethods.dispatchEvent(evnt.type, { value: inputValue }, evnt)
365
+ }
366
+
367
+ const handleChange = (val: number | null, inputValue: string, evnt: Event | { type: string }) => {
368
+ const value = eqEmptyValue(val) ? null : Number(val)
369
+ const isChange = value !== props.modelValue
370
+ if (isChange) {
371
+ internalData.isUM = true
372
+ emit('update:modelValue', value)
373
+ }
374
+ if (reactData.inputValue !== inputValue) {
375
+ nextTick(() => {
376
+ reactData.inputValue = inputValue || ''
377
+ })
378
+ }
379
+ numberInputMethods.dispatchEvent('input', { value }, evnt as Event)
380
+ if (isChange) {
381
+ numberInputMethods.dispatchEvent('change', { value }, evnt as Event)
382
+ // 自动更新校验状态
383
+ if ($xeForm && formItemInfo) {
384
+ $xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, value)
385
+ }
386
+ }
387
+ }
388
+
389
+ const emitInputEvent = (inputValue: any, evnt: Event) => {
390
+ const inpImmediate = computeInpImmediate.value
391
+ const value = eqEmptyValue(inputValue) ? null : XEUtils.toNumber(inputValue)
392
+ reactData.inputValue = inputValue
393
+ if (inpImmediate) {
394
+ handleChange(value, inputValue, evnt)
395
+ } else {
396
+ numberInputMethods.dispatchEvent('input', { value }, evnt)
397
+ }
398
+ }
399
+
400
+ const inputEvent = (evnt: Event & { type: 'input' }) => {
401
+ const inputElem = evnt.target as HTMLInputElement
402
+ const value = inputElem.value
403
+ emitInputEvent(value, evnt)
404
+ }
405
+
406
+ const changeEvent = (evnt: Event & { type: 'change' }) => {
407
+ const inpImmediate = computeInpImmediate.value
408
+ if (!inpImmediate) {
409
+ triggerEvent(evnt)
410
+ }
411
+ $xeNumberInput.dispatchEvent('lazy-change', { value: reactData.inputValue }, evnt)
412
+ }
413
+
414
+ const focusEvent = (evnt: Event & { type: 'focus' }) => {
415
+ const inputReadonly = computeInputReadonly.value
416
+ if (!inputReadonly) {
417
+ const { inputValue } = reactData
418
+ reactData.inputValue = eqEmptyValue(inputValue) ? '' : `${XEUtils.toNumber(inputValue)}`
419
+ reactData.isFocus = true
420
+ reactData.isActivated = true
421
+ triggerEvent(evnt)
422
+ }
423
+ }
424
+
425
+ const clickPrefixEvent = (evnt: Event) => {
426
+ const isDisabled = computeIsDisabled.value
427
+ if (!isDisabled) {
428
+ const { inputValue } = reactData
429
+ numberInputMethods.dispatchEvent('prefix-click', { value: inputValue }, evnt)
430
+ }
431
+ }
432
+
433
+ const clearValueEvent = (evnt: Event, value: VxeNumberInputPropTypes.ModelValue) => {
434
+ focus()
435
+ handleChange(null, '', evnt)
436
+ numberInputMethods.dispatchEvent('clear', { value }, evnt)
437
+ $xeNumberInput.dispatchEvent('lazy-change', { value }, evnt)
438
+ }
439
+
440
+ const clickSuffixEvent = (evnt: Event) => {
441
+ const isDisabled = computeIsDisabled.value
442
+ if (!isDisabled) {
443
+ const { inputValue } = reactData
444
+ numberInputMethods.dispatchEvent('suffix-click', { value: inputValue }, evnt)
445
+ }
446
+ }
447
+
448
+ const updateModel = (val: any) => {
449
+ const { autoFill } = props
450
+ const { inputValue } = reactData
451
+ const digitsValue = computeDigitsValue.value
452
+ const decimalsType = computeDecimalsType.value
453
+ if (eqEmptyValue(val)) {
454
+ reactData.inputValue = ''
455
+ } else {
456
+ let textValue = `${val}`
457
+ if (decimalsType) {
458
+ textValue = toFloatValueFixed(val, digitsValue)
459
+ if (!autoFill) {
460
+ textValue = `${XEUtils.toNumber(textValue)}`
461
+ }
462
+ }
463
+ if (textValue !== inputValue) {
464
+ reactData.inputValue = textValue
465
+ }
466
+ }
467
+ }
468
+
469
+ /**
470
+ * 检查初始值
471
+ */
472
+ const initValue = () => {
473
+ const { autoFill } = props
474
+ const { inputValue } = reactData
475
+ const digitsValue = computeDigitsValue.value
476
+ const decimalsType = computeDecimalsType.value
477
+ if (decimalsType) {
478
+ if (inputValue) {
479
+ let textValue = ''
480
+ let validValue: number | null = null
481
+ if (inputValue) {
482
+ textValue = toFloatValueFixed(inputValue, digitsValue)
483
+ validValue = XEUtils.toNumber(textValue)
484
+ if (!autoFill) {
485
+ textValue = `${validValue}`
486
+ }
487
+ }
488
+ if (inputValue !== validValue) {
489
+ handleChange(validValue, textValue, { type: 'init' })
490
+ } else {
491
+ reactData.inputValue = textValue
492
+ }
493
+ }
494
+ }
495
+ }
496
+
497
+ const validMaxNum = (num: number | string) => {
498
+ return props.max === null || props.max === '' || XEUtils.toNumber(num) <= XEUtils.toNumber(props.max)
499
+ }
500
+
501
+ const validMinNum = (num: number | string) => {
502
+ return props.min === null || props.min === '' || XEUtils.toNumber(num) >= XEUtils.toNumber(props.min)
503
+ }
504
+
505
+ const afterCheckValue = () => {
506
+ const { type, min, max, exponential } = props
507
+ const { inputValue } = reactData
508
+ const inputReadonly = computeInputReadonly.value
509
+ if (!inputReadonly) {
510
+ if (eqEmptyValue(inputValue)) {
511
+ let inpNumVal = null
512
+ let inpValue = inputValue
513
+ if (min || min === 0) {
514
+ inpNumVal = XEUtils.toNumber(min)
515
+ inpValue = `${inpNumVal}`
516
+ }
517
+ handleChange(inpNumVal, `${inpValue || ''}`, { type: 'check' })
518
+ return
519
+ }
520
+ if (inputValue || (min || max)) {
521
+ let inpNumVal: number | string = type === 'integer' ? XEUtils.toInteger(handleNumber(inputValue)) : XEUtils.toNumber(handleNumber(inputValue))
522
+ if (!validMinNum(inpNumVal)) {
523
+ inpNumVal = min as number
524
+ } else if (!validMaxNum(inpNumVal)) {
525
+ inpNumVal = max as number
526
+ }
527
+ if (exponential) {
528
+ const inpStringVal = handleNumberString(inputValue).toLowerCase()
529
+ if (inpStringVal === XEUtils.toNumber(inpNumVal).toExponential()) {
530
+ inpNumVal = inpStringVal
531
+ }
532
+ }
533
+ const inpValue = getNumberValue(inpNumVal)
534
+ handleChange(eqEmptyValue(inpValue) ? null : Number(inpValue), inpValue, { type: 'check' })
535
+ }
536
+ }
537
+ }
538
+
539
+ const blurEvent = (evnt: Event & { type: 'blur' }) => {
540
+ const { inputValue } = reactData
541
+ const inpImmediate = computeInpImmediate.value
542
+ const value = inputValue ? Number(inputValue) : null
543
+ if (!inpImmediate) {
544
+ handleChange(value, handleNumberString(inputValue), evnt)
545
+ }
546
+ afterCheckValue()
547
+ reactData.isFocus = false
548
+ reactData.isActivated = false
549
+ numberInputMethods.dispatchEvent('blur', { value }, evnt)
550
+ // 自动更新校验状态
551
+ if ($xeForm && formItemInfo) {
552
+ $xeForm.triggerItemEvent(evnt, formItemInfo.itemConfig.field, value)
553
+ }
554
+ }
555
+
556
+ // 数值
557
+ const numberChange = (isPlus: boolean, evnt: Event) => {
558
+ const { min, max, type } = props
559
+ const { inputValue } = reactData
560
+ const stepValue = computeStepValue.value
561
+ const numValue = type === 'integer' ? XEUtils.toInteger(handleNumber(inputValue)) : XEUtils.toNumber(handleNumber(inputValue))
562
+ const newValue = isPlus ? XEUtils.add(numValue, stepValue) : XEUtils.subtract(numValue, stepValue)
563
+ let restNum: number | string
564
+ if (!validMinNum(newValue)) {
565
+ restNum = min as number
566
+ } else if (!validMaxNum(newValue)) {
567
+ restNum = max as number
568
+ } else {
569
+ restNum = newValue
570
+ }
571
+ emitInputEvent(getNumberValue(restNum), evnt as (Event & { type: 'input' }))
572
+ }
573
+
574
+ const numberPlusEvent = (evnt: Event) => {
575
+ const isDisabled = computeIsDisabled.value
576
+ const formReadonly = computeFormReadonly.value
577
+ const isDisabledAddNumber = computeIsDisabledAddNumber.value
578
+ if (!isDisabled && !formReadonly && !isDisabledAddNumber) {
579
+ numberChange(true, evnt)
580
+ }
581
+ reactData.isActivated = true
582
+ numberInputMethods.dispatchEvent('plus-number', { value: reactData.inputValue }, evnt)
583
+ $xeNumberInput.dispatchEvent('lazy-change', { value: reactData.inputValue }, evnt)
584
+ // 已废弃
585
+ numberInputMethods.dispatchEvent('next-number', { value: reactData.inputValue }, evnt)
586
+ }
587
+
588
+ const numberMinusEvent = (evnt: Event) => {
589
+ const isDisabled = computeIsDisabled.value
590
+ const formReadonly = computeFormReadonly.value
591
+ const isDisabledSubtractNumber = computeIsDisabledSubtractNumber.value
592
+ if (!isDisabled && !formReadonly && !isDisabledSubtractNumber) {
593
+ numberChange(false, evnt)
594
+ }
595
+ reactData.isActivated = true
596
+ numberInputMethods.dispatchEvent('minus-number', { value: reactData.inputValue }, evnt)
597
+ $xeNumberInput.dispatchEvent('lazy-change', { value: reactData.inputValue }, evnt)
598
+ // 已废弃
599
+ numberInputMethods.dispatchEvent('prev-number', { value: reactData.inputValue }, evnt)
600
+ }
601
+
602
+ const numberKeydownEvent = (evnt: KeyboardEvent) => {
603
+ const isUpArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_UP)
604
+ const isDwArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_DOWN)
605
+ if (isUpArrow || isDwArrow) {
606
+ evnt.preventDefault()
607
+ if (isUpArrow) {
608
+ numberPlusEvent(evnt)
609
+ } else {
610
+ numberMinusEvent(evnt)
611
+ }
612
+ }
613
+ }
614
+
615
+ const keydownEvent = (evnt: KeyboardEvent & { type: 'keydown' }) => {
616
+ const { type, exponential, controls } = props
617
+ const controlOpts = computeControlOpts.value
618
+ const { isArrow } = controlOpts
619
+ const inputReadonly = computeInputReadonly.value
620
+ const isControlKey = hasControlKey(evnt)
621
+ const isShiftKey = evnt.shiftKey
622
+ const isAltKey = evnt.altKey
623
+ const keyCode = evnt.keyCode
624
+ const isEsc = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ESCAPE)
625
+ const isUpArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_UP)
626
+ const isDwArrow = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.ARROW_DOWN)
627
+ if (!isControlKey && !isShiftKey && !isAltKey) {
628
+ if (globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.SPACEBAR) || (type === 'integer' && keyCode === 110) || ((!exponential || keyCode !== 69) && (keyCode >= 65 && keyCode <= 90)) || (keyCode >= 186 && keyCode <= 188) || keyCode >= 191) {
629
+ evnt.preventDefault()
630
+ }
631
+ }
632
+ if (isEsc) {
633
+ afterCheckValue()
634
+ } else if (isUpArrow || isDwArrow) {
635
+ if (isEnableConf(controlOpts) && (controls === false ? controls : isArrow) && !inputReadonly) {
636
+ numberKeydownEvent(evnt)
637
+ }
638
+ }
639
+ triggerEvent(evnt)
640
+ }
641
+
642
+ const keyupEvent = (evnt: KeyboardEvent & { type: 'keyup' }) => {
643
+ triggerEvent(evnt)
644
+ }
645
+
646
+ // 数值
647
+ const stopDown = () => {
648
+ const { dnTimeout } = internalData
649
+ if (dnTimeout) {
650
+ clearTimeout(dnTimeout)
651
+ internalData.dnTimeout = undefined
652
+ }
653
+ }
654
+
655
+ const stopAutoIncrement = () => {
656
+ const { ainTimeout } = internalData
657
+ if (ainTimeout) {
658
+ clearTimeout(ainTimeout)
659
+ internalData.ainTimeout = undefined
660
+ }
661
+ }
662
+
663
+ const numberDownMinusEvent = (evnt: Event) => {
664
+ numberStopAll()
665
+ internalData.ainTimeout = setTimeout(() => {
666
+ numberMinusEvent(evnt)
667
+ numberDownMinusEvent(evnt)
668
+ }, 60)
669
+ }
670
+
671
+ const numberDownPlusEvent = (evnt: Event) => {
672
+ numberStopAll()
673
+ internalData.ainTimeout = setTimeout(() => {
674
+ numberPlusEvent(evnt)
675
+ numberDownPlusEvent(evnt)
676
+ }, 60)
677
+ }
678
+
679
+ const numberStopAll = () => {
680
+ stopDown()
681
+ stopAutoIncrement()
682
+ }
683
+
684
+ const numberClickEvent = (evnt: MouseEvent) => {
685
+ if (internalData.isMouseDown) {
686
+ internalData.isMouseDown = false
687
+ } else {
688
+ numberStopAll()
689
+ const isAddNumber = hasClass(evnt.currentTarget, 'is--plus')
690
+ if (isAddNumber) {
691
+ numberPlusEvent(evnt)
692
+ } else {
693
+ numberMinusEvent(evnt)
694
+ }
695
+ }
696
+ }
697
+
698
+ const numberMousedownEvent = (evnt: MouseEvent) => {
699
+ numberStopAll()
700
+ internalData.isMouseDown = true
701
+ if (evnt.button === 0) {
702
+ const isAddNumber = hasClass(evnt.currentTarget, 'is--plus')
703
+ if (isAddNumber) {
704
+ numberPlusEvent(evnt)
705
+ } else {
706
+ numberMinusEvent(evnt)
707
+ }
708
+ internalData.dnTimeout = setTimeout(() => {
709
+ if (isAddNumber) {
710
+ numberDownPlusEvent(evnt)
711
+ } else {
712
+ numberDownMinusEvent(evnt)
713
+ }
714
+ }, 500)
715
+ }
716
+ }
717
+
718
+ const wheelEvent = (evnt: WheelEvent) => {
719
+ const { controls } = props
720
+ const controlOpts = computeControlOpts.value
721
+ const { isWheel } = controlOpts
722
+ const inputReadonly = computeInputReadonly.value
723
+ if (isEnableConf(controlOpts) && (controls === false ? controls : isWheel) && !inputReadonly) {
724
+ if (reactData.isActivated) {
725
+ evnt.stopPropagation()
726
+ evnt.preventDefault()
727
+ const delta = evnt.deltaY
728
+ if (delta > 0) {
729
+ // 向下
730
+ numberMinusEvent(evnt)
731
+ } else if (delta < 0) {
732
+ // 向上
733
+ numberPlusEvent(evnt)
734
+ }
735
+ }
736
+ }
737
+ triggerEvent(evnt as WheelEvent & { type: 'wheel' })
738
+ }
739
+
740
+ const clickEvent = (evnt: Event & { type: 'click' }) => {
741
+ triggerEvent(evnt)
742
+ }
743
+
744
+ // 全局事件
745
+ const handleGlobalMousedownEvent = (evnt: Event) => {
746
+ const { isActivated } = reactData
747
+ const el = refElem.value
748
+ const panelElem = refInputPanel.value
749
+ const isDisabled = computeIsDisabled.value
750
+ const inputReadonly = computeInputReadonly.value
751
+ const inpImmediate = computeInpImmediate.value
752
+ if (!isDisabled && !inputReadonly && isActivated) {
753
+ reactData.isActivated = getEventTargetNode(evnt, el).flag || getEventTargetNode(evnt, panelElem).flag
754
+ if (!reactData.isActivated) {
755
+ if (!inpImmediate) {
756
+ const { inputValue } = reactData
757
+ const value = inputValue ? Number(inputValue) : null
758
+ handleChange(value, handleNumberString(inputValue), evnt)
759
+ }
760
+ afterCheckValue()
761
+ }
762
+ }
763
+ }
764
+
765
+ const handleGlobalKeydownEvent = (evnt: KeyboardEvent) => {
766
+ const { clearable } = props
767
+ const isDisabled = computeIsDisabled.value
768
+ const inputReadonly = computeInputReadonly.value
769
+ if (!isDisabled && !inputReadonly) {
770
+ const isTab = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.TAB)
771
+ const isDel = globalEvents.hasKey(evnt, GLOBAL_EVENT_KEYS.DELETE)
772
+ let isActivated = reactData.isActivated
773
+ if (isTab) {
774
+ if (isActivated) {
775
+ afterCheckValue()
776
+ }
777
+ isActivated = false
778
+ reactData.isActivated = isActivated
779
+ }
780
+ if (isDel && clearable) {
781
+ if (isActivated) {
782
+ clearValueEvent(evnt, null)
783
+ }
784
+ }
785
+ }
786
+ }
787
+
788
+ const handleGlobalBlurEvent = () => {
789
+ const { isActivated } = reactData
790
+ if (isActivated) {
791
+ afterCheckValue()
792
+ }
793
+ }
794
+
795
+ const dispatchEvent = (type: ValueOf<VxeNumberInputEmits>, params: Record<string, any>, evnt: Event | null) => {
796
+ emit(type, createEvent(evnt, { $numberInput: $xeNumberInput }, params))
797
+ }
798
+
799
+ numberInputMethods = {
800
+ dispatchEvent,
801
+
802
+ focus () {
803
+ const inputReadonly = computeInputReadonly.value
804
+ if (!inputReadonly) {
805
+ const inputElem = refInputTarget.value
806
+ reactData.isActivated = true
807
+ inputElem.focus()
808
+ }
809
+ return nextTick()
810
+ },
811
+ blur () {
812
+ const inputElem = refInputTarget.value
813
+ inputElem.blur()
814
+ reactData.isActivated = false
815
+ return nextTick()
816
+ },
817
+ select () {
818
+ const inputElem = refInputTarget.value
819
+ inputElem.select()
820
+ reactData.isActivated = false
821
+ return nextTick()
822
+ }
823
+ }
824
+
825
+ Object.assign($xeNumberInput, numberInputMethods)
826
+
827
+ const renderPrefixIcon = () => {
828
+ const { prefixIcon } = props
829
+ const prefixOpts = computePrefixOpts.value
830
+ const prefixSlot = slots.prefix
831
+ const preIcon = prefixIcon || prefixOpts.icon
832
+ const sufContent = prefixOpts.content
833
+ return prefixSlot || preIcon || sufContent
834
+ ? h('div', {
835
+ class: 'vxe-number-input--prefix',
836
+ onClick: clickPrefixEvent
837
+ }, [
838
+ h('div', {
839
+ class: 'vxe-number-input--prefix-icon'
840
+ }, prefixSlot
841
+ ? getSlotVNs(prefixSlot({}))
842
+ : [
843
+ preIcon
844
+ ? h('i', {
845
+ class: preIcon
846
+ })
847
+ : renderEmptyElement($xeNumberInput),
848
+ sufContent
849
+ ? h('span', {
850
+ class: 'vxe-prefix-input--suffix-text'
851
+ }, `${sufContent}`)
852
+ : renderEmptyElement($xeNumberInput)
853
+ ])
854
+ ])
855
+ : renderEmptyElement($xeNumberInput)
856
+ }
857
+
858
+ const renderSuffixIcon = () => {
859
+ const { suffixIcon } = props
860
+ const { inputValue } = reactData
861
+ const suffixSlot = slots.suffix
862
+ const suffixOpts = computeSuffixOpts.value
863
+ const isDisabled = computeIsDisabled.value
864
+ const isClearable = computeIsClearable.value
865
+ const sufIcon = suffixIcon || suffixOpts.icon
866
+ const sufContent = suffixOpts.content
867
+ return h('div', {
868
+ class: ['vxe-number-input--suffix', {
869
+ 'is--clear': isClearable && !isDisabled && !(inputValue === '' || XEUtils.eqNull(inputValue))
870
+ }]
871
+ }, [
872
+ isClearable
873
+ ? h('div', {
874
+ class: 'vxe-number-input--clear-icon',
875
+ onClick: clearValueEvent
876
+ }, [
877
+ h('i', {
878
+ class: getIcon().INPUT_CLEAR
879
+ })
880
+ ])
881
+ : renderEmptyElement($xeNumberInput),
882
+ suffixSlot || sufIcon || sufContent
883
+ ? h('div', {
884
+ class: 'vxe-number-input--suffix-icon',
885
+ onClick: clickSuffixEvent
886
+ }, suffixSlot
887
+ ? getSlotVNs(suffixSlot({}))
888
+ : [
889
+ sufIcon
890
+ ? h('i', {
891
+ class: sufIcon
892
+ })
893
+ : renderEmptyElement($xeNumberInput),
894
+ sufContent
895
+ ? h('span', {
896
+ class: 'vxe-number-input--suffix-text'
897
+ }, `${sufContent}`)
898
+ : renderEmptyElement($xeNumberInput)
899
+ ])
900
+ : renderEmptyElement($xeNumberInput)
901
+ ])
902
+ }
903
+
904
+ const renderInput = () => {
905
+ const { type, name, autocomplete, autoComplete } = props
906
+ const { inputValue, isFocus } = reactData
907
+ const isDisabled = computeIsDisabled.value
908
+ const numLabel = computeNumLabel.value
909
+ const inputReadonly = computeInputReadonly.value
910
+ const inpMaxLength = computeInpMaxLength.value
911
+ const inpPlaceholder = computeInpPlaceholder.value
912
+ return h('div', {
913
+ key: 'ni',
914
+ class: 'vxe-number-input--input-wrapper'
915
+ }, [
916
+ renderPrefixIcon(),
917
+ h('div', {
918
+ class: 'vxe-number-input--input-inner'
919
+ }, [
920
+ h('input', {
921
+ ref: refInputTarget,
922
+ class: 'vxe-number-input--input',
923
+ value: !isFocus && type === 'amount' ? numLabel : inputValue,
924
+ name,
925
+ type: 'text',
926
+ placeholder: inpPlaceholder,
927
+ maxlength: inpMaxLength,
928
+ readonly: inputReadonly,
929
+ disabled: isDisabled,
930
+ autocomplete: autoComplete || autocomplete,
931
+ onKeydown: keydownEvent,
932
+ onKeyup: keyupEvent,
933
+ onClick: clickEvent,
934
+ onInput: inputEvent,
935
+ onChange: changeEvent,
936
+ onFocus: focusEvent,
937
+ onBlur: blurEvent
938
+ })
939
+ ]),
940
+ renderSuffixIcon()
941
+ ])
942
+ }
943
+
944
+ const renderMinusBtn = () => {
945
+ const { minusIcon } = props
946
+ const isDisabledSubtractNumber = computeIsDisabledSubtractNumber.value
947
+ return h('button', {
948
+ key: 'prev',
949
+ class: ['vxe-number-input--minus-btn is--minus', {
950
+ 'is--disabled': isDisabledSubtractNumber
951
+ }],
952
+ type: 'button',
953
+ onClick: numberClickEvent,
954
+ onMousedown: numberMousedownEvent,
955
+ onMouseup: numberStopAll,
956
+ onMouseleave: numberStopAll
957
+ }, [
958
+ h('i', {
959
+ class: minusIcon || getIcon().NUMBER_INPUT_MINUS_NUM
960
+ })
961
+ ])
962
+ }
963
+
964
+ const renderPlusBtn = () => {
965
+ const { plusIcon } = props
966
+ const isDisabledAddNumber = computeIsDisabledAddNumber.value
967
+ return h('button', {
968
+ key: 'next',
969
+ class: ['vxe-number-input--plus-btn is--plus', {
970
+ 'is--disabled': isDisabledAddNumber
971
+ }],
972
+ type: 'button',
973
+ onClick: numberClickEvent,
974
+ onMousedown: numberMousedownEvent,
975
+ onMouseup: numberStopAll,
976
+ onMouseleave: numberStopAll
977
+ }, [
978
+ h('i', {
979
+ class: plusIcon || getIcon().NUMBER_INPUT_PLUS_NUM
980
+ })
981
+ ])
982
+ }
983
+
984
+ const renderSideControl = () => {
985
+ return h('div', {
986
+ key: 'cplr',
987
+ class: 'vxe-number-input--side-control'
988
+ }, [
989
+ renderPlusBtn(),
990
+ renderMinusBtn()
991
+ ])
992
+ }
993
+
994
+ const renderVN = () => {
995
+ const { className, controls, type, align, prefixIcon, suffixIcon } = props
996
+ const { inputValue, isActivated } = reactData
997
+ const vSize = computeSize.value
998
+ const controlOpts = computeControlOpts.value
999
+ const { layout, showButton } = controlOpts
1000
+ const isDisabled = computeIsDisabled.value
1001
+ const formReadonly = computeFormReadonly.value
1002
+ const numLabel = computeNumLabel.value
1003
+ const prefixSlot = slots.prefix
1004
+ const suffixSlot = slots.suffix
1005
+ if (formReadonly) {
1006
+ return h('div', {
1007
+ ref: refElem,
1008
+ class: ['vxe-number-input--readonly', `type--${type}`, className]
1009
+ }, numLabel)
1010
+ }
1011
+ const inputReadonly = computeInputReadonly.value
1012
+ const isClearable = computeIsClearable.value
1013
+ const isControls = isEnableConf(controlOpts) && (controls === false ? controls : showButton)
1014
+ return h('div', {
1015
+ ref: refElem,
1016
+ class: ['vxe-number-input', `type--${type}`, `ctl--${layout === 'right' || layout === 'left' ? layout : 'default'}`, className, {
1017
+ [`size--${vSize}`]: vSize,
1018
+ [`is--${align}`]: align,
1019
+ 'is--controls': isControls && !inputReadonly,
1020
+ 'is--prefix': !!prefixSlot || prefixIcon,
1021
+ 'is--suffix': !!suffixSlot || suffixIcon,
1022
+ 'is--disabled': isDisabled,
1023
+ 'is--active': isActivated,
1024
+ 'show--clear': isClearable && !isDisabled && !(inputValue === '' || XEUtils.eqNull(inputValue))
1025
+ }],
1026
+ spellcheck: false
1027
+ }, isControls
1028
+ ? (layout === 'right'
1029
+ ? [
1030
+ renderInput(),
1031
+ renderSideControl()
1032
+ ]
1033
+ : (layout === 'left'
1034
+ ? [
1035
+ renderSideControl(),
1036
+ renderInput()
1037
+ ]
1038
+ : [
1039
+ renderMinusBtn(),
1040
+ renderInput(),
1041
+ renderPlusBtn()
1042
+ ]))
1043
+ : [
1044
+ renderInput()
1045
+ ])
1046
+ }
1047
+
1048
+ $xeNumberInput.renderVN = renderVN
1049
+
1050
+ watch(() => props.modelValue, (val) => {
1051
+ if (!internalData.isUM) {
1052
+ updateModel(val)
1053
+ }
1054
+ internalData.isUM = false
1055
+ })
1056
+
1057
+ watch(() => props.type, () => {
1058
+ // 切换类型是重置内置变量
1059
+ Object.assign(reactData, {
1060
+ inputValue: props.modelValue
1061
+ })
1062
+ initValue()
1063
+ })
1064
+
1065
+ onMounted(() => {
1066
+ updateModel(props.modelValue)
1067
+ const targetElem = refInputTarget.value
1068
+ if (targetElem) {
1069
+ targetElem.addEventListener('wheel', wheelEvent, { passive: false })
1070
+ }
1071
+ globalEvents.on($xeNumberInput, 'mousedown', handleGlobalMousedownEvent)
1072
+ globalEvents.on($xeNumberInput, 'keydown', handleGlobalKeydownEvent)
1073
+ globalEvents.on($xeNumberInput, 'blur', handleGlobalBlurEvent)
1074
+ })
1075
+
1076
+ onBeforeUnmount(() => {
1077
+ reactData.isFocus = false
1078
+ numberStopAll()
1079
+ afterCheckValue()
1080
+ const targetElem = refInputTarget.value
1081
+ if (targetElem) {
1082
+ targetElem.removeEventListener('wheel', wheelEvent)
1083
+ }
1084
+ globalEvents.off($xeNumberInput, 'mousedown')
1085
+ globalEvents.off($xeNumberInput, 'keydown')
1086
+ globalEvents.off($xeNumberInput, 'blur')
1087
+ })
1088
+
1089
+ initValue()
1090
+
1091
+ return $xeNumberInput
1092
+ },
1093
+ render () {
1094
+ return this.renderVN()
1095
+ }
1096
+ })