阶段性提交

This commit is contained in:
GoEdgeLab
2020-07-22 22:19:39 +08:00
parent cc971be504
commit b984b68089
143 changed files with 22667 additions and 37 deletions

View File

@@ -0,0 +1,13 @@
/**
* 一级菜单
*/
Vue.component("first-menu", {
template: ' \
<div class="first-menu"> \
<div class="ui menu text blue small">\
<slot></slot>\
</div> \
<div class="ui divider"></div> \
<div class="margin"></div> \
</div>'
});

View File

@@ -0,0 +1,7 @@
Vue.component("labeled-input", {
props: ["name", "size", "maxlength", "label", "value"],
template: '<div class="ui input right labeled"> \
<input type="text" :name="name" :size="size" :maxlength="maxlength" :value="value"/>\
<span class="ui label">{{label}}</span>\
</div>'
});

View File

@@ -0,0 +1,23 @@
/**
* 菜单项
*/
Vue.component("menu-item", {
props: ["href", "active", "code"],
data: function () {
var active = this.active;
if (typeof(active) =="undefined") {
var itemCode = "";
if (typeof (window.TEA.ACTION.data.firstMenuItem) != "undefined") {
itemCode = window.TEA.ACTION.data.firstMenuItem;
}
active = (itemCode == this.code);
}
return {
vHref: (this.href == null) ? "" : this.href,
vActive: active
};
},
template: '\
<a :href="vHref" class="item" :class="{active:vActive}"><slot></slot></a> \
'
});

View File

@@ -0,0 +1,19 @@
/**
* 更多选项
*/
Vue.component("more-options-indicator", {
data: function () {
return {
visible: false
};
},
methods: {
changeVisible: function () {
this.visible = !this.visible;
if (Tea.Vue != null) {
Tea.Vue.moreOptionsVisible = this.visible;
}
}
},
template: '<a href="" style="font-weight: normal" @click.prevent="changeVisible()">更多选项 <i class="icon angle" :class="{down:!visible, up:visible}"></i> </a>'
});

View File

@@ -0,0 +1,12 @@
/**
* 二级菜单
*/
Vue.component("second-menu", {
template: ' \
<div class="second-menu"> \
<div class="ui menu text blue small">\
<slot></slot>\
</div> \
<div class="ui divider"></div> \
</div>'
});

View File

@@ -0,0 +1,6 @@
/**
* 保存按钮
*/
Vue.component("submit-btn", {
template: '<button class="ui button primary" type="submit"><slot>保存</slot></button>'
});

View File

