Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DropdownToggle.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import PropTypes from 'prop-types';
  2. import React from 'react';
  3. import DropdownContext from './DropdownContext';
  4. var propTypes = {
  5. /**
  6. * A render prop that returns a Toggle element. The `props`
  7. * argument should spread through to **a component that can accept a ref**. Use
  8. * the `onToggle` argument to toggle the menu open or closed
  9. *
  10. * @type {Function ({
  11. * show: boolean,
  12. * toggle: (show: boolean) => void,
  13. * props: {
  14. * ref: (?HTMLElement) => void,
  15. * aria-haspopup: true
  16. * aria-expanded: boolean
  17. * },
  18. * }) => React.Element}
  19. */
  20. children: PropTypes.func.isRequired
  21. };
  22. function DropdownToggle(_ref) {
  23. var children = _ref.children;
  24. return React.createElement(DropdownContext.Consumer, null, function (_ref2) {
  25. var show = _ref2.show,
  26. toggle = _ref2.toggle,
  27. toggleRef = _ref2.toggleRef;
  28. return children({
  29. show: show,
  30. toggle: toggle,
  31. props: {
  32. ref: toggleRef,
  33. 'aria-haspopup': true,
  34. 'aria-expanded': !!show
  35. }
  36. });
  37. });
  38. }
  39. DropdownToggle.displayName = 'ReactOverlaysDropdownToggle';
  40. DropdownToggle.propTypes = propTypes;
  41. export default DropdownToggle;