Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

709 строки
22 KiB

  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. var _extends2 = require('babel-runtime/helpers/extends');
  6. var _extends3 = _interopRequireDefault(_extends2);
  7. var _objectWithoutProperties2 = require('babel-runtime/helpers/objectWithoutProperties');
  8. var _objectWithoutProperties3 = _interopRequireDefault(_objectWithoutProperties2);
  9. var _toArray2 = require('babel-runtime/helpers/toArray');
  10. var _toArray3 = _interopRequireDefault(_toArray2);
  11. var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
  12. var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
  13. var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
  14. var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
  15. var _createClass2 = require('babel-runtime/helpers/createClass');
  16. var _createClass3 = _interopRequireDefault(_createClass2);
  17. var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
  18. var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
  19. var _inherits2 = require('babel-runtime/helpers/inherits');
  20. var _inherits3 = _interopRequireDefault(_inherits2);
  21. var _simpleAssign = require('simple-assign');
  22. var _simpleAssign2 = _interopRequireDefault(_simpleAssign);
  23. var _react = require('react');
  24. var _react2 = _interopRequireDefault(_react);
  25. var _propTypes = require('prop-types');
  26. var _propTypes2 = _interopRequireDefault(_propTypes);
  27. var _reactDom = require('react-dom');
  28. var _reactDom2 = _interopRequireDefault(_reactDom);
  29. var _shallowEqual = require('recompose/shallowEqual');
  30. var _shallowEqual2 = _interopRequireDefault(_shallowEqual);
  31. var _ClickAwayListener = require('../internal/ClickAwayListener');
  32. var _ClickAwayListener2 = _interopRequireDefault(_ClickAwayListener);
  33. var _keycode = require('keycode');
  34. var _keycode2 = _interopRequireDefault(_keycode);
  35. var _propTypes3 = require('../utils/propTypes');
  36. var _propTypes4 = _interopRequireDefault(_propTypes3);
  37. var _List = require('../List/List');
  38. var _List2 = _interopRequireDefault(_List);
  39. var _menuUtils = require('./menuUtils');
  40. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  41. function getStyles(props, context) {
  42. var desktop = props.desktop,
  43. maxHeight = props.maxHeight,
  44. width = props.width;
  45. var muiTheme = context.muiTheme;
  46. var styles = {
  47. root: {
  48. // Nested div because the List scales x faster than it scales y
  49. zIndex: muiTheme.zIndex.menu,
  50. maxHeight: maxHeight,
  51. overflowY: maxHeight ? 'auto' : null
  52. },
  53. divider: {
  54. marginTop: 7,
  55. marginBottom: 8
  56. },
  57. list: {
  58. display: 'table-cell',
  59. paddingBottom: desktop ? 16 : 8,
  60. paddingTop: desktop ? 16 : 8,
  61. userSelect: 'none',
  62. width: width
  63. },
  64. selectedMenuItem: {
  65. color: muiTheme.menuItem.selectedTextColor
  66. }
  67. };
  68. return styles;
  69. }
  70. var Menu = function (_Component) {
  71. (0, _inherits3.default)(Menu, _Component);
  72. function Menu(props, context) {
  73. (0, _classCallCheck3.default)(this, Menu);
  74. var _this = (0, _possibleConstructorReturn3.default)(this, (Menu.__proto__ || (0, _getPrototypeOf2.default)(Menu)).call(this, props, context));
  75. _initialiseProps.call(_this);
  76. var filteredChildren = _this.getFilteredChildren(props.children);
  77. var selectedIndex = _this.getLastSelectedIndex(props, filteredChildren);
  78. var newFocusIndex = props.disableAutoFocus ? -1 : selectedIndex >= 0 ? selectedIndex : 0;
  79. if (newFocusIndex !== -1 && props.onMenuItemFocusChange) {
  80. props.onMenuItemFocusChange(null, newFocusIndex);
  81. }
  82. _this.state = {
  83. focusIndex: newFocusIndex,
  84. isKeyboardFocused: props.initiallyKeyboardFocused,
  85. keyWidth: props.desktop ? 64 : 56
  86. };
  87. _this.hotKeyHolder = new _menuUtils.HotKeyHolder();
  88. return _this;
  89. }
  90. (0, _createClass3.default)(Menu, [{
  91. key: 'componentDidMount',
  92. value: function componentDidMount() {
  93. if (this.props.autoWidth) {
  94. this.setWidth();
  95. }
  96. this.setScollPosition();
  97. }
  98. }, {
  99. key: 'componentWillReceiveProps',
  100. value: function componentWillReceiveProps(nextProps) {
  101. var selectedIndex = void 0;
  102. var filteredChildren = this.getFilteredChildren(nextProps.children);
  103. if (this.props.multiple !== true) {
  104. selectedIndex = this.getLastSelectedIndex(nextProps, filteredChildren);
  105. } else {
  106. selectedIndex = this.state.focusIndex;
  107. }
  108. var newFocusIndex = nextProps.disableAutoFocus ? -1 : selectedIndex >= 0 ? selectedIndex : 0;
  109. if (newFocusIndex !== this.state.focusIndex && this.props.onMenuItemFocusChange) {
  110. this.props.onMenuItemFocusChange(null, newFocusIndex);
  111. }
  112. this.setState({
  113. focusIndex: newFocusIndex,
  114. keyWidth: nextProps.desktop ? 64 : 56
  115. });
  116. }
  117. }, {
  118. key: 'shouldComponentUpdate',
  119. value: function shouldComponentUpdate(nextProps, nextState, nextContext) {
  120. return !(0, _shallowEqual2.default)(this.props, nextProps) || !(0, _shallowEqual2.default)(this.state, nextState) || !(0, _shallowEqual2.default)(this.context, nextContext);
  121. }
  122. }, {
  123. key: 'componentDidUpdate',
  124. value: function componentDidUpdate() {
  125. if (this.props.autoWidth) this.setWidth();
  126. }
  127. }, {
  128. key: 'getValueLink',
  129. // Do not use outside of this component, it will be removed once valueLink is deprecated
  130. value: function getValueLink(props) {
  131. return props.valueLink || {
  132. value: props.value,
  133. requestChange: props.onChange
  134. };
  135. }
  136. }, {
  137. key: 'setKeyboardFocused',
  138. value: function setKeyboardFocused(keyboardFocused) {
  139. this.setState({
  140. isKeyboardFocused: keyboardFocused
  141. });
  142. }
  143. }, {
  144. key: 'getFilteredChildren',
  145. value: function getFilteredChildren(children) {
  146. var filteredChildren = [];
  147. _react2.default.Children.forEach(children, function (child) {
  148. if (child) {
  149. filteredChildren.push(child);
  150. }
  151. });
  152. return filteredChildren;
  153. }
  154. }, {
  155. key: 'cloneMenuItem',
  156. value: function cloneMenuItem(child, childIndex, styles, index) {
  157. var _this2 = this;
  158. var childIsDisabled = child.props.disabled;
  159. var selectedChildStyles = {};
  160. if (!childIsDisabled) {
  161. var selected = this.isChildSelected(child, this.props);
  162. if (selected) {
  163. (0, _simpleAssign2.default)(selectedChildStyles, styles.selectedMenuItem, this.props.selectedMenuItemStyle);
  164. }
  165. }
  166. var mergedChildStyles = (0, _simpleAssign2.default)({}, child.props.style, this.props.menuItemStyle, selectedChildStyles);
  167. var extraProps = {
  168. desktop: this.props.desktop,
  169. style: mergedChildStyles
  170. };
  171. if (!childIsDisabled) {
  172. var isFocused = childIndex === this.state.focusIndex;
  173. var focusState = 'none';
  174. if (isFocused) {
  175. focusState = this.state.isKeyboardFocused ? 'keyboard-focused' : 'focused';
  176. }
  177. (0, _simpleAssign2.default)(extraProps, {
  178. focusState: focusState,
  179. onClick: function onClick(event) {
  180. _this2.handleMenuItemClick(event, child, index);
  181. if (child.props.onClick) child.props.onClick(event);
  182. },
  183. ref: isFocused ? 'focusedMenuItem' : null
  184. });
  185. }
  186. return _react2.default.cloneElement(child, extraProps);
  187. }
  188. }, {
  189. key: 'decrementKeyboardFocusIndex',
  190. value: function decrementKeyboardFocusIndex(event) {
  191. var index = this.state.focusIndex;
  192. index--;
  193. if (index < 0) index = 0;
  194. this.setFocusIndex(event, index, true);
  195. }
  196. }, {
  197. key: 'getMenuItemCount',
  198. value: function getMenuItemCount(filteredChildren) {
  199. var menuItemCount = 0;
  200. filteredChildren.forEach(function (child) {
  201. var childIsADivider = child.type && child.type.muiName === 'Divider';
  202. var childIsDisabled = child.props.disabled;
  203. if (!childIsADivider && !childIsDisabled) menuItemCount++;
  204. });
  205. return menuItemCount;
  206. }
  207. }, {
  208. key: 'getLastSelectedIndex',
  209. value: function getLastSelectedIndex(props, filteredChildren) {
  210. var _this3 = this;
  211. var selectedIndex = -1;
  212. var menuItemIndex = 0;
  213. filteredChildren.forEach(function (child) {
  214. var childIsADivider = child.type && child.type.muiName === 'Divider';
  215. if (_this3.isChildSelected(child, props)) selectedIndex = menuItemIndex;
  216. if (!childIsADivider) menuItemIndex++;
  217. });
  218. return selectedIndex;
  219. }
  220. }, {
  221. key: 'setFocusIndexStartsWith',
  222. value: function setFocusIndexStartsWith(event, keys, filteredChildren) {
  223. var foundIndex = -1;
  224. _react2.default.Children.forEach(filteredChildren, function (child, index) {
  225. if (foundIndex >= 0) {
  226. return;
  227. }
  228. var primaryText = child.props.primaryText;
  229. if (typeof primaryText === 'string' && primaryText.substr(0, keys.length).toLowerCase() === keys.toLowerCase()) {
  230. foundIndex = index;
  231. }
  232. });
  233. if (foundIndex >= 0) {
  234. this.setFocusIndex(event, foundIndex, true);
  235. return true;
  236. }
  237. return false;
  238. }
  239. }, {
  240. key: 'handleMenuItemClick',
  241. value: function handleMenuItemClick(event, item, index) {
  242. var children = this.props.children;
  243. var multiple = this.props.multiple;
  244. var valueLink = this.getValueLink(this.props);
  245. var menuValue = valueLink.value;
  246. var itemValue = item.props.value;
  247. var focusIndex = _react2.default.isValidElement(children) ? 0 : children.indexOf(item);
  248. this.setFocusIndex(event, focusIndex, false);
  249. if (multiple) {
  250. menuValue = menuValue || [];
  251. var itemIndex = menuValue.indexOf(itemValue);
  252. var _menuValue = menuValue,
  253. _menuValue2 = (0, _toArray3.default)(_menuValue),
  254. newMenuValue = _menuValue2.slice(0);
  255. if (itemIndex === -1) {
  256. newMenuValue.push(itemValue);
  257. } else {
  258. newMenuValue.splice(itemIndex, 1);
  259. }
  260. valueLink.requestChange(event, newMenuValue);
  261. } else if (!multiple && itemValue !== menuValue) {
  262. valueLink.requestChange(event, itemValue);
  263. }
  264. this.props.onItemClick(event, item, index);
  265. }
  266. }, {
  267. key: 'incrementKeyboardFocusIndex',
  268. value: function incrementKeyboardFocusIndex(event, filteredChildren) {
  269. var index = this.state.focusIndex;
  270. var maxIndex = this.getMenuItemCount(filteredChildren) - 1;
  271. index++;
  272. if (index > maxIndex) index = maxIndex;
  273. this.setFocusIndex(event, index, true);
  274. }
  275. }, {
  276. key: 'isChildSelected',
  277. value: function isChildSelected(child, props) {
  278. var menuValue = this.getValueLink(props).value;
  279. var childValue = child.props.value;
  280. if (props.multiple) {
  281. return menuValue && menuValue.length && menuValue.indexOf(childValue) !== -1;
  282. } else {
  283. return child.props.hasOwnProperty('value') && menuValue === childValue;
  284. }
  285. }
  286. }, {
  287. key: 'setFocusIndex',
  288. value: function setFocusIndex(event, newIndex, isKeyboardFocused) {
  289. if (this.props.onMenuItemFocusChange) {
  290. // Do this even if `newIndex === this.state.focusIndex` to allow users
  291. // to detect up-arrow on the first MenuItem or down-arrow on the last.
  292. this.props.onMenuItemFocusChange(event, newIndex);
  293. }
  294. this.setState({
  295. focusIndex: newIndex,
  296. isKeyboardFocused: isKeyboardFocused
  297. });
  298. }
  299. }, {
  300. key: 'setScollPosition',
  301. value: function setScollPosition() {
  302. var desktop = this.props.desktop;
  303. var focusedMenuItem = this.refs.focusedMenuItem;
  304. var menuItemHeight = desktop ? 32 : 48;
  305. if (focusedMenuItem) {
  306. var selectedOffSet = _reactDom2.default.findDOMNode(focusedMenuItem).offsetTop;
  307. // Make the focused item be the 2nd item in the list the user sees
  308. var scrollTop = selectedOffSet - menuItemHeight;
  309. if (scrollTop < menuItemHeight) scrollTop = 0;
  310. _reactDom2.default.findDOMNode(this.refs.scrollContainer).scrollTop = scrollTop;
  311. }
  312. }
  313. }, {
  314. key: 'cancelScrollEvent',
  315. value: function cancelScrollEvent(event) {
  316. event.stopPropagation();
  317. event.preventDefault();
  318. return false;
  319. }
  320. }, {
  321. key: 'setWidth',
  322. value: function setWidth() {
  323. var el = _reactDom2.default.findDOMNode(this);
  324. var listEl = _reactDom2.default.findDOMNode(this.refs.list);
  325. var elWidth = el.offsetWidth;
  326. var keyWidth = this.state.keyWidth;
  327. var minWidth = keyWidth * 1.5;
  328. var keyIncrements = elWidth / keyWidth;
  329. var newWidth = void 0;
  330. keyIncrements = keyIncrements <= 1.5 ? 1.5 : Math.ceil(keyIncrements);
  331. newWidth = keyIncrements * keyWidth;
  332. if (newWidth < minWidth) newWidth = minWidth;
  333. el.style.width = newWidth + 'px';
  334. listEl.style.width = newWidth + 'px';
  335. }
  336. }, {
  337. key: 'render',
  338. value: function render() {
  339. var _this4 = this;
  340. var _props = this.props,
  341. autoWidth = _props.autoWidth,
  342. children = _props.children,
  343. desktop = _props.desktop,
  344. disableAutoFocus = _props.disableAutoFocus,
  345. initiallyKeyboardFocused = _props.initiallyKeyboardFocused,
  346. listStyle = _props.listStyle,
  347. maxHeight = _props.maxHeight,
  348. multiple = _props.multiple,
  349. onItemClick = _props.onItemClick,
  350. onEscKeyDown = _props.onEscKeyDown,
  351. onMenuItemFocusChange = _props.onMenuItemFocusChange,
  352. selectedMenuItemStyle = _props.selectedMenuItemStyle,
  353. menuItemStyle = _props.menuItemStyle,
  354. style = _props.style,
  355. value = _props.value,
  356. valueLink = _props.valueLink,
  357. width = _props.width,
  358. other = (0, _objectWithoutProperties3.default)(_props, ['autoWidth', 'children', 'desktop', 'disableAutoFocus', 'initiallyKeyboardFocused', 'listStyle', 'maxHeight', 'multiple', 'onItemClick', 'onEscKeyDown', 'onMenuItemFocusChange', 'selectedMenuItemStyle', 'menuItemStyle', 'style', 'value', 'valueLink', 'width']);
  359. var prepareStyles = this.context.muiTheme.prepareStyles;
  360. var styles = getStyles(this.props, this.context);
  361. var mergedRootStyles = (0, _simpleAssign2.default)(styles.root, style);
  362. var mergedListStyles = (0, _simpleAssign2.default)(styles.list, listStyle);
  363. var filteredChildren = this.getFilteredChildren(children);
  364. var menuItemIndex = 0;
  365. var newChildren = _react2.default.Children.map(filteredChildren, function (child, index) {
  366. var childIsDisabled = child.props.disabled;
  367. var childName = child.type ? child.type.muiName : '';
  368. var newChild = child;
  369. switch (childName) {
  370. case 'MenuItem':
  371. newChild = _this4.cloneMenuItem(child, menuItemIndex, styles, index);
  372. break;
  373. case 'Divider':
  374. newChild = _react2.default.cloneElement(child, {
  375. style: (0, _simpleAssign2.default)({}, styles.divider, child.props.style)
  376. });
  377. break;
  378. }
  379. if (childName === 'MenuItem' && !childIsDisabled) {
  380. menuItemIndex++;
  381. }
  382. return newChild;
  383. });
  384. return _react2.default.createElement(
  385. _ClickAwayListener2.default,
  386. { onClickAway: this.handleClickAway },
  387. _react2.default.createElement(
  388. 'div',
  389. {
  390. onKeyDown: this.handleKeyDown,
  391. onWheel: this.handleOnWheel,
  392. style: prepareStyles(mergedRootStyles),
  393. ref: 'scrollContainer',
  394. role: 'presentation'
  395. },
  396. _react2.default.createElement(
  397. _List2.default,
  398. (0, _extends3.default)({}, other, {
  399. ref: 'list',
  400. style: mergedListStyles,
  401. role: 'menu'
  402. }),
  403. newChildren
  404. )
  405. )
  406. );
  407. }
  408. }]);
  409. return Menu;
  410. }(_react.Component);
  411. Menu.defaultProps = {
  412. autoWidth: true,
  413. desktop: false,
  414. disableAutoFocus: false,
  415. initiallyKeyboardFocused: false,
  416. maxHeight: null,
  417. multiple: false,
  418. onChange: function onChange() {},
  419. onEscKeyDown: function onEscKeyDown() {},
  420. onItemClick: function onItemClick() {},
  421. onKeyDown: function onKeyDown() {}
  422. };
  423. Menu.contextTypes = {
  424. muiTheme: _propTypes2.default.object.isRequired
  425. };
  426. var _initialiseProps = function _initialiseProps() {
  427. var _this5 = this;
  428. this.handleClickAway = function (event) {
  429. if (event.defaultPrevented) {
  430. return;
  431. }
  432. var focusIndex = _this5.state.focusIndex;
  433. if (focusIndex < 0) {
  434. return;
  435. }
  436. var filteredChildren = _this5.getFilteredChildren(_this5.props.children);
  437. var focusedItem = filteredChildren[focusIndex];
  438. if (!!focusedItem && focusedItem.props.menuItems && focusedItem.props.menuItems.length > 0) {
  439. return;
  440. }
  441. _this5.setFocusIndex(event, -1, false);
  442. };
  443. this.handleKeyDown = function (event) {
  444. var filteredChildren = _this5.getFilteredChildren(_this5.props.children);
  445. var key = (0, _keycode2.default)(event);
  446. switch (key) {
  447. case 'down':
  448. event.preventDefault();
  449. _this5.incrementKeyboardFocusIndex(event, filteredChildren);
  450. break;
  451. case 'esc':
  452. _this5.props.onEscKeyDown(event);
  453. break;
  454. case 'tab':
  455. event.preventDefault();
  456. if (event.shiftKey) {
  457. _this5.decrementKeyboardFocusIndex(event);
  458. } else {
  459. _this5.incrementKeyboardFocusIndex(event, filteredChildren);
  460. }
  461. break;
  462. case 'up':
  463. event.preventDefault();
  464. _this5.decrementKeyboardFocusIndex(event);
  465. break;
  466. default:
  467. if (key && key.length === 1) {
  468. var hotKeys = _this5.hotKeyHolder.append(key);
  469. if (_this5.setFocusIndexStartsWith(event, hotKeys, filteredChildren)) {
  470. event.preventDefault();
  471. }
  472. }
  473. }
  474. _this5.props.onKeyDown(event);
  475. };
  476. this.handleOnWheel = function (event) {
  477. var scrollContainer = _this5.refs.scrollContainer;
  478. // Only scroll lock if the the Menu is scrollable.
  479. if (scrollContainer.scrollHeight <= scrollContainer.clientHeight) return;
  480. var scrollTop = scrollContainer.scrollTop,
  481. scrollHeight = scrollContainer.scrollHeight,
  482. clientHeight = scrollContainer.clientHeight;
  483. var wheelDelta = event.deltaY;
  484. var isDeltaPositive = wheelDelta > 0;
  485. if (isDeltaPositive && wheelDelta > scrollHeight - clientHeight - scrollTop) {
  486. scrollContainer.scrollTop = scrollHeight;
  487. return _this5.cancelScrollEvent(event);
  488. } else if (!isDeltaPositive && -wheelDelta > scrollTop) {
  489. scrollContainer.scrollTop = 0;
  490. return _this5.cancelScrollEvent(event);
  491. }
  492. };
  493. };
  494. Menu.propTypes = process.env.NODE_ENV !== "production" ? {
  495. /**
  496. * If true, the width of the menu will be set automatically
  497. * according to the widths of its children,
  498. * using proper keyline increments (64px for desktop,
  499. * 56px otherwise).
  500. */
  501. autoWidth: _propTypes2.default.bool,
  502. /**
  503. * The content of the menu. This is usually used to pass `MenuItem`
  504. * elements.
  505. */
  506. children: _propTypes2.default.node,
  507. /**
  508. * If true, the menu item will render with compact desktop styles.
  509. */
  510. desktop: _propTypes2.default.bool,
  511. /**
  512. * If true, the menu will not be auto-focused.
  513. */
  514. disableAutoFocus: _propTypes2.default.bool,
  515. /**
  516. * If true, the menu will be keyboard-focused initially.
  517. */
  518. initiallyKeyboardFocused: _propTypes2.default.bool,
  519. /**
  520. * Override the inline-styles of the underlying `List` element.
  521. */
  522. listStyle: _propTypes2.default.object,
  523. /**
  524. * The maximum height of the menu in pixels. If specified,
  525. * the menu will be scrollable if it is taller than the provided
  526. * height.
  527. */
  528. maxHeight: _propTypes2.default.number,
  529. /**
  530. * Override the inline-styles of menu items.
  531. */
  532. menuItemStyle: _propTypes2.default.object,
  533. /**
  534. * If true, `value` must be an array and the menu will support
  535. * multiple selections.
  536. */
  537. multiple: _propTypes2.default.bool,
  538. /**
  539. * Callback function fired when a menu item with `value` not
  540. * equal to the current `value` of the menu is clicked.
  541. *
  542. * @param {object} event Click event targeting the menu item.
  543. * @param {any} value If `multiple` is true, the menu's `value`
  544. * array with either the menu item's `value` added (if
  545. * it wasn't already selected) or omitted (if it was already selected).
  546. * Otherwise, the `value` of the menu item.
  547. */
  548. onChange: _propTypes2.default.func,
  549. /**
  550. * Callback function fired when the menu is focused and the *Esc* key
  551. * is pressed.
  552. *
  553. * @param {object} event `keydown` event targeting the menu.
  554. */
  555. onEscKeyDown: _propTypes2.default.func,
  556. /**
  557. * Callback function fired when a menu item is clicked.
  558. *
  559. * @param {object} event Click event targeting the menu item.
  560. * @param {object} menuItem The menu item.
  561. * @param {number} index The index of the menu item.
  562. */
  563. onItemClick: _propTypes2.default.func,
  564. /** @ignore */
  565. onKeyDown: _propTypes2.default.func,
  566. /**
  567. * Callback function fired when the focus on a `MenuItem` is changed.
  568. * There will be some "duplicate" changes reported if two different
  569. * focusing event happen, for example if a `MenuItem` is focused via
  570. * the keyboard and then it is clicked on.
  571. *
  572. * @param {object} event The event that triggered the focus change.
  573. * The event can be null since the focus can be changed for non-event
  574. * reasons such as prop changes.
  575. * @param {number} newFocusIndex The index of the newly focused
  576. * `MenuItem` or `-1` if focus was lost.
  577. */
  578. onMenuItemFocusChange: _propTypes2.default.func,
  579. /**
  580. * Override the inline-styles of selected menu items.
  581. */
  582. selectedMenuItemStyle: _propTypes2.default.object,
  583. /**
  584. * Override the inline-styles of the root element.
  585. */
  586. style: _propTypes2.default.object,
  587. /**
  588. * If `multiple` is true, an array of the `value`s of the selected
  589. * menu items. Otherwise, the `value` of the selected menu item.
  590. * If provided, the menu will be a controlled component.
  591. * This component also supports valueLink.
  592. */
  593. value: _propTypes2.default.any,
  594. /**
  595. * ValueLink for the menu's `value`.
  596. */
  597. valueLink: _propTypes2.default.object,
  598. /**
  599. * The width of the menu. If not specified, the menu's width
  600. * will be set according to the widths of its children, using
  601. * proper keyline increments (64px for desktop, 56px otherwise).
  602. */
  603. width: _propTypes4.default.stringOrNumber
  604. } : {};
  605. exports.default = Menu;