chore: add trailingComma

This commit is contained in:
陈嘉涵
2020-01-19 11:57:09 +08:00
parent e841175fe8
commit 389d68884d
269 changed files with 2706 additions and 2702 deletions
+15 -15
View File
@@ -39,8 +39,8 @@ export default createComponent({
visibleItemCount: Number,
initialOptions: {
type: Array,
default: () => []
}
default: () => [],
},
},
data() {
@@ -48,7 +48,7 @@ export default createComponent({
offset: 0,
duration: 0,
options: deepClone(this.initialOptions),
currentIndex: this.defaultIndex
currentIndex: this.defaultIndex,
};
},
@@ -75,7 +75,7 @@ export default createComponent({
watch: {
defaultIndex(val) {
this.setIndex(val);
}
},
},
computed: {
@@ -85,7 +85,7 @@ export default createComponent({
baseOffset() {
return (this.itemHeight * (this.visibleItemCount - 1)) / 2;
}
},
},
methods: {
@@ -243,7 +243,7 @@ export default createComponent({
genOptions() {
const optionStyle = {
height: `${this.itemHeight}px`
height: `${this.itemHeight}px`,
};
return this.options.map((option, index) => {
@@ -254,31 +254,31 @@ export default createComponent({
style: optionStyle,
attrs: {
role: 'button',
tabindex: disabled ? -1 : 0
tabindex: disabled ? -1 : 0,
},
class: [
'van-ellipsis',
bem('item', {
disabled,
selected: index === this.currentIndex
})
selected: index === this.currentIndex,
}),
],
on: {
click: () => {
this.onClickItem(index);
}
}
},
},
};
if (this.allowHtml) {
data.domProps = {
innerHTML: text
innerHTML: text,
};
}
return <li {...data}>{this.allowHtml ? '' : text}</li>;
});
}
},
},
render() {
@@ -286,7 +286,7 @@ export default createComponent({
transform: `translate3d(0, ${this.offset + this.baseOffset}px, 0)`,
transitionDuration: `${this.duration}ms`,
transitionProperty: this.duration ? 'all' : 'none',
lineHeight: `${this.itemHeight}px`
lineHeight: `${this.itemHeight}px`,
};
return (
@@ -301,5 +301,5 @@ export default createComponent({
</ul>
</div>
);
}
},
});
+13 -13
View File
@@ -66,9 +66,9 @@ export default {
column2: [{ text: '杭州', disabled: true }, { text: '宁波' }, { text: '温州' }],
column3: {
浙江: ['杭州', '宁波', '温州', '嘉兴', '湖州'],
福建: ['福州', '厦门', '莆田', '三明', '泉州']
福建: ['福州', '厦门', '莆田', '三明', '泉州'],
},
toastContent: (value, index) => `当前值:${value}, 当前索引:${index}`
toastContent: (value, index) => `当前值:${value}, 当前索引:${index}`,
},
'en-US': {
city: 'City',
@@ -82,20 +82,20 @@ export default {
column2: [
{ text: 'Delaware', disabled: true },
{ text: 'Florida' },
{ text: 'Georqia' }
{ text: 'Georqia' },
],
column3: {
Group1: ['Delaware', 'Florida', 'Georqia', 'Indiana', 'Maine'],
Group2: ['Alabama', 'Kansas', 'Louisiana', 'Texas']
Group2: ['Alabama', 'Kansas', 'Louisiana', 'Texas'],
},
toastContent: (value, index) => `Value: ${value}, Index${index}`
}
toastContent: (value, index) => `Value: ${value}, Index${index}`,
},
},
data() {
return {
showPicker: false,
fieldValue: ''
fieldValue: '',
};
},
@@ -105,15 +105,15 @@ export default {
return [
{
values: Object.keys(column),
className: 'column1'
className: 'column1',
},
{
values: column[Object.keys(column)[0]],
className: 'column2',
defaultIndex: 2
}
defaultIndex: 2,
},
];
}
},
},
methods: {
@@ -144,7 +144,7 @@ export default {
onCancel2() {
this.showPicker = false;
}
}
},
},
};
</script>
+14 -14
View File
@@ -13,36 +13,36 @@ export default createComponent({
...pickerProps,
defaultIndex: {
type: Number,
default: 0
default: 0,
},
columns: {
type: Array,
default: () => []
default: () => [],
},
toolbarPosition: {
type: String,
default: 'top'
default: 'top',
},
valueKey: {
type: String,
default: 'text'
}
default: 'text',
},
},
data() {
return {
children: []
children: [],
};
},
computed: {
simple() {
return this.columns.length && !this.columns[0].values;
}
},
},
watch: {
columns: 'setColumns'
columns: 'setColumns',
},
methods: {
@@ -194,7 +194,7 @@ export default createComponent({
onClick={this.confirm}
>
{this.confirmButtonText || t('confirm')}
</button>
</button>,
]}
</div>
);
@@ -219,7 +219,7 @@ export default createComponent({
}}
/>
));
}
},
},
render(h) {
@@ -227,15 +227,15 @@ export default createComponent({
const wrapHeight = itemHeight * this.visibleItemCount;
const frameStyle = {
height: `${itemHeight}px`
height: `${itemHeight}px`,
};
const columnsStyle = {
height: `${wrapHeight}px`
height: `${wrapHeight}px`,
};
const maskStyle = {
backgroundSize: `100% ${(wrapHeight - itemHeight) / 2}px`
backgroundSize: `100% ${(wrapHeight - itemHeight) / 2}px`,
};
return (
@@ -259,5 +259,5 @@ export default createComponent({
{this.toolbarPosition === 'bottom' ? this.genToolbar() : h()}
</div>
);
}
},
});
+5 -5
View File
@@ -16,18 +16,18 @@ export const pickerProps = {
confirmButtonText: String,
allowHtml: {
type: Boolean,
default: true
default: true,
},
visibleItemCount: {
type: Number,
default: 5
default: 5,
},
itemHeight: {
type: Number,
default: 44
default: 44,
},
swipeDuration: {
type: Number,
default: 1000
}
default: 1000,
},
};
+29 -29
View File
@@ -6,20 +6,20 @@ const simpleColumn = ['1990', '1991', '1992', '1993', '1994', '1995'];
const columns = [
{
values: ['vip', 'normal'],
className: 'column1'
className: 'column1',
},
{
values: simpleColumn,
className: 'column2'
}
className: 'column2',
},
];
test('simple columns confirm & cancel event', () => {
const wrapper = mount(Picker, {
propsData: {
showToolbar: true,
columns: simpleColumn
}
columns: simpleColumn,
},
});
wrapper.find('.van-picker__confirm').trigger('click');
@@ -32,8 +32,8 @@ test('simple columns confirm & cancel event', () => {
test('multiple columns confirm & cancel event', () => {
const wrapper = mount(Picker, {
propsData: {
showToolbar: true
}
showToolbar: true,
},
});
wrapper.find('.van-picker__confirm').trigger('click');
@@ -45,8 +45,8 @@ test('multiple columns confirm & cancel event', () => {
test('set picker values', () => {
const wrapper = mount(Picker, {
propsData: {
columns
}
columns,
},
});
const { vm } = wrapper;
@@ -83,8 +83,8 @@ test('set picker values', () => {
test('drag columns', () => {
const wrapper = mount(Picker, {
propsData: {
columns
}
columns,
},
});
triggerDrag(wrapper.find('.van-picker-column'), 0, -100);
@@ -98,8 +98,8 @@ test('drag columns', () => {
test('drag simple columns', () => {
const wrapper = mount(Picker, {
propsData: {
columns: simpleColumn
}
columns: simpleColumn,
},
});
triggerDrag(wrapper.find('.van-picker-column'), 0, -100);
@@ -117,8 +117,8 @@ test('column watch default index', async () => {
initialOptions: [disabled, ...simpleColumn],
valueKey: 'text',
itemHeight: 50,
visibleItemCount: 5
}
visibleItemCount: 5,
},
});
await later();
@@ -136,8 +136,8 @@ test('render title slot', () => {
</picker>
`,
components: {
Picker
}
Picker,
},
});
expect(wrapper).toMatchSnapshot();
@@ -152,14 +152,14 @@ test('simulation finger swipe again before transitionend', () => {
return {
...style,
transform: 'matrix(1, 0, 0, 1, 0, -5)'
transform: 'matrix(1, 0, 0, 1, 0, -5)',
};
};
const wrapper = mount(Picker, {
propsData: {
columns: simpleColumn
}
columns: simpleColumn,
},
});
triggerDrag(wrapper.find('.van-picker-column'), 0, -5);
@@ -173,12 +173,12 @@ test('click column\'s item', () => {
{ text: '杭州' },
{ text: '宁波' },
{ text: '温州', disabled: true },
{ text: '嘉兴', disabled: true }
{ text: '嘉兴', disabled: true },
];
const wrapper = mount(Picker, {
propsData: {
columns
}
columns,
},
});
wrapper.findAll('.van-picker-column__item').at(3).trigger('click');
@@ -189,8 +189,8 @@ test('toolbar-position prop', () => {
const wrapper = mount(Picker, {
propsData: {
showToolbar: true,
toolbarPosition: 'bottom'
}
toolbarPosition: 'bottom',
},
});
expect(wrapper).toMatchSnapshot();
@@ -200,8 +200,8 @@ test('not allow html', () => {
const wrapper = mount(Picker, {
propsData: {
allowHtml: false,
columns: ['<div>option</div>']
}
columns: ['<div>option</div>'],
},
});
expect(wrapper).toMatchSnapshot();
@@ -210,12 +210,12 @@ test('not allow html', () => {
test('columns-top、columns-bottom prop', () => {
const wrapper = mount(Picker, {
propsData: {
showToolbar: true
showToolbar: true,
},
scopedSlots: {
'columns-top': () => 'Custom Columns Top',
'columns-bottom': () => 'Custom Columns Bottom',
}
},
});
expect(wrapper).toMatchSnapshot();