<commit_before>let React = require('react');
let Paper = require('../paper');
let StylePropable = require('../mixins/style-propable');
let CardExpandable = require('./card-expandable');

let Card = React.createClass({
  mixins:[StylePropable],

  getInitialState() {
    return { expanded: this.props.initiallyExpanded ? true : false };
  },

  propTypes: {
    style: React.PropTypes.object,
    expandable: React.PropTypes.bool,
    initiallyExpanded: React.PropTypes.bool,
  },

  _onExpandable(value) {
    this.setState({expanded: value});
  },

  render() {

    let newChildren = React.Children.map(this.props.children, (currentChild) => {
      if (!currentChild) {
        return null;
      }
      if (this.state.expanded === false && currentChild.props.expandable === true)
        return;
      if (currentChild.props.expandableController === true) {
        return React.cloneElement(currentChild, {},
          currentChild.props.children,
          <CardExpandable expanded={this.state.expanded} onExpanding={this._onExpandable}/>);
      }
      return currentChild;
    }, this);


    //TODO
    let lastElement = React.Children.count(this.props.children) > 1 ?
      this.props.children[this.props.children.length - 1]
      : this.props.children;

    // If the last element is text or a title we should add
    // 8px padding to the bottom of the card
    let addBottomPadding = (lastElement.type.displayName === "CardText" ||
      lastElement.type.displayName === "CardTitle");
    let {
      style,
      ...other,
    } = this.props;

    let mergedStyles = this.mergeAndPrefix({
      overflow: 'hidden',
      zIndex: 1,
    }, style);

    return (
      <Paper {...other} style={mergedStyles}>
        <div style={{paddingBottom: addBottomPadding ? 8 : 0}}>
          {newChildren}
        </div>
      </Paper>
    );
  },
});
<commit_msg>[Card] Fix lastElement<commit_after>let React = require('react');
let Paper = require('../paper');
let StylePropable = require('../mixins/style-propable');
let CardExpandable = require('./card-expandable');

let Card = React.createClass({
  mixins:[StylePropable],

  getInitialState() {
    return { expanded: this.props.initiallyExpanded ? true : false };
  },

  propTypes: {
    style: React.PropTypes.object,
    expandable: React.PropTypes.bool,
    initiallyExpanded: React.PropTypes.bool,
  },

  _onExpandable(value) {
    this.setState({expanded: value});
  },

  render() {
    let lastElement;
    let newChildren = React.Children.map(this.props.children, (currentChild) => {
      if (!currentChild) {
        return null;
      }
      if (this.state.expanded === false && currentChild.props.expandable === true)
        return;
      if (currentChild.props.expandableController === true) {
        lastElement = React.cloneElement(currentChild, {},
          currentChild.props.children,
          <CardExpandable expanded={this.state.expanded} onExpanding={this._onExpandable}/>);
      } else {
        lastElement = currentChild;
      }
      return lastElement;
    }, this);

    // If the last element is text or a title we should add
    // 8px padding to the bottom of the card
    let addBottomPadding = (lastElement && (lastElement.type.displayName === "CardText" ||
      lastElement.type.displayName === "CardTitle"));
    let {
      style,
      ...other,
    } = this.props;

    let mergedStyles = this.mergeAndPrefix({
      overflow: 'hidden',
      zIndex: 1,
    }, style);

    return (
      <Paper {...other} style={mergedStyles}>
        <div style={{paddingBottom: addBottomPadding ? 8 : 0}}>
          {newChildren}
        </div>
      </Paper>
    );
  },
});

{'fraction_non_alphanumeric': 0.14231292517006802, 'fraction_numerical': 0.0027210884353741495, 'mean_word_length': 2.7510204081632654, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3577766', 'n_tokens_mistral': 1119, 'n_tokens_neox': 1082, 'n_words': 234}