react-bootstrap
Version:
Bootstrap 3 components build with React
1,791 lines (1,557 loc) • 156 kB
JavaScript
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD.
define(['react'], factory);
} else {
// Browser globals
root.ReactBootstrap = factory(root.React);
}
}(this, function (React) {
/**
* almond 0.1.2 Copyright (c) 2011, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/jrburke/almond for details
*/
//Going sloppy to avoid 'use strict' string cost, but strict practices should
//be followed.
/*jslint sloppy: true */
/*global setTimeout: false */
var requirejs, require, define;
(function (undef) {
var defined = {},
waiting = {},
config = {},
defining = {},
aps = [].slice,
main, req;
/**
* Given a relative module name, like ./something, normalize it to
* a real name that can be mapped to a path.
* @param {String} name the relative name
* @param {String} baseName a real name that the name arg is relative
* to.
* @returns {String} normalized name
*/
function normalize(name, baseName) {
var baseParts = baseName && baseName.split("/"),
map = config.map,
starMap = (map && map['*']) || {},
nameParts, nameSegment, mapValue, foundMap,
foundI, foundStarMap, starI, i, j, part;
//Adjust any relative paths.
if (name && name.charAt(0) === ".") {
//If have a base name, try to normalize against it,
//otherwise, assume it is a top-level require that will
//be relative to baseUrl in the end.
if (baseName) {
//Convert baseName to array, and lop off the last part,
//so that . matches that "directory" and not name of the baseName's
//module. For instance, baseName of "one/two/three", maps to
//"one/two/three.js", but we want the directory, "one/two" for
//this normalization.
baseParts = baseParts.slice(0, baseParts.length - 1);
name = baseParts.concat(name.split("/"));
//start trimDots
for (i = 0; (part = name[i]); i++) {
if (part === ".") {
name.splice(i, 1);
i -= 1;
} else if (part === "..") {
if (i === 1 && (name[2] === '..' || name[0] === '..')) {
//End of the line. Keep at least one non-dot
//path segment at the front so it can be mapped
//correctly to disk. Otherwise, there is likely
//no path mapping for a path starting with '..'.
//This can still fail, but catches the most reasonable
//uses of ..
return true;
} else if (i > 0) {
name.splice(i - 1, 2);
i -= 2;
}
}
}
//end trimDots
name = name.join("/");
}
}
//Apply map config if available.
if ((baseParts || starMap) && map) {
nameParts = name.split('/');
for (i = nameParts.length; i > 0; i -= 1) {
nameSegment = nameParts.slice(0, i).join("/");
if (baseParts) {
//Find the longest baseName segment match in the config.
//So, do joins on the biggest to smallest lengths of baseParts.
for (j = baseParts.length; j > 0; j -= 1) {
mapValue = map[baseParts.slice(0, j).join('/')];
//baseName segment has config, find if it has one for
//this name.
if (mapValue) {
mapValue = mapValue[nameSegment];
if (mapValue) {
//Match, update name to the new value.
foundMap = mapValue;
foundI = i;
break;
}
}
}
}
if (foundMap) {
break;
}
//Check for a star map match, but just hold on to it,
//if there is a shorter segment match later in a matching
//config, then favor over this star map.
if (!foundStarMap && starMap && starMap[nameSegment]) {
foundStarMap = starMap[nameSegment];
starI = i;
}
}
if (!foundMap && foundStarMap) {
foundMap = foundStarMap;
foundI = starI;
}
if (foundMap) {
nameParts.splice(0, foundI, foundMap);
name = nameParts.join('/');
}
}
return name;
}
function makeRequire(relName, forceSync) {
return function () {
//A version of a require function that passes a moduleName
//value for items that may need to
//look up paths relative to the moduleName
return req.apply(undef, aps.call(arguments, 0).concat([relName, forceSync]));
};
}
function makeNormalize(relName) {
return function (name) {
return normalize(name, relName);
};
}
function makeLoad(depName) {
return function (value) {
defined[depName] = value;
};
}
function callDep(name) {
if (waiting.hasOwnProperty(name)) {
var args = waiting[name];
delete waiting[name];
defining[name] = true;
main.apply(undef, args);
}
if (!defined.hasOwnProperty(name)) {
throw new Error('No ' + name);
}
return defined[name];
}
/**
* Makes a name map, normalizing the name, and using a plugin
* for normalization if necessary. Grabs a ref to plugin
* too, as an optimization.
*/
function makeMap(name, relName) {
var prefix, plugin,
index = name.indexOf('!');
if (index !== -1) {
prefix = normalize(name.slice(0, index), relName);
name = name.slice(index + 1);
plugin = callDep(prefix);
//Normalize according
if (plugin && plugin.normalize) {
name = plugin.normalize(name, makeNormalize(relName));
} else {
name = normalize(name, relName);
}
} else {
name = normalize(name, relName);
}
//Using ridiculous property names for space reasons
return {
f: prefix ? prefix + '!' + name : name, //fullName
n: name,
p: plugin
};
}
function makeConfig(name) {
return function () {
return (config && config.config && config.config[name]) || {};
};
}
main = function (name, deps, callback, relName) {
var args = [],
usingExports,
cjsModule, depName, ret, map, i;
//Use name if no relName
relName = relName || name;
//Call the callback to define the module, if necessary.
if (typeof callback === 'function') {
//Pull out the defined dependencies and pass the ordered
//values to the callback.
//Default to [require, exports, module] if no deps
deps = !deps.length && callback.length ? ['require', 'exports', 'module'] : deps;
for (i = 0; i < deps.length; i++) {
map = makeMap(deps[i], relName);
depName = map.f;
//Fast path CommonJS standard dependencies.
if (depName === "require") {
args[i] = makeRequire(name);
} else if (depName === "exports") {
//CommonJS module spec 1.1
args[i] = defined[name] = {};
usingExports = true;
} else if (depName === "module") {
//CommonJS module spec 1.1
cjsModule = args[i] = {
id: name,
uri: '',
exports: defined[name],
config: makeConfig(name)
};
} else if (defined.hasOwnProperty(depName) || waiting.hasOwnProperty(depName)) {
args[i] = callDep(depName);
} else if (map.p) {
map.p.load(map.n, makeRequire(relName, true), makeLoad(depName), {});
args[i] = defined[depName];
} else if (!defining[depName]) {
throw new Error(name + ' missing ' + depName);
}
}
ret = callback.apply(defined[name], args);
if (name) {
//If setting exports via "module" is in play,
//favor that over return value and exports. After that,
//favor a non-undefined return value over exports use.
if (cjsModule && cjsModule.exports !== undef &&
cjsModule.exports !== defined[name]) {
defined[name] = cjsModule.exports;
} else if (ret !== undef || !usingExports) {
//Use the return value from the function.
defined[name] = ret;
}
}
} else if (name) {
//May just be an object definition for the module. Only
//worry about defining if have a module name.
defined[name] = callback;
}
};
requirejs = require = req = function (deps, callback, relName, forceSync) {
if (typeof deps === "string") {
//Just return the module wanted. In this scenario, the
//deps arg is the module name, and second arg (if passed)
//is just the relName.
//Normalize module name, if it contains . or ..
return callDep(makeMap(deps, callback).f);
} else if (!deps.splice) {
//deps is a config object, not an array.
config = deps;
if (callback.splice) {
//callback is an array, which means it is a dependency list.
//Adjust args if there are dependencies
deps = callback;
callback = relName;
relName = null;
} else {
deps = undef;
}
}
//Support require(['a'])
callback = callback || function () {};
//Simulate async callback;
if (forceSync) {
main(undef, deps, callback, relName);
} else {
setTimeout(function () {
main(undef, deps, callback, relName);
}, 15);
}
return req;
};
/**
* Just drops the config on the floor, but returns req in case
* the config return value is used.
*/
req.config = function (cfg) {
config = cfg;
return req;
};
define = function (name, deps, callback) {
//This module may not have dependencies
if (!deps.splice) {
//deps is not an array, so probably means
//an object literal or factory function for
//the value. Adjust args.
callback = deps;
deps = [];
}
waiting[name] = [name, deps, callback];
};
define.amd = {
jQuery: true
};
}());
define("almond", function(){});
define('lib/utils/joinClasses',['require','exports','module'],function (require, exports, module) {/**
* Copyright 2013-2014, Facebook, Inc.
* All rights reserved.
*
* This file contains an unmodified version of:
* https://github.com/facebook/react/blob/v0.12.0/src/utils/joinClasses.js
*
* This source code is licensed under the BSD-style license found here:
* https://github.com/facebook/react/blob/v0.12.0/LICENSE
* An additional grant of patent rights can be found here:
* https://github.com/facebook/react/blob/v0.12.0/PATENTS
*/
/**
* Combines multiple className strings into one.
* http://jsperf.com/joinclasses-args-vs-array
*
* @param {...?string} classes
* @return {string}
*/
function joinClasses(className/*, ... */) {
if (!className) {
className = '';
}
var nextClass;
var argLength = arguments.length;
if (argLength > 1) {
for (var ii = 1; ii < argLength; ii++) {
nextClass = arguments[ii];
if (nextClass) {
className = (className ? className + ' ' : '') + nextClass;
}
}
}
return className;
}
module.exports = joinClasses;
});
define('lib/utils/classSet',['require','exports','module'],function (require, exports, module) {/**
* Copyright 2013-2014, Facebook, Inc.
* All rights reserved.
*
* This file contains an unmodified version of:
* https://github.com/facebook/react/blob/v0.12.0/src/vendor/stubs/cx.js
*
* This source code is licensed under the BSD-style license found here:
* https://github.com/facebook/react/blob/v0.12.0/LICENSE
* An additional grant of patent rights can be found here:
* https://github.com/facebook/react/blob/v0.12.0/PATENTS
*/
/**
* This function is used to mark string literals representing CSS class names
* so that they can be transformed statically. This allows for modularization
* and minification of CSS class names.
*
* In static_upstream, this function is actually implemented, but it should
* eventually be replaced with something more descriptive, and the transform
* that is used in the main stack should be ported for use elsewhere.
*
* @param string|object className to modularize, or an object of key/values.
* In the object case, the values are conditions that
* determine if the className keys should be included.
* @param [string ...] Variable list of classNames in the string case.
* @return string Renderable space-separated CSS className.
*/
function cx(classNames) {
if (typeof classNames == 'object') {
return Object.keys(classNames).filter(function(className) {
return classNames[className];
}).join(' ');
} else {
return Array.prototype.join.call(arguments, ' ');
}
}
module.exports = cx;
});
define('lib/utils/Object.assign',['require','exports','module'],function (require, exports, module) {/**
* Copyright 2014, Facebook, Inc.
* All rights reserved.
*
* This file contains an unmodified version of:
* https://github.com/facebook/react/blob/v0.12.0/src/vendor/stubs/Object.assign.js
*
* This source code is licensed under the BSD-style license found here:
* https://github.com/facebook/react/blob/v0.12.0/LICENSE
* An additional grant of patent rights can be found here:
* https://github.com/facebook/react/blob/v0.12.0/PATENTS
*/
// https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign
function assign(target, sources) {
if (target == null) {
throw new TypeError('Object.assign target cannot be null or undefined');
}
var to = Object(target);
var hasOwnProperty = Object.prototype.hasOwnProperty;
for (var nextIndex = 1; nextIndex < arguments.length; nextIndex++) {
var nextSource = arguments[nextIndex];
if (nextSource == null) {
continue;
}
var from = Object(nextSource);
// We don't currently support accessors nor proxies. Therefore this
// copy cannot throw. If we ever supported this then we must handle
// exceptions and side-effects. We don't support symbols so they won't
// be transferred.
for (var key in from) {
if (hasOwnProperty.call(from, key)) {
to[key] = from[key];
}
}
}
return to;
};
module.exports = assign;
});
define('lib/utils/cloneWithProps',['require','exports','module','react','./joinClasses','./Object.assign'],function (require, exports, module) {/**
* Copyright 2013-2014, Facebook, Inc.
* All rights reserved.
*
* This file contains modified versions of:
* https://github.com/facebook/react/blob/v0.12.0/src/utils/cloneWithProps.js
* https://github.com/facebook/react/blob/v0.12.0/src/core/ReactPropTransferer.js
*
* This source code is licensed under the BSD-style license found here:
* https://github.com/facebook/react/blob/v0.12.0/LICENSE
* An additional grant of patent rights can be found here:
* https://github.com/facebook/react/blob/v0.12.0/PATENTS
*
* TODO: This should be replaced as soon as cloneWithProps is available via
* the core React package or a separate package.
* @see https://github.com/facebook/react/issues/1906
*/
var React = require('react');
var joinClasses = require('./joinClasses');
var assign = require("./Object.assign");
/**
* Creates a transfer strategy that will merge prop values using the supplied
* `mergeStrategy`. If a prop was previously unset, this just sets it.
*
* @param {function} mergeStrategy
* @return {function}
*/
function createTransferStrategy(mergeStrategy) {
return function(props, key, value) {
if (!props.hasOwnProperty(key)) {
props[key] = value;
} else {
props[key] = mergeStrategy(props[key], value);
}
};
}
var transferStrategyMerge = createTransferStrategy(function(a, b) {
// `merge` overrides the first object's (`props[key]` above) keys using the
// second object's (`value`) keys. An object's style's existing `propA` would
// get overridden. Flip the order here.
return assign({}, b, a);
});
function emptyFunction() {}
/**
* Transfer strategies dictate how props are transferred by `transferPropsTo`.
* NOTE: if you add any more exceptions to this list you should be sure to
* update `cloneWithProps()` accordingly.
*/
var TransferStrategies = {
/**
* Never transfer `children`.
*/
children: emptyFunction,
/**
* Transfer the `className` prop by merging them.
*/
className: createTransferStrategy(joinClasses),
/**
* Transfer the `style` prop (which is an object) by merging them.
*/
style: transferStrategyMerge
};
/**
* Mutates the first argument by transferring the properties from the second
* argument.
*
* @param {object} props
* @param {object} newProps
* @return {object}
*/
function transferInto(props, newProps) {
for (var thisKey in newProps) {
if (!newProps.hasOwnProperty(thisKey)) {
continue;
}
var transferStrategy = TransferStrategies[thisKey];
if (transferStrategy && TransferStrategies.hasOwnProperty(thisKey)) {
transferStrategy(props, thisKey, newProps[thisKey]);
} else if (!props.hasOwnProperty(thisKey)) {
props[thisKey] = newProps[thisKey];
}
}
return props;
}
/**
* Merge two props objects using TransferStrategies.
*
* @param {object} oldProps original props (they take precedence)
* @param {object} newProps new props to merge in
* @return {object} a new object containing both sets of props merged.
*/
function mergeProps(oldProps, newProps) {
return transferInto(assign({}, oldProps), newProps);
}
var ReactPropTransferer = {
mergeProps: mergeProps
};
var CHILDREN_PROP = 'children';
/**
* Sometimes you want to change the props of a child passed to you. Usually
* this is to add a CSS class.
*
* @param {object} child child component you'd like to clone
* @param {object} props props you'd like to modify. They will be merged
* as if you used `transferPropsTo()`.
* @return {object} a clone of child with props merged in.
*/
function cloneWithProps(child, props) {
var newProps = ReactPropTransferer.mergeProps(props, child.props);
// Use `child.props.children` if it is provided.
if (!newProps.hasOwnProperty(CHILDREN_PROP) &&
child.props.hasOwnProperty(CHILDREN_PROP)) {
newProps.children = child.props.children;
}
if (React.version.substr(0, 4) === '0.12'){
var mockLegacyFactory = function(){};
mockLegacyFactory.isReactLegacyFactory = true;
mockLegacyFactory.type = child.type;
return React.createElement(mockLegacyFactory, newProps);
}
// The current API doesn't retain _owner and _context, which is why this
// doesn't use ReactElement.cloneAndReplaceProps.
return React.createElement(child.type, newProps);
}
module.exports = cloneWithProps;
});
define('lib/constants',['require','exports','module'],function (require, exports, module) {module.exports = {
CLASSES: {
'alert': 'alert',
'button': 'btn',
'button-group': 'btn-group',
'button-toolbar': 'btn-toolbar',
'column': 'col',
'input-group': 'input-group',
'form': 'form',
'glyphicon': 'glyphicon',
'label': 'label',
'list-group-item': 'list-group-item',
'panel': 'panel',
'panel-group': 'panel-group',
'progress-bar': 'progress-bar',
'nav': 'nav',
'navbar': 'navbar',
'modal': 'modal',
'row': 'row',
'well': 'well'
},
STYLES: {
'default': 'default',
'primary': 'primary',
'success': 'success',
'info': 'info',
'warning': 'warning',
'danger': 'danger',
'link': 'link',
'inline': 'inline',
'tabs': 'tabs',
'pills': 'pills'
},
SIZES: {
'large': 'lg',
'medium': 'md',
'small': 'sm',
'xsmall': 'xs'
},
GLYPHS: [
'asterisk',
'plus',
'euro',
'eur',
'minus',
'cloud',
'envelope',
'pencil',
'glass',
'music',
'search',
'heart',
'star',
'star-empty',
'user',
'film',
'th-large',
'th',
'th-list',
'ok',
'remove',
'zoom-in',
'zoom-out',
'off',
'signal',
'cog',
'trash',
'home',
'file',
'time',
'road',
'download-alt',
'download',
'upload',
'inbox',
'play-circle',
'repeat',
'refresh',
'list-alt',
'lock',
'flag',
'headphones',
'volume-off',
'volume-down',
'volume-up',
'qrcode',
'barcode',
'tag',
'tags',
'book',
'bookmark',
'print',
'camera',
'font',
'bold',
'italic',
'text-height',
'text-width',
'align-left',
'align-center',
'align-right',
'align-justify',
'list',
'indent-left',
'indent-right',
'facetime-video',
'picture',
'map-marker',
'adjust',
'tint',
'edit',
'share',
'check',
'move',
'step-backward',
'fast-backward',
'backward',
'play',
'pause',
'stop',
'forward',
'fast-forward',
'step-forward',
'eject',
'chevron-left',
'chevron-right',
'plus-sign',
'minus-sign',
'remove-sign',
'ok-sign',
'question-sign',
'info-sign',
'screenshot',
'remove-circle',
'ok-circle',
'ban-circle',
'arrow-left',
'arrow-right',
'arrow-up',
'arrow-down',
'share-alt',
'resize-full',
'resize-small',
'exclamation-sign',
'gift',
'leaf',
'fire',
'eye-open',
'eye-close',
'warning-sign',
'plane',
'calendar',
'random',
'comment',
'magnet',
'chevron-up',
'chevron-down',
'retweet',
'shopping-cart',
'folder-close',
'folder-open',
'resize-vertical',
'resize-horizontal',
'hdd',
'bullhorn',
'bell',
'certificate',
'thumbs-up',
'thumbs-down',
'hand-right',
'hand-left',
'hand-up',
'hand-down',
'circle-arrow-right',
'circle-arrow-left',
'circle-arrow-up',
'circle-arrow-down',
'globe',
'wrench',
'tasks',
'filter',
'briefcase',
'fullscreen',
'dashboard',
'paperclip',
'heart-empty',
'link',
'phone',
'pushpin',
'usd',
'gbp',
'sort',
'sort-by-alphabet',
'sort-by-alphabet-alt',
'sort-by-order',
'sort-by-order-alt',
'sort-by-attributes',
'sort-by-attributes-alt',
'unchecked',
'expand',
'collapse-down',
'collapse-up',
'log-in',
'flash',
'log-out',
'new-window',
'record',
'save',
'open',
'saved',
'import',
'export',
'send',
'floppy-disk',
'floppy-saved',
'floppy-remove',
'floppy-save',
'floppy-open',
'credit-card',
'transfer',
'cutlery',
'header',
'compressed',
'earphone',
'phone-alt',
'tower',
'stats',
'sd-video',
'hd-video',
'subtitles',
'sound-stereo',
'sound-dolby',
'sound-5-1',
'sound-6-1',
'sound-7-1',
'copyright-mark',
'registration-mark',
'cloud-download',
'cloud-upload',
'tree-conifer',
'tree-deciduous',
'cd',
'save-file',
'open-file',
'level-up',
'copy',
'paste',
'alert',
'equalizer',
'king',
'queen',
'pawn',
'bishop',
'knight',
'baby-formula',
'tent',
'blackboard',
'bed',
'apple',
'erase',
'hourglass',
'lamp',
'duplicate',
'piggy-bank',
'scissors',
'bitcoin',
'yen',
'ruble',
'scale',
'ice-lolly',
'ice-lolly-tasted',
'education',
'option-horizontal',
'option-vertical',
'menu-hamburger',
'modal-window',
'oil',
'grain',
'sunglasses',
'text-size',
'text-color',
'text-background',
'object-align-top',
'object-align-bottom',
'object-align-horizontal',
'object-align-left',
'object-align-vertical',
'object-align-right',
'triangle-right',
'triangle-left',
'triangle-bottom',
'triangle-top',
'console',
'superscript',
'subscript',
'menu-left',
'menu-right',
'menu-down',
'menu-up'
]
};
});
define('lib/BootstrapMixin',['require','exports','module','react','./constants'],function (require, exports, module) {var React = require('react');
var constants = require('./constants');
var BootstrapMixin = {
propTypes: {
bsClass: React.PropTypes.oneOf(Object.keys(constants.CLASSES)),
bsStyle: React.PropTypes.oneOf(Object.keys(constants.STYLES)),
bsSize: React.PropTypes.oneOf(Object.keys(constants.SIZES))
},
getBsClassSet: function () {
var classes = {};
var bsClass = this.props.bsClass && constants.CLASSES[this.props.bsClass];
if (bsClass) {
classes[bsClass] = true;
var prefix = bsClass + '-';
var bsSize = this.props.bsSize && constants.SIZES[this.props.bsSize];
if (bsSize) {
classes[prefix + bsSize] = true;
}
var bsStyle = this.props.bsStyle && constants.STYLES[this.props.bsStyle];
if (this.props.bsStyle) {
classes[prefix + bsStyle] = true;
}
}
return classes;
}
};
module.exports = BootstrapMixin;
});
define('lib/utils/ValidComponentChildren',['require','exports','module','react'],function (require, exports, module) {var React = require('react');
/**
* Maps children that are typically specified as `props.children`,
* but only iterates over children that are "valid components".
*
* The mapFunction provided index will be normalised to the components mapped,
* so an invalid component would not increase the index.
*
* @param {?*} children Children tree container.
* @param {function(*, int)} mapFunction.
* @param {*} mapContext Context for mapFunction.
* @return {object} Object containing the ordered map of results.
*/
function mapValidComponents(children, func, context) {
var index = 0;
return React.Children.map(children, function (child) {
if (React.isValidElement(child)) {
var lastIndex = index;
index++;
return func.call(context, child, lastIndex);
}
return child;
});
}
/**
* Iterates through children that are typically specified as `props.children`,
* but only iterates over children that are "valid components".
*
* The provided forEachFunc(child, index) will be called for each
* leaf child with the index reflecting the position relative to "valid components".
*
* @param {?*} children Children tree container.
* @param {function(*, int)} forEachFunc.
* @param {*} forEachContext Context for forEachContext.
*/
function forEachValidComponents(children, func, context) {
var index = 0;
return React.Children.forEach(children, function (child) {
if (React.isValidElement(child)) {
func.call(context, child, index);
index++;
}
});
}
/**
* Count the number of "valid components" in the Children container.
*
* @param {?*} children Children tree container.
* @returns {number}
*/
function numberOfValidComponents(children) {
var count = 0;
React.Children.forEach(children, function (child) {
if (React.isValidElement(child)) { count++; }
});
return count;
}
/**
* Determine if the Child container has one or more "valid components".
*
* @param {?*} children Children tree container.
* @returns {boolean}
*/
function hasValidComponent(children) {
var hasValid = false;
React.Children.forEach(children, function (child) {
if (!hasValid && React.isValidElement(child)) {
hasValid = true;
}
});
return hasValid;
}
module.exports = {
map: mapValidComponents,
forEach: forEachValidComponents,
numberOf: numberOfValidComponents,
hasValidComponent: hasValidComponent
};
});
define('lib/PanelGroup',['require','exports','module','react','./utils/joinClasses','./utils/classSet','./utils/cloneWithProps','./BootstrapMixin','./utils/ValidComponentChildren'],function (require, exports, module) {var React = require('react');
var joinClasses = require('./utils/joinClasses');
var classSet = require('./utils/classSet');
var cloneWithProps = require('./utils/cloneWithProps');
var BootstrapMixin = require('./BootstrapMixin');
var ValidComponentChildren = require('./utils/ValidComponentChildren');
var PanelGroup = React.createClass({displayName: "PanelGroup",
mixins: [BootstrapMixin],
propTypes: {
collapsable: React.PropTypes.bool,
activeKey: React.PropTypes.any,
defaultActiveKey: React.PropTypes.any,
onSelect: React.PropTypes.func
},
getDefaultProps: function () {
return {
bsClass: 'panel-group'
};
},
getInitialState: function () {
var defaultActiveKey = this.props.defaultActiveKey;
return {
activeKey: defaultActiveKey
};
},
render: function () {
var classes = this.getBsClassSet();
return (
React.createElement("div", React.__spread({}, this.props, {className: joinClasses(this.props.className, classSet(classes)), onSelect: null}),
ValidComponentChildren.map(this.props.children, this.renderPanel)
)
);
},
renderPanel: function (child, index) {
var activeKey =
this.props.activeKey != null ? this.props.activeKey : this.state.activeKey;
var props = {
bsStyle: child.props.bsStyle || this.props.bsStyle,
key: child.key ? child.key : index,
ref: child.ref
};
if (this.props.accordion) {
props.collapsable = true;
props.expanded = (child.props.eventKey === activeKey);
props.onSelect = this.handleSelect;
}
return cloneWithProps(
child,
props
);
},
shouldComponentUpdate: function() {
// Defer any updates to this component during the `onSelect` handler.
return !this._isChanging;
},
handleSelect: function (key) {
if (this.props.onSelect) {
this._isChanging = true;
this.props.onSelect(key);
this._isChanging = false;
}
if (this.state.activeKey === key) {
key = null;
}
this.setState({
activeKey: key
});
}
});
module.exports = PanelGroup;
});
define('lib/Accordion',['require','exports','module','react','./PanelGroup'],function (require, exports, module) {var React = require('react');
var PanelGroup = require('./PanelGroup');
var Accordion = React.createClass({displayName: "Accordion",
render: function () {
return (
React.createElement(PanelGroup, React.__spread({}, this.props, {accordion: true}),
this.props.children
)
);
}
});
module.exports = Accordion;
});
define('lib/utils/domUtils',['require','exports','module'],function (require, exports, module) {
/**
* Shortcut to compute element style
*
* @param {HTMLElement} elem
* @returns {CssStyle}
*/
function getComputedStyles(elem) {
return elem.ownerDocument.defaultView.getComputedStyle(elem, null);
}
/**
* Get elements offset
*
* TODO: REMOVE JQUERY!
*
* @param {HTMLElement} DOMNode
* @returns {{top: number, left: number}}
*/
function getOffset(DOMNode) {
if (window.jQuery) {
return window.jQuery(DOMNode).offset();
}
var docElem = document.documentElement;
var box = { top: 0, left: 0 };
// If we don't have gBCR, just use 0,0 rather than error
// BlackBerry 5, iOS 3 (original iPhone)
if ( typeof DOMNode.getBoundingClientRect !== 'undefined' ) {
box = DOMNode.getBoundingClientRect();
}
return {
top: box.top + window.pageYOffset - docElem.clientTop,
left: box.left + window.pageXOffset - docElem.clientLeft
};
}
/**
* Get elements position
*
* TODO: REMOVE JQUERY!
*
* @param {HTMLElement} elem
* @param {HTMLElement?} offsetParent
* @returns {{top: number, left: number}}
*/
function getPosition(elem, offsetParent) {
if (window.jQuery) {
return window.jQuery(elem).position();
}
var offset,
parentOffset = {top: 0, left: 0};
// Fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
if (getComputedStyles(elem).position === 'fixed' ) {
// We assume that getBoundingClientRect is available when computed position is fixed
offset = elem.getBoundingClientRect();
} else {
if (!offsetParent) {
// Get *real* offsetParent
offsetParent = offsetParent(elem);
}
// Get correct offsets
offset = getOffset(elem);
if ( offsetParent.nodeName !== 'HTML') {
parentOffset = getOffset(offsetParent);
}
// Add offsetParent borders
parentOffset.top += parseInt(getComputedStyles(offsetParent).borderTopWidth, 10);
parentOffset.left += parseInt(getComputedStyles(offsetParent).borderLeftWidth, 10);
}
// Subtract parent offsets and element margins
return {
top: offset.top - parentOffset.top - parseInt(getComputedStyles(elem).marginTop, 10),
left: offset.left - parentOffset.left - parseInt(getComputedStyles(elem).marginLeft, 10)
};
}
/**
* Get parent element
*
* @param {HTMLElement?} elem
* @returns {HTMLElement}
*/
function offsetParent(elem) {
var docElem = document.documentElement;
var offsetParent = elem.offsetParent || docElem;
while ( offsetParent && ( offsetParent.nodeName !== 'HTML' &&
getComputedStyles(offsetParent).position === 'static' ) ) {
offsetParent = offsetParent.offsetParent;
}
return offsetParent || docElem;
}
module.exports = {
getComputedStyles: getComputedStyles,
getOffset: getOffset,
getPosition: getPosition,
offsetParent: offsetParent
};
});
define('lib/utils/EventListener',['require','exports','module'],function (require, exports, module) {/**
* Copyright 2013-2014 Facebook, Inc.
*
* This file contains a modified version of:
* https://github.com/facebook/react/blob/v0.12.0/src/vendor/stubs/EventListener.js
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* TODO: remove in favour of solution provided by:
* https://github.com/facebook/react/issues/285
*/
/**
* Does not take into account specific nature of platform.
*/
var EventListener = {
/**
* Listen to DOM events during the bubble phase.
*
* @param {DOMEventTarget} target DOM element to register listener on.
* @param {string} eventType Event type, e.g. 'click' or 'mouseover'.
* @param {function} callback Callback function.
* @return {object} Object with a `remove` method.
*/
listen: function(target, eventType, callback) {
if (target.addEventListener) {
target.addEventListener(eventType, callback, false);
return {
remove: function() {
target.removeEventListener(eventType, callback, false);
}
};
} else if (target.attachEvent) {
target.attachEvent('on' + eventType, callback);
return {
remove: function() {
target.detachEvent('on' + eventType, callback);
}
};
}
}
};
module.exports = EventListener;
});
define('lib/AffixMixin',['require','exports','module','react','./utils/domUtils','./utils/EventListener'],function (require, exports, module) {/* global window, document */
var React = require('react');
var domUtils = require('./utils/domUtils');
var EventListener = require('./utils/EventListener');
var AffixMixin = {
propTypes: {
offset: React.PropTypes.number,
offsetTop: React.PropTypes.number,
offsetBottom: React.PropTypes.number
},
getInitialState: function () {
return {
affixClass: 'affix-top'
};
},
getPinnedOffset: function (DOMNode) {
if (this.pinnedOffset) {
return this.pinnedOffset;
}
DOMNode.className = DOMNode.className.replace(/affix-top|affix-bottom|affix/, '');
DOMNode.className += DOMNode.className.length ? ' affix' : 'affix';
this.pinnedOffset = domUtils.getOffset(DOMNode).top - window.pageYOffset;
return this.pinnedOffset;
},
checkPosition: function () {
var DOMNode, scrollHeight, scrollTop, position, offsetTop, offsetBottom,
affix, affixType, affixPositionTop;
// TODO: or not visible
if (!this.isMounted()) {
return;
}
DOMNode = this.getDOMNode();
scrollHeight = document.documentElement.offsetHeight;
scrollTop = window.pageYOffset;
position = domUtils.getOffset(DOMNode);
offsetTop;
offsetBottom;
if (this.affixed === 'top') {
position.top += scrollTop;
}
offsetTop = this.props.offsetTop != null ?
this.props.offsetTop : this.props.offset;
offsetBottom = this.props.offsetBottom != null ?
this.props.offsetBottom : this.props.offset;
if (offsetTop == null && offsetBottom == null) {
return;
}
if (offsetTop == null) {
offsetTop = 0;
}
if (offsetBottom == null) {
offsetBottom = 0;
}
if (this.unpin != null && (scrollTop + this.unpin <= position.top)) {
affix = false;
} else if (offsetBottom != null && (position.top + DOMNode.offsetHeight >= scrollHeight - offsetBottom)) {
affix = 'bottom';
} else if (offsetTop != null && (scrollTop <= offsetTop)) {
affix = 'top';
} else {
affix = false;
}
if (this.affixed === affix) {
return;
}
if (this.unpin != null) {
DOMNode.style.top = '';
}
affixType = 'affix' + (affix ? '-' + affix : '');
this.affixed = affix;
this.unpin = affix === 'bottom' ?
this.getPinnedOffset(DOMNode) : null;
if (affix === 'bottom') {
DOMNode.className = DOMNode.className.replace(/affix-top|affix-bottom|affix/, 'affix-bottom');
affixPositionTop = scrollHeight - offsetBottom - DOMNode.offsetHeight - domUtils.getOffset(DOMNode).top;
}
this.setState({
affixClass: affixType,
affixPositionTop: affixPositionTop
});
},
checkPositionWithEventLoop: function () {
setTimeout(this.checkPosition, 0);
},
componentDidMount: function () {
this._onWindowScrollListener =
EventListener.listen(window, 'scroll', this.checkPosition);
this._onDocumentClickListener =
EventListener.listen(document, 'click', this.checkPositionWithEventLoop);
},
componentWillUnmount: function () {
if (this._onWindowScrollListener) {
this._onWindowScrollListener.remove();
}
if (this._onDocumentClickListener) {
this._onDocumentClickListener.remove();
}
},
componentDidUpdate: function (prevProps, prevState) {
if (prevState.affixClass === this.state.affixClass) {
this.checkPositionWithEventLoop();
}
}
};
module.exports = AffixMixin;
});
define('lib/Affix',['require','exports','module','react','./utils/joinClasses','./AffixMixin','./utils/domUtils'],function (require, exports, module) {var React = require('react');
var joinClasses = require('./utils/joinClasses');
var AffixMixin = require('./AffixMixin');
var domUtils = require('./utils/domUtils');
var Affix = React.createClass({displayName: "Affix",
statics: {
domUtils: domUtils
},
mixins: [AffixMixin],
render: function () {
var holderStyle = {top: this.state.affixPositionTop};
return (
React.createElement("div", React.__spread({}, this.props, {className: joinClasses(this.props.className, this.state.affixClass), style: holderStyle}),
this.props.children
)
);
}
});
module.exports = Affix;
});
define('lib/Alert',['require','exports','module','react','./utils/joinClasses','./utils/classSet','./BootstrapMixin'],function (require, exports, module) {var React = require('react');
var joinClasses = require('./utils/joinClasses');
var classSet = require('./utils/classSet');
var BootstrapMixin = require('./BootstrapMixin');
var Alert = React.createClass({displayName: "Alert",
mixins: [BootstrapMixin],
propTypes: {
onDismiss: React.PropTypes.func,
dismissAfter: React.PropTypes.number
},
getDefaultProps: function () {
return {
bsClass: 'alert',
bsStyle: 'info'
};
},
renderDismissButton: function () {
return (
React.createElement("button", {
type: "button",
className: "close",
onClick: this.props.onDismiss,
"aria-hidden": "true"},
"×"
)
);
},
render: function () {
var classes = this.getBsClassSet();
var isDismissable = !!this.props.onDismiss;
classes['alert-dismissable'] = isDismissable;
return (
React.createElement("div", React.__spread({}, this.props, {className: joinClasses(this.props.className, classSet(classes))}),
isDismissable ? this.renderDismissButton() : null,
this.props.children
)
);
},
componentDidMount: function() {
if (this.props.dismissAfter && this.props.onDismiss) {
this.dismissTimer = setTimeout(this.props.onDismiss, this.props.dismissAfter);
}
},
componentWillUnmount: function() {
clearTimeout(this.dismissTimer);
}
});
module.exports = Alert;
});
define('lib/Badge',['require','exports','module','react','./utils/joinClasses','./utils/ValidComponentChildren','./utils/classSet'],function (require, exports, module) {var React = require('react');
var joinClasses = require('./utils/joinClasses');
var ValidComponentChildren = require('./utils/ValidComponentChildren');
var classSet = require('./utils/classSet');
var Badge = React.createClass({displayName: "Badge",
propTypes: {
pullRight: React.PropTypes.bool
},
hasContent: function () {
return ValidComponentChildren.hasValidComponent(this.props.children) ||
(typeof this.props.children === 'string') ||
(typeof this.props.children === 'number')
},
render: function () {
var classes = {
'pull-right': this.props.pullRight,
'badge': this.hasContent()
};
return (
React.createElement("span", React.__spread({},
this.props,
{className: joinClasses(this.props.className, classSet(classes))}),
this.props.children
)
);
}
});
module.exports = Badge;
});
define('lib/Button',['require','exports','module','react','./utils/joinClasses','./utils/classSet','./BootstrapMixin'],function (require, exports, module) {var React = require('react');
var joinClasses = require('./utils/joinClasses');
var classSet = require('./utils/classSet');
var BootstrapMixin = require('./BootstrapMixin');
var Button = React.createClass({displayName: "Button",
mixins: [BootstrapMixin],
propTypes: {
active: React.PropTypes.bool,
disabled: React.PropTypes.bool,
block: React.PropTypes.bool,
navItem: React.PropTypes.bool,
navDropdown: React.PropTypes.bool,
componentClass: React.PropTypes.node,
href: React.PropTypes.string,
target: React.PropTypes.string
},
getDefaultProps: function () {
return {
bsClass: 'button',
bsStyle: 'default',
type: 'button'
};
},
render: function () {
var classes = this.props.navDropdown ? {} : this.getBsClassSet();
var renderFuncName;
classes['active'] = this.props.active;
classes['btn-block'] = this.props.block;
if (this.props.navItem) {
return this.renderNavItem(classes);
}
renderFuncName = this.props.href || this.props.target || this.props.navDropdown ?
'renderAnchor' : 'renderButton';
return this[renderFuncName](classes);
},
renderAnchor: function (classes) {
var Component = this.props.componentClass || 'a';
var href = this.props.href || '#';
classes['disabled'] = this.props.disabled;
return (
React.createElement(Component, React.__spread({},
this.props,
{href: href,
className: joinClasses(this.props.className, classSet(classes)),
role: "button"}),
this.props.children
)
);
},
renderButton: function (classes) {
var Component = this.props.componentClass || 'button';
return (
React.createElement(Component, React.__spread({},
this.props,
{className: joinClasses(this.props.className, classSet(classes))}),
this.props.children
)
);
},
renderNavItem: function (classes) {
var liClasses = {
active: this.props.active
};
return (
React.createElement("li", {className: classSet(liClasses)},
this.renderAnchor(classes)
)
);
}
});
module.exports = Button;
});
define('lib/ButtonGroup',['require','exports','module','react','./utils/joinClasses','./utils/classSet','./BootstrapMixin','./Button'],function (require, exports, module) {var React = require('react');
var joinClasses = require('./utils/joinClasses');
var classSet = require('./utils/classSet');
var BootstrapMixin = require('./BootstrapMixin');
var Button = require('./Button');
var ButtonGroup = React.createClass({displayName: "ButtonGroup",
mixins: [BootstrapMixin],
propTypes: {
vertical: React.PropTypes.bool,
justified: React.PropTypes.bool
},
getDefaultProps: function () {
return {
bsClass: 'button-group'
};
},
render: function () {
var classes = this.getBsClassSet();
classes['btn-group'] = !this.props.vertical;
classes['btn-group-vertical'] = this.props.vertical;
classes['btn-group-justified'] = this.props.justified;
return (
React.createElement("div", React.__spread({},
this.props,
{className: joinClasses(this.props.className, classSet(classes))}),
this.props.children
)
);
}
});
module.exports = ButtonGroup;
});
define('lib/ButtonToolbar',['require','exports','module','react','./utils/joinClasses','./utils/classSet','./BootstrapMixin','./Button'],function (require, exports, module) {var React = require('react');
var joinClasses = require('./utils/joinClasses');
var classSet = require('./utils/classSet');
var BootstrapMixin = require('./BootstrapMixin');
var Button = require('./Button');
var ButtonToolbar = React.createClass({displayName: "ButtonToolbar",
mixins: [BootstrapMixin],
getDefaultProps: function () {
return {
bsClass: 'button-toolbar'
};
},
render: function () {
var classes = this.getBsClassSet();
return (
React.createElement("div", React.__spread({},
this.props,
{role: "toolbar",
className: joinClasses(this.props.className, classSet(classes))}),
this.props.children
)
);
}
});
module.exports = ButtonToolbar;
});
define('lib/Carousel',['require','exports','module','react','./utils/joinClasses','./utils/classSet','./utils/cloneWithProps','./BootstrapMixin','./utils/ValidComponentChildren'],function (require, exports, module) {var React = require('react');
var joinClasses = require('./utils/joinClasses');
var classSet = require('./utils/classSet');
var cloneWithProps = require('./utils/cloneWithProps');
var BootstrapMixin = require('./BootstrapMixin');
var ValidComponentChildren = require('./utils/ValidComponentChildren');
var Carousel = React.createClass({displayName: "Carousel",
mixins: [BootstrapMixin],
propTypes: {
slide: React.PropTypes.bool,
indicators: React.PropTypes.bool,
controls: React.PropTypes.bool,
pauseOnHover: React.PropTypes.bool,
wrap: React.PropTypes.bool,
onSelect: React.PropTypes.func,
onSlideEnd: React.PropTypes.func,
activeIndex: React.PropTypes.number,
defaultActiveIndex: React.PropTypes.number,
direction: React.PropTypes.oneOf(['prev', 'next'])
},
getDefaultProps: function () {
return {
slide: true,
interval: 5000,
pauseOnHover: true,
wrap: true,
indicators: true,
controls: true
};
},
getInitialState: function () {
return {
activeIndex: this.props.defaultActiveIndex == null ?
0 : this.props.defaultActiveIndex,
previousActiveIndex: null,
direction: null
};
},
getDirection: function (prevIndex, index) {
if (prevIndex === index) {
return null;
}
re