import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
import React from "react";
import { connect } from "react-redux";
import isEqual from "lodash/isEqual"; // import moment from 'moment';

import { SimpleForm as Form } from '@whalecloud/fdx';
import LabelEdit from "../plugins/elementSettings/components/LabelRender";
import { getParentFormWidthChildren } from "../selectors";

var FormItem = function FormItem(props) {
  if (!props.parentIsForm) {
    return props.children;
  }

  var id = props.id,
      label = props.label,
      formData = props.formData,
      restProps = _objectWithoutProperties(props, ["id", "label", "formData"]);

  return /*#__PURE__*/React.createElement(Form.Item, Object.assign({
    className: !label ? 'no-label' : null
  }, restProps, {
    label: /*#__PURE__*/React.createElement(LabelEdit, {
      label: label,
      formData: formData
    })
  }), props.children);
};

export default connect(function (state, props) {
  var formElement = getParentFormWidthChildren(state, props.id);
  var parentIsForm = (formElement === null || formElement === void 0 ? void 0 : formElement.type) === 'form';
  return {
    parentIsForm: parentIsForm,
    formData: parentIsForm && (formElement === null || formElement === void 0 ? void 0 : formElement.data) || {}
  };
}, null, null, {
  areStatePropsEqual: isEqual
})( /*#__PURE__*/React.memo(FormItem));
//# sourceMappingURL=FormItem.js.map