1.0.8 • Published 15 days ago

alpinjs-dialog v1.0.8

Weekly downloads
-
License
ISC
Repository
github
Last release
15 days ago

alpinjs-dialog@1.0.8

Dialog component for Alpine.js

Authors

License

MIT

Badges

MIT License GPLv3 License AGPL License

Demo

Demo link : Click here

Git Repo

Github : Click here

Installation

Install alpinjs-dialog with npm

  npm install alpinejs gsap alpinjs-dialog
  or
  yarn add alpinejs gsap alpinjs-dialog

Usage/Examples

import :

  import Alpine from 'alpinejs';
  import dialog from "alpinjs-dialog";

  Alpine.plugin(dialog);
  Alpine.start();

USAGE

  <template x-dialog="dialogName">
    <h1>Hello Dialog</h1>
    <p>Dialog is working!</p>
  </template>
  ...
  <button @click="$dialog('dialogName').open()">Show Dialog</button>
  // or
  this.$dialog("dialogName").open({
      addClass: ["custom-class-1", "custom-class-2"], //class as array
      data: null, // pass data into dialog
      config: {
        width: "500px", // dialog width
        height: "200px", // dialog height
        position: "center", // center , left, right, top, bottom
        backdrop: true //set true click away to close
        blur: 13, //set true to blur overlay,
        animate: {
          enter: 0.2, // seconds
          leave: 0.2, // seconds
        },
      },
      props: {
        click: this.counter.bind(this), // dialog props
      },
      afterOpen: (dialog) => {
        // callback after dialog open
        console.log("after dialog opened", dialog);
      },
      beforeClose: (dialog) => {
        // callback before dialog close
        console.log("before dialog close", dialog);
      },
      afterClose: (dialog) => {
        // callback after dialog close
        console.log("after dialog closed", dialog);
      }
    });

    // get data from dialog v1.0.54 or higher
    let data = this.$dialog("dialogName").data;

    // get data from dialog v1.0.53 or lower
    let data = this.$dialog("dialogName").data();

    // close dialog
    this.$dialog("dialogName").close(/* return something after close here */);

    // close dialog with validation
    this.$dialog("dialogName").validClose(() => {
      // return true to close dialog
      return true;
    });

    //event listener
    this.$dialog("dialogName")
      .target
      .addEventListener("dialogReady", (e) => {
          // dialog is ready
          console.log("dialogReady", e.detail);
        }
      );

     this.$dialog("dialogName")
      .target
      .addEventListener("dialogClose", (e) => {
          // dialog is closed
          console.log("dialogClosed", e.detail);
        }
      );

    // props
    this.$dialog("dialogName").props.click(1);

    // static config
    <template
        x-dialog="dialogName"
        width="1000px"
        height="500px"
        position="center"
        blur="3"
        animate-enter="0.5"
        animate-leave="0.2"
      >
      ....
    </template>

API

PropertyTypeDescriptionValue
showbooleanDialog active statustrue,false
persistbooleanPersist the dialog contenttrue,false
dataanyData to be passed to the dialog
addClassstring[]Additional CSS classes to add to the dialog
addOverlayClassstring[]Additional CSS classes to add to the overlay
drawerstringDrawer element class
configobjectConfiguration options for the dialog
config.widthstringWidth of the dialog
config.heightstringHeight of the dialog
config.positionstringPosition of the dialogcenter,right,left,top,bottom
config.backdropbooleanShow backdrop or nottrue,false
config.blurnumberBlur the background or not
config.animate.enternumberAnimation duration for enter transition
config.animate.leavenumberAnimation duration for leave transition
propsobjectAdditional props to be passed to the dialog
processingbooleanIndicates if the dialog is processing or nottrue,false
afterOpenfunctionCallback function after the dialog is opened
beforeClosefunctionCallback function before the dialog is closed
afterClosefunctionCallback function after the dialog is closed
targetHTML element referenceThe dialog element
open(config = {})functionFunction to open the dialog with configuration options
close(data)functionFunction to close the dialog and pass data
dataanyGet the dialog data
rawDataanyGet a clone of the dialog data
validClose(fn)functionSet the function to validate if the dialog can be closed or not
1.0.8

15 days ago

1.0.76

28 days ago

1.0.73

1 month ago

1.0.75

30 days ago

1.0.74

1 month ago

1.0.72

4 months ago

1.0.71

4 months ago

1.0.61

6 months ago

1.0.60

6 months ago

1.0.70

6 months ago

1.0.59

6 months ago

1.0.58

1 year ago

1.0.57

1 year ago

1.0.56

1 year ago

1.0.55

1 year ago

1.0.54

1 year ago

1.0.49

1 year ago

1.0.51

1 year ago

1.0.50

1 year ago

1.0.53

1 year ago

1.0.52

1 year ago

1.0.48

1 year ago

1.0.47

1 year ago

1.0.46

1 year ago

1.0.45

1 year ago

1.0.44

1 year ago

1.0.43

1 year ago

1.0.42

1 year ago

1.0.41

1 year ago

1.0.40

1 year ago

1.0.39

1 year ago

1.0.38

1 year ago

1.0.37

1 year ago

1.0.36

1 year ago

1.0.35

1 year ago

1.0.34

1 year ago

1.0.33

1 year ago

1.0.32

1 year ago

1.0.31

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago