"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _bem = require("@zarm-design/bem");

var React = _interopRequireWildcard(require("react"));

var _configProvider = require("../config-provider");

var _popup = _interopRequireDefault(require("../popup"));

var _safeArea = _interopRequireDefault(require("../safe-area"));

var _utils = require("../utils");

var PickerContainer = /*#__PURE__*/React.forwardRef(function (props, ref) {
  var className = props.className,
      style = props.style,
      visible = props.visible,
      title = props.title,
      confirmText = props.confirmText,
      cancelText = props.cancelText,
      maskClosable = props.maskClosable,
      forceRender = props.forceRender,
      destroy = props.destroy,
      safeArea = props.safeArea,
      mountContainer = props.mountContainer,
      onConfirm = props.onConfirm,
      onCancel = props.onCancel,
      onClose = props.onClose,
      afterOpen = props.afterOpen,
      afterClose = props.afterClose,
      children = props.children;

  var _React$useContext = React.useContext(_configProvider.ConfigContext),
      prefixCls = _React$useContext.prefixCls,
      locale = _React$useContext.locale,
      globalSafeArea = _React$useContext.safeArea;

  var bem = (0, _bem.createBEM)('picker', {
    prefixCls: prefixCls
  });
  return /*#__PURE__*/React.createElement(_popup.default, {
    ref: ref,
    visible: visible,
    onMaskClick: maskClosable ? onClose : _utils.noop,
    mountContainer: mountContainer,
    forceRender: forceRender,
    destroy: destroy,
    afterOpen: afterOpen,
    afterClose: afterClose
  }, /*#__PURE__*/React.createElement("div", {
    className: bem('', [className]),
    style: style,
    onClick: function onClick(event) {
      event.stopPropagation();
    }
  }, /*#__PURE__*/React.createElement("div", {
    className: bem('header')
  }, /*#__PURE__*/React.createElement("div", {
    className: bem('cancel'),
    onClick: function onClick() {
      return onCancel === null || onCancel === void 0 ? void 0 : onCancel();
    }
  }, cancelText || (locale === null || locale === void 0 ? void 0 : locale.Picker.cancelText)), /*#__PURE__*/React.createElement("div", {
    className: bem('title')
  }, title || (locale === null || locale === void 0 ? void 0 : locale.Picker.title)), /*#__PURE__*/React.createElement("div", {
    className: bem('confirm'),
    onClick: function onClick() {
      return onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm();
    }
  }, confirmText || (locale === null || locale === void 0 ? void 0 : locale.Picker.confirmText))), /*#__PURE__*/React.createElement("div", {
    className: bem('body')
  }, children), (safeArea !== null && safeArea !== void 0 ? safeArea : globalSafeArea) && /*#__PURE__*/React.createElement(_safeArea.default, {
    position: "bottom"
  })));
});
var _default = PickerContainer;
exports.default = _default;