sweetalert2 11.3.3 → 11.3.4

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.
@@ -12,13 +12,19 @@ export const iOSfix = () => {
12
12
  document.body.style.top = `${offset * -1}px`
13
13
  dom.addClass(document.body, swalClasses.iosfix)
14
14
  lockBodyScroll()
15
- addBottomPaddingForTallPopups() // #1948
15
+ addBottomPaddingForTallPopups()
16
16
  }
17
17
  }
18
18
 
19
+ /**
20
+ * https://github.com/sweetalert2/sweetalert2/issues/1948
21
+ */
19
22
  const addBottomPaddingForTallPopups = () => {
20
- const safari = !navigator.userAgent.match(/(CriOS|FxiOS|EdgiOS|YaBrowser|UCBrowser)/i)
21
- if (safari) {
23
+ const ua = navigator.userAgent
24
+ const iOS = !!ua.match(/iPad/i) || !!ua.match(/iPhone/i)
25
+ const webkit = !!ua.match(/WebKit/i)
26
+ const iOSSafari = iOS && webkit && !ua.match(/CriOS/i)
27
+ if (iOSSafari) {
22
28
  const bottomPanelHeight = 44
23
29
  if (dom.getPopup().scrollHeight > window.innerHeight - bottomPanelHeight) {
24
30
  dom.getContainer().style.paddingBottom = `${bottomPanelHeight}px`
@@ -43,7 +49,7 @@ const lockBodyScroll = () => { // #1246
43
49
  const shouldPreventTouchMove = (event) => {
44
50
  const target = event.target
45
51
  const container = dom.getContainer()
46
- if (isStylys(event) || isZoom(event)) {
52
+ if (isStylus(event) || isZoom(event)) {
47
53
  return false
48
54
  }
49
55
  if (target === container) {
@@ -63,7 +69,13 @@ const shouldPreventTouchMove = (event) => {
63
69
  return false
64
70
  }
65
71
 
66
- const isStylys = (event) => { // #1786
72
+ /**
73
+ * https://github.com/sweetalert2/sweetalert2/issues/1786
74
+ *
75
+ * @param {*} event
76
+ * @returns {boolean}
77
+ */
78
+ const isStylus = (event) => {
67
79
  return event.touches && event.touches.length && event.touches[0].touchType === 'stylus'
68
80
  }
69
81
 
@@ -79,7 +79,7 @@ const fixScrollContainer = (container, scrollbarPadding, initialBodyOverflow) =>
79
79
 
80
80
  const addClasses = (container, popup, params) => {
81
81
  dom.addClass(container, params.showClass.backdrop)
82
- // the workaround with setting/unsetting opacity is needed for #2019 and 2059
82
+ // this workaround with opacity is needed for https://github.com/sweetalert2/sweetalert2/issues/2059
83
83
  popup.style.setProperty('opacity', '0', 'important')
84
84
  dom.show(popup, 'grid')
85
85
  setTimeout(() => {
@@ -16,27 +16,28 @@ export const uniqueArray = (arr) => {
16
16
 
17
17
  /**
18
18
  * Capitalize the first letter of a string
19
- * @param str
19
+ * @param {string} str
20
+ * @returns {string}
20
21
  */
21
22
  export const capitalizeFirstLetter = (str) => str.charAt(0).toUpperCase() + str.slice(1)
22
23
 
23
24
  /**
24
- * Convert NodeList to Array
25
- * @param nodeList
25
+ * @param {NodeList | HTMLCollection | NamedNodeMap} nodeList
26
+ * @returns {array}
26
27
  */
27
28
  export const toArray = (nodeList) => Array.prototype.slice.call(nodeList)
28
29
 
29
30
  /**
30
- * Standardise console warnings
31
- * @param message
31
+ * Standardize console warnings
32
+ * @param {string | array} message
32
33
  */
33
34
  export const warn = (message) => {
34
35
  console.warn(`${consolePrefix} ${typeof message === 'object' ? message.join(' ') : message}`)
35
36
  }
36
37
 
37
38
  /**
38
- * Standardise console errors
39
- * @param message
39
+ * Standardize console errors
40
+ * @param {string} message
40
41
  */
41
42
  export const error = (message) => {
42
43
  console.error(`${consolePrefix} ${message}`)
@@ -51,7 +52,7 @@ const previousWarnOnceMessages = []
51
52
 
52
53
  /**
53
54
  * Show a console warning, but only if it hasn't already been shown
54
- * @param message
55
+ * @param {string} message
55
56
  */
56
57
  export const warnOnce = (message) => {
57
58
  if (!previousWarnOnceMessages.includes(message)) {