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

ngx-mat-alert-confirm

v10.0.2

Published

A highly customizable library for alerts and confirm messages using angular material components

Downloads

144

Readme

ngx-mat-alert-confirm

Compatible with Angular 7+

Compatibility

|Angular Version|Ngx-Mat-Alert-Confirm Version| |--|--| | v7.x.x | v7.0.0 | | v8.x.x | v8.0.1 | | v9.x.x | v9.0.1 | | v10.x.x | v10.0.2 |

Demo

https://ankit1329.github.io/ngx-mat-alert-confirm/

toaster.png confirm-dialog.png

ToDo

  • Add form fields with validations in confirm box dialogs.

Dependencies

  • Angular Material (peer dependency)
  • (npm i @angular/[email protected] --save) (peer dependency) @angular/animations version matching projects angular version. If project is running on angular 7.3.3, use angular animation version 7.3.3. (No need if animations were enabled while adding angular material)
  • (npm i angular-animations) (bundled dependency, no need to install) https://github.com/filipows/angular-animations.

Getting Started

Install

npm i ngx-mat-alert-confirm --save

Import NgxMatAlertConfirmModule and NgxMatAlertConfirmService

import {
  NgxMatAlertConfirmModule,
  NgxMatAlertConfirmService,
} from 'ngx-mat-alert-confirm';

Add NgxMatAlertConfirmModule to imports and NgxMatAlertConfirmService to providers

 imports: [
    BrowserModule,
    NgxMatAlertConfirmModule
  ],
 providers: [NgxMatAlertConfirmService],

Usage

In your component, import service and the config interfaces:

import {
	AlertServiceService,
	ToasterConfig, 
	ConfirmConfig, 
	ConfirmButtonConfig
} from 'ngx-mat-alert-confirm';

Inject the service in your component's constructor private alertConfirmService: NgxMatAlertConfirmService

Toaster Config

Available config options:

let toasterConfig: ToasterConfig = {
	title: 'Toaster',
	titleSize: 16,
	message: 'This is a sample toaster!',
	messageSize: 14,
	duration: 5000,
	horizontalPosition: 'right',
	verticlePosition: 'top',
	width: 0,
	backgroundColor: 'white',
	textColor: '',
	matIcon: '',
	iconColor: '',
	showProgressBar: true,
	progressBarColor: undefined,
	progressBarType: undefined,
	pauseProgressBarOnHover: true,
	closeOnClick: true,
	showCloseButton: true,
	closeButtonColor: undefined,
	showActionButton: false,
	actionButtonText: '',
	actionButtonColor: undefined
}

Note: Only Title is compulsory, rest configs are optional.

Basic usage of toaster:

let toasterRef = this.alertService.toaster(this.toasterConfig);

toasterRef.afterDismissed().subscribe(() => {
	console.log('The toaster was dismissed!');
});

toasterRef.onAction().subscribe(() => {
	console.log('Toaster action button was clicked!');
});

Confirm Box Config

Available config options:

confirmConfig: ConfirmConfig = {
	title: 'Are You Sure?',
	titleSize: 28,
	message: 'This action cannot be reversed!',
	messageSize: 16,
	matIcon: 'access_alarm',
	iconAnimation: 'shake',
	iconColor: '',
	buttons: [],
	disableClose: true,
	autoFocus: true,
	restoreFocus: true,
	width: undefined
}

buttonArr: Array < ConfirmButtonConfig > = [{
	id: 'default',
	text: 'OK',
	color: 'primary',
	type: 'basic',
	icon: ''
}]

Note: Only Title is compulsory, rest configs are optional.

Basic Usage of Confirm Alerts

//Assign buttons in the confirmConfig
this.confirmConfig.buttons = this.buttonArr;

const dialogueRef = this.alertService.confirm(this.confirmConfig);

dialogueRef.afterClosed().subscribe(confirmResult => {
	//confirmResult contains the id of the button clicked
	console.log(confirmResult)
});

Quick Usage Example

Both Confirm Alerts and Toasters can be given small config objects inline and events like afterDismissed, onAction, afterClosed can be left unhandled if no action is needed when toaster or confirm alert is closed by user action.

this.alertService.toaster({
	title:  "Success!",
	message:  "Boost Setting Updated.",
	matIcon:  "done_outline",
	iconColor:  'teal',
	showProgressBar:  true,
	progressBarColor:  'accent',
	duration:  5000,
	pauseProgressBarOnHover:  true
})