Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mcwv/dialog

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mcwv/dialog

The Vue Material Adapter for the web dialog component

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Usage

<mdc-button raised @click="open=!open">Show dialog</mdc-button>
<mdc-dialog v-model="open" accept-raised
  title="Title" accept="Accept" cancel="Decline"
  @accept="onAccept" @cancel="onDecline">
  {{ dialogText }}
</mdc-dialog>
var vm = new Vue({
  data: {
    dialogText: 'Lorem ipsum dolor sit amet, ...',
    open: false,
  },
  methods: {
    onAccept() {
      console.log('accepted');
    },
    onDecline() {
      console.log('declined');
    },
  },
});

props

propsTypeDefaultDescription
openBooleanfalseoptional v-model when true opens dialog
titleStringundefinedthe dialog title
acceptString'Ok'the dialog accept button text
accept-disabledBooleanfalsedisable the accept button
accept-raisedBooleanfalsedisplay accept button as raised
cancelStringundefinedthe dialog cancel button text
cancel-raisedBooleanfalsedisplay cancel button as raised
scrollableBooleanfalsewhether the dialog is scrollable
accentBooleanfalseset accented style to the footer buttons

In order to hide the Dialog Footer, force the accept property to ""

events

propsargsDescription
@changeBooleannotify v-model/listeners that drawer state has changed.
@acceptnoneemitted when dialog is accepted
@cancelnoneemitted when dialog is cancelled
@validateacceptemitted before the dialog is accepted (*)
@validateCancelcancelemitted before the dialog is cancelled (*)

Note that if you listen to the @validate or @validateCancel events, then You must call the accept or cancel argument to finally close the box. Use accept(false) to prevent emitting the accept event and just close, and cancel(false) to prevent emitting the cancel event.

Custom validation logic

You can use the accept-disabled property to prevent the dialog to close when the accept button is clicked.

<mdc-dialog ref="dialog" title="Dialog" accept="Accept" cancel="Decline"
  :accept-disabled="isThisNotAcceptable"
>Lorem ipsum dolor sit amet</mdc-dialog>

Or use the @validate event to trigger your own validation logic as follow:

<mdc-dialog ref="dialog" title="Dialog" accept="Accept" cancel="Decline"
  @validate="onValidate"
>Lorem ipsum dolor sit amet</mdc-dialog>
export default {
  methods: {
    onValidate({ accept }) {
      let isValid = false;
      // custom validation logic here
      // ..
      if (isValid) {
        accept();
      }
    },
  },
};

You can use @validateCancel to trigger validation logic for the cancel event, as follows:

<mdc-dialog ref="dialog" title="Dialog" accept="Accept" cancel="Decline"
  @validateCancel="onValidateCancel"
>Lorem ipsum dolor sit amet</mdc-dialog>
export default {
  methods: {
    onValidateCancel({ cancel }) {
      let isValid = false;
      // custom validation logic here
      // ..
      if (isValid) {
        cancel();
      }
    },
  },
};

Reference

https://material.io/components/web/catalog/dialogs

Keywords

FAQs

Package last updated on 10 Mar 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc