@veltra/desktop 1.14.1 → 1.15.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 (163) hide show
  1. package/dist/components/auto-complete/style.d.ts +0 -1
  2. package/dist/components/cascade/cascade.js +13 -19
  3. package/dist/components/cascade/cascade.js.map +1 -1
  4. package/dist/components/cascade/style.d.ts +1 -3
  5. package/dist/components/checkbox/checkbox.js +5 -11
  6. package/dist/components/checkbox/checkbox.js.map +1 -1
  7. package/dist/components/checkbox/style.d.ts +1 -1
  8. package/dist/components/checkbox/style.js +0 -1
  9. package/dist/components/checkbox-group/style.d.ts +1 -1
  10. package/dist/components/chip/chip.js +63 -0
  11. package/dist/components/chip/chip.js.map +1 -0
  12. package/dist/components/chip/style.d.ts +1 -0
  13. package/dist/components/chip/style.js +1 -0
  14. package/dist/components/chip/style2.css +90 -0
  15. package/dist/components/chip-group/chip-group.js +279 -0
  16. package/dist/components/chip-group/chip-group.js.map +1 -0
  17. package/dist/components/chip-group/reveal.js +80 -0
  18. package/dist/components/chip-group/reveal.js.map +1 -0
  19. package/dist/components/chip-group/style.d.ts +1 -0
  20. package/dist/components/chip-group/style.js +2 -0
  21. package/dist/components/chip-group/style2.css +68 -0
  22. package/dist/components/condition-editor/style.d.ts +0 -1
  23. package/dist/components/date-picker/style.d.ts +1 -2
  24. package/dist/components/date-range-picker/date-range-picker.js +14 -20
  25. package/dist/components/date-range-picker/date-range-picker.js.map +1 -1
  26. package/dist/components/dialog/dialog.js +5 -2
  27. package/dist/components/dialog/dialog.js.map +1 -1
  28. package/dist/components/dialog/style2.css +0 -10
  29. package/dist/components/dialog/use-maximum.js +77 -20
  30. package/dist/components/dialog/use-maximum.js.map +1 -1
  31. package/dist/components/drawer/style2.css +4 -4
  32. package/dist/components/form-item/style2.css +1 -1
  33. package/dist/components/index.d.ts +32 -30
  34. package/dist/components/index.js +63 -59
  35. package/dist/components/index.js.map +1 -1
  36. package/dist/components/input/input.js.map +1 -1
  37. package/dist/components/input/input.vue_vue_type_script_setup_true_lang.js +13 -19
  38. package/dist/components/input/input.vue_vue_type_script_setup_true_lang.js.map +1 -1
  39. package/dist/components/input/style.d.ts +1 -1
  40. package/dist/components/input/style.js +0 -1
  41. package/dist/components/message/style2.css +13 -0
  42. package/dist/components/message-confirm/style2.css +10 -0
  43. package/dist/components/multi-select/multi-select.js +13 -19
  44. package/dist/components/multi-select/multi-select.js.map +1 -1
  45. package/dist/components/multi-select/style.d.ts +1 -4
  46. package/dist/components/multi-select/style.js +0 -1
  47. package/dist/components/multi-tree-select/multi-tree-select.js +10 -19
  48. package/dist/components/multi-tree-select/multi-tree-select.js.map +1 -1
  49. package/dist/components/multi-tree-select/style.d.ts +1 -5
  50. package/dist/components/multi-tree-select/style.js +0 -1
  51. package/dist/components/nav/nav-sub.js +56 -51
  52. package/dist/components/nav/nav-sub.js.map +1 -1
  53. package/dist/components/notification/notification-box.js +4 -2
  54. package/dist/components/notification/notification-box.js.map +1 -1
  55. package/dist/components/notification/style2.css +16 -0
  56. package/dist/components/number-input/style.d.ts +0 -1
  57. package/dist/components/palette/style.d.ts +1 -2
  58. package/dist/components/password-input/style.d.ts +1 -1
  59. package/dist/components/radio/radio.js +5 -8
  60. package/dist/components/radio/radio.js.map +1 -1
  61. package/dist/components/radio/style.d.ts +1 -1
  62. package/dist/components/radio/style.js +0 -1
  63. package/dist/components/radio-group/style.d.ts +1 -1
  64. package/dist/components/rich-text-editor/style2.css +2 -2
  65. package/dist/components/scroll/style2.css +27 -13
  66. package/dist/components/segment/segment.js +50 -3
  67. package/dist/components/segment/segment.js.map +1 -1
  68. package/dist/components/segment/style2.css +20 -2
  69. package/dist/components/select/select.js +24 -25
  70. package/dist/components/select/select.js.map +1 -1
  71. package/dist/components/select/style.d.ts +0 -1
  72. package/dist/components/switch/style2.css +1 -1
  73. package/dist/components/table/style.d.ts +1 -3
  74. package/dist/components/tabs/style.d.ts +1 -2
  75. package/dist/components/tabs/style.js +0 -1
  76. package/dist/components/tabs/style2.css +29 -0
  77. package/dist/components/tabs/tabs-horizontal.js +7 -3
  78. package/dist/components/tabs/tabs-horizontal.js.map +1 -1
  79. package/dist/components/tabs/tabs.js +2 -8
  80. package/dist/components/tabs/tabs.js.map +1 -1
  81. package/dist/components/tabs/use-tabs-bar.js +41 -9
  82. package/dist/components/tabs/use-tabs-bar.js.map +1 -1
  83. package/dist/components/tag/style2.css +3 -3
  84. package/dist/components/textarea/style.d.ts +1 -1
  85. package/dist/components/textarea/style.js +0 -1
  86. package/dist/components/textarea/textarea.js +7 -13
  87. package/dist/components/textarea/textarea.js.map +1 -1
  88. package/dist/components/theme/style.d.ts +0 -1
  89. package/dist/components/theme/style2.css +9 -5
  90. package/dist/components/time-picker/style.d.ts +1 -2
  91. package/dist/components/tip/style2.css +5 -5
  92. package/dist/components/tip/tip.js +22 -1
  93. package/dist/components/tip/tip.js.map +1 -1
  94. package/dist/components/transfer/style.d.ts +1 -2
  95. package/dist/components/tree/style.d.ts +1 -1
  96. package/dist/components/tree-select/style.d.ts +1 -3
  97. package/dist/components/tree-select/tree-select.js +24 -25
  98. package/dist/components/tree-select/tree-select.js.map +1 -1
  99. package/dist/index.d.ts +86 -82
  100. package/dist/index.js +84 -82
  101. package/dist/style.d.ts +0 -8
  102. package/dist/style.js +2 -0
  103. package/dist/types/chip-group.d.ts +35 -0
  104. package/dist/types/chip.d.ts +28 -0
  105. package/dist/types/index.d.ts +3 -1
  106. package/package.json +1 -1
  107. package/src/components/cascade/cascade.vue +9 -11
  108. package/src/components/checkbox/checkbox.vue +6 -8
  109. package/src/components/checkbox/style.ts +0 -1
  110. package/src/components/chip/__test__/chip.test.ts +69 -0
  111. package/src/components/chip/chip.vue +54 -0
  112. package/src/components/chip/index.ts +1 -0
  113. package/src/components/chip/style.scss +91 -0
  114. package/src/components/chip/style.ts +1 -0
  115. package/src/components/chip-group/__test__/chip-group.test.ts +411 -0
  116. package/src/components/chip-group/__test__/reveal.test.ts +74 -0
  117. package/src/components/chip-group/chip-group.vue +326 -0
  118. package/src/components/chip-group/index.ts +1 -0
  119. package/src/components/chip-group/reveal.ts +106 -0
  120. package/src/components/chip-group/style.scss +72 -0
  121. package/src/components/chip-group/style.ts +2 -0
  122. package/src/components/date-range-picker/date-range-picker.vue +10 -12
  123. package/src/components/dialog/dialog.vue +2 -1
  124. package/src/components/dialog/style.scss +0 -12
  125. package/src/components/dialog/use-maximum.ts +88 -28
  126. package/src/components/drawer/style.scss +1 -1
  127. package/src/components/form-item/style.scss +2 -2
  128. package/src/components/index.ts +4 -0
  129. package/src/components/input/input.vue +14 -16
  130. package/src/components/input/style.ts +0 -1
  131. package/src/components/message/style.scss +15 -0
  132. package/src/components/message-confirm/style.scss +14 -0
  133. package/src/components/multi-select/multi-select.vue +8 -10
  134. package/src/components/multi-select/style.ts +0 -1
  135. package/src/components/multi-tree-select/multi-tree-select.vue +8 -10
  136. package/src/components/multi-tree-select/style.ts +0 -1
  137. package/src/components/nav/nav-sub.vue +22 -11
  138. package/src/components/notification/notification-box.vue +5 -2
  139. package/src/components/notification/style.scss +18 -0
  140. package/src/components/radio/radio.vue +1 -3
  141. package/src/components/radio/style.ts +0 -1
  142. package/src/components/rich-text-editor/style.scss +7 -2
  143. package/src/components/scroll/style.scss +39 -20
  144. package/src/components/segment/segment.vue +44 -2
  145. package/src/components/segment/style.scss +22 -2
  146. package/src/components/select/select.vue +24 -19
  147. package/src/components/switch/style.scss +4 -1
  148. package/src/components/tabs/style.scss +35 -0
  149. package/src/components/tabs/style.ts +0 -1
  150. package/src/components/tabs/tabs-horizontal.vue +2 -1
  151. package/src/components/tabs/tabs.vue +4 -6
  152. package/src/components/tabs/use-tabs-bar.ts +55 -8
  153. package/src/components/tag/style.scss +4 -4
  154. package/src/components/textarea/style.ts +0 -1
  155. package/src/components/textarea/textarea.vue +7 -9
  156. package/src/components/theme/style.scss +25 -5
  157. package/src/components/tip/style.scss +5 -5
  158. package/src/components/tip/tip.vue +33 -1
  159. package/src/components/tree-select/tree-select.vue +21 -17
  160. package/src/style.ts +2 -0
  161. package/src/types/chip-group.ts +36 -0
  162. package/src/types/chip.ts +29 -0
  163. package/src/types/index.ts +2 -0
