0.0.1 • Published 9 years ago

react-form-inputs v0.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
9 years ago

react-form-inputs

npm version Build Status

Synposis

react-form-inputs is a baseline collection of pluggable input components for react-form.

Components

NameTypeBrowser SupportDetails on PropsValid initial valuesComments
BaseInternalAll browsersPass-through to inputString-like valuesShim for other components. Should not be used directly.
BooleanExtendedAll browsersOptional checkedValue, uncheckedValuetrue, false, "true", "false", 1, 0Creates both a hidden input (uncheckedValue) and a checkbox input (checkedValue). Servers accepting POSTs must always use the last-encoded value.
CheckboxArrayAll browsersRequires collection (object or array)Array of String-like valuesCreates a consistently-named checkbox input for each array item or key-value pair in collection. Value is always an array.
ColorStandard (HTML5)Modern browsersPass-through to inputHex color strings
DatalistArrayModern browsersPass-through to input, requires array collectionString-like valuesCreates a datalist and accompanying input field. Collection must be an array of String-like values.
DateStandard (HTML5)Modern browsersPass-through to inputDate strings
DatetimeStandard (HTML5)Modern browsersPass-through to inputDatetime-local stringsUses datetime-local for greater browser compatibility.
EmailStandard (HTML5)Modern browsersPass-through to inputValid email strings
HiddenStandardAll browsersPass-through to inputString-like values
NumberExtendedAll browsersPass-through to input, pattern (regex string)Numeric String-like valuesImplemented using an enhanced "text" input. Does not allow entry of non-numeric characters. Decimals okay.
PasswordStandardAll browsersPass-through to inputString-like values
RadioArrayAll browsersRequires collection (object or array)String-like values (within collection)Creates a label and matching radio button for each array item or key-value pair in collection. Value is always a single value contained within collection.
RangeStandard (HTML5)Modern browsersPass-through to input, min, max, stepNumeric String-like values
SearchStandard (HTML5)Modern browsersPass-through to inputString-like values
SelectArrayAll browsersRequires collection (object or array), optional multiple (boolean)String-like values (within collection)Creates a select or multi-select with an option for each array item or key-value pair in collection. If props.multiple=true, value is always an array of value(s) from collection, else value is a single , non-array value from collection.
TextStandardAll browsersPass-through to inputString-like valuesStandard, work-horse input component
TextareaStandardAll browsersPass-through to textareaString-like values
TimeStandard (HTML5)Modern browsersPass-through to inputString time (HH:MM) values

A note on array-type (collection) components

Any array-type component accepting a collection consisting of an object or array will behave similarly.

If collection is an array of values: those values will be used for both the visible label and underlying "value" used for selection/form submission.

If collection is an object (key-value pairs): object keys will be visible to users, object values will be used as the underlying "value" used for selection/form submission.

Tips

  • To reduce over-the-wire payload, only require specific components:
    var Text = require('react-form-inputs/text');

Developing

Install gulp, dependencies:

npm install -g gulp
npm install

Build it!:

#To build once:
gulp build

#To watch and rebuild on changes:
gulp watch

Link dependent project to ./dist/:

#Within dependent project directory...
npm link ~/path-to-react-form-inputs/dist/

Contributing

  • Fork the project.
  • Create a descriptively-named branch for your changes. (fix_whatever, add_this)
  • Commit your change.
  • Add appropriate documentation, test coverage.
  • Test with "npm test" (requires jest-cli).
  • Issue a pull request for your branch.

License

react-form-inputs is released under the MIT License.