UNPKG

@trycourier/courier-ui-inbox

Version:

Inbox components for the Courier web UI

108 lines (107 loc) 4.89 kB
import { CourierBaseElement, CourierComponentThemeMode } from '@trycourier/courier-ui-core'; import { CourierInboxFeedType } from '../types/feed-type'; import { CourierInboxHeaderFactoryProps, CourierInboxListItemActionFactoryProps, CourierInboxListItemFactoryProps, CourierInboxPaginationItemFactoryProps, CourierInboxStateEmptyFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxStateLoadingFactoryProps } from '../types/factories'; import { CourierInboxTheme } from '../types/courier-inbox-theme'; import { CourierInboxThemeManager } from '../types/courier-inbox-theme-manager'; export declare class CourierInbox extends CourierBaseElement { static get id(): string; private _currentFeed; /** Returns the current feed type. */ get currentFeed(): CourierInboxFeedType; private _themeManager; /** Returns the current theme object. */ get theme(): CourierInboxTheme; /** * Set the light theme for the inbox. * @param theme The light theme object to set. */ setLightTheme(theme: CourierInboxTheme): void; /** * Set the dark theme for the inbox. * @param theme The dark theme object to set. */ setDarkTheme(theme: CourierInboxTheme): void; /** * Set the theme mode (light/dark/system). * @param mode The theme mode to set. */ setMode(mode: CourierComponentThemeMode): void; private _inboxStyle?; private _unreadIndicatorStyle?; private _list?; private _datastoreListener; private _authListener; private _header?; private _headerFactory; private _onMessageClick?; private _onMessageActionClick?; private _onMessageLongPress?; private _defaultProps; static get observedAttributes(): string[]; constructor(themeManager?: CourierInboxThemeManager); onComponentMounted(): void; onComponentUnmounted(): void; private refreshTheme; private getStyles; /** * Sets a custom header factory for the inbox. * @param factory - A function that returns an HTMLElement to render as the header. */ setHeader(factory: (props: CourierInboxHeaderFactoryProps | undefined | null) => HTMLElement): void; /** * Removes the custom header factory from the inbox, reverting to the default header. */ removeHeader(): void; /** * Sets a custom loading state factory for the inbox list. * @param factory - A function that returns an HTMLElement to render as the loading state. */ setLoadingState(factory: (props: CourierInboxStateLoadingFactoryProps | undefined | null) => HTMLElement): void; /** * Sets a custom empty state factory for the inbox list. * @param factory - A function that returns an HTMLElement to render as the empty state. */ setEmptyState(factory: (props: CourierInboxStateEmptyFactoryProps | undefined | null) => HTMLElement): void; /** * Sets a custom error state factory for the inbox list. * @param factory - A function that returns an HTMLElement to render as the error state. */ setErrorState(factory: (props: CourierInboxStateErrorFactoryProps | undefined | null) => HTMLElement): void; /** * Sets a custom list item factory for the inbox list. * @param factory - A function that returns an HTMLElement to render as a list item. */ setListItem(factory: (props: CourierInboxListItemFactoryProps | undefined | null) => HTMLElement): void; /** * Sets a custom pagination item factory for the inbox list. * @param factory - A function that returns an HTMLElement to render as a pagination item. */ setPaginationItem(factory: (props: CourierInboxPaginationItemFactoryProps | undefined | null) => HTMLElement): void; /** * Registers a handler for message click events. * @param handler - A function to be called when a message is clicked. */ onMessageClick(handler?: (props: CourierInboxListItemFactoryProps) => void): void; /** * Registers a handler for message action click events. * @param handler - A function to be called when a message action is clicked. */ onMessageActionClick(handler?: (props: CourierInboxListItemActionFactoryProps) => void): void; /** * Registers a handler for message long press events. * @param handler - A function to be called when a message is long-pressed. */ onMessageLongPress(handler?: (props: CourierInboxListItemFactoryProps) => void): void; /** * Sets the feed type for the inbox (e.g., "inbox" or "archive"). * @param feedType - The feed type to display. */ setFeedType(feedType: CourierInboxFeedType): void; private updateHeader; private load; /** * Forces a reload of the inbox data, bypassing the cache. */ refresh(): void; attributeChangedCallback(name: string, oldValue: string, newValue: string): void; }