@oinone/kunlun-vue-ui-antd 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) hide show
  1. package/README.md +1 -0
  2. package/dist/oinone-kunlun-vue-ui-antd.css +1 -0
  3. package/dist/oinone-kunlun-vue-ui-antd.esm.js +16 -0
  4. package/dist/oinone-kunlun-vue-ui-antd.scss +1 -0
  5. package/dist/types/index.d.ts +3 -0
  6. package/dist/types/src/component/index.d.ts +31 -0
  7. package/dist/types/src/component/oio-block/index.d.ts +3 -0
  8. package/dist/types/src/component/oio-block/oio-block.vue.d.ts +39 -0
  9. package/dist/types/src/component/oio-block/oio-col.vue.d.ts +86 -0
  10. package/dist/types/src/component/oio-block/oio-row.vue.d.ts +34 -0
  11. package/dist/types/src/component/oio-breadcrumb/index.d.ts +2 -0
  12. package/dist/types/src/component/oio-breadcrumb/oio-breadcrumb-item.vue.d.ts +14 -0
  13. package/dist/types/src/component/oio-breadcrumb/oio-breadcrumb.vue.d.ts +14 -0
  14. package/dist/types/src/component/oio-button/index.d.ts +1 -0
  15. package/dist/types/src/component/oio-button/oio-button.vue.d.ts +136 -0
  16. package/dist/types/src/component/oio-cascader/index.d.ts +1 -0
  17. package/dist/types/src/component/oio-cascader/oio-cascader.vue.d.ts +236 -0
  18. package/dist/types/src/component/oio-checkbox/index.d.ts +1 -0
  19. package/dist/types/src/component/oio-checkbox/oio-checkbox.vue.d.ts +56 -0
  20. package/dist/types/src/component/oio-collapse/index.d.ts +2 -0
  21. package/dist/types/src/component/oio-collapse/oio-collapse-panel.vue.d.ts +86 -0
  22. package/dist/types/src/component/oio-collapse/oio-collapse.vue.d.ts +103 -0
  23. package/dist/types/src/component/oio-date-time-picker/index.d.ts +5 -0
  24. package/dist/types/src/component/oio-date-time-picker/oio-date-picker.vue.d.ts +182 -0
  25. package/dist/types/src/component/oio-date-time-picker/oio-date-time-picker.vue.d.ts +240 -0
  26. package/dist/types/src/component/oio-date-time-picker/oio-time-picker.vue.d.ts +176 -0
  27. package/dist/types/src/component/oio-date-time-picker/oio-year-picker.vue.d.ts +139 -0
  28. package/dist/types/src/component/oio-date-time-picker/use-date-time-picker-props.d.ts +15 -0
  29. package/dist/types/src/component/oio-date-time-range-picker/index.d.ts +5 -0
  30. package/dist/types/src/component/oio-date-time-range-picker/oio-date-range-picker.vue.d.ts +139 -0
  31. package/dist/types/src/component/oio-date-time-range-picker/oio-date-time-range-picker.vue.d.ts +195 -0
  32. package/dist/types/src/component/oio-date-time-range-picker/oio-time-range-picker.vue.d.ts +139 -0
  33. package/dist/types/src/component/oio-date-time-range-picker/oio-year-range-picker.vue.d.ts +124 -0
  34. package/dist/types/src/component/oio-date-time-range-picker/use-date-time-range-picker-props.d.ts +12 -0
  35. package/dist/types/src/component/oio-divider/index.d.ts +2 -0
  36. package/dist/types/src/component/oio-divider/oio-divider.vue.d.ts +38 -0
  37. package/dist/types/src/component/oio-drawer/index.d.ts +1 -0
  38. package/dist/types/src/component/oio-drawer/oio-drawer.vue.d.ts +227 -0
  39. package/dist/types/src/component/oio-dropdown/index.d.ts +1 -0
  40. package/dist/types/src/component/oio-dropdown/oio-dropdown.vue.d.ts +78 -0
  41. package/dist/types/src/component/oio-empty/index.d.ts +1 -0
  42. package/dist/types/src/component/oio-empty/oio-empty-data.vue.d.ts +42 -0
  43. package/dist/types/src/component/oio-form/index.d.ts +2 -0
  44. package/dist/types/src/component/oio-form/oio-form-item.vue.d.ts +126 -0
  45. package/dist/types/src/component/oio-form/oio-form.vue.d.ts +100 -0
  46. package/dist/types/src/component/oio-gallery/index.d.ts +1 -0
  47. package/dist/types/src/component/oio-gallery/oio-gallery.vue.d.ts +98 -0
  48. package/dist/types/src/component/oio-group/index.d.ts +2 -0
  49. package/dist/types/src/component/oio-group/oio-group-help.vue.d.ts +65 -0
  50. package/dist/types/src/component/oio-group/oio-group.vue.d.ts +113 -0
  51. package/dist/types/src/component/oio-inner-popup/index.d.ts +1 -0
  52. package/dist/types/src/component/oio-inner-popup/oio-inner-popup.vue.d.ts +195 -0
  53. package/dist/types/src/component/oio-input/index.d.ts +5 -0
  54. package/dist/types/src/component/oio-input/oio-input-group.vue.d.ts +16 -0
  55. package/dist/types/src/component/oio-input/oio-input-number.vue.d.ts +167 -0
  56. package/dist/types/src/component/oio-input/oio-input-password.vue.d.ts +111 -0
  57. package/dist/types/src/component/oio-input/oio-input-search.vue.d.ts +106 -0
  58. package/dist/types/src/component/oio-input/oio-input.vue.d.ts +107 -0
  59. package/dist/types/src/component/oio-modal/index.d.ts +1 -0
  60. package/dist/types/src/component/oio-modal/oio-modal.vue.d.ts +230 -0
  61. package/dist/types/src/component/oio-notification/index.d.ts +116 -0
  62. package/dist/types/src/component/oio-pagination/index.d.ts +1 -0
  63. package/dist/types/src/component/oio-pagination/oio-pagination.vue.d.ts +107 -0
  64. package/dist/types/src/component/oio-popconfirm/index.d.ts +1 -0
  65. package/dist/types/src/component/oio-popconfirm/oio-popconfirm.vue.d.ts +119 -0
  66. package/dist/types/src/component/oio-select/index.d.ts +1 -0
  67. package/dist/types/src/component/oio-select/oio-select.vue.d.ts +153 -0
  68. package/dist/types/src/component/oio-slider/index.d.ts +1 -0
  69. package/dist/types/src/component/oio-slider/oio-slider.vue.d.ts +155 -0
  70. package/dist/types/src/component/oio-spin/index.d.ts +1 -0
  71. package/dist/types/src/component/oio-spin/oio-spin.vue.d.ts +54 -0
  72. package/dist/types/src/component/oio-switch/index.d.ts +1 -0
  73. package/dist/types/src/component/oio-switch/oio-switch.vue.d.ts +92 -0
  74. package/dist/types/src/component/oio-tabs/index.d.ts +3 -0
  75. package/dist/types/src/component/oio-tabs/oio-tab.vue.d.ts +67 -0
  76. package/dist/types/src/component/oio-tabs/oio-tabs.vue.d.ts +93 -0
  77. package/dist/types/src/component/oio-tabs/use-tab-bar.d.ts +5 -0
  78. package/dist/types/src/component/oio-textarea/index.d.ts +1 -0
  79. package/dist/types/src/component/oio-textarea/oio-textarea.vue.d.ts +100 -0
  80. package/dist/types/src/component/oio-tooltip/index.d.ts +2 -0
  81. package/dist/types/src/component/oio-tooltip/oio-tooltip-help.vue.d.ts +12 -0
  82. package/dist/types/src/component/oio-tooltip/oio-tooltip.vue.d.ts +76 -0
  83. package/dist/types/src/component/oio-tree/index.d.ts +1 -0
  84. package/dist/types/src/component/oio-tree/oio-tree.vue.d.ts +171 -0
  85. package/dist/types/src/component/oio-tree-select/index.d.ts +1 -0
  86. package/dist/types/src/component/oio-tree-select/oio-tree-select.vue.d.ts +226 -0
  87. package/dist/types/src/component/oio-upload/index.d.ts +1 -0
  88. package/dist/types/src/component/oio-upload/oio-upload.vue.d.ts +187 -0
  89. package/dist/types/src/index.d.ts +2 -0
  90. package/dist/types/src/theme/index.d.ts +1 -0
  91. package/dist/types/src/vc-component/index.d.ts +1 -0
  92. package/dist/types/src/vc-component/use-max-tag-placeholder.d.ts +7 -0
  93. package/index.ts +3 -0
  94. package/package.json +36 -0
  95. package/rollup.config.js +15 -0
  96. package/src/component/index.ts +32 -0
  97. package/src/component/oio-block/index.ts +3 -0
  98. package/src/component/oio-block/oio-block.vue +77 -0
  99. package/src/component/oio-block/oio-col.vue +32 -0
  100. package/src/component/oio-block/oio-row.vue +42 -0
  101. package/src/component/oio-block/style/a-col.scss +18 -0
  102. package/src/component/oio-block/style/index.scss +42 -0
  103. package/src/component/oio-block/style/parameters.scss +13 -0
  104. package/src/component/oio-breadcrumb/index.ts +2 -0
  105. package/src/component/oio-breadcrumb/oio-breadcrumb-item.vue +30 -0
  106. package/src/component/oio-breadcrumb/oio-breadcrumb.vue +30 -0
  107. package/src/component/oio-button/index.ts +1 -0
  108. package/src/component/oio-button/oio-button.vue +154 -0
  109. package/src/component/oio-button/style/a-button.scss +210 -0
  110. package/src/component/oio-button/style/index.scss +21 -0
  111. package/src/component/oio-button/style/parameters.scss +5 -0
  112. package/src/component/oio-cascader/index.ts +1 -0
  113. package/src/component/oio-cascader/oio-cascader.vue +171 -0
  114. package/src/component/oio-cascader/style/index.scss +59 -0
  115. package/src/component/oio-cascader/style/parameters.scss +5 -0
  116. package/src/component/oio-checkbox/index.ts +1 -0
  117. package/src/component/oio-checkbox/oio-checkbox.vue +69 -0
  118. package/src/component/oio-checkbox/style/index.scss +8 -0
  119. package/src/component/oio-checkbox/style/parameters.scss +5 -0
  120. package/src/component/oio-collapse/index.ts +2 -0
  121. package/src/component/oio-collapse/oio-collapse-panel.vue +92 -0
  122. package/src/component/oio-collapse/oio-collapse.vue +138 -0
  123. package/src/component/oio-collapse/style/index.scss +59 -0
  124. package/src/component/oio-collapse/style/parameters.scss +5 -0
  125. package/src/component/oio-date-time-picker/index.ts +5 -0
  126. package/src/component/oio-date-time-picker/oio-date-picker.vue +34 -0
  127. package/src/component/oio-date-time-picker/oio-date-time-picker.vue +91 -0
  128. package/src/component/oio-date-time-picker/oio-time-picker.vue +34 -0
  129. package/src/component/oio-date-time-picker/oio-year-picker.vue +34 -0
  130. package/src/component/oio-date-time-picker/style/index.scss +348 -0
  131. package/src/component/oio-date-time-picker/style/mixin.scss +16 -0
  132. package/src/component/oio-date-time-picker/style/parameters.scss +5 -0
  133. package/src/component/oio-date-time-picker/use-date-time-picker-props.ts +151 -0
  134. package/src/component/oio-date-time-range-picker/index.ts +5 -0
  135. package/src/component/oio-date-time-range-picker/oio-date-range-picker.vue +29 -0
  136. package/src/component/oio-date-time-range-picker/oio-date-time-range-picker.vue +82 -0
  137. package/src/component/oio-date-time-range-picker/oio-time-range-picker.vue +29 -0
  138. package/src/component/oio-date-time-range-picker/oio-year-range-picker.vue +29 -0
  139. package/src/component/oio-date-time-range-picker/style/index.scss +227 -0
  140. package/src/component/oio-date-time-range-picker/style/parameters.scss +5 -0
  141. package/src/component/oio-date-time-range-picker/use-date-time-range-picker-props.ts +138 -0
  142. package/src/component/oio-divider/index.ts +3 -0
  143. package/src/component/oio-divider/oio-divider.vue +31 -0
  144. package/src/component/oio-divider/style/index.scss +7 -0
  145. package/src/component/oio-divider/style/parameters.scss +5 -0
  146. package/src/component/oio-drawer/index.ts +1 -0
  147. package/src/component/oio-drawer/oio-drawer.vue +120 -0
  148. package/src/component/oio-drawer/style/index.scss +93 -0
  149. package/src/component/oio-drawer/style/parameters.scss +5 -0
  150. package/src/component/oio-dropdown/index.ts +1 -0
  151. package/src/component/oio-dropdown/oio-dropdown.vue +81 -0
  152. package/src/component/oio-dropdown/style/index.scss +30 -0
  153. package/src/component/oio-dropdown/style/parameters.scss +5 -0
  154. package/src/component/oio-empty/index.ts +1 -0
  155. package/src/component/oio-empty/oio-empty-data.vue +47 -0
  156. package/src/component/oio-empty/style/index.scss +6 -0
  157. package/src/component/oio-form/index.ts +2 -0
  158. package/src/component/oio-form/oio-form-item.vue +81 -0
  159. package/src/component/oio-form/oio-form.vue +102 -0
  160. package/src/component/oio-form/style/animation.scss +17 -0
  161. package/src/component/oio-form/style/index.scss +135 -0
  162. package/src/component/oio-form/style/parameters.scss +9 -0
  163. package/src/component/oio-gallery/index.ts +1 -0
  164. package/src/component/oio-gallery/oio-gallery.vue +158 -0
  165. package/src/component/oio-group/index.ts +2 -0
  166. package/src/component/oio-group/oio-group-help.vue +28 -0
  167. package/src/component/oio-group/oio-group.vue +140 -0
  168. package/src/component/oio-group/style/index.scss +98 -0
  169. package/src/component/oio-group/style/parameters.scss +5 -0
  170. package/src/component/oio-inner-popup/index.ts +1 -0
  171. package/src/component/oio-inner-popup/oio-inner-popup.vue +230 -0
  172. package/src/component/oio-inner-popup/style/index.scss +147 -0
  173. package/src/component/oio-inner-popup/style/parameters.scss +5 -0
  174. package/src/component/oio-input/index.ts +5 -0
  175. package/src/component/oio-input/oio-input-group.vue +40 -0
  176. package/src/component/oio-input/oio-input-number.vue +374 -0
  177. package/src/component/oio-input/oio-input-password.vue +67 -0
  178. package/src/component/oio-input/oio-input-search.vue +107 -0
  179. package/src/component/oio-input/oio-input.vue +124 -0
  180. package/src/component/oio-input/style/a-input.scss +103 -0
  181. package/src/component/oio-input/style/index.scss +198 -0
  182. package/src/component/oio-input/style/mixin.scss +50 -0
  183. package/src/component/oio-input/style/oio-input-group.scss +31 -0
  184. package/src/component/oio-input/style/oio-input-number.scss +13 -0
  185. package/src/component/oio-input/style/oio-input-search.scss +94 -0
  186. package/src/component/oio-input/style/parameters.scss +21 -0
  187. package/src/component/oio-modal/index.ts +1 -0
  188. package/src/component/oio-modal/index.zh-CN.md +167 -0
  189. package/src/component/oio-modal/oio-modal.vue +184 -0
  190. package/src/component/oio-modal/style/index.scss +167 -0
  191. package/src/component/oio-modal/style/parameters.scss +5 -0
  192. package/src/component/oio-notification/index.ts +197 -0
  193. package/src/component/oio-notification/style/index.scss +67 -0
  194. package/src/component/oio-notification/style/parameters.scss +5 -0
  195. package/src/component/oio-pagination/index.ts +1 -0
  196. package/src/component/oio-pagination/oio-pagination.vue +105 -0
  197. package/src/component/oio-pagination/style/index.scss +181 -0
  198. package/src/component/oio-pagination/style/parameters.scss +5 -0
  199. package/src/component/oio-popconfirm/index.ts +1 -0
  200. package/src/component/oio-popconfirm/oio-popconfirm.vue +192 -0
  201. package/src/component/oio-popconfirm/style/index.scss +54 -0
  202. package/src/component/oio-popconfirm/style/parameters.scss +5 -0
  203. package/src/component/oio-popover/style/index.scss +16 -0
  204. package/src/component/oio-popover/style/parameters.scss +5 -0
  205. package/src/component/oio-radio/style/index.scss +24 -0
  206. package/src/component/oio-radio/style/parameters.scss +5 -0
  207. package/src/component/oio-select/index.ts +1 -0
  208. package/src/component/oio-select/oio-select.vue +104 -0
  209. package/src/component/oio-select/style/a-select.scss +102 -0
  210. package/src/component/oio-select/style/index.scss +129 -0
  211. package/src/component/oio-select/style/mixin.scss +18 -0
  212. package/src/component/oio-select/style/parameters.scss +5 -0
  213. package/src/component/oio-slider/index.ts +1 -0
  214. package/src/component/oio-slider/oio-slider.vue +81 -0
  215. package/src/component/oio-slider/style/index.scss +100 -0
  216. package/src/component/oio-slider/style/parameters.scss +5 -0
  217. package/src/component/oio-spin/index.ts +1 -0
  218. package/src/component/oio-spin/oio-spin.vue +87 -0
  219. package/src/component/oio-spin/style/index.scss +48 -0
  220. package/src/component/oio-spin/style/parameters.scss +5 -0
  221. package/src/component/oio-switch/index.ts +1 -0
  222. package/src/component/oio-switch/oio-switch.vue +42 -0
  223. package/src/component/oio-switch/style/index.scss +36 -0
  224. package/src/component/oio-switch/style/parameters.scss +5 -0
  225. package/src/component/oio-tabs/index.ts +3 -0
  226. package/src/component/oio-tabs/oio-tab.vue +99 -0
  227. package/src/component/oio-tabs/oio-tabs.vue +188 -0
  228. package/src/component/oio-tabs/style/index.scss +274 -0
  229. package/src/component/oio-tabs/style/parameters.scss +9 -0
  230. package/src/component/oio-tabs/use-tab-bar.ts +69 -0
  231. package/src/component/oio-textarea/index.ts +1 -0
  232. package/src/component/oio-textarea/oio-textarea.vue +76 -0
  233. package/src/component/oio-textarea/style/index.scss +108 -0
  234. package/src/component/oio-textarea/style/parameters.scss +5 -0
  235. package/src/component/oio-tooltip/index.ts +2 -0
  236. package/src/component/oio-tooltip/oio-tooltip-help.vue +40 -0
  237. package/src/component/oio-tooltip/oio-tooltip.vue +59 -0
  238. package/src/component/oio-tooltip/style/index.scss +8 -0
  239. package/src/component/oio-tooltip/style/parameters.scss +9 -0
  240. package/src/component/oio-tree/index.ts +1 -0
  241. package/src/component/oio-tree/oio-tree.vue +181 -0
  242. package/src/component/oio-tree/style/index.scss +51 -0
  243. package/src/component/oio-tree/style/parameters.scss +5 -0
  244. package/src/component/oio-tree-select/index.ts +1 -0
  245. package/src/component/oio-tree-select/oio-tree-select.vue +180 -0
  246. package/src/component/oio-tree-select/style/index.scss +92 -0
  247. package/src/component/oio-tree-select/style/parameters.scss +5 -0
  248. package/src/component/oio-upload/index.ts +1 -0
  249. package/src/component/oio-upload/oio-upload.vue +232 -0
  250. package/src/component/oio-upload/style/index.scss +66 -0
  251. package/src/component/oio-upload/style/parameters.scss +5 -0
  252. package/src/index.ts +3 -0
  253. package/src/shim-translate.d.ts +7 -0
  254. package/src/shim-vue.d.ts +6 -0
  255. package/src/style/global-parameters.scss +9 -0
  256. package/src/style/index.scss +31 -0
  257. package/src/style/mixin.scss +135 -0
  258. package/src/theme/index.ts +1 -0
  259. package/src/vc-component/index.ts +1 -0
  260. package/src/vc-component/use-max-tag-placeholder.ts +38 -0
@@ -0,0 +1,374 @@
1
+ <script lang="ts">
2
+ import { DownOutlined, UpOutlined } from '@ant-design/icons-vue';
3
+ import {
4
+ BigNumber,
5
+ CastHelper,
6
+ fetchRealValue,
7
+ NumberHelper,
8
+ Optional,
9
+ StandardNumber,
10
+ StringHelper
11
+ } from '@oinone/kunlun-shared';
12
+ import { OioInputNumberProps, PropRecordHelper } from '@oinone/kunlun-vue-ui-common';
13
+ import { isEmpty, isNil, isString, toString } from 'lodash-es';
14
+ import { computed, createVNode, defineComponent, ref, Slot } from 'vue';
15
+ import { DEFAULT_PREFIX } from '../../theme';
16
+ import OioInput from './oio-input.vue';
17
+
18
+ export default defineComponent({
19
+ name: 'OioInputNumber',
20
+ components: {
21
+ OioInput
22
+ },
23
+ inheritAttrs: false,
24
+ props: {
25
+ ...OioInputNumberProps
26
+ },
27
+ slots: ['prepend', 'append', 'prefix', 'suffix'],
28
+ emits: ['update:value', 'focus', 'blur'],
29
+ setup(props, context) {
30
+ const origin = ref();
31
+ const realValue = computed<BigNumber | undefined>(() => {
32
+ return Optional.ofNullable(props.value)
33
+ .map<BigNumber | undefined>((v) => new BigNumber(v!))
34
+ .orElse(undefined);
35
+ });
36
+ const focused = ref<boolean>(false);
37
+
38
+ const realMinValue = computed(() => {
39
+ const { min, minSafeInteger } = props;
40
+ return fetchRealValue(min, minSafeInteger);
41
+ });
42
+
43
+ const realMaxValue = computed(() => {
44
+ const { max, maxSafeInteger } = props;
45
+ return fetchRealValue(max, maxSafeInteger);
46
+ });
47
+
48
+ const compareToMinValue = (val: BigNumber): boolean => {
49
+ const min = realMinValue.value;
50
+ if (isNil(min)) {
51
+ return true;
52
+ }
53
+ return val.comparedTo(min.value) >= 0;
54
+ };
55
+
56
+ const compareToMaxValue = (val: BigNumber): boolean => {
57
+ const max = realMaxValue.value;
58
+ if (isNil(max)) {
59
+ return true;
60
+ }
61
+ return val.comparedTo(max.value) <= 0;
62
+ };
63
+
64
+ const change = (val: BigNumber | StandardNumber): boolean => {
65
+ const rv = realValue.value;
66
+ if (isNil(val)) {
67
+ if (isNil(rv)) {
68
+ return false;
69
+ }
70
+ context.emit('update:value', val);
71
+ return true;
72
+ }
73
+ let newVal = val.toString();
74
+ if (newVal.endsWith('.') || newVal.endsWith('0')) {
75
+ context.emit('update:value', newVal);
76
+ return true;
77
+ }
78
+ const newNumberVal = new BigNumber(newVal);
79
+ if (!newNumberVal.isNaN()) {
80
+ newVal = newNumberVal.toString();
81
+ }
82
+ const { value } = props;
83
+ if (value && toString(value) === newVal) {
84
+ return false;
85
+ }
86
+ context.emit('update:value', newVal);
87
+ return true;
88
+ };
89
+
90
+ const setValue = (val: BigNumber | StandardNumber): boolean => {
91
+ if (isNil(val)) {
92
+ return change(val);
93
+ }
94
+ if (isString(val)) {
95
+ if (isEmpty(val)) {
96
+ return change(null);
97
+ }
98
+ if (val === '-' || val.indexOf('.') === val.length - 1) {
99
+ if (props.precision === 0) {
100
+ const ra = val.replaceAll('.', '');
101
+ if (ra === '') {
102
+ return change(undefined);
103
+ }
104
+ return change(ra);
105
+ }
106
+ return change(val);
107
+ }
108
+ const vsl = val.split('.').length;
109
+ if (!isNil(props.precision)) {
110
+ if (vsl > 2) {
111
+ return false;
112
+ }
113
+ } else if (vsl !== 1) {
114
+ return false;
115
+ }
116
+ if (!NumberHelper.isNumber(val)) {
117
+ return false;
118
+ }
119
+ }
120
+ return change(val);
121
+ };
122
+
123
+ const realAddStep = computed<BigNumber>(() => {
124
+ return Optional.ofNullable(props.addStep)
125
+ .map((v) => new BigNumber(v!))
126
+ .filter((v) => !v.isNaN())
127
+ .orElseGet(() =>
128
+ Optional.ofNullable(props.step)
129
+ .map((v) => new BigNumber(v!))
130
+ .filter((v) => !v.isNaN())
131
+ .orElse(new BigNumber(1))
132
+ );
133
+ });
134
+
135
+ const realReduceStep = computed<BigNumber>(() => {
136
+ return Optional.ofNullable(props.reduceStep)
137
+ .map((v) => new BigNumber(v!))
138
+ .filter((v) => !v.isNaN())
139
+ .orElseGet(() =>
140
+ Optional.ofNullable(props.step)
141
+ .map((v) => new BigNumber(v!))
142
+ .filter((v) => !v.isNaN())
143
+ .orElse(new BigNumber(1))
144
+ );
145
+ });
146
+
147
+ const upStep = (event) => {
148
+ let rv = realValue.value;
149
+ if (realValue.value && realValue.value.c === null) {
150
+ rv = new BigNumber(0);
151
+ }
152
+ event.preventDefault();
153
+ event.stopPropagation();
154
+ origin.value.focus();
155
+ change((rv || new BigNumber(0)).plus(realAddStep.value));
156
+ };
157
+
158
+ const downStep = (event) => {
159
+ let rv = realValue.value;
160
+ if (realValue.value && realValue.value.c === null) {
161
+ rv = new BigNumber(0);
162
+ }
163
+ event.preventDefault();
164
+ event.stopPropagation();
165
+ origin.value.focus();
166
+ change((rv || new BigNumber(0)).minus(realReduceStep.value));
167
+ };
168
+
169
+ const formatterShowThousandth = (val: string): string => {
170
+ if (props.showThousandth) {
171
+ const vs = val.split('.');
172
+ let fv = vs[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',');
173
+ if (val.indexOf('.') !== -1) {
174
+ fv += '.';
175
+ }
176
+ fv += vs[1] || '';
177
+ return fv;
178
+ }
179
+ return val;
180
+ };
181
+
182
+ const parserShowThousandth = (val: string): string => {
183
+ return val.replace(/,/g, '');
184
+ };
185
+
186
+ const fetchFormatterValue = (val: BigNumber | string | number | null | undefined): string => {
187
+ let fv: string | undefined = '';
188
+ if (isNil(val)) {
189
+ return '';
190
+ }
191
+ if (isString(val)) {
192
+ if (val === '-' || val === '-0' || val.endsWith('.')) {
193
+ fv = val;
194
+ }
195
+ }
196
+ if (isEmpty(fv)) {
197
+ fv = val.toString();
198
+ }
199
+ if (props.formatter) {
200
+ return props.formatter(fv);
201
+ }
202
+ return formatterShowThousandth(fv);
203
+ };
204
+
205
+ const fetchParserValue = (val: string | undefined): string => {
206
+ let fv: string | undefined;
207
+ if (isNil(val)) {
208
+ fv = '';
209
+ } else {
210
+ fv = val.toString();
211
+ }
212
+ if (props.parser) {
213
+ return props.parser(fv);
214
+ }
215
+ return parserShowThousandth(fv);
216
+ };
217
+
218
+ const autocorrection = (): BigNumber | undefined => {
219
+ const rv = realValue.value;
220
+ let fv: BigNumber | undefined;
221
+ if (isNil(rv) || rv.isNaN()) {
222
+ fv = undefined;
223
+ } else if (!compareToMinValue(rv)) {
224
+ const rmv = realMinValue.value;
225
+ if (isNil(rmv) || rmv.isSafeInteger) {
226
+ return;
227
+ }
228
+ fv = rmv.value;
229
+ } else if (!compareToMaxValue(rv)) {
230
+ const rmv = realMaxValue.value;
231
+ if (isNil(rmv) || rmv.isSafeInteger) {
232
+ return;
233
+ }
234
+ fv = rmv.value;
235
+ } else {
236
+ fv = rv;
237
+ }
238
+ return fv;
239
+ };
240
+
241
+ const focus = (event: Event) => {
242
+ focused.value = true;
243
+ context.emit('focus', event);
244
+ };
245
+
246
+ const blur = (event: Event) => {
247
+ focused.value = false;
248
+ let fv: BigNumber | undefined;
249
+ let isModify = false;
250
+ if (props.autocorrection) {
251
+ fv = autocorrection();
252
+ if (!isNil(fv)) {
253
+ isModify = true;
254
+ }
255
+ }
256
+ if (isModify) {
257
+ change(fv);
258
+ }
259
+ context.emit('blur', event);
260
+ };
261
+
262
+ context.expose({
263
+ getRealValue: (): BigNumber | undefined => realValue.value,
264
+ setValue,
265
+ autocorrection
266
+ });
267
+
268
+ return {
269
+ origin,
270
+ realValue,
271
+ focused,
272
+ setValue,
273
+ upStep,
274
+ downStep,
275
+ fetchFormatterValue,
276
+ fetchParserValue,
277
+ focus,
278
+ blur
279
+ };
280
+ },
281
+ render() {
282
+ const slots: Record<string, Slot> = PropRecordHelper.collectionSlots(this.$slots, [
283
+ 'prepend',
284
+ 'append',
285
+ 'prefix',
286
+ 'suffix'
287
+ ]);
288
+ const classList = [`${DEFAULT_PREFIX}-input-number`];
289
+ if (this.hiddenStepHandle || this.disabled || this.readonly) {
290
+ classList.push(`${DEFAULT_PREFIX}-input-number-not-handler`);
291
+ } else {
292
+ const handlerComponent = createVNode(
293
+ 'div',
294
+ {
295
+ class: `${DEFAULT_PREFIX}-handler-wrapper`
296
+ },
297
+ [
298
+ createVNode(UpOutlined, {
299
+ class: `${DEFAULT_PREFIX}-handler-up-inner`,
300
+ onClick: this.upStep,
301
+ onMousedown: (e) => e?.preventDefault()
302
+ }),
303
+ createVNode(DownOutlined, {
304
+ class: `${DEFAULT_PREFIX}-handler-down-inner`,
305
+ onClick: this.downStep,
306
+ onMousedown: (e) => e?.preventDefault()
307
+ })
308
+ ]
309
+ );
310
+ const { suffix } = slots;
311
+ if (suffix) {
312
+ slots.suffix = () => [...suffix(), handlerComponent];
313
+ } else {
314
+ slots.suffix = () => [handlerComponent];
315
+ }
316
+ }
317
+ if (this.unit) {
318
+ const unitComponent = createVNode(
319
+ 'div',
320
+ {
321
+ class: `${DEFAULT_PREFIX}-unit`
322
+ },
323
+ this.unit
324
+ );
325
+ const { append } = slots;
326
+ if (append) {
327
+ slots.append = () => [...append(), unitComponent];
328
+ } else {
329
+ slots.append = () => [unitComponent];
330
+ }
331
+ }
332
+ const { value } = this;
333
+ let fv: string | undefined;
334
+ if (isString(value)) {
335
+ const vsl = value.split('.').length;
336
+ if (value === '-' || value === '-0' || vsl === 2) {
337
+ fv = value;
338
+ }
339
+ }
340
+ if (isEmpty(fv)) {
341
+ const rv = this.realValue;
342
+ if (isNil(rv)) {
343
+ fv = '';
344
+ } else {
345
+ fv = rv.toString();
346
+ }
347
+ }
348
+ fv = this.focused ? fv : this.fetchFormatterValue(fv);
349
+ return createVNode(
350
+ OioInput,
351
+ {
352
+ value: fv,
353
+ defaultValue: Optional.ofNullable(this.defaultValue)
354
+ .map((v) => new BigNumber(v!))
355
+ .filter((v) => !v.isNaN())
356
+ .map<string | undefined>((v) => v.toString())
357
+ .map((v) => (this.focused ? v : this.fetchFormatterValue(v)))
358
+ .orElse(undefined),
359
+ placeholder: this.placeholder,
360
+ disabled: this.disabled,
361
+ readonly: this.readonly,
362
+ allowClear: false,
363
+ ...this.$attrs,
364
+ 'onUpdate:value': (val) => this.setValue(val),
365
+ onFocus: this.focus,
366
+ onBlur: this.blur,
367
+ class: StringHelper.append(classList, CastHelper.cast(this.$attrs.class)),
368
+ ref: 'origin'
369
+ },
370
+ slots
371
+ );
372
+ }
373
+ });
374
+ </script>
@@ -0,0 +1,67 @@
1
+ <script lang="ts">
2
+ import { EyeInvisibleOutlined, EyeOutlined } from '@ant-design/icons-vue';
3
+ import { BooleanHelper, CastHelper, StringHelper } from '@oinone/kunlun-shared';
4
+ import { AInputPasswordProps, OioInputPasswordProps, PropRecordHelper } from '@oinone/kunlun-vue-ui-common';
5
+ import { InputPassword as AInputPassword } from 'ant-design-vue';
6
+ import { isBoolean, isNil } from 'lodash-es';
7
+ import { computed, createVNode, defineComponent, VNode } from 'vue';
8
+ import { DEFAULT_PREFIX } from '../../theme';
9
+
10
+ export default defineComponent({
11
+ name: 'OioInputPassword',
12
+ components: {
13
+ AInputPassword
14
+ },
15
+ inheritAttrs: false,
16
+ props: {
17
+ ...OioInputPasswordProps
18
+ },
19
+ slots: ['prepend', 'append', 'prefix'],
20
+ emits: ['update:value'],
21
+ setup(props) {
22
+ const autocomplete = computed<string | undefined>(() => {
23
+ if (props.autocomplete == null) {
24
+ return 'new-password';
25
+ }
26
+ const val = BooleanHelper.toBoolean(props.autocomplete);
27
+ if (isBoolean(val)) {
28
+ return val ? 'on' : 'off';
29
+ }
30
+ return props.autocomplete as string | undefined;
31
+ });
32
+
33
+ return {
34
+ autocomplete
35
+ };
36
+ },
37
+ render() {
38
+ return createVNode(
39
+ AInputPassword,
40
+ {
41
+ ...PropRecordHelper.convert(AInputPasswordProps, CastHelper.cast(this)),
42
+ readonly: this.readonly,
43
+ iconRender: (visible: boolean) => {
44
+ const result: VNode[] = [];
45
+ const { value } = this;
46
+ if (isNil(value) || !value.length) {
47
+ return result;
48
+ }
49
+ if (visible) {
50
+ result.push(createVNode(EyeOutlined));
51
+ } else {
52
+ result.push(createVNode(EyeInvisibleOutlined));
53
+ }
54
+ return result;
55
+ },
56
+ ...this.$attrs,
57
+ 'onUpdate:value': (val) => this.$emit('update:value', val),
58
+ class: StringHelper.append(
59
+ [`${DEFAULT_PREFIX}-input`, `${DEFAULT_PREFIX}-input-password`],
60
+ CastHelper.cast(this.$attrs.class)
61
+ )
62
+ },
63
+ PropRecordHelper.collectionSlots(this.$slots, [['prepend', 'addonBefore'], ['append', 'addonAfter'], 'prefix'])
64
+ );
65
+ }
66
+ });
67
+ </script>
@@ -0,0 +1,107 @@
1
+ <script lang="ts">
2
+ import { BooleanHelper, CastHelper } from '@oinone/kunlun-shared';
3
+ import { AInputSearchProps, InputSearchEvent, OioInputSearchProps, PropRecordHelper } from '@oinone/kunlun-vue-ui-common';
4
+ import { InputSearch as AInputSearch } from 'ant-design-vue';
5
+ import { isBoolean, isEmpty } from 'lodash-es';
6
+ import { computed, createVNode, defineComponent, ref } from 'vue';
7
+ import { DEFAULT_PREFIX } from '../../theme';
8
+ import { OioButton } from '../oio-button';
9
+
10
+ export default defineComponent({
11
+ name: 'OioInputSearch',
12
+ components: {
13
+ AInputSearch
14
+ },
15
+ inheritAttrs: false,
16
+ props: {
17
+ ...OioInputSearchProps
18
+ },
19
+ slots: ['prepend', 'append', 'prefix', 'suffix', 'enter'],
20
+ emits: ['update:value', 'search'],
21
+ setup(props, context) {
22
+ const internalValue = ref();
23
+ const value = computed(() => {
24
+ if (props.value === undefined) {
25
+ return internalValue.value;
26
+ }
27
+ return props.value;
28
+ });
29
+
30
+ const autocomplete = computed<string | undefined>(() => {
31
+ if (props.autocomplete == null) {
32
+ return 'new-password';
33
+ }
34
+ const val = BooleanHelper.toBoolean(props.autocomplete);
35
+ if (isBoolean(val)) {
36
+ return val ? 'on' : 'off';
37
+ }
38
+ return props.autocomplete as string | undefined;
39
+ });
40
+
41
+ const onUpdateValue = (val: string) => {
42
+ internalValue.value = val;
43
+ context.emit('update:value', val);
44
+ };
45
+
46
+ const onSearch = (val: string, e: PointerEvent | KeyboardEvent) => {
47
+ const event: InputSearchEvent = {
48
+ origin: [val, e],
49
+ event: e,
50
+ value: val
51
+ };
52
+ context.emit('search', event);
53
+ };
54
+
55
+ return {
56
+ value,
57
+ autocomplete,
58
+
59
+ onUpdateValue,
60
+ onSearch
61
+ };
62
+ },
63
+ render() {
64
+ const mainClassName = `${DEFAULT_PREFIX}-input-search`;
65
+ const inputClassList = [mainClassName, `${mainClassName}-normal`];
66
+ if (this.readonly) {
67
+ inputClassList.push(`${DEFAULT_PREFIX}-input-readonly`);
68
+ }
69
+ const allowClear = this.allowClear && !isEmpty(this.value);
70
+ if (allowClear) {
71
+ inputClassList.push(`${DEFAULT_PREFIX}-input-allow-clear`);
72
+ }
73
+ return createVNode(
74
+ AInputSearch,
75
+ {
76
+ ...PropRecordHelper.convert(AInputSearchProps, CastHelper.cast(this)),
77
+ ...PropRecordHelper.collectionBasicProps(this.$attrs, inputClassList),
78
+ readonly: this.readonly,
79
+ minlength: this.minlength,
80
+ 'onUpdate:value': this.onUpdateValue,
81
+ onSearch: this.onSearch
82
+ },
83
+ PropRecordHelper.collectionSlots(this.$slots, [
84
+ ['prepend', 'addonBefore'],
85
+ ['append', 'addonAfter'],
86
+ 'prefix',
87
+ 'suffix',
88
+ {
89
+ origin: 'enter',
90
+ target: 'enterButton',
91
+ default: () => {
92
+ return [
93
+ createVNode(
94
+ {
95
+ ...OioButton,
96
+ __ANT_BUTTON: true
97
+ },
98
+ { icon: 'oinone-sousuo1' }
99
+ )
100
+ ];
101
+ }
102
+ }
103
+ ])
104
+ );
105
+ }
106
+ });
107
+ </script>
@@ -0,0 +1,124 @@
1
+ <script lang="ts">
2
+ import { BooleanHelper, CastHelper, StringHelper } from '@oinone/kunlun-shared';
3
+ import { AInputProps, InputFocusOptions, OioInputProps, PropRecordHelper } from '@oinone/kunlun-vue-ui-common';
4
+ import { Input as AInput } from 'ant-design-vue';
5
+ import { isBoolean, isEmpty, isNil } from 'lodash-es';
6
+ import { computed, createVNode, defineComponent, onMounted, ref } from 'vue';
7
+ import { DEFAULT_PREFIX } from '../../theme';
8
+
9
+ export default defineComponent({
10
+ name: 'OioInput',
11
+ components: {
12
+ AInput
13
+ },
14
+ inheritAttrs: false,
15
+ props: {
16
+ ...OioInputProps
17
+ },
18
+ slots: ['prepend', 'append', 'prefix', 'suffix'],
19
+ emits: ['update:value', 'press-enter'],
20
+ setup(props, context) {
21
+ const origin = ref();
22
+
23
+ const internalValue = ref<string | undefined>();
24
+ const value = computed<string | undefined>({
25
+ get() {
26
+ return props.value || internalValue.value;
27
+ },
28
+ set(value) {
29
+ context.emit('update:value', value);
30
+ internalValue.value = value;
31
+ }
32
+ });
33
+
34
+ const autocomplete = computed<string | undefined>(() => {
35
+ if (props.autocomplete == null) {
36
+ return 'new-password';
37
+ }
38
+ const val = BooleanHelper.toBoolean(props.autocomplete);
39
+ if (isBoolean(val)) {
40
+ return val ? 'on' : 'off';
41
+ }
42
+ return props.autocomplete as string | undefined;
43
+ });
44
+
45
+ const onUpdateValue = (val: string | undefined) => {
46
+ value.value = val;
47
+ };
48
+
49
+ const onPressEnter = (event: KeyboardEvent) => {
50
+ context.emit('press-enter', event);
51
+ };
52
+
53
+ context.expose({
54
+ focus: (options?: InputFocusOptions) => origin.value.focus(options),
55
+ blur: () => origin.value.blur()
56
+ });
57
+
58
+ onMounted(() => {
59
+ if (props.autofocus) {
60
+ origin.value.focus();
61
+ }
62
+ });
63
+
64
+ return {
65
+ origin,
66
+ value,
67
+ autocomplete,
68
+
69
+ onUpdateValue,
70
+ onPressEnter
71
+ };
72
+ },
73
+ render() {
74
+ const inputClassList = [`${DEFAULT_PREFIX}-input`];
75
+ if (this.readonly) {
76
+ inputClassList.push(`${DEFAULT_PREFIX}-input-readonly`);
77
+ }
78
+ const allowClear = this.allowClear && !isEmpty(this.value);
79
+ if (allowClear) {
80
+ inputClassList.push(`${DEFAULT_PREFIX}-input-allow-clear`);
81
+ }
82
+ let component = createVNode(
83
+ AInput,
84
+ {
85
+ ...PropRecordHelper.convert(AInputProps, CastHelper.cast(this)),
86
+ autocomplete: this.autocomplete,
87
+ readonly: this.readonly,
88
+ ...this.$attrs,
89
+ 'onUpdate:value': this.onUpdateValue,
90
+ onPressEnter: this.onPressEnter,
91
+ class: StringHelper.append(inputClassList, CastHelper.cast(this.$attrs.class)),
92
+ ref: 'origin'
93
+ },
94
+ PropRecordHelper.collectionSlots(this.$slots, [
95
+ ['prepend', 'addonBefore'],
96
+ ['append', 'addonAfter'],
97
+ 'prefix',
98
+ 'suffix'
99
+ ])
100
+ );
101
+ const maxlenght = this.maxlength;
102
+ if (this.showCount && !isNil(maxlenght)) {
103
+ const wrapperClassList = [`${DEFAULT_PREFIX}-input-wrapper`, `${DEFAULT_PREFIX}-input-show-count`];
104
+ if (allowClear) {
105
+ wrapperClassList.push(`${DEFAULT_PREFIX}-input-allow-clear`);
106
+ }
107
+ let { value } = this;
108
+ if (isNil(value)) {
109
+ value = '';
110
+ }
111
+ component = createVNode(
112
+ 'div',
113
+ {
114
+ class: wrapperClassList,
115
+ 'data-count': value.length,
116
+ 'data-total': maxlenght
117
+ },
118
+ [component]
119
+ );
120
+ }
121
+ return component;
122
+ }
123
+ });
124
+ </script>