-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #321 from appfolio/addressInputSelects
Replace AddressInput Selects
- Loading branch information
Showing
11 changed files
with
378 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Input from './Input'; | ||
import COUNTRIES from './address/Countries.js'; // TODO i18n country names based on locale | ||
|
||
export default class CountryInput extends React.Component { | ||
static propTypes = { | ||
className: PropTypes.string, | ||
disabled: PropTypes.bool, | ||
id: PropTypes.string, | ||
name: PropTypes.string, | ||
onChange: PropTypes.func, | ||
placeholder: PropTypes.string, | ||
value: PropTypes.string | ||
} | ||
|
||
static defaultProps = { | ||
onChange: () => {} | ||
} | ||
|
||
render() { | ||
const { | ||
className, | ||
disabled, | ||
id, | ||
name, | ||
onChange, | ||
placeholder, | ||
...props | ||
} = this.props; | ||
|
||
return ( | ||
<Input | ||
type="select" | ||
{...props} | ||
className={className} | ||
disabled={disabled} | ||
id={id} | ||
name={name} | ||
onChange={e => onChange(e.target.value === '' ? null : e.target.value)} | ||
> | ||
<option value="">{placeholder}</option> | ||
{COUNTRIES.map(country => | ||
<option value={country.value} key={country.value}>{country.label}</option>)} | ||
</Input> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Input from './Input'; | ||
import STATES from './address/USStates.js'; // TODO Dynamic states based on country | ||
|
||
export default class StateInput extends React.Component { | ||
static propTypes = { | ||
className: PropTypes.string, | ||
disabled: PropTypes.bool, | ||
id: PropTypes.string, | ||
name: PropTypes.string, | ||
onChange: PropTypes.func, | ||
placeholder: PropTypes.string, | ||
value: PropTypes.string | ||
} | ||
|
||
static defaultProps = { | ||
onChange: () => {} | ||
} | ||
|
||
render() { | ||
const { | ||
className, | ||
disabled, | ||
id, | ||
name, | ||
onChange, | ||
placeholder, | ||
...props | ||
} = this.props; | ||
|
||
return ( | ||
<Input | ||
type="select" | ||
{...props} | ||
className={className} | ||
disabled={disabled} | ||
id={id} | ||
name={name} | ||
onChange={e => onChange(e.target.value === '' ? null : e.target.value)} | ||
> | ||
<option value="">{placeholder}</option> | ||
{STATES.map(state => | ||
<option title={state.label} value={state.value} key={state.value}>{state.value}</option>)} | ||
</Input> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.