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-bob-form

v0.16.4

Published

React Native Form

Downloads

34

Readme

react-native-bob-form

Example

Built-in Field Types

This package comes standard with a large group of field types that cover all of the common form fields and data types you'll encounter:

Text Fields

  • TextType
  • TextareaType
  • EmailType
  • IntegerType
  • MoneyType
  • NumberType
  • PasswordType
  • PercentType
  • SearchType
  • UrlType
  • RangeType - @todo: Slider

Choice Fields

  • ChoiceType
  • EntityType
  • CountryType
  • LanguageType
  • LocaleType
  • TimezoneType
  • CurrencyType

Date and Time Fields

  • DateType
  • DateTimeType
  • TimeType
  • BirthdayType

Other Fields

  • CheckboxType
  • FileType
  • RadioType

Field Groups

  • CollectionType
  • RepeatedType

Hidden Fields

  • HiddenType

Buttons

  • ButtonType
  • ResetType
  • SubmitType

Base Fields

  • FormType

Example

'use strict';

import React, {
    Component,
    PropTypes,
    Text,
    TouchableOpacity,
    View,
    StyleSheet,
    ScrollView
} from 'react-native';

import BobForm, {
    TextType,
    TextareaType,
    EmailType,
    PasswordType,
    UrlType,
    IntegerType,
    NumberType,
    MoneyType,
    PercentType,
    RangeType,

    ChoiceType,
    EntityType,
    CountryType,
    LanguageType,
    LocaleType,
    TimezoneType,
    CurrencyType,

    CheckboxType,
    RadioType
} from 'react-native-bob-form';


import {
    AllValidator,
} from 'bob-validator';

class ReactNativeBobForm extends Component {
    constructor(props) {
        super(props);
        this.state = {
            textType: 'Nullam a mollis elit.',
            textareaType: 'Aliquam convallis vel dolor ac porta. Vestibulum orci ex, ultricies sit amet urna eu, tempor mattis diam. Sed at lectus libero. Aliquam laoreet, erat in cursus pretium, sem purus semper magna, ornare pharetra erat dolor eget mi.',
            emailType: '[email protected]',
            passwordType: '123456789',
            urlType: 'https://www.npmjs.com/package/react-native-bob-form',
            integerType: '12548',
            numberType: '12548.25',
            moneyType: '35.28',
            percentType: '.95',
            rangeType: '10',
            choiceType: 'AG',
            countryType: 'US',
            languageType: 'FR',
            localeType: 'en-GB',
            timezoneType: 'Alaskan Standard Time',
            currencyType: 'USD',
            entityType: 'GB',
            checkboxType: 'abc',
            radioType: 'dfg'
        };
    }

    onChange = (name, value) => {
        this.setState({[name]: value});

        console.log(this.state);
    };

    onValidate = (name, value) => {
        this.setState({[name+'Valid']: value});
    };

