2.6.14 • Published 4 months ago

react-native-form-component v2.6.14

Weekly downloads
14
License
MIT
Repository
github
Last release
4 months ago

react-native-form-component

A customizable form component for react-native. It handles basic validation of inputs, and also alerts you of failed validations.

WhatsApp Image 2021-09-28 at 6 30 53 PM ezgif com-gif-maker

Installation

yarn add react-native-form-component

Functions

NameDescription
submitFormDoes the same thing as onButtonPress() in Form component. It does validation first, then carries out the defined action

Components

Form

Wrapper component for form items. It is advised to use this component to wrap every other component contained in this library. The Form component comes with a button that does validation of FormItems when clicked. The default validation for each FormItem is based on the value of its keyboardType prop.

import { Form, FormItem } from 'react-native-form-component';
//...

return (
  <Form onButtonPress={() => console.warn('do something')}>
    <FormItem />
  </Form>
);

Props

PropFunctionTypeDefaultPlatform
keyboardVerticalOffsetDistance between the top of the user screen and the Form component, may be non-zero in some use cases.number50iOS
buttonTextText to be displayed by submit buttonstringSubmitAll
buttonStyleStyle of submit buttonobject | object[]-All
buttonTextStyleStyle of submit button textobject | object[]-All
onButtonPressAction to be performed when submit button is pressed() => void-All
styleStyle Form wrapperViewStyle{}All
hideSubmitButtonTo not render the submit buttonbooleanfalseAll

FormItem

import React, { useRef } from 'react';
import { FormItem } from 'react-native-form-component';
//...

const emailInput = useRef();

return (
  //...
  <FormItem
    label="Email"
    isRequired
    value={email}
    onChangeText={(email) => setEmail(email)}
    asterik
    ref={emailInput}
  />
);

Props

Inherits TextInput Props

PropFunctionTypeRequired
refref for itemReact.Refyes
valueValue to show for the FormItemstringyes
labelLabel for FormItemstringno
labelStyleStyle of labelobject | object[]no
textInputStyleStyle of TextInput portion of FormItemobject | object[]no
isRequiredIndicates whethter this item is required or notbooleanno
underneathTextText just below the FormItemstringno
underneathTextStyleStyle of underneathTextobject | object[]no
customValidationA function used to add custom validation to a FormItem. The function returns an object of the shape {status: boolean, message: string}. status is true when the validation passes and false when it fails. message is the underneath text to be shown when validation fails.() => {status: boolean, message: string}no
asterikWhether or not to add an asterik to labelbooleanno
childrenA ReactElement to render on the left part of the TextInput. Usually an iconReactElementno
floatingLabelWhether or not the label should floatbooleanno
textAreaWhether or not the input should be a textAreabooleanno
showErrorIconWhether or not to show an icon when an error occursbooleanno
errorBorderColorSet the color of the border when an error occursstringno
showIconIcon to be rendered when secureTextEntry is true and you want password to be visibleJSX.Elementno
hideIconIcon to be rendered when secureTextEntry is true and you want password to be hiddenJSX.Elementno

Label

import { Label } from 'react-native-form-component';
//...

return (
  //...
  <Label text="repository name" isRequired />
);

Props

PropTypeRequired
textstringyes
asterikbooleanno
textStyleTextStyleno
styleViewStyleno
asterikStyleobject | object[]no

Modal

import { Modal } from 'react-native-form-component';

return (
  <Modal show isRequired>
    <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
      <Text>I am inside a modal!</Text>
    </View>
  </Modal>
);

Props

Inherits Modal Props

PropTypeRequired
showbooleanyes
backgroundColorstringno
childrenReactNodeno

Picker

ezgif com-gif-maker

import React, { useState } from 'react';
import { Picker } from 'react-native-form-component';

const [number, setNumber] = useState(1);

return (
  <Picker
    items={[
      { label: 'One', value: 1 },
      { label: 'Two', value: 2 },
      { label: 'Three', value: 3 },
    ]}
    label="Pick a number"
    selectedValue={number}
    onSelection={(item) => setNumber(item.value)}
  />
);

Props

PropTypeRequired
itemsArray<{label: string; value: string | number}>yes
onSelection(item) => voidyes
selectedValuestring | numberyes
pickerIconReactNodeno
iconWrapperStyleViewStyleno
asterikbooleanno
asterikStyleTextStyleno
labelstringno
labelStyleTextStyleno
labelWrapperStyleViewStyleno
placeholderstringno
selectedValueStyleTextStyleno
buttonStyleViewStyleno
itemLabelStyleTextStyleno
type"modal" | "dropdown"no

PinInput

import React, { useState } from 'react';
import { PinInput } from 'react-native-form-component';

const [pin, setPin] = useState('');

return <PinInput numOfInput={4} onChangeText={(text) => setPin(text)} />;

Props

PropTypeRequired
numOfInputnumberyes
onChangeText(text: string) => voidyes
textInputStyleTextStyleno
styleStylePropno

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

2.6.14

4 months ago

2.6.13

6 months ago

2.6.11

11 months ago

2.6.12

11 months ago

2.6.10

1 year ago

2.6.5

1 year ago

2.6.4

1 year ago

2.6.7

1 year ago

2.6.6

1 year ago

2.6.9

1 year ago

2.6.8

1 year ago

2.6.1

1 year ago

2.6.0

2 years ago

2.6.3

1 year ago

2.6.2

1 year ago

2.5.0

2 years ago

2.4.0

2 years ago

2.3.2

2 years ago

2.3.1

2 years ago

2.3.3

2 years ago

2.2.4

2 years ago

2.2.1

2 years ago

2.2.3

2 years ago

2.2.2

2 years ago

2.2.0

3 years ago

2.1.0

3 years ago

2.0.3

3 years ago

2.0.5

3 years ago

2.0.4

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.1.24

3 years ago

0.1.25

3 years ago

0.1.26

3 years ago

0.1.20

3 years ago

0.1.21

3 years ago

0.1.22

3 years ago

0.1.23

3 years ago

0.1.18

3 years ago

0.1.16

3 years ago

0.1.17

3 years ago

0.14.15

3 years ago

0.1.14

3 years ago

0.1.13

3 years ago

0.1.12

3 years ago

0.1.11

3 years ago

0.1.10

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago