communication-react-19
Version:
React library for building modern communication user experiences utilizing Azure Communication Services (React 19 compatible fork)
72 lines • 3.2 kB
TypeScript
/// <reference types="react" />
import { CallingHandlers, GetCallingSelector } from "../../calling-component-bindings/src";
import { ChatHandlers, GetChatSelector } from "../../chat-component-bindings/src";
import { ChatClientState } from "../../chat-stateful-client/src";
import { CallClientState } from "../../calling-stateful-client/src";
import { Common } from "../../acs-ui-common/src";
/**
* Centralized state for {@link @azure/communication-calling#CallClient} or {@link @azure/communication-chat#ChatClient}.
*
* See also: {@link CallClientState}, {@link ChatClientState}.
* @public
*/
export type ClientState = CallClientState & ChatClientState;
/**
* An optimized selector that refines {@link ClientState} updates into props for React Components in this library.
*
* @public
*/
export type Selector = (state: ClientState, props: any) => any;
/**
* Hook to obtain a selector for a specified component.
*
* Useful when implementing a custom component that utilizes the providers
* exported from this library.
*
* @public
*/
export declare const useSelector: <ParamT extends Selector | undefined>(selector: ParamT, selectorProps?: ParamT extends Selector ? Parameters<ParamT>[1] : undefined, type?: 'calling' | 'chat') => ParamT extends Selector ? ReturnType<ParamT> : undefined;
/**
* Helper type for {@link usePropsFor}.
*
* @public
*/
export type ChatReturnProps<Component extends (props: any) => JSX.Element> = GetChatSelector<Component> extends (state: ChatClientState, props: any) => any ? ReturnType<GetChatSelector<Component>> & Common<ChatHandlers, Parameters<Component>[0]> : never;
/**
* Helper type for {@link usePropsFor}.
*
* @public
*/
export type CallingReturnProps<Component extends (props: any) => JSX.Element> = GetCallingSelector<Component> extends (state: CallClientState, props: any) => any ? ReturnType<GetCallingSelector<Component>> & Common<CallingHandlers, Parameters<Component>[0]> : never;
/**
* Helper type for {@link usePropsFor}.
*
* @public
*/
export type ComponentProps<Component extends (props: any) => JSX.Element> = ChatReturnProps<Component> extends never ? CallingReturnProps<Component> extends never ? undefined : CallingReturnProps<Component> : ChatReturnProps<Component>;
/**
* Primary hook to get all hooks necessary for a React Component from this library.
*
* To call this hook, the component requires to be wrapped under these providers:
*
* 1. For chat components: {@link ChatClientProvider} and {@link ChatThreadClientProvider}.
*
* 2. For calling components: {@link CallClientProvider}, {@link CallAgentProvider} and {@link CallAgentProvider}.
*
* Most straightforward usage of a components looks like:
*
* @example
* ```
* import { ParticipantList, usePropsFor } from '@azure/communication-react';
*
* const App = (): JSX.Element => {
* // ... code to setup Providers ...
*
* return <ParticipantList {...usePropsFor(ParticipantList)}/>
* }
* ```
*
* @public
*/
export declare const usePropsFor: <Component extends (props: any) => JSX.Element>(component: Component, type?: 'calling' | 'chat') => ComponentProps<Component>;
//# sourceMappingURL=mergedHooks.d.ts.map