ion-card.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*!
  2. * (C) Ionic http://ionicframework.com - MIT License
  3. */
  4. import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
  5. import { d as inheritAttributes } from './helpers.js';
  6. import { o as openURL, c as createColorClasses } from './theme.js';
  7. import { b as getIonMode } from './ionic-global.js';
  8. import { d as defineCustomElement$2 } from './ripple-effect.js';
  9. const cardIosCss = ":host{--ion-safe-area-left:0px;--ion-safe-area-right:0px;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;display:block;position:relative;background:var(--background);color:var(--color);font-family:var(--ion-font-family, inherit);contain:content;overflow:hidden}:host(.ion-color){background:var(--ion-color-base);color:var(--ion-color-contrast)}:host(.card-disabled){cursor:default;opacity:0.3;pointer-events:none}.card-native{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;padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;display:block;width:100%;min-height:var(--min-height);-webkit-transition:var(--transition);transition:var(--transition);border-width:var(--border-width);border-style:var(--border-style);border-color:var(--border-color);outline:none;background:inherit}.card-native::-moz-focus-inner{border:0}button,a{cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-user-drag:none}ion-ripple-effect{color:var(--ripple-color)}:host{--background:var(--ion-card-background, var(--ion-item-background, var(--ion-background-color, #fff)));--color:var(--ion-card-color, var(--ion-item-color, var(--ion-color-step-600, var(--ion-text-color-step-400, #666666))));-webkit-margin-start:16px;margin-inline-start:16px;-webkit-margin-end:16px;margin-inline-end:16px;margin-top:24px;margin-bottom:24px;border-radius:8px;-webkit-transition:-webkit-transform 500ms cubic-bezier(0.12, 0.72, 0.29, 1);transition:-webkit-transform 500ms cubic-bezier(0.12, 0.72, 0.29, 1);transition:transform 500ms cubic-bezier(0.12, 0.72, 0.29, 1);transition:transform 500ms cubic-bezier(0.12, 0.72, 0.29, 1), -webkit-transform 500ms cubic-bezier(0.12, 0.72, 0.29, 1);font-size:0.875rem;-webkit-box-shadow:0 4px 16px rgba(0, 0, 0, 0.12);box-shadow:0 4px 16px rgba(0, 0, 0, 0.12)}:host(.ion-activated){-webkit-transform:scale3d(0.97, 0.97, 1);transform:scale3d(0.97, 0.97, 1)}";
  10. const IonCardIosStyle0 = cardIosCss;
  11. const cardMdCss = ":host{--ion-safe-area-left:0px;--ion-safe-area-right:0px;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased;display:block;position:relative;background:var(--background);color:var(--color);font-family:var(--ion-font-family, inherit);contain:content;overflow:hidden}:host(.ion-color){background:var(--ion-color-base);color:var(--ion-color-contrast)}:host(.card-disabled){cursor:default;opacity:0.3;pointer-events:none}.card-native{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;padding-left:0;padding-right:0;padding-top:0;padding-bottom:0;margin-left:0;margin-right:0;margin-top:0;margin-bottom:0;display:block;width:100%;min-height:var(--min-height);-webkit-transition:var(--transition);transition:var(--transition);border-width:var(--border-width);border-style:var(--border-style);border-color:var(--border-color);outline:none;background:inherit}.card-native::-moz-focus-inner{border:0}button,a{cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-user-drag:none}ion-ripple-effect{color:var(--ripple-color)}:host{--background:var(--ion-card-background, var(--ion-item-background, var(--ion-background-color, #fff)));--color:var(--ion-card-color, var(--ion-item-color, var(--ion-color-step-550, var(--ion-text-color-step-450, #737373))));-webkit-margin-start:10px;margin-inline-start:10px;-webkit-margin-end:10px;margin-inline-end:10px;margin-top:10px;margin-bottom:10px;border-radius:4px;font-size:0.875rem;-webkit-box-shadow:0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12);box-shadow:0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12)}";
  12. const IonCardMdStyle0 = cardMdCss;
  13. const Card = /*@__PURE__*/ proxyCustomElement(class Card extends HTMLElement {
  14. constructor() {
  15. super();
  16. this.__registerHost();
  17. this.__attachShadow();
  18. this.inheritedAriaAttributes = {};
  19. this.color = undefined;
  20. this.button = false;
  21. this.type = 'button';
  22. this.disabled = false;
  23. this.download = undefined;
  24. this.href = undefined;
  25. this.rel = undefined;
  26. this.routerDirection = 'forward';
  27. this.routerAnimation = undefined;
  28. this.target = undefined;
  29. }
  30. componentWillLoad() {
  31. this.inheritedAriaAttributes = inheritAttributes(this.el, ['aria-label']);
  32. }
  33. isClickable() {
  34. return this.href !== undefined || this.button;
  35. }
  36. renderCard(mode) {
  37. const clickable = this.isClickable();
  38. if (!clickable) {
  39. return [h("slot", null)];
  40. }
  41. const { href, routerAnimation, routerDirection, inheritedAriaAttributes } = this;
  42. const TagType = clickable ? (href === undefined ? 'button' : 'a') : 'div';
  43. const attrs = TagType === 'button'
  44. ? { type: this.type }
  45. : {
  46. download: this.download,
  47. href: this.href,
  48. rel: this.rel,
  49. target: this.target,
  50. };
  51. return (h(TagType, Object.assign({}, attrs, inheritedAriaAttributes, { class: "card-native", part: "native", disabled: this.disabled, onClick: (ev) => openURL(href, ev, routerDirection, routerAnimation) }), h("slot", null), clickable && mode === 'md' && h("ion-ripple-effect", null)));
  52. }
  53. render() {
  54. const mode = getIonMode(this);
  55. return (h(Host, { key: '85e9b30bd81e79a0c7ac75cb3664bdcf9e4afc4d', class: createColorClasses(this.color, {
  56. [mode]: true,
  57. 'card-disabled': this.disabled,
  58. 'ion-activatable': this.isClickable(),
  59. }) }, this.renderCard(mode)));
  60. }
  61. get el() { return this; }
  62. static get style() { return {
  63. ios: IonCardIosStyle0,
  64. md: IonCardMdStyle0
  65. }; }
  66. }, [33, "ion-card", {
  67. "color": [513],
  68. "button": [4],
  69. "type": [1],
  70. "disabled": [4],
  71. "download": [1],
  72. "href": [1],
  73. "rel": [1],
  74. "routerDirection": [1, "router-direction"],
  75. "routerAnimation": [16],
  76. "target": [1]
  77. }]);
  78. function defineCustomElement$1() {
  79. if (typeof customElements === "undefined") {
  80. return;
  81. }
  82. const components = ["ion-card", "ion-ripple-effect"];
  83. components.forEach(tagName => { switch (tagName) {
  84. case "ion-card":
  85. if (!customElements.get(tagName)) {
  86. customElements.define(tagName, Card);
  87. }
  88. break;
  89. case "ion-ripple-effect":
  90. if (!customElements.get(tagName)) {
  91. defineCustomElement$2();
  92. }
  93. break;
  94. } });
  95. }
  96. const IonCard = Card;
  97. const defineCustomElement = defineCustomElement$1;
  98. export { IonCard, defineCustomElement };