From 599d92a6c07fd6478724e55808b60bed0ba08bf4 Mon Sep 17 00:00:00 2001 From: Birk Johansson Date: Mon, 16 Oct 2023 21:30:42 +0200 Subject: [PATCH 1/9] feat: add types for FF field-wrappers --- .../src/CheckboxFieldFF/types/index.d.ts | 19 +++++++++++++++ .../forms/src/FieldGroupFF/types/index.d.ts | 8 +++++++ .../src/FileInputFieldFF/types/index.d.ts | 14 +++++++++++ .../forms/src/InputFieldFF/types/index.d.ts | 14 +++++++++++ .../src/MultiSelectFieldFF/types/index.d.ts | 24 +++++++++++++++++++ .../forms/src/RadioFieldFF/types/index.d.ts | 14 +++++++++++ .../src/SingleSelectFieldFF/types/index.d.ts | 18 ++++++++++++++ .../forms/src/SwitchFieldFF/types/index.d.ts | 15 ++++++++++++ .../src/TextAreaFieldFF/types/index.d.ts | 15 ++++++++++++ collections/forms/types/index.d.ts | 14 +++++++++++ 10 files changed, 155 insertions(+) create mode 100644 collections/forms/src/CheckboxFieldFF/types/index.d.ts create mode 100644 collections/forms/src/FieldGroupFF/types/index.d.ts create mode 100644 collections/forms/src/FileInputFieldFF/types/index.d.ts create mode 100644 collections/forms/src/InputFieldFF/types/index.d.ts create mode 100644 collections/forms/src/MultiSelectFieldFF/types/index.d.ts create mode 100644 collections/forms/src/RadioFieldFF/types/index.d.ts create mode 100644 collections/forms/src/SingleSelectFieldFF/types/index.d.ts create mode 100644 collections/forms/src/SwitchFieldFF/types/index.d.ts create mode 100644 collections/forms/src/TextAreaFieldFF/types/index.d.ts create mode 100644 collections/forms/types/index.d.ts diff --git a/collections/forms/src/CheckboxFieldFF/types/index.d.ts b/collections/forms/src/CheckboxFieldFF/types/index.d.ts new file mode 100644 index 0000000000..8815928392 --- /dev/null +++ b/collections/forms/src/CheckboxFieldFF/types/index.d.ts @@ -0,0 +1,19 @@ +import type { FieldRenderProps } from 'react-final-form' +import type { + CheckboxFocusHandler, + CheckboxFieldProps, +} from '@dhis2-ui/checkbox' +import React from 'react' + +export type CheckBoxValue = CheckboxFieldProps['value'] +type CheckboxOverriddenProps = Omit< + CheckboxFieldProps, + 'onChange' | 'value' | 'checked' | 'name' +> + +export type CheckboxFieldFFProps = FieldRenderProps & + CheckboxOverriddenProps & { + showValidStatus?: boolean + } + +export const CheckboxFieldFF: React.FC diff --git a/collections/forms/src/FieldGroupFF/types/index.d.ts b/collections/forms/src/FieldGroupFF/types/index.d.ts new file mode 100644 index 0000000000..40598a27ae --- /dev/null +++ b/collections/forms/src/FieldGroupFF/types/index.d.ts @@ -0,0 +1,8 @@ +import React from 'react' +import type { FieldGroupProps } from '@dhis2-ui/field' + +export type CheckBoxValue = string | boolean + +export type FieldGroupFFProps = Pick + +export const FieldGroupFF: React.FC diff --git a/collections/forms/src/FileInputFieldFF/types/index.d.ts b/collections/forms/src/FileInputFieldFF/types/index.d.ts new file mode 100644 index 0000000000..b3ce134cdd --- /dev/null +++ b/collections/forms/src/FileInputFieldFF/types/index.d.ts @@ -0,0 +1,14 @@ +import React from 'react' +import type { FileInputFieldProps } from '@dhis2-ui/file-input' +import type { FieldRenderProps } from 'react-final-form' + +export type FilesValue = File[] | undefined | null | '' + +type FileInputOverriddenProps = Omit + +export type FileInputFieldFFProps = FieldRenderProps & FileInputOverriddenProps & { + showValidStatus?: boolean + multifile: FileInputFieldProps['multiple'] +} + +export const FileInputFieldFF: React.FC diff --git a/collections/forms/src/InputFieldFF/types/index.d.ts b/collections/forms/src/InputFieldFF/types/index.d.ts new file mode 100644 index 0000000000..ea581c7495 --- /dev/null +++ b/collections/forms/src/InputFieldFF/types/index.d.ts @@ -0,0 +1,14 @@ +import React from 'react' +import type { InputFieldProps } from '@dhis2-ui/input' +import type { FieldRenderProps } from 'react-final-form' + +export type InputValue = InputFieldProps['value'] + +type InputFieldOverriddenProps = Omit + +export type InputFieldFFProps = FieldRenderProps & InputFieldOverriddenProps & { + showLoadingStatus?: boolean + showValidStatus?: boolean +} + +export const InputFieldFF: React.FC diff --git a/collections/forms/src/MultiSelectFieldFF/types/index.d.ts b/collections/forms/src/MultiSelectFieldFF/types/index.d.ts new file mode 100644 index 0000000000..26bc43943f --- /dev/null +++ b/collections/forms/src/MultiSelectFieldFF/types/index.d.ts @@ -0,0 +1,24 @@ +import React from 'react' +import type { FieldRenderProps } from 'react-final-form' +import type { + MultiSelectOptionProps, + MultiSelectFieldProps, +} from '@dhis2-ui/select' + +type InputValue = MultiSelectFieldProps['selected'] | '' + +type MultiSelectFieldOverriddenProps = Omit< + MultiSelectFieldProps, + 'onChange' | 'value' +> + +type MultiSelectOptions = Array> + +export type MultiSelectFieldFFProps = FieldRenderProps & + MultiSelectFieldOverriddenProps & { + showLoadingStatus?: boolean + showValidStatus?: boolean + options: MultiSelectOptions + } + +export const MultiSelectFieldFF: React.FC diff --git a/collections/forms/src/RadioFieldFF/types/index.d.ts b/collections/forms/src/RadioFieldFF/types/index.d.ts new file mode 100644 index 0000000000..9d3dfc104f --- /dev/null +++ b/collections/forms/src/RadioFieldFF/types/index.d.ts @@ -0,0 +1,14 @@ +import React from 'react' +import type { FieldRenderProps } from 'react-final-form' +import type { RadioProps } from '@dhis2-ui/radio' + +type InputValue = RadioProps['value'] + +type RadioOverriddenProps = Omit + +export type RadioFieldFFProps = FieldRenderProps & + RadioOverriddenProps & { + showValidStatus?: boolean + } + +export const RadioFieldFF: React.FC diff --git a/collections/forms/src/SingleSelectFieldFF/types/index.d.ts b/collections/forms/src/SingleSelectFieldFF/types/index.d.ts new file mode 100644 index 0000000000..04ed38fd38 --- /dev/null +++ b/collections/forms/src/SingleSelectFieldFF/types/index.d.ts @@ -0,0 +1,18 @@ +import React from 'react' +import type { FieldRenderProps } from 'react-final-form' +import type { SingleSelectOptionProps, SingleSelectFieldProps } from '@dhis2-ui/select' + +type InputValue = SingleSelectFieldProps['selected'] + +type SingleSelectOptions = Array> + +type SingleSelectOverriddenProps = Omit + +export type SingleSelectFieldFFProps = FieldRenderProps & + SingleSelectOverriddenProps & { + showLoadingStatus?: boolean + showValidStatus?: boolean + options: SingleSelectOptions + } + +export const SingleSelectFieldFF: React.FC diff --git a/collections/forms/src/SwitchFieldFF/types/index.d.ts b/collections/forms/src/SwitchFieldFF/types/index.d.ts new file mode 100644 index 0000000000..2cf85d9f7b --- /dev/null +++ b/collections/forms/src/SwitchFieldFF/types/index.d.ts @@ -0,0 +1,15 @@ +import React from 'react' +import type { FieldRenderProps } from 'react-final-form' +import type { SwitchFieldProps } from '@dhis2-ui/switch' + +type InputValue = SwitchFieldProps['value'] + +type SwitchFieldOverriddenProps = Omit< + SwitchFieldProps, + 'onChange' | 'checked' | 'value' | 'name' +> + +export type SwitchFieldFFProps = FieldRenderProps & + SwitchFieldOverriddenProps + +export const SwitchFieldFF: React.FC diff --git a/collections/forms/src/TextAreaFieldFF/types/index.d.ts b/collections/forms/src/TextAreaFieldFF/types/index.d.ts new file mode 100644 index 0000000000..33c4c7ee73 --- /dev/null +++ b/collections/forms/src/TextAreaFieldFF/types/index.d.ts @@ -0,0 +1,15 @@ +import React from 'react' +import type { FieldRenderProps } from 'react-final-form' +import type { TextAreaFieldProps } from '@dhis2-ui/text-area' + +type InputValue = TextAreaFieldProps['value'] + +type TextAreaFieldOverriddenProps = Omit< + TextAreaFieldProps, + 'onChange' | 'value' | 'name' +> + +export type TextAreaFieldFFProps = FieldRenderProps & + TextAreaFieldOverriddenProps + +export const TextAreaFieldFF: React.FC diff --git a/collections/forms/types/index.d.ts b/collections/forms/types/index.d.ts new file mode 100644 index 0000000000..4f23904a42 --- /dev/null +++ b/collections/forms/types/index.d.ts @@ -0,0 +1,14 @@ + +export { CheckboxFieldFF } from '../src/CheckboxFieldFF/types' +export { FileInputFieldFF } from '../src/FileInputFieldFF/types' +export { InputFieldFF } from '../src/InputFieldFF/types' +export { MultiSelectFieldFF } from '../src/MultiSelectFieldFF/types' +export { SingleSelectFieldFF } from '../src/SingleSelectFieldFF/types' +export { RadioFieldFF } from '../src/RadioFieldFF/types' +export { SwitchFieldFF } from '../src/SwitchFieldFF/types' +export { TextAreaFieldFF } from '../src/TextAreaFieldFF/types' +export { FieldGroupFF } from '../src/FieldGroupFF/types' + +// export * from '../transformers/index.js' +// export * from '../validators/index.js' + From 827f5e471e8895772a0d9e4073762522285bbf70 Mon Sep 17 00:00:00 2001 From: Birk Johansson Date: Mon, 16 Oct 2023 21:55:30 +0200 Subject: [PATCH 2/9] feat(types): add types for transformers and validators --- .../forms/src/transformers/types/index.d.ts | 7 ++++ .../forms/src/validators/types/index.d.ts | 33 +++++++++++++++++++ .../forms/src/validators/types/text.ts | 0 3 files changed, 40 insertions(+) create mode 100644 collections/forms/src/transformers/types/index.d.ts create mode 100644 collections/forms/src/validators/types/index.d.ts create mode 100644 collections/forms/src/validators/types/text.ts diff --git a/collections/forms/src/transformers/types/index.d.ts b/collections/forms/src/transformers/types/index.d.ts new file mode 100644 index 0000000000..1183000dc6 --- /dev/null +++ b/collections/forms/src/transformers/types/index.d.ts @@ -0,0 +1,7 @@ + +type ValuesWithId = Array<{ id: string }> | undefined + +export const arrayWithIdObjects: { + format: (value: ValuesWithId) => string, + pars: (value: string) => ValuesWithId +} diff --git a/collections/forms/src/validators/types/index.d.ts b/collections/forms/src/validators/types/index.d.ts new file mode 100644 index 0000000000..06d5426df0 --- /dev/null +++ b/collections/forms/src/validators/types/index.d.ts @@ -0,0 +1,33 @@ +type ValuesWithId = Array<{ id: string }> | undefined + +type Validator = (value: unknown) => string | undefined + +export const alphaNumeric: Validator +export const boolean: Validator +export const composeValidators: (...validators: Validator[]) => Validator + +export const createCharacterLengthRange: ( + lowerBound: number, + upperBound: number, + customMessage?: string +) => Validator +export const createEqualTo: (key: string, description?: string) => Validator +export const createMaxCharacterLength: (upperBound: number) => Validator +export const createMaxNumber: (upperBound: number) => Validator +export const createMinCharacterLength: (lowerBound: number) => Validator +export const createMinNumber: (lowerBound: number) => Validator +export const createNumberRange: ( + lowerBound: number, + upperBound: number, + customMessage?: string +) => Validator +export const createPattern: (pattern: RegExp, message?: string) => Validator +export const dhis2Password: Validator +export const dhis2Username: Validator +export const email: Validator +export const hasValue: Validator +export const integer: Validator +export const internationalPhoneNumber: Validator +export const number: Validator +export const string: Validator +export const url: Validator diff --git a/collections/forms/src/validators/types/text.ts b/collections/forms/src/validators/types/text.ts new file mode 100644 index 0000000000..e69de29bb2 From a1ee7584b73045c2ef56cf449aea8b4f6d3c8c10 Mon Sep 17 00:00:00 2001 From: Birk Johansson Date: Mon, 16 Oct 2023 22:22:01 +0200 Subject: [PATCH 3/9] fix: mirror folder-structure for types --- .../CheckboxFieldFF/CheckboxFieldFF.d.ts | 18 ++++++++++ .../types/FieldGroupFF/FieldGroupFF.d.ts | 9 +++++ .../FileInputFieldFF/FileInputFieldFF.d.ts | 14 ++++++++ .../types/InputFieldFF/InputFieldFF.d.ts | 14 ++++++++ .../MutliSelectFieldFF.d.ts | 24 ++++++++++++++ .../types/RadioFieldFF/RadioFieldFF.d.ts | 14 ++++++++ .../SingleSelectFieldFF.d.ts | 18 ++++++++++ .../types/SwitchFieldFF/SwitchFieldFF.d.ts | 15 +++++++++ .../TextAreaFieldFF/TextAreaFieldFF.d.ts | 15 +++++++++ collections/forms/types/index.d.ts | 22 ++++++------- .../forms/types/transformers/index.d.ts | 7 ++++ collections/forms/types/validators/index.d.ts | 33 +++++++++++++++++++ 12 files changed, 192 insertions(+), 11 deletions(-) create mode 100644 collections/forms/types/CheckboxFieldFF/CheckboxFieldFF.d.ts create mode 100644 collections/forms/types/FieldGroupFF/FieldGroupFF.d.ts create mode 100644 collections/forms/types/FileInputFieldFF/FileInputFieldFF.d.ts create mode 100644 collections/forms/types/InputFieldFF/InputFieldFF.d.ts create mode 100644 collections/forms/types/MultiSelectFieldFF/MutliSelectFieldFF.d.ts create mode 100644 collections/forms/types/RadioFieldFF/RadioFieldFF.d.ts create mode 100644 collections/forms/types/SingleSelectFieldFF/SingleSelectFieldFF.d.ts create mode 100644 collections/forms/types/SwitchFieldFF/SwitchFieldFF.d.ts create mode 100644 collections/forms/types/TextAreaFieldFF/TextAreaFieldFF.d.ts create mode 100644 collections/forms/types/transformers/index.d.ts create mode 100644 collections/forms/types/validators/index.d.ts diff --git a/collections/forms/types/CheckboxFieldFF/CheckboxFieldFF.d.ts b/collections/forms/types/CheckboxFieldFF/CheckboxFieldFF.d.ts new file mode 100644 index 0000000000..7dcc976c9c --- /dev/null +++ b/collections/forms/types/CheckboxFieldFF/CheckboxFieldFF.d.ts @@ -0,0 +1,18 @@ +import type { FieldRenderProps } from 'react-final-form' +import type { + CheckboxFieldProps, +} from '@dhis2-ui/checkbox' +import React from 'react' + +type CheckBoxValue = CheckboxFieldProps['value'] +type CheckboxOverriddenProps = Omit< + CheckboxFieldProps, + 'onChange' | 'value' | 'checked' | 'name' +> + +export type CheckboxFieldFFProps = FieldRenderProps & + CheckboxOverriddenProps & { + showValidStatus?: boolean + } + +export const CheckboxFieldFF: React.FC diff --git a/collections/forms/types/FieldGroupFF/FieldGroupFF.d.ts b/collections/forms/types/FieldGroupFF/FieldGroupFF.d.ts new file mode 100644 index 0000000000..166b3fe6cc --- /dev/null +++ b/collections/forms/types/FieldGroupFF/FieldGroupFF.d.ts @@ -0,0 +1,9 @@ +import React from 'react' +import type { FieldGroupProps } from '@dhis2-ui/field' + +export type FieldGroupFFProps = Pick< + FieldGroupProps, + 'children' | 'label' | 'name' | 'required' +> + +export const FieldGroupFF: React.FC diff --git a/collections/forms/types/FileInputFieldFF/FileInputFieldFF.d.ts b/collections/forms/types/FileInputFieldFF/FileInputFieldFF.d.ts new file mode 100644 index 0000000000..b3ce134cdd --- /dev/null +++ b/collections/forms/types/FileInputFieldFF/FileInputFieldFF.d.ts @@ -0,0 +1,14 @@ +import React from 'react' +import type { FileInputFieldProps } from '@dhis2-ui/file-input' +import type { FieldRenderProps } from 'react-final-form' + +export type FilesValue = File[] | undefined | null | '' + +type FileInputOverriddenProps = Omit + +export type FileInputFieldFFProps = FieldRenderProps & FileInputOverriddenProps & { + showValidStatus?: boolean + multifile: FileInputFieldProps['multiple'] +} + +export const FileInputFieldFF: React.FC diff --git a/collections/forms/types/InputFieldFF/InputFieldFF.d.ts b/collections/forms/types/InputFieldFF/InputFieldFF.d.ts new file mode 100644 index 0000000000..ea581c7495 --- /dev/null +++ b/collections/forms/types/InputFieldFF/InputFieldFF.d.ts @@ -0,0 +1,14 @@ +import React from 'react' +import type { InputFieldProps } from '@dhis2-ui/input' +import type { FieldRenderProps } from 'react-final-form' + +export type InputValue = InputFieldProps['value'] + +type InputFieldOverriddenProps = Omit + +export type InputFieldFFProps = FieldRenderProps & InputFieldOverriddenProps & { + showLoadingStatus?: boolean + showValidStatus?: boolean +} + +export const InputFieldFF: React.FC diff --git a/collections/forms/types/MultiSelectFieldFF/MutliSelectFieldFF.d.ts b/collections/forms/types/MultiSelectFieldFF/MutliSelectFieldFF.d.ts new file mode 100644 index 0000000000..26bc43943f --- /dev/null +++ b/collections/forms/types/MultiSelectFieldFF/MutliSelectFieldFF.d.ts @@ -0,0 +1,24 @@ +import React from 'react' +import type { FieldRenderProps } from 'react-final-form' +import type { + MultiSelectOptionProps, + MultiSelectFieldProps, +} from '@dhis2-ui/select' + +type InputValue = MultiSelectFieldProps['selected'] | '' + +type MultiSelectFieldOverriddenProps = Omit< + MultiSelectFieldProps, + 'onChange' | 'value' +> + +type MultiSelectOptions = Array> + +export type MultiSelectFieldFFProps = FieldRenderProps & + MultiSelectFieldOverriddenProps & { + showLoadingStatus?: boolean + showValidStatus?: boolean + options: MultiSelectOptions + } + +export const MultiSelectFieldFF: React.FC diff --git a/collections/forms/types/RadioFieldFF/RadioFieldFF.d.ts b/collections/forms/types/RadioFieldFF/RadioFieldFF.d.ts new file mode 100644 index 0000000000..9a0423b81a --- /dev/null +++ b/collections/forms/types/RadioFieldFF/RadioFieldFF.d.ts @@ -0,0 +1,14 @@ +import React from 'react' +import type { FieldRenderProps } from 'react-final-form' +import type { RadioProps } from '@dhis2-ui/radio' + +type InputValue = RadioProps['value'] + +type RadioOverriddenProps = Omit + +export type RadioFieldFFProps = FieldRenderProps & + RadioOverriddenProps & { + showValidStatus?: boolean + } + +export const RadioFieldFF: React.FC diff --git a/collections/forms/types/SingleSelectFieldFF/SingleSelectFieldFF.d.ts b/collections/forms/types/SingleSelectFieldFF/SingleSelectFieldFF.d.ts new file mode 100644 index 0000000000..04ed38fd38 --- /dev/null +++ b/collections/forms/types/SingleSelectFieldFF/SingleSelectFieldFF.d.ts @@ -0,0 +1,18 @@ +import React from 'react' +import type { FieldRenderProps } from 'react-final-form' +import type { SingleSelectOptionProps, SingleSelectFieldProps } from '@dhis2-ui/select' + +type InputValue = SingleSelectFieldProps['selected'] + +type SingleSelectOptions = Array> + +type SingleSelectOverriddenProps = Omit + +export type SingleSelectFieldFFProps = FieldRenderProps & + SingleSelectOverriddenProps & { + showLoadingStatus?: boolean + showValidStatus?: boolean + options: SingleSelectOptions + } + +export const SingleSelectFieldFF: React.FC diff --git a/collections/forms/types/SwitchFieldFF/SwitchFieldFF.d.ts b/collections/forms/types/SwitchFieldFF/SwitchFieldFF.d.ts new file mode 100644 index 0000000000..2cf85d9f7b --- /dev/null +++ b/collections/forms/types/SwitchFieldFF/SwitchFieldFF.d.ts @@ -0,0 +1,15 @@ +import React from 'react' +import type { FieldRenderProps } from 'react-final-form' +import type { SwitchFieldProps } from '@dhis2-ui/switch' + +type InputValue = SwitchFieldProps['value'] + +type SwitchFieldOverriddenProps = Omit< + SwitchFieldProps, + 'onChange' | 'checked' | 'value' | 'name' +> + +export type SwitchFieldFFProps = FieldRenderProps & + SwitchFieldOverriddenProps + +export const SwitchFieldFF: React.FC diff --git a/collections/forms/types/TextAreaFieldFF/TextAreaFieldFF.d.ts b/collections/forms/types/TextAreaFieldFF/TextAreaFieldFF.d.ts new file mode 100644 index 0000000000..33c4c7ee73 --- /dev/null +++ b/collections/forms/types/TextAreaFieldFF/TextAreaFieldFF.d.ts @@ -0,0 +1,15 @@ +import React from 'react' +import type { FieldRenderProps } from 'react-final-form' +import type { TextAreaFieldProps } from '@dhis2-ui/text-area' + +type InputValue = TextAreaFieldProps['value'] + +type TextAreaFieldOverriddenProps = Omit< + TextAreaFieldProps, + 'onChange' | 'value' | 'name' +> + +export type TextAreaFieldFFProps = FieldRenderProps & + TextAreaFieldOverriddenProps + +export const TextAreaFieldFF: React.FC diff --git a/collections/forms/types/index.d.ts b/collections/forms/types/index.d.ts index 4f23904a42..118a3bae2a 100644 --- a/collections/forms/types/index.d.ts +++ b/collections/forms/types/index.d.ts @@ -1,14 +1,14 @@ -export { CheckboxFieldFF } from '../src/CheckboxFieldFF/types' -export { FileInputFieldFF } from '../src/FileInputFieldFF/types' -export { InputFieldFF } from '../src/InputFieldFF/types' -export { MultiSelectFieldFF } from '../src/MultiSelectFieldFF/types' -export { SingleSelectFieldFF } from '../src/SingleSelectFieldFF/types' -export { RadioFieldFF } from '../src/RadioFieldFF/types' -export { SwitchFieldFF } from '../src/SwitchFieldFF/types' -export { TextAreaFieldFF } from '../src/TextAreaFieldFF/types' -export { FieldGroupFF } from '../src/FieldGroupFF/types' +export { CheckboxFieldFF } from './CheckboxFieldFF/CheckboxFieldFF' +export { FileInputFieldFF } from './FileInputFieldFF/FileInputFieldFF' +export { InputFieldFF } from './InputFieldFF/InputFieldFF' +export { MultiSelectFieldFF } from './MultiSelectFieldFF/MutliSelectFieldFF' +export { SingleSelectFieldFF } from './SingleSelectFieldFF/SingleSelectFieldFF' +export { RadioFieldFF } from './RadioFieldFF/RadioFieldFF' +export { SwitchFieldFF } from './SwitchFieldFF/SwitchFieldFF' +export { TextAreaFieldFF } from './TextAreaFieldFF/TextAreaFieldFF' +export { FieldGroupFF } from './FieldGroupFF/FieldGroupFF' -// export * from '../transformers/index.js' -// export * from '../validators/index.js' +export * from './transformers' +export * from './validators' diff --git a/collections/forms/types/transformers/index.d.ts b/collections/forms/types/transformers/index.d.ts new file mode 100644 index 0000000000..158b0c73b2 --- /dev/null +++ b/collections/forms/types/transformers/index.d.ts @@ -0,0 +1,7 @@ + +import type { ValuesWithId } from "../validators" + +export const arrayWithIdObjects: { + format: (value: ValuesWithId) => string, + pars: (value: string) => ValuesWithId +} diff --git a/collections/forms/types/validators/index.d.ts b/collections/forms/types/validators/index.d.ts new file mode 100644 index 0000000000..b5b199ed4e --- /dev/null +++ b/collections/forms/types/validators/index.d.ts @@ -0,0 +1,33 @@ +export type ValuesWithId = Array<{ id: string }> | undefined + +export type Validator = (value: unknown) => string | undefined + +export const alphaNumeric: Validator +export const boolean: Validator +export const composeValidators: (...validators: Validator[]) => Validator + +export const createCharacterLengthRange: ( + lowerBound: number, + upperBound: number, + customMessage?: string +) => Validator +export const createEqualTo: (key: string, description?: string) => Validator +export const createMaxCharacterLength: (upperBound: number) => Validator +export const createMaxNumber: (upperBound: number) => Validator +export const createMinCharacterLength: (lowerBound: number) => Validator +export const createMinNumber: (lowerBound: number) => Validator +export const createNumberRange: ( + lowerBound: number, + upperBound: number, + customMessage?: string +) => Validator +export const createPattern: (pattern: RegExp, message?: string) => Validator +export const dhis2Password: Validator +export const dhis2Username: Validator +export const email: Validator +export const hasValue: Validator +export const integer: Validator +export const internationalPhoneNumber: Validator +export const number: Validator +export const string: Validator +export const url: Validator From e3d27f8e200067976559d31dcd035ca4fa1103cb Mon Sep 17 00:00:00 2001 From: Birk Johansson Date: Mon, 16 Oct 2023 22:24:12 +0200 Subject: [PATCH 4/9] fix: remove old-types structure --- .../src/CheckboxFieldFF/types/index.d.ts | 19 ----------- .../forms/src/FieldGroupFF/types/index.d.ts | 8 ----- .../src/FileInputFieldFF/types/index.d.ts | 14 -------- .../forms/src/InputFieldFF/types/index.d.ts | 14 -------- .../src/MultiSelectFieldFF/types/index.d.ts | 24 -------------- .../forms/src/RadioFieldFF/types/index.d.ts | 14 -------- .../src/SingleSelectFieldFF/types/index.d.ts | 18 ---------- .../forms/src/SwitchFieldFF/types/index.d.ts | 15 --------- .../src/TextAreaFieldFF/types/index.d.ts | 15 --------- .../forms/src/transformers/types/index.d.ts | 7 ---- .../forms/src/validators/types/index.d.ts | 33 ------------------- .../forms/src/validators/types/text.ts | 0 12 files changed, 181 deletions(-) delete mode 100644 collections/forms/src/CheckboxFieldFF/types/index.d.ts delete mode 100644 collections/forms/src/FieldGroupFF/types/index.d.ts delete mode 100644 collections/forms/src/FileInputFieldFF/types/index.d.ts delete mode 100644 collections/forms/src/InputFieldFF/types/index.d.ts delete mode 100644 collections/forms/src/MultiSelectFieldFF/types/index.d.ts delete mode 100644 collections/forms/src/RadioFieldFF/types/index.d.ts delete mode 100644 collections/forms/src/SingleSelectFieldFF/types/index.d.ts delete mode 100644 collections/forms/src/SwitchFieldFF/types/index.d.ts delete mode 100644 collections/forms/src/TextAreaFieldFF/types/index.d.ts delete mode 100644 collections/forms/src/transformers/types/index.d.ts delete mode 100644 collections/forms/src/validators/types/index.d.ts delete mode 100644 collections/forms/src/validators/types/text.ts diff --git a/collections/forms/src/CheckboxFieldFF/types/index.d.ts b/collections/forms/src/CheckboxFieldFF/types/index.d.ts deleted file mode 100644 index 8815928392..0000000000 --- a/collections/forms/src/CheckboxFieldFF/types/index.d.ts +++ /dev/null @@ -1,19 +0,0 @@ -import type { FieldRenderProps } from 'react-final-form' -import type { - CheckboxFocusHandler, - CheckboxFieldProps, -} from '@dhis2-ui/checkbox' -import React from 'react' - -export type CheckBoxValue = CheckboxFieldProps['value'] -type CheckboxOverriddenProps = Omit< - CheckboxFieldProps, - 'onChange' | 'value' | 'checked' | 'name' -> - -export type CheckboxFieldFFProps = FieldRenderProps & - CheckboxOverriddenProps & { - showValidStatus?: boolean - } - -export const CheckboxFieldFF: React.FC diff --git a/collections/forms/src/FieldGroupFF/types/index.d.ts b/collections/forms/src/FieldGroupFF/types/index.d.ts deleted file mode 100644 index 40598a27ae..0000000000 --- a/collections/forms/src/FieldGroupFF/types/index.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import React from 'react' -import type { FieldGroupProps } from '@dhis2-ui/field' - -export type CheckBoxValue = string | boolean - -export type FieldGroupFFProps = Pick - -export const FieldGroupFF: React.FC diff --git a/collections/forms/src/FileInputFieldFF/types/index.d.ts b/collections/forms/src/FileInputFieldFF/types/index.d.ts deleted file mode 100644 index b3ce134cdd..0000000000 --- a/collections/forms/src/FileInputFieldFF/types/index.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react' -import type { FileInputFieldProps } from '@dhis2-ui/file-input' -import type { FieldRenderProps } from 'react-final-form' - -export type FilesValue = File[] | undefined | null | '' - -type FileInputOverriddenProps = Omit - -export type FileInputFieldFFProps = FieldRenderProps & FileInputOverriddenProps & { - showValidStatus?: boolean - multifile: FileInputFieldProps['multiple'] -} - -export const FileInputFieldFF: React.FC diff --git a/collections/forms/src/InputFieldFF/types/index.d.ts b/collections/forms/src/InputFieldFF/types/index.d.ts deleted file mode 100644 index ea581c7495..0000000000 --- a/collections/forms/src/InputFieldFF/types/index.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react' -import type { InputFieldProps } from '@dhis2-ui/input' -import type { FieldRenderProps } from 'react-final-form' - -export type InputValue = InputFieldProps['value'] - -type InputFieldOverriddenProps = Omit - -export type InputFieldFFProps = FieldRenderProps & InputFieldOverriddenProps & { - showLoadingStatus?: boolean - showValidStatus?: boolean -} - -export const InputFieldFF: React.FC diff --git a/collections/forms/src/MultiSelectFieldFF/types/index.d.ts b/collections/forms/src/MultiSelectFieldFF/types/index.d.ts deleted file mode 100644 index 26bc43943f..0000000000 --- a/collections/forms/src/MultiSelectFieldFF/types/index.d.ts +++ /dev/null @@ -1,24 +0,0 @@ -import React from 'react' -import type { FieldRenderProps } from 'react-final-form' -import type { - MultiSelectOptionProps, - MultiSelectFieldProps, -} from '@dhis2-ui/select' - -type InputValue = MultiSelectFieldProps['selected'] | '' - -type MultiSelectFieldOverriddenProps = Omit< - MultiSelectFieldProps, - 'onChange' | 'value' -> - -type MultiSelectOptions = Array> - -export type MultiSelectFieldFFProps = FieldRenderProps & - MultiSelectFieldOverriddenProps & { - showLoadingStatus?: boolean - showValidStatus?: boolean - options: MultiSelectOptions - } - -export const MultiSelectFieldFF: React.FC diff --git a/collections/forms/src/RadioFieldFF/types/index.d.ts b/collections/forms/src/RadioFieldFF/types/index.d.ts deleted file mode 100644 index 9d3dfc104f..0000000000 --- a/collections/forms/src/RadioFieldFF/types/index.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react' -import type { FieldRenderProps } from 'react-final-form' -import type { RadioProps } from '@dhis2-ui/radio' - -type InputValue = RadioProps['value'] - -type RadioOverriddenProps = Omit - -export type RadioFieldFFProps = FieldRenderProps & - RadioOverriddenProps & { - showValidStatus?: boolean - } - -export const RadioFieldFF: React.FC diff --git a/collections/forms/src/SingleSelectFieldFF/types/index.d.ts b/collections/forms/src/SingleSelectFieldFF/types/index.d.ts deleted file mode 100644 index 04ed38fd38..0000000000 --- a/collections/forms/src/SingleSelectFieldFF/types/index.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -import React from 'react' -import type { FieldRenderProps } from 'react-final-form' -import type { SingleSelectOptionProps, SingleSelectFieldProps } from '@dhis2-ui/select' - -type InputValue = SingleSelectFieldProps['selected'] - -type SingleSelectOptions = Array> - -type SingleSelectOverriddenProps = Omit - -export type SingleSelectFieldFFProps = FieldRenderProps & - SingleSelectOverriddenProps & { - showLoadingStatus?: boolean - showValidStatus?: boolean - options: SingleSelectOptions - } - -export const SingleSelectFieldFF: React.FC diff --git a/collections/forms/src/SwitchFieldFF/types/index.d.ts b/collections/forms/src/SwitchFieldFF/types/index.d.ts deleted file mode 100644 index 2cf85d9f7b..0000000000 --- a/collections/forms/src/SwitchFieldFF/types/index.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -import React from 'react' -import type { FieldRenderProps } from 'react-final-form' -import type { SwitchFieldProps } from '@dhis2-ui/switch' - -type InputValue = SwitchFieldProps['value'] - -type SwitchFieldOverriddenProps = Omit< - SwitchFieldProps, - 'onChange' | 'checked' | 'value' | 'name' -> - -export type SwitchFieldFFProps = FieldRenderProps & - SwitchFieldOverriddenProps - -export const SwitchFieldFF: React.FC diff --git a/collections/forms/src/TextAreaFieldFF/types/index.d.ts b/collections/forms/src/TextAreaFieldFF/types/index.d.ts deleted file mode 100644 index 33c4c7ee73..0000000000 --- a/collections/forms/src/TextAreaFieldFF/types/index.d.ts +++ /dev/null @@ -1,15 +0,0 @@ -import React from 'react' -import type { FieldRenderProps } from 'react-final-form' -import type { TextAreaFieldProps } from '@dhis2-ui/text-area' - -type InputValue = TextAreaFieldProps['value'] - -type TextAreaFieldOverriddenProps = Omit< - TextAreaFieldProps, - 'onChange' | 'value' | 'name' -> - -export type TextAreaFieldFFProps = FieldRenderProps & - TextAreaFieldOverriddenProps - -export const TextAreaFieldFF: React.FC diff --git a/collections/forms/src/transformers/types/index.d.ts b/collections/forms/src/transformers/types/index.d.ts deleted file mode 100644 index 1183000dc6..0000000000 --- a/collections/forms/src/transformers/types/index.d.ts +++ /dev/null @@ -1,7 +0,0 @@ - -type ValuesWithId = Array<{ id: string }> | undefined - -export const arrayWithIdObjects: { - format: (value: ValuesWithId) => string, - pars: (value: string) => ValuesWithId -} diff --git a/collections/forms/src/validators/types/index.d.ts b/collections/forms/src/validators/types/index.d.ts deleted file mode 100644 index 06d5426df0..0000000000 --- a/collections/forms/src/validators/types/index.d.ts +++ /dev/null @@ -1,33 +0,0 @@ -type ValuesWithId = Array<{ id: string }> | undefined - -type Validator = (value: unknown) => string | undefined - -export const alphaNumeric: Validator -export const boolean: Validator -export const composeValidators: (...validators: Validator[]) => Validator - -export const createCharacterLengthRange: ( - lowerBound: number, - upperBound: number, - customMessage?: string -) => Validator -export const createEqualTo: (key: string, description?: string) => Validator -export const createMaxCharacterLength: (upperBound: number) => Validator -export const createMaxNumber: (upperBound: number) => Validator -export const createMinCharacterLength: (lowerBound: number) => Validator -export const createMinNumber: (lowerBound: number) => Validator -export const createNumberRange: ( - lowerBound: number, - upperBound: number, - customMessage?: string -) => Validator -export const createPattern: (pattern: RegExp, message?: string) => Validator -export const dhis2Password: Validator -export const dhis2Username: Validator -export const email: Validator -export const hasValue: Validator -export const integer: Validator -export const internationalPhoneNumber: Validator -export const number: Validator -export const string: Validator -export const url: Validator diff --git a/collections/forms/src/validators/types/text.ts b/collections/forms/src/validators/types/text.ts deleted file mode 100644 index e69de29bb2..0000000000 From 392f78229e8f499061b5fc0e5367752e1f4f0eab Mon Sep 17 00:00:00 2001 From: Birk Johansson Date: Mon, 16 Oct 2023 22:30:42 +0200 Subject: [PATCH 5/9] fix(types): cleanup --- .../forms/types/RadioFieldFF/RadioFieldFF.d.ts | 2 +- collections/forms/types/index.d.ts | 16 ++++++++++++++++ collections/forms/types/transformers/index.d.ts | 2 +- collections/forms/types/validators/index.d.ts | 2 -- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/collections/forms/types/RadioFieldFF/RadioFieldFF.d.ts b/collections/forms/types/RadioFieldFF/RadioFieldFF.d.ts index 9a0423b81a..6699ff8197 100644 --- a/collections/forms/types/RadioFieldFF/RadioFieldFF.d.ts +++ b/collections/forms/types/RadioFieldFF/RadioFieldFF.d.ts @@ -4,7 +4,7 @@ import type { RadioProps } from '@dhis2-ui/radio' type InputValue = RadioProps['value'] -type RadioOverriddenProps = Omit +type RadioOverriddenProps = Omit export type RadioFieldFFProps = FieldRenderProps & RadioOverriddenProps & { diff --git a/collections/forms/types/index.d.ts b/collections/forms/types/index.d.ts index 118a3bae2a..490492c96b 100644 --- a/collections/forms/types/index.d.ts +++ b/collections/forms/types/index.d.ts @@ -1,3 +1,6 @@ +import * as FinalForm from 'final-form' +import * as ReactFinalForm from 'react-final-form' + export { CheckboxFieldFF } from './CheckboxFieldFF/CheckboxFieldFF' export { FileInputFieldFF } from './FileInputFieldFF/FileInputFieldFF' @@ -12,3 +15,16 @@ export { FieldGroupFF } from './FieldGroupFF/FieldGroupFF' export * from './transformers' export * from './validators' + +/** + * Allows direct access to the FinalForm library. Please note that this is considered advanced + * usage and that you need to stay up to date with breaking changes in the FinalForm library. + */ +export { FinalForm } + +/** + * Allows direct access to the ReactFinalForm library. Please note that this is considered + * advanced usage and that you need to stay up to date with breaking changes in the FinalForm + * library. + */ +export { ReactFinalForm } diff --git a/collections/forms/types/transformers/index.d.ts b/collections/forms/types/transformers/index.d.ts index 158b0c73b2..a48956b79f 100644 --- a/collections/forms/types/transformers/index.d.ts +++ b/collections/forms/types/transformers/index.d.ts @@ -1,5 +1,5 @@ -import type { ValuesWithId } from "../validators" +export type ValuesWithId = Array<{ id: string }> | undefined export const arrayWithIdObjects: { format: (value: ValuesWithId) => string, diff --git a/collections/forms/types/validators/index.d.ts b/collections/forms/types/validators/index.d.ts index b5b199ed4e..0ead88dae6 100644 --- a/collections/forms/types/validators/index.d.ts +++ b/collections/forms/types/validators/index.d.ts @@ -1,5 +1,3 @@ -export type ValuesWithId = Array<{ id: string }> | undefined - export type Validator = (value: unknown) => string | undefined export const alphaNumeric: Validator From 4927daf5d0dc4ae88b9dff889afc59524bfe7daf Mon Sep 17 00:00:00 2001 From: Birk Johansson Date: Tue, 17 Oct 2023 16:23:40 +0200 Subject: [PATCH 6/9] style: run prettier --- .../types/CheckboxFieldFF/CheckboxFieldFF.d.ts | 4 +--- .../types/FileInputFieldFF/FileInputFieldFF.d.ts | 14 +++++++++----- .../forms/types/InputFieldFF/InputFieldFF.d.ts | 14 +++++++++----- .../forms/types/RadioFieldFF/RadioFieldFF.d.ts | 5 ++++- .../SingleSelectFieldFF/SingleSelectFieldFF.d.ts | 14 +++++++++++--- collections/forms/types/index.d.ts | 2 -- collections/forms/types/transformers/index.d.ts | 3 +-- 7 files changed, 35 insertions(+), 21 deletions(-) diff --git a/collections/forms/types/CheckboxFieldFF/CheckboxFieldFF.d.ts b/collections/forms/types/CheckboxFieldFF/CheckboxFieldFF.d.ts index 7dcc976c9c..a7bdf5148f 100644 --- a/collections/forms/types/CheckboxFieldFF/CheckboxFieldFF.d.ts +++ b/collections/forms/types/CheckboxFieldFF/CheckboxFieldFF.d.ts @@ -1,7 +1,5 @@ import type { FieldRenderProps } from 'react-final-form' -import type { - CheckboxFieldProps, -} from '@dhis2-ui/checkbox' +import type { CheckboxFieldProps } from '@dhis2-ui/checkbox' import React from 'react' type CheckBoxValue = CheckboxFieldProps['value'] diff --git a/collections/forms/types/FileInputFieldFF/FileInputFieldFF.d.ts b/collections/forms/types/FileInputFieldFF/FileInputFieldFF.d.ts index b3ce134cdd..8f7cf3419f 100644 --- a/collections/forms/types/FileInputFieldFF/FileInputFieldFF.d.ts +++ b/collections/forms/types/FileInputFieldFF/FileInputFieldFF.d.ts @@ -4,11 +4,15 @@ import type { FieldRenderProps } from 'react-final-form' export type FilesValue = File[] | undefined | null | '' -type FileInputOverriddenProps = Omit +type FileInputOverriddenProps = Omit< + FileInputFieldProps, + 'onChange' | 'multiple' | 'name' +> -export type FileInputFieldFFProps = FieldRenderProps & FileInputOverriddenProps & { - showValidStatus?: boolean - multifile: FileInputFieldProps['multiple'] -} +export type FileInputFieldFFProps = FieldRenderProps & + FileInputOverriddenProps & { + showValidStatus?: boolean + multifile: FileInputFieldProps['multiple'] + } export const FileInputFieldFF: React.FC diff --git a/collections/forms/types/InputFieldFF/InputFieldFF.d.ts b/collections/forms/types/InputFieldFF/InputFieldFF.d.ts index ea581c7495..97697e1713 100644 --- a/collections/forms/types/InputFieldFF/InputFieldFF.d.ts +++ b/collections/forms/types/InputFieldFF/InputFieldFF.d.ts @@ -4,11 +4,15 @@ import type { FieldRenderProps } from 'react-final-form' export type InputValue = InputFieldProps['value'] -type InputFieldOverriddenProps = Omit +type InputFieldOverriddenProps = Omit< + InputFieldProps, + 'onChange' | 'value' | 'name' +> -export type InputFieldFFProps = FieldRenderProps & InputFieldOverriddenProps & { - showLoadingStatus?: boolean - showValidStatus?: boolean -} +export type InputFieldFFProps = FieldRenderProps & + InputFieldOverriddenProps & { + showLoadingStatus?: boolean + showValidStatus?: boolean + } export const InputFieldFF: React.FC diff --git a/collections/forms/types/RadioFieldFF/RadioFieldFF.d.ts b/collections/forms/types/RadioFieldFF/RadioFieldFF.d.ts index 6699ff8197..8eb8eb1631 100644 --- a/collections/forms/types/RadioFieldFF/RadioFieldFF.d.ts +++ b/collections/forms/types/RadioFieldFF/RadioFieldFF.d.ts @@ -4,7 +4,10 @@ import type { RadioProps } from '@dhis2-ui/radio' type InputValue = RadioProps['value'] -type RadioOverriddenProps = Omit +type RadioOverriddenProps = Omit< + RadioProps, + 'onChange' | 'value' | 'checked' | 'name' +> export type RadioFieldFFProps = FieldRenderProps & RadioOverriddenProps & { diff --git a/collections/forms/types/SingleSelectFieldFF/SingleSelectFieldFF.d.ts b/collections/forms/types/SingleSelectFieldFF/SingleSelectFieldFF.d.ts index 04ed38fd38..5a22c78fad 100644 --- a/collections/forms/types/SingleSelectFieldFF/SingleSelectFieldFF.d.ts +++ b/collections/forms/types/SingleSelectFieldFF/SingleSelectFieldFF.d.ts @@ -1,12 +1,20 @@ import React from 'react' import type { FieldRenderProps } from 'react-final-form' -import type { SingleSelectOptionProps, SingleSelectFieldProps } from '@dhis2-ui/select' +import type { + SingleSelectOptionProps, + SingleSelectFieldProps, +} from '@dhis2-ui/select' type InputValue = SingleSelectFieldProps['selected'] -type SingleSelectOptions = Array> +type SingleSelectOptions = Array< + Pick +> -type SingleSelectOverriddenProps = Omit +type SingleSelectOverriddenProps = Omit< + SingleSelectFieldProps, + 'onChange' | 'value' | 'name' +> export type SingleSelectFieldFFProps = FieldRenderProps & SingleSelectOverriddenProps & { diff --git a/collections/forms/types/index.d.ts b/collections/forms/types/index.d.ts index 490492c96b..844d413348 100644 --- a/collections/forms/types/index.d.ts +++ b/collections/forms/types/index.d.ts @@ -1,7 +1,6 @@ import * as FinalForm from 'final-form' import * as ReactFinalForm from 'react-final-form' - export { CheckboxFieldFF } from './CheckboxFieldFF/CheckboxFieldFF' export { FileInputFieldFF } from './FileInputFieldFF/FileInputFieldFF' export { InputFieldFF } from './InputFieldFF/InputFieldFF' @@ -15,7 +14,6 @@ export { FieldGroupFF } from './FieldGroupFF/FieldGroupFF' export * from './transformers' export * from './validators' - /** * Allows direct access to the FinalForm library. Please note that this is considered advanced * usage and that you need to stay up to date with breaking changes in the FinalForm library. diff --git a/collections/forms/types/transformers/index.d.ts b/collections/forms/types/transformers/index.d.ts index a48956b79f..e985979da6 100644 --- a/collections/forms/types/transformers/index.d.ts +++ b/collections/forms/types/transformers/index.d.ts @@ -1,7 +1,6 @@ - export type ValuesWithId = Array<{ id: string }> | undefined export const arrayWithIdObjects: { - format: (value: ValuesWithId) => string, + format: (value: ValuesWithId) => string pars: (value: string) => ValuesWithId } From 0a3c283fbc54b261c0163af47cc6fbdb4f02774e Mon Sep 17 00:00:00 2001 From: Birk Johansson Date: Tue, 17 Oct 2023 23:58:16 +0200 Subject: [PATCH 7/9] refactor: rename overridden type name to rest --- collections/forms/types/CheckboxFieldFF/CheckboxFieldFF.d.ts | 4 ++-- collections/forms/types/FieldGroupFF/FieldGroupFF.d.ts | 2 +- .../forms/types/FileInputFieldFF/FileInputFieldFF.d.ts | 4 ++-- collections/forms/types/InputFieldFF/InputFieldFF.d.ts | 4 ++-- .../forms/types/MultiSelectFieldFF/MutliSelectFieldFF.d.ts | 4 ++-- collections/forms/types/RadioFieldFF/RadioFieldFF.d.ts | 4 ++-- .../forms/types/SingleSelectFieldFF/SingleSelectFieldFF.d.ts | 4 ++-- collections/forms/types/SwitchFieldFF/SwitchFieldFF.d.ts | 4 ++-- collections/forms/types/TextAreaFieldFF/TextAreaFieldFF.d.ts | 4 ++-- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/collections/forms/types/CheckboxFieldFF/CheckboxFieldFF.d.ts b/collections/forms/types/CheckboxFieldFF/CheckboxFieldFF.d.ts index a7bdf5148f..8375721a23 100644 --- a/collections/forms/types/CheckboxFieldFF/CheckboxFieldFF.d.ts +++ b/collections/forms/types/CheckboxFieldFF/CheckboxFieldFF.d.ts @@ -3,13 +3,13 @@ import type { CheckboxFieldProps } from '@dhis2-ui/checkbox' import React from 'react' type CheckBoxValue = CheckboxFieldProps['value'] -type CheckboxOverriddenProps = Omit< +type CheckboxRestProps = Omit< CheckboxFieldProps, 'onChange' | 'value' | 'checked' | 'name' > export type CheckboxFieldFFProps = FieldRenderProps & - CheckboxOverriddenProps & { + CheckboxRestProps & { showValidStatus?: boolean } diff --git a/collections/forms/types/FieldGroupFF/FieldGroupFF.d.ts b/collections/forms/types/FieldGroupFF/FieldGroupFF.d.ts index 166b3fe6cc..203e544641 100644 --- a/collections/forms/types/FieldGroupFF/FieldGroupFF.d.ts +++ b/collections/forms/types/FieldGroupFF/FieldGroupFF.d.ts @@ -1,7 +1,7 @@ import React from 'react' import type { FieldGroupProps } from '@dhis2-ui/field' -export type FieldGroupFFProps = Pick< +export type FieldGroupFFProps = Omit< FieldGroupProps, 'children' | 'label' | 'name' | 'required' > diff --git a/collections/forms/types/FileInputFieldFF/FileInputFieldFF.d.ts b/collections/forms/types/FileInputFieldFF/FileInputFieldFF.d.ts index 8f7cf3419f..338dfc6626 100644 --- a/collections/forms/types/FileInputFieldFF/FileInputFieldFF.d.ts +++ b/collections/forms/types/FileInputFieldFF/FileInputFieldFF.d.ts @@ -4,13 +4,13 @@ import type { FieldRenderProps } from 'react-final-form' export type FilesValue = File[] | undefined | null | '' -type FileInputOverriddenProps = Omit< +type FileInputRestProps = Omit< FileInputFieldProps, 'onChange' | 'multiple' | 'name' > export type FileInputFieldFFProps = FieldRenderProps & - FileInputOverriddenProps & { + FileInputRestProps & { showValidStatus?: boolean multifile: FileInputFieldProps['multiple'] } diff --git a/collections/forms/types/InputFieldFF/InputFieldFF.d.ts b/collections/forms/types/InputFieldFF/InputFieldFF.d.ts index 97697e1713..f16692947d 100644 --- a/collections/forms/types/InputFieldFF/InputFieldFF.d.ts +++ b/collections/forms/types/InputFieldFF/InputFieldFF.d.ts @@ -4,13 +4,13 @@ import type { FieldRenderProps } from 'react-final-form' export type InputValue = InputFieldProps['value'] -type InputFieldOverriddenProps = Omit< +type InputFieldRestProps = Omit< InputFieldProps, 'onChange' | 'value' | 'name' > export type InputFieldFFProps = FieldRenderProps & - InputFieldOverriddenProps & { + InputFieldRestProps & { showLoadingStatus?: boolean showValidStatus?: boolean } diff --git a/collections/forms/types/MultiSelectFieldFF/MutliSelectFieldFF.d.ts b/collections/forms/types/MultiSelectFieldFF/MutliSelectFieldFF.d.ts index 26bc43943f..d30d6b6a04 100644 --- a/collections/forms/types/MultiSelectFieldFF/MutliSelectFieldFF.d.ts +++ b/collections/forms/types/MultiSelectFieldFF/MutliSelectFieldFF.d.ts @@ -7,7 +7,7 @@ import type { type InputValue = MultiSelectFieldProps['selected'] | '' -type MultiSelectFieldOverriddenProps = Omit< +type MultiSelectFieldRestProps = Omit< MultiSelectFieldProps, 'onChange' | 'value' > @@ -15,7 +15,7 @@ type MultiSelectFieldOverriddenProps = Omit< type MultiSelectOptions = Array> export type MultiSelectFieldFFProps = FieldRenderProps & - MultiSelectFieldOverriddenProps & { + MultiSelectFieldRestProps & { showLoadingStatus?: boolean showValidStatus?: boolean options: MultiSelectOptions diff --git a/collections/forms/types/RadioFieldFF/RadioFieldFF.d.ts b/collections/forms/types/RadioFieldFF/RadioFieldFF.d.ts index 8eb8eb1631..847b65ae2a 100644 --- a/collections/forms/types/RadioFieldFF/RadioFieldFF.d.ts +++ b/collections/forms/types/RadioFieldFF/RadioFieldFF.d.ts @@ -4,13 +4,13 @@ import type { RadioProps } from '@dhis2-ui/radio' type InputValue = RadioProps['value'] -type RadioOverriddenProps = Omit< +type RadioRestProps = Omit< RadioProps, 'onChange' | 'value' | 'checked' | 'name' > export type RadioFieldFFProps = FieldRenderProps & - RadioOverriddenProps & { + RadioRestProps & { showValidStatus?: boolean } diff --git a/collections/forms/types/SingleSelectFieldFF/SingleSelectFieldFF.d.ts b/collections/forms/types/SingleSelectFieldFF/SingleSelectFieldFF.d.ts index 5a22c78fad..40bb616d5c 100644 --- a/collections/forms/types/SingleSelectFieldFF/SingleSelectFieldFF.d.ts +++ b/collections/forms/types/SingleSelectFieldFF/SingleSelectFieldFF.d.ts @@ -11,13 +11,13 @@ type SingleSelectOptions = Array< Pick > -type SingleSelectOverriddenProps = Omit< +type SingleSelectRestProps = Omit< SingleSelectFieldProps, 'onChange' | 'value' | 'name' > export type SingleSelectFieldFFProps = FieldRenderProps & - SingleSelectOverriddenProps & { + SingleSelectRestProps & { showLoadingStatus?: boolean showValidStatus?: boolean options: SingleSelectOptions diff --git a/collections/forms/types/SwitchFieldFF/SwitchFieldFF.d.ts b/collections/forms/types/SwitchFieldFF/SwitchFieldFF.d.ts index 2cf85d9f7b..5996b936c4 100644 --- a/collections/forms/types/SwitchFieldFF/SwitchFieldFF.d.ts +++ b/collections/forms/types/SwitchFieldFF/SwitchFieldFF.d.ts @@ -4,12 +4,12 @@ import type { SwitchFieldProps } from '@dhis2-ui/switch' type InputValue = SwitchFieldProps['value'] -type SwitchFieldOverriddenProps = Omit< +type SwitchFieldRestProps = Omit< SwitchFieldProps, 'onChange' | 'checked' | 'value' | 'name' > export type SwitchFieldFFProps = FieldRenderProps & - SwitchFieldOverriddenProps + SwitchFieldRestProps export const SwitchFieldFF: React.FC diff --git a/collections/forms/types/TextAreaFieldFF/TextAreaFieldFF.d.ts b/collections/forms/types/TextAreaFieldFF/TextAreaFieldFF.d.ts index 33c4c7ee73..af829af51e 100644 --- a/collections/forms/types/TextAreaFieldFF/TextAreaFieldFF.d.ts +++ b/collections/forms/types/TextAreaFieldFF/TextAreaFieldFF.d.ts @@ -4,12 +4,12 @@ import type { TextAreaFieldProps } from '@dhis2-ui/text-area' type InputValue = TextAreaFieldProps['value'] -type TextAreaFieldOverriddenProps = Omit< +type TextAreaFieldRestProps = Omit< TextAreaFieldProps, 'onChange' | 'value' | 'name' > export type TextAreaFieldFFProps = FieldRenderProps & - TextAreaFieldOverriddenProps + TextAreaFieldRestProps export const TextAreaFieldFF: React.FC From b54551e4789751e16083ceba8ff943d03eeec567 Mon Sep 17 00:00:00 2001 From: Birk Johansson Date: Wed, 18 Oct 2023 15:03:54 +0200 Subject: [PATCH 8/9] style: run prettier --- collections/forms/types/InputFieldFF/InputFieldFF.d.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/collections/forms/types/InputFieldFF/InputFieldFF.d.ts b/collections/forms/types/InputFieldFF/InputFieldFF.d.ts index f16692947d..048590da5e 100644 --- a/collections/forms/types/InputFieldFF/InputFieldFF.d.ts +++ b/collections/forms/types/InputFieldFF/InputFieldFF.d.ts @@ -4,10 +4,7 @@ import type { FieldRenderProps } from 'react-final-form' export type InputValue = InputFieldProps['value'] -type InputFieldRestProps = Omit< - InputFieldProps, - 'onChange' | 'value' | 'name' -> +type InputFieldRestProps = Omit export type InputFieldFFProps = FieldRenderProps & InputFieldRestProps & { From 3b8a53911bd33fdf315b6c61c21556c23e03999e Mon Sep 17 00:00:00 2001 From: Birk Johansson Date: Thu, 19 Oct 2023 14:13:22 +0200 Subject: [PATCH 9/9] fix(types): make selected payload always present --- components/select/types/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/select/types/index.d.ts b/components/select/types/index.d.ts index 800d4e34ff..008b627a29 100644 --- a/components/select/types/index.d.ts +++ b/components/select/types/index.d.ts @@ -3,13 +3,13 @@ import { LayerBackdropClickEvent } from '@dhis2-ui/layer' import { CheckboxProps } from '@dhis2-ui/checkbox' interface BaseEventPayload { - selected?: string | string[] + selected: string | string[] } interface SingleSelectEventPayload extends BaseEventPayload { - selected?: string + selected: string } interface MultiSelectEventPayload extends BaseEventPayload { - selected?: string[] + selected: string[] } type SelectEventHandler<