@@ -1,4 +1,3 @@
1
- import { useTransition } from '@veltra/compositions'
2
1
  import { type BEM, removeStyles, setStyles } from '@veltra/utils'
3
2
  import { shallowRef, type ShallowRef } from 'vue'
4
3
 
@@ -12,47 +11,108 @@ interface Returned {
12
11
  maximized: ShallowRef<boolean>
13
12
  /** 切换最大状态 */
14
13
  toggleMaximize: (maxim: boolean) => void
14
+ /** 关闭对话框时清掉 FLIP 内联 transform,避免与 fade-scale / spring 的 scale 叠乘 */
15
+ cancelMaximizeMotion: () => void
15
16
  }
16
17
 
17
- // 最大化过程
18
- // 1. 先设置一个高度才会有过渡动画
19
- // 2. 在下一个帧应用最大化时的类名
20
- // 3. 在进入动画结束时移除高度
18
+ interface Rect {
19
+ left: number
20
+ top: number
21
+ width: number
22
+ height: number
23
+ }
24
+
25
+ const ENTER_TO = 'dialog-maximize-enter-to'
26
+ const FLIP_MS = 250
27
+ const FLIP_TRANSITION = 'transform 250ms cubic-bezier(0.23, 1, 0.32, 1)'
28
+
29
+ function readRect(dom: HTMLElement): Rect {
30
+ const r = dom.getBoundingClientRect()
31
+ return { left: r.left, top: r.top, width: r.width, height: r.height }
32
+ }
33
+
34
+ /**
35
+ * transform-origin 为 0 0。CSS 变换从右往左应用:
36
+ * 先 scale,再 translate,把最大化后的布局框映回开始时的视觉矩形。
37
+ */
38
+ function invert(from: Rect, to: Rect): string {
39
+ const sx = to.width === 0 ? 1 : from.width / to.width
40
+ const sy = to.height === 0 ? 1 : from.height / to.height
41
+ const dx = from.left - to.left
42
+ const dy = from.top - to.top
43
+ return `translate(${dx}px, ${dy}px) scale(${sx}, ${sy})`
44
+ }
21
45
 
