/home/mip/mip/public/vendor/laravel-filemanager/files/folder-1/821668/sweetalert2.zip
PK @]�3�I I LICENSEnu �Iw�� 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.
PK @]��̗3 �3 src/sweetalert2.scssnu �Iw�� // SweetAlert2
// github.com/limonte/sweetalert2
@import 'colors';
body {
&.swal2-shown {
overflow-y: hidden;
}
&.swal2-iosfix {
position: fixed;
left: 0;
right: 0;
}
}
.swal2-container {
// centering
display: flex;
align-items: center;
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
padding: 10px;
// backdrop
background-color: transparent;
z-index: 1060;
&.swal2-fade {
transition: background-color .1s;
}
&.swal2-shown {
background-color: $swal2-overlay;
}
}
.swal2-modal {
background-color: $swal2-white;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
border-radius: 5px;
box-sizing: border-box;
text-align: center;
margin: auto;
overflow-x: hidden;
overflow-y: auto;
display: none;
position: relative;
max-width: 100%;
&:focus {
outline: none;
}
&.swal2-loading {
overflow-y: hidden;
}
.swal2-title {
color: lighten($swal2-black, 35);
font-size: 30px;
text-align: center;
font-weight: 600;
text-transform: none;
position: relative;
margin: 0 0 .4em;
padding: 0;
display: block;
word-wrap: break-word;
}
.swal2-buttonswrapper {
margin-top: 15px;
&:not(.swal2-loading) {
.swal2-styled {
&[disabled] {
opacity: .4;
cursor: no-drop;
}
}
}
&.swal2-loading {
.swal2-styled {
&.swal2-confirm {
box-sizing: border-box;
border: 4px solid transparent;
border-color: transparent;
width: 40px;
height: 40px;
padding: 0;
margin: 7.5px;
vertical-align: top;
background-color: transparent !important;
color: transparent;
cursor: default;
border-radius: 100%;
animation: rotate-loading 1.5s linear 0s infinite normal;
user-select: none;
}
&.swal2-cancel {
margin-left: 30px;
margin-right: 30px;
}
}
:not(.swal2-styled) {
&.swal2-confirm {
&::after {
display: inline-block;
content: '';
margin-left: 5px 0 15px;
vertical-align: -1px;
height: 15px;
width: 15px;
border: 3px solid lighten($swal2-black, 60);
box-shadow: 1px 1px 1px $swal2-white;
border-right-color: transparent;
border-radius: 50%;
animation: rotate-loading 1.5s linear 0s infinite normal;
}
}
}
}
}
.swal2-styled {
border: 0;
border-radius: 3px;
box-shadow: none;
color: $swal2-white;
cursor: pointer;
font-size: 17px;
font-weight: 500;
margin: 15px 5px 0;
padding: 10px 32px;
}
.swal2-image {
margin: 20px auto;
max-width: 100%;
}
.swal2-close {
background: $swal2-transparent;
border: 0;
margin: 0;
padding: 0;
width: 38px;
height: 40px;
font-size: 36px;
line-height: 40px;
font-family: serif;
position: absolute;
top: 5px;
right: 8px;
cursor: pointer;
color: $swal2-close-button;
transition: color .1s ease;
&:hover {
color: $swal2-close-button-hover;
}
}
> .swal2-input,
> .swal2-file,
> .swal2-textarea,
> .swal2-select,
> .swal2-radio,
> .swal2-checkbox {
display: none;
}
.swal2-content {
font-size: 18px;
text-align: center;
font-weight: 300;
position: relative;
float: none;
margin: 0;
padding: 0;
line-height: normal;
color: lighten($swal2-black, 33);
word-wrap: break-word;
}
.swal2-input,
.swal2-file,
.swal2-textarea,
.swal2-select,
.swal2-radio,
.swal2-checkbox {
margin: 20px auto;
}
.swal2-input,
.swal2-file,
.swal2-textarea {
width: 100%;
box-sizing: border-box;
font-size: 18px;
border-radius: 3px;
border: 1px solid $swal2-input-border;
box-shadow: inset 0 1px 1px $swal2-input-box-shadow;
transition: border-color box-shadow .3s;
&.swal2-inputerror {
border-color: $swal2-error !important;
box-shadow: 0 0 2px $swal2-error !important;
}
&:focus {
outline: none;
border: 1px solid $swal2-input-border-focus;
box-shadow: 0 0 3px $swal2-input-box-shadow-focus;
&::placeholder {
transition: opacity .3s .03s ease;
opacity: .8;
}
}
&::placeholder {
color: lighten($swal2-black, 90);
}
}
.swal2-range {
input {
float: left;
width: 80%;
}
output {
float: right;
width: 20%;
font-size: 20px;
font-weight: 600;
text-align: center;
}
input,
output {
height: 43px;
line-height: 43px;
vertical-align: middle;
margin: 20px auto;
padding: 0;
}
}
.swal2-input {
height: 43px;
padding: 0 12px;
&[type='number'] {
max-width: 150px;
}
}
.swal2-file {
font-size: 20px;
}
.swal2-textarea {
height: 108px;
padding: 12px;
}
.swal2-select {
color: lighten($swal2-black, 33);
font-size: inherit;
padding: 5px 10px;
min-width: 40%;
max-width: 100%;
}
.swal2-radio {
border: 0;
label {
&:not(:first-child) {
margin-left: 20px;
}
}
input,
span {
vertical-align: middle;
}
input {
margin: 0 3px 0 0;
}
}
.swal2-checkbox {
color: lighten($swal2-black, 33);
input,
span {
vertical-align: middle;
}
}
.swal2-validationerror {
background-color: lighten($swal2-black, 94);
margin: 0 -20px;
overflow: hidden;
padding: 10px;
color: lighten($swal2-black, 50);
font-size: 16px;
font-weight: 300;
display: none;
&::before {
content: '!';
display: inline-block;
width: 24px;
height: 24px;
border-radius: 50%;
background-color: $swal2-validationerror-background;
color: $swal2-validationerror-color;
line-height: 24px;
text-align: center;
margin-right: 10px;
}
}
}
@supports (-ms-accelerator: true) {
.swal2-range {
input {
width: 100% !important;
}
output {
display: none;
}
}
}
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
.swal2-range {
input {
width: 100% !important;
}
output {
display: none;
}
}
}
.swal2-icon {
width: 80px;
height: 80px;
border: 4px solid transparent;
border-radius: 50%;
margin: 20px auto 30px;
padding: 0;
position: relative;
box-sizing: content-box;
cursor: default;
user-select: none;
&.swal2-error {
border-color: $swal2-error;
.swal2-x-mark {
position: relative;
display: block;
}
[class^='swal2-x-mark-line'] {
position: absolute;
height: 5px;
width: 47px;
background-color: $swal2-error;
display: block;
top: 37px;
border-radius: 2px;
&[class$='left'] {
transform: rotate(45deg);
left: 17px;
}
&[class$='right'] {
transform: rotate(-45deg);
right: 16px;
}
}
}
&.swal2-warning {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
color: $swal2-warning;
border-color: lighten($swal2-warning, 7);
font-size: 60px;
line-height: 80px;
text-align: center;
}
&.swal2-info {
font-family: 'Open Sans', sans-serif;
color: $swal2-info;
border-color: lighten($swal2-info, 20);
font-size: 60px;
line-height: 80px;
text-align: center;
}
&.swal2-question {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
color: $swal2-question;
border-color: lighten($swal2-question, 20);
font-size: 60px;
line-height: 80px;
text-align: center;
}
&.swal2-success {
border-color: $swal2-success;
[class^='swal2-success-circular-line'] { // Emulate moving circular line
border-radius: 50%;
position: absolute;
width: 60px;
height: 120px;
transform: rotate(45deg);
&[class$='left'] {
border-radius: 120px 0 0 120px;
top: -7px;
left: -33px;
transform: rotate(-45deg);
transform-origin: 60px 60px;
}
&[class$='right'] {
border-radius: 0 120px 120px 0;
top: -11px;
left: 30px;
transform: rotate(-45deg);
transform-origin: 0 60px;
}
}
.swal2-success-ring { // Ring
width: 80px;
height: 80px;
border: 4px solid $swal2-success-border;
border-radius: 50%;
box-sizing: content-box;
position: absolute;
left: -4px;
top: -4px;
z-index: 2;
}
.swal2-success-fix { // Hide corners left from animation
width: 7px;
height: 90px;
position: absolute;
left: 28px;
top: 8px;
z-index: 1;
transform: rotate(-45deg);
}
[class^='swal2-success-line'] {
height: 5px;
background-color: $swal2-success;
display: block;
border-radius: 2px;
position: absolute;
z-index: 2;
&[class$='tip'] {
width: 25px;
left: 14px;
top: 46px;
transform: rotate(45deg);
}
&[class$='long'] {
width: 47px;
right: 8px;
top: 38px;
transform: rotate(-45deg);
}
}
}
}
.swal2-progresssteps {
$lightblue: #add8e6;
$blue: #3085d6;
font-weight: 600;
margin: 0 0 20px;
padding: 0;
li {
display: inline-block;
position: relative;
}
.swal2-progresscircle {
background: $blue;
border-radius: 2em;
color: $swal2-white;
height: 2em;
line-height: 2em;
text-align: center;
width: 2em;
z-index: 20;
&:first-child {
margin-left: 0;
}
&:last-child {
margin-right: 0;
}
&.swal2-activeprogressstep {
background: $blue;
~ .swal2-progresscircle {
background: $lightblue;
}
~ .swal2-progressline {
background: $lightblue;
}
}
}
.swal2-progressline {
background: $blue;
height: .4em;
margin: 0 -1px;
z-index: 10;
}
}
// github.com/limonte/sweetalert2/issues/268
[class^='swal2'] {
-webkit-tap-highlight-color: $swal2-transparent;
}
// Animations
@mixin keyframes($animation-name) {
@keyframes #{$animation-name} {
@content;
}
}
@mixin animation($str) {
animation: #{$str};
}
// Modal animation
@include keyframes(showSweetAlert) {
0% {
transform: scale(.7);
}
45% {
transform: scale(1.05);
}
80% {
transform: scale(.95);
}
100% {
transform: scale(1);
}
}
@include keyframes(hideSweetAlert) {
0% {
transform: scale(1);
opacity: 1;
}
100% {
transform: scale(.5);
opacity: 0;
}
}
.swal2-show {
@include animation('showSweetAlert 0.3s');
&.swal2-noanimation {
@include animation('none');
}
}
.swal2-hide {
@include animation('hideSweetAlert 0.15s forwards');
&.swal2-noanimation {
@include animation('none');
}
}
// Success icon animation
@include keyframes(animate-success-tip) {
0% {
width: 0;
left: 1px;
top: 19px;
}
54% {
width: 0;
left: 1px;
top: 19px;
}
70% {
width: 50px;
left: -8px;
top: 37px;
}
84% {
width: 17px;
left: 21px;
top: 48px;
}
100% {
width: 25px;
left: 14px;
top: 45px;
}
}
@include keyframes(animate-success-long) {
0% {
width: 0;
right: 46px;
top: 54px;
}
65% {
width: 0;
right: 46px;
top: 54px;
}
84% {
width: 55px;
right: 0;
top: 35px;
}
100% {
width: 47px;
right: 8px;
top: 38px;
}
}
@include keyframes(rotatePlaceholder) {
0% {
transform: rotate(-45deg);
}
5% {
transform: rotate(-45deg);
}
12% {
transform: rotate(-405deg);
}
100% {
transform: rotate(-405deg);
}
}
.swal2-animate-success-line-tip {
@include animation('animate-success-tip 0.75s');
}
.swal2-animate-success-line-long {
@include animation('animate-success-long 0.75s');
}
.swal2-success {
&.swal2-animate-success-icon {
.swal2-success-circular-line-right {
@include animation('rotatePlaceholder 4.25s ease-in');
}
}
}
// Error icon animation
@include keyframes(animate-error-icon) {
0% {
transform: rotateX(100deg);
opacity: 0;
}
100% {
transform: rotateX(0deg);
opacity: 1;
}
}
.swal2-animate-error-icon {
@include animation('animate-error-icon 0.5s');
}
@include keyframes(animate-x-mark) {
0% {
transform: scale(.4);
margin-top: 26px;
opacity: 0;
}
50% {
transform: scale(.4);
margin-top: 26px;
opacity: 0;
}
80% {
transform: scale(1.15);
margin-top: -6px;
}
100% {
transform: scale(1);
margin-top: 0;
opacity: 1;
}
}
.swal2-animate-x-mark {
@include animation('animate-x-mark 0.5s');
}
@include keyframes(rotate-loading) {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
PK @]��z�� �� src/sweetalert2.jsnu �Iw�� import defaultParams from './utils/params.js'
import { swalClasses, iconTypes } from './utils/classes.js'
import { colorLuminance } from './utils/utils.js'
import * as dom from './utils/dom.js'
let modalParams = Object.assign({}, defaultParams)
let queue = []
let swal2Observer
/*
* Set type, text and actions on modal
*/
const setParameters = (params) => {
const modal = dom.getModal() || dom.init(params)
for (let param in params) {
if (!defaultParams.hasOwnProperty(param) && param !== 'extraParams') {
console.warn(`SweetAlert2: Unknown parameter "${param}"`)
}
}
// Set modal width
modal.style.width = (typeof params.width === 'number') ? params.width + 'px' : params.width
modal.style.padding = params.padding + 'px'
modal.style.background = params.background
const successIconParts = modal.querySelectorAll('[class^=swal2-success-circular-line], .swal2-success-fix')
for (let i = 0; i < successIconParts.length; i++) {
successIconParts[i].style.background = params.background
}
const title = dom.getTitle()
const content = dom.getContent()
const buttonsWrapper = dom.getButtonsWrapper()
const confirmButton = dom.getConfirmButton()
const cancelButton = dom.getCancelButton()
const closeButton = dom.getCloseButton()
// Title
if (params.titleText) {
title.innerText = params.titleText
} else {
title.innerHTML = params.title.split('\n').join('<br>')
}
// Content
if (params.text || params.html) {
if (typeof params.html === 'object') {
content.innerHTML = ''
if (0 in params.html) {
for (let i = 0; i in params.html; i++) {
content.appendChild(params.html[i].cloneNode(true))
}
} else {
content.appendChild(params.html.cloneNode(true))
}
} else if (params.html) {
content.innerHTML = params.html
} else if (params.text) {
content.textContent = params.text
}
dom.show(content)
} else {
dom.hide(content)
}
// Close button
if (params.showCloseButton) {
dom.show(closeButton)
} else {
dom.hide(closeButton)
}
// Custom Class
modal.className = swalClasses.modal
if (params.customClass) {
dom.addClass(modal, params.customClass)
}
// Progress steps
let progressStepsContainer = dom.getProgressSteps()
let currentProgressStep = parseInt(params.currentProgressStep === null ? sweetAlert.getQueueStep() : params.currentProgressStep, 10)
if (params.progressSteps.length) {
dom.show(progressStepsContainer)
dom.empty(progressStepsContainer)
if (currentProgressStep >= params.progressSteps.length) {
console.warn(
'SweetAlert2: Invalid currentProgressStep parameter, it should be less than progressSteps.length ' +
'(currentProgressStep like JS arrays starts from 0)'
)
}
params.progressSteps.forEach((step, index) => {
let circle = document.createElement('li')
dom.addClass(circle, swalClasses.progresscircle)
circle.innerHTML = step
if (index === currentProgressStep) {
dom.addClass(circle, swalClasses.activeprogressstep)
}
progressStepsContainer.appendChild(circle)
if (index !== params.progressSteps.length - 1) {
let line = document.createElement('li')
dom.addClass(line, swalClasses.progressline)
line.style.width = params.progressStepsDistance
progressStepsContainer.appendChild(line)
}
})
} else {
dom.hide(progressStepsContainer)
}
// Icon
const icons = dom.getIcons()
for (let i = 0; i < icons.length; i++) {
dom.hide(icons[i])
}
if (params.type) {
let validType = false
for (let iconType in iconTypes) {
if (params.type === iconType) {
validType = true
break
}
}
if (!validType) {
console.error(`SweetAlert2: Unknown alert type: ${params.type}`)
return false
}
const icon = modal.querySelector(`.${swalClasses.icon}.${iconTypes[params.type]}`)
dom.show(icon)
// Animate icon
if (params.animation) {
switch (params.type) {
case 'success':
dom.addClass(icon, 'swal2-animate-success-icon')
dom.addClass(icon.querySelector('.swal2-success-line-tip'), 'swal2-animate-success-line-tip')
dom.addClass(icon.querySelector('.swal2-success-line-long'), 'swal2-animate-success-line-long')
break
case 'error':
dom.addClass(icon, 'swal2-animate-error-icon')
dom.addClass(icon.querySelector('.swal2-x-mark'), 'swal2-animate-x-mark')
break
default:
break
}
}
}
// Custom image
const image = dom.getImage()
if (params.imageUrl) {
image.setAttribute('src', params.imageUrl)
dom.show(image)
if (params.imageWidth) {
image.setAttribute('width', params.imageWidth)
} else {
image.removeAttribute('width')
}
if (params.imageHeight) {
image.setAttribute('height', params.imageHeight)
} else {
image.removeAttribute('height')
}
image.className = swalClasses.image
if (params.imageClass) {
dom.addClass(image, params.imageClass)
}
} else {
dom.hide(image)
}
// Cancel button
if (params.showCancelButton) {
cancelButton.style.display = 'inline-block'
} else {
dom.hide(cancelButton)
}
// Confirm button
if (params.showConfirmButton) {
dom.removeStyleProperty(confirmButton, 'display')
} else {
dom.hide(confirmButton)
}
// Buttons wrapper
if (!params.showConfirmButton && !params.showCancelButton) {
dom.hide(buttonsWrapper)
} else {
dom.show(buttonsWrapper)
}
// Edit text on cancel and confirm buttons
confirmButton.innerHTML = params.confirmButtonText
cancelButton.innerHTML = params.cancelButtonText
// Set buttons to selected background colors
if (params.buttonsStyling) {
confirmButton.style.backgroundColor = params.confirmButtonColor
cancelButton.style.backgroundColor = params.cancelButtonColor
}
// Add buttons custom classes
confirmButton.className = swalClasses.confirm
dom.addClass(confirmButton, params.confirmButtonClass)
cancelButton.className = swalClasses.cancel
dom.addClass(cancelButton, params.cancelButtonClass)
// Buttons styling
if (params.buttonsStyling) {
dom.addClass(confirmButton, swalClasses.styled)
dom.addClass(cancelButton, swalClasses.styled)
} else {
dom.removeClass(confirmButton, swalClasses.styled)
dom.removeClass(cancelButton, swalClasses.styled)
confirmButton.style.backgroundColor = confirmButton.style.borderLeftColor = confirmButton.style.borderRightColor = ''
cancelButton.style.backgroundColor = cancelButton.style.borderLeftColor = cancelButton.style.borderRightColor = ''
}
// CSS animation
if (params.animation === true) {
dom.removeClass(modal, swalClasses.noanimation)
} else {
dom.addClass(modal, swalClasses.noanimation)
}
}
/*
* Animations
*/
const openModal = (animation, onComplete) => {
const container = dom.getContainer()
const modal = dom.getModal()
if (animation) {
dom.addClass(modal, swalClasses.show)
dom.addClass(container, swalClasses.fade)
dom.removeClass(modal, swalClasses.hide)
} else {
dom.removeClass(modal, swalClasses.fade)
}
dom.show(modal)
// scrolling is 'hidden' until animation is done, after that 'auto'
container.style.overflowY = 'hidden'
if (dom.animationEndEvent && !dom.hasClass(modal, swalClasses.noanimation)) {
modal.addEventListener(dom.animationEndEvent, function swalCloseEventFinished () {
modal.removeEventListener(dom.animationEndEvent, swalCloseEventFinished)
container.style.overflowY = 'auto'
})
} else {
container.style.overflowY = 'auto'
}
dom.addClass(document.documentElement, swalClasses.shown)
dom.addClass(document.body, swalClasses.shown)
dom.addClass(container, swalClasses.shown)
fixScrollbar()
iOSfix()
dom.states.previousActiveElement = document.activeElement
if (onComplete !== null && typeof onComplete === 'function') {
setTimeout(function () {
onComplete(modal)
})
}
}
const fixScrollbar = () => {
// for queues, do not do this more than once
if (dom.states.previousBodyPadding !== null) {
return
}
// if the body has overflow
if (document.body.scrollHeight > window.innerHeight) {
// add padding so the content doesn't shift after removal of scrollbar
dom.states.previousBodyPadding = document.body.style.paddingRight
document.body.style.paddingRight = dom.measureScrollbar() + 'px'
}
}
const undoScrollbar = () => {
if (dom.states.previousBodyPadding !== null) {
document.body.style.paddingRight = dom.states.previousBodyPadding
dom.states.previousBodyPadding = null
}
}
// Fix iOS scrolling http://stackoverflow.com/q/39626302/1331425
const iOSfix = () => {
const iOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream
if (iOS && !dom.hasClass(document.body, swalClasses.iosfix)) {
const offset = document.body.scrollTop
document.body.style.top = (offset * -1) + 'px'
dom.addClass(document.body, swalClasses.iosfix)
}
}
const undoIOSfix = () => {
if (dom.hasClass(document.body, swalClasses.iosfix)) {
const offset = parseInt(document.body.style.top, 10)
dom.removeClass(document.body, swalClasses.iosfix)
document.body.style.top = ''
document.body.scrollTop = (offset * -1)
}
}
// SweetAlert entry point
const sweetAlert = (...args) => {
if (args[0] === undefined) {
console.error('SweetAlert2 expects at least 1 attribute!')
return false
}
let params = Object.assign({}, modalParams)
switch (typeof args[0]) {
case 'string':
[params.title, params.html, params.type] = args
break
case 'object':
Object.assign(params, args[0])
params.extraParams = args[0].extraParams
if (params.input === 'email' && params.inputValidator === null) {
params.inputValidator = (email) => {
return new Promise((resolve, reject) => {
const emailRegex = /^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/
if (emailRegex.test(email)) {
resolve()
} else {
reject('Invalid email address')
}
})
}
}
if (params.input === 'url' && params.inputValidator === null) {
params.inputValidator = (url) => {
return new Promise((resolve, reject) => {
// taken from https://stackoverflow.com/a/3809435/1331425
const urlRegex = /^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)$/
if (urlRegex.test(url)) {
resolve()
} else {
reject('Invalid URL')
}
})
}
}
break
default:
console.error('SweetAlert2: Unexpected type of argument! Expected "string" or "object", got ' + typeof args[0])
return false
}
setParameters(params)
const container = dom.getContainer()
const modal = dom.getModal()
return new Promise((resolve, reject) => {
// Close on timer
if (params.timer) {
modal.timeout = setTimeout(() => {
sweetAlert.closeModal(params.onClose)
if (params.useRejections) {
reject('timer')
} else {
resolve({dismiss: 'timer'})
}
}, params.timer)
}
// Get input element by specified type or, if type isn't specified, by params.input
const getInput = (inputType) => {
inputType = inputType || params.input
if (!inputType) {
return null
}
switch (inputType) {
case 'select':
case 'textarea':
case 'file':
return dom.getChildByClass(modal, swalClasses[inputType])
case 'checkbox':
return modal.querySelector(`.${swalClasses.checkbox} input`)
case 'radio':
return modal.querySelector(`.${swalClasses.radio} input:checked`) ||
modal.querySelector(`.${swalClasses.radio} input:first-child`)
case 'range':
return modal.querySelector(`.${swalClasses.range} input`)
default:
return dom.getChildByClass(modal, swalClasses.input)
}
}
// Get the value of the modal input
const getInputValue = () => {
const input = getInput()
if (!input) {
return null
}
switch (params.input) {
case 'checkbox':
return input.checked ? 1 : 0
case 'radio':
return input.checked ? input.value : null
case 'file':
return input.files.length ? input.files[0] : null
default:
return params.inputAutoTrim ? input.value.trim() : input.value
}
}
// input autofocus
if (params.input) {
setTimeout(() => {
const input = getInput()
if (input) {
dom.focusInput(input)
}
}, 0)
}
const confirm = (value) => {
if (params.showLoaderOnConfirm) {
sweetAlert.showLoading()
}
if (params.preConfirm) {
params.preConfirm(value, params.extraParams).then(
(preConfirmValue) => {
sweetAlert.closeModal(params.onClose)
resolve(preConfirmValue || value)
},
(error) => {
sweetAlert.hideLoading()
if (error) {
sweetAlert.showValidationError(error)
}
}
)
} else {
sweetAlert.closeModal(params.onClose)
if (params.useRejections) {
resolve(value)
} else {
resolve({value: value})
}
}
}
// Mouse interactions
const onButtonEvent = (event) => {
const e = event || window.event
const target = e.target || e.srcElement
const confirmButton = dom.getConfirmButton()
const cancelButton = dom.getCancelButton()
const targetedConfirm = confirmButton && (confirmButton === target || confirmButton.contains(target))
const targetedCancel = cancelButton && (cancelButton === target || cancelButton.contains(target))
switch (e.type) {
case 'mouseover':
case 'mouseup':
if (params.buttonsStyling) {
if (targetedConfirm) {
confirmButton.style.backgroundColor = colorLuminance(params.confirmButtonColor, -0.1)
} else if (targetedCancel) {
cancelButton.style.backgroundColor = colorLuminance(params.cancelButtonColor, -0.1)
}
}
break
case 'mouseout':
if (params.buttonsStyling) {
if (targetedConfirm) {
confirmButton.style.backgroundColor = params.confirmButtonColor
} else if (targetedCancel) {
cancelButton.style.backgroundColor = params.cancelButtonColor
}
}
break
case 'mousedown':
if (params.buttonsStyling) {
if (targetedConfirm) {
confirmButton.style.backgroundColor = colorLuminance(params.confirmButtonColor, -0.2)
} else if (targetedCancel) {
cancelButton.style.backgroundColor = colorLuminance(params.cancelButtonColor, -0.2)
}
}
break
case 'click':
// Clicked 'confirm'
if (targetedConfirm && sweetAlert.isVisible()) {
sweetAlert.disableButtons()
if (params.input) {
const inputValue = getInputValue()
if (params.inputValidator) {
sweetAlert.disableInput()
params.inputValidator(inputValue, params.extraParams).then(
() => {
sweetAlert.enableButtons()
sweetAlert.enableInput()
confirm(inputValue)
},
(error) => {
sweetAlert.enableButtons()
sweetAlert.enableInput()
if (error) {
sweetAlert.showValidationError(error)
}
}
)
} else {
confirm(inputValue)
}
} else {
confirm(true)
}
// Clicked 'cancel'
} else if (targetedCancel && sweetAlert.isVisible()) {
sweetAlert.disableButtons()
sweetAlert.closeModal(params.onClose)
if (params.useRejections) {
reject('cancel')
} else {
resolve({dismiss: 'cancel'})
}
}
break
default:
}
}
const buttons = modal.querySelectorAll('button')
for (let i = 0; i < buttons.length; i++) {
buttons[i].onclick = onButtonEvent
buttons[i].onmouseover = onButtonEvent
buttons[i].onmouseout = onButtonEvent
buttons[i].onmousedown = onButtonEvent
}
// Closing modal by close button
dom.getCloseButton().onclick = () => {
sweetAlert.closeModal(params.onClose)
if (params.useRejections) {
reject('close')
} else {
resolve({dismiss: 'close'})
}
}
// Closing modal by overlay click
container.onclick = (e) => {
if (e.target !== container) {
return
}
if (params.allowOutsideClick) {
sweetAlert.closeModal(params.onClose)
if (params.useRejections) {
reject('overlay')
} else {
resolve({dismiss: 'overlay'})
}
}
}
const buttonsWrapper = dom.getButtonsWrapper()
const confirmButton = dom.getConfirmButton()
const cancelButton = dom.getCancelButton()
// Reverse buttons (Confirm on the right side)
if (params.reverseButtons) {
confirmButton.parentNode.insertBefore(cancelButton, confirmButton)
} else {
confirmButton.parentNode.insertBefore(confirmButton, cancelButton)
}
// Focus handling
const setFocus = (index, increment) => {
const focusableElements = dom.getFocusableElements(params.focusCancel)
// search for visible elements and select the next possible match
for (let i = 0; i < focusableElements.length; i++) {
index = index + increment
// rollover to first item
if (index === focusableElements.length) {
index = 0
// go to last item
} else if (index === -1) {
index = focusableElements.length - 1
}
// determine if element is visible
const el = focusableElements[index]
if (dom.isVisible(el)) {
return el.focus()
}
}
}
const handleKeyDown = (event) => {
const e = event || window.event
const keyCode = e.keyCode || e.which
if ([9, 13, 32, 27, 37, 38, 39, 40].indexOf(keyCode) === -1) {
// Don't do work on keys we don't care about.
return
}
const targetElement = e.target || e.srcElement
const focusableElements = dom.getFocusableElements(params.focusCancel)
let btnIndex = -1 // Find the button - note, this is a nodelist, not an array.
for (let i = 0; i < focusableElements.length; i++) {
if (targetElement === focusableElements[i]) {
btnIndex = i
break
}
}
// TAB
if (keyCode === 9) {
if (!e.shiftKey) {
// Cycle to the next button
setFocus(btnIndex, 1)
} else {
// Cycle to the prev button
setFocus(btnIndex, -1)
}
e.stopPropagation()
e.preventDefault()
// ARROWS - switch focus between buttons
} else if (keyCode === 37 || keyCode === 38 || keyCode === 39 || keyCode === 40) {
// focus Cancel button if Confirm button is currently focused
if (document.activeElement === confirmButton && dom.isVisible(cancelButton)) {
cancelButton.focus()
// and vice versa
} else if (document.activeElement === cancelButton && dom.isVisible(confirmButton)) {
confirmButton.focus()
}
// ENTER/SPACE
} else if (keyCode === 13 || keyCode === 32) {
if (btnIndex === -1 && params.allowEnterKey) {
// ENTER/SPACE clicked outside of a button.
if (params.focusCancel) {
dom.fireClick(cancelButton, e)
} else {
dom.fireClick(confirmButton, e)
}
e.stopPropagation()
e.preventDefault()
}
// ESC
} else if (keyCode === 27 && params.allowEscapeKey === true) {
sweetAlert.closeModal(params.onClose)
if (params.useRejections) {
reject('esc')
} else {
resolve({dismiss: 'esc'})
}
}
}
if (!window.onkeydown || window.onkeydown.toString() !== handleKeyDown.toString()) {
dom.states.previousWindowKeyDown = window.onkeydown
window.onkeydown = handleKeyDown
}
// Loading state
if (params.buttonsStyling) {
confirmButton.style.borderLeftColor = params.confirmButtonColor
confirmButton.style.borderRightColor = params.confirmButtonColor
}
/**
* Show spinner instead of Confirm button and disable Cancel button
*/
sweetAlert.hideLoading = sweetAlert.disableLoading = () => {
if (!params.showConfirmButton) {
dom.hide(confirmButton)
if (!params.showCancelButton) {
dom.hide(dom.getButtonsWrapper())
}
}
dom.removeClass(buttonsWrapper, swalClasses.loading)
dom.removeClass(modal, swalClasses.loading)
confirmButton.disabled = false
cancelButton.disabled = false
}
sweetAlert.getTitle = () => dom.getTitle()
sweetAlert.getContent = () => dom.getContent()
sweetAlert.getInput = () => getInput()
sweetAlert.getImage = () => dom.getImage()
sweetAlert.getButtonsWrapper = () => dom.getButtonsWrapper()
sweetAlert.getConfirmButton = () => dom.getConfirmButton()
sweetAlert.getCancelButton = () => dom.getCancelButton()
sweetAlert.enableButtons = () => {
confirmButton.disabled = false
cancelButton.disabled = false
}
sweetAlert.disableButtons = () => {
confirmButton.disabled = true
cancelButton.disabled = true
}
sweetAlert.enableConfirmButton = () => {
confirmButton.disabled = false
}
sweetAlert.disableConfirmButton = () => {
confirmButton.disabled = true
}
sweetAlert.enableInput = () => {
const input = getInput()
if (!input) {
return false
}
if (input.type === 'radio') {
const radiosContainer = input.parentNode.parentNode
const radios = radiosContainer.querySelectorAll('input')
for (let i = 0; i < radios.length; i++) {
radios[i].disabled = false
}
} else {
input.disabled = false
}
}
sweetAlert.disableInput = () => {
const input = getInput()
if (!input) {
return false
}
if (input && input.type === 'radio') {
const radiosContainer = input.parentNode.parentNode
const radios = radiosContainer.querySelectorAll('input')
for (let i = 0; i < radios.length; i++) {
radios[i].disabled = true
}
} else {
input.disabled = true
}
}
// Set modal min-height to disable scrolling inside the modal
sweetAlert.recalculateHeight = dom.debounce(() => {
const modal = dom.getModal()
if (!modal) {
return
}
const prevState = modal.style.display
modal.style.minHeight = ''
dom.show(modal)
modal.style.minHeight = (modal.scrollHeight + 1) + 'px'
modal.style.display = prevState
}, 50)
// Show block with validation error
sweetAlert.showValidationError = (error) => {
const validationError = dom.getValidationError()
validationError.innerHTML = error
dom.show(validationError)
const input = getInput()
if (input) {
dom.focusInput(input)
dom.addClass(input, swalClasses.inputerror)
}
}
// Hide block with validation error
sweetAlert.resetValidationError = () => {
const validationError = dom.getValidationError()
dom.hide(validationError)
sweetAlert.recalculateHeight()
const input = getInput()
if (input) {
dom.removeClass(input, swalClasses.inputerror)
}
}
sweetAlert.getProgressSteps = () => {
return params.progressSteps
}
sweetAlert.setProgressSteps = (progressSteps) => {
params.progressSteps = progressSteps
setParameters(params)
}
sweetAlert.showProgressSteps = () => {
dom.show(dom.getProgressSteps())
}
sweetAlert.hideProgressSteps = () => {
dom.hide(dom.getProgressSteps())
}
sweetAlert.enableButtons()
sweetAlert.hideLoading()
sweetAlert.resetValidationError()
// inputs
const inputTypes = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea']
let input
for (let i = 0; i < inputTypes.length; i++) {
const inputClass = swalClasses[inputTypes[i]]
const inputContainer = dom.getChildByClass(modal, inputClass)
input = getInput(inputTypes[i])
// set attributes
if (input) {
for (let j in input.attributes) {
if (input.attributes.hasOwnProperty(j)) {
const attrName = input.attributes[j].name
if (attrName !== 'type' && attrName !== 'value') {
input.removeAttribute(attrName)
}
}
}
for (let attr in params.inputAttributes) {
input.setAttribute(attr, params.inputAttributes[attr])
}
}
// set class
inputContainer.className = inputClass
if (params.inputClass) {
dom.addClass(inputContainer, params.inputClass)
}
dom.hide(inputContainer)
}
let populateInputOptions
switch (params.input) {
case 'text':
case 'email':
case 'password':
case 'number':
case 'tel':
case 'url':
input = dom.getChildByClass(modal, swalClasses.input)
input.value = params.inputValue
input.placeholder = params.inputPlaceholder
input.type = params.input
dom.show(input)
break
case 'file':
input = dom.getChildByClass(modal, swalClasses.file)
input.placeholder = params.inputPlaceholder
input.type = params.input
dom.show(input)
break
case 'range':
const range = dom.getChildByClass(modal, swalClasses.range)
const rangeInput = range.querySelector('input')
const rangeOutput = range.querySelector('output')
rangeInput.value = params.inputValue
rangeInput.type = params.input
rangeOutput.value = params.inputValue
dom.show(range)
break
case 'select':
const select = dom.getChildByClass(modal, swalClasses.select)
select.innerHTML = ''
if (params.inputPlaceholder) {
const placeholder = document.createElement('option')
placeholder.innerHTML = params.inputPlaceholder
placeholder.value = ''
placeholder.disabled = true
placeholder.selected = true
select.appendChild(placeholder)
}
populateInputOptions = (inputOptions) => {
for (let optionValue in inputOptions) {
const option = document.createElement('option')
option.value = optionValue
option.innerHTML = inputOptions[optionValue]
if (params.inputValue === optionValue) {
option.selected = true
}
select.appendChild(option)
}
dom.show(select)
select.focus()
}
break
case 'radio':
const radio = dom.getChildByClass(modal, swalClasses.radio)
radio.innerHTML = ''
populateInputOptions = (inputOptions) => {
for (let radioValue in inputOptions) {
const radioInput = document.createElement('input')
const radioLabel = document.createElement('label')
const radioLabelSpan = document.createElement('span')
radioInput.type = 'radio'
radioInput.name = swalClasses.radio
radioInput.value = radioValue
if (params.inputValue === radioValue) {
radioInput.checked = true
}
radioLabelSpan.innerHTML = inputOptions[radioValue]
radioLabel.appendChild(radioInput)
radioLabel.appendChild(radioLabelSpan)
radioLabel.for = radioInput.id
radio.appendChild(radioLabel)
}
dom.show(radio)
const radios = radio.querySelectorAll('input')
if (radios.length) {
radios[0].focus()
}
}
break
case 'checkbox':
const checkbox = dom.getChildByClass(modal, swalClasses.checkbox)
const checkboxInput = getInput('checkbox')
checkboxInput.type = 'checkbox'
checkboxInput.value = 1
checkboxInput.id = swalClasses.checkbox
checkboxInput.checked = Boolean(params.inputValue)
let label = checkbox.getElementsByTagName('span')
if (label.length) {
checkbox.removeChild(label[0])
}
label = document.createElement('span')
label.innerHTML = params.inputPlaceholder
checkbox.appendChild(label)
dom.show(checkbox)
break
case 'textarea':
const textarea = dom.getChildByClass(modal, swalClasses.textarea)
textarea.value = params.inputValue
textarea.placeholder = params.inputPlaceholder
dom.show(textarea)
break
case null:
break
default:
console.error(`SweetAlert2: Unexpected type of input! Expected "text", "email", "password", "number", "tel", "select", "radio", "checkbox", "textarea", "file" or "url", got "${params.input}"`)
break
}
if (params.input === 'select' || params.input === 'radio') {
if (params.inputOptions instanceof Promise) {
sweetAlert.showLoading()
params.inputOptions.then((inputOptions) => {
sweetAlert.hideLoading()
populateInputOptions(inputOptions)
})
} else if (typeof params.inputOptions === 'object') {
populateInputOptions(params.inputOptions)
} else {
console.error('SweetAlert2: Unexpected type of inputOptions! Expected object or Promise, got ' + typeof params.inputOptions)
}
}
openModal(params.animation, params.onOpen)
// Focus the first element (input or button)
if (params.allowEnterKey) {
setFocus(-1, 1)
} else {
if (document.activeElement) {
document.activeElement.blur()
}
}
// fix scroll
dom.getContainer().scrollTop = 0
// Observe changes inside the modal and adjust height
if (typeof MutationObserver !== 'undefined' && !swal2Observer) {
swal2Observer = new MutationObserver(sweetAlert.recalculateHeight)
swal2Observer.observe(modal, {childList: true, characterData: true, subtree: true})
}
})
}
/*
* Global function to determine if swal2 modal is shown
*/
sweetAlert.isVisible = () => {
return !!dom.getModal()
}
/*
* Global function for chaining sweetAlert modals
*/
sweetAlert.queue = (steps) => {
queue = steps
const resetQueue = () => {
queue = []
document.body.removeAttribute('data-swal2-queue-step')
}
let queueResult = []
return new Promise((resolve, reject) => {
(function step (i, callback) {
if (i < queue.length) {
document.body.setAttribute('data-swal2-queue-step', i)
sweetAlert(queue[i]).then(
(result) => {
queueResult.push(result)
step(i + 1, callback)
},
(dismiss) => {
resetQueue()
reject(dismiss)
}
)
} else {
resetQueue()
resolve(queueResult)
}
})(0)
})
}
/*
* Global function for getting the index of current modal in queue
*/
sweetAlert.getQueueStep = () => document.body.getAttribute('data-swal2-queue-step')
/*
* Global function for inserting a modal to the queue
*/
sweetAlert.insertQueueStep = (step, index) => {
if (index && index < queue.length) {
return queue.splice(index, 0, step)
}
return queue.push(step)
}
/*
* Global function for deleting a modal from the queue
*/
sweetAlert.deleteQueueStep = (index) => {
if (typeof queue[index] !== 'undefined') {
queue.splice(index, 1)
}
}
/*
* Global function to close sweetAlert
*/
sweetAlert.close = sweetAlert.closeModal = (onComplete) => {
const container = dom.getContainer()
const modal = dom.getModal()
if (!modal) {
return
}
dom.removeClass(modal, swalClasses.show)
dom.addClass(modal, swalClasses.hide)
clearTimeout(modal.timeout)
dom.resetPrevState()
const removeModalAndResetState = () => {
if (container.parentNode) {
container.parentNode.removeChild(container)
}
dom.removeClass(document.documentElement, swalClasses.shown)
dom.removeClass(document.body, swalClasses.shown)
undoScrollbar()
undoIOSfix()
}
// If animation is supported, animate
if (dom.animationEndEvent && !dom.hasClass(modal, swalClasses.noanimation)) {
modal.addEventListener(dom.animationEndEvent, function swalCloseEventFinished () {
modal.removeEventListener(dom.animationEndEvent, swalCloseEventFinished)
if (dom.hasClass(modal, swalClasses.hide)) {
removeModalAndResetState()
}
})
} else {
// Otherwise, remove immediately
removeModalAndResetState()
}
if (onComplete !== null && typeof onComplete === 'function') {
setTimeout(function () {
onComplete(modal)
})
}
}
/*
* Global function to click 'Confirm' button
*/
sweetAlert.clickConfirm = () => dom.getConfirmButton().click()
/*
* Global function to click 'Cancel' button
*/
sweetAlert.clickCancel = () => dom.getCancelButton().click()
/**
* Show spinner instead of Confirm button and disable Cancel button
*/
sweetAlert.showLoading = sweetAlert.enableLoading = () => {
const modal = dom.getModal()
if (!modal) {
sweetAlert('')
}
const buttonsWrapper = dom.getButtonsWrapper()
const confirmButton = dom.getConfirmButton()
const cancelButton = dom.getCancelButton()
dom.show(buttonsWrapper)
dom.show(confirmButton, 'inline-block')
dom.addClass(buttonsWrapper, swalClasses.loading)
dom.addClass(modal, swalClasses.loading)
confirmButton.disabled = true
cancelButton.disabled = true
}
/**
* Set default params for each popup
* @param {Object} userParams
*/
sweetAlert.setDefaults = (userParams) => {
if (!userParams || typeof userParams !== 'object') {
return console.error('SweetAlert2: the argument for setDefaults() is required and has to be a object')
}
for (let param in userParams) {
if (!defaultParams.hasOwnProperty(param) && param !== 'extraParams') {
console.warn(`SweetAlert2: Unknown parameter "${param}"`)
delete userParams[param]
}
}
Object.assign(modalParams, userParams)
}
/**
* Reset default params for each popup
*/
sweetAlert.resetDefaults = () => {
modalParams = Object.assign({}, defaultParams)
}
sweetAlert.noop = () => { }
sweetAlert.version = ''
sweetAlert.default = sweetAlert
export default sweetAlert
PK @]3 ��+ + src/utils/utils.jsnu �Iw�� /*
* Set hover, active and focus-states for buttons (source: http://www.sitepoint.com/javascript-generate-lighter-darker-color)
*/
export const colorLuminance = (hex, lum) => {
// Validate hex string
hex = String(hex).replace(/[^0-9a-f]/gi, '')
if (hex.length < 6) {
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]
}
lum = lum || 0
// Convert to decimal and change luminosity
let rgb = '#'
for (let i = 0; i < 3; i++) {
let c = parseInt(hex.substr(i * 2, 2), 16)
c = Math.round(Math.min(Math.max(0, c + (c * lum)), 255)).toString(16)
rgb += ('00' + c).substr(c.length)
}
return rgb
}
export const uniqueArray = (arr) => {
const result = []
for (var i in arr) {
if (result.indexOf(arr[i]) === -1) {
result.push(arr[i])
}
}
return result
}
PK @]�ő src/utils/params.jsnu �Iw�� export default {
title: '',
titleText: '',
text: '',
html: '',
type: null,
customClass: '',
target: 'body',
animation: true,
allowOutsideClick: true,
allowEscapeKey: true,
allowEnterKey: true,
showConfirmButton: true,
showCancelButton: false,
preConfirm: null,
confirmButtonText: 'OK',
confirmButtonColor: '#3085d6',
confirmButtonClass: null,
cancelButtonText: 'Cancel',
cancelButtonColor: '#aaa',
cancelButtonClass: null,
buttonsStyling: true,
reverseButtons: false,
focusCancel: false,
showCloseButton: false,
showLoaderOnConfirm: false,
imageUrl: null,
imageWidth: null,
imageHeight: null,
imageClass: null,
timer: null,
width: 500,
padding: 20,
background: '#fff',
input: null,
inputPlaceholder: '',
inputValue: '',
inputOptions: {},
inputAutoTrim: true,
inputClass: null,
inputAttributes: {},
inputValidator: null,
progressSteps: [],
currentProgressStep: null,
progressStepsDistance: '40px',
onOpen: null,
onClose: null,
useRejections: true
}
PK @]�S� � src/utils/classes.jsnu �Iw�� export const swalPrefix = 'swal2-'
export const prefix = (items) => {
const result = {}
for (const i in items) {
result[items[i]] = swalPrefix + items[i]
}
return result
}
export const swalClasses = prefix([
'container',
'shown',
'iosfix',
'modal',
'overlay',
'fade',
'show',
'hide',
'noanimation',
'close',
'title',
'content',
'buttonswrapper',
'confirm',
'cancel',
'icon',
'image',
'input',
'file',
'range',
'select',
'radio',
'checkbox',
'textarea',
'inputerror',
'validationerror',
'progresssteps',
'activeprogressstep',
'progresscircle',
'progressline',
'loading',
'styled'
])
export const iconTypes = prefix([
'success',
'warning',
'info',
'question',
'error'
])
PK @]�z�g'