<commit_before>'use strict';

var React = require('react/addons');
var setClass = React.addons.classSet;

var MediaObject = React.createClass({
  render: function () {
    var classes = setClass({
      'media-left': this.props.horizontalAlignment === 'left',
      'media-right': this.props.horizontalAlignment === 'right',
      'media-middle': this.props.vAlign === 'middle',
      'media-bottom': this.props.vAlign === 'bottom'
    });

    var paddingClasses = setClass({
      'prs': this.props.leftMediaSpacing === 'small',
      'prm': this.props.leftMediaSpacing === 'medium',
      'prl': this.props.leftMediaSpacing === 'large',
      'prxl': this.props.leftMediaSpacing === 'xlarge',
      'pls': this.props.rightMediaSpacing === 'small',
      'plm': this.props.rightMediaSpacing === 'medium',
      'pll': this.props.rightMediaSpacing === 'large',
      'plxl': this.props.rightMediaSpacing === 'xlarge'
    });

    var mediaClasses = [classes, paddingClasses].join(' ');


    return (
      <div className={mediaClasses}>
        {this.props.children}
      </div>
    );
  }
});

var Media = React.createClass({
  propTypes: {
    stackSize: React.PropTypes.oneOf(["xsmall", "small", "medium", "large"]),
    vAlign: React.PropTypes.oneOf(["middle","bottom"]),
    hasImages: function(props) {
      if(!props["leftImage"] && !props["rightImage"]) {
        return new Error("The media component must have at least one image");
      }
    }
  },
  render: function () {
    var leftMedia,
        rightMedia = '';

    var classes = setClass({
      'media': true,
      'media-stackable-xs': this.props.stackSize === 'xsmall',
      'media-stackable-sm': this.props.stackSize === 'small',
      'media-stackable-md': this.props.stackSize === 'medium',
      'media-stackable-lg': this.props.stackSize === 'large'
    });

    var bodyClasses = setClass({
      'media-body': true,
      'media-middle': this.props.vAlign === 'middle',
      'media-bottom': this.props.vAlign === 'bottom'
    });

    if (this.props.leftImage) {
      leftMedia = (
        <MediaObject
          horizontalAlignment='left'
          vAlign={this.props.vAlign}
          leftMediaSpacing={this.props.leftMediaSpacing}>
            {this.props.leftImage}
        </MediaObject>
      );
    }

    if (this.props.rightImage) {
      rightMedia = (
        <MediaObject
          horizontalAlignment='right'
          vAlign={this.props.vAlign}
          rightMediaSpacing={this.props.rightMediaSpacing}>
            {this.props.rightImage}
        </MediaObject>
      );
    }

    return (
      <div {...this.props} className={classes}>
        {leftMedia}
        <div className={bodyClasses}>
          {this.props.children}
        </div>
        {rightMedia}
      </div>
    );
  }
});

var Flag = React.createClass({
  getDefaultProps: function () {
    return {
      vAlign: 'middle'
    };
  },
  render: function () {
    return (
      <Media {...this.props}>{this.props.children}</Media>
    );
  }
});

module.exports = {
  Media: Media,
  Flag: Flag
};<commit_msg>fix(react-media): update prop validation<commit_after>'use strict';

var React = require('react/addons');
var setClass = React.addons.classSet;

var MediaObject = React.createClass({
  render: function () {
    var classes = setClass({
      'media-left': this.props.horizontalAlignment === 'left',
      'media-right': this.props.horizontalAlignment === 'right',
      'media-middle': this.props.vAlign === 'middle',
      'media-bottom': this.props.vAlign === 'bottom'
    });

    var paddingClasses = setClass({
      'prs': this.props.leftMediaSpacing === 'small',
      'prm': this.props.leftMediaSpacing === 'medium',
      'prl': this.props.leftMediaSpacing === 'large',
      'prxl': this.props.leftMediaSpacing === 'xlarge',
      'pls': this.props.rightMediaSpacing === 'small',
      'plm': this.props.rightMediaSpacing === 'medium',
      'pll': this.props.rightMediaSpacing === 'large',
      'plxl': this.props.rightMediaSpacing === 'xlarge'
    });

    var mediaClasses = [classes, paddingClasses].join(' ');


    return (
      <div className={mediaClasses}>
        {this.props.children}
      </div>
    );
  }
});

var Media = React.createClass({
  propTypes: {
    hasImages: function(props) {
      if(!props["leftImage"] && !props["rightImage"]) {
        return new Error("The media component must have at least one image");
      }
    },
    leftMediaSpacing: React.PropTypes.oneOf(["small", "medium", "large", "xlarge"]),
    rightMediaSpacing: React.PropTypes.oneOf(["small", "medium", "large", "xlarge"]),
    stackSize: React.PropTypes.oneOf(["xsmall", "small", "medium", "large"]),
    vAlign: React.PropTypes.oneOf(["middle","bottom"]),
  },

  render: function () {
    var {leftImage, leftMediaSpacing, rightImage, rightMediaSpacing, 
        stackSize, vAlign, children, ...other} = this.props;
    var leftMedia, rightMedia;

    var classes = setClass({
      'media': true,
      'media-stackable-xs': stackSize === 'xsmall',
      'media-stackable-sm': stackSize === 'small',
      'media-stackable-md': stackSize === 'medium',
      'media-stackable-lg': stackSize === 'large'
    });

    var bodyClasses = setClass({
      'media-body': true,
      'media-middle': vAlign === 'middle',
      'media-bottom': vAlign === 'bottom'
    });

    if (leftImage) {
      leftMedia = (
        <MediaObject
          horizontalAlignment='left'
          vAlign={vAlign}
          leftMediaSpacing={leftMediaSpacing}>
            {leftImage}
        </MediaObject>
      );
    }

    if (rightImage) {
      rightMedia = (
        <MediaObject
          horizontalAlignment='right'
          vAlign={vAlign}
          rightMediaSpacing={rightMediaSpacing}>
            {rightImage}
        </MediaObject>
      );
    }

    return (
      <div {...other} className={classes}>
        {leftMedia}
        <div className={bodyClasses}>
          {children}
        </div>
        {rightMedia}
      </div>
    );
  }
});

var Flag = React.createClass({
  render: function () {
    return <Media {...this.props} vAlign='middle' />;
  }
});

module.exports = {
  Media: Media,
  Flag: Flag
};
{'fraction_non_alphanumeric': 0.16897551546391754, 'fraction_numerical': 0.0, 'mean_word_length': 2.6545026486168335, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 26, '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': '4995059', 'n_tokens_mistral': 1925, 'n_tokens_neox': 1902, 'n_words': 359}