Line data Source code
1 16 : <template>
2 28 : <section class="flex w-full flex-wrap items-center justify-end gap-4 p-4">
3 : <Button
4 : :disabled
5 : variant="muted-textonly"
6 : size="lg"
7 : autofocus
8 : @click="settle('cancel')"
9 : >
10 : {{ cancelText }}
11 : </Button>
12 : <Button
13 : :disabled
14 : :variant="confirmVariant ?? 'textonly'"
15 : size="lg"
16 : :class="confirmClass"
17 : @click="settle('confirm')"
18 : >
19 : {{ confirmText }}
20 : </Button>
21 : </section>
22 : </template>
23 : <script setup lang="ts">
24 : import { computed, ref, toValue } from 'vue'
25 : import type { MaybeRefOrGetter } from 'vue'
26 :
27 : import Button from '@comfyorg/design-system/button/Button'
28 : import type { ButtonVariants } from '@comfyorg/design-system/button.variants'
29 :
30 : const {
31 : cancelText,
32 : confirmText,
33 : confirmClass,
34 : confirmVariant,
35 : optionsDisabled
36 : } = defineProps<{
37 : cancelText: string
38 : confirmText: string
39 : confirmClass?: string
40 : confirmVariant?: ButtonVariants['variant']
41 : optionsDisabled?: MaybeRefOrGetter<boolean>
42 : }>()
43 :
44 26 : const emit = defineEmits<{
45 : cancel: []
46 : confirm: []
47 : }>()
48 :
49 26 : const settled = ref(false)
50 :
51 26 : const disabled = computed(() => settled.value || toValue(optionsDisabled))
52 :
53 16 : function settle(choice: 'cancel' | 'confirm') {
54 16 : if (settled.value) return
55 16 : settled.value = true
56 16 : if (choice === 'cancel') emit('cancel')
57 5 : else emit('confirm')
58 : }
59 : </script>
|