Skip to content

Popconfirm ​

Лёгкое всплывающее окно подтверждения, привязанное к элементу-триггеру. Идеально для встроенных подтверждений перед деструктивными или важными действиями.

Basic ​

vue
<VxPopconfirm title="Are you sure?" @confirm="onConfirm" @cancel="onCancel">
  <VxButton>Click me</VxButton>
</VxPopconfirm>

With Description ​

vue
<VxPopconfirm title="Delete this item?" description="This action cannot be undone.">
  <VxButton>Delete</VxButton>
</VxPopconfirm>

Types ​

vue
<VxPopconfirm title="Info confirmation" type="info">
  <VxButton>Info</VxButton>
</VxPopconfirm>

<VxPopconfirm title="Operation successful" type="success">
  <VxButton>Success</VxButton>
</VxPopconfirm>

<VxPopconfirm title="Proceed with caution?" type="warning">
  <VxButton>Warning</VxButton>
</VxPopconfirm>

<VxPopconfirm title="Delete permanently?" description="All data will be lost." type="danger">
  <VxButton variant="destructive">Danger</VxButton>
</VxPopconfirm>

Hover Trigger ​

Открывайте popconfirm при наведении вместо клика.

vue
<VxPopconfirm title="Remove from list?" trigger="hover" type="warning">
  <VxButton>Hover me</VxButton>
</VxPopconfirm>

Before Confirm Hook ​

Выполняет асинхронную валидацию перед подтверждением. Спиннер автоматически отображается во время проверки. Если функция возвращает false или выбрасывает ошибку, подтверждение блокируется.

vue
<script setup>
async function validate() {
  const ok = await checkServer()
  return ok // return false to block confirm
}
</script>

<VxPopconfirm title="Save changes?" :before-confirm="validate" @confirm="onConfirm">
  <VxButton>Save</VxButton>
</VxPopconfirm>

Auto Close ​

Автоматически закрывает popconfirm по истечении таймаута (в мс).

vue
<VxPopconfirm title="Quick! Confirm within 3s" :auto-close="3000">
  <VxButton>Auto Close (3s)</VxButton>
</VxPopconfirm>

Condition ​

Когда condition равно false, клик по триггеру сразу вызывает confirm без показа всплывающего окна. Полезно для включения/отключения подтверждения.

vue
<script setup>
const needConfirm = ref(true)
</script>

<VxPopconfirm title="Are you sure?" :condition="needConfirm" @confirm="onDelete">
  <VxButton>Delete</VxButton>
</VxPopconfirm>

<VxSwitch v-model="needConfirm" /> Require confirmation

Custom Icon Slot ​

Замените стандартную иконку типа своей.

vue
<VxPopconfirm title="Publish article?">
  <template #icon>
    <div class="my-icon">
      <MyCustomIcon />
    </div>
  </template>
  <VxButton>Custom Icon</VxButton>
</VxPopconfirm>

Custom Actions Slot ​

Полностью настройте кнопки подвала. Слот предоставляет функции confirm, cancel и состояние loading.

vue
<VxPopconfirm title="Choose an action">
  <template #actions="{ confirm, cancel }">
    <button @click="cancel">Skip</button>
    <button @click="saveDraft">Draft</button>
    <button @click="confirm">Publish</button>
  </template>
  <VxButton>Three Actions</VxButton>
</VxPopconfirm>

Loading ​

vue
<script setup>
const loading = ref(false)

function onConfirm() {
  loading.value = true
  deleteRecord().finally(() => { loading.value = false })
}
</script>

<VxPopconfirm
  title="Delete this record?"
  type="danger"
  :loading="loading"
  @confirm="onConfirm"
>
  <VxButton variant="destructive">Delete</VxButton>
</VxPopconfirm>

No Icon ​

vue
<VxPopconfirm title="Are you sure?" :icon="false">
  <VxButton>No Icon</VxButton>
</VxPopconfirm>

Custom Button Text ​

vue
<VxPopconfirm
  title="Discard draft?"
  confirm-text="Discard"
  cancel-text="Keep Editing"
  type="warning"
