ion-refresher-content.js 5.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*!
  2. * (C) Ionic http://ionicframework.com - MIT License
  3. */
  4. import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
  5. import { E as ENABLE_HTML_CONTENT_DEFAULT, a as sanitizeDOMString } from './config.js';
  6. import { p as caretBackSharp, q as arrowDown } from './index7.js';
  7. import { c as config } from './index4.js';
  8. import { b as getIonMode } from './ionic-global.js';
  9. import { e as supportsRubberBandScrolling } from './refresher.utils.js';
  10. import { d as defineCustomElement$2, S as SPINNERS } from './spinner.js';
  11. import { d as defineCustomElement$3 } from './icon.js';
  12. const RefresherContent = /*@__PURE__*/ proxyCustomElement(class RefresherContent extends HTMLElement {
  13. constructor() {
  14. super();
  15. this.__registerHost();
  16. this.customHTMLEnabled = config.get('innerHTMLTemplatesEnabled', ENABLE_HTML_CONTENT_DEFAULT);
  17. this.pullingIcon = undefined;
  18. this.pullingText = undefined;
  19. this.refreshingSpinner = undefined;
  20. this.refreshingText = undefined;
  21. }
  22. componentWillLoad() {
  23. if (this.pullingIcon === undefined) {
  24. /**
  25. * The native iOS refresher uses a spinner instead of
  26. * an icon, so we need to see if this device supports
  27. * the native iOS refresher.
  28. */
  29. const hasRubberBandScrolling = supportsRubberBandScrolling();
  30. const mode = getIonMode(this);
  31. const overflowRefresher = hasRubberBandScrolling ? 'lines' : arrowDown;
  32. this.pullingIcon = config.get('refreshingIcon', mode === 'ios' && hasRubberBandScrolling ? config.get('spinner', overflowRefresher) : 'circular');
  33. }
  34. if (this.refreshingSpinner === undefined) {
  35. const mode = getIonMode(this);
  36. this.refreshingSpinner = config.get('refreshingSpinner', config.get('spinner', mode === 'ios' ? 'lines' : 'circular'));
  37. }
  38. }
  39. renderPullingText() {
  40. const { customHTMLEnabled, pullingText } = this;
  41. if (customHTMLEnabled) {
  42. return h("div", { class: "refresher-pulling-text", innerHTML: sanitizeDOMString(pullingText) });
  43. }
  44. return h("div", { class: "refresher-pulling-text" }, pullingText);
  45. }
  46. renderRefreshingText() {
  47. const { customHTMLEnabled, refreshingText } = this;
  48. if (customHTMLEnabled) {
  49. return h("div", { class: "refresher-refreshing-text", innerHTML: sanitizeDOMString(refreshingText) });
  50. }
  51. return h("div", { class: "refresher-refreshing-text" }, refreshingText);
  52. }
  53. render() {
  54. const pullingIcon = this.pullingIcon;
  55. const hasSpinner = pullingIcon != null && SPINNERS[pullingIcon] !== undefined;
  56. const mode = getIonMode(this);
  57. return (h(Host, { key: 'fb78d7e31f8feb31025e58903eb9de85cb928dbd', class: mode }, h("div", { key: '23f67800f09765ef8fde8cf85a843e19e667f337', class: "refresher-pulling" }, this.pullingIcon && hasSpinner && (h("div", { key: '5a08d3b69762f8b51dcd3dcfbaf3fddb707257fa', class: "refresher-pulling-icon" }, h("div", { key: '42a613b029e092acdff7fe613a429375d89f157e', class: "spinner-arrow-container" }, h("ion-spinner", { key: '2f9cdc75938c4d306de7a717ed67901daef71c2c', name: this.pullingIcon, paused: true }), mode === 'md' && this.pullingIcon === 'circular' && (h("div", { key: '1f8a6347b4a46417ba55286a79f1a41f04bf9c91', class: "arrow-container" }, h("ion-icon", { key: '326713d11d482d420ba5a739ff4528400a37e9ca', icon: caretBackSharp, "aria-hidden": "true" })))))), this.pullingIcon && !hasSpinner && (h("div", { key: 'ab18c7cbea7bcbfa034f90f317652af4d93660ed', class: "refresher-pulling-icon" }, h("ion-icon", { key: 'f488acd54acc8a61b6c5a279f0d7f9a437c370c0', icon: this.pullingIcon, lazy: false, "aria-hidden": "true" }))), this.pullingText !== undefined && this.renderPullingText()), h("div", { key: '914ad6139442dac53af47120ea821fa11c309a38', class: "refresher-refreshing" }, this.refreshingSpinner && (h("div", { key: '7eba732f5e2d72b90399d68a3e89617d8979b3d1', class: "refresher-refreshing-icon" }, h("ion-spinner", { key: '838d66d8bef6f56622c62b1068e7fed29e094302', name: this.refreshingSpinner }))), this.refreshingText !== undefined && this.renderRefreshingText())));
  58. }
  59. get el() { return this; }
  60. }, [0, "ion-refresher-content", {
  61. "pullingIcon": [1025, "pulling-icon"],
  62. "pullingText": [1, "pulling-text"],
  63. "refreshingSpinner": [1025, "refreshing-spinner"],
  64. "refreshingText": [1, "refreshing-text"]
  65. }]);
  66. function defineCustomElement$1() {
  67. if (typeof customElements === "undefined") {
  68. return;
  69. }
  70. const components = ["ion-refresher-content", "ion-icon", "ion-spinner"];
  71. components.forEach(tagName => { switch (tagName) {
  72. case "ion-refresher-content":
  73. if (!customElements.get(tagName)) {
  74. customElements.define(tagName, RefresherContent);
  75. }
  76. break;
  77. case "ion-icon":
  78. if (!customElements.get(tagName)) {
  79. defineCustomElement$3();
  80. }
  81. break;
  82. case "ion-spinner":
  83. if (!customElements.get(tagName)) {
  84. defineCustomElement$2();
  85. }
  86. break;
  87. } });
  88. }
  89. const IonRefresherContent = RefresherContent;
  90. const defineCustomElement = defineCustomElement$1;
  91. export { IonRefresherContent, defineCustomElement };