@selfcommunity/react-ui
Version:
React UI Components to integrate a Community created with SelfCommunity Platform.
103 lines (97 loc) • 3.78 kB
TypeScript
import { SyntheticEvent } from 'react';
import { SCCategoryType, SCContributionType, SCEventType, SCFeedDiscussionType, SCFeedPostType, SCFeedStatusType, SCFeedTypologyType, SCGroupType, SCMediaType, SCPollType, SCTagType } from '@selfcommunity/types';
import { DialogProps } from '@mui/material';
import { EditorProps } from '../Editor';
import { SCMediaObjectType } from '../../types/media';
export interface ComposerProps extends Omit<DialogProps, 'defaultValue' | 'scroll'> {
/**
* Id of feed object
* @default null
*/
feedObjectId?: number;
/**
* Type of feed object
* @default null
*/
feedObjectType?: Exclude<SCContributionType, SCContributionType.COMMENT>;
/**
* Feed object
* @default null
*/
feedObject?: SCFeedDiscussionType | SCFeedPostType | SCFeedStatusType | null;
/**
* Initialization Data for the Composer, this is a hook to generate custom posts
* @default null
*/
defaultValue?: {
title?: string;
text?: string;
categories?: SCCategoryType[];
event?: SCEventType;
group?: SCGroupType;
audience?: string;
addressing?: SCTagType[];
medias?: SCMediaType[];
poll?: SCPollType;
location?: string;
};
/**
* Media objects available
* @default File, Document, Link
*/
mediaObjectTypes?: SCMediaObjectType[];
/**
* Editor props
* @default {}
*/
EditorProps?: Omit<EditorProps, 'onFocus'>;
/**
* Callback triggered on success contribution creation
* @default null
*/
onSuccess?: (res: any) => void;
/**
* Callback triggered on close click
* @default null
*/
onClose?: (e: SyntheticEvent) => void;
/**
* The feed where the component is rendered
* @default SCFeedTypologyType.HOME
*/
feedType?: SCFeedTypologyType;
}
/**
* > API documentation for the Community-JS Composer component. Learn about the available props and the CSS API.
*
*
* The Composer component contains the logic around the creation of [Post](https://developers.selfcommunity.com/docs/apireference/v2/post/create_a_post) and [Discussion](https://developers.selfcommunity.com/docs/apireference/v2/discussion/create_a_discussion) objects.
*
*
:::info
To prevent the editor toolbar and action botton bar being hidden underneath the Virtual Keyboard you need to set the `interactive-widget=resizes-content` on meta viewport.
This works on chrome for android.
For iOS devices there is a lack of support of this meta so we force the blur event when the user start dragging.
[More information](https://bram.us/2021/09/13/prevent-items-from-being-hidden-underneath-the-virtual-keyboard-by-means-of-the-virtualkeyboard-api/)
:::
#### Import
```jsx
import {Composer} from '@selfcommunity/react-ui';
```
#### Component Name
The name `SCComposer` can be used when providing style overrides in the theme.
#### CSS
|Rule Name|Global class|Description|
|---|---|---|
|root|.SCComposer-root|Styles applied to the root element.|
|ios|.SCComposer-ios|Styles applied to the root element when the device is ios.|
|title|.SCComposer-title|Styles applied to the title element.|
|types|.SCComposer-types|Styles applied to the types element.|
|content|.SCComposer-content|Styles applied to the content.|
|attributes|.SCComposer-attributes|Styles applied to the attributes.|
|medias|.SCComposer-medias|Styles applied to the medias.|
|actions|.SCComposer-actions|Styles applied to the actions section.|
|layerTransitionRoot|.SCComposer-layer-transition-root|Styles applied to the overlay layers (eg. location).|
* @param inProps
*/
export default function Composer(inProps: ComposerProps): JSX.Element;