cf-component-checkbox
Advanced tools
Comparing version 1.0.5 to 2.0.0
'use strict'; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -16,40 +18,40 @@ | ||
function Checkbox() { | ||
var _temp, _this, _ret; | ||
_classCallCheck(this, Checkbox); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
return _possibleConstructorReturn(this, (Checkbox.__proto__ || Object.getPrototypeOf(Checkbox)).apply(this, arguments)); | ||
} | ||
_createClass(Checkbox, [{ | ||
key: 'handleChange', | ||
value: function handleChange(e) { | ||
this.props.onChange(e.target.checked); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var className = 'cf-checkbox'; | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.handleChange = function (e) { | ||
_this.props.onChange(e.target.checked); | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
} | ||
if (this.props.checked) { | ||
className += ' cf-checkbox--checked'; | ||
} | ||
Checkbox.prototype.render = function render() { | ||
var className = 'cf-checkbox'; | ||
if (this.props.checked) { | ||
className += ' cf-checkbox--checked'; | ||
return React.createElement( | ||
'label', | ||
{ htmlFor: this.props.name, className: className }, | ||
React.createElement('input', { type: 'checkbox', | ||
className: 'cf-checkbox__input', | ||
id: this.props.name, | ||
name: this.props.name, | ||
value: this.props.value, | ||
checked: this.props.checked, | ||
onChange: this.handleChange }), | ||
this.props.label && React.createElement( | ||
'span', | ||
{ className: 'cf-checkbox__label' }, | ||
this.props.label | ||
) | ||
); | ||
} | ||
}]); | ||
return React.createElement( | ||
'label', | ||
{ htmlFor: this.props.name, className: className }, | ||
React.createElement('input', { type: 'checkbox', | ||
className: 'cf-checkbox__input', | ||
id: this.props.name, | ||
name: this.props.name, | ||
value: this.props.value, | ||
checked: this.props.checked, | ||
onChange: this.handleChange }), | ||
this.props.label && React.createElement( | ||
'span', | ||
{ className: 'cf-checkbox__label' }, | ||
this.props.label | ||
) | ||
); | ||
}; | ||
return Checkbox; | ||
@@ -66,3 +68,2 @@ }(React.Component); | ||
module.exports = Checkbox; |
'use strict'; | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -18,13 +20,17 @@ | ||
function CheckboxGroup() { | ||
var _temp, _this, _ret; | ||
function CheckboxGroup(props) { | ||
_classCallCheck(this, CheckboxGroup); | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
var _this = _possibleConstructorReturn(this, (CheckboxGroup.__proto__ || Object.getPrototypeOf(CheckboxGroup)).call(this, props)); | ||
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _React$Component.call.apply(_React$Component, [this].concat(args))), _this), _this.handleChange = function (value, checked) { | ||
var values = _this.props.options.filter(function (option) { | ||
_this.handleChange = _this.handleChange.bind(_this); | ||
return _this; | ||
} | ||
_createClass(CheckboxGroup, [{ | ||
key: 'handleChange', | ||
value: function handleChange(value, checked) { | ||
var _this2 = this; | ||
var values = this.props.options.filter(function (option) { | ||
if (option.value === value) { | ||
@@ -34,3 +40,3 @@ return checked; | ||
return includes(_this.props.values, option.value); | ||
return includes(_this2.props.values, option.value); | ||
}).map(function (option) { | ||
@@ -40,26 +46,27 @@ return option.value; | ||
_this.props.onChange(values); | ||
}, _temp), _possibleConstructorReturn(_this, _ret); | ||
} | ||
this.props.onChange(values); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var _this3 = this; | ||
CheckboxGroup.prototype.render = function render() { | ||
var _this2 = this; | ||
return React.createElement( | ||
'div', | ||
{ className: 'cf-checkbox__group' }, | ||
this.props.options.map(function (option) { | ||
return React.createElement(Checkbox, { | ||
key: option.name, | ||
label: option.label, | ||
name: option.name, | ||
value: option.value, | ||
checked: includes(_this3.props.values, option.value), | ||
onChange: function onChange(val) { | ||
return _this3.handleChange(option.value, val); | ||
} }); | ||
}) | ||
); | ||
} | ||
}]); | ||
return React.createElement( | ||
'div', | ||
{ className: 'cf-checkbox__group' }, | ||
this.props.options.map(function (option) { | ||
return React.createElement(Checkbox, { | ||
key: option.name, | ||
label: option.label, | ||
name: option.name, | ||
value: option.value, | ||
checked: includes(_this2.props.values, option.value), | ||
onChange: function onChange(val) { | ||
return _this2.handleChange(option.value, val); | ||
} }); | ||
}) | ||
); | ||
}; | ||
return CheckboxGroup; | ||
@@ -78,3 +85,2 @@ }(React.Component); | ||
module.exports = CheckboxGroup; |
{ | ||
"name": "cf-component-checkbox", | ||
"description": "CloudFlare Checkbox Component", | ||
"version": "1.0.5", | ||
"version": "2.0.0", | ||
"main": "lib/index.js", | ||
@@ -13,8 +13,8 @@ "author": "James Kyle <jkyle@cloudflare.com>", | ||
"lodash": "^4.1.0", | ||
"react": "^0.14.2" | ||
"react": "^0.14.2 || ^15.0.0-0" | ||
}, | ||
"devDependencies": { | ||
"assert-equal-jsx": "^1.0.0", | ||
"react-dom": "^0.14.2" | ||
"react-dom": "^15.0.0-0" | ||
} | ||
} |
@@ -21,9 +21,13 @@ # cf-component-checkbox | ||
class Application extends React.Component { | ||
state = { | ||
checkbox1: true, | ||
checkbox2: false, | ||
checkboxValues: ["option1"] | ||
}; | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
checkbox1: true, | ||
checkbox2: false, | ||
checkboxValues: ["option1"] | ||
}; | ||
this.onCheckboxGroupChange = this.onCheckboxGroupChange.bind(this); | ||
} | ||
onCheckboxGroupChange = values => { | ||
onCheckboxGroupChange(values) { | ||
this.setState({ | ||
@@ -30,0 +34,0 @@ checkboxValues: values |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9103
121
81
1
+ Addedcreate-react-class@15.7.0(transitive)
+ Addedencoding@0.1.13(transitive)
+ Addedfbjs@0.8.18(transitive)
+ Addediconv-lite@0.6.3(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addedisomorphic-fetch@2.2.1(transitive)
+ Addednode-fetch@1.7.3(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedprop-types@15.8.1(transitive)
+ Addedreact@15.7.0(transitive)
+ Addedreact-is@16.13.1(transitive)
+ Addedsetimmediate@1.0.5(transitive)
+ Addedwhatwg-fetch@3.6.20(transitive)
- Removedacorn@5.7.4(transitive)
- Removedamdefine@1.0.1(transitive)
- Removedast-types@0.9.6(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbase62@1.2.8(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedcommander@2.20.3(transitive)
- Removedcommoner@0.10.8(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removeddefined@1.0.1(transitive)
- Removeddetective@4.7.1(transitive)
- Removedenvify@3.4.1(transitive)
- Removedesprima@3.1.3(transitive)
- Removedesprima-fb@15001.1.0-dev-harmony-fb(transitive)
- Removedfbjs@0.6.1(transitive)
- Removedglob@5.0.15(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removediconv-lite@0.4.24(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedjstransform@11.0.3(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedminimist@1.2.8(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removedobject-assign@2.1.1(transitive)
- Removedonce@1.4.0(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedprivate@0.1.8(transitive)
- Removedq@1.5.1(transitive)
- Removedreact@0.14.10(transitive)
- Removedrecast@0.11.23(transitive)
- Removedsource-map@0.4.40.5.7(transitive)
- Removedthrough@2.3.8(transitive)
- Removedwhatwg-fetch@0.9.0(transitive)
- Removedwrappy@1.0.2(transitive)
Updatedreact@^0.14.2 || ^15.0.0-0