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

vue-confirmation-modal

v0.0.9

Published

๐Ÿš€ Simple and lightweight promise based confirmation modal.

Downloads

42

Readme

Vue Confirmation Modal

A Vue 3 plugin for easily integrating promise based confirmation modals into your application, with support for theme customization and global configuration.

Requirements

Vue version >=3.2.25

Installation

Install the package using npm:

npm install vue-confirmation-modal

Or using yarn:

yarn add vue-confirmation-modal

Setup

Add ConfirmationModal to your Vue application in your main entry file (typically main.ts or main.js):

import { createApp } from 'vue';
import App from './App.vue';
import ConfirmationModal from 'vue-confirmation-modal';
import 'vue-confirmation-modal/dist/style.css'; // import styles

const app = createApp(App);

app.use(ConfirmationModal, {
  // Global configuration options
  title: 'Are you sure?',
  animation: 'slideUp', // 'none' | 'slideUp' | 'slideDown' | 'roadRunner' | 'bounce'
  theme: 'auto' // 'auto' | 'light' | 'dark' (auto defaults to system preference)
});

app.mount('#app');

Usage

Use the confirmationModal object to display a modal. The show method returns a promise that resolves to true if the user confirms or false if the user rejects or closes the modal.

<script setup lang="ts">
  import { confirmationModal } from 'vue-confirmation-modal';

  const handleDelete = async () => {
    try {
      const confirmed = await confirmationModal.show({
        // these options will override default
        text: 'This action will permanently delete this record! Is it ok to proceed?',
        primaryBtnText: 'Confirm'
      });

      if (!confirmed) return;

      // your functionality goes here

      alert('Deleted successfully');
    } catch (error) {
      alert('Failed to delete');
    }
  };
</script>

<template>
  <main>
    <button @click="handleDelete">delete something</button>
  </main>
</template>

Options

You can customize the confirmation modal by providing options either globally (when adding the plugin to your app) or locally (when calling the show method). These are default options:

export const defaultOptions: Options = {
  title: 'Are you sure?',
  text: 'This action will permanently delete this record! Is it ok to proceed?',
  primaryBtnText: 'Confirm',
  theme: 'light',
  animation: 'slideUp'
};

Contributing

Contributions are welcome! Please open an issue or submit a pull request with any improvements or bug fixes.