UNPKG

@omnia/fx

Version:

Provide Omnia Fx typings and tooling for clientside Omnia development.

69 lines (68 loc) 3.32 kB
import { PostStyle, TsxAllowUnknowProperties } from ".."; import { GuidValue, OmitProperties, ThemeDefinition, IPostBaseWithContext, IPostBaseContext, IPersistedPost, ResolvedUserIdentity, ReactionType } from "../../models"; import { IRichTextEditor } from "../richtexteditor"; export interface IPostCustomSlots { /** * Should render both the author name and custom part, if not passed will render default author name * */ renderTitle?: (post: IPersistedPost<IPostBaseWithContext<IPostBaseContext>>, targetThemeId?: GuidValue) => JSX.Element | JSX.Element[]; /** * Render additional content next to the Post/Save button * */ renderActionButtons?: (post: IPersistedPost<IPostBaseWithContext<IPostBaseContext>>, targetThemeId?: GuidValue) => JSX.Element | JSX.Element[]; /** * Render promote post actions, next to Reply * */ promotePostAction?: (post: IPersistedPost<IPostBaseWithContext<IPostBaseContext>>, targetThemeId?: GuidValue) => JSX.Element | JSX.Element[]; } export interface PostPermission { contributor: boolean; moderator: boolean; } export type PostHandler<TPostTypeWithContext extends IPostBaseWithContext<TPostContext>, TPostContext extends IPostBaseContext> = { handleAddingPost: (addingPost: TPostTypeWithContext) => Promise<IPersistedPost<TPostTypeWithContext>>; handleEditingPosts?: (postsBeingEdited: Array<IPersistedPost<TPostTypeWithContext>>) => void; handleUpdatingPost: (updatingPost: IPersistedPost<TPostTypeWithContext>) => Promise<IPersistedPost<TPostTypeWithContext>>; handleDeletingPost: (deletingPost: IPersistedPost<TPostTypeWithContext>) => Promise<IPersistedPost<TPostTypeWithContext>>; handleTogglingLike: (togglingPost: IPersistedPost<TPostTypeWithContext>) => Promise<IPersistedPost<TPostTypeWithContext>>; handleSocialReacts: (postToReact: IPersistedPost<TPostTypeWithContext>, isReacts: boolean, reactionType: ReactionType) => Promise<IPersistedPost<TPostTypeWithContext>>; }; export interface PostProvider<TPostContext extends IPostBaseContext = IPostBaseContext, TPostTypeWithContext extends IPostBaseWithContext<TPostContext> = IPostBaseWithContext<TPostContext>> { posts: Array<IPersistedPost<TPostTypeWithContext>>; promotedPost?: IPersistedPost<TPostTypeWithContext>; handler: PostHandler<TPostTypeWithContext, TPostContext>; } export interface IPostComponent { omniaServiceId: GuidValue; postTypeId: GuidValue; provider: PostProvider; richTextSettings?: OmitProperties<IRichTextEditor, "initialContent" | "onContentChange">; cardStyle?: ThemeDefinition; showMoreSize?: number; styles?: typeof PostStyle; allowLikes?: boolean; enableMention?: boolean; customSlots?: IPostCustomSlots; hideEditOption?: boolean; editContentOnTop?: boolean; getTopPostIds: () => { [commentId: string]: string; }; getUserHash: () => { [principalName: string]: ResolvedUserIdentity; }; topicPermissionDictionary: { [topicId: string]: PostPermission; }; } declare global { namespace JSX { interface Element { } interface ElementClass { } interface IntrinsicElements { "omfx-post-component": TsxAllowUnknowProperties<IPostComponent>; } } }