diff --git a/dist/index.d.ts b/dist/index.d.ts new file mode 100644 index 0000000..50ab72d --- /dev/null +++ b/dist/index.d.ts @@ -0,0 +1,40 @@ +declare module 'react-quiz-component' { + import { ReactElement } from 'react'; + + type QuestionType = "text" | "photo" + + type AnswerSelectionType = "single" | "multiple" + + type Question = { + question: string + questionType: QuestionType + answers: string[] + correctAnswer: string + answerSelectionType: AnswerSelectionType + messageForCorrectAnswer?: string + messageForIncorrectAnswer?: string + explanation?: string + point?: string + segment?: string + } + + type QuizStructure = { + quizTitle: string + questions: Question[] + } + + type QuizProps = { + quiz: QuizStructure; + disableSynopsis?: boolean; + shuffleAnswer?: boolean; + shuffle?: boolean; + showDefaultResult?: boolean; + showInstantFeedback?: boolean; + continueTillCorrect?: boolean; + timer?: number; + allowPauseTimer?: boolean + } + + const Quiz: (props: QuizProps) => ReactElement; + export default Quiz; +} diff --git a/package.json b/package.json index 8cace2b..d7acb78 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,7 @@ "version": "0.9.1", "description": "React Quiz Component", "main": "dist/index.js", + "types": "dist/index.d.ts", "module": "dist/index.es.js", "scripts": { "dev": "webpack-dev-server --mode development", @@ -24,7 +25,7 @@ "@babel/plugin-proposal-object-rest-spread": "^7.3.2", "@babel/preset-env": "^7.3.1", "@babel/preset-react": "^7.23.3", - "@rollup/plugin-babel": "^6.0.4", + "@rollup/plug-babel": "^6.0.4", "@rollup/plugin-commonjs": "^28.0.0", "@rollup/plugin-html": "^1.0.3", "@rollup/plugin-node-resolve": "^15.2.3",