diff --git a/packages/evolution-generator/src/types/inputTypes.ts b/packages/evolution-generator/src/types/inputTypes.ts index 7bb643bb..9985db7e 100644 --- a/packages/evolution-generator/src/types/inputTypes.ts +++ b/packages/evolution-generator/src/types/inputTypes.ts @@ -8,6 +8,7 @@ // Note: This file includes types for all the different input and widgets types used in the evolution-generator import { TFunction } from 'i18next'; +// import { IconDefinition } from '@fortawesome/fontawesome-common-types'; // import IconDefinition from '@fortawesome/fontawesome-svg-core/definitions/IconDefinition'; /* Define types for all the different input types */ @@ -18,7 +19,9 @@ type Multiple = boolean; type Columns = 1 | 2; type Path = string; type Placeholder = string; +type DefaultValue = string | ((interview?, path?) => string | void); type Align = 'left' | 'right' | 'center'; +type Size = 'small' | 'large'; type Title = { fr: string | ((interview?, path?) => string); en: string | ((interview?, path?) => string) }; export type InputFilter = (value) => string | number; type LabelFunction = (t: TFunction, interview?, path?) => string; @@ -30,11 +33,12 @@ export type Labels = { en: string; }[]; type Choice = { - value: string | number; + value: string | number | boolean; label: { fr: string; en: string; }; + iconPath?: string; conditional?: Conditional; }; type ChoiceFunction = (interview, path?: Path) => Choice[]; @@ -78,7 +82,7 @@ type Geojsons = ( export type InputRadioBase = { type: 'question'; inputType: 'radio'; - datatype: 'string' | 'integer'; + datatype: 'string' | 'integer' | 'boolean'; containsHtml: ContainsHtml; twoColumns: TwoColumns; columns: Columns; @@ -100,7 +104,7 @@ export type InputStringBase = { datatype: 'string' | 'integer'; containsHtml: ContainsHtml; twoColumns: TwoColumns; - size?: 'small' | 'large'; + size?: Size; inputFilter?: InputFilter; numericKeyboard?: boolean; maxLength?: number; @@ -113,7 +117,7 @@ export type InputString = InputStringBase & { conditional: Conditional; validations?: Validations; textTransform?: 'uppercase' | 'lowercase' | 'capitalize'; - defaultValue?: string; + defaultValue?: DefaultValue; }; /* Text widgetConfig Type */ @@ -204,24 +208,28 @@ export type InputMultiselect = { /* InputButton widgetConfig Type */ export type InputButtonBase = { type: 'button'; - color: 'green'; + color: 'green' | 'red'; hideWhenRefreshing: boolean; - icon: any; // icon: IconDefinition; + icon: any; + // icon: IconProp | IconDefinition; + // icon: IconDefinition; align: Align; - action: () => void; + action: (interview?, section?, sections?, saveCallback?) => void; }; export type InputButton = InputButtonBase & { path: Path; label: Label; confirmPopup?: { shortname: string; - content: { fr: (interview, path) => string; en: (interview, path) => string }; - showConfirmButton: boolean; - cancelButtonColor: 'blue' | 'green'; - cancelButtonLabel: { fr: string; en: string }; - conditional: Conditional; + content: { fr: (interview?, path?) => string; en: (interview?, path?) => string }; + showConfirmButton?: boolean; + cancelButtonColor?: 'blue' | 'green'; + cancelButtonLabel?: { fr: string; en: string }; + conditional?: Conditional; }; + size?: Size; saveCallback?: () => void; + conditional?: Conditional; }; /* InputText widgetConfig Type */ @@ -260,7 +268,7 @@ export type InputMapFindPlaceBase = { containsHtml: ContainsHtml; autoConfirmIfSingleResult: boolean; placesIcon: { url: (interview?, path?) => string; size: [number, number] }; - defaultValue?: (interview) => void; + defaultValue?: DefaultValue; defaultCenter: { lat: number; lon: number }; refreshGeocodingLabel: Label; showSearchPlaceButton: (interview?, path?) => boolean;