@@ -0,0 +1,77 @@
Vue.component("values-box", {
props: ["values", "size", "maxlength", "name"],
data: function () {
let values = this.values;
if (typeof (values) != "object") {
values = [];
}
return {
"vValues": values,
"isUpdating": false,
"isAdding": false,
"index": 0,
"value": ""
}
},
methods: {
create: function () {
this.isAdding = true;
var that = this;
setTimeout(function () {
that.$refs.value.focus();
}, 200);
},
update: function (index) {
this.cancel()
this.isUpdating = true;
this.index = index;
this.value = this.vValues[index];
var that = this;
setTimeout(function () {
that.$refs.value.focus();
}, 200);
},
confirm: function () {
if (this.isUpdating) {
Vue.set(this.vValues, this.index, this.value);
} else {
this.vValues.push(this.value);
}
this.cancel();
},
remove: function (index) {
this.vValues.$remove(index);
},
cancel: function () {
this.isUpdating = false;
this.isAdding = false;
this.value = "";
}
},
template: '<div>\
<div style="margin-bottom: 1em" v-if="vValues.length > 0">\
<div class="ui label tiny" v-for="(value, index) in vValues" style="margin-top:0.4em;margin-bottom:0.4em">{{value}}\
<input type="hidden" :name="name" :value="value"/>\
&nbsp; <a href="" @click.prevent="update(index)" title="修改"><i class="icon pencil small" ></i></a> \
<a href="" @click.prevent="remove(index)" title="删除"><i class="icon remove"></i></a> \
</div> \
</div> \
<!-- 添加|修改 -->\
<div v-if="isAdding || isUpdating">\
<div class="ui fields inline">\
<div class="ui field">\
<input type="text" :size="size" :maxlength="maxlength" v-model="value" ref="value" @keyup.enter="confirm()" @keypress.enter.prevent="1"/>\
</div> \
<div class="ui field">\
<button class="ui button small" type="button" @click.prevent="confirm()">确定</button> \
</div>\
<div class="ui field">\
<a href="" @click.prevent="cancel()">取消</a> \
</div> \
</div> \
</div> \
<div v-if="!isAdding && !isUpdating">\
<button class="ui button small" type="button" @click.prevent="create()">+</button> \
</div>\
</div>'
});

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2014 Tristan Edwards & Limon Monte
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,258 @@
<p align="center">
<a href="https://github.com/sponsors/limonte">[== Become the :trophy: Ultimate Sponsor of SweetAlert2 and place your banner here (100K+ unique visitors per month!) ==]</a>
</p>
<p align="center">
<a href="https://sweetalert2.github.io/">
<img src="/assets/swal2-logo.png" alt="SweetAlert2">
</a>
</p>
<p align="center">
A beautiful, responsive, customizable, accessible (WAI-ARIA) replacement for JavaScript's popup boxes. Zero dependencies.
</p>
<p align="center">
<a href="https://sweetalert2.github.io/">
<img src="https://raw.github.com/sweetalert2/sweetalert2/master/assets/sweetalert2.gif" width="562"><br>
See SweetAlert2 in action ↗
</a>
</p>
<p align="center">
<a href="https://github.com/sweetalert2/sweetalert2/actions"><img alt="Build Status" src="https://github.com/sweetalert2/sweetalert2/workflows/build/badge.svg"></a>
<a href="https://codeclimate.com/github/sweetalert2/sweetalert2/test_coverage"><img alt="Coverage Status" src="https://api.codeclimate.com/v1/badges/eba34bb80477933854d4/test_coverage"></a>
<a href="https://www.npmjs.com/package/sweetalert2"><img alt="Version" src="https://img.shields.io/npm/v/sweetalert2.svg"></a>
<a href="https://www.jsdelivr.com/package/npm/sweetalert2"><img alt="jsdelivr" src="https://data.jsdelivr.com/v1/package/npm/sweetalert2/badge?style=rounded"></a>
<a href="#support-and-donations"><img alt="Support Donate" src="https://ionicabizau.github.io/badges/paypal.svg"></a>
</p>
---
:shipit: The author of SweetAlert2 ([@limonte](https://github.com/limonte/)) is looking for short-term to medium-term working contracts in front-end, preferably OSS.
---
:point_right: **Upgrading from v8.x to v9.x?** [Read the release notes!](https://github.com/sweetalert2/sweetalert2/releases/tag/v9.0.0)
<br>If you're upgrading from v7.x, please [upgrade from v7 to v8](https://github.com/sweetalert2/sweetalert2/releases/tag/v8.0.0) first!
<br>If you're upgrading from v6.x, please [upgrade from v6 to v7](https://github.com/sweetalert2/sweetalert2/releases/tag/v7.0.0) first!
:point_right: **Migrating from [SweetAlert](https://github.com/t4t5/sweetalert)?** [SweetAlert 1.x to SweetAlert2 migration guide](https://github.com/sweetalert2/sweetalert2/wiki/Migration-from-SweetAlert-to-SweetAlert2)
---
Installation
------------
```sh
npm install --save sweetalert2
```
Or grab from [jsdelivr CDN](https://www.jsdelivr.com/package/npm/sweetalert2)
:
```html
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@9"></script>
```
Usage
-----
```html
<script src="sweetalert2/dist/sweetalert2.all.min.js"></script>
<!-- Include a polyfill for ES6 Promises (optional) for IE11 -->
<script src="https://cdn.jsdelivr.net/npm/promise-polyfill9/dist/polyfill.js"></script>
```
You can also include the stylesheet separately if desired:
```html
<script src="sweetalert2/dist/sweetalert2.min.js"></script>
<link rel="stylesheet" href="sweetalert2/dist/sweetalert2.min.css">
```
Or:
```js
// ES6 Modules or TypeScript
import Swal from 'sweetalert2'
// CommonJS
const Swal = require('sweetalert2')
```
Or with JS modules:
```html
<link rel="stylesheet" href="sweetalert2/dist/sweetalert2.css">
<script type="module">
import Swal from 'sweetalert2/src/sweetalert2.js'
</script>
```
It's possible to import JS and CSS separately, e.g. if you need to customize styles:
```js
import Swal from 'sweetalert2/dist/sweetalert2.js'
import 'sweetalert2/src/sweetalert2.scss'
```
Please note that [TypeScript is well-supported](https://github.com/sweetalert2/sweetalert2/blob/master/sweetalert2.d.ts), so you don't have to install a third-party declaration file.
Examples
--------
The most basic message:
```js
Swal.fire('Hello world!')
```
A message signaling an error:
```js
Swal.fire('Oops...', 'Something went wrong!', 'error')
```
Handling the result of SweetAlert2 modal:
```js
Swal.fire({
title: 'Are you sure?',
text: 'You will not be able to recover this imaginary file!',
icon: 'warning',
showCancelButton: true,
confirmButtonText: 'Yes, delete it!',
cancelButtonText: 'No, keep it'
}).then((result) => {
if (result.value) {
Swal.fire(
'Deleted!',
'Your imaginary file has been deleted.',
'success'
)
// For more information about handling dismissals please visit
// https://sweetalert2.github.io/#handling-dismissals
} else if (result.dismiss === Swal.DismissReason.cancel) {
Swal.fire(
'Cancelled',
'Your imaginary file is safe :)',
'error'
)
}
})
```
## [Go here to see the docs and more examples ↗](https://sweetalert2.github.io/)
Browser compatibility
---------------------
IE11* | Edge | Chrome | Firefox | Safari | Opera | UC Browser
-------|------|--------|---------|--------|-------|------------
:heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
\* ES6 Promise polyfill should be included, see [usage example](#usage).
Note that SweetAlert2 **does not** and **will not** provide support or functionality of any kind on IE10 and lower.
Themes ([`sweetalert2-themes ↗`](https://github.com/sweetalert2/sweetalert2-themes))
------
- [`Dark`](https://github.com/sweetalert2/sweetalert2-themes/tree/master/dark)
- [`Minimal`](https://github.com/sweetalert2/sweetalert2-themes/tree/master/minimal)
- [`Borderless`](https://github.com/sweetalert2/sweetalert2-themes/tree/master/borderless)
- [`Bootstrap 4`](https://github.com/sweetalert2/sweetalert2-themes/tree/master/bootstrap-4)
- [`Material UI`](https://github.com/sweetalert2/sweetalert2-themes/tree/master/material-ui)
- [`Default`](https://github.com/sweetalert2/sweetalert2-themes/tree/master/default)
Related projects
-------------------------
- [ngx-sweetalert2](https://github.com/sweetalert2/ngx-sweetalert2) - Angular 4+ integration
- [sweetalert2-react-content](https://github.com/sweetalert2/sweetalert2-react-content) - React integration
- [sweetalert2-webpack-demo](https://github.com/sweetalert2/sweetalert2-webpack-demo) - webpack demo
- [sweetalert2-parcel-demo](https://github.com/sweetalert2/sweetalert2-parcel-demo) - overriding SCSS variables demo
Related community projects
-------------------------
- [avil13/vue-sweetalert2](https://github.com/avil13/vue-sweetalert2) - Vue.js wrapper
- [realrashid/sweet-alert](https://github.com/realrashid/sweet-alert) - Laravel 5 Package
- [Basaingeal/Razor.SweetAlert2](https://github.com/Basaingeal/Razor.SweetAlert2) - Blazor Wrapper
- [ElectronAlert](https://electron.guide/electron-alert/) - SweetAlert2 for Electron applications (main process)
Collaborators
-------------
[![](https://avatars3.githubusercontent.com/u/17089396?v=4&s=80)](https://github.com/gverni) | [![](https://avatars3.githubusercontent.com/u/3198597?v=4&s=80)](https://github.com/zenflow) | [![](https://avatars1.githubusercontent.com/u/1343250?v=4&s=80)](https://github.com/toverux)
-|-|-
[@gverni](https://github.com/gverni) | [@zenflow](https://github.com/zenflow) | [@toverux](https://github.com/toverux)
Contributing
------------
[![Maintainability](https://api.codeclimate.com/v1/badges/eba34bb80477933854d4/maintainability)](https://codeclimate.com/github/sweetalert2/sweetalert2/maintainability)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/sweetalert2/sweetalert2/blob/master/CHANGELOG.md)
If you would like to contribute enhancements or fixes, please do the following:
1. Fork the `sweetalert2` repository and clone it locally.
2. Make sure you have [npm](https://www.npmjs.com/) or [yarn](https://yarnpkg.com/) installed.
3. When in the SweetAlert2 directory, run `npm install` or `yarn install` to install dependencies.
4. To begin active development, run `npm start` or `yarn start`. This does several things for you:
- Builds the `dist` folder
- Serves sandbox.html @ http://localhost:8080/ (browser-sync ui: http://localhost:8081/)
- Re-builds and re-loads as necessary when files change
Big Thanks
----------
- [Serena Verni (@serenaperora)](https://serena.verni.xyz) for creating the amazing project logo
- [Sauce Labs](https://saucelabs.com/) for providing the reliable cross-browser testing platform
Sponsors
--------
[<img src="https://sweetalert2.github.io/images/sponsors/flowcrypt-banner.png">](https://flowcrypt.com/?utm_source=sweetalert2&utm_medium=banner)
[<img src="https://sweetalert2.github.io/images/plus.png" width="80">](SPONSORS.md) | [<img src="https://avatars2.githubusercontent.com/u/28631236?s=80&v=4" width="80">](https://flowcrypt.com/?utm_source=sweetalert2&utm_medium=logo) | [<img src="https://sweetalert2.github.io/images/sponsors/wp-reset.png" width="80">](https://wpreset.com/?utm_source=sweetalert2&utm_medium=logo) | [<img src="https://sweetalert2.github.io/images/sponsors/sebaebc.png" width="80">](https://github.com/sebaebc) | [<img src="https://sweetalert2.github.io/images/sponsors/lapaklein.png" width="80">](https://lapakle.in/?utm_source=sweetalert2&utm_medium=logo) |
-|-|-|-|-
[Become a sponsor](SPONSORS.md) | [FlowCrypt](https://flowcrypt.com/?utm_source=sweetalert2&utm_medium=logo) | [WP Reset](https://wpreset.com/?utm_source=sweetalert2&utm_medium=logo) | [SebaEBC](https://github.com/sebaebc) | [Lapakle](https://lapakle.in/)
NSFW Sponsors
-------------
[<img src="https://sweetalert2.github.io/images/sponsors/sexualalpha.jpg" width="80">](https://sexualalpha.com/?utm_source=sweetalert2&utm_medium=logo) | [<img src="https://sweetalert2.github.io/images/sponsors/sex-toy-education.png" width="80">](https://sextoyeducation.com/?utm_source=sweetalert2&utm_medium=logo) | [<img src="https://sweetalert2.github.io/images/sponsors/yourdoll.jpg" width="80">](https://www.yourdoll.com/?utm_source=sweetalert2&utm_medium=logo) | [<img src="https://sweetalert2.github.io/images/sponsors/sextoycollective.jpg" width="80">](https://sextoycollective.com/?utm_source=sweetalert2&utm_medium=logo) | [<img src="https://sweetalert2.github.io/images/sponsors/bingato.png" width="80">](https://bingato.com/?utm_source=sweetalert2&utm_medium=logo) | [<img src="https://sweetalert2.github.io/images/sponsors/realsexdoll.png" width="80">](https://realsexdoll.com/?utm_source=sweetalert2&utm_medium=logo)| [<img src="https://sweetalert2.github.io/images/sponsors/doctorclimax.png" width="80">](https://doctorclimax.com/)
-|-|-|-|-|-|-
[SexualAlpha](https://sexualalpha.com/?utm_source=sweetalert2&utm_medium=logo) | [STED](https://sextoyeducation.com/?utm_source=sweetalert2&utm_medium=logo) | [YourDoll](https://www.yourdoll.com/?utm_source=sweetalert2&utm_medium=logo) | [STC](https://sextoycollective.com/?utm_source=sweetalert2&utm_medium=logo) | [Bingato](https://bingato.com/?utm_source=sweetalert2&utm_medium=logo) | [RealSexDoll](https://realsexdoll.com/?utm_source=sweetalert2&utm_medium=logo) | [DoctorClimax](https://doctorclimax.com/)
Support and Donations
---------------------
Has SweetAlert2 helped you create an amazing application? You can show your support by making a donation:
- [GitHub Sponsors :heart:](https://github.com/sponsors/limonte)
- PayPal: [USD (US$)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=UW5EA4KTHM4B6) | [EUR (€)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=TKTWHJGUWLR7E) | [JPY (¥)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FE4JP23V88G3C) | [GBP (£)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QJ3KEXBUHCL3C) | [AUD (A$)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SG3T6NCCQFYE2) | [CAD (C$)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4SB64A93A7VZ8) | [CHF (CHF)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=UGHWAA7MRH7MQ) | [HKD (HK$)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=CPZP4SJAFZKAU) | [NZD (NZ$)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=F42C5XL3M3JCQ) | [SEK (kr)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=GRRZTRQLA4NWL) | [SGD (S$)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=386ALCBUUFXES) | [NOK (kr)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XFPKPQDZWFKAW) | [MXN ($)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=WSXP62LE49PPN) | [RUB (₽)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=98BDRFSZAPV3Q) | [BRL (R$)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=LYFEH4N33DHQC) | [TWD (NT$)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=5HL8BJ97RRANU) | [DKK (kr)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=T7RD9MRR3MXTG) | [PLN (zł)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SHAUMPM36UNP6)
- [PayPal.me](https://www.paypal.me/limonte)
- Bitcoin: `16Z7RvFv7PsV3XzFvchYwPnRfw9KeLTZQJ`
- Ether: `0x192096161eB2273f12b1cB4E31aBB09Bfc03a7F3`
- Bitcoin Cash: `qz28x66hrljtdz3052p8ya3cmkwwva5avy0msz2ej3`
- Stellar: `GDUM4VJZYDNRHBTKUQBOPC374AP6MMMVOJDMSHIPEJPEMBCY4ZHH6NDY`
### [Hall of Donators :trophy:](DONATIONS.md)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,108 @@
{
"name": "sweetalert2",
"version": "9.10.2",
"repository": "sweetalert2/sweetalert2",
"homepage": "https://sweetalert2.github.io/",
"description": "A beautiful, responsive, customizable and accessible (WAI-ARIA) replacement for JavaScript's popup boxes, supported fork of sweetalert",
"main": "dist/sweetalert2.all.js",
"browser": "dist/sweetalert2.all.js",
"module": "src/sweetalert2.js",
"types": "sweetalert2.d.ts",
"devDependencies": {
"@babel/core": "^7.2.2",
"@babel/plugin-transform-object-assign": "^7.2.0",
"@babel/preset-env": "^7.3.1",
"@cypress/code-coverage": "^1.10.4",
"@rollup/plugin-json": "^4.0.2",
"@sweetalert2/eslint-config": "^1.0.0",
"@sweetalert2/execute": "^1.0.0",
"@sweetalert2/stylelint-config": "^1.1.5",
"babel-loader": "^8.0.4",
"babel-plugin-array-includes": "^2.0.3",
"browser-sync": "^2.26.3",
"custom-event-polyfill": "^1.0.6",
"cypress": "^4.0.1",
"eslint": "^6.0.0",
"eslint-plugin-cypress": "^2.8.1",
"gulp": "^4.0.0",
"gulp-autoprefixer": "^7.0.0",
"gulp-clean-css": "^4.0.0",
"gulp-concat": "^2.6.1",
"gulp-css2js": "^1.1.2",
"gulp-if": "^3.0.0",
"gulp-rename": "^2.0.0",
"gulp-rollup": "^2.16.2",
"gulp-uglify": "^3.0.0",
"istanbul-lib-coverage": "^3.0.0",
"jquery": "^3.3.1",
"karma": "^4.0.0",
"karma-chrome-launcher": "^3.0.0",
"karma-firefox-launcher": "^1.1.0",
"karma-ie-launcher": "^1.0.0",
"karma-qunit": "^4.0.0",
"karma-sauce-launcher": "^2.0.2",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "^0.0.32",
"karma-webpack": "^4.0.0",
"merge2": "^1.2.3",
"nyc": "^15.0.0",
"promise-polyfill": "^8.1.0",
"qunit": "^2.8.0",
"replace-in-file": "^5.0.2",
"rollup": "^2.0.0",
"rollup-plugin-babel": "^4.3.2",
"sass": "^1.22.1",
"sinon": "^9.0.0",
"stylelint": "^13.0.0",
"typescript": "^3.5.0",
"webpack": "^4.29.0"
},
"files": [
"dist",
"src",
"sweetalert2.d.ts"
],
"bundlewatch": {
"files": [
{
"path": "dist/sweetalert2.all.min.js",
"maxSize": "20kB"
}
]
},
"author": "Limon Monte <limon.monte@gmail.com> (https://limonte.github.io)",
"contributors": [
"Giuseppe Verni (https://github.com/gverni)",
"Matthew Francis Brunetti <zenflow87@gmail.com> (https://github.com/zenflow)",
"Morgan Touverey-Quilling <mtouverey@alembic-dev.com> (https://github.com/toverux)",
"Sam Turrell <sam@samturrell.co.uk> (https://github.com/samturrell)",
"Joseph Schultz (https://github.com/acupajoe)",
"Johan Fagerberg (https://github.com/birjolaxew)"
],
"keywords": [
"sweetalert",
"sweetalert2",
"alert",
"modal",
"popup",
"prompt",
"confirm",
"toast",
"accessible"
],
"scripts": {
"start": "gulp develop --continue-on-error --skip-minification --skip-standalone",
"lint": "stylelint src && eslint src test cypress tools *.js *.ts",
"build": "gulp build",
"nyc:instrument": "nyc instrument --compact=false src src_instrumented && rm -rf src && mv src_instrumented src",
"cy:start": "cypress open",
"cy:run": "cypress run --browser chrome --config supportFile=cypress/support/ci.js",
"cy:run:headless": "cypress run --headless --browser chrome --config supportFile=cypress/support/ci.js",
"test": "karma start karma.conf.js --single-run"
},
"funding": {
"url": "https://sweetalert2.github.io/#donations"
},
"bugs": "https://github.com/sweetalert2/sweetalert2/issues",
"license": "MIT"
}

View File

@@ -0,0 +1,980 @@
declare module 'sweetalert2' {
/**
* A namespace inside the default function, containing utility function for controlling the currently-displayed
* popup.
*
* Example:
* ```
* Swal.fire('Hey user!', 'I don\'t like you.', 'warning');
*
* if(Swal.isVisible()) { // instant regret
* Swal.close();
* }
* ```
*/
namespace Swal {
/**
* Function to display a simple SweetAlert2 popup.
*
* Example:
* ```
* Swal.fire('The Internet?', 'That thing is still around?', 'question');
* ```
*/
function fire(title?: string, html?: string, icon?: SweetAlertIcon): Promise<SweetAlertResult>;
/**
* Function to display a SweetAlert2 popup, with an object of options, all being optional.
* See the `SweetAlertOptions` interface for the list of accepted fields and values.
*
* Example:
* ```
* Swal.fire({
* title: 'Auto close alert!',
* text: 'I will close in 2 seconds.',
* timer: 2000
* })
* ```
*/
function fire(options: SweetAlertOptions): Promise<SweetAlertResult>;
/**
* Reuse configuration by creating a `Swal` instance.
*
* Example:
* ```
* const Toast = Swal.mixin({
* toast: true,
* position: 'top-end',
* timer: 3000,
* timerProgressBar: true
* })
* Toast.fire('Something interesting happened', '', 'info')
* ```
*
* @param options the default options to set for this instance.
*/
function mixin(options?: SweetAlertOptions): typeof Swal;
/**
* Determines if a popup is shown.
*/
function isVisible(): boolean;
/**
* Updates popup options.
* See the `SweetAlertOptions` interface for the list of accepted fields and values.
*
* Example:
* ```
* Swal.update({
* icon: 'error'
* })
* ```
*/
function update(options: SweetAlertOptions): void;
/**
* Closes the currently open SweetAlert2 popup programmatically.
*
* @param result The promise originally returned by `Swal.fire()` will be resolved with this value.
* If no object is given, the promise is resolved with an empty `SweetAlertResult` object.
*/
function close(result?: SweetAlertResult): void;
/**
* Gets the popup.
*/
function getPopup(): HTMLElement;
/**
* Gets the popup title.
*/
function getTitle(): HTMLElement;
/**
* Gets the popup header.
*/
function getHeader(): HTMLElement;
/**
* Gets progress steps.
*/
function getProgressSteps(): HTMLElement;
/**
* Gets the popup content.
*/
function getContent(): HTMLElement;
/**
* Gets the DOM element where the `html`/`text` parameter is rendered to.
*/
function getHtmlContainer(): HTMLElement;
/**
* Gets the image.
*/
function getImage(): HTMLElement;
/**
* Gets the close button.
*/
function getCloseButton(): HTMLElement;
/**
* Gets the current visible icon.
*/
function getIcon(): HTMLElement | null;
/**
* Gets all icons. The current visible icon will have `style="display: flex"`,
* all other will be hidden by `style="display: none"`.
*/
function getIcons(): HTMLElement[];
/**
* Gets the "Confirm" button.
*/
function getConfirmButton(): HTMLElement;
/**
* Gets the "Cancel" button.
*/
function getCancelButton(): HTMLElement;
/**
* Gets actions (buttons) wrapper.
*/
function getActions(): HTMLElement;
/**
* Gets the popup footer.
*/
function getFooter(): HTMLElement;
/**
* Gets the timer progress bar (see the `timerProgressBar` param).
*/
function getTimerProgressBar(): HTMLElement;
/**
* Gets all focusable elements in the popup.
*/
function getFocusableElements(): HTMLElement[];
/**
* Enables "Confirm" and "Cancel" buttons.
*/
function enableButtons(): void;
/**
* Disables "Confirm" and "Cancel" buttons.
*/
function disableButtons(): void;
/**
* Disables buttons and show loader. This is useful with AJAX requests.
*/
function showLoading(): void;
/**
* Enables buttons and hide loader.
*/
function hideLoading(): void;
/**
* Determines if popup is in the loading state.
*/
function isLoading(): boolean;
/**
* Clicks the "Confirm" button programmatically.
*/
function clickConfirm(): void;
/**
* Clicks the "Cancel" button programmatically.
*/
function clickCancel(): void;
/**
* Shows a validation message.
*
* @param validationMessage The validation message.
*/
function showValidationMessage(validationMessage: string): void;
/**
* Hides validation message.
*/
function resetValidationMessage(): void;
/**
* Gets the input DOM node, this method works with input parameter.
*/
function getInput(): HTMLInputElement;
/**
* Disables the popup input. A disabled input element is unusable and un-clickable.
*/
function disableInput(): void;
/**
* Enables the popup input.
*/
function enableInput(): void;
/**
* Gets the validation message container.
*/
function getValidationMessage(): HTMLElement;
/**
* If `timer` parameter is set, returns number of milliseconds of timer remained.
* Otherwise, returns undefined.
*/
function getTimerLeft(): number | undefined;
/**
* Stop timer. Returns number of milliseconds of timer remained.
* If `timer` parameter isn't set, returns `undefined`.
*/
function stopTimer(): number | undefined;
/**
* Resume timer. Returns number of milliseconds of timer remained.
* If `timer` parameter isn't set, returns `undefined`.
*/
function resumeTimer(): number | undefined;
/**
* Toggle timer. Returns number of milliseconds of timer remained.
* If `timer` parameter isn't set, returns `undefined`.
*/
function toggleTimer(): number | undefined;
/**
* Check if timer is running. Returns true if timer is running,
* and false is timer is paused / stopped.
* If `timer` parameter isn't set, returns `undefined`.
*/
function isTimerRunning(): boolean | undefined;
/**
* Increase timer. Returns number of milliseconds of an updated timer.
* If `timer` parameter isn't set, returns `undefined`.
*
* @param n The number of milliseconds to add to the currect timer
*/
function increaseTimer(n: number): number | undefined;
/**
* Provide an array of SweetAlert2 parameters to show multiple popups, one popup after another.
*
* @param steps The steps' configuration.
*/
function queue(steps: Array<SweetAlertOptions | string>): Promise<any>;
/**
* Gets the index of current popup in queue. When there's no active queue, `null` will be returned.
*/
function getQueueStep(): string | null;
/**
* Inserts a popup in the queue.
*
* @param step The step configuration (same object as in the `Swal.fire()` call).
* @param index The index to insert the step at.
* By default a popup will be added to the end of a queue.
*/
function insertQueueStep(step: SweetAlertOptions, index?: number): number;
/**
* Deletes the popup at the specified index in the queue.
*
* @param index The popup index in the queue.
*/
function deleteQueueStep(index: number): void;
/**
* Determines if a given parameter name is valid.
*
* @param paramName The parameter to check
*/
function isValidParameter(paramName: string): boolean;
/**
* Determines if a given parameter name is valid for `Swal.update()` method.
*
* @param paramName The parameter to check
*/
function isUpdatableParameter(paramName: string): boolean;
/**
* Normalizes the arguments you can give to Swal.fire() in an object of type SweetAlertOptions.
*
* Example:
* ```
* Swal.argsToParams(['title', 'text']); //=> { title: 'title', text: 'text' }
* Swal.argsToParams({ title: 'title', text: 'text' }); //=> { title: 'title', text: 'text' }
* ```
*
* @param params The array of arguments to normalize.
*/
function argsToParams(params: SweetAlertArrayOptions | [SweetAlertOptions]): SweetAlertOptions;
/**
* An enum of possible reasons that can explain an alert dismissal.
*/
enum DismissReason {
cancel, backdrop, close, esc, timer
}
/**
* SweetAlert2's version
*/
const version: string
}
export type SweetAlertIcon = 'success' | 'error' | 'warning' | 'info' | 'question';
export type SweetAlertInput =
'text' | 'email' | 'password' | 'number' | 'tel' | 'range' | 'textarea' | 'select' | 'radio' | 'checkbox' |
'file' | 'url';
export type SweetAlertPosition =
'top' | 'top-start' | 'top-end' | 'top-left' | 'top-right' |
'center' | 'center-start' | 'center-end' | 'center-left' | 'center-right' |
'bottom' | 'bottom-start' | 'bottom-end' | 'bottom-left' | 'bottom-right';
export type SweetAlertGrow = 'row' | 'column' | 'fullscreen' | false;
export interface SweetAlertResult {
value?: any;
dismiss?: Swal.DismissReason;
}
export interface SweetAlertShowClass {
popup?: string;
backdrop?: string;
icon?: string;
}
export interface SweetAlertHideClass {
popup?: string;
backdrop?: string;
icon?: string;
}
export interface SweetAlertCustomClass {
container?: string;
popup?: string;
header?: string;
title?: string;
closeButton?: string;
icon?: string;
image?: string;
content?: string;
input?: string;
actions?: string;
confirmButton?: string;
cancelButton?: string;
footer?: string;
}
type SyncOrAsync<T> = T | Promise<T>;
type ValueOrThunk<T> = T | (() => T);
export type SweetAlertArrayOptions = [string?, string?, SweetAlertIcon?];
export interface SweetAlertOptions {
/**
* The title of the popup, as HTML.
* It can either be added to the object under the key `title` or passed as the first parameter of `Swal.fire()`.
*
* @default ''
*/
title?: string | HTMLElement | JQuery;
/**
* The title of the popup, as text. Useful to avoid HTML injection.
*
* @default ''
*/
titleText?: string;
/**
* A description for the popup.
* If `text` and `html` parameters are provided in the same time, `text` will be used.
*
* @default ''
*/
text?: string;
/**
* A HTML description for the popup.
* It can either be added to the object under the key `html` or passed as the second parameter of `Swal.fire()`.
*
* @default ''
*/
html?: string | HTMLElement | JQuery;
/**
* The icon of the popup.
* SweetAlert2 comes with 5 built-in icons which will show a corresponding icon animation:
* `'warning'`, `'error'`, `'success'`, `'info'` and `'question'`.
* It can either be put to the object under the key `icon` or passed as the third parameter of `Swal.fire()`.
*
* @default undefined
*/
icon?: SweetAlertIcon;
/**
* The custom HTML content for an icon.
*
* Example:
* ```
* Swal.fire({
* icon: 'error',
* iconHtml: '<i class="fas fa-bug"></i>'
* })
* ```
*
* @default undefined
*/
iconHtml?: string;
/**
* The footer of the popup, as HTML.
*
* @default ''
*/
footer?: string | HTMLElement | JQuery;
/**
* Whether or not SweetAlert2 should show a full screen click-to-dismiss backdrop.
* Either a boolean value or a css background value (hex, rgb, rgba, url, etc.)
*
* @default true
*/
backdrop?: boolean | string;
/**
* Whether or not an alert should be treated as a toast notification.
* This option is normally coupled with the `position` and `timer` parameters.
* Toasts are NEVER autofocused.
*
* @default false
*/
toast?: boolean;
/**
* The container element for adding popup into (query selector only).
*
* @default 'body'
*/
target?: string | HTMLElement;
/**
* Input field type, can be `'text'`, `'email'`, `'password'`, `'number'`, `'tel'`, `'range'`, `'textarea'`,
* `'select'`, `'radio'`, `'checkbox'`, `'file'` and `'url'`.
*
* @default undefined
*/
input?: SweetAlertInput;
/**
* Popup width, including paddings (`box-sizing: border-box`). Can be in px or %.
*
* @default undefined
*/
width?: number | string;
/**
* Popup padding.
*
* @default undefined
*/
padding?: number | string;
/**
* Popup background (CSS `background` property).
*
* @default undefined
*/
background?: string;
/**
* Popup position
*
* @default 'center'
*/
position?: SweetAlertPosition;
/**
* Popup grow direction
*
* @default false
*/
grow?: SweetAlertGrow;
/**
* CSS classes for animations when showing a popup (fade in)
*/
showClass?: SweetAlertShowClass;
/**
* CSS classes for animations when hiding a popup (fade out)
*/
hideClass?: SweetAlertHideClass;
/**
* A custom CSS class for the popup.
* If a string value is provided, the classname will be applied to the popup.
* If an object is provided, the classnames will be applied to the corresponding fields:
*
* Example:
* ```
* Swal.fire({
* customClass: {
* container: 'container-class',
* popup: 'popup-class',
* header: 'header-class',
* title: 'title-class',
* closeButton: 'close-button-class',
* icon: 'icon-class',
* image: 'image-class',
* content: 'content-class',
* input: 'input-class',
* actions: 'actions-class',
* confirmButton: 'confirm-button-class',
* cancelButton: 'cancel-button-class',
* footer: 'footer-class'
* }
* })
* ```
*
* @default undefined
*/
customClass?: SweetAlertCustomClass;
/**
* Auto close timer of the popup. Set in ms (milliseconds).
*
* @default undefined
*/
timer?: number;
/**
* If set to true, the timer will have a progress bar at the bottom of a popup.
* Mostly, this feature is useful with toasts.
*
* @default false
*/
timerProgressBar?: boolean;
/**
* @deprecated
* If set to `false`, popup CSS animation will be disabled.
*
* @default true
*/
animation?: ValueOrThunk<boolean>;
/**
* By default, SweetAlert2 sets html's and body's CSS `height` to `auto !important`.
* If this behavior isn't compatible with your project's layout, set `heightAuto` to `false`.
*
* @default true
*/
heightAuto?: boolean;
/**
* If set to `false`, the user can't dismiss the popup by clicking outside it.
* You can also pass a custom function returning a boolean value, e.g. if you want
* to disable outside clicks for the loading state of a popup.
*
* @default true
*/
allowOutsideClick?: ValueOrThunk<boolean>;
/**
* If set to `false`, the user can't dismiss the popup by pressing the Escape key.
* You can also pass a custom function returning a boolean value, e.g. if you want
* to disable the escape key for the loading state of a popup.
*
* @default true
*/
allowEscapeKey?: ValueOrThunk<boolean>;
/**
* If set to `false`, the user can't confirm the popup by pressing the Enter or Space keys,
* unless they manually focus the confirm button.
* You can also pass a custom function returning a boolean value.
*
* @default true
*/
allowEnterKey?: ValueOrThunk<boolean>;
/**
* If set to `false`, SweetAlert2 will allow keydown events propagation to the document.
*
* @default true
*/
stopKeydownPropagation?: boolean;
/**
* Useful for those who are using SweetAlert2 along with Bootstrap modals.
* By default keydownListenerCapture is `false` which means when a user hits `Esc`,
* both SweetAlert2 and Bootstrap modals will be closed.
* Set `keydownListenerCapture` to `true` to fix that behavior.
*
* @default false
*/
keydownListenerCapture?: boolean;
/**
* If set to `false`, the "Confirm" button will not be shown.
* It can be useful when you're using custom HTML description.
*
* @default true
*/
showConfirmButton?: boolean;
/**
* If set to `true`, the "Cancel" button will be shown, which the user can click on to dismiss the popup.
*
* @default false
*/
showCancelButton?: boolean;
/**
* Use this to change the text on the "Confirm" button.
*
* @default 'OK'
*/
confirmButtonText?: string;
/**
* Use this to change the text on the "Cancel" button.
*
* @default 'Cancel'
*/
cancelButtonText?: string;
/**
* Use this to change the background color of the "Confirm" button (must be a HEX value).
*
* @default undefined
*/
confirmButtonColor?: string;
/**
* Use this to change the background color of the "Cancel" button (must be a HEX value).
*
* @default undefined
*/
cancelButtonColor?: string;
/**
* Use this to change the `aria-label` for the "Confirm" button.
*
* @default ''
*/
confirmButtonAriaLabel?: string;
/**
* Use this to change the `aria-label` for the "Cancel" button.
*
* @default ''
*/
cancelButtonAriaLabel?: string;
/**
* Whether to apply the default SweetAlert2 styling to buttons.
* If you want to use your own classes (e.g. Bootstrap classes) set this parameter to false.
*
* @default true
*/
buttonsStyling?: boolean;
/**
* Set to true if you want to invert default buttons positions.
*
* @default false
*/
reverseButtons?: boolean;
/**
* Set to `false` if you want to focus the first element in tab order instead of the "Confirm" button by default.
*
* @default true
*/
focusConfirm?: boolean;
/**
* Set to `true` if you want to focus the "Cancel" button by default.
*
* @default false
*/
focusCancel?: boolean;
/**
* Set to `true` to show close button.
*
* @default false
*/
showCloseButton?: boolean;
/**
* Use this to change the content of the close button.
*
* @default '&times;'
*/
closeButtonHtml?: string;
/**
* Use this to change the `aria-label` for the close button.
*
* @default 'Close this dialog'
*/
closeButtonAriaLabel?: string;
/**
* Set to true to disable buttons and show that something is loading. Useful for AJAX requests.
*
* @default false
*/
showLoaderOnConfirm?: boolean;
/**
* Function to execute before confirm, may be async (Promise-returning) or sync.
*
* Example:
* ```
* Swal.fire({
* title: 'Multiple inputs',
* html:
* '<input id="swal-input1" class="swal2-input">' +
* '<input id="swal-input2" class="swal2-input">',
* focusConfirm: false,
* preConfirm: () => [
* document.querySelector('#swal-input1').value,
* document.querySelector('#swal-input2').value
* ]
* }).then(result => Swal.fire(JSON.stringify(result));
* ```
*
* @default undefined
*/
preConfirm?(inputValue: any): SyncOrAsync<any | void>;
/**
* Add an image to the popup. Should contain a string with the path or URL to the image.
*
* @default undefined
*/
imageUrl?: string;
/**
* If imageUrl is set, you can specify imageWidth to describes image width in px.
*
* @default undefined
*/
imageWidth?: number;
/**
* If imageUrl is set, you can specify imageHeight to describes image height in px.
*
* @default undefined
*/
imageHeight?: number;
/**
* An alternative text for the custom image icon.
*
* @default ''
*/
imageAlt?: string;
/**
* Input field placeholder.
*
* @default ''
*/
inputPlaceholder?: string;
/**
* Input field initial value.
*
* @default ''
*/
inputValue?: SyncOrAsync<string>;
/**
* If the `input` parameter is set to `'select'` or `'radio'`, you can provide options.
* Object keys will represent options values, object values will represent options text values.
*/
inputOptions?: SyncOrAsync<Map<string, string> | { [inputValue: string]: string }>;
/**
* Automatically remove whitespaces from both ends of a result string.
* Set this parameter to `false` to disable auto-trimming.
*
* @default true
*/
inputAutoTrim?: boolean;
/**
* HTML input attributes (e.g. `min`, `max`, `step`, `accept`), that are added to the input field.
*
* Example:
* ```
* Swal.fire({
* title: 'Select a file',
* input: 'file',
* inputAttributes: {
* accept: 'image/*'
* }
* })
* ```
*
* @default undefined
*/
inputAttributes?: { [attribute: string]: string };
/**
* Validator for input field, may be async (Promise-returning) or sync.
*
* Example:
* ```
* Swal.fire({
* title: 'Select color',
* input: 'radio',
* inputValidator: result => !result && 'You need to select something!'
* })
* ```
*
* @default undefined
*/
inputValidator?(inputValue: string): SyncOrAsync<string | null>;
/**
* A custom validation message for default validators (email, url).
*
* Example:
* ```
* Swal.fire({
* input: 'email',
* validationMessage: 'Adresse e-mail invalide'
* })
* ```
*
* @default undefined
*/
validationMessage?: string;
/**
* Progress steps, useful for popup queues.
*
* @default []
*/
progressSteps?: string[];
/**
* Current active progress step.
*
* @default undefined
*/
currentProgressStep?: string;
/**
* Distance between progress steps.
*
* @default undefined
*/
progressStepsDistance?: string;
/**
* Function to run when popup built, but not shown yet. Provides popup DOM element as the first argument.
*
* @default undefined
*/
onBeforeOpen?(popup: HTMLElement): void;
/**
* Function to run when popup opens, provides popup DOM element as the first argument.
*
* @default undefined
*/
onOpen?(popup: HTMLElement): void;
/**
* Function to run after popup DOM has been updated.
* Typically, this will happen after `Swal.fire()` or `Swal.update()`.
* If you want to perform changes in the popup's DOM, that survive `Swal.update()`, `onRender` is a good place.
*
* @default undefined
*/
onRender?(popup: HTMLElement): void;
/**
* Function to run when popup closes by user interaction (and not by another popup), provides popup DOM element
* as the first argument.
*
* @default undefined
*/
onClose?(popup: HTMLElement): void;
/**
* Function to run after popup has been disposed by user interaction (and not by another popup).
*
* @default undefined
*/
onAfterClose?(): void;
/**
* Function to run after popup has been destroyed either by user interaction or by another popup.
*
* @default undefined
*/
onDestroy?(): void;
/**
* Set to `false` to disable body padding adjustment when scrollbar is present.
*
* @default true
*/
scrollbarPadding?: boolean;
}
export default Swal
}
declare module 'sweetalert2/*/sweetalert2.js' {
export * from 'sweetalert2'
// "export *" does not matches the default export, so do it explicitly.
export { default } from 'sweetalert2' // eslint-disable-line
}
declare module 'sweetalert2/*/sweetalert2.all.js' {
export * from 'sweetalert2'
// "export *" does not matches the default export, so do it explicitly.
export { default } from 'sweetalert2' // eslint-disable-line
}
/**
* These interfaces aren't provided by SweetAlert2, but its definitions use them.
* They will be merged with 'true' definitions.
*/
interface JQuery {
}
interface Promise<T> {
}
interface Map<K, V> {
}