|
@@ -1,5 +1,5 @@
|
|
|
|
|
|
-* sweetalert2 v10.10.2
|
|
|
+* sweetalert2 v10.12.5
|
|
|
* Released under the MIT License.
|
|
|
*/
|
|
|
(function (global, factory) {
|
|
@@ -239,7 +239,7 @@
|
|
|
*/
|
|
|
|
|
|
var warn = function warn(message) {
|
|
|
- console.warn("".concat(consolePrefix, " ").concat(message));
|
|
|
+ console.warn("".concat(consolePrefix, " ").concat(_typeof(message) === 'object' ? message.join(' ') : message));
|
|
|
};
|
|
|
|
|
|
* Standardise console errors
|
|
@@ -841,7 +841,7 @@
|
|
|
}
|
|
|
|
|
|
|
|
|
- loader.innerHTML = params.loaderHtml;
|
|
|
+ setInnerHtml(loader, params.loaderHtml);
|
|
|
applyCustomClass(loader, params, 'loader');
|
|
|
};
|
|
|
|
|
@@ -1115,13 +1115,16 @@
|
|
|
setInputPlaceholder(textarea, params);
|
|
|
setInputLabel(textarea, textarea, params);
|
|
|
|
|
|
+ var getPadding = function getPadding(el) {
|
|
|
+ return parseInt(window.getComputedStyle(el).paddingLeft) + parseInt(window.getComputedStyle(el).paddingRight);
|
|
|
+ };
|
|
|
+
|
|
|
if ('MutationObserver' in window) {
|
|
|
|
|
|
var initialPopupWidth = parseInt(window.getComputedStyle(getPopup()).width);
|
|
|
- var popupPadding = parseInt(window.getComputedStyle(getPopup()).paddingLeft) + parseInt(window.getComputedStyle(getPopup()).paddingRight);
|
|
|
|
|
|
var outputsize = function outputsize() {
|
|
|
- var contentWidth = textarea.offsetWidth + popupPadding;
|
|
|
+ var contentWidth = textarea.offsetWidth + getPadding(getPopup()) + getPadding(getContent());
|
|
|
|
|
|
if (contentWidth > initialPopupWidth) {
|
|
|
getPopup().style.width = "".concat(contentWidth, "px");
|
|
@@ -1561,8 +1564,8 @@
|
|
|
|
|
|
_createClass(MixinSwal, [{
|
|
|
key: "_main",
|
|
|
- value: function _main(params) {
|
|
|
- return _get(_getPrototypeOf(MixinSwal.prototype), "_main", this).call(this, _extends({}, mixinParams, params));
|
|
|
+ value: function _main(params, prevMixinParams) {
|
|
|
+ return _get(_getPrototypeOf(MixinSwal.prototype), "_main", this).call(this, params, _extends({}, prevMixinParams, mixinParams));
|
|
|
}
|
|
|
}]);
|
|
|
|
|
@@ -1701,6 +1704,35 @@
|
|
|
return globalState.timeout && globalState.timeout.isRunning();
|
|
|
};
|
|
|
|
|
|
+ var bodyClickListenerAdded = false;
|
|
|
+ var clickHandlers = {};
|
|
|
+ function bindClickHandler() {
|
|
|
+ var attr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'data-swal-template';
|
|
|
+ clickHandlers[attr] = this;
|
|
|
+
|
|
|
+ if (!bodyClickListenerAdded) {
|
|
|
+ document.body.addEventListener('click', bodyClickListener);
|
|
|
+ bodyClickListenerAdded = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var bodyClickListener = function bodyClickListener(event) {
|
|
|
+
|
|
|
+
|
|
|
+ for (var el = event.target; el && el !== document; el = el.parentNode) {
|
|
|
+ for (var attr in clickHandlers) {
|
|
|
+ var template = el.getAttribute(attr);
|
|
|
+
|
|
|
+ if (template) {
|
|
|
+ clickHandlers[attr].fire({
|
|
|
+ template: template
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
var defaultParams = {
|
|
|
title: '',
|
|
|
titleText: '',
|
|
@@ -1710,6 +1742,7 @@
|
|
|
icon: undefined,
|
|
|
iconColor: undefined,
|
|
|
iconHtml: undefined,
|
|
|
+ template: undefined,
|
|
|
toast: false,
|
|
|
animation: true,
|
|
|
showClass: {
|
|
@@ -1722,7 +1755,7 @@
|
|
|
backdrop: 'swal2-backdrop-hide',
|
|
|
icon: 'swal2-icon-hide'
|
|
|
},
|
|
|
- customClass: undefined,
|
|
|
+ customClass: {},
|
|
|
target: 'body',
|
|
|
backdrop: true,
|
|
|
heightAuto: true,
|
|
@@ -1910,7 +1943,8 @@
|
|
|
resumeTimer: resumeTimer,
|
|
|
toggleTimer: toggleTimer,
|
|
|
increaseTimer: increaseTimer,
|
|
|
- isTimerRunning: isTimerRunning
|
|
|
+ isTimerRunning: isTimerRunning,
|
|
|
+ bindClickHandler: bindClickHandler
|
|
|
});
|
|
|
|
|
|
|
|
@@ -2457,6 +2491,181 @@
|
|
|
init(params);
|
|
|
}
|
|
|
|
|
|
+ var swalStringParams = ['swal-title', 'swal-html', 'swal-footer'];
|
|
|
+ var getTemplateParams = function getTemplateParams(params) {
|
|
|
+ var template = typeof params.template === 'string' ? document.querySelector(params.template) : params.template;
|
|
|
+
|
|
|
+ if (!template) {
|
|
|
+ return {};
|
|
|
+ }
|
|
|
+
|
|
|
+ var templateContent = template.content || template;
|
|
|
+
|
|
|
+ showWarningsForElements(templateContent);
|
|
|
+
|
|
|
+ var result = _extends(getSwalParams(templateContent), getSwalButtons(templateContent), getSwalImage(templateContent), getSwalIcon(templateContent), getSwalInput(templateContent), getSwalStringParams(templateContent, swalStringParams));
|
|
|
+
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+
|
|
|
+ var getSwalParams = function getSwalParams(templateContent) {
|
|
|
+ var result = {};
|
|
|
+ toArray(templateContent.querySelectorAll('swal-param')).forEach(function (param) {
|
|
|
+ showWarningsForAttributes(param, ['name', 'value']);
|
|
|
+ var paramName = param.getAttribute('name');
|
|
|
+ var value = param.getAttribute('value');
|
|
|
+
|
|
|
+ if (typeof defaultParams[paramName] === 'boolean' && value === 'false') {
|
|
|
+ value = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_typeof(defaultParams[paramName]) === 'object') {
|
|
|
+ value = JSON.parse(value);
|
|
|
+ }
|
|
|
+
|
|
|
+ result[paramName] = value;
|
|
|
+ });
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+
|
|
|
+ var getSwalButtons = function getSwalButtons(templateContent) {
|
|
|
+ var result = {};
|
|
|
+ toArray(templateContent.querySelectorAll('swal-button')).forEach(function (button) {
|
|
|
+ showWarningsForAttributes(button, ['type', 'color', 'aria-label']);
|
|
|
+ var type = button.getAttribute('type');
|
|
|
+ result["".concat(type, "ButtonText")] = button.innerHTML;
|
|
|
+ result["show".concat(capitalizeFirstLetter(type), "Button")] = true;
|
|
|
+
|
|
|
+ if (button.hasAttribute('color')) {
|
|
|
+ result["".concat(type, "ButtonColor")] = button.getAttribute('color');
|
|
|
+ }
|
|
|
+
|
|
|
+ if (button.hasAttribute('aria-label')) {
|
|
|
+ result["".concat(type, "ButtonAriaLabel")] = button.getAttribute('aria-label');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+
|
|
|
+ var getSwalImage = function getSwalImage(templateContent) {
|
|
|
+ var result = {};
|
|
|
+ var image = templateContent.querySelector('swal-image');
|
|
|
+
|
|
|
+ if (image) {
|
|
|
+ showWarningsForAttributes(image, ['src', 'width', 'height', 'alt']);
|
|
|
+
|
|
|
+ if (image.hasAttribute('src')) {
|
|
|
+ result.imageUrl = image.getAttribute('src');
|
|
|
+ }
|
|
|
+
|
|
|
+ if (image.hasAttribute('width')) {
|
|
|
+ result.imageWidth = image.getAttribute('width');
|
|
|
+ }
|
|
|
+
|
|
|
+ if (image.hasAttribute('height')) {
|
|
|
+ result.imageHeight = image.getAttribute('height');
|
|
|
+ }
|
|
|
+
|
|
|
+ if (image.hasAttribute('alt')) {
|
|
|
+ result.imageAlt = image.getAttribute('alt');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+
|
|
|
+ var getSwalIcon = function getSwalIcon(templateContent) {
|
|
|
+ var result = {};
|
|
|
+ var icon = templateContent.querySelector('swal-icon');
|
|
|
+
|
|
|
+ if (icon) {
|
|
|
+ showWarningsForAttributes(icon, ['type', 'color']);
|
|
|
+
|
|
|
+ if (icon.hasAttribute('type')) {
|
|
|
+ result.icon = icon.getAttribute('type');
|
|
|
+ }
|
|
|
+
|
|
|
+ if (icon.hasAttribute('color')) {
|
|
|
+ result.iconColor = icon.getAttribute('color');
|
|
|
+ }
|
|
|
+
|
|
|
+ result.iconHtml = icon.innerHTML;
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+
|
|
|
+ var getSwalInput = function getSwalInput(templateContent) {
|
|
|
+ var result = {};
|
|
|
+ var input = templateContent.querySelector('swal-input');
|
|
|
+
|
|
|
+ if (input) {
|
|
|
+ showWarningsForAttributes(input, ['type', 'label', 'placeholder', 'value']);
|
|
|
+ result.input = input.getAttribute('type') || 'text';
|
|
|
+
|
|
|
+ if (input.hasAttribute('label')) {
|
|
|
+ result.inputLabel = input.getAttribute('label');
|
|
|
+ }
|
|
|
+
|
|
|
+ if (input.hasAttribute('placeholder')) {
|
|
|
+ result.inputPlaceholder = input.getAttribute('placeholder');
|
|
|
+ }
|
|
|
+
|
|
|
+ if (input.hasAttribute('value')) {
|
|
|
+ result.inputValue = input.getAttribute('value');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var inputOptions = templateContent.querySelectorAll('swal-input-option');
|
|
|
+
|
|
|
+ if (inputOptions.length) {
|
|
|
+ result.inputOptions = {};
|
|
|
+ toArray(inputOptions).forEach(function (option) {
|
|
|
+ showWarningsForAttributes(option, ['value']);
|
|
|
+ var optionValue = option.getAttribute('value');
|
|
|
+ var optionName = option.innerHTML;
|
|
|
+ result.inputOptions[optionValue] = optionName;
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+
|
|
|
+ var getSwalStringParams = function getSwalStringParams(templateContent, paramNames) {
|
|
|
+ var result = {};
|
|
|
+
|
|
|
+ for (var i in paramNames) {
|
|
|
+ var paramName = paramNames[i];
|
|
|
+ var tag = templateContent.querySelector(paramName);
|
|
|
+
|
|
|
+ if (tag) {
|
|
|
+ showWarningsForAttributes(tag, []);
|
|
|
+ result[paramName.replace(/^swal-/, '')] = tag.innerHTML;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+ };
|
|
|
+
|
|
|
+ var showWarningsForElements = function showWarningsForElements(template) {
|
|
|
+ var allowedElements = swalStringParams.concat(['swal-param', 'swal-button', 'swal-image', 'swal-icon', 'swal-input', 'swal-input-option']);
|
|
|
+ toArray(template.querySelectorAll('*')).forEach(function (el) {
|
|
|
+ var tagName = el.tagName.toLowerCase();
|
|
|
+
|
|
|
+ if (allowedElements.indexOf(tagName) === -1) {
|
|
|
+ warn("Unrecognized element <".concat(tagName, ">"));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
+ var showWarningsForAttributes = function showWarningsForAttributes(el, allowedAttributes) {
|
|
|
+ toArray(el.attributes).forEach(function (attribute) {
|
|
|
+ if (allowedAttributes.indexOf(attribute.name) === -1) {
|
|
|
+ warn(["Unrecognized attribute \"".concat(attribute.name, "\" on <").concat(el.tagName.toLowerCase(), ">."), "".concat(allowedAttributes.length ? "Allowed attributes are: ".concat(allowedAttributes.join(', ')) : 'To set the value, use HTML within the element.')]);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
var SHOW_CLASS_TIMEOUT = 10;
|
|
|
|
|
|
* Open popup, add necessary classes and styles, fix scrollbar
|
|
@@ -2647,11 +2856,7 @@
|
|
|
var option = document.createElement('option');
|
|
|
option.value = optionValue;
|
|
|
setInnerHtml(option, optionLabel);
|
|
|
-
|
|
|
- if (params.inputValue.toString() === optionValue.toString()) {
|
|
|
- option.selected = true;
|
|
|
- }
|
|
|
-
|
|
|
+ option.selected = isSelected(optionValue, params.inputValue);
|
|
|
parent.appendChild(option);
|
|
|
};
|
|
|
|
|
@@ -2690,7 +2895,7 @@
|
|
|
radioInput.name = swalClasses.radio;
|
|
|
radioInput.value = radioValue;
|
|
|
|
|
|
- if (params.inputValue.toString() === radioValue.toString()) {
|
|
|
+ if (isSelected(radioValue, params.inputValue)) {
|
|
|
radioInput.checked = true;
|
|
|
}
|
|
|
|
|
@@ -2743,6 +2948,10 @@
|
|
|
return result;
|
|
|
};
|
|
|
|
|
|
+ var isSelected = function isSelected(optionValue, inputValue) {
|
|
|
+ return inputValue && inputValue.toString() === optionValue.toString();
|
|
|
+ };
|
|
|
+
|
|
|
var handleConfirmButtonClick = function handleConfirmButtonClick(instance, innerParams) {
|
|
|
instance.disableButtons();
|
|
|
|
|
@@ -2877,7 +3086,7 @@
|
|
|
var setFocus = function setFocus(innerParams, index, increment) {
|
|
|
var focusableElements = getFocusableElements();
|
|
|
|
|
|
- for (var i = 0; i < focusableElements.length; i++) {
|
|
|
+ if (focusableElements.length) {
|
|
|
index = index + increment;
|
|
|
|
|
|
if (index === focusableElements.length) {
|
|
@@ -3053,14 +3262,15 @@
|
|
|
};
|
|
|
|
|
|
function _main(userParams) {
|
|
|
- showWarningsForParams(userParams);
|
|
|
+ var mixinParams = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
|
+ showWarningsForParams(_extends({}, mixinParams, userParams));
|
|
|
|
|
|
if (globalState.currentInstance) {
|
|
|
globalState.currentInstance._destroy();
|
|
|
}
|
|
|
|
|
|
globalState.currentInstance = this;
|
|
|
- var innerParams = prepareParams(userParams);
|
|
|
+ var innerParams = prepareParams(userParams, mixinParams);
|
|
|
setParameters(innerParams);
|
|
|
Object.freeze(innerParams);
|
|
|
|
|
@@ -3077,12 +3287,15 @@
|
|
|
return swalPromise(this, domCache, innerParams);
|
|
|
}
|
|
|
|
|
|
- var prepareParams = function prepareParams(userParams) {
|
|
|
- var showClass = _extends({}, defaultParams.showClass, userParams.showClass);
|
|
|
+ var prepareParams = function prepareParams(userParams, mixinParams) {
|
|
|
+ var templateParams = getTemplateParams(userParams);
|
|
|
+
|
|
|
+ var showClass = _extends({}, defaultParams.showClass, mixinParams.showClass, templateParams.showClass, userParams.showClass);
|
|
|
+
|
|
|
+ var hideClass = _extends({}, defaultParams.hideClass, mixinParams.hideClass, templateParams.hideClass, userParams.hideClass);
|
|
|
|
|
|
- var hideClass = _extends({}, defaultParams.hideClass, userParams.hideClass);
|
|
|
+ var params = _extends({}, defaultParams, mixinParams, templateParams, userParams);
|
|
|
|
|
|
- var params = _extends({}, defaultParams, userParams);
|
|
|
|
|
|
params.showClass = showClass;
|
|
|
params.hideClass = hideClass;
|
|
@@ -3403,7 +3616,7 @@
|
|
|
};
|
|
|
});
|
|
|
SweetAlert.DismissReason = DismissReason;
|
|
|
- SweetAlert.version = '10.10.2';
|
|
|
+ SweetAlert.version = '10.12.5';
|
|
|
|
|
|
var Swal = SweetAlert;
|
|
|
Swal["default"] = Swal;
|