import "./spinner-DIlC--PL.js"; import { CSSResultGroup, PropertyValues } from "lit"; import { SigveloElement } from "@mcp-b/wc-support/base/sigvelo-element"; //#region src/components/infinite-scroller/infinite-scroller.d.ts /** * * * @summary Provides an accessible container for continuously loading content feeds. * @tag sigvelo-infinite-scroller * @documentation https://design-system.sigvelo.com/docs/components/infinite-scroller * @status stable * @since 1.0 * * @dependency sigvelo-spinner * * @slot - The default slot for feed items. Each item should have role="article" and be focusable. * * @event sigvelo-load-more - Emitted when scrolling reaches the threshold and more items should be loaded. * * @cssstate loading - Applied when the infinite scroller is loading more content. * @cssstate complete - Applied when the infinite scroller has no more content to load. * * @example Default * Infinite scrollers load new content automatically as users scroll down a feed. Instead of clicking "Next" buttons, content continuously appears as they approach the bottom. Infinite scroller follows the ARIA APG Infinite Scrolling Feed pattern for accessibility. * * ```html * *
Item 1
*
Item 2
*
Item 3
*
Item 4
*
Item 5
*
Item 6
*
Item 7
*
Item 8
*
Item 9
*
Item 10
*
Item 11
*
Item 12
*
Item 13
*
Item 14
*
Item 15
*
Item 16
*
Item 17
*
Item 18
*
Item 19
*
Item 20
*
* * * * * ``` * * @example Providing initial content * You can slot just about any content you want into an infinite scroller container. The component watches the scroll position and dispatches the `sigvelo-load-more` event when users get close to the bottom. * * ```html * * *
First item
*
Second item
*
Third item
* ... *
* ``` * * @example Loading more content * In your code, listen for the `sigvelo-load-more` event. This is your cue to asynchronously load more content, e.g. from the server, and append it to the container. If no more content is available, call the component's `complete()` method to disable further loading. * * ```js * const infiniteScroll = document.querySelector('sigvelo-infinite-scroll'); * let currentPage = 1; * * infiniteScroll.addEventListener('sigvelo-load-more', async () => { * try { * // Fetch new data from your API * const response = await fetch(`/api/posts?page=${currentPage}`); * const posts = await response.json(); * * // Append posts to the feed * posts.forEach(post => { * const item = document.createElement('article'); * item.className = 'feed-item'; * item.innerHTML = `

${post.title}

${post.excerpt}

`; * infiniteScroll.appendChild(item); * }); * * currentPage++; * * // Stop loading when no more content is available * if (posts.length === 0) { * infiniteScroll.complete(); * } * } catch (error) { * console.error('Failed to load more items:', error); * } * }); * ``` * * To reenable loading, append additional items to the container or perform any DOM action that results in a `slotchange`. * * **Note:** When the container is empty initially or if the items don't cause the container to scroll, the `sigvelo-load-more` event will be dispatched immediately to request more items. This behavior allows the entire feed to load, regardless of content or screen size. */ declare class SigveloInfiniteScroller extends SigveloElement { static styles: CSSResultGroup; defaultSlot: HTMLSlotElement; isLoading: boolean; isComplete: boolean; private contentCheckFrameId; private localize; private thresholdInPixels; private thresholdInPercent; /** An accessible label for the feed. */ label: string; /** * The scroll threshold at which to trigger loading more items. Accepts percentages (e.g., "20%") or pixels * (e.g., "200px"). */ threshold: string; connectedCallback(): void; disconnectedCallback(): void; updated(changedProperties: PropertyValues): void; private parseThreshold; private checkScrollThreshold; private handleScroll; private handleSlotChange; private isScrollable; private scheduleContentCheck; /** * Mark the feed as completed, preventing further load events. Changing content in the default slot will reset this * and re-enable infinite scrolling. */ complete(): void; render(): import("lit-html").TemplateResult<1>; } declare global { interface HTMLElementTagNameMap { "sigvelo-infinite-scroller": SigveloInfiniteScroller; } } //#endregion export { SigveloInfiniteScroller as t };