    render() {
        return (
            <ScrollView>
                <View style={{'marginTop': 55}}>
                    <CheckboxType
                        options={{'name': 'checkboxType', 'label': 'Checkbox Type', 'data': this.state.checkboxType, 'size': 'medium', 'value': 'abc'}}
                        onChange={this.onChange}
                        onValidate={this.onValidate}
                    />
                    <RadioType
                        options={{'name': 'radioType', 'label': 'Radio Type', 'data': this.state.radioType, 'size': 'medium', 'value': 'dfg'}}
                        onChange={this.onChange}
                        onValidate={this.onValidate}
                    />
                    <EntityType
                        options={{
                            'name': 'entityType',
                            'label': 'Entity Type',
                            'data': this.state.entityType,
                            'queryConfiguration': {
                                'repositoryUrl': 'https://raw.githubusercontent.com/alexeybob/react-native-bob-form/master/lib/Form/Extension/Core/Data/Test/data2.json',
                                'table': 'countries',
                                'key': '%key%',
                                'value': 'name',
                                'preferredChoices': ['US', 'DE', 'FR']
                            },
                            'attr': {
                                'style': {color: 'black'},
                                'itemStyle': {fontWeight: 'bold'}
                            },
                            'placeholder': 'Please select ...'
                        }}
                        onChange={this.onChange}
                        onValidate={this.onValidate}
                    />
                    <CurrencyType
                        options={{
                            'name': 'currencyType',
                            'label': 'Currency Type',
                            'data': this.state.currencyType,
                            'preferredChoices': ['USD', 'CAD', 'EUR'],
                            'placeholder': 'Please select ...'
                        }}
                        onChange={this.onChange}
                        onValidate={this.onValidate}
                    />
                    <TimezoneType
                        options={{
                            'name': 'timezoneType',
                            'label': 'Timezone Type',
                            'data': this.state.timezoneType,
                            'preferredChoices': ['Middle East Standard Time', 'E. Europe Standard Time', 'FLE Standard Time'],
                            'placeholder': 'Please select ...'
                        }}
                        onChange={this.onChange}
                        onValidate={this.onValidate}
                    />
                    <LocaleType
                        options={{
                            'name': 'localeType',
                            'nameType': 'nativeName',
                            'label': 'Locale Type',
                            'data': this.state.localeType,
                            'preferredChoices': ['de-CH', 'en-GB', 'fr-CA'],
                            'placeholder': 'Please select ...'
                        }}
                        onChange={this.onChange}
                        onValidate={this.onValidate}
                    />
                    <LanguageType
                        options={{
                            'name': 'languageType',
                            'nameType': 'name',
                            'label': 'Language Type',
                            'data': this.state.languageType,
                            'preferredChoices': ['FR', 'DE', 'EN'],
                            'placeholder': 'Please select ...'
                        }}
                        onChange={this.onChange}
                        onValidate={this.onValidate}
                    />
                    <CountryType
                        options={{
                            'name': 'countryType',
                            'nameType': 'name',
                            'label': 'Country Type',
                            'data': this.state.countryType,
                            'preferredChoices': ['AU', 'GB', 'US'],
                            'placeholder': 'Please select ...'
                        }}
                        onChange={this.onChange}
                        onValidate={this.onValidate}
                    />
                    <ChoiceType
                        options={{
                            'name': 'choiceType',
                            'label': 'Choice Type',
                            'data': this.state.choiceType,
                            'choices': [
                                {'key': 'AF', 'value': 'Afghanistan'},
                                {'key': 'AL', 'value': 'Albania'},
                                {'key': 'DZ', 'value': 'Algeria'},
                                {'key': 'AS', 'value': 'American Samoa'},
                                {'key': 'AD', 'value': 'Andorra'},
                                {'key': 'AO', 'value': 'Angola'},
                                {'key': 'AI', 'value': 'Anguilla'},
                                {'key': 'AQ', 'value': 'Antarctica'},
                                {'key': 'AG', 'value': 'Antigua & Barbuda'},
                                {'key': 'AR', 'value': 'Argentina'},
                                {'key': 'AM', 'value': 'Armenia'},
                                {'key': 'AW', 'value': 'Aruba'},
                                {'key': 'AC', 'value': 'Ascension Island'},
                                {'key': 'AU', 'value': 'Australia'},
                                {'key': 'AT', 'value': 'Austria'},
                                {'key': 'AZ', 'value': 'Azerbaijan'},
                                {'key': 'BS', 'value': 'Bahamas'}
                            ],
                            'preferredChoices': ['AT', 'AQ', 'BS'],
                            'attr': {
                                'style': {color: 'black'},
                                'itemStyle': {fontWeight: 'bold'}
                            },
                            'placeholder': 'Please select ...'
                        }}
                        onChange={this.onChange}
                        onValidate={this.onValidate}
                    />
                    <TextType
                        options={{'name': 'textType', 'label': 'Text Type', 'data': this.state.textType}}
                        onChange={this.onChange}
                        onValidate={this.onValidate}
                    />
                    <TextareaType
                        options={{'name': 'textareaType', 'label': 'Textarea Type', 'data': this.state.textareaType}}
                        onChange={this.onChange}
                        onValidate={this.onValidate}
                    />
                    <EmailType
                        options={{'name': 'emailType', 'label': 'Email Type', 'data': this.state.emailType}}
                        onChange={this.onChange}
                        onValidate={this.onValidate}
                    />
                    <PasswordType
                        options={{'name': 'passwordType', 'label': 'Password Type', 'data': this.state.passwordType}}
                        onChange={this.onChange}
                        onValidate={this.onValidate}
                    />
                    <UrlType
                        options={{'name': 'urlType', 'label': 'Url Type', 'data': this.state.urlType}}
                        onChange={this.onChange}
                        onValidate={this.onValidate}
                    />
                    <IntegerType
                        options={{'name': 'integerType', 'label': 'Integer Type', 'data': this.state.integerType}}
                        onChange={this.onChange}
                        onValidate={this.onValidate}
                    />
                    <NumberType
                        options={{'name': 'numberType', 'label': 'Number Type', 'data': this.state.numberType}}
                        onChange={this.onChange}
                        onValidate={this.onValidate}
                    />
                    <MoneyType
                        options={{'name': 'moneyType', 'label': 'Money Type', 'data': this.state.moneyType, 'currency': 'USD'}}
                        onChange={this.onChange}
                        onValidate={this.onValidate}
                    />
                    <PercentType
                        options={{'name': 'percentType', 'label': 'Percent Type', 'data': this.state.percentType}}
                        onChange={this.onChange}
                        onValidate={this.onValidate}
                    />
                    <RangeType
                        options={{'name': 'rangeType', 'label': 'Range Type', 'data': this.state.rangeType, 'minimumValue': 10, 'maximumValue': 100}}
                        onChange={this.onChange}
                        onValidate={this.onValidate}
                    />
                </View>
            </ScrollView>
        );
    }
}

export default ReactNativeBobForm;