UNPKG

analytica-frontend-lib

Version:

Repositório público dos componentes utilizados nas plataformas da Analytica Ensino

60 lines 2.75 kB
import React from 'react'; import type { PreviewQuestion } from '../../ActivityPreview/index'; interface QuestionsPdfGeneratorProps { questions: PreviewQuestion[]; onPrint?: () => void; onPrintError?: (error: Error) => void; /** * Optional render prop to access the handlePrint function. * If not provided, the component will render the hidden PDF content only. * Consumers can use the hook directly (useQuestionsPdfPrint) for more control. */ children?: (handlePrint: () => void) => React.ReactNode; } /** * Component that renders questions in a format suitable for PDF printing * This component is hidden from view and only used for printing */ export declare const QuestionsPdfContent: React.ForwardRefExoticComponent<{ questions: PreviewQuestion[]; } & React.RefAttributes<HTMLDivElement>>; /** * Hook to generate PDF from questions using native browser print API * Returns the content ref and print handler * * Security: Content is sanitized via DOMPurify in LatexRenderer before rendering. * CSP: Ensure your Content Security Policy allows loading KaTeX CSS from cdn.jsdelivr.net * or serve KaTeX CSS locally for stricter CSP compliance. */ export declare const useQuestionsPdfPrint: (questions: PreviewQuestion[], onPrint?: () => void, onPrintError?: (error: Error) => void) => { contentRef: React.RefObject<HTMLDivElement | null>; handlePrint: () => void; }; /** * QuestionsPdfGenerator Component * * Isolated and reusable component for generating PDFs of questions without answers. * Formats questions for school printing with specific layouts for each question type. * * This component renders hidden content and optionally exposes handlePrint via render prop. * For more control, consumers can use the hook directly (useQuestionsPdfPrint). * * @param questions - Array of questions to render in PDF * @param onPrint - Optional callback when print is triggered * @param onPrintError - Optional callback when print error occurs * @param children - Optional render prop function that receives handlePrint * @returns Component with hidden PDF content and optionally rendered children * * @example * // Without render prop (hidden content only) * <QuestionsPdfGenerator questions={questions} /> * * @example * // With render prop (expose handlePrint) * <QuestionsPdfGenerator questions={questions}> * {(handlePrint) => <button onClick={handlePrint}>Print</button>} * </QuestionsPdfGenerator> */ export declare const QuestionsPdfGenerator: ({ questions, onPrint, onPrintError, children, }: QuestionsPdfGeneratorProps) => import("react/jsx-runtime").JSX.Element; export type { QuestionsPdfGeneratorProps }; //# sourceMappingURL=QuestionsPdfGenerator.d.ts.map