diff --git a/packages/core/src/model/InputType.ts b/packages/core/src/model/InputType.ts index 54df5a9..a95643a 100644 --- a/packages/core/src/model/InputType.ts +++ b/packages/core/src/model/InputType.ts @@ -1,34 +1,24 @@ -// "intro" | "submit" | "ending"| "text" ; -// | "phone" | "email" | "dropdown" | "cpr" | "bankaccount" -// | "firstName" | "lastName" | "industry" | "role" | "goal" | "email"; - import { QuestionModel } from "./QuestionModel"; -//export type InputTypes = -// "text" | -// "multilinetext" | -// "dropdown" -// // "radio" | -// // "slider" | -// // "select"; -// ; - export type InputProps = { questionModel: QuestionModel; onOutputChange(output: string): void; } const Dropdown = "dropdown"; +const Email = "email"; +const Multilinetext = "multilinetext"; const Radio = "radio"; const Slider = "slider"; -const Multilinetext = "multilinetext"; const Text = "text"; -const Email = "email"; export interface InputTypeMap { [Dropdown]: DropDownProperties; + [Email]: EmailProperties; + [Multilinetext]: MultilineProperties; [Radio]: RadioProperties; [Slider]: SliderProperties; + [Text]: TextProperties; } export type DropDownProperties = { @@ -40,6 +30,14 @@ export type DropDownProperties = { } } +export type EmailProperties = { + inputType: typeof Email; +} + +export type MultilineProperties = { + inputType: typeof Multilinetext; +} + export type RadioProperties = { inputType: typeof Radio; options: any; @@ -52,17 +50,6 @@ export type SliderProperties = { step: number; } -export type MultilineProperties = { - inputType: typeof Multilinetext; - rows?: any; -} - export type TextProperties = { inputType: typeof Text; - rows?: any; } - -export type EmailProperties = { - inputType: typeof Email; - rows?: any; -} \ No newline at end of file diff --git a/packages/core/src/services/defaults/DefaultInputTypeResolver.ts b/packages/core/src/services/defaults/DefaultInputTypeResolver.ts index dacf8e3..d0ab6d0 100644 --- a/packages/core/src/services/defaults/DefaultInputTypeResolver.ts +++ b/packages/core/src/services/defaults/DefaultInputTypeResolver.ts @@ -5,19 +5,7 @@ import { registerQuickFormService } from "../QuickFormServices"; function parseInputProperties(questionJsonModel: QuestionJsonModel): DropDownProperties | RadioProperties | SliderProperties | undefined { let inputProperties: DropDownProperties | RadioProperties | SliderProperties | undefined; - // switch (value.inputType) { - // case "dropdown": - // inputProperties = value as DropDownProperties; - // break; - // case "radio": - // inputProperties = value as RadioProperties; - // break; - // case "slider": - // inputProperties = value as SliderProperties; - // break; - // default: - // inputProperties = {}; - // } + switch (questionJsonModel.inputType) { case "dropdown": inputProperties = { @@ -69,7 +57,6 @@ const inputComponents: InputComponentDictionary = { // TODO - Create Toggle "toggle": TextInput, - "text": TextInput, "slider": TextInput, "multilinetext": MultilineInput,