types(Steps): use tsx (#8123)

This commit is contained in:
neverland
2021-02-10 20:37:00 +08:00
committed by GitHub
parent 5b352d0339
commit 3e08b2471a
4 changed files with 53 additions and 20 deletions
+18 -6
View File
@@ -1,15 +1,29 @@
import { computed } from 'vue';
// Utils
import { createNamespace } from '../utils';
import { BORDER } from '../utils/constant';
import { STEPS_KEY } from '../steps';
import { STEPS_KEY, StepsProvide } from '../steps';
// Composition
import { useParent } from '@vant/use';
// Components
import Icon from '../icon';
const [createComponent, bem] = createNamespace('step');
export default createComponent({
setup(props, { slots }) {
const { parent, index } = useParent(STEPS_KEY);
const { parent, index } = useParent<StepsProvide>(STEPS_KEY);
if (!parent) {
if (process.env.NODE_ENV !== 'production') {
console.error('[Vant] Step must be a child component of Steps.');
}
return;
}
const parentProps = parent.props;
const getStatus = () => {
@@ -17,9 +31,7 @@ export default createComponent({
if (index.value < active) {
return 'finish';
}
if (index.value === active) {
return 'process';
}
return index.value === active ? 'process' : 'waiting';
};
const isActive = () => getStatus() === 'process';
@@ -41,7 +53,7 @@ export default createComponent({
});
const onClickStep = () => {
parent.emit('click-step', index.value);
parent.onClickStep(index.value);
};
const renderCircle = () => {