import _extends from '@babel/runtime/helpers/extends';
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
import PropTypes from 'prop-types';
import React__default, { useCallback } from 'react';
import { SideNavMenu } from '@carbon/react';
import classnames from 'classnames';
import { settings } from '../../constants/Settings.js';

var _excluded = ["children", "isFiltering", "testId", "className"];
var iotPrefix = settings.iotPrefix;
var propTypes = {
  children: PropTypes.node.isRequired,
  isFiltering: PropTypes.bool.isRequired,
  className: PropTypes.string
};
var defaultProps = {
  className: ''
};
var FilterableSideNavMenu = function FilterableSideNavMenu(_ref) {
  var children = _ref.children,
    isFiltering = _ref.isFiltering,
    testId = _ref.testId,
    className = _ref.className,
    myProps = _objectWithoutProperties(_ref, _excluded);
  // Unfortunately there is other way to set tabindex
  // without modifying the Carbon SideNavMenu source code.
  // TODO: create carbon issue for that
  var callbackRef = useCallback(function (menuElement) {
    if (menuElement !== null && isFiltering) {
      menuElement.setAttribute('tabIndex', -1);
    }
  }, [isFiltering]);
  var sideNavMenu = /*#__PURE__*/React__default.createElement(SideNavMenu, _extends({
    "data-testid": testId,
    ref: callbackRef,
    defaultExpanded: isFiltering,
    isSideNavExpanded: true,
    className: classnames(className, _defineProperty({}, "".concat(iotPrefix, "--side-nav__item--is-filtering"), isFiltering))
  }, myProps), children);
  return sideNavMenu;
};
FilterableSideNavMenu.propTypes = propTypes;
FilterableSideNavMenu.defautProps = defaultProps;
FilterableSideNavMenu.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "FilterableSideNavMenu",
  "props": {
    "children": {
      "description": "",
      "type": {
        "name": "node"
      },
      "required": true
    },
    "isFiltering": {
      "description": "",
      "type": {
        "name": "bool"
      },
      "required": true
    },
    "className": {
      "description": "",
      "type": {
        "name": "string"
      },
      "required": false
    }
  }
};
var FilterableSideNavMenu$1 = FilterableSideNavMenu;

export { FilterableSideNavMenu$1 as default };
