npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-form-idable

v3.0.1

Published

## Installation

Downloads

19

Readme

react-native-form-idable

Installation

yarn add react-native-form-idable

Features

  • Sets input props based on the type you pass it. For instance, type="email" implies autocorrect="false"
  • Automatically adds a submit function
  • Validation available out of the box but highly customizable
  • Native-like DatePicker with same API for both Android & iOS
  • Highly customizable components and validation with React Native like API

Usage

This is a minimal example:

import { Form, TextInput } from 'react-native-form-idable';

...

<Form
  formStyles={formStyles}
  toastErrors
  onSubmit={formData => console.log(formData)}
  onValidationError={errors => console.log(errors)}
>
  <TextInput
    name="email"
    placeholder="Email"
    type="email"
    required
  />
  <TextInput
    name="password"
    placeholder="Password"
    type="password"
    required
  />
  <TouchableOpacity type="submit">
    <Text>Submit</Text>
  </TouchableOpacity>
</Form>

In the example above, if the inputs are filled, when pressing on the buttons, the onSubmit prop will be called with

{
  email: "[email protected]",
  password: "very secure password"
}

How it works:

  • The Form component wraps the inputs and handles the logic
  • One of the direct child should have a type="submit" prop. The form will add an onPress prop on it, which will call the onSubmit prop with the formData when clicking

Styling the form

The styles are passed through the formStyles prop. Here are the available style props:

  • inputContainerStyle: style applied to the global container (View)
  • nonEditableInput: style applied to the global container when TextInput is not editable
  • inputLabelContainer: style applied to the label container (View)
  • inputLabel: style applied to the text label (Text)
  • activeInputLabel: style applied to the text label when focused or filled (Text)
  • fieldContainer: style applied to the field container (View)
  • activeFieldContainer: style applied to the field container when focused (View)
  • validFieldContainer: style applied to the field container when filled with valid info (View)
  • fieldText: style applied to the input (TextInput)
  • activeFieldText: style applied to the input when focused (TextInput)
  • validFieldText: style applied to the input when filled with valid info (TextInput)
  • errorTextContainer: style applied to the error container (View)
  • placeholderAndSelectionColors: color of the selection bar and of the placeholder
  • activePlaceholderAndSelectionColors: color of the selection bar and of the placeholder when focused or filled
  • error: style applied to the error text (Text)

Expo Example

There's an expo example available in ./example.

You can try out the published version with the Expo app.

More advanced example

import React, { Component } from 'react';
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
import { DatePicker, Picker, Form, TextInput } from 'react-native-form-idable';

const styles = StyleSheet.create({
  container: {
    flex: 1,
    paddingTop: 40,
  },
  button: {
    alignSelf: 'stretch',
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: 'blue',
    paddingHorizontal: 10,
    minHeight: 40,
  },
  buttonText: {
    fontSize: 20,
    color: 'white',
  },
  form: {
    borderTopWidth: 1,
    borderTopColor: '#ddd',
  },
});

const formStyles = {
  fieldContainer: {
    backgroundColor: 'white',
    borderBottomWidth: 1,
    borderBottomColor: '#ddd',
  },
  fieldText: {
    color: '#333',
    fontSize: 14,
    fontWeight: '600',
    paddingHorizontal: 20,
    paddingVertical: 12,
  },
};

export default class FormidableExample extends Component {
  onSubmit = formData => console.log(formData);

  render() {
    return (
      <View style={styles.container}>
        <Form
          formStyles={formStyles}
          onSubmit={this.onSubmit}
          toastErrors
          style={styles.form}
          onValidationError={errors => console.log(errors)}
        >
          <TextInput name="email" placeholder="Email" type="email" required />
          <Picker name="language" type="language" placeholder="Language" formStyles={formStyles}>
            <Picker.Item label="English" value="en" />
            <Picker.Item label="French" value="fr" />
          </Picker>
          <DatePicker
            name="birthdate"
            type="date"
            placeholder="Birthdate"
            minimumDate={new Date(1992, 7, 17)}
            date={new Date(2017, 8, 1)}
            maximumDate={new Date(2017, 8, 10)}
          />
          <DatePicker
            format={'HH:mm'}
            name="hour"
            type="date"
            placeholder="Hour"
            mode="time"
            androidMode="calendar"
            is24Hour
            minuteInterval={30}
            timeZoneOffsetInMinutes={-7 * 60}
            date={new Date(2017, 8, 1, 14, 54)}
          />
          <DatePicker
            format={'D MMMM YYYY HH:mm'}
            name="datetime"
            type="datetime"
            placeholder="Datetime"
            mode="datetime"
            androidMode="calendar"
            date={new Date(2017, 8, 1, 14, 54)}
          />
          <TextInput name="password" placeholder="Password" type="password" required />
          <TouchableOpacity type="submit" style={styles.button}>
            <Text style={styles.buttonText}>Submit</Text>
          </TouchableOpacity>
        </Form>
      </View>
    );
  }
}

Contributing

Commits follow the Angular commit convention to create releases automatically.

To help you out, you can run

yarn
yarn commit

in the repo

Creating releases

commitizen uses semantic-release to release new versions automatically.

Commits of type fix will trigger bugfix releases, think 0.0.1 Commits of type feat will trigger feature releases, think 0.1.0 Commits with BREAKING CHANGE in body or footer will trigger breaking releases, think 1.0.0 All other commit types will trigger no new release.