var __assign = this && this.__assign || function () {
  __assign = Object.assign || function (t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
      s = arguments[i];

      for (var p in s) {
        if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
      }
    }

    return t;
  };

  return __assign.apply(this, arguments);
};

var __rest = this && this.__rest || function (s, e) {
  var t = {};

  for (var p in s) {
    if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
  }

  if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
    if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
  }
  return t;
};

import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import * as React from 'react';
import classNames from 'classnames';
import Icon from "../icon";
import "./style/form-item.css";
var prefixCls = 'dmc-form-item';
var FormItem = /*#__PURE__*/React.forwardRef(function (_a, ref) {
  var _b, _c, _d;

  var messageIcon = _a.messageIcon,
      label = _a.label,
      children = _a.children,
      position = _a.position,
      required = _a.required,
      message = _a.message,
      direction = _a.direction,
      extraNode = _a.extraNode,
      status = _a.status,
      block = _a.block,
      restProps = __rest(_a, ["messageIcon", "label", "children", "position", "required", "message", "direction", "extraNode", "status", "block"]);

  var requiredNode = required === true ? _jsx("div", __assign({
    className: prefixCls + "-required"
  }, {
    children: "*"
  }), void 0) : required;
  var iconNode = typeof messageIcon === 'string' ? _jsx(Icon, {
    icon: messageIcon,
    className: prefixCls + "-icon"
  }, void 0) : messageIcon;
  var itemCls = classNames(prefixCls, (_b = {}, _b[prefixCls + "-" + direction] = direction, _b[prefixCls + "-" + status] = status, _b[prefixCls + "-block"] = block, _b));
  var labelCls = classNames(prefixCls + "-label", (_c = {}, _c[prefixCls + "-label-" + position] = position, _c));
  var messageCls = classNames(prefixCls + "-message", (_d = {}, _d[prefixCls + "-message-" + status] = status, _d));
  return _jsxs("div", __assign({}, restProps, {
    className: itemCls,
    ref: ref
  }, {
    children: [_jsxs("div", __assign({
      className: labelCls
    }, {
      children: [requiredNode, _jsx("span", __assign({
        className: prefixCls + "-label-context"
      }, {
        children: label
      }), void 0)]
    }), void 0), _jsxs("div", __assign({
      className: prefixCls + "-message-wrapper"
    }, {
      children: [children, !!message && _jsxs("div", __assign({
        className: messageCls
      }, {
        children: [iconNode, _jsx("span", {
          children: message
        }, void 0)]
      }), void 0), extraNode]
    }), void 0)]
  }), void 0);
});
FormItem.displayName = 'FormItem';
export default FormItem;
var FormItemMemo = /*#__PURE__*/React.memo(FormItem);
FormItemMemo.displayName = 'FormItemMemo';
export { FormItemMemo };

