<commit_before>import React from 'react';
import PropTypes from 'prop-types';
import { DragLayer as LibDragLayer } from 'react-dnd';
import DragItemPreviewContainer from './styles/DragItemPreviewContainer';
import DragLayerOverlay from './styles/DragLayerOverlay';
import { DragContext } from 'components/DragContainer';
import { identity } from 'lodash';

/**
 * Renders a generic layer for drawing dragged items from draggable
 * components.
 */
class DragLayer extends React.Component {
  static propTypes = {
    /**
     * Provided by DragGroupItem via drag context.
     * Contains details needed to render an item preview
     */
    item: PropTypes.shape({
      children: PropTypes.node.isRequired,
      dimensions: PropTypes.shape({
        width: PropTypes.number.isRequired,
        height: PropTypes.number.isRequired,
      }).isRequired,
    }),
    /**
     * Provided by
     * Offset values for the position of the dragged preview
     * item
     */
    clientOffset: PropTypes.object,

    /**
     * Override the presentational component which renders the full-screen
     * overlay
     */
    Overlay: PropTypes.func,
    /**
     * Override the presentational component which positions and sizes
     * the preview element
     */
    PreviewContainer: PropTypes.func,
  };

  static defaultProps = {
    item: null,
    clientOffset: null,
    Overlay: DragLayerOverlay,
    PreviewContainer: DragItemPreviewContainer,
  };

  renderPreviewContent = () => {
    const { item } = this.props;

    return React.Children.map(
      item.children,
      child =>
        child ? React.cloneElement(child, { wrapDragHandle: identity }) : null,
    );
  };

  render() {
    const {
      item,
      clientOffset,
      Overlay,
      PreviewContainer,
      Cutout,
    } = this.props;

    if (!item || !clientOffset) {
      return <Overlay />;
    }

    const previewPositionStyles = {
      transform: `translate(${clientOffset.x}px, ${clientOffset.y}px)`,
      width: item.dimensions.width + 'px',
      height: item.dimensions.height + 'px',
    };
<commit_msg>drag layer undefined dimensions fix<commit_after>import React from 'react';
import PropTypes from 'prop-types';
import { DragLayer as LibDragLayer } from 'react-dnd';
import DragItemPreviewContainer from './styles/DragItemPreviewContainer';
import DragLayerOverlay from './styles/DragLayerOverlay';
import { DragContext } from 'components/DragContainer';
import { identity } from 'lodash';

/**
 * Renders a generic layer for drawing dragged items from draggable
 * components.
 */
class DragLayer extends React.Component {
  static propTypes = {
    /**
     * Provided by DragGroupItem via drag context.
     * Contains details needed to render an item preview
     */
    item: PropTypes.shape({
      children: PropTypes.node,
      dimensions: PropTypes.shape({
        width: PropTypes.number,
        height: PropTypes.number,
      }),
    }),
    /**
     * Provided by
     * Offset values for the position of the dragged preview
     * item
     */
    clientOffset: PropTypes.object,

    /**
     * Override the presentational component which renders the full-screen
     * overlay
     */
    Overlay: PropTypes.func,
    /**
     * Override the presentational component which positions and sizes
     * the preview element
     */
    PreviewContainer: PropTypes.func,
  };

  static defaultProps = {
    item: null,
    clientOffset: null,
    Overlay: DragLayerOverlay,
    PreviewContainer: DragItemPreviewContainer,
  };

  renderPreviewContent = () => {
    const { item } = this.props;

    return (
      item.children &&
      React.Children.map(
        item.children,
        child =>
          child
            ? React.cloneElement(child, { wrapDragHandle: identity })
            : null,
      )
    );
  };

  render() {
    const {
      item,
      clientOffset,
      Overlay,
      PreviewContainer,
      Cutout,
    } = this.props;

    if (!item || !clientOffset) {
      return <Overlay />;
    }

    const previewPositionStyles = {
      transform: `translate(${clientOffset.x}px, ${clientOffset.y}px)`,
      width: item.dimensions ? item.dimensions.width + 'px' : '0px',
      height: item.dimensions ? item.dimensions.height + 'px' : '0px',
    };

{'fraction_non_alphanumeric': 0.1062835786031301, 'fraction_numerical': 0.000467180565288484, 'mean_word_length': 2.6598290598290597, 'pattern_counts': {'":': 0, '<': 5, '<?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': '6630575', 'n_tokens_mistral': 1181, 'n_tokens_neox': 1183, 'n_words': 322}