@veltra/desktop 1.15.0 → 1.15.1
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 +31 -28
- package/dist/components/alert/alert.js.map +1 -1
- package/dist/components/alert/style.d.ts +1 -1
- package/dist/components/alert/style.js +1 -0
- package/dist/components/alert/style2.css +5 -1
- package/dist/components/auto-complete/style2.css +1 -0
- package/dist/components/back-top/style2.css +11 -2
- package/dist/components/badge/badge.js +15 -15
- package/dist/components/badge/badge.js.map +1 -1
- package/dist/components/badge/style2.css +10 -1
- package/dist/components/batch-edit/batch-edit-form.js +108 -97
- package/dist/components/batch-edit/batch-edit-form.js.map +1 -1
- package/dist/components/batch-edit/batch-edit.js +11 -5
- package/dist/components/batch-edit/batch-edit.js.map +1 -1
- package/dist/components/batch-edit/style2.css +25 -1
- package/dist/components/breadcrumb/style2.css +4 -1
- package/dist/components/button/style2.css +3 -2
- package/dist/components/carousel/carousel.js +5 -3
- package/dist/components/carousel/carousel.js.map +1 -1
- package/dist/components/carousel/style2.css +7 -1
- package/dist/components/carousel/use-carousel.js +16 -2
- package/dist/components/carousel/use-carousel.js.map +1 -1
- package/dist/components/cascade/style2.css +16 -0
- package/dist/components/check-tag/check-tag.js +11 -5
- package/dist/components/check-tag/check-tag.js.map +1 -1
- package/dist/components/check-tag/style2.css +10 -0
- package/dist/components/checkbox/checkbox-button.js +8 -3
- package/dist/components/checkbox/checkbox-button.js.map +1 -1
- package/dist/components/checkbox/checkbox.js +5 -9
- package/dist/components/checkbox/checkbox.js.map +1 -1
- package/dist/components/checkbox/style2.css +32 -2
- package/dist/components/chip/style2.css +4 -0
- package/dist/components/code-editor/code-editor.js +26 -3
- package/dist/components/code-editor/code-editor.js.map +1 -1
- package/dist/components/code-editor/style2.css +38 -3
- package/dist/components/collapse/collapse-item.js +4 -1
- package/dist/components/collapse/collapse-item.js.map +1 -1
- package/dist/components/collapse/collapse.js +1 -1
- package/dist/components/collapse/collapse.js.map +1 -1
- package/dist/components/collapse/style2.css +6 -3
- package/dist/components/condition-editor/style2.css +24 -6
- package/dist/components/contextmenu/contextmenu-sub.js +13 -7
- package/dist/components/contextmenu/contextmenu-sub.js.map +1 -1
- package/dist/components/contextmenu/style2.css +14 -1
- package/dist/components/date-panel/style2.css +9 -1
- package/dist/components/dialog/style2.css +5 -1
- package/dist/components/dialog/use-maximum.js +6 -0
- package/dist/components/dialog/use-maximum.js.map +1 -1
- package/dist/components/drawer/style2.css +4 -0
- package/dist/components/dual-nav/style2.css +5 -2
- package/dist/components/expression-editor/style2.css +17 -5
- package/dist/components/file-viewer/style2.css +8 -2
- package/dist/components/float-button/float-button.js +1 -1
- package/dist/components/float-button/float-button.js.map +1 -1
- package/dist/components/float-button/style2.css +2 -3
- package/dist/components/form-item/style2.css +13 -1
- package/dist/components/grid-input/style2.css +15 -3
- package/dist/components/group-nav/style2.css +16 -7
- package/dist/components/icon/style2.css +1 -1
- package/dist/components/image-cropper/style2.css +4 -1
- package/dist/components/image-previewer/image-previewer.js +14 -2
- package/dist/components/image-previewer/image-previewer.js.map +1 -1
- package/dist/components/image-previewer/style.d.ts +1 -1
- package/dist/components/image-previewer/style.js +1 -0
- package/dist/components/image-previewer/style2.css +9 -14
- package/dist/components/input/input.js.map +1 -1
- package/dist/components/input/input.vue_vue_type_script_setup_true_lang.js +4 -4
- package/dist/components/input/input.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/input/style2.css +13 -1
- package/dist/components/kanban/kanban-column.js +1 -0
- package/dist/components/kanban/kanban-column.js.map +1 -1
- package/dist/components/kanban/style2.css +6 -2
- package/dist/components/layout/layout-resizer.js +8 -1
- package/dist/components/layout/layout-resizer.js.map +1 -1
- package/dist/components/layout/layout.js +11 -1
- package/dist/components/layout/layout.js.map +1 -1
- package/dist/components/layout/style2.css +22 -0
- package/dist/components/loading/style2.css +26 -7
- package/dist/components/message/style2.css +18 -2
- package/dist/components/message-confirm/style2.css +11 -0
- package/dist/components/multi-select/multi-select.js +21 -18
- package/dist/components/multi-select/multi-select.js.map +1 -1
- package/dist/components/multi-select/style2.css +13 -0
- package/dist/components/nav/nav-sub.js +8 -2
- package/dist/components/nav/nav-sub.js.map +1 -1
- package/dist/components/nav/style2.css +50 -26
- package/dist/components/notification/style2.css +21 -0
- package/dist/components/number-input/style2.css +5 -2
- package/dist/components/paginator/style2.css +1 -0
- package/dist/components/password-input/style2.css +10 -1
- package/dist/components/pop-confirm/pop-confirm.js +1 -1
- package/dist/components/pop-confirm/pop-confirm.js.map +1 -1
- package/dist/components/progress/style2.css +2 -2
- package/dist/components/progress-nodes/style2.css +3 -3
- package/dist/components/radio/radio.js +1 -4
- package/dist/components/radio/radio.js.map +1 -1
- package/dist/components/radio/style2.css +11 -1
- package/dist/components/rate/style2.css +7 -0
- package/dist/components/rich-text-editor/style2.css +6 -3
- package/dist/components/scroll/style2.css +2 -2
- package/dist/components/segment/segment.js +5 -1
- package/dist/components/segment/segment.js.map +1 -1
- package/dist/components/segment/style2.css +6 -0
- package/dist/components/select/select.js +5 -1
- package/dist/components/select/select.js.map +1 -1
- package/dist/components/select/style2.css +11 -1
- package/dist/components/steps/style2.css +21 -2
- package/dist/components/switch/style2.css +10 -2
- package/dist/components/table/style2.css +20 -7
- package/dist/components/tabs/style2.css +9 -3
- package/dist/components/tag/style2.css +16 -7
- package/dist/components/textarea/style2.css +9 -1
- package/dist/components/theme/style2.css +38 -29
- package/dist/components/time-picker/style2.css +4 -1
- package/dist/components/tip/style2.css +11 -0
- package/dist/components/transfer/style2.css +21 -1
- package/dist/components/transfer/transfer-list.js +20 -17
- package/dist/components/transfer/transfer-list.js.map +1 -1
- package/dist/components/tree/style2.css +5 -2
- package/package.json +1 -1
- package/src/components/alert/alert.vue +18 -16
- package/src/components/alert/style.scss +9 -1
- package/src/components/alert/style.ts +1 -0
- package/src/components/auto-complete/style.scss +3 -0
- package/src/components/back-top/style.scss +17 -3
- package/src/components/badge/badge.vue +6 -7
- package/src/components/badge/style.scss +20 -1
- package/src/components/batch-edit/__test__/batch-edit.test.ts +10 -0
- package/src/components/batch-edit/batch-edit-form.vue +95 -83
- package/src/components/batch-edit/batch-edit.vue +18 -3
- package/src/components/batch-edit/style.scss +39 -3
- package/src/components/breadcrumb/style.scss +5 -1
- package/src/components/button/style.scss +4 -2
- package/src/components/carousel/carousel.vue +8 -2
- package/src/components/carousel/style.scss +10 -1
- package/src/components/carousel/use-carousel.ts +17 -2
- package/src/components/cascade/style.scss +27 -0
- package/src/components/check-tag/check-tag.vue +13 -3
- package/src/components/check-tag/style.scss +21 -0
- package/src/components/checkbox/checkbox-button.vue +11 -1
- package/src/components/checkbox/checkbox.vue +6 -2
- package/src/components/checkbox/style.scss +51 -2
- package/src/components/chip/style.scss +11 -0
- package/src/components/code-editor/code-editor.vue +24 -3
- package/src/components/code-editor/style.scss +54 -4
- package/src/components/collapse/collapse-item.vue +10 -1
- package/src/components/collapse/collapse.vue +3 -1
- package/src/components/collapse/style.scss +10 -7
- package/src/components/condition-editor/style.scss +39 -12
- package/src/components/contextmenu/contextmenu-sub.vue +9 -7
- package/src/components/contextmenu/style.scss +17 -1
- package/src/components/date-panel/style.scss +22 -1
- package/src/components/dialog/style.scss +6 -1
- package/src/components/dialog/use-maximum.ts +8 -0
- package/src/components/drawer/style.scss +5 -0
- package/src/components/dual-nav/style.scss +9 -4
- package/src/components/expression-editor/style.scss +27 -9
- package/src/components/file-viewer/style.scss +12 -2
- package/src/components/float-button/float-button.vue +1 -1
- package/src/components/float-button/style.scss +4 -3
- package/src/components/form-item/style.scss +16 -2
- package/src/components/grid-input/style.scss +6 -1
- package/src/components/group-nav/style.scss +30 -13
- package/src/components/icon/style.scss +2 -1
- package/src/components/image-cropper/style.scss +6 -1
- package/src/components/image-previewer/image-previewer.vue +20 -2
- package/src/components/image-previewer/style.scss +17 -14
- package/src/components/image-previewer/style.ts +1 -0
- package/src/components/input/input.vue +2 -8
- package/src/components/input/style.scss +19 -1
- package/src/components/kanban/kanban-column.vue +2 -0
- package/src/components/kanban/style.scss +11 -2
- package/src/components/layout/__test__/layout.test.ts +135 -0
- package/src/components/layout/layout-resizer.vue +8 -1
- package/src/components/layout/layout.vue +17 -1
- package/src/components/layout/style.scss +31 -6
- package/src/components/loading/style.scss +39 -8
- package/src/components/message/style.scss +20 -2
- package/src/components/message-confirm/style.scss +13 -0
- package/src/components/multi-select/multi-select.vue +13 -10
- package/src/components/multi-select/style.scss +14 -0
- package/src/components/multi-tree-select/__test__/multi-tree-select.test.ts +4 -2
- package/src/components/nav/nav-sub.vue +10 -2
- package/src/components/nav/style.scss +37 -13
- package/src/components/notification/style.scss +13 -0
- package/src/components/number-input/style.scss +8 -2
- package/src/components/paginator/style.scss +3 -0
- package/src/components/password-input/style.scss +15 -1
- package/src/components/pop-confirm/pop-confirm.vue +1 -1
- package/src/components/progress/style.scss +3 -3
- package/src/components/progress-nodes/style.scss +5 -5
- package/src/components/radio/radio.vue +1 -1
- package/src/components/radio/style.scss +19 -1
- package/src/components/rate/style.scss +9 -0
- package/src/components/rich-text-editor/style.scss +11 -6
- package/src/components/scroll/style.scss +3 -3
- package/src/components/segment/segment.vue +13 -1
- package/src/components/segment/style.scss +13 -3
- package/src/components/select/select.vue +1 -1
- package/src/components/select/style.scss +22 -1
- package/src/components/steps/style.scss +27 -5
- package/src/components/switch/style.scss +13 -2
- package/src/components/table/style.scss +44 -20
- package/src/components/tabs/style.scss +16 -3
- package/src/components/tag/style.scss +18 -1
- package/src/components/textarea/style.scss +15 -2
- package/src/components/theme/style.scss +62 -40
- package/src/components/time-picker/style.scss +9 -1
- package/src/components/tip/style.scss +13 -0
- package/src/components/transfer/style.scss +31 -1
- package/src/components/transfer/transfer-list.vue +18 -15
- package/src/components/tree/style.scss +8 -3
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<Teleport to="body" :disabled="!modal">
|
|
3
|
-
<transition :name="modal ? '
|
|
3
|
+
<transition :name="modal ? 'fade-scale' : ''">
|
|
4
4
|
<div v-if="!modal || open" :class="[cls.b, bem.is('modal', modal)]">
|
|
5
5
|
<div
|
|
6
6
|
ref="stage"
|
|
7
|
-
:class="[
|
|
7
|
+
:class="[
|
|
8
|
+
cls.e('stage'),
|
|
9
|
+
bem.is('pannable', scale > 1),
|
|
10
|
+
bem.is('dragging', isDragging),
|
|
11
|
+
bem.is('wheeling', isWheeling)
|
|
12
|
+
]"
|
|
8
13
|
v-bind="attrs"
|
|
9
14
|
@mousedown.self="onBackdropMousedown"
|
|
10
15
|
@pointerdown="onPointerDown"
|
|
@@ -126,6 +131,8 @@ const failed = ref(false)
|
|
|
126
131
|
const scale = ref(1)
|
|
127
132
|
/** 拖拽起止各写一次,仅驱动 grabbing 光标 */
|
|
128
133
|
const isDragging = ref(false)
|
|
134
|
+
/** ctrl+wheel 连续缩放期间置位:stage 禁用 transform 过渡保证逐档跟手 */
|
|
135
|
+
const isWheeling = ref(false)
|
|
129
136
|
|
|
130
137
|
const zoomPercent = computed(() => `${Math.round(scale.value * 100)}%`)
|
|
131
138
|
|
|
@@ -199,9 +206,19 @@ function onPointerEnd(e: PointerEvent) {
|
|
|
199
206
|
isDragging.value = false
|
|
200
207
|
}
|
|
201
208
|
|
|
209
|
+
/** wheel 序列防抖计时:滚动停止约一个 fast 过渡时长后恢复过渡 */
|
|
210
|
+
let wheelStopTimer: ReturnType<typeof setTimeout> | undefined
|
|
211
|
+
|
|
202
212
|
function onWheel(e: WheelEvent) {
|
|
203
213
|
if (!(e.ctrlKey || e.metaKey)) return
|
|
204
214
|
e.preventDefault()
|
|
215
|
+
// 连续缩放档位间不做过渡(每档 0.15s 过渡叠加会迟滞);停止滚动后再恢复
|
|
216
|
+
if (!isWheeling.value) isWheeling.value = true
|
|
217
|
+
clearTimeout(wheelStopTimer)
|
|
218
|
+
wheelStopTimer = setTimeout(() => {
|
|
219
|
+
isWheeling.value = false
|
|
220
|
+
wheelStopTimer = undefined
|
|
221
|
+
}, 150)
|
|
205
222
|
setScale(scale.value + (e.deltaY > 0 ? -ZOOM_STEP : ZOOM_STEP))
|
|
206
223
|
}
|
|
207
224
|
|
|
@@ -308,6 +325,7 @@ watch(
|
|
|
308
325
|
)
|
|
309
326
|
|
|
310
327
|
onBeforeUnmount(() => {
|
|
328
|
+
clearTimeout(wheelStopTimer)
|
|
311
329
|
revoke?.()
|
|
312
330
|
url.value = ''
|
|
313
331
|
})
|
|
@@ -39,7 +39,8 @@
|
|
|
39
39
|
user-select: none;
|
|
40
40
|
// 图片缩放/拖拽的 transform 直接写在本元素 style 上(见 applyTransform)
|
|
41
41
|
transform-origin: center center;
|
|
42
|
-
|
|
42
|
+
// 缩放是操作反馈:ease-out 起步快,指尖/滚轮动作即时可见
|
|
43
|
+
transition: transform fn.use-var(transition, fast) fn.use-var(transition, ease-out);
|
|
43
44
|
will-change: transform;
|
|
44
45
|
|
|
45
46
|
&.is-pannable {
|
|
@@ -53,6 +54,11 @@
|
|
|
53
54
|
transition: none;
|
|
54
55
|
}
|
|
55
56
|
|
|
57
|
+
// ctrl+wheel 连续缩放期间禁用过渡:每档 0.15s 过渡叠加会让缩放迟滞
|
|
58
|
+
&.is-wheeling {
|
|
59
|
+
transition: none;
|
|
60
|
+
}
|
|
61
|
+
|
|
56
62
|
img {
|
|
57
63
|
max-width: 100%;
|
|
58
64
|
max-height: 100%;
|
|
@@ -146,12 +152,18 @@
|
|
|
146
152
|
color: inherit;
|
|
147
153
|
background: transparent;
|
|
148
154
|
cursor: pointer;
|
|
149
|
-
transition:
|
|
155
|
+
transition:
|
|
156
|
+
background fn.use-var(transition, fast) fn.use-var(transition, ease),
|
|
157
|
+
transform fn.use-var(transition, fast) fn.use-var(transition, ease);
|
|
150
158
|
|
|
151
159
|
&:not(:disabled):hover {
|
|
152
160
|
background: fn.color-a(text-color, 22, white);
|
|
153
161
|
}
|
|
154
162
|
|
|
163
|
+
&:not(:disabled):active {
|
|
164
|
+
transform: translateY(1px);
|
|
165
|
+
}
|
|
166
|
+
|
|
155
167
|
&:disabled {
|
|
156
168
|
opacity: 0.38;
|
|
157
169
|
cursor: not-allowed;
|
|
@@ -172,17 +184,8 @@
|
|
|
172
184
|
}
|
|
173
185
|
}
|
|
174
186
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
will-change: opacity;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
.u-image-previewer-fade-enter-from,
|
|
182
|
-
.u-image-previewer-fade-leave-to {
|
|
183
|
-
opacity: 0;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
.u-image-previewer-fade-leave-active {
|
|
187
|
+
// 开/关过渡复用共享 fade-scale 类(同 dialog)。共享类不带 pointer-events 防护,
|
|
188
|
+
// 离开期间在组件作用域内补一层,避免关闭动画中误触背衬关闭。
|
|
189
|
+
#{fn.bem(image-previewer)}.fade-scale-leave-active {
|
|
187
190
|
pointer-events: none;
|
|
188
191
|
}
|
|
@@ -29,17 +29,11 @@
|
|
|
29
29
|
/>
|
|
30
30
|
|
|
31
31
|
<span :class="suffixClass" v-if="hasSuffix">
|
|
32
|
-
<UIcon
|
|
33
|
-
v-if="showClear"
|
|
34
|
-
:class="cls.e('clear')"
|
|
35
|
-
title="清除"
|
|
36
|
-
@click.stop="clearModelValue"
|
|
37
|
-
key="clear"
|
|
38
|
-
>
|
|
32
|
+
<UIcon v-if="showClear" :class="cls.e('clear')" title="清除" @click.stop="clearModelValue">
|
|
39
33
|
<Close />
|
|
40
34
|
</UIcon>
|
|
41
35
|
|
|
42
|
-
<span v-else :class="cls.e('suffix-content')" @click="handleSuffixClick"
|
|
36
|
+
<span v-else :class="cls.e('suffix-content')" @click="handleSuffixClick">
|
|
43
37
|
{{ suffix }}
|
|
44
38
|
<slot name="suffix"></slot>
|
|
45
39
|
</span>
|
|
@@ -54,7 +54,7 @@ $root-name: input;
|
|
|
54
54
|
font-family: fn.use-var(font-family);
|
|
55
55
|
|
|
56
56
|
&:-webkit-autofill {
|
|
57
|
-
color:
|
|
57
|
+
color: fn.use-var(text-color, white) !important;
|
|
58
58
|
background-color: transparent;
|
|
59
59
|
}
|
|
60
60
|
|
|
@@ -74,12 +74,30 @@ $root-name: input;
|
|
|
74
74
|
|
|
75
75
|
@include m.is(clickable) {
|
|
76
76
|
cursor: pointer;
|
|
77
|
+
transition: background-color fn.use-var(transition, fast) fn.use-var(transition, ease);
|
|
78
|
+
|
|
79
|
+
&:hover {
|
|
80
|
+
background-color: fn.color-a(color, 5, primary);
|
|
81
|
+
}
|
|
77
82
|
}
|
|
78
83
|
}
|
|
79
84
|
|
|
80
85
|
@include m.e(clear) {
|
|
81
86
|
cursor: pointer;
|
|
82
87
|
color: fn.use-var(text-color, main);
|
|
88
|
+
transition:
|
|
89
|
+
color fn.use-var(transition, fast) fn.use-var(transition, ease),
|
|
90
|
+
transform fn.use-var(transition, fast) fn.use-var(transition, ease-out);
|
|
91
|
+
|
|
92
|
+
&:hover {
|
|
93
|
+
color: fn.use-var(color, primary);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// 高频小图标:按下瞬间缩到位,松手回弹走过渡
|
|
97
|
+
&:active {
|
|
98
|
+
transform: scale(0.92);
|
|
99
|
+
transition-duration: 0s;
|
|
100
|
+
}
|
|
83
101
|
}
|
|
84
102
|
|
|
85
103
|
@include m.e(suffix-content) {
|
|
@@ -54,6 +54,8 @@ function makeConfig(): VueParentConfig<Record<string, any>> {
|
|
|
54
54
|
dragHandle: `.${cls.e('card-handle')}`,
|
|
55
55
|
draggable: (el) => el.classList.contains(cls.e('card')),
|
|
56
56
|
draggingClass: 'is-dragging',
|
|
57
|
+
// formkit 拖起后下一帧把原位元素换成 placeholder 类;跟随鼠标的是原生拖拽快照
|
|
58
|
+
dragPlaceholderClass: 'is-drag-placeholder',
|
|
57
59
|
dropZoneClass: 'is-dropzone',
|
|
58
60
|
disabled: ctx.kanbanProps.disabled,
|
|
59
61
|
// 排序/转移数据已由 onReorder 写回,这里只负责对外发 change 通知
|
|
@@ -56,6 +56,8 @@
|
|
|
56
56
|
// 空列也保持可拖入的目标高度
|
|
57
57
|
min-height: 64px;
|
|
58
58
|
padding: 2px;
|
|
59
|
+
// 拖入目标态背景色平滑淡入,避免瞬现瞬灭
|
|
60
|
+
transition: background-color fn.use-var(transition, fast) fn.use-var(transition, ease);
|
|
59
61
|
|
|
60
62
|
&.is-dropzone {
|
|
61
63
|
background-color: fn.color-a(color, 4, primary);
|
|
@@ -80,8 +82,12 @@
|
|
|
80
82
|
box-shadow: fn.use-var(shadow);
|
|
81
83
|
}
|
|
82
84
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
+
// 拖拽中原位卡片整体隐形(is-dragging 只存在一帧,随后换 is-drag-placeholder),
|
|
86
|
+
// 跟随鼠标的是浏览器原生拖拽快照——呈现"一直被抓着"的效果;不加 scale/阴影,
|
|
87
|
+
// formkit animations 插件会在节点上写内联 transform。
|
|
88
|
+
&.is-dragging,
|
|
89
|
+
&.is-drag-placeholder {
|
|
90
|
+
opacity: 0;
|
|
85
91
|
}
|
|
86
92
|
}
|
|
87
93
|
|
|
@@ -91,9 +97,11 @@
|
|
|
91
97
|
color: fn.use-var(text-color, assist);
|
|
92
98
|
cursor: grab;
|
|
93
99
|
user-select: none;
|
|
100
|
+
transition: transform fn.use-var(transition, fast) fn.use-var(transition, ease-out);
|
|
94
101
|
|
|
95
102
|
&:active {
|
|
96
103
|
cursor: grabbing;
|
|
104
|
+
transform: scale(0.94);
|
|
97
105
|
}
|
|
98
106
|
}
|
|
99
107
|
|
|
@@ -118,6 +126,7 @@
|
|
|
118
126
|
|
|
119
127
|
&:active {
|
|
120
128
|
cursor: not-allowed;
|
|
129
|
+
transform: none;
|
|
121
130
|
}
|
|
122
131
|
}
|
|
123
132
|
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
|
|
3
|
+
import { afterEach, describe, expect, it, vi } from 'vite-plus/test'
|
|
4
|
+
import { createApp, h, nextTick, type App } from 'vue'
|
|
5
|
+
|
|
6
|
+
import ULayout from '../layout.vue'
|
|
7
|
+
|
|
8
|
+
/** happy-dom 无真实布局,列的几何尺寸全部用桩值喂给组件 */
|
|
9
|
+
function mockColumn(el: HTMLElement, offsetLeft: number, width: number) {
|
|
10
|
+
Object.defineProperty(el, 'offsetLeft', { value: offsetLeft, configurable: true })
|
|
11
|
+
Object.defineProperty(el, 'offsetWidth', { value: width, configurable: true })
|
|
12
|
+
el.getBoundingClientRect = () => ({ width }) as DOMRect
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function mouseEvent(type: string, clientX: number, clientY = 0, bubbles = false) {
|
|
16
|
+
const e = new MouseEvent(type, { bubbles, button: 0, clientX, clientY })
|
|
17
|
+
// happy-dom 的 MouseEvent 未实现 x / y 别名,而 useDrag 读取 e.x / e.y
|
|
18
|
+
Object.defineProperty(e, 'x', { value: clientX })
|
|
19
|
+
Object.defineProperty(e, 'y', { value: clientY })
|
|
20
|
+
return e
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function startDrag(resizer: HTMLElement, startX = 100) {
|
|
24
|
+
resizer.dispatchEvent(mouseEvent('mousedown', startX, 0, true))
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function moveDrag(dx: number, lastX = 100) {
|
|
28
|
+
document.dispatchEvent(mouseEvent('mousemove', lastX + dx))
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function endDrag() {
|
|
32
|
+
document.dispatchEvent(mouseEvent('mouseup', 0))
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function flush() {
|
|
36
|
+
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
37
|
+
await nextTick()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** 挂载两列(400px + 300px,最小宽度 200 / 150),列边界桩值与 cols 一致 */
|
|
41
|
+
async function mountLayout() {
|
|
42
|
+
const host = document.createElement('div')
|
|
43
|
+
document.body.appendChild(host)
|
|
44
|
+
const app = createApp({
|
|
45
|
+
render: () =>
|
|
46
|
+
h(ULayout, { resizable: true, cols: ['400px', '300px'], colMinSizes: [200, 150] }, () => [
|
|
47
|
+
h('div', { class: 'col-a' }),
|
|
48
|
+
h('div', { class: 'col-b' })
|
|
49
|
+
])
|
|
50
|
+
})
|
|
51
|
+
app.mount(host)
|
|
52
|
+
|
|
53
|
+
const container = host.firstElementChild as HTMLElement
|
|
54
|
+
// mount 后同步打桩,抢在 syncResizers 的 nextTick 测量之前
|
|
55
|
+
mockColumn(container.children[0] as HTMLElement, 0, 400)
|
|
56
|
+
mockColumn(container.children[1] as HTMLElement, 410, 300)
|
|
57
|
+
await flush()
|
|
58
|
+
|
|
59
|
+
const resizer = container.querySelector<HTMLElement>('.u-layout__resizer')!
|
|
60
|
+
return { app, container, resizer }
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
describe('ULayout resizable', () => {
|
|
64
|
+
let app: App | undefined
|
|
65
|
+
|
|
66
|
+
afterEach(() => {
|
|
67
|
+
app?.unmount()
|
|
68
|
+
app = undefined
|
|
69
|
+
document.body.innerHTML = ''
|
|
70
|
+
vi.unstubAllGlobals()
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
it('未超限拖拽:两列等量增减,把手跟随交界线', async () => {
|
|
74
|
+
const ctx = await mountLayout()
|
|
75
|
+
app = ctx.app
|
|
76
|
+
|
|
77
|
+
startDrag(ctx.resizer)
|
|
78
|
+
moveDrag(50)
|
|
79
|
+
await nextTick()
|
|
80
|
+
expect(ctx.container.style.gridTemplateColumns).toBe('450px 250px')
|
|
81
|
+
expect(ctx.resizer.style.transform).toBe('translate3d(450px, 0, 0)')
|
|
82
|
+
endDrag()
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
it('超限拖拽:把手顶在钳制边界,不跟随鼠标穿过它', async () => {
|
|
86
|
+
const ctx = await mountLayout()
|
|
87
|
+
app = ctx.app
|
|
88
|
+
|
|
89
|
+
startDrag(ctx.resizer)
|
|
90
|
+
// 右侧余量只有 300 - 150 = 150,多拖 50
|
|
91
|
+
moveDrag(200)
|
|
92
|
+
await nextTick()
|
|
93
|
+
expect(ctx.container.style.gridTemplateColumns).toBe('550px 150px')
|
|
94
|
+
expect(ctx.resizer.style.transform).toBe('translate3d(550px, 0, 0)')
|
|
95
|
+
endDrag()
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
it('超限后松手:把手精确落回两列交界线', async () => {
|
|
99
|
+
const ctx = await mountLayout()
|
|
100
|
+
app = ctx.app
|
|
101
|
+
|
|
102
|
+
startDrag(ctx.resizer)
|
|
103
|
+
moveDrag(200)
|
|
104
|
+
endDrag()
|
|
105
|
+
|
|
106
|
+
// 模拟浏览器重排后真实边界(556)与拖拽期回写值(550)存在舍入差异,
|
|
107
|
+
// 只有 resize-end 的 syncResizers 会按重排结果重新对齐把手
|
|
108
|
+
mockColumn(ctx.container.children[0] as HTMLElement, 0, 556)
|
|
109
|
+
mockColumn(ctx.container.children[1] as HTMLElement, 566, 144)
|
|
110
|
+
await flush()
|
|
111
|
+
|
|
112
|
+
expect(ctx.resizer.style.transform).toBe('translate3d(556px, 0, 0)')
|
|
113
|
+
})
|
|
114
|
+
|
|
115
|
+
it('再次拖拽:从真实边界起步,上一轮超限不传染脏值', async () => {
|
|
116
|
+
const ctx = await mountLayout()
|
|
117
|
+
app = ctx.app
|
|
118
|
+
|
|
119
|
+
// 第一轮向右超限 50 后松手
|
|
120
|
+
startDrag(ctx.resizer)
|
|
121
|
+
moveDrag(200)
|
|
122
|
+
endDrag()
|
|
123
|
+
mockColumn(ctx.container.children[0] as HTMLElement, 0, 550)
|
|
124
|
+
mockColumn(ctx.container.children[1] as HTMLElement, 560, 150)
|
|
125
|
+
await flush()
|
|
126
|
+
|
|
127
|
+
// 第二轮向左拖 50(合法范围内);若把手 offset 残留超限脏值 600,这里会显示 550
|
|
128
|
+
startDrag(ctx.resizer, 300)
|
|
129
|
+
moveDrag(-50, 300)
|
|
130
|
+
await nextTick()
|
|
131
|
+
expect(ctx.container.style.gridTemplateColumns).toBe('500px 200px')
|
|
132
|
+
expect(ctx.resizer.style.transform).toBe('translate3d(500px, 0, 0)')
|
|
133
|
+
endDrag()
|
|
134
|
+
})
|
|
135
|
+
})
|
|
@@ -35,10 +35,15 @@ const emit = defineEmits<{
|
|
|
35
35
|
const { cls } = inject(LayoutDIKey)!
|
|
36
36
|
|
|
37
37
|
const className = computed(() => {
|
|
38
|
-
return [
|
|
38
|
+
return [
|
|
39
|
+
cls.e('resizer'),
|
|
40
|
+
bem.is('horizontal', props.horizontal),
|
|
41
|
+
bem.is('dragging', dragging.value)
|
|
42
|
+
]
|
|
39
43
|
})
|
|
40
44
|
|
|
41
45
|
const resizerRef = shallowRef<HTMLDivElement>()
|
|
46
|
+
const dragging = shallowRef(false)
|
|
42
47
|
|
|
43
48
|
let offset = props.offset ?? 0
|
|
44
49
|
const offsets = shallowReactive({
|
|
@@ -49,6 +54,7 @@ let currentOffset = 0
|
|
|
49
54
|
useDrag({
|
|
50
55
|
target: resizerRef,
|
|
51
56
|
onDragStart() {
|
|
57
|
+
dragging.value = true
|
|
52
58
|
currentOffset = offset
|
|
53
59
|
emit('resize-start')
|
|
54
60
|
},
|
|
@@ -64,6 +70,7 @@ useDrag({
|
|
|
64
70
|
}
|
|
65
71
|
},
|
|
66
72
|
onDragEnd() {
|
|
73
|
+
dragging.value = false
|
|
67
74
|
emit('resize-end')
|
|
68
75
|
}
|
|
69
76
|
})
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
direction="vertical"
|
|
12
12
|
@resize="handleResize($event, index)"
|
|
13
13
|
@resize-start="handleStartResize(index)"
|
|
14
|
-
@resize-end="
|
|
14
|
+
@resize-end="handleEndResize(index)"
|
|
15
15
|
>
|
|
16
16
|
</ULayoutResizer>
|
|
17
17
|
|
|
@@ -115,6 +115,8 @@ function syncResizers() {
|
|
|
115
115
|
|
|
116
116
|
let prevSize = 0
|
|
117
117
|
let nextSize = 0
|
|
118
|
+
// 拖拽起点的把手位置(左侧列的右边界),量取口径与 getResizeOffsets 一致
|
|
119
|
+
let startOffset = 0
|
|
118
120
|
const handleStartResize = (index: number) => {
|
|
119
121
|
const container = containerRef.value
|
|
120
122
|
if (!container) return
|
|
@@ -125,6 +127,7 @@ const handleStartResize = (index: number) => {
|
|
|
125
127
|
const nextDom = container.children[index + 1] as HTMLElement | undefined
|
|
126
128
|
prevSize = prevDom ? prevDom.getBoundingClientRect().width : 0
|
|
127
129
|
nextSize = nextDom ? nextDom.getBoundingClientRect().width : 0
|
|
130
|
+
startOffset = prevDom ? prevDom.offsetLeft + prevDom.offsetWidth : 0
|
|
128
131
|
emit('resize-start', index)
|
|
129
132
|
}
|
|
130
133
|
const handleResize = (offset: number, index: number) => {
|
|
@@ -135,6 +138,19 @@ const handleResize = (offset: number, index: number) => {
|
|
|
135
138
|
const clamped = Math.max(minPrev - prevSize, Math.min(nextSize - minNext, offset))
|
|
136
139
|
templateCols.value[index] = `${prevSize + clamped}px`
|
|
137
140
|
templateCols.value[index + 1] = `${nextSize - clamped}px`
|
|
141
|
+
// 增量被钳制时把手不能继续跟随鼠标,否则会脱离两列交界线(把手位置由列宽决定,
|
|
142
|
+
// resizer 自身的 offset 只是鼠标位移的镜像,松手后由 handleEndResize 回正)
|
|
143
|
+
if (clamped !== offset) {
|
|
144
|
+
resizerRefs.value[index]!.update(startOffset + clamped)
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** 拖拽期间容器尺寸不变、props 也不变,ResizeObserver 与 watch 都不会触发,需手动回正把手 */
|
|
149
|
+
const handleEndResize = (index: number) => {
|
|
150
|
+
emit('resize-end', index)
|
|
151
|
+
nextTick(() => {
|
|
152
|
+
syncResizers()
|
|
153
|
+
})
|
|
138
154
|
}
|
|
139
155
|
|
|
140
156
|
provide(LayoutDIKey, { cls })
|
|
@@ -10,16 +10,41 @@
|
|
|
10
10
|
position: absolute;
|
|
11
11
|
left: 0;
|
|
12
12
|
top: 0;
|
|
13
|
+
z-index: 1;
|
|
13
14
|
cursor: col-resize;
|
|
14
|
-
// background-color: fn.use-var(bg-color, middle);
|
|
15
|
-
// box-shadow: fn.use-var(shadow);
|
|
16
15
|
height: 100%;
|
|
17
16
|
width: 10px;
|
|
18
17
|
@include m.flex($align: center, $justify: center);
|
|
18
|
+
transition: background-color fn.use-var(transition, fast) fn.use-var(transition, ease);
|
|
19
19
|
|
|
20
|
-
//
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
// 常驻把手图标弱化显示,hover / 拖拽时点亮,避免整条把手长期抢视线
|
|
21
|
+
@include m.bem(icon) {
|
|
22
|
+
color: fn.use-var(text-color, assist);
|
|
23
|
+
opacity: 0.45;
|
|
24
|
+
transition:
|
|
25
|
+
color fn.use-var(transition, fast) fn.use-var(transition, ease),
|
|
26
|
+
opacity fn.use-var(transition, fast) fn.use-var(transition, ease);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&:hover,
|
|
30
|
+
&:active {
|
|
31
|
+
background-color: fn.color-a(color, 8, primary);
|
|
32
|
+
|
|
33
|
+
@include m.bem(icon) {
|
|
34
|
+
color: fn.use-var(color, primary);
|
|
35
|
+
opacity: 1;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// 拖拽中:整条把手保持高亮指示
|
|
40
|
+
@include m.is(dragging) {
|
|
41
|
+
background-color: fn.color-a(color, 16, primary);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@include m.is(horizontal) {
|
|
45
|
+
height: 10px;
|
|
46
|
+
width: 100%;
|
|
47
|
+
cursor: row-resize;
|
|
48
|
+
}
|
|
24
49
|
}
|
|
25
50
|
}
|
|
@@ -28,7 +28,7 @@ $root-name: loading;
|
|
|
28
28
|
border: 3px solid fn.color-a(color, 22, primary);
|
|
29
29
|
border-top-color: currentColor;
|
|
30
30
|
position: relative;
|
|
31
|
-
animation: loading-spin 0.
|
|
31
|
+
animation: loading-spin 0.6s linear infinite;
|
|
32
32
|
|
|
33
33
|
&::after {
|
|
34
34
|
content: '';
|
|
@@ -37,7 +37,7 @@ $root-name: loading;
|
|
|
37
37
|
border-radius: 50%;
|
|
38
38
|
border: 2px solid fn.color-a(color, 22, primary);
|
|
39
39
|
border-bottom-color: currentColor;
|
|
40
|
-
animation: loading-spin
|
|
40
|
+
animation: loading-spin 0.9s linear infinite reverse;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
}
|
|
@@ -90,13 +90,13 @@ $root-name: loading;
|
|
|
90
90
|
border-radius: 50%;
|
|
91
91
|
border: 3px solid fn.color-a(color, 22, primary);
|
|
92
92
|
border-top-color: currentColor;
|
|
93
|
-
animation: loading-spin 0.
|
|
93
|
+
animation: loading-spin 0.7s linear infinite;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
// ============================================================
|
|
98
98
|
// bars — 三条音频跳动
|
|
99
|
-
//
|
|
99
|
+
// 三根竖条固定 26px 高,以中心为基准 scaleY 对称伸缩(纯合成器动画,不动布局)
|
|
100
100
|
// ============================================================
|
|
101
101
|
@include m.e(bars) {
|
|
102
102
|
@include m.bem($root-name, loader) {
|
|
@@ -105,15 +105,16 @@ $root-name: loading;
|
|
|
105
105
|
background: currentColor;
|
|
106
106
|
border-radius: 3px;
|
|
107
107
|
position: relative;
|
|
108
|
+
transform-origin: center;
|
|
108
109
|
animation: loading-bars 1s ease-in-out infinite;
|
|
109
110
|
animation-delay: 0.15s;
|
|
110
111
|
|
|
112
|
+
// 伪元素与主条等高:top: 0 即垂直居中,不再占用 transform
|
|
111
113
|
&::before,
|
|
112
114
|
&::after {
|
|
113
115
|
content: '';
|
|
114
116
|
position: absolute;
|
|
115
|
-
top:
|
|
116
|
-
transform: translateY(-50%);
|
|
117
|
+
top: 0;
|
|
117
118
|
width: 6px;
|
|
118
119
|
height: 26px;
|
|
119
120
|
background: currentColor;
|
|
@@ -158,9 +159,39 @@ $root-name: loading;
|
|
|
158
159
|
@keyframes loading-bars {
|
|
159
160
|
0%,
|
|
160
161
|
100% {
|
|
161
|
-
|
|
162
|
+
transform: scaleY(0.38);
|
|
162
163
|
}
|
|
163
164
|
50% {
|
|
164
|
-
|
|
165
|
+
transform: scaleY(1);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// 减弱动态效果下仍保留的透明度呼吸(参照 skeleton-pulse 思路)
|
|
170
|
+
@keyframes loading-breathe {
|
|
171
|
+
0%,
|
|
172
|
+
100% {
|
|
173
|
+
opacity: 1;
|
|
174
|
+
}
|
|
175
|
+
50% {
|
|
176
|
+
opacity: 0.4;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// 减弱动态效果:旋转 spinner 改为 opacity 呼吸,去掉持续旋转
|
|
181
|
+
@media (prefers-reduced-motion: reduce) {
|
|
182
|
+
@include m.bem($root-name, dual-ring) {
|
|
183
|
+
@include m.bem($root-name, loader) {
|
|
184
|
+
animation: loading-breathe 1.2s ease-in-out infinite;
|
|
185
|
+
|
|
186
|
+
&::after {
|
|
187
|
+
animation: loading-breathe 1.2s ease-in-out infinite reverse;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
@include m.bem($root-name, ring) {
|
|
193
|
+
@include m.bem($root-name, loader) {
|
|
194
|
+
animation: loading-breathe 1.2s ease-in-out infinite;
|
|
195
|
+
}
|
|
165
196
|
}
|
|
166
197
|
}
|
|
@@ -35,6 +35,13 @@ $root-name: message;
|
|
|
35
35
|
|
|
36
36
|
@include m.e(close) {
|
|
37
37
|
cursor: pointer;
|
|
38
|
+
transition: transform fn.use-var(transition, fast) fn.use-var(transition, ease-out);
|
|
39
|
+
|
|
40
|
+
// 点击即关闭,过渡来不及显示——按下瞬间缩到位
|
|
41
|
+
&:active {
|
|
42
|
+
transform: scale(0.9);
|
|
43
|
+
transition-duration: 0s;
|
|
44
|
+
}
|
|
38
45
|
}
|
|
39
46
|
|
|
40
47
|
@include m.size using ($size) {
|
|
@@ -70,11 +77,22 @@ $root-name: message;
|
|
|
70
77
|
.#{$root-name}-move, /* 对移动中的元素应用的过渡 */
|
|
71
78
|
.#{$root-name}-enter-active,
|
|
72
79
|
.#{$root-name}-leave-active {
|
|
73
|
-
transition-duration:
|
|
74
|
-
transition-timing-function: ease;
|
|
80
|
+
transition-duration: fn.use-var(transition, normal);
|
|
81
|
+
transition-timing-function: fn.use-var(transition, ease-out);
|
|
75
82
|
transition-property: opacity, transform;
|
|
76
83
|
}
|
|
77
84
|
|
|
85
|
+
/* 出场比入场快 */
|
|
86
|
+
.#{$root-name}-leave-active {
|
|
87
|
+
transition-duration: fn.use-var(transition, fast);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* 列表重排为屏内位移:用 ease 更自然。leave(fast) 先于 move(normal) 结束,
|
|
91
|
+
离场项淡出后堆叠仍在缓收,不会出现悬空空档或骤停 */
|
|
92
|
+
.#{$root-name}-move {
|
|
93
|
+
transition-timing-function: fn.use-var(transition, ease);
|
|
94
|
+
}
|
|
95
|
+
|
|
78
96
|
.#{$root-name}-enter-from,
|
|
79
97
|
.#{$root-name}-leave-to {
|
|
80
98
|
opacity: 0;
|
|
@@ -82,6 +82,19 @@ $root-name: message-confirm;
|
|
|
82
82
|
transition-property: opacity;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
/* 出场比入场快:根 / mask / box(含 box 的 transform 过渡)同步缩短 */
|
|
86
|
+
.#{$root-name}-leave-active {
|
|
87
|
+
transition-duration: fn.use-var(transition, fast);
|
|
88
|
+
|
|
89
|
+
@include m.bem($root-name, mask) {
|
|
90
|
+
transition-duration: fn.use-var(transition, fast);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@include m.bem($root-name, box) {
|
|
94
|
+
transition-duration: fn.use-var(transition, fast);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
85
98
|
.#{$root-name}-enter-from,
|
|
86
99
|
.#{$root-name}-leave-to {
|
|
87
100
|
opacity: 0;
|
|
@@ -21,16 +21,19 @@
|
|
|
21
21
|
</span>
|
|
22
22
|
|
|
23
23
|
<div v-if="model?.length || filterable" :class="cls.e('tags')">
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
<!-- 离场纯淡出 + -move 收拢;入场沿用 tag 组件自身的缩放动画 -->
|
|
25
|
+
<TransitionGroup name="u-multi-select-tags">
|
|
26
|
+
<u-tag
|
|
27
|
+
v-for="option of tags"
|
|
28
|
+
:key="option[valueKey]"
|
|
29
|
+
:closable="!disabled"
|
|
30
|
+
size="small"
|
|
31
|
+
@close="handleClose(option)"
|
|
32
|
+
>
|
|
33
|
+
{{ renderOptionLabel(option) }}
|
|
34
|
+
</u-tag>
|
|
35
|
+
<u-tag v-if="restTag" key="__rest__" size="small"> {{ restTag }}+ </u-tag>
|
|
36
|
+
</TransitionGroup>
|
|
34
37
|
|
|
35
38
|
<!-- 内嵌查询输入框:承载过滤与回车创建 -->
|
|
36
39
|
<input
|