import type { ReactNode, Ref, MouseEvent, MouseEventHandler } from 'react'; import type { UtilitiesSummaryProps } from '@pega/cosmos-react-work/lib/components/CaseView/UtilitiesSummary'; import type { BaseProps, AvatarProps, SentimentProps, OmitStrict, MenuProps, MenuItemProps, NoChildrenProp, EmptyStateProps, ProgressProps, PageTemplateProps, PopoverProps, BannerProps, FileItemProps, FileDisplayListProps } from '@pega/cosmos-react-core'; import type { EditorProps, EditorState, RichTextEditorProps } from '@pega/cosmos-react-rte'; import type { AISummaryProps } from '@pega/cosmos-react-social'; import type { EmailSelectorProps } from './EmailSelector'; export interface EmailTemplate { /** Template title */ title: string; /** Template id */ id: string; /** categorized templates */ templates?: Pick[]; } export interface EmailUser { /** Short name of the User */ shortName: string; /** Full name of the User */ fullName: string; /** Email of the User */ emailAddress: string; /** Avatar props of the User */ avatarProps?: Partial; } export interface EntityHighlightMapping { value: string; type: string; variant: number; names?: string[]; icon?: string; } export interface EntityMatch extends EntityHighlightMapping, MatchRange { matchedText: string; children?: EntityMatch[]; } export interface MatchRange { start: number; end: number; } export interface ContextMenuProps extends Pick { /** Callback triggered when a menu item is clicked */ onItemClick: (selectedValue: { fieldName: string; fieldValue: string; }) => void; /** Menu items */ items: MenuItemProps[]; /** Imperative handle */ handle: Ref; } export interface ContextMenuHandleValue { setItems: (contextMenuItems: ContextMenuProps['items']) => void; setOpen: (open: boolean) => void; setLoading: (loading: boolean) => void; } export interface EmailProps extends BaseProps, NoChildrenProp { /** Ref to the element */ ref?: Ref; /** Unique ID for this email record */ id: string; /** Timestamp of this email as ISO8601 string, timestamp or native Date object. */ timeStamp: Date | number | string; /** From email */ from: EmailUser; /** To email */ to: EmailUser[]; /** Carbon copy of email users list */ cc?: EmailUser[]; /** Blind carbon copy of email users list */ bcc?: EmailUser[]; /** Sentiment */ sentiment?: SentimentProps; /** Subject of the email */ subject?: string; /** Body */ body?: string; /** Forwarded content or previous conversation content. Collapsed by default. Can be defer loaded */ trail?: { /** HTML string containing the trail messages */ content?: string; /** * Flag to show progress indicator * @default false */ loading?: boolean; /** Flag indicating the expanded state of the trail. Expanded when true and collapsed when false */ expanded: boolean; /** Callback triggered when the expand or collapse button is clicked */ onExpandCollapse: (id: EmailProps['id']) => void; }; /** * Entity highlight mapping * This requires body to be passed as a string with html tags */ entityHighlightMapping?: EntityHighlightMapping[]; /** onReply callback */ onReply?: (id: EmailProps['id']) => void; /** onForward Callback */ onForward?: (id: EmailProps['id']) => void; /** onReply callback */ onReplyAll?: (id: EmailProps['id']) => void; /** Edit draft callback */ onEditDraft?: (id: EmailProps['id']) => void; /** Delete draft Callback */ onDeleteDraft?: (id: EmailProps['id']) => void; /** Show either undelivered or draft status on email */ status?: 'undelivered' | 'draft'; /** List of suggestions */ suggestions?: EmailTemplate[]; /** Callback that triggers on click of tag */ onSuggestionClick?: (id: EmailProps['id'], suggestionId: EmailTemplate['id']) => void; /** * Flag that indicates if email is unread * @default false */ unRead?: boolean; /** Attachments list */ attachments?: FileDisplayListProps['items']; /** * Context menu props. Context menu is disabled if it is not provided. * To set the context menu items, use the setContextMenuItems method provided on handle */ contextMenu?: OmitStrict & { /** Callback on right click of content */ onContextMenu: (id: EmailProps['id'], e: MouseEvent) => void; }; /** Show banner for undelivered email */ banner?: Pick; /** * Flag indicating whether the email is marked as important. * @default false */ markAsImportant?: boolean; } export interface EmailConversationProps extends BaseProps { /** ref to the element */ ref?: Ref; /** Unique ID for this email conversation record */ id: string; /** List of mails */ emails: EmailProps[]; /** Sender(s) of this email conversation */ from: EmailUser; /** Recipient(s) of this email conversation */ to: EmailUser[]; /** Count of unread emails */ unReadEmailCount?: number; /** Total number of attachments in the email conversation. */ attachmentCount?: number; /** Timestamp of this conversation as ISO8601 string, timestamp or native Date object. */ timeStamp: Date | string | number; /** Flag that indicates if email conversation is expanded */ isCollapsed?: boolean; /** Flag to set if conversation is spun off from forwarded email */ isForwarded?: boolean; /** Callback when email conversation is collapsed */ onCollapse?: () => void; /** Callback when email conversation is expanded */ onExpand?: () => void; /** Flag that indicates if email conversation contains drafted emails */ drafts?: boolean; /** Flag that indicates if email conversation contains undelivered emails */ undelivered?: boolean; } export type EmailResponseType = 'reply' | 'replyAll' | 'forward'; export type EmailComposerFieldType = 'to' | 'cc' | 'bcc' | 'subject' | 'bodyContent' | 'attachments' | 'emailAccount' | 'responseType' | 'selectedTemplateId' | 'markImportant'; export type EmailComposerValueType = T extends 'to' | 'cc' | 'bcc' ? EmailUser['emailAddress'][] : T extends 'subject' | 'bodyContent' ? string : T extends 'selectedTemplateId' ? string : T extends 'attachments' ? (FileItemProps & { File?: File; })[] : T extends 'responseType' ? EmailResponseType : T extends 'emailAccount' ? string : T extends 'markImportant' ? boolean : never; export interface EmailDirectRecipients { /** To address/addresses in case of reply response type on email. */ reply: EmailUser['emailAddress'][]; /** To address/addresses in case of replyAll response type on email. */ replyAll: EmailUser['emailAddress'][]; /** To address/addresses in case of forward response type on email. */ forward?: EmailUser['emailAddress'][]; } export interface EmailComposerHandleValue { replaceBodyContent: (content: string) => void; updateImage: EditorState['appendImage']; activate: () => void; setCursorLocationToStart: EditorState['setCursorLocationToStart']; } export interface EmailFieldValue extends Pick { value: EmailUser['emailAddress'][]; error?: string; } export interface EmailComposerBaseProps extends Pick, BaseProps, NoChildrenProp { /** Show loader until the background process completes */ progress?: boolean | Pick; /** Object containing full list of email participants. */ participants: EmailUser[]; /** Object containing full list of sender email accounts */ senderAccounts?: EmailUser[]; /** Data for all fields of the composer */ data: { /** Object to hold selected email account and field error */ emailAccount?: OmitStrict & { value: EmailUser['emailAddress']; }; /** Object to hold To field data */ to?: EmailFieldValue; /** Object to hold Cc field data */ cc?: EmailFieldValue; /** Object to hold Bcc field data */ bcc?: EmailFieldValue; /** Object to hold the subject value and error */ subject: { value: string; error?: string; }; /** Object containing the default body content and error */ bodyContent: { defaultValue: string; error?: string; }; /** Selected template id */ selectedTemplateId?: EmailTemplate['id']; /** List of attachments */ attachments?: FileItemProps[]; /** Email response types */ responseType?: EmailResponseType; } & Pick; /** Callback when image is added */ onImageAdded?: RichTextEditorProps['onImageAdded']; /** Region to show more actions in footer */ footerMoreActions?: ReactNode; /** Templates for drafting email */ templates?: EmailTemplate[]; /** Callback when user clicks on cancel */ onCancel: () => void; /** * Callback to handle external entry validation for to, cc and bcc fields while adding a new email to the list * If returned true considers the entry to be a valid entry */ externalValidator?: (value: string) => boolean; /** Ref to the element */ ref?: Ref; /** Imperative handle for composer */ handle?: Ref; /** Change handler to all fields */ onChange: (field: T, value: EmailComposerValueType, isProgrammatic?: boolean) => void; /** Callback fired when the Combobox input value changes. */ onFilterChange: >(field: T, filterValue: string) => void; /** Callback to fetch more rows */ onLoadMore?: >(field: T, filterValue: string) => void; /** Callback when composer body editor is initialized */ onEditorInit?: EditorProps['onInit']; } type EmailComposerActions = { onSend: () => void; onSave?: () => void; } | { onSend?: () => void; onSave: () => void; }; export type EmailComposerProps = EmailComposerBaseProps & EmailComposerActions; export interface EmailShellProps extends BaseProps { /** ref to the element */ ref?: Ref; /** Region for header */ headerProps?: { /** Region for actions */ actions?: ReactNode; /** Subject of the email conversations list */ subject?: string; }; /** Email conversations */ conversations?: EmailConversationProps[]; /** Shows only one conversation at a time */ autoCollapse?: boolean; summary?: AISummaryProps; } export interface EmailSummaryItemProps extends BaseProps, Pick { /** Id of each summary item */ id: string; /** List of from participant names of the conversations */ activeParticipants: EmailUser[]; /** Email body of last email in the email */ message: string; /** Timestamp of the latest email */ timeStamp: Date | string | number; /** Top topic of an email */ topic?: string; /** Sentiment */ sentiment?: SentimentProps; /** Urgency of an email */ urgency?: number; /** Total number of unread emails in the email */ unreadEmailCount?: number; /** Is the email currently active */ active?: boolean; /** On click of email item */ onSelect: (id: EmailSummaryItemProps['id']) => void; /** Contains search string used to highlight matching text in heading */ searchQuery?: EmailSummaryListProps['searchQuery']; /** ref to the element */ ref?: Ref; } export interface Filter { /** Sets DOM id for the control and associates label element via 'for' attribute. */ id: string; /** Pass a string or a fragment with an Icon and string for the filter label. */ label: ReactNode; /** * Disables the filter. * @default false */ disabled?: boolean; /** * Sets on prop via onFilterChange. * @default false */ on?: boolean; } interface EmailCount { total: number; unread?: number; } export interface EmailSummaryListProps extends BaseProps { /** List of email categories */ categories?: MenuProps['items']; /** Handles category change */ onCategoryClick?: MenuItemProps['onClick']; /** List of EmailItems items */ items: OmitStrict[]; /** Object containing count of total and unread emails */ count?: EmailCount; /** A set of filters to apply to the email inbox. */ filters?: Filter[]; /** A callback that runs when a filter is clicked. */ onFilterChange?: (filterId: Filter['id'], on: boolean) => void; /** onClick of list item */ onItemClick: (id: EmailSummaryItemProps['id']) => void; /** Indicates if the data is being currently loading */ loading?: boolean; /** Callback to fetch more rows */ onLoadMore?: () => void; /** Empty message when there are no email summary items */ emptyMessage?: EmptyStateProps['message']; /** Id of the EmailSummaryItem */ currentItemId?: string; /** Use summary list as selectable list */ selectable?: boolean; /** Contains search string used to show static heading text and * show matching text as highlighted text in EmailSummaryItem heading */ searchQuery?: string; /** ref to the element */ ref?: Ref; } export interface EmailEntityProps extends BaseProps { entity: OmitStrict & { description?: string | string[]; }; ref?: Ref; } export interface TargetProps { cursorPosition: { x: number; y: number; }; targetNode: Element | null; } export interface ContextMenuPopoverProps extends BaseProps, TargetProps { contextMenu: ContextMenuProps; show: PopoverProps['show']; ref?: PopoverProps['ref']; } export interface EntityListProps extends BaseProps { content: { name: string; value?: { id: string; entity: OmitStrict; }[]; }[]; header?: { icon: string; text: string; }; /** * Context menu props. Context menu is disabled if it is not provided. * To set the context menu items, use the setContextMenuItems method provided on handle */ contextMenu?: OmitStrict & { onContextMenu: (e: MouseEvent) => void; popoverRef?: ContextMenuPopoverProps['ref']; }; ref?: Ref; } export interface EmailManagerProps extends BaseProps { /** Header of the component */ header?: { title: PageTemplateProps['title']; icon?: PageTemplateProps['icon']; getNextEmail?: () => void; }; /** A region to hold an EmailSummaryList component */ list?: ReactNode; /** Email case details */ emailCaseDetails?: ReactNode; } export interface EmailCaseViewProps extends BaseProps { /** Header of the the component */ header?: EmailManagerProps['header']; /** A region to hold an Emails component */ content: ReactNode; /** A region above the center column to display banners. */ banners?: ReactNode; /** A region that is used to hold Utility components. */ utilities?: ReactNode; /** The utilities summary array will be used to render the minimized utilities card. */ utilitiesSummaryItems?: UtilitiesSummaryProps['items']; /** Expand/Collapse utilities */ defaultUtilitiesExpanded?: boolean; } export interface EmailNotificationPanelProps extends BaseProps { count: number; label: string; onClick: MouseEventHandler; } export {}; //# sourceMappingURL=Email.types.d.ts.map