Skip to content

Commit

Permalink
Merge pull request SpareBank1#20 in FFE/ffe-radio-button-react from m…
Browse files Browse the repository at this point in the history
…aster_use-prop-types-package to master

* commit '19a45f35b4b6d9b011b688d763318e7feabf0686':
  * Use PropTypes from prop-types package
  • Loading branch information
orhels committed Sep 6, 2017
2 parents adf6d5b + d41659e commit 520149e
Show file tree
Hide file tree
Showing 6 changed files with 119 additions and 78 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## v1.2.1
* Use PropTypes from prop-types package

## v1.2.0 (17.7.2017)
* Fixed: `aria-invalid` was not being set on `input`-elements.
* Removed `aria-invalid` from `RadioButtonGroup`s fieldset.
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ffe-radio-button-react",
"version": "1.2.0",
"version": "1.2.1",
"main": "lib/index.js",
"scripts": {
"build": "babel -d lib/. --ignore=*.test.js src/.",
Expand Down Expand Up @@ -52,6 +52,7 @@
"dependencies": {
"classnames": "^2.2.5",
"nfe-hash": "^1.1.0",
"prop-types": "*",
"react": "^15.0.1",
"react-dom": "^15.0.1"
}
Expand Down
46 changes: 28 additions & 18 deletions src/radio-base.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
import React, { Component, PropTypes } from 'react';
import React, { Component } from 'react';
import {
bool,
func,
node,
number,
object,
oneOf,
oneOfType,
string
} from 'prop-types';
import hash from 'nfe-hash';
import classnames from 'classnames';

Expand Down Expand Up @@ -95,23 +105,23 @@ class RadioBase extends Component {
}

RadioBase.propTypes = {
'aria-invalid': PropTypes.oneOf(['true', 'false', true, false]),
checked: PropTypes.bool,
children: PropTypes.node,
disabled: PropTypes.bool,
id: PropTypes.string,
inline: PropTypes.bool,
invalid: PropTypes.oneOf(['true', 'false', true, false]),
label: PropTypes.string,
labelClasses: PropTypes.string.isRequired,
name: PropTypes.string,
onChange: PropTypes.func,
style: PropTypes.object,
tooltip: PropTypes.string,
value: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.bool
'aria-invalid': oneOf(['true', 'false', true, false]),
checked: bool,
children: node,
disabled: bool,
id: string,
inline: bool,
invalid: oneOf(['true', 'false', true, false]),
label: string,
labelClasses: string.isRequired,
name: string,
onChange: func,
style: object,
tooltip: string,
value: oneOfType([
string,
number,
bool
]).isRequired,
};

Expand Down
54 changes: 32 additions & 22 deletions src/radio-button-group.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
import React, { Children, PropTypes } from 'react';
import React, { Children } from 'react';
import {
arrayOf,
bool,
func,
number,
oneOf,
oneOfType,
shape,
string
} from 'prop-types';
import RadioBase from './radio-base';
import RadioButton from './radio-button';

Expand Down Expand Up @@ -87,7 +97,7 @@ const RadioButtonGroup = (props) => {
};

RadioButtonGroup.propTypes = {
'aria-invalid': PropTypes.oneOf(['true', 'false', true, false]),
'aria-invalid': oneOf(['true', 'false', true, false]),
children: (props, name) => {
const children = Children.toArray(props[name]);
const allowedTypes = [RadioButton, RadioBase];
Expand All @@ -97,28 +107,28 @@ RadioButtonGroup.propTypes = {
);
}
},
buttons: PropTypes.arrayOf(PropTypes.shape({
value: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.bool
buttons: arrayOf(shape({
value: oneOfType([
string,
number,
bool
]).isRequired,
label: PropTypes.string.isRequired,
name: PropTypes.string,
inline: PropTypes.bool,
checked: PropTypes.bool,
disabled: PropTypes.bool,
onChange: PropTypes.func
label: string.isRequired,
name: string,
inline: bool,
checked: bool,
disabled: bool,
onChange: func
})),
disabled: PropTypes.bool,
invalid: PropTypes.oneOf(['true', 'false', true, false]),
label: PropTypes.string,
name: PropTypes.string,
onChange: PropTypes.func,
value: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.bool
disabled: bool,
invalid: oneOf(['true', 'false', true, false]),
label: string,
name: string,
onChange: func,
value: oneOfType([
string,
number,
bool
]),
};

Expand Down
34 changes: 21 additions & 13 deletions src/radio-button.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
import React, { Component, PropTypes } from 'react';
import React, { Component } from 'react';
import {
bool,
func,
number,
oneOf,
oneOfType,
string
} from 'prop-types';

import RadioBase from './radio-base';

Expand All @@ -20,18 +28,18 @@ class RadioButton extends Component {
}

RadioButton.propTypes = {
'aria-invalid': PropTypes.oneOf(['true', 'false', true, false]),
checked: PropTypes.bool,
disabled: PropTypes.bool,
inline: PropTypes.bool,
invalid: PropTypes.oneOf(['true', 'false', true, false]),
label: PropTypes.string,
name: PropTypes.string,
onChange: PropTypes.func,
value: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.bool
'aria-invalid': oneOf(['true', 'false', true, false]),
checked: bool,
disabled: bool,
inline: bool,
invalid: oneOf(['true', 'false', true, false]),
label: string,
name: string,
onChange: func,
value: oneOfType([
string,
number,
bool
]).isRequired,
};

Expand Down
57 changes: 33 additions & 24 deletions src/radio-switch.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
import React, { PropTypes } from 'react';

import React from 'react';
import {
oneOf,
bool,
shape,
node,
oneOfType,
string,
number,
func
} from 'prop-types';
import RadioButtonGroup from './radio-button-group';
import RadioBase from './radio-base';

Expand Down Expand Up @@ -37,32 +46,32 @@ const RadioSwitch = (props) => {
};

RadioSwitch.propTypes = {
'aria-invalid': PropTypes.oneOf(['true', 'false', true, false]),
disabled: PropTypes.bool,
firstOption: PropTypes.shape({
label: PropTypes.node.isRequired,
value: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.bool
'aria-invalid': oneOf(['true', 'false', true, false]),
disabled: bool,
firstOption: shape({
label: node.isRequired,
value: oneOfType([
string,
number,
bool
]).isRequired,
}).isRequired,
invalid: PropTypes.oneOf(['true', 'false', true, false]),
label: PropTypes.string,
lastOption: PropTypes.shape({
label: PropTypes.node.isRequired,
value: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.bool
invalid: oneOf(['true', 'false', true, false]),
label: string,
lastOption: shape({
label: node.isRequired,
value: oneOfType([
string,
number,
bool
]).isRequired,
}).isRequired,
name: PropTypes.string,
onChange: PropTypes.func,
value: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number,
PropTypes.bool
name: string,
onChange: func,
value: oneOfType([
string,
number,
bool
]),
};

Expand Down

0 comments on commit 520149e

Please sign in to comment.