@veltra/desktop 1.3.9 → 1.4.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/action/action-group.vue.d.ts +2 -2
- package/dist/components/action/action.vue.d.ts +1 -1
- package/dist/components/auto-complete/auto-complete.js +6 -1
- package/dist/components/auto-complete/auto-complete.js.map +1 -1
- package/dist/components/auto-complete/style2.css +6 -4
- package/dist/components/batch-edit/batch-edit.vue.d.ts +8 -8
- package/dist/components/cascade/cascade.vue.d.ts +2 -2
- package/dist/components/checkbox/checkbox-button.vue.d.ts +1 -1
- package/dist/components/checkbox-group/checkbox-group.vue.d.ts +2 -2
- package/dist/components/collapse/collapse-item.js +34 -11
- package/dist/components/collapse/collapse-item.js.map +1 -1
- package/dist/components/collapse/collapse-item.vue.d.ts +9 -1
- package/dist/components/collapse/style2.css +29 -51
- package/dist/components/date-panel/date-panel.vue.d.ts +1 -1
- package/dist/components/date-picker/date-picker.vue.d.ts +1 -1
- package/dist/components/date-range-picker/date-range-picker.vue.d.ts +1 -1
- package/dist/components/input/input.vue.d.ts +2 -2
- package/dist/components/multi-select/multi-select.vue.d.ts +2 -2
- package/dist/components/multi-tree-select/multi-tree-select.vue.d.ts +2 -2
- package/dist/components/radio-group/radio-group.vue.d.ts +2 -2
- package/dist/components/select/select.vue.d.ts +2 -2
- package/dist/components/steps/steps.vue.d.ts +2 -2
- package/dist/components/steps/style2.css +14 -14
- package/dist/components/textarea/textarea.vue.d.ts +2 -2
- package/dist/components/tree-select/tree-select.vue.d.ts +2 -2
- package/dist/components/watermark/watermark.vue.d.ts +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/types/collapse.d.ts +23 -4
- package/dist/types/index.d.ts +3 -3
- package/package.json +6 -6
- package/src/components/auto-complete/auto-complete.vue +8 -0
- package/src/components/auto-complete/style.scss +6 -4
- package/src/components/collapse/__test__/collapse.test.ts +178 -1
- package/src/components/collapse/collapse-item.vue +40 -12
- package/src/components/collapse/style.scss +26 -62
- package/src/components/steps/style.scss +2 -2
- package/src/types/collapse.ts +25 -3
|
@@ -29,25 +29,38 @@
|
|
|
29
29
|
</template>
|
|
30
30
|
|
|
31
31
|
<script lang="ts" setup>
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
32
|
+
import { useModel } from '@veltra/compositions'
|
|
33
|
+
import { ArrowDown } from '@veltra/icons/normal'
|
|
34
|
+
import { bem, ExpandTransition } from '@veltra/utils'
|
|
34
35
|
import { computed, inject, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
35
36
|
|
|
36
|
-
import type { CollapseItemProps } from '../../types'
|
|
37
|
+
import type { CollapseItemEmits, CollapseItemProps } from '../../types'
|
|
37
38
|
import { UIcon } from '../icon'
|
|
38
39
|
import { CollapseDIKey } from './di'
|
|
39
40
|
|
|
40
41
|
defineOptions({ name: 'UCollapseItem' })
|
|
41
42
|
|
|
42
|
-
const props = defineProps<CollapseItemProps>()
|
|
43
|
+
const props = withDefaults(defineProps<CollapseItemProps>(), { modelValue: false })
|
|
44
|
+
const emit = defineEmits<CollapseItemEmits>()
|
|
43
45
|
|
|
44
|
-
const context = inject(CollapseDIKey)
|
|
46
|
+
const context = inject(CollapseDIKey, undefined)
|
|
45
47
|
|
|
46
48
|
const cls = context?.cls ?? bem('collapse')
|
|
47
49
|
|
|
48
|
-
const
|
|
50
|
+
const standaloneModel = useModel<CollapseItemProps, 'modelValue'>({
|
|
51
|
+
props,
|
|
52
|
+
emit,
|
|
53
|
+
defaultValue: false
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
const isActive = computed(() => {
|
|
57
|
+
if (context) {
|
|
58
|
+
return props.value !== undefined && context.activeValues.value.includes(props.value)
|
|
59
|
+
}
|
|
60
|
+
return !!standaloneModel.value
|
|
61
|
+
})
|
|
49
62
|
|
|
50
|
-
const iconComponent = computed(() => context?.expandIcon.value ??
|
|
63
|
+
const iconComponent = computed(() => context?.expandIcon.value ?? props.expandIcon ?? ArrowDown)
|
|
51
64
|
|
|
52
65
|
const classList = computed(() => [
|
|
53
66
|
cls.e('item'),
|
|
@@ -61,17 +74,30 @@ const headerClassList = computed(() => [
|
|
|
61
74
|
bem.is('active', isActive.value)
|
|
62
75
|
])
|
|
63
76
|
|
|
77
|
+
const expandTransition =
|
|
78
|
+
context?.expandTransition ??
|
|
79
|
+
new ExpandTransition({ transition: 'height 0.24s cubic-bezier(0.4, 0, 0.2, 1)' })
|
|
80
|
+
|
|
64
81
|
const handleClick = () => {
|
|
65
82
|
if (props.disabled) return
|
|
66
|
-
|
|
83
|
+
|
|
84
|
+
if (context) {
|
|
85
|
+
if (props.value === undefined) return
|
|
86
|
+
context.toggle(props.value)
|
|
87
|
+
return
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const next = !standaloneModel.value
|
|
91
|
+
standaloneModel.value = next
|
|
92
|
+
emit('change', next)
|
|
67
93
|
}
|
|
68
94
|
|
|
69
95
|
const wrapperEl = ref<HTMLElement>()
|
|
70
96
|
|
|
71
|
-
const { expandTransition } = context
|
|
72
|
-
|
|
73
97
|
onMounted(() => {
|
|
74
|
-
context
|
|
98
|
+
if (context && props.value !== undefined) {
|
|
99
|
+
context.register(props.value)
|
|
100
|
+
}
|
|
75
101
|
if (!wrapperEl.value) return
|
|
76
102
|
expandTransition.setExpanded(wrapperEl.value, isActive.value)
|
|
77
103
|
})
|
|
@@ -82,7 +108,9 @@ watch(isActive, (active) => {
|
|
|
82
108
|
})
|
|
83
109
|
|
|
84
110
|
onBeforeUnmount(() => {
|
|
85
|
-
context
|
|
111
|
+
if (context && props.value !== undefined) {
|
|
112
|
+
context.unregister(props.value)
|
|
113
|
+
}
|
|
86
114
|
if (!wrapperEl.value) return
|
|
87
115
|
expandTransition.cancel(wrapperEl.value)
|
|
88
116
|
})
|
|
@@ -3,16 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
$root-name: collapse;
|
|
5
5
|
|
|
6
|
-
// 与 tabs/menu 一致的 Material standard 缓动
|
|
7
6
|
$ease: cubic-bezier(0.4, 0, 0.2, 1);
|
|
8
7
|
$transition-fast: 0.18s $ease;
|
|
9
8
|
$transition-normal: 0.24s $ease;
|
|
10
|
-
$item-bg: fn.component-var(collapse, item-bg);
|
|
11
|
-
$item-hover-bg: fn.component-var(collapse, item-hover-bg);
|
|
12
|
-
$item-active-bg: fn.component-var(collapse, item-active-bg);
|
|
13
|
-
$header-active-bg: fn.component-var(collapse, header-active-bg);
|
|
14
|
-
$content-bg: fn.component-var(collapse, content-bg);
|
|
15
|
-
$active-title-color: fn.component-var(collapse, active-title-color, fn.use-var(color, primary));
|
|
16
9
|
|
|
17
10
|
@include m.b($root-name) {
|
|
18
11
|
width: 100%;
|
|
@@ -22,44 +15,15 @@ $active-title-color: fn.component-var(collapse, active-title-color, fn.use-var(c
|
|
|
22
15
|
|
|
23
16
|
// ===== Item =====
|
|
24
17
|
@include m.e(item) {
|
|
25
|
-
|
|
26
|
-
border-radius:
|
|
18
|
+
border: fn.use-var(border-muted);
|
|
19
|
+
border-radius: fn.use-var(radius, default);
|
|
20
|
+
background-color: fn.use-var(bg-color, middle);
|
|
27
21
|
overflow: hidden;
|
|
28
|
-
background-color: $item-bg;
|
|
29
|
-
transition: background-color $transition-fast;
|
|
30
|
-
|
|
31
|
-
&::before {
|
|
32
|
-
content: '';
|
|
33
|
-
position: absolute;
|
|
34
|
-
top: 0;
|
|
35
|
-
bottom: 0;
|
|
36
|
-
left: 0;
|
|
37
|
-
width: 3px;
|
|
38
|
-
background-color: fn.use-var(color, primary);
|
|
39
|
-
opacity: 0;
|
|
40
|
-
pointer-events: none;
|
|
41
|
-
transition: opacity $transition-fast;
|
|
42
|
-
z-index: 1;
|
|
43
|
-
}
|
|
44
22
|
|
|
45
23
|
& + #{fn.bem($root-name, item)} {
|
|
46
24
|
margin-top: fn.use-var(gap, default);
|
|
47
25
|
}
|
|
48
26
|
|
|
49
|
-
@include m.is-not(disabled) {
|
|
50
|
-
&:hover {
|
|
51
|
-
background-color: $item-hover-bg;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
@include m.is(active) {
|
|
56
|
-
background-color: $item-active-bg;
|
|
57
|
-
|
|
58
|
-
&::before {
|
|
59
|
-
opacity: 1;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
27
|
@include m.is(disabled) {
|
|
64
28
|
opacity: 0.55;
|
|
65
29
|
}
|
|
@@ -70,43 +34,46 @@ $active-title-color: fn.component-var(collapse, active-title-color, fn.use-var(c
|
|
|
70
34
|
position: relative;
|
|
71
35
|
display: flex;
|
|
72
36
|
align-items: center;
|
|
73
|
-
gap:
|
|
37
|
+
gap: fn.use-var(gap, small);
|
|
38
|
+
padding: fn.use-var(gap, small) fn.use-var(gap, default);
|
|
74
39
|
cursor: pointer;
|
|
75
40
|
font-weight: 500;
|
|
76
41
|
letter-spacing: 0.01em;
|
|
77
|
-
color: fn.
|
|
42
|
+
color: fn.use-var(text-color, main);
|
|
78
43
|
user-select: none;
|
|
79
44
|
outline: none;
|
|
80
|
-
transition:
|
|
81
|
-
|
|
82
|
-
background-color $transition-fast;
|
|
83
|
-
border-radius: inherit;
|
|
45
|
+
transition: background-color $transition-fast;
|
|
46
|
+
border-radius: 0;
|
|
84
47
|
|
|
85
48
|
&:focus-visible {
|
|
86
49
|
box-shadow: inset 0 0 0 2px fn.use-var(color, primary);
|
|
87
50
|
}
|
|
88
51
|
|
|
52
|
+
@include m.is-not(disabled) {
|
|
53
|
+
&:hover {
|
|
54
|
+
background-color: fn.use-var(bg-color, hover);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
89
58
|
@include m.is(disabled) {
|
|
90
59
|
cursor: not-allowed;
|
|
91
60
|
color: fn.use-var(text-color, placeholder);
|
|
92
61
|
}
|
|
93
62
|
|
|
94
63
|
@include m.is(active) {
|
|
95
|
-
|
|
96
|
-
color: $active-title-color;
|
|
97
|
-
background-color: $header-active-bg;
|
|
98
|
-
border-bottom-right-radius: 0;
|
|
99
|
-
border-bottom-left-radius: 0;
|
|
64
|
+
background-color: fn.use-var(bg-color, hover);
|
|
100
65
|
|
|
101
66
|
#{fn.bem($root-name, icon)} {
|
|
102
|
-
transform: rotate(
|
|
103
|
-
color: $active-title-color;
|
|
67
|
+
transform: rotate(180deg);
|
|
104
68
|
}
|
|
105
69
|
}
|
|
106
70
|
}
|
|
107
71
|
|
|
108
72
|
// ===== Title =====
|
|
109
73
|
@include m.e(title) {
|
|
74
|
+
display: flex;
|
|
75
|
+
align-items: center;
|
|
76
|
+
gap: fn.use-var(gap, small);
|
|
110
77
|
flex: 1 1 auto;
|
|
111
78
|
min-width: 0;
|
|
112
79
|
line-height: 1.5;
|
|
@@ -118,10 +85,8 @@ $active-title-color: fn.component-var(collapse, active-title-color, fn.use-var(c
|
|
|
118
85
|
align-items: center;
|
|
119
86
|
justify-content: center;
|
|
120
87
|
flex: 0 0 auto;
|
|
121
|
-
color: fn.use-var(text-color,
|
|
122
|
-
transition:
|
|
123
|
-
transform $transition-normal,
|
|
124
|
-
color $transition-fast;
|
|
88
|
+
color: fn.use-var(text-color, assist);
|
|
89
|
+
transition: transform 0.2s $ease;
|
|
125
90
|
will-change: transform;
|
|
126
91
|
}
|
|
127
92
|
|
|
@@ -129,15 +94,14 @@ $active-title-color: fn.component-var(collapse, active-title-color, fn.use-var(c
|
|
|
129
94
|
@include m.e(content-wrapper) {
|
|
130
95
|
overflow: hidden;
|
|
131
96
|
height: 0;
|
|
132
|
-
|
|
133
|
-
border-bottom-left-radius: inherit;
|
|
134
|
-
background-color: $content-bg;
|
|
97
|
+
background-color: transparent;
|
|
135
98
|
transition: height $transition-normal;
|
|
136
99
|
}
|
|
137
100
|
|
|
138
101
|
@include m.e(content) {
|
|
139
102
|
color: fn.use-var(text-color, main);
|
|
140
103
|
line-height: 1.7;
|
|
104
|
+
padding: fn.use-var(gap, small) fn.use-var(gap, default);
|
|
141
105
|
}
|
|
142
106
|
|
|
143
107
|
// ===== Sizes =====
|
|
@@ -145,17 +109,17 @@ $active-title-color: fn.component-var(collapse, active-title-color, fn.use-var(c
|
|
|
145
109
|
font-size: fn.use-var(font-size-main, $size);
|
|
146
110
|
|
|
147
111
|
@include m.bem($root-name, header) {
|
|
148
|
-
padding:
|
|
112
|
+
padding: fn.use-var(gap, $size) fn.use-var(gap, $size);
|
|
149
113
|
font-size: fn.use-var(font-size-main, $size);
|
|
150
114
|
}
|
|
151
115
|
|
|
152
116
|
@include m.bem($root-name, content) {
|
|
153
117
|
font-size: fn.use-var(font-size-main, $size);
|
|
154
|
-
padding:
|
|
118
|
+
padding: fn.use-var(gap, $size);
|
|
155
119
|
}
|
|
156
120
|
|
|
157
121
|
#{fn.bem($root-name, item)} {
|
|
158
|
-
border-radius:
|
|
122
|
+
border-radius: fn.use-var(radius, $size);
|
|
159
123
|
|
|
160
124
|
& + #{fn.bem($root-name, item)} {
|
|
161
125
|
margin-top: fn.use-var(gap, $size);
|
|
@@ -12,14 +12,14 @@ $root-name: steps;
|
|
|
12
12
|
|
|
13
13
|
@each $type in vars.$color-types {
|
|
14
14
|
@include m.em(finished, $type) {
|
|
15
|
-
@include m.
|
|
15
|
+
@include m.bem($root-name, item) {
|
|
16
16
|
@include m.is(finished) {
|
|
17
17
|
color: fn.use-var(color, $type);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
@include m.em(current, $type) {
|
|
22
|
-
@include m.
|
|
22
|
+
@include m.bem($root-name, item) {
|
|
23
23
|
@include m.is(current) {
|
|
24
24
|
color: fn.use-var(color, $type);
|
|
25
25
|
}
|
package/src/types/collapse.ts
CHANGED
|
@@ -25,7 +25,7 @@ export interface CollapseProps extends ComponentProps {
|
|
|
25
25
|
defaultCollapseAll?: boolean
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
* 自定义展开图标组件,活动态会自动旋转
|
|
28
|
+
* 自定义展开图标组件,活动态会自动旋转 180°。
|
|
29
29
|
* 接受任意 Vue 组件(SFC、Functional Component 等)。
|
|
30
30
|
*/
|
|
31
31
|
expandIcon?: Component
|
|
@@ -39,12 +39,34 @@ export interface CollapseEmits {
|
|
|
39
39
|
|
|
40
40
|
/** CollapseItem 组件属性 */
|
|
41
41
|
export interface CollapseItemProps {
|
|
42
|
-
/**
|
|
43
|
-
|
|
42
|
+
/**
|
|
43
|
+
* 唯一标识;在 `UCollapse` 内使用时必填。
|
|
44
|
+
* 独立使用时可选。
|
|
45
|
+
*/
|
|
46
|
+
value?: CollapseValue
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 独立使用时的展开状态(`v-model`)。
|
|
50
|
+
* 在 `UCollapse` 内由父组件 `modelValue` 管理,此属性无效。
|
|
51
|
+
* @default false
|
|
52
|
+
*/
|
|
53
|
+
modelValue?: boolean
|
|
44
54
|
|
|
45
55
|
/** 标题文本(也可使用 #title 插槽) */
|
|
46
56
|
title?: string
|
|
47
57
|
|
|
48
58
|
/** 是否禁用 */
|
|
49
59
|
disabled?: boolean
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 独立使用时的自定义展开图标,活动态会自动旋转 180°。
|
|
63
|
+
* 在 `UCollapse` 内由父组件 `expandIcon` 统一管理。
|
|
64
|
+
*/
|
|
65
|
+
expandIcon?: Component
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface CollapseItemEmits {
|
|
69
|
+
(e: 'update:modelValue', value: boolean): void
|
|
70
|
+
/** 展开状态变更时触发(仅独立使用) */
|
|
71
|
+
(e: 'change', value: boolean): void
|
|
50
72
|
}
|