22
46
  export function useMaximum(options: Options): Returned {
23
47
  const { dialogRef } = options
24
-
25
48
  const maximized = shallowRef(false)
49
+ let flipToken = 0
50
+ let flipTimer: ReturnType<typeof setTimeout> | undefined
26
51
 
27
- let needRmoveHeight = false
52
+ function clearFlip(dom: HTMLElement) {
53
+ removeStyles(dom, ['transform', 'transform-origin', 'transition'])
54
+ }
28
55
 
29
- const maximizeTransition = useTransition('css', {
30
- target: dialogRef,
31
- name: 'dialog-maximize',
32
- keepEnterTo: true,
33
- afterLeave() {
34
- if (!maximized.value || !needRmoveHeight) return
35
- needRmoveHeight = false
36
- dialogRef.value && removeStyles(dialogRef.value, ['height'])
56
+ function cancelMaximizeMotion() {
57
+ flipToken += 1
58
+ if (flipTimer !== undefined) {
59
+ clearTimeout(flipTimer)
60
+ flipTimer = undefined
37
61
  }
38
- })
62
+ const dom = dialogRef.value
63
+ if (dom) clearFlip(dom)
64
+ }
65
+
66
+ function playFlip(dom: HTMLElement, from: Rect, to: Rect) {
67
+ const token = ++flipToken
68
+ if (flipTimer !== undefined) clearTimeout(flipTimer)
69
+
70
+ const same =
71
+ from.left === to.left &&
72
+ from.top === to.top &&
73
+ from.width === to.width &&
74
+ from.height === to.height
75
+
76
+ if (same || to.width === 0 || to.height === 0) {
77
+ clearFlip(dom)
78
+ return
79
+ }
80
+
81
+ setStyles(dom, { transformOrigin: '0 0', transform: invert(from, to), transition: 'none' })
82
+ void dom.offsetWidth
83
+ setStyles(dom, { transition: FLIP_TRANSITION, transform: 'none' })
84
+
85
+ const finish = () => {
86
+ if (token !== flipToken) return
87
+ flipToken += 1
88
+ if (flipTimer !== undefined) {
89
+ clearTimeout(flipTimer)
90
+ flipTimer = undefined
91
+ }
92
+ dom.removeEventListener('transitionend', onEnd)
93
+ clearFlip(dom)
94
+ }
95
+
96
+ const onEnd = (event: TransitionEvent) => {
97
+ if (event.target !== dom || event.propertyName !== 'transform') return
98
+ finish()
99
+ }
100
+
101
+ dom.addEventListener('transitionend', onEnd)
102
+ flipTimer = setTimeout(finish, FLIP_MS + 50)
103
+ }
39
104
 
40
- /** 切换最大化 */
41
105
  const toggleMaximize = (maxim: boolean): void => {
42
106
  maximized.value = maxim
43
107
  const dom = dialogRef.value
44
108
  if (!dom) return
45
- if (maxim) {
46
- // 先设置一个高度才会有过渡动画
47
- if (!dom.style.height) {
48
- needRmoveHeight = true
49
- setStyles(dom, { height: `${dom.offsetHeight}px` })
50
- }
51
- maximizeTransition.enter()
52
- } else {
53
- maximizeTransition.leave()
54
- }
109
+
110
+ const from = readRect(dom)
111
+ clearFlip(dom)
112
+ dom.classList.toggle(ENTER_TO, maxim)
113
+ const to = readRect(dom)
114
+ playFlip(dom, from, to)
55
115
  }
56
116
 
57
- return { maximized, toggleMaximize }
117
+ return { maximized, toggleMaximize, cancelMaximizeMotion }
58
118
  }
@@ -135,7 +135,7 @@ $direction-map: (
135
135
  $enter-duration: 0.28s;
136
136
  $leave-duration: 0.2s;
137
137
  $enter-ease: cubic-bezier(0.16, 1, 0.3, 1);
138
- $leave-ease: cubic-bezier(0.4, 0, 1, 1);
138
+ $leave-ease: cubic-bezier(0.16, 1, 0.3, 1);
139
139
 
140
140
  // 遮罩只淡透明度,不跟面板的位移曲线
141
141
  .drawer-fade-enter-active,
@@ -139,6 +139,6 @@ $root-name: form-item;
139
139
  .#{$root-name}-tips-enter-active,
140
140
  .#{$root-name}-tips-leave-active {
141
141
  transition:
142
- transform 0.15s cubic-bezier(0.01, 1.22, 0.43, 1.62),
143
- opacity 0.15s ease-out;
142
+ transform 0.15s cubic-bezier(0.23, 1, 0.32, 1),
143
+ opacity 0.15s cubic-bezier(0.23, 1, 0.32, 1);
144
144
  }
@@ -124,6 +124,10 @@ export * from './form-item'
124
124
 
125
125
  export * from './radio-group'
126
126
 
127
+ export * from './chip'
128
+
129
+ export * from './chip-group'
130
+
127
131
  export * from './checkbox-group'
128
132
 
129
133
  export * from './file-viewer'
@@ -29,22 +29,20 @@
29
29
  />
30
30
 
31
31
  <span :class="suffixClass" v-if="hasSuffix">
32
- <Transition name="zoom-in" mode="out-in">
33
- <UIcon
34
- v-if="showClear"
35
- :class="cls.e('clear')"
36
- title="清除"
37
- @click.stop="clearModelValue"
38
- key="clear"
39
- >
40
- <Close />
41
- </UIcon>
42
-
43
- <span v-else :class="cls.e('suffix-content')" @click="handleSuffixClick" key="suffix">
44
- {{ suffix }}
45
- <slot name="suffix"></slot>
46
- </span>
47
- </Transition>
32
+ <UIcon
33
+ v-if="showClear"
34
+ :class="cls.e('clear')"
35
+ title="清除"
36
+ @click.stop="clearModelValue"
37
+ key="clear"
38
+ >
39
+ <Close />
40
+ </UIcon>
41
+
42
+ <span v-else :class="cls.e('suffix-content')" @click="handleSuffixClick" key="suffix">
43
+ {{ suffix }}
44
+ <slot name="suffix"></slot>
45
+ </span>
48
46
  </span>
49
47
  </div>
50
48
 
@@ -1,3 +1,2 @@
1
1
  import '../icon/style'
2
- import '@veltra/styles/transitions/zoom-in.scss'
3
2
  import './style.scss'
@@ -87,3 +87,18 @@ $root-name: message;
87
87
  position: absolute;
88
88
  width: max-content;
89
89
  }
