Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cf-component-checkbox

Package Overview
Dependencies
Maintainers
9
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cf-component-checkbox - npm Package Compare versions

Comparing version 1.0.5 to 2.0.0

65

lib/Checkbox.js
'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

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