@trycourier/courier-ui-inbox
Version:
Inbox components for the Courier web UI
220 lines (219 loc) • 8.54 kB
TypeScript
import { CourierBaseElement, CourierComponentThemeMode } from '@trycourier/courier-ui-core';
import { CourierInboxFeed } from '../types/inbox-data-set';
import { CourierInboxHeaderFactoryProps, CourierInboxHeaderFeed, CourierInboxListItemActionFactoryProps, CourierInboxListItemFactoryProps, CourierInboxPaginationItemFactoryProps, CourierInboxStateEmptyFactoryProps, CourierInboxStateErrorFactoryProps, CourierInboxStateLoadingFactoryProps } from '../types/factories';
import { CourierInboxTheme } from '../types/courier-inbox-theme';
import { CourierInboxThemeManager } from '../types/courier-inbox-theme-manager';
import { CourierInboxHeaderAction, CourierInboxListItemAction } from '../types/inbox-defaults';
export declare class CourierInbox extends CourierBaseElement {
static get id(): string;
/**
* Returns the default set of feeds used by CourierInbox.
* Exposed as a convenience for constructing matching datasets in
* custom integrations (for example, when using CourierInboxDatastore directly).
*
* @example
* Returns:
* [
* {
* feedId: 'inbox_feed',
* title: 'Inbox',
* iconSVG: CourierIconSVGs.inbox,
* tabs: [
* {
* datasetId: 'all_messages',
* title: 'All Messages',
* filter: {}
* }
* ]
* },
* {
* feedId: 'archive_feed',
* title: 'Archive',
* iconSVG: CourierIconSVGs.archive,
* tabs: [
* {
* datasetId: 'archived_messages',
* title: 'Archived Messages',
* filter: {
* archived: true
* }
* }
* ]
* }
* ]
*/
static defaultFeeds(): CourierInboxFeed[];
/**
* Returns the default header actions used by CourierInbox.
* Exposed as a convenience for building matching headers in custom UIs.
*
* @example
* Returns:
* [
* { id: 'readAll' },
* { id: 'archiveRead' },
* { id: 'archiveAll' }
* ]
*/
static defaultActions(): CourierInboxHeaderAction[];
/**
* Returns the default list item actions used by CourierInbox.
* Exposed as a convenience for building matching message menus in custom UIs.
*
* @example
* Returns:
* [
* { id: 'read_unread' },
* { id: 'archive_unarchive' }
* ]
*/
static defaultListItemActions(): CourierInboxListItemAction[];
private _currentFeedId;
private _feedTabMap;
/** Returns the current feed type. */
get currentFeedId(): string;
/** Returns the current tab ID for the current feed. */
private get _currentTabId();
/** Returns the selected tab ID for a given feed ID. */
private getSelectedTabIdForFeed;
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 _list?;
private _datastoreListener;
private _authListener;
private _feeds;
private _header?;
private _headerFactory;
private _actions;
private _onMessageClick?;
private _onMessageActionClick?;
private _onMessageLongPress?;
private _listItemActions;
private _defaultProps;
static get observedAttributes(): string[];
constructor(themeManager?: CourierInboxThemeManager);
private resetInitialFeedAndTab;
onComponentMounted(): void;
private readInitialThemeAttributes;
private setupThemeSubscription;
private setupAuthListener;
private initializeInboxData;
private attachElements;
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;
private reloadListForTab;
/**
* Sets the active feed for the inbox.
* @param feedId - The feed ID to display.
*/
selectFeed(feedId: string): void;
/**
* Switches to a tab by updating components and loading data.
* @param tabId - The tab ID to switch to.
* @param animate - Whether to animate the scroll to top.
*/
selectTab(tabId: string): void;
/**
* Updates unread counts for a list of tabs.
* @param tabs - The tabs to update unread counts for.
*/
private updateTabUnreadCounts;
/**
* Sets the enabled header actions for the inbox.
* Pass an empty array to remove all actions.
* @param actions - The header actions to enable (e.g., [{ id: 'readAll', iconSVG: '...', text: '...' }]).
*/
setActions(actions: CourierInboxHeaderAction[]): void;
/**
* Sets the enabled list item actions for the inbox.
* Pass an empty array to remove all actions.
* @param actions - The list item actions to enable (e.g., [{ id: 'read_unread', readIconSVG: '...', unreadIconSVG: '...' }]).
*/
setListItemActions(actions: CourierInboxListItemAction[]): void;
/**
* Sets the feeds for the inbox.
* @param feeds - The feeds to set for the inbox.
*/
setFeeds(feeds: CourierInboxFeed[]): void;
/** Get the current set of feeds. */
getFeeds(): CourierInboxFeed[];
/**
* Returns the header feeds in the format expected by header factories.
* @public
*/
getHeaderFeeds(): CourierInboxHeaderFeed[];
private updateHeader;
private load;
/**
* Forces a reload of the inbox data, bypassing the cache.
*/
refresh(): Promise<void>;
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
}