@veltra/mobile 1.0.0 → 1.1.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 (245) hide show
  1. package/package.json +32 -6
  2. package/src/components/_internal/bottom-sheet/bottom-sheet.vue +81 -0
  3. package/src/components/_internal/bottom-sheet/index.ts +1 -0
  4. package/src/components/_internal/bottom-sheet/style.scss +116 -0
  5. package/src/components/_internal/bottom-sheet/style.ts +1 -0
  6. package/src/components/_internal/overlay-container.ts +34 -0
  7. package/src/components/avatar/avatar.vue +44 -0
  8. package/src/components/avatar/index.ts +1 -0
  9. package/src/components/avatar/style.scss +53 -0
  10. package/src/components/avatar/style.ts +1 -0
  11. package/src/components/badge/badge.vue +59 -0
  12. package/src/components/badge/index.ts +1 -0
  13. package/src/components/badge/style.scss +62 -0
  14. package/src/components/badge/style.ts +1 -0
  15. package/src/components/button/button.vue +76 -0
  16. package/src/components/button/index.ts +1 -0
  17. package/src/components/button/style.scss +207 -0
  18. package/src/components/button/style.ts +1 -0
  19. package/src/components/card/card.vue +24 -0
  20. package/src/components/card/index.ts +1 -0
  21. package/src/components/card/style.scss +35 -0
  22. package/src/components/card/style.ts +1 -0
  23. package/src/components/cascade/cascade.vue +595 -0
  24. package/src/components/cascade/index.ts +1 -0
  25. package/src/components/cascade/node.ts +29 -0
  26. package/src/components/cascade/style.scss +424 -0
  27. package/src/components/cascade/style.ts +2 -0
  28. package/src/components/check-tag/check-tag.vue +35 -0
  29. package/src/components/check-tag/index.ts +1 -0
  30. package/src/components/check-tag/style.scss +46 -0
  31. package/src/components/check-tag/style.ts +1 -0
  32. package/src/components/checkbox/checkbox.vue +67 -0
  33. package/src/components/checkbox/index.ts +1 -0
  34. package/src/components/checkbox/style.scss +132 -0
  35. package/src/components/checkbox/style.ts +2 -0
  36. package/src/components/checkbox-group/checkbox-group.vue +94 -0
  37. package/src/components/checkbox-group/index.ts +1 -0
  38. package/src/components/checkbox-group/style.scss +57 -0
  39. package/src/components/checkbox-group/style.ts +2 -0
  40. package/src/components/collapse/collapse-item.vue +134 -0
  41. package/src/components/collapse/collapse.vue +117 -0
  42. package/src/components/collapse/di.ts +18 -0
  43. package/src/components/collapse/index.ts +3 -0
  44. package/src/components/collapse/style.scss +157 -0
  45. package/src/components/collapse/style.ts +1 -0
  46. package/src/components/date-picker/date-picker.vue +326 -0
  47. package/src/components/date-picker/index.ts +1 -0
  48. package/src/components/date-picker/style.scss +236 -0
  49. package/src/components/date-picker/style.ts +2 -0
  50. package/src/components/descriptions/descriptions-item.vue +12 -0
  51. package/src/components/descriptions/descriptions.vue +50 -0
  52. package/src/components/descriptions/index.ts +2 -0
  53. package/src/components/descriptions/style.scss +120 -0
  54. package/src/components/descriptions/style.ts +1 -0
  55. package/src/components/dialog/dialog.vue +143 -0
  56. package/src/components/dialog/index.ts +1 -0
  57. package/src/components/dialog/style.scss +163 -0
  58. package/src/components/dialog/style.ts +4 -0
  59. package/src/components/divider/divider.vue +29 -0
  60. package/src/components/divider/index.ts +1 -0
  61. package/src/components/divider/style.scss +91 -0
  62. package/src/components/divider/style.ts +1 -0
  63. package/src/components/drawer/drawer.vue +168 -0
  64. package/src/components/drawer/index.ts +1 -0
  65. package/src/components/drawer/style.scss +240 -0
  66. package/src/components/drawer/style.ts +2 -0
  67. package/src/components/empty/empty.vue +22 -0
  68. package/src/components/empty/index.ts +1 -0
  69. package/src/components/empty/style.scss +36 -0
  70. package/src/components/empty/style.ts +1 -0
  71. package/src/components/form/form.vue +119 -0
  72. package/src/components/form/index.ts +1 -0
  73. package/src/components/form/is-field-modified.ts +16 -0
  74. package/src/components/form/style.scss +58 -0
  75. package/src/components/form/style.ts +2 -0
  76. package/src/components/form/use-form-fields.ts +115 -0
  77. package/src/components/form/use-node-interceptor.ts +101 -0
  78. package/src/components/form-item/form-item.vue +171 -0
  79. package/src/components/form-item/helper.ts +9 -0
  80. package/src/components/form-item/index.ts +1 -0
  81. package/src/components/form-item/style.scss +121 -0
  82. package/src/components/form-item/style.ts +1 -0
  83. package/src/components/form-item/validate.ts +131 -0
  84. package/src/components/icon/icon.vue +23 -0
  85. package/src/components/icon/index.ts +1 -0
  86. package/src/components/icon/style.scss +37 -0
  87. package/src/components/icon/style.ts +1 -0
  88. package/src/components/input/index.ts +1 -0
  89. package/src/components/input/input.vue +187 -0
  90. package/src/components/input/style.scss +121 -0
  91. package/src/components/input/style.ts +1 -0
  92. package/src/components/list/index.ts +3 -0
  93. package/src/components/list/list-item.vue +20 -0
  94. package/src/components/list/list.vue +20 -0
  95. package/src/components/list/style.scss +50 -0
  96. package/src/components/list/style.ts +1 -0
  97. package/src/components/loading/directive.ts +34 -0
  98. package/src/components/loading/index.ts +3 -0
  99. package/src/components/loading/loading.vue +25 -0
  100. package/src/components/loading/style.scss +179 -0
  101. package/src/components/loading/style.ts +2 -0
  102. package/src/components/message/helper.ts +28 -0
  103. package/src/components/message/index.ts +3 -0
  104. package/src/components/message/message-box.vue +31 -0
  105. package/src/components/message/message.ts +122 -0
  106. package/src/components/message/message.vue +54 -0
  107. package/src/components/message/style.scss +130 -0
  108. package/src/components/message/style.ts +1 -0
  109. package/src/components/message-confirm/index.ts +3 -0
  110. package/src/components/message-confirm/message-confirm-box.vue +36 -0
  111. package/src/components/message-confirm/message-confirm.ts +139 -0
  112. package/src/components/message-confirm/message-confirm.vue +53 -0
  113. package/src/components/message-confirm/style.scss +138 -0
  114. package/src/components/message-confirm/style.ts +1 -0
  115. package/src/components/multi-select/index.ts +1 -0
  116. package/src/components/multi-select/multi-select.vue +410 -0
  117. package/src/components/multi-select/style.scss +376 -0
  118. package/src/components/multi-select/style.ts +2 -0
  119. package/src/components/number-input/index.ts +1 -0
  120. package/src/components/number-input/number-input.vue +407 -0
  121. package/src/components/number-input/style.scss +118 -0
  122. package/src/components/number-input/style.ts +2 -0
  123. package/src/components/password-input/index.ts +1 -0
  124. package/src/components/password-input/password-input.vue +134 -0
  125. package/src/components/password-input/style.scss +40 -0
  126. package/src/components/password-input/style.ts +2 -0
  127. package/src/components/progress/index.ts +1 -0
  128. package/src/components/progress/progress.vue +90 -0
  129. package/src/components/progress/style.scss +73 -0
  130. package/src/components/progress/style.ts +1 -0
  131. package/src/components/radio/index.ts +1 -0
  132. package/src/components/radio/radio.vue +57 -0
  133. package/src/components/radio/style.scss +113 -0
  134. package/src/components/radio/style.ts +1 -0
  135. package/src/components/radio-group/index.ts +1 -0
  136. package/src/components/radio-group/radio-group.vue +60 -0
  137. package/src/components/radio-group/style.scss +29 -0
  138. package/src/components/radio-group/style.ts +2 -0
  139. package/src/components/segment/index.ts +1 -0
  140. package/src/components/segment/segment.vue +121 -0
  141. package/src/components/segment/style.scss +118 -0
  142. package/src/components/segment/style.ts +1 -0
  143. package/src/components/select/index.ts +1 -0
  144. package/src/components/select/select.vue +278 -0
  145. package/src/components/select/style.scss +237 -0
  146. package/src/components/select/style.ts +2 -0
  147. package/src/components/select/use-options.ts +195 -0
  148. package/src/components/skeleton/index.ts +1 -0
  149. package/src/components/skeleton/skeleton.vue +37 -0
  150. package/src/components/skeleton/style.scss +95 -0
  151. package/src/components/skeleton/style.ts +1 -0
  152. package/src/components/space/index.ts +1 -0
  153. package/src/components/space/space.vue +45 -0
  154. package/src/components/space/style.scss +41 -0
  155. package/src/components/space/style.ts +1 -0
  156. package/src/components/steps/index.ts +1 -0
  157. package/src/components/steps/steps.vue +114 -0
  158. package/src/components/steps/style.scss +231 -0
  159. package/src/components/steps/style.ts +1 -0
  160. package/src/components/switch/index.ts +1 -0
  161. package/src/components/switch/style.scss +137 -0
  162. package/src/components/switch/style.ts +1 -0
  163. package/src/components/switch/switch.vue +63 -0
  164. package/src/components/tabs/index.ts +1 -0
  165. package/src/components/tabs/style.scss +285 -0
  166. package/src/components/tabs/style.ts +1 -0
  167. package/src/components/tabs/tabs.vue +127 -0
  168. package/src/components/tag/index.ts +1 -0
  169. package/src/components/tag/style.scss +114 -0
  170. package/src/components/tag/style.ts +1 -0
  171. package/src/components/tag/tag.vue +49 -0
  172. package/src/components/text/index.ts +1 -0
  173. package/src/components/text/style.scss +63 -0
  174. package/src/components/text/style.ts +1 -0
  175. package/src/components/text/text.vue +63 -0
  176. package/src/components/textarea/index.ts +1 -0
  177. package/src/components/textarea/style.scss +124 -0
  178. package/src/components/textarea/style.ts +1 -0
  179. package/src/components/textarea/textarea.vue +121 -0
  180. package/src/components/textarea/utils.ts +11 -0
  181. package/src/components/time-picker/index.ts +1 -0
  182. package/src/components/time-picker/style.scss +216 -0
  183. package/src/components/time-picker/style.ts +2 -0
  184. package/src/components/time-picker/time-picker.vue +263 -0
  185. package/src/components/timeline/index.ts +2 -0
  186. package/src/components/timeline/style.scss +107 -0
  187. package/src/components/timeline/style.ts +1 -0
  188. package/src/components/timeline/timeline-item.vue +43 -0
  189. package/src/components/timeline/timeline.vue +16 -0
  190. package/src/components/uploader/index.ts +1 -0
  191. package/src/components/uploader/style.scss +220 -0
  192. package/src/components/uploader/style.ts +1 -0
  193. package/src/components/uploader/uploader.vue +306 -0
  194. package/src/env.d.ts +7 -0
  195. package/src/index.ts +99 -1
  196. package/src/shared/bem.ts +12 -0
  197. package/src/shared/use-scroll-lock.ts +111 -0
  198. package/src/shared/use-touch-gesture.ts +150 -0
  199. package/src/styles/_tokens.scss +129 -0
  200. package/src/types/avatar.ts +31 -0
  201. package/src/types/badge.ts +28 -0
  202. package/src/types/button.ts +48 -0
  203. package/src/types/card.ts +16 -0
  204. package/src/types/cascade.ts +87 -0
  205. package/src/types/check-tag.ts +24 -0
  206. package/src/types/checkbox-group.ts +20 -0
  207. package/src/types/checkbox.ts +15 -0
  208. package/src/types/collapse.ts +79 -0
  209. package/src/types/date-picker.ts +39 -0
  210. package/src/types/descriptions.ts +22 -0
  211. package/src/types/dialog.ts +54 -0
  212. package/src/types/divider.ts +14 -0
  213. package/src/types/drawer.ts +38 -0
  214. package/src/types/empty.ts +19 -0
  215. package/src/types/form-item.ts +22 -0
  216. package/src/types/form.ts +54 -0
  217. package/src/types/icon.ts +10 -0
  218. package/src/types/input.ts +51 -0
  219. package/src/types/list.ts +13 -0
  220. package/src/types/loading.ts +20 -0
  221. package/src/types/message-confirm.ts +72 -0
  222. package/src/types/message.ts +71 -0
  223. package/src/types/multi-select.ts +38 -0
  224. package/src/types/number-input.ts +32 -0
  225. package/src/types/password-input.ts +19 -0
  226. package/src/types/progress.ts +22 -0
  227. package/src/types/radio-group.ts +33 -0
  228. package/src/types/radio.ts +18 -0
  229. package/src/types/segment.ts +42 -0
  230. package/src/types/select.ts +63 -0
  231. package/src/types/skeleton.ts +29 -0
  232. package/src/types/space.ts +22 -0
  233. package/src/types/steps.ts +67 -0
  234. package/src/types/switch.ts +17 -0
  235. package/src/types/tabs.ts +63 -0
  236. package/src/types/tag.ts +19 -0
  237. package/src/types/text.ts +28 -0
  238. package/src/types/textarea.ts +76 -0
  239. package/src/types/time-picker.ts +40 -0
  240. package/src/types/timeline.ts +15 -0
  241. package/src/types/uploader.ts +50 -0
  242. package/.turbo/turbo-build.log +0 -2
  243. package/.turbo/turbo-check-types.log +0 -1
  244. package/tsconfig.json +0 -12
  245. package/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1 @@
