ion-nav-link.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*!
  2. * (C) Ionic http://ionicframework.com - MIT License
  3. */
  4. import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
  5. const navLink = (el, routerDirection, component, componentProps, routerAnimation) => {
  6. const nav = el.closest('ion-nav');
  7. if (nav) {
  8. if (routerDirection === 'forward') {
  9. if (component !== undefined) {
  10. return nav.push(component, componentProps, { skipIfBusy: true, animationBuilder: routerAnimation });
  11. }
  12. }
  13. else if (routerDirection === 'root') {
  14. if (component !== undefined) {
  15. return nav.setRoot(component, componentProps, { skipIfBusy: true, animationBuilder: routerAnimation });
  16. }
  17. }
  18. else if (routerDirection === 'back') {
  19. return nav.pop({ skipIfBusy: true, animationBuilder: routerAnimation });
  20. }
  21. }
  22. return Promise.resolve(false);
  23. };
  24. const NavLink = /*@__PURE__*/ proxyCustomElement(class NavLink extends HTMLElement {
  25. constructor() {
  26. super();
  27. this.__registerHost();
  28. this.onClick = () => {
  29. return navLink(this.el, this.routerDirection, this.component, this.componentProps, this.routerAnimation);
  30. };
  31. this.component = undefined;
  32. this.componentProps = undefined;
  33. this.routerDirection = 'forward';
  34. this.routerAnimation = undefined;
  35. }
  36. render() {
  37. return h(Host, { key: '9ba170d1b10e08e8a6b5e6a30d363871d455a0a9', onClick: this.onClick });
  38. }
  39. get el() { return this; }
  40. }, [0, "ion-nav-link", {
  41. "component": [1],
  42. "componentProps": [16],
  43. "routerDirection": [1, "router-direction"],
  44. "routerAnimation": [16]
  45. }]);
  46. function defineCustomElement$1() {
  47. if (typeof customElements === "undefined") {
  48. return;
  49. }
  50. const components = ["ion-nav-link"];
  51. components.forEach(tagName => { switch (tagName) {
  52. case "ion-nav-link":
  53. if (!customElements.get(tagName)) {
  54. customElements.define(tagName, NavLink);
  55. }
  56. break;
  57. } });
  58. }
  59. const IonNavLink = NavLink;
  60. const defineCustomElement = defineCustomElement$1;
  61. export { IonNavLink, defineCustomElement };