vft 0.0.1

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 (321) hide show
  1. package/package.json +54 -0
  2. package/src/app/index.ts +3 -0
  3. package/src/app/page-loading/assets/spin.gif +0 -0
  4. package/src/app/page-loading/index.less +10 -0
  5. package/src/app/page-loading/index.ts +3 -0
  6. package/src/app/page-loading/index.vue +38 -0
  7. package/src/app/table/assets/sort_triangle.png +0 -0
  8. package/src/app/table/demos/basic.vue +117 -0
  9. package/src/app/table/demos/complex.vue +2543 -0
  10. package/src/app/table/demos/index.vue +453 -0
  11. package/src/app/table/demos/rightAngle.png +0 -0
  12. package/src/app/table/header.vue +203 -0
  13. package/src/app/table/index.less +119 -0
  14. package/src/app/table/index.ts +5 -0
  15. package/src/app/table/index.vue +478 -0
  16. package/src/app/table/md/api.md +23 -0
  17. package/src/app/table/md/demo.md +3 -0
  18. package/src/app/table/types.ts +45 -0
  19. package/src/common/badge/index.scss +78 -0
  20. package/src/common/badge/index.ts +4 -0
  21. package/src/common/badge/index.vue +111 -0
  22. package/src/common/badge/types.ts +1 -0
  23. package/src/common/clamp/clamp-toggle.vue +91 -0
  24. package/src/common/clamp/index.ts +4 -0
  25. package/src/common/clamp/index.vue +247 -0
  26. package/src/common/code/index.less +321 -0
  27. package/src/common/code/index.ts +3 -0
  28. package/src/common/code/index.vue +60 -0
  29. package/src/common/config-provider/index.ts +4 -0
  30. package/src/common/config-provider/index.vue +94 -0
  31. package/src/common/config-provider/types.ts +29 -0
  32. package/src/common/icon/iconfont/iconfont.css +334 -0
  33. package/src/common/icon/index.scss +31 -0
  34. package/src/common/icon/index.ts +4 -0
  35. package/src/common/icon/index.vue +74 -0
  36. package/src/common/icon/types.ts +16 -0
  37. package/src/common/index.ts +6 -0
  38. package/src/common/message/index.ts +5 -0
  39. package/src/common/message/instance.ts +29 -0
  40. package/src/common/message/message.scss +108 -0
  41. package/src/common/message/message.ts +80 -0
  42. package/src/common/message/message.vue +162 -0
  43. package/src/common/message/method.ts +172 -0
  44. package/src/common/overlay/index.scss +14 -0
  45. package/src/common/overlay/index.ts +3 -0
  46. package/src/common/overlay/index.vue +117 -0
  47. package/src/constants/comp.ts +1 -0
  48. package/src/constants/index.ts +1 -0
  49. package/src/index.ts +3 -0
  50. package/src/page/index.ts +1 -0
  51. package/src/page/page-wrapper/index.scss +31 -0
  52. package/src/page/page-wrapper/index.ts +5 -0
  53. package/src/page/page-wrapper/index.vue +31 -0
  54. package/src/styles/vars.scss +500 -0
  55. package/src/use/index.ts +14 -0
  56. package/src/use/onPopupReopen.ts +15 -0
  57. package/src/use/use-delayed-toggle/index.ts +30 -0
  58. package/src/use/use-floating/index.ts +121 -0
  59. package/src/use/use-forward-ref.ts +35 -0
  60. package/src/use/use-global-config/index.ts +81 -0
  61. package/src/use/use-id/index.ts +43 -0
  62. package/src/use/use-model-toggle/index.ts +151 -0
  63. package/src/use/use-namespace/index.ts +91 -0
  64. package/src/use/use-ordered-children/index.ts +43 -0
  65. package/src/use/use-popper-container/index.ts +43 -0
  66. package/src/use/use-timeout/index.ts +18 -0
  67. package/src/use/use-z-index/index.ts +20 -0
  68. package/src/use/useGlobalZIndex.ts +24 -0
  69. package/src/use/useLazyRender.ts +17 -0
  70. package/src/use/useLockScroll.ts +66 -0
  71. package/src/utils/aria.ts +126 -0
  72. package/src/utils/arrays.ts +13 -0
  73. package/src/utils/error.ts +23 -0
  74. package/src/utils/event.ts +15 -0
  75. package/src/utils/helper.ts +7 -0
  76. package/src/utils/index.ts +8 -0
  77. package/src/utils/interceptor.ts +39 -0
  78. package/src/utils/mount-component.ts +65 -0
  79. package/src/utils/popper.ts +6 -0
  80. package/src/utils/rand.ts +12 -0
  81. package/src/utils/scroll.ts +101 -0
  82. package/src/utils/vnode.ts +169 -0
  83. package/src/web/avatar/index.scss +50 -0
  84. package/src/web/avatar/index.ts +3 -0
  85. package/src/web/avatar/index.vue +83 -0
  86. package/src/web/back-top/index.scss +35 -0
  87. package/src/web/back-top/index.ts +3 -0
  88. package/src/web/back-top/index.vue +72 -0
  89. package/src/web/back-top/types.ts +14 -0
  90. package/src/web/back-top/use-back-top.ts +65 -0
  91. package/src/web/cascader/index.scss +214 -0
  92. package/src/web/cascader/index.ts +5 -0
  93. package/src/web/cascader/index.vue +767 -0
  94. package/src/web/cascader-panel/config.ts +44 -0
  95. package/src/web/cascader-panel/index.scss +134 -0
  96. package/src/web/cascader-panel/index.ts +5 -0
  97. package/src/web/cascader-panel/index.vue +319 -0
  98. package/src/web/cascader-panel/menu.vue +135 -0
  99. package/src/web/cascader-panel/node-content.ts +23 -0
  100. package/src/web/cascader-panel/node.ts +218 -0
  101. package/src/web/cascader-panel/node.vue +197 -0
  102. package/src/web/cascader-panel/store.ts +83 -0
  103. package/src/web/cascader-panel/types.ts +56 -0
  104. package/src/web/cascader-panel/utils.ts +40 -0
  105. package/src/web/cascader-select/README.md +31 -0
  106. package/src/web/cascader-select/index.scss +54 -0
  107. package/src/web/cascader-select/index.ts +5 -0
  108. package/src/web/cascader-select/index.vue +132 -0
  109. package/src/web/cascader-select/types.ts +9 -0
  110. package/src/web/context-menu/createContextMenu.ts +72 -0
  111. package/src/web/context-menu/index.ts +4 -0
  112. package/src/web/context-menu/index.vue +89 -0
  113. package/src/web/context-menu/types.ts +27 -0
  114. package/src/web/context-menu/useContextMenu.ts +14 -0
  115. package/src/web/descriptions/description-item.vue +34 -0
  116. package/src/web/descriptions/description.vue +124 -0
  117. package/src/web/descriptions/descriptions-cell.ts +95 -0
  118. package/src/web/descriptions/descriptions-item.scss +68 -0
  119. package/src/web/descriptions/descriptions-row.vue +49 -0
  120. package/src/web/descriptions/descriptions.scss +153 -0
  121. package/src/web/descriptions/descriptions.type.ts +19 -0
  122. package/src/web/descriptions/index.ts +4 -0
  123. package/src/web/descriptions/token.ts +4 -0
  124. package/src/web/divider/index.scss +53 -0
  125. package/src/web/divider/index.ts +5 -0
  126. package/src/web/divider/index.vue +60 -0
  127. package/src/web/divider/types.ts +2 -0
  128. package/src/web/empty/assets/no-collect.png +0 -0
  129. package/src/web/empty/assets/no-data.png +0 -0
  130. package/src/web/empty/assets/no-filter.png +0 -0
  131. package/src/web/empty/assets/no-page-data.png +0 -0
  132. package/src/web/empty/assets/no-search.png +0 -0
  133. package/src/web/empty/constants.ts +12 -0
  134. package/src/web/empty/index.scss +57 -0
  135. package/src/web/empty/index.ts +5 -0
  136. package/src/web/empty/index.vue +96 -0
  137. package/src/web/exception/exception.png +0 -0
  138. package/src/web/exception/index.ts +3 -0
  139. package/src/web/exception/index.vue +44 -0
  140. package/src/web/filter/README.md +25 -0
  141. package/src/web/filter/index.scss +14 -0
  142. package/src/web/filter/index.ts +5 -0
  143. package/src/web/filter/index.vue +60 -0
  144. package/src/web/filter/type.ts +13 -0
  145. package/src/web/focus-trap/index.ts +6 -0
  146. package/src/web/focus-trap/index.vue +328 -0
  147. package/src/web/focus-trap/tokens.ts +23 -0
  148. package/src/web/focus-trap/utils.ts +178 -0
  149. package/src/web/full-screen/index.scss +22 -0
  150. package/src/web/full-screen/index.ts +3 -0
  151. package/src/web/full-screen/index.vue +24 -0
  152. package/src/web/icon-text/index.ts +3 -0
  153. package/src/web/icon-text/index.vue +77 -0
  154. package/src/web/image/index.scss +46 -0
  155. package/src/web/image/index.ts +5 -0
  156. package/src/web/image/index.vue +251 -0
  157. package/src/web/image/types.ts +1 -0
  158. package/src/web/index.ts +33 -0
  159. package/src/web/input/index.scss +473 -0
  160. package/src/web/input/index.ts +3 -0
  161. package/src/web/input/index.vue +533 -0
  162. package/src/web/input/utils.ts +102 -0
  163. package/src/web/layouts/blank.vue +4 -0
  164. package/src/web/layouts/footer/index.scss +31 -0
  165. package/src/web/layouts/footer/index.ts +3 -0
  166. package/src/web/layouts/footer/index.vue +38 -0
  167. package/src/web/layouts/header/index.scss +35 -0
  168. package/src/web/layouts/header/index.ts +3 -0
  169. package/src/web/layouts/header/index.vue +47 -0
  170. package/src/web/layouts/iframe/index.scss +18 -0
  171. package/src/web/layouts/iframe/index.vue +36 -0
  172. package/src/web/layouts/iframe/page.vue +30 -0
  173. package/src/web/layouts/index.ts +8 -0
  174. package/src/web/layouts/router-view-content/index.vue +70 -0
  175. package/src/web/link/index.scss +95 -0
  176. package/src/web/link/index.ts +3 -0
  177. package/src/web/link/index.vue +68 -0
  178. package/src/web/loading/directive.ts +104 -0
  179. package/src/web/loading/index.ts +6 -0
  180. package/src/web/loading/loading.scss +108 -0
  181. package/src/web/loading/loading.ts +156 -0
  182. package/src/web/loading/service.ts +145 -0
  183. package/src/web/loading/types.ts +29 -0
  184. package/src/web/logo/index.scss +31 -0
  185. package/src/web/logo/index.ts +5 -0
  186. package/src/web/logo/index.vue +45 -0
  187. package/src/web/logo/types.ts +6 -0
  188. package/src/web/menu/index.scss +336 -0
  189. package/src/web/menu/index.ts +8 -0
  190. package/src/web/menu/menu-collapse-transition.vue +62 -0
  191. package/src/web/menu/menu-item-group.vue +27 -0
  192. package/src/web/menu/menu-item.vue +126 -0
  193. package/src/web/menu/menu.vue +459 -0
  194. package/src/web/menu/sub-menu.vue +440 -0
  195. package/src/web/menu/types.ts +66 -0
  196. package/src/web/menu/use-menu-css-var.ts +11 -0
  197. package/src/web/menu/use-menu.ts +60 -0
  198. package/src/web/menu/utils/menu-bar.ts +19 -0
  199. package/src/web/menu/utils/menu-item.ts +55 -0
  200. package/src/web/menu/utils/submenu.ts +66 -0
  201. package/src/web/multiple-select-flat/index.ts +5 -0
  202. package/src/web/multiple-select-flat/index.vue +53 -0
  203. package/src/web/multiple-select-flat/types.ts +5 -0
  204. package/src/web/multiple-tabs/index.scss +16 -0
  205. package/src/web/multiple-tabs/index.ts +5 -0
  206. package/src/web/multiple-tabs/index.vue +193 -0
  207. package/src/web/multiple-tabs/tab-content.vue +40 -0
  208. package/src/web/multiple-tabs/types.ts +3 -0
  209. package/src/web/multiple-tabs/use/index.ts +2 -0
  210. package/src/web/multiple-tabs/use/use-multiple-tabs.ts +86 -0
  211. package/src/web/multiple-tabs/use/use-tab-dropdown.ts +101 -0
  212. package/src/web/nodata/README.md +42 -0
  213. package/src/web/nodata/fail.vue +13 -0
  214. package/src/web/nodata/img/100.png +0 -0
  215. package/src/web/nodata/img/101.png +0 -0
  216. package/src/web/nodata/img/102.png +0 -0
  217. package/src/web/nodata/img/103.png +0 -0
  218. package/src/web/nodata/img/104.png +0 -0
  219. package/src/web/nodata/img/105.png +0 -0
  220. package/src/web/nodata/img/106.png +0 -0
  221. package/src/web/nodata/img/107.png +0 -0
  222. package/src/web/nodata/img/200.png +0 -0
  223. package/src/web/nodata/img/201.png +0 -0
  224. package/src/web/nodata/img/202.png +0 -0
  225. package/src/web/nodata/img/203.png +0 -0
  226. package/src/web/nodata/index.scss +37 -0
  227. package/src/web/nodata/index.ts +6 -0
  228. package/src/web/nodata/index.vue +46 -0
  229. package/src/web/nodata/types.ts +17 -0
  230. package/src/web/only-child/index.tsx +69 -0
  231. package/src/web/pagination/components/jumper.vue +49 -0
  232. package/src/web/pagination/components/next.vue +40 -0
  233. package/src/web/pagination/components/pager.vue +215 -0
  234. package/src/web/pagination/components/prev.vue +35 -0
  235. package/src/web/pagination/components/sizes.vue +76 -0
  236. package/src/web/pagination/components/total.vue +21 -0
  237. package/src/web/pagination/index.scss +231 -0
  238. package/src/web/pagination/index.ts +5 -0
  239. package/src/web/pagination/pagination.ts +363 -0
  240. package/src/web/pagination/usePagination.ts +13 -0
  241. package/src/web/popover/directive.ts +21 -0
  242. package/src/web/popover/index.scss +58 -0
  243. package/src/web/popover/index.ts +3 -0
  244. package/src/web/popover/index.vue +161 -0
  245. package/src/web/popover/types.ts +26 -0
  246. package/src/web/popper/arrow.vue +45 -0
  247. package/src/web/popper/content.vue +311 -0
  248. package/src/web/popper/index.scss +108 -0
  249. package/src/web/popper/index.ts +11 -0
  250. package/src/web/popper/popper.vue +57 -0
  251. package/src/web/popper/tokens.ts +28 -0
  252. package/src/web/popper/trigger.vue +166 -0
  253. package/src/web/popper/types.ts +49 -0
  254. package/src/web/popper/utils.ts +81 -0
  255. package/src/web/qrcode/drawCanvas.ts +32 -0
  256. package/src/web/qrcode/drawLogo.ts +82 -0
  257. package/src/web/qrcode/index.ts +5 -0
  258. package/src/web/qrcode/index.vue +107 -0
  259. package/src/web/qrcode/qrcodePlus.ts +4 -0
  260. package/src/web/qrcode/toCanvas.ts +11 -0
  261. package/src/web/qrcode/types.ts +38 -0
  262. package/src/web/result/index.scss +69 -0
  263. package/src/web/result/index.ts +3 -0
  264. package/src/web/result/index.vue +63 -0
  265. package/src/web/scrollbar/bar.vue +48 -0
  266. package/src/web/scrollbar/index.scss +91 -0
  267. package/src/web/scrollbar/index.ts +5 -0
  268. package/src/web/scrollbar/index.vue +236 -0
  269. package/src/web/scrollbar/thumb.vue +183 -0
  270. package/src/web/scrollbar/tokens.ts +10 -0
  271. package/src/web/scrollbar/types.ts +7 -0
  272. package/src/web/scrollbar/util.ts +38 -0
  273. package/src/web/select/constants.ts +13 -0
  274. package/src/web/select/index.ts +11 -0
  275. package/src/web/select/index.vue +555 -0
  276. package/src/web/select/option-group.scss +49 -0
  277. package/src/web/select/option-group.vue +97 -0
  278. package/src/web/select/option-item.scss +66 -0
  279. package/src/web/select/option.scss +32 -0
  280. package/src/web/select/option.vue +110 -0
  281. package/src/web/select/select-dropdown.scss +86 -0
  282. package/src/web/select/select-dropdown.vue +51 -0
  283. package/src/web/select/select.scss +213 -0
  284. package/src/web/select/token.ts +56 -0
  285. package/src/web/select/useOption.ts +146 -0
  286. package/src/web/select/useSelect.ts +942 -0
  287. package/src/web/select/utils.ts +5 -0
  288. package/src/web/side-menu/index.scss +66 -0
  289. package/src/web/side-menu/index.ts +4 -0
  290. package/src/web/side-menu/index.vue +228 -0
  291. package/src/web/side-menu/types.ts +20 -0
  292. package/src/web/single-select/index.scss +60 -0
  293. package/src/web/single-select/index.ts +5 -0
  294. package/src/web/single-select/index.vue +70 -0
  295. package/src/web/single-select/select@2x.png +0 -0
  296. package/src/web/single-select/types.ts +5 -0
  297. package/src/web/svg/index.ts +3 -0
  298. package/src/web/svg/index.vue +22 -0
  299. package/src/web/tabs/index.scss +579 -0
  300. package/src/web/tabs/index.ts +6 -0
  301. package/src/web/tabs/index.vue +236 -0
  302. package/src/web/tabs/tab-bar.vue +90 -0
  303. package/src/web/tabs/tab-nav.vue +403 -0
  304. package/src/web/tabs/tab-pane.vue +90 -0
  305. package/src/web/tabs/types.ts +66 -0
  306. package/src/web/tag/index.scss +182 -0
  307. package/src/web/tag/index.ts +5 -0
  308. package/src/web/tag/index.vue +78 -0
  309. package/src/web/tag/types.ts +2 -0
  310. package/src/web/tooltip/content.vue +239 -0
  311. package/src/web/tooltip/index.ts +4 -0
  312. package/src/web/tooltip/tokens.ts +21 -0
  313. package/src/web/tooltip/tooltip.vue +270 -0
  314. package/src/web/tooltip/trigger.vue +119 -0
  315. package/src/web/tooltip/types.ts +56 -0
  316. package/src/web/tooltip/utils.ts +20 -0
  317. package/src/web/transition/collapse-transition.vue +73 -0
  318. package/src/web/transition/index.ts +5 -0
  319. package/tsconfig.json +8 -0
  320. package/types/component.ts +1 -0
  321. package/types/index.d.ts +286 -0
