"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ArrowKeyNavigationProvider = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _react = _interopRequireDefault(require("react"));
var _uiReact = require("../../ui-react");
var _ColorPaletteArrowKeyNavigationProvider = require("./ColorPaletteArrowKeyNavigationProvider");
var _MenuArrowKeyNavigationProvider = require("./MenuArrowKeyNavigationProvider");
var _types = require("./types");
var _excluded = ["children", "type"];
var ArrowKeyNavigationProvider = exports.ArrowKeyNavigationProvider = function ArrowKeyNavigationProvider(props) {
  var children = props.children,
    type = props.type,
    restProps = (0, _objectWithoutProperties2.default)(props, _excluded);
  if (type === _types.ArrowKeyNavigationType.COLOR) {
    return /*#__PURE__*/_react.default.createElement(_uiReact.ReactEditorViewContext.Consumer, null, function (_ref) {
      var editorView = _ref.editorView,
        editorRef = _ref.editorRef;
      return editorRef && /*#__PURE__*/_react.default.createElement(_ColorPaletteArrowKeyNavigationProvider.ColorPaletteArrowKeyNavigationProvider, (0, _extends2.default)({
        selectedRowIndex: props.selectedRowIndex,
        selectedColumnIndex: props.selectedColumnIndex,
        isOpenedByKeyboard: props.isOpenedByKeyboard,
        isPopupPositioned: props.isPopupPositioned,
        editorRef: editorRef
      }, restProps), children);
    });
  }
  return /*#__PURE__*/_react.default.createElement(_uiReact.ReactEditorViewContext.Consumer, null, function (_ref2) {
    var editorView = _ref2.editorView,
      editorRef = _ref2.editorRef;
    return editorRef && /*#__PURE__*/_react.default.createElement(_MenuArrowKeyNavigationProvider.MenuArrowKeyNavigationProvider, (0, _extends2.default)({
      editorRef: editorRef
    }, restProps), children);
  });
};