90
+
91
+ // 减弱动态效果:不位移、不缩放,堆叠重排也不滑动,只保留透明度
92
+ @media (prefers-reduced-motion: reduce) {
93
+ .message-move,
94
+ .message-enter-active,
95
+ .message-leave-active {
96
+ transition-property: opacity;
97
+ }
98
+
99
+ .message-enter-from,
100
+ .message-leave-to {
101
+ transform: none;
102
+ opacity: 0;
103
+ }
104
+ }
@@ -95,3 +95,17 @@ $root-name: message-confirm;
95
95
  transform: translateY(-40px);
96
96
  }
97
97
  }
98
+
99
+ // 减弱动态效果:确认框不位移,只保留透明度。根上的 opacity 过渡不能删。
100
+ @media (prefers-reduced-motion: reduce) {
101
+ @include m.bem($root-name, box) {
102
+ transition-property: opacity;
103
+ }
104
+
105
+ .#{$root-name}-enter-from,
106
+ .#{$root-name}-leave-to {
107
+ @include m.bem($root-name, box) {
108
+ transform: none;
109
+ }
110
+ }
111
+ }
@@ -46,17 +46,15 @@
46
46
  />
47
47
  </div>
48
48
 
49
- <transition name="zoom-in" mode="out-in">
50
- <u-icon
51
- v-if="clearable && model?.length && hovered && !disabled"
52
- :class="cls.e('clear')"
53
- @click.stop="handleClear"
54
- >
55
- <Close />
56
- </u-icon>
49
+ <u-icon
50
+ v-if="clearable && model?.length && hovered && !disabled"
51
+ :class="cls.e('clear')"
52
+ @click.stop="handleClear"
53
+ >
54
+ <Close />
55
+ </u-icon>
57
56
 
58
- <u-icon :class="cls.e('arrow')" v-else><ArrowDown /></u-icon>
59
- </transition>
57
+ <u-icon :class="cls.e('arrow')" v-else><ArrowDown /></u-icon>
60
58
  </template>
61
59
 
62
60
  <!-- 下拉内容 -->
@@ -6,5 +6,4 @@ import '../dropdown/style'
6
6
  import '../tag/style'
7
7
  import '../empty/style'
8
8
  import '@veltra/directives/ripple/style.js'
9
- import '@veltra/styles/transitions/zoom-in.scss'
10
9
  import './style.scss'
@@ -45,16 +45,14 @@
45
45
  />
46
46
  </div>
47
47
  <!-- 清空 icon -->
48
- <transition name="zoom-in" mode="out-in">
49
- <u-icon v-if="showClear" :class="cls.e('clear')" @click.stop="handleClear">
50
- <Close />
51
- </u-icon>
52
-
53
- <!-- 下拉 icon -->
54
- <u-icon :class="cls.e(`arrow`)" v-else-if="!readonly">
55
- <ArrowDown />
56
- </u-icon>
57
- </transition>
48
+ <u-icon v-if="showClear" :class="cls.e('clear')" @click.stop="handleClear">
49
+ <Close />
50
+ </u-icon>
51
+
52
+ <!-- 下拉 icon -->
53
+ <u-icon :class="cls.e(`arrow`)" v-else-if="!readonly">
54
+ <ArrowDown />
55
+ </u-icon>
58
56
  </template>
59
57
  <template #content>
60
58
  <div :class="[cls.e('content-header'), cls.m(size)]">
@@ -5,5 +5,4 @@ import '../tag/style'
5
5
  import '../checkbox/style'
6
6
  import '../input/style'
