import type { ComponentInterface } from '@stencil/core'; import { Component, Host, Prop, h } from '@stencil/core'; import { ENABLE_HTML_CONTENT_DEFAULT } from '@utils/config'; import { sanitizeDOMString } from '@utils/sanitization'; import { config } from '../../global/config'; import { getIonTheme } from '../../global/ionic-global'; import type { IonicSafeString } from '../../utils/sanitization'; import type { SpinnerTypes } from '../spinner/spinner-configs'; /** * @virtualProp {"ios" | "md"} mode - The mode determines the platform behaviors of the component. * @virtualProp {"ios" | "md" | "ionic"} theme - The theme determines the visual appearance of the component. */ @Component({ tag: 'ion-infinite-scroll-content', styleUrls: { ios: 'infinite-scroll-content.ios.scss', md: 'infinite-scroll-content.md.scss', ionic: 'infinite-scroll-content.md.scss', }, }) export class InfiniteScrollContent implements ComponentInterface { private customHTMLEnabled = config.get('innerHTMLTemplatesEnabled', ENABLE_HTML_CONTENT_DEFAULT); /** * An animated SVG spinner that shows while loading. */ @Prop({ mutable: true }) loadingSpinner?: SpinnerTypes | null; /** * Optional text to display while loading. * `loadingText` can accept either plaintext or HTML as a string. * To display characters normally reserved for HTML, they * must be escaped. For example `` would become * `<Ionic>` * * For more information: [Security Documentation](https://ionicframework.com/docs/faq/security) * * This property accepts custom HTML as a string. * Content is parsed as plaintext by default. * `innerHTMLTemplatesEnabled` must be set to `true` in the Ionic config * before custom HTML can be used. */ @Prop() loadingText?: string | IonicSafeString; componentDidLoad() { if (this.loadingSpinner === undefined) { const theme = getIonTheme(this); this.loadingSpinner = config.get( 'infiniteLoadingSpinner', config.get('spinner', theme === 'ios' ? 'lines' : 'crescent') ); } } private renderLoadingText() { const { customHTMLEnabled, loadingText } = this; if (customHTMLEnabled) { return
; } return
{this.loadingText}
; } render() { const theme = getIonTheme(this); return (
{this.loadingSpinner && (
)} {this.loadingText !== undefined && this.renderLoadingText()}
); } }