2.0.4 • Published 4 years ago

formik_typescript_ui v2.0.4

Weekly downloads
26
License
MIT
Repository
github
Last release
4 years ago

Formik TypeScript UI

NPM license

Overview

Formik TypeScript UI, contains simple HTML form fields wrapped with Formik and written in TypeScript.

Installation

npm install --save formik_typescript_ui

Change Log

2.0.4 - 2019-12-12

This release contains breaking changes from the previous version.

Changed

  • index.ts components export
  • HandleChange type on TagsInputField was renamed to HandleTagsChange

Fixed

  • React scripts dependencies
  • Dependencies vulnerabilities

Components

CheckboxField

The CheckboxField component renders a simple HTML <input> of the type checkbox and its respective <label>.

Props

NameTypeDefault ValueDescription
classNamestringnullAdds a custom class to the <input> element
classNameLabelstringnullAdds a custom class to the <label> element
disabledbooleanfalseDisables the <input> element
idstringnullSets an id for the <input> element. If not specified, the name would be used instead
labelstringrequiredSets the text for the <label> element
labelStyleobject{}Adds custom inline style to the <label> element
namestringrequiredSets the name of the <input> element
styleobject{}Adds custom inline style to the <input> element

CheckboxGroup

The CheckboxGroup component renders a list of <CheckboxField /> from the given options.

CheckOptionType

interface CheckOptionType {
  id?: string;
  label: string;
  name: string;
}

Props

NameTypeDefault ValueDescription
classNamestringnullAdds a custom class to each <input> element
classNameLabelstringnullAdds a custom class to each <label> element
labelStyleobject{}Adds custom inline style to each <label> element
optionsCheckOptionType[]requiredSets the required props for the <CheckboxField /> components
styleobject{}Adds custom inline style to each <input> element

DatePickerField

The DatePickerField component renders a simple HTML <input> of the type date.

Props

NameTypeDefault ValueDescription
classNamestringnullAdds a custom class to the <input> element
disabledbooleanfalseDisables the <input> element
idstringnullSets an id for the <input> element. If not specified, the name would be used instead
maxDatestringnullSets the maximun date that can be selected. If not in the correct format AAAA-MM-DD, this validation won't have any effects
minDatestringnullSets the minimun date that can be selected. If not in the correct formar AAAA-MM-DD, this validation won't have any effects
namestringrequiredSets the name of the <input> element
styleobject{}Adds custom inline style to the <input> element

RadioButtonField

The RadioButtonField component renders a simple HTML <input> of the type radio and its respective <label>.

Props

NameTypeDefault ValueDescription
classNamestringnullAdds a custom class to the <input> element
classNameLabelstringnullAdds a custom class to the <label> element
disabledbooleanfalseDisables the <input> element
idstringrequiredSets an id for the <input> element
labelstringnullSets the text for the <label> element
labelStyleobject{}Adds custom inline style to the <label> element
namestringrequiredSets the name of the <input> element
styleobject{}Adds custom inline style to the <input> element

RadioButtonGroup

The RadioButtonGroup component renders a list of <RadioButtonField /> from the given options.

RadioOptionType

interface RadioOptionType {
  id: string;
  label: string;
}

Props

NameTypeDefault ValueDescription
classNamestringnullAdds a custom class to each <input> element
classNameLabelstringnullAdds a custom class to each <label> element
labelStyleobject{}Adds custom inline style to each <label> element
namestringrequiredSets the name for all the <input> elements
optionsRadioOptionType[]requiredSets the required props for the <RadioButtonField /> components
styleobject{}Adds custom inline style to each <input> element

SelectField

The SelectField component uses react-select to render the select element and it's respective options. For more information on the react-select library, click here.

OptionType

interface OptionType {
  label: string;
  value: string;
}

Props

NameTypeDefault ValueDescription
autofocusbooleanfalseSets wether the control is focused or not when the component is mounted
classNamestringnullAdds a custom class to the <Select /> component
idstringnullSets an id for the <SelectContainer />. If not specified, the name would be used instead
isDisabledbooleanfalseSets wether the <Select /> is disabled or not
isLoadingbooleanfalseSets wether the <Select /> is loading its content (asynchronous) or not
isMultibooleanfalseSets wether the <Select /> allows for multiple selection or not
isSearchablebooleanfalseSets wether the options can be searched or not
namestringrequiredSets the name for the <input> element
optionsOptionType[]requiredSets the options for the <Select /> component
placeholderstringnullSets the placeholder for the <input> element
styleobject{}Style modifier methods as described on react-select docs

