ion-router-link.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*!
  2. * (C) Ionic http://ionicframework.com - MIT License
  3. */
  4. import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
  5. import { o as openURL, c as createColorClasses } from './theme.js';
  6. import { b as getIonMode } from './ionic-global.js';
  7. const routerLinkCss = ":host{--background:transparent;--color:var(--ion-color-primary, #0054e9);background:var(--background);color:var(--color)}:host(.ion-color){color:var(--ion-color-base)}a{font-family:inherit;font-size:inherit;font-style:inherit;font-weight:inherit;letter-spacing:inherit;text-decoration:inherit;text-indent:inherit;text-overflow:inherit;text-transform:inherit;text-align:inherit;white-space:inherit;color:inherit}";
  8. const IonRouterLinkStyle0 = routerLinkCss;
  9. const RouterLink = /*@__PURE__*/ proxyCustomElement(class RouterLink extends HTMLElement {
  10. constructor() {
  11. super();
  12. this.__registerHost();
  13. this.__attachShadow();
  14. this.onClick = (ev) => {
  15. openURL(this.href, ev, this.routerDirection, this.routerAnimation);
  16. };
  17. this.color = undefined;
  18. this.href = undefined;
  19. this.rel = undefined;
  20. this.routerDirection = 'forward';
  21. this.routerAnimation = undefined;
  22. this.target = undefined;
  23. }
  24. render() {
  25. const mode = getIonMode(this);
  26. const attrs = {
  27. href: this.href,
  28. rel: this.rel,
  29. target: this.target,
  30. };
  31. return (h(Host, { key: '11183264fb6ae0db9a7a47c71b6862d60001b834', onClick: this.onClick, class: createColorClasses(this.color, {
  32. [mode]: true,
  33. 'ion-activatable': true,
  34. }) }, h("a", Object.assign({ key: '3e0e5242161cb0df593d6d573e51b8ba750065a1' }, attrs), h("slot", { key: '5bd808e98a4627bb1236f0d955f4b32971355417' }))));
  35. }
  36. static get style() { return IonRouterLinkStyle0; }
  37. }, [1, "ion-router-link", {
  38. "color": [513],
  39. "href": [1],
  40. "rel": [1],
  41. "routerDirection": [1, "router-direction"],
  42. "routerAnimation": [16],
  43. "target": [1]
  44. }]);
  45. function defineCustomElement$1() {
  46. if (typeof customElements === "undefined") {
  47. return;
  48. }
  49. const components = ["ion-router-link"];
  50. components.forEach(tagName => { switch (tagName) {
  51. case "ion-router-link":
  52. if (!customElements.get(tagName)) {
  53. customElements.define(tagName, RouterLink);
  54. }
  55. break;
  56. } });
  57. }
  58. const IonRouterLink = RouterLink;
  59. const defineCustomElement = defineCustomElement$1;
  60. export { IonRouterLink, defineCustomElement };