157 lines
6.3 KiB
Vue
157 lines
6.3 KiB
Vue
<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">
|
|
<template #container="{ message, onAccept, onReject }">
|
|
<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">
|
|
<Button label="Save" @click="onAccept" class="w-8rem"></Button>
|
|
<Button label="Cancel" outlined @click="onReject" class="w-8rem"></Button>
|
|
</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">
|
|
<template #container="{ message, onAccept, onReject }">
|
|
<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">
|
|
<Button label="Save" @click="onAccept" class="w-8rem"></Button>
|
|
<Button label="Cancel" outlined @click="onReject" class="w-8rem"></Button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</ConfirmDialog>
|
|
<Button @click="requireConfirmation()" icon="pi pi-check" label="Confirm"></Button>
|
|
`,
|
|
options: `
|
|
<template>
|
|
<ConfirmDialog group="headless">
|
|
<template #container="{ message, onAccept, onReject }">
|
|
<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">
|
|
<Button label="Save" @click="onAccept" class="w-8rem"></Button>
|
|
<Button label="Cancel" outlined @click="onReject" class="w-8rem"></Button>
|
|
</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">
|
|
<template #container="{ message, onAccept, onReject }">
|
|
<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">
|
|
<Button label="Save" @click="onAccept"></Button>
|
|
<Button label="Cancel" outlined @click="onReject"></Button>
|
|
</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>
|