sweetalert

WebJar for sweetalert

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

sweetalert
Последняя версия

Последняя версия

2.1.2
Дата

Дата

Тип

Тип

jar
Описание

Описание

sweetalert
WebJar for sweetalert
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/t4t5/sweetalert

Скачать sweetalert

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/sweetalert/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>sweetalert</artifactId>
    <version>2.1.2</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/sweetalert/
implementation 'org.webjars.npm:sweetalert:2.1.2'
// https://jarcasting.com/artifacts/org.webjars.npm/sweetalert/
implementation ("org.webjars.npm:sweetalert:2.1.2")
'org.webjars.npm:sweetalert:jar:2.1.2'
<dependency org="org.webjars.npm" name="sweetalert" rev="2.1.2">
  <artifact name="sweetalert" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='sweetalert', version='2.1.2')
)
libraryDependencies += "org.webjars.npm" % "sweetalert" % "2.1.2"
[org.webjars.npm/sweetalert "2.1.2"]

Зависимости

compile (2)

Идентификатор библиотеки Тип Версия
org.webjars.npm : es6-object-assign jar [1.1.0,2)
org.webjars.npm : promise-polyfill jar [6.0.2,7)

Модули Проекта

Данный проект не имеет модулей.

SweetAlert

A beautiful replacement for JavaScript's "alert"

npm version Build status

A success modal

Installation

$ npm install --save sweetalert

Usage

import swal from 'sweetalert';

swal("Hello world!");

Upgrading from 1.X

Many improvements and breaking changes have been introduced in the 2.0 release. Make sure you read the upgrade guide to avoid nasty suprises!

Guides

Documentation

Examples

An error message:

swal("Oops!", "Something went wrong!", "error");

A warning message, with a function attached to the confirm message:

  • Using promises:
swal({
  title: "Are you sure?",
  text: "Are you sure that you want to leave this page?",
  icon: "warning",
  dangerMode: true,
})
.then(willDelete => {
  if (willDelete) {
    swal("Deleted!", "Your imaginary file has been deleted!", "success");
  }
});
  • Using async/await:
const willDelete = await swal({
  title: "Are you sure?",
  text: "Are you sure that you want to delete this file?",
  icon: "warning",
  dangerMode: true,
});

if (willDelete) {
  swal("Deleted!", "Your imaginary file has been deleted!", "success");
}

A prompt modal, where the user's input is logged:

  • Using promises:
swal("Type something:", {
  content: "input",
})
.then((value) => {
  swal(`You typed: ${value}`);
});
  • Using async/await:
const value = await swal("Type something:", {
  content: "input",
});

swal(`You typed: ${value}`);

In combination with Fetch:

  • Using promises:
swal({
  text: "Wanna log some information about Bulbasaur?",
  button: {
    text: "Search!",
    closeModal: false,
  },
})
.then(willSearch => {
  if (willSearch) {
    return fetch("http://pokeapi.co/api/v2/pokemon/1");
  }
})
.then(result => result.json())
.then(json => console.log(json))
.catch(err => {
  swal("Oops!", "Seems like we couldn't fetch the info", "error");
});
  • Using async/await:
const willSearch = await swal({
  text: "Wanna log some information about Bulbasaur?",
  button: {
    text: "Search!",
    closeModal: false,
  },
});

if (willSearch) {
  try {
    const result = await fetch("http://pokeapi.co/api/v2/pokemon/1");
    const json = await result.json();
    console.log(json);
  } catch (err) {
    swal("Oops!", "Seems like we couldn't fetch the info", "error");
  }
}

Using with React

SweetAlert has tools for integrating with your favourite rendering library..

If you're using React, you can install SweetAlert with React in addition to the main library, and easily add React components to your alerts like this:

import React from 'react'
import swal from '@sweetalert/with-react'

swal(
  <div>
    <h1>Hello world!</h1>
    <p>
      This is now rendered with JSX!
    </p>
  </div>
)

Read more about integrating with React

Contributing

If you're changing the core library:

  1. Make changes in the src folder.
  2. Preview changes by running npm run docs
  3. Submit pull request

If you're changing the documentation:

  1. Make changes in the docs-src folder.
  2. Preview changes by running npm run docs
  3. Run npm run builddocs to compile the changes to the docs folder
  4. Submit pull request

Contributors

This project exists thanks to all the people who contribute. [Contribute].

Backers

Thank you to all our backers! 🙏 [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

Версии библиотеки

Версия
2.1.2
2.1.0
2.0.8
1.1.3
1.1.2
1.1.1