From 95eae772dc6543cd00679ee9ab8d61dbf3f35382 Mon Sep 17 00:00:00 2001 From: dignifiedquire Date: Thu, 30 Apr 2015 17:52:40 +0200 Subject: [PATCH] Build --- dist/react-simpletabs.js | 49 +++++++++++++++++------------------- dist/react-simpletabs.min.js | 2 +- 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/dist/react-simpletabs.js b/dist/react-simpletabs.js index 9834249..1fe91da 100644 --- a/dist/react-simpletabs.js +++ b/dist/react-simpletabs.js @@ -20,41 +20,41 @@ return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; -/******/ + /******/ // The require function /******/ function __webpack_require__(moduleId) { -/******/ + /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) /******/ return installedModules[moduleId].exports; -/******/ + /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ exports: {}, /******/ id: moduleId, /******/ loaded: false /******/ }; -/******/ + /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ + /******/ // Flag the module as loaded /******/ module.loaded = true; -/******/ + /******/ // Return the exports of the module /******/ return module.exports; /******/ } -/******/ -/******/ + + /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; -/******/ + /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; -/******/ + /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; -/******/ + /******/ // Load entry module and return exports /******/ return __webpack_require__(0); /******/ }) @@ -84,10 +84,7 @@ return /******/ (function(modules) { // webpackBootstrap onMount: React.PropTypes.func, onBeforeChange: React.PropTypes.func, onAfterChange: React.PropTypes.func, - children: React.PropTypes.oneOfType([ - React.PropTypes.array, - React.PropTypes.element - ]).isRequired + children: React.PropTypes.node.isRequired }, getDefaultProps:function () { return { tabActive: 1 }; @@ -142,16 +139,15 @@ return /******/ (function(modules) { // webpackBootstrap throw new Error('Tabs must contain at least one Tabs.Panel'); } - if (!Array.isArray(this.props.children)) { - this.props.children = [this.props.children]; - } + var $menuItems = React.Children + .map(this.props.children, function($panel, index) { + if (typeof $panel === 'function') { + $panel = $panel() + } - var $menuItems = this.props.children - .map(function($panel) {return typeof $panel === 'function' ? $panel() : $panel;}) - .filter(function($panel) {return $panel;}) - .map(function($panel, index) { var ref = ("tab-menu-" + (index + 1)); var title = $panel.props.title; + var classes = classNames( 'tabs-menu-item', this.state.tabActive === (index + 1) && 'is-active' @@ -187,11 +183,11 @@ return /******/ (function(modules) { // webpackBootstrap Tabs.Panel = React.createClass({ displayName: 'Panel', propTypes: { - title: React.PropTypes.string.isRequired, - children: React.PropTypes.oneOfType([ - React.PropTypes.array, + title: React.PropTypes.oneOfType([ + React.PropTypes.string, React.PropTypes.element - ]).isRequired + ]).isRequired, + children: React.PropTypes.node.isRequired }, render:function () { return React.createElement("div", null, this.props.children); @@ -252,3 +248,4 @@ return /******/ (function(modules) { // webpackBootstrap /***/ } /******/ ]) }); +; \ No newline at end of file diff --git a/dist/react-simpletabs.min.js b/dist/react-simpletabs.min.js index 864e691..c833c0e 100644 --- a/dist/react-simpletabs.min.js +++ b/dist/react-simpletabs.min.js @@ -7,4 +7,4 @@ * @author Pedro Nauck (https://github.com/pedronauck) * */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.ReactSimpleTabs=t(require("react")):e.ReactSimpleTabs=t(e.React)}(this,function(e){return function(e){function t(n){if(r[n])return r[n].exports;var s=r[n]={exports:{},id:n,loaded:!1};return e[n].call(s.exports,s,s.exports,t),s.loaded=!0,s.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){"use strict";var n=r(1),s=r(2);r(3);var i=n.createClass({displayName:"Tabs",propTypes:{className:n.PropTypes.oneOfType([n.PropTypes.array,n.PropTypes.string,n.PropTypes.object]),tabActive:n.PropTypes.number,onMount:n.PropTypes.func,onBeforeChange:n.PropTypes.func,onAfterChange:n.PropTypes.func,children:n.PropTypes.oneOfType([n.PropTypes.array,n.PropTypes.element]).isRequired},getDefaultProps:function(){return{tabActive:1}},getInitialState:function(){return{tabActive:this.props.tabActive}},componentDidMount:function(){var e=this.state.tabActive,t=this.refs["tab-panel"],r=this.refs["tab-menu-"+e];this.props.onMount&&this.props.onMount(e,t,r)},componentWillReceiveProps:function(e){e.tabActive&&this.setState({tabActive:e.tabActive})},render:function(){var e=s("tabs",this.props.className);return n.createElement("div",{className:e},this._getMenuItems(),this._getSelectedPanel())},setActive:function(e,t){var r=this.props.onAfterChange,n=this.props.onBeforeChange,s=this.refs["tab-panel"],i=this.refs["tab-menu-"+e];if(n){var a=n(e,s,i);if(a===!1)return}this.setState({tabActive:e},function(){r&&r(e,s,i)}),t.preventDefault()},_getMenuItems:function(){if(!this.props.children)throw new Error("Tabs must contain at least one Tabs.Panel");Array.isArray(this.props.children)||(this.props.children=[this.props.children]);var e=this.props.children.map(function(e){return"function"==typeof e?e():e}).filter(function(e){return e}).map(function(e,t){var r="tab-menu-"+(t+1),i=e.props.title,a=s("tabs-menu-item",this.state.tabActive===t+1&&"is-active");return n.createElement("li",{ref:r,key:t,className:a},n.createElement("a",{href:"#",onClick:this.setActive.bind(this,t+1)},i))}.bind(this));return n.createElement("nav",{className:"tabs-navigation"},n.createElement("ul",{className:"tabs-menu"},e))},_getSelectedPanel:function(){var e=this.state.tabActive-1,t=this.props.children[e];return n.createElement("article",{ref:"tab-panel",className:"tab-panel"},t)}});i.Panel=n.createClass({displayName:"Panel",propTypes:{title:n.PropTypes.string.isRequired,children:n.PropTypes.oneOfType([n.PropTypes.array,n.PropTypes.element]).isRequired},render:function(){return n.createElement("div",null,this.props.children)}}),e.exports=i},function(t){t.exports=e},function(e){function t(){for(var e,r="",n=0;n