<commit_before>import React from 'react';
import ReactDOM from 'react-dom';

import Notification from './Notification';

const className = '.el-notification';

export default function NotificationCenter(props = {}, type) {
  const div = document.createElement('div');

  document.body.appendChild(div);

  if (typeof props === 'string' || React.isValidElement(props)) {
    props = {
      message: props
    };
  }

  if (type) {
    props.type = type;
  }

  if (!props.offset) {
    props.offset = 0
  }

  const instances = document.querySelectorAll(className)

  const lastInstance = instances[instances.length - 1];

  props.top = (lastInstance ? (parseInt(lastInstance.style.top) + lastInstance.offsetHeight) : props.offset) + 16;

  const element = React.createElement(Notification, Object.assign({}, props, {
    willUnmount(height, top) {
      ReactDOM.unmountComponentAtNode(div);
      document.body.removeChild(div);

      requestAnimationFrame(() => {
        const instances = document.querySelectorAll(className);

        for (let i = 0, len = instances.length; i < len; i++) {
          const element = instances[i];

          if (element.offsetTop > top) {
            element.style.top = `${element.offsetTop - height - 16}px`;
          }
        }
      })
    }
  }));

  ReactDOM.render(element, div);
}

/* eslint-disable */<commit_msg>Notification: 修复连续弹出时可能错位的问题<commit_after>import React from 'react';
import ReactDOM from 'react-dom';

import Notification from './Notification';

const className = '.el-notification';

export default function NotificationCenter(props = {}, type) {
  const div = document.createElement('div');

  document.body.appendChild(div);

  if (typeof props === 'string' || React.isValidElement(props)) {
    props = {
      message: props
    };
  }

  if (type) {
    props.type = type;
  }

  if (!props.offset) {
    props.offset = 0
  }

  const instances = document.querySelectorAll(className)

  const lastInstance = instances[instances.length - 1];

  props.top = (lastInstance ? (parseInt(lastInstance.style.top) + lastInstance.offsetHeight) : props.offset) + 16;

  const element = React.createElement(Notification, Object.assign({}, props, {
    willUnmount(height, top) {
      ReactDOM.unmountComponentAtNode(div);
      document.body.removeChild(div);

      requestAnimationFrame(() => {
        const instances = document.querySelectorAll(className);

        for (let i = 0, len = instances.length; i < len; i++) {
          const element = instances[i];
          const elementTop = parseInt(element.style.top);

          if (elementTop > top) {
            element.style.top = `${elementTop - height - 16}px`;
          }
        }
      })
    }
  }));

  ReactDOM.render(element, div);
}

/* eslint-disable */
{'fraction_non_alphanumeric': 0.1374237531395766, 'fraction_numerical': 0.005023322569070686, 'mean_word_length': 3.0289017341040463, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '4215185', 'n_tokens_mistral': 839, 'n_tokens_neox': 819, 'n_words': 180}