@veltra/mobile 1.0.0 → 1.1.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/package.json +32 -6
- package/src/components/_internal/bottom-sheet/bottom-sheet.vue +81 -0
- package/src/components/_internal/bottom-sheet/index.ts +1 -0
- package/src/components/_internal/bottom-sheet/style.scss +116 -0
- package/src/components/_internal/bottom-sheet/style.ts +1 -0
- package/src/components/_internal/overlay-container.ts +34 -0
- package/src/components/avatar/avatar.vue +44 -0
- package/src/components/avatar/index.ts +1 -0
- package/src/components/avatar/style.scss +53 -0
- package/src/components/avatar/style.ts +1 -0
- package/src/components/badge/badge.vue +59 -0
- package/src/components/badge/index.ts +1 -0
- package/src/components/badge/style.scss +62 -0
- package/src/components/badge/style.ts +1 -0
- package/src/components/button/button.vue +76 -0
- package/src/components/button/index.ts +1 -0
- package/src/components/button/style.scss +207 -0
- package/src/components/button/style.ts +1 -0
- package/src/components/card/card.vue +24 -0
- package/src/components/card/index.ts +1 -0
- package/src/components/card/style.scss +35 -0
- package/src/components/card/style.ts +1 -0
- package/src/components/cascade/cascade.vue +595 -0
- package/src/components/cascade/index.ts +1 -0
- package/src/components/cascade/node.ts +29 -0
- package/src/components/cascade/style.scss +424 -0
- package/src/components/cascade/style.ts +2 -0
- package/src/components/check-tag/check-tag.vue +35 -0
- package/src/components/check-tag/index.ts +1 -0
- package/src/components/check-tag/style.scss +46 -0
- package/src/components/check-tag/style.ts +1 -0
- package/src/components/checkbox/checkbox.vue +67 -0
- package/src/components/checkbox/index.ts +1 -0
- package/src/components/checkbox/style.scss +132 -0
- package/src/components/checkbox/style.ts +2 -0
- package/src/components/checkbox-group/checkbox-group.vue +94 -0
- package/src/components/checkbox-group/index.ts +1 -0
- package/src/components/checkbox-group/style.scss +57 -0
- package/src/components/checkbox-group/style.ts +2 -0
- package/src/components/collapse/collapse-item.vue +134 -0
- package/src/components/collapse/collapse.vue +117 -0
- package/src/components/collapse/di.ts +18 -0
- package/src/components/collapse/index.ts +3 -0
- package/src/components/collapse/style.scss +157 -0
- package/src/components/collapse/style.ts +1 -0
- package/src/components/date-picker/date-picker.vue +326 -0
- package/src/components/date-picker/index.ts +1 -0
- package/src/components/date-picker/style.scss +236 -0
- package/src/components/date-picker/style.ts +2 -0
- package/src/components/descriptions/descriptions-item.vue +12 -0
- package/src/components/descriptions/descriptions.vue +50 -0
- package/src/components/descriptions/index.ts +2 -0
- package/src/components/descriptions/style.scss +120 -0
- package/src/components/descriptions/style.ts +1 -0
- package/src/components/dialog/dialog.vue +143 -0
- package/src/components/dialog/index.ts +1 -0
- package/src/components/dialog/style.scss +163 -0
- package/src/components/dialog/style.ts +4 -0
- package/src/components/divider/divider.vue +29 -0
- package/src/components/divider/index.ts +1 -0
- package/src/components/divider/style.scss +91 -0
- package/src/components/divider/style.ts +1 -0
- package/src/components/drawer/drawer.vue +168 -0
- package/src/components/drawer/index.ts +1 -0
- package/src/components/drawer/style.scss +240 -0
- package/src/components/drawer/style.ts +2 -0
- package/src/components/empty/empty.vue +22 -0
- package/src/components/empty/index.ts +1 -0
- package/src/components/empty/style.scss +36 -0
- package/src/components/empty/style.ts +1 -0
- package/src/components/form/form.vue +119 -0
- package/src/components/form/index.ts +1 -0
- package/src/components/form/is-field-modified.ts +16 -0
- package/src/components/form/style.scss +58 -0
- package/src/components/form/style.ts +2 -0
- package/src/components/form/use-form-fields.ts +115 -0
- package/src/components/form/use-node-interceptor.ts +101 -0
- package/src/components/form-item/form-item.vue +171 -0
- package/src/components/form-item/helper.ts +9 -0
- package/src/components/form-item/index.ts +1 -0
- package/src/components/form-item/style.scss +121 -0
- package/src/components/form-item/style.ts +1 -0
- package/src/components/form-item/validate.ts +131 -0
- package/src/components/icon/icon.vue +23 -0
- package/src/components/icon/index.ts +1 -0
- package/src/components/icon/style.scss +37 -0
- package/src/components/icon/style.ts +1 -0
- package/src/components/input/index.ts +1 -0
- package/src/components/input/input.vue +187 -0
- package/src/components/input/style.scss +121 -0
- package/src/components/input/style.ts +1 -0
- package/src/components/list/index.ts +3 -0
- package/src/components/list/list-item.vue +20 -0
- package/src/components/list/list.vue +20 -0
- package/src/components/list/style.scss +50 -0
- package/src/components/list/style.ts +1 -0
- package/src/components/loading/directive.ts +34 -0
- package/src/components/loading/index.ts +3 -0
- package/src/components/loading/loading.vue +25 -0
- package/src/components/loading/style.scss +179 -0
- package/src/components/loading/style.ts +2 -0
- package/src/components/message/helper.ts +28 -0
- package/src/components/message/index.ts +3 -0
- package/src/components/message/message-box.vue +31 -0
- package/src/components/message/message.ts +122 -0
- package/src/components/message/message.vue +54 -0
- package/src/components/message/style.scss +130 -0
- package/src/components/message/style.ts +1 -0
- package/src/components/message-confirm/index.ts +3 -0
- package/src/components/message-confirm/message-confirm-box.vue +36 -0
- package/src/components/message-confirm/message-confirm.ts +139 -0
- package/src/components/message-confirm/message-confirm.vue +53 -0
- package/src/components/message-confirm/style.scss +138 -0
- package/src/components/message-confirm/style.ts +1 -0
- package/src/components/multi-select/index.ts +1 -0
- package/src/components/multi-select/multi-select.vue +410 -0
- package/src/components/multi-select/style.scss +376 -0
- package/src/components/multi-select/style.ts +2 -0
- package/src/components/number-input/index.ts +1 -0
- package/src/components/number-input/number-input.vue +407 -0
- package/src/components/number-input/style.scss +118 -0
- package/src/components/number-input/style.ts +2 -0
- package/src/components/password-input/index.ts +1 -0
- package/src/components/password-input/password-input.vue +134 -0
- package/src/components/password-input/style.scss +40 -0
- package/src/components/password-input/style.ts +2 -0
- package/src/components/progress/index.ts +1 -0
- package/src/components/progress/progress.vue +90 -0
- package/src/components/progress/style.scss +73 -0
- package/src/components/progress/style.ts +1 -0
- package/src/components/radio/index.ts +1 -0
- package/src/components/radio/radio.vue +57 -0
- package/src/components/radio/style.scss +113 -0
- package/src/components/radio/style.ts +1 -0
- package/src/components/radio-group/index.ts +1 -0
- package/src/components/radio-group/radio-group.vue +60 -0
- package/src/components/radio-group/style.scss +29 -0
- package/src/components/radio-group/style.ts +2 -0
- package/src/components/segment/index.ts +1 -0
- package/src/components/segment/segment.vue +121 -0
- package/src/components/segment/style.scss +118 -0
- package/src/components/segment/style.ts +1 -0
- package/src/components/select/index.ts +1 -0
- package/src/components/select/select.vue +278 -0
- package/src/components/select/style.scss +237 -0
- package/src/components/select/style.ts +2 -0
- package/src/components/select/use-options.ts +195 -0
- package/src/components/skeleton/index.ts +1 -0
- package/src/components/skeleton/skeleton.vue +37 -0
- package/src/components/skeleton/style.scss +95 -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/steps/index.ts +1 -0
- package/src/components/steps/steps.vue +114 -0
- package/src/components/steps/style.scss +231 -0
- package/src/components/steps/style.ts +1 -0
- package/src/components/switch/index.ts +1 -0
- package/src/components/switch/style.scss +137 -0
- package/src/components/switch/style.ts +1 -0
- package/src/components/switch/switch.vue +63 -0
- package/src/components/tabs/index.ts +1 -0
- package/src/components/tabs/style.scss +285 -0
- package/src/components/tabs/style.ts +1 -0
- package/src/components/tabs/tabs.vue +127 -0
- package/src/components/tag/index.ts +1 -0
- package/src/components/tag/style.scss +114 -0
- package/src/components/tag/style.ts +1 -0
- package/src/components/tag/tag.vue +49 -0
- package/src/components/text/index.ts +1 -0
- package/src/components/text/style.scss +63 -0
- package/src/components/text/style.ts +1 -0
- package/src/components/text/text.vue +63 -0
- package/src/components/textarea/index.ts +1 -0
- package/src/components/textarea/style.scss +124 -0
- package/src/components/textarea/style.ts +1 -0
- package/src/components/textarea/textarea.vue +121 -0
- package/src/components/textarea/utils.ts +11 -0
- package/src/components/time-picker/index.ts +1 -0
- package/src/components/time-picker/style.scss +216 -0
- package/src/components/time-picker/style.ts +2 -0
- package/src/components/time-picker/time-picker.vue +263 -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 +16 -0
- package/src/components/uploader/index.ts +1 -0
- package/src/components/uploader/style.scss +220 -0
- package/src/components/uploader/style.ts +1 -0
- package/src/components/uploader/uploader.vue +306 -0
- package/src/env.d.ts +7 -0
- package/src/index.ts +99 -1
- package/src/shared/bem.ts +12 -0
- package/src/shared/use-scroll-lock.ts +111 -0
- package/src/shared/use-touch-gesture.ts +150 -0
- package/src/styles/_tokens.scss +129 -0
- package/src/types/avatar.ts +31 -0
- package/src/types/badge.ts +28 -0
- package/src/types/button.ts +48 -0
- package/src/types/card.ts +16 -0
- package/src/types/cascade.ts +87 -0
- package/src/types/check-tag.ts +24 -0
- package/src/types/checkbox-group.ts +20 -0
- package/src/types/checkbox.ts +15 -0
- package/src/types/collapse.ts +79 -0
- package/src/types/date-picker.ts +39 -0
- package/src/types/descriptions.ts +22 -0
- package/src/types/dialog.ts +54 -0
- package/src/types/divider.ts +14 -0
- package/src/types/drawer.ts +38 -0
- package/src/types/empty.ts +19 -0
- package/src/types/form-item.ts +22 -0
- package/src/types/form.ts +54 -0
- package/src/types/icon.ts +10 -0
- package/src/types/input.ts +51 -0
- package/src/types/list.ts +13 -0
- package/src/types/loading.ts +20 -0
- package/src/types/message-confirm.ts +72 -0
- package/src/types/message.ts +71 -0
- package/src/types/multi-select.ts +38 -0
- package/src/types/number-input.ts +32 -0
- package/src/types/password-input.ts +19 -0
- package/src/types/progress.ts +22 -0
- package/src/types/radio-group.ts +33 -0
- package/src/types/radio.ts +18 -0
- package/src/types/segment.ts +42 -0
- package/src/types/select.ts +63 -0
- package/src/types/skeleton.ts +29 -0
- package/src/types/space.ts +22 -0
- package/src/types/steps.ts +67 -0
- package/src/types/switch.ts +17 -0
- package/src/types/tabs.ts +63 -0
- package/src/types/tag.ts +19 -0
- package/src/types/text.ts +28 -0
- package/src/types/textarea.ts +76 -0
- package/src/types/time-picker.ts +40 -0
- package/src/types/timeline.ts +15 -0
- package/src/types/uploader.ts +50 -0
- package/.turbo/turbo-build.log +0 -2
- package/.turbo/turbo-check-types.log +0 -1
- package/tsconfig.json +0 -12
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
@use 'pkg:@veltra/styles/mixins' as m with ($namespace: um);
|
|
2
|
+
@use 'pkg:@veltra/styles/functions' as fn;
|
|
3
|
+
@use '../../styles/tokens' as t;
|
|
4
|
+
|
|
5
|
+
$root-name: dialog;
|
|
6
|
+
|
|
7
|
+
// NutUI 惯例卡片宽度上限;视口内不溢出由 overlay 留白 + width: 100% 保证
|
|
8
|
+
$dialog-max-width: 320px;
|
|
9
|
+
|
|
10
|
+
@include m.bem($root-name, overlay) {
|
|
11
|
+
position: fixed;
|
|
12
|
+
inset: 0;
|
|
13
|
+
pointer-events: none;
|
|
14
|
+
outline: none;
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
// 两侧留白保证卡片在窄视口内不贴边
|
|
17
|
+
padding: fn.use-var(gap, large);
|
|
18
|
+
@include m.flex($justify: center);
|
|
19
|
+
|
|
20
|
+
@include m.is(modal) {
|
|
21
|
+
// 遮罩压暗主题无关,black 不在 theme.color 表内、无 alpha token,直接写 rgba
|
|
22
|
+
background-color: rgba(0, 0, 0, 0.32);
|
|
23
|
+
pointer-events: auto;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@include m.is(fullscreen) {
|
|
27
|
+
// 全屏去留白:卡片铺满到屏幕边缘,方角由设备屏幕圆角(真机硬件 / 外壳)裁剪
|
|
28
|
+
padding: 0;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@include m.b($root-name) {
|
|
33
|
+
pointer-events: auto;
|
|
34
|
+
box-sizing: border-box;
|
|
35
|
+
display: flex;
|
|
36
|
+
flex-direction: column;
|
|
37
|
+
flex-wrap: nowrap;
|
|
38
|
+
overflow: hidden;
|
|
39
|
+
width: 100%;
|
|
40
|
+
max-width: $dialog-max-width;
|
|
41
|
+
max-height: 86%;
|
|
42
|
+
// NutUI 惯例:大圆角居中卡片(弹层容器圆角)
|
|
43
|
+
border-radius: t.use-var('panel-radius');
|
|
44
|
+
background-color: fn.use-var(bg-color, top);
|
|
45
|
+
box-shadow: fn.use-var(shadow, lg);
|
|
46
|
+
|
|
47
|
+
// NutUI 惯例:标题居中加粗,主字号
|
|
48
|
+
@include m.e(header) {
|
|
49
|
+
position: relative;
|
|
50
|
+
flex-shrink: 0;
|
|
51
|
+
min-height: t.use-var('form-row-height');
|
|
52
|
+
padding: t.use-var('spacing-lg') t.use-var('spacing-lg') 0;
|
|
53
|
+
@include m.flex($justify: center);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@include m.e(title) {
|
|
57
|
+
width: 100%;
|
|
58
|
+
font-size: t.use-var('font-size-main');
|
|
59
|
+
font-weight: 600;
|
|
60
|
+
color: fn.use-var(text-color, title);
|
|
61
|
+
line-height: 1.4;
|
|
62
|
+
text-align: center;
|
|
63
|
+
// 多行标题省略为两行,长标题不挤压正文
|
|
64
|
+
display: -webkit-box;
|
|
65
|
+
-webkit-box-orient: vertical;
|
|
66
|
+
-webkit-line-clamp: 2;
|
|
67
|
+
overflow: hidden;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// 标题居中时关闭按钮绝对定位在右上角,不挤偏标题
|
|
71
|
+
@include m.e(close) {
|
|
72
|
+
position: absolute;
|
|
73
|
+
top: 0;
|
|
74
|
+
right: 0;
|
|
75
|
+
// 关闭热区不小于 44x44
|
|
76
|
+
min-width: t.use-var('touch-target');
|
|
77
|
+
min-height: t.use-var('touch-target');
|
|
78
|
+
padding: 0;
|
|
79
|
+
border: none;
|
|
80
|
+
background-color: transparent;
|
|
81
|
+
color: fn.use-var(text-color, second);
|
|
82
|
+
font-size: t.use-var('font-size-main');
|
|
83
|
+
line-height: 1;
|
|
84
|
+
-webkit-appearance: none;
|
|
85
|
+
-webkit-tap-highlight-color: transparent;
|
|
86
|
+
@include m.flex($display: inline-flex, $justify: center);
|
|
87
|
+
|
|
88
|
+
&:active {
|
|
89
|
+
color: fn.use-var(text-color, main);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
& > svg {
|
|
93
|
+
width: 1em;
|
|
94
|
+
height: 1em;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@include m.e(body) {
|
|
99
|
+
flex-grow: 1;
|
|
100
|
+
overflow-y: auto;
|
|
101
|
+
-webkit-overflow-scrolling: touch;
|
|
102
|
+
// NutUI 惯例:正文默认居中,表单等场景经 contentAlign 切左对齐
|
|
103
|
+
text-align: center;
|
|
104
|
+
font-size: t.use-var('font-size-main');
|
|
105
|
+
color: fn.use-var(text-color, second);
|
|
106
|
+
line-height: 1.6;
|
|
107
|
+
padding: t.use-var('spacing-lg');
|
|
108
|
+
word-break: break-word;
|
|
109
|
+
|
|
110
|
+
@include m.is(align-left) {
|
|
111
|
+
text-align: left;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@include m.is(align-right) {
|
|
115
|
+
text-align: right;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// 移动端惯例水平按钮组:等宽铺满、主操作(最后一个)居右,
|
|
120
|
+
// 操作区高度不小于 44px 触控下限(NutUI 惯例 48px)
|
|
121
|
+
@include m.e(footer) {
|
|
122
|
+
flex-shrink: 0;
|
|
123
|
+
gap: t.use-var('spacing-md');
|
|
124
|
+
min-height: t.use-var('form-row-height');
|
|
125
|
+
padding: t.use-var('spacing-sm') t.use-var('spacing-lg');
|
|
126
|
+
@include m.flex;
|
|
127
|
+
|
|
128
|
+
// 按钮等宽铺满,包括插槽内容
|
|
129
|
+
& > * {
|
|
130
|
+
flex: 1 1 0;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
@include m.is(actions-vertical) {
|
|
134
|
+
flex-direction: column;
|
|
135
|
+
|
|
136
|
+
& > * {
|
|
137
|
+
width: 100%;
|
|
138
|
+
flex-basis: auto;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@include m.is(fullscreen) {
|
|
144
|
+
max-width: none;
|
|
145
|
+
max-height: none;
|
|
146
|
+
width: 100%;
|
|
147
|
+
height: 100%;
|
|
148
|
+
border-radius: 0;
|
|
149
|
+
|
|
150
|
+
// 全屏铺满视口时正文与按钮组让出底部安全区(手势条)
|
|
151
|
+
@include m.bem($root-name, body) {
|
|
152
|
+
padding-bottom: calc(#{t.use-var('spacing-lg')} + env(safe-area-inset-bottom));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
@include m.bem($root-name, footer) {
|
|
156
|
+
padding-bottom: calc(#{t.use-var('spacing-sm')} + env(safe-area-inset-bottom));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
@include m.bem($root-name, trigger) {
|
|
162
|
+
display: inline-flex;
|
|
163
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="classList" 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 { computed, useSlots } from 'vue'
|
|
11
|
+
|
|
12
|
+
import { bem } from '../../shared/bem'
|
|
13
|
+
import type { DividerProps } from '../../types/divider'
|
|
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 classList = 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,91 @@
|
|
|
1
|
+
@use 'pkg:@veltra/styles/mixins' as m with ($namespace: um);
|
|
2
|
+
@use 'pkg:@veltra/styles/functions' as fn;
|
|
3
|
+
@use '../../styles/tokens' as t;
|
|
4
|
+
|
|
5
|
+
// 方便拼接
|
|
6
|
+
$root-name: divider;
|
|
7
|
+
|
|
8
|
+
// 文字靠左/靠右时,对侧长线之外那一侧的短线宽度
|
|
9
|
+
$short-line-width: 5%;
|
|
10
|
+
|
|
11
|
+
@include m.b($root-name) {
|
|
12
|
+
// 水平分割线(默认形态):单独使用时由上边框划线
|
|
13
|
+
border-top: 1px solid fn.use-var(border-color);
|
|
14
|
+
margin: t.use-var(spacing-lg) 0;
|
|
15
|
+
|
|
16
|
+
// 虚线
|
|
17
|
+
@include m.is(dashed) {
|
|
18
|
+
border-top-style: dashed;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// 垂直分割线:行内元素,随文字高度伸缩
|
|
22
|
+
@include m.m(vertical) {
|
|
23
|
+
display: inline-block;
|
|
24
|
+
border-top: none;
|
|
25
|
+
border-left: 1px solid fn.use-var(border-color);
|
|
26
|
+
height: 1em;
|
|
27
|
+
margin: 0 t.use-var(spacing-sm);
|
|
28
|
+
vertical-align: middle;
|
|
29
|
+
|
|
30
|
+
@include m.is(dashed) {
|
|
31
|
+
border-left-style: dashed;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// 嵌套文字:两侧伪元素划线,文字默认居中
|
|
36
|
+
@include m.is(with-text) {
|
|
37
|
+
display: flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
border-top: none;
|
|
40
|
+
margin: t.use-var(spacing-lg) 0;
|
|
41
|
+
|
|
42
|
+
&::before,
|
|
43
|
+
&::after {
|
|
44
|
+
content: '';
|
|
45
|
+
flex: 1;
|
|
46
|
+
border-top: 1px solid fn.use-var(border-color);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
&::before {
|
|
50
|
+
margin-right: t.use-var(spacing-sm);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
&::after {
|
|
54
|
+
margin-left: t.use-var(spacing-sm);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// 虚线作用于两侧伪元素线
|
|
58
|
+
@include m.is(dashed) {
|
|
59
|
+
&::before,
|
|
60
|
+
&::after {
|
|
61
|
+
border-top-style: dashed;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// 文字靠左:左线收窄为短线
|
|
67
|
+
@include m.m(left) {
|
|
68
|
+
@include m.is(with-text) {
|
|
69
|
+
&::before {
|
|
70
|
+
flex: none;
|
|
71
|
+
width: $short-line-width;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// 文字靠右:右线收窄为短线
|
|
77
|
+
@include m.m(right) {
|
|
78
|
+
@include m.is(with-text) {
|
|
79
|
+
&::after {
|
|
80
|
+
flex: none;
|
|
81
|
+
width: $short-line-width;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@include m.e(text) {
|
|
87
|
+
color: fn.use-var(text-color, main);
|
|
88
|
+
font-size: t.use-var(font-size-main);
|
|
89
|
+
white-space: nowrap;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './style.scss'
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Teleport :to="getOverlayContainer()">
|
|
3
|
+
<transition name="fade" appear @enter="onOverlayEnter" @after-leave="onOverlayLeave">
|
|
4
|
+
<div
|
|
5
|
+
v-if="overlayVisible"
|
|
6
|
+
:class="overlayCls.b"
|
|
7
|
+
:style="{ zIndex: overlayZIndex }"
|
|
8
|
+
@click="close"
|
|
9
|
+
>
|
|
10
|
+
<transition :name="transitionName" appear @after-leave="onAfterDrawerLeave">
|
|
11
|
+
<div
|
|
12
|
+
v-if="drawerVisible"
|
|
13
|
+
v-bind="$attrs"
|
|
14
|
+
:class="drawerClass"
|
|
15
|
+
:style="dragStyle"
|
|
16
|
+
@click.stop
|
|
17
|
+
>
|
|
18
|
+
<!-- 边缘拖拽把手:上/下为整行横把手,左/右为内沿居中的竖把手 -->
|
|
19
|
+
<div
|
|
20
|
+
:class="cls.e('grabber')"
|
|
21
|
+
@touchstart.passive="dragHandlers.touchstart"
|
|
22
|
+
@touchmove.prevent="dragHandlers.touchmove"
|
|
23
|
+
@touchend.passive="dragHandlers.touchend"
|
|
24
|
+
@touchcancel.passive="dragHandlers.touchcancel"
|
|
25
|
+
/>
|
|
26
|
+
|
|
27
|
+
<div v-if="title || showClose" :class="cls.e('header')">
|
|
28
|
+
<span :class="cls.e('title')">{{ title }}</span>
|
|
29
|
+
|
|
30
|
+
<button
|
|
31
|
+
v-if="showClose"
|
|
32
|
+
:class="cls.e('close')"
|
|
33
|
+
type="button"
|
|
34
|
+
aria-label="关闭"
|
|
35
|
+
@click="close"
|
|
36
|
+
>
|
|
37
|
+
<Close />
|
|
38
|
+
</button>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<div :class="cls.e('content')">
|
|
42
|
+
<slot />
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
</transition>
|
|
46
|
+
</div>
|
|
47
|
+
</transition>
|
|
48
|
+
</Teleport>
|
|
49
|
+
</template>
|
|
50
|
+
|
|
51
|
+
<script lang="ts" setup>
|
|
52
|
+
import { Close } from '@veltra/icons/normal'
|
|
53
|
+
import { zIndex } from '@veltra/utils'
|
|
54
|
+
import { computed, shallowRef, watch } from 'vue'
|
|
55
|
+
|
|
56
|
+
import { bem } from '../../shared/bem'
|
|
57
|
+
import { shouldCloseByDrag, useTouchGesture } from '../../shared/use-touch-gesture'
|
|
58
|
+
import type { DrawerEmits, DrawerPlacement, DrawerProps } from '../../types/drawer'
|
|
59
|
+
import { getOverlayContainer, useOverlayScrollLock } from '../_internal/overlay-container'
|
|
60
|
+
|
|
61
|
+
defineOptions({ name: 'UDrawer', inheritAttrs: false })
|
|
62
|
+
|
|
63
|
+
const props = withDefaults(defineProps<DrawerProps>(), { placement: 'bottom' })
|
|
64
|
+
|
|
65
|
+
const emit = defineEmits<DrawerEmits>()
|
|
66
|
+
|
|
67
|
+
const cls = bem('drawer')
|
|
68
|
+
const overlayCls = bem('drawer-overlay')
|
|
69
|
+
|
|
70
|
+
const visible = defineModel<boolean>({ default: false })
|
|
71
|
+
|
|
72
|
+
const overlayVisible = shallowRef(false)
|
|
73
|
+
const drawerVisible = shallowRef(false)
|
|
74
|
+
const overlayZIndex = shallowRef<number>()
|
|
75
|
+
|
|
76
|
+
const transitionName = computed(() => `drawer-slide-${props.placement}`)
|
|
77
|
+
|
|
78
|
+
// 打开期间锁定背景滚动(body / 设备外壳视口),完全关闭后恢复原滚动位置
|
|
79
|
+
const scrollLock = useOverlayScrollLock()
|
|
80
|
+
|
|
81
|
+
// 打开时盖在新一层级上;关闭链路:抽屉滑出 -> 遮罩退场 -> closed
|
|
82
|
+
watch(
|
|
83
|
+
visible,
|
|
84
|
+
(v) => {
|
|
85
|
+
if (v) {
|
|
86
|
+
overlayZIndex.value = zIndex()
|
|
87
|
+
resetDrag()
|
|
88
|
+
scrollLock.lock()
|
|
89
|
+
overlayVisible.value = true
|
|
90
|
+
} else {
|
|
91
|
+
drawerVisible.value = false
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
{ immediate: true }
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
function onOverlayEnter() {
|
|
98
|
+
drawerVisible.value = true
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function onAfterDrawerLeave() {
|
|
102
|
+
overlayVisible.value = false
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** 遮罩退场完成即整条关闭链路结束:解锁背景滚动并通知 closed */
|
|
106
|
+
function onOverlayLeave() {
|
|
107
|
+
scrollLock.unlock()
|
|
108
|
+
emit('closed')
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** 关闭抽屉:写回 model(emit update:modelValue),滑出经 watch 驱动 */
|
|
112
|
+
const close = () => {
|
|
113
|
+
visible.value = false
|
|
114
|
+
emit('close')
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// ---- 四向边缘拖拽关闭(实现细节,不新增公开 API) ----
|
|
118
|
+
|
|
119
|
+
/** 各方位沿关闭方向拖拽的轴与符号:bottom 下拉 / top 上推 / left 左拖 / right 右拖 */
|
|
120
|
+
const DRAG_DISMISS: Record<DrawerPlacement, { axis: 'x' | 'y'; sign: 1 | -1 }> = {
|
|
121
|
+
bottom: { axis: 'y', sign: 1 },
|
|
122
|
+
top: { axis: 'y', sign: -1 },
|
|
123
|
+
left: { axis: 'x', sign: -1 },
|
|
124
|
+
right: { axis: 'x', sign: 1 }
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** 沿关闭方向的实时偏移,经 CSS 变量并入滑动过渡,松手回弹或继续滑出 */
|
|
128
|
+
const dragOffset = shallowRef(0)
|
|
129
|
+
const dragging = shallowRef(false)
|
|
130
|
+
|
|
131
|
+
const dragStyle = computed(() => {
|
|
132
|
+
return dragOffset.value ? { '--u-drawer-drag': `${dragOffset.value}px` } : undefined
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
const drawerClass = computed(() => {
|
|
136
|
+
return [cls.b, bem.is(props.placement), bem.is('dragging', dragging.value)]
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
const dragHandlers = useTouchGesture({
|
|
140
|
+
onStart() {
|
|
141
|
+
dragging.value = true
|
|
142
|
+
},
|
|
143
|
+
onMove(state) {
|
|
144
|
+
const { axis, sign } = DRAG_DISMISS[props.placement]
|
|
145
|
+
// 只跟随朝关闭方向的分量,反方向拖动面板不动
|
|
146
|
+
dragOffset.value = Math.max(0, sign * (axis === 'x' ? state.dx : state.dy))
|
|
147
|
+
},
|
|
148
|
+
onEnd(state) {
|
|
149
|
+
dragging.value = false
|
|
150
|
+
const { axis, sign } = DRAG_DISMISS[props.placement]
|
|
151
|
+
if (shouldCloseByDrag(state, { axis, sign })) {
|
|
152
|
+
close()
|
|
153
|
+
} else {
|
|
154
|
+
dragOffset.value = 0
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
onCancel() {
|
|
158
|
+
// 手势被打断(来电、落到多指等):回弹而不是关闭
|
|
159
|
+
dragging.value = false
|
|
160
|
+
dragOffset.value = 0
|
|
161
|
+
}
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
function resetDrag() {
|
|
165
|
+
dragging.value = false
|
|
166
|
+
dragOffset.value = 0
|
|
167
|
+
}
|
|
168
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as UDrawer } from './drawer.vue'
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
@use 'pkg:@veltra/styles/mixins' as m with ($namespace: um);
|
|
2
|
+
@use 'pkg:@veltra/styles/functions' as fn;
|
|
3
|
+
@use '../../styles/tokens' as t;
|
|
4
|
+
|
|
5
|
+
$root-name: drawer;
|
|
6
|
+
$overlay-name: #{$root-name}-overlay;
|
|
7
|
+
|
|
8
|
+
// 侧滑宽度 / 上下抽屉高度上限(相对弹层宿主,窄屏与模拟器内均不溢出)
|
|
9
|
+
$side-width: min(86%, 400px);
|
|
10
|
+
$vertical-max-height: min(70%, 560px);
|
|
11
|
+
|
|
12
|
+
@include m.b($overlay-name) {
|
|
13
|
+
position: fixed;
|
|
14
|
+
inset: 0;
|
|
15
|
+
// 遮罩压暗主题无关,black 不在 theme.color 表内、无 alpha token,直接写 rgba
|
|
16
|
+
background-color: rgba(0, 0, 0, 0.32);
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@include m.b($root-name) {
|
|
21
|
+
position: absolute;
|
|
22
|
+
box-sizing: border-box;
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
background-color: fn.use-var(bg-color, top);
|
|
26
|
+
box-shadow: fn.use-var(shadow, lg);
|
|
27
|
+
// 松手回弹;进出滑动的 -active 类在其后声明,覆盖此过渡
|
|
28
|
+
transition: transform fn.use-var(transition, normal) fn.use-var(transition, ease-out);
|
|
29
|
+
|
|
30
|
+
// 拖拽跟手期间禁用过渡,松手回弹 / 继续滑出时恢复
|
|
31
|
+
@include m.is(dragging) {
|
|
32
|
+
transition: none;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// 边缘拖拽把手:热区不小于 44x44,视觉为居中的圆角把手
|
|
36
|
+
@include m.e(grabber) {
|
|
37
|
+
flex-shrink: 0;
|
|
38
|
+
box-sizing: border-box;
|
|
39
|
+
touch-action: none;
|
|
40
|
+
@include m.flex($display: flex, $justify: center);
|
|
41
|
+
|
|
42
|
+
&::after {
|
|
43
|
+
content: '';
|
|
44
|
+
border-radius: t.control-radius(small);
|
|
45
|
+
background-color: fn.use-var(text-color, assist);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@include m.e(header) {
|
|
50
|
+
flex-shrink: 0;
|
|
51
|
+
min-height: t.use-var('form-row-height');
|
|
52
|
+
padding: 0 t.use-var('spacing-md');
|
|
53
|
+
gap: t.use-var('spacing-md');
|
|
54
|
+
border-bottom: fn.use-var(border);
|
|
55
|
+
@include m.flex($justify: space-between);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@include m.e(title) {
|
|
59
|
+
font-size: t.use-var('font-size-main');
|
|
60
|
+
font-weight: 600;
|
|
61
|
+
color: fn.use-var(text-color, title);
|
|
62
|
+
@include m.ellipsis;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@include m.e(close) {
|
|
66
|
+
// 关闭热区不小于 44x44
|
|
67
|
+
flex-shrink: 0;
|
|
68
|
+
min-width: t.use-var('touch-target');
|
|
69
|
+
min-height: t.use-var('touch-target');
|
|
70
|
+
padding: 0;
|
|
71
|
+
border: none;
|
|
72
|
+
background-color: transparent;
|
|
73
|
+
color: fn.use-var(text-color, second);
|
|
74
|
+
font-size: t.use-var('font-size-main');
|
|
75
|
+
line-height: 1;
|
|
76
|
+
-webkit-appearance: none;
|
|
77
|
+
-webkit-tap-highlight-color: transparent;
|
|
78
|
+
@include m.flex($display: inline-flex, $justify: center);
|
|
79
|
+
|
|
80
|
+
&:active {
|
|
81
|
+
color: fn.use-var(text-color, main);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
& > svg {
|
|
85
|
+
width: 1em;
|
|
86
|
+
height: 1em;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
@include m.e(content) {
|
|
91
|
+
flex-grow: 1;
|
|
92
|
+
overflow-y: auto;
|
|
93
|
+
-webkit-overflow-scrolling: touch;
|
|
94
|
+
font-size: t.use-var('font-size-main');
|
|
95
|
+
padding: t.use-var('spacing-lg');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@include m.is(left, right) {
|
|
99
|
+
top: 0;
|
|
100
|
+
bottom: 0;
|
|
101
|
+
width: $side-width;
|
|
102
|
+
max-height: 100%;
|
|
103
|
+
|
|
104
|
+
// 侧边形态:内沿中部 44x44 竖把手(绝对定位,不占内容流)
|
|
105
|
+
@include m.bem($root-name, grabber) {
|
|
106
|
+
position: absolute;
|
|
107
|
+
top: 50%;
|
|
108
|
+
width: t.use-var('touch-target');
|
|
109
|
+
height: t.use-var('touch-target');
|
|
110
|
+
transform: translateY(-50%);
|
|
111
|
+
z-index: 1;
|
|
112
|
+
|
|
113
|
+
&::after {
|
|
114
|
+
width: 4px;
|
|
115
|
+
height: 36px;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@include m.is(top, bottom) {
|
|
121
|
+
left: 0;
|
|
122
|
+
right: 0;
|
|
123
|
+
max-height: $vertical-max-height;
|
|
124
|
+
|
|
125
|
+
// 上下形态:整行 44px 触控热区,视觉为居中横把手(把手由 flex 居中,热区 padding 走间距刻度)
|
|
126
|
+
@include m.bem($root-name, grabber) {
|
|
127
|
+
width: 100%;
|
|
128
|
+
height: t.use-var('touch-target');
|
|
129
|
+
padding: t.use-var('spacing-sm') 0;
|
|
130
|
+
|
|
131
|
+
&::after {
|
|
132
|
+
width: 36px;
|
|
133
|
+
height: 4px;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// 各方位:贴边定位、外沿圆角,拖拽偏移挂到基础 transform 上,
|
|
139
|
+
// 松手关闭时从当前位置继续滑出(--u-drawer-drag 始终 ≥ 0,方向由此处折叠)
|
|
140
|
+
@include m.is(right) {
|
|
141
|
+
right: 0;
|
|
142
|
+
border-radius: t.use-var('panel-radius') 0 0 t.use-var('panel-radius');
|
|
143
|
+
transform: translateX(var(--u-drawer-drag, 0px));
|
|
144
|
+
|
|
145
|
+
// 把手锚定在面板左内沿
|
|
146
|
+
@include m.bem($root-name, grabber) {
|
|
147
|
+
left: 0;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
&.drawer-slide-right-enter-from,
|
|
151
|
+
&.drawer-slide-right-leave-to {
|
|
152
|
+
transform: translateX(calc(100% + var(--u-drawer-drag, 0px)));
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
@include m.is(left) {
|
|
157
|
+
left: 0;
|
|
158
|
+
border-radius: 0 t.use-var('panel-radius') t.use-var('panel-radius') 0;
|
|
159
|
+
transform: translateX(calc(-1 * var(--u-drawer-drag, 0px)));
|
|
160
|
+
|
|
161
|
+
// 把手锚定在面板右内沿
|
|
162
|
+
@include m.bem($root-name, grabber) {
|
|
163
|
+
right: 0;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
&.drawer-slide-left-enter-from,
|
|
167
|
+
&.drawer-slide-left-leave-to {
|
|
168
|
+
transform: translateX(calc(-100% - var(--u-drawer-drag, 0px)));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
@include m.is(top) {
|
|
173
|
+
top: 0;
|
|
174
|
+
border-radius: 0 0 t.use-var('panel-radius') t.use-var('panel-radius');
|
|
175
|
+
// 顶部形态让出刘海安全区
|
|
176
|
+
padding-top: env(safe-area-inset-top);
|
|
177
|
+
transform: translateY(calc(-1 * var(--u-drawer-drag, 0px)));
|
|
178
|
+
|
|
179
|
+
// 把手渲染在面板下边缘(关闭方向)
|
|
180
|
+
@include m.bem($root-name, grabber) {
|
|
181
|
+
order: 1;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
&.drawer-slide-top-enter-from,
|
|
185
|
+
&.drawer-slide-top-leave-to {
|
|
186
|
+
transform: translateY(calc(-100% - var(--u-drawer-drag, 0px)));
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
@include m.is(bottom) {
|
|
191
|
+
bottom: 0;
|
|
192
|
+
border-radius: t.use-var('panel-radius') t.use-var('panel-radius') 0 0;
|
|
193
|
+
// 底部形态让出手势条安全区
|
|
194
|
+
padding-bottom: env(safe-area-inset-bottom);
|
|
195
|
+
transform: translateY(var(--u-drawer-drag, 0px));
|
|
196
|
+
|
|
197
|
+
&.drawer-slide-bottom-enter-from,
|
|
198
|
+
&.drawer-slide-bottom-leave-to {
|
|
199
|
+
transform: translateY(calc(100% + var(--u-drawer-drag, 0px)));
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// 滑动进出过渡
|
|
205
|
+
.drawer-slide-right-enter-active,
|
|
206
|
+
.drawer-slide-left-enter-active,
|
|
207
|
+
.drawer-slide-top-enter-active,
|
|
208
|
+
.drawer-slide-bottom-enter-active,
|
|
209
|
+
.drawer-slide-right-leave-active,
|
|
210
|
+
.drawer-slide-left-leave-active,
|
|
211
|
+
.drawer-slide-top-leave-active,
|
|
212
|
+
.drawer-slide-bottom-leave-active {
|
|
213
|
+
transition: transform fn.use-var(transition, normal) fn.use-var(transition, ease-out);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// 减弱动态效果:面板不位移,只淡入淡出。拖拽跟手不在这里处理。
|
|
217
|
+
@media (prefers-reduced-motion: reduce) {
|
|
218
|
+
.drawer-slide-right-enter-active,
|
|
219
|
+
.drawer-slide-left-enter-active,
|
|
220
|
+
.drawer-slide-top-enter-active,
|
|
221
|
+
.drawer-slide-bottom-enter-active,
|
|
222
|
+
.drawer-slide-right-leave-active,
|
|
223
|
+
.drawer-slide-left-leave-active,
|
|
224
|
+
.drawer-slide-top-leave-active,
|
|
225
|
+
.drawer-slide-bottom-leave-active {
|
|
226
|
+
transition-property: opacity;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.drawer-slide-right-enter-from,
|
|
230
|
+
.drawer-slide-right-leave-to,
|
|
231
|
+
.drawer-slide-left-enter-from,
|
|
232
|
+
.drawer-slide-left-leave-to,
|
|
233
|
+
.drawer-slide-top-enter-from,
|
|
234
|
+
.drawer-slide-top-leave-to,
|
|
235
|
+
.drawer-slide-bottom-enter-from,
|
|
236
|
+
.drawer-slide-bottom-leave-to {
|
|
237
|
+
transform: none;
|
|
238
|
+
opacity: 0;
|
|
239
|
+
}
|
|
240
|
+
}
|