UNPKG

@selfcommunity/react-ui

Version:

React UI Components to integrate a Community created with SelfCommunity Platform.

179 lines (178 loc) 5.63 kB
import React, { ReactNode } from 'react'; import { SCFeedWidgetType } from '../../types/feed'; import { CustomAdvProps } from '../CustomAdv'; import { SCCustomAdvPosition, SCFeedUnitType, SCUserType } from '@selfcommunity/types'; import { EndpointType, SCPaginatedResponse } from '@selfcommunity/api-services'; import { CacheStrategies } from '@selfcommunity/utils'; import { VirtualizedScrollerCommonProps } from '../../shared/VirtualizedScroller'; import { StickyBoxProps } from '../../shared/StickyBox'; /** * FeedSidebarProps has the same props as StickyBoxProps type */ export type FeedSidebarProps = StickyBoxProps; /** * FeedRef props */ export type FeedRef = { addFeedData: (obj: any, syncPagination?: boolean) => void; refresh: () => void; getCurrentFeedObjectIds: () => number[]; }; export interface FeedProps { /** * Id of the feed object * @default 'feed' */ id?: string; /** * Overrides or extends the styles applied to the component. * @default null */ className?: string; /** * Feed API Endpoint */ endpoint: EndpointType; /** * Feed API Query Params * @default [{'limit': 5}] */ endpointQueryParams?: Record<string, string | number>; /** * End message, rendered when no more feed item can be displayed * @default `<FormattedMessage id="ui.feed.noOtherFeedObject" defaultMessage="ui.feed.noOtherFeedObject" />` */ endMessage?: ReactNode; /** * Empty feed placeholder, rendered when no feed item can be displayed * @default null */ emptyFeedPlaceholder?: ReactNode; /** * Refresh message, rendered when no more feed item can be displayed * @default `<FormattedMessage id="ui.feed.refreshRelease" defaultMessage="ui.feed.refreshRelease" />` */ refreshMessage?: ReactNode; /** * Component used as header. It will be displayed at the beginning of the feed @default null */ HeaderComponent?: JSX.Element; /** * Component used as footer. It will be displayed after the end messages @default `<Footer>` */ FooterComponent?: React.ElementType; /** * Props to spread to FooterComponent * @default empty object */ FooterComponentProps?: any; /** * Widgets to insert into the feed * @default empty array */ widgets?: SCFeedWidgetType[]; /** * Component used to render single feed item retrieved by the endpoint */ ItemComponent: React.ElementType; /** * Function used to convert the single result returned by the Endpoint into the props necessary to render the ItemComponent */ itemPropsGenerator: (scUser: SCUserType, item: any) => any; /** * Function used to generate an id from the single result returned by the Endpoint */ itemIdGenerator: (item: any) => any; /** * Props to spread to single feed item * @default empty object */ ItemProps?: any; /** * Skeleton used to render loading effect during fetch */ ItemSkeleton: React.ElementType; /** * Props to spread to single feed item skeleton * @default empty object */ ItemSkeletonProps?: any; /** * Callback invoked whenever data is loaded during paging next */ onNextData?: (page: number, offset: number, total: number, data: any[]) => any; /** * Callback invoked whenever data is loaded during paging previous */ onPreviousData?: (page: number, offset: number, total: number, data: any[]) => any; /** * Authenticated or not */ requireAuthentication?: boolean; /** * Caching strategies * @default CacheStrategies.CACHE_FIRST */ cacheStrategy?: CacheStrategies; /** * Props to spread to the sidebar * @default {} */ FeedSidebarProps?: FeedSidebarProps; /** * Props to spread to single custom adv element (this props can be used only if Custom Adv are enabled) * @default {} */ CustomAdvProps?: CustomAdvProps; /** * Props to programmatically enable the custom adv position in the feed * @default [SCCustomAdvPosition.POSITION_FEED_SIDEBAR, SCCustomAdvPosition.POSITION_FEED] */ enabledCustomAdvPositions?: SCCustomAdvPosition[]; /** * Prefetch data. Useful for SSR. * Use this to init the component (in particular useSCFetchFeed) */ prefetchedData?: SCPaginatedResponse<SCFeedUnitType>; /** * If the feed is being rendered in a "scrollable container" * (for example, if one of the parent elements of the list is * styled with max-height and overflow: auto), * then passing the "scrollableTargetId" */ scrollableTargetId?: string; /** * Props to spread to VirtualizedScroller object. * @default {} */ VirtualizedScrollerProps?: VirtualizedScrollerCommonProps; /** * Add/remove pagination links on top/bottom of items * @default false */ disablePaginationLinks?: boolean; /** * Show/hide pagination links * @default true */ hidePaginationLinks?: boolean; /** * Page query parameter name * @default 'page' */ paginationLinksPageQueryParam?: string; /** * Props to spread to the pagination Link component * @default {} */ PaginationLinkProps?: Record<string, any>; /** * Show/hide adv banners * @default false */ hideAdvs?: boolean; } declare const _default: React.ForwardRefExoticComponent<FeedProps & React.RefAttributes<FeedRef>>; export default _default;