UNPKG

@memoraiz/react-widgets

Version:

A collection of React-based widgets for educational applications, powered by AI-driven functionalities from **MemorAIz**. This package provides flexible and interactive UI components designed to integrate seamlessly with React projects, enabling developer

1,411 lines (1,218 loc) 47.6 kB
import { ApiClient } from '@memoraiz/api-client'; import { ApiClientConfig } from '@memoraiz/api-client'; import { ClassProp } from 'class-variance-authority/types'; import { Context } from 'react'; import { ForwardRefExoticComponent } from 'react'; import { JSX as JSX_2 } from 'react/jsx-runtime'; import { KeyedMutator } from 'swr'; import { OpArgType } from '@memoraiz/api-client'; import { OpResultType } from '@memoraiz/api-client'; import * as ProgressPrimitive from '@radix-ui/react-progress'; import * as React_2 from 'react'; import { ReactNode } from 'react'; import { RefAttributes } from 'react'; import { SWRConfiguration } from 'swr'; import { SWRMutationConfiguration } from 'swr/mutation'; import { TriggerWithOptionsArgs } from 'swr/mutation'; import { VariantProps } from 'class-variance-authority'; export declare const ACTIVITY_SELECTOR: { withLessAttempt: (activities: QuizWidgetActivity[]) => { id: string; name: string; type: "quiz" | "assignment"; reference?: string; description?: string; dueDate?: string; maxGrade?: number; createdAt: string; updatedAt: string; timeLimit?: number; maxAttempts?: number; submissionType?: "file" | "text" | "both"; attempts: { id: string; startTime: string; timeTaken: number; outcome: { score?: number; grade?: string | number; }; }[]; } | null; }; declare interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, ButtonVariantProps { asChild?: boolean; startIcon?: React.ReactNode; endIcon?: React.ReactNode; helpText?: string; } declare type ButtonVariantProps = VariantProps<typeof buttonVariants>; declare const buttonVariants: (props?: ({ variant?: "link" | "brand" | "primary" | "outline" | "secondary" | "ghost" | null | undefined; size?: "default" | "xs" | "sm" | "lg" | "icon" | null | undefined; } & ClassProp) | undefined) => string; declare type CardProps = React_2.ComponentProps<'div'>; declare type CarouselProps = React.ComponentProps<'div'> & VariantProps<typeof trackVariant> & { asChild?: boolean; }; declare type CarouselSlideProps = React.ComponentProps<'div'> & { asChild?: boolean; }; declare type ComponentPropsOverride<T extends React_2.ElementType, TProps> = { [K in keyof (React_2.ComponentProps<T> & TProps)]: K extends keyof TProps ? TProps[K] : React_2.ComponentProps<T>[K]; }; declare type CreateQuizAttemptResponse = OpResultType<'/widgets/attempts/{id}', 'post'>; export declare function Dashboard({ filter, onLoad, onRefresh, onRequest, children, ...others }: DashboardProps): JSX_2.Element; export declare const DashboardBlock: { ({ type, size, asChild, className, loading, slots, children, ...others }: DashboardBlockProps): JSX_2.Element; displayName: string; }; export declare type DashboardBlockProps = React.ComponentProps<'div'> & { type: string; size?: number; loading?: boolean; asChild?: boolean; slots?: { Loading?: React.ElementType; }; }; export declare const DashboardContext: Context<DashboardController | null>; declare type DashboardController = { data: Stats | null; loading: boolean; refresh: () => void; }; export declare type DashboardControllerProps = { filter?: { from: Date; to: Date; }; onLoad?: (data: Stats) => void; onRefresh?: () => void; onRequest?: () => void; }; export declare function DashboardDisplay({ className, title, subtitle, children, slots, slotProps, ...others }: DashboardDisplayProps): JSX_2.Element; export declare namespace DashboardDisplay { var displayName: string; } export declare type DashboardDisplayProps = Omit<React.ComponentProps<'div'>, 'title'> & { title?: React.ReactNode; subtitle?: React.ReactNode; slots?: DashboarSlots; slotProps?: { body?: React.ComponentProps<'div'>; }; }; declare type DashboardEntryData = OpResultType<'/widgets/dashboard', 'get'>[number]; declare type DashboardEntryDataSelector = (data: DashboardEntryData[]) => DashboardEntryData | null; export declare const DashboardIndicator: { Number: React.FC<NumberIndicatorProps>; }; export declare const DashboardIndicatorBlock: ({ select, type, displayDescription, displayLabel, displayValue, render, ...others }: DashboardIndicatorBlockProps) => JSX_2.Element; export declare type DashboardIndicatorBlockProps = React.ComponentProps<'div'> & UseDashboardIndicatorProps & { type?: string; render?: (props: { label: React.ReactNode; description: React.ReactNode; value: React.ReactNode; refreshing: boolean; data: StatIndicator | null; }) => React.ReactNode; }; export declare type DashboardProps = DashboardControllerProps & DashboardDisplayProps; export declare function DashboardProvider({ controller, ...others }: React.PropsWithChildren<DashboardProviderProps>): JSX_2.Element; export declare namespace DashboardProvider { var displayName: string; } export declare type DashboardProviderProps = { controller: DashboardController; }; export declare function DashboardToolbar({ children: _children, title, ...others }: DashboardToolbarProps_2): JSX_2.Element; export declare namespace DashboardToolbar { var displayName: string; } declare type DashboardToolbarProps = { title?: React.ReactNode; className?: string; }; declare type DashboardToolbarProps_2 = ComponentPropsOverride<'div', DashboardToolbarProps>; declare type DashboarSlots = { Toolbar?: React.ElementType<DashboardToolbarProps> | null; Loading?: React.ElementType<{ className?: string; }> | null; Empty?: React.ElementType | null; }; export declare type FlaschardThumbProps = { seen?: boolean; slideIndex: number; displayIndex?: number; onSelect?: () => void; }; export declare function Flashcard({ className, reference, displayIndex, preventFlipBack, disabled, onFlip, onNavigateTo, onLoad, selectDeck, ...others }: FlashcardProps): JSX_2.Element; export declare namespace Flashcard { var displayName: string; } export declare function FlashcardCarousel({ displayIndex, slides, onSettle, ...others }: FlashcardCarouselProps): JSX_2.Element; export declare namespace FlashcardCarousel { var displayName: string; } declare type FlashcardCarouselProps = CarouselProps & { displayIndex?: number; slides?: React.ReactNode[]; onSettle?: () => void; }; export declare const FlashcardContext: Context<FlashcardController | null>; export declare type FlashcardController = { deck: FlashcardDeckWidgetData | null; current: FlashcardDeckItem | null; displayIndex: number; displaySide: 'front' | 'back'; loading: boolean; disabled: boolean; preventFlipBack: boolean; flip: (index?: number) => void; navigateTo: (index: number) => void; flipSide: (index: number) => 'front' | 'back'; flipAll: (side: 'front' | 'back') => void; }; export declare type FlashcardDeckItem = FlashcardDeckWidgetData['content'][number]; export declare type FlashcardDeckWidgetData = OpResultType<'/flashcard-deck', 'get'>['data'][number]; export declare function FlashcardDisplay({ className, slots, title, ...others }: FlashcardDisplayProps): JSX_2.Element | null; export declare namespace FlashcardDisplay { var displayName: string; } export declare type FlashcardDisplayProps = React.ComponentProps<'div'> & { slots?: FlashcardSlots; title?: React.ReactNode; }; export declare type FlashcardFlipCardProps = { onFlip?: () => void; displaySide?: 'front' | 'back'; preventFlipBack?: boolean; data: FlashcardDeckItem; disabled?: boolean; className?: string; }; export declare type FlashcardNavProps = { deck: FlashcardDeckWidgetData; onNavigateTo?: FlashcardController['navigateTo']; displayIndex?: number; disabled?: boolean; className?: string; }; export declare type FlashcardProps = UseFlashcardControllerProps & FlashcardDisplayProps; export declare function FlashcardProvider({ controller, ...others }: React.PropsWithChildren<FlashcardProviderProps>): JSX_2.Element; export declare namespace FlashcardProvider { var displayName: string; } export declare type FlashcardProviderProps = { controller: FlashcardController; }; export declare type FlashcardSelector = (data: FlashcardDeckWidgetData[]) => FlashcardDeckWidgetData | null; export declare type FlashcardSlots = { Loading?: React.ElementType; Empty?: React.ElementType; Nav?: React.ElementType<FlashcardNavProps> | null; FlipCard?: React.ElementType<FlashcardFlipCardProps>; Toolbar?: React.ElementType<FlashcardToolbarProps> | null; }; export declare function FlashcardThumbSlide(props: Omit<CarouselSlideProps, 'asChild'> & FlaschardThumbProps): JSX_2.Element; export declare namespace FlashcardThumbSlide { var displayName: string; } export declare function FlashcardThumbsNav({ onNavigateTo, displayIndex, disabled, deck, slots, className, ...others }: FlashcardThumbsNavProps): JSX_2.Element; export declare namespace FlashcardThumbsNav { var displayName: string; } export declare type FlashcardThumbsNavProps = React.ComponentProps<'div'> & FlashcardNavProps & { slots?: { ThumbSlide?: React.ElementType<FlaschardThumbProps>; }; }; export declare function FlashcardToolbar({ children: _children, title, className, ...others }: FlashcardToolbarProps_2): JSX_2.Element; export declare namespace FlashcardToolbar { var displayName: string; } export declare type FlashcardToolbarProps = { title?: React.ReactNode | null; className?: string; }; declare type FlashcardToolbarProps_2 = FlashcardToolbarProps & ToolbarProps; export declare function FlashcardView({ data, displaySide, preventFlipBack, onFlip, slots, disabled, className, }: FlashcardViewProps): JSX_2.Element; export declare namespace FlashcardView { var displayName: string; } export declare type FlashcardViewProps = FlashcardFlipCardProps & { slots?: { FlipButton?: React.ElementType<FlipcardButtonProps>; }; }; export declare const Flipcard: ForwardRefExoticComponent<Omit<FlipcardProps, "ref"> & RefAttributes<HTMLDivElement>>; export declare const FlipcardButton: { ({ flipped, className, label, children, ...others }: FlipcardButtonProps): JSX_2.Element; displayName: string; }; export declare type FlipcardButtonProps = ButtonProps & { flipped?: boolean; label?: string; }; export declare const FlipcardContent: { ({ className, ...others }: React.ComponentProps<"div">): JSX_2.Element; displayName: string; }; export declare type FlipcardProps = React.ComponentProps<'div'> & { front?: React.ReactNode; back?: React.ReactNode; flip?: boolean; height?: string | number; slots?: { Card?: React.ElementType; }; slotProps?: { card?: CardProps; }; }; declare type GetQuizResponse = OpResultType<'/quiz/{id}', 'get'>; export declare type Locale = { lang: 'it' | 'en'; data: LocaleData; }; export declare type LocaleData = { start: string; isTrue: string; isFalse: string; next: string; confirm: string; end: string; score: string; rateOnQuestion: string; correctAnswer: string; quizEnd: string; invalidAnswer: string; dashboardIndicator: Record<string, string>; }; declare type NumberIndicatorProps = React.ComponentProps<'div'> & UseDashboardIndicatorProps & { icon?: StatsCardProps['icon']; variant?: StatsCardProps['variant']; displayChange?: (indicator: DashboardEntryData, data: DashboardEntryData[]) => { value: React.ReactNode; trending?: 'up' | 'down'; } | null; }; declare type ProgressBarProps = React_2.ComponentPropsWithoutRef<typeof ProgressPrimitive.Root>; export declare function Provider({ sdk: sdkConfig, theme, locale, children, }: React.PropsWithChildren<ProviderProps>): JSX_2.Element; export declare const ProviderContext: Context<ProviderContextValue | null>; export declare type ProviderContextValue = { sdk: WidgetSdk; i18n?: Locale; }; export declare type ProviderProps = { sdk?: SdkConfig; theme?: string | Theme; locale?: Locale; }; export declare function Quiz({ reference, displayIndex, displayRandom, requireConfirm, onActivitiesLoad, onActivitySelect, onQuizLoad, onDisplayQuestion, onAttemptCreated, onStart, onCancel, onAnswer, onTimeUp, onFinish, onSubmitSuccess, onSubmitError, children, ...others }: QuizProps): JSX_2.Element; export declare namespace Quiz { var displayName: string; } export declare type QuizActivitySelector = (activities: QuizWidgetActivity[]) => QuizWidgetActivity | null; export declare const QuizContext: Context<QuizController | null>; export declare type QuizController = QuizPlayerValidation & { attempts: QuizPlayerAttempt[]; data: QuizWidgetActivity[]; activity: QuizWidgetActivity | null; quiz: QuizWidgetSource | null; questions: QuizPlayerItem[]; displayIndex: number; requireConfirm: boolean; events: QuizPlayerEvents; loading: boolean; saving: boolean; selectActivity: (id: string) => void; }; export declare function QuizDisplay({ title, description, variant, defaultScreen, className, slots, autoselect, displayStrategy, displayActivity, disabled, ...others }: QuizDisplayProps): JSX_2.Element | null; export declare type QuizDisplayActivityProps = { data?: QuizWidgetActivity[]; onActivitySelect?: (id: string) => void; disabled?: string[]; }; export declare type QuizDisplayProps = React.ComponentProps<'div'> & { title?: React.ReactNode; description?: React.ReactNode; variant?: 'default' | 'contained' | 'ghost'; defaultScreen?: 'welcome' | 'quiz'; slots?: QuizSlots; disabled?: string[] | ((data: QuizWidgetActivity[]) => string[]); autoselect?: boolean; displayStrategy?: 'auto' | 'activity' | 'quiz'; displayActivity?: (data: QuizWidgetActivity[]) => QuizWidgetActivity | null; }; export declare type QuizHistoryFilter = (activities: QuizWidgetActivity[]) => QuizWidgetActivity[]; export declare function QuizPlayer({ questions, events, validate, requireConfirm, displayIndex, defaultScreen, title, description, attempts, variant, slots, slotProps, className, onFeedback, ...others }: QuizPlayerProps): JSX_2.Element; export declare type QuizPlayerAttempt = { date?: Date; score: number; }; export declare function QuizPlayerChoice({ selected, disabled, isCorrect, isWrong, onClick, children, className, ...others }: QuizPlayerChoiceProps): JSX_2.Element; export declare namespace QuizPlayerChoice { var displayName: string; } declare type QuizPlayerChoiceProps = React.ComponentProps<'button'> & { selected?: boolean; disabled?: boolean; isCorrect?: boolean; isWrong?: boolean; onClick?: () => void; }; export declare type QuizPlayerControl = ReturnType<typeof useQuizPlayer>; export declare function QuizPlayerControls({ onCancel, onConfirm, onNext, selectedAnswer, isAnswerValidated, isLastQuestion, requireConfirm, className, slots, slotProps, ...others }: QuizPlayerControlsProps_2): JSX_2.Element; export declare namespace QuizPlayerControls { var displayName: string; } export declare type QuizPlayerControlsProps = { className?: string; onCancel?: () => void; onConfirm?: () => void; onNext?: () => void; selectedAnswer?: unknown | null; isAnswerValidated?: boolean; isLastQuestion?: boolean; requireConfirm?: boolean; }; declare type QuizPlayerControlsProps_2 = React.ComponentProps<'div'> & QuizPlayerControlsProps & { slots?: { Button?: React.ElementType<ButtonProps>; }; slotProps?: { button?: ButtonProps; }; }; export declare type QuizPlayerEndProps = React.ComponentProps<'div'> & { score?: number; totalQuestions?: number; stats?: QuizStats; onRestart?: () => void; onFeedback?: (value: number) => void; }; export declare function QuizPlayerEndScreen({ score, totalQuestions, stats, onRestart, onFeedback, slots, slotProps, }: QuizPlayerEndScreenProps): JSX_2.Element; export declare namespace QuizPlayerEndScreen { var displayName: string; } declare type QuizPlayerEndScreenProps = React.ComponentProps<'div'> & QuizPlayerEndProps & { slots?: { Button?: React.ElementType<ButtonProps>; }; slotProps?: { button?: ButtonProps; }; }; export declare type QuizPlayerEvents = { onStart?: () => void; onAnswer?: (questionId: string, answer: unknown, isCorrect: boolean) => void; onCancel?: () => void; onFinish?: (score: number, totalQuestions: number) => void; onTimeUp?: (questionId: string) => void; onRestart?: () => void; onNavigateTo?: (index: number) => void; }; export declare function QuizPlayerFeedback({ isCorrect, }: React.ComponentProps<'div'> & { isCorrect?: boolean; }): JSX_2.Element; export declare namespace QuizPlayerFeedback { var displayName: string; } export declare function QuizPlayerHint({ children, className, ...others }: QuizPlayerHintProps): JSX_2.Element; export declare namespace QuizPlayerHint { var displayName: string; } export declare type QuizPlayerHintProps = React.ComponentProps<'button'> & {}; export declare type QuizPlayerItem = { id: string; question: string; choices: { label: string; value: unknown; }[]; correctAnswer: unknown; hint?: string; timeLimit?: number; }; export declare function QuizPlayerProgress({ current, total, timeLimit, isTimerActive, onTimeUp, onCancel, className, slots, title, ...others }: QuizPlayerProgressProps_2): JSX_2.Element; export declare namespace QuizPlayerProgress { var displayName: string; } export declare type QuizPlayerProgressProps = { className?: string; title?: React.ReactNode; current?: number; total?: number; timeLimit?: number; isTimerActive?: boolean; onTimeUp?: () => void; onCancel?: () => void; }; declare type QuizPlayerProgressProps_2 = React.ComponentProps<'div'> & QuizPlayerProgressProps & { slots?: { ProgressBar?: React.ElementType<ProgressBarProps>; }; }; export declare type QuizPlayerProps = React.ComponentProps<'div'> & UseQuizPlayerProps & VariantProps<typeof rootVariants> & QuizPlayerRootProps; export declare function QuizPlayerQuestion({ question, choices, selectedAnswer, isAnswerValidated, correctAnswer, hint, isCorrect, title, onSelectAnswer, className, ...others }: QuizPlayerQuestionProps_2): JSX_2.Element; export declare type QuizPlayerQuestionProps = { className?: string; title?: React.ReactNode; question: QuizPlayerItem['question']; choices: QuizPlayerItem['choices']; correctAnswer: QuizPlayerItem['correctAnswer']; hint?: QuizPlayerItem['hint']; selectedAnswer?: unknown | null; isAnswerValidated?: boolean; isCorrect?: boolean; onSelectAnswer?: (choice: unknown) => void; }; declare type QuizPlayerQuestionProps_2 = React.ComponentProps<'div'> & QuizPlayerQuestionProps; export declare type QuizPlayerRootProps = { title?: React.ReactNode; description?: React.ReactNode; attempts?: QuizPlayerAttempt[]; variant?: 'default' | 'contained' | 'ghost'; slots?: QuizPlayerSlots; slotProps?: { welcome?: Partial<QuizPlayerWelcomeProps>; end?: Partial<QuizPlayerEndProps>; }; defaultScreen?: 'welcome' | 'quiz'; onFeedback?: (value: number) => void; }; export declare const QuizPlayerScreen: ({ className, variant, ...others }: React.ComponentProps<"div"> & { variant: QuizPlayerScreenType; }) => JSX_2.Element; export declare type QuizPlayerScreenType = 'welcome' | 'quiz' | 'end'; export declare type QuizPlayerSlots = { Progress?: React.ElementType<QuizPlayerProgressProps>; Question?: React.ElementType<QuizPlayerQuestionProps>; Controls?: React.ElementType<QuizPlayerControlsProps>; WelcomeScreen?: React.ElementType<QuizPlayerWelcomeProps>; EndScreen?: React.ElementType<QuizPlayerEndProps>; }; export declare type QuizPlayerValidation = { validate?: (answer: unknown, correctAnswer: unknown) => Promise<boolean>; }; export declare type QuizPlayerWelcomeProps = React.ComponentProps<'div'> & { title?: React.ReactNode; description?: React.ReactNode; questions?: QuizPlayerItem[]; details?: { icon: React.ReactNode; label: React.ReactNode; }[]; onStart?: () => void; onCancel?: () => void; }; export declare function QuizPlayerWelcomeScreen({ title, description, questions, onStart, onCancel, slots, slotProps, details: customDetails, }: QuizPlayerWelcomeScreenProps): JSX_2.Element; declare type QuizPlayerWelcomeScreenProps = React.ComponentProps<'div'> & QuizPlayerWelcomeProps & { slots?: { Button?: React.ElementType<ButtonProps>; }; slotProps?: { button?: ButtonProps; }; }; export declare type QuizProps = UseQuizControllerProps & QuizDisplayProps; export declare function QuizProvider({ controller, ...others }: React.PropsWithChildren<QuizProviderProps>): JSX_2.Element; export declare namespace QuizProvider { var displayName: string; } export declare type QuizProviderProps = { controller: QuizController; }; export declare type QuizSlots = QuizPlayerSlots & { Loading?: React.ElementType; Empty?: React.ElementType; DisplayActivityScreen?: React.ElementType<QuizDisplayActivityProps>; }; export declare type QuizStats = { totalAttempts?: number; avgScore?: number; }; export declare type QuizWidgetActivity = SearchActivityResponse['data'][number]; export declare type QuizWidgetAttempt = CreateQuizAttemptResponse['data']; export declare type QuizWidgetQuestion = QuizWidgetSource['questions'][number]; export declare type QuizWidgetSource = NonNullable<GetQuizResponse['data']>; export declare const resources: { activity: (client: ApiClient) => { getByReference: (reference: string, filter?: Omit<{ reference?: string | string[]; }, "reference">) => Promise<{ id: string; name: string; type: "quiz" | "assignment"; reference?: string; description?: string; dueDate?: string; maxGrade?: number; createdAt: string; updatedAt: string; timeLimit?: number; maxAttempts?: number; submissionType?: "file" | "text" | "both"; attempts: { id: string; startTime: string; timeTaken: number; outcome: { score?: number; grade?: string | number; }; }[]; }[]>; }; flashcard: (client: ApiClient) => { getById: (id: string) => Promise<{ id: string; title: string; reference?: string; description?: string; url?: string; createdAt: string; updatedAt: string; content: { front: string; back: string; }; deck?: string; metadata: { [key: string]: unknown; }; } | null>; getByReference: (reference: string) => Promise<{ id: string; title: string; reference?: string; description?: string; url?: string; createdAt: string; updatedAt: string; content: { front: string; back: string; }; deck?: string; metadata: { [key: string]: unknown; }; }[]>; getDeckByReference: (reference: string) => Promise<{ id: string; title: string; reference?: string; description?: string; url?: string; createdAt: string; updatedAt: string; content: { id: string; front: string; back: string; }[]; metadata: { [key: string]: unknown; }; }[]>; }; feedback: (client: ApiClient) => { create: (data: OpArgType<"/widgets/feedbacks", "post">) => Promise<{ id: string; author: string; object: string; context?: { feature?: string; useCase?: string; platform?: string; sessionId?: string; }; rating: number; comment?: string; metadata: { [key: string]: unknown; }; date: string; }>; }; quiz: (client: ApiClient) => { getById: (id: string) => Promise<{ id: string; name: string; reference?: string; description?: string; questions: (({ id: string; question: string; points: number; type: "multiple_choice"; choices: string[]; correctAnswerIndex: number; } | { id: string; question: string; points: number; type: "true_false"; correctAnswer: boolean; }) | { id: string; question: string; points: number; type: "short_answer"; correctAnswer: string; })[]; metadata: { [key: string]: unknown; }; createdAt: string; updatedAt: string; } | null>; }; summary: (client: ApiClient) => { getById: (id: string) => Promise<{ id: string; title: string; reference?: string; description?: string; url?: string; text: string; keypoints: string[]; keywords: string[]; createdAt: string; updatedAt: string; } | null>; getByReference: (reference: string) => Promise<{ id: string; title: string; reference?: string; description?: string; url?: string; text: string; keypoints: string[]; keywords: string[]; createdAt: string; updatedAt: string; }[]>; }; attempt: (client: ApiClient) => { create: (data: OpArgType<"/widgets/attempts", "post">) => Promise<{ id: string; startTime: string; activityId: string; status: "CANCELLED" | "COMPLETED" | "EVALUATED" | "STARTED"; timeTaken?: number; output?: ({ answers: { questionId: string; answer: string | boolean; }[]; } | { type: "file" | "text"; content: string; submittedAt: string; }) | null; outcome?: ({ score: number; answer: { total: number; valid: number; }; feedback?: string; } | { grade: string | number; gradedAt: string; feedback?: string; }) | null; }>; update: (id: string, data: OpArgType<"/widgets/attempts/{id}", "post">) => Promise<{ id: string; startTime: string; activityId: string; status: "CANCELLED" | "COMPLETED" | "EVALUATED" | "STARTED"; timeTaken?: number; output?: ({ answers: { questionId: string; answer: string | boolean; }[]; } | { type: "file" | "text"; content: string; submittedAt: string; }) | null; outcome?: ({ score: number; answer: { total: number; valid: number; }; feedback?: string; } | { grade: string | number; gradedAt: string; feedback?: string; }) | null; }>; }; dashboard: (client: ApiClient) => { getByDate: (fromDate: Date, toDate: Date) => Promise<{ metric: string; type: string; value: { [key: string]: number; } | number | Record<string, never>; }[]>; }; }; declare const rootVariants: (props?: ({ variant?: "default" | "ghost" | "contained" | null | undefined; } & ClassProp) | undefined) => string; declare const rootVariants_2: (props?: ({ variant?: "default" | "primary" | "outline" | "secondary" | null | undefined; } & ClassProp) | undefined) => string; declare type Sdk<T extends Record<string, SdkResourceFactory>> = { [K in keyof T]: ReturnType<T[K]>; } & { client: ApiClient; }; declare const Sdk: { from: <T extends Record<string, SdkResourceFactory>>(resources: T, config: SdkConfig) => Sdk<T>; fromResources: <T extends Record<string, SdkResourceFactory>>(resources: T) => { init: (config: SdkConfig) => Sdk<T>; }; }; export declare const sdk: { init: (config: SdkConfig) => Sdk<{ activity: (client: ApiClient) => { getByReference: (reference: string, filter?: Omit<{ reference?: string | string[]; }, "reference">) => Promise<{ id: string; name: string; type: "quiz" | "assignment"; reference?: string; description?: string; dueDate?: string; maxGrade?: number; createdAt: string; updatedAt: string; timeLimit?: number; maxAttempts?: number; submissionType?: "file" | "text" | "both"; attempts: { id: string; startTime: string; timeTaken: number; outcome: { score?: number; grade?: string | number; }; }[]; }[]>; }; flashcard: (client: ApiClient) => { getById: (id: string) => Promise<{ id: string; title: string; reference?: string; description?: string; url?: string; createdAt: string; updatedAt: string; content: { front: string; back: string; }; deck?: string; metadata: { [key: string]: unknown; }; } | null>; getByReference: (reference: string) => Promise<{ id: string; title: string; reference?: string; description?: string; url?: string; createdAt: string; updatedAt: string; content: { front: string; back: string; }; deck?: string; metadata: { [key: string]: unknown; }; }[]>; getDeckByReference: (reference: string) => Promise<{ id: string; title: string; reference?: string; description?: string; url?: string; createdAt: string; updatedAt: string; content: { id: string; front: string; back: string; }[]; metadata: { [key: string]: unknown; }; }[]>; }; feedback: (client: ApiClient) => { create: (data: OpArgType<"/widgets/feedbacks", "post">) => Promise<{ id: string; author: string; object: string; context?: { feature?: string; useCase?: string; platform?: string; sessionId?: string; }; rating: number; comment?: string; metadata: { [key: string]: unknown; }; date: string; }>; }; quiz: (client: ApiClient) => { getById: (id: string) => Promise<{ id: string; name: string; reference?: string; description?: string; questions: (({ id: string; question: string; points: number; type: "multiple_choice"; choices: string[]; correctAnswerIndex: number; } | { id: string; question: string; points: number; type: "true_false"; correctAnswer: boolean; }) | { id: string; question: string; points: number; type: "short_answer"; correctAnswer: string; })[]; metadata: { [key: string]: unknown; }; createdAt: string; updatedAt: string; } | null>; }; summary: (client: ApiClient) => { getById: (id: string) => Promise<{ id: string; title: string; reference?: string; description?: string; url?: string; text: string; keypoints: string[]; keywords: string[]; createdAt: string; updatedAt: string; } | null>; getByReference: (reference: string) => Promise<{ id: string; title: string; reference?: string; description?: string; url?: string; text: string; keypoints: string[]; keywords: string[]; createdAt: string; updatedAt: string; }[]>; }; attempt: (client: ApiClient) => { create: (data: OpArgType<"/widgets/attempts", "post">) => Promise<{ id: string; startTime: string; activityId: string; status: "CANCELLED" | "COMPLETED" | "EVALUATED" | "STARTED"; timeTaken?: number; output?: ({ answers: { questionId: string; answer: string | boolean; }[]; } | { type: "file" | "text"; content: string; submittedAt: string; }) | null; outcome?: ({ score: number; answer: { total: number; valid: number; }; feedback?: string; } | { grade: string | number; gradedAt: string; feedback?: string; }) | null; }>; update: (id: string, data: OpArgType<"/widgets/attempts/{id}", "post">) => Promise<{ id: string; startTime: string; activityId: string; status: "CANCELLED" | "COMPLETED" | "EVALUATED" | "STARTED"; timeTaken?: number; output?: ({ answers: { questionId: string; answer: string | boolean; }[]; } | { type: "file" | "text"; content: string; submittedAt: string; }) | null; outcome?: ({ score: number; answer: { total: number; valid: number; }; feedback?: string; } | { grade: string | number; gradedAt: string; feedback?: string; }) | null; }>; }; dashboard: (client: ApiClient) => { getByDate: (fromDate: Date, toDate: Date) => Promise<{ metric: string; type: string; value: { [key: string]: number; } | number | Record<string, never>; }[]>; }; }>; }; export declare type SdkConfig = Partial<ApiClientConfig>; export declare type SdkResourceFactory<T = unknown> = (client: ApiClient) => T; declare type SearchActivityResponse = OpResultType<'/widgets/activities', 'get'>; declare type StatIndicator = OpResultType<'/widgets/dashboard', 'get'>[number]; declare type Stats = OpResultType<'/widgets/dashboard', 'get'>; declare type StatsCardProps = React.ComponentProps<'div'> & VariantProps<typeof rootVariants_2> & { label?: React.ReactNode; description?: React.ReactNode; value?: React.ReactNode; change?: React.ReactNode; trending?: 'up' | 'down'; icon?: React.ElementType; }; export declare function Summary({ reference, onReceiveFeedback, selectSummary, className, ...others }: SummaryProps): JSX_2.Element; export declare const SummaryContext: Context<SummaryController | null>; declare type SummaryController = { data: SummaryWidgetData | null; loading: boolean; setFeedback: (value: number) => void; }; export declare function SummaryDisplay({ className, slots, title, asChild, ...others }: SummaryDisplayProps): JSX_2.Element | null; export declare type SummaryDisplayProps = React.ComponentProps<'div'> & { slots?: SummarySlots; title?: React.ReactNode; asChild?: boolean; }; export declare function SummaryDisplaySection({ title, content, className, children, ...others }: SummaryDisplaySectionProps): JSX_2.Element; export declare type SummaryDisplaySectionProps = React.ComponentProps<'div'> & { title?: React.ReactNode; variant?: string; }; export declare type SummaryProps = UseSummaryControllerProps & SummaryDisplayProps; export declare function SummaryProvider({ controller, ...others }: React.PropsWithChildren<SummaryProviderProps>): JSX_2.Element; export declare type SummaryProviderProps = { controller: SummaryController; }; declare type SummarySlots = { Loading?: React.ElementType; Empty?: React.ElementType; Toolbar?: React.ElementType<SummaryToolbarProps>; }; export declare function SummaryToolbar({ title, ...others }: SummaryToolbarProps_2): JSX_2.Element; declare type SummaryToolbarProps = { className?: string; title?: React.ReactNode; }; declare type SummaryToolbarProps_2 = React.ComponentProps<'div'> & SummaryToolbarProps; declare type SummaryWidgetData = OpResultType<'/summary', 'get'>['data'][number] & { feedback?: number; }; export declare type SummaryWidgetSelector = (value: SummaryWidgetData[]) => SummaryWidgetData | null; declare type Theme = { id?: string; variant?: 'playful' | 'simple'; darkmode?: boolean; }; declare type ToolbarProps = React.ComponentProps<'div'>; declare const trackVariant: (props?: ({ spacing?: "default" | "sm" | "lg" | null | undefined; } & ClassProp) | undefined) => string; export declare function useDashboardContext(): DashboardController; export declare function useDashboardController(props: DashboardControllerProps): DashboardController; export declare function useDashboardIndicator(props: UseDashboardIndicatorProps): { display: { value: ReactNode; label: ReactNode; description: ReactNode; } | null; loading: boolean; data: { metric: string; type: string; value: { [key: string]: number; } | number | Record<string, never>; }[] | null; current: { metric: string; type: string; value: { [key: string]: number; } | number | Record<string, never>; } | null; }; export declare type UseDashboardIndicatorProps = { select: string | DashboardEntryDataSelector; displayValue?: (data: DashboardEntryData) => React.ReactNode; displayLabel?: string | ((indicator: DashboardEntryData) => React.ReactNode); displayDescription?: string | ((indicator: DashboardEntryData) => React.ReactNode); }; export declare function useFlashcardContext(): FlashcardController; export declare function useFlashcardController(props: UseFlashcardControllerProps): FlashcardController; export declare type UseFlashcardControllerProps = { reference: string; displayIndex?: number; preventFlipBack?: boolean; disabled?: boolean; onFlip?: (index: number, side: 'front' | 'back') => void; onNavigateTo?: (index: number) => void; onLoad?: (data: FlashcardDeckWidgetData[]) => void; selectDeck?: (data: FlashcardDeckWidgetData[]) => FlashcardDeckWidgetData | null; }; declare type UseMutationProps<T, TError extends Error> = Pick<SWRMutationConfiguration<T, TError>, 'onSuccess' | 'onError'> & { namespace?: string; tags?: string[]; }; declare type UseQueryProps<T> = Pick<SWRConfiguration<T>, 'onSuccess' | 'onError' | 'revalidateOnMount' | 'keepPreviousData'> & { namespace?: string; tags?: string[]; }; export declare function useQuizContext(): QuizController; export declare function useQuizController(props: UseQuizControllerProps): QuizController; export declare type UseQuizControllerProps = { reference: string; displayIndex?: number; displayRandom?: boolean; requireConfirm?: boolean; filterHistory?: QuizHistoryFilter; onActivitiesLoad?: (data: QuizWidgetActivity[]) => void; onActivitySelect?: (data: QuizWidgetActivity) => void; onQuizLoad?: (data: QuizWidgetSource | null) => void; onAttemptCreated?: (attempt: QuizWidgetAttempt) => void; onStart?: () => void; onCancel?: () => void; onDisplayQuestion?: (question: QuizWidgetQuestion, index: number) => void; onAnswer?: (question: QuizWidgetQuestion, answer: unknown, isCorrect?: boolean) => void; onTimeUp?: (question: QuizWidgetQuestion) => void; onFinish?: () => void; onSubmitSuccess?: (data: QuizWidgetAttempt) => void; onSubmitError?: (error: unknown) => void; }; export declare function useQuizHistory(data: QuizWidgetActivity[] | undefined, filter: (activities: QuizWidgetActivity[]) => QuizWidgetActivity[]): { attempts: QuizPlayerAttempt[]; register: (score: number, date?: Date) => void; }; export declare function useQuizPlayer({ questions, events, attempts, displayIndex, validate, requireConfirm, defaultScreen, }: UseQuizPlayerProps): { currentQuestion: QuizPlayerItem | undefined; currentIndex: number; selectedAnswer: unknown; isAnswerValidated: boolean; isCorrect: boolean; score: number; screen: QuizPlayerScreenType; stats: QuizStats; handleAnswerSelection: (choice: unknown) => void; handleConfirmAnswer: () => void; handleNext: () => void; handleCancel: () => void; handleTimeUp: () => void; handleStart: () => void; handleRestart: () => void; isTimerActive: boolean; }; export declare type UseQuizPlayerProps = QuizPlayerValidation & { questions?: QuizPlayerItem[]; events?: QuizPlayerEvents; attempts?: QuizPlayerAttempt[]; requireConfirm?: boolean; displayIndex?: number; defaultScreen?: 'welcome' | 'quiz'; }; export declare function useQuizTimer(start?: boolean): { isTimerActive: boolean; pauseTimer: () => void; resumeTimer: () => void; resetTimer: () => void; }; export declare function useSdkMutation<T, TArg, TError extends Error = Error>(key: string | null, handler: UseSdkRequestHandler<T, TArg>, props?: UseMutationProps<T, TError>): readonly [{ readonly data: NonNullable<T> | null; readonly error: TError | null; readonly submitting: boolean; readonly reset: () => void; }, TriggerWithOptionsArgs<T, TError, { namespace: string; tags: string[] | undefined; key: string | null; }, any>]; export declare function useSdkQuery<T>(key: string | null, handler: UseSdkRequestHandler<T>, props?: UseQueryProps<T>): { data: NonNullable<T> | null; loading: boolean; loaded: boolean; reload: KeyedMutator<T>; }; declare type UseSdkRequestHandler<TReturn, TArgs = undefined> = (sdk: WidgetSdk, args: TArgs) => Promise<TReturn>; export declare function useSummaryContext(): SummaryController; export declare function useSummaryController(props: UseSummaryControllerProps): SummaryController; export declare type UseSummaryControllerProps = { reference: string; selectSummary?: SummaryWidgetSelector; onReceiveFeedback?: (value: number) => void; }; export declare function useWidgetContext(): ProviderContextValue; export declare type WidgetSdk = Sdk<typeof resources>; export { } declare global { interface Window { mermaid: any; } }