From 1d49380ac58c2073439bc9d0e2dc9f1eeca95eaf Mon Sep 17 00:00:00 2001 From: rhenck <richard.henck@iqb.hu-berlin.de> Date: Thu, 14 Oct 2021 14:31:09 +0200 Subject: [PATCH] Add type definitions for UI element types and input element values This makes it easier to define types of objects in surrounding code. --- projects/common/classes/uIElement.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/projects/common/classes/uIElement.ts b/projects/common/classes/uIElement.ts index 0ca1101e2..5ecd5cbfa 100644 --- a/projects/common/classes/uIElement.ts +++ b/projects/common/classes/uIElement.ts @@ -1,10 +1,13 @@ // eslint-disable-next-line max-classes-per-file import { IdService } from '../id.service'; +export type UIElementType = 'text' | 'button' | 'text-field' | 'text-area' | 'checkbox' +| 'dropdown' | 'radio' | 'image' | 'audio' | 'video'; +export type InputElementValue = string | number | boolean | null; + export abstract class UIElement { [index: string]: string | number | boolean | string[] | null | ((...args: any) => any); - type!: 'text' | 'button' | 'text-field' | 'text-area' | 'checkbox' - | 'dropdown' | 'radio' | 'image' | 'audio' | 'video'; + type!: UIElementType; id: string = 'id_placeholder'; zIndex: number = 0; @@ -41,7 +44,7 @@ export abstract class UIElement { export abstract class InputElement extends UIElement { label: string; - value: string | number | boolean | null; + value: InputElementValue; required: boolean; requiredWarnMessage: string; -- GitLab