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 }">
|
2023-10-28 13:59:59 +00:00
|
|
|
<div class="flex flex-column align-items-center p-5 surface-overlay border-round">
|
|
|
|
<div class="border-circle bg-primary inline-flex justify-content-center align-items-center h-6rem w-6rem -mt-8">
|
|
|
|
<i class="pi pi-question text-5xl"></i>
|
|
|
|
</div>
|
|
|
|
<span class="font-bold text-2xl block mb-2 mt-4">{{ message.header }}</span>
|
|
|
|
<p class="mb-0">{{ message.message }}</p>
|
|
|
|
<div class="flex align-items-center gap-2 mt-4">
|
2023-10-31 13:03:45 +00:00
|
|
|
<Button label="Save" @click="acceptCallback" class="w-8rem"></Button>
|
|
|
|
<Button label="Cancel" outlined @click="rejectCallback" class="w-8rem"></Button>
|
2023-10-28 13:59:59 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</ConfirmDialog>
|
|
|
|
<div class="card flex justify-content-center">
|
|
|
|
<Button @click="requireConfirmation()" icon="pi pi-check" label="Confirm"></Button>
|
|
|
|
</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 }">
|
2023-10-28 13:59:59 +00:00
|
|
|
<div class="flex flex-column align-items-center p-5 surface-overlay border-round">
|
|
|
|
<div class="border-circle bg-primary inline-flex justify-content-center align-items-center h-6rem w-6rem -mt-8">
|
|
|
|
<i class="pi pi-question text-5xl"></i>
|
|
|
|
</div>
|
|
|
|
<span class="font-bold text-2xl block mb-2 mt-4">{{ message.header }}</span>
|
|
|
|
<p class="mb-0">{{ message.message }}</p>
|
|
|
|
<div class="flex align-items-center gap-2 mt-4">
|
2023-10-31 13:03:45 +00:00
|
|
|
<Button label="Save" @click="acceptCallback" class="w-8rem"></Button>
|
|
|
|
<Button label="Cancel" outlined @click="rejectCallback" class="w-8rem"></Button>
|
2023-10-28 13:59:59 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</ConfirmDialog>
|
|
|
|
<Button @click="requireConfirmation()" icon="pi pi-check" label="Confirm"></Button>
|
|
|
|
`,
|
|
|
|
options: `
|
|
|
|
<template>
|
|
|
|
<ConfirmDialog group="headless">
|
2023-10-31 13:03:45 +00:00
|
|
|
<template #container="{ message, acceptCallback, rejectCallback }">
|
2023-10-28 13:59:59 +00:00
|
|
|
<div class="flex flex-column align-items-center p-5 surface-overlay border-round">
|
|
|
|
<div class="border-circle bg-primary inline-flex justify-content-center align-items-center h-6rem w-6rem -mt-8">
|
|
|
|
<i class="pi pi-question text-5xl"></i>
|
|
|
|
</div>
|
|
|
|
<span class="font-bold text-2xl block mb-2 mt-4">{{ message.header }}</span>
|
|
|
|
<p class="mb-0">{{ message.message }}</p>
|
|
|
|
<div class="flex align-items-center gap-2 mt-4">
|
2023-10-31 13:03:45 +00:00
|
|
|
<Button label="Save" @click="acceptCallback" class="w-8rem"></Button>
|
|
|
|
<Button label="Cancel" outlined @click="rejectCallback" class="w-8rem"></Button>
|
2023-10-28 13:59:59 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</ConfirmDialog>
|
|
|
|
<div class="card flex justify-content-center">
|
|
|
|
<Button @click="requireConfirmation()" icon="pi pi-check" label="Confirm"></Button>
|
|
|
|
</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 }">
|
2023-10-28 13:59:59 +00:00
|
|
|
<div class="flex flex-column align-items-center p-5 surface-overlay border-round">
|
|
|
|
<div class="border-circle bg-primary inline-flex justify-content-center align-items-center h-6rem w-6rem -mt-8">
|
|
|
|
<i class="pi pi-question text-5xl"></i>
|
|
|
|
</div>
|
|
|
|
<span class="font-bold text-2xl block mb-2 mt-4">{{ message.header }}</span>
|
|
|
|
<p class="mb-0">{{ message.message }}</p>
|
|
|
|
<div class="flex align-items-center gap-2 mt-4">
|
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>
|
|
|
|
<div class="card flex justify-content-center">
|
|
|
|
<Button @click="requireConfirmation()" icon="pi pi-check" label="Confirm"></Button>
|
|
|
|
</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>
|