import _extends from "@babel/runtime/helpers/extends";
import React from 'react';
import { ReactEditorViewContext } from '../../ui-react';
import { ColorPaletteArrowKeyNavigationProvider } from './ColorPaletteArrowKeyNavigationProvider';
import { MenuArrowKeyNavigationProvider } from './MenuArrowKeyNavigationProvider';
import { ArrowKeyNavigationType } from './types';
export const ArrowKeyNavigationProvider = props => {
  const {
    children,
    type,
    ...restProps
  } = props;
  if (type === ArrowKeyNavigationType.COLOR) {
    return /*#__PURE__*/React.createElement(ReactEditorViewContext.Consumer, null, ({
      editorView,
      editorRef
    }) => editorRef && /*#__PURE__*/React.createElement(ColorPaletteArrowKeyNavigationProvider, _extends({
      selectedRowIndex: props.selectedRowIndex,
      selectedColumnIndex: props.selectedColumnIndex,
      isOpenedByKeyboard: props.isOpenedByKeyboard,
      isPopupPositioned: props.isPopupPositioned,
      editorRef: editorRef
    }, restProps), children));
  }
  return /*#__PURE__*/React.createElement(ReactEditorViewContext.Consumer, null, ({
    editorView,
    editorRef
  }) => editorRef && /*#__PURE__*/React.createElement(MenuArrowKeyNavigationProvider, _extends({
    editorRef: editorRef
  }, restProps), children));
};