"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _antd = require("antd");
var _ConfigContext = require("../ConfigContext");
var _useLanguage = require("../hooks/use-language");
var _style = _interopRequireDefault(require("./style"));
var _classnames = _interopRequireDefault(require("classnames"));
var _data = require("../data");
var _IconNode = _interopRequireDefault(require("../components/IconNode"));
var _ActionList = _interopRequireDefault(require("../StandardForm/ActionList"));
var _lodash = require("lodash");
var _ = require("./..");
var _RenderItemGroup = _interopRequireDefault(require("../FormComp/RenderItemGroup"));
var _TabForm = _interopRequireDefault(require("../StandardForm/TabForm"));
var _StepForm = _interopRequireDefault(require("../StandardForm/StepForm"));
var _excluded = ["children", "formPrefix", "formPostfix", "className", "style", "size", "type", "formItemGroup", "title", "open", "onSubmit", "onCancel", "onClose", "confirmLoading", "footer", "initialValues", "parseTransform", "dateFormatter", "getFormFields", "fieldStatus", "formLayout", "tabsConfig", "stepsConfig", "displayLayout", "itemGroupConfig", "hideRequiredMark"],
  _excluded2 = ["name", "type", "icon", "ghost", "disabled", "loading", "fn"];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
var StandardDrawer = function StandardDrawer(props) {
  var componentName = 'spec-standard-drawer';
  var _useStyle = (0, _style.default)(componentName),
    _useStyle2 = _slicedToArray(_useStyle, 2),
    wrapSSR = _useStyle2[0],
    hashId = _useStyle2[1];
  var lang = (0, _useLanguage.useLanguageObject)(); // 当前使用的语言包
  var InitFanContext = (0, _react.useContext)(_ConfigContext.FanContext);
  var providerConfig = InitFanContext['StandardDrawer'] || {}; // 使用上下文（全局配置）设置扩展的配置项
  var ConcatDrawerProps = _objectSpread(_objectSpread({}, providerConfig), props);
  var children = ConcatDrawerProps.children,
    formPrefix = ConcatDrawerProps.formPrefix,
    formPostfix = ConcatDrawerProps.formPostfix,
    className = ConcatDrawerProps.className,
    style = ConcatDrawerProps.style,
    _ConcatDrawerProps$si = ConcatDrawerProps.size,
    size = _ConcatDrawerProps$si === void 0 ? 'sm' : _ConcatDrawerProps$si,
    type = ConcatDrawerProps.type,
    formItemGroup = ConcatDrawerProps.formItemGroup,
    title = ConcatDrawerProps.title,
    open = ConcatDrawerProps.open,
    onSubmit = ConcatDrawerProps.onSubmit,
    onCancel = ConcatDrawerProps.onCancel,
    onClose = ConcatDrawerProps.onClose,
    confirmLoading = ConcatDrawerProps.confirmLoading,
    footer = ConcatDrawerProps.footer,
    initialValues = ConcatDrawerProps.initialValues,
    parseTransform = ConcatDrawerProps.parseTransform,
    dateFormatter = ConcatDrawerProps.dateFormatter,
    _getFormFields = ConcatDrawerProps.getFormFields,
    _ConcatDrawerProps$fi = ConcatDrawerProps.fieldStatus,
    fieldStatus = _ConcatDrawerProps$fi === void 0 ? 'default' : _ConcatDrawerProps$fi,
    _ConcatDrawerProps$fo = ConcatDrawerProps.formLayout,
    formLayout = _ConcatDrawerProps$fo === void 0 ? 'horizontal' : _ConcatDrawerProps$fo,
    tabsConfig = ConcatDrawerProps.tabsConfig,
    stepsConfig = ConcatDrawerProps.stepsConfig,
    displayLayout = ConcatDrawerProps.displayLayout,
    _ConcatDrawerProps$it = ConcatDrawerProps.itemGroupConfig,
    itemGroupConfig = _ConcatDrawerProps$it === void 0 ? {} : _ConcatDrawerProps$it,
    hideRequiredMark = ConcatDrawerProps.hideRequiredMark,
    otherProps = _objectWithoutProperties(ConcatDrawerProps, _excluded);

  // 通过useState控制按钮的禁用状态，结合setTimeout实现冷却时间（用于限制提交时不会重复点击）
  var _useState = (0, _react.useState)(false),
    _useState2 = _slicedToArray(_useState, 2),
    submitIsDisabled = _useState2[0],
    setSubmitIsDisabled = _useState2[1];
  var timerRef = (0, _react.useRef)(null);
  // setTabFormChild
  var _useState3 = (0, _react.useState)(),
    _useState4 = _slicedToArray(_useState3, 2),
    formChild = _useState4[0],
    setFormChild = _useState4[1]; // <---- set the ref when Form Rendered
  var _Form$useForm = _antd.Form.useForm(),
    _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
    drawerForm = _Form$useForm2[0];
  var drawerWidthOrHeight = (0, _react.useMemo)(function () {
    var widHeiBySize = 384;
    if (size === 'sm' || size === 'default') {
      widHeiBySize = _data.general.drawerSize['sm'].width || 384;
    }
    if (size === 'md') {
      widHeiBySize = _data.general.drawerSize['md'].width || 576;
    }
    if (size === 'lg' || size === 'large') {
      widHeiBySize = _data.general.drawerSize['lg'].width || 768;
    }
    if (size === 'xlg') {
      widHeiBySize = _data.general.drawerSize['xlg'].width || 960;
    }
    if ((otherProps === null || otherProps === void 0 ? void 0 : otherProps.placement) === 'top' || (otherProps === null || otherProps === void 0 ? void 0 : otherProps.placement) === 'bottom') {
      if (size === 'xlg') {
        return {
          height: '100vh'
        };
      }
      return {
        height: widHeiBySize
      };
    } else {
      return {
        width: widHeiBySize
      };
    }
  }, [size, otherProps === null || otherProps === void 0 ? void 0 : otherProps.width, otherProps === null || otherProps === void 0 ? void 0 : otherProps.height, otherProps === null || otherProps === void 0 ? void 0 : otherProps.placement]);
  var handleSubmit = (0, _lodash.debounce)(function () {
    if (!submitIsDisabled) {
      setSubmitIsDisabled(true);
      // cooldownRef.current = true;
      var _type = ConcatDrawerProps.type,
        _formItemGroup = ConcatDrawerProps.formItemGroup,
        _onSubmit = ConcatDrawerProps.onSubmit,
        _confirmLoading = ConcatDrawerProps.confirmLoading;
      if (_type === 'form' || _type === 'gridForm') {
        drawerForm.validateFields().then(function (values) {
          if (Object.prototype.hasOwnProperty.call(values, 'false')) {
            delete values.false; // 自定义结构会莫名的出来一个false字段
          }
          var resultValues = (0, _.UtilValueFormat)(values, _formItemGroup, dateFormatter);
          if (_onSubmit) {
            _onSubmit(_objectSpread({}, resultValues));
          }
        }).catch(function () {
          // 定位到第一条表单异常的
          var errorCollection = Array.prototype.slice.call(document.getElementsByClassName('ant-form-item-has-error'));
          if (errorCollection[0] && errorCollection[0].getElementsByTagName('input')) {
            Array.prototype.slice.call(errorCollection[0].getElementsByTagName('input'))[0].focus();
          }
          // console.error('表单填写有误', errorInfo, '第一条数据',errorInfo.errorFields[0].name[0])
        });
      } else if (_type === 'stepForm' || _type === 'tabForm') {
        // onSubmit && onSubmit()
        formChild.validateFields().then(function (values) {
          // console.log(values)
          if (Object.prototype.hasOwnProperty.call(values, 'false')) {
            delete values.false; // 自定义结构会莫名的出来一个false字段
          }
          var resultValues = (0, _.UtilValueFormat)(values, _formItemGroup, dateFormatter);
          if (_onSubmit) {
            _onSubmit(_objectSpread({}, resultValues));
          }
        }).catch(function () {
          // 定位到第一条表单异常的
          var errorCollection = Array.prototype.slice.call(document.getElementsByClassName('ant-form-item-has-error'));
          if (errorCollection[0] && errorCollection[0].getElementsByTagName('input')) {
            Array.prototype.slice.call(errorCollection[0].getElementsByTagName('input'))[0].focus();
          }
          // console.error('表单填写有误', errorInfo, '第一条数据',errorInfo.errorFields[0].name[0])
        });
      } else {
        // 没有表单数组 formItemGroup 配置
        _onSubmit && _onSubmit();
      }

      // @ts-ignore 设置1秒后解除禁用
      timerRef.current = setTimeout(function () {
        setSubmitIsDisabled(false);
      }, 1000);
    }
  }, 100);
  (0, _react.useEffect)(function () {
    return function () {
      if (timerRef.current) clearTimeout(timerRef.current);
    };
  }, []);
  var handleCancel = function handleCancel() {
    if (ConcatDrawerProps.hasOwnProperty('onClose')) {
      onClose === null || onClose === void 0 || onClose();
    } else {
      onCancel === null || onCancel === void 0 || onCancel();
    }
  };
  // 强制更新表单值，用于赋初始化实例值
  var forceUpdateForm = function forceUpdateForm() {
    _getFormFields && _getFormFields(drawerForm.getFieldsValue() || {}, drawerForm);
  };
  (0, _react.useEffect)(function () {
    if (open && drawerForm) {
      // <---- check ref before use the form instance
      if (initialValues && _typeof(initialValues) === 'object') {
        initialValues && drawerForm.setFieldsValue(parseTransform ? parseTransform(_objectSpread({}, initialValues)) : _objectSpread({}, initialValues));
        forceUpdateForm();
      }
    }
    // if (!open && drawerFormRef) {
    //   clearAllFieldsValue() // 清空表单传参数
    // }
  }, [drawerForm, open]);
  var handleStepType = function handleStepType(type, extraFunc) {
    var current = stepsConfig.current;
    switch (type) {
      case 'submit':
      case 'next':
        // 获取当前步骤的表单配置下有 rules 的控件进行校验（自定义的控件则自己有业务层面处理添加校验）
        // console.log('执行下一步骤，需要优先进行校验')
        var currentFields = (formItemGroup || [])[current].fields;
        var validatorGroup = currentFields && Array.isArray(currentFields) ? currentFields.map(function (fItem) {
          return fItem.rules ? fItem.filedName || fItem.filedName : null;
        }) : [];
        formChild.validateFields(validatorGroup).then(function () {
          // if (stepClick) stepClick(type, formChild, values);
          extraFunc && extraFunc();
        }).catch(function () {
          // console.log('表单校验不通过 ', errorFields.map(err => err))
        });
        break;
      case 'prev':
        // if (stepClick) stepClick(type, formChild);
        extraFunc && extraFunc();
        break;
      case 'cancel':
        // if (stepClick) stepClick(type, formChild);
        extraFunc && extraFunc();
        break;
      default:
        // extraFunc()
        break;
    }
  };
  // 重置所有表单
  var clearAllFieldsValue = function clearAllFieldsValue() {
    // let allFields = {}
    // Object.keys(drawerForm.getFieldsValue()).map((item) => allFields[item] = undefined)
    // drawerForm.setFieldsValue(allFields) // 直接清空表单的赋值(initialValues传值如果没有前后赋值没有全部带上所有字段，则会默认又使用之前的部分未传参字段)
    drawerForm.resetFields(); // 直接使用这个无效
  };
  var onAfterClose = function onAfterClose(curOpen) {
    var afterOpenChange = ConcatDrawerProps.afterOpenChange;
    if (type === 'form') clearAllFieldsValue();
    afterOpenChange === null || afterOpenChange === void 0 || afterOpenChange(curOpen);
  };
  var renderFormItemGroup = function renderFormItemGroup() {
    var fieldStatus = ConcatDrawerProps.fieldStatus,
      formItemGroup = ConcatDrawerProps.formItemGroup,
      _ConcatDrawerProps$si2 = ConcatDrawerProps.size,
      size = _ConcatDrawerProps$si2 === void 0 ? 'md' : _ConcatDrawerProps$si2,
      type = ConcatDrawerProps.type;
    if (Array.isArray(formItemGroup)) {
      if (type === 'gridForm') {
        // 栅格组
        return /*#__PURE__*/_react.default.createElement(_antd.Row, {
          gutter: 20
        }, (formItemGroup || []).map(function (item, index) {
          var childrenFields = item.fields || [];
          if (item.label) {
            childrenFields = [{
              type: item.type,
              label: item.label,
              protoConfig: _objectSpread({}, item.protoConfig)
              // protoConfig: { className: '', ...item.protoConfig }
            }].concat(childrenFields);
          }
          return /*#__PURE__*/_react.default.createElement(_antd.Col, {
            key: index,
            span: item.gridSpan || 24
          }, /*#__PURE__*/_react.default.createElement(_RenderItemGroup.default, _extends({
            size: size === 'lg' || size === 'large' ? 'md' : size === 'default' || size === 'md' ? 'sm' : size // lg也使用md排列成2列表单
            ,
            layout: formLayout,
            doUpdateFormFields: function doUpdateFormFields() {
              return forceUpdateForm();
            },
            displayLayout: item.displayLayout || displayLayout,
            itemGroup: childrenFields,
            fieldStatus: fieldStatus,
            form: drawerForm
          }, itemGroupConfig)));
        }));
      }
      return /*#__PURE__*/_react.default.createElement(_RenderItemGroup.default, _extends({
        size: size === 'lg' || size === 'large' ? 'md' : size === 'default' || size === 'md' ? 'sm' : size // lg也使用md排列成2列表单
        ,
        layout: formLayout,
        doUpdateFormFields: function doUpdateFormFields() {
          return forceUpdateForm();
        },
        displayLayout: displayLayout,
        itemGroup: formItemGroup,
        fieldStatus: fieldStatus,
        form: drawerForm
      }, itemGroupConfig));
    }
    return formItemGroup;
  };
  // 内容渲染
  var renderChildrenNodes = function renderChildrenNodes() {
    return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children, (type === 'form' || type === 'gridForm') && /*#__PURE__*/_react.default.createElement(_antd.Form, {
      layout: formLayout
      // ref={(formInstance)=> {
      //   // console.log('formInstance', formInstance)
      //   // setModalFormRef(formInstance)
      // }}
      ,
      form: drawerForm,
      onFinish: handleSubmit,
      hideRequiredMark: fieldStatus === 'viewOnly' || hideRequiredMark,
      initialValues: parseTransform ? parseTransform(_objectSpread({}, initialValues || {})) : _objectSpread({}, initialValues || {}) // 不传初始值，直接强制更新时会被重置掉
      ,
      scrollToFirstError: true,
      className: "drawerForm"
    }, formPrefix && /*#__PURE__*/_react.default.createElement(_antd.Row, null, formPrefix(drawerForm, ConcatDrawerProps, forceUpdateForm)), formItemGroup ? renderFormItemGroup() : null, formPostfix && /*#__PURE__*/_react.default.createElement(_antd.Row, null, formPostfix(drawerForm, ConcatDrawerProps, forceUpdateForm), " ")), type === 'tabForm' && /*#__PURE__*/_react.default.createElement(_TabForm.default, {
      grid: size,
      layout: formLayout,
      fieldStatus: fieldStatus,
      actionHide: true
      // @ts-ignore
      ,
      getFormFields: function getFormFields(fields, form) {
        setFormChild(form);
        _getFormFields && _getFormFields(fields, form);
      },
      formItemGroup: formItemGroup,
      tabsConfig: tabsConfig,
      onSubmit: handleSubmit,
      initialValues: _objectSpread({}, initialValues),
      parseTransform: parseTransform,
      displayLayout: displayLayout
    }), type === 'stepForm' && /*#__PURE__*/_react.default.createElement(_StepForm.default, {
      grid: size,
      layout: formLayout,
      fieldStatus: fieldStatus,
      actionHide: true
      // @ts-ignore
      ,
      getFormFields: function getFormFields(fields, form) {
        setFormChild(form);
        _getFormFields && _getFormFields(fields, form);
      },
      formItemGroup: formItemGroup,
      stepsConfig: stepsConfig,
      onSubmit: handleSubmit,
      initialValues: _objectSpread({}, initialValues),
      parseTransform: parseTransform,
      displayLayout: displayLayout
    }));
  };
  var renderButtonGroup = function renderButtonGroup() {
    var footerButtonGroup = ConcatDrawerProps.footerButtonGroup,
      confirmLoading = ConcatDrawerProps.confirmLoading,
      cancelText = ConcatDrawerProps.cancelText,
      confirmText = ConcatDrawerProps.confirmText,
      okText = ConcatDrawerProps.okText,
      okButtonProps = ConcatDrawerProps.okButtonProps,
      confirmButtonProps = ConcatDrawerProps.confirmButtonProps,
      cancelButtonProps = ConcatDrawerProps.cancelButtonProps;
    if (footerButtonGroup) {
      if (Array.isArray(footerButtonGroup)) {
        if (footerButtonGroup.length === 0) return null; // <div>按钮组合配置为空</div>
        return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, footerButtonGroup.map(function (item) {
          if (_typeof(item) === 'object' && !(item !== null && item !== void 0 && item.$$typeof)) {
            if (item.isHide) return null;
            var name = item.name,
              _type2 = item.type,
              icon = item.icon,
              ghost = item.ghost,
              disabled = item.disabled,
              loading = item.loading,
              fn = item.fn,
              others = _objectWithoutProperties(item, _excluded2);
            return /*#__PURE__*/_react.default.createElement(_antd.Button, _extends({
              key: name,
              type: _type2 || 'primary',
              icon: icon ? /*#__PURE__*/_react.default.createElement(_IconNode.default, {
                icon: icon
              }) : null,
              ghost: ghost,
              disabled: disabled,
              loading: loading,
              onClick: fn ? function (e) {
                return fn(item, drawerForm, ConcatDrawerProps, e);
              } : null
            }, others), name);
          } else {
            return item; // 如果是DOM，则直接渲染
          }
        }));
      }
      if (typeof footerButtonGroup === 'function') {
        return footerButtonGroup(drawerForm, ConcatDrawerProps);
      }
      return footerButtonGroup;
    }
    if (footer || ConcatDrawerProps.hasOwnProperty('footer')) return footer;
    if (fieldStatus === 'disabled' || fieldStatus === 'viewOnly') {
      return null;
    }
    return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_antd.Button, _extends({
      key: "submit",
      type: 'primary',
      disabled: submitIsDisabled,
      loading: confirmLoading,
      onClick: handleSubmit
    }, confirmButtonProps, okButtonProps), confirmText || okText || (lang === null || lang === void 0 ? void 0 : lang['global.confirm.text']) || '确定'), /*#__PURE__*/_react.default.createElement(_antd.Button, _extends({
      key: "back",
      onClick: handleCancel
    }, cancelButtonProps), cancelText || (lang === null || lang === void 0 ? void 0 : lang['global.cancel.text']) || '取消'));
  };
  var renderFooter = function renderFooter() {
    if (type === 'stepForm') {
      var _currentStepInfo$acti;
      // 过滤隐藏掉的步骤表单
      var currentStepInfo = (formItemGroup || []).filter(function (fItem) {
        return !fItem.hideStep;
      })[stepsConfig.current];
      return (currentStepInfo === null || currentStepInfo === void 0 || (_currentStepInfo$acti = currentStepInfo.actions) === null || _currentStepInfo$acti === void 0 ? void 0 : _currentStepInfo$acti.length) > 0 ? /*#__PURE__*/_react.default.createElement(_ActionList.default, {
        list: currentStepInfo.actions || [],
        onStep: handleStepType,
        form: formChild,
        other: ConcatDrawerProps
      }) : null;
    }
    if (type === 'tabForm') {
      var _activeTabInfo$action;
      var activeTabInfo = (formItemGroup || []).find(function (fItem) {
        return fItem.key === (tabsConfig === null || tabsConfig === void 0 ? void 0 : tabsConfig.activeKey);
      });
      return (activeTabInfo === null || activeTabInfo === void 0 || (_activeTabInfo$action = activeTabInfo.actions) === null || _activeTabInfo$action === void 0 ? void 0 : _activeTabInfo$action.length) > 0 ? /*#__PURE__*/_react.default.createElement(_ActionList.default, {
        list: (activeTabInfo === null || activeTabInfo === void 0 ? void 0 : activeTabInfo.actions) || [],
        form: formChild,
        other: ConcatDrawerProps
      }) : null;
    }
    return renderButtonGroup();
  };

  // @ts-ignore
  return wrapSSR( /*#__PURE__*/_react.default.createElement(_antd.Drawer, _extends({
    rootClassName: (0, _classnames.default)(componentName, className, fieldStatus === 'viewOnly' ? 'is-view' : '', hashId),
    closeIcon: null
  }, drawerWidthOrHeight, otherProps, {
    maskClosable: (type === 'form' || type === 'stepForm' || type === 'tabForm') && fieldStatus === 'default' ? false : otherProps.maskClosable,
    className: (0, _classnames.default)("spec-standard-drawer-content", className),
    open: open,
    title: title,
    footer: renderFooter(),
    afterOpenChange: onAfterClose,
    onClose: handleCancel
  }), renderChildrenNodes()));
};
var _default = exports.default = StandardDrawer;