@@ -0,0 +1,533 @@
1
+ <script lang="ts" setup>
2
+ /* eslint-disable @typescript-eslint/no-unused-vars */
3
+ import { UPDATE_MODEL_EVENT } from '@vri/constants';
4
+ import { useAttrs } from '@vri/use';
5
+ import { isObject, noop, isString, singleAttrToObj, addUnit } from '@vri/utils';
6
+ import { isClient, useResizeObserver } from '@vueuse/core';
7
+ import { useCursor, useDisabled, useFormItem, useFormItemInputId, useSize } from 'element-plus';
8
+ import { isNil } from 'lodash';
9
+ import { Icon as VriIcon, type IconProps } from '../../common';
10
+ import type { StyleValue } from 'vue';
11
+ import {
12
+ computed,
13
+ nextTick,
14
+ onMounted,
15
+ ref,
16
+ shallowRef,
17
+ useAttrs as useRawAttrs,
18
+ useSlots,
19
+ watch,
20
+ getCurrentInstance
21
+ } from 'vue';
22
+ import { calcTextareaHeight } from './utils';
23
+ import { useNamespace } from '../../use';
24
+ import { debugWarn } from '../../utils';
25
+
26
+ type TargetElement = HTMLInputElement | HTMLTextAreaElement;
27
+
28
+ interface InputProps {
29
+ id?: string;
30
+ size?: 'default' | 'small' | 'large';
31
+ disabled?: boolean;
32
+ modelValue?: string | number;
33
+ type?: string;
34
+ resize?: 'none' | 'both' | 'horizontal' | 'vertical';
35
+ autosize?: {minRows?: number; maxRows?: number} | boolean;
36
+ autocomplete?: string;
37
+ formatter?: Function;
38
+ parser?: Function;
39
+ placeholder?: string;
40
+ form?: string;
41
+ readonly?: boolean;
42
+ clearable?: boolean;
43
+ showPassword?: boolean;
44
+ showWordLimit?: boolean;
45
+ suffixIcon?: IconProps;
46
+ prefixIcon?: IconProps;
47
+ clearIcon?: IconProps;
48
+ containerRole?: string;
49
+ label?: string;
50
+ tabindex?: string | number;
51
+ validateEvent?: boolean;
52
+ inputStyle?: StyleValue;
53
+ focusWidth?: Numberish
54
+ }
55
+
56
+ const {
57
+ id,
58
+ size = '',
59
+ disabled,
60
+ type = 'text',
61
+ autosize = false,
62
+ autocomplete = 'off',
63
+ tabindex = 0,
64
+ validateEvent = true,
65
+ modelValue,
66
+ resize,
67
+ formatter,
68
+ parser,
69
+ placeholder,
70
+ form,
71
+ readonly,
72
+ clearable,
73
+ showPassword,
74
+ showWordLimit,
75
+ suffixIcon,
76
+ prefixIcon,
77
+ clearIcon,
78
+ containerRole,
79
+ label,
80
+ inputStyle,
81
+ focusWidth
82
+ } = defineProps<InputProps>();
83
+
84
+ const emit = defineEmits({
85
+ [UPDATE_MODEL_EVENT]: (value: string) => isString(value),
86
+ input: (value: string) => isString(value),
87
+ change: (value: string) => isString(value),
88
+ suffixclick: (value) => isString(value),
89
+ focus: (evt: FocusEvent) => evt instanceof FocusEvent,
90
+ blur: (evt: FocusEvent) => evt instanceof FocusEvent,
91
+ clear: () => true,
92
+ mouseleave: (evt: MouseEvent) => evt instanceof MouseEvent,
93
+ mouseenter: (evt: MouseEvent) => evt instanceof MouseEvent,
94
+ // NOTE: when autofill by browser, the keydown event is instanceof Event, not KeyboardEvent
95
+ // relative bug report https://github.com/element-plus/element-plus/issues/6665
96
+ keydown: (evt: KeyboardEvent | Event) => evt instanceof Event,
97
+ compositionstart: (evt: CompositionEvent) => evt instanceof CompositionEvent,
98
+ compositionupdate: (evt: CompositionEvent) => evt instanceof CompositionEvent,
99
+ compositionend: (evt: CompositionEvent) => evt instanceof CompositionEvent
100
+ });
101
+
102
+ const rawAttrs = useRawAttrs();
103
+ const slots = useSlots();
104
+
105
+ const containerAttrs = computed(() => {
106
+ const comboBoxAttrs: Record<string, unknown> = {};
107
+ if (containerRole === 'combobox') {
108
+ comboBoxAttrs['aria-haspopup'] = rawAttrs['aria-haspopup'];
109
+ comboBoxAttrs['aria-owns'] = rawAttrs['aria-owns'];
110
+ comboBoxAttrs['aria-expanded'] = rawAttrs['aria-expanded'];
111
+ }
112
+ return comboBoxAttrs;
113
+ });
114
+
115
+ const containerKls = computed(() => [
116
+ type === 'textarea' ? nsTextarea.b() : nsInput.b(),
117
+ nsInput.m(inputSize.value),
118
+ nsInput.is('disabled', inputDisabled.value),
119
+ nsInput.is('exceed', inputExceed.value),
120
+ nsInput.is('focus', focused.value),
121
+ {
122
+ [nsInput.b('group')]: slots.prepend || slots.append,
123
+ [nsInput.bm('group', 'append')]: slots.append,
124
+ [nsInput.bm('group', 'prepend')]: slots.prepend,
125
+ [nsInput.m('prefix')]: slots.prefix || prefixIcon,
126
+ [nsInput.m('suffix')]: slots.suffix || suffixIcon || clearable || showPassword,
127
+ [nsInput.bm('suffix', 'password-clear')]: showClear.value && showPwdVisible.value
128
+ },
129
+ rawAttrs.class
130
+ ]);
131
+
132
+ const instance = getCurrentInstance()!;
133
+
134
+ const wrapperKls = computed(() => [nsInput.e('wrapper'), nsInput.is('focus', focused.value)]);
135
+
136
+ const attrs = useAttrs({
137
+ excludeKeys: computed<string[]>(() => {
138
+ return Object.keys(containerAttrs.value);
139
+ })
140
+ });
141
+
142
+ const { form: _form, formItem } = useFormItem();
143
+ const { inputId } = useFormItemInputId(instance.props, {
144
+ formItemContext: formItem
145
+ });
146
+ const inputSize = useSize();
147
+ const inputDisabled = useDisabled();
148
+ const nsInput = useNamespace('input');
149
+ const nsTextarea = useNamespace('textarea');
150
+
151
+ const input = shallowRef<HTMLInputElement>();
152
+ const textarea = shallowRef<HTMLTextAreaElement>();
153
+
154
+ const focused = ref(false);
155
+ const hovering = ref(false);
156
+ const isComposing = ref(false);
157
+ const passwordVisible = ref(false);
158
+ const countStyle = ref<StyleValue>();
159
+ const textareaCalcStyle = shallowRef(inputStyle);
160
+
161
+ const _ref = computed(() => input.value || textarea.value);
162
+
163
+ const _prefixIcon = computed(() => {
164
+ return singleAttrToObj(prefixIcon, 'icon') as IconProps;
165
+ });
166
+
167
+ const _suffixIcon = computed(() => {
168
+ return singleAttrToObj(suffixIcon, 'icon') as IconProps;
169
+ });
170
+
171
+ const _clearIcon = computed(() => {
172
+ return singleAttrToObj(clearIcon, 'icon', { icon: 'vi-close-full', size: 16 }) as IconProps;
173
+ });
174
+
175
+ const needStatusIcon = computed(() => _form?.statusIcon ?? false);
176
+ const validateState = computed(() => formItem?.validateState || '');
177
+ const validateIcon = computed(() => validateState.value && 'vi-user');
178
+ const passwordIcon = computed(
179
+ () => (passwordVisible.value ? { icon: 'vi-view', size: 16 } : { icon: 'vi-no-view', size: 16 }));
180
+ const containerStyle = computed<StyleValue>(() => [rawAttrs.style as StyleValue, inputStyle!,
181
+ focusWidth && focused.value ? { width: addUnit(focusWidth) } : {}]);
182
+
183
+ const textareaStyle = computed<StyleValue>(
184
+ () => [inputStyle!, textareaCalcStyle.value as StyleValue, { resize: resize }]);
185
+ const nativeInputValue = computed(() => (isNil(modelValue) ? '' : String(modelValue)));
186
+ const showClear = computed(
187
+ () => clearable && !inputDisabled.value && !readonly && !!nativeInputValue.value && (focused.value || hovering.value));
188
+ const showPwdVisible = computed(
189
+ () => showPassword && !inputDisabled.value && !readonly && !!nativeInputValue.value && (!!nativeInputValue.value || focused.value));
190
+ const isWordLimitVisible = computed(
191
+ () => showWordLimit && !!attrs.value.maxlength && (type === 'text' || type === 'textarea') && !inputDisabled.value && !readonly && !showPassword);
192
+ const textLength = computed(() => Array.from(nativeInputValue.value).length);
193
+ const inputExceed = computed(
194
+ () =>
195
+ // show exceed style if length of initial value greater then maxlength
196
+ !!isWordLimitVisible.value && textLength.value > Number(attrs.value.maxlength)
197
+ );
198
+ const suffixVisible = computed(
199
+ () => !!slots.suffix || !!suffixIcon || showClear.value || showPassword || isWordLimitVisible.value || (!!validateState.value && needStatusIcon.value));
200
+
201
+ const [recordCursor, setCursor] = useCursor(input);
202
+
203
+ useResizeObserver(textarea, (entries) => {
204
+ if (!isWordLimitVisible.value || resize !== 'both') return;
205
+ const entry = entries[0];
206
+ const { width } = entry.contentRect;
207
+ countStyle.value = {
208
+ /** right: 100% - width + padding(15) + right(6) */
209
+ right: `calc(100% - ${width + 15 + 6}px)`
210
+ };
211
+ });
212
+
213
+ const resizeTextarea = () => {
214
+ if (!isClient || type !== 'textarea') return;
215
+
216
+ if (autosize) {
217
+ const minRows = isObject(autosize) ? autosize.minRows : undefined;
218
+ const maxRows = isObject(autosize) ? autosize.maxRows : undefined;
219
+ textareaCalcStyle.value = {
220
+ ...calcTextareaHeight(textarea.value!, minRows, maxRows)
221
+ };
222
+ } else {
223
+ textareaCalcStyle.value = {
224
+ minHeight: calcTextareaHeight(textarea.value!).minHeight
225
+ };
226
+ }
227
+ };
228
+
229
+ const setNativeInputValue = () => {
230
+ const input = _ref.value;
231
+ if (!input || input.value === nativeInputValue.value) return;
232
+ input.value = nativeInputValue.value;
233
+ };
234
+
235
+ const handleInput = async(event: InputEvent) => {
236
+ recordCursor();
237
+
238
+ let { value } = event.target as TargetElement;
239
+
240
+ // 处理 number 下 maxlength 失效的问题
241
+ if (attrs.value.maxlength && value.length >= attrs.value.maxlength) {
242
+ value = value.slice(0, Number(attrs.value.maxlength));
243
+ }
244
+
245
+ if (formatter) {
246
+ value = parser ? parser(value) : value;
247
+ value = formatter(value);
248
+ }
249
+
250
+ // should not emit input during composition
251
+ // see: https://github.com/ElemeFE/element/issues/10516
252
+ if (isComposing.value) return;
253
+
254
+ // hack for https://github.com/ElemeFE/element/issues/8548
255
+ // should remove the following line when we don't support IE
256
+ if (value === nativeInputValue.value) {
257
+ setNativeInputValue();
258
+ return;
259
+ }
260
+
261
+ emit(UPDATE_MODEL_EVENT, value);
262
+ emit('input', value);
263
+
264
+ // ensure native input value is controlled
265
+ // see: https://github.com/ElemeFE/element/issues/12850
266
+ await nextTick();
267
+ setNativeInputValue();
268
+ setCursor();
269
+ };
270
+
271
+ const handleChange = (event: Event) => {
272
+ emit('change', (event.target as TargetElement).value);
273
+ };
274
+
275
+ const handleSuffixClick = () => {
276
+ emit('suffixclick', modelValue);
277
+ };
278
+
279
+ const handleCompositionStart = (event: CompositionEvent) => {
280
+ emit('compositionstart', event);
281
+ isComposing.value = true;
282
+ };
283
+
284
+ const isKorean = (text: string) => /([(\uAC00-\uD7AF)|(\u3130-\u318F)])+/gi.test(text);
285
+
286
+ const handleCompositionUpdate = (event: CompositionEvent) => {
287
+ emit('compositionupdate', event);
288
+ const text = (event.target as HTMLInputElement)?.value;
289
+ const lastCharacter = text[text.length - 1] || '';
290
+ isComposing.value = !isKorean(lastCharacter);
291
+ };
292
+
293
+ const handleCompositionEnd = (event: CompositionEvent) => {
294
+ emit('compositionend', event);
295
+ if (isComposing.value) {
296
+ isComposing.value = false;
297
+ handleInput(event);
298
+ }
299
+ };
300
+
301
+ const handlePasswordVisible = () => {
302
+ passwordVisible.value = !passwordVisible.value;
303
+ focus();
304
+ };
305
+
306
+ const focus = async() => {
307
+ // see: https://github.com/ElemeFE/element/issues/18573
308
+ await nextTick();
309
+ _ref.value?.focus();
310
+ };
311
+
312
+ const blur = () => _ref.value?.blur();
313
+
314
+ const handleFocus = (event: FocusEvent) => {
315
+ focused.value = true;
316
+ emit('focus', event);
317
+ };
318
+
319
+ const handleBlur = (event: FocusEvent) => {
320
+ focused.value = false;
321
+ emit('blur', event);
322
+ if (validateEvent) {
323
+ formItem?.validate?.('blur').catch((err) => debugWarn(err));
324
+ }
325
+ };
326
+
327
+ const handleMouseLeave = (evt: MouseEvent) => {
328
+ hovering.value = false;
329
+ emit('mouseleave', evt);
330
+ };
331
+
332
+ const handleMouseEnter = (evt: MouseEvent) => {
333
+ hovering.value = true;
334
+ emit('mouseenter', evt);
335
+ };
336
+
337
+ const handleKeydown = (evt: KeyboardEvent) => {
338
+ let key = evt.key;
339
+ if ((evt.target as TargetElement).type === 'number') {
340
+ const forbidKey = ['e', '+', '-0', 'E'];
341
+ if (forbidKey.includes(key)){
342
+ evt.returnValue = false;
343
+ return false;
344
+ }
345
+ }
346
+
347
+ emit('keydown', evt);
348
+ };
349
+
350
+ const select = () => {
351
+ _ref.value?.select();
352
+ };
353
+
354
+ const clear = () => {
355
+ emit(UPDATE_MODEL_EVENT, '');
356
+ emit('change', '');
357
+ emit('clear');
358
+ emit('input', '');
359
+ };
360
+
361
+ watch(
362
+ () => modelValue,
363
+ () => {
364
+ nextTick(() => resizeTextarea());
365
+ if (validateEvent) {
366
+ formItem?.validate?.('change').catch((err) => debugWarn(err));
367
+ }
368
+ }
369
+ );
370
+
371
+ // native input value is set explicitly
372
+ // do not use v-model / :value in template
373
+ // see: https://github.com/ElemeFE/element/issues/14521
374
+ watch(nativeInputValue, () => setNativeInputValue());
375
+
376
+ // when change between <input> and <textarea>,
377
+ // update DOM dependent value and styles
378
+ // https://github.com/ElemeFE/element/issues/14857
379
+ watch(
380
+ () => type,
381
+ async() => {
382
+ await nextTick();
383
+ setNativeInputValue();
384
+ resizeTextarea();
385
+ }
386
+ );
387
+
388
+ onMounted(() => {
389
+ if (!formatter && parser) {
390
+ debugWarn('VriInput', 'If you set the parser, you also need to set the formatter.');
391
+ }
392
+ setNativeInputValue();
393
+ nextTick(resizeTextarea);
394
+ });
395
+
396
+ defineExpose({
397
+ /** @description HTML input element */
398
+ input,
399
+ /** @description HTML textarea element */
400
+ textarea,
401
+ /** @description HTML element, input or textarea */
402
+ ref: _ref,
403
+ /** @description style of textarea. */
404
+ textareaStyle,
405
+
406
+ /** @description from props (used on unit test) */
407
+ autosize,
408
+
409
+ /** @description HTML input element native method */
410
+ focus,
411
+ /** @description HTML input element native method */
412
+ blur,
413
+ /** @description HTML input element native method */
414
+ select,
415
+ /** @description clear input value */
416
+ clear,
417
+ /** @description resize textarea. */
418
+ resizeTextarea
419
+ });
420
+ </script>
421
+
422
+ <template>
423
+ <div v-show="type !== 'hidden'" v-bind="containerAttrs" :class="containerKls"
424
+ :style="containerStyle" :role="containerRole" @mouseenter="handleMouseEnter"
425
+ @mouseleave="handleMouseLeave">
426
+ <!-- input -->
427
+ <template v-if="type !== 'textarea'">
428
+ <!-- prepend slot -->
429
+ <div v-if="$slots.prepend" :class="nsInput.be('group', 'prepend')">
430
+ <slot name="prepend" />
431
+ </div>
432
+
433
+ <div :class="wrapperKls">
434
+ <!-- prefix slot -->
435
+ <span v-if="$slots.prefix || _prefixIcon?.icon" :class="nsInput.e('prefix')">
436
+ <span :class="nsInput.e('prefix-inner')" @click="focus">
437
+ <slot name="prefix" />
438
+ <vri-icon v-if="_prefixIcon?.icon" v-bind="_prefixIcon" :class="nsInput.e('icon')" />
439
+ </span>
440
+ </span>
441
+
442
+ <input
443
+ :id="inputId"
444
+ ref="input"
445
+ :class="nsInput.e('inner')"
446
+ v-bind="attrs"
447
+ :type="showPassword ? (passwordVisible ? 'text' : 'password') : type"
448
+ :disabled="inputDisabled"
449
+ :formatter="formatter"
450
+ :parser="parser"
451
+ :readonly="readonly"
452
+ :autocomplete="autocomplete"
453
+ :tabindex="tabindex"
454
+ :aria-label="label"
455
+ :placeholder="placeholder"
456
+ :style="inputStyle"
457
+ :form="form"
458
+ @compositionstart="handleCompositionStart"
459
+ @compositionupdate="handleCompositionUpdate"
460
+ @compositionend="handleCompositionEnd"
461
+ @input="handleInput"
462
+ @focus="handleFocus"
463
+ @blur="handleBlur"
464
+ @change="handleChange"
465
+ @keydown="handleKeydown"
466
+ />
467
+
468
+ <!-- suffix slot -->
469
+ <span v-if="suffixVisible" :class="nsInput.e('suffix')">
470
+ <span :class="nsInput.e('suffix-inner')" @click="focus">
471
+ <template v-if="!showClear || !showPwdVisible || !isWordLimitVisible">
472
+ <slot name="suffix" />
473
+ <vri-icon
474
+ @click="handleSuffixClick"
475
+ v-if="_suffixIcon?.icon" v-bind="_suffixIcon" :class="nsInput.e('icon')" />
476
+ </template>
477
+ <vri-icon v-if="showClear" :class="[nsInput.e('icon'), nsInput.e('clear')]"
478
+ v-bind="_clearIcon" @mousedown.prevent="noop" @click="clear" />
479
+ <vri-icon v-if="showPwdVisible" v-bind="passwordIcon"
480
+ :class="[nsInput.e('icon'), nsInput.e('password')]" @click="handlePasswordVisible" />
481
+ <span v-if="isWordLimitVisible" :class="nsInput.e('count')">
482
+ <span
483
+ :class="nsInput.e('count-inner')">{{ textLength }} / {{ attrs.maxlength }}</span>
484
+ </span>
485
+ <vri-icon
486
+ v-if="validateState && validateIcon && needStatusIcon"
487
+ :icon="validateIcon"
488
+ :class="[nsInput.e('icon'), nsInput.e('validateIcon'), nsInput.is('loading', validateState === 'validating')]"
489
+ />
490
+ </span>
491
+ </span>
492
+ </div>
493
+
494
+ <!-- append slot -->
495
+ <div v-if="$slots.append" :class="nsInput.be('group', 'append')">
496
+ <slot name="append" />
497
+ </div>
498
+ </template>
499
+
500
+ <!-- textarea -->
501
+ <template v-else>
502
+ <textarea
503
+ :id="inputId"
504
+ ref="textarea"
505
+ :class="nsTextarea.e('inner')"
506
+ v-bind="attrs"
507
+ :tabindex="tabindex"
508
+ :disabled="inputDisabled"
509
+ :readonly="readonly"
510
+ :autocomplete="autocomplete"
511
+ :style="textareaStyle"
512
+ :aria-label="label"
513
+ :placeholder="placeholder"
514
+ :form="form"
515
+ @compositionstart="handleCompositionStart"
516
+ @compositionupdate="handleCompositionUpdate"
517
+ @compositionend="handleCompositionEnd"
518
+ @input="handleInput"
519
+ @focus="handleFocus"
520
+ @blur="handleBlur"
521
+ @change="handleChange"
522
+ @keydown="handleKeydown"
523
+ />
524
+ <span v-if="isWordLimitVisible" :style="countStyle"
525
+ :class="nsInput.e('count')">{{ textLength }} / {{ attrs.maxlength }}</span>
526
+ </template>
527
+ </div>
528
+ </template>
529
+
530
+
531
+ <style lang="scss">
532
+ @import './index.scss';
533
+ </style>
@@ -0,0 +1,102 @@
1
+ import { isNumber } from '@vri/utils';
2
+
3
+ let hiddenTextarea: HTMLTextAreaElement | undefined = undefined;
4
+
5
+ const HIDDEN_STYLE = `
6
+ height:0 !important;
7
+ visibility:hidden !important;
8
+ overflow:hidden !important;
9
+ position:absolute !important;
10
+ z-index:-1000 !important;
11
+ top:0 !important;
12
+ right:0 !important;
13
+ `;
14
+
15
+ const CONTEXT_STYLE = [
16
+ 'letter-spacing',
17
+ 'line-height',
18
+ 'padding-top',
19
+ 'padding-bottom',
20
+ 'font-family',
21
+ 'font-weight',
22
+ 'font-size',
23
+ 'text-rendering',
24
+ 'text-transform',
25
+ 'width',
26
+ 'text-indent',
27
+ 'padding-left',
28
+ 'padding-right',
29
+ 'border-width',
30
+ 'box-sizing'
31
+ ];
32
+
33
+ type NodeStyle = {
34
+ contextStyle: string;
35
+ boxSizing: string;
36
+ paddingSize: number;
37
+ borderSize: number;
38
+ };
39
+
40
+ type TextAreaHeight = {
41
+ height: string;
42
+ minHeight?: string;
43
+ };
44
+
45
+ function calculateNodeStyling(targetElement: Element): NodeStyle {
46
+ const style = window.getComputedStyle(targetElement);
47
+
48
+ const boxSizing = style.getPropertyValue('box-sizing');
49
+
50
+ const paddingSize = Number.parseFloat(style.getPropertyValue('padding-bottom')) + Number.parseFloat(style.getPropertyValue('padding-top'));
51
+
52
+ const borderSize = Number.parseFloat(style.getPropertyValue('border-bottom-width')) + Number.parseFloat(style.getPropertyValue('border-top-width'));
53
+
54
+ const contextStyle = CONTEXT_STYLE.map((name) => `${name}:${style.getPropertyValue(name)}`).join(';');
55
+
56
+ return { contextStyle, paddingSize, borderSize, boxSizing };
57
+ }
58
+
59
+ export function calcTextareaHeight(targetElement: HTMLTextAreaElement, minRows = 1, maxRows?: number): TextAreaHeight {
60
+ if (!hiddenTextarea) {
61
+ hiddenTextarea = document.createElement('textarea');
62
+ document.body.appendChild(hiddenTextarea);
63
+ }
64
+
65
+ const { paddingSize, borderSize, boxSizing, contextStyle } = calculateNodeStyling(targetElement);
66
+
67
+ hiddenTextarea.setAttribute('style', `${contextStyle};${HIDDEN_STYLE}`);
68
+ hiddenTextarea.value = targetElement.value || targetElement.placeholder || '';
69
+
70
+ let height = hiddenTextarea.scrollHeight;
71
+ const result = {} as TextAreaHeight;
72
+
73
+ if (boxSizing === 'border-box') {
74
+ height = height + borderSize;
75
+ } else if (boxSizing === 'content-box') {
76
+ height = height - paddingSize;
77
+ }
78
+
79
+ hiddenTextarea.value = '';
80
+ const singleRowHeight = hiddenTextarea.scrollHeight - paddingSize;
81
+
82
+ if (isNumber(minRows)) {
83
+ let minHeight = singleRowHeight * minRows;
84
+ if (boxSizing === 'border-box') {
85
+ minHeight = minHeight + paddingSize + borderSize;
86
+ }
87
+ height = Math.max(minHeight, height);
88
+ result.minHeight = `${minHeight}px`;
89
+ }
90
+ if (isNumber(maxRows)) {
91
+ let maxHeight = singleRowHeight * maxRows;
92
+ if (boxSizing === 'border-box') {
93
+ maxHeight = maxHeight + paddingSize + borderSize;
94
+ }
95
+ height = Math.min(maxHeight, height);
96
+ }
97
+ result.height = `${height}px`;
98
+ hiddenTextarea.parentNode?.removeChild(hiddenTextarea);
99
+ hiddenTextarea = undefined;
100
+
101
+ return result;
102
+ }
@@ -0,0 +1,4 @@
1
+ <template>
2
+ <div/>
3
+ </template>
4
+
@@ -0,0 +1,31 @@
1
+ $name: layout-footer;
2
+
3
+ @include set-root-css-vars($name, $layout-footer);
4
+
5
+ @function getCompCssVar($value) {
6
+ @return getCssVar($name, $value);
7
+ }
8
+
9
+ @include b($name) {
10
+ // noinspection CssInvalidPropertyValue
11
+ width: calc(100% - getCompCssVar('left'));
12
+ background-color: getCompCssVar('bg-color');
13
+ height: getCompCssVar('height');
14
+ border-top: getCompCssVar('border-top');
15
+ display: flex;
16
+ justify-content: space-between;
17
+ align-items: center;
18
+ flex: none;
19
+ overflow: hidden;
20
+ position: relative;
21
+ transition: left .5s;
22
+ left: getCompCssVar('left');
23
+
24
+ @include e(left) {
25
+ min-width: getCompCssVar('left-min-width');
26
+ }
27
+
28
+ @include e(right) {
29
+ min-width: getCompCssVar('right-min-width');
30
+ }
31
+ }
@@ -0,0 +1,3 @@
1
+ import LayoutFooter from './index.vue';
2
+
3
+ export { LayoutFooter };