@vtj/materials 0.13.15 → 0.13.17
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/assets/antdv/index.umd.js +2 -2
- package/dist/assets/charts/index.umd.js +2 -2
- package/dist/assets/element/index.umd.js +3 -3
- package/dist/assets/icons/index.umd.js +2 -2
- package/dist/assets/ui/index.umd.js +2 -2
- package/dist/assets/uni-h5/index.umd.js +2 -2
- package/dist/assets/uni-ui/index.umd.js +2 -2
- package/dist/assets/vant/index.umd.js +2 -2
- package/dist/deps/@vtj/charts/index.umd.js +2 -2
- package/dist/deps/@vtj/icons/index.umd.js +2 -2
- package/dist/deps/@vtj/ui/index.umd.js +4 -4
- package/dist/deps/@vtj/ui/style.css +1 -1
- package/dist/deps/@vtj/utils/index.umd.js +28 -33
- package/dist/deps/@vueuse/core/index.iife.min.js +1 -1
- package/dist/deps/element-plus/index.css +1 -1
- package/dist/deps/element-plus/index.full.min.js +14 -14
- package/dist/deps/element-plus/zh-cn.js +1 -1
- package/dist/deps/uni-app/index.umd.js +1 -1
- package/dist/deps/uni-h5/index.umd.js +8 -8
- package/dist/deps/uni-h5/style.css +1 -1
- package/dist/deps/uni-h5-vue/index.umd.js +1 -1
- package/dist/deps/uni-ui/index.umd.js +6 -1
- package/dist/deps/uni-ui/style.css +1 -1
- package/dist/deps/vue/vue.global.js +88 -53
- package/dist/deps/vue/vue.global.prod.js +9 -9
- package/package.json +12 -12
- package/src/antdv/image.ts +1 -1
- package/src/element/image.ts +1 -1
- package/src/element/virtualizedTable.ts +6 -6
- package/src/manifest.json +69 -0
- package/src/pages/index.vue +2 -0
- package/src/pages.json +19 -0
- package/src/uni-ui/index.ts +88 -58
- package/src/{uni-ui/lib/uni.scss → uni.scss} +4 -0
- package/src/version.ts +2 -2
- package/src/uni-ui/lib/uni-col/uni-col.vue +0 -324
- package/src/uni-ui/lib/uni-collapse/uni-collapse.vue +0 -153
- package/src/uni-ui/lib/uni-collapse-item/uni-collapse-item.vue +0 -425
- package/src/uni-ui/lib/uni-data-picker/keypress.js +0 -45
- package/src/uni-ui/lib/uni-data-picker/uni-data-picker.vue +0 -604
- package/src/uni-ui/lib/uni-data-pickerview/uni-data-picker.js +0 -622
- package/src/uni-ui/lib/uni-data-pickerview/uni-data-pickerview.css +0 -76
- package/src/uni-ui/lib/uni-data-pickerview/uni-data-pickerview.vue +0 -335
- package/src/uni-ui/lib/uni-data-select/uni-data-select.vue +0 -590
- package/src/uni-ui/lib/uni-datetime-picker/calendar-item.vue +0 -188
- package/src/uni-ui/lib/uni-datetime-picker/calendar.vue +0 -985
- package/src/uni-ui/lib/uni-datetime-picker/i18n/en.json +0 -22
- package/src/uni-ui/lib/uni-datetime-picker/i18n/index.js +0 -8
- package/src/uni-ui/lib/uni-datetime-picker/i18n/zh-Hans.json +0 -22
- package/src/uni-ui/lib/uni-datetime-picker/i18n/zh-Hant.json +0 -22
- package/src/uni-ui/lib/uni-datetime-picker/time-picker.vue +0 -1032
- package/src/uni-ui/lib/uni-datetime-picker/uni-datetime-picker.vue +0 -1230
- package/src/uni-ui/lib/uni-datetime-picker/util.js +0 -448
- package/src/uni-ui/lib/uni-easyinput/common.js +0 -54
- package/src/uni-ui/lib/uni-easyinput/uni-easyinput.vue +0 -790
- package/src/uni-ui/lib/uni-fav/i18n/en.json +0 -4
- package/src/uni-ui/lib/uni-fav/i18n/index.js +0 -8
- package/src/uni-ui/lib/uni-fav/i18n/zh-Hans.json +0 -4
- package/src/uni-ui/lib/uni-fav/i18n/zh-Hant.json +0 -4
- package/src/uni-ui/lib/uni-fav/uni-fav.vue +0 -170
- package/src/uni-ui/lib/uni-file-picker/choose-and-upload-file.js +0 -280
- package/src/uni-ui/lib/uni-file-picker/uni-file-picker.vue +0 -668
- package/src/uni-ui/lib/uni-file-picker/upload-file.vue +0 -325
- package/src/uni-ui/lib/uni-file-picker/upload-image.vue +0 -292
- package/src/uni-ui/lib/uni-file-picker/utils.js +0 -110
- package/src/uni-ui/lib/uni-forms/uni-forms.vue +0 -416
- package/src/uni-ui/lib/uni-forms/utils.js +0 -293
- package/src/uni-ui/lib/uni-forms/validate.js +0 -486
- package/src/uni-ui/lib/uni-forms-item/uni-forms-item.vue +0 -630
- package/src/uni-ui/lib/uni-goods-nav/i18n/en.json +0 -6
- package/src/uni-ui/lib/uni-goods-nav/i18n/index.js +0 -8
- package/src/uni-ui/lib/uni-goods-nav/i18n/zh-Hans.json +0 -6
- package/src/uni-ui/lib/uni-goods-nav/i18n/zh-Hant.json +0 -6
- package/src/uni-ui/lib/uni-goods-nav/uni-goods-nav.vue +0 -231
- package/src/uni-ui/lib/uni-grid/uni-grid.vue +0 -148
- package/src/uni-ui/lib/uni-icons/uni-icons.uvue +0 -91
- package/src/uni-ui/lib/uni-icons/uni-icons.vue +0 -114
- package/src/uni-ui/lib/uni-icons/uniicons.css +0 -664
- package/src/uni-ui/lib/uni-icons/uniicons.ttf +0 -0
- package/src/uni-ui/lib/uni-icons/uniicons_file.ts +0 -664
- package/src/uni-ui/lib/uni-icons/uniicons_file_vue.js +0 -649
- package/src/uni-ui/lib/uni-indexed-list/uni-indexed-list-item.vue +0 -168
- package/src/uni-ui/lib/uni-indexed-list/uni-indexed-list.vue +0 -404
- package/src/uni-ui/lib/uni-list/uni-list.vue +0 -123
- package/src/uni-ui/lib/uni-list/uni-refresh.vue +0 -65
- package/src/uni-ui/lib/uni-list/uni-refresh.wxs +0 -87
- package/src/uni-ui/lib/uni-load-more/i18n/en.json +0 -5
- package/src/uni-ui/lib/uni-load-more/i18n/index.js +0 -8
- package/src/uni-ui/lib/uni-load-more/i18n/zh-Hans.json +0 -5
- package/src/uni-ui/lib/uni-load-more/i18n/zh-Hant.json +0 -5
- package/src/uni-ui/lib/uni-load-more/uni-load-more.vue +0 -456
- package/src/uni-ui/lib/uni-notice-bar/uni-notice-bar.vue +0 -484
- package/src/uni-ui/lib/uni-popup/i18n/en.json +0 -7
- package/src/uni-ui/lib/uni-popup/i18n/index.js +0 -8
- package/src/uni-ui/lib/uni-popup/i18n/zh-Hans.json +0 -7
- package/src/uni-ui/lib/uni-popup/i18n/zh-Hant.json +0 -7
- package/src/uni-ui/lib/uni-popup/keypress.js +0 -45
- package/src/uni-ui/lib/uni-popup/popup.js +0 -26
- package/src/uni-ui/lib/uni-popup/uni-popup.uvue +0 -90
- package/src/uni-ui/lib/uni-popup/uni-popup.vue +0 -552
- package/src/uni-ui/lib/uni-popup-dialog/keypress.js +0 -45
- package/src/uni-ui/lib/uni-popup-dialog/uni-popup-dialog.vue +0 -324
- package/src/uni-ui/lib/uni-popup-message/uni-popup-message.vue +0 -149
- package/src/uni-ui/lib/uni-rate/uni-rate.vue +0 -380
- package/src/uni-ui/lib/uni-row/uni-row.vue +0 -193
- package/src/uni-ui/lib/uni-search-bar/i18n/en.json +0 -4
- package/src/uni-ui/lib/uni-search-bar/i18n/index.js +0 -8
- package/src/uni-ui/lib/uni-search-bar/i18n/zh-Hans.json +0 -4
- package/src/uni-ui/lib/uni-search-bar/i18n/zh-Hant.json +0 -4
- package/src/uni-ui/lib/uni-search-bar/uni-search-bar.vue +0 -339
- package/src/uni-ui/lib/uni-swipe-action-item/bindingx.js +0 -311
- package/src/uni-ui/lib/uni-swipe-action-item/isPC.js +0 -12
- package/src/uni-ui/lib/uni-swipe-action-item/mpalipay.js +0 -195
- package/src/uni-ui/lib/uni-swipe-action-item/mpother.js +0 -260
- package/src/uni-ui/lib/uni-swipe-action-item/mpwxs.js +0 -84
- package/src/uni-ui/lib/uni-swipe-action-item/render.js +0 -270
- package/src/uni-ui/lib/uni-swipe-action-item/uni-swipe-action-item.vue +0 -493
- package/src/uni-ui/lib/uni-swipe-action-item/wx.wxs +0 -341
- package/src/uni-ui/lib/uni-table/uni-table.vue +0 -496
- package/src/uni-ui/lib/uni-td/uni-td.vue +0 -99
- package/src/uni-ui/lib/uni-th/filter-dropdown.vue +0 -559
- package/src/uni-ui/lib/uni-th/uni-th.vue +0 -322
- package/src/uni-ui/lib/uni-tr/table-checkbox.vue +0 -181
- package/src/uni-ui/lib/uni-tr/uni-tr.vue +0 -208
- package/src/uni-ui/lib/uni-transition/createAnimation.js +0 -131
- package/src/uni-ui/lib/uni-transition/uni-transition.vue +0 -310
- package/src/uni-ui/polyfill.ts +0 -41
@@ -1,324 +0,0 @@
|
|
1
|
-
<template>
|
2
|
-
<!-- #ifndef APP-NVUE -->
|
3
|
-
<view
|
4
|
-
:class="['uni-col', sizeClass, pointClassList]"
|
5
|
-
:style="{
|
6
|
-
paddingLeft: `${Number(gutter)}rpx`,
|
7
|
-
paddingRight: `${Number(gutter)}rpx`
|
8
|
-
}">
|
9
|
-
<slot></slot>
|
10
|
-
</view>
|
11
|
-
<!-- #endif -->
|
12
|
-
<!-- #ifdef APP-NVUE -->
|
13
|
-
<!-- 在nvue上,类名样式不生效,换为style -->
|
14
|
-
<!-- 设置right正值失效,设置 left 负值 -->
|
15
|
-
<!-- <view :class="['uni-col']" :style="{
|
16
|
-
paddingLeft:`${Number(gutter)}rpx`,
|
17
|
-
paddingRight:`${Number(gutter)}rpx`,
|
18
|
-
width:`${nvueWidth}rpx`,
|
19
|
-
position:'relative',
|
20
|
-
marginLeft:`${marginLeft}rpx`,
|
21
|
-
left:`${right === 0 ? left : -right}rpx`
|
22
|
-
}">
|
23
|
-
<slot></slot>
|
24
|
-
</view> -->
|
25
|
-
<!-- #endif -->
|
26
|
-
</template>
|
27
|
-
|
28
|
-
<script>
|
29
|
-
/**
|
30
|
-
* Col 布局-列
|
31
|
-
* @description 搭配uni-row使用,构建布局。
|
32
|
-
* @tutorial https://ext.dcloud.net.cn/plugin?id=3958
|
33
|
-
*
|
34
|
-
* @property {span} type = Number 栅格占据的列数
|
35
|
-
* 默认 24
|
36
|
-
* @property {offset} type = Number 栅格左侧的间隔格数
|
37
|
-
* @property {push} type = Number 栅格向右移动格数
|
38
|
-
* @property {pull} type = Number 栅格向左移动格数
|
39
|
-
* @property {xs} type = [Number, Object] <768px 响应式栅格数或者栅格属性对象
|
40
|
-
* @description Number时表示在此屏幕宽度下,栅格占据的列数。Object时可配置多个描述{span: 4, offset: 4}
|
41
|
-
* @property {sm} type = [Number, Object] ≥768px 响应式栅格数或者栅格属性对象
|
42
|
-
* @description Number时表示在此屏幕宽度下,栅格占据的列数。Object时可配置多个描述{span: 4, offset: 4}
|
43
|
-
* @property {md} type = [Number, Object] ≥992px 响应式栅格数或者栅格属性对象
|
44
|
-
* @description Number时表示在此屏幕宽度下,栅格占据的列数。Object时可配置多个描述{span: 4, offset: 4}
|
45
|
-
* @property {lg} type = [Number, Object] ≥1200px 响应式栅格数或者栅格属性对象
|
46
|
-
* @description Number时表示在此屏幕宽度下,栅格占据的列数。Object时可配置多个描述{span: 4, offset: 4}
|
47
|
-
* @property {xl} type = [Number, Object] ≥1920px 响应式栅格数或者栅格属性对象
|
48
|
-
* @description Number时表示在此屏幕宽度下,栅格占据的列数。Object时可配置多个描述{span: 4, offset: 4}
|
49
|
-
*/
|
50
|
-
const ComponentClass = 'uni-col';
|
51
|
-
|
52
|
-
// -1 默认值,因为在微信小程序端只给Number会有默认值0
|
53
|
-
export default {
|
54
|
-
name: 'uniCol',
|
55
|
-
// #ifdef MP-WEIXIN
|
56
|
-
options: {
|
57
|
-
virtualHost: true // 在微信小程序中将组件节点渲染为虚拟节点,更加接近Vue组件的表现
|
58
|
-
},
|
59
|
-
// #endif
|
60
|
-
props: {
|
61
|
-
span: {
|
62
|
-
type: Number,
|
63
|
-
default: 24
|
64
|
-
},
|
65
|
-
offset: {
|
66
|
-
type: Number,
|
67
|
-
default: -1
|
68
|
-
},
|
69
|
-
pull: {
|
70
|
-
type: Number,
|
71
|
-
default: -1
|
72
|
-
},
|
73
|
-
push: {
|
74
|
-
type: Number,
|
75
|
-
default: -1
|
76
|
-
},
|
77
|
-
xs: [Number, Object],
|
78
|
-
sm: [Number, Object],
|
79
|
-
md: [Number, Object],
|
80
|
-
lg: [Number, Object],
|
81
|
-
xl: [Number, Object]
|
82
|
-
},
|
83
|
-
data() {
|
84
|
-
return {
|
85
|
-
gutter: 0,
|
86
|
-
sizeClass: '',
|
87
|
-
parentWidth: 0,
|
88
|
-
nvueWidth: 0,
|
89
|
-
marginLeft: 0,
|
90
|
-
right: 0,
|
91
|
-
left: 0
|
92
|
-
};
|
93
|
-
},
|
94
|
-
created() {
|
95
|
-
// 字节小程序中,在computed中读取$parent为undefined
|
96
|
-
let parent = this.$parent;
|
97
|
-
|
98
|
-
while (parent && parent.$options.componentName !== 'uniRow') {
|
99
|
-
parent = parent.$parent;
|
100
|
-
}
|
101
|
-
|
102
|
-
this.updateGutter(parent.gutter);
|
103
|
-
parent.$watch('gutter', (gutter) => {
|
104
|
-
this.updateGutter(gutter);
|
105
|
-
});
|
106
|
-
|
107
|
-
// #ifdef APP-NVUE
|
108
|
-
this.updateNvueWidth(parent.width);
|
109
|
-
parent.$watch('width', (width) => {
|
110
|
-
this.updateNvueWidth(width);
|
111
|
-
});
|
112
|
-
// #endif
|
113
|
-
},
|
114
|
-
computed: {
|
115
|
-
sizeList() {
|
116
|
-
let { span, offset, pull, push } = this;
|
117
|
-
|
118
|
-
return {
|
119
|
-
span,
|
120
|
-
offset,
|
121
|
-
pull,
|
122
|
-
push
|
123
|
-
};
|
124
|
-
},
|
125
|
-
// #ifndef APP-NVUE
|
126
|
-
pointClassList() {
|
127
|
-
let classList = [];
|
128
|
-
|
129
|
-
['xs', 'sm', 'md', 'lg', 'xl'].forEach((point) => {
|
130
|
-
const props = this[point];
|
131
|
-
if (typeof props === 'number') {
|
132
|
-
classList.push(`${ComponentClass}-${point}-${props}`);
|
133
|
-
} else if (typeof props === 'object' && props) {
|
134
|
-
Object.keys(props).forEach((pointProp) => {
|
135
|
-
classList.push(
|
136
|
-
pointProp === 'span'
|
137
|
-
? `${ComponentClass}-${point}-${props[pointProp]}`
|
138
|
-
: `${ComponentClass}-${point}-${pointProp}-${props[pointProp]}`
|
139
|
-
);
|
140
|
-
});
|
141
|
-
}
|
142
|
-
});
|
143
|
-
|
144
|
-
// 支付宝小程序使用 :class=[ ['a','b'] ],渲染错误
|
145
|
-
return classList.join(' ');
|
146
|
-
}
|
147
|
-
// #endif
|
148
|
-
},
|
149
|
-
methods: {
|
150
|
-
updateGutter(parentGutter) {
|
151
|
-
parentGutter = Number(parentGutter);
|
152
|
-
if (!isNaN(parentGutter)) {
|
153
|
-
this.gutter = parentGutter / 2;
|
154
|
-
}
|
155
|
-
},
|
156
|
-
// #ifdef APP-NVUE
|
157
|
-
updateNvueWidth(width) {
|
158
|
-
// 用于在nvue端,span,offset,pull,push的计算
|
159
|
-
this.parentWidth = width;
|
160
|
-
['span', 'offset', 'pull', 'push'].forEach((size) => {
|
161
|
-
const curSize = this[size];
|
162
|
-
if ((curSize || curSize === 0) && curSize !== -1) {
|
163
|
-
let RPX = (1 / 24) * curSize * width;
|
164
|
-
RPX = Number(RPX);
|
165
|
-
switch (size) {
|
166
|
-
case 'span':
|
167
|
-
this.nvueWidth = RPX;
|
168
|
-
break;
|
169
|
-
case 'offset':
|
170
|
-
this.marginLeft = RPX;
|
171
|
-
break;
|
172
|
-
case 'pull':
|
173
|
-
this.right = RPX;
|
174
|
-
break;
|
175
|
-
case 'push':
|
176
|
-
this.left = RPX;
|
177
|
-
break;
|
178
|
-
}
|
179
|
-
}
|
180
|
-
});
|
181
|
-
}
|
182
|
-
// #endif
|
183
|
-
},
|
184
|
-
watch: {
|
185
|
-
sizeList: {
|
186
|
-
immediate: true,
|
187
|
-
handler(newVal) {
|
188
|
-
// #ifndef APP-NVUE
|
189
|
-
let classList = [];
|
190
|
-
for (let size in newVal) {
|
191
|
-
const curSize = newVal[size];
|
192
|
-
if ((curSize || curSize === 0) && curSize !== -1) {
|
193
|
-
classList.push(
|
194
|
-
size === 'span'
|
195
|
-
? `${ComponentClass}-${curSize}`
|
196
|
-
: `${ComponentClass}-${size}-${curSize}`
|
197
|
-
);
|
198
|
-
}
|
199
|
-
}
|
200
|
-
// 支付宝小程序使用 :class=[ ['a','b'] ],渲染错误
|
201
|
-
this.sizeClass = classList.join(' ');
|
202
|
-
// #endif
|
203
|
-
// #ifdef APP-NVUE
|
204
|
-
this.updateNvueWidth(this.parentWidth);
|
205
|
-
// #endif
|
206
|
-
}
|
207
|
-
}
|
208
|
-
}
|
209
|
-
};
|
210
|
-
</script>
|
211
|
-
|
212
|
-
<style lang="scss" scoped>
|
213
|
-
/* breakpoints */
|
214
|
-
$--sm: 768px !default;
|
215
|
-
$--md: 992px !default;
|
216
|
-
$--lg: 1200px !default;
|
217
|
-
$--xl: 1920px !default;
|
218
|
-
|
219
|
-
$breakpoints: (
|
220
|
-
'xs': (
|
221
|
-
max-width: $--sm - 1
|
222
|
-
),
|
223
|
-
'sm': (
|
224
|
-
min-width: $--sm
|
225
|
-
),
|
226
|
-
'md': (
|
227
|
-
min-width: $--md
|
228
|
-
),
|
229
|
-
'lg': (
|
230
|
-
min-width: $--lg
|
231
|
-
),
|
232
|
-
'xl': (
|
233
|
-
min-width: $--xl
|
234
|
-
)
|
235
|
-
);
|
236
|
-
|
237
|
-
$layout-namespace: '.uni-';
|
238
|
-
$col: $layout-namespace + 'col';
|
239
|
-
|
240
|
-
@function getSize($size) {
|
241
|
-
/* TODO 1/24 * $size * 100 * 1%; 使用计算后的值,为了解决 vue3 控制台报错 */
|
242
|
-
@return 0.04166666666 * $size * 100 * 1%;
|
243
|
-
}
|
244
|
-
|
245
|
-
@mixin res($key, $map: $breakpoints) {
|
246
|
-
@if map-has-key($map, $key) {
|
247
|
-
@media screen and #{inspect(map-get($map,$key))} {
|
248
|
-
@content;
|
249
|
-
}
|
250
|
-
} @else {
|
251
|
-
@warn "Undeinfed point: `#{$key}`";
|
252
|
-
}
|
253
|
-
}
|
254
|
-
|
255
|
-
/* #ifndef APP-NVUE */
|
256
|
-
#{$col} {
|
257
|
-
float: left;
|
258
|
-
box-sizing: border-box;
|
259
|
-
}
|
260
|
-
|
261
|
-
#{$col}-0 {
|
262
|
-
/* #ifdef APP-NVUE */
|
263
|
-
width: 0;
|
264
|
-
height: 0;
|
265
|
-
margin-top: 0;
|
266
|
-
margin-right: 0;
|
267
|
-
margin-bottom: 0;
|
268
|
-
margin-left: 0;
|
269
|
-
/* #endif */
|
270
|
-
/* #ifndef APP-NVUE */
|
271
|
-
display: none;
|
272
|
-
/* #endif */
|
273
|
-
}
|
274
|
-
|
275
|
-
@for $i from 0 through 24 {
|
276
|
-
#{$col}-#{$i} {
|
277
|
-
width: getSize($i);
|
278
|
-
}
|
279
|
-
|
280
|
-
#{$col}-offset-#{$i} {
|
281
|
-
margin-left: getSize($i);
|
282
|
-
}
|
283
|
-
|
284
|
-
#{$col}-pull-#{$i} {
|
285
|
-
position: relative;
|
286
|
-
right: getSize($i);
|
287
|
-
}
|
288
|
-
|
289
|
-
#{$col}-push-#{$i} {
|
290
|
-
position: relative;
|
291
|
-
left: getSize($i);
|
292
|
-
}
|
293
|
-
}
|
294
|
-
|
295
|
-
@each $point in map-keys($breakpoints) {
|
296
|
-
@include res($point) {
|
297
|
-
#{$col}-#{$point}-0 {
|
298
|
-
display: none;
|
299
|
-
}
|
300
|
-
|
301
|
-
@for $i from 0 through 24 {
|
302
|
-
#{$col}-#{$point}-#{$i} {
|
303
|
-
width: getSize($i);
|
304
|
-
}
|
305
|
-
|
306
|
-
#{$col}-#{$point}-offset-#{$i} {
|
307
|
-
margin-left: getSize($i);
|
308
|
-
}
|
309
|
-
|
310
|
-
#{$col}-#{$point}-pull-#{$i} {
|
311
|
-
position: relative;
|
312
|
-
right: getSize($i);
|
313
|
-
}
|
314
|
-
|
315
|
-
#{$col}-#{$point}-push-#{$i} {
|
316
|
-
position: relative;
|
317
|
-
left: getSize($i);
|
318
|
-
}
|
319
|
-
}
|
320
|
-
}
|
321
|
-
}
|
322
|
-
|
323
|
-
/* #endif */
|
324
|
-
</style>
|
@@ -1,153 +0,0 @@
|
|
1
|
-
<template>
|
2
|
-
<view class="uni-collapse">
|
3
|
-
<slot />
|
4
|
-
</view>
|
5
|
-
</template>
|
6
|
-
<script>
|
7
|
-
/**
|
8
|
-
* Collapse 折叠面板
|
9
|
-
* @description 展示可以折叠 / 展开的内容区域
|
10
|
-
* @tutorial https://ext.dcloud.net.cn/plugin?id=23
|
11
|
-
* @property {String|Array} value 当前激活面板改变时触发(如果是手风琴模式,参数类型为string,否则为array)
|
12
|
-
* @property {Boolean} accordion = [true|false] 是否开启手风琴效果是否开启手风琴效果
|
13
|
-
* @event {Function} change 切换面板时触发,如果是手风琴模式,返回类型为string,否则为array
|
14
|
-
*/
|
15
|
-
export default {
|
16
|
-
name: 'uniCollapse',
|
17
|
-
emits: ['change', 'activeItem', 'input', 'update:modelValue'],
|
18
|
-
props: {
|
19
|
-
// value: {
|
20
|
-
// type: [String, Array],
|
21
|
-
// default: ''
|
22
|
-
// },
|
23
|
-
modelValue: {
|
24
|
-
type: [String, Array],
|
25
|
-
default: ''
|
26
|
-
},
|
27
|
-
accordion: {
|
28
|
-
// 是否开启手风琴效果
|
29
|
-
type: [Boolean, String],
|
30
|
-
default: false
|
31
|
-
}
|
32
|
-
},
|
33
|
-
data() {
|
34
|
-
return {};
|
35
|
-
},
|
36
|
-
computed: {
|
37
|
-
// TODO 兼容 vue2 和 vue3
|
38
|
-
dataValue() {
|
39
|
-
let value =
|
40
|
-
(typeof this.value === 'string' && this.value === '') ||
|
41
|
-
(Array.isArray(this.value) && this.value.length === 0);
|
42
|
-
let modelValue =
|
43
|
-
(typeof this.modelValue === 'string' && this.modelValue === '') ||
|
44
|
-
(Array.isArray(this.modelValue) && this.modelValue.length === 0);
|
45
|
-
if (value) {
|
46
|
-
return this.modelValue;
|
47
|
-
}
|
48
|
-
if (modelValue) {
|
49
|
-
return this.value;
|
50
|
-
}
|
51
|
-
|
52
|
-
return this.value;
|
53
|
-
}
|
54
|
-
},
|
55
|
-
watch: {
|
56
|
-
dataValue(val) {
|
57
|
-
this.setOpen(val);
|
58
|
-
}
|
59
|
-
},
|
60
|
-
created() {
|
61
|
-
this.childrens = [];
|
62
|
-
this.names = [];
|
63
|
-
},
|
64
|
-
mounted() {
|
65
|
-
this.$nextTick(() => {
|
66
|
-
this.setOpen(this.dataValue);
|
67
|
-
});
|
68
|
-
},
|
69
|
-
methods: {
|
70
|
-
setOpen(val) {
|
71
|
-
let str = typeof val === 'string';
|
72
|
-
let arr = Array.isArray(val);
|
73
|
-
this.childrens.forEach((vm, index) => {
|
74
|
-
if (str) {
|
75
|
-
if (val === vm.nameSync) {
|
76
|
-
if (!this.accordion) {
|
77
|
-
console.warn(
|
78
|
-
'accordion 属性为 false ,v-model 类型应该为 array'
|
79
|
-
);
|
80
|
-
return;
|
81
|
-
}
|
82
|
-
vm.isOpen = true;
|
83
|
-
}
|
84
|
-
}
|
85
|
-
if (arr) {
|
86
|
-
val.forEach((v) => {
|
87
|
-
if (v === vm.nameSync) {
|
88
|
-
if (this.accordion) {
|
89
|
-
console.warn(
|
90
|
-
'accordion 属性为 true ,v-model 类型应该为 string'
|
91
|
-
);
|
92
|
-
return;
|
93
|
-
}
|
94
|
-
vm.isOpen = true;
|
95
|
-
}
|
96
|
-
});
|
97
|
-
}
|
98
|
-
});
|
99
|
-
this.emit(val);
|
100
|
-
},
|
101
|
-
setAccordion(self) {
|
102
|
-
if (!this.accordion) return;
|
103
|
-
this.childrens.forEach((vm, index) => {
|
104
|
-
if (self !== vm) {
|
105
|
-
vm.isOpen = false;
|
106
|
-
}
|
107
|
-
});
|
108
|
-
},
|
109
|
-
resize() {
|
110
|
-
this.childrens.forEach((vm, index) => {
|
111
|
-
// #ifndef APP-NVUE
|
112
|
-
vm.getCollapseHeight();
|
113
|
-
// #endif
|
114
|
-
// #ifdef APP-NVUE
|
115
|
-
// vm.getNvueHwight()
|
116
|
-
// #endif
|
117
|
-
});
|
118
|
-
},
|
119
|
-
onChange(isOpen, self) {
|
120
|
-
let activeItem = [];
|
121
|
-
|
122
|
-
if (this.accordion) {
|
123
|
-
activeItem = isOpen ? self.nameSync : '';
|
124
|
-
} else {
|
125
|
-
this.childrens.forEach((vm, index) => {
|
126
|
-
if (vm.isOpen) {
|
127
|
-
activeItem.push(vm.nameSync);
|
128
|
-
}
|
129
|
-
});
|
130
|
-
}
|
131
|
-
this.$emit('change', activeItem);
|
132
|
-
this.emit(activeItem);
|
133
|
-
},
|
134
|
-
emit(val) {
|
135
|
-
this.$emit('input', val);
|
136
|
-
this.$emit('update:modelValue', val);
|
137
|
-
}
|
138
|
-
}
|
139
|
-
};
|
140
|
-
</script>
|
141
|
-
<style lang="scss">
|
142
|
-
.uni-collapse {
|
143
|
-
/* #ifndef APP-NVUE */
|
144
|
-
width: 100%;
|
145
|
-
display: flex;
|
146
|
-
/* #endif */
|
147
|
-
/* #ifdef APP-NVUE */
|
148
|
-
flex: 1;
|
149
|
-
/* #endif */
|
150
|
-
flex-direction: column;
|
151
|
-
background-color: #fff;
|
152
|
-
}
|
153
|
-
</style>
|