@ionic/core 7.5.4-dev.11699469920.1af6ea12 → 7.5.4-dev.11699632730.1e6d9b70

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.
Files changed (121) hide show
  1. package/components/ion-modal.js +2 -2
  2. package/components/ion-select.js +1 -23
  3. package/components/ion-toast.js +67 -417
  4. package/components/overlays.js +1 -2
  5. package/components/radio-group.js +2 -0
  6. package/components/radio.js +40 -2
  7. package/css/ionic.bundle.css +1 -1
  8. package/css/ionic.bundle.css.map +1 -1
  9. package/css/themes/dark.css +135 -0
  10. package/css/themes/dark.css.map +1 -0
  11. package/css/utils.bundle.css +133 -0
  12. package/css/utils.bundle.css.map +1 -1
  13. package/dist/cjs/compare-with-utils-c0444525.js +44 -0
  14. package/dist/cjs/index.cjs.js +1 -1
  15. package/dist/cjs/ion-action-sheet.cjs.entry.js +1 -1
  16. package/dist/cjs/ion-alert.cjs.entry.js +1 -1
  17. package/dist/cjs/ion-datetime_3.cjs.entry.js +1 -1
  18. package/dist/cjs/ion-loading.cjs.entry.js +1 -1
  19. package/dist/cjs/ion-menu_3.cjs.entry.js +1 -1
  20. package/dist/cjs/ion-modal.cjs.entry.js +2 -2
  21. package/dist/cjs/ion-popover.cjs.entry.js +1 -1
  22. package/dist/cjs/ion-radio_2.cjs.entry.js +4 -1
  23. package/dist/cjs/ion-select_3.cjs.entry.js +6 -27
  24. package/dist/cjs/ion-toast.cjs.entry.js +83 -430
  25. package/dist/cjs/ionic.cjs.js +1 -1
  26. package/dist/cjs/loader.cjs.js +1 -1
  27. package/dist/cjs/{overlays-ba1a1e21.js → overlays-d80a2cf2.js} +0 -2
  28. package/dist/collection/components/modal/gestures/swipe-to-close.js +1 -2
  29. package/dist/collection/components/radio/radio.js +3 -2
  30. package/dist/collection/components/radio-group/radio-group.js +24 -0
  31. package/dist/collection/components/select/select.js +2 -24
  32. package/dist/collection/components/toast/animations/ios.enter.js +1 -2
  33. package/dist/collection/components/toast/animations/md.enter.js +1 -2
  34. package/dist/collection/components/toast/animations/utils.js +0 -11
  35. package/dist/collection/components/toast/toast.js +1 -104
  36. package/dist/collection/utils/forms/compare-with-utils.js +39 -0
  37. package/dist/collection/utils/forms/index.js +1 -0
  38. package/dist/collection/utils/overlays.js +0 -1
  39. package/dist/docs.json +43 -38
  40. package/dist/esm/compare-with-utils-4928c09d.js +41 -0
  41. package/dist/esm/index.js +1 -1
  42. package/dist/esm/ion-action-sheet.entry.js +1 -1
  43. package/dist/esm/ion-alert.entry.js +1 -1
  44. package/dist/esm/ion-datetime_3.entry.js +1 -1
  45. package/dist/esm/ion-loading.entry.js +1 -1
  46. package/dist/esm/ion-menu_3.entry.js +1 -1
  47. package/dist/esm/ion-modal.entry.js +2 -2
  48. package/dist/esm/ion-popover.entry.js +1 -1
  49. package/dist/esm/ion-radio_2.entry.js +4 -1
  50. package/dist/esm/ion-select_3.entry.js +2 -23
  51. package/dist/esm/ion-toast.entry.js +66 -413
  52. package/dist/esm/ionic.js +1 -1
  53. package/dist/esm/loader.js +1 -1
  54. package/dist/esm/{overlays-d79b34b4.js → overlays-a31c8878.js} +1 -2
  55. package/dist/esm-es5/compare-with-utils-4928c09d.js +4 -0
  56. package/dist/esm-es5/index.js +1 -1
  57. package/dist/esm-es5/ion-action-sheet.entry.js +1 -1
  58. package/dist/esm-es5/ion-alert.entry.js +1 -1
  59. package/dist/esm-es5/ion-datetime_3.entry.js +1 -1
  60. package/dist/esm-es5/ion-loading.entry.js +1 -1
  61. package/dist/esm-es5/ion-menu_3.entry.js +1 -1
  62. package/dist/esm-es5/ion-modal.entry.js +1 -1
  63. package/dist/esm-es5/ion-popover.entry.js +1 -1
  64. package/dist/esm-es5/ion-radio_2.entry.js +1 -1
  65. package/dist/esm-es5/ion-select_3.entry.js +1 -1
  66. package/dist/esm-es5/ion-toast.entry.js +1 -1
  67. package/dist/esm-es5/ionic.js +1 -1
  68. package/dist/esm-es5/loader.js +1 -1
  69. package/dist/esm-es5/{overlays-d79b34b4.js → overlays-a31c8878.js} +1 -1
  70. package/dist/html.html-data.json +5 -10
  71. package/dist/ionic/index.esm.js +1 -1
  72. package/dist/ionic/ionic.esm.js +1 -1
  73. package/dist/ionic/p-02663394.system.js +1 -1
  74. package/dist/ionic/p-139bd79d.system.entry.js +4 -0
  75. package/dist/ionic/{p-3dedd258.system.entry.js → p-1e59dd04.system.entry.js} +1 -1
  76. package/dist/ionic/{p-938c4956.js → p-307963db.js} +1 -1
  77. package/dist/ionic/{p-1fc6b5a5.system.entry.js → p-3a769110.system.entry.js} +1 -1
  78. package/dist/ionic/p-3bc3d880.system.js +4 -0
  79. package/dist/ionic/p-43716898.js +4 -0
  80. package/dist/ionic/{p-1511dc35.system.js → p-4c75cb48.system.js} +1 -1
  81. package/dist/ionic/p-539c09e8.system.entry.js +4 -0
  82. package/dist/ionic/{p-e525dbea.entry.js → p-53b1930e.entry.js} +1 -1
  83. package/dist/ionic/{p-ab1908ba.system.entry.js → p-59107f99.system.entry.js} +1 -1
  84. package/dist/ionic/p-6b45cfd0.system.entry.js +4 -0
  85. package/dist/ionic/{p-664cc492.entry.js → p-75338011.entry.js} +1 -1
  86. package/dist/ionic/p-7d68e4ea.entry.js +4 -0
  87. package/dist/ionic/{p-78a8e1e8.entry.js → p-8140a084.entry.js} +1 -1
  88. package/dist/ionic/{p-2151a4a4.system.entry.js → p-90020ef0.system.entry.js} +1 -1
  89. package/dist/ionic/{p-53f75103.system.js → p-98c70e3c.system.js} +1 -1
  90. package/dist/ionic/p-999a7271.entry.js +4 -0
  91. package/dist/ionic/p-a4e4dba1.entry.js +4 -0
  92. package/dist/ionic/{p-138a4a93.entry.js → p-b86c6c05.entry.js} +1 -1
  93. package/dist/ionic/p-be499f29.entry.js +4 -0
  94. package/dist/ionic/{p-a9424586.entry.js → p-c09fa14d.entry.js} +1 -1
  95. package/dist/ionic/{p-020dd47f.entry.js → p-c32a6c04.entry.js} +1 -1
  96. package/dist/ionic/{p-81bdfa1c.system.entry.js → p-d54a8393.system.entry.js} +1 -1
  97. package/dist/ionic/p-e66f7d10.system.entry.js +4 -0
  98. package/dist/ionic/{p-cb6c380e.system.entry.js → p-e91c7eb4.system.entry.js} +1 -1
  99. package/dist/types/components/radio-group/radio-group-interface.d.ts +1 -0
  100. package/dist/types/components/radio-group/radio-group.d.ts +8 -1
  101. package/dist/types/components/select/select.d.ts +4 -1
  102. package/dist/types/components/toast/animations/utils.d.ts +0 -9
  103. package/dist/types/components/toast/toast-interface.d.ts +0 -1
  104. package/dist/types/components/toast/toast.d.ts +1 -28
  105. package/dist/types/components.d.ts +14 -14
  106. package/dist/types/utils/forms/compare-with-utils.d.ts +18 -0
  107. package/dist/types/utils/forms/index.d.ts +1 -0
  108. package/dist/types/utils/overlays.d.ts +0 -1
  109. package/hydrate/index.js +107 -436
  110. package/package.json +1 -1
  111. package/dist/collection/components/toast/gestures/swipe-to-dismiss.js +0 -267
  112. package/dist/collection/components/toast/test/swipe-gesture/toast.e2e.js +0 -84
  113. package/dist/ionic/p-344706aa.entry.js +0 -4
  114. package/dist/ionic/p-637d836a.system.entry.js +0 -4
  115. package/dist/ionic/p-6c89025e.system.entry.js +0 -4
  116. package/dist/ionic/p-8414ed31.entry.js +0 -4
  117. package/dist/ionic/p-d075c0aa.system.entry.js +0 -4
  118. package/dist/ionic/p-e3b7a2d0.system.entry.js +0 -4
  119. package/dist/ionic/p-ea1650b0.entry.js +0 -4
  120. package/dist/ionic/p-f2d4e3c8.entry.js +0 -4
  121. package/dist/types/components/toast/gestures/swipe-to-dismiss.d.ts +0 -9
@@ -5,107 +5,18 @@
5
5
 
6
6
  Object.defineProperty(exports, '__esModule', { value: true });
7
7
 
8
- const index$3 = require('./index-73186843.js');
8
+ const index$2 = require('./index-73186843.js');
9
9
  const config = require('./config-d5882735.js');
10
10
  const helpers = require('./helpers-ea4ccbcb.js');
11
11
  const lockController = require('./lock-controller-4ae2eb59.js');
12
12
  const index$1 = require('./index-cc7dfb7c.js');
13
- const overlays = require('./overlays-ba1a1e21.js');
13
+ const overlays = require('./overlays-d80a2cf2.js');
14
14
  const theme = require('./theme-fbc56b3b.js');
15
15
  const ionicGlobal = require('./ionic-global-4538d91c.js');
16
16
  const animation = require('./animation-d101aa7a.js');
17
17
  const index = require('./index-c8d52405.js');
18
- const index$2 = require('./index-0ee995e4.js');
19
18
  require('./framework-delegate-c0873a6f.js');
20
19
  require('./hardware-back-button-b67c8e75.js');
21
- require('./gesture-controller-b46721be.js');
22
-
23
- /**
24
- * Calculate the CSS top and bottom position of the toast, to be used
25
- * as starting points for the animation keyframes.
26
- *
27
- * The default animations for both MD and iOS
28
- * use translateY, which calculates from the
29
- * top edge of the screen. This behavior impacts
30
- * how we compute the offset when a toast has
31
- * position='bottom' since we need to calculate from
32
- * the bottom edge of the screen instead.
33
- *
34
- * @param position The value of the toast's position prop.
35
- * @param positionAnchor The element the toast should be anchored to,
36
- * if applicable.
37
- * @param mode The toast component's mode (md, ios, etc).
38
- * @param toast A reference to the toast element itself.
39
- */
40
- function getAnimationPosition(position, positionAnchor, mode, toast) {
41
- /**
42
- * Start with a predefined offset from the edge the toast will be
43
- * positioned relative to, whether on the screen or anchor element.
44
- */
45
- let offset;
46
- if (mode === 'md') {
47
- offset = position === 'top' ? 8 : -8;
48
- }
49
- else {
50
- offset = position === 'top' ? 10 : -10;
51
- }
52
- /**
53
- * If positionAnchor is defined, add in the distance from the target
54
- * screen edge to the target anchor edge. For position="top", the
55
- * bottom anchor edge is targeted. For position="bottom", the top
56
- * anchor edge is targeted.
57
- */
58
- if (positionAnchor && index.win) {
59
- warnIfAnchorIsHidden(positionAnchor, toast);
60
- const box = positionAnchor.getBoundingClientRect();
61
- if (position === 'top') {
62
- offset += box.bottom;
63
- }
64
- else if (position === 'bottom') {
65
- /**
66
- * Just box.top is the distance from the top edge of the screen
67
- * to the top edge of the anchor. We want to calculate from the
68
- * bottom edge of the screen instead.
69
- */
70
- offset -= index.win.innerHeight - box.top;
71
- }
72
- /**
73
- * We don't include safe area here because that should already be
74
- * accounted for when checking the position of the anchor.
75
- */
76
- return {
77
- top: `${offset}px`,
78
- bottom: `${offset}px`,
79
- };
80
- }
81
- else {
82
- return {
83
- top: `calc(${offset}px + var(--ion-safe-area-top, 0px))`,
84
- bottom: `calc(${offset}px - var(--ion-safe-area-bottom, 0px))`,
85
- };
86
- }
87
- }
88
- /**
89
- * If the anchor element is hidden, getBoundingClientRect()
90
- * will return all 0s for it, which can cause unexpected
91
- * results in the position calculation when animating.
92
- */
93
- function warnIfAnchorIsHidden(positionAnchor, toast) {
94
- if (positionAnchor.offsetParent === null) {
95
- index$1.printIonWarning('The positionAnchor element for ion-toast was found in the DOM, but appears to be hidden. This may lead to unexpected positioning of the toast.', toast);
96
- }
97
- }
98
- /**
99
- * Returns the top offset required to place
100
- * the toast in the middle of the screen.
101
- * Only needed when position="toast".
102
- * @param toastHeight: The height of the ion-toast element
103
- * @param wrapperHeight: The height of the .toast-wrapper element
104
- * inside the toast's shadow root.
105
- */
106
- const getOffsetForMiddlePosition = (toastHeight, wrapperHeight) => {
107
- return Math.floor(toastHeight / 2 - wrapperHeight / 2);
108
- };
109
20
 
110
21
  /**
111
22
  * iOS Toast Enter Animation
@@ -122,7 +33,7 @@ const iosEnterAnimation = (baseEl, opts) => {
122
33
  wrapperAnimation.fromTo('transform', 'translateY(-100%)', `translateY(${top})`);
123
34
  break;
124
35
  case 'middle':
125
- const topPosition = getOffsetForMiddlePosition(baseEl.clientHeight, wrapperEl.clientHeight);
36
+ const topPosition = Math.floor(baseEl.clientHeight / 2 - wrapperEl.clientHeight / 2);
126
37
  wrapperEl.style.top = `${topPosition}px`;
127
38
  wrapperAnimation.fromTo('opacity', 0.01, 1);
128
39
  break;
@@ -173,7 +84,7 @@ const mdEnterAnimation = (baseEl, opts) => {
173
84
  wrapperAnimation.fromTo('opacity', 0.01, 1);
174
85
  break;
175
86
  case 'middle':
176
- const topPosition = getOffsetForMiddlePosition(baseEl.clientHeight, wrapperEl.clientHeight);
87
+ const topPosition = Math.floor(baseEl.clientHeight / 2 - wrapperEl.clientHeight / 2);
177
88
  wrapperEl.style.top = `${topPosition}px`;
178
89
  wrapperAnimation.fromTo('opacity', 0.01, 1);
179
90
  break;
@@ -198,261 +109,80 @@ const mdLeaveAnimation = (baseEl) => {
198
109
  };
199
110
 
200
111
  /**
201
- * Create a gesture that allows the Toast
202
- * to be swiped to dismiss.
203
- * @param el - The Toast element
204
- * @param toastPosition - The last computed position of the Toast. This is computed in the "present" method.
205
- * @param onDismiss - A callback to fire when the Toast was swiped to dismiss.
112
+ * Calculate the CSS top and bottom position of the toast, to be used
113
+ * as starting points for the animation keyframes.
114
+ *
115
+ * The default animations for both MD and iOS
116
+ * use translateY, which calculates from the
117
+ * top edge of the screen. This behavior impacts
118
+ * how we compute the offset when a toast has
119
+ * position='bottom' since we need to calculate from
120
+ * the bottom edge of the screen instead.
121
+ *
122
+ * @param position The value of the toast's position prop.
123
+ * @param positionAnchor The element the toast should be anchored to,
124
+ * if applicable.
125
+ * @param mode The toast component's mode (md, ios, etc).
126
+ * @param toast A reference to the toast element itself.
206
127
  */
207
- const createSwipeToDismissGesture = (el, toastPosition, onDismiss) => {
208
- /**
209
- * Users should swipe on the visible toast wrapper
210
- * rather than on ion-toast which covers the entire screen.
211
- * When testing the class instance the inner wrapper will not
212
- * be defined. As a result, we use a placeholder element in those environments.
213
- */
214
- const wrapperEl = helpers.getElementRoot(el).querySelector('.toast-wrapper');
215
- const hostElHeight = el.clientHeight;
216
- const wrapperElBox = wrapperEl.getBoundingClientRect();
217
- /**
218
- * The maximum amount that
219
- * the toast can be swiped. This should
220
- * account for the wrapper element's height
221
- * too so the toast can be swiped offscreen
222
- * completely.
223
- */
224
- let MAX_SWIPE_DISTANCE = 0;
225
- /**
226
- * The step value at which a toast
227
- * is eligible for dismissing via gesture.
228
- */
229
- const DISMISS_THRESHOLD = 0.5;
230
- /**
231
- * The middle position Toast starts 50% of the way
232
- * through the animation, so we need to use this
233
- * as the starting point for our step values.
234
- */
235
- const STEP_OFFSET = el.position === 'middle' ? 0.5 : 0;
128
+ function getAnimationPosition(position, positionAnchor, mode, toast) {
236
129
  /**
237
- * When the Toast is at the top users will be
238
- * swiping up. As a result, the delta values will be
239
- * negative numbers which will result in negative steps
240
- * and thresholds. As a result, we need to make those numbers
241
- * positive.
130
+ * Start with a predefined offset from the edge the toast will be
131
+ * positioned relative to, whether on the screen or anchor element.
242
132
  */
243
- const INVERSION_FACTOR = el.position === 'top' ? -1 : 1;
133
+ let offset;
134
+ if (mode === 'md') {
135
+ offset = position === 'top' ? 8 : -8;
136
+ }
137
+ else {
138
+ offset = position === 'top' ? 10 : -10;
139
+ }
244
140
  /**
245
- * The top offset that places the
246
- * toast in the middle of the screen.
247
- * Only needed when position="middle".
141
+ * If positionAnchor is defined, add in the distance from the target
142
+ * screen edge to the target anchor edge. For position="top", the
143
+ * bottom anchor edge is targeted. For position="bottom", the top
144
+ * anchor edge is targeted.
248
145
  */
249
- const topPosition = getOffsetForMiddlePosition(hostElHeight, wrapperElBox.height);
250
- const SWIPE_UP_DOWN_KEYFRAMES = [
251
- { offset: 0, transform: `translateY(-${topPosition + wrapperElBox.height}px)` },
252
- { offset: 0.5, transform: `translateY(0px)` },
253
- { offset: 1, transform: `translateY(${topPosition + wrapperElBox.height}px)` },
254
- ];
255
- const swipeAnimation = animation.createAnimation('toast-swipe-to-dismiss-animation')
256
- .addElement(wrapperEl)
257
- /**
258
- * The specific value here does not actually
259
- * matter. We just need this to be a positive
260
- * value so the animation does not jump
261
- * to the end when the user beings to drag.
262
- */
263
- .duration(100);
264
- switch (el.position) {
265
- case 'middle':
266
- MAX_SWIPE_DISTANCE = hostElHeight + wrapperElBox.height;
267
- swipeAnimation.keyframes(SWIPE_UP_DOWN_KEYFRAMES);
268
- /**
269
- * Toast can be swiped up or down but
270
- * should start in the middle of the screen.
271
- */
272
- swipeAnimation.progressStart(true, 0.5);
273
- break;
274
- case 'top':
275
- /**
276
- * The bottom edge of the wrapper
277
- * includes the distance between the top
278
- * of the screen and the top of the wrapper
279
- * as well as the wrapper height so the wrapper
280
- * can be dragged fully offscreen.
281
- */
282
- MAX_SWIPE_DISTANCE = wrapperElBox.bottom;
283
- swipeAnimation.keyframes([
284
- { offset: 0, transform: `translateY(${toastPosition.top})` },
285
- { offset: 1, transform: 'translateY(-100%)' },
286
- ]);
287
- swipeAnimation.progressStart(true, 0);
288
- break;
289
- case 'bottom':
290
- default:
291
- /**
292
- * This computes the distance between the
293
- * top of the wrapper and the bottom of the
294
- * screen including the height of the wrapper
295
- * element so it can be dragged fully offscreen.
296
- */
297
- MAX_SWIPE_DISTANCE = hostElHeight - wrapperElBox.top;
298
- swipeAnimation.keyframes([
299
- { offset: 0, transform: `translateY(${toastPosition.bottom})` },
300
- { offset: 1, transform: 'translateY(100%)' },
301
- ]);
302
- swipeAnimation.progressStart(true, 0);
303
- break;
304
- }
305
- const computeStep = (delta) => {
306
- return (delta * INVERSION_FACTOR) / MAX_SWIPE_DISTANCE;
307
- };
308
- const onMove = (detail) => {
309
- const step = STEP_OFFSET + computeStep(detail.deltaY);
310
- swipeAnimation.progressStep(step);
311
- };
312
- const onEnd = (detail) => {
313
- const velocity = detail.velocityY;
314
- const threshold = ((detail.deltaY + velocity * 1000) / MAX_SWIPE_DISTANCE) * INVERSION_FACTOR;
315
- /**
316
- * Disable the gesture for the remainder of the animation.
317
- * It will be re-enabled if the toast animates back to
318
- * its initial presented position.
319
- */
320
- gesture.enable(false);
321
- let shouldDismiss = true;
322
- let playTo = 1;
323
- let step = 0;
324
- let remainingDistance = 0;
325
- if (el.position === 'middle') {
326
- /**
327
- * A middle positioned Toast appears
328
- * in the middle of the screen (at animation offset 0.5).
329
- * As a result, the threshold will be calculated relative
330
- * to this starting position. In other words at animation offset 0.5
331
- * the threshold will be 0. We want the middle Toast to be eligible
332
- * for dismiss when the user has swiped either half way up or down the
333
- * screen. As a result, we divide DISMISS_THRESHOLD in half. We also
334
- * consider when the threshold is a negative in the event the
335
- * user drags up (since the deltaY will also be negative).
336
- */
337
- shouldDismiss = threshold >= DISMISS_THRESHOLD / 2 || threshold <= -DISMISS_THRESHOLD / 2;
338
- /**
339
- * Since we are replacing the keyframes
340
- * below the animation always starts from
341
- * the beginning of the new keyframes.
342
- * Similarly, we are always playing to
343
- * the end of the new keyframes.
344
- */
345
- playTo = 1;
346
- step = 0;
347
- /**
348
- * The Toast should animate from wherever its
349
- * current position is to the desired end state.
350
- *
351
- * To begin, we get the current position of the
352
- * Toast for its starting state.
353
- */
354
- const wrapperElBox = wrapperEl.getBoundingClientRect();
355
- const startOffset = wrapperElBox.top - topPosition;
356
- const startPosition = `${startOffset}px`;
357
- /**
358
- * If the deltaY is negative then the user is swiping
359
- * up, so the Toast should animate to the top of the screen.
360
- * If the deltaY is positive then the user is swiping
361
- * down, so the Toast should animate to the bottom of the screen.
362
- * We also account for when the deltaY is 0, but realistically
363
- * that should never happen because it means the user did not drag
364
- * the toast.
365
- */
366
- const offsetFactor = detail.deltaY <= 0 ? -1 : 1;
367
- const endOffset = (topPosition + wrapperElBox.height) * offsetFactor;
368
- /**
369
- * If the Toast should dismiss
370
- * then we need to figure out which edge of
371
- * the screen it should animate towards.
372
- * By default, the Toast will come
373
- * back to its default state in the
374
- * middle of the screen.
375
- */
376
- const endPosition = shouldDismiss ? `${endOffset}px` : '0px';
377
- const KEYFRAMES = [
378
- { offset: 0, transform: `translateY(${startPosition})` },
379
- { offset: 1, transform: `translateY(${endPosition})` },
380
- ];
381
- swipeAnimation.keyframes(KEYFRAMES);
382
- /**
383
- * Compute the remaining amount of pixels the
384
- * toast needs to move to be fully dismissed.
385
- */
386
- remainingDistance = endOffset - startOffset;
146
+ if (positionAnchor && index.win) {
147
+ warnIfAnchorIsHidden(positionAnchor, toast);
148
+ const box = positionAnchor.getBoundingClientRect();
149
+ if (position === 'top') {
150
+ offset += box.bottom;
387
151
  }
388
- else {
389
- shouldDismiss = threshold >= DISMISS_THRESHOLD;
390
- playTo = shouldDismiss ? 1 : 0;
391
- step = computeStep(detail.deltaY);
152
+ else if (position === 'bottom') {
392
153
  /**
393
- * Compute the remaining amount of pixels the
394
- * toast needs to move to be fully dismissed.
154
+ * Just box.top is the distance from the top edge of the screen
155
+ * to the top edge of the anchor. We want to calculate from the
156
+ * bottom edge of the screen instead.
395
157
  */
396
- const remainingStepAmount = shouldDismiss ? 1 - step : step;
397
- remainingDistance = remainingStepAmount * MAX_SWIPE_DISTANCE;
158
+ offset -= index.win.innerHeight - box.top;
398
159
  }
399
160
  /**
400
- * The animation speed should depend on how quickly
401
- * the user flicks the toast across the screen. However,
402
- * it should be no slower than 200ms.
403
- * We use Math.abs on the remainingDistance because that value
404
- * can be negative when swiping up on a middle position toast.
405
- */
406
- const duration = Math.min(Math.abs(remainingDistance) / Math.abs(velocity), 200);
407
- swipeAnimation
408
- .onFinish(() => {
409
- if (shouldDismiss) {
410
- onDismiss();
411
- swipeAnimation.destroy();
412
- }
413
- else {
414
- if (el.position === 'middle') {
415
- /**
416
- * If the toast snapped back to
417
- * the middle of the screen we need
418
- * to reset the keyframes
419
- * so the toast can be swiped
420
- * up or down again.
421
- */
422
- swipeAnimation.keyframes(SWIPE_UP_DOWN_KEYFRAMES).progressStart(true, 0.5);
423
- }
424
- else {
425
- swipeAnimation.progressStart(true, 0);
426
- }
427
- /**
428
- * If the toast did not dismiss then
429
- * the user should be able to swipe again.
430
- */
431
- gesture.enable(true);
432
- }
433
- /**
434
- * This must be a one time callback
435
- * otherwise a new callback will
436
- * be added every time onEnd runs.
437
- */
438
- }, { oneTimeCallback: true })
439
- .progressEnd(playTo, step, duration);
440
- };
441
- const gesture = index$2.createGesture({
442
- el: wrapperEl,
443
- gestureName: 'toast-swipe-to-dismiss',
444
- gesturePriority: overlays.OVERLAY_GESTURE_PRIORITY,
445
- /**
446
- * Toast only supports vertical swipes.
447
- * This needs to be updated if we later
448
- * support horizontal swipes.
161
+ * We don't include safe area here because that should already be
162
+ * accounted for when checking the position of the anchor.
449
163
  */
450
- direction: 'y',
451
- onMove,
452
- onEnd,
453
- });
454
- return gesture;
455
- };
164
+ return {
165
+ top: `${offset}px`,
166
+ bottom: `${offset}px`,
167
+ };
168
+ }
169
+ else {
170
+ return {
171
+ top: `calc(${offset}px + var(--ion-safe-area-top, 0px))`,
172
+ bottom: `calc(${offset}px - var(--ion-safe-area-bottom, 0px))`,
173
+ };
174
+ }
175
+ }
176
+ /**
177
+ * If the anchor element is hidden, getBoundingClientRect()
178
+ * will return all 0s for it, which can cause unexpected
179
+ * results in the position calculation when animating.
180
+ */
181
+ function warnIfAnchorIsHidden(positionAnchor, toast) {
182
+ if (positionAnchor.offsetParent === null) {
183
+ index$1.printIonWarning('The positionAnchor element for ion-toast was found in the DOM, but appears to be hidden. This may lead to unexpected positioning of the toast.', toast);
184
+ }
185
+ }
456
186
 
457
187
  const toastIosCss = ":host{--border-width:0;--border-style:none;--border-color:initial;--box-shadow:none;--min-width:auto;--width:auto;--min-height:auto;--height:auto;--max-height:auto;--white-space:normal;top:0;display:block;position:absolute;width:100%;height:100%;outline:none;color:var(--color);font-family:var(--ion-font-family, inherit);contain:strict;z-index:1001;pointer-events:none}@supports (inset-inline-start: 0){:host{inset-inline-start:0}}@supports not (inset-inline-start: 0){:host{left:0}:host-context([dir=rtl]){left:unset;right:unset;right:0}@supports selector(:dir(rtl)){:host(:dir(rtl)){left:unset;right:unset;right:0}}}:host(.overlay-hidden){display:none}:host(.ion-color){--button-color:inherit;color:var(--ion-color-contrast)}:host(.ion-color) .toast-button-cancel{color:inherit}:host(.ion-color) .toast-wrapper{background:var(--ion-color-base)}.toast-wrapper{border-radius:var(--border-radius);width:var(--width);min-width:var(--min-width);max-width:var(--max-width);height:var(--height);min-height:var(--min-height);max-height:var(--max-height);border-width:var(--border-width);border-style:var(--border-style);border-color:var(--border-color);background:var(--background);-webkit-box-shadow:var(--box-shadow);box-shadow:var(--box-shadow)}@supports (inset-inline-start: 0){.toast-wrapper{inset-inline-start:var(--start);inset-inline-end:var(--end)}}@supports not (inset-inline-start: 0){.toast-wrapper{left:var(--start);right:var(--end)}:host-context([dir=rtl]) .toast-wrapper{left:unset;right:unset;left:var(--end);right:var(--start)}[dir=rtl] .toast-wrapper{left:unset;right:unset;left:var(--end);right:var(--start)}@supports selector(:dir(rtl)){.toast-wrapper:dir(rtl){left:unset;right:unset;left:var(--end);right:var(--start)}}}.toast-wrapper.toast-top{-webkit-transform:translate3d(0, -100%, 0);transform:translate3d(0, -100%, 0);top:0}.toast-wrapper.toast-bottom{-webkit-transform:translate3d(0, 100%, 0);transform:translate3d(0, 100%, 0);bottom:0}.toast-container{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;pointer-events:auto;height:inherit;min-height:inherit;max-height:inherit;contain:content}.toast-layout-stacked .toast-container{-ms-flex-wrap:wrap;flex-wrap:wrap}.toast-layout-baseline .toast-content{display:-ms-flexbox;display:flex;-ms-flex:1;flex:1;-ms-flex-direction:column;flex-direction:column;-ms-flex-pack:center;justify-content:center}.toast-icon{-webkit-margin-start:16px;margin-inline-start:16px}.toast-content{min-width:0}.toast-message{-ms-flex:1;flex:1;white-space:var(--white-space)}.toast-button-group{display:-ms-flexbox;display:flex}.toast-layout-stacked .toast-button-group{-ms-flex-pack:end;justify-content:end;width:100%}.toast-button{border:0;outline:none;color:var(--button-color);z-index:0}.toast-icon,.toast-button-icon{font-size:1.4em}.toast-button-inner{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center}@media (any-hover: hover){.toast-button:hover{cursor:pointer}}:host{--background:var(--ion-color-step-50, #f2f2f2);--border-radius:14px;--button-color:var(--ion-color-primary, #3880ff);--color:var(--ion-color-step-850, #262626);--max-width:700px;--max-height:478px;--start:10px;--end:10px;font-size:clamp(14px, 0.875rem, 43.4px)}.toast-wrapper{-webkit-margin-start:auto;margin-inline-start:auto;-webkit-margin-end:auto;margin-inline-end:auto;margin-top:auto;margin-bottom:auto;display:block;position:absolute;z-index:10}@supports ((-webkit-backdrop-filter: blur(0)) or (backdrop-filter: blur(0))){:host(.toast-translucent) .toast-wrapper{background:rgba(var(--ion-background-color-rgb, 255, 255, 255), 0.8);-webkit-backdrop-filter:saturate(180%) blur(20px);backdrop-filter:saturate(180%) blur(20px)}:host(.ion-color.toast-translucent) .toast-wrapper{background:rgba(var(--ion-color-base-rgb), 0.8)}}.toast-wrapper.toast-middle{opacity:0.01}.toast-content{-webkit-padding-start:15px;padding-inline-start:15px;-webkit-padding-end:15px;padding-inline-end:15px;padding-top:15px;padding-bottom:15px}.toast-header{margin-bottom:2px;font-weight:500}.toast-button{-webkit-padding-start:15px;padding-inline-start:15px;-webkit-padding-end:15px;padding-inline-end:15px;padding-top:10px;padding-bottom:10px;min-height:44px;-webkit-transition:background-color, opacity 100ms linear;transition:background-color, opacity 100ms linear;border:0;background-color:transparent;font-family:var(--ion-font-family);font-size:clamp(17px, 1.0625rem, 21.998px);font-weight:500;overflow:hidden}.toast-button.ion-activated{opacity:0.4}@media (any-hover: hover){.toast-button:hover{opacity:0.6}}";
458
188
 
@@ -460,15 +190,15 @@ const toastMdCss = ":host{--border-width:0;--border-style:none;--border-color:in
460
190
 
461
191
  const Toast = class {
462
192
  constructor(hostRef) {
463
- index$3.registerInstance(this, hostRef);
464
- this.didPresent = index$3.createEvent(this, "ionToastDidPresent", 7);
465
- this.willPresent = index$3.createEvent(this, "ionToastWillPresent", 7);
466
- this.willDismiss = index$3.createEvent(this, "ionToastWillDismiss", 7);
467
- this.didDismiss = index$3.createEvent(this, "ionToastDidDismiss", 7);
468
- this.didPresentShorthand = index$3.createEvent(this, "didPresent", 7);
469
- this.willPresentShorthand = index$3.createEvent(this, "willPresent", 7);
470
- this.willDismissShorthand = index$3.createEvent(this, "willDismiss", 7);
471
- this.didDismissShorthand = index$3.createEvent(this, "didDismiss", 7);
193
+ index$2.registerInstance(this, hostRef);
194
+ this.didPresent = index$2.createEvent(this, "ionToastDidPresent", 7);
195
+ this.willPresent = index$2.createEvent(this, "ionToastWillPresent", 7);
196
+ this.willDismiss = index$2.createEvent(this, "ionToastWillDismiss", 7);
197
+ this.didDismiss = index$2.createEvent(this, "ionToastDidDismiss", 7);
198
+ this.didPresentShorthand = index$2.createEvent(this, "didPresent", 7);
199
+ this.willPresentShorthand = index$2.createEvent(this, "willPresent", 7);
200
+ this.willDismissShorthand = index$2.createEvent(this, "willDismiss", 7);
201
+ this.didDismissShorthand = index$2.createEvent(this, "didDismiss", 7);
472
202
  this.delegateController = overlays.createDelegateController(this);
473
203
  this.lockController = lockController.createLockController();
474
204
  this.triggerController = overlays.createTriggerController();
@@ -481,41 +211,6 @@ const Toast = class {
481
211
  this.callButtonHandler(cancelButton);
482
212
  }
483
213
  };
484
- /**
485
- * Create a new swipe gesture so Toast
486
- * can be swiped to dismiss.
487
- */
488
- this.createSwipeGesture = (toastPosition) => {
489
- const gesture = (this.gesture = createSwipeToDismissGesture(this.el, toastPosition, () => {
490
- /**
491
- * If the gesture completed then
492
- * we should dismiss the toast.
493
- */
494
- this.dismiss(undefined, overlays.GESTURE);
495
- }));
496
- gesture.enable(true);
497
- };
498
- /**
499
- * Destroy an existing swipe gesture
500
- * so Toast can no longer be swiped to dismiss.
501
- */
502
- this.destroySwipeGesture = () => {
503
- const { gesture } = this;
504
- if (gesture === undefined) {
505
- return;
506
- }
507
- gesture.destroy();
508
- this.gesture = undefined;
509
- };
510
- /**
511
- * Returns `true` if swipeGesture
512
- * is configured to a value that enables the swipe behavior.
513
- * Returns `false` otherwise.
514
- */
515
- this.prefersSwipeGesture = () => {
516
- const { swipeGesture } = this;
517
- return swipeGesture === 'vertical';
518
- };
519
214
  this.revealContentToScreenReader = false;
520
215
  this.overlayIndex = undefined;
521
216
  this.delegate = undefined;
@@ -536,37 +231,9 @@ const Toast = class {
536
231
  this.animated = true;
537
232
  this.icon = undefined;
538
233
  this.htmlAttributes = undefined;
539
- this.swipeGesture = undefined;
540
234
  this.isOpen = false;
541
235
  this.trigger = undefined;
542
236
  }
543
- swipeGestureChanged() {
544
- /**
545
- * If the Toast is presented, then we need to destroy
546
- * any actives gestures before a new gesture is potentially
547
- * created below.
548
- *
549
- * If the Toast is dismissed, then no gesture should be available
550
- * since the Toast is not visible. This case should never
551
- * happen since the "dismiss" method handles destroying
552
- * any active swipe gestures, but we keep this code
553
- * around to handle the first case.
554
- */
555
- this.destroySwipeGesture();
556
- /**
557
- * A new swipe gesture should only be created
558
- * if the Toast is presented. If the Toast is not
559
- * yet presented then the "present" method will
560
- * handle calling the swipe gesture setup function.
561
- */
562
- if (this.presented && this.prefersSwipeGesture()) {
563
- /**
564
- * If the Toast is presented then
565
- * lastPresentedPosition is defined.
566
- */
567
- this.createSwipeGesture(this.lastPresentedPosition);
568
- }
569
- }
570
237
  onIsOpenChange(newValue, oldValue) {
571
238
  if (newValue === true && oldValue === false) {
572
239
  this.present();
@@ -628,14 +295,6 @@ const Toast = class {
628
295
  if (this.duration > 0) {
629
296
  this.durationTimeout = setTimeout(() => this.dismiss(undefined, 'timeout'), this.duration);
630
297
  }
631
- /**
632
- * If the Toast has a swipe gesture then we can
633
- * create the gesture so users can swipe the
634
- * presented Toast.
635
- */
636
- if (this.prefersSwipeGesture()) {
637
- this.createSwipeGesture(animationPosition);
638
- }
639
298
  unlock();
640
299
  }
641
300
  /**
@@ -670,11 +329,6 @@ const Toast = class {
670
329
  this.revealContentToScreenReader = false;
671
330
  }
672
331
  this.lastPresentedPosition = undefined;
673
- /**
674
- * If the Toast has a swipe gesture then we can
675
- * safely destroy it now that it is dismissed.
676
- */
677
- this.destroySwipeGesture();
678
332
  unlock();
679
333
  return dismissed;
680
334
  }
@@ -773,7 +427,7 @@ const Toast = class {
773
427
  'toast-button-group': true,
774
428
  [`toast-button-group-${side}`]: true,
775
429
  };
776
- return (index$3.h("div", { class: buttonGroupsClasses }, buttons.map((b) => (index$3.h("button", Object.assign({}, b.htmlAttributes, { type: "button", class: buttonClass(b), tabIndex: 0, onClick: () => this.buttonClick(b), part: buttonPart(b) }), index$3.h("div", { class: "toast-button-inner" }, b.icon && (index$3.h("ion-icon", { "aria-hidden": "true", icon: b.icon, slot: b.text === undefined ? 'icon-only' : undefined, class: "toast-button-icon" })), b.text), mode === 'md' && (index$3.h("ion-ripple-effect", { type: b.icon !== undefined && b.text === undefined ? 'unbounded' : 'bounded' })))))));
430
+ return (index$2.h("div", { class: buttonGroupsClasses }, buttons.map((b) => (index$2.h("button", Object.assign({}, b.htmlAttributes, { type: "button", class: buttonClass(b), tabIndex: 0, onClick: () => this.buttonClick(b), part: buttonPart(b) }), index$2.h("div", { class: "toast-button-inner" }, b.icon && (index$2.h("ion-icon", { "aria-hidden": "true", icon: b.icon, slot: b.text === undefined ? 'icon-only' : undefined, class: "toast-button-icon" })), b.text), mode === 'md' && (index$2.h("ion-ripple-effect", { type: b.icon !== undefined && b.text === undefined ? 'unbounded' : 'bounded' })))))));
777
431
  }
778
432
  /**
779
433
  * Render the `message` property.
@@ -783,9 +437,9 @@ const Toast = class {
783
437
  renderToastMessage(key, ariaHidden = null) {
784
438
  const { customHTMLEnabled, message } = this;
785
439
  if (customHTMLEnabled) {
786
- return (index$3.h("div", { key: key, "aria-hidden": ariaHidden, class: "toast-message", part: "message", innerHTML: config.sanitizeDOMString(message) }));
440
+ return (index$2.h("div", { key: key, "aria-hidden": ariaHidden, class: "toast-message", part: "message", innerHTML: config.sanitizeDOMString(message) }));
787
441
  }
788
- return (index$3.h("div", { key: key, "aria-hidden": ariaHidden, class: "toast-message", part: "message" }, message));
442
+ return (index$2.h("div", { key: key, "aria-hidden": ariaHidden, class: "toast-message", part: "message" }, message));
789
443
  }
790
444
  /**
791
445
  * Render the `header` property.
@@ -793,7 +447,7 @@ const Toast = class {
793
447
  * @param ariaHidden - If "true" then content will be hidden from screen readers.
794
448
  */
795
449
  renderHeader(key, ariaHidden = null) {
796
- return (index$3.h("div", { key: key, class: "toast-header", "aria-hidden": ariaHidden, part: "header" }, this.header));
450
+ return (index$2.h("div", { key: key, class: "toast-header", "aria-hidden": ariaHidden, part: "header" }, this.header));
797
451
  }
798
452
  render() {
799
453
  const { layout, el, revealContentToScreenReader, header, message } = this;
@@ -813,13 +467,12 @@ const Toast = class {
813
467
  if (layout === 'stacked' && startButtons.length > 0 && endButtons.length > 0) {
814
468
  index$1.printIonWarning('This toast is using start and end buttons with the stacked toast layout. We recommend following the best practice of using either start or end buttons with the stacked toast layout.', el);
815
469
  }
816
- return (index$3.h(index$3.Host, Object.assign({ tabindex: "-1" }, this.htmlAttributes, { style: {
470
+ return (index$2.h(index$2.Host, Object.assign({ tabindex: "-1" }, this.htmlAttributes, { style: {
817
471
  zIndex: `${60000 + this.overlayIndex}`,
818
- }, class: theme.createColorClasses(this.color, Object.assign(Object.assign({ [mode]: true }, theme.getClassMap(this.cssClass)), { 'overlay-hidden': true, 'toast-translucent': this.translucent })), onIonToastWillDismiss: this.dispatchCancelHandler }), index$3.h("div", { class: wrapperClass }, index$3.h("div", { class: "toast-container", part: "container" }, this.renderButtons(startButtons, 'start'), this.icon !== undefined && (index$3.h("ion-icon", { class: "toast-icon", part: "icon", icon: this.icon, lazy: false, "aria-hidden": "true" })), index$3.h("div", { class: "toast-content", role: "status", "aria-atomic": "true", "aria-live": "polite" }, !revealContentToScreenReader && header !== undefined && this.renderHeader('oldHeader', 'true'), !revealContentToScreenReader && message !== undefined && this.renderToastMessage('oldMessage', 'true'), revealContentToScreenReader && header !== undefined && this.renderHeader('header'), revealContentToScreenReader && message !== undefined && this.renderToastMessage('header')), this.renderButtons(endButtons, 'end')))));
472
+ }, class: theme.createColorClasses(this.color, Object.assign(Object.assign({ [mode]: true }, theme.getClassMap(this.cssClass)), { 'overlay-hidden': true, 'toast-translucent': this.translucent })), onIonToastWillDismiss: this.dispatchCancelHandler }), index$2.h("div", { class: wrapperClass }, index$2.h("div", { class: "toast-container", part: "container" }, this.renderButtons(startButtons, 'start'), this.icon !== undefined && (index$2.h("ion-icon", { class: "toast-icon", part: "icon", icon: this.icon, lazy: false, "aria-hidden": "true" })), index$2.h("div", { class: "toast-content", role: "status", "aria-atomic": "true", "aria-live": "polite" }, !revealContentToScreenReader && header !== undefined && this.renderHeader('oldHeader', 'true'), !revealContentToScreenReader && message !== undefined && this.renderToastMessage('oldMessage', 'true'), revealContentToScreenReader && header !== undefined && this.renderHeader('header'), revealContentToScreenReader && message !== undefined && this.renderToastMessage('header')), this.renderButtons(endButtons, 'end')))));
819
473
  }
820
- get el() { return index$3.getElement(this); }
474
+ get el() { return index$2.getElement(this); }
821
475
  static get watchers() { return {
822
- "swipeGesture": ["swipeGestureChanged"],
823
476
  "isOpen": ["onIsOpenChange"],
824
477
  "trigger": ["triggerChanged"]
825
478
  }; }