sweetalert2 11.4.11 → 11.4.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -46,9 +46,9 @@ NSFW Sponsors
46
46
  -|-|-|-|-|-
47
47
  [hydoll](https://www.hydoll.com/) | [SexDollsOff](https://www.sexdollsoff.com/) | [RealSexDoll](https://realsexdoll.com/) | [Your Doll](https://www.yourdoll.com/) | [Annie's Dollhouse](https://anniesdollhouse.com/) | [Sex Doll Center](https://sexdollcenter.vip/)
48
48
 
49
- [<img src="https://sweetalert2.github.io/images/sponsors/vsdoll.png" width="80">](https://vsdoll.com/sex-doll-in-us/) | [<img src="https://sweetalert2.github.io/images/sponsors/sexangelbaby.png" width="80">](https://sexangelbaby.com/) | [<img src="https://sweetalert2.github.io/images/sponsors/theadulttoyfinder.png" width="80">](https://theadulttoyfinder.com/?utm_source=sweetalert2&utm_medium=logo)
49
+ [<img src="https://sweetalert2.github.io/images/sponsors/vsdoll.png" width="80">](https://vsdoll.com/homepage/) | [<img src="https://sweetalert2.github.io/images/sponsors/sexangelbaby.png" width="80">](https://sexangelbaby.com/) | [<img src="https://sweetalert2.github.io/images/sponsors/theadulttoyfinder.png" width="80">](https://theadulttoyfinder.com/?utm_source=sweetalert2&utm_medium=logo)
50
50
  -|-|-
51
- [VSDoll](https://vsdoll.com/sex-doll-in-us/) | [SexAngelbaby](https://sexangelbaby.com/) | [The Adult Toy Finder](https://theadulttoyfinder.com/?utm_source=sweetalert2&utm_medium=logo)
51
+ [VSDoll](https://vsdoll.com/homepage/) | [SexAngelbaby](https://sexangelbaby.com/) | [The Adult Toy Finder](https://theadulttoyfinder.com/?utm_source=sweetalert2&utm_medium=logo)
52
52
 
53
53
  [<img src="https://sweetalert2.github.io/images/sponsors/my-sex-toy-guide.jpg" width="80">](https://www.mysextoyguide.com/?utm_source=sweetalert2&utm_medium=logo) | [<img src="https://sweetalert2.github.io/images/sponsors/best-blowjob-machines.jpg" width="80">](https://www.bestblowjobmachines.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/doctorclimax.png" width="80">](https://doctorclimax.com/)
54
54
  -|-|-|-
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * sweetalert2 v11.4.11
2
+ * sweetalert2 v11.4.12
3
3
  * Released under the MIT License.
4
4
  */
5
5
  (function (global, factory) {
@@ -390,20 +390,20 @@
390
390
  };
391
391
  /**
392
392
  * @param {HTMLElement} popup
393
- * @param {string} inputType
393
+ * @param {import('./renderers/renderInput').InputClass} inputClass
394
394
  * @returns {HTMLInputElement | null}
395
395
  */
396
396
 
397
- const getInput = (popup, inputType) => {
398
- if (!inputType) {
397
+ const getInput = (popup, inputClass) => {
398
+ if (!inputClass) {
399
399
  return null;
400
400
  }
401
401
 
402
- switch (inputType) {
402
+ switch (inputClass) {
403
403
  case 'select':
404
404
  case 'textarea':
405
405
  case 'file':
406
- return popup.querySelector(".".concat(swalClasses.popup, " > .").concat(swalClasses[inputType]));
406
+ return popup.querySelector(".".concat(swalClasses.popup, " > .").concat(swalClasses[inputClass]));
407
407
 
408
408
  case 'checkbox':
409
409
  return popup.querySelector(".".concat(swalClasses.popup, " > .").concat(swalClasses.checkbox, " input"));
@@ -419,7 +419,7 @@
419
419
  }
420
420
  };
421
421
  /**
422
- * @param {HTMLInputElement} input
422
+ * @param {HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement} input
423
423
  */
424
424
 
425
425
  const focusInput = input => {
@@ -434,7 +434,7 @@
434
434
  };
435
435
  /**
436
436
  * @param {HTMLElement | HTMLElement[] | null} target
437
- * @param {string | string[]} classList
437
+ * @param {string | string[] | readonly string[]} classList
438
438
  * @param {boolean} condition
439
439
  */
440
440
 
@@ -459,7 +459,7 @@
459
459
  };
460
460
  /**
461
461
  * @param {HTMLElement | HTMLElement[] | null} target
462
- * @param {string | string[]} classList
462
+ * @param {string | string[] | readonly string[]} classList
463
463
  */
464
464
 
465
465
  const addClass = (target, classList) => {
@@ -467,7 +467,7 @@
467
467
  };
468
468
  /**
469
469
  * @param {HTMLElement | HTMLElement[] | null} target
470
- * @param {string | string[]} classList
470
+ * @param {string | string[] | readonly string[]} classList
471
471
  */
472
472
 
473
473
  const removeClass = (target, classList) => {
@@ -955,22 +955,24 @@
955
955
  };
956
956
 
957
957
  /// <reference path="../../../../sweetalert2.d.ts"/>
958
- const inputTypes = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
958
+ /** @type {InputClass[]} */
959
+
960
+ const inputClasses = ['input', 'file', 'range', 'select', 'radio', 'checkbox', 'textarea'];
959
961
  /**
960
- * @typedef { import("sweetalert2").SweetAlertOptions } SweetAlertOptions
962
+ * @param {SweetAlert2} instance
963
+ * @param {SweetAlertOptions} params
961
964
  */
962
965
 
963
966
  const renderInput = (instance, params) => {
964
967
  const popup = getPopup();
965
968
  const innerParams = privateProps.innerParams.get(instance);
966
969
  const rerender = !innerParams || params.input !== innerParams.input;
967
- inputTypes.forEach(inputType => {
968
- const inputClass = swalClasses[inputType];
969
- const inputContainer = getDirectChildByClass(popup, inputClass); // set attributes
970
+ inputClasses.forEach(inputClass => {
971
+ const inputContainer = getDirectChildByClass(popup, swalClasses[inputClass]); // set attributes
970
972
 
971
- setAttributes(inputType, params.inputAttributes); // set class
973
+ setAttributes(inputClass, params.inputAttributes); // set class
972
974
 
973
- inputContainer.className = inputClass;
975
+ inputContainer.className = swalClasses[inputClass];
974
976
 
975
977
  if (rerender) {
976
978
  hide(inputContainer);
@@ -986,6 +988,9 @@
986
988
  setCustomClass(params);
987
989
  }
988
990
  };
991
+ /**
992
+ * @param {SweetAlertOptions} params
993
+ */
989
994
 
990
995
  const showInput = params => {
991
996
  if (!renderInputType[params.input]) {
@@ -1000,6 +1005,10 @@
1000
1005
  focusInput(input);
1001
1006
  });
1002
1007
  };
1008
+ /**
1009
+ * @param {HTMLInputElement} input
1010
+ */
1011
+
1003
1012
 
1004
1013
  const removeAttributes = input => {
1005
1014
  for (let i = 0; i < input.attributes.length; i++) {
@@ -1010,9 +1019,14 @@
1010
1019
  }
1011
1020
  }
1012
1021
  };
1022
+ /**
1023
+ * @param {InputClass} inputClass
1024
+ * @param {SweetAlertOptions['inputAttributes']} inputAttributes
1025
+ */
1013
1026
 
1014
- const setAttributes = (inputType, inputAttributes) => {
1015
- const input = getInput(getPopup(), inputType);
1027
+
1028
+ const setAttributes = (inputClass, inputAttributes) => {
1029
+ const input = getInput(getPopup(), inputClass);
1016
1030
 
1017
1031
  if (!input) {
1018
1032
  return;
@@ -1024,20 +1038,35 @@
1024
1038
  input.setAttribute(attr, inputAttributes[attr]);
1025
1039
  }
1026
1040
  };
1041
+ /**
1042
+ * @param {SweetAlertOptions} params
1043
+ */
1044
+
1027
1045
 
1028
1046
  const setCustomClass = params => {
1029
1047
  const inputContainer = getInputContainer(params.input);
1030
1048
 
1031
- if (params.customClass) {
1049
+ if (typeof params.customClass === 'object') {
1032
1050
  addClass(inputContainer, params.customClass.input);
1033
1051
  }
1034
1052
  };
1053
+ /**
1054
+ * @param {HTMLInputElement | HTMLTextAreaElement} input
1055
+ * @param {SweetAlertOptions} params
1056
+ */
1057
+
1035
1058
 
1036
1059
  const setInputPlaceholder = (input, params) => {
1037
1060
  if (!input.placeholder || params.inputPlaceholder) {
1038
1061
  input.placeholder = params.inputPlaceholder;
1039
1062
  }
1040
1063
  };
1064
+ /**
1065
+ * @param {Input} input
1066
+ * @param {Input} prependTo
1067
+ * @param {SweetAlertOptions} params
1068
+ */
1069
+
1041
1070
 
1042
1071
  const setInputLabel = (input, prependTo, params) => {
1043
1072
  if (params.inputLabel) {
@@ -1046,60 +1075,88 @@
1046
1075
  const labelClass = swalClasses['input-label'];
1047
1076
  label.setAttribute('for', input.id);
1048
1077
  label.className = labelClass;
1049
- addClass(label, params.customClass.inputLabel);
1078
+
1079
+ if (typeof params.customClass === 'object') {
1080
+ addClass(label, params.customClass.inputLabel);
1081
+ }
1082
+
1050
1083
  label.innerText = params.inputLabel;
1051
1084
  prependTo.insertAdjacentElement('beforebegin', label);
1052
1085
  }
1053
1086
  };
1087
+ /**
1088
+ * @param {SweetAlertOptions['input']} inputType
1089
+ * @returns {HTMLElement}
1090
+ */
1091
+
1054
1092
 
1055
1093
  const getInputContainer = inputType => {
1056
- const inputClass = swalClasses[inputType] ? swalClasses[inputType] : swalClasses.input;
1057
- return getDirectChildByClass(getPopup(), inputClass);
1094
+ return getDirectChildByClass(getPopup(), swalClasses[inputType] || swalClasses.input);
1058
1095
  };
1059
-
1060
- const renderInputType = {};
1061
1096
  /**
1062
- * @param {HTMLInputElement | HTMLTextAreaElement} input
1063
- * @param {SweetAlertOptions} params
1097
+ * @param {HTMLInputElement | HTMLOutputElement | HTMLTextAreaElement} input
1098
+ * @param {SweetAlertOptions['inputValue']} inputValue
1064
1099
  */
1065
1100
 
1066
- const checkAndSetInputValue = (input, params) => {
1067
- if (['string', 'number'].includes(typeof params.inputValue)) {
1068
- input.value = "".concat(params.inputValue);
1069
- } else if (!isPromise(params.inputValue)) {
1070
- warn("Unexpected type of inputValue! Expected \"string\", \"number\" or \"Promise\", got \"".concat(typeof params.inputValue, "\""));
1101
+
1102
+ const checkAndSetInputValue = (input, inputValue) => {
1103
+ if (['string', 'number'].includes(typeof inputValue)) {
1104
+ input.value = "".concat(inputValue);
1105
+ } else if (!isPromise(inputValue)) {
1106
+ warn("Unexpected type of inputValue! Expected \"string\", \"number\" or \"Promise\", got \"".concat(typeof inputValue, "\""));
1071
1107
  }
1072
1108
  };
1109
+ /** @type Record<string, (input: Input | HTMLElement, params: SweetAlertOptions) => Input> */
1110
+
1111
+
1112
+ const renderInputType = {};
1073
1113
  /**
1074
1114
  * @param {HTMLInputElement} input
1075
1115
  * @param {SweetAlertOptions} params
1076
- * @returns
1116
+ * @returns {HTMLInputElement}
1077
1117
  */
1078
1118
 
1079
-
1080
1119
  renderInputType.text = renderInputType.email = renderInputType.password = renderInputType.number = renderInputType.tel = renderInputType.url = (input, params) => {
1081
- checkAndSetInputValue(input, params);
1120
+ checkAndSetInputValue(input, params.inputValue);
1082
1121
  setInputLabel(input, input, params);
1083
1122
  setInputPlaceholder(input, params);
1084
1123
  input.type = params.input;
1085
1124
  return input;
1086
1125
  };
1126
+ /**
1127
+ * @param {HTMLInputElement} input
1128
+ * @param {SweetAlertOptions} params
1129
+ * @returns {HTMLInputElement}
1130
+ */
1131
+
1087
1132
 
1088
1133
  renderInputType.file = (input, params) => {
1089
1134
  setInputLabel(input, input, params);
1090
1135
  setInputPlaceholder(input, params);
1091
1136
  return input;
1092
1137
  };
1138
+ /**
1139
+ * @param {HTMLInputElement} range
1140
+ * @param {SweetAlertOptions} params
1141
+ * @returns {HTMLInputElement}
1142
+ */
1143
+
1093
1144
 
1094
1145
  renderInputType.range = (range, params) => {
1095
1146
  const rangeInput = range.querySelector('input');
1096
1147
  const rangeOutput = range.querySelector('output');
1097
- rangeInput.value = params.inputValue;
1148
+ checkAndSetInputValue(rangeInput, params.inputValue);
1098
1149
  rangeInput.type = params.input;
1099
- rangeOutput.value = params.inputValue;
1150
+ checkAndSetInputValue(rangeOutput, params.inputValue);
1100
1151
  setInputLabel(rangeInput, range, params);
1101
1152
  return range;
1102
1153
  };
1154
+ /**
1155
+ * @param {HTMLSelectElement} select
1156
+ * @param {SweetAlertOptions} params
1157
+ * @returns {HTMLSelectElement}
1158
+ */
1159
+
1103
1160
 
1104
1161
  renderInputType.select = (select, params) => {
1105
1162
  select.textContent = '';
@@ -1116,33 +1173,47 @@
1116
1173
  setInputLabel(select, select, params);
1117
1174
  return select;
1118
1175
  };
1176
+ /**
1177
+ * @param {HTMLInputElement} radio
1178
+ * @returns {HTMLInputElement}
1179
+ */
1180
+
1119
1181
 
1120
1182
  renderInputType.radio = radio => {
1121
1183
  radio.textContent = '';
1122
1184
  return radio;
1123
1185
  };
1186
+ /**
1187
+ * @param {HTMLLabelElement} checkboxContainer
1188
+ * @param {SweetAlertOptions} params
1189
+ * @returns {HTMLInputElement}
1190
+ */
1191
+
1124
1192
 
1125
1193
  renderInputType.checkbox = (checkboxContainer, params) => {
1126
- /** @type {HTMLInputElement} */
1127
1194
  const checkbox = getInput(getPopup(), 'checkbox');
1128
1195
  checkbox.value = '1';
1129
1196
  checkbox.id = swalClasses.checkbox;
1130
1197
  checkbox.checked = Boolean(params.inputValue);
1131
1198
  const label = checkboxContainer.querySelector('span');
1132
1199
  setInnerHtml(label, params.inputPlaceholder);
1133
- return checkboxContainer;
1200
+ return checkbox;
1134
1201
  };
1135
1202
  /**
1136
1203
  * @param {HTMLTextAreaElement} textarea
1137
1204
  * @param {SweetAlertOptions} params
1138
- * @returns
1205
+ * @returns {HTMLTextAreaElement}
1139
1206
  */
1140
1207
 
1141
1208
 
1142
1209
  renderInputType.textarea = (textarea, params) => {
1143
- checkAndSetInputValue(textarea, params);
1210
+ checkAndSetInputValue(textarea, params.inputValue);
1144
1211
  setInputPlaceholder(textarea, params);
1145
1212
  setInputLabel(textarea, textarea, params);
1213
+ /**
1214
+ * @param {HTMLElement} el
1215
+ * @returns {number}
1216
+ */
1146
1217
 
1147
1218
  const getMargin = el => parseInt(window.getComputedStyle(el).marginLeft) + parseInt(window.getComputedStyle(el).marginRight); // https://github.com/sweetalert2/sweetalert2/issues/2291
1148
1219
 
@@ -3467,7 +3538,7 @@
3467
3538
  };
3468
3539
  });
3469
3540
  SweetAlert.DismissReason = DismissReason;
3470
- SweetAlert.version = '11.4.11';
3541
+ SweetAlert.version = '11.4.12';
3471
3542
 
3472
3543
  const Swal = SweetAlert; // @ts-ignore
3473
3544