본문으로 건너뛰기

Alert Dialog ​

Alert Dialog는 되돌릴 수 없는 동작을 실행하기 전에 사용자의 확인을 받기 위해 화면 중앙에 표시되는 모달입니다. 주로 삭제, 초기화, 권한 해제처럼 실수했을 때 되돌리기 어려운 작업에 사용됩니다. 배경을 눌러도 닫히지 않아 사용자가 취소와 확인 중 하나를 직접 고르도록 합니다.

State ​

Code ​

vue
<script setup>
import { ref } from 'vue'
import { AAlertDialog, AButton } from '@mobigen/rnd-design-system'

const open = ref(false)

function onConfirm() {
  // 확인 후 처리
}
</script>

<template>
  <AButton variant="secondary" @click="open = true">Open Alert Dialog</AButton>
  <AAlertDialog
    v-model="open"
    title="삭제하시겠습니까?"
    description="이 작업은 되돌릴 수 없습니다."
    cancel-text="취소"
    confirm-text="삭제"
    @confirm="onConfirm"
  />
</template>

처리가 끝날 때까지 대화상자 안에 진행 상태를 보이려면 close-on-confirm 을 끄고 loading 을 연결합니다. 처리가 끝나면 호출부가 직접 닫습니다.

vue
<script setup>
import { ref } from 'vue'
import { AAlertDialog, AButton } from '@mobigen/rnd-design-system'

const open = ref(false)
const deleting = ref(false)

async function onConfirm() {
  deleting.value = true
  try {
    await deleteReport() // 실제 삭제 요청
    open.value = false
  } catch (e) {
    // 실패하면 창을 열어 둔 채 오류를 알린다
  } finally {
    deleting.value = false
  }
}
</script>

<template>
  <AButton variant="danger" @click="open = true">삭제</AButton>
  <AAlertDialog
    v-model="open"
    title="'월간 보고서'를 삭제할까요?"
    description="삭제한 보고서는 되돌릴 수 없습니다."
    cancel-text="취소"
    confirm-text="삭제"
    confirm-variant="danger"
    :close-on-confirm="false"
    :loading="deleting"
    @confirm="onConfirm"
  />
</template>

Props ​

속성값
modelValuetrue, false
titleString
descriptionString
cancelTextString
confirmTextString
widthString
confirmVariantprimary, danger
loadingtrue, false
closeOnConfirmtrue, false (기본 true)

Events ​

이벤트전달 값
update:modelValuefalse
cancel없음
confirm없음

Slots ​

슬롯전달 값
default없음

Notes ​

  • 기본 문구(정말 진행할까요?, 계속 등)는 어떤 동작인지 알려 주지 않는다. title, description, confirmText에 실제 동작("데이터셋 삭제")을 넣는다.
  • 기본(closeOnConfirm 참)은 확인을 누르면 update:modelValue(false) 와 confirm 을 함께 보내 바로 닫힌다.
  • closeOnConfirm 이 거짓이면 confirm 만 보낸다. 처리가 끝나면 호출부가 v-model 을 false 로 바꿔 닫는다.
  • loading 이 참이면 확인 버튼이 회전 아이콘을 보이며 클릭을 받지 않고, 취소 버튼과 Escape 닫기도 막힌다. 처리가 실패해도 loading 을 거짓으로 되돌려야 사용자가 창을 닫을 수 있다.