2.1.0 • Published 2 years ago

vuetify3-confirm-dialog v2.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

vuetify3-confirm-dialog

Simple Confirm Dialog verification plugin with VueJS 3 and Vuetify 3.

Demo: https://demo.tandd.dev/vuetify3-confirm-dialog/

Install

$ npm install --save vuetify3-confirm-dialog

Or

$ yarn add vuetify3-confirm-dialog

Quick Start Usage

In main.js or plugin (for Nuxt.js):

import {createApp} from 'vue'
import App from './App.vue'
// Vuetify
import 'vuetify/styles'
import {createVuetify} from 'vuetify'
import * as components from 'vuetify/components'
import * as directives from 'vuetify/directives'

const vuetify = createVuetify({
    components,
    directives,
})

import Vuetify3ConfirmDialog from 'vuetify3-confirm-dialog'

createApp(App).use(vuetify).use(Vuetify3ConfirmDialog).mount('#app')

In App.vue (or in the template file for Nuxt.js (layout/default.vue)):

<template>
    <div id="app">
        <vuetify3-confirm-dialog/>
        <!-- your code -->
    </div>
</template>

<script>
    export default {
        name: 'app'
    }
</script>

In any of functions :

methods: {
    handleClick()
    {
        this.$confirmDialog(
            {
                title  : "Confirm",
                message: "Are you sure?",
                button : {
                    no : 'No',
                    yes: 'Yes'
                },
                /**
                 * Callback Function
                 * @param {Boolean} confirm
                 */
                callback: confirm => {
                    if (confirm) {
                        console.log(confirm)
                        // Do something
                    }
                }
            }
        )
    }
}

If you want to use in *.js file (e.g Vuex Store) before import Vue and after use Vue.\$confirmDialog.

import Vue from 'vue'

export default {
    namespaced: true,
    state     : {},
    actions   : {
        logout({commit}) {
            Vue.$confirmDialog({
                title   : 'Are you sure?',
                message : 'Are you sure you want to logout?',
                button  : {
                    yes: 'Yes',
                    no : 'Cancel'
                },
                callback: confirm => {
                    // ...do something
                }
            })
        }
    }
}

Props

NameTypeDefaultDescription
persistentbooleanfalseClicking outside of the element or pressing esc key will not deactivate it.
transitionStringfade-transitionSets the component transition. Can be one of the built in or custom transition.
widthString I NumberautoSet the width for the component.
min-widthString I NumberautoSet the min-width for the component.
max-widthString I NumberautoSet the max-width for the component.
z-indexString I Number2400The z-index used for the component
title-classString'bg-blue'The card title class.
content-classStringThe card body class.
actions-classStringThe card actions class.
variant-button'flat' I 'text' I 'elevated' I 'tonal' I 'outlined' I 'plain''outlined'Applies a distinct style to the component
no-button-classStringThe class for "no" button.
yes-button-classStringThe class for "yes" button.
no-button-colorStringThe color for "no" button.
yes-button-colorString'blue'The color for "yes" button.

Use only for information

If you want to use only for information, and you want of see one button in dialog, you can use only one of 'no' or 'yes' button object.

methods: {
    handleClick()
    {
        this.$confirmDialog(
            {
                title  : "Confirm",
                message: "Are you sure?",
                button : {
                    yes: 'Yes'
                },
                /**
                 * Callback Function
                 * @param {Boolean} confirm
                 */
                callback: confirm => {
                    if (confirm) {
                        console.log(confirm)
                        // Do something
                    }
                }
            }
        )
    }
}
2.1.0

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago