import _extends from "@babel/runtime/helpers/extends";
// Copyright 1999-2020. Plesk International GmbH. All rights reserved.
import React, { useContext } from 'react';
import classNames from 'classnames';
import { CLS_PREFIX } from '../../constants';
import VerticalContext from '../VerticalContext';

const normalize = value => String(Number(value)) === String(value) ? "".concat(value, "px") : value;
/**
 * `Column` component is a part of [Columns](#!/Columns).
 * @since 2.6.0
 */


const Column = ({
  baseClassName = "".concat(CLS_PREFIX, "columns__column"),
  className,
  children,
  fill,
  ratio,
  style,
  width,
  minWidth,
  maxWidth,
  ...props
}) => {
  const vertical = useContext(VerticalContext);
  return /*#__PURE__*/React.createElement("div", _extends({
    className: classNames(baseClassName, {
      ["".concat(baseClassName, "--fill")]: fill && !vertical,
      ["".concat(baseClassName, "--ratio-").concat(ratio)]: ratio && !vertical,
      ["".concat(baseClassName, "--has-width")]: width && !vertical
    }, className),
    style: vertical ? style : {
      width: normalize(width),
      flexBasis: normalize(minWidth),
      maxWidth: normalize(maxWidth),
      ...style
    }
  }, props), children);
};

export default Column;