import {computed, designComponent, getComponentCls, getCurrentDesignInstance, useClasses, useRefs} from "@peryl/react-compose"; import Triangle from "../Triangle"; import {ArrowStepCollector} from "../ArrowStepGroup"; import {StepStatus, StepUtils} from "../StepGroup/step.utils"; export const ArrowStep = designComponent({ name: 'arrow-step', props: { status: { type: String }, title: { type: String }, val: { type: String }, hideIndex: { type: Boolean }, }, inheritPropsType: HTMLDivElement, slots: ['default'], setup({ props, slots }) { const ctx = getCurrentDesignInstance()!; const { refs, onRef } = useRefs({ el: HTMLDivElement }); const stepGroup = ArrowStepCollector.child({ sort: () => refs.el! }); /*---------------------------------------computer-------------------------------------------*/ const index = computed(() => { return stepGroup.items.indexOf(ctx.proxy); }) as { value: number }; const isLast = computed(() => { return index.value === stepGroup.items.length - 1; }); const isFirst = computed(() => { return index.value === 0; }); const currentStatus: { value: StepStatus | null } = computed(() => { return StepUtils.getStepStatus({ currentIndex: stepGroup.currentIndex as any, currentStatus: stepGroup.props.currentStatus as any }, { status: props.status as any, index: index as any }); }); const classes = useClasses(() => [ getComponentCls('arrow-step'), `arrow-step-status-${currentStatus.value}`, ]); return { refer: { refs, props, }, render: () => ( index.value != null ? (