MCPcopy
hub / github.com/t4t5/sweetalert

github.com/t4t5/sweetalert @v2.1.0 sqlite

repository ↗ · DeepWiki ↗ · release v2.1.0 ↗
2,789 symbols 5,524 edges 66 files 624 documented · 22%
README

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: javascript 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: ```javascript 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: javascript swal("Type something:", { content: "input", }) .then((value) => { swal(`You typed: ${value}`); })
  • Using async/await: ```javascript const value = await swal("Type something:", { content: "input", })

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

In combination with Fetch:

  • Using promises: javascript 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: ```javascript 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") } } ```

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

Extension points exported contracts — how you extend this code

SweetAlert (Interface)
(no doc)
src/core.ts
SwalState (Interface)
(no doc)
src/modules/state.ts
SweetAlert (Interface)
(no doc)
typings/core.d.ts
SwalState (Interface)
(no doc)
typings/modules/state.d.ts
ActionOptions (Interface)
(no doc)
src/modules/state.ts
ActionOptions (Interface)
(no doc)
typings/modules/state.d.ts
ClassNameList (Interface)
(no doc)
src/modules/class-list/index.ts
ClassNameList (Interface)
(no doc)
typings/modules/class-list/index.d.ts

Core symbols most depended-on inside this repo

_interopRequireDefault
called by 422
docs/assets/js/index.js
_interopRequireDefault
called by 409
docs/assets/js/add-preview-buttons.js
invariant
called by 119
docs/assets/js/index.js
_interopRequireWildcard
called by 116
docs/assets/js/add-preview-buttons.js
_interopRequireWildcard
called by 116
docs/assets/js/index.js
$$
called by 59
test/utils.ts
has
called by 59
docs/assets/js/index.js
next
called by 57
docs/assets/js/add-preview-buttons.js

Shape

Function 2,754
Interface 20
Method 13
Class 2

Languages

TypeScript100%

Modules by API surface

docs/assets/js/index.js1,510 symbols
docs/assets/js/add-preview-buttons.js1,133 symbols
docs/assets/sweetalert/sweetalert.min.js24 symbols
src/modules/event-listeners.ts14 symbols
src/modules/options/index.ts9 symbols
src/modules/utils.ts7 symbols
src/modules/options/buttons.ts7 symbols
src/core.ts7 symbols
typings/core.d.ts6 symbols
src/modules/state.ts6 symbols
docs/assets/js/landing-text-rotater.js6 symbols
src/modules/init/modal.ts5 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

Dependencies from manifests, versioned

@types/jest19.2.3 · 1×
autoprefixer6.7.7 · 1×
babel-core6.24.1 · 1×
babel-loader6.4.1 · 1×
babel-plugin-transform-es2015-modules-commonjs6.24.1 · 1×
babel-plugin-transform-runtime6.23.0 · 1×
babel-preset-env1.4.0 · 1×
babel-preset-es20156.24.1 · 1×
babel-preset-react6.24.1 · 1×
babel-standalone6.26.0 · 1×
babelify6.0.2 · 1×
browserify9.0.8 · 1×

For agents

$ claude mcp add sweetalert \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact