0.2.1 • Published 6 years ago

react-intl-input v0.2.1

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

react-intl-input

A flexible input control for React to handle multi languages fields.

Travis npm package Coveralls

Installation

npm install --save react-intl-input

Then you can import one of react-intl-input components as follows:

import { IntlInput } from 'react-intl-input';

Features

  • Can be used standalone
  • Works with redux-form
  • Easy customization

Basic usage

import { IntlInput } from 'react-intl-input';

class Form extends React.Component {

  constructor(props) {
    super(props);
    this.state = {
      languages: [
       { value: 'en', label: 'English' },
       { value: 'fr', label: 'French' },
      ],
      initialValues: {
        en: 'This is an english translation',
        fr: 'Ceci est un texte en francais',
      },
    }
  }

  render() {
    return (
      <form onSubmit={() => {}}>
        <IntlInput
          name="basic-intl-input"
          {...this.state}
        />
      </form>
    )
  }
}

Demo & Examples

Live demo with many concrete examples: papswell.github.io/react-intl-input

Props

PropertyTypeDefaultDescription
namestring (required)The name attribute of the html input.
languagesarray (required)The languages handled by the input
initialLangstringThe language selected on the first render
initialValuesobjectThe initial values for each language
onLangChangefuncCalled whenever the language selection changes. onLangChange({ value, label}, state)
onInputChangefuncCalled whenever the current value changes. onInputChange(currentLanguage, inputValue, state)
onInputFocusfuncCalled when the input is focused. onInputFocus(syntheticEvent)
onInputBlurfuncCalled when the input is blurred. onInputChange(syntheticEvent)
inputComponentfuncA function or a React.Component to be used as the input.
0.2.1

6 years ago

0.2.0

6 years ago

0.1.1

6 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago