stellar-ui-v2 1.35.3
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/common/css/common.scss +61 -0
- package/components/ste-animate/README.md +117 -0
- package/components/ste-animate/animate.scss +247 -0
- package/components/ste-animate/ste-animate.vue +200 -0
- package/components/ste-badge/README.md +171 -0
- package/components/ste-badge/ste-badge.vue +238 -0
- package/components/ste-barcode/README.md +36 -0
- package/components/ste-barcode/encode2.js +317 -0
- package/components/ste-barcode/ste-barcode.vue +213 -0
- package/components/ste-button/README.md +129 -0
- package/components/ste-button/ste-button.vue +345 -0
- package/components/ste-calendar/README.md +304 -0
- package/components/ste-calendar/self-date.js +119 -0
- package/components/ste-calendar/ste-calendar.vue +578 -0
- package/components/ste-checkbox/README.md +297 -0
- package/components/ste-checkbox/ste-checkbox.vue +305 -0
- package/components/ste-checkbox-group/ste-checkbox-group.vue +133 -0
- package/components/ste-code-input/README.md +67 -0
- package/components/ste-code-input/ste-code-input.vue +302 -0
- package/components/ste-date-picker/README.md +135 -0
- package/components/ste-date-picker/ste-date-picker.vue +407 -0
- package/components/ste-drag/README.md +103 -0
- package/components/ste-drag/ste-drag.vue +203 -0
- package/components/ste-dropdown-menu/README.md +358 -0
- package/components/ste-dropdown-menu/ste-dropdown-menu.vue +405 -0
- package/components/ste-dropdown-menu-item/ste-dropdown-menu-item.vue +176 -0
- package/components/ste-icon/README.md +90 -0
- package/components/ste-icon/iconfont.css +8 -0
- package/components/ste-icon/ste-icon.vue +147 -0
- package/components/ste-image/README.md +154 -0
- package/components/ste-image/ste-image.vue +218 -0
- package/components/ste-index-item/ste-index-item.vue +96 -0
- package/components/ste-index-list/README.md +153 -0
- package/components/ste-index-list/ste-index-list.vue +128 -0
- package/components/ste-input/README.md +146 -0
- package/components/ste-input/ste-input.vue +480 -0
- package/components/ste-loading/README.md +81 -0
- package/components/ste-loading/ste-loading.vue +166 -0
- package/components/ste-media-preview/README.md +243 -0
- package/components/ste-media-preview/TouchScaleing.js +102 -0
- package/components/ste-media-preview/ste-media-preview.vue +267 -0
- package/components/ste-message-box/README.md +217 -0
- package/components/ste-message-box/ste-message-box.js +72 -0
- package/components/ste-message-box/ste-message-box.vue +380 -0
- package/components/ste-notice-bar/README.md +129 -0
- package/components/ste-notice-bar/ste-notice-bar.vue +331 -0
- package/components/ste-number-keyboard/README.md +246 -0
- package/components/ste-number-keyboard/keyboard.vue +140 -0
- package/components/ste-number-keyboard/ste-number-keyboard.vue +240 -0
- package/components/ste-picker/ste-picker.vue +258 -0
- package/components/ste-popup/README.md +148 -0
- package/components/ste-popup/ste-popup.vue +337 -0
- package/components/ste-price/README.md +129 -0
- package/components/ste-price/ste-price.vue +258 -0
- package/components/ste-progress/README.md +87 -0
- package/components/ste-progress/ste-progress.vue +200 -0
- package/components/ste-qrcode/README.md +50 -0
- package/components/ste-qrcode/ste-qrcode.vue +164 -0
- package/components/ste-qrcode/uqrcode.js +34 -0
- package/components/ste-radio/README.md +286 -0
- package/components/ste-radio/ste-radio.vue +293 -0
- package/components/ste-radio-group/ste-radio-group.vue +128 -0
- package/components/ste-rate/README.md +115 -0
- package/components/ste-rate/ste-rate.vue +202 -0
- package/components/ste-read-more/README.md +111 -0
- package/components/ste-read-more/ste-read-more.vue +133 -0
- package/components/ste-rich-text/README.md +31 -0
- package/components/ste-rich-text/ste-rich-text.vue +70 -0
- package/components/ste-scroll-to/README.md +68 -0
- package/components/ste-scroll-to/mixin.js +173 -0
- package/components/ste-scroll-to/ste-scroll-to.vue +45 -0
- package/components/ste-scroll-to-item/ste-scroll-to-item.vue +25 -0
- package/components/ste-search/README.md +262 -0
- package/components/ste-search/ste-search.vue +547 -0
- package/components/ste-select/README.md +434 -0
- package/components/ste-select/datapager.vue +62 -0
- package/components/ste-select/datetime.vue +106 -0
- package/components/ste-select/defaultDate.js +142 -0
- package/components/ste-select/ste-select.vue +843 -0
- package/components/ste-signature/README.md +105 -0
- package/components/ste-signature/ste-signature.vue +220 -0
- package/components/ste-slider/README.md +165 -0
- package/components/ste-slider/ste-slider.vue +544 -0
- package/components/ste-step/ste-step.vue +264 -0
- package/components/ste-stepper/README.md +170 -0
- package/components/ste-stepper/ste-stepper.vue +373 -0
- package/components/ste-steps/README.md +132 -0
- package/components/ste-steps/ste-steps.vue +65 -0
- package/components/ste-sticky/README.md +52 -0
- package/components/ste-sticky/ste-sticky.vue +127 -0
- package/components/ste-swipe-action/README.md +197 -0
- package/components/ste-swipe-action/ste-swipe-action.vue +303 -0
- package/components/ste-swipe-action-group/ste-swipe-action-group.vue +104 -0
- package/components/ste-swiper/README.md +173 -0
- package/components/ste-swiper/ste-swiper.vue +462 -0
- package/components/ste-swiper-item/ste-swiper-item.vue +41 -0
- package/components/ste-switch/README.md +110 -0
- package/components/ste-switch/ste-switch.vue +144 -0
- package/components/ste-tab/ste-tab.vue +87 -0
- package/components/ste-table/README.md +785 -0
- package/components/ste-table/common.js +8 -0
- package/components/ste-table/ste-table.vue +666 -0
- package/components/ste-table/utils.js +20 -0
- package/components/ste-table-column/checkbox-icon.vue +65 -0
- package/components/ste-table-column/common.scss +65 -0
- package/components/ste-table-column/radio-icon.vue +110 -0
- package/components/ste-table-column/ste-table-column.vue +255 -0
- package/components/ste-table-column/sub-table.vue +116 -0
- package/components/ste-table-column/table-popover.vue +204 -0
- package/components/ste-table-column/var.scss +1 -0
- package/components/ste-tabs/README.md +475 -0
- package/components/ste-tabs/props.js +212 -0
- package/components/ste-tabs/ste-tabs.vue +758 -0
- package/components/ste-text/README.md +66 -0
- package/components/ste-text/ste-text.vue +72 -0
- package/components/ste-toast/README.md +243 -0
- package/components/ste-toast/ste-toast.js +69 -0
- package/components/ste-toast/ste-toast.vue +231 -0
- package/components/ste-touch-swipe/README.md +104 -0
- package/components/ste-touch-swipe/TouchEvent.js +72 -0
- package/components/ste-touch-swipe/ste-touch-swipe.vue +327 -0
- package/components/ste-touch-swipe-item/ste-touch-swipe-item.vue +33 -0
- package/components/ste-tour/README.md +194 -0
- package/components/ste-tour/ste-tour.vue +355 -0
- package/components/ste-tree/README.md +240 -0
- package/components/ste-tree/ste-tree.vue +350 -0
- package/components/ste-upload/README.md +276 -0
- package/components/ste-upload/ReadFile.js +229 -0
- package/components/ste-upload/ste-upload.vue +526 -0
- package/components/ste-video/README.md +60 -0
- package/components/ste-video/props.js +149 -0
- package/components/ste-video/ste-video.vue +647 -0
- package/config/color.js +22 -0
- package/index.js +2 -0
- package/package.json +19 -0
- package/utils/Color.js +66 -0
- package/utils/System.js +110 -0
- package/utils/dayjs.min.js +1 -0
- package/utils/mixin.js +67 -0
- package/utils/store.js +7 -0
- package/utils/utils.js +604 -0
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
class="ste-dropdown-menu-root"
|
|
4
|
+
:class="[cmpRootClass]"
|
|
5
|
+
:style="[cmpRootStyle]"
|
|
6
|
+
@touchmove.stop.prevent="touchmove"
|
|
7
|
+
@wheel.stop.prevent
|
|
8
|
+
>
|
|
9
|
+
<view
|
|
10
|
+
class="dropdown-placeholder"
|
|
11
|
+
:style="[cmpMenuPlaceholderStyle]"
|
|
12
|
+
@click="close"
|
|
13
|
+
@touchmove.stop.prevent="touchmove"
|
|
14
|
+
@wheel.stop.prevent
|
|
15
|
+
/>
|
|
16
|
+
<view class="menu-box" @click="handleMenuClick" @touchmove.stop.prevent="touchmove" @wheel.stop.prevent>
|
|
17
|
+
<text class="title">{{ menuTitle || title }}</text>
|
|
18
|
+
<view class="menu-title-icon">
|
|
19
|
+
<ste-icon code="" size="16" color="#bbbbbb"></ste-icon>
|
|
20
|
+
</view>
|
|
21
|
+
</view>
|
|
22
|
+
<view
|
|
23
|
+
:class="hiddenContent ? 'dropdown-content hidden' : 'dropdown-content'"
|
|
24
|
+
:style="[cmpMenuContentStyle]"
|
|
25
|
+
@click="handleMaskClick"
|
|
26
|
+
@touchmove.stop.prevent="touchmove"
|
|
27
|
+
@wheel.stop.prevent
|
|
28
|
+
>
|
|
29
|
+
<view class="menu-item-content" @click.stop="handleMenuConentClick">
|
|
30
|
+
<slot></slot>
|
|
31
|
+
</view>
|
|
32
|
+
</view>
|
|
33
|
+
</view>
|
|
34
|
+
</template>
|
|
35
|
+
|
|
36
|
+
<script>
|
|
37
|
+
import utils from '../../utils/utils.js';
|
|
38
|
+
import useColor from '../../config/color.js';
|
|
39
|
+
let color = useColor();
|
|
40
|
+
import System from '../../utils/System.js';
|
|
41
|
+
const DEFAULT_ROOT_QUERY = { height: 0, left: 0, top: 0, bottom: 0 };
|
|
42
|
+
const DEFAULT_DURATION = 0.2;
|
|
43
|
+
const MIN_DURATION = 0;
|
|
44
|
+
const MAX_DURATION = 10;
|
|
45
|
+
const addPx = (val) => {
|
|
46
|
+
if (utils.isNumber(val)) {
|
|
47
|
+
return `${val}px`;
|
|
48
|
+
} else {
|
|
49
|
+
return 0;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* ste-dropdown-menu 下拉菜单
|
|
54
|
+
* @description 下拉菜单
|
|
55
|
+
* @tutorial https://stellar-ui.intecloud.com.cn/pc/index/index?name=ste-dropdown-menu
|
|
56
|
+
* @property {String} title 菜单标题,未设置时会显示选中项的值
|
|
57
|
+
* @property {String|Array} value 下拉菜单选中的值
|
|
58
|
+
* @property {String} inactiveColor 未选中颜色 #000000
|
|
59
|
+
* @property {String} activeColor 选中色 #0090FF
|
|
60
|
+
* @property {String} direction 展开方向 默认down
|
|
61
|
+
* @value up 向上展开 {String}
|
|
62
|
+
* @value down 向下展开 {String}
|
|
63
|
+
* @property {Number} duration 展开动画执行时间 默认0.2s
|
|
64
|
+
* @property {Boolean} showMask 是否展示遮罩 默认 true
|
|
65
|
+
* @property {Boolean} isMaskClick 是否点击遮罩关闭 默认 true
|
|
66
|
+
* @property {Number} zIndex 弹窗层级z-index
|
|
67
|
+
* @property {String} type 下拉选项的形状 默认block
|
|
68
|
+
* @value round 圆形 {String}
|
|
69
|
+
* @value block 块状 {String}
|
|
70
|
+
* @property {Number} max 可选数量 默认1
|
|
71
|
+
* @event {Function} change 选项改变时触发
|
|
72
|
+
* @event {Function} open 菜单打开
|
|
73
|
+
* @event {Function} close 菜单收起
|
|
74
|
+
**/
|
|
75
|
+
export default {
|
|
76
|
+
group: '导航组件',
|
|
77
|
+
title: 'DropdownMenu 下拉菜单',
|
|
78
|
+
name: 'ste-dropdown-menu',
|
|
79
|
+
options: {
|
|
80
|
+
virtualHost: true,
|
|
81
|
+
},
|
|
82
|
+
props: {
|
|
83
|
+
title: {
|
|
84
|
+
type: [String, null],
|
|
85
|
+
default: '',
|
|
86
|
+
},
|
|
87
|
+
value: {
|
|
88
|
+
type: [String, Number, Array, null],
|
|
89
|
+
default: undefined,
|
|
90
|
+
},
|
|
91
|
+
inactiveColor: {
|
|
92
|
+
type: [String, null],
|
|
93
|
+
default: '#000000',
|
|
94
|
+
},
|
|
95
|
+
activeColor: {
|
|
96
|
+
type: [String, null],
|
|
97
|
+
default: '',
|
|
98
|
+
},
|
|
99
|
+
direction: {
|
|
100
|
+
type: [String, null],
|
|
101
|
+
default: 'down',
|
|
102
|
+
},
|
|
103
|
+
duration: {
|
|
104
|
+
type: [Number, null],
|
|
105
|
+
default: 0.2,
|
|
106
|
+
},
|
|
107
|
+
showMask: {
|
|
108
|
+
type: [Boolean, null],
|
|
109
|
+
default: true,
|
|
110
|
+
},
|
|
111
|
+
isMaskClick: {
|
|
112
|
+
type: [Boolean, null],
|
|
113
|
+
default: true,
|
|
114
|
+
},
|
|
115
|
+
zIndex: {
|
|
116
|
+
type: [Number, null],
|
|
117
|
+
default: 1000,
|
|
118
|
+
},
|
|
119
|
+
type: {
|
|
120
|
+
default: [String, null],
|
|
121
|
+
default: 'block',
|
|
122
|
+
},
|
|
123
|
+
max: {
|
|
124
|
+
type: [Number, null],
|
|
125
|
+
default: 1,
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
model: {
|
|
129
|
+
prop: 'value',
|
|
130
|
+
// 派发事件名,更新父组件数据
|
|
131
|
+
event: 'input',
|
|
132
|
+
},
|
|
133
|
+
provide() {
|
|
134
|
+
return {
|
|
135
|
+
_menuComponent: { getParent: () => this },
|
|
136
|
+
};
|
|
137
|
+
},
|
|
138
|
+
data() {
|
|
139
|
+
return {
|
|
140
|
+
menuTitle: '',
|
|
141
|
+
chooseItems: [],
|
|
142
|
+
showMenu: false,
|
|
143
|
+
hiddenContent: false,
|
|
144
|
+
contentHeight: 0,
|
|
145
|
+
menuRootQuery: DEFAULT_ROOT_QUERY,
|
|
146
|
+
menuItems: [],
|
|
147
|
+
};
|
|
148
|
+
},
|
|
149
|
+
mounted() {},
|
|
150
|
+
computed: {
|
|
151
|
+
cmpRootClass() {
|
|
152
|
+
let classArr = [this.direction, this.showMenu ? 'open' : 'close', this.type];
|
|
153
|
+
return classArr.join(' ');
|
|
154
|
+
},
|
|
155
|
+
cmpRootStyle() {
|
|
156
|
+
let style = {
|
|
157
|
+
'--duration': this.cmpDuration + 's',
|
|
158
|
+
'--active-color': this.activeColor ? this.activeColor : color.getColor().steThemeColor,
|
|
159
|
+
'--inactive-color': this.inactiveColor,
|
|
160
|
+
'--menu-z-index': this.zIndex,
|
|
161
|
+
};
|
|
162
|
+
return style;
|
|
163
|
+
},
|
|
164
|
+
cmpMenuPlaceholderStyle() {
|
|
165
|
+
let style = { height: 0 };
|
|
166
|
+
|
|
167
|
+
if (this.showMenu) {
|
|
168
|
+
if (this.direction == 'down') {
|
|
169
|
+
style.height = addPx(this.menuRootQuery.top + this.menuRootQuery.height);
|
|
170
|
+
} else {
|
|
171
|
+
let windowHeight = System.getWindowInfo().windowHeight;
|
|
172
|
+
style.height = addPx(windowHeight - this.menuRootQuery.bottom + this.menuRootQuery.height);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return style;
|
|
177
|
+
},
|
|
178
|
+
cmpMenuContentStyle() {
|
|
179
|
+
let style = {
|
|
180
|
+
height: addPx(this.contentHeight),
|
|
181
|
+
background: this.showMask ? 'rgba(0, 0, 0, 0.6)' : 'rgba(0, 0, 0, 0)',
|
|
182
|
+
};
|
|
183
|
+
if (this.direction == 'down') {
|
|
184
|
+
style.top = addPx(this.menuRootQuery.top + this.menuRootQuery.height);
|
|
185
|
+
} else {
|
|
186
|
+
style.top = 0;
|
|
187
|
+
}
|
|
188
|
+
return style;
|
|
189
|
+
},
|
|
190
|
+
cmpDuration() {
|
|
191
|
+
if (!utils.isNumber(this.duration)) {
|
|
192
|
+
return DEFAULT_DURATION;
|
|
193
|
+
}
|
|
194
|
+
if (this.duration > MAX_DURATION) {
|
|
195
|
+
return MAX_DURATION;
|
|
196
|
+
}
|
|
197
|
+
if (this.duration < MIN_DURATION) {
|
|
198
|
+
return MIN_DURATION;
|
|
199
|
+
}
|
|
200
|
+
return this.duration;
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
watch: {
|
|
204
|
+
value: {
|
|
205
|
+
handler(val) {
|
|
206
|
+
if (Array.isArray(val)) {
|
|
207
|
+
this.chooseItems = val;
|
|
208
|
+
} else {
|
|
209
|
+
val ? (this.chooseItems = [val]) : '';
|
|
210
|
+
}
|
|
211
|
+
// this.loadMenuTitle();
|
|
212
|
+
},
|
|
213
|
+
immediate: true,
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
methods: {
|
|
217
|
+
updateItems() {
|
|
218
|
+
let menuItems = utils.getChildrenProps(this, 'ste-dropdown-menu-item');
|
|
219
|
+
if (menuItems.length !== this.menuItems.length) {
|
|
220
|
+
this.menuItems = menuItems;
|
|
221
|
+
this.loadMenuTitle();
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
loadMenuTitle() {
|
|
225
|
+
if (!this.title) {
|
|
226
|
+
let item =
|
|
227
|
+
this.menuItems.find((e) => {
|
|
228
|
+
return this.chooseItems.find((v) => v == e.value);
|
|
229
|
+
}) || {};
|
|
230
|
+
this.menuTitle = item.title;
|
|
231
|
+
} else {
|
|
232
|
+
this.menuTitle = this.title;
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
touchmove(e) {
|
|
236
|
+
// TODO nvue 取消冒泡
|
|
237
|
+
e.stopPropagation();
|
|
238
|
+
},
|
|
239
|
+
async getContentHeight() {
|
|
240
|
+
let windowHeight = System.getWindowInfo().windowHeight;
|
|
241
|
+
const res = await utils.querySelector('.ste-dropdown-menu-root', this);
|
|
242
|
+
this.menuRootQuery = res;
|
|
243
|
+
this.contentHeight =
|
|
244
|
+
this.direction == 'down' ? windowHeight - this.menuRootQuery.bottom : this.menuRootQuery.top;
|
|
245
|
+
},
|
|
246
|
+
async handleMenuClick() {
|
|
247
|
+
if (!this.showMenu) {
|
|
248
|
+
await this.getContentHeight();
|
|
249
|
+
this.open();
|
|
250
|
+
} else {
|
|
251
|
+
this.close();
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
open() {
|
|
255
|
+
this.showMenu = true;
|
|
256
|
+
this.hiddenContent = false;
|
|
257
|
+
this.$emit('open');
|
|
258
|
+
},
|
|
259
|
+
close() {
|
|
260
|
+
this.showMenu = false;
|
|
261
|
+
setTimeout(() => {
|
|
262
|
+
this.hiddenContent = true;
|
|
263
|
+
this.contentHeight = 0;
|
|
264
|
+
this.menuRootQuery = DEFAULT_ROOT_QUERY;
|
|
265
|
+
this.$emit('close');
|
|
266
|
+
}, this.cmpDuration * 1000);
|
|
267
|
+
},
|
|
268
|
+
choose(item) {
|
|
269
|
+
let temp = this.chooseItems;
|
|
270
|
+
let index = temp.findIndex((e) => e == item.value);
|
|
271
|
+
let max = this.max < 1 ? 1 : this.max;
|
|
272
|
+
if (index > -1) {
|
|
273
|
+
// 当选中项再次被选中时,做取消选中操作
|
|
274
|
+
temp.splice(index, 1);
|
|
275
|
+
} else {
|
|
276
|
+
if (this.chooseItems.length < max) {
|
|
277
|
+
temp.push(item.value);
|
|
278
|
+
} else {
|
|
279
|
+
temp.shift();
|
|
280
|
+
temp.push(item.value);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
this.chooseItems = temp;
|
|
285
|
+
this.loadMenuTitle();
|
|
286
|
+
if (this.chooseItems.length == max) {
|
|
287
|
+
this.close();
|
|
288
|
+
}
|
|
289
|
+
this.$emit('input', this.chooseItems);
|
|
290
|
+
this.$emit('change', this.chooseItems);
|
|
291
|
+
this.$emit('item-choose', item);
|
|
292
|
+
},
|
|
293
|
+
handleMaskClick() {
|
|
294
|
+
if (this.isMaskClick) {
|
|
295
|
+
this.close();
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
handleMenuConentClick() {},
|
|
299
|
+
},
|
|
300
|
+
};
|
|
301
|
+
</script>
|
|
302
|
+
|
|
303
|
+
<style lang="scss" scoped>
|
|
304
|
+
.ste-dropdown-menu-root {
|
|
305
|
+
.menu-box {
|
|
306
|
+
padding: 20rpx 0;
|
|
307
|
+
.menu-title-icon {
|
|
308
|
+
display: inline-flex;
|
|
309
|
+
transition: all var(--duration) linear;
|
|
310
|
+
}
|
|
311
|
+
.title {
|
|
312
|
+
font-size: 28rpx;
|
|
313
|
+
margin-right: 16rpx;
|
|
314
|
+
}
|
|
315
|
+
display: flex;
|
|
316
|
+
align-items: center;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.dropdown-placeholder {
|
|
320
|
+
position: fixed;
|
|
321
|
+
z-index: 1;
|
|
322
|
+
width: 100vw;
|
|
323
|
+
top: 0;
|
|
324
|
+
left: 0;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.dropdown-content {
|
|
328
|
+
transition: opacity var(--duration) linear;
|
|
329
|
+
position: fixed;
|
|
330
|
+
z-index: 1;
|
|
331
|
+
width: 100vw;
|
|
332
|
+
left: 0;
|
|
333
|
+
overflow: hidden;
|
|
334
|
+
top: 40rpx;
|
|
335
|
+
opacity: 0;
|
|
336
|
+
|
|
337
|
+
&.hidden {
|
|
338
|
+
z-index: -1 !important;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
.menu-item-content {
|
|
342
|
+
width: 100%;
|
|
343
|
+
transition: all var(--duration);
|
|
344
|
+
transition-duration: var(--duration);
|
|
345
|
+
transform: translateY(-100%);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
&.round {
|
|
350
|
+
.menu-item-content {
|
|
351
|
+
padding: 24rpx;
|
|
352
|
+
background-color: #fff;
|
|
353
|
+
border-top: solid 2rpx #f9f9f9;
|
|
354
|
+
|
|
355
|
+
display: flex;
|
|
356
|
+
justify-content: space-between;
|
|
357
|
+
flex-flow: wrap;
|
|
358
|
+
|
|
359
|
+
row-gap: 20rpx;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
&.open {
|
|
364
|
+
.menu-title-icon {
|
|
365
|
+
transform: rotate(180deg);
|
|
366
|
+
}
|
|
367
|
+
.dropdown-content {
|
|
368
|
+
opacity: 1;
|
|
369
|
+
z-index: var(--menu-z-index);
|
|
370
|
+
|
|
371
|
+
.menu-item-content {
|
|
372
|
+
transform: translateY(0);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
&.up {
|
|
378
|
+
.menu-title-icon {
|
|
379
|
+
transform: rotate(180deg);
|
|
380
|
+
}
|
|
381
|
+
.dropdown-content {
|
|
382
|
+
display: flex;
|
|
383
|
+
flex-direction: column;
|
|
384
|
+
justify-content: flex-end;
|
|
385
|
+
|
|
386
|
+
.menu-item-content {
|
|
387
|
+
transform: translateY(100%);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
&.open {
|
|
391
|
+
.menu-title-icon {
|
|
392
|
+
transform: rotate(0);
|
|
393
|
+
}
|
|
394
|
+
.menu-item-content {
|
|
395
|
+
transform: translateY(0);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
.dropdown-placeholder {
|
|
399
|
+
top: auto;
|
|
400
|
+
bottom: 0;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
</style>
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="ste-dropdown-menu-item-root" :class="[cmpRootClass]" @click="handleClick">
|
|
3
|
+
<text class="text">{{ title }}</text>
|
|
4
|
+
<view class="menu-item-icon" v-if="type == 'block'">
|
|
5
|
+
<ste-icon code="" size="32"></ste-icon>
|
|
6
|
+
</view>
|
|
7
|
+
</view>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
import utils from '../../utils/utils.js';
|
|
12
|
+
/**
|
|
13
|
+
* ste-dropdown-menu-item 下拉菜单项
|
|
14
|
+
* @description 下拉菜单项
|
|
15
|
+
* @tutorial https://stellar-ui.intecloud.com.cn/pc/index/index?name=ste-dropdown-menu
|
|
16
|
+
* @property {String} value 选中项对应的值
|
|
17
|
+
* @property {String} title 选中项对应的标题
|
|
18
|
+
* @property {Boolean} disabled 是否禁用 默认 false
|
|
19
|
+
* @property {Boolean} readonly 只读(不置灰) 默认 false
|
|
20
|
+
* @event {Function} click 选中时触发(可拦截选中)
|
|
21
|
+
**/
|
|
22
|
+
export default {
|
|
23
|
+
group: '导航组件',
|
|
24
|
+
title: 'DropdownMenuItem 下拉菜单项',
|
|
25
|
+
name: 'ste-dropdown-menu-item',
|
|
26
|
+
inject: ['_menuComponent'],
|
|
27
|
+
props: {
|
|
28
|
+
value: {
|
|
29
|
+
type: [String, null],
|
|
30
|
+
default: '',
|
|
31
|
+
},
|
|
32
|
+
title: {
|
|
33
|
+
type: [String, null],
|
|
34
|
+
default: '',
|
|
35
|
+
},
|
|
36
|
+
disabled: {
|
|
37
|
+
type: [Boolean, null],
|
|
38
|
+
default: false,
|
|
39
|
+
},
|
|
40
|
+
readonly: {
|
|
41
|
+
type: [Boolean, null],
|
|
42
|
+
default: false,
|
|
43
|
+
},
|
|
44
|
+
max: {
|
|
45
|
+
type: [Number, null],
|
|
46
|
+
default: 1,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
data() {
|
|
50
|
+
return {
|
|
51
|
+
parent: {},
|
|
52
|
+
status: false, // 是否选中状态 true: 选中,false: 未选中
|
|
53
|
+
clickTask: null,
|
|
54
|
+
type: 'block',
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
created() {
|
|
58
|
+
this.parent = this._menuComponent.getParent();
|
|
59
|
+
this.type = this.parent.type;
|
|
60
|
+
},
|
|
61
|
+
mounted() {
|
|
62
|
+
this.parent.updateItems();
|
|
63
|
+
this.loadStatus();
|
|
64
|
+
this.parent.$on('item-choose', (value) => {
|
|
65
|
+
this.loadStatus();
|
|
66
|
+
});
|
|
67
|
+
},
|
|
68
|
+
computed: {
|
|
69
|
+
cmpRootClass() {
|
|
70
|
+
let classArr = [this.parent.direction];
|
|
71
|
+
if (this.status) {
|
|
72
|
+
classArr.push('active');
|
|
73
|
+
}
|
|
74
|
+
if (this.readonly) {
|
|
75
|
+
classArr.push('readonly');
|
|
76
|
+
}
|
|
77
|
+
if (this.disabled) {
|
|
78
|
+
classArr.push('disabled');
|
|
79
|
+
}
|
|
80
|
+
classArr.push(this.type);
|
|
81
|
+
return classArr.join(' ');
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
methods: {
|
|
85
|
+
loadStatus() {
|
|
86
|
+
this.status = !!this.parent.chooseItems.find((e) => e == this.value);
|
|
87
|
+
},
|
|
88
|
+
async handleClick() {
|
|
89
|
+
if (!this.disabled && !this.readonly) {
|
|
90
|
+
if (this.clickTask) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
let next = true;
|
|
94
|
+
this.clickTask = new Promise((resolve, reject) => {
|
|
95
|
+
this.$emit(
|
|
96
|
+
'click',
|
|
97
|
+
() => (next = false),
|
|
98
|
+
() => resolve(),
|
|
99
|
+
() => reject()
|
|
100
|
+
);
|
|
101
|
+
});
|
|
102
|
+
if (!next) {
|
|
103
|
+
await this.clickTask;
|
|
104
|
+
}
|
|
105
|
+
this.parent.choose({ title: this.title, value: this.value });
|
|
106
|
+
setTimeout(() => {
|
|
107
|
+
this.clickTask = null;
|
|
108
|
+
}, this.parent.cmpDuration * 1000);
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
</script>
|
|
114
|
+
|
|
115
|
+
<style lang="scss" scoped>
|
|
116
|
+
.ste-dropdown-menu-item-root {
|
|
117
|
+
&.down {
|
|
118
|
+
border-top: solid 2rpx #f9f9f9;
|
|
119
|
+
}
|
|
120
|
+
&.up {
|
|
121
|
+
border-bottom: solid 2rpx #f9f9f9;
|
|
122
|
+
}
|
|
123
|
+
background-color: #ffffff;
|
|
124
|
+
padding: 24rpx;
|
|
125
|
+
|
|
126
|
+
display: flex;
|
|
127
|
+
align-items: center;
|
|
128
|
+
justify-content: space-between;
|
|
129
|
+
color: var(--inactive-color);
|
|
130
|
+
.menu-item-icon {
|
|
131
|
+
display: none;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.text {
|
|
135
|
+
font-size: 28rpx;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
&.disabled {
|
|
139
|
+
color: #cccccc !important;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
&.active {
|
|
143
|
+
color: var(--active-color);
|
|
144
|
+
.menu-item-icon {
|
|
145
|
+
display: inline-flex;
|
|
146
|
+
align-items: center;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
&.round {
|
|
151
|
+
display: inline-flex;
|
|
152
|
+
border: none;
|
|
153
|
+
padding: 14rpx 10rpx;
|
|
154
|
+
border-radius: 48rpx;
|
|
155
|
+
border: 2rpx solid var(--active-color);
|
|
156
|
+
width: 194rpx;
|
|
157
|
+
white-space: nowrap;
|
|
158
|
+
|
|
159
|
+
.text {
|
|
160
|
+
width: 100%;
|
|
161
|
+
text-align: center;
|
|
162
|
+
color: var(--active-color);
|
|
163
|
+
white-space: nowrap;
|
|
164
|
+
text-overflow: ellipsis;
|
|
165
|
+
overflow: hidden;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
&.active {
|
|
169
|
+
background-color: var(--active-color);
|
|
170
|
+
.text {
|
|
171
|
+
color: #fff;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
</style>
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Icon 图标
|
|
2
|
+
|
|
3
|
+
基于字体的图标集,包含了大多数常见场景的图标
|
|
4
|
+
|
|
5
|
+
---$
|
|
6
|
+
|
|
7
|
+
## 代码演示
|
|
8
|
+
|
|
9
|
+
### 基础用法
|
|
10
|
+
|
|
11
|
+
通过 `code` 属性来指定需要使用的图标,Stellar 组件使用[iconfont 做图标库](https://at.alicdn.com/t/c/font_4041637_pivqtx3f1mq.json?spm=a313x.manage_type_myprojects.i1.49.f7ba3a81fFvJ6W&file=font_4041637_pivqtx3f1mq.json),
|
|
12
|
+
可以直接传入对应的编码来使用
|
|
13
|
+
|
|
14
|
+
```html
|
|
15
|
+
<ste-icon code=""></ste-icon>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### 图标颜色
|
|
19
|
+
|
|
20
|
+
通过 `color` 属性来设置图标的颜色
|
|
21
|
+
|
|
22
|
+
```html
|
|
23
|
+
<ste-icon code="" color="#1989fa" size="60" marginRight="30"></ste-icon>
|
|
24
|
+
<ste-icon code="" color="#ee0a24" size="60"></ste-icon>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 图标大小
|
|
28
|
+
|
|
29
|
+
通过 `size` 属性来设置图标的尺寸大小,单位为 rpx,默认`28`
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
<ste-icon code="" marginRight="30"></ste-icon>
|
|
33
|
+
<ste-icon code="" marginRight="30" size="50"></ste-icon>
|
|
34
|
+
<ste-icon code="" marginRight="30" size="70"></ste-icon>
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 图标是否粗体
|
|
38
|
+
|
|
39
|
+
通过 `bold` 属性来设置图标是否粗体,默认`false`
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<ste-icon code="" marginRight="30"></ste-icon>
|
|
43
|
+
<ste-icon code="" bold></ste-icon>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 自定义图标
|
|
47
|
+
|
|
48
|
+
如果需要在现有 `Icon` 的基础上使用更多图标,可以引入第三方 `iconfont` 对应的字体文件和 `CSS` 文件,之后就可以在 `Icon` 组件中直接使用。
|
|
49
|
+
|
|
50
|
+
```css
|
|
51
|
+
/* 引入第三方或自定义的字体图标样式 */
|
|
52
|
+
@font-face {
|
|
53
|
+
font-family: 'iconfont'; /* Project id 2344394 */
|
|
54
|
+
src: url('//at.alicdn.com/t/c/font_2344394_nltp3ggc4q.woff2?t=1709779088427') format('woff2');
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
```html
|
|
59
|
+
<!-- 通过 class-prefix 指定类名为 font-family属性的值:如iconfont -->
|
|
60
|
+
<ste-icon fontFamily="iconfont" code="" />
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---$
|
|
64
|
+
### API
|
|
65
|
+
|
|
66
|
+
#### Props
|
|
67
|
+
|
|
68
|
+
| 属性名 | 说明 | 类型 | 默认值 | 可选值 | 支持版本 |
|
|
69
|
+
| --------------| -------------------- | --------------- | ------- | ----------------------------------------- | -------- |
|
|
70
|
+
| `code` | 图标编码 | `String` | 必填 | - | - |
|
|
71
|
+
| `color` | 图标颜色 | `String` | - | - | - |
|
|
72
|
+
| `size` | 图标大小(单位 rpx) | `Number/String` | `28` | - | - |
|
|
73
|
+
| `bold` | 图标是否粗体 | `Boolean` | `false` | - | - |
|
|
74
|
+
| `marginLeft` | 左外边距(单位 rpx) | `Number/String` | `0` | - | - |
|
|
75
|
+
| `marginRight` | 右外边距(单位 rpx) | `Number/String` | `0` | - | - |
|
|
76
|
+
| `marginTop` | 上外边距(单位 rpx) | `Number/String` | `0` | - | - |
|
|
77
|
+
| `marginBottom`| 下外边距(单位 rpx) | `Number/String` | `0` | - | - |
|
|
78
|
+
| `fontFamily` | 字体名 | `String` | - | - | - |
|
|
79
|
+
| `inlineBlock` | 容器对齐方式 | `Boolean` | `true` | `true`:`inline-block` <br>`false`:`inline-flex` | `1.1.6` |
|
|
80
|
+
|
|
81
|
+
#### Events
|
|
82
|
+
|
|
83
|
+
| 事件名 | 说明 | 事件参数 | 支持版本 |
|
|
84
|
+
| ------- | ---------------- | -------- | -------- |
|
|
85
|
+
| `click` | 图标点击回调事件 | - | - |
|
|
86
|
+
|
|
87
|
+
---$
|
|
88
|
+
{{zyy}}
|
|
89
|
+
|
|
90
|
+
{{qinpengfei}}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/* 在线链接服务仅供平台体验和调试使用,平台不承诺服务的稳定性,企业客户需下载字体包自行发布使用并做好备份。 */
|
|
2
|
+
@font-face {
|
|
3
|
+
font-family: 'ste-iconfont-1709689042473';
|
|
4
|
+
/* Project id 4457057 */
|
|
5
|
+
src: url('//at.alicdn.com/t/c/font_4457057_378iyzac6bn.woff2?t=1727661432800') format('woff2'),
|
|
6
|
+
url('//at.alicdn.com/t/c/font_4457057_378iyzac6bn.woff?t=1727661432800') format('woff'),
|
|
7
|
+
url('//at.alicdn.com/t/c/font_4457057_378iyzac6bn.ttf?t=1727661432800') format('truetype');
|
|
8
|
+
}
|