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-element-dialog

v1.0.5

Published

An imperative call to the el-dialog component in element-ui based on [email protected]

Downloads

9

Readme

vue-element-dialog

npm build status download

Provides an imperative call to the el-dialog component in element-ui based on [email protected].

Install

npm i vue-element-dialog element-ui
# or pnpm
pnpm add vue-element-dialog element-ui

Usage

Register

import Vue from 'vue' // [email protected]
import ElementUI from 'element-ui'
import VueElementDialog from 'vue-element-dialog'
import 'element-ui/lib/theme-chalk/index.css'

Vue.use(ElementUI)
Vue.use(VueElementDialog, { center: true })

Invoking

App.vue:

<template>
  <div id="app">
    <el-button type="primary" @click="onOpen">onOpen</el-button>
  </div>
</template>

<script>
import YourComponent from 'path/to/YourComponent.vue'

export default {
  name: 'App',

  methods: {
    onOpen() {
      this.$dialog(
        // Your component will be shown in the default slot of the el-dialog component.
        YourComponent,
        // props and events configuration for the el-dialog component
        {
          // props
          visible: true,
          title: 'Your Title',
          // events
          opened() {
            console.log('has opened...')
          }
        }
      )
        .then((value) => {
          console.log(value)  // Follow or Like
        })
    }
  }
}
</script>

YourComponent.vue:

<template>
  <el-main>
    <h1>Hi</h1>
    <div>
      <el-button type="primary" @click="onLike">Like</el-button>
      <el-button type="primary" @click="onFollow">Follow</el-button>
    </div>
  </el-main>
</template>

<script>
export default {
  name: 'YourComponent',

  props: {
    msg: String
  },
  methods: {
    onLike() {
      this.$emit('close', 'Like')
    },
    onFollow() {
      this.$emit('close', 'Follow')
    }
  }
}
</script>

Options

Supports all of the props, events and slots defined on the el-dialog component.

slots

There are three ways of defining slots to be chosen from.

  1. Directly passes your component, which will be shown in the default slot. e.g.
this.$dialog(MainComponent)
  1. Provides an object where each key-value pair represents a slot supported by el-dialog. e.g.
this.$dialog({
  default: MainComponent,
  title: TitleComponent,
  footer: FooterComponent
})
  1. Similar to the second way, it supports the components that have the props`` option and need the props` data. e.g.
this.$dialog({
  default: {
    component: MainComponent,
    propsData: {
      msg: 'Follow and Like it.'
    }
  }
})

props and events

The second parameter is used to configure all of the props and events supported by el-dialog. e.g.

this.$dialog(YourComponent, {
  // props
  visible: true,
  title: 'your title',
  // events
  opened() {
    console.log('has opened...')
  }
})

Injected Event

This plugin will inject a called close event into your component passed to the el-dialog. You can call it to close the current opened dialog and pass some values. The eventual state of the promise returned by calling this.$dialog will become resolved when calling the close event, so you will be able to access the values passed to the close event.

Note that due to the limitations of the resolve method, the type of the resolved value will vary depending on the number of arguments you pass to this $emit('close', ...). The value is undefined if you don't pass anything. The value is the argument itself if you pass one. The value is an array of arguments if you pass more than one. e.g.

this.$emit('close') // the value is `undefined`
this.$emit('close', { foo: 1 }) // the value is `{ foo: 1 }`
this.$emit('close', 'Follow', { number: 99 }) // the value is `['Follow', { number: 99 }]`

License

MIT