npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

v-dialogs

v3.0.3

Published

A simple style useful dialog component collection for Vue3

Downloads

858

Readme

v-dialogs

CircleCI code coverage npm version license npm

A simple style useful dialog component collection for Vue3

  • Alert Interactive dialog boxes, for notifications that require explicit feedback from the user
  • Modal Modal container dialog, It is displayed at the center of the screen
  • Drawer Another modal container dialog, It is displayed at the edge of the screen, and it is the better choice for quickly viewing details
  • Message Silent message notification, displayed in the vertical center area of ​​the screen
  • Toast Silent message notification, displayed in the corner of the screen
  • Mask A screen mask that blocks user actions

If you are using vue 2.x version, please use v-dialogs 2.x version instead

Examples and Documentation

Documentation and examples please visit below sites

Features

  • Simple style, makes it easier to apply in more UI
  • Provides 6 types of dialogs: Modal, Drawer, Alert, Message, Mask and Toast
  • Functional form of use
  • Modal and Drawer provide DialogModalBox and DialogDrawerBox component form
  • Alert, Message and Toast types provides message type quick access function
  • Built-in 4 languages: Chinese, English, Japanese and Portuguese
  • Globally instance(not recommended)

Installation

# npm
npm i v-dialogs
# yarn
yarn add v-dialogs
# pnpm
pnpm add v-dialogs

API

type MessageContent = string | VNode
type ComponentResult = VNode | Component
type ComponentContent = ComponentResult | (() => ComponentResult)

function DialogAlert(message?: MessageContent, callback?: Function, options?: AlertOptions): Function
function DialogMessage(message?: MessageContent, callback?: Function, options?: MessageOptions): Function
function DialogToast(message?: MessageContent, callback?: Function, options?: ToastOptions): Function
function DialogMask(message?: MessageContent, callback?: Function, options?: MaskOptions): Function
function DialogModal(component: ComponentContent, options?: ModalOptions): Function
function DialogDrawer(component: ComponentContent, options?: DrawerOptions): Function

Usage

Confirm and Message

import { DialogAlert, DialogMessage } from 'v-dialogs'

function deleteUser (userId) {
  DialogAlert('Deleted data cannot be recovered, are you sure?', () => {
    executeDeleteUser(userId).then(() => {
      DialogMessage('Delete complete.', { messageType: 'success' })
    })
  }, { messageType: 'confirm' })
}

Modal dialog

import { DialogModal, DialogAlert } from 'v-dialogs'
import UserProfile from './UserProfile.vue'

DialogModal(UserProfile, {
  width: 900,
  height: 600,
  title: 'User Profile',
  params: {
    userId: 1,
    userName: 'Terry Zeng'
  },
  callback: data => {
    DialogAlert(`Received message: ${data}`)
  }
})

Component form

<template>
  <div>
    <DialogDrawerBox v-model:visible="visible" >
      <UserProfile />
    </DialogDrawerBox>

    <button
      type="button"
      @click="openDialog"
    >Open Drawer</button>
  </div>
</template>

<script setup>
import { ref } from 'vue'
import { DialogDrawerBox } from 'v-dialogs'

import UserProfile from './UserProfile.vue'

const visible = ref(false)

function openDialog () {
  visible.value = true
}
</script>

Fetch data

import { DialogMask, DialogMessage, DialogAlert } from 'v-dialogs'

function loadDataList () {
  const destroy = DialogMask()

  fetchData()
    .then(data => {
      list.value = data.list
      // Dismiss mask overlay
      destroy()
      DialogMessage('Data loaded successfully', { messageType: 'success' })
    })
    .catch(() => {
      DialogAlert('Data Load Failure', { messageType: 'error' })
    })
}

Message type quick access

Alert, Message and Toast types provides message type quick access function

import {
  DialogMessage
  DialogMessageSuccess
} from 'v-dialogs'

DialogMessageSuccess('Saved successfully!')
// Equivalent to
DialogMessage('Saved successfully!', { messageType: 'success' })

Globally instance

v-dialogs also provides a globally instance to open dialogs, you can use it in any component

The default instance name is $dlg

import { createApp } from 'vue'
import dialogs from 'v-dialogs'
import App from 'App.vue'

createApp(App).use(dialogs).mount('#app')

The global instance are only supported as a feature and are not recommended for use

Option API

export default {
  mounted () {
    this.$dlg.message('Saved successfully!')
  }
}

Composition API

import { getCurrentInstance } from 'vue'

// const $dlg = getCurrentInstance().appContext.config.globalProperties.$dlg
const $dlg = getCurrentInstance().proxy.$dlg

$dlg.message('Saved successfully!')