diff options
Diffstat (limited to 'packages/exchange-backoffice-ui/src/handlers/forms.ts')
-rw-r--r-- | packages/exchange-backoffice-ui/src/handlers/forms.ts | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/packages/exchange-backoffice-ui/src/handlers/forms.ts b/packages/exchange-backoffice-ui/src/handlers/forms.ts index a97b8561d..115127cc3 100644 --- a/packages/exchange-backoffice-ui/src/handlers/forms.ts +++ b/packages/exchange-backoffice-ui/src/handlers/forms.ts @@ -25,18 +25,18 @@ type DoubleColumnFormSection = { /** * Constrain the type with the ui props */ -type FieldType = { +type FieldType<T extends object = any, K extends keyof T = any> = { group: Parameters<typeof Group>[0]; caption: Parameters<typeof Caption>[0]; - array: Parameters<typeof InputArray>[0]; - file: Parameters<typeof InputFile>[0]; - selectOne: Parameters<typeof InputSelectOne>[0]; - selectMultiple: Parameters<typeof InputSelectMultiple>[0]; - text: Parameters<typeof InputText>[0]; - textArea: Parameters<typeof InputTextArea>[0]; - choiceStacked: Parameters<typeof InputChoiceStacked>[0]; - date: Parameters<typeof InputDate>[0]; - integer: Parameters<typeof InputInteger>[0]; + array: Parameters<typeof InputArray<T, K>>[0]; + file: Parameters<typeof InputFile<T, K>>[0]; + selectOne: Parameters<typeof InputSelectOne<T, K>>[0]; + selectMultiple: Parameters<typeof InputSelectMultiple<T, K>>[0]; + text: Parameters<typeof InputText<T, K>>[0]; + textArea: Parameters<typeof InputTextArea<T, K>>[0]; + choiceStacked: Parameters<typeof InputChoiceStacked<T, K>>[0]; + date: Parameters<typeof InputDate<T, K>>[0]; + integer: Parameters<typeof InputInteger<T, K>>[0]; }; /** @@ -69,14 +69,20 @@ type UIFormFieldMap = { const UIFormConfiguration: UIFormFieldMap = { group: Group, caption: Caption, + //@ts-ignore array: InputArray, text: InputText, + //@ts-ignore file: InputFile, textArea: InputTextArea, + //@ts-ignore date: InputDate, + //@ts-ignore choiceStacked: InputChoiceStacked, integer: InputInteger, + //@ts-ignore selectOne: InputSelectOne, + //@ts-ignore selectMultiple: InputSelectMultiple, }; @@ -97,11 +103,11 @@ export function RenderAllFieldsByUiConfig({ ); } -type FormSet<T> = { +type FormSet<T extends object, K extends keyof T = any> = { Provider: typeof FormProvider<T>; - InputLine: typeof InputLine<T>; + InputLine: typeof InputLine<T, K>; }; -export function createNewForm<T>(): FormSet<T> { +export function createNewForm<T extends object>(): FormSet<T> { return { Provider: FormProvider, InputLine: InputLine, |