>
  <VxButton>Discard</VxButton>
</VxPopconfirm>

No Cancel Button ​

vue
<VxPopconfirm title="Continue?" :show-cancel="false">
  <VxButton>Acknowledge</VxButton>
</VxPopconfirm>

Disabled ​

vue
<VxPopconfirm title="This won't open" disabled>
  <VxButton disabled>Disabled</VxButton>
</VxPopconfirm>

Custom Content Slot ​

vue
<VxPopconfirm title="Update settings?">
  <template #content>
    <div>
      This will apply to <strong>all team members</strong>. Are you sure?
    </div>
  </template>
  <VxButton>Update</VxButton>
</VxPopconfirm>

Programmatic Usage ​

Используйте usePopconfirm() для Promise-based API. Резолвится при подтверждении, отклоняется при отмене.

vue
<script setup>
import { usePopconfirm } from 'veloxui'

const popconfirm = usePopconfirm()

// Basic
popconfirm('Are you sure?')
  .then(() => console.log('Confirmed'))
  .catch(() => console.log('Cancelled'))

// Type-specific with options
popconfirm.danger({
  title: 'Delete account?',
  description: 'This cannot be undone.',
  confirmText: 'Delete',
}).then(() => { ... })

// Other types
popconfirm.success({ title: 'Publish?' })
popconfirm.warning({ title: 'Discard changes?' })
popconfirm.info({ title: 'Continue?' })
</script>

API ​

Props ​

PropTypeDefaultDescription
titlestring''Текст заголовка
descriptionstring''Текст описания
type'info' | 'success' | 'warning' | 'danger''info'Вариант типа (влияет на иконку и цвет кнопки подтверждения)
iconbooleantrueПоказывать иконку типа
confirmTextstring'Yes'Текст кнопки подтверждения
cancelTextstring'No'Текст кнопки отмены
showCancelbooleantrueПоказывать кнопку отмены
loadingbooleanfalseПоказать спиннер на кнопке подтверждения (предотвращает закрытие)
disabledbooleanfalseОтключить открытие popconfirm
widthstring | number280Ширина панели
gapnumber8Отступ между триггером и панелью в px
trigger'click' | 'hover''click'Способ открытия popconfirm
beforeConfirm() => boolean | Promise<boolean>—Асинхронный обработчик перед подтверждением. Верните false или выбросите ошибку, чтобы заблокировать
autoClosenumber0Автозакрытие через N миллисекунд (0 = отключено)
hideOnRouteChangebooleantrueАвтозакрытие при навигации браузера
conditionbooleantrueПри false пропускает всплывающее окно и сразу вызывает confirm

Events ​

EventPayloadDescription
confirm—Вызывается при клике на кнопку подтверждения (и если beforeConfirm пройдена)
cancel—Вызывается при клике на кнопку отмены
open—Вызывается при открытии popconfirm
close—Вызывается при закрытии popconfirm

Slots ​

SlotPropsDescription
default—Элемент-триггер
content—Пользовательское содержимое под заголовком (заменяет description)
icon—Пользовательская иконка (заменяет стандартную иконку типа)
actions{ confirm, cancel, loading }Пользовательские кнопки действий

usePopconfirm ​

ts
const popconfirm = usePopconfirm()

popconfirm(options: PopconfirmOptions | string): Promise<void>
popconfirm.info(options): Promise<void>
popconfirm.success(options): Promise<void>
popconfirm.warning(options): Promise<void>
popconfirm.danger(options): Promise<void>

PopconfirmOptions:

OptionTypeDefaultDescription
titlestring—Текст заголовка
descriptionstring—Текст описания
typePopconfirmType'info'Вариант типа
iconbooleantrueПоказывать иконку
confirmTextstring'Yes'Текст кнопки подтверждения
cancelTextstring'No'Текст кнопки отмены
showCancelbooleantrueПоказывать кнопку отмены
widthstring | number280Ширина панели
beforeConfirm() => boolean | Promise<boolean>—Асинхронный обработчик
autoClosenumber0Таймаут автозакрытия