backdrop.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*!
  2. * (C) Ionic http://ionicframework.com - MIT License
  3. */
  4. import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
  5. import { b as getIonMode } from './ionic-global.js';
  6. const backdropIosCss = ":host{left:0;right:0;top:0;bottom:0;display:block;position:absolute;-webkit-transform:translateZ(0);transform:translateZ(0);contain:strict;cursor:pointer;opacity:0.01;-ms-touch-action:none;touch-action:none;z-index:2}:host(.backdrop-hide){background:transparent}:host(.backdrop-no-tappable){cursor:auto}:host{background-color:var(--ion-backdrop-color, #000)}";
  7. const IonBackdropIosStyle0 = backdropIosCss;
  8. const backdropMdCss = ":host{left:0;right:0;top:0;bottom:0;display:block;position:absolute;-webkit-transform:translateZ(0);transform:translateZ(0);contain:strict;cursor:pointer;opacity:0.01;-ms-touch-action:none;touch-action:none;z-index:2}:host(.backdrop-hide){background:transparent}:host(.backdrop-no-tappable){cursor:auto}:host{background-color:var(--ion-backdrop-color, #000)}";
  9. const IonBackdropMdStyle0 = backdropMdCss;
  10. const Backdrop = /*@__PURE__*/ proxyCustomElement(class Backdrop extends HTMLElement {
  11. constructor() {
  12. super();
  13. this.__registerHost();
  14. this.__attachShadow();
  15. this.ionBackdropTap = createEvent(this, "ionBackdropTap", 7);
  16. this.visible = true;
  17. this.tappable = true;
  18. this.stopPropagation = true;
  19. }
  20. onMouseDown(ev) {
  21. this.emitTap(ev);
  22. }
  23. emitTap(ev) {
  24. if (this.stopPropagation) {
  25. ev.preventDefault();
  26. ev.stopPropagation();
  27. }
  28. if (this.tappable) {
  29. this.ionBackdropTap.emit();
  30. }
  31. }
  32. render() {
  33. const mode = getIonMode(this);
  34. return (h(Host, { key: '7abaf2c310aa399607451b14063265e8a5846938', "aria-hidden": "true", class: {
  35. [mode]: true,
  36. 'backdrop-hide': !this.visible,
  37. 'backdrop-no-tappable': !this.tappable,
  38. } }));
  39. }
  40. static get style() { return {
  41. ios: IonBackdropIosStyle0,
  42. md: IonBackdropMdStyle0
  43. }; }
  44. }, [33, "ion-backdrop", {
  45. "visible": [4],
  46. "tappable": [4],
  47. "stopPropagation": [4, "stop-propagation"]
  48. }, [[2, "click", "onMouseDown"]]]);
  49. function defineCustomElement() {
  50. if (typeof customElements === "undefined") {
  51. return;
  52. }
  53. const components = ["ion-backdrop"];
  54. components.forEach(tagName => { switch (tagName) {
  55. case "ion-backdrop":
  56. if (!customElements.get(tagName)) {
  57. customElements.define(tagName, Backdrop);
  58. }
  59. break;
  60. } });
  61. }
  62. export { Backdrop as B, defineCustomElement as d };