v-slim-dialog

Vue Dialog
6,454 12
Install
npm install v-slim-dialog
Latest Version:0.0.10
License:MIT
Last Updated:Dec 8, 2022
Links: GitHub  ·  npm
Maintainer: dflourusso

v-slim-dialog

Slim Dialog for Vuejs

Installation

yarn add v-slim-dialog
# Or using npm
npm install v-slim-dialog --save

Usage

import Vue from 'vue'

import 'v-slim-dialog/dist/v-slim-dialog.css'
import SlimDialog from 'v-slim-dialog'

Vue.use(SlimDialog)

Options params

Name Type Required Default value Info
title String No Title of modal
okLabel String No OK Label of button OK
cancelLabel String No Cancel Label of button cancel
size String('sm'or'lg') No Size of modal
prompt Object No Hash for prompt {value: '', invalidMessage: 'invalid!', component: VueComponent}

In your component

alert

//...
methods: {
  /**
   * @param String message
   * @param Object options default { title, okLabel = 'OK', size }
   */
  showAlert() {
    const options = {title: 'Info', size: 'sm'}
    this.$dialogs.alert('Your message', options)
    .then(res => {
      console.log(res) // {ok: true|false|undefined}
    })
  }
}
//...

confirm

//...
methods: {
  /**
   * @param String message
   * @param Object options default { title, cancelLabel = 'Cancel', okLabel = 'OK', size }
   */
  showConfirm() {
    const options = {title: 'Confirm?', cancelLabel: 'No'}
    this.$dialogs.confirm('Your message!', options)
    .then(res => {
      console.log(res) // {ok: true|false|undefined}
    })
  }

}
//...

prompt

//...
methods: {
  /**
   * @param String message
   * @param Object options default { title, okLabel = 'OK', size, prompt }
   */
  showPrompt() {
    const options = {title: 'Continue?', okLabel: 'Continue'}
    this.$dialogs.prompt('Your message!', options)
    .then(res => {
      console.log(res) // {value: 'user input', ok: true|false|undefined}
    })

    // with custom input prompt
    const options = {title: 'Continue?', prompt: {component: 'cpf-cnpj'}}
    this.$dialogs.prompt('Your message!', options)
    .then(res => {
      console.log(res) // {value: 'user input', ok: true|false|undefined}
    })

    // or
    import YourComponent from './YourComponent'
    const options = {title: 'Continue?', prompt: {component: YourComponent}}
    this.$dialogs.prompt('Your message!', options)
    .then(res => {
      console.log(res) // {value: 'user input', ok: true|false|undefined}
    })

  }

}
//...

Sample custom prompt Component

This is the default component if you do not report

<template>
  <input v-model='model'>
</template>

<script>
export default {
  props: {
    value: [Number, String]
  },

  computed: {
    model: {
      get() {
        return this.value
      },
      set(v) {
        this.$emit('input', v)
      }
    }
  },
  methods: {
    isValid() {
      return Boolean(String(this.model).trim())
    }
  },
  mounted() {
    this.$el.focus()
  }
}
</script>

Development

# install dependencies
yarn install

# build with minification
yarn release

# publish
bin/publish

Related Packages

vue-simple-alert

Simple alert(), confirm(), prompt() for Vue.js, using sweetalert2.

84,981 131
vue3-simple-alert

Simple alert(), confirm(), prompt() for Vue.js version 3, using sweetalert2.

46,518 10
vue3-simple-alert-next

Simple alert(), confirm(), prompt() for Vue.js version 3, using sweetalert2.

9,653 1
vuetify-dialog

Dialog helper for vuetify.js

87,446 192

Version History

Version Released License
0.0.10 MIT
0.0.9 MIT
0.0.8 MIT
0.0.7 MIT
0.0.6 MIT