7
7
  import '../button/style'
8
- import '@veltra/styles/transitions/zoom-in.scss'
9
8
  import './style.scss'
@@ -22,28 +22,21 @@
22
22
  </u-icon>
23
23
  </div>
24
24
 
25
- <!-- @vue-ignore -->
26
- <transition
27
- @enter="(el: Element) => expandTransition.enter(el as HTMLElement)"
28
- @after-enter="(el: Element) => expandTransition.afterEnter(el as HTMLElement)"
29
- @before-leave="(el: Element) => expandTransition.beforeLeave(el as HTMLElement)"
30
- @leave="(el: Element) => expandTransition.leave(el as HTMLElement)"
31
- @after-leave="(el: Element) => expandTransition.afterLeave(el as HTMLElement)"
32
- >
33
- <ul :class="[cls.e('sub-list'), bem.is('has-active', branchActive)]" v-show="expanded">
25
+ <div ref="wrapperEl" :aria-hidden="expanded ? undefined : 'true'">
26
+ <ul :class="[cls.e('sub-list'), bem.is('has-active', branchActive)]">
34
27
  <template v-for="(child, index) of item.children!" :key="getKey(index, parentKey)">
35
28
  <UNavItem v-if="!child.children?.length" :item="child" :depth="depth + 1" />
36
29
  <NavSub v-else :item="child" :parent-key="getKey(index, parentKey)" :depth="depth + 1" />
37
30
  </template>
38
31
  </ul>
39
- </transition>
32
+ </div>
40
33
  </li>
41
34
  </template>
42
35
 
43
36
  <script setup lang="ts">
44
37
  import { ArrowRight } from '@veltra/icons/normal'
45
38
  import { bem } from '@veltra/utils'
46
- import { computed, inject } from 'vue'
39
+ import { computed, inject, onBeforeUnmount, onMounted, ref, watch } from 'vue'
47
40
 
48
41
  import type { NavItem } from '../../types'
49
42
  import { UIcon } from '../icon'
@@ -60,6 +53,24 @@ const { cls, expandedPath, navProps, expandTransition } = inject(NavDIKey)!
60
53
 
61
54
  const expanded = computed(() => expandedPath.has(props.item.path))
62
55
 
