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