@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,51 @@
|
|
|
1
|
+
@use 'pkg:@veltra/styles/mixins' as m;
|
|
2
|
+
@use 'pkg:@veltra/styles/functions' as fn;
|
|
3
|
+
|
|
4
|
+
$root-name: rate;
|
|
5
|
+
|
|
6
|
+
@include m.b($root-name) {
|
|
7
|
+
@include m.flex(inline-flex, flex-start, center);
|
|
8
|
+
gap: fn.use-var(gap, small);
|
|
9
|
+
font-size: fn.use-var(font-size, main, large);
|
|
10
|
+
outline: none;
|
|
11
|
+
border-radius: fn.use-var(radius, small);
|
|
12
|
+
|
|
13
|
+
@include m.is(disabled) {
|
|
14
|
+
cursor: not-allowed;
|
|
15
|
+
opacity: 0.55;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@include m.is(readonly) {
|
|
19
|
+
cursor: default;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@include m.is-not(readonly, disabled) {
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
|
|
25
|
+
&:focus-visible {
|
|
26
|
+
box-shadow: fn.use-var(focus-ring);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@include m.e(item) {
|
|
31
|
+
position: relative;
|
|
32
|
+
display: inline-flex;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@include m.e(base) {
|
|
36
|
+
display: inline-flex;
|
|
37
|
+
color: fn.use-var(text-color, placeholder);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 彩色层按分值裁剪宽度,叠在灰色底星上
|
|
41
|
+
@include m.e(overlay) {
|
|
42
|
+
position: absolute;
|
|
43
|
+
top: 0;
|
|
44
|
+
left: 0;
|
|
45
|
+
height: 100%;
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
white-space: nowrap;
|
|
48
|
+
pointer-events: none;
|
|
49
|
+
color: fn.component-var(rate, active-color, fn.use-var(color, warning));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './style.scss'
|
|
@@ -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 { bem } from '@veltra/utils'
|
|
17
|
+
import { computed } from 'vue'
|
|
18
|
+
|
|
19
|
+
import type { SkeletonProps } from '../../types'
|
|
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,94 @@
|
|
|
1
|
+
@use 'pkg:@veltra/styles/mixins' as m;
|
|
2
|
+
@use 'pkg:@veltra/styles/functions' as fn;
|
|
3
|
+
|
|
4
|
+
// 方便拼接
|
|
5
|
+
$root-name: skeleton;
|
|
6
|
+
|
|
7
|
+
// 头像占位边长(正方形圆形头像)
|
|
8
|
+
$avatar-size: 40px;
|
|
9
|
+
// 标题占位高度与宽度(宽度按内容区比例收窄)
|
|
10
|
+
$title-height: 16px;
|
|
11
|
+
$title-width: 33%;
|
|
12
|
+
// 段落行占位高度与末行宽度(末行收窄模拟自然段落)
|
|
13
|
+
$paragraph-height: 14px;
|
|
14
|
+
$paragraph-last-width: 60%;
|
|
15
|
+
// 按钮形态占位宽度(高度走 form-component-height token)
|
|
16
|
+
$button-width: 80px;
|
|
17
|
+
// 呼吸动画一轮时长(token 无该量级档位,组件级常量)
|
|
18
|
+
$pulse-duration: 1.4s;
|
|
19
|
+
|
|
20
|
+
@include m.b($root-name) {
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: flex-start;
|
|
23
|
+
gap: fn.use-var(gap, default);
|
|
24
|
+
|
|
25
|
+
// 头像占位
|
|
26
|
+
@include m.e(avatar) {
|
|
27
|
+
flex: none;
|
|
28
|
+
width: $avatar-size;
|
|
29
|
+
height: $avatar-size;
|
|
30
|
+
border-radius: 50%;
|
|
31
|
+
background-color: fn.use-var(bg-color, hover);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 文本区占位
|
|
35
|
+
@include m.e(content) {
|
|
36
|
+
flex: 1;
|
|
37
|
+
display: flex;
|
|
38
|
+
flex-direction: column;
|
|
39
|
+
gap: fn.use-var(gap, default);
|
|
40
|
+
min-width: 0;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// 标题占位
|
|
44
|
+
@include m.e(title) {
|
|
45
|
+
height: $title-height;
|
|
46
|
+
width: $title-width;
|
|
47
|
+
border-radius: fn.use-var(radius, small);
|
|
48
|
+
background-color: fn.use-var(bg-color, hover);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// 段落占位:末行收窄模拟自然段落
|
|
52
|
+
@include m.e(paragraph) {
|
|
53
|
+
height: $paragraph-height;
|
|
54
|
+
border-radius: fn.use-var(radius, small);
|
|
55
|
+
background-color: fn.use-var(bg-color, hover);
|
|
56
|
+
|
|
57
|
+
&:last-child {
|
|
58
|
+
width: $paragraph-last-width;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 按钮形态占位
|
|
63
|
+
@include m.e(button) {
|
|
64
|
+
width: $button-width;
|
|
65
|
+
height: fn.use-var(form-component-height, default);
|
|
66
|
+
border-radius: fn.use-var(radius, default);
|
|
67
|
+
background-color: fn.use-var(bg-color, hover);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// 胶囊圆角:作用于标题 / 段落 / 按钮
|
|
71
|
+
@include m.is(round) {
|
|
72
|
+
@include m.bem($root-name, title paragraph button) {
|
|
73
|
+
border-radius: fn.use-var(radius, large);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// 动画:占位块呼吸明暗
|
|
78
|
+
@include m.is(animated) {
|
|
79
|
+
@include m.bem($root-name, avatar title paragraph button) {
|
|
80
|
+
animation: skeleton-pulse $pulse-duration ease-in-out infinite;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
@keyframes skeleton-pulse {
|
|
86
|
+
0%,
|
|
87
|
+
100% {
|
|
88
|
+
opacity: 1;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
50% {
|
|
92
|
+
opacity: 0.4;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -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="className" :style="style">
|
|
3
|
+
<slot />
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script lang="ts" setup>
|
|
8
|
+
import { bem } from '@veltra/utils'
|
|
9
|
+
import { computed } from 'vue'
|
|
10
|
+
|
|
11
|
+
import type { SpaceProps } from '../../types'
|
|
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 className = 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;
|
|
2
|
+
@use 'pkg:@veltra/styles/functions' as fn;
|
|
3
|
+
|
|
4
|
+
// 方便拼接
|
|
5
|
+
$root-name: space;
|
|
6
|
+
|
|
7
|
+
@include m.b($root-name) {
|
|
8
|
+
display: inline-flex;
|
|
9
|
+
gap: fn.use-var(gap, default);
|
|
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
|
+
// 间距档:走主题 gap token
|
|
21
|
+
@include m.m(small) {
|
|
22
|
+
gap: fn.use-var(gap, small);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@include m.m(large) {
|
|
26
|
+
gap: fn.use-var(gap, large);
|
|
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 UTimePicker } from './time-picker.vue'
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
@use 'pkg:@veltra/styles/mixins' as m;
|
|
2
|
+
@use 'pkg:@veltra/styles/functions' as fn;
|
|
3
|
+
@use 'pkg:@veltra/styles/vars';
|
|
4
|
+
|
|
5
|
+
// 方便拼接
|
|
6
|
+
$root-name: time-picker;
|
|
7
|
+
|
|
8
|
+
@include m.b($root-name) {
|
|
9
|
+
width: 100%;
|
|
10
|
+
|
|
11
|
+
@include m.size using ($size) {
|
|
12
|
+
@include m.bem($root-name, icon) {
|
|
13
|
+
font-size: calc(fn.use-var(form-component-height, $size) / 2 + 2px);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@include m.e(panel) {
|
|
18
|
+
@include m.flex($justify: space-between);
|
|
19
|
+
gap: fn.use-var(gap, default);
|
|
20
|
+
padding: fn.use-var(gap, default);
|
|
21
|
+
|
|
22
|
+
// 一列可见 7 项;上下补 3 项高的占位,使首尾项也能滚动到可视区中央
|
|
23
|
+
@include m.size using ($size) {
|
|
24
|
+
font-size: fn.use-var(font-size-main, $size);
|
|
25
|
+
|
|
26
|
+
@include m.bem($root-name, column) {
|
|
27
|
+
height: calc(fn.use-var(form-component-height, $size) * 7);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@include m.bem($root-name, item) {
|
|
31
|
+
height: fn.use-var(form-component-height, $size);
|
|
32
|
+
line-height: fn.use-var(form-component-height, $size);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@include m.bem($root-name, spacer) {
|
|
36
|
+
height: calc(fn.use-var(form-component-height, $size) * 3);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@include m.e(column) {
|
|
42
|
+
position: relative;
|
|
43
|
+
// 固定列宽容纳两位数「00–59」+ item 两侧各 4px 内缩的选中底
|
|
44
|
+
width: 56px;
|
|
45
|
+
flex: none;
|
|
46
|
+
overflow-y: auto;
|
|
47
|
+
scrollbar-width: none;
|
|
48
|
+
|
|
49
|
+
&::-webkit-scrollbar {
|
|
50
|
+
display: none;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@include m.e(item) {
|
|
55
|
+
margin: 0 4px;
|
|
56
|
+
text-align: center;
|
|
57
|
+
border-radius: 99px;
|
|
58
|
+
cursor: pointer;
|
|
59
|
+
user-select: none;
|
|
60
|
+
color: fn.use-var(text-color, main);
|
|
61
|
+
transition: background-color fn.use-var(transition, fast) fn.use-var(transition, ease);
|
|
62
|
+
|
|
63
|
+
&:hover {
|
|
64
|
+
background-color: fn.use-var(bg-color, hover);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@include m.is(selected) {
|
|
68
|
+
background-color: fn.use-var(color, primary);
|
|
69
|
+
color: fn.use-var(text-color, white);
|
|
70
|
+
font-weight: 600;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
@include m.is(disabled) {
|
|
74
|
+
cursor: not-allowed;
|
|
75
|
+
color: fn.use-var(text-color, disabled);
|
|
76
|
+
|
|
77
|
+
&:hover {
|
|
78
|
+
background-color: transparent;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<u-dropdown
|
|
3
|
+
v-if="!readonly"
|
|
4
|
+
v-bind="$attrs"
|
|
5
|
+
:class="className"
|
|
6
|
+
trigger="click"
|
|
7
|
+
width="auto"
|
|
8
|
+
:disabled="disabled"
|
|
9
|
+
>
|
|
10
|
+
<template #trigger>
|
|
11
|
+
<u-input
|
|
12
|
+
:size="size"
|
|
13
|
+
native-readonly
|
|
14
|
+
:clearable="clearable"
|
|
15
|
+
:placeholder="placeholder"
|
|
16
|
+
:model-value="displayedValue"
|
|
17
|
+
:disabled="disabled"
|
|
18
|
+
@clear="handleClear"
|
|
19
|
+
>
|
|
20
|
+
<template #suffix>
|
|
21
|
+
<u-icon :class="cls.e('icon')"><Time /></u-icon>
|
|
22
|
+
</template>
|
|
23
|
+
</u-input>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<template #content>
|
|
27
|
+
<div :ref="scrollSelectedToCenter" :class="[cls.e('panel'), cls.em('panel', size)]">
|
|
28
|
+
<div v-for="col in columns" :key="col.name" :class="cls.e('column')">
|
|
29
|
+
<div :class="cls.e('spacer')" aria-hidden="true"></div>
|
|
30
|
+
<div
|
|
31
|
+
v-for="item in col.values"
|
|
32
|
+
:key="item.value"
|
|
33
|
+
:class="[
|
|
34
|
+
cls.e('item'),
|
|
35
|
+
bem.is('selected', col.selected === item.value),
|
|
36
|
+
bem.is('disabled', item.disabled)
|
|
37
|
+
]"
|
|
38
|
+
@click="handleSelect(col.name, item)"
|
|
39
|
+
>
|
|
40
|
+
{{ pad(item.value) }}
|
|
41
|
+
</div>
|
|
42
|
+
<div :class="cls.e('spacer')" aria-hidden="true"></div>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
</template>
|
|
46
|
+
</u-dropdown>
|
|
47
|
+
|
|
48
|
+
<template v-else>
|
|
49
|
+
{{ displayedValue || FORM_EMPTY_CONTENT }}
|
|
50
|
+
</template>
|
|
51
|
+
</template>
|
|
52
|
+
|
|
53
|
+
<script lang="ts" setup>
|
|
54
|
+
import { date, Dater } from '@cat-kit/core'
|
|
55
|
+
import { useFormFallbackProps, useUserAction } from '@veltra/compositions'
|
|
56
|
+
import { Time } from '@veltra/icons/normal'
|
|
57
|
+
import { bem, FORM_EMPTY_CONTENT, injectFormContext } from '@veltra/utils'
|
|
58
|
+
import { computed, nextTick, shallowRef, watch } from 'vue'
|
|
59
|
+
|
|
60
|
+
import type { TimePickerEmits, TimePickerProps } from '../../types'
|
|
61
|
+
import { UDropdown } from '../dropdown'
|
|
62
|
+
import { UIcon } from '../icon'
|
|
63
|
+
import { UInput } from '../input'
|
|
64
|
+
|
|
65
|
+
defineOptions({ name: 'UTimePicker', inheritAttrs: false })
|
|
66
|
+
|
|
67
|
+
const props = defineProps<TimePickerProps>()
|
|
68
|
+
|
|
69
|
+
const emit = defineEmits<TimePickerEmits>()
|
|
70
|
+
|
|
71
|
+
const cls = bem('time-picker')
|
|
72
|
+
|
|
73
|
+
const { formProps } = injectFormContext()
|
|
74
|
+
|
|
75
|
+
const { size, disabled, readonly } = useFormFallbackProps([formProps ?? {}, props], {
|
|
76
|
+
size: 'default',
|
|
77
|
+
disabled: false,
|
|
78
|
+
readonly: false
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
const className = computed(() => [cls.b, cls.m(size.value)])
|
|
82
|
+
|
|
83
|
+
const placeholder = computed(() => props.placeholder ?? '选择时间')
|
|
84
|
+
|
|
85
|
+
const clearable = computed(() => props.clearable ?? true)
|
|
86
|
+
|
|
87
|
+
const formatStr = computed(() => props.format ?? 'HH:mm:ss')
|
|
88
|
+
|
|
89
|
+
const currentTime = shallowRef<Dater>()
|
|
90
|
+
|
|
91
|
+
const { userAction, isUserActive } = useUserAction()
|
|
92
|
+
|
|
93
|
+
function parseModelValue(val?: string | number | Date): Dater | undefined {
|
|
94
|
+
if (val == null || val === '') return undefined
|
|
95
|
+
if (val instanceof Date || typeof val === 'number') {
|
|
96
|
+
const d = date(val)
|
|
97
|
+
return isNaN(d.timestamp) ? undefined : d
|
|
98
|
+
}
|
|
99
|
+
const parsed = Dater.parse(val, props.valueFormat ?? formatStr.value)
|
|
100
|
+
if (!isNaN(parsed.timestamp)) return parsed
|
|
101
|
+
const fallback = date(val)
|
|
102
|
+
return isNaN(fallback.timestamp) ? undefined : fallback
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
watch(
|
|
106
|
+
() => props.modelValue,
|
|
107
|
+
(modelValue) => {
|
|
108
|
+
if (isUserActive()) return
|
|
109
|
+
currentTime.value = parseModelValue(modelValue)
|
|
110
|
+
},
|
|
111
|
+
{ immediate: true }
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
const displayedValue = computed(() => currentTime.value?.format(formatStr.value) ?? '')
|
|
115
|
+
|
|
116
|
+
type TimeUnit = 'hours' | 'minutes' | 'seconds'
|
|
117
|
+
|
|
118
|
+
interface TimeItem {
|
|
119
|
+
value: number
|
|
120
|
+
disabled: boolean
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const columns = computed(() => {
|
|
124
|
+
const t = currentTime.value
|
|
125
|
+
const disabledHours = new Set(props.disabledHours?.() ?? [])
|
|
126
|
+
const disabledMinutes = new Set(props.disabledMinutes?.(t?.hours ?? 0) ?? [])
|
|
127
|
+
const disabledSeconds = new Set(props.disabledSeconds?.(t?.hours ?? 0, t?.minutes ?? 0) ?? [])
|
|
128
|
+
|
|
129
|
+
return [
|
|
130
|
+
{ name: 'hours' as const, selected: t?.hours, values: buildValues(24, disabledHours) },
|
|
131
|
+
{ name: 'minutes' as const, selected: t?.minutes, values: buildValues(60, disabledMinutes) },
|
|
132
|
+
{ name: 'seconds' as const, selected: t?.seconds, values: buildValues(60, disabledSeconds) }
|
|
133
|
+
]
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
function buildValues(count: number, disabled: Set<number>): TimeItem[] {
|
|
137
|
+
return Array.from({ length: count }, (_, value) => ({ value, disabled: disabled.has(value) }))
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const pad = (value: number) => `${value}`.padStart(2, '0')
|
|
141
|
+
|
|
142
|
+
function formatModelValue(d: Dater) {
|
|
143
|
+
if (props.dataType === 'date') return d.raw
|
|
144
|
+
if (props.dataType === 'timestamp') return d.timestamp
|
|
145
|
+
return d.format(props.valueFormat ?? formatStr.value)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const commitSelectedTime = userAction((time: Dater) => {
|
|
149
|
+
currentTime.value = time
|
|
150
|
+
emit('update:modelValue', formatModelValue(time))
|
|
151
|
+
emit('change', time.raw)
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
function handleSelect(unit: TimeUnit, item: TimeItem) {
|
|
155
|
+
if (item.disabled) return
|
|
156
|
+
// 无初值时以当天 00:00:00 为基底,只改点击的维度,未选维度保持 0
|
|
157
|
+
const next = (currentTime.value ?? date().setHours(0).setMinutes(0).setSeconds(0)).clone()
|
|
158
|
+
if (unit === 'hours') next.setHours(item.value)
|
|
159
|
+
else if (unit === 'minutes') next.setMinutes(item.value)
|
|
160
|
+
else next.setSeconds(item.value)
|
|
161
|
+
commitSelectedTime(next)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function handleClear() {
|
|
165
|
+
currentTime.value = undefined
|
|
166
|
+
emit('update:modelValue', undefined)
|
|
167
|
+
emit('change', undefined)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** 函数 ref:面板经 Teleport 挂载时元素先创建、后插入文档(ref 回调时还未连接),推迟到 nextTick 再把各列滚动到选中值居中 */
|
|
171
|
+
function scrollSelectedToCenter(panel: Element | null) {
|
|
172
|
+
if (!(panel instanceof HTMLElement)) return
|
|
173
|
+
nextTick(() => {
|
|
174
|
+
if (!panel.isConnected) return
|
|
175
|
+
for (const column of panel.querySelectorAll<HTMLElement>(`.${cls.e('column')}`)) {
|
|
176
|
+
const selected = column.querySelector('.is-selected')
|
|
177
|
+
if (selected instanceof HTMLElement) {
|
|
178
|
+
column.scrollTop = selected.offsetTop - (column.clientHeight - selected.offsetHeight) / 2
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
</script>
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
@use 'pkg:@veltra/styles/mixins' as m;
|
|
2
|
+
@use 'pkg:@veltra/styles/functions' as fn;
|
|
3
|
+
|
|
4
|
+
$root-name: 'timeline';
|
|
5
|
+
|
|
6
|
+
// 首行行高系数:与根 line-height 保持一致,圆点、尾线、时间戳的对齐基准由它派生
|
|
7
|
+
$line-ratio: 1.6;
|
|
8
|
+
// 内容首行行盒高度:圆点垂直中心的对齐目标
|
|
9
|
+
$first-line: calc(#{fn.use-var(font-size-main, default)} * #{$line-ratio});
|
|
10
|
+
// 圆点直径(几何常量)
|
|
11
|
+
$node-size: 12px;
|
|
12
|
+
// 尾线宽度(几何常量)
|
|
13
|
+
$tail-width: 2px;
|
|
14
|
+
|
|
15
|
+
@include m.b($root-name) {
|
|
16
|
+
margin: 0;
|
|
17
|
+
padding: 0;
|
|
18
|
+
list-style: none;
|
|
19
|
+
font-size: fn.use-var(font-size-main, default);
|
|
20
|
+
line-height: $line-ratio;
|
|
21
|
+
color: fn.use-var(text-color, main);
|
|
22
|
+
|
|
23
|
+
@include m.e(item) {
|
|
24
|
+
position: relative;
|
|
25
|
+
padding-left: calc(#{$node-size} + fn.use-var(gap, default));
|
|
26
|
+
padding-bottom: fn.use-var(gap, large);
|
|
27
|
+
|
|
28
|
+
// 尾线:伪元素绘制,起点在圆点下方一个小间距,水平中心与圆点同心
|
|
29
|
+
&::before {
|
|
30
|
+
content: '';
|
|
31
|
+
position: absolute;
|
|
32
|
+
left: calc((#{$node-size} - #{$tail-width}) / 2);
|
|
33
|
+
top: calc((#{$first-line} + #{$node-size}) / 2 + fn.use-var(gap, small));
|
|
34
|
+
bottom: 0;
|
|
35
|
+
border-left: #{$tail-width} solid fn.use-var(border-color);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&:last-child {
|
|
39
|
+
padding-bottom: 0;
|
|
40
|
+
|
|
41
|
+
&::before {
|
|
42
|
+
display: none;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// 节点盒:高度等于首行行盒,盒内垂直居中即与首行文字中心对齐(纯 CSS,自定义 #dot 同样适用)
|
|
48
|
+
@include m.e(node) {
|
|
49
|
+
position: absolute;
|
|
50
|
+
left: 0;
|
|
51
|
+
top: 0;
|
|
52
|
+
display: flex;
|
|
53
|
+
align-items: center;
|
|
54
|
+
justify-content: center;
|
|
55
|
+
width: $node-size;
|
|
56
|
+
height: $first-line;
|
|
57
|
+
|
|
58
|
+
// 默认圆点
|
|
59
|
+
&::before {
|
|
60
|
+
content: '';
|
|
61
|
+
width: $node-size;
|
|
62
|
+
height: $node-size;
|
|
63
|
+
border-radius: 50%;
|
|
64
|
+
background-color: fn.use-var(border-color);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// 语义色圆点
|
|
68
|
+
@each $type in (primary, success, warning, danger) {
|
|
69
|
+
@include m.m(#{$type}) {
|
|
70
|
+
&::before {
|
|
71
|
+
background-color: fn.use-var(color, $type);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// 自定义节点(#dot 插槽):隐藏默认圆点,插槽内容在首行行盒内垂直居中
|
|
77
|
+
@include m.is(custom) {
|
|
78
|
+
width: auto;
|
|
79
|
+
|
|
80
|
+
&::before {
|
|
81
|
+
display: none;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@include m.e(wrapper) {
|
|
87
|
+
min-width: 0;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@include m.e(timestamp) {
|
|
91
|
+
margin-top: fn.use-var(gap, small);
|
|
92
|
+
color: fn.use-var(text-color, second);
|
|
93
|
+
font-size: fn.use-var(font-size, main, small);
|
|
94
|
+
// 行盒与内容首行等高,timestamp-placement 为 top 时与圆点共用对齐基准
|
|
95
|
+
line-height: $first-line;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// 时间戳在内容上方时改为下间距
|
|
99
|
+
@include m.em(timestamp, top) {
|
|
100
|
+
margin-top: 0;
|
|
101
|
+
margin-bottom: fn.use-var(gap, small);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@include m.e(content) {
|
|
105
|
+
word-break: break-word;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './style.scss'
|