@veltra/desktop 1.14.0 → 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.
- package/dist/components/auto-complete/style.d.ts +0 -1
- package/dist/components/cascade/cascade.js +13 -19
- package/dist/components/cascade/cascade.js.map +1 -1
- package/dist/components/cascade/style.d.ts +1 -3
- package/dist/components/checkbox/checkbox.js +5 -11
- package/dist/components/checkbox/checkbox.js.map +1 -1
- package/dist/components/checkbox/style.d.ts +1 -1
- package/dist/components/checkbox/style.js +0 -1
- package/dist/components/checkbox-group/style.d.ts +1 -1
- package/dist/components/chip/chip.js +63 -0
- package/dist/components/chip/chip.js.map +1 -0
- package/dist/components/chip/style.d.ts +1 -0
- package/dist/components/chip/style.js +1 -0
- package/dist/components/chip/style2.css +90 -0
- package/dist/components/chip-group/chip-group.js +279 -0
- package/dist/components/chip-group/chip-group.js.map +1 -0
- package/dist/components/chip-group/reveal.js +80 -0
- package/dist/components/chip-group/reveal.js.map +1 -0
- package/dist/components/chip-group/style.d.ts +1 -0
- package/dist/components/chip-group/style.js +2 -0
- package/dist/components/chip-group/style2.css +68 -0
- package/dist/components/condition-editor/style.d.ts +0 -1
- package/dist/components/date-picker/style.d.ts +1 -2
- package/dist/components/date-range-picker/date-range-picker.js +14 -20
- package/dist/components/date-range-picker/date-range-picker.js.map +1 -1
- package/dist/components/dialog/dialog.js +5 -2
- package/dist/components/dialog/dialog.js.map +1 -1
- package/dist/components/dialog/style2.css +0 -10
- package/dist/components/dialog/use-maximum.js +77 -20
- package/dist/components/dialog/use-maximum.js.map +1 -1
- package/dist/components/drawer/drawer.js +57 -54
- package/dist/components/drawer/drawer.js.map +1 -1
- package/dist/components/drawer/style.d.ts +1 -1
- package/dist/components/drawer/style.js +0 -1
- package/dist/components/drawer/style2.css +139 -15
- package/dist/components/form-item/style2.css +1 -1
- package/dist/components/index.d.ts +32 -30
- package/dist/components/index.js +63 -59
- package/dist/components/index.js.map +1 -1
- package/dist/components/input/input.js.map +1 -1
- package/dist/components/input/input.vue_vue_type_script_setup_true_lang.js +13 -19
- package/dist/components/input/input.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/input/style.d.ts +1 -1
- package/dist/components/input/style.js +0 -1
- package/dist/components/message/style2.css +13 -0
- package/dist/components/message-confirm/style2.css +10 -0
- package/dist/components/multi-select/multi-select.js +19 -21
- package/dist/components/multi-select/multi-select.js.map +1 -1
- package/dist/components/multi-select/style.d.ts +1 -4
- package/dist/components/multi-select/style.js +0 -1
- package/dist/components/multi-tree-select/multi-tree-select.js +20 -22
- package/dist/components/multi-tree-select/multi-tree-select.js.map +1 -1
- package/dist/components/multi-tree-select/style.d.ts +1 -5
- package/dist/components/multi-tree-select/style.js +0 -1
- package/dist/components/nav/nav-sub.js +56 -51
- package/dist/components/nav/nav-sub.js.map +1 -1
- package/dist/components/notification/notification-box.js +4 -2
- package/dist/components/notification/notification-box.js.map +1 -1
- package/dist/components/notification/style2.css +16 -0
- package/dist/components/number-input/style.d.ts +0 -1
- package/dist/components/palette/style.d.ts +1 -2
- package/dist/components/password-input/style.d.ts +1 -1
- package/dist/components/radio/radio.js +5 -8
- package/dist/components/radio/radio.js.map +1 -1
- package/dist/components/radio/style.d.ts +1 -1
- package/dist/components/radio/style.js +0 -1
- package/dist/components/radio-group/style.d.ts +1 -1
- package/dist/components/rich-text-editor/style2.css +2 -2
- package/dist/components/scroll/style2.css +27 -13
- package/dist/components/segment/segment.js +50 -3
- package/dist/components/segment/segment.js.map +1 -1
- package/dist/components/segment/style2.css +20 -2
- package/dist/components/select/select.js +24 -25
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/select/style.d.ts +0 -1
- package/dist/components/switch/style2.css +1 -1
- package/dist/components/table/style.d.ts +1 -3
- package/dist/components/tabs/style.d.ts +1 -2
- package/dist/components/tabs/style.js +0 -1
- package/dist/components/tabs/style2.css +29 -0
- package/dist/components/tabs/tabs-horizontal.js +7 -3
- package/dist/components/tabs/tabs-horizontal.js.map +1 -1
- package/dist/components/tabs/tabs.js +2 -8
- package/dist/components/tabs/tabs.js.map +1 -1
- package/dist/components/tabs/use-tabs-bar.js +41 -9
- package/dist/components/tabs/use-tabs-bar.js.map +1 -1
- package/dist/components/tag/style2.css +3 -3
- package/dist/components/textarea/style.d.ts +1 -1
- package/dist/components/textarea/style.js +0 -1
- package/dist/components/textarea/textarea.js +7 -13
- package/dist/components/textarea/textarea.js.map +1 -1
- package/dist/components/theme/style.d.ts +0 -1
- package/dist/components/theme/style2.css +9 -5
- package/dist/components/time-picker/style.d.ts +1 -2
- package/dist/components/tip/style2.css +5 -5
- package/dist/components/tip/tip.js +22 -1
- package/dist/components/tip/tip.js.map +1 -1
- package/dist/components/transfer/style.d.ts +1 -2
- package/dist/components/tree/style.d.ts +1 -1
- package/dist/components/tree-select/style.d.ts +1 -3
- package/dist/components/tree-select/tree-select.js +24 -25
- package/dist/components/tree-select/tree-select.js.map +1 -1
- package/dist/index.d.ts +86 -82
- package/dist/index.js +84 -82
- package/dist/style.d.ts +0 -9
- package/dist/style.js +2 -0
- package/dist/types/chip-group.d.ts +35 -0
- package/dist/types/chip.d.ts +28 -0
- package/dist/types/index.d.ts +3 -1
- package/package.json +1 -1
- package/src/components/cascade/cascade.vue +9 -11
- package/src/components/checkbox/checkbox.vue +6 -8
- package/src/components/checkbox/style.ts +0 -1
- package/src/components/chip/__test__/chip.test.ts +69 -0
- package/src/components/chip/chip.vue +54 -0
- package/src/components/chip/index.ts +1 -0
- package/src/components/chip/style.scss +91 -0
- package/src/components/chip/style.ts +1 -0
- package/src/components/chip-group/__test__/chip-group.test.ts +411 -0
- package/src/components/chip-group/__test__/reveal.test.ts +74 -0
- package/src/components/chip-group/chip-group.vue +326 -0
- package/src/components/chip-group/index.ts +1 -0
- package/src/components/chip-group/reveal.ts +106 -0
- package/src/components/chip-group/style.scss +72 -0
- package/src/components/chip-group/style.ts +2 -0
- package/src/components/date-range-picker/date-range-picker.vue +10 -12
- package/src/components/dialog/dialog.vue +2 -1
- package/src/components/dialog/style.scss +0 -12
- package/src/components/dialog/use-maximum.ts +88 -28
- package/src/components/drawer/__test__/drawer.test.ts +23 -2
- package/src/components/drawer/drawer.vue +49 -40
- package/src/components/drawer/style.scss +63 -53
- package/src/components/drawer/style.ts +0 -1
- package/src/components/form-item/style.scss +2 -2
- package/src/components/index.ts +4 -0
- package/src/components/input/input.vue +14 -16
- package/src/components/input/style.ts +0 -1
- package/src/components/message/style.scss +15 -0
- package/src/components/message-confirm/style.scss +14 -0
- package/src/components/multi-select/__test__/multi-select.test.ts +47 -0
- package/src/components/multi-select/multi-select.vue +14 -12
- package/src/components/multi-select/style.ts +0 -1
- package/src/components/multi-tree-select/__test__/multi-tree-select.test.ts +41 -0
- package/src/components/multi-tree-select/multi-tree-select.vue +20 -13
- package/src/components/multi-tree-select/style.ts +0 -1
- package/src/components/nav/nav-sub.vue +22 -11
- package/src/components/notification/notification-box.vue +5 -2
- package/src/components/notification/style.scss +18 -0
- package/src/components/radio/radio.vue +1 -3
- package/src/components/radio/style.ts +0 -1
- package/src/components/rich-text-editor/style.scss +7 -2
- package/src/components/scroll/style.scss +39 -20
- package/src/components/segment/segment.vue +44 -2
- package/src/components/segment/style.scss +22 -2
- package/src/components/select/select.vue +24 -19
- package/src/components/switch/style.scss +4 -1
- package/src/components/tabs/style.scss +35 -0
- package/src/components/tabs/style.ts +0 -1
- package/src/components/tabs/tabs-horizontal.vue +2 -1
- package/src/components/tabs/tabs.vue +4 -6
- package/src/components/tabs/use-tabs-bar.ts +55 -8
- package/src/components/tag/style.scss +4 -4
- package/src/components/textarea/style.ts +0 -1
- package/src/components/textarea/textarea.vue +7 -9
- package/src/components/theme/style.scss +25 -5
- package/src/components/tip/style.scss +5 -5
- package/src/components/tip/tip.vue +33 -1
- package/src/components/tree-select/tree-select.vue +21 -17
- package/src/style.ts +2 -0
- package/src/types/chip-group.ts +36 -0
- package/src/types/chip.ts +29 -0
- package/src/types/index.ts +2 -0
|
@@ -41,22 +41,20 @@
|
|
|
41
41
|
:placeholder="model?.length ? '' : placeholder"
|
|
42
42
|
:disabled="disabled"
|
|
43
43
|
@click.stop="handleInputClick"
|
|
44
|
-
@
|
|
44
|
+
@input="handleInput"
|
|
45
45
|
@keydown.enter.prevent="handleCreateByEnter"
|
|
46
46
|
/>
|
|
47
47
|
</div>
|
|
48
48
|
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
59
|
-
</transition>
|
|
57
|
+
<u-icon :class="cls.e('arrow')" v-else><ArrowDown /></u-icon>
|
|
60
58
|
</template>
|
|
61
59
|
|
|
62
60
|
<!-- 下拉内容 -->
|
|
@@ -360,7 +358,11 @@ const handleInputClick = () => {
|
|
|
360
358
|
if (!dropdownVisible.value) dropdownRef.value?.open()
|
|
361
359
|
}
|
|
362
360
|
|
|
363
|
-
|
|
361
|
+
/**
|
|
362
|
+
* 键入过滤词时确保面板展开。不监听 focus:模态弹框打开时会把焦点移入面板内
|
|
363
|
+
* 第一个可聚焦元素(正是本输入框),监听 focus 会让下拉随弹框打开而自动展开。
|
|
364
|
+
*/
|
|
365
|
+
const handleInput = () => {
|
|
364
366
|
if (!dropdownVisible.value) dropdownRef.value?.open()
|
|
365
367
|
}
|
|
366
368
|
|
|
@@ -249,3 +249,44 @@ describe('UMultiTreeSelect labelTemplate', () => {
|
|
|
249
249
|
}
|
|
250
250
|
})
|
|
251
251
|
})
|
|
252
|
+
|
|
253
|
+
describe('UMultiTreeSelect dropdown opening', () => {
|
|
254
|
+
it('does not open the panel when the filter input is focused programmatically', async () => {
|
|
255
|
+
const { host, unmount } = mountMultiTreeSelect({ filterable: true })
|
|
256
|
+
|
|
257
|
+
try {
|
|
258
|
+
const input = host.querySelector<HTMLInputElement>('.u-multi-tree-select__input')!
|
|
259
|
+
expect(input).toBeTruthy()
|
|
260
|
+
|
|
261
|
+
// 模态弹框打开时会把焦点移入面板内第一个可聚焦元素(即本输入框),不应连带展开面板
|
|
262
|
+
input.dispatchEvent(new FocusEvent('focus'))
|
|
263
|
+
for (let attempt = 0; attempt < 6; attempt++) {
|
|
264
|
+
await nextTick()
|
|
265
|
+
await sleep(25)
|
|
266
|
+
}
|
|
267
|
+
expect(queryNodeContents().length).toBe(0)
|
|
268
|
+
} finally {
|
|
269
|
+
unmount()
|
|
270
|
+
}
|
|
271
|
+
})
|
|
272
|
+
|
|
273
|
+
it('opens the panel and keeps the first-keystroke filter when typing into the input', async () => {
|
|
274
|
+
const { host, unmount } = mountMultiTreeSelect({ filterable: true })
|
|
275
|
+
|
|
276
|
+
try {
|
|
277
|
+
const input = host.querySelector<HTMLInputElement>('.u-multi-tree-select__input')!
|
|
278
|
+
input.value = '亚'
|
|
279
|
+
input.dispatchEvent(new Event('input', { bubbles: true }))
|
|
280
|
+
|
|
281
|
+
// 面板懒渲染:键入后自动展开,且首字符过滤在展开后补一次,不被丢失
|
|
282
|
+
for (let attempt = 0; attempt < 20; attempt++) {
|
|
283
|
+
await nextTick()
|
|
284
|
+
await sleep(25)
|
|
285
|
+
if (queryNodeContents().length > 0) break
|
|
286
|
+
}
|
|
287
|
+
expect(queryNodeContents().map((el) => el.textContent)).toEqual(['亚洲'])
|
|
288
|
+
} finally {
|
|
289
|
+
unmount()
|
|
290
|
+
}
|
|
291
|
+
})
|
|
292
|
+
})
|
|
@@ -41,20 +41,18 @@
|
|
|
41
41
|
:placeholder="tags.length ? '' : placeholder"
|
|
42
42
|
:disabled="disabled"
|
|
43
43
|
@click.stop="handleInputClick"
|
|
44
|
-
@
|
|
44
|
+
@input="handleInput"
|
|
45
45
|
/>
|
|
46
46
|
</div>
|
|
47
47
|
<!-- 清空 icon -->
|
|
48
|
-
<
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
<
|
|
55
|
-
|
|
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)]">
|
|
@@ -385,7 +383,16 @@ const handleInputClick = () => {
|
|
|
385
383
|
if (!dropdownVisible.value) dropdownRef.value?.open()
|
|
386
384
|
}
|
|
387
385
|
|
|
388
|
-
|
|
389
|
-
|
|
386
|
+
/**
|
|
387
|
+
* 键入过滤词时确保面板展开。不监听 focus:模态弹框打开时会把焦点移入面板内
|
|
388
|
+
* 第一个可聚焦元素(正是本输入框),监听 focus 会让下拉随弹框打开而自动展开。
|
|
389
|
+
* 面板为懒渲染,展开后需补一次过滤,否则首字符的过滤条件会丢失。
|
|
390
|
+
*/
|
|
391
|
+
const handleInput = () => {
|
|
392
|
+
if (dropdownVisible.value) return
|
|
393
|
+
dropdownRef.value?.open()
|
|
394
|
+
if (qs.value && typeof props.data !== 'function') {
|
|
395
|
+
nextTick(() => treeRef.value?.filter(qs.value))
|
|
396
|
+
}
|
|
390
397
|
}
|
|
391
398
|
</script>
|
|
@@ -22,28 +22,21 @@
|
|
|
22
22
|
</u-icon>
|
|
23
23
|
</div>
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
</
|
|
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:
|
|
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
|
-
<
|
|
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')">
|
|
@@ -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:
|
|
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:
|
|
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:
|
|
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
|
-
|
|
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
|
-
|
|
78
|
-
|
|
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
|
-
|
|
95
|
-
|
|
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
|
-
|
|
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
|
-
|
|
109
|
-
|
|
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
|
-
|
|
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]
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
@use 'pkg:@veltra/styles/vars';
|
|
4
4
|
|
|
5
5
|
@include m.b(segment) {
|
|
6
|
+
position: relative;
|
|
6
7
|
vertical-align: middle;
|
|
7
8
|
@include m.flex($display: inline-flex, $align: center);
|
|
8
9
|
gap: 2px;
|
|
@@ -10,6 +11,23 @@
|
|
|
10
11
|
background-color: fn.use-var(bg-color, bottom);
|
|
11
12
|
box-sizing: border-box;
|
|
12
13
|
|
|
14
|
+
@include m.e(thumb) {
|
|
15
|
+
position: absolute;
|
|
16
|
+
left: 0;
|
|
17
|
+
top: 0;
|
|
18
|
+
z-index: 0;
|
|
19
|
+
pointer-events: none;
|
|
20
|
+
background-color: fn.use-var(bg-color, top);
|
|
21
|
+
box-shadow: fn.use-var(shadow, sm);
|
|
22
|
+
transition:
|
|
23
|
+
transform 200ms cubic-bezier(0.77, 0, 0.175, 1),
|
|
24
|
+
opacity 200ms cubic-bezier(0.77, 0, 0.175, 1);
|
|
25
|
+
|
|
26
|
+
@media (prefers-reduced-motion: reduce) {
|
|
27
|
+
transition: none;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
13
31
|
@include m.size using ($size) {
|
|
14
32
|
border-radius: fn.use-var(radius, $size);
|
|
15
33
|
|
|
@@ -22,6 +40,8 @@
|
|
|
22
40
|
}
|
|
23
41
|
|
|
24
42
|
@include m.e(item) {
|
|
43
|
+
position: relative;
|
|
44
|
+
z-index: 1;
|
|
25
45
|
margin: 0;
|
|
26
46
|
display: inline-flex;
|
|
27
47
|
align-items: center;
|
|
@@ -45,8 +65,8 @@
|
|
|
45
65
|
|
|
46
66
|
@include m.is(active) {
|
|
47
67
|
color: fn.use-var(color, primary);
|
|
48
|
-
background-color:
|
|
49
|
-
box-shadow:
|
|
68
|
+
background-color: transparent;
|
|
69
|
+
box-shadow: none;
|
|
50
70
|
font-weight: 600;
|
|
51
71
|
}
|
|
52
72
|
|
|
@@ -34,20 +34,18 @@
|
|
|
34
34
|
</template>
|
|
35
35
|
|
|
36
36
|
<template #suffix>
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
<
|
|
48
|
-
|
|
49
|
-
</u-icon>
|
|
50
|
-
</transition>
|
|
37
|
+
<u-icon
|
|
38
|
+
v-if="showClear"
|
|
39
|
+
:class="cls.e('clear')"
|
|
40
|
+
title="清除"
|
|
41
|
+
key="clear"
|
|
42
|
+
@click.stop="handleClear"
|
|
43
|
+
>
|
|
44
|
+
<Close />
|
|
45
|
+
</u-icon>
|
|
46
|
+
<u-icon v-else :class="cls.e('arrow')" key="arrow">
|
|
47
|
+
<ArrowDown />
|
|
48
|
+
</u-icon>
|
|
51
49
|
</template>
|
|
52
50
|
</u-input>
|
|
53
51
|
</template>
|
|
@@ -265,16 +263,23 @@ const showClear = computed(() => {
|
|
|
265
263
|
})
|
|
266
264
|
|
|
267
265
|
/**
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
*
|
|
266
|
+
* 点击输入框时在 capture 阶段完成开合。
|
|
267
|
+
* 过滤模式只打开、不关闭,避免打断输入;非过滤模式切换开合。
|
|
268
|
+
* 箭头和留白仍交给 dropdown 的 click。
|
|
271
269
|
*/
|
|
272
270
|
function handleTriggerClickCapture(e: MouseEvent) {
|
|
273
|
-
if (
|
|
271
|
+
if (disabled.value) return
|
|
274
272
|
if (!(e.target instanceof HTMLInputElement)) return
|
|
275
273
|
|
|
274
|
+
// capture 与 dropdown 的 bubble click 会在同一毫秒内先后绑定。
|
|
275
|
+
// Vue 会丢掉后绑定的那个,非过滤模式下面板就打不开。开合放在先执行的 capture 里。
|
|
276
276
|
e.stopPropagation()
|
|
277
|
-
if (
|
|
277
|
+
if (filterable.value) {
|
|
278
|
+
if (!dropdownVisible.value) dropdownRef.value?.open()
|
|
279
|
+
return
|
|
280
|
+
}
|
|
281
|
+
if (dropdownVisible.value) dropdownRef.value?.close()
|
|
282
|
+
else dropdownRef.value?.open()
|
|
278
283
|
}
|
|
279
284
|
|
|
280
285
|
const { userAction, isUserActive } = useUserAction()
|
|
@@ -82,7 +82,10 @@ $root-name: switch;
|
|
|
82
82
|
border-radius: 100px;
|
|
83
83
|
background-color: fn.use-var(bg-color, bottom);
|
|
84
84
|
border: 1px solid fn.use-var(border, muted-color);
|
|
85
|
-
transition:
|
|
85
|
+
transition:
|
|
86
|
+
background-color fn.use-var(transition, fast) fn.use-var(transition, ease),
|
|
87
|
+
border-color fn.use-var(transition, fast) fn.use-var(transition, ease),
|
|
88
|
+
box-shadow fn.use-var(transition, fast) fn.use-var(transition, ease);
|
|
86
89
|
padding: 2px;
|
|
87
90
|
flex-shrink: 0;
|
|
88
91
|
}
|
|
@@ -273,6 +273,10 @@ $active-shadow: fn.use-var(shadow, sm);
|
|
|
273
273
|
@include m.bem(tabs-bar, nav) {
|
|
274
274
|
border-radius: 9999px;
|
|
275
275
|
}
|
|
276
|
+
|
|
277
|
+
@include m.bem(tabs-bar, indicator) {
|
|
278
|
+
border-radius: 9999px;
|
|
279
|
+
}
|
|
276
280
|
}
|
|
277
281
|
|
|
278
282
|
@include m.m(horizontal) {
|
|
@@ -280,4 +284,35 @@ $active-shadow: fn.use-var(shadow, sm);
|
|
|
280
284
|
border-radius: 9999px;
|
|
281
285
|
}
|
|
282
286
|
}
|
|
287
|
+
|
|
288
|
+
@include m.m(horizontal) {
|
|
289
|
+
@include m.bem(tabs-bar, list) {
|
|
290
|
+
position: relative;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
@include m.bem(tabs-bar, indicator) {
|
|
294
|
+
position: absolute;
|
|
295
|
+
left: 0;
|
|
296
|
+
top: 0;
|
|
297
|
+
z-index: 0;
|
|
298
|
+
pointer-events: none;
|
|
299
|
+
border-radius: $item-radius;
|
|
300
|
+
background-color: $active-bg;
|
|
301
|
+
box-shadow: $active-shadow;
|
|
302
|
+
transition: transform 200ms cubic-bezier(0.77, 0, 0.175, 1);
|
|
303
|
+
|
|
304
|
+
@media (prefers-reduced-motion: reduce) {
|
|
305
|
+
transition: none;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
@include m.bem(tabs-bar, item) {
|
|
310
|
+
z-index: 1;
|
|
311
|
+
|
|
312
|
+
@include m.is(active) {
|
|
313
|
+
background-color: transparent;
|
|
314
|
+
box-shadow: none;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
283
318
|
}
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
<div ref="viewportRef" :class="cls.e('viewport')">
|
|
23
23
|
<div ref="listRef" :class="cls.e('list')">
|
|
24
|
+
<div :class="cls.e('indicator')" :style="indicatorStyle" aria-hidden="true" />
|
|
24
25
|
<button
|
|
25
26
|
type="button"
|
|
26
27
|
role="tab"
|
|
@@ -99,7 +100,7 @@ const listRef = shallowRef<HTMLElement>()
|
|
|
99
100
|
|
|
100
101
|
const itemsRef = computed(() => props.items)
|
|
101
102
|
|
|
102
|
-
const { showNav, canPrev, canNext, scrollByStep } = useTabsBar({
|
|
103
|
+
const { showNav, canPrev, canNext, scrollByStep, indicatorStyle } = useTabsBar({
|
|
103
104
|
viewportRef,
|
|
104
105
|
listRef,
|
|
105
106
|
items: itemsRef,
|