import {computed, designComponent, getComponentCls, getCurrentDesignInstance, iMouseEvent, useClasses, useRefs} from "@peryl/react-compose"; import {StepCollector} from "../StepGroup"; import {StepStatus, StepUtils} from "../StepGroup/step.utils"; import Icon from "../Icon"; import Loading from "../Loading"; export const Step = designComponent({ name: '-step', props: { icon: { type: String }, status: { type: String }, val: { type: String }, title: { type: String }, message: { type: String }, }, emits: { onClick: (e: iMouseEvent) => true, }, inheritPropsType: HTMLDivElement, slots: ['head', 'content', 'default'], setup({ props, event: { emit }, slots }) { const { refs, onRef } = useRefs({ el: HTMLDivElement }); const stepGroup = StepCollector.child({ sort: () => refs.el! }); const ctx = getCurrentDesignInstance()!; /*---------------------------------------computer-------------------------------------------*/ const index = computed(() => stepGroup.items.indexOf(ctx.proxy)); const icon = computed(() => { if (!!props.icon) return props.icon; return null; }); const isLast = computed(() => { return index.value === stepGroup.items.length - 1; }); 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 }); }); const classes = useClasses(() => [ getComponentCls('step'), `step-status-${currentStatus.value}`, { 'step-has-icon': !!icon.value, 'step-last': isLast.value, } ]); return { refer: { props, refs, }, render: () => (