<commit_before>import React, { Component } from 'react';
import classnames from 'classnames';
import { BaseInputNumberProps } from './PropsType';
import Events from '../utils/events';
import KeyboardPicker from '../KeyboardPicker';

declare const document;

export interface InputNumberProps extends BaseInputNumberProps {
  prefixCls?: string;
  className?: string;
}

export default class InputNumber extends Component<InputNumberProps, any> {

  static defaultProps = {
    prefixCls: 'za-input',
    disabled: false,
  };

  private input;

  constructor(props) {
    super(props);
    this.state = {
      visible: false,
      value: props.value || props.defaultValue || '',
    };
  }

  componentDidMount() {
    Events.on(document.body, 'touchstart', this.onClosePicker);
  }

  componentWillUnmount() {
    Events.off(document.body, 'touchstart', this.onClosePicker);
  }

  closest = (el, selector) => {
    const matchesSelector = el.matches || el.webkitMatchesSelector || el.mozMatchesSelector || el.msMatchesSelector;
    while (el) {
      if (matchesSelector.call(el, selector)) {
        return el;
      } else {
        el = el.parentElement;
      }
    }
    return null;
  }

  onClosePicker = (e) => {
    if (!this.input || !this.state.visible) {
      return;
    }

    const pNode = this.closest(e.target, '.za-keyboard');

    if (!pNode) {
      this.close();
    }
  }

  onFocus = () => {
    document.activeElement.blur();
    this.open();
  }

  onKeyClick = (key) => {
    const value = this.state.value;
    const newValue = (key === 'delete')
      ? value.slice(0, value.length - 1)
      : value + key;

    if (newValue !== value) {
      const { onChange } = this.props;
      this.setState({ value: newValue });

      if (typeof onChange === 'function') {
        onChange(newValue);
      }
    }
  }

  open = () => {
    this.setState({ visible: true });
    // KeyboardPicker.show({
    //   visible: true,
    //   type: this.props.type,
    //   onKeyClick: this.onKeyClick,
    // });
  }

  close = () => {
    this.setState({ visible: false });
    // KeyboardPicker.hide();
  }

  render() {
    const { prefixCls, className, type, disabled, defaultValue, placeholder, ...others } = this.props;
    const { visible, value } = this.state;
<commit_msg>remove unused code<commit_after>import React, { Component } from 'react';
import classnames from 'classnames';
import { BaseInputNumberProps } from './PropsType';
import Events from '../utils/events';
import KeyboardPicker from '../KeyboardPicker';

declare const document;

export interface InputNumberProps extends BaseInputNumberProps {
  prefixCls?: string;
  className?: string;
}

export default class InputNumber extends Component<InputNumberProps, any> {

  static defaultProps = {
    prefixCls: 'za-input',
    disabled: false,
  };

  private input;

  constructor(props) {
    super(props);
    this.state = {
      visible: false,
      value: props.value || props.defaultValue || '',
    };
  }

  componentDidMount() {
    Events.on(document.body, 'touchstart', this.onClosePicker);
  }

  componentWillUnmount() {
    Events.off(document.body, 'touchstart', this.onClosePicker);
  }

  closest = (el, selector) => {
    const matchesSelector = el.matches || el.webkitMatchesSelector || el.mozMatchesSelector || el.msMatchesSelector;
    while (el) {
      if (matchesSelector.call(el, selector)) {
        return el;
      } else {
        el = el.parentElement;
      }
    }
    return null;
  }

  onClosePicker = (e) => {
    if (!this.input || !this.state.visible) {
      return;
    }

    const pNode = this.closest(e.target, '.za-keyboard');

    if (!pNode) {
      this.close();
    }
  }

  onFocus = () => {
    document.activeElement.blur();
    this.open();
  }

  onKeyClick = (key) => {
    const value = this.state.value;
    const newValue = (key === 'delete')
      ? value.slice(0, value.length - 1)
      : value + key;

    if (newValue !== value) {
      const { onChange } = this.props;
      this.setState({ value: newValue });

      if (typeof onChange === 'function') {
        onChange(newValue);
      }
    }
  }

  open = () => {
    this.setState({ visible: true });
  }

  close = () => {
    this.setState({ visible: false });
  }

  render() {
    const { prefixCls, className, type, disabled, defaultValue, placeholder, ...others } = this.props;
    const { visible, value } = this.state;

{'fraction_non_alphanumeric': 0.14825646794150732, 'fraction_numerical': 0.0008998875140607424, 'mean_word_length': 2.7142857142857144, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '7127547', 'n_tokens_mistral': 1395, 'n_tokens_neox': 1370, 'n_words': 312}