import { PropType, defineComponent, ExtractPropTypes } from 'vue'; import { createNamespace } from '../utils'; import { useChildren } from '@vant/use'; const [name, bem] = createNamespace('steps'); export const STEPS_KEY = Symbol(name); export type StepsDirection = 'horizontal' | 'vertical'; const props = { iconPrefix: String, finishIcon: String, activeColor: String, inactiveIcon: String, inactiveColor: String, active: { type: [Number, String], default: 0, }, direction: { type: String as PropType, default: 'horizontal', }, activeIcon: { type: String, default: 'checked', }, }; export type StepsProvide = { props: ExtractPropTypes; onClickStep: (index: number) => void; }; export default defineComponent({ name, props, emits: ['click-step'], setup(props, { emit, slots }) { const { linkChildren } = useChildren(STEPS_KEY); const onClickStep = (index: number) => emit('click-step', index); linkChildren({ props, onClickStep, }); return () => (
{slots.default?.()}
); }, });