TagsInputField

The TagsInputField component uses react-tagsinput to render the input element and it's respective tags. For more information on the react-tagsinput library, click here.

InputProps

The InputProps, can be exported from the react-tagsinput library or defined as follows:

interface InputProps {
  className: string;
  placeholder: string;
}

Default values for inputProps:

const defaultInputProps: InputProps = {
  className: 'react-tagsinput-input',
  placeholder: 'Add a tag',
}

PasteSplit

The PasteSplit type, can be defined as follows:

  type PasteSplit = (text: string) => string[];
  const defaultPasteSplit: PasteSplit = (text: string) => (
    text.split(' ').map(word => word.trim());
  );

TagProps

The TagProps, can be exported from the react-tagsinput library or defined as follows:

interface TagProps {
  className: string;
  classNameRemove: string;
}

Default values for tagProps:

const defaultTagProps: TagProps = {
  className: 'react-tagsinput-tag',
  classNameRemove: 'react-tagsinput-remove',
}

Props

NameTypeDefault ValueDescription
addOnBlurbooleanfalseAdds a tag on the input blur event
addOnPastebooleanfalseAdds a tag on HTML5 paste
classNamestringreact-tagsinputAdds a custom class to the component's wrapper
disabledbooleanfalseDisables the <input> element
focusedClassNamestringreact-tagsinput--focusedAdds a custom class to the component's wrapper when it's focused
inputPropsInputPropsdefaultInputPropsProps passed down to the <input> element
maxTagsnumber-1Sets a maximum amount of tags. Use -1 for infinite tags
namestringrequiredSets the name for the component
pasteSplitPasteSplitdefaultPasteSplitFunction that splits the pasted text
tagPropsTagPropsdefaultTagPropsProps passed down to every tag component

TextareaField

The TextareaField component renders a simple HTML <textarea>.

Props

NameTypeDefault ValueDescription
classNamestringnullAdds a custom class to the <textarea> element
disabledbooleanfalseDisables the <textarea> element
idstringnullSets an id for the <textarea> element. If not specified, the name would be used instead
namestringrequiredSets the name for the <textarea> element
placeholderstringnullSets the placeholder for the <textarea> element
styleobject{}Adds custom inline style to the <textarea> element

TextField

The TextField component renders a simple HTML <input>.

Props

type OnChange = (event: React.ChangeEvent<HTMLInputElement>) => void;
type OnInput = (event: React.ChangeEvent<HTMLInputElement>) => void;
type RefType = string | ((instance: HTMLInputElement | null) => void) | React.RefObject<HTMLInputElement> | null | undefined;
NameTypeDefault ValueDescription
classNamestringnullAdds a custom class to the <input> element
disabledbooleanfalseDisables the <input> element
forwardRefRefTypeundefinedSets a ref for the <input> element.
idstringnullSets an id for the <input> element. If not specified, the name would be used instead
namestringrequiredSets the name for the <input> element
maxnumberundefinedSets the max for the <input> element
maxLengthnumberundefinedSets the maxLength for the <input>
minnumberundefinedSets the min for the <input> element
minLengthnumberundefinedSets the minLength for the <input> element
onChangeOnChangeundefinedSets the onChange function for the <input> element. When undefined, it takes the formik field default onChange function.
onInputOnInputundefinedSets the onInput function for the <input> element
onKeyDownOnKeyDownundefinedSets the onKeyDown function for the <input> element
patternstringundefinedSets the pattern for the <input> element
placeholderstringnullSets the placeholder for the <input> element
styleobject{}Adds custom inline style to the <input> element
typestring'text'HTML types: text, email, password and number

License

MIT © Romina Manzano

2.0.4

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.3.10

5 years ago

1.3.9

5 years ago

1.3.8

5 years ago

1.3.7

5 years ago

1.3.6

5 years ago

1.3.5

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago