types: extract prop types (#8332)

This commit is contained in:
neverland
2021-03-14 10:58:08 +08:00
committed by GitHub
parent 6e026e18c3
commit ceebc22e63
9 changed files with 235 additions and 260 deletions
+22 -28
View File
@@ -1,4 +1,4 @@
import { PropType, defineComponent } from 'vue';
import { PropType, defineComponent, ExtractPropTypes } from 'vue';
import { createNamespace } from '../utils';
import { useChildren } from '@vant/use';
@@ -8,40 +8,34 @@ export const STEPS_KEY = Symbol(name);
export type StepsDirection = 'horizontal' | 'vertical';
const props = {
finishIcon: String,
activeColor: String,
inactiveIcon: String,
inactiveColor: String,
active: {
type: [Number, String],
default: 0,
},
direction: {
type: String as PropType<StepsDirection>,
default: 'horizontal',
},
activeIcon: {
type: String,
default: 'checked',
},
};
export type StepsProvide = {
props: {
active: number | string;
direction: StepsDirection;
activeIcon: string;
finishIcon?: string;
activeColor?: string;
inactiveIcon?: string;
inactiveColor?: string;
};
props: ExtractPropTypes<typeof props>;
onClickStep: (index: number) => void;
};
export default defineComponent({
name,
props: {
finishIcon: String,
activeColor: String,
inactiveIcon: String,
inactiveColor: String,
active: {
type: [Number, String],
default: 0,
},
direction: {
type: String as PropType<StepsDirection>,
default: 'horizontal',
},
activeIcon: {
type: String,
default: 'checked',
},
},
props,
emits: ['click-step'],