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

react-checkbox-tree

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-checkbox-tree - npm Package Compare versions

Comparing version 0.3.0-rc.1 to 0.3.0-rc.2

.babelrc

145

lib/index.js

@@ -1,2 +0,2 @@

/*! react-checkbox-tree - v0.3.0-rc.1 | 2016 */
/*! react-checkbox-tree - v0.3.0-rc.1 | 2017 */
(function webpackUniversalModuleDefinition(root, factory) {

@@ -77,2 +77,4 @@ if(typeof exports === 'object' && typeof module === 'object')

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
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; }; }();

@@ -88,2 +90,6 @@

var _nodeShape = __webpack_require__(4);
var _nodeShape2 = _interopRequireDefault(_nodeShape);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -236,2 +242,3 @@

var treeNodes = nodes.map(function (node, index) {
var key = index + '-' + node.value;
var checked = _this6.getCheckState(node);

@@ -243,8 +250,8 @@ var children = _this6.renderChildNodes(node);

{
key: index,
value: node.value,
title: node.title,
key: key,
checked: checked,
expanded: node.expanded,
rawChildren: node.children,
title: node.title,
value: node.value,
onCheck: _this6.onCheck,

@@ -290,6 +297,6 @@ onExpand: _this6.onExpand

return this.props.checked.map(function (value, index) {
return this.props.checked.map(function (value) {
var name = _this7.props.name + '[]';
return _react2.default.createElement('input', { key: index, name: name, type: 'hidden', value: value });
return _react2.default.createElement('input', { key: value, name: name, type: 'hidden', value: value });
});

@@ -302,3 +309,3 @@ }

return _react2.default.createElement('input', { name: this.props.name, value: checked, type: 'hidden' });
return _react2.default.createElement('input', { name: this.props.name, type: 'hidden', value: checked });
}

@@ -324,10 +331,20 @@ }, {

Tree.propTypes = {
onCheck: _react2.default.PropTypes.func.isRequired,
onExpand: _react2.default.PropTypes.func.isRequired,
checked: _react2.default.PropTypes.arrayOf(_react2.default.PropTypes.string),
expanded: _react2.default.PropTypes.arrayOf(_react2.default.PropTypes.string),
name: _react2.default.PropTypes.string,
nameAsArray: _react2.default.PropTypes.bool,
nodes: _react2.default.PropTypes.array,
checked: _react2.default.PropTypes.array,
expanded: _react2.default.PropTypes.array,
onCheck: _react2.default.PropTypes.func,
onExpand: _react2.default.PropTypes.func
nodes: _react2.default.PropTypes.arrayOf(_react2.default.PropTypes.oneOfType([_react2.default.PropTypes.shape(_nodeShape2.default), _react2.default.PropTypes.shape(_extends({}, _nodeShape2.default, {
children: _react2.default.PropTypes.arrayOf(_nodeShape2.default)
}))]))
};
Tree.defaultProps = {
checked: [],
expanded: [],
name: undefined,
nameAsArray: false,
nodes: []
};
exports.default = Tree;

@@ -345,3 +362,3 @@

"use strict";
'use strict';

@@ -358,2 +375,6 @@ Object.defineProperty(exports, "__esModule", {

var _nodeShape = __webpack_require__(4);
var _nodeShape2 = _interopRequireDefault(_nodeShape);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -381,3 +402,3 @@

_createClass(TreeNode, [{
key: "onCheck",
key: 'onCheck',
value: function onCheck() {

@@ -398,3 +419,3 @@ var isChecked = 0;

}, {
key: "onExpand",
key: 'onExpand',
value: function onExpand() {

@@ -407,42 +428,42 @@ this.props.onExpand({

}, {
key: "renderCollapseIcon",
key: 'renderCollapseIcon',
value: function renderCollapseIcon() {
if (this.props.rawChildren === null) {
return _react2.default.createElement("i", { className: "fa" });
return _react2.default.createElement('i', { className: 'fa' });
}
if (!this.props.expanded) {
return _react2.default.createElement("i", { className: "fa fa-chevron-right" });
return _react2.default.createElement('i', { className: 'fa fa-chevron-right' });
}
return _react2.default.createElement("i", { className: "fa fa-chevron-down" });
return _react2.default.createElement('i', { className: 'fa fa-chevron-down' });
}
}, {
key: "renderCheckboxIcon",
key: 'renderCheckboxIcon',
value: function renderCheckboxIcon() {
if (this.props.checked === 0) {
return _react2.default.createElement("i", { className: "fa fa-square-o" });
return _react2.default.createElement('i', { className: 'fa fa-square-o' });
}
if (this.props.checked === 1) {
return _react2.default.createElement("i", { className: "fa fa-check-square-o" });
return _react2.default.createElement('i', { className: 'fa fa-check-square-o' });
}
return _react2.default.createElement("i", { className: "fa fa-check-square-o rct-half-checked" });
return _react2.default.createElement('i', { className: 'fa fa-check-square-o rct-half-checked' });
}
}, {
key: "renderNodeIcon",
key: 'renderNodeIcon',
value: function renderNodeIcon() {
if (this.props.rawChildren !== null) {
if (!this.props.expanded) {
return _react2.default.createElement("i", { className: "fa fa-folder-o" });
return _react2.default.createElement('i', { className: 'fa fa-folder-o' });
}
return _react2.default.createElement("i", { className: "fa fa-folder-open-o" });
return _react2.default.createElement('i', { className: 'fa fa-folder-open-o' });
}
return _react2.default.createElement("i", { className: "fa fa-file-o" });
return _react2.default.createElement('i', { className: 'fa fa-file-o' });
}
}, {
key: "renderChildren",
key: 'renderChildren',
value: function renderChildren() {

@@ -456,31 +477,31 @@ if (!this.props.expanded) {

}, {
key: "render",
key: 'render',
value: function render() {
return _react2.default.createElement(
"li",
{ className: "rct-node" },
'li',
{ className: 'rct-node' },
_react2.default.createElement(
"span",
{ className: "rct-text" },
'span',
{ className: 'rct-text' },
_react2.default.createElement(
"span",
{ className: "rct-collapse", onClick: this.onExpand, title: "Toggle" },
'span',
{ className: 'rct-collapse', title: 'Toggle', onClick: this.onExpand },
this.renderCollapseIcon()
),
_react2.default.createElement(
"label",
'label',
{ onClick: this.onCheck },
_react2.default.createElement(
"span",
{ className: "rct-checkbox" },
'span',
{ className: 'rct-checkbox' },
this.renderCheckboxIcon()
),
_react2.default.createElement(
"span",
{ className: "rct-icon" },
'span',
{ className: 'rct-icon' },
this.renderNodeIcon()
),
_react2.default.createElement(
"span",
{ className: "rct-title" },
'span',
{ className: 'rct-title' },
this.props.title

@@ -499,13 +520,39 @@ )

TreeNode.propTypes = {
checked: _react2.default.PropTypes.number.isRequired,
expanded: _react2.default.PropTypes.bool.isRequired,
title: _react2.default.PropTypes.string.isRequired,
value: _react2.default.PropTypes.string.isRequired,
onCheck: _react2.default.PropTypes.func.isRequired,
onExpand: _react2.default.PropTypes.func.isRequired,
children: _react2.default.PropTypes.node,
checked: _react2.default.PropTypes.number,
expanded: _react2.default.PropTypes.bool,
rawChildren: _react2.default.PropTypes.any,
onCheck: _react2.default.PropTypes.func,
onExpand: _react2.default.PropTypes.func,
title: _react2.default.PropTypes.string,
value: _react2.default.PropTypes.string
rawChildren: _react2.default.PropTypes.arrayOf(_react2.default.PropTypes.shape(_nodeShape2.default))
};
TreeNode.defaultProps = {
children: null,
rawChildren: undefined
};
exports.default = TreeNode;
/***/ },
/* 4 */
/***/ function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _react = __webpack_require__(2);
var _react2 = _interopRequireDefault(_react);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = {
value: _react2.default.PropTypes.oneOfType([_react2.default.PropTypes.string, _react2.default.PropTypes.number]),
title: _react2.default.PropTypes.string
};
/***/ }

@@ -512,0 +559,0 @@ /******/ ])

The MIT License (MIT)
Copyright (c) 2016 <Jake Zatecky>
Copyright (c) 2017 Jake Zatecky

@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy

{
"name": "react-checkbox-tree",
"version": "0.3.0-rc.1",
"version": "0.3.0-rc.2",
"description": "React component for checkbox trees.",

@@ -32,12 +32,12 @@ "author": "Jake Zatecky",

"chai": "^3.5.0",
"eslint": "^3.2.2",
"eslint-config-airbnb": "^12.0.0",
"eslint-plugin-import": "^1.13.0",
"eslint-plugin-jsx-a11y": "^2.1.0",
"eslint-plugin-react": "^6.0.0",
"eslint": "^3.13.0",
"eslint-config-airbnb": "^14.0.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^3.0.2",
"eslint-plugin-react": "^6.9.0",
"gulp": "^3.9.1",
"gulp-eslint": "^3.0.1",
"gulp-header": "^1.8.8",
"gulp-mocha-phantomjs": "^0.11.0",
"gulp-sass": "^2.3.2",
"gulp-mocha-phantomjs": "^0.12.0",
"gulp-sass": "^3.0.0",
"gulp-scss-lint": "^0.4.0",

@@ -44,0 +44,0 @@ "http-server": "^0.9.0",

import React from 'react';
import TreeNode from './TreeNode';
import nodeShape from './nodeShape';
class Tree extends React.Component {
static propTypes = {
onCheck: React.PropTypes.func.isRequired,
onExpand: React.PropTypes.func.isRequired,
checked: React.PropTypes.arrayOf(React.PropTypes.string),
expanded: React.PropTypes.arrayOf(React.PropTypes.string),
name: React.PropTypes.string,
nameAsArray: React.PropTypes.bool,
nodes: React.PropTypes.array,
checked: React.PropTypes.array,
expanded: React.PropTypes.array,
onCheck: React.PropTypes.func,
onExpand: React.PropTypes.func,
nodes: React.PropTypes.arrayOf(
React.PropTypes.oneOfType([
React.PropTypes.shape(nodeShape),
React.PropTypes.shape({
...nodeShape,
children: React.PropTypes.arrayOf(nodeShape),
}),
]),
),
};
static defaultProps = {
checked: [],
expanded: [],
name: undefined,
nameAsArray: false,
nodes: [],
};
constructor(props) {

@@ -125,2 +143,3 @@ super(props);

const treeNodes = nodes.map((node, index) => {
const key = `${index}-${node.value}`;
const checked = this.getCheckState(node);

@@ -131,8 +150,8 @@ const children = this.renderChildNodes(node);

<TreeNode
key={index}
value={node.value}
title={node.title}
key={key}
checked={checked}
expanded={node.expanded}
rawChildren={node.children}
title={node.title}
value={node.value}
onCheck={this.onCheck}

@@ -174,6 +193,6 @@ onExpand={this.onExpand}

renderArrayHiddenInput() {
return this.props.checked.map((value, index) => {
return this.props.checked.map((value) => {
const name = `${this.props.name}[]`;
return <input key={index} name={name} type="hidden" value={value} />;
return <input key={value} name={name} type="hidden" value={value} />;
});

@@ -185,3 +204,3 @@ }

return <input name={this.props.name} value={checked} type="hidden" />;
return <input name={this.props.name} type="hidden" value={checked} />;
}

@@ -188,0 +207,0 @@

import React from 'react';
import nodeShape from './nodeShape';
class TreeNode extends React.Component {
static propTypes = {
checked: React.PropTypes.number.isRequired,
expanded: React.PropTypes.bool.isRequired,
title: React.PropTypes.string.isRequired,
value: React.PropTypes.string.isRequired,
onCheck: React.PropTypes.func.isRequired,
onExpand: React.PropTypes.func.isRequired,
children: React.PropTypes.node,
checked: React.PropTypes.number,
expanded: React.PropTypes.bool,
rawChildren: React.PropTypes.any,
onCheck: React.PropTypes.func,
onExpand: React.PropTypes.func,
title: React.PropTypes.string,
value: React.PropTypes.string,
rawChildren: React.PropTypes.arrayOf(React.PropTypes.shape(nodeShape)),
};
static defaultProps = {
children: null,
rawChildren: undefined,
};
constructor(props) {

@@ -92,3 +100,3 @@ super(props);

<span className="rct-text">
<span className="rct-collapse" onClick={this.onExpand} title="Toggle">
<span className="rct-collapse" title="Toggle" onClick={this.onExpand}>
{this.renderCollapseIcon()}

@@ -95,0 +103,0 @@ </span>

@@ -31,5 +31,2 @@ module.exports = {

loader: 'babel',
query: {
presets: ['react', 'es2015', 'stage-0'],
},
},

@@ -36,0 +33,0 @@ ],

@@ -13,5 +13,2 @@ module.exports = {

loader: 'babel',
query: {
presets: ['react', 'es2015', 'stage-0'],
},
},

@@ -18,0 +15,0 @@ ],

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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