Socket
Socket
Sign inDemoInstall

react-country-region-selector

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-country-region-selector - npm Package Compare versions

Comparing version 1.0.4 to 1.1.0

.publish/bundle.js

29

examples/src/examples.js

@@ -71,3 +71,3 @@ import React from 'react';

country={this.getCountryValue(2)}
region={this.getRegionValue(2)}
value={this.getRegionValue(2)}
onChange={(val) => this.selectRegion(2, val)} />

@@ -78,3 +78,3 @@ </div>

codeVisible: false,
code: '&lt;CountryDropdown\n showDefaultOption={false}\n value={country}\n onChange={selectCountry} />\n&lt;RegionDropdown\n showDefaultOption={false}\n country={country}\n region={region}\n onChange={selectRegion} />',
code: '&lt;CountryDropdown\n showDefaultOption={false}\n value={country}\n onChange={selectCountry} />\n&lt;RegionDropdown\n showDefaultOption={false}\n country={country}\n value={region}\n onChange={selectRegion} />',
country: '',

@@ -203,3 +203,28 @@ region: ''

region: ''
},
{
label: 'Explicitly disabling the country and region dropdowns (with defaults).',
jsx: () => {
return (
<div>
<CountryDropdown
value={this.getCountryValue(8)}
onChange={(val) => this.selectCountry(8, val)}
blacklist={['AF','AX','AL','DZ','AS','AD','AO','AI','AQ','AG','AR','AM','AW','AU','AT','AZ']}
disabled={true} />
<RegionDropdown
country={this.getCountryValue(8)}
value={this.getRegionValue(8)}
onChange={(val) => this.selectRegion(8, val)}
disabled={true} />
</div>
);
},
codeVisible: false,
code: "&lt;CountryDropdown\n value=\"United States\"\n onChange={selectCountry}\n disabled={true} />\n&lt;RegionDropdown\n country={country}\n value=\"Washington\"\n onChange={selectRegion}\n disabled={true} />",
country: 'United States',
region: 'Washington'
}
]

@@ -206,0 +231,0 @@ };

17

lib/rcrs.js

@@ -95,2 +95,3 @@ 'use strict';

var _onChange = _props3.onChange;
var disabled = _props3.disabled;

@@ -102,3 +103,4 @@ var attrs = {

return _onChange(e.target.value);
}
},
disabled: disabled
};

@@ -135,3 +137,4 @@ if (id) {

whitelist: _propTypes2['default'].array,
blacklist: _propTypes2['default'].array
blacklist: _propTypes2['default'].array,
disabled: _propTypes2['default'].bool
};

@@ -149,3 +152,4 @@ CountryDropdown.defaultProps = {

whitelist: [],
blacklist: []
blacklist: [],
disabled: false
};

@@ -267,5 +271,6 @@

var classes = _props6.classes;
var disabled = _props6.disabled;
var disableWhenEmpty = _props6.disableWhenEmpty;
var disabled = disableWhenEmpty && country == '';
var isDisabled = disabled || disableWhenEmpty && country == '';
var attrs = {

@@ -277,3 +282,3 @@ name: name,

},
disabled: disabled
disabled: isDisabled
};

@@ -311,2 +316,3 @@ if (id) {

valueType: _propTypes2['default'].string,
disabled: _propTypes2['default'].bool,
disableWhenEmpty: _propTypes2['default'].bool

@@ -327,2 +333,3 @@ };

valueType: C.DISPLAY_TYPE_FULL,
disabled: false,
disableWhenEmpty: false

@@ -329,0 +336,0 @@ };

@@ -10,2 +10,5 @@ ### Notes for me

To see the example, boot up a server and just view the dist files, e.g.
`http://localhost:8888/react-country-region-selector/examples/dist/`
Note: there's an issue with the synchronous gulp process not being sync. It should process the custom build file

@@ -12,0 +15,0 @@ first (i.e. generate the src/source-data.js file first) then package it up. Until this is fixed, do it manually:

{
"name": "react-country-region-selector",
"version": "1.0.4",
"version": "1.1.0",
"description": "CountryDropdown and RegionDropdown React components for your forms.",

@@ -43,4 +43,4 @@ "main": "lib/rcrs.js",

"prop-types": "^15.5.8",
"react": "^15.1.0",
"react-dom": "^15.1.0",
"react": "^15.5.4",
"react-dom": "^15.5.4",
"reactify": "^1.1.1"

@@ -47,0 +47,0 @@ },

@@ -206,4 +206,4 @@ # React-Country-Region-Selector

| blacklist | No | `[]` | `array` | Lets you target countries that should *not* appear in the dropdown. Should also be an array of country shortcodes. |
| disabled | No | `false` | `boolean` | Disables the country field. |
```<RegionDropdown />```

@@ -213,3 +213,3 @@

|:---|:---:|:---|:---|:---|
| countryValue | Yes | `""` | `string` | The currently selected country. |
| country | Yes | `""` | `string` | The currently selected country. |
| value | Yes | `""` | `string` | The currently selected region. |

@@ -228,2 +228,3 @@ | onChange | Yes | - | `function` | Callback that gets called when the user selects a region. Use this to store the value in whatever store you're using (or just the parent component state). |

| disableWhenEmpty | No | `false` | `boolean` | Disables the region field when the user hasn't selected a country. |
| disabled | No | `false` | `boolean` | Disables the region field. If set to true, it overrides `disableWhenEmpty` |

@@ -256,2 +257,3 @@

- `1.1.0` - May 18, 2017 - dependency updates. `disabled` option added to `<CountryDropdown />` and `<RegionDropdown />`.
- `1.0.4` - April 12, 2017 - bug fix. Thanks @bebbi and @tchaffee!

@@ -258,0 +260,0 @@ - `1.0.3` - Jan 2, 2016 - updated country-region-data, repo link fix.

@@ -44,7 +44,8 @@ import React from 'react';

render () {
const { name, id, classes, value, onChange } = this.props;
const { name, id, classes, value, onChange, disabled } = this.props;
const attrs = {
name,
value,
onChange: (e) => onChange(e.target.value)
onChange: (e) => onChange(e.target.value),
disabled
};

@@ -77,3 +78,4 @@ if (id) {

whitelist: PropTypes.array,
blacklist: PropTypes.array
blacklist: PropTypes.array,
disabled: PropTypes.bool
};

@@ -91,3 +93,4 @@ CountryDropdown.defaultProps = {

whitelist: [],
blacklist: []
blacklist: [],
disabled: false
};

@@ -158,4 +161,4 @@

render () {
const { value, country, onChange, id, name, classes, disableWhenEmpty } = this.props;
const disabled = (disableWhenEmpty && country == '');
const { value, country, onChange, id, name, classes, disabled, disableWhenEmpty } = this.props;
const isDisabled = disabled || (disableWhenEmpty && country == '');
const attrs = {

@@ -165,3 +168,3 @@ name,

onChange: (e) => onChange(e.target.value),
disabled
disabled: isDisabled
};

@@ -195,2 +198,3 @@ if (id) {

valueType: PropTypes.string,
disabled: PropTypes.bool,
disableWhenEmpty: PropTypes.bool

@@ -211,2 +215,3 @@ };

valueType: C.DISPLAY_TYPE_FULL,
disabled: false,
disableWhenEmpty: false

@@ -213,0 +218,0 @@ };

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc