Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/Fields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
IVGSCollectDateField,
IVGSCollectForm,
VGSCollectStateParams,
IVGSCollectDropdownField,
} from './types/Form';

import {
Expand Down Expand Up @@ -212,6 +213,16 @@ const FileField = React.memo((props: Partial<IVGSCollectFileField & GeneralField
)
});

const DropdownField = React.memo((props: Partial<IVGSCollectDropdownField & GeneralFieldProps>) => {
return (
<RenderField
{...Object.assign({
...DEFAULT_CONFIG.FILE,
}, props)}
/>
)
});

export {
TextField,
CardNumberField,
Expand All @@ -223,5 +234,6 @@ export {
TextareaField,
NumberField,
FileField,
DateField
DateField,
DropdownField
};
4 changes: 3 additions & 1 deletion src/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
SSNField,
TextField,
TextareaField,
ZipCodeField
ZipCodeField,
DropdownField
} from './Fields';
import { DispatchStateContext, DispatchSubmitContext } from './provider';
import { FormStateProvider, DispatchFormContext } from './formStateProvider';
Expand Down Expand Up @@ -165,3 +166,4 @@ VGSCollectForm.TextareaField = TextareaField;
VGSCollectForm.NumberField = NumberField;
VGSCollectForm.FileField = FileField;
VGSCollectForm.DateField = DateField;
VGSCollectForm.DropdownField = DropdownField
4 changes: 4 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ const DEFAULT_CONFIG = {
DATE: {
type: 'date',
placeholder: ''
},
DROPDOWN: {
type: 'dropdown',
placeholder: '',
}
};

Expand Down
11 changes: 11 additions & 0 deletions src/types/Form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ interface IFieldTokenization {
storage?: StorageTypes;
}

interface IDropdownOption {
value: string,
text: string
}

interface IDefaultFieldOptions {
type: VGSCollectFieldType;
name: string;
Expand All @@ -108,6 +113,7 @@ interface IDefaultFieldOptions {
readonly?: BooleanValue;
inputMode?: InputMode;
tokenization?: IFieldTokenization | boolean;
defaultValue?: string
}

type FieldConfig =
Expand Down Expand Up @@ -191,6 +197,10 @@ interface IVGSCollectFileField extends IDefaultFieldOptions {
maxFiled: number;
}

interface IVGSCollectDropdownField extends IDefaultFieldOptions {
options?: IDropdownOption[]
}

interface IVGSCollectDateField extends IDefaultFieldOptions {
type: 'date';
min?: number;
Expand Down Expand Up @@ -306,6 +316,7 @@ export type {
IVGSCollectTextareaField,
IVGSCollectDateField,
IVGSCollectFileField,
IVGSCollectDropdownField,
ICollectFormProps,
ICollectFormPayloadStructure,
VGSCollectFormState,
Expand Down