import {designComponent, getComponentCls, PropType, useModel} from "@peryl/react-compose"; import Popup from "../Popup"; import Space from "../Space"; import Button from "../Button"; import i18n from "../i18n"; import './confirm-popup.scss'; import {ePopupTrigger, iPopupTrigger} from "../usePopup/utils/popup.utils"; export const ConfirmPopup = designComponent({ name: 'confirm-popup', inheritPropsType: Popup, props: { title: { type: String }, trigger: { type: String as PropType, default: ePopupTrigger.click }, confirmLabel: { type: String }, cancelLabel: { type: String }, modelValue: { type: Boolean }, }, emits: { onConfirm: () => true, onCancel: () => true, onUpdateModelValue: (val: boolean) => true, }, slots: ['default'], setup({ props, slots, attrs, event: { emit } }) { const model = useModel(() => props.modelValue, emit.onUpdateModelValue); const handler = { onConfirm: () => { model.value = false; emit.onConfirm(); }, onCancel: () => { model.value = false; emit.onCancel(); }, }; return () => { const hasTitle = !!props.title; return ( slots.default(), popper: () => ( hasTitle ? (