import React from 'react'; import { StyleProp, ViewStyle } from 'react-native'; import { Socket } from 'socket.io-client'; import { RenderRequestComponentOptions } from './RenderRequestComponent'; import { RespondToRequestsType } from '../../methods/requestsMethods/respondToRequests'; import { Request } from '../../@types/types'; /** * Configuration parameters used by `RequestsModal` to hydrate dynamic state. * * @interface RequestsModalParameters * * **Utility:** * @property {() => { filteredRequestList: Request[] }} getUpdatedAllParams Fetches the latest filtered request list snapshot. * @property {Record} [key: string] Additional values exposed to modal consumers. */ export interface RequestsModalParameters { /** * Function to get updated parameters, particularly the filtered request list. */ getUpdatedAllParams: () => { filteredRequestList: Request[]; }; [key: string]: any; } /** * Configuration options for the `RequestsModal` component. * * @interface RequestsModalOptions * * **Modal Control:** * @property {boolean} isRequestsModalVisible Toggles modal visibility. * @property {() => void} onRequestClose Invoked when the modal should close. * * **Request Management:** * @property {number} requestCounter Total pending requests displayed in the badge. * @property {Request[]} requestList Complete list of requests to render. * @property {(newRequestList: Request[]) => void} updateRequestList Updates persistent request state after actions. * @property {(text: string) => void} onRequestFilterChange Tracks filter input changes. * @property {RespondToRequestsType} [onRequestItemPress] Optional handler for accept/deny actions (defaults to `respondToRequests`). * * **Session Context:** * @property {string} roomName Identifier for the active room used when responding. * @property {Socket} socket Active socket.io connection enabling real-time updates. * * **State Parameters:** * @property {RequestsModalParameters} parameters Encapsulated helpers that deliver filtered lists to the modal. * * **Customization:** * @property {'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'center'} [position='topRight'] Placement of the modal container. * @property {string} [backgroundColor='#83c0e9'] Background color applied to the modal card. * @property {StyleProp} [style] Additional styling injected into the modal container. * @property {React.FC} [renderRequestComponent] Custom renderer for individual request items. * * **Advanced Render Overrides:** * @property {(options: { defaultContent: JSX.Element; dimensions: { width: number; height: number } }) => JSX.Element} [renderContent] * Override for the default body layout. * @property {(options: { defaultContainer: JSX.Element; dimensions: { width: number; height: number } }) => JSX.Element} [renderContainer] * Override for the modal container wrapper. */ export interface RequestsModalOptions { /** * Flag to control the visibility of the modal. */ isRequestsModalVisible: boolean; /** * Callback function to handle the closing of the modal. */ onRequestClose: () => void; /** * Initial count of requests. */ requestCounter: number; /** * Function to handle the filter input changes. */ onRequestFilterChange: (text: string) => void; /** * Function to handle the action when a request item is pressed. */ onRequestItemPress?: RespondToRequestsType; /** * List of requests. */ requestList: Request[]; /** * Function to update the request list. */ updateRequestList: (newRequestList: Request[]) => void; /** * Name of the room. */ roomName: string; /** * Socket instance for real-time communication. */ socket: Socket; /** * Component to render each request item. * Defaults to RenderRequestComponent. */ renderRequestComponent?: React.FC; /** * Background color of the modal. * Defaults to '#83c0e9'. */ backgroundColor?: string; /** * Position of the modal on the screen. * Possible values: 'topLeft', 'topRight', 'bottomLeft', 'bottomRight', 'center'. * Defaults to 'topRight'. */ position?: 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'center'; /** * Additional parameters for the modal. */ parameters: RequestsModalParameters; /** * Optional custom style for the modal container. */ style?: StyleProp; /** * Custom render function for modal content. */ renderContent?: (options: { defaultContent: JSX.Element; dimensions: { width: number; height: number; }; }) => JSX.Element; /** * Custom render function for the modal container. */ renderContainer?: (options: { defaultContainer: JSX.Element; dimensions: { width: number; height: number; }; }) => JSX.Element; } export type RequestsModalType = (options: RequestsModalOptions) => JSX.Element; /** * RequestsModal - Participant request management modal. * * Presents host/co-host controls for reviewing, filtering, and responding to * participant requests (raise hand, mic access, etc.) in real time. Supports * custom row renderers and override hooks for deeper UI customization. * * **Key Features:** * - Real-time request badge that mirrors the incoming queue length. * - Inline search/filtering to quickly find participants. * - Default integration with `respondToRequests` for socket acknowledgements. * - Configurable modal positioning and optional container styling. * - Empty-state messaging when no results match the filter. * - Override hooks (`renderContent`/`renderContainer`) for advanced layouts. * - Custom request row support via `renderRequestComponent`. * - Keyboard-friendly text input for quick filtering. * * **UI Customization:** * Supply a replacement component through `uiOverrides.requestsModal` to swap * the entire modal while reusing the provided action handlers. * * @component * @param {RequestsModalOptions} props Component properties. * @returns {JSX.Element} Rendered request management modal. * * @example * ```tsx * // Basic host usage * ({ filteredRequestList: filtered }) }} * /> * ``` * * @example * ```tsx * // Custom request renderer * ({ filteredRequestList: filtered }) }} * /> * ``` * * @example * ```tsx * // uiOverrides integration * const RequestsModalComponent = withOverride(uiOverrides.requestsModal, RequestsModal); * * ``` */ declare const RequestsModal: React.FC; export default RequestsModal;