vxe-pc-ui 4.14.4 → 4.14.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (480) 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/tree/src/tree.js +31 -2
  7. package/es/tree-select/src/tree-select.js +2 -0
  8. package/es/ui/index.js +1 -1
  9. package/es/ui/src/log.js +1 -1
  10. package/lib/index.umd.js +2359 -2257
  11. package/lib/index.umd.min.js +1 -1
  12. package/lib/tree/src/tree.js +27 -2
  13. package/lib/tree/src/tree.min.js +1 -1
  14. package/lib/tree-select/src/tree-select.js +2 -0
  15. package/lib/tree-select/src/tree-select.min.js +1 -1
  16. package/lib/ui/index.js +1 -1
  17. package/lib/ui/index.min.js +1 -1
  18. package/lib/ui/src/log.js +1 -1
  19. package/lib/ui/src/log.min.js +1 -1
  20. package/package.json +88 -88
  21. package/packages/alert/index.ts +16 -16
  22. package/packages/alert/src/alert.ts +124 -124
  23. package/packages/anchor/index.ts +16 -16
  24. package/packages/anchor/src/anchor-link.ts +121 -121
  25. package/packages/anchor/src/anchor.ts +237 -237
  26. package/packages/anchor/src/util.ts +23 -23
  27. package/packages/anchor-link/index.ts +16 -16
  28. package/packages/avatar/index.ts +16 -16
  29. package/packages/avatar/src/avatar.ts +149 -149
  30. package/packages/backtop/index.ts +16 -16
  31. package/packages/backtop/src/backtop.ts +314 -314
  32. package/packages/badge/index.ts +16 -16
  33. package/packages/badge/src/badge.ts +100 -100
  34. package/packages/breadcrumb/index.ts +16 -16
  35. package/packages/breadcrumb/src/breadcrumb-item.ts +106 -106
  36. package/packages/breadcrumb/src/breadcrumb.ts +92 -92
  37. package/packages/breadcrumb-item/index.ts +16 -16
  38. package/packages/button/index.ts +16 -16
  39. package/packages/button/src/button-group.ts +110 -110
  40. package/packages/button/src/button.ts +841 -841
  41. package/packages/button-group/index.ts +16 -16
  42. package/packages/calendar/index.ts +16 -16
  43. package/packages/calendar/src/calendar.ts +1351 -1351
  44. package/packages/card/index.ts +16 -16
  45. package/packages/card/src/card.ts +175 -175
  46. package/packages/carousel/index.ts +16 -16
  47. package/packages/carousel/src/carousel-item.ts +102 -102
  48. package/packages/carousel/src/carousel.ts +414 -414
  49. package/packages/carousel/src/util.ts +21 -21
  50. package/packages/carousel-item/index.ts +16 -16
  51. package/packages/cascader/index.ts +16 -16
  52. package/packages/cascader/src/cascader.ts +741 -741
  53. package/packages/checkbox/index.ts +16 -16
  54. package/packages/checkbox/src/button.ts +144 -144
  55. package/packages/checkbox/src/checkbox.ts +154 -154
  56. package/packages/checkbox/src/group.ts +222 -222
  57. package/packages/checkbox-button/index.ts +16 -16
  58. package/packages/checkbox-group/index.ts +16 -16
  59. package/packages/col/index.ts +16 -16
  60. package/packages/collapse/index.ts +16 -16
  61. package/packages/collapse/src/collapse-pane.ts +114 -114
  62. package/packages/collapse/src/collapse.ts +284 -284
  63. package/packages/collapse/src/util.ts +21 -21
  64. package/packages/collapse-pane/index.ts +16 -16
  65. package/packages/color-picker/index.ts +16 -16
  66. package/packages/color-picker/src/color-picker.ts +1109 -1109
  67. package/packages/color-picker/src/util.ts +198 -198
  68. package/packages/components.ts +307 -307
  69. package/packages/context-menu/index.ts +54 -54
  70. package/packages/context-menu/src/context-menu.ts +681 -681
  71. package/packages/countdown/index.ts +16 -16
  72. package/packages/countdown/src/countdown.ts +262 -262
  73. package/packages/date-panel/index.ts +16 -16
  74. package/packages/date-panel/src/date-panel.ts +1809 -1809
  75. package/packages/date-panel/src/util.ts +244 -244
  76. package/packages/date-picker/index.ts +16 -16
  77. package/packages/date-picker/src/date-picker.ts +1071 -1071
  78. package/packages/date-range-picker/index.ts +16 -16
  79. package/packages/date-range-picker/src/date-range-picker.ts +1280 -1280
  80. package/packages/drawer/index.ts +77 -77
  81. package/packages/drawer/src/drawer.ts +657 -657
  82. package/packages/dynamics/index.ts +89 -89
  83. package/packages/empty/index.ts +16 -16
  84. package/packages/empty/src/empty.ts +100 -100
  85. package/packages/form/index.ts +16 -16
  86. package/packages/form/render/index.ts +598 -598
  87. package/packages/form/src/form-config-item.ts +72 -72
  88. package/packages/form/src/form-group.ts +86 -86
  89. package/packages/form/src/form-item.ts +174 -174
  90. package/packages/form/src/form.ts +987 -987
  91. package/packages/form/src/itemInfo.ts +80 -80
  92. package/packages/form/src/render.ts +387 -387
  93. package/packages/form/src/util.ts +93 -93
  94. package/packages/form-gather/index.ts +26 -26
  95. package/packages/form-group/index.ts +16 -16
  96. package/packages/form-item/index.ts +16 -16
  97. package/packages/icon/index.ts +16 -16
  98. package/packages/icon/src/icon.ts +75 -75
  99. package/packages/icon-picker/index.ts +16 -16
  100. package/packages/icon-picker/src/icon-picker.ts +626 -626
  101. package/packages/image/index.ts +16 -16
  102. package/packages/image/src/group.ts +153 -153
  103. package/packages/image/src/image.ts +298 -298
  104. package/packages/image/src/preview.ts +672 -672
  105. package/packages/image/src/util.ts +59 -59
  106. package/packages/image-group/index.ts +16 -16
  107. package/packages/image-preview/index.ts +19 -19
  108. package/packages/index.ts +4 -4
  109. package/packages/input/index.ts +16 -16
  110. package/packages/input/src/input.ts +2788 -2788
  111. package/packages/language/ar-EG.ts +840 -840
  112. package/packages/language/de-DE.ts +840 -840
  113. package/packages/language/en-US.ts +840 -840
  114. package/packages/language/es-ES.ts +840 -840
  115. package/packages/language/fr-FR.ts +840 -840
  116. package/packages/language/hu-HU.ts +840 -840
  117. package/packages/language/hy-AM.ts +840 -840
  118. package/packages/language/id-ID.ts +840 -840
  119. package/packages/language/it-IT.ts +840 -840
  120. package/packages/language/ja-JP.ts +840 -840
  121. package/packages/language/ko-KR.ts +840 -840
  122. package/packages/language/ms-MY.ts +840 -840
  123. package/packages/language/nb-NO.ts +840 -840
  124. package/packages/language/pt-BR.ts +840 -840
  125. package/packages/language/ru-RU.ts +840 -840
  126. package/packages/language/th-TH.ts +840 -840
  127. package/packages/language/ug-CN.ts +840 -840
  128. package/packages/language/uk-UA.ts +840 -840
  129. package/packages/language/uz-UZ.ts +840 -840
  130. package/packages/language/vi-VN.ts +840 -840
  131. package/packages/language/zh-CHT.ts +840 -840
  132. package/packages/language/zh-CN.ts +840 -840
  133. package/packages/language/zh-HK.ts +3 -3
  134. package/packages/language/zh-MO.ts +3 -3
  135. package/packages/language/zh-TC.ts +3 -3
  136. package/packages/language/zh-TW.ts +3 -3
  137. package/packages/layout-aside/index.ts +16 -16
  138. package/packages/layout-aside/src/layout-aside.ts +123 -123
  139. package/packages/layout-body/index.ts +16 -16
  140. package/packages/layout-body/src/layout-body.ts +142 -142
  141. package/packages/layout-container/index.ts +16 -16
  142. package/packages/layout-container/src/layout-container.ts +82 -82
  143. package/packages/layout-footer/index.ts +16 -16
  144. package/packages/layout-footer/src/layout-footer.ts +74 -74
  145. package/packages/layout-header/index.ts +16 -16
  146. package/packages/layout-header/src/layout-header.ts +73 -73
  147. package/packages/link/index.ts +16 -16
  148. package/packages/link/src/link.ts +161 -161
  149. package/packages/list/index.ts +16 -16
  150. package/packages/list/src/list.ts +442 -442
  151. package/packages/loading/index.ts +34 -34
  152. package/packages/loading/src/loading.ts +152 -152
  153. package/packages/mention/index.ts +16 -16
  154. package/packages/mention/src/mention.ts +71 -71
  155. package/packages/menu/index.ts +16 -16
  156. package/packages/menu/src/menu.ts +581 -581
  157. package/packages/modal/index.ts +136 -136
  158. package/packages/modal/src/modal.ts +1494 -1494
  159. package/packages/notice-bar/index.ts +16 -16
  160. package/packages/notice-bar/src/notice-bar.ts +181 -181
  161. package/packages/number-input/index.ts +16 -16
  162. package/packages/number-input/src/number-input.ts +1096 -1096
  163. package/packages/number-input/src/util.ts +12 -12
  164. package/packages/optgroup/index.ts +16 -16
  165. package/packages/option/index.ts +16 -16
  166. package/packages/pager/index.ts +16 -16
  167. package/packages/pager/src/pager.ts +769 -769
  168. package/packages/password-input/index.ts +16 -16
  169. package/packages/password-input/src/password-input.ts +378 -378
  170. package/packages/print/index.ts +18 -18
  171. package/packages/print/src/page-break.ts +92 -92
  172. package/packages/print/src/print.ts +272 -272
  173. package/packages/print/src/util.ts +284 -284
  174. package/packages/print-page-break/index.ts +16 -16
  175. package/packages/pulldown/index.ts +16 -16
  176. package/packages/pulldown/src/pulldown.ts +457 -457
  177. package/packages/radio/index.ts +16 -16
  178. package/packages/radio/src/button.ts +173 -173
  179. package/packages/radio/src/group.ts +213 -213
  180. package/packages/radio/src/radio.ts +180 -180
  181. package/packages/radio-button/index.ts +16 -16
  182. package/packages/radio-group/index.ts +16 -16
  183. package/packages/rate/index.ts +16 -16
  184. package/packages/rate/src/rate.ts +192 -192
  185. package/packages/result/index.ts +16 -16
  186. package/packages/result/src/result.ts +112 -112
  187. package/packages/row/index.ts +16 -16
  188. package/packages/row/src/col.ts +136 -136
  189. package/packages/row/src/row.ts +119 -119
  190. package/packages/segmented/index.ts +16 -16
  191. package/packages/segmented/src/segmented.ts +264 -264
  192. package/packages/select/index.ts +16 -16
  193. package/packages/select/src/optgroup.ts +49 -49
  194. package/packages/select/src/option-info.ts +20 -20
  195. package/packages/select/src/option.ts +47 -47
  196. package/packages/select/src/select.ts +1699 -1699
  197. package/packages/select/src/util.ts +47 -47
  198. package/packages/slider/index.ts +16 -16
  199. package/packages/slider/src/slider.ts +304 -304
  200. package/packages/split/index.ts +16 -16
  201. package/packages/split-pane/index.ts +17 -17
  202. package/packages/splitter/index.ts +16 -16
  203. package/packages/splitter/src/splitter-panel.ts +145 -145
  204. package/packages/splitter/src/splitter.ts +1009 -1009
  205. package/packages/splitter/src/util.ts +21 -21
  206. package/packages/splitter-panel/index.ts +16 -16
  207. package/packages/steps/index.ts +16 -16
  208. package/packages/steps/src/steps.ts +68 -68
  209. package/packages/switch/index.ts +16 -16
  210. package/packages/switch/src/switch.ts +237 -237
  211. package/packages/tab-pane/index.ts +16 -16
  212. package/packages/table-select/index.ts +16 -16
  213. package/packages/table-select/src/table-select.ts +800 -800
  214. package/packages/tabs/index.ts +16 -16
  215. package/packages/tabs/src/tab-pane.ts +117 -117
  216. package/packages/tabs/src/tabs.ts +940 -940
  217. package/packages/tabs/src/util.ts +21 -21
  218. package/packages/tag/index.ts +16 -16
  219. package/packages/tag/src/tag.ts +187 -187
  220. package/packages/text/index.ts +16 -16
  221. package/packages/text/src/text.ts +260 -260
  222. package/packages/text-ellipsis/index.ts +16 -16
  223. package/packages/text-ellipsis/src/text-ellipsis.ts +282 -282
  224. package/packages/textarea/index.ts +16 -16
  225. package/packages/textarea/src/textarea.ts +373 -373
  226. package/packages/timeline/index.ts +16 -16
  227. package/packages/timeline/src/timeline-item.ts +67 -67
  228. package/packages/timeline/src/timeline.ts +71 -71
  229. package/packages/timeline-item/index.ts +16 -16
  230. package/packages/tip/index.ts +19 -19
  231. package/packages/tip/src/tip.ts +129 -129
  232. package/packages/tooltip/index.ts +16 -16
  233. package/packages/tooltip/src/tooltip.ts +589 -589
  234. package/packages/tour/index.ts +16 -16
  235. package/packages/tour/src/tour.ts +71 -71
  236. package/packages/tree/index.ts +16 -16
  237. package/packages/tree/src/store.ts +14 -14
  238. package/packages/tree/src/tree.ts +2825 -2795
  239. package/packages/tree/src/util.ts +45 -45
  240. package/packages/tree-select/index.ts +16 -16
  241. package/packages/tree-select/src/tree-select.ts +979 -977
  242. package/packages/ui/index.ts +697 -697
  243. package/packages/ui/src/anime.ts +52 -52
  244. package/packages/ui/src/comp.ts +3 -3
  245. package/packages/ui/src/dom.ts +279 -279
  246. package/packages/ui/src/log.ts +6 -6
  247. package/packages/ui/src/utils.ts +49 -49
  248. package/packages/ui/src/vn.ts +39 -39
  249. package/packages/upload/index.ts +20 -20
  250. package/packages/upload/src/upload.ts +1919 -1919
  251. package/packages/upload/src/util.ts +109 -109
  252. package/packages/watermark/index.ts +31 -31
  253. package/packages/watermark/src/util.ts +176 -176
  254. package/packages/watermark/src/watermark.ts +168 -168
  255. package/styles/all.scss +90 -90
  256. package/styles/base.scss +16 -16
  257. package/styles/components/alert.scss +101 -101
  258. package/styles/components/anchor.scss +44 -44
  259. package/styles/components/avatar.scss +115 -115
  260. package/styles/components/backtop.scss +82 -82
  261. package/styles/components/badge.scss +45 -45
  262. package/styles/components/breadcrumb.scss +29 -29
  263. package/styles/components/button-group.scss +30 -30
  264. package/styles/components/button.scss +415 -415
  265. package/styles/components/calendar.scss +471 -471
  266. package/styles/components/card.scss +121 -121
  267. package/styles/components/carousel.scss +184 -184
  268. package/styles/components/cascader.scss +140 -140
  269. package/styles/components/checkbox-button.scss +57 -57
  270. package/styles/components/checkbox.scss +81 -81
  271. package/styles/components/collapse.scss +56 -56
  272. package/styles/components/color-picker.scss +409 -409
  273. package/styles/components/context-menu.scss +102 -102
  274. package/styles/components/countdown.scss +35 -35
  275. package/styles/components/date-panel.scss +505 -505
  276. package/styles/components/date-picker.scss +247 -247
  277. package/styles/components/date-range-picker.scss +252 -252
  278. package/styles/components/drawer.scss +298 -298
  279. package/styles/components/empty.scss +79 -79
  280. package/styles/components/form.scss +668 -668
  281. package/styles/components/icon-picker.scss +211 -211
  282. package/styles/components/icon.scss +1048 -1048
  283. package/styles/components/image-group.scss +2 -2
  284. package/styles/components/image-preview.scss +215 -215
  285. package/styles/components/image.scss +16 -16
  286. package/styles/components/input.scss +846 -846
  287. package/styles/components/layout-aside.scss +22 -22
  288. package/styles/components/layout-body.scss +14 -14
  289. package/styles/components/layout-container.scss +13 -13
  290. package/styles/components/layout-footer.scss +14 -14
  291. package/styles/components/layout-header.scss +11 -11
  292. package/styles/components/link.scss +115 -115
  293. package/styles/components/list.scss +40 -40
  294. package/styles/components/loading.scss +137 -137
  295. package/styles/components/menu.scss +150 -150
  296. package/styles/components/modal.scss +480 -480
  297. package/styles/components/notice-bar.scss +91 -91
  298. package/styles/components/number-input.scss +283 -283
  299. package/styles/components/old-icon.scss +4 -4
  300. package/styles/components/pager.scss +282 -282
  301. package/styles/components/password-input.scss +374 -374
  302. package/styles/components/print.scss +3 -3
  303. package/styles/components/pulldown.scss +75 -75
  304. package/styles/components/radio-button.scss +57 -57
  305. package/styles/components/radio.scss +79 -79
  306. package/styles/components/rate.scss +76 -76
  307. package/styles/components/result.scss +91 -91
  308. package/styles/components/row.scss +69 -69
  309. package/styles/components/segmented.scss +215 -215
  310. package/styles/components/select.scss +244 -244
  311. package/styles/components/slider.scss +139 -139
  312. package/styles/components/split.scss +1 -1
  313. package/styles/components/splitter.scss +318 -318
  314. package/styles/components/switch.scss +128 -128
  315. package/styles/components/table-select.scss +105 -105
  316. package/styles/components/tabs.scss +745 -745
  317. package/styles/components/tag.scss +184 -184
  318. package/styles/components/text-ellipsis.scss +130 -130
  319. package/styles/components/text.scss +123 -123
  320. package/styles/components/textarea.scss +106 -106
  321. package/styles/components/tip.scss +97 -97
  322. package/styles/components/tooltip.scss +141 -141
  323. package/styles/components/tree-select.scss +166 -166
  324. package/styles/components/tree.scss +294 -294
  325. package/styles/components/upload.scss +497 -497
  326. package/styles/components/watermark.scss +26 -26
  327. package/styles/helpers/baseMixin.scss +95 -95
  328. package/styles/helpers/baseVar.scss +3 -3
  329. package/styles/helpers/placement.scss +38 -38
  330. package/styles/theme/base.scss +214 -214
  331. package/styles/theme/dark.scss +119 -119
  332. package/styles/theme/light.scss +118 -118
  333. package/styles/variable.scss +111 -111
  334. package/types/all.d.ts +327 -327
  335. package/types/components/alert.d.ts +87 -87
  336. package/types/components/anchor-link.d.ts +91 -91
  337. package/types/components/anchor.d.ts +104 -104
  338. package/types/components/avatar.d.ts +88 -88
  339. package/types/components/backtop.d.ts +122 -122
  340. package/types/components/badge.d.ts +76 -76
  341. package/types/components/breadcrumb-item.d.ts +80 -80
  342. package/types/components/breadcrumb.d.ts +87 -87
  343. package/types/components/button-group.d.ts +120 -120
  344. package/types/components/button.d.ts +323 -323
  345. package/types/components/calendar.d.ts +264 -264
  346. package/types/components/card.d.ts +93 -93
  347. package/types/components/carousel-item.d.ts +75 -75
  348. package/types/components/carousel.d.ts +134 -134
  349. package/types/components/cascader.d.ts +263 -263
  350. package/types/components/checkbox-button.d.ts +103 -103
  351. package/types/components/checkbox-group.d.ts +143 -143
  352. package/types/components/checkbox.d.ts +123 -123
  353. package/types/components/col.d.ts +80 -80
  354. package/types/components/colgroup.d.ts +137 -137
  355. package/types/components/collapse-pane.d.ts +89 -89
  356. package/types/components/collapse.d.ts +121 -121
  357. package/types/components/color-picker.d.ts +176 -176
  358. package/types/components/column.d.ts +841 -841
  359. package/types/components/context-menu.d.ts +289 -289
  360. package/types/components/countdown.d.ts +112 -112
  361. package/types/components/date-panel.d.ts +280 -280
  362. package/types/components/date-picker.d.ts +332 -332
  363. package/types/components/date-range-picker.d.ts +352 -352
  364. package/types/components/drawer.d.ts +299 -299
  365. package/types/components/empty.d.ts +78 -78
  366. package/types/components/flow-design.d.ts +85 -85
  367. package/types/components/flow-view.d.ts +85 -85
  368. package/types/components/form-design.d.ts +376 -376
  369. package/types/components/form-gather.d.ts +124 -124
  370. package/types/components/form-group.d.ts +77 -77
  371. package/types/components/form-item.d.ts +411 -411
  372. package/types/components/form-view.d.ts +183 -183
  373. package/types/components/form.d.ts +468 -468
  374. package/types/components/gantt-module/gantt-view.d.ts +177 -177
  375. package/types/components/gantt-module/index.d.ts +1 -1
  376. package/types/components/gantt-plugins/extend-gantt-chart.d.ts +131 -131
  377. package/types/components/gantt-plugins/index.d.ts +1 -1
  378. package/types/components/gantt.d.ts +1194 -1185
  379. package/types/components/grid.d.ts +1040 -1040
  380. package/types/components/icon-picker.d.ts +196 -196
  381. package/types/components/icon.d.ts +87 -87
  382. package/types/components/image-group.d.ts +127 -127
  383. package/types/components/image-preview.d.ts +167 -167
  384. package/types/components/image.d.ts +173 -173
  385. package/types/components/input.d.ts +435 -435
  386. package/types/components/layout-aside.d.ts +80 -80
  387. package/types/components/layout-body.d.ts +91 -91
  388. package/types/components/layout-container.d.ts +73 -73
  389. package/types/components/layout-footer.d.ts +73 -73
  390. package/types/components/layout-header.d.ts +69 -69
  391. package/types/components/link.d.ts +111 -111
  392. package/types/components/list-design.d.ts +190 -190
  393. package/types/components/list-view.d.ts +199 -199
  394. package/types/components/list.d.ts +204 -204
  395. package/types/components/loading.d.ts +103 -103
  396. package/types/components/mention.d.ts +77 -77
  397. package/types/components/menu.d.ts +211 -211
  398. package/types/components/modal.d.ts +542 -542
  399. package/types/components/notice-bar.d.ts +102 -102
  400. package/types/components/number-input.d.ts +309 -309
  401. package/types/components/optgroup.d.ts +88 -88
  402. package/types/components/option.d.ts +103 -103
  403. package/types/components/pager.d.ts +335 -335
  404. package/types/components/password-input.d.ts +142 -142
  405. package/types/components/print-page-break.d.ts +69 -69
  406. package/types/components/print.d.ts +206 -206
  407. package/types/components/pulldown.d.ts +231 -231
  408. package/types/components/radio-button.d.ts +114 -114
  409. package/types/components/radio-group.d.ts +144 -144
  410. package/types/components/radio.d.ts +129 -129
  411. package/types/components/rate.d.ts +88 -88
  412. package/types/components/result.d.ts +84 -84
  413. package/types/components/row.d.ts +79 -79
  414. package/types/components/segmented.d.ts +123 -123
  415. package/types/components/select.d.ts +527 -527
  416. package/types/components/slider.d.ts +126 -126
  417. package/types/components/split-pane.d.ts +133 -133
  418. package/types/components/split.d.ts +312 -312
  419. package/types/components/splitter-panel.d.ts +105 -105
  420. package/types/components/splitter.d.ts +288 -288
  421. package/types/components/steps.d.ts +68 -68
  422. package/types/components/switch.d.ts +133 -133
  423. package/types/components/tab-pane.d.ts +114 -114
  424. package/types/components/table-module/custom.d.ts +123 -123
  425. package/types/components/table-module/edit.d.ts +243 -243
  426. package/types/components/table-module/export.d.ts +96 -96
  427. package/types/components/table-module/filter.d.ts +140 -140
  428. package/types/components/table-module/index.d.ts +7 -7
  429. package/types/components/table-module/keyboard.d.ts +26 -26
  430. package/types/components/table-module/menu.d.ts +28 -28
  431. package/types/components/table-module/validator.d.ts +53 -53
  432. package/types/components/table-plugins/extend-cell-area.d.ts +770 -770
  433. package/types/components/table-plugins/extend-pivot-table.d.ts +58 -58
  434. package/types/components/table-plugins/filters-combination.d.ts +15 -15
  435. package/types/components/table-plugins/filters-complex-input.d.ts +9 -9
  436. package/types/components/table-plugins/index.d.ts +4 -4
  437. package/types/components/table-select.d.ts +219 -219
  438. package/types/components/table.d.ts +7465 -7465
  439. package/types/components/tabs.d.ts +332 -332
  440. package/types/components/tag.d.ts +114 -114
  441. package/types/components/text-ellipsis.d.ts +112 -112
  442. package/types/components/text.d.ts +122 -122
  443. package/types/components/textarea.d.ts +247 -247
  444. package/types/components/timeline-item.d.ts +75 -75
  445. package/types/components/timeline.d.ts +77 -77
  446. package/types/components/tip.d.ts +83 -83
  447. package/types/components/toolbar.d.ts +336 -336
  448. package/types/components/tooltip.d.ts +180 -180
  449. package/types/components/tour.d.ts +77 -77
  450. package/types/components/tree-select.d.ts +310 -310
  451. package/types/components/tree.d.ts +843 -833
  452. package/types/components/upload.d.ts +437 -437
  453. package/types/components/watermark.d.ts +120 -120
  454. package/types/handles/form-design.d.ts +50 -50
  455. package/types/handles/index.d.ts +3 -3
  456. package/types/handles/list-design.d.ts +2 -2
  457. package/types/handles/table.d.ts +15 -15
  458. package/types/index.d.ts +8 -8
  459. package/types/ui/commands.d.ts +57 -57
  460. package/types/ui/formats.d.ts +62 -62
  461. package/types/ui/global-config.d.ts +254 -254
  462. package/types/ui/global-icon.d.ts +292 -292
  463. package/types/ui/hooks.d.ts +13 -13
  464. package/types/ui/index.d.ts +96 -96
  465. package/types/ui/interceptor.d.ts +52 -52
  466. package/types/ui/menus.d.ts +77 -77
  467. package/types/ui/renderer.d.ts +1041 -1041
  468. package/types/ui/validators.d.ts +38 -38
  469. /package/es/icon/{iconfont.1778169084473.ttf → iconfont.1778317220469.ttf} +0 -0
  470. /package/es/icon/{iconfont.1778169084473.woff → iconfont.1778317220469.woff} +0 -0
  471. /package/es/icon/{iconfont.1778169084473.woff2 → iconfont.1778317220469.woff2} +0 -0
  472. /package/es/{iconfont.1778169084473.ttf → iconfont.1778317220469.ttf} +0 -0
  473. /package/es/{iconfont.1778169084473.woff → iconfont.1778317220469.woff} +0 -0
  474. /package/es/{iconfont.1778169084473.woff2 → iconfont.1778317220469.woff2} +0 -0
  475. /package/lib/icon/style/{iconfont.1778169084473.ttf → iconfont.1778317220469.ttf} +0 -0
  476. /package/lib/icon/style/{iconfont.1778169084473.woff → iconfont.1778317220469.woff} +0 -0
  477. /package/lib/icon/style/{iconfont.1778169084473.woff2 → iconfont.1778317220469.woff2} +0 -0
  478. /package/lib/{iconfont.1778169084473.ttf → iconfont.1778317220469.ttf} +0 -0
  479. /package/lib/{iconfont.1778169084473.woff → iconfont.1778317220469.woff} +0 -0
  480. /package/lib/{iconfont.1778169084473.woff2 → iconfont.1778317220469.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
+ })