1
+ export { default as USkeleton } from './skeleton.vue'
@@ -0,0 +1,37 @@
1
+ <template>
2
+ <div v-if="loading" :class="className">
3
+ <span v-if="avatar" :class="cls.e('avatar')" />
4
+ <div :class="cls.e('content')">
5
+ <span v-if="title" :class="cls.e('title')" />
6
+ <template v-if="paragraph">
7
+ <span v-for="i in rows" :key="i" :class="cls.e('paragraph')" />
8
+ </template>
9
+ <span v-if="button" :class="cls.e('button')" />
10
+ </div>
11
+ </div>
12
+ <slot v-else />
13
+ </template>
14
+
15
+ <script lang="ts" setup>
16
+ import { computed } from 'vue'
17
+
18
+ import { bem } from '../../shared/bem'
19
+ import type { SkeletonProps } from '../../types/skeleton'
20
+
21
+ defineOptions({ name: 'USkeleton' })
22
+
23
+ const {
24
+ loading = true,
25
+ avatar = false,
26
+ title = true,
27
+ paragraph = true,
28
+ rows = 3,
29
+ button = false,
30
+ round = false,
31
+ animated = false
32
+ } = defineProps<SkeletonProps>()
33
+
34
+ const cls = bem('skeleton')
35
+
36
+ const className = computed(() => [cls.b, bem.is('animated', animated), bem.is('round', round)])
37
+ </script>
@@ -0,0 +1,95 @@
1
+ @use 'pkg:@veltra/styles/mixins' as m with ($namespace: um);
2
+ @use 'pkg:@veltra/styles/functions' as fn;
3
+ @use '../../styles/tokens' as t;
4
+
5
+ // 方便拼接
6
+ $root-name: skeleton;
7
+
8
+ // 头像占位边长:移动端头像默认档
9
+ $avatar-size: t.use-var(avatar-size-default);
10
+ // 标题占位高度:主字号 + 4px(宽度按内容区比例收窄)
11
+ $title-height: calc(#{t.use-var(font-size-main)} + #{t.use-var(spacing-xs)});
12
+ $title-width: 33%;
13
+ // 段落行占位高度:辅助字号 + 4px(末行收窄模拟自然段落)
14
+ $paragraph-height: calc(#{t.use-var(font-size-secondary)} + #{t.use-var(spacing-xs)});
15
+ $paragraph-last-width: 60%;
16
+ // 按钮形态占位:宽度为触控热区两倍,高度走控件默认档
17
+ $button-width: calc(#{t.use-var(touch-target)} * 2);
18
+ // 呼吸动画一轮时长(token 无该量级档位,组件级常量)
19
+ $pulse-duration: 1.4s;
20
+
21
+ @include m.b($root-name) {
22
+ display: flex;
23
+ align-items: flex-start;
24
+ gap: t.use-var(spacing-md);
25
+
26
+ // 头像占位
27
+ @include m.e(avatar) {
28
+ flex: none;
29
+ width: $avatar-size;
30
+ height: $avatar-size;
31
+ border-radius: 50%;
32
+ background-color: fn.use-var(bg-color, hover);
33
+ }
34
+
35
+ // 文本区占位
36
+ @include m.e(content) {
37
+ flex: 1;
38
+ display: flex;
39
+ flex-direction: column;
40
+ gap: t.use-var(spacing-md);
41
+ min-width: 0;
42
+ }
43
+
44
+ // 标题占位
45
+ @include m.e(title) {
46
+ height: $title-height;
47
+ width: $title-width;
48
+ border-radius: t.control-radius(small);
49
+ background-color: fn.use-var(bg-color, hover);
50
+ }
51
+
52
+ // 段落占位:末行收窄模拟自然段落
53
+ @include m.e(paragraph) {
54
+ height: $paragraph-height;
55
+ border-radius: t.control-radius(small);
56
+ background-color: fn.use-var(bg-color, hover);
57
+
58
+ &:last-child {
59
+ width: $paragraph-last-width;
60
+ }
61
+ }
62
+
63
+ // 按钮形态占位:圆角与 button 控件档一致
64
+ @include m.e(button) {
65
+ width: $button-width;
66
+ height: t.control-height(default);
67
+ border-radius: t.control-radius(default);
68
+ background-color: fn.use-var(bg-color, hover);
69
+ }
70
+
71
+ // 胶囊形态:作用于标题 / 段落 / 按钮
72
+ @include m.is(round) {
73
+ @include m.bem($root-name, title paragraph button) {
74
+ border-radius: 999px;
75
+ }
76
+ }
77
+
78
+ // 动画:占位块呼吸明暗
79
+ @include m.is(animated) {
80
+ @include m.bem($root-name, avatar title paragraph button) {
81
+ animation: um-skeleton-pulse $pulse-duration ease-in-out infinite;
82
+ }
83
+ }
84
+ }
85
+
86
+ @keyframes um-skeleton-pulse {
87
+ 0%,
88
+ 100% {
89
+ opacity: 1;
90
+ }
91
+
92
+ 50% {
93
+ opacity: 0.4;
94
+ }
95
+ }
@@ -0,0 +1 @@
1
+ import './style.scss'
@@ -0,0 +1 @@
1
+ export { default as USpace } from './space.vue'
@@ -0,0 +1,45 @@
1
+ <template>
2
+ <div :class="classList" :style="style">
3
+ <slot />
4
+ </div>
5
+ </template>
6
+
7
+ <script lang="ts" setup>
8
+ import { computed } from 'vue'
9
+
10
+ import { bem } from '../../shared/bem'
11
+ import type { SpaceProps } from '../../types/space'
12
+
13
+ defineOptions({ name: 'USpace' })
14
+
15
+ const {
16
+ size = 'default',
17
+ direction = 'horizontal',
18
+ align = 'center',
19
+ wrap = false
20
+ } = defineProps<SpaceProps>()
21
+
22
+ const cls = bem('space')
23
+
24
+ const classList = computed(() => [
25
+ cls.b,
26
+ cls.m(direction),
27
+ typeof size === 'string' && cls.m(size),
28
+ cls.m('align-' + align),
29
+ bem.is('wrap', wrap)
30
+ ])
31
+
32
+ /** 间距档走 token class;数字与二元组写内联 gap */
33
+ const style = computed(() => {
34
+ if (typeof size === 'number') {
35
+ return { gap: `${size}px` }
36
+ }
37
+
38
+ if (Array.isArray(size)) {
39
+ const [horizontal, vertical] = size
40
+ return { columnGap: `${horizontal}px`, rowGap: `${vertical}px` }
41
+ }
42
+
43
+ return undefined
44
+ })
45
+ </script>
@@ -0,0 +1,41 @@
1
+ @use 'pkg:@veltra/styles/mixins' as m with ($namespace: um);
2
+ @use '../../styles/tokens' as t;
3
+
4
+ // 方便拼接
5
+ $root-name: space;
6
+
7
+ @include m.b($root-name) {
8
+ display: inline-flex;
9
+ gap: t.use-var(spacing-md);
10
+ align-items: center;
11
+
12
+ @include m.m(vertical) {
13
+ flex-direction: column;
14
+ }
15
+
16
+ @include m.is(wrap) {
17
+ flex-wrap: wrap;
18
+ }
19
+
20
+ // 间距档:走 --um-* 间距刻度 token
21
+ @include m.m(small) {
22
+ gap: t.use-var(spacing-sm);
23
+ }
24
+
25
+ @include m.m(large) {
26
+ gap: t.use-var(spacing-lg);
27
+ }
28
+
29
+ // 交叉轴对齐
30
+ @include m.m(align-start) {
31
+ align-items: flex-start;
32
+ }
33
+
34
+ @include m.m(align-end) {
35
+ align-items: flex-end;
36
+ }
37
+
38
+ @include m.m(align-baseline) {
39
+ align-items: baseline;
40
+ }
41
+ }
@@ -0,0 +1 @@
1
+ import './style.scss'
@@ -0,0 +1 @@
1
+ export { default as USteps } from './steps.vue'
@@ -0,0 +1,114 @@
1
+ <template>
2
+ <ol :class="className" ref="steps">
3
+ <li
4
+ v-for="(item, index) in items"
5
+ :key="index"
6
+ :class="[
7
+ cls.e('item'),
8
+ bem.is('current', index === currentIndex),
9
+ bem.is('finished', currentIndex === undefined || index < currentIndex)
10
+ ]"
11
+ @click="handleStepClick(item, index)"
12
+ >
13
+ <div :class="cls.e('node')">
14
+ <i :class="cls.e('link')" v-if="index !== items.length - 1"></i>
15
+
16
+ <span :class="cls.e('icon')">
17
+ <slot name="icon" :item="item" :index="index">
18
+ <Check v-if="currentIndex === undefined || index < currentIndex" />
19
+
20
+ <template v-else>
21
+ {{ index + 1 }}
22
+ </template>
23
+ </slot>
24
+ </span>
25
+ </div>
26
+
27
+ <div :class="cls.e('content')">
28
+ <slot name="content" :item="item" :index="index">
29
+ {{ item[labelKey] }}
30
+ </slot>
31
+ </div>
32
+ </li>
33
+ </ol>
34
+ </template>
35
+
36
+ <script lang="ts" setup>
37
+ import { Check } from '@veltra/icons/normal'
38
+ import { fieldKey } from '@veltra/utils'
39
+ import { computed, useTemplateRef, watch } from 'vue'
40
+
41
+ import { bem } from '../../shared/bem'
42
+ import type { StepsEmits, StepsProps, StepsSlotScope } from '../../types/steps'
43
+
44
+ defineOptions({ name: 'USteps' })
45
+
46
+ const props = withDefaults(defineProps<StepsProps>(), {
47
+ direction: 'horizontal',
48
+ finishedStepType: 'success',
49
+ labelKey: 'label'
50
+ })
51
+
52
+ const emit = defineEmits<StepsEmits>()
53
+
54
+ defineSlots<{ icon?: (scope: StepsSlotScope) => any; content?: (scope: StepsSlotScope) => any }>()
55
+
56
+ const cls = bem('steps')
57
+
58
+ const labelKey = computed(() => fieldKey(props.labelKey, 'label'))
59
+
60
+ const className = computed(() => {
61
+ const { direction, currentStepType, finishedStepType } = props
62
+ const ret: string[] = [
63
+ cls.b,
64
+ bem.is(direction),
65
+ cls.m(props.size ?? 'default'),
66
+ bem.is('align-center', props.alignCenter),
67
+ cls.em('finished', finishedStepType)
68
+ ]
69
+ currentStepType && ret.push(cls.em('current', currentStepType))
70
+ return ret
71
+ })
72
+
73
+ const stepsRef = useTemplateRef('steps')
74
+
75
+ const currentToIndexMap = computed<Record<string, number> | undefined>(() => {
76
+ const { currentKey, items } = props
77
+ if (!currentKey) return undefined
78
+ return items.reduce(
79
+ (acc, item, index) => {
80
+ acc[item[currentKey]] = index
81
+ return acc
82
+ },
83
+ {} as Record<string, number>
84
+ )
85
+ })
86
+
87
+ /** 当前索引 */
88
+ const currentIndex = computed<number | undefined>(() => {
89
+ const { currentKey, current } = props
90
+ if (current === undefined) return undefined
91
+
92
+ if (currentKey) {
93
+ return currentToIndexMap.value?.[current]
94
+ }
95
+
96
+ if (typeof current !== 'number') return undefined
97
+ return Math.min(Math.max(current, 0), props.items.length - 1)
98
+ })
99
+
100
+ // 横向滚动形态下把当前步骤滚入视野
101
+ watch(currentIndex, (index) => {
102
+ if (index === undefined || props.direction === 'vertical') return
103
+ const step = stepsRef.value?.children[index]
104
+ if (step) {
105
+ step.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'center' })
106
+ }
107
+ })
108
+
109
+ // 点击步骤项
110
+ function handleStepClick(item: Record<string, any>, index: number) {
111
+ emit('item-click', item, index)
112
+ emit('update:current', props.currentKey ? item[props.currentKey] : index)
113
+ }
114
+ </script>
@@ -0,0 +1,231 @@
1
+ @use 'pkg:@veltra/styles/mixins' as m with ($namespace: um);
2
+ @use 'pkg:@veltra/styles/functions' as fn;
3
+ @use 'pkg:@veltra/styles/vars';
4
+ @use '../../styles/tokens' as t;
5
+
6
+ // 方便拼接
7
+ $root-name: steps;
8
+
9
+ // 触控可读的下限:圆圈直径与点击热区不小于该值
10
+ $icon-min: 40px;
11
+
12
+ @include m.b($root-name) {
13
+ padding: 0;
14
+ margin: 0;
15
+ list-style: none;
16
+ font-size: t.use-var('font-size-main');
17
+ color: fn.use-var(text-color, main);
18
+ -webkit-tap-highlight-color: transparent;
19
+
20
+ @each $type, $_ in vars.$color-types {
21
+ @include m.em(finished, $type) {
22
+ @include m.bem($root-name, item) {
23
+ @include m.is(finished) {
24
+ color: fn.use-var(color, $type);
25
+ }
26
+ }
27
+ }
28
+ @include m.em(current, $type) {
29
+ @include m.bem($root-name, item) {
30
+ @include m.is(current) {
31
+ color: fn.use-var(color, $type);
32
+ }
33
+ }
34
+ }
35
+ }
36
+
37
+ /** 步骤项(整项可点击,热区高度不小于 44px) */
38
+ @include m.e(item) {
39
+ font-weight: 600;
40
+ color: fn.use-var(text-color, placeholder);
41
+ min-height: t.use-var('touch-target');
42
+ border-radius: t.control-radius(default);
43
+ -webkit-tap-highlight-color: transparent;
44
+ transition: background-color fn.use-var(transition, fast) fn.use-var(transition, ease);
45
+
46
+ // 可点项按压反馈(移动端无 hover)
47
+ &:active {
48
+ background-color: fn.use-var(bg-color, hover);
49
+ }
50
+ }
51
+
52
+ @include m.e(node) {
53
+ position: relative;
54
+ }
55
+
56
+ @include m.e(link) {
57
+ background-color: currentColor;
58
+ position: absolute;
59
+ margin: auto;
60
+ z-index: 0;
61
+ }
62
+
63
+ @keyframes um-steps-link-flow-horizontal {
64
+ 0% {
65
+ background-position: 0 0;
66
+ }
67
+ 100% {
68
+ // 位移是虚线周期(8px)的整数倍,保证流动动画首尾衔接
69
+ background-position: 16px 0;
70
+ }
71
+ }
72
+
73
+ @keyframes um-steps-link-flow-vertical {
74
+ 0% {
75
+ background-position: 0 0;
76
+ }
77
+ 100% {
78
+ background-position: 0 16px;
79
+ }
80
+ }
81
+
82
+ @keyframes um-steps-icon-breathing {
83
+ 0% {
84
+ color: fn.use-var(text-color, placeholder);
85
+ border-color: fn.use-var(text-color, placeholder);
86
+ }
87
+ 50% {
88
+ color: currentColor;
89
+ border-color: currentColor;
90
+ }
91
+ 100% {
92
+ color: fn.use-var(text-color, placeholder);
93
+ border-color: fn.use-var(text-color, placeholder);
94
+ }
95
+ }
96
+
97
+ @include m.e(icon) {
98
+ display: flex;
99
+ border: 2px solid currentColor;
100
+ border-radius: 50%;
101
+ align-items: center;
102
+ justify-content: center;
103
+ background-color: fn.use-var(bg-color, top);
104
+ position: relative;
105
+ z-index: 1;
106
+ box-sizing: border-box;
107
+ transition: opacity 0.3s ease;
108
+
109
+ svg {
110
+ width: 1em;
111
+ height: 1em;
112
+ fill: currentColor;
113
+ }
114
+ }
115
+
116
+ @include m.bem($root-name, item) {
117
+ @include m.is(current) {
118
+ @include m.bem($root-name, icon) {
119
+ animation: um-steps-icon-breathing 2s ease-in-out infinite;
120
+ will-change: opacity;
121
+ }
122
+ }
123
+ }
124
+
125
+ /** 步骤项描述 */
126
+ @include m.e(content) {
127
+ padding: t.use-var('spacing-sm') 0;
128
+ word-break: break-word;
129
+ }
130
+
131
+ // 横向滚动形态:窄屏不压缩步骤,超出横向滚动
132
+ @include m.is(horizontal) {
133
+ display: flex;
134
+ overflow-x: auto;
135
+ scrollbar-width: none;
136
+ -webkit-overflow-scrolling: touch;
137
+
138
+ &::-webkit-scrollbar {
139
+ display: none;
140
+ }
141
+
142
+ @include m.bem($root-name, item) {
143
+ flex: 1 0 auto;
144
+ min-width: 100px;
145
+
146
+ @include m.is(current) {
147
+ @include m.bem($root-name, link) {
148
+ background-color: transparent;
149
+ background-image: linear-gradient(
150
+ to right,
151
+ currentColor 0%,
152
+ currentColor 50%,
153
+ transparent 50%,
154
+ transparent 100%
155
+ );
156
+ background-size: 8px 2px;
157
+ animation: um-steps-link-flow-horizontal 1s linear infinite;
158
+ }
159
+ }
160
+ }
161
+
162
+ @include m.bem($root-name, link) {
163
+ width: 100%;
164
+ height: 2px;
165
+ left: 0;
166
+ top: 0;
167
+ bottom: 0;
168
+ }
169
+
170
+ @include m.is(align-center) {
171
+ @include m.bem($root-name, (content, node)) {
172
+ display: flex;
173
+ align-items: center;
174
+ justify-content: center;
175
+ }
176
+
177
+ @include m.bem($root-name, link) {
178
+ left: 50%;
179
+ }
180
+ }
181
+ }
182
+
183
+ // 纵向形态:窄屏主形态,节点在左、内容在右
184
+ @include m.is(vertical) {
185
+ @include m.bem($root-name, item) {
186
+ @include m.flex($align: stretch, $wrap: nowrap);
187
+ gap: t.use-var('spacing-md');
188
+ padding-bottom: t.use-var('spacing-md');
189
+
190
+ &:last-child {
191
+ padding-bottom: 0;
192
+ }
193
+
194
+ @include m.is(current) {
195
+ @include m.bem($root-name, link) {
196
+ background-color: transparent;
197
+ background-image: linear-gradient(
198
+ to bottom,
199
+ currentColor 0%,
200
+ currentColor 50%,
201
+ transparent 50%,
202
+ transparent 100%
203
+ );
204
+ background-size: 2px 8px;
205
+ animation: um-steps-link-flow-vertical 1s linear infinite;
206
+ }
207
+ }
208
+ }
209
+
210
+ @include m.bem($root-name, link) {
211
+ height: 100%;
212
+ width: 2px;
213
+ top: 0;
214
+ left: 0;
215
+ right: 0;
216
+ }
217
+
218
+ // 长文本在窄屏换行而非撑破容器
219
+ @include m.bem($root-name, content) {
220
+ min-width: 0;
221
+ }
222
+ }
223
+
224
+ @include m.size using ($size) {
225
+ @include m.bem($root-name, icon) {
226
+ font-size: t.use-var('font-size-main');
227
+ width: max(t.control-height($size), $icon-min);
228
+ height: max(t.control-height($size), $icon-min);
229
+ }
230
+ }
231
+ }
@@ -0,0 +1 @@
1
+ import './style.scss'
@@ -0,0 +1 @@
1
+ export { default as USwitch } from './switch.vue'