import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
import React from 'react';
import { i18n } from '@fishx/i18n';
import { Modal, SimpleForm as Form, Input } from '@whalecloud/fdx';
import { ElementCreateType } from "../../../../constant";
import { toolFormAttr } from "../../../utils";

var SaveDialog = function SaveDialog(props) {
  var open = props.open,
      onClose = props.onClose,
      onSubmit = props.onSubmit;

  var _Form$useForm = Form.useForm(),
      _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
      form = _Form$useForm2[0];

  var handleOk = function handleOk() {
    var validateFields = form.validateFields;
    validateFields().then(function (values) {
      var data = values;
      data.type = ElementCreateType.LOCAL;
      onSubmit(data);
    }).catch(function (errorInfo) {});
  };

  return /*#__PURE__*/React.createElement(Modal, {
    title: i18n('PAGEBUIDER_BLOCK_SAVE_TITLE'),
    visible: open,
    onCancel: onClose,
    onOk: handleOk
  }, /*#__PURE__*/React.createElement(Form, Object.assign({}, toolFormAttr, {
    form: form
  }), /*#__PURE__*/React.createElement(Form.Item, {
    label: i18n('PAGEBUIDER_BLOCK_SAVE_NAME'),
    name: "name",
    rules: [{
      required: true,
      message: '请输入!'
    }]
  }, /*#__PURE__*/React.createElement(Input, {
    placeholder: "\u8BF7\u8F93\u5165\u533A\u5757\u6A21\u677F\u540D\u79F0\uFF08\u5FC5\u586B\uFF0C\u4E0D\u8981\u5305\u542B\u7A7A\u683C\uFF09"
  }))));
};

export default SaveDialog;
//# sourceMappingURL=SaveDialog.js.map