@veltra/desktop 1.8.5 → 1.9.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/alert/alert.js +69 -0
- package/dist/components/alert/alert.js.map +1 -0
- package/dist/components/alert/style.d.ts +1 -0
- package/dist/components/alert/style.js +1 -0
- package/dist/components/alert/style2.css +76 -0
- package/dist/components/anchor/anchor-item.js +35 -0
- package/dist/components/anchor/anchor-item.js.map +1 -0
- package/dist/components/anchor/anchor.js +61 -0
- package/dist/components/anchor/anchor.js.map +1 -0
- package/dist/components/anchor/di.js +6 -0
- package/dist/components/anchor/di.js.map +1 -0
- package/dist/components/anchor/style.d.ts +1 -0
- package/dist/components/anchor/style.js +1 -0
- package/dist/components/anchor/style2.css +45 -0
- package/dist/components/anchor/use-anchor.js +81 -0
- package/dist/components/anchor/use-anchor.js.map +1 -0
- package/dist/components/avatar/avatar-group.js +28 -0
- package/dist/components/avatar/avatar-group.js.map +1 -0
- package/dist/components/avatar/avatar.js +51 -0
- package/dist/components/avatar/avatar.js.map +1 -0
- package/dist/components/avatar/style.d.ts +1 -0
- package/dist/components/avatar/style.js +1 -0
- package/dist/components/avatar/style2.css +87 -0
- package/dist/components/back-top/back-top.js +82 -0
- package/dist/components/back-top/back-top.js.map +1 -0
- package/dist/components/back-top/style.d.ts +1 -0
- package/dist/components/back-top/style.js +2 -0
- package/dist/components/back-top/style2.css +32 -0
- package/dist/components/carousel/carousel-item.js +27 -0
- package/dist/components/carousel/carousel-item.js.map +1 -0
- package/dist/components/carousel/carousel.js +118 -0
- package/dist/components/carousel/carousel.js.map +1 -0
- package/dist/components/carousel/di.js +7 -0
- package/dist/components/carousel/di.js.map +1 -0
- package/dist/components/carousel/style.d.ts +1 -0
- package/dist/components/carousel/style.js +1 -0
- package/dist/components/carousel/style2.css +97 -0
- package/dist/components/carousel/use-carousel.js +68 -0
- package/dist/components/carousel/use-carousel.js.map +1 -0
- package/dist/components/descriptions/descriptions-item.js +16 -0
- package/dist/components/descriptions/descriptions-item.js.map +1 -0
- package/dist/components/descriptions/descriptions.js +67 -0
- package/dist/components/descriptions/descriptions.js.map +1 -0
- package/dist/components/descriptions/style.d.ts +1 -0
- package/dist/components/descriptions/style.js +1 -0
- package/dist/components/descriptions/style2.css +81 -0
- package/dist/components/divider/divider.js +41 -0
- package/dist/components/divider/divider.js.map +1 -0
- package/dist/components/divider/style.d.ts +1 -0
- package/dist/components/divider/style.js +1 -0
- package/dist/components/divider/style2.css +68 -0
- package/dist/components/expression-editor/components/variable-picker.js +1 -1
- package/dist/components/expression-editor/components/variable-picker.js.map +1 -1
- package/dist/components/image-cropper/image-cropper.js +1 -1
- package/dist/components/image-cropper/image-cropper.js.map +1 -1
- package/dist/components/index.d.ts +48 -30
- package/dist/components/index.js +95 -59
- package/dist/components/index.js.map +1 -1
- package/dist/components/rate/rate.js +130 -0
- package/dist/components/rate/rate.js.map +1 -0
- package/dist/components/rate/style.d.ts +1 -0
- package/dist/components/rate/style.js +1 -0
- package/dist/components/rate/style2.css +58 -0
- package/dist/components/skeleton/skeleton.js +74 -0
- package/dist/components/skeleton/skeleton.js.map +1 -0
- package/dist/components/skeleton/style.d.ts +1 -0
- package/dist/components/skeleton/style.js +1 -0
- package/dist/components/skeleton/style2.css +86 -0
- package/dist/components/space/space.js +47 -0
- package/dist/components/space/space.js.map +1 -0
- package/dist/components/space/style.d.ts +1 -0
- package/dist/components/space/style.js +1 -0
- package/dist/components/space/style2.css +43 -0
- package/dist/components/time-picker/style.d.ts +2 -0
- package/dist/components/time-picker/style.js +3 -0
- package/dist/components/time-picker/style2.css +110 -0
- package/dist/components/time-picker/time-picker.js +196 -0
- package/dist/components/time-picker/time-picker.js.map +1 -0
- package/dist/components/timeline/style.d.ts +1 -0
- package/dist/components/timeline/style.js +1 -0
- package/dist/components/timeline/style2.css +95 -0
- package/dist/components/timeline/timeline-item.js +32 -0
- package/dist/components/timeline/timeline-item.js.map +1 -0
- package/dist/components/timeline/timeline.js +17 -0
- package/dist/components/timeline/timeline.js.map +1 -0
- package/dist/components/transfer/style.d.ts +2 -0
- package/dist/components/transfer/style.js +4 -0
- package/dist/components/transfer/style2.css +172 -0
- package/dist/components/transfer/transfer-list.js +101 -0
- package/dist/components/transfer/transfer-list.js.map +1 -0
- package/dist/components/transfer/transfer.js +138 -0
- package/dist/components/transfer/transfer.js.map +1 -0
- package/dist/index.d.ts +119 -88
- package/dist/index.js +106 -88
- package/dist/types/alert.d.ts +27 -0
- package/dist/types/anchor.d.ts +48 -0
- package/dist/types/avatar.d.ts +28 -0
- package/dist/types/back-top.d.ts +19 -0
- package/dist/types/carousel.d.ts +25 -0
- package/dist/types/descriptions.d.ts +22 -0
- package/dist/types/divider.d.ts +14 -0
- package/dist/types/index.d.ts +14 -1
- package/dist/types/layout.d.ts +2 -1
- package/dist/types/rate.d.ts +26 -0
- package/dist/types/skeleton.d.ts +24 -0
- package/dist/types/space.d.ts +20 -0
- package/dist/types/time-picker.d.ts +38 -0
- package/dist/types/timeline.d.ts +16 -0
- package/dist/types/transfer.d.ts +37 -0
- package/package.json +2 -1
- package/src/components/alert/alert.vue +62 -0
- package/src/components/alert/index.ts +1 -0
- package/src/components/alert/style.scss +67 -0
- package/src/components/alert/style.ts +1 -0
- package/src/components/anchor/anchor-item.vue +35 -0
- package/src/components/anchor/anchor.vue +63 -0
- package/src/components/anchor/di.ts +15 -0
- package/src/components/anchor/index.ts +2 -0
- package/src/components/anchor/style.scss +44 -0
- package/src/components/anchor/style.ts +1 -0
- package/src/components/anchor/use-anchor.ts +120 -0
- package/src/components/avatar/avatar-group.vue +26 -0
- package/src/components/avatar/avatar.vue +52 -0
- package/src/components/avatar/index.ts +2 -0
- package/src/components/avatar/style.scss +79 -0
- package/src/components/avatar/style.ts +1 -0
- package/src/components/back-top/back-top.vue +89 -0
- package/src/components/back-top/index.ts +1 -0
- package/src/components/back-top/style.scss +31 -0
- package/src/components/back-top/style.ts +2 -0
- package/src/components/carousel/carousel-item.vue +27 -0
- package/src/components/carousel/carousel.vue +93 -0
- package/src/components/carousel/di.ts +15 -0
- package/src/components/carousel/index.ts +2 -0
- package/src/components/carousel/style.scss +109 -0
- package/src/components/carousel/style.ts +1 -0
- package/src/components/carousel/use-carousel.ts +77 -0
- package/src/components/descriptions/descriptions-item.vue +12 -0
- package/src/components/descriptions/descriptions.vue +81 -0
- package/src/components/descriptions/index.ts +2 -0
- package/src/components/descriptions/style.scss +73 -0
- package/src/components/descriptions/style.ts +1 -0
- package/src/components/divider/divider.vue +29 -0
- package/src/components/divider/index.ts +1 -0
- package/src/components/divider/style.scss +90 -0
- package/src/components/divider/style.ts +1 -0
- package/src/components/expression-editor/components/variable-picker.vue +1 -1
- package/src/components/image-cropper/image-cropper.vue +1 -1
- package/src/components/index.ts +26 -0
- package/src/components/rate/index.ts +1 -0
- package/src/components/rate/rate.vue +127 -0
- package/src/components/rate/style.scss +51 -0
- package/src/components/rate/style.ts +1 -0
- package/src/components/skeleton/index.ts +1 -0
- package/src/components/skeleton/skeleton.vue +37 -0
- package/src/components/skeleton/style.scss +94 -0
- package/src/components/skeleton/style.ts +1 -0
- package/src/components/space/index.ts +1 -0
- package/src/components/space/space.vue +45 -0
- package/src/components/space/style.scss +41 -0
- package/src/components/space/style.ts +1 -0
- package/src/components/time-picker/index.ts +1 -0
- package/src/components/time-picker/style.scss +82 -0
- package/src/components/time-picker/style.ts +3 -0
- package/src/components/time-picker/time-picker.vue +183 -0
- package/src/components/timeline/index.ts +2 -0
- package/src/components/timeline/style.scss +107 -0
- package/src/components/timeline/style.ts +1 -0
- package/src/components/timeline/timeline-item.vue +43 -0
- package/src/components/timeline/timeline.vue +17 -0
- package/src/components/transfer/index.ts +1 -0
- package/src/components/transfer/style.scss +135 -0
- package/src/components/transfer/style.ts +4 -0
- package/src/components/transfer/transfer-list.vue +120 -0
- package/src/components/transfer/transfer.vue +134 -0
- package/src/types/alert.ts +29 -0
- package/src/types/anchor.ts +50 -0
- package/src/types/avatar.ts +31 -0
- package/src/types/back-top.ts +20 -0
- package/src/types/carousel.ts +29 -0
- package/src/types/descriptions.ts +22 -0
- package/src/types/divider.ts +14 -0
- package/src/types/index.ts +16 -0
- package/src/types/layout.ts +2 -1
- package/src/types/rate.ts +27 -0
- package/src/types/skeleton.ts +29 -0
- package/src/types/space.ts +22 -0
- package/src/types/time-picker.ts +40 -0
- package/src/types/timeline.ts +15 -0
- package/src/types/transfer.ts +45 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
@use 'pkg:@veltra/styles/mixins' as m;
|
|
2
|
+
@use 'pkg:@veltra/styles/functions' as fn;
|
|
3
|
+
|
|
4
|
+
$root-name: carousel;
|
|
5
|
+
|
|
6
|
+
@include m.b($root-name) {
|
|
7
|
+
position: relative;
|
|
8
|
+
width: 100%;
|
|
9
|
+
overflow: hidden;
|
|
10
|
+
border-radius: fn.use-var(radius, default);
|
|
11
|
+
background-color: fn.use-var(bg-color, middle);
|
|
12
|
+
|
|
13
|
+
// 轨道:单层 flex 横排,经 translateX 整体滑动翻页;时长与缓动走 token
|
|
14
|
+
// (transform 过渡期间浏览器会自动提升合成层,不常驻 will-change 以免长期占用层内存)
|
|
15
|
+
@include m.e(track) {
|
|
16
|
+
display: flex;
|
|
17
|
+
transition: transform fn.use-var(transition, slow) fn.use-var(transition, ease-out);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@include m.e(item) {
|
|
21
|
+
flex: 0 0 100%;
|
|
22
|
+
width: 100%;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// 切换箭头:浮在内容上的半透明圆钮
|
|
26
|
+
@include m.e(arrow) {
|
|
27
|
+
position: absolute;
|
|
28
|
+
top: 50%;
|
|
29
|
+
z-index: 1;
|
|
30
|
+
display: inline-flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
justify-content: center;
|
|
33
|
+
// 圆钮直径 32px,保证可点击热区又不遮内容
|
|
34
|
+
width: 32px;
|
|
35
|
+
height: 32px;
|
|
36
|
+
padding: 0;
|
|
37
|
+
border: none;
|
|
38
|
+
border-radius: 50%;
|
|
39
|
+
transform: translateY(-50%);
|
|
40
|
+
cursor: pointer;
|
|
41
|
+
color: fn.use-var(text-color, white);
|
|
42
|
+
background-color: fn.color-a(bg-color, 70, black);
|
|
43
|
+
transition:
|
|
44
|
+
transform fn.use-var(transition, fast) fn.use-var(transition, ease),
|
|
45
|
+
opacity fn.use-var(transition, fast) fn.use-var(transition, ease);
|
|
46
|
+
|
|
47
|
+
&:hover:not(:disabled) {
|
|
48
|
+
transform: translateY(-50%) scale(1.08);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&:focus-visible {
|
|
52
|
+
box-shadow: fn.use-var(focus-ring);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&:disabled {
|
|
56
|
+
cursor: not-allowed;
|
|
57
|
+
opacity: 0.55;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@include m.m(prev) {
|
|
61
|
+
left: fn.use-var(gap, default);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@include m.m(next) {
|
|
65
|
+
right: fn.use-var(gap, default);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// 指示器圆点:激活项拉长为胶囊
|
|
70
|
+
@include m.e(dots) {
|
|
71
|
+
position: absolute;
|
|
72
|
+
bottom: fn.use-var(gap, small);
|
|
73
|
+
left: 0;
|
|
74
|
+
right: 0;
|
|
75
|
+
z-index: 1;
|
|
76
|
+
display: flex;
|
|
77
|
+
align-items: center;
|
|
78
|
+
justify-content: center;
|
|
79
|
+
gap: fn.use-var(gap, small);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@include m.e(dot) {
|
|
83
|
+
// 圆点直径 8px,激活时拉长为 20px 胶囊
|
|
84
|
+
width: 8px;
|
|
85
|
+
height: 8px;
|
|
86
|
+
padding: 0;
|
|
87
|
+
border: none;
|
|
88
|
+
border-radius: fn.use-var(radius, default);
|
|
89
|
+
cursor: pointer;
|
|
90
|
+
background-color: fn.color-a(text-color, 40, white);
|
|
91
|
+
transition:
|
|
92
|
+
width fn.use-var(transition, fast) fn.use-var(transition, ease),
|
|
93
|
+
background-color fn.use-var(transition, fast) fn.use-var(transition, ease);
|
|
94
|
+
|
|
95
|
+
&:hover {
|
|
96
|
+
background-color: fn.color-a(text-color, 70, white);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&:focus-visible {
|
|
100
|
+
box-shadow: fn.use-var(focus-ring);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
@include m.is(active) {
|
|
104
|
+
// 激活胶囊宽度,与 8px 圆点同高保持轴心不跳
|
|
105
|
+
width: 20px;
|
|
106
|
+
background-color: fn.use-var(text-color, white);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './style.scss'
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { MaybeRefOrGetter, ModelRef } from 'vue'
|
|
2
|
+
import { computed, onScopeDispose, toValue, watch } from 'vue'
|
|
3
|
+
|
|
4
|
+
export interface UseCarouselOptions {
|
|
5
|
+
/** 当前页索引,v-model:active-index */
|
|
6
|
+
model: ModelRef<number>
|
|
7
|
+
/** 页数,取已注册页数量 */
|
|
8
|
+
count: MaybeRefOrGetter<number>
|
|
9
|
+
/** 是否自动播放 */
|
|
10
|
+
autoplay: MaybeRefOrGetter<boolean>
|
|
11
|
+
/** 自动播放间隔(毫秒) */
|
|
12
|
+
interval: MaybeRefOrGetter<number>
|
|
13
|
+
/** 是否循环切换 */
|
|
14
|
+
loop: MaybeRefOrGetter<boolean>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 走马灯索引与自动播放计时:
|
|
19
|
+
* - `goTo` 把目标索引收敛到 `[0, 页数)`,越界按取模回绕
|
|
20
|
+
* - `prev` / `next` 单步切换,循环时回绕,非循环时停在边界
|
|
21
|
+
* - 自动播放开关、间隔、页数、当前页任一变化后重置计时,手动切换同样重新计时
|
|
22
|
+
*/
|
|
23
|
+
export function useCarousel({ model, count, autoplay, interval, loop }: UseCarouselOptions) {
|
|
24
|
+
const pageCount = () => Math.max(toValue(count), 0)
|
|
25
|
+
|
|
26
|
+
/** 展示索引:外部传入越界值时收敛到页数范围内,避免轨道滑出空白 */
|
|
27
|
+
const current = computed(() => {
|
|
28
|
+
const total = pageCount()
|
|
29
|
+
if (total <= 0) return 0
|
|
30
|
+
return Math.min(Math.max(model.value, 0), total - 1)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const goTo = (index: number) => {
|
|
34
|
+
const total = pageCount()
|
|
35
|
+
if (total <= 0) return
|
|
36
|
+
const next = ((index % total) + total) % total
|
|
37
|
+
if (next !== model.value) model.value = next
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const step = (direction: 1 | -1) => {
|
|
41
|
+
const total = pageCount()
|
|
42
|
+
if (total <= 1) return
|
|
43
|
+
const target = current.value + direction
|
|
44
|
+
if (toValue(loop)) {
|
|
45
|
+
goTo(target)
|
|
46
|
+
return
|
|
47
|
+
}
|
|
48
|
+
if (target >= 0 && target < total) goTo(target)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const canPrev = computed(() => toValue(loop) || current.value > 0)
|
|
52
|
+
const canNext = computed(() => toValue(loop) || current.value < pageCount() - 1)
|
|
53
|
+
|
|
54
|
+
const prev = () => step(-1)
|
|
55
|
+
const next = () => step(1)
|
|
56
|
+
|
|
57
|
+
let timer: ReturnType<typeof setInterval> | undefined
|
|
58
|
+
|
|
59
|
+
const stopAutoplay = () => {
|
|
60
|
+
if (timer !== undefined) {
|
|
61
|
+
clearInterval(timer)
|
|
62
|
+
timer = undefined
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const startAutoplay = () => {
|
|
67
|
+
stopAutoplay()
|
|
68
|
+
if (!toValue(autoplay) || pageCount() < 2) return
|
|
69
|
+
timer = setInterval(() => step(1), toValue(interval))
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
watch([autoplay, count, interval, current], startAutoplay)
|
|
73
|
+
|
|
74
|
+
onScopeDispose(stopAutoplay)
|
|
75
|
+
|
|
76
|
+
return { current, canPrev, canNext, goTo, prev, next }
|
|
77
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- 本组件不自行布局:由 UDescriptions 收集插槽 vnode 后渲染进键值表格 -->
|
|
3
|
+
<slot />
|
|
4
|
+
</template>
|
|
5
|
+
|
|
6
|
+
<script lang="ts" setup>
|
|
7
|
+
import type { DescriptionsItemProps } from '../../types'
|
|
8
|
+
|
|
9
|
+
defineOptions({ name: 'UDescriptionsItem' })
|
|
10
|
+
|
|
11
|
+
defineProps<DescriptionsItemProps>()
|
|
12
|
+
</script>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="classList">
|
|
3
|
+
<div v-if="title" :class="cls.e('header')">{{ title }}</div>
|
|
4
|
+
|
|
5
|
+
<table v-if="rows.length" :class="cls.e('table')">
|
|
6
|
+
<tbody>
|
|
7
|
+
<template v-for="(row, rowIndex) of rows" :key="rowIndex">
|
|
8
|
+
<template v-if="isVertical">
|
|
9
|
+
<tr>
|
|
10
|
+
<th v-for="(item, i) of row" :key="i" :class="cls.e('label')">
|
|
11
|
+
{{ item.label }}
|
|
12
|
+
</th>
|
|
13
|
+
</tr>
|
|
14
|
+
<tr>
|
|
15
|
+
<td v-for="(item, i) of row" :key="i" :class="cls.e('content')">
|
|
16
|
+
<component :is="item.vnode" />
|
|
17
|
+
</td>
|
|
18
|
+
</tr>
|
|
19
|
+
</template>
|
|
20
|
+
<tr v-else>
|
|
21
|
+
<template v-for="(item, i) of row" :key="i">
|
|
22
|
+
<th :class="cls.e('label')">{{ item.label }}</th>
|
|
23
|
+
<td :class="cls.e('content')">
|
|
24
|
+
<component :is="item.vnode" />
|
|
25
|
+
</td>
|
|
26
|
+
</template>
|
|
27
|
+
</tr>
|
|
28
|
+
</template>
|
|
29
|
+
</tbody>
|
|
30
|
+
</table>
|
|
31
|
+
</div>
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<script lang="ts" setup>
|
|
35
|
+
import { useFallbackProps } from '@veltra/compositions'
|
|
36
|
+
import { bem } from '@veltra/utils'
|
|
37
|
+
import { computed, useSlots, type VNode } from 'vue'
|
|
38
|
+
|
|
39
|
+
import type { ComponentSize, DescriptionsProps } from '../../types'
|
|
40
|
+
import UDescriptionsItem from './descriptions-item.vue'
|
|
41
|
+
|
|
42
|
+
defineOptions({ name: 'UDescriptions' })
|
|
43
|
+
|
|
44
|
+
const props = defineProps<DescriptionsProps>()
|
|
45
|
+
|
|
46
|
+
const { size } = useFallbackProps([props], { size: 'default' as ComponentSize })
|
|
47
|
+
|
|
48
|
+
const cls = bem('descriptions')
|
|
49
|
+
|
|
50
|
+
const slots = useSlots()
|
|
51
|
+
|
|
52
|
+
interface DescriptionItem {
|
|
53
|
+
label: string | undefined
|
|
54
|
+
vnode: VNode
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 插槽 vnode 须在渲染路径读取:插槽内容读取的响应式数据经调用链追踪,内容变化时重新计算
|
|
58
|
+
const rows = computed<DescriptionItem[][]>(() => {
|
|
59
|
+
const items = (slots.default?.() ?? []).filter((vnode) => vnode.type === UDescriptionsItem)
|
|
60
|
+
const column = Math.max(1, Math.trunc(props.column ?? 3))
|
|
61
|
+
|
|
62
|
+
const grouped: DescriptionItem[][] = []
|
|
63
|
+
for (let i = 0; i < items.length; i += column) {
|
|
64
|
+
grouped.push(
|
|
65
|
+
items
|
|
66
|
+
.slice(i, i + column)
|
|
67
|
+
.map((vnode) => ({ label: vnode.props?.label as string | undefined, vnode }))
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
return grouped
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
const isVertical = computed(() => props.layout === 'vertical')
|
|
74
|
+
|
|
75
|
+
const classList = computed(() => [
|
|
76
|
+
cls.b,
|
|
77
|
+
cls.m(props.layout ?? 'horizontal'),
|
|
78
|
+
cls.m(size.value),
|
|
79
|
+
bem.is('bordered', !!props.border)
|
|
80
|
+
])
|
|
81
|
+
</script>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
@use 'pkg:@veltra/styles/mixins' as m;
|
|
2
|
+
@use 'pkg:@veltra/styles/functions' as fn;
|
|
3
|
+
|
|
4
|
+
$root-name: descriptions;
|
|
5
|
+
|
|
6
|
+
@include m.b($root-name) {
|
|
7
|
+
font-size: fn.use-var(font-size-main, default);
|
|
8
|
+
line-height: 1.6;
|
|
9
|
+
color: fn.use-var(text-color, main);
|
|
10
|
+
|
|
11
|
+
@include m.e(header) {
|
|
12
|
+
margin-bottom: fn.use-var(gap, default);
|
|
13
|
+
font-weight: 600;
|
|
14
|
+
color: fn.use-var(text-color, main);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@include m.e(table) {
|
|
18
|
+
width: 100%;
|
|
19
|
+
table-layout: fixed;
|
|
20
|
+
border-collapse: separate;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@include m.e(label) {
|
|
24
|
+
padding: fn.use-var(gap, small) fn.use-var(gap, default);
|
|
25
|
+
text-align: start;
|
|
26
|
+
font-weight: 500;
|
|
27
|
+
color: fn.use-var(text-color, second);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@include m.e(content) {
|
|
31
|
+
padding: fn.use-var(gap, small) fn.use-var(gap, default);
|
|
32
|
+
word-break: break-word;
|
|
33
|
+
color: fn.use-var(text-color, main);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// 尺寸档位:字号随根尺寸类切换,单元格垂直内边距随档位收紧/放宽
|
|
37
|
+
@include m.size using ($size) {
|
|
38
|
+
font-size: fn.use-var(font-size, main, $size);
|
|
39
|
+
|
|
40
|
+
#{fn.bem($root-name, label)},
|
|
41
|
+
#{fn.bem($root-name, content)} {
|
|
42
|
+
padding: fn.use-var(gap, $size) fn.use-var(gap, default);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// 垂直布局:键名行与内容行上下紧贴
|
|
47
|
+
@include m.m(vertical) {
|
|
48
|
+
#{fn.bem($root-name, label)} {
|
|
49
|
+
padding-bottom: 0;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
#{fn.bem($root-name, content)} {
|
|
53
|
+
padding-top: fn.use-var(gap, small);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 边框模式:单元格描边 + 键名底色,外层表格描边合成完整网格
|
|
58
|
+
@include m.is(bordered) {
|
|
59
|
+
#{fn.bem($root-name, table)} {
|
|
60
|
+
border-collapse: collapse;
|
|
61
|
+
border: fn.use-var(border-muted);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
#{fn.bem($root-name, label)} {
|
|
65
|
+
background-color: fn.use-var(bg-color, middle);
|
|
66
|
+
border: fn.use-var(border-muted);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
#{fn.bem($root-name, content)} {
|
|
70
|
+
border: fn.use-var(border-muted);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './style.scss'
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="className" role="separator" :aria-orientation="direction">
|
|
3
|
+
<span v-if="slots.default" :class="cls.e('text')">
|
|
4
|
+
<slot />
|
|
5
|
+
</span>
|
|
6
|
+
</div>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script lang="ts" setup>
|
|
10
|
+
import { bem } from '@veltra/utils'
|
|
11
|
+
import { computed, useSlots } from 'vue'
|
|
12
|
+
|
|
13
|
+
import type { DividerProps } from '../../types'
|
|
14
|
+
|
|
15
|
+
defineOptions({ name: 'UDivider' })
|
|
16
|
+
|
|
17
|
+
const { direction = 'horizontal', dashed = false, align = 'center' } = defineProps<DividerProps>()
|
|
18
|
+
|
|
19
|
+
const slots = useSlots()
|
|
20
|
+
const cls = bem('divider')
|
|
21
|
+
|
|
22
|
+
const className = computed(() => [
|
|
23
|
+
cls.b,
|
|
24
|
+
cls.m(direction),
|
|
25
|
+
bem.is('dashed', dashed),
|
|
26
|
+
bem.is('with-text', !!slots.default),
|
|
27
|
+
slots.default && cls.m(align)
|
|
28
|
+
])
|
|
29
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as UDivider } from './divider.vue'
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
@use 'pkg:@veltra/styles/mixins' as m;
|
|
2
|
+
@use 'pkg:@veltra/styles/functions' as fn;
|
|
3
|
+
|
|
4
|
+
// 方便拼接
|
|
5
|
+
$root-name: divider;
|
|
6
|
+
|
|
7
|
+
// 文字靠左/靠右时,对侧长线之外那一侧的短线宽度
|
|
8
|
+
$short-line-width: 5%;
|
|
9
|
+
|
|
10
|
+
@include m.b($root-name) {
|
|
11
|
+
// 水平分割线(默认形态):单独使用时由上边框划线
|
|
12
|
+
border-top: 1px solid fn.use-var(border-color);
|
|
13
|
+
margin: fn.use-var(gap, large) 0;
|
|
14
|
+
|
|
15
|
+
// 虚线
|
|
16
|
+
@include m.is(dashed) {
|
|
17
|
+
border-top-style: dashed;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// 垂直分割线:行内元素,随文字高度伸缩
|
|
21
|
+
@include m.m(vertical) {
|
|
22
|
+
display: inline-block;
|
|
23
|
+
border-top: none;
|
|
24
|
+
border-left: 1px solid fn.use-var(border-color);
|
|
25
|
+
height: 1em;
|
|
26
|
+
margin: 0 fn.use-var(gap);
|
|
27
|
+
vertical-align: middle;
|
|
28
|
+
|
|
29
|
+
@include m.is(dashed) {
|
|
30
|
+
border-left-style: dashed;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 嵌套文字:两侧伪元素划线,文字默认居中
|
|
35
|
+
@include m.is(with-text) {
|
|
36
|
+
display: flex;
|
|
37
|
+
align-items: center;
|
|
38
|
+
border-top: none;
|
|
39
|
+
margin: fn.use-var(gap, large) 0;
|
|
40
|
+
|
|
41
|
+
&::before,
|
|
42
|
+
&::after {
|
|
43
|
+
content: '';
|
|
44
|
+
flex: 1;
|
|
45
|
+
border-top: 1px solid fn.use-var(border-color);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&::before {
|
|
49
|
+
margin-right: fn.use-var(gap);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&::after {
|
|
53
|
+
margin-left: fn.use-var(gap);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// 虚线作用于两侧伪元素线
|
|
57
|
+
@include m.is(dashed) {
|
|
58
|
+
&::before,
|
|
59
|
+
&::after {
|
|
60
|
+
border-top-style: dashed;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// 文字靠左:左线收窄为短线
|
|
66
|
+
@include m.m(left) {
|
|
67
|
+
@include m.is(with-text) {
|
|
68
|
+
&::before {
|
|
69
|
+
flex: none;
|
|
70
|
+
width: $short-line-width;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 文字靠右:右线收窄为短线
|
|
76
|
+
@include m.m(right) {
|
|
77
|
+
@include m.is(with-text) {
|
|
78
|
+
&::after {
|
|
79
|
+
flex: none;
|
|
80
|
+
width: $short-line-width;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@include m.e(text) {
|
|
86
|
+
color: fn.use-var(text-color, main);
|
|
87
|
+
font-size: fn.use-var(font-size, main);
|
|
88
|
+
white-space: nowrap;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './style.scss'
|
|
@@ -149,7 +149,7 @@ import { usePreview } from './use-preview'
|
|
|
149
149
|
import { SELECTION_HANDLES, useSelection } from './use-selection'
|
|
150
150
|
import { useTransform } from './use-transform'
|
|
151
151
|
|
|
152
|
-
defineOptions({ name: '
|
|
152
|
+
defineOptions({ name: 'UImageCropper' })
|
|
153
153
|
|
|
154
154
|
const props = withDefaults(defineProps<ImageCropperProps>(), {
|
|
155
155
|
showToolbar: true,
|
package/src/components/index.ts
CHANGED
|
@@ -86,6 +86,8 @@ export * from './action'
|
|
|
86
86
|
|
|
87
87
|
export * from './tip'
|
|
88
88
|
|
|
89
|
+
export * from './transfer'
|
|
90
|
+
|
|
89
91
|
export * from './textarea'
|
|
90
92
|
|
|
91
93
|
export * from './button'
|
|
@@ -155,3 +157,27 @@ export * from './segment'
|
|
|
155
157
|
export * from './image-cropper'
|
|
156
158
|
|
|
157
159
|
export * from './kanban'
|
|
160
|
+
|
|
161
|
+
export * from './anchor'
|
|
162
|
+
|
|
163
|
+
export * from './avatar'
|
|
164
|
+
|
|
165
|
+
export * from './back-top'
|
|
166
|
+
|
|
167
|
+
export * from './alert'
|
|
168
|
+
|
|
169
|
+
export * from './rate'
|
|
170
|
+
|
|
171
|
+
export * from './divider'
|
|
172
|
+
|
|
173
|
+
export * from './space'
|
|
174
|
+
|
|
175
|
+
export * from './skeleton'
|
|
176
|
+
|
|
177
|
+
export * from './time-picker'
|
|
178
|
+
|
|
179
|
+
export * from './descriptions'
|
|
180
|
+
|
|
181
|
+
export * from './timeline'
|
|
182
|
+
|
|
183
|
+
export * from './carousel'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as URate } from './rate.vue'
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
:class="className"
|
|
4
|
+
:style="rateStyle"
|
|
5
|
+
:tabindex="interactive ? 0 : -1"
|
|
6
|
+
role="slider"
|
|
7
|
+
:aria-valuemin="0"
|
|
8
|
+
:aria-valuemax="count"
|
|
9
|
+
:aria-valuenow="model"
|
|
10
|
+
@mouseleave="hoverValue = undefined"
|
|
11
|
+
@keydown="handleKeydown"
|
|
12
|
+
>
|
|
13
|
+
<div
|
|
14
|
+
v-for="star in count"
|
|
15
|
+
:key="star"
|
|
16
|
+
:class="cls.e('item')"
|
|
17
|
+
@mousemove="handleItemMove(star, $event)"
|
|
18
|
+
@click="handleItemClick(star, $event)"
|
|
19
|
+
>
|
|
20
|
+
<span :class="cls.e('base')">
|
|
21
|
+
<u-icon v-if="!character"><StarFilled /></u-icon>
|
|
22
|
+
<template v-else>{{ character }}</template>
|
|
23
|
+
</span>
|
|
24
|
+
|
|
25
|
+
<span :class="cls.e('overlay')" :style="{ width: overlayWidth(star) }">
|
|
26
|
+
<u-icon v-if="!character"><StarFilled /></u-icon>
|
|
27
|
+
<template v-else>{{ character }}</template>
|
|
28
|
+
</span>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<script lang="ts" setup>
|
|
34
|
+
import { useFormFallbackProps } from '@veltra/compositions'
|
|
35
|
+
import { StarFilled } from '@veltra/icons/normal'
|
|
36
|
+
import { bem, injectFormContext } from '@veltra/utils'
|
|
37
|
+
import { computed, ref, type CSSProperties } from 'vue'
|
|
38
|
+
|
|
39
|
+
import type { RateEmits, RateProps } from '../../types'
|
|
40
|
+
import { UIcon } from '../icon'
|
|
41
|
+
|
|
42
|
+
defineOptions({ name: 'URate' })
|
|
43
|
+
|
|
44
|
+
const props = defineProps<RateProps>()
|
|
45
|
+
|
|
46
|
+
const emit = defineEmits<RateEmits>()
|
|
47
|
+
|
|
48
|
+
const cls = bem('rate')
|
|
49
|
+
|
|
50
|
+
const model = defineModel<number>({ default: 0 })
|
|
51
|
+
|
|
52
|
+
const { formProps } = injectFormContext()
|
|
53
|
+
|
|
54
|
+
const { disabled, readonly } = useFormFallbackProps([formProps ?? {}, props])
|
|
55
|
+
|
|
56
|
+
const count = computed(() => props.count ?? 5)
|
|
57
|
+
|
|
58
|
+
/** 步长:允许半星时 0.5,否则 1 */
|
|
59
|
+
const step = computed(() => (props.allowHalf ? 0.5 : 1))
|
|
60
|
+
|
|
61
|
+
/** 悬浮预览的分值,未悬浮时为 undefined */
|
|
62
|
+
const hoverValue = ref<number | undefined>()
|
|
63
|
+
|
|
64
|
+
const interactive = computed(() => !disabled.value && !readonly.value)
|
|
65
|
+
|
|
66
|
+
const className = computed(() => [
|
|
67
|
+
cls.b,
|
|
68
|
+
bem.is('disabled', disabled.value),
|
|
69
|
+
bem.is('readonly', readonly.value)
|
|
70
|
+
])
|
|
71
|
+
|
|
72
|
+
/** color 属性经 CSS 变量注入,未传时走 token 默认值 */
|
|
73
|
+
const rateStyle = computed<CSSProperties>(() => ({ '--u-rate-active-color': props.color }))
|
|
74
|
+
|
|
75
|
+
/** 当前展示分值:悬浮预览优先 */
|
|
76
|
+
const displayValue = computed(() => hoverValue.value ?? model.value)
|
|
77
|
+
|
|
78
|
+
/** 第 star 颗星彩色层的裁剪宽度 */
|
|
79
|
+
const overlayWidth = (star: number) => {
|
|
80
|
+
const value = displayValue.value
|
|
81
|
+
if (value >= star) return '100%'
|
|
82
|
+
if (props.allowHalf && value >= star - 0.5) return '50%'
|
|
83
|
+
return '0%'
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** 按事件位置算分值:左半颗 0.5(allowHalf 时),右半颗整颗 */
|
|
87
|
+
const eventToValue = (star: number, e: MouseEvent) => {
|
|
88
|
+
if (!props.allowHalf) return star
|
|
89
|
+
|
|
90
|
+
const rect = (e.currentTarget as HTMLElement).getBoundingClientRect()
|
|
91
|
+
return e.clientX - rect.left < rect.width / 2 ? star - 0.5 : star
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const handleItemMove = (star: number, e: MouseEvent) => {
|
|
95
|
+
if (!interactive.value) return
|
|
96
|
+
hoverValue.value = eventToValue(star, e)
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const handleItemClick = (star: number, e: MouseEvent) => {
|
|
100
|
+
if (!interactive.value) return
|
|
101
|
+
setValue(eventToValue(star, e))
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const handleKeydown = (e: KeyboardEvent) => {
|
|
105
|
+
if (!interactive.value) return
|
|
106
|
+
|
|
107
|
+
const keyMap: Record<string, number> = {
|
|
108
|
+
ArrowRight: step.value,
|
|
109
|
+
ArrowUp: step.value,
|
|
110
|
+
ArrowLeft: -step.value,
|
|
111
|
+
ArrowDown: -step.value
|
|
112
|
+
}
|
|
113
|
+
const delta = keyMap[e.key]
|
|
114
|
+
if (delta === undefined) return
|
|
115
|
+
|
|
116
|
+
e.preventDefault()
|
|
117
|
+
setValue(clamp(model.value + delta))
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const clamp = (value: number) => Math.min(Math.max(value, 0), count.value)
|
|
121
|
+
|
|
122
|
+
const setValue = (value: number) => {
|
|
123
|
+
if (value === model.value) return
|
|
124
|
+
model.value = value
|
|
125
|
+
emit('change', value)
|
|
126
|
+
}
|
|
127
|
+
</script>
|