56
+ const wrapperEl = ref<HTMLElement>()
57
+
58
+ onMounted(() => {
59
+ if (!wrapperEl.value) return
60
+ expandTransition.setExpanded(wrapperEl.value, expanded.value)
61
+ })
62
+
63
+ watch(expanded, (open) => {
64
+ if (!wrapperEl.value) return
65
+ if (open) expandTransition.expand(wrapperEl.value)
66
+ else expandTransition.collapse(wrapperEl.value)
67
+ })
68
+
69
+ onBeforeUnmount(() => {
70
+ if (!wrapperEl.value) return
71
+ expandTransition.cancel(wrapperEl.value)
72
+ })
73
+
63
74
  const branchActive = computed(() => {
64
75
  const currentPath = navProps.currentPath
65
76
  if (!currentPath) return false
@@ -73,6 +73,8 @@ function observeItem(el: Element | null, key: string) {
73
73
 
74
74
  onBeforeUnmount(() => observer.disconnect())
75
75
 
76
+ const reduceMotion = window.matchMedia('(prefers-reduced-motion: reduce)')
77
+
76
78
  /** 数组末尾为最新通知, 位于堆叠最前 */
77
79
  function cardStyle(index: number): CSSProperties {
78
80
  const items = props.notifications
@@ -86,15 +88,16 @@ function cardStyle(index: number): CSSProperties {
86
88
  }
87
89
  return {
88
90
  transform: `translateY(${direction.value * offset}px) scale(1)`,
89
- opacity: 1,
91
+ ...(reduceMotion.matches ? {} : { opacity: 1 }),
90
92
  pointerEvents: 'auto'
91
93
  }
92
94
  }
93
95
 
94
96
  const clamped = Math.min(stackIndex, MAX_VISIBLE - 1)
97
+ const hidden = stackIndex >= MAX_VISIBLE
95
98
  return {
96
99
  transform: `translateY(${direction.value * clamped * PEEK}px) scale(${1 - clamped * 0.05})`,
97
- opacity: stackIndex >= MAX_VISIBLE ? 0 : 1,
100
+ ...(hidden ? { opacity: 0 } : reduceMotion.matches ? {} : { opacity: 1 }),
98
101
  pointerEvents: stackIndex === 0 ? 'auto' : 'none'
99
102
  }
100
103
  }
@@ -132,3 +132,21 @@ $stack-positions: (
132
132
  opacity: 0;
133
133
  transform: translateY(-100%);
134
134
  }
135
+
136
+ // 减弱动态效果:进入/离开不滑移。堆叠用的内联 transform 不再被动画。
137
+ @media (prefers-reduced-motion: reduce) {
138
+ .notification-bottom-enter-active,
139
+ .notification-bottom-leave-active,
140
+ .notification-top-enter-active,
141
+ .notification-top-leave-active {
142
+ transition-property: opacity;
143
+ }
144
+
145
+ .notification-bottom-enter-from,
146
+ .notification-bottom-leave-to,
147
+ .notification-top-enter-from,
148
+ .notification-top-leave-to {
149
+ transform: none;
150
+ opacity: 0;
151
+ }
152
+ }
@@ -10,9 +10,7 @@
10
10
 
11
11
  <!-- radio框 -->
12
12
  <section :class="cls.e('button')">
13
- <transition name="zoom-in">
14
- <span :class="cls.e('inner')" v-if="radioChecked"></span>
15
- </transition>
13
+ <span :class="cls.e('inner')" v-if="radioChecked"></span>
16
14
  </section>
17
15
 
18
16
  <span :class="cls.e('label')">
@@ -1,2 +1 @@
1
- import '@veltra/styles/transitions/zoom-in.scss'
2
1
  import './style.scss'
@@ -52,7 +52,10 @@ $root-name: rich-text-editor;
52
52
  background: transparent;
53
53
  color: fn.use-var(text-color, main);
54
54
  cursor: pointer;
55
- transition: all 0.15s ease;
55
+ transition:
56
+ background-color 0.15s ease,
57
+ color 0.15s ease,
58
+ opacity 0.15s ease;
56
59
  padding: 0;
57
60
 
58
61
  @include m.is-not(disabled) {
@@ -108,7 +111,9 @@ $root-name: rich-text-editor;
108
111
  font-size: 13px;
109
112
  cursor: pointer;
110
113
  outline: none;
111
- transition: all 0.15s ease;
114
+ transition:
115
+ border-color 0.15s ease,
116
+ opacity 0.15s ease;
112
117
  // Custom arrow
113
118
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
114
119
  background-repeat: no-repeat;
@@ -46,10 +46,9 @@ $root-name: scroll;
46
46
  // 滚动条背景色
47
47
  $bar-color: fn.use-var(text-color, assist);
48
48
 
49
- // 滚动条默认尺寸(宽度)
49
+ // 滚动条默认厚度。悬停变厚走 ::before 的 scale,避免动画 width/height,
50
+ // 也避免和 scroll-bar.vue 的内联 translate 抢 transform。
50
51
  $bar-size: 6px;
51
- // 滚动条滚动或者悬浮时的尺寸
52
- $bar-active-size: $bar-size + 4px;
53
52
 
54
53
  // 滚动条
55
54
  @include m.e(bar-x, bar-y) {
@@ -57,25 +56,32 @@ $root-name: scroll;
57
56
  cursor: default;
58
57
  position: absolute;
59
58
  border-radius: $bar-size;
60
- background-color: fn.color-a(text-color, 40, assist);
59
+ background-color: transparent;
61
60
  will-change: transform;
62
- transition:
63
- opacity 0.3s ease-in,
64
- background-color 0.3s ease-in,
65
- height 0.15s ease-in,
66
- width 0.15s ease-in;
67
-
61
+ transition: opacity 160ms cubic-bezier(0.23, 1, 0.32, 1);
68
62
  z-index: 1;
69
63
 
70
- &:hover {
64
+ &::before {
65
+ content: '';
66
+ position: absolute;
67
+ inset: 0;
68
+ border-radius: inherit;
69
+ background-color: fn.color-a(text-color, 40, assist);
70
+ transition:
71
+ transform 150ms cubic-bezier(0.23, 1, 0.32, 1),
72
+ background-color 160ms cubic-bezier(0.23, 1, 0.32, 1);
73
+ }
74
+
75
+ &:hover::before {
71
76
  background-color: fn.color-a(text-color, 60, assist);
72
- border-radius: $bar-active-size;
73
77
  }
74
78
 
75
79
  @include m.is(active) {
76
80
  opacity: 1;
77
- background-color: $bar-color;
78
- border-radius: $bar-active-size;
81
+
82
+ &::before {
83
+ background-color: $bar-color;
84
+ }
79
85
  }
80
86
  }
81
87
 
@@ -91,12 +97,18 @@ $root-name: scroll;
91
97
  top: 0;
92
98
  right: 0;
93
99
 
94
- &:hover {
95
- width: $bar-active-size;
100
+ &::before {
101
+ transform-origin: right center;
102
+ }
103
+
104
+ &:hover::before {
105
+ transform: scaleX(calc(10 / 6));
96
106
  }
97
107
 
98
108
  @include m.is(active) {
99
- width: $bar-active-size;
109
+ &::before {
110
+ transform: scaleX(calc(10 / 6));
111
+ }
100
112
  }
101
113
  }
102
114
 
@@ -105,11 +117,18 @@ $root-name: scroll;
105
117
  bottom: 0;
106
118
  left: 0;
107
119
 
108
- &:hover {
109
- height: $bar-active-size;
120
+ &::before {
121
+ transform-origin: center bottom;
122
+ }
123
+
124
+ &:hover::before {
125
+ transform: scaleY(calc(10 / 6));
110
126
  }
127
+
111
128
  @include m.is(active) {
112
- height: $bar-active-size;
129
+ &::before {
130
+ transform: scaleY(calc(10 / 6));
131
+ }
113
132
  }
114
133
  }
115
134
  }
@@ -2,9 +2,11 @@
2
2
  <div
3
3
  v-if="!readonly"
4
4
  v-bind="$attrs"
5
+ ref="trackRef"
5
6
  :class="[cls.b, bem.is('block', block), bem.is('disabled', disabled), cls.m(size)]"
6
7
  role="radiogroup"
7
8
  >
9
+ <div :class="cls.e('thumb')" :style="thumbStyle" aria-hidden="true" />
8
10
  <div
9
11
  v-for="item of items"
10
12
  :key="item[valueKey]"
@@ -33,9 +35,9 @@
33
35
  </template>
34
36
 
35
37
  <script lang="ts" setup>
36
- import { useFormFallbackProps } from '@veltra/compositions'
38
+ import { useFormFallbackProps, useResizeObserver } from '@veltra/compositions'
37
39
  import { bem, fieldKey, FORM_EMPTY_CONTENT, injectFormContext } from '@veltra/utils'
38
- import { computed } from 'vue'
40
+ import { computed, nextTick, onMounted, shallowRef, watch } from 'vue'
39
41
 
40
42
  import type { SegmentEmits, SegmentItem, SegmentProps } from '../../types'
41
43
 
@@ -67,6 +69,46 @@ const cls = bem('segment')
67
69
  const labelKey = computed(() => fieldKey(props.labelKey, 'label'))
68
70
  const valueKey = computed(() => fieldKey(props.valueKey, 'value'))
69
71
 
72
+ const trackRef = shallowRef<HTMLElement>()
73
+ const thumbX = shallowRef(0)
74
+ const thumbY = shallowRef(0)
75
+ const thumbW = shallowRef(0)
76
+ const thumbH = shallowRef(0)
77
+ const thumbRadius = shallowRef('0px')
78
+ const thumbOn = shallowRef(false)
79
+
80
+ const thumbStyle = computed(() => ({
81
+ width: `${thumbW.value}px`,
82
+ height: `${thumbH.value}px`,
83
+ borderRadius: thumbRadius.value,
84
+ transform: `translate(${thumbX.value}px, ${thumbY.value}px)`,
85
+ opacity: thumbOn.value ? '1' : '0'
86
+ }))
87
+
88
+ function measure() {
89
+ const track = trackRef.value
90
+ if (!track) return
91
+ const active = track.querySelector<HTMLElement>(':scope > .is-active')
92
+ if (!active) {
93
+ thumbOn.value = false
94
+ return
95
+ }
96
+ const trackBox = track.getBoundingClientRect()
97
+ const box = active.getBoundingClientRect()
98
+ thumbX.value = box.left - trackBox.left
99
+ thumbY.value = box.top - trackBox.top
100
+ thumbW.value = box.width
101
+ thumbH.value = box.height
102
+ thumbRadius.value = getComputedStyle(active).borderRadius
103
+ thumbOn.value = true
104
+ }
105
+
106
+ useResizeObserver({ targets: trackRef, onResize: () => measure() })
107
+
108
+ watch([model, () => props.items, size], () => nextTick(measure), { deep: true })
109
+
110
+ onMounted(() => nextTick(measure))
111
+
70
112
  const handleSelect = (item: SegmentItem) => {
71
113
  if (disabled.value || props.disabledItem?.(item)) return
72
114
  const val = item[valueKey.value]