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

@akiltech/modal-confirm

v0.1.8

Published

Handle your modal dialog as you want without having to configure anything.

Downloads

60

Readme

Modal Confirm

Handle your modal dialog as you want without having to configure anything.

Installation

NPM (for @angular/[email protected] and higher)

$ npm install @akiltech/modal-confirm --save

YARN

$ yarn add @akiltech/modal-confirm

NPM (for @angular/[email protected] and lower)

$ npm install @akiltech/[email protected] --save

YARN

$ yarn add @akiltech/[email protected]

you must install these two libraries for the application to work properly @angular/material and [email protected]

@angular/material

$ ng add @angular/material

BOOTSTRAP

$ npm install bootstrap

OR

$ yarn add bootstrap

Configuration

import { ModalConfirmModule } from '@akiltech/modal-confirm';

@NgModule({
  declarations: [],
  imports: [ModalConfirmModule],
  providers: [],
  bootstrap: []
})
export class AppModule { }

import bootstrap styles in your styles.scss

// Bootstrap
@import "~bootstrap/scss/bootstrap";

Available Parameters

You can pass two parameters to customize your modal dialog. the first parameter must be of type ConfirmInterface and the second parameter must be of type OptionsInterface

Parameters structure

import { ConfirmInterface, OptionsInterface} from '@akiltech/modal-confirm';

export class AppComponent {

  const dialogData: ConfirmInterface {
      // here dialog data parameters...
  }

  const dialogOptions: OptionsInterface {
      // here options parameters...
  }
}

Available Methods

There are several methods to facilitate the use of a service, you should know that some methods returns an observable.

OPENDIALOG

The openDialog method allows you to open your modal dialog and you can pass or no parameters if you want.

First Parameter (Dialog datas)

| Parameter(s) | Type | Required | Description | |--------------|----------|------|--------------| | type | String | none | Define a modal dialog type (SUCCESS, DANGER, WARNING, DEFAULT) | | headerTitle | String | none | Define a modal dialog header title | | headerShown | Boolean | none | Define if header modal dialog must show | | footerShown | Boolean | none | Define if modal dialog footer must show | | iconShown | Boolean | none | Define if modal dialog icon must show | | iconName | String | none | Define a modal dialog icon name if you don't want default icon | | bodyText | String | none | Define a modal dialog body text | | childComponent | Component | none | You can decide to inject component in you modal dialog | | data | any | none | You can decide to pass datas to your incoming component | | btnYes | String | none | Define a text for your modal dialog confirm button | | btnNo | String | none | Define a text for your modal dialog cancel button |

Second Parameter (Options datas)

| Parameter(s) | Type | Required | Description | |--------------|----------|------|--------------| | size | String | none | Define a size for your modal dialog type | | disabledClose | String | none | You can disable close for you modal dialog |

CLOSEDIALOG

The closeAllDialog method allows you to close your modal dialog.

| Parameter(s) | Type | |--------------|----------| | No parameters | Void |

How to use

Basic use

import { ModalConfirmService } from '@akiltech/modal-confirm';

export class AppComponent {

  constructor(private confirmService: ModalConfirmService) {}

  openDialog () {
      this.confirmService.openDialog().subscribe(dialog => {
        if (dialog) {
          console.log('Do something here');
        } else {
          console.log('Do something here');
        }
      })
  }
}

Advanced use

import { CONFIRMATION_TYPE, ConfirmInterface, ModalConfirmService, OptionsInterface } from '@akiltech/modal-confirm';

export class AppComponent {

  constructor(private confirmService: ModalConfirmService) {}

  const dialogData: ConfirmInterface = {
      type: CONFIRMATION_TYPE.DANGER, // Modal confirm type
      headerShown: false, // if you don't want to show header
      iconShown: false, // if you don't want to show dialog icon
      footerShown: false, // if you don't want to show footer
      headerTitle: 'Your header title',
      iconName: 'your icon name', // if you don't want to use default icon
      bodyText: 'Here body text',
      childComponent: YourComponent, // if you want to inject component
      data: { id: 1, title: 'data title' } // Example of data you can pass to your incoming component
      btnYes: 'Confirm btn label',
      btnNo: 'Cancel btn label'
  };

  const dialogOptions: OptionsInterface = {
      size: '800', // Modal dialog size
      disabledClose: true // you can disable or no dialog closure
  } 

  openDialog () {
      this.confirmService.openDialog(dialogData, dialogOptions).subscribe(dialog => {
        if (dialog) {
          console.log('Do something here');
        } else {
          console.log('Do something here');
        }
      })
  }
}

Notice

  • If you want to inject component to your modal dialog, you must add it to entryComponents
import { ModalConfirmModule } from '@akiltech/modal-confirm';

@NgModule({
  declarations: [],
  imports: [ModalConfirmModule],
  providers: [],
  entryComponents: [YourInjectedComponent],
  bootstrap: [],
})
export class AppModule { }
  • If you decide to inject component, you can't use bodyText parameter again.
  • If you want to pass data to your injected component. use the @Input decorator to get the data conten.
@Component()
export class YourInjectedComponent {

  // Gets incoming data
  @Input() data: any;
}

See demo

  • https://github.com/devsanogo/modal-confirm