<commit_before>// Copyright (c) 2013-2016, the Clean project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// A Dart library for building UI using ReactJS.
library react;

/// Top-level ReactJS [Component class](https://facebook.github.io/react/docs/top-level-api.html#react.component)
/// which provides the [ReactJS Component API](https://facebook.github.io/react/docs/component-api.html)
abstract class Component {
  /// ReactJS `Component` props.
  Map props;

  /// Provides access to the underlying DOM representation of the [render]ed `Component`.
  dynamic ref;

  dynamic _jsRedraw;

  dynamic _jsThis;

  List _setStateCallbacks = [];

  List _transactionalSetStateCallbacks = [];

  /// The List of callbacks to be called after the component has been updated from a call to [setState].
  List get setStateCallbacks => _setStateCallbacks;

  /// The List of transactional `setState` callbacks to be called before the component updates.
  List get transactionalSetStateCallbacks => _transactionalSetStateCallbacks;

  /// The JavaScript [`ReactComponent`](https://facebook.github.io/react/docs/top-level-api.html#reactdom.render)
  /// instance of this `Component` returned by [render].
  dynamic get jsThis => _jsThis;

  /// Allows the [ReactJS `displayName` property](https://facebook.github.io/react/docs/component-specs.html#displayname)
  /// to be set for debugging purposes.
  String get displayName => runtimeType.toString();

  /// Bind the value of input to [state[key]].
  bind(key) => [state[key], (value) => setState({key: value})];

  initComponentInternal(props, _jsRedraw, [ref, _jsThis]) {
    this._jsRedraw = _jsRedraw;
    this.ref = ref;
    this._jsThis = _jsThis;
    _initProps(props);
  }

  _initProps(props) {
    this.props = new Map.from(props);
    this.nextProps = this.props;
  }

  initStateInternal() {
    this.state = new Map.from(getInitialState());
    // Call `transferComponentState` to get state also to `_prevState`
    transferComponentState();
  }

  /// ReactJS `Component` state.
  Map state = {};

  /// Private reference to the value of [state] from the previous render cycle.
  ///
  /// Useful for ReactJS lifecycle methods [shouldComponentUpdate], [componentWillUpdate] and [componentDidUpdate].
  Map _prevState = null;

  /// Private reference to the value of [state] for the upcoming render cycle.
  ///
  /// Useful for ReactJS lifecycle methods [shouldComponentUpdate], [componentWillUpdate] and [componentDidUpdate].
  Map _nextState = null;<commit_msg>Make fields private<commit_after>// Copyright (c) 2013-2016, the Clean project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

/// A Dart library for building UI using ReactJS.
library react;

import 'dart:html';

/// Top-level ReactJS [Component class](https://facebook.github.io/react/docs/top-level-api.html#react.component)
/// which provides the [ReactJS Component API](https://facebook.github.io/react/docs/component-api.html)
abstract class Component {
  Map _props;
  Map _state = {};
  dynamic _ref;

  /// ReactJS `Component` props.
  Map get props => _props;
  set props(Map value) => _props = value;

  /// ReactJS `Component` state.
  Map get state => _state;
  set state(Map value) => _state = value;

  /// Returns the component of the specified [ref].
  ///
  /// Returns a [Component] if it is a Dart component, otherwise returns an "Dom component" ([Element]).
  dynamic get ref => _ref;
  set ref(dynamic value) => _ref = value;

  dynamic _jsRedraw;

  dynamic _jsThis;

  List _setStateCallbacks = [];

  List _transactionalSetStateCallbacks = [];

  /// The List of callbacks to be called after the component has been updated from a call to [setState].
  List get setStateCallbacks => _setStateCallbacks;

  /// The List of transactional `setState` callbacks to be called before the component updates.
  List get transactionalSetStateCallbacks => _transactionalSetStateCallbacks;

  /// The JavaScript [`ReactComponent`](https://facebook.github.io/react/docs/top-level-api.html#reactdom.render)
  /// instance of this `Component` returned by [render].
  dynamic get jsThis => _jsThis;

  /// Allows the [ReactJS `displayName` property](https://facebook.github.io/react/docs/component-specs.html#displayname)
  /// to be set for debugging purposes.
  String get displayName => runtimeType.toString();

  /// Bind the value of input to [state[key]].
  bind(key) => [state[key], (value) => setState({key: value})];

  initComponentInternal(props, _jsRedraw, [ref, _jsThis]) {
    this._jsRedraw = _jsRedraw;
    this.ref = ref;
    this._jsThis = _jsThis;
    _initProps(props);
  }

  _initProps(props) {
    this.props = new Map.from(props);
    this.nextProps = this.props;
  }

  initStateInternal() {
    this.state = new Map.from(getInitialState());
    // Call `transferComponentState` to get state also to `_prevState`
    transferComponentState();
  }

  /// Private reference to the value of [state] from the previous render cycle.
  ///
  /// Useful for ReactJS lifecycle methods [shouldComponentUpdate], [componentWillUpdate] and [componentDidUpdate].
  Map _prevState = null;

  /// Private reference to the value of [state] for the upcoming render cycle.
  ///
  /// Useful for ReactJS lifecycle methods [shouldComponentUpdate], [componentWillUpdate] and [componentDidUpdate].
  Map _nextState = null;
{'fraction_non_alphanumeric': 0.1170080142475512, 'fraction_numerical': 0.0028495102404274266, 'mean_word_length': 3.691729323308271, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 8, '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': '6561317', 'n_tokens_mistral': 1641, 'n_tokens_neox': 1600, 'n_words': 539}