换ubuntu
This commit is contained in:
2
utils/dist/dropdown-item/index.d.ts
vendored
2
utils/dist/dropdown-item/index.d.ts
vendored
@@ -1 +1 @@
|
||||
export {};
|
||||
export {};
|
||||
|
||||
208
utils/dist/dropdown-item/index.js
vendored
208
utils/dist/dropdown-item/index.js
vendored
@@ -1,104 +1,104 @@
|
||||
import { VantComponent } from '../common/component';
|
||||
VantComponent({
|
||||
field: true,
|
||||
relation: {
|
||||
name: 'dropdown-menu',
|
||||
type: 'ancestor',
|
||||
linked(target) {
|
||||
this.parent = target;
|
||||
this.updateDataFromParent();
|
||||
},
|
||||
unlinked() {
|
||||
this.parent = null;
|
||||
}
|
||||
},
|
||||
props: {
|
||||
value: {
|
||||
type: null,
|
||||
observer: 'rerender'
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
observer: 'rerender'
|
||||
},
|
||||
disabled: Boolean,
|
||||
titleClass: {
|
||||
type: String,
|
||||
observer: 'rerender'
|
||||
},
|
||||
options: {
|
||||
type: Array,
|
||||
value: [],
|
||||
observer: 'rerender'
|
||||
}
|
||||
},
|
||||
data: {
|
||||
transition: true,
|
||||
showPopup: false,
|
||||
showWrapper: false,
|
||||
displayTitle: ''
|
||||
},
|
||||
methods: {
|
||||
rerender() {
|
||||
wx.nextTick(() => {
|
||||
this.parent && this.parent.updateItemListData();
|
||||
});
|
||||
},
|
||||
updateDataFromParent() {
|
||||
if (this.parent) {
|
||||
const { overlay, duration, activeColor, closeOnClickOverlay, direction } = this.parent.data;
|
||||
this.setData({
|
||||
overlay,
|
||||
duration,
|
||||
activeColor,
|
||||
closeOnClickOverlay,
|
||||
direction
|
||||
});
|
||||
}
|
||||
},
|
||||
onClickOverlay() {
|
||||
this.toggle();
|
||||
this.$emit('close');
|
||||
},
|
||||
onOptionTap(event) {
|
||||
const { option } = event.currentTarget.dataset;
|
||||
const { value } = option;
|
||||
const shouldEmitChange = this.data.value !== value;
|
||||
this.setData({ showPopup: false, value });
|
||||
setTimeout(() => {
|
||||
this.setData({ showWrapper: false });
|
||||
}, this.data.duration || 0);
|
||||
this.rerender();
|
||||
if (shouldEmitChange) {
|
||||
this.$emit('change', value);
|
||||
}
|
||||
},
|
||||
toggle(show, options = {}) {
|
||||
const { showPopup, duration } = this.data;
|
||||
if (show == null) {
|
||||
show = !showPopup;
|
||||
}
|
||||
if (show === showPopup) {
|
||||
return;
|
||||
}
|
||||
if (!show) {
|
||||
const time = options.immediate ? 0 : duration;
|
||||
this.setData({ transition: !options.immediate, showPopup: show });
|
||||
setTimeout(() => {
|
||||
this.setData({ showWrapper: false });
|
||||
}, time);
|
||||
this.rerender();
|
||||
return;
|
||||
}
|
||||
this.parent.getChildWrapperStyle().then((wrapperStyle = '') => {
|
||||
this.setData({
|
||||
transition: !options.immediate,
|
||||
showPopup: show,
|
||||
wrapperStyle,
|
||||
showWrapper: true
|
||||
});
|
||||
this.rerender();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
import { VantComponent } from '../common/component';
|
||||
VantComponent({
|
||||
field: true,
|
||||
relation: {
|
||||
name: 'dropdown-menu',
|
||||
type: 'ancestor',
|
||||
linked(target) {
|
||||
this.parent = target;
|
||||
this.updateDataFromParent();
|
||||
},
|
||||
unlinked() {
|
||||
this.parent = null;
|
||||
}
|
||||
},
|
||||
props: {
|
||||
value: {
|
||||
type: null,
|
||||
observer: 'rerender'
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
observer: 'rerender'
|
||||
},
|
||||
disabled: Boolean,
|
||||
titleClass: {
|
||||
type: String,
|
||||
observer: 'rerender'
|
||||
},
|
||||
options: {
|
||||
type: Array,
|
||||
value: [],
|
||||
observer: 'rerender'
|
||||
}
|
||||
},
|
||||
data: {
|
||||
transition: true,
|
||||
showPopup: false,
|
||||
showWrapper: false,
|
||||
displayTitle: ''
|
||||
},
|
||||
methods: {
|
||||
rerender() {
|
||||
wx.nextTick(() => {
|
||||
this.parent && this.parent.updateItemListData();
|
||||
});
|
||||
},
|
||||
updateDataFromParent() {
|
||||
if (this.parent) {
|
||||
const { overlay, duration, activeColor, closeOnClickOverlay, direction } = this.parent.data;
|
||||
this.setData({
|
||||
overlay,
|
||||
duration,
|
||||
activeColor,
|
||||
closeOnClickOverlay,
|
||||
direction
|
||||
});
|
||||
}
|
||||
},
|
||||
onClickOverlay() {
|
||||
this.toggle();
|
||||
this.$emit('close');
|
||||
},
|
||||
onOptionTap(event) {
|
||||
const { option } = event.currentTarget.dataset;
|
||||
const { value } = option;
|
||||
const shouldEmitChange = this.data.value !== value;
|
||||
this.setData({ showPopup: false, value });
|
||||
setTimeout(() => {
|
||||
this.setData({ showWrapper: false });
|
||||
}, this.data.duration || 0);
|
||||
this.rerender();
|
||||
if (shouldEmitChange) {
|
||||
this.$emit('change', value);
|
||||
}
|
||||
},
|
||||
toggle(show, options = {}) {
|
||||
const { showPopup, duration } = this.data;
|
||||
if (show == null) {
|
||||
show = !showPopup;
|
||||
}
|
||||
if (show === showPopup) {
|
||||
return;
|
||||
}
|
||||
if (!show) {
|
||||
const time = options.immediate ? 0 : duration;
|
||||
this.setData({ transition: !options.immediate, showPopup: show });
|
||||
setTimeout(() => {
|
||||
this.setData({ showWrapper: false });
|
||||
}, time);
|
||||
this.rerender();
|
||||
return;
|
||||
}
|
||||
this.parent.getChildWrapperStyle().then((wrapperStyle = '') => {
|
||||
this.setData({
|
||||
transition: !options.immediate,
|
||||
showPopup: show,
|
||||
wrapperStyle,
|
||||
showWrapper: true
|
||||
});
|
||||
this.rerender();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
16
utils/dist/dropdown-item/index.json
vendored
16
utils/dist/dropdown-item/index.json
vendored
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-popup": "../popup/index",
|
||||
"van-cell": "../cell/index",
|
||||
"van-icon": "../icon/index"
|
||||
}
|
||||
}
|
||||
{
|
||||
"component": true,
|
||||
"usingComponents": {
|
||||
"van-popup": "../popup/index",
|
||||
"van-cell": "../cell/index",
|
||||
"van-icon": "../icon/index"
|
||||
}
|
||||
}
|
||||
|
||||
88
utils/dist/dropdown-item/index.wxml
vendored
88
utils/dist/dropdown-item/index.wxml
vendored
@@ -1,44 +1,44 @@
|
||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||
|
||||
<view
|
||||
wx:if="{{ showWrapper }}"
|
||||
class="{{ utils.bem('dropdown-item', direction) }}"
|
||||
style="{{ wrapperStyle }}"
|
||||
>
|
||||
<van-popup
|
||||
show="{{ showPopup }}"
|
||||
custom-style="position: absolute;"
|
||||
overlay-style="position: absolute;"
|
||||
overlay="{{ overlay }}"
|
||||
position="{{ direction === 'down' ? 'top' : 'bottom' }}"
|
||||
duration="{{ transition ? duration : 0 }}"
|
||||
close-on-click-overlay="{{ closeOnClickOverlay }}"
|
||||
bind:close="onClickOverlay"
|
||||
>
|
||||
<van-cell
|
||||
wx:for="{{ options }}"
|
||||
wx:key="{{ item.value }}"
|
||||
data-option="{{ item }}"
|
||||
class="{{ utils.bem('dropdown-item__option', { active: item.value === value } ) }}"
|
||||
clickable
|
||||
icon="{{ item.icon }}"
|
||||
bind:tap="onOptionTap"
|
||||
>
|
||||
<view
|
||||
slot="title"
|
||||
class="van-dropdown-item__title"
|
||||
style="{{ item.value === value ? 'color:' + activeColor : '' }}"
|
||||
>
|
||||
{{ item.text }}
|
||||
</view>
|
||||
<van-icon
|
||||
wx:if="{{ item.value === value }}"
|
||||
name="success"
|
||||
class="van-dropdown-item__icon"
|
||||
color="{{ activeColor }}"
|
||||
/>
|
||||
</van-cell>
|
||||
|
||||
<slot />
|
||||
</van-popup>
|
||||
</view>
|
||||
<wxs src="../wxs/utils.wxs" module="utils" />
|
||||
|
||||
<view
|
||||
wx:if="{{ showWrapper }}"
|
||||
class="{{ utils.bem('dropdown-item', direction) }}"
|
||||
style="{{ wrapperStyle }}"
|
||||
>
|
||||
<van-popup
|
||||
show="{{ showPopup }}"
|
||||
custom-style="position: absolute;"
|
||||
overlay-style="position: absolute;"
|
||||
overlay="{{ overlay }}"
|
||||
position="{{ direction === 'down' ? 'top' : 'bottom' }}"
|
||||
duration="{{ transition ? duration : 0 }}"
|
||||
close-on-click-overlay="{{ closeOnClickOverlay }}"
|
||||
bind:close="onClickOverlay"
|
||||
>
|
||||
<van-cell
|
||||
wx:for="{{ options }}"
|
||||
wx:key="{{ item.value }}"
|
||||
data-option="{{ item }}"
|
||||
class="{{ utils.bem('dropdown-item__option', { active: item.value === value } ) }}"
|
||||
clickable
|
||||
icon="{{ item.icon }}"
|
||||
bind:tap="onOptionTap"
|
||||
>
|
||||
<view
|
||||
slot="title"
|
||||
class="van-dropdown-item__title"
|
||||
style="{{ item.value === value ? 'color:' + activeColor : '' }}"
|
||||
>
|
||||
{{ item.text }}
|
||||
</view>
|
||||
<van-icon
|
||||
wx:if="{{ item.value === value }}"
|
||||
name="success"
|
||||
class="van-dropdown-item__icon"
|
||||
color="{{ activeColor }}"
|
||||
/>
|
||||
</van-cell>
|
||||
|
||||
<slot />
|
||||
</van-popup>
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user