Skip to content

Commit

Permalink
Add new input types for Evolution-Generator
Browse files Browse the repository at this point in the history
Add new input types for Evolution-Generator
Remove optional interview and path on input types for function
  • Loading branch information
samuel-duhaime committed Mar 27, 2024
1 parent a456341 commit 7ff5641
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions packages/evolution-generator/src/types/inputTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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;
Expand All @@ -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[];
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -113,7 +117,7 @@ export type InputString = InputStringBase & {
conditional: Conditional;
validations?: Validations;
textTransform?: 'uppercase' | 'lowercase' | 'capitalize';
defaultValue?: string;
defaultValue?: DefaultValue;
};

/* Text widgetConfig Type */
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 7ff5641

Please sign in to comment.