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

react-bootstrap

Package Overview
Dependencies
Maintainers
1
Versions
219
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-bootstrap - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

amd.js

10

amd/transpiled/Alert.js
define(
["./BootstrapMixin","exports"],
function(__dependency1__, __exports__) {
["./react-es6","./react-es6/lib/cx","./BootstrapMixin","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
"use strict";
/** @jsx React.DOM */
var React = require('react');
var classSet = require('react/lib/cx');
var BootstrapMixin = __dependency1__["default"];
var React = __dependency1__["default"];
var classSet = __dependency2__["default"];
var BootstrapMixin = __dependency3__["default"];

@@ -11,0 +11,0 @@

define(
["./constants","exports"],
function(__dependency1__, __exports__) {
["./react-es6","./constants","exports"],
function(__dependency1__, __dependency2__, __exports__) {
"use strict";
var React = require('react');
var constants = __dependency1__["default"];
var React = __dependency1__["default"];
var constants = __dependency2__["default"];

@@ -8,0 +8,0 @@ var BootstrapMixin = {

define(
["./BootstrapMixin","exports"],
function(__dependency1__, __exports__) {
["./react-es6","./react-es6/lib/cx","./BootstrapMixin","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
"use strict";
/** @jsx React.DOM */
var React = require('react');
var classSet = require('react/lib/cx');
var BootstrapMixin = __dependency1__["default"];
var React = __dependency1__["default"];
var classSet = __dependency2__["default"];
var BootstrapMixin = __dependency3__["default"];

@@ -15,3 +15,4 @@ var Button = React.createClass({displayName: 'Button',

propTypes: {
loadingChildren: React.PropTypes.renderable,
// TODO: Uncompatable with React 0.8.0
//loadingChildren: React.PropTypes.renderable,
isLoading: React.PropTypes.bool,

@@ -18,0 +19,0 @@ isActive: React.PropTypes.bool,

define(
["./BootstrapMixin","exports"],
function(__dependency1__, __exports__) {
["./react-es6","./react-es6/lib/cx","./BootstrapMixin","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
"use strict";
/** @jsx React.DOM */
var React = require('react');
var classSet = require('react/lib/cx');
var BootstrapMixin = __dependency1__["default"];
var React = __dependency1__["default"];
var classSet = __dependency2__["default"];
var BootstrapMixin = __dependency3__["default"];

@@ -11,0 +11,0 @@ var CollapsePanel = React.createClass({displayName: 'CollapsePanel',

@@ -14,3 +14,4 @@ define(

'form': 'form',
'panel': 'panel'
'panel': 'panel',
'nav': 'nav'
},

@@ -25,3 +26,5 @@ STYLES: {

'link': 'link',
'inline': 'inline'
'inline': 'inline',
'tabs': 'tabs',
'pills': 'pills'
},

@@ -28,0 +31,0 @@ SIZES: {

define(
["./Button","./BootstrapMixin","./utils","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
["./react-es6","./react-es6/lib/cx","./Button","./BootstrapMixin","./utils","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __exports__) {
"use strict";
/** @jsx React.DOM */
var React = require('react');
var classSet = require('react/lib/cx');
var Button = __dependency1__["default"];
var BootstrapMixin = __dependency2__["default"];
var utils = __dependency3__["default"];
var React = __dependency1__["default"];
var classSet = __dependency2__["default"];
var Button = __dependency3__["default"];
var BootstrapMixin = __dependency4__["default"];
var utils = __dependency5__["default"];

@@ -88,13 +88,2 @@

var menuItems = this.props.children
.map(function (child, i) {
return utils.cloneWithProps(
child,
{
onSelect: this.handleOptionSelect.bind(this, i)
}
);
}, this);
var title = this.props.isTitleHidden ?

@@ -105,18 +94,27 @@ React.DOM.span( {className:"sr-only"}, this.props.title) : this.props.title;

React.DOM.div( {className:groupClassName},
Button(
{id:this.props.id,
ref:"button",
className:className,
onClick:this.handleClick},
title,' ',React.DOM.span( {className:"caret"} )
),
React.DOM.ul(
{className:"dropdown-menu",
role:"menu",
ref:"menu",
'aria-labelledby':this.props.id},
menuItems
)
Button(
{id:this.props.id,
ref:"button",
className:className,
onClick:this.handleClick},
title,' ',React.DOM.span( {className:"caret"} )
),
React.DOM.ul(
{className:"dropdown-menu",
role:"menu",
ref:"menu",
'aria-labelledby':this.props.id},
utils.modifyChildren(this.props.children, this.renderMenuItem)
)
)
);
},
renderMenuItem: function (child, i) {
return utils.cloneWithProps(
child,
{
onSelect: this.handleOptionSelect.bind(this, i)
}
);
}

@@ -123,0 +121,0 @@ });

define(
["exports"],
function(__exports__) {
["./react-es6","./react-es6/lib/cx","exports"],
function(__dependency1__, __dependency2__, __exports__) {
"use strict";
/** @jsx React.DOM */
var React = require('react');
var classSet = require('react/lib/cx');
var React = __dependency1__["default"];
var classSet = __dependency2__["default"];

@@ -10,0 +10,0 @@ var INPUT_TYPES = [

define(
["exports"],
function(__exports__) {
["./react-es6","exports"],
function(__dependency1__, __exports__) {
"use strict";
/** @jsx React.DOM */
var React = require('react');
var React = __dependency1__["default"];

@@ -9,0 +9,0 @@ var MenuItem = React.createClass({displayName: 'MenuItem',

define(
["./BootstrapMixin","./Button","./DropdownButton","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
["./react-es6","./react-es6/lib/cx","./BootstrapMixin","./Button","./DropdownButton","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __exports__) {
"use strict";
/** @jsx React.DOM */
var React = require('react');
var classSet = require('react/lib/cx');
var BootstrapMixin = __dependency1__["default"];
var Button = __dependency2__["default"];
var DropdownButton = __dependency3__["default"];
var React = __dependency1__["default"];
var classSet = __dependency2__["default"];
var BootstrapMixin = __dependency3__["default"];
var Button = __dependency4__["default"];
var DropdownButton = __dependency5__["default"];

@@ -17,4 +17,5 @@ var SplitButton = React.createClass({displayName: 'SplitButton',

propTypes: {
title: React.PropTypes.renderable.isRequired,
dropdownTitle: React.PropTypes.renderable,
// TODO: Uncompatable with React 0.8.0
//title: React.PropTypes.renderable.isRequired,
//dropdownTitle: React.PropTypes.renderable,
bsVariation: React.PropTypes.oneOf(['dropup']),

@@ -21,0 +22,0 @@ isInInputGroup: React.PropTypes.bool,

define(
["exports"],
function(__exports__) {
["./react-es6","./react-es6/lib/cx","exports"],
function(__dependency1__, __dependency2__, __exports__) {
"use strict";
/** @jsx React.DOM */
var React = require('react');
var classSet = require('react/lib/cx');
var React = __dependency1__["default"];
var classSet = __dependency2__["default"];

@@ -10,0 +10,0 @@ var Tab = React.createClass({displayName: 'Tab',

define(
["./BootstrapMixin","./utils","./Tab","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __exports__) {
["./react-es6","./BootstrapMixin","./utils","./Nav","./NavItem","exports"],
function(__dependency1__, __dependency2__, __dependency3__, __dependency4__, __dependency5__, __exports__) {
"use strict";
/** @jsx React.DOM */
var React = require('react');
var BootstrapMixin = __dependency1__["default"];
var utils = __dependency2__["default"];
var Tab = __dependency3__["default"];
var React = __dependency1__["default"];
var BootstrapMixin = __dependency2__["default"];
var utils = __dependency3__["default"];
var Nav = __dependency4__["default"];
var NavItem = __dependency5__["default"];

@@ -34,8 +35,5 @@ var TabbedArea = React.createClass({displayName: 'TabbedArea',

render: function () {
var children = this.props.children;
var activeKey =
this.props.activeKey != null ? this.props.activeKey : this.state.activeKey;
if (!Array.isArray(children)) {
children = [children]
}
function hasTab (child) {

@@ -47,7 +45,7 @@ return !!child.props.tab;

React.DOM.div(null,
React.DOM.ul( {className:"nav nav-tabs", ref:"tabs"},
children.filter(hasTab).map(this.renderTab)
Nav( {bsStyle:"tabs", activeKey:activeKey, onSelect:this.handleSelect, ref:"tabs"},
utils.modifyChildren(utils.filterChildren(this.props.children, hasTab), this.renderTab)
),
React.DOM.div( {id:this.props.id, ref:"panes"},
children.map(this.renderPane)
React.DOM.div( {id:this.props.id, className:"tab-content", ref:"panes"},
utils.modifyChildren(this.props.children, this.renderPane)
)

@@ -70,12 +68,7 @@ )

renderTab: function (child) {
var activeKey =
this.props.activeKey != null ? this.props.activeKey : this.state.activeKey;
var key = child.props.key;
return (
Tab(
{id:child.props.id,
ref:'tab' + key,
key:key,
isActive:key === activeKey,
onSelect:this.handleSelect.bind(this, key)},
NavItem(
{ref:'tab' + key,
key:key},
child.props.tab

@@ -82,0 +75,0 @@ )

define(
["exports"],
function(__exports__) {
["./react-es6","./react-es6/lib/cx","exports"],
function(__dependency1__, __dependency2__, __exports__) {
"use strict";
/** @jsx React.DOM */
var React = require('react');
var classSet = require('react/lib/cx');
var React = __dependency1__["default"];
var classSet = __dependency2__["default"];

@@ -14,3 +14,3 @@ var TabPane = React.createClass({displayName: 'TabPane',

'tab-pane': true,
'open': this.props.isActive
'active': this.props.isActive
};

@@ -17,0 +17,0 @@

define(
["exports"],
function(__exports__) {
["./react-es6/lib/ReactPropTransferer","exports"],
function(__dependency1__, __exports__) {
"use strict";
var ReactPropTransferer = require('react/lib/ReactPropTransferer');
var ReactPropTransferer = __dependency1__["default"];

@@ -10,2 +10,63 @@ __exports__["default"] = {

/**
* Modify each item in a React children array without
* unnecessarily allocating a new array.
*
* @param {array|object} children
* @param {function} modifier
* @returns {*}
*/
modifyChildren: function (children, modifier) {
if (children == null) {
return children;
}
return Array.isArray(children) ? children.map(modifier) : modifier(children, 0);
},
/**
* Filter each item in a React children array without
* unnecessarily allocating a new array.
*
* @param {array|object} children
* @param {function} filter
* @returns {*}
*/
filterChildren: function (children, filter) {
if (children == null) {
return children;
}
if (Array.isArray(children)) {
return children.filter(filter);
} else {
return filter(children, 0) ? children : null;
}
},
/**
* Safe chained function
*
* Will only create a new function if needed,
* otherwise will pass back existing functions or null.
*
* @param {function} one
* @param {function} two
* @returns {function|null}
*/
createChainedFunction: function (one, two) {
var hasOne = typeof one === 'function';
var hasTwo = typeof two === 'function';
if (!hasOne && !hasTwo) { return null; }
if (!hasOne) { return two; }
if (!hasTwo) { return one; }
return function chainedFunction() {
one.apply(this, arguments);
two.apply(this, arguments);
};
},
/**
* Sometimes you want to change the props of a child passed to you. Usually

@@ -12,0 +73,0 @@ * this is to add a CSS class.

{
"name": "react-bootstrap",
"version": "0.2.0",
"version": "0.3.0",
"main": [
"dist/react-bootstrap.min.js",
"amd.js"
],
"ignore": []
}
"use strict";
/** @jsx React.DOM */
var React = require('react');
var classSet = require('react/lib/cx');
var React = require("./react-es6")["default"];
var classSet = require("./react-es6/lib/cx")["default"];
var BootstrapMixin = require("./BootstrapMixin")["default"];

@@ -7,0 +7,0 @@

"use strict";
var React = require('react');
var React = require("./react-es6")["default"];
var constants = require("./constants")["default"];

@@ -4,0 +4,0 @@

"use strict";
/** @jsx React.DOM */
var React = require('react');
var classSet = require('react/lib/cx');
var React = require("./react-es6")["default"];
var classSet = require("./react-es6/lib/cx")["default"];
var BootstrapMixin = require("./BootstrapMixin")["default"];

@@ -12,3 +12,4 @@

propTypes: {
loadingChildren: React.PropTypes.renderable,
// TODO: Uncompatable with React 0.8.0
//loadingChildren: React.PropTypes.renderable,
isLoading: React.PropTypes.bool,

@@ -15,0 +16,0 @@ isActive: React.PropTypes.bool,

"use strict";
/** @jsx React.DOM */
var React = require('react');
var classSet = require('react/lib/cx');
var React = require("./react-es6")["default"];
var classSet = require("./react-es6/lib/cx")["default"];
var BootstrapMixin = require("./BootstrapMixin")["default"];

@@ -7,0 +7,0 @@

@@ -11,3 +11,4 @@ "use strict";

'form': 'form',
'panel': 'panel'
'panel': 'panel',
'nav': 'nav'
},

@@ -22,3 +23,5 @@ STYLES: {

'link': 'link',
'inline': 'inline'
'inline': 'inline',
'tabs': 'tabs',
'pills': 'pills'
},

@@ -25,0 +28,0 @@ SIZES: {

"use strict";
/** @jsx React.DOM */
var React = require('react');
var classSet = require('react/lib/cx');
var React = require("./react-es6")["default"];
var classSet = require("./react-es6/lib/cx")["default"];
var Button = require("./Button")["default"];

@@ -85,13 +85,2 @@ var BootstrapMixin = require("./BootstrapMixin")["default"];

var menuItems = this.props.children
.map(function (child, i) {
return utils.cloneWithProps(
child,
{
onSelect: this.handleOptionSelect.bind(this, i)
}
);
}, this);
var title = this.props.isTitleHidden ?

@@ -102,18 +91,27 @@ React.DOM.span( {className:"sr-only"}, this.props.title) : this.props.title;

React.DOM.div( {className:groupClassName},
Button(
{id:this.props.id,
ref:"button",
className:className,
onClick:this.handleClick},
title,' ',React.DOM.span( {className:"caret"} )
),
React.DOM.ul(
{className:"dropdown-menu",
role:"menu",
ref:"menu",
'aria-labelledby':this.props.id},
menuItems
)
Button(
{id:this.props.id,
ref:"button",
className:className,
onClick:this.handleClick},
title,' ',React.DOM.span( {className:"caret"} )
),
React.DOM.ul(
{className:"dropdown-menu",
role:"menu",
ref:"menu",
'aria-labelledby':this.props.id},
utils.modifyChildren(this.props.children, this.renderMenuItem)
)
)
);
},
renderMenuItem: function (child, i) {
return utils.cloneWithProps(
child,
{
onSelect: this.handleOptionSelect.bind(this, i)
}
);
}

@@ -120,0 +118,0 @@ });

"use strict";
/** @jsx React.DOM */
var React = require('react');
var classSet = require('react/lib/cx');
var React = require("./react-es6")["default"];
var classSet = require("./react-es6/lib/cx")["default"];

@@ -7,0 +7,0 @@ var INPUT_TYPES = [

"use strict";
/** @jsx React.DOM */
var React = require('react');
var React = require("./react-es6")["default"];

@@ -6,0 +6,0 @@ var MenuItem = React.createClass({displayName: 'MenuItem',

"use strict";
/** @jsx React.DOM */
var React = require('react');
var classSet = require('react/lib/cx');
var React = require("./react-es6")["default"];
var classSet = require("./react-es6/lib/cx")["default"];
var BootstrapMixin = require("./BootstrapMixin")["default"];

@@ -14,4 +14,5 @@ var Button = require("./Button")["default"];

propTypes: {
title: React.PropTypes.renderable.isRequired,
dropdownTitle: React.PropTypes.renderable,
// TODO: Uncompatable with React 0.8.0
//title: React.PropTypes.renderable.isRequired,
//dropdownTitle: React.PropTypes.renderable,
bsVariation: React.PropTypes.oneOf(['dropup']),

@@ -18,0 +19,0 @@ isInInputGroup: React.PropTypes.bool,

"use strict";
/** @jsx React.DOM */
var React = require('react');
var classSet = require('react/lib/cx');
var React = require("./react-es6")["default"];
var classSet = require("./react-es6/lib/cx")["default"];

@@ -7,0 +7,0 @@ var Tab = React.createClass({displayName: 'Tab',

"use strict";
/** @jsx React.DOM */
var React = require('react');
var React = require("./react-es6")["default"];
var BootstrapMixin = require("./BootstrapMixin")["default"];
var utils = require("./utils")["default"];
var Tab = require("./Tab")["default"];
var Nav = require("./Nav")["default"];
var NavItem = require("./NavItem")["default"];

@@ -31,8 +32,5 @@ var TabbedArea = React.createClass({displayName: 'TabbedArea',

render: function () {
var children = this.props.children;
var activeKey =
this.props.activeKey != null ? this.props.activeKey : this.state.activeKey;
if (!Array.isArray(children)) {
children = [children]
}
function hasTab (child) {

@@ -44,7 +42,7 @@ return !!child.props.tab;

React.DOM.div(null,
React.DOM.ul( {className:"nav nav-tabs", ref:"tabs"},
children.filter(hasTab).map(this.renderTab)
Nav( {bsStyle:"tabs", activeKey:activeKey, onSelect:this.handleSelect, ref:"tabs"},
utils.modifyChildren(utils.filterChildren(this.props.children, hasTab), this.renderTab)
),
React.DOM.div( {id:this.props.id, ref:"panes"},
children.map(this.renderPane)
React.DOM.div( {id:this.props.id, className:"tab-content", ref:"panes"},
utils.modifyChildren(this.props.children, this.renderPane)
)

@@ -67,12 +65,7 @@ )

renderTab: function (child) {
var activeKey =
this.props.activeKey != null ? this.props.activeKey : this.state.activeKey;
var key = child.props.key;
return (
Tab(
{id:child.props.id,
ref:'tab' + key,
key:key,
isActive:key === activeKey,
onSelect:this.handleSelect.bind(this, key)},
NavItem(
{ref:'tab' + key,
key:key},
child.props.tab

@@ -79,0 +72,0 @@ )

"use strict";
/** @jsx React.DOM */
var React = require('react');
var classSet = require('react/lib/cx');
var React = require("./react-es6")["default"];
var classSet = require("./react-es6/lib/cx")["default"];

@@ -11,3 +11,3 @@ var TabPane = React.createClass({displayName: 'TabPane',

'tab-pane': true,
'open': this.props.isActive
'active': this.props.isActive
};

@@ -14,0 +14,0 @@

"use strict";
var ReactPropTransferer = require('react/lib/ReactPropTransferer');
var ReactPropTransferer = require("./react-es6/lib/ReactPropTransferer")["default"];

@@ -7,2 +7,63 @@ exports["default"] = {

/**
* Modify each item in a React children array without
* unnecessarily allocating a new array.
*
* @param {array|object} children
* @param {function} modifier
* @returns {*}
*/
modifyChildren: function (children, modifier) {
if (children == null) {
return children;
}
return Array.isArray(children) ? children.map(modifier) : modifier(children, 0);
},
/**
* Filter each item in a React children array without
* unnecessarily allocating a new array.
*
* @param {array|object} children
* @param {function} filter
* @returns {*}
*/
filterChildren: function (children, filter) {
if (children == null) {
return children;
}
if (Array.isArray(children)) {
return children.filter(filter);
} else {
return filter(children, 0) ? children : null;
}
},
/**
* Safe chained function
*
* Will only create a new function if needed,
* otherwise will pass back existing functions or null.
*
* @param {function} one
* @param {function} two
* @returns {function|null}
*/
createChainedFunction: function (one, two) {
var hasOne = typeof one === 'function';
var hasTwo = typeof two === 'function';
if (!hasOne && !hasTwo) { return null; }
if (!hasOne) { return two; }
if (!hasTwo) { return one; }
return function chainedFunction() {
one.apply(this, arguments);
two.apply(this, arguments);
};
},
/**
* Sometimes you want to change the props of a child passed to you. Usually

@@ -9,0 +70,0 @@ * this is to add a CSS class.

@@ -5,12 +5,3 @@ module.exports = function (grunt) {

pkg: grunt.file.readJSON('package.json'),
// uglify: {
// options: {
// banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
// },
// build: {
// src: 'src/<%= pkg.name %>.js',
// dest: 'build/<%= pkg.name %>.min.js'
// }
// }
//
transpile: {

@@ -22,3 +13,3 @@ cjs: {

cwd: '.',
src: ['transpiled/*.js'],
src: ['transpiled/**/*.js'],
dest: 'cjs/'

@@ -33,3 +24,3 @@ }]

cwd: '.',
src: ['transpiled/*.js'],
src: ['transpiled/**/*.js'],
dest: 'amd/'

@@ -48,3 +39,3 @@ }]

cwd: 'cjs/transpiled',
src: ['**/*.js'],
src: ['*.js'],
dest: 'cjs'

@@ -60,3 +51,3 @@ }]

cwd: 'amd/transpiled',
src: ['**/*.js'],
src: ['*.js'],
dest: 'amd'

@@ -119,6 +110,28 @@ }]

options: {
transform: ['envify']
transform: ['envify'],
verbose: true
}
}
},
// TODO: work out how to get grunt-contrib-requirejs working
shell: {
requirejs: {
command: 'node tools/r.js -o tools/build.js',
options: {
stdout: true
}
}
},
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
src: 'dist/<%= pkg.name %>.min.js',
dest: 'dist/<%= pkg.name %>.min.js'
}
}
});

@@ -134,2 +147,3 @@

grunt.loadNpmTasks('grunt-browserify');
grunt.loadNpmTasks('grunt-shell');

@@ -143,2 +157,4 @@ grunt.registerTask('build', [

'browserify',
'shell:requirejs',
'uglify',
'clean:transpiled'

@@ -145,0 +161,0 @@ ]);

{
"name": "react-bootstrap",
"version": "0.2.0",
"version": "0.3.0",
"description": "Bootstrap 3 components build with React",

@@ -44,4 +44,6 @@ "main": "main.js",

"grunt-cli": "~0.1.13",
"grunt-react": "~0.6.0"
"grunt-react": "~0.6.0",
"grunt-contrib-requirejs": "~0.4.1",
"grunt-shell": "~0.6.4"
}
}

@@ -10,6 +10,40 @@ # react-bootstrap

- Huge contributions from [syllog1sm](https://github.com/syllog1sm) ([blog](http://clozeit.wordpress.com/))
- [Pieter Vanderwerff](https://github.com/pieter-vanderwerff)
- [Pieter Vanderwerff](https://github.com/pieterv)
## Getting started
You can import the lib with as AMD modules, CommonJS modules as a global JS script.
First add the bootstrap CSS to your project then
### AMD
```
bower install react-bootstrap
var Alert = require('react-bootstrap/amd/Alert');
// or
var Alert = require('react-bootstrap/amd').Alert;
```
### CommonJS
```
npm install react react-bootstrap
var Alert = require('react-bootstrap/cjs/Alert');
// or
var Alert = require('react-bootstrap').Alert;
```
### Browser globals
```
<script src="http://fb.me/react-0.8.0.js"></script>
<script src="react-bootstrap/dist/react-bootstrap.min.js"></script>
<script>
var Alert = ReactBootstrap.Alert;
</script>
```
## Currently implemented (but under active development)
- [Nav, NavItem](#Nav)
- [Button](#Button)

@@ -23,2 +57,21 @@ - [DropdownButton](#DropdownButton)

### <a name="Nav"></a>Nav
```
var Nav = require('react-bootstrap/cjs/Nav');
var NavItem = require('react-bootstrap/cjs/NavItem');
var key = 1;
function handleSelect (selectedKey) {
key = selectedKey;
}
<Nav bsStyle="[tabs|pills]" bsVariation="[stacked|justified]" activeKey={key} onSelect={handleSelect}>
<NavItem key={1} href="/home">NavItem 1 content</NavItem>
<NavItem key={2} title="Item">NavItem 2 content</NavItem>
<NavItem key={3} disabled={true}>NavItem 3 content</NavItem>
</Nav>
```
### <a name="Button"></a>Button

@@ -111,4 +164,3 @@

- Accordion
- Nav, NavItem
- Pagination, Pager
- Modal
/** @jsx React.DOM */
var React = require('react');
var classSet = require('react/lib/cx');
import React from './react-es6';
import classSet from './react-es6/lib/cx';
import BootstrapMixin from './BootstrapMixin';

@@ -6,0 +6,0 @@

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

var React = require('react');
import React from './react-es6';
import constants from './constants';

@@ -3,0 +3,0 @@

/** @jsx React.DOM */
var React = require('react');
var classSet = require('react/lib/cx');
import React from './react-es6';
import classSet from './react-es6/lib/cx';
import BootstrapMixin from './BootstrapMixin';

@@ -11,3 +11,4 @@

propTypes: {
loadingChildren: React.PropTypes.renderable,
// TODO: Uncompatable with React 0.8.0
//loadingChildren: React.PropTypes.renderable,
isLoading: React.PropTypes.bool,

@@ -14,0 +15,0 @@ isActive: React.PropTypes.bool,

/** @jsx React.DOM */
var React = require('react');
var classSet = require('react/lib/cx');
import React from './react-es6';
import classSet from './react-es6/lib/cx';
import BootstrapMixin from './BootstrapMixin';

@@ -6,0 +6,0 @@

@@ -10,3 +10,4 @@ export default = {

'form': 'form',
'panel': 'panel'
'panel': 'panel',
'nav': 'nav'
},

@@ -21,3 +22,5 @@ STYLES: {

'link': 'link',
'inline': 'inline'
'inline': 'inline',
'tabs': 'tabs',
'pills': 'pills'
},

@@ -24,0 +27,0 @@ SIZES: {

/** @jsx React.DOM */
var React = require('react');
var classSet = require('react/lib/cx');
import React from './react-es6';
import classSet from './react-es6/lib/cx';
import Button from './Button';

@@ -84,13 +84,2 @@ import BootstrapMixin from './BootstrapMixin';

var menuItems = this.props.children
.map(function (child, i) {
return utils.cloneWithProps(
child,
{
onSelect: this.handleOptionSelect.bind(this, i)
}
);
}, this);
var title = this.props.isTitleHidden ?

@@ -101,18 +90,27 @@ <span className="sr-only">{this.props.title}</span> : this.props.title;

<div className={groupClassName}>
<Button
id={this.props.id}
ref="button"
className={className}
onClick={this.handleClick}>
{title}{' '}<span className="caret" />
</Button>
<ul
className="dropdown-menu"
role="menu"
ref="menu"
aria-labelledby={this.props.id}>
{menuItems}
</ul>
<Button
id={this.props.id}
ref="button"
className={className}
onClick={this.handleClick}>
{title}{' '}<span className="caret" />
</Button>
<ul
className="dropdown-menu"
role="menu"
ref="menu"
aria-labelledby={this.props.id}>
{utils.modifyChildren(this.props.children, this.renderMenuItem)}
</ul>
</div>
);
},
renderMenuItem: function (child, i) {
return utils.cloneWithProps(
child,
{
onSelect: this.handleOptionSelect.bind(this, i)
}
);
}

@@ -119,0 +117,0 @@ });

/** @jsx React.DOM */
var React = require('react');
var classSet = require('react/lib/cx');
import React from './react-es6';
import classSet from './react-es6/lib/cx';

@@ -6,0 +6,0 @@ var INPUT_TYPES = [

/** @jsx React.DOM */
var React = require('react');
import React from './react-es6';

@@ -5,0 +5,0 @@ var MenuItem = React.createClass({

/** @jsx React.DOM */
var React = require('react');
var classSet = require('react/lib/cx');
import React from './react-es6';
import classSet from './react-es6/lib/cx';
import BootstrapMixin from './BootstrapMixin';

@@ -13,4 +13,5 @@ import Button from './Button';

propTypes: {
title: React.PropTypes.renderable.isRequired,
dropdownTitle: React.PropTypes.renderable,
// TODO: Uncompatable with React 0.8.0
//title: React.PropTypes.renderable.isRequired,
//dropdownTitle: React.PropTypes.renderable,
bsVariation: React.PropTypes.oneOf(['dropup']),

@@ -17,0 +18,0 @@ isInInputGroup: React.PropTypes.bool,

/** @jsx React.DOM */
var React = require('react');
var classSet = require('react/lib/cx');
import React from './react-es6';
import classSet from './react-es6/lib/cx';

@@ -6,0 +6,0 @@ var Tab = React.createClass({

/** @jsx React.DOM */
var React = require('react');
import BootstrapMixin from './BootstrapMixin';
import utils from './utils';
import Tab from './Tab';
import React from './react-es6';
import BootstrapMixin from './BootstrapMixin';
import utils from './utils';
import Nav from './Nav';
import NavItem from './NavItem';

@@ -30,8 +31,5 @@ var TabbedArea = React.createClass({

render: function () {
var children = this.props.children;
var activeKey =
this.props.activeKey != null ? this.props.activeKey : this.state.activeKey;
if (!Array.isArray(children)) {
children = [children]
}
function hasTab (child) {

@@ -43,7 +41,7 @@ return !!child.props.tab;

<div>
<ul className="nav nav-tabs" ref="tabs">
{children.filter(hasTab).map(this.renderTab)}
</ul>
<div id={this.props.id} ref="panes">
{children.map(this.renderPane)}
<Nav bsStyle="tabs" activeKey={activeKey} onSelect={this.handleSelect} ref="tabs">
{utils.modifyChildren(utils.filterChildren(this.props.children, hasTab), this.renderTab)}
</Nav>
<div id={this.props.id} className="tab-content" ref="panes">
{utils.modifyChildren(this.props.children, this.renderPane)}
</div>

@@ -66,14 +64,9 @@ </div>

renderTab: function (child) {
var activeKey =
this.props.activeKey != null ? this.props.activeKey : this.state.activeKey;
var key = child.props.key;
return (
<Tab
id={child.props.id}
<NavItem
ref={'tab' + key}
key={key}
isActive={key === activeKey}
onSelect={this.handleSelect.bind(this, key)}>
key={key}>
{child.props.tab}
</Tab>
</NavItem>
);

@@ -80,0 +73,0 @@ },

/** @jsx React.DOM */
var React = require('react');
var classSet = require('react/lib/cx');
import React from './react-es6';
import classSet from './react-es6/lib/cx';

@@ -10,3 +10,3 @@ var TabPane = React.createClass({

'tab-pane': true,
'open': this.props.isActive
'active': this.props.isActive
};

@@ -13,0 +13,0 @@

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

var ReactPropTransferer = require('react/lib/ReactPropTransferer');
import ReactPropTransferer from './react-es6/lib/ReactPropTransferer';

@@ -6,2 +6,63 @@ export default = {

/**
* Modify each item in a React children array without
* unnecessarily allocating a new array.
*
* @param {array|object} children
* @param {function} modifier
* @returns {*}
*/
modifyChildren: function (children, modifier) {
if (children == null) {
return children;
}
return Array.isArray(children) ? children.map(modifier) : modifier(children, 0);
},
/**
* Filter each item in a React children array without
* unnecessarily allocating a new array.
*
* @param {array|object} children
* @param {function} filter
* @returns {*}
*/
filterChildren: function (children, filter) {
if (children == null) {
return children;
}
if (Array.isArray(children)) {
return children.filter(filter);
} else {
return filter(children, 0) ? children : null;
}
},
/**
* Safe chained function
*
* Will only create a new function if needed,
* otherwise will pass back existing functions or null.
*
* @param {function} one
* @param {function} two
* @returns {function|null}
*/
createChainedFunction: function (one, two) {
var hasOne = typeof one === 'function';
var hasTwo = typeof two === 'function';
if (!hasOne && !hasTwo) { return null; }
if (!hasOne) { return two; }
if (!hasTwo) { return one; }
return function chainedFunction() {
one.apply(this, arguments);
two.apply(this, arguments);
};
},
/**
* Sometimes you want to change the props of a child passed to you. Usually

@@ -8,0 +69,0 @@ * this is to add a CSS class.

@@ -13,4 +13,4 @@ /** @jsx React.DOM */

<TabbedArea activeKey={1}>
<TabPane tab="Tab 1" key={1}>Tab 1 content</TabPane>
<TabPane tab="Tab 2" key={2}>Tab 2 content</TabPane>
<TabPane tab="Tab 1" key={1} ref="pane1">Tab 1 content</TabPane>
<TabPane tab="Tab 2" key={2} ref="pane2">Tab 2 content</TabPane>
</TabbedArea>

@@ -20,9 +20,10 @@ );

ReactTestUtils.renderIntoDocument(instance);
assert.ok(instance.refs.panes.getDOMNode().children[0].className.match(/\bopen\b/));
assert.notOk(instance.refs.panes.getDOMNode().children[1].className.match(/\bopen\b/));
assert.ok(instance.refs.tab1.getDOMNode().className.match(/\active\b/));
assert.notOk(instance.refs.tab2.getDOMNode().className.match(/\active\b/));
assert.equal(instance.refs.pane1.props.isActive, true);
assert.equal(instance.refs.pane2.props.isActive, false);
assert.equal(instance.refs.tabs.props.activeKey, 1);
});
it('Should only show the tabs with tab prop', function () {
it('Should only show the tabs with `TabPane.props.tab` set', function () {
var instance = (

@@ -37,11 +38,5 @@ <TabbedArea activeKey={3}>

ReactTestUtils.renderIntoDocument(instance);
var panes = instance.refs.panes.getDOMNode();
assert.equal(panes.children.length, 3);
assert.notOk(panes.children[0].className.match(/\bopen\b/));
assert.notOk(panes.children[1].className.match(/\bopen\b/));
assert.ok(panes.children[2].className.match(/\bopen\b/));
var tabs = instance.refs.tabs.getDOMNode();
assert.equal(tabs.children.length, 2);
assert.notOk(tabs.children[0].className.match(/\active\b/));
assert.ok(tabs.children[1].className.match(/\active\b/));
assert.equal(instance.refs.tabs.props.children.length, 2);
assert.equal(instance.refs.tabs.props.activeKey, 3);
});

@@ -51,6 +46,6 @@

var tabTitle = (
<strong>Tab 2</strong>
<strong className="special-tab">Tab 2</strong>
);
var instance = (
<TabbedArea activeKey={3}>
<TabbedArea activeKey={2}>
<TabPane tab="Tab 1" key={1}>Tab 1 content</TabPane>

@@ -62,14 +57,17 @@ <TabPane tab={tabTitle} key={2}>Tab 2 content</TabPane>

ReactTestUtils.renderIntoDocument(instance);
assert.ok(ReactTestUtils.findRenderedDOMComponentWithTag(instance.refs.tab2, 'strong'));
assert.ok(ReactTestUtils.findRenderedDOMComponentWithClass(instance.refs.tabs, 'special-tab'));
});
it('Should call onSelect when tab is selected', function (done) {
var onSelect = function (key) {
assert.equal(key, 2);
done();
},
instance = (
function onSelect(key) {
assert.equal(key, 2);
done();
}
var tab2 = <span>Tab2</span>;
var instance = (
<TabbedArea onSelect={onSelect} activeKey={1}>
<TabPane tab="Tab 1" key={1}>Tab 1 content</TabPane>
<TabPane tab="Tab 2" key={2}>Tab 2 content</TabPane>
<TabPane tab={tab2} key={2}>Tab 2 content</TabPane>
</TabbedArea>

@@ -79,9 +77,9 @@ );

ReactTestUtils.renderIntoDocument(instance);
ReactTestUtils.Simulate.click(instance.refs.tab2.refs.button.getDOMNode());
ReactTestUtils.Simulate.click(tab2.getDOMNode());
});
it('Should have children with the correct props', function () {
it('Should have children with the correct DOM properties', function () {
var instance = (
<TabbedArea activeKey={1}>
<TabPane tab="Tab 1" className="custom" id="pane0id" key={1}>Tab 1 content</TabPane>
<TabPane tab="Tab 1" className="custom" id="pane0id" key={1} ref="pane1">Tab 1 content</TabPane>
<TabPane tab="Tab 2" key={2}>Tab 2 content</TabPane>

@@ -92,15 +90,12 @@ </TabbedArea>

ReactTestUtils.renderIntoDocument(instance);
assert.ok(instance.refs.panes.getDOMNode().children[0].className.match(/\bcustom\b/));
assert.equal(instance.refs.panes.getDOMNode().children[0].id, 'pane0id');
assert.equal(
instance.refs.tab1.refs.button.getDOMNode().getAttribute('href'),
'#pane0id'
);
assert.ok(instance.refs.pane1.getDOMNode().className.match(/\bcustom\b/));
assert.equal(instance.refs.pane1.getDOMNode().id, 'pane0id');
});
it('Should show the correct initial tab', function () {
it('Should show the correct initial pane', function () {
var instance = (
<TabbedArea initialActiveKey={2}>
<TabPane tab="Tab 1" key={1}>Tab 1 content</TabPane>
<TabPane tab="Tab 2" key={2}>Tab 2 content</TabPane>
<TabPane tab="Tab 1" key={1} ref="pane1">Tab 1 content</TabPane>
<TabPane tab="Tab 2" key={2} ref="pane2">Tab 2 content</TabPane>
</TabbedArea>

@@ -110,6 +105,7 @@ );

ReactTestUtils.renderIntoDocument(instance);
assert.notOk(instance.refs.panes.getDOMNode().children[0].className.match(/\bopen\b/));
assert.ok(instance.refs.panes.getDOMNode().children[1].className.match(/\bopen\b/));
assert.notOk(instance.refs.tab1.getDOMNode().className.match(/\active\b/));
assert.ok(instance.refs.tab2.getDOMNode().className.match(/\active\b/));
assert.equal(instance.refs.pane1.props.isActive, false);
assert.equal(instance.refs.pane2.props.isActive, true);
assert.equal(instance.refs.tabs.props.activeKey, 2);
});

@@ -120,4 +116,4 @@

<TabbedArea>
<TabPane tab="Tab 1" key={1}>Tab 1 content</TabPane>
<TabPane tab="Tab 2" key={2}>Tab 2 content</TabPane>
<TabPane tab="Tab 1" key={1} ref="pane1">Tab 1 content</TabPane>
<TabPane tab="Tab 2" key={2} ref="pane2">Tab 2 content</TabPane>
</TabbedArea>

@@ -127,16 +123,19 @@ );

ReactTestUtils.renderIntoDocument(instance);
assert.ok(instance.refs.panes.getDOMNode().children[0].className.match(/\bopen\b/));
assert.notOk(instance.refs.panes.getDOMNode().children[1].className.match(/\bopen\b/));
assert.ok(instance.refs.tab1.getDOMNode().className.match(/\active\b/));
assert.notOk(instance.refs.tab2.getDOMNode().className.match(/\active\b/));
assert.equal(instance.refs.pane1.props.isActive, true);
assert.equal(instance.refs.pane2.props.isActive, false);
assert.equal(instance.refs.tabs.props.activeKey, 1);
});
it('Should show the correct tab when selected', function (done) {
var tab1 = <span>Tab 1</span>;
var instance = (
<TabbedArea initialActiveKey={2}>
<TabPane tab="Tab 1" key={1}>Tab 1 content</TabPane>
<TabPane tab="Tab 2" key={2}>Tab 2 content</TabPane>
</TabbedArea>
<TabbedArea initalActiveKey={2}>
<TabPane tab={tab1} key={1} ref="pane1">Tab 1 content</TabPane>
<TabPane tab="Tab 2" key={2} ref="pane2">Tab 2 content</TabPane>
</TabbedArea>
);
// Override `componentDidUpdate` for now, but this should be replaced

@@ -146,6 +145,6 @@ // with `ReactTestUtils#nextUpdate()` when it is merged.

instance.componentDidUpdate = function () {
assert.ok(instance.refs.panes.getDOMNode().children[0].className.match(/\bopen\b/));
assert.notOk(instance.refs.panes.getDOMNode().children[1].className.match(/\bopen\b/));
assert.ok(instance.refs.tab1.getDOMNode().className.match(/\active\b/));
assert.notOk(instance.refs.tab2.getDOMNode().className.match(/\active\b/));
assert.equal(instance.refs.pane1.props.isActive, true);
assert.equal(instance.refs.pane2.props.isActive, false);
assert.equal(instance.refs.tabs.props.activeKey, 1);
done();

@@ -155,4 +154,4 @@ };

ReactTestUtils.renderIntoDocument(instance);
ReactTestUtils.Simulate.click(instance.refs.tab1.refs.button.getDOMNode());
ReactTestUtils.Simulate.click(tab1.getDOMNode());
});
});
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