Skip to content

Commit

Permalink
fix: cleaned up inputtypes
Browse files Browse the repository at this point in the history
  • Loading branch information
KasperBaun committed Feb 27, 2024
1 parent b228410 commit fdb42c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 40 deletions.
39 changes: 13 additions & 26 deletions packages/core/src/model/InputType.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -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;
Expand All @@ -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;
}
15 changes: 1 addition & 14 deletions packages/core/src/services/defaults/DefaultInputTypeResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -69,7 +57,6 @@ const inputComponents: InputComponentDictionary = {
// TODO - Create Toggle
"toggle": TextInput,


"text": TextInput,
"slider": TextInput,
"multilinetext": MultilineInput,
Expand Down

0 comments on commit fdb42c9

Please sign in to comment.