<commit_before>// @flow weak

import React, { Component, Children, cloneElement } from 'react';
import warning from 'warning';
import PropTypes from 'prop-types';
import compose from 'recompose/compose';
import classNames from 'classnames';
import EventListener from 'react-event-listener';
import debounce from 'lodash/debounce';
import ScrollbarSize from 'react-scrollbar-size';
import scroll from 'scroll';
import createStyleSheet from '../styles/createStyleSheet';
import withStyles from '../styles/withStyles';
import withWidth, { isWidthUp } from '../utils/withWidth';
import TabIndicator from './TabIndicator';
import TabScrollButton from './TabScrollButton';

export const styleSheet = createStyleSheet('MuiTabs', {
  root: {
    overflow: 'hidden',
  },
  flexContainer: {
    display: 'flex',
  },
  scrollingContainer: {
    display: 'inline-block',
    flex: '1 1 auto',
    whiteSpace: 'nowrap',
  },
  fixed: {
    overflowX: 'hidden',
    width: '100%',
  },
  scrollable: {
    overflowX: 'scroll',
  },
  centered: {
    justifyContent: 'center',
  },
});

/**
 * Notice that this Component is incompatible with server side rendering.
 */
class Tabs extends Component {
  static defaultProps = {
    centered: false,
    fullWidth: false,
    indicatorColor: 'accent',
    scrollable: false,
    scrollButtons: 'auto',
    textColor: 'inherit',
  };

  state = {
    indicatorStyle: {},
    scrollerStyle: {
      marginBottom: 0,
    },
    showLeftScroll: false,
    showRightScroll: false,
  };

  componentDidMount() {
    this.updateIndicatorState(this.props);
    this.updateScrollButtonState();
  }

  componentWillReceiveProps(nextProps) {
    if (this.props.index !== nextProps.index) {
      this.updateIndicatorState(nextProps);
    }
  }

  componentDidUpdate(prevProps, prevState) {
    if (
      this.props.width !== prevProps.width ||
      this.state.indicatorStyle !== prevState.indicatorStyle
    ) {
      this.scrollSelectedIntoView();
    }
  }

  componentWillUnmount() {
    this.handleResize.cancel();
    this.handleTabsScroll.cancel();
  }

  tabs = undefined;

  handleResize = debounce(() => {
    this.updateIndicatorState(this.props);
    this.updateScrollButtonState();
  }, 166);

  handleLeftScrollClick = () => {
    this.moveTabsScroll(-this.tabs.clientWidth);
  };

  handleRightScrollClick = () => {
    this.moveTabsScroll(this.tabs.clientWidth);
  };<commit_msg>[Tabs] Check scroll button status on update (#7576)<commit_after>// @flow weak

import React, { Component, Children, cloneElement } from 'react';
import warning from 'warning';
import PropTypes from 'prop-types';
import compose from 'recompose/compose';
import classNames from 'classnames';
import EventListener from 'react-event-listener';
import debounce from 'lodash/debounce';
import ScrollbarSize from 'react-scrollbar-size';
import scroll from 'scroll';
import createStyleSheet from '../styles/createStyleSheet';
import withStyles from '../styles/withStyles';
import withWidth, { isWidthUp } from '../utils/withWidth';
import TabIndicator from './TabIndicator';
import TabScrollButton from './TabScrollButton';

export const styleSheet = createStyleSheet('MuiTabs', {
  root: {
    overflow: 'hidden',
  },
  flexContainer: {
    display: 'flex',
  },
  scrollingContainer: {
    display: 'inline-block',
    flex: '1 1 auto',
    whiteSpace: 'nowrap',
  },
  fixed: {
    overflowX: 'hidden',
    width: '100%',
  },
  scrollable: {
    overflowX: 'scroll',
  },
  centered: {
    justifyContent: 'center',
  },
});

/**
 * Notice that this Component is incompatible with server side rendering.
 */
class Tabs extends Component {
  static defaultProps = {
    centered: false,
    fullWidth: false,
    indicatorColor: 'accent',
    scrollable: false,
    scrollButtons: 'auto',
    textColor: 'inherit',
  };

  state = {
    indicatorStyle: {},
    scrollerStyle: {
      marginBottom: 0,
    },
    showLeftScroll: false,
    showRightScroll: false,
  };

  componentDidMount() {
    this.updateIndicatorState(this.props);
    this.updateScrollButtonState();
  }

  componentWillReceiveProps(nextProps) {
    if (this.props.index !== nextProps.index) {
      this.updateIndicatorState(nextProps);
    }
  }

  componentDidUpdate(prevProps, prevState) {
    this.updateScrollButtonState();
    if (
      this.props.width !== prevProps.width ||
      this.state.indicatorStyle !== prevState.indicatorStyle
    ) {
      this.scrollSelectedIntoView();
    }
  }

  componentWillUnmount() {
    this.handleResize.cancel();
    this.handleTabsScroll.cancel();
  }

  tabs = undefined;

  handleResize = debounce(() => {
    this.updateIndicatorState(this.props);
    this.updateScrollButtonState();
  }, 166);

  handleLeftScrollClick = () => {
    this.moveTabsScroll(-this.tabs.clientWidth);
  };

  handleRightScrollClick = () => {
    this.moveTabsScroll(this.tabs.clientWidth);
  };
{'fraction_non_alphanumeric': 0.13253257328990228, 'fraction_numerical': 0.004478827361563518, 'mean_word_length': 3.670152091254753, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '758692', 'n_tokens_mistral': 1500, 'n_tokens_neox': 1476, 'n_words': 328}