mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[improvement] Picker: shared props (#2888)
This commit is contained in:
parent
0245e663d0
commit
317b9c329d
@ -1,13 +1,12 @@
|
|||||||
import { use } from '../utils';
|
import { use } from '../utils';
|
||||||
import Picker from '../picker';
|
import Picker from '../picker';
|
||||||
import { PickerMixin } from '../mixins/picker';
|
import { pickerProps } from '../picker/shared';
|
||||||
|
|
||||||
const [sfc, bem] = use('area');
|
const [sfc, bem] = use('area');
|
||||||
|
|
||||||
export default sfc({
|
export default sfc({
|
||||||
mixins: [PickerMixin],
|
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
|
...pickerProps,
|
||||||
value: String,
|
value: String,
|
||||||
areaList: {
|
areaList: {
|
||||||
type: Object,
|
type: Object,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { use, range } from '../utils';
|
import { use, range } from '../utils';
|
||||||
import Picker from '../picker';
|
import Picker from '../picker';
|
||||||
import { PickerMixin } from '../mixins/picker';
|
import { pickerProps } from '../picker/shared';
|
||||||
import {
|
import {
|
||||||
times,
|
times,
|
||||||
padZero,
|
padZero,
|
||||||
@ -13,9 +13,8 @@ const [sfc, bem] = use('datetime-picker');
|
|||||||
const currentYear = new Date().getFullYear();
|
const currentYear = new Date().getFullYear();
|
||||||
|
|
||||||
export default sfc({
|
export default sfc({
|
||||||
mixins: [PickerMixin],
|
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
|
...pickerProps,
|
||||||
value: null,
|
value: null,
|
||||||
minHour: Number,
|
minHour: Number,
|
||||||
minMinute: Number,
|
minMinute: Number,
|
||||||
@ -302,7 +301,7 @@ export default sfc({
|
|||||||
|
|
||||||
render(h) {
|
render(h) {
|
||||||
const props = {};
|
const props = {};
|
||||||
Object.keys(PickerMixin.props).forEach(key => {
|
Object.keys(pickerProps).forEach(key => {
|
||||||
props[key] = this[key];
|
props[key] = this[key];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
/**
|
|
||||||
* Common Picker Props
|
|
||||||
*/
|
|
||||||
|
|
||||||
export const PickerMixin = {
|
|
||||||
props: {
|
|
||||||
title: String,
|
|
||||||
loading: Boolean,
|
|
||||||
showToolbar: Boolean,
|
|
||||||
cancelButtonText: String,
|
|
||||||
confirmButtonText: String,
|
|
||||||
visibleItemCount: {
|
|
||||||
type: Number,
|
|
||||||
default: 5
|
|
||||||
},
|
|
||||||
itemHeight: {
|
|
||||||
type: Number,
|
|
||||||
default: 44
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
@ -1,16 +1,15 @@
|
|||||||
import { use } from '../utils';
|
import { use } from '../utils';
|
||||||
import { prevent } from '../utils/event';
|
import { prevent } from '../utils/event';
|
||||||
import { deepClone } from '../utils/deep-clone';
|
import { deepClone } from '../utils/deep-clone';
|
||||||
import { PickerMixin } from '../mixins/picker';
|
import { pickerProps } from './shared';
|
||||||
import Loading from '../loading';
|
import Loading from '../loading';
|
||||||
import PickerColumn from './PickerColumn';
|
import PickerColumn from './PickerColumn';
|
||||||
|
|
||||||
const [sfc, bem, t] = use('picker');
|
const [sfc, bem, t] = use('picker');
|
||||||
|
|
||||||
export default sfc({
|
export default sfc({
|
||||||
mixins: [PickerMixin],
|
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
|
...pickerProps,
|
||||||
columns: Array,
|
columns: Array,
|
||||||
valueKey: {
|
valueKey: {
|
||||||
type: String,
|
type: String,
|
||||||
|
25
packages/picker/shared.ts
Normal file
25
packages/picker/shared.ts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
export type SharedPickerProps = {
|
||||||
|
title?: string;
|
||||||
|
loading?: boolean;
|
||||||
|
itemHeight: number;
|
||||||
|
showToolbar?: boolean;
|
||||||
|
visibleItemCount: number;
|
||||||
|
cancelButtonText?: string;
|
||||||
|
confirmButtonText?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const pickerProps = {
|
||||||
|
title: String,
|
||||||
|
loading: Boolean,
|
||||||
|
showToolbar: Boolean,
|
||||||
|
cancelButtonText: String,
|
||||||
|
confirmButtonText: String,
|
||||||
|
visibleItemCount: {
|
||||||
|
type: Number,
|
||||||
|
default: 5
|
||||||
|
},
|
||||||
|
itemHeight: {
|
||||||
|
type: Number,
|
||||||
|
default: 44
|
||||||
|
}
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user