From 54fbe4e32f78e6bd8a225686623ce1a974acd7db Mon Sep 17 00:00:00 2001 From: Gianluca Date: Thu, 6 May 2021 11:34:52 +0100 Subject: [PATCH] chore: fix build issue --- src/AutoField.tsx | 3 +-- src/RadioField.tsx | 20 +++++++++++-------- src/SelectField.tsx | 48 ++++++++++++++++++++++++++------------------- 3 files changed, 41 insertions(+), 30 deletions(-) diff --git a/src/AutoField.tsx b/src/AutoField.tsx index fa04c34..f3827e4 100644 --- a/src/AutoField.tsx +++ b/src/AutoField.tsx @@ -1,6 +1,5 @@ -// import { Override, connectField, useField } from 'uniforms/es5'; import invariant from 'invariant'; -import { createAutoField } from 'uniforms'; +import { createAutoField } from 'uniforms/es5'; import BoolField from './BoolField'; import DateField from './DateField'; diff --git a/src/RadioField.tsx b/src/RadioField.tsx index 4dab23a..3088b5f 100644 --- a/src/RadioField.tsx +++ b/src/RadioField.tsx @@ -1,16 +1,20 @@ import React from 'react'; import { Radio as RadioField, RadioProps } from '@patternfly/react-core'; -import { connectField, filterDOMProps } from 'uniforms/es5'; +import { connectField, filterDOMProps, HTMLFieldProps } from 'uniforms/es5'; import wrapField from './wrapField'; -export type RadioFieldProps = { - transform?: (string?: string) => string; - allowedValues: string[]; - onChange: (value: string) => void; - value?: string; - disabled: boolean; -} & Omit; +export type RadioFieldProps = HTMLFieldProps< + string, + HTMLDivElement, + { + transform?: (string?: string) => string; + allowedValues: string[]; + onChange: (value: string) => void; + value?: string; + disabled: boolean; + } +>; const Radio = (props: RadioFieldProps) => { filterDOMProps.register('checkboxes', 'decimal'); diff --git a/src/SelectField.tsx b/src/SelectField.tsx index baac43d..63f51c0 100644 --- a/src/SelectField.tsx +++ b/src/SelectField.tsx @@ -10,7 +10,7 @@ import { SelectVariant, SelectOptionObject, } from '@patternfly/react-core'; -import { connectField, filterDOMProps } from 'uniforms/es5'; +import { connectField, FieldProps, filterDOMProps } from 'uniforms/es5'; import wrapField from './wrapField'; @@ -23,14 +23,18 @@ function xor(item: T, array: T[]) { return array.slice(0, index).concat(array.slice(index + 1)); } -type CheckboxesProps = { - fieldType?: typeof Array | any; - onChange: (value?: string | string[]) => void; - transform?: (value?: string) => string; - allowedValues: string[]; - id: string; - disabled?: boolean; -} & (Omit | Omit); +type CheckboxesProps = FieldProps< + string | string[], + CheckboxProps | RadioProps, + { + fieldType?: typeof Array | any; + onChange: (value?: string | string[]) => void; + transform?: (value?: string) => string; + allowedValues: string[]; + id: string; + disabled?: boolean; + } +>; filterDOMProps.register('autoValue'); @@ -74,17 +78,21 @@ function RenderCheckboxes(props: CheckboxesProps) { ); } -type SelectInputProps = { - required?: boolean; - id: string; - fieldType?: typeof Array | any; - onChange: (value?: string | string[]) => void; - placeholder: string; - allowedValues?: string[]; - disabled?: boolean; - error?: boolean; - transform?: (value?: string) => string; -} & Omit; +type SelectInputProps = FieldProps< + string | string[], + SelectProps, + { + required?: boolean; + id: string; + fieldType?: typeof Array | any; + onChange: (value?: string | string[]) => void; + placeholder: string; + allowedValues?: string[]; + disabled?: boolean; + error?: boolean; + transform?: (value?: string) => string; + } +>; function isSelectOptionObject( toBeDetermined: string | SelectOptionObject