import { computed, defineComponent, toRefs } from 'vue'; import classNames from '../_util/classNames'; import { isFunction } from '../_util/util'; import CloseOutlined from '@ant-design/icons-vue/CloseOutlined'; import { tourStepProps } from './interface'; import type { TourBtnProps } from './interface'; import LocaleReceiver from '../locale/LocaleReceiver'; import Button from '../button'; import type { ButtonProps } from '../button'; import defaultLocale from '../locale/en_US'; import type { VueNode } from '../_util/type'; const panelRender = defineComponent({ name: 'ATourPanel', inheritAttrs: false, props: tourStepProps(), setup(props, { attrs, slots }) { const { current, total } = toRefs(props); const isLastStep = computed(() => current.value === total.value - 1); const prevBtnClick = e => { const prevButtonProps = props.prevButtonProps as TourBtnProps; props.onPrev?.(e); if (typeof prevButtonProps?.onClick === 'function') { prevButtonProps?.onClick(); } }; const nextBtnClick = e => { const nextButtonProps = props.nextButtonProps as TourBtnProps; if (isLastStep.value) { props.onFinish?.(e); } else { props.onNext?.(e); } if (typeof nextButtonProps?.onClick === 'function') { nextButtonProps?.onClick(); } }; return () => { const { prefixCls, title, onClose, cover, description, type: stepType, arrow } = props; const prevButtonProps = props.prevButtonProps as TourBtnProps; const nextButtonProps = props.nextButtonProps as TourBtnProps; let headerNode: VueNode; if (title) { headerNode = (