import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
import { createBEM } from '@zarm-design/bem';
import * as React from 'react';
import { ConfigContext } from '../config-provider';
import Keyboard from '../keyboard';
import Popup from '../popup';
import SafeArea from '../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 = _objectWithoutProperties(props, ["className", "style", "visible", "destroy", "safeArea"]);

  var keyboardPickerRef = ref || /*#__PURE__*/React.createRef();

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

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

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