2023-10-28 13:59:59 +00:00
|
|
|
<template>
|
|
|
|
<DocSectionText v-bind="$attrs">
|
|
|
|
<p>Headless mode is enabled by defining a <i>container</i> slot that lets you implement entire confirmation UI instead of the default elements.</p>
|
|
|
|
</DocSectionText>
|
|
|
|
<ConfirmDialog group="headless">
|
2023-10-31 13:03:45 +00:00
|
|
|
<template #container="{ message, acceptCallback, rejectCallback }">
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="flex flex-col items-center p-8 bg-surface-0 dark:bg-surface-900 rounded">
|
|
|
|
<div class="rounded-full bg-primary text-primary-contrast inline-flex justify-center items-center h-24 w-24 -mt-20">
|
2023-10-28 13:59:59 +00:00
|
|
|
<i class="pi pi-question text-5xl"></i>
|
|
|
|
</div>
|
2024-05-20 12:14:38 +00:00
|
|
|
<span class="font-bold text-2xl block mb-2 mt-6">{{ message.header }}</span>
|
2023-10-28 13:59:59 +00:00
|
|
|
<p class="mb-0">{{ message.message }}</p>
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="flex items-center gap-2 mt-6">
|
|
|
|
<Button label="Save" @click="acceptCallback" class="w-32"></Button>
|
|
|
|
<Button label="Cancel" outlined @click="rejectCallback" class="w-32"></Button>
|
2023-10-28 13:59:59 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</ConfirmDialog>
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="card flex justify-center">
|
2024-01-24 06:54:02 +00:00
|
|
|
<Button @click="requireConfirmation()" label="Save"></Button>
|
2023-10-28 13:59:59 +00:00
|
|
|
</div>
|
|
|
|
<DocSectionCode :code="code" />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
code: {
|
|
|
|
basic: `
|
|
|
|
<ConfirmDialog group="headless">
|
2023-10-31 13:03:45 +00:00
|
|
|
<template #container="{ message, acceptCallback, rejectCallback }">
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="flex flex-col items-center p-8 bg-surface-0 dark:bg-surface-900 rounded">
|
|
|
|
<div class="rounded-full bg-primary text-primary-contrast inline-flex justify-center items-center h-24 w-24 -mt-20">
|
2023-10-28 13:59:59 +00:00
|
|
|
<i class="pi pi-question text-5xl"></i>
|
|
|
|
</div>
|
2024-05-20 12:14:38 +00:00
|
|
|
<span class="font-bold text-2xl block mb-2 mt-6">{{ message.header }}</span>
|
2023-10-28 13:59:59 +00:00
|
|
|
<p class="mb-0">{{ message.message }}</p>
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="flex items-center gap-2 mt-6">
|
|
|
|
<Button label="Save" @click="acceptCallback" class="w-32"></Button>
|
|
|
|
<Button label="Cancel" outlined @click="rejectCallback" class="w-32"></Button>
|
2023-10-28 13:59:59 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</ConfirmDialog>
|
2024-01-24 06:54:02 +00:00
|
|
|
<Button @click="requireConfirmation()" label="Save"></Button>
|
2023-10-28 13:59:59 +00:00
|
|
|
`,
|
|
|
|
options: `
|
|
|
|
<template>
|
|
|
|
<ConfirmDialog group="headless">
|
2023-10-31 13:03:45 +00:00
|
|
|
<template #container="{ message, acceptCallback, rejectCallback }">
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="flex flex-col items-center p-8 bg-surface-0 dark:bg-surface-900 rounded">
|
|
|
|
<div class="rounded-full bg-primary text-primary-contrast inline-flex justify-center items-center h-24 w-24 -mt-20">
|
2023-10-28 13:59:59 +00:00
|
|
|
<i class="pi pi-question text-5xl"></i>
|
|
|
|
</div>
|
2024-05-20 12:14:38 +00:00
|
|
|
<span class="font-bold text-2xl block mb-2 mt-6">{{ message.header }}</span>
|
2023-10-28 13:59:59 +00:00
|
|
|
<p class="mb-0">{{ message.message }}</p>
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="flex items-center gap-2 mt-6">
|
|
|
|
<Button label="Save" @click="acceptCallback" class="w-32"></Button>
|
|
|
|
<Button label="Cancel" outlined @click="rejectCallback" class="w-32"></Button>
|
2023-10-28 13:59:59 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</ConfirmDialog>
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="card flex justify-center">
|
2024-01-24 06:54:02 +00:00
|
|
|
<Button @click="requireConfirmation()" label="Save"></Button>
|
2023-10-28 13:59:59 +00:00
|
|
|
</div>
|
|
|
|
<Toast />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
methods: {
|
|
|
|
requireConfirmation() {
|
|
|
|
this.$confirm.require({
|
|
|
|
group: 'headless',
|
|
|
|
header: 'Are you sure?',
|
|
|
|
message: 'Please confirm to proceed.',
|
|
|
|
accept: () => {
|
|
|
|
this.$toast.add({ severity: 'info', summary: 'Confirmed', detail: 'You have accepted', life: 3000 });
|
|
|
|
},
|
|
|
|
reject: () => {
|
|
|
|
this.$toast.add({ severity: 'error', summary: 'Rejected', detail: 'You have rejected', life: 3000 });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
<\/script>
|
|
|
|
`,
|
|
|
|
composition: `
|
|
|
|
<template>
|
|
|
|
<ConfirmDialog group="headless">
|
2023-10-31 13:03:45 +00:00
|
|
|
<template #container="{ message, acceptCallback, rejectCallback }">
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="flex flex-col items-center p-8 bg-surface-0 dark:bg-surface-900 rounded">
|
|
|
|
<div class="rounded-full bg-primary text-primary-contrast inline-flex justify-center items-center h-24 w-24 -mt-20">
|
2023-10-28 13:59:59 +00:00
|
|
|
<i class="pi pi-question text-5xl"></i>
|
|
|
|
</div>
|
2024-05-20 12:14:38 +00:00
|
|
|
<span class="font-bold text-2xl block mb-2 mt-6">{{ message.header }}</span>
|
2023-10-28 13:59:59 +00:00
|
|
|
<p class="mb-0">{{ message.message }}</p>
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="flex items-center gap-2 mt-6">
|
2023-10-31 13:03:45 +00:00
|
|
|
<Button label="Save" @click="acceptCallback"></Button>
|
|
|
|
<Button label="Cancel" outlined @click="rejectCallback"></Button>
|
2023-10-28 13:59:59 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</ConfirmDialog>
|
2024-05-20 12:14:38 +00:00
|
|
|
<div class="card flex justify-center">
|
2024-01-24 06:54:02 +00:00
|
|
|
<Button @click="requireConfirmation()" label="Save"></Button>
|
2023-10-28 13:59:59 +00:00
|
|
|
</div>
|
|
|
|
<Toast />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
import { useConfirm } from "primevue/useconfirm";
|
|
|
|
import { useToast } from "primevue/usetoast";
|
|
|
|
|
|
|
|
const confirm = useConfirm();
|
|
|
|
const toast = useToast();
|
|
|
|
|
|
|
|
const requireConfirmation = () => {
|
|
|
|
confirm.require({
|
|
|
|
group: 'headless',
|
|
|
|
header: 'Are you sure?',
|
|
|
|
message: 'Please confirm to proceed.',
|
|
|
|
accept: () => {
|
|
|
|
toast.add({ severity: 'info', summary: 'Confirmed', detail: 'You have accepted', life: 3000 });
|
|
|
|
},
|
|
|
|
reject: () => {
|
|
|
|
toast.add({ severity: 'error', summary: 'Rejected', detail: 'You have rejected', life: 3000 });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
<\/script>
|
|
|
|
`
|
|
|
|
}
|
|
|
|
};
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
requireConfirmation() {
|
|
|
|
this.$confirm.require({
|
|
|
|
group: 'headless',
|
|
|
|
header: 'Are you sure?',
|
|
|
|
message: 'Please confirm to proceed.',
|
|
|
|
accept: () => {
|
|
|
|
this.$toast.add({ severity: 'info', summary: 'Confirmed', detail: 'You have accepted', life: 3000 });
|
|
|
|
},
|
|
|
|
reject: () => {
|
|
|
|
this.$toast.add({ severity: 'error', summary: 'Rejected', detail: 'You have rejected', life: 3000 });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|