"use strict";

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

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

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

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

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

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

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

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

var _keyboard = _interopRequireDefault(require("../keyboard"));

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

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

var KeyboardPicker = /*#__PURE__*/React.forwardRef(function (props, ref) {
  var className = props.className,
      style = props.style,
      visible = props.visible,
      destroy = props.destroy,
      safeArea = props.safeArea,
      restProps = (0, _objectWithoutProperties2.default)(props, ["className", "style", "visible", "destroy", "safeArea"]);
  var keyboardPickerRef = ref || /*#__PURE__*/React.createRef();

  var _React$useState = React.useState(visible),
      _React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
      currentVisible = _React$useState2[0],
      setCurrentVisible = _React$useState2[1];

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

  var bem = (0, _bem.createBEM)('keyboard-picker', {
    prefixCls: prefixCls
  });
  var cls = bem([className]);
  React.useEffect(function () {
    setCurrentVisible(visible);
  }, [visible]);
  return /*#__PURE__*/React.createElement(_popup.default, {
    ref: keyboardPickerRef,
    visible: currentVisible,
    mask: false,
    lockScroll: false,
    destroy: destroy
  }, /*#__PURE__*/React.createElement("div", {
    className: cls,
    style: style
  }, /*#__PURE__*/React.createElement(_keyboard.default, restProps), (safeArea !== null && safeArea !== void 0 ? safeArea : globalSafeArea) && /*#__PURE__*/React.createElement(_safeArea.default, {
    position: "bottom"
  })));
});
KeyboardPicker.displayName = 'KeyboardPicker';
KeyboardPicker.defaultProps = {
  visible: false,
  type: 'number',
  destroy: true
};
var _default = KeyboardPicker;
exports.default = _default;