ion-alert.cjs.entry.js 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. /*!
  2. * (C) Ionic http://ionicframework.com - MIT License
  3. */
  4. 'use strict';
  5. Object.defineProperty(exports, '__esModule', { value: true });
  6. const index = require('./index-2e236a04.js');
  7. const config = require('./config-f6225ae7.js');
  8. const buttonActive = require('./button-active-43e2b419.js');
  9. const helpers = require('./helpers-8a48fdea.js');
  10. const lockController = require('./lock-controller-6585a42a.js');
  11. const index$1 = require('./index-cc858e97.js');
  12. const overlays = require('./overlays-4c291a05.js');
  13. const theme = require('./theme-d1c573d2.js');
  14. const ionicGlobal = require('./ionic-global-6dea5a96.js');
  15. const animation = require('./animation-ab2d3449.js');
  16. require('./haptic-f6b37aa3.js');
  17. require('./capacitor-c04564bf.js');
  18. require('./index-c8d52405.js');
  19. require('./index-ee07ed59.js');
  20. require('./gesture-controller-9436f482.js');
  21. require('./hardware-back-button-3d2b1004.js');
  22. require('./framework-delegate-862d9d00.js');
  23. /**
  24. * iOS Alert Enter Animation
  25. */
  26. const iosEnterAnimation = (baseEl) => {
  27. const baseAnimation = animation.createAnimation();
  28. const backdropAnimation = animation.createAnimation();
  29. const wrapperAnimation = animation.createAnimation();
  30. backdropAnimation
  31. .addElement(baseEl.querySelector('ion-backdrop'))
  32. .fromTo('opacity', 0.01, 'var(--backdrop-opacity)')
  33. .beforeStyles({
  34. 'pointer-events': 'none',
  35. })
  36. .afterClearStyles(['pointer-events']);
  37. wrapperAnimation.addElement(baseEl.querySelector('.alert-wrapper')).keyframes([
  38. { offset: 0, opacity: '0.01', transform: 'scale(1.1)' },
  39. { offset: 1, opacity: '1', transform: 'scale(1)' },
  40. ]);
  41. return baseAnimation
  42. .addElement(baseEl)
  43. .easing('ease-in-out')
  44. .duration(200)
  45. .addAnimation([backdropAnimation, wrapperAnimation]);
  46. };
  47. /**
  48. * iOS Alert Leave Animation
  49. */
  50. const iosLeaveAnimation = (baseEl) => {
  51. const baseAnimation = animation.createAnimation();
  52. const backdropAnimation = animation.createAnimation();
  53. const wrapperAnimation = animation.createAnimation();
  54. backdropAnimation.addElement(baseEl.querySelector('ion-backdrop')).fromTo('opacity', 'var(--backdrop-opacity)', 0);
  55. wrapperAnimation.addElement(baseEl.querySelector('.alert-wrapper')).keyframes([
  56. { offset: 0, opacity: 0.99, transform: 'scale(1)' },
  57. { offset: 1, opacity: 0, transform: 'scale(0.9)' },
  58. ]);
  59. return baseAnimation
  60. .addElement(baseEl)
  61. .easing('ease-in-out')
  62. .duration(200)
  63. .addAnimation([backdropAnimation, wrapperAnimation]);
  64. };
  65. /**
  66. * Md Alert Enter Animation
  67. */
  68. const mdEnterAnimation = (baseEl) => {
  69. const baseAnimation = animation.createAnimation();
  70. const backdropAnimation = animation.createAnimation();
  71. const wrapperAnimation = animation.createAnimation();
  72. backdropAnimation
  73. .addElement(baseEl.querySelector('ion-backdrop'))
  74. .fromTo('opacity', 0.01, 'var(--backdrop-opacity)')
  75. .beforeStyles({
  76. 'pointer-events': 'none',
  77. })
  78. .afterClearStyles(['pointer-events']);
  79. wrapperAnimation.addElement(baseEl.querySelector('.alert-wrapper')).keyframes([
  80. { offset: 0, opacity: '0.01', transform: 'scale(0.9)' },
  81. { offset: 1, opacity: '1', transform: 'scale(1)' },
  82. ]);
  83. return baseAnimation
  84. .addElement(baseEl)
  85. .easing('ease-in-out')
  86. .duration(150)
  87. .addAnimation([backdropAnimation, wrapperAnimation]);
  88. };
  89. /**
  90. * Md Alert Leave Animation
  91. */
  92. const mdLeaveAnimation = (baseEl) => {
  93. const baseAnimation = animation.createAnimation();
  94. const backdropAnimation = animation.createAnimation();
  95. const wrapperAnimation = animation.createAnimation();
  96. backdropAnimation.addElement(baseEl.querySelector('ion-backdrop')).fromTo('opacity', 'var(--backdrop-opacity)', 0);
  97. wrapperAnimation.addElement(baseEl.querySelector('.alert-wrapper')).fromTo('opacity', 0.99, 0);
  98. return baseAnimation
  99. .addElement(baseEl)
  100. .easing('ease-in-out')
  101. .duration(150)
  102. .addAnimation([backdropAnimation, wrapperAnimation]);
  103. };
  104. const alertIosCss = ".sc-ion-alert-ios-h{--min-width:250px;--width:auto;--min-height:auto;--height:auto;--max-height:90%;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;left:0;right:0;top:0;bottom:0;display:-ms-flexbox;display:flex;position:absolute;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;outline:none;font-family:var(--ion-font-family, inherit);contain:strict;-ms-touch-action:none;touch-action:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;z-index:1001}.overlay-hidden.sc-ion-alert-ios-h{display:none}.alert-top.sc-ion-alert-ios-h{padding-top:50px;-ms-flex-align:start;align-items:flex-start}.alert-wrapper.sc-ion-alert-ios{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;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);background:var(--background);contain:content;opacity:0;z-index:10}.alert-title.sc-ion-alert-ios{margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;padding-left:0;padding-right:0;padding-top:0;padding-bottom:0}.alert-sub-title.sc-ion-alert-ios{margin-left:0;margin-right:0;margin-top:5px;margin-bottom:0;padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;font-weight:normal}.alert-message.sc-ion-alert-ios,.alert-input-group.sc-ion-alert-ios{-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-overflow-scrolling:touch;overflow-y:auto;overscroll-behavior-y:contain}.alert-checkbox-label.sc-ion-alert-ios,.alert-radio-label.sc-ion-alert-ios{overflow-wrap:anywhere}@media (any-pointer: coarse){.alert-checkbox-group.sc-ion-alert-ios::-webkit-scrollbar,.alert-radio-group.sc-ion-alert-ios::-webkit-scrollbar,.alert-message.sc-ion-alert-ios::-webkit-scrollbar{display:none}}.alert-input.sc-ion-alert-ios{padding-left:0;padding-right:0;padding-top:10px;padding-bottom:10px;width:100%;border:0;background:inherit;font:inherit;-webkit-box-sizing:border-box;box-sizing:border-box}.alert-button-group.sc-ion-alert-ios{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;width:100%}.alert-button-group-vertical.sc-ion-alert-ios{-ms-flex-direction:column;flex-direction:column;-ms-flex-wrap:nowrap;flex-wrap:nowrap}.alert-button.sc-ion-alert-ios{margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;display:block;border:0;font-size:0.875rem;line-height:1.25rem;z-index:0}.alert-button.ion-focused.sc-ion-alert-ios,.alert-tappable.ion-focused.sc-ion-alert-ios{background:var(--ion-color-step-100, var(--ion-background-color-step-100, #e6e6e6))}.alert-button-inner.sc-ion-alert-ios{display:-ms-flexbox;display:flex;-ms-flex-flow:row nowrap;flex-flow:row nowrap;-ms-flex-negative:0;flex-shrink:0;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;width:100%;height:100%;min-height:inherit}.alert-input-disabled.sc-ion-alert-ios,.alert-checkbox-button-disabled.sc-ion-alert-ios .alert-button-inner.sc-ion-alert-ios,.alert-radio-button-disabled.sc-ion-alert-ios .alert-button-inner.sc-ion-alert-ios{cursor:default;opacity:0.5;pointer-events:none}.alert-tappable.sc-ion-alert-ios{margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;display:-ms-flexbox;display:flex;width:100%;border:0;background:transparent;font-size:inherit;line-height:initial;text-align:start;-webkit-appearance:none;-moz-appearance:none;appearance:none;contain:content}.alert-button.sc-ion-alert-ios,.alert-checkbox.sc-ion-alert-ios,.alert-input.sc-ion-alert-ios,.alert-radio.sc-ion-alert-ios{outline:none}.alert-radio-icon.sc-ion-alert-ios,.alert-checkbox-icon.sc-ion-alert-ios,.alert-checkbox-inner.sc-ion-alert-ios{-webkit-box-sizing:border-box;box-sizing:border-box}textarea.alert-input.sc-ion-alert-ios{min-height:37px;resize:none}.sc-ion-alert-ios-h{--background:var(--ion-overlay-background-color, var(--ion-color-step-100, var(--ion-background-color-step-100, #f9f9f9)));--max-width:clamp(270px, 16.875rem, 324px);--backdrop-opacity:var(--ion-backdrop-opacity, 0.3);font-size:max(14px, 0.875rem)}.alert-wrapper.sc-ion-alert-ios{border-radius:13px;-webkit-box-shadow:none;box-shadow:none;overflow:hidden}.alert-button.sc-ion-alert-ios .alert-button-inner.sc-ion-alert-ios{pointer-events:none}@supports ((-webkit-backdrop-filter: blur(0)) or (backdrop-filter: blur(0))){.alert-translucent.sc-ion-alert-ios-h .alert-wrapper.sc-ion-alert-ios{background:rgba(var(--ion-background-color-rgb, 255, 255, 255), 0.9);-webkit-backdrop-filter:saturate(180%) blur(20px);backdrop-filter:saturate(180%) blur(20px)}}.alert-head.sc-ion-alert-ios{-webkit-padding-start:16px;padding-inline-start:16px;-webkit-padding-end:16px;padding-inline-end:16px;padding-top:12px;padding-bottom:7px;text-align:center}.alert-title.sc-ion-alert-ios{margin-top:8px;color:var(--ion-text-color, #000);font-size:max(17px, 1.0625rem);font-weight:600}.alert-sub-title.sc-ion-alert-ios{color:var(--ion-color-step-600, var(--ion-text-color-step-400, #666666));font-size:max(14px, 0.875rem)}.alert-message.sc-ion-alert-ios,.alert-input-group.sc-ion-alert-ios{-webkit-padding-start:16px;padding-inline-start:16px;-webkit-padding-end:16px;padding-inline-end:16px;padding-top:0;padding-bottom:21px;color:var(--ion-text-color, #000);font-size:max(13px, 0.8125rem);text-align:center}.alert-message.sc-ion-alert-ios{max-height:240px}.alert-message.sc-ion-alert-ios:empty{padding-left:0;padding-right:0;padding-top:0;padding-bottom:12px}.alert-input.sc-ion-alert-ios{border-radius:7px;margin-top:10px;-webkit-padding-start:7px;padding-inline-start:7px;-webkit-padding-end:7px;padding-inline-end:7px;padding-top:7px;padding-bottom:7px;border:0.55px solid var(--ion-color-step-250, var(--ion-background-color-step-250, #bfbfbf));background-color:var(--ion-background-color, #fff);-webkit-appearance:none;-moz-appearance:none;appearance:none;font-size:1rem}.alert-input.sc-ion-alert-ios::-webkit-input-placeholder{color:var(--ion-placeholder-color, var(--ion-color-step-400, var(--ion-text-color-step-600, #999999)));font-family:inherit;font-weight:inherit}.alert-input.sc-ion-alert-ios::-moz-placeholder{color:var(--ion-placeholder-color, var(--ion-color-step-400, var(--ion-text-color-step-600, #999999)));font-family:inherit;font-weight:inherit}.alert-input.sc-ion-alert-ios:-ms-input-placeholder{color:var(--ion-placeholder-color, var(--ion-color-step-400, var(--ion-text-color-step-600, #999999)));font-family:inherit;font-weight:inherit}.alert-input.sc-ion-alert-ios::-ms-input-placeholder{color:var(--ion-placeholder-color, var(--ion-color-step-400, var(--ion-text-color-step-600, #999999)));font-family:inherit;font-weight:inherit}.alert-input.sc-ion-alert-ios::placeholder{color:var(--ion-placeholder-color, var(--ion-color-step-400, var(--ion-text-color-step-600, #999999)));font-family:inherit;font-weight:inherit}.alert-input.sc-ion-alert-ios::-ms-clear{display:none}.alert-input.sc-ion-alert-ios::-webkit-date-and-time-value{height:18px}.alert-radio-group.sc-ion-alert-ios,.alert-checkbox-group.sc-ion-alert-ios{-ms-scroll-chaining:none;overscroll-behavior:contain;max-height:240px;border-top:0.55px solid rgba(var(--ion-text-color-rgb, 0, 0, 0), 0.2);overflow-y:auto;-webkit-overflow-scrolling:touch}.alert-tappable.sc-ion-alert-ios{min-height:44px}.alert-radio-label.sc-ion-alert-ios{-webkit-padding-start:13px;padding-inline-start:13px;-webkit-padding-end:13px;padding-inline-end:13px;padding-top:13px;padding-bottom:13px;-ms-flex:1;flex:1;-ms-flex-order:0;order:0;color:var(--ion-text-color, #000)}[aria-checked=true].sc-ion-alert-ios .alert-radio-label.sc-ion-alert-ios{color:var(--ion-color-primary, #0054e9)}.alert-radio-icon.sc-ion-alert-ios{position:relative;-ms-flex-order:1;order:1;min-width:30px}[aria-checked=true].sc-ion-alert-ios .alert-radio-inner.sc-ion-alert-ios{top:-7px;position:absolute;width:6px;height:12px;-webkit-transform:rotate(45deg);transform:rotate(45deg);border-width:2px;border-top-width:0;border-left-width:0;border-style:solid;border-color:var(--ion-color-primary, #0054e9)}[aria-checked=true].sc-ion-alert-ios .alert-radio-inner.sc-ion-alert-ios{inset-inline-start:7px}.alert-checkbox-label.sc-ion-alert-ios{-webkit-padding-start:13px;padding-inline-start:13px;-webkit-padding-end:13px;padding-inline-end:13px;padding-top:13px;padding-bottom:13px;-ms-flex:1;flex:1;color:var(--ion-text-color, #000)}.alert-checkbox-icon.sc-ion-alert-ios{border-radius:50%;-webkit-margin-start:16px;margin-inline-start:16px;-webkit-margin-end:6px;margin-inline-end:6px;margin-top:10px;margin-bottom:10px;position:relative;width:min(1.375rem, 55.836px);height:min(1.375rem, 55.836px);border-width:0.125rem;border-style:solid;border-color:var(--ion-item-border-color, var(--ion-border-color, var(--ion-color-step-250, var(--ion-background-color-step-250, #c8c7cc))));background-color:var(--ion-item-background, var(--ion-background-color, #fff));contain:strict}[aria-checked=true].sc-ion-alert-ios .alert-checkbox-icon.sc-ion-alert-ios{border-color:var(--ion-color-primary, #0054e9);background-color:var(--ion-color-primary, #0054e9)}[aria-checked=true].sc-ion-alert-ios .alert-checkbox-inner.sc-ion-alert-ios{top:calc(min(1.375rem, 55.836px) / 8);position:absolute;width:calc(min(1.375rem, 55.836px) / 6 + 1px);height:calc(min(1.375rem, 55.836px) * 0.5);-webkit-transform:rotate(45deg);transform:rotate(45deg);border-width:0.125rem;border-top-width:0;border-left-width:0;border-style:solid;border-color:var(--ion-background-color, #fff)}[aria-checked=true].sc-ion-alert-ios .alert-checkbox-inner.sc-ion-alert-ios{inset-inline-start:calc(min(1.375rem, 55.836px) / 3)}.alert-button-group.sc-ion-alert-ios{-webkit-margin-end:-0.55px;margin-inline-end:-0.55px;-ms-flex-wrap:wrap;flex-wrap:wrap}.alert-button-group-vertical.sc-ion-alert-ios .alert-button.sc-ion-alert-ios{border-right:none}[dir=rtl].sc-ion-alert-ios-h .alert-button-group-vertical.sc-ion-alert-ios .alert-button.sc-ion-alert-ios:last-child,[dir=rtl] .sc-ion-alert-ios-h .alert-button-group-vertical.sc-ion-alert-ios .alert-button.sc-ion-alert-ios:last-child{border-right:none}[dir=rtl].sc-ion-alert-ios .alert-button-group-vertical.sc-ion-alert-ios .alert-button.sc-ion-alert-ios:last-child{border-right:none}@supports selector(:dir(rtl)){.alert-button-group-vertical.sc-ion-alert-ios .alert-button.sc-ion-alert-ios:last-child:dir(rtl){border-right:none}}.alert-button.sc-ion-alert-ios{-webkit-padding-start:8px;padding-inline-start:8px;-webkit-padding-end:8px;padding-inline-end:8px;margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;border-radius:0;-ms-flex:1 1 auto;flex:1 1 auto;min-width:50%;height:max(44px, 2.75rem);border-top:0.55px solid rgba(var(--ion-text-color-rgb, 0, 0, 0), 0.2);border-right:0.55px solid rgba(var(--ion-text-color-rgb, 0, 0, 0), 0.2);background-color:transparent;color:var(--ion-color-primary, #0054e9);font-size:max(17px, 1.0625rem);overflow:hidden}[dir=rtl].sc-ion-alert-ios-h .alert-button.sc-ion-alert-ios:first-child,[dir=rtl] .sc-ion-alert-ios-h .alert-button.sc-ion-alert-ios:first-child{border-right:0}[dir=rtl].sc-ion-alert-ios .alert-button.sc-ion-alert-ios:first-child{border-right:0}@supports selector(:dir(rtl)){.alert-button.sc-ion-alert-ios:first-child:dir(rtl){border-right:0}}.alert-button.sc-ion-alert-ios:last-child{border-right:0;font-weight:bold}[dir=rtl].sc-ion-alert-ios-h .alert-button.sc-ion-alert-ios:last-child,[dir=rtl] .sc-ion-alert-ios-h .alert-button.sc-ion-alert-ios:last-child{border-right:0.55px solid rgba(var(--ion-text-color-rgb, 0, 0, 0), 0.2)}[dir=rtl].sc-ion-alert-ios .alert-button.sc-ion-alert-ios:last-child{border-right:0.55px solid rgba(var(--ion-text-color-rgb, 0, 0, 0), 0.2)}@supports selector(:dir(rtl)){.alert-button.sc-ion-alert-ios:last-child:dir(rtl){border-right:0.55px solid rgba(var(--ion-text-color-rgb, 0, 0, 0), 0.2)}}.alert-button.ion-activated.sc-ion-alert-ios{background-color:rgba(var(--ion-text-color-rgb, 0, 0, 0), 0.1)}.alert-button-role-destructive.sc-ion-alert-ios,.alert-button-role-destructive.ion-activated.sc-ion-alert-ios,.alert-button-role-destructive.ion-focused.sc-ion-alert-ios{color:var(--ion-color-danger, #c5000f)}";
  105. const IonAlertIosStyle0 = alertIosCss;
  106. const alertMdCss = ".sc-ion-alert-md-h{--min-width:250px;--width:auto;--min-height:auto;--height:auto;--max-height:90%;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;left:0;right:0;top:0;bottom:0;display:-ms-flexbox;display:flex;position:absolute;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;outline:none;font-family:var(--ion-font-family, inherit);contain:strict;-ms-touch-action:none;touch-action:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;z-index:1001}.overlay-hidden.sc-ion-alert-md-h{display:none}.alert-top.sc-ion-alert-md-h{padding-top:50px;-ms-flex-align:start;align-items:flex-start}.alert-wrapper.sc-ion-alert-md{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;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);background:var(--background);contain:content;opacity:0;z-index:10}.alert-title.sc-ion-alert-md{margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;padding-left:0;padding-right:0;padding-top:0;padding-bottom:0}.alert-sub-title.sc-ion-alert-md{margin-left:0;margin-right:0;margin-top:5px;margin-bottom:0;padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;font-weight:normal}.alert-message.sc-ion-alert-md,.alert-input-group.sc-ion-alert-md{-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-overflow-scrolling:touch;overflow-y:auto;overscroll-behavior-y:contain}.alert-checkbox-label.sc-ion-alert-md,.alert-radio-label.sc-ion-alert-md{overflow-wrap:anywhere}@media (any-pointer: coarse){.alert-checkbox-group.sc-ion-alert-md::-webkit-scrollbar,.alert-radio-group.sc-ion-alert-md::-webkit-scrollbar,.alert-message.sc-ion-alert-md::-webkit-scrollbar{display:none}}.alert-input.sc-ion-alert-md{padding-left:0;padding-right:0;padding-top:10px;padding-bottom:10px;width:100%;border:0;background:inherit;font:inherit;-webkit-box-sizing:border-box;box-sizing:border-box}.alert-button-group.sc-ion-alert-md{display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;width:100%}.alert-button-group-vertical.sc-ion-alert-md{-ms-flex-direction:column;flex-direction:column;-ms-flex-wrap:nowrap;flex-wrap:nowrap}.alert-button.sc-ion-alert-md{margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;display:block;border:0;font-size:0.875rem;line-height:1.25rem;z-index:0}.alert-button.ion-focused.sc-ion-alert-md,.alert-tappable.ion-focused.sc-ion-alert-md{background:var(--ion-color-step-100, var(--ion-background-color-step-100, #e6e6e6))}.alert-button-inner.sc-ion-alert-md{display:-ms-flexbox;display:flex;-ms-flex-flow:row nowrap;flex-flow:row nowrap;-ms-flex-negative:0;flex-shrink:0;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;width:100%;height:100%;min-height:inherit}.alert-input-disabled.sc-ion-alert-md,.alert-checkbox-button-disabled.sc-ion-alert-md .alert-button-inner.sc-ion-alert-md,.alert-radio-button-disabled.sc-ion-alert-md .alert-button-inner.sc-ion-alert-md{cursor:default;opacity:0.5;pointer-events:none}.alert-tappable.sc-ion-alert-md{margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;display:-ms-flexbox;display:flex;width:100%;border:0;background:transparent;font-size:inherit;line-height:initial;text-align:start;-webkit-appearance:none;-moz-appearance:none;appearance:none;contain:content}.alert-button.sc-ion-alert-md,.alert-checkbox.sc-ion-alert-md,.alert-input.sc-ion-alert-md,.alert-radio.sc-ion-alert-md{outline:none}.alert-radio-icon.sc-ion-alert-md,.alert-checkbox-icon.sc-ion-alert-md,.alert-checkbox-inner.sc-ion-alert-md{-webkit-box-sizing:border-box;box-sizing:border-box}textarea.alert-input.sc-ion-alert-md{min-height:37px;resize:none}.sc-ion-alert-md-h{--background:var(--ion-overlay-background-color, var(--ion-background-color, #fff));--max-width:280px;--backdrop-opacity:var(--ion-backdrop-opacity, 0.32);font-size:0.875rem}.alert-wrapper.sc-ion-alert-md{border-radius:4px;-webkit-box-shadow:0 11px 15px -7px rgba(0, 0, 0, 0.2), 0 24px 38px 3px rgba(0, 0, 0, 0.14), 0 9px 46px 8px rgba(0, 0, 0, 0.12);box-shadow:0 11px 15px -7px rgba(0, 0, 0, 0.2), 0 24px 38px 3px rgba(0, 0, 0, 0.14), 0 9px 46px 8px rgba(0, 0, 0, 0.12)}.alert-head.sc-ion-alert-md{-webkit-padding-start:23px;padding-inline-start:23px;-webkit-padding-end:23px;padding-inline-end:23px;padding-top:20px;padding-bottom:15px;text-align:start}.alert-title.sc-ion-alert-md{color:var(--ion-text-color, #000);font-size:1.25rem;font-weight:500}.alert-sub-title.sc-ion-alert-md{color:var(--ion-text-color, #000);font-size:1rem}.alert-message.sc-ion-alert-md,.alert-input-group.sc-ion-alert-md{-webkit-padding-start:24px;padding-inline-start:24px;-webkit-padding-end:24px;padding-inline-end:24px;padding-top:20px;padding-bottom:20px;color:var(--ion-color-step-550, var(--ion-text-color-step-450, #737373))}.alert-message.sc-ion-alert-md{font-size:1rem}@media screen and (max-width: 767px){.alert-message.sc-ion-alert-md{max-height:266px}}.alert-message.sc-ion-alert-md:empty{padding-left:0;padding-right:0;padding-top:0;padding-bottom:0}.alert-head.sc-ion-alert-md+.alert-message.sc-ion-alert-md{padding-top:0}.alert-input.sc-ion-alert-md{margin-left:0;margin-right:0;margin-top:5px;margin-bottom:5px;border-bottom:1px solid var(--ion-color-step-150, var(--ion-background-color-step-150, #d9d9d9));color:var(--ion-text-color, #000)}.alert-input.sc-ion-alert-md::-webkit-input-placeholder{color:var(--ion-placeholder-color, var(--ion-color-step-400, var(--ion-text-color-step-600, #999999)));font-family:inherit;font-weight:inherit}.alert-input.sc-ion-alert-md::-moz-placeholder{color:var(--ion-placeholder-color, var(--ion-color-step-400, var(--ion-text-color-step-600, #999999)));font-family:inherit;font-weight:inherit}.alert-input.sc-ion-alert-md:-ms-input-placeholder{color:var(--ion-placeholder-color, var(--ion-color-step-400, var(--ion-text-color-step-600, #999999)));font-family:inherit;font-weight:inherit}.alert-input.sc-ion-alert-md::-ms-input-placeholder{color:var(--ion-placeholder-color, var(--ion-color-step-400, var(--ion-text-color-step-600, #999999)));font-family:inherit;font-weight:inherit}.alert-input.sc-ion-alert-md::placeholder{color:var(--ion-placeholder-color, var(--ion-color-step-400, var(--ion-text-color-step-600, #999999)));font-family:inherit;font-weight:inherit}.alert-input.sc-ion-alert-md::-ms-clear{display:none}.alert-input.sc-ion-alert-md:focus{margin-bottom:4px;border-bottom:2px solid var(--ion-color-primary, #0054e9)}.alert-radio-group.sc-ion-alert-md,.alert-checkbox-group.sc-ion-alert-md{position:relative;border-top:1px solid var(--ion-color-step-150, var(--ion-background-color-step-150, #d9d9d9));border-bottom:1px solid var(--ion-color-step-150, var(--ion-background-color-step-150, #d9d9d9));overflow:auto}@media screen and (max-width: 767px){.alert-radio-group.sc-ion-alert-md,.alert-checkbox-group.sc-ion-alert-md{max-height:266px}}.alert-tappable.sc-ion-alert-md{position:relative;min-height:48px}.alert-radio-label.sc-ion-alert-md{-webkit-padding-start:52px;padding-inline-start:52px;-webkit-padding-end:26px;padding-inline-end:26px;padding-top:13px;padding-bottom:13px;-ms-flex:1;flex:1;color:var(--ion-color-step-850, var(--ion-text-color-step-150, #262626));font-size:1rem}.alert-radio-icon.sc-ion-alert-md{top:0;border-radius:50%;display:block;position:relative;width:20px;height:20px;border-width:2px;border-style:solid;border-color:var(--ion-color-step-550, var(--ion-background-color-step-550, #737373))}.alert-radio-icon.sc-ion-alert-md{inset-inline-start:26px}.alert-radio-inner.sc-ion-alert-md{top:3px;border-radius:50%;position:absolute;width:10px;height:10px;-webkit-transform:scale3d(0, 0, 0);transform:scale3d(0, 0, 0);-webkit-transition:-webkit-transform 280ms cubic-bezier(0.4, 0, 0.2, 1);transition:-webkit-transform 280ms cubic-bezier(0.4, 0, 0.2, 1);transition:transform 280ms cubic-bezier(0.4, 0, 0.2, 1);transition:transform 280ms cubic-bezier(0.4, 0, 0.2, 1), -webkit-transform 280ms cubic-bezier(0.4, 0, 0.2, 1);background-color:var(--ion-color-primary, #0054e9)}.alert-radio-inner.sc-ion-alert-md{inset-inline-start:3px}[aria-checked=true].sc-ion-alert-md .alert-radio-label.sc-ion-alert-md{color:var(--ion-color-step-850, var(--ion-text-color-step-150, #262626))}[aria-checked=true].sc-ion-alert-md .alert-radio-icon.sc-ion-alert-md{border-color:var(--ion-color-primary, #0054e9)}[aria-checked=true].sc-ion-alert-md .alert-radio-inner.sc-ion-alert-md{-webkit-transform:scale3d(1, 1, 1);transform:scale3d(1, 1, 1)}.alert-checkbox-label.sc-ion-alert-md{-webkit-padding-start:53px;padding-inline-start:53px;-webkit-padding-end:26px;padding-inline-end:26px;padding-top:13px;padding-bottom:13px;-ms-flex:1;flex:1;width:calc(100% - 53px);color:var(--ion-color-step-850, var(--ion-text-color-step-150, #262626));font-size:1rem}.alert-checkbox-icon.sc-ion-alert-md{top:0;border-radius:2px;position:relative;width:16px;height:16px;border-width:2px;border-style:solid;border-color:var(--ion-color-step-550, var(--ion-background-color-step-550, #737373));contain:strict}.alert-checkbox-icon.sc-ion-alert-md{inset-inline-start:26px}[aria-checked=true].sc-ion-alert-md .alert-checkbox-icon.sc-ion-alert-md{border-color:var(--ion-color-primary, #0054e9);background-color:var(--ion-color-primary, #0054e9)}[aria-checked=true].sc-ion-alert-md .alert-checkbox-inner.sc-ion-alert-md{top:0;position:absolute;width:6px;height:10px;-webkit-transform:rotate(45deg);transform:rotate(45deg);border-width:2px;border-top-width:0;border-left-width:0;border-style:solid;border-color:var(--ion-color-primary-contrast, #fff)}[aria-checked=true].sc-ion-alert-md .alert-checkbox-inner.sc-ion-alert-md{inset-inline-start:3px}.alert-button-group.sc-ion-alert-md{-webkit-padding-start:8px;padding-inline-start:8px;-webkit-padding-end:8px;padding-inline-end:8px;padding-top:8px;padding-bottom:8px;-webkit-box-sizing:border-box;box-sizing:border-box;-ms-flex-wrap:wrap-reverse;flex-wrap:wrap-reverse;-ms-flex-pack:end;justify-content:flex-end}.alert-button.sc-ion-alert-md{border-radius:2px;-webkit-margin-start:0;margin-inline-start:0;-webkit-margin-end:8px;margin-inline-end:8px;margin-top:0;margin-bottom:0;-webkit-padding-start:10px;padding-inline-start:10px;-webkit-padding-end:10px;padding-inline-end:10px;padding-top:10px;padding-bottom:10px;position:relative;background-color:transparent;color:var(--ion-color-primary, #0054e9);font-weight:500;text-align:end;text-transform:uppercase;overflow:hidden}.alert-button-inner.sc-ion-alert-md{-ms-flex-pack:end;justify-content:flex-end}@media screen and (min-width: 768px){.sc-ion-alert-md-h{--max-width:min(100vw - 96px, 560px);--max-height:min(100vh - 96px, 560px)}}";
  107. const IonAlertMdStyle0 = alertMdCss;
  108. const Alert = class {
  109. constructor(hostRef) {
  110. index.registerInstance(this, hostRef);
  111. this.didPresent = index.createEvent(this, "ionAlertDidPresent", 7);
  112. this.willPresent = index.createEvent(this, "ionAlertWillPresent", 7);
  113. this.willDismiss = index.createEvent(this, "ionAlertWillDismiss", 7);
  114. this.didDismiss = index.createEvent(this, "ionAlertDidDismiss", 7);
  115. this.didPresentShorthand = index.createEvent(this, "didPresent", 7);
  116. this.willPresentShorthand = index.createEvent(this, "willPresent", 7);
  117. this.willDismissShorthand = index.createEvent(this, "willDismiss", 7);
  118. this.didDismissShorthand = index.createEvent(this, "didDismiss", 7);
  119. this.delegateController = overlays.createDelegateController(this);
  120. this.lockController = lockController.createLockController();
  121. this.triggerController = overlays.createTriggerController();
  122. this.customHTMLEnabled = index$1.config.get('innerHTMLTemplatesEnabled', config.ENABLE_HTML_CONTENT_DEFAULT);
  123. this.processedInputs = [];
  124. this.processedButtons = [];
  125. this.presented = false;
  126. this.onBackdropTap = () => {
  127. this.dismiss(undefined, overlays.BACKDROP);
  128. };
  129. this.dispatchCancelHandler = (ev) => {
  130. const role = ev.detail.role;
  131. if (overlays.isCancel(role)) {
  132. const cancelButton = this.processedButtons.find((b) => b.role === 'cancel');
  133. this.callButtonHandler(cancelButton);
  134. }
  135. };
  136. this.overlayIndex = undefined;
  137. this.delegate = undefined;
  138. this.hasController = false;
  139. this.keyboardClose = true;
  140. this.enterAnimation = undefined;
  141. this.leaveAnimation = undefined;
  142. this.cssClass = undefined;
  143. this.header = undefined;
  144. this.subHeader = undefined;
  145. this.message = undefined;
  146. this.buttons = [];
  147. this.inputs = [];
  148. this.backdropDismiss = true;
  149. this.translucent = false;
  150. this.animated = true;
  151. this.htmlAttributes = undefined;
  152. this.isOpen = false;
  153. this.trigger = undefined;
  154. }
  155. onIsOpenChange(newValue, oldValue) {
  156. if (newValue === true && oldValue === false) {
  157. this.present();
  158. }
  159. else if (newValue === false && oldValue === true) {
  160. this.dismiss();
  161. }
  162. }
  163. triggerChanged() {
  164. const { trigger, el, triggerController } = this;
  165. if (trigger) {
  166. triggerController.addClickListener(el, trigger);
  167. }
  168. }
  169. onKeydown(ev) {
  170. var _a;
  171. const inputTypes = new Set(this.processedInputs.map((i) => i.type));
  172. /**
  173. * Based on keyboard navigation requirements, the
  174. * checkbox should not respond to the enter keydown event.
  175. */
  176. if (inputTypes.has('checkbox') && ev.key === 'Enter') {
  177. ev.preventDefault();
  178. return;
  179. }
  180. /**
  181. * Ensure when alert container is being focused, and the user presses the tab + shift keys, the focus will be set to the last alert button.
  182. */
  183. if (ev.target.classList.contains('alert-wrapper')) {
  184. if (ev.key === 'Tab' && ev.shiftKey) {
  185. ev.preventDefault();
  186. const lastChildBtn = (_a = this.wrapperEl) === null || _a === void 0 ? void 0 : _a.querySelector('.alert-button:last-child');
  187. lastChildBtn.focus();
  188. return;
  189. }
  190. }
  191. // The only inputs we want to navigate between using arrow keys are the radios
  192. // ignore the keydown event if it is not on a radio button
  193. if (!inputTypes.has('radio') ||
  194. (ev.target && !this.el.contains(ev.target)) ||
  195. ev.target.classList.contains('alert-button')) {
  196. return;
  197. }
  198. // Get all radios inside of the radio group and then
  199. // filter out disabled radios since we need to skip those
  200. const query = this.el.querySelectorAll('.alert-radio');
  201. const radios = Array.from(query).filter((radio) => !radio.disabled);
  202. // The focused radio is the one that shares the same id as
  203. // the event target
  204. const index = radios.findIndex((radio) => radio.id === ev.target.id);
  205. // We need to know what the next radio element should
  206. // be in order to change the focus
  207. let nextEl;
  208. // If hitting arrow down or arrow right, move to the next radio
  209. // If we're on the last radio, move to the first radio
  210. if (['ArrowDown', 'ArrowRight'].includes(ev.key)) {
  211. nextEl = index === radios.length - 1 ? radios[0] : radios[index + 1];
  212. }
  213. // If hitting arrow up or arrow left, move to the previous radio
  214. // If we're on the first radio, move to the last radio
  215. if (['ArrowUp', 'ArrowLeft'].includes(ev.key)) {
  216. nextEl = index === 0 ? radios[radios.length - 1] : radios[index - 1];
  217. }
  218. if (nextEl && radios.includes(nextEl)) {
  219. const nextProcessed = this.processedInputs.find((input) => input.id === (nextEl === null || nextEl === void 0 ? void 0 : nextEl.id));
  220. if (nextProcessed) {
  221. this.rbClick(nextProcessed);
  222. nextEl.focus();
  223. }
  224. }
  225. }
  226. buttonsChanged() {
  227. const buttons = this.buttons;
  228. this.processedButtons = buttons.map((btn) => {
  229. return typeof btn === 'string' ? { text: btn, role: btn.toLowerCase() === 'cancel' ? 'cancel' : undefined } : btn;
  230. });
  231. }
  232. inputsChanged() {
  233. const inputs = this.inputs;
  234. // Get the first input that is not disabled and the checked one
  235. // If an enabled checked input exists, set it to be the focusable input
  236. // otherwise we default to focus the first input
  237. // This will only be used when the input is type radio
  238. const first = inputs.find((input) => !input.disabled);
  239. const checked = inputs.find((input) => input.checked && !input.disabled);
  240. const focusable = checked || first;
  241. // An alert can be created with several different inputs. Radios,
  242. // checkboxes and inputs are all accepted, but they cannot be mixed.
  243. const inputTypes = new Set(inputs.map((i) => i.type));
  244. if (inputTypes.has('checkbox') && inputTypes.has('radio')) {
  245. index$1.printIonWarning(`[ion-alert] - Alert cannot mix input types: ${Array.from(inputTypes.values()).join('/')}. Please see alert docs for more info.`);
  246. }
  247. this.inputType = inputTypes.values().next().value;
  248. this.processedInputs = inputs.map((i, index) => {
  249. var _a;
  250. return ({
  251. type: i.type || 'text',
  252. name: i.name || `${index}`,
  253. placeholder: i.placeholder || '',
  254. value: i.value,
  255. label: i.label,
  256. checked: !!i.checked,
  257. disabled: !!i.disabled,
  258. id: i.id || `alert-input-${this.overlayIndex}-${index}`,
  259. handler: i.handler,
  260. min: i.min,
  261. max: i.max,
  262. cssClass: (_a = i.cssClass) !== null && _a !== void 0 ? _a : '',
  263. attributes: i.attributes || {},
  264. tabindex: i.type === 'radio' && i !== focusable ? -1 : 0,
  265. });
  266. });
  267. }
  268. connectedCallback() {
  269. overlays.prepareOverlay(this.el);
  270. this.triggerChanged();
  271. }
  272. componentWillLoad() {
  273. var _a;
  274. if (!((_a = this.htmlAttributes) === null || _a === void 0 ? void 0 : _a.id)) {
  275. overlays.setOverlayId(this.el);
  276. }
  277. this.inputsChanged();
  278. this.buttonsChanged();
  279. }
  280. disconnectedCallback() {
  281. this.triggerController.removeClickListener();
  282. if (this.gesture) {
  283. this.gesture.destroy();
  284. this.gesture = undefined;
  285. }
  286. }
  287. componentDidLoad() {
  288. /**
  289. * Only create gesture if:
  290. * 1. A gesture does not already exist
  291. * 2. App is running in iOS mode
  292. * 3. A wrapper ref exists
  293. */
  294. if (!this.gesture && ionicGlobal.getIonMode(this) === 'ios' && this.wrapperEl) {
  295. this.gesture = buttonActive.createButtonActiveGesture(this.wrapperEl, (refEl) => refEl.classList.contains('alert-button'));
  296. this.gesture.enable(true);
  297. }
  298. /**
  299. * If alert was rendered with isOpen="true"
  300. * then we should open alert immediately.
  301. */
  302. if (this.isOpen === true) {
  303. helpers.raf(() => this.present());
  304. }
  305. /**
  306. * When binding values in frameworks such as Angular
  307. * it is possible for the value to be set after the Web Component
  308. * initializes but before the value watcher is set up in Stencil.
  309. * As a result, the watcher callback may not be fired.
  310. * We work around this by manually calling the watcher
  311. * callback when the component has loaded and the watcher
  312. * is configured.
  313. */
  314. this.triggerChanged();
  315. }
  316. /**
  317. * Present the alert overlay after it has been created.
  318. */
  319. async present() {
  320. const unlock = await this.lockController.lock();
  321. await this.delegateController.attachViewToDom();
  322. await overlays.present(this, 'alertEnter', iosEnterAnimation, mdEnterAnimation).then(() => {
  323. var _a, _b;
  324. /**
  325. * Check if alert has only one button and no inputs.
  326. * If so, then focus on the button. Otherwise, focus the alert wrapper.
  327. * This will map to the default native alert behavior.
  328. */
  329. if (this.buttons.length === 1 && this.inputs.length === 0) {
  330. const queryBtn = (_a = this.wrapperEl) === null || _a === void 0 ? void 0 : _a.querySelector('.alert-button');
  331. queryBtn.focus();
  332. }
  333. else {
  334. (_b = this.wrapperEl) === null || _b === void 0 ? void 0 : _b.focus();
  335. }
  336. });
  337. unlock();
  338. }
  339. /**
  340. * Dismiss the alert overlay after it has been presented.
  341. *
  342. * @param data Any data to emit in the dismiss events.
  343. * @param role The role of the element that is dismissing the alert.
  344. * This can be useful in a button handler for determining which button was
  345. * clicked to dismiss the alert.
  346. * Some examples include: ``"cancel"`, `"destructive"`, "selected"`, and `"backdrop"`.
  347. *
  348. * This is a no-op if the overlay has not been presented yet. If you want
  349. * to remove an overlay from the DOM that was never presented, use the
  350. * [remove](https://developer.mozilla.org/en-US/docs/Web/API/Element/remove) method.
  351. */
  352. async dismiss(data, role) {
  353. const unlock = await this.lockController.lock();
  354. const dismissed = await overlays.dismiss(this, data, role, 'alertLeave', iosLeaveAnimation, mdLeaveAnimation);
  355. if (dismissed) {
  356. this.delegateController.removeViewFromDom();
  357. }
  358. unlock();
  359. return dismissed;
  360. }
  361. /**
  362. * Returns a promise that resolves when the alert did dismiss.
  363. */
  364. onDidDismiss() {
  365. return overlays.eventMethod(this.el, 'ionAlertDidDismiss');
  366. }
  367. /**
  368. * Returns a promise that resolves when the alert will dismiss.
  369. */
  370. onWillDismiss() {
  371. return overlays.eventMethod(this.el, 'ionAlertWillDismiss');
  372. }
  373. rbClick(selectedInput) {
  374. for (const input of this.processedInputs) {
  375. input.checked = input === selectedInput;
  376. input.tabindex = input === selectedInput ? 0 : -1;
  377. }
  378. this.activeId = selectedInput.id;
  379. overlays.safeCall(selectedInput.handler, selectedInput);
  380. index.forceUpdate(this);
  381. }
  382. cbClick(selectedInput) {
  383. selectedInput.checked = !selectedInput.checked;
  384. overlays.safeCall(selectedInput.handler, selectedInput);
  385. index.forceUpdate(this);
  386. }
  387. async buttonClick(button) {
  388. const role = button.role;
  389. const values = this.getValues();
  390. if (overlays.isCancel(role)) {
  391. return this.dismiss({ values }, role);
  392. }
  393. const returnData = await this.callButtonHandler(button, values);
  394. if (returnData !== false) {
  395. return this.dismiss(Object.assign({ values }, returnData), button.role);
  396. }
  397. return false;
  398. }
  399. async callButtonHandler(button, data) {
  400. if (button === null || button === void 0 ? void 0 : button.handler) {
  401. // a handler has been provided, execute it
  402. // pass the handler the values from the inputs
  403. const returnData = await overlays.safeCall(button.handler, data);
  404. if (returnData === false) {
  405. // if the return value of the handler is false then do not dismiss
  406. return false;
  407. }
  408. if (typeof returnData === 'object') {
  409. return returnData;
  410. }
  411. }
  412. return {};
  413. }
  414. getValues() {
  415. if (this.processedInputs.length === 0) {
  416. // this is an alert without any options/inputs at all
  417. return undefined;
  418. }
  419. if (this.inputType === 'radio') {
  420. // this is an alert with radio buttons (single value select)
  421. // return the one value which is checked, otherwise undefined
  422. const checkedInput = this.processedInputs.find((i) => !!i.checked);
  423. return checkedInput ? checkedInput.value : undefined;
  424. }
  425. if (this.inputType === 'checkbox') {
  426. // this is an alert with checkboxes (multiple value select)
  427. // return an array of all the checked values
  428. return this.processedInputs.filter((i) => i.checked).map((i) => i.value);
  429. }
  430. // this is an alert with text inputs
  431. // return an object of all the values with the input name as the key
  432. const values = {};
  433. this.processedInputs.forEach((i) => {
  434. values[i.name] = i.value || '';
  435. });
  436. return values;
  437. }
  438. renderAlertInputs() {
  439. switch (this.inputType) {
  440. case 'checkbox':
  441. return this.renderCheckbox();
  442. case 'radio':
  443. return this.renderRadio();
  444. default:
  445. return this.renderInput();
  446. }
  447. }
  448. renderCheckbox() {
  449. const inputs = this.processedInputs;
  450. const mode = ionicGlobal.getIonMode(this);
  451. if (inputs.length === 0) {
  452. return null;
  453. }
  454. return (index.h("div", { class: "alert-checkbox-group" }, inputs.map((i) => (index.h("button", { type: "button", onClick: () => this.cbClick(i), "aria-checked": `${i.checked}`, id: i.id, disabled: i.disabled, tabIndex: i.tabindex, role: "checkbox", class: Object.assign(Object.assign({}, theme.getClassMap(i.cssClass)), { 'alert-tappable': true, 'alert-checkbox': true, 'alert-checkbox-button': true, 'ion-focusable': true, 'alert-checkbox-button-disabled': i.disabled || false }) }, index.h("div", { class: "alert-button-inner" }, index.h("div", { class: "alert-checkbox-icon" }, index.h("div", { class: "alert-checkbox-inner" })), index.h("div", { class: "alert-checkbox-label" }, i.label)), mode === 'md' && index.h("ion-ripple-effect", null))))));
  455. }
  456. renderRadio() {
  457. const inputs = this.processedInputs;
  458. if (inputs.length === 0) {
  459. return null;
  460. }
  461. return (index.h("div", { class: "alert-radio-group", role: "radiogroup", "aria-activedescendant": this.activeId }, inputs.map((i) => (index.h("button", { type: "button", onClick: () => this.rbClick(i), "aria-checked": `${i.checked}`, disabled: i.disabled, id: i.id, tabIndex: i.tabindex, class: Object.assign(Object.assign({}, theme.getClassMap(i.cssClass)), { 'alert-radio-button': true, 'alert-tappable': true, 'alert-radio': true, 'ion-focusable': true, 'alert-radio-button-disabled': i.disabled || false }), role: "radio" }, index.h("div", { class: "alert-button-inner" }, index.h("div", { class: "alert-radio-icon" }, index.h("div", { class: "alert-radio-inner" })), index.h("div", { class: "alert-radio-label" }, i.label)))))));
  462. }
  463. renderInput() {
  464. const inputs = this.processedInputs;
  465. if (inputs.length === 0) {
  466. return null;
  467. }
  468. return (index.h("div", { class: "alert-input-group" }, inputs.map((i) => {
  469. var _a, _b, _c, _d;
  470. if (i.type === 'textarea') {
  471. return (index.h("div", { class: "alert-input-wrapper" }, index.h("textarea", Object.assign({ placeholder: i.placeholder, value: i.value, id: i.id, tabIndex: i.tabindex }, i.attributes, { disabled: (_b = (_a = i.attributes) === null || _a === void 0 ? void 0 : _a.disabled) !== null && _b !== void 0 ? _b : i.disabled, class: inputClass(i), onInput: (e) => {
  472. var _a;
  473. i.value = e.target.value;
  474. if ((_a = i.attributes) === null || _a === void 0 ? void 0 : _a.onInput) {
  475. i.attributes.onInput(e);
  476. }
  477. } }))));
  478. }
  479. else {
  480. return (index.h("div", { class: "alert-input-wrapper" }, index.h("input", Object.assign({ placeholder: i.placeholder, type: i.type, min: i.min, max: i.max, value: i.value, id: i.id, tabIndex: i.tabindex }, i.attributes, { disabled: (_d = (_c = i.attributes) === null || _c === void 0 ? void 0 : _c.disabled) !== null && _d !== void 0 ? _d : i.disabled, class: inputClass(i), onInput: (e) => {
  481. var _a;
  482. i.value = e.target.value;
  483. if ((_a = i.attributes) === null || _a === void 0 ? void 0 : _a.onInput) {
  484. i.attributes.onInput(e);
  485. }
  486. } }))));
  487. }
  488. })));
  489. }
  490. renderAlertButtons() {
  491. const buttons = this.processedButtons;
  492. const mode = ionicGlobal.getIonMode(this);
  493. const alertButtonGroupClass = {
  494. 'alert-button-group': true,
  495. 'alert-button-group-vertical': buttons.length > 2,
  496. };
  497. return (index.h("div", { class: alertButtonGroupClass }, buttons.map((button) => (index.h("button", Object.assign({}, button.htmlAttributes, { type: "button", id: button.id, class: buttonClass(button), tabIndex: 0, onClick: () => this.buttonClick(button) }), index.h("span", { class: "alert-button-inner" }, button.text), mode === 'md' && index.h("ion-ripple-effect", null))))));
  498. }
  499. renderAlertMessage(msgId) {
  500. const { customHTMLEnabled, message } = this;
  501. if (customHTMLEnabled) {
  502. return index.h("div", { id: msgId, class: "alert-message", innerHTML: config.sanitizeDOMString(message) });
  503. }
  504. return (index.h("div", { id: msgId, class: "alert-message" }, message));
  505. }
  506. render() {
  507. const { overlayIndex, header, subHeader, message, htmlAttributes } = this;
  508. const mode = ionicGlobal.getIonMode(this);
  509. const hdrId = `alert-${overlayIndex}-hdr`;
  510. const msgId = `alert-${overlayIndex}-msg`;
  511. const subHdrId = `alert-${overlayIndex}-sub-hdr`;
  512. const role = this.inputs.length > 0 || this.buttons.length > 0 ? 'alertdialog' : 'alert';
  513. /**
  514. * Use both the header and subHeader ids if they are defined.
  515. * If only the header is defined, use the header id.
  516. * If only the subHeader is defined, use the subHeader id.
  517. * If neither are defined, do not set aria-labelledby.
  518. */
  519. const ariaLabelledBy = header && subHeader ? `${hdrId} ${subHdrId}` : header ? hdrId : subHeader ? subHdrId : null;
  520. return (index.h(index.Host, { key: 'f8ee04fe6a97a2585b302c8e1a9eea3b122e3479', tabindex: "-1", style: {
  521. zIndex: `${20000 + overlayIndex}`,
  522. }, class: Object.assign(Object.assign({}, theme.getClassMap(this.cssClass)), { [mode]: true, 'overlay-hidden': true, 'alert-translucent': this.translucent }), onIonAlertWillDismiss: this.dispatchCancelHandler, onIonBackdropTap: this.onBackdropTap }, index.h("ion-backdrop", { key: 'e9592e879f51c27ef20016beec12c986be632cf3', tappable: this.backdropDismiss }), index.h("div", { key: '5e9425c3c8acdea6f8006389689c73220e2ce423', tabindex: "0", "aria-hidden": "true" }), index.h("div", Object.assign({ key: '615465703e357619681fc36ed7276591a6fe3787', class: "alert-wrapper ion-overlay-wrapper", role: role, "aria-modal": "true", "aria-labelledby": ariaLabelledBy, "aria-describedby": message !== undefined ? msgId : null, tabindex: "0", ref: (el) => (this.wrapperEl = el) }, htmlAttributes), index.h("div", { key: '934eba3759456cd4660e10f274edc7859f908461', class: "alert-head" }, header && (index.h("h2", { key: '7d5d98d71f81f59a2cba227121b6fa01e6cc53b6', id: hdrId, class: "alert-title" }, header)), subHeader && !header && (index.h("h2", { key: 'e5f5d35748c58a98ee933eb15cb1dcaf8113e9a7', id: subHdrId, class: "alert-sub-title" }, subHeader)), subHeader && header && (index.h("h3", { key: 'a5cb89ca02bfa9c4828e694cb0835493a9088b05', id: subHdrId, class: "alert-sub-title" }, subHeader))), this.renderAlertMessage(msgId), this.renderAlertInputs(), this.renderAlertButtons()), index.h("div", { key: 'cacffc31c911882df73e6845d15c8bb2d4acab56', tabindex: "0", "aria-hidden": "true" })));
  523. }
  524. get el() { return index.getElement(this); }
  525. static get watchers() { return {
  526. "isOpen": ["onIsOpenChange"],
  527. "trigger": ["triggerChanged"],
  528. "buttons": ["buttonsChanged"],
  529. "inputs": ["inputsChanged"]
  530. }; }
  531. };
  532. const inputClass = (input) => {
  533. var _a, _b, _c;
  534. return Object.assign(Object.assign({ 'alert-input': true, 'alert-input-disabled': ((_b = (_a = input.attributes) === null || _a === void 0 ? void 0 : _a.disabled) !== null && _b !== void 0 ? _b : input.disabled) || false }, theme.getClassMap(input.cssClass)), theme.getClassMap(input.attributes ? (_c = input.attributes.class) === null || _c === void 0 ? void 0 : _c.toString() : ''));
  535. };
  536. const buttonClass = (button) => {
  537. return Object.assign({ 'alert-button': true, 'ion-focusable': true, 'ion-activatable': true, [`alert-button-role-${button.role}`]: button.role !== undefined }, theme.getClassMap(button.cssClass));
  538. };
  539. Alert.style = {
  540. ios: IonAlertIosStyle0,
  541. md: IonAlertMdStyle0
  542. };
  543. exports.ion_alert = Alert;