New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@costlydeveloper/ngx-awesome-popup

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

@costlydeveloper/ngx-awesome-popup

Gives new functionality to Angular 9+, generates beautiful popups, dialogs, ConfirmBoxes, AlertBoxes, ToastNotifications. Also gives the ability of opening dynamic components directly from typescript!

  • 0.0.1-alpha11
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
820
increased by34.65%
Maintainers
1
Weekly downloads
 
Created
Source

Logo

@costlydeveloper/ngx-awesome-popup

Downloads per month NPM Version Dependencies Contributors Maintained undefined

Gives new functionality to Angular 9+, generates beautiful popups, dialogs, ConfirmBoxes, AlertBoxes, ToastNotifications. Also gives the ability of opening dynamic components directly from typescript!
Use this popup generator to easily generate beautiful, highly scalable popups. From regular Angular component it renders dynamic component view in popup directly from typescript, including toast notifications, alert box or confirm box.


  • Well documented: Extremely simple to use - just follow the tutorials and API documentation!
  • Powerful: It uses Angular factory features - generates any component anywhere in popup without HTML selector!
  • Awesome: The tool you don't know you needed before!

-----------------------------------------------------

-----------------------------------------------------

➤ Table of Contents

-----------------------------------------------------

➤ Installation

Install the library with:

npm install @costlydeveloper/ngx-awesome-popup

Then import it in your AppModule:

import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {AppComponent} from './app.component';

// Import your library
import {ConfirmBoxConfigModule, DialogConfigModule, NgxAwesomePopupModule, ToastNotificationConfigModule} from '@costlydeveloper/ngx-awesome-popup';


@NgModule({
    declarations: [
        AppComponent
    ],
    imports     : [
        BrowserModule,

        // Importing @costlydeveloper/ngx-awesome-popup modules
        NgxAwesomePopupModule.forRoot(),
        DialogConfigModule.forRoot(),
        ConfirmBoxConfigModule.forRoot(),
        ToastNotificationConfigModule.forRoot()
    ],
    providers   : [],
    bootstrap   : [AppComponent]
})
export class AppModule {
}

API documentation:

-----------------------------------------------------

➤ Usage

Check The API Documentation for more advance setup.

Toast Notification

Simply open toast notification from any component or any custom typescript class:

import {Component, OnInit} from '@angular/core';

// import library classes
import {DialogLayoutDisplay, ToastNotificationInitializer} from '@costlydeveloper/ngx-awesome-popup';

@Component({
    selector   : 'app-root',
    templateUrl: './app.component.html',
    styleUrls  : ['./app.component.scss']
})
export class AppComponent implements OnInit {

    ngOnInit() {
        
        // Call the method
        this.toastNotification();
    }

    // Create the method
    toastNotification() {
        const newToastNotification = new ToastNotificationInitializer();
        newToastNotification.setTitle('Warning!');
        newToastNotification.setMessage('Form is not valid!');
        
        // Choose layout color type
        newToastNotification.setConfig({
            LayoutType: DialogLayoutDisplay.WARNING // SUCCESS | INFO | NONE | DANGER | WARNING
        });
        
        // Simply open the popup
        newToastNotification.openToastNotification$();
    }

}

API documentation:

Confirm Box / Alert Box

It is very easy to open Confirm Box or Alert Box from any component or any custom typescript class:

import {Component, OnInit} from '@angular/core';

// import library classes
import {DialogLayoutDisplay, ConfirmBoxInitializer} from '@costlydeveloper/ngx-awesome-popup';

@Component({
    selector   : 'app-root',
    templateUrl: './app.component.html',
    styleUrls  : ['./app.component.scss']
})
export class AppComponent implements OnInit {
    
    ngOnInit() {
    
        // Call the method
        this.confirmBox();
    }
    
    // Create the method
    confirmBox() {
        const confirmBox = new ConfirmBoxInitializer();
        confirmBox.setTitle('Are you sure?');
        confirmBox.setMessage('Confirm to delete user: John Doe!');
        confirmBox.setButtonLabels('YES', 'NO');
        
        // Choose layout color type
        confirmBox.setConfig({
            LayoutType: DialogLayoutDisplay.DANGER // SUCCESS | INFO | NONE | DANGER | WARNING
        });
        
        // Simply open the popup and listen which button is clicked
        const subscription = confirmBox.openConfirmBox$().subscribe(resp => {
            // IConfirmBoxPublicResponse
            console.log('Clicked button response: ', resp);
            subscription.unsubscribe();
        });
    }

}

API documentation:

Open any component in Dialog

Simply open any Angular component from any typescript file without HTML selector.

  • Send and receive any data with dialog dynamic component and back.
  • Set custom buttons and listen the click event inside dynamic component (AnyAngularComponent)
Setup of evoke of the dialog:
import {Component, OnInit} from '@angular/core';

// import desired angular component for DialogInitializer 
import {AnyAngularComponent} from './any-angular-component/any-angular.component';

// import library classes
import {DialogLayoutDisplay, DialogInitializer, ButtonLayoutDisplay, ButtonMaker} from '@costlydeveloper/ngx-awesome-popup';

@Component({
    selector   : 'app-root',
    templateUrl: './app.component.html',
    styleUrls  : ['./app.component.scss']
})
export class AppComponent implements OnInit {

    ngOnInit() {
        
        // Call the method.
        this.dialog();
    }

    // Create the method.
    dialog() {
        
        // Instance of DialogInitializer includes any valid angular component as argument.
        const dialogPopup = new DialogInitializer(AnyAngularComponent);
        
        // Any data can be sent to AnyAngularComponent.
        dialogPopup.setCustomData({name: 'John', surname: 'Doe', id: 1});
        
        // Set some configuration.
        dialogPopup.setConfig({
            Width     : '500px',
            LayoutType: DialogLayoutDisplay.NONE // SUCCESS | INFO | NONE | DANGER | WARNING
        });
        
        // Set some custom buttons as list.
        // SUCCESS | INFO | NONE | DANGER | WARNING | PRIMARY | SECONDARY | LINK | DARK | LIGHT
        dialogPopup.setButtons([
            new ButtonMaker('Edit', 'edit', ButtonLayoutDisplay.WARNING), 
            new ButtonMaker('Submit', 'submit', ButtonLayoutDisplay.SUCCESS),
            new ButtonMaker('Cancel', 'cancel', ButtonLayoutDisplay.SECONDARY)
        ]);
    
        // Simply open the popup and listen which button is clicked and, 
        // receive optional payload from AnyAngularComponent.
        const subscription = dialogPopup.openDialog$().subscribe(resp => {
            // IDialogPublicResponse
            console.log('dialog response: ', resp);
            subscription.unsubscribe();
        });
    }

}

API documentation:

Setup of child-dynamic component that is rendered in dialog:

The child dynamic component represents AnyAngularComponent from example above.

import { Component, OnInit, OnDestroy } from '@angular/core';
import {Subscription} from 'rxjs';
import {DialogBelonging} from '@costlydeveloper/ngx-awesome-popup';

@Component({
    selector: 'app-any-angular-component',
    templateUrl: './any-angular.component.html',
    styleUrls: ['./any-angular.component.scss']
})
export class AnyAngularComponent implements OnInit, OnDestroy{
    
    subscriptions: Subscription[] = [];
    
    // Dependency Injection of the dialogBelonging in constructor is crucial.
    constructor(private dialogBelonging: DialogBelonging) {}
    
    ngOnInit(): void {
        // Check recived data and other available features.
        console.log(this.dialogBelonging);
        
        // Subscribe to button listeners.
        this.subscriptions.push(
            // IDialogEventsController
            this.dialogBelonging.EventsController.onButtonClick$.subscribe((_Button) => {
                if (_Button.ID === 'edit') {
                    
                    // Do some logic for example edit user.
                } else if (_Button.ID === 'submit') {
                    
                    // Do some logic and close popup.
                    this.dialogBelonging.EventsController.close();
                }
                else if (_Button.ID === 'cancel') {
                    
                    // Do some logic and close popup.
                    this.dialogBelonging.EventsController.close();
                }
            })
        );
        
        // Timeout emulates asyinc data.
        setTimeout(() => {
            
            // Close the loader after some data is ready.
            // IDialogEventsController
            this.dialogBelonging.EventsController.closeLoader();
        }, 1000);
    }
    
    ngOnDestroy(): void {
        
        // Care about memory and close all subscriptions.
        this.subscriptions.forEach(sub => sub.unsubscribe());
    }
}

API documentation:

-----------------------------------------------------

➤ License

Licensed under MIT.

Keywords

FAQs

Package last updated on 02 May 2021

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