import React from 'react'; import { StyleProp, ViewStyle } from 'react-native'; import { Socket } from 'socket.io-client'; import { HandleCreatePollType, HandleEndPollType, HandleVotePollType, Poll, ShowAlert } from '../../@types/types'; /** * Configuration options for the `PollModal` component. * * @interface PollModalOptions * * **Modal Control:** * @property {boolean} isPollModalVisible Controls modal visibility. * @property {() => void} onClose Callback invoked when the modal should close. * @property {(isVisible: boolean) => void} updateIsPollModalVisible Updates the external visibility state. * * **Poll Management:** * @property {Poll[]} polls Collection of every poll available in the session. * @property {Poll | null} poll Currently active poll (if any) displayed in the modal. * @property {HandleCreatePollType} handleCreatePoll Handler that persists a new poll (host/co-host only). * @property {HandleEndPollType} handleEndPoll Handler that terminates the active poll (host/co-host only). * @property {HandleVotePollType} handleVotePoll Handler that records the participant's vote selection. * * **User Context:** * @property {string} member Identifier for the current participant submitting votes. * @property {string} islevel Permission level (`'0'` participant, `'1'` co-host, `'2'` host) driving available actions. * * **Session Context:** * @property {Socket} socket Active socket.io connection for real-time poll updates. * @property {string} roomName Room identifier associated with poll events. * @property {ShowAlert} [showAlert] Optional alert helper for surfacing poll feedback. * * **Customization:** * @property {'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'center'} [position='topRight'] Modal anchoring position. * @property {string} [backgroundColor='#f5f5f5'] Background color for the modal surface. * @property {StyleProp} [style] Extra styles applied to the modal container. * * **Advanced Render Overrides:** * @property {(options: { defaultContent: JSX.Element; dimensions: { width: number; height: number } }) => JSX.Element} [renderContent] * Custom renderer for the modal body content. * @property {(options: { defaultContainer: JSX.Element; dimensions: { width: number; height: number } }) => JSX.Element} [renderContainer] * Custom renderer that can wrap/replace the outer modal container. */ export interface PollModalOptions { isPollModalVisible: boolean; onClose: () => void; position?: 'topLeft' | 'topRight' | 'bottomLeft' | 'bottomRight' | 'center'; backgroundColor?: string; member: string; islevel: string; polls: Poll[]; poll: Poll | null; socket: Socket; roomName: string; showAlert?: ShowAlert; updateIsPollModalVisible: (isVisible: boolean) => void; handleCreatePoll: HandleCreatePollType; handleEndPoll: HandleEndPollType; handleVotePoll: HandleVotePollType; style?: StyleProp; renderContent?: (options: { defaultContent: JSX.Element; dimensions: { width: number; height: number; }; }) => JSX.Element; renderContainer?: (options: { defaultContainer: JSX.Element; dimensions: { width: number; height: number; }; }) => JSX.Element; } export type PollModalType = (options: PollModalOptions) => JSX.Element; /** * PollModal - Interactive polling and voting interface. * * Provides a full polling workflow for MediaSFU rooms, enabling hosts to * author polls, participants to vote, and everyone to view live results with * percentages. Layout and container wrappers can be overridden through * `uiOverrides.pollModal` while retaining the built-in handlers. * * **Key Features:** * - Guided poll creation with multiple choice support (host/co-host only). * - Participant voting with per-user selection highlighting. * - Real-time tally and percentage breakdown of each option. * - Previous poll archive including ended/archived questions. * - Configurable modal positioning for disparate layout needs. * - Optional custom styling via `style` prop or render overrides. * - Socket-driven synchronization to keep all clients consistent. * - Single-vote enforcement leveraging member identity tracking. * * **UI Customization:** * Replace via `uiOverrides.pollModal` to supply an entirely custom polling UI * while continuing to leverage the provided poll handlers. * * @component * @param {PollModalOptions} props Component properties. * @returns {JSX.Element} Rendered poll modal. * * @example * ```tsx * // Host creating and managing polls * setIsOpen(false)} * member="host-user" * islevel="2" * polls={allPolls} * poll={activePoll} * socket={socket} * roomName="demo-room" * handleCreatePoll={handleCreatePoll} * handleEndPoll={handleEndPoll} * handleVotePoll={handleVotePoll} * updateIsPollModalVisible={setIsOpen} * /> * ``` * * @example * ```tsx * // Participant voting with custom styling * * ``` * * @example * ```tsx * // Supplying a custom container through uiOverrides * const overrides = { * pollModal: { * component: MyCustomPollModal, * injectedProps: { * theme: 'dark', * }, * }, * }; * * const PollModalComponent = withOverride(overrides.pollModal, PollModal); * * ``` */ declare const PollModal: React.FC; export default PollModal;