<commit_before>/* @flow */
import generateDisplayName from './generateDisplayName'

export default function connectFactory(
  BaseComponent: any,
  createElement: Function,
  contextTypes?: Object
): Function {
  return function connect(mapStylesToProps: Function): Function {
    return (component: any): any => {
      class EnhancedComponent extends BaseComponent {
        static displayName = generateDisplayName(component);

        render() {
          const { renderer, theme } = this.context

          const styles = mapStylesToProps({
            ...this.props,
            theme: theme || {}
          })(renderer)

          return createElement(component, {
            ...this.props,
            styles
          })
        }
      }

      if (contextTypes) {
        EnhancedComponent.contextTypes = {
          ...component.contextTypes,
          ...contextTypes
        }
      }

      return EnhancedComponent
    }
  }
}<commit_msg>change `connect(mapStylesToProps)` to be `connect(rules)`<commit_after>/* @flow */
import generateDisplayName from './generateDisplayName'

export default function connectFactory(
  BaseComponent: any,
  createElement: Function,
  contextTypes?: Object
): Function {
  return function connect(rules: Object): Function {
    return (component: any): any => {
      class EnhancedComponent extends BaseComponent {
        static displayName = generateDisplayName(component);

        render() {
          const { renderer, theme = {} } = this.context
          const styleProps = { ...this.props, theme }

          const styles = Object.keys(rules).reduce((sofar, key) => {
            const style = renderer.renderRule(rules[key], styleProps)
            return Object.assign(sofar, { [key]: style })
          }, {})

          const props = { ...this.props, styles }
          return createElement(component, props)
        }
      }

      if (contextTypes) {
        EnhancedComponent.contextTypes = {
          ...component.contextTypes,
          ...contextTypes
        }
      }

      return EnhancedComponent
    }
  }
}
{'fraction_non_alphanumeric': 0.10839328537170263, 'fraction_numerical': 0.0, 'mean_word_length': 2.2191358024691357, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '7229463', 'n_tokens_mistral': 536, 'n_tokens_neox': 520, 'n_words': 128}