Skip to content

Commit db06a09

Browse files
feat: export UseQuizResult and UseQuizProps interfaces (#571)
Co-authored-by: Huyen Nguyen <[email protected]>
1 parent af20c67 commit db06a09

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export { Row } from "./row";
1919
export { Spacer } from "./spacer";
2020
export { Table } from "./table";
2121
export { Tabs, TabsList, TabsTrigger, TabsContent } from "./tabs";
22-
export { Quiz, useQuiz } from "./quiz";
22+
export { Quiz, useQuiz, type UseQuizResult, type UseQuizProps } from "./quiz";
2323
export { QuizQuestion } from "./quiz-question";
2424

2525
export { getThemingClass } from "./utils";

src/quiz/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export { Quiz } from "./quiz";
2-
export { useQuiz } from "./use-quiz";
2+
export { useQuiz, type UseQuizResult, type UseQuizProps } from "./use-quiz";

src/quiz/use-quiz.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type ReturnedQuestion<AnswerT extends number | string> = Question<AnswerT> & {
1212
onChange: (selectedAnswer: AnswerT) => void;
1313
};
1414

15-
interface Props<AnswerT extends number | string> {
15+
export interface UseQuizProps<AnswerT extends number | string> {
1616
initialQuestions: InitialQuestion<AnswerT>[];
1717
validationMessages: {
1818
correct: string;
@@ -28,7 +28,7 @@ type ValidationData =
2828
| { validated: true; grade: number; correctAnswerCount: number }
2929
| { validated: false; grade?: never; correctAnswerCount?: never };
3030

31-
type UseQuizReturnType<AnswerT extends number | string> = ValidationData & {
31+
export type UseQuizResult<AnswerT extends number | string> = ValidationData & {
3232
questions: ReturnedQuestion<AnswerT>[];
3333
validateAnswers: () => void;
3434
};
@@ -40,7 +40,7 @@ export const useQuiz = <AnswerT extends number | string>({
4040
onFailure,
4141
passingPercent,
4242
showCorrectAnswersOnSuccess,
43-
}: Props<AnswerT>): UseQuizReturnType<AnswerT> => {
43+
}: UseQuizProps<AnswerT>): UseQuizResult<AnswerT> => {
4444
const [questions, setQuestions] =
4545
useState<Question<AnswerT>[]>(initialQuestions);
4646
const [validation, setValidation] = useState<ValidationData>({

0 commit comments

Comments
 (0)