@szhsin/react-menu
Advanced tools
Comparing version 3.1.1 to 3.1.2
@@ -8,3 +8,3 @@ import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../_virtual/_rollupPluginBabelHelpers.js'; | ||
import { useBEM } from '../hooks/useBEM.js'; | ||
import { SettingsContext, ItemSettingsContext, EventHandlersContext, MenuStateMap, Keys, CloseReason, menuContainerClass } from '../utils/constants.js'; | ||
import { SettingsContext, ItemSettingsContext, EventHandlersContext, Keys, CloseReason, MenuStateMap, menuContainerClass } from '../utils/constants.js'; | ||
import { rootMenuPropTypes } from '../utils/propTypes.js'; | ||
@@ -11,0 +11,0 @@ import { safeCall, getTransition, attachHandlerProps, values, isMenuOpen } from '../utils/utils.js'; |
@@ -102,3 +102,3 @@ import { objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose, extends as _extends } from '../_virtual/_rollupPluginBabelHelpers.js'; | ||
var _useItems = useItems(menuRef), | ||
var _useItems = useItems(menuRef, focusRef), | ||
hoverItem = _useItems.hoverItem, | ||
@@ -264,3 +264,3 @@ dispatch = _useItems.dispatch, | ||
}, [overflowData, setDownOverflow]); | ||
useEffect(function () { | ||
useIsomorphicLayoutEffect(function () { | ||
return updateItems; | ||
@@ -267,0 +267,0 @@ }, [updateItems]); |
@@ -13,3 +13,3 @@ import { extends as _extends, objectWithoutPropertiesLoose as _objectWithoutPropertiesLoose } from '../_virtual/_rollupPluginBabelHelpers.js'; | ||
import { useBEM } from '../hooks/useBEM.js'; | ||
import { SettingsContext, ItemSettingsContext, MenuListContext, MenuListItemContext, HoverActionTypes, menuClass, subMenuClass, menuItemClass, Keys, FocusPositions } from '../utils/constants.js'; | ||
import { SettingsContext, ItemSettingsContext, MenuListContext, MenuListItemContext, menuClass, subMenuClass, menuItemClass, HoverActionTypes, Keys, FocusPositions } from '../utils/constants.js'; | ||
import { useCombinedRef } from '../hooks/useCombinedRef.js'; | ||
@@ -16,0 +16,0 @@ import { attachHandlerProps, commonProps, safeCall, isMenuOpen, batchedUpdates } from '../utils/utils.js'; |
@@ -1,5 +0,5 @@ | ||
import { useEffect } from 'react'; | ||
import { useLayoutEffect as useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect.js'; | ||
var useItemEffect = function useItemEffect(isDisabled, itemRef, updateItems) { | ||
useEffect(function () { | ||
useIsomorphicLayoutEffect(function () { | ||
if (process.env.NODE_ENV !== 'production' && !updateItems) { | ||
@@ -6,0 +6,0 @@ throw new Error("[React-Menu] This menu item or submenu should be rendered under a menu: " + itemRef.current.outerHTML); |
@@ -5,3 +5,3 @@ import { useState, useRef, useCallback } from 'react'; | ||
var useItems = function useItems(menuRef) { | ||
var useItems = function useItems(menuRef, focusRef) { | ||
var _useState = useState(), | ||
@@ -26,3 +26,11 @@ hoverItem = _useState[0], | ||
var index = items.indexOf(item); | ||
if (index > -1) items.splice(index, 1); | ||
if (index > -1) { | ||
items.splice(index, 1); | ||
if (item.contains(document.activeElement)) { | ||
focusRef.current.focus(); | ||
setHoverItem(); | ||
} | ||
} | ||
} | ||
@@ -32,3 +40,3 @@ | ||
mutableState.sorted = false; | ||
}, [mutableState]); | ||
}, [mutableState, focusRef]); | ||
var dispatch = useCallback(function (actionType, item, nextIndex) { | ||
@@ -35,0 +43,0 @@ var items = mutableState.items, |
@@ -22,7 +22,7 @@ import { extends as _extends } from '../_virtual/_rollupPluginBabelHelpers.js'; | ||
return [_extends({}, menuProps, { | ||
return [_extends({ | ||
menuItemFocus: menuItemFocus | ||
}), toggleMenu, openMenu]; | ||
}, menuProps), toggleMenu, openMenu]; | ||
}; | ||
export { useMenuStateAndFocus }; |
import { extends as _extends } from '../_virtual/_rollupPluginBabelHelpers.js'; | ||
import { oneOfType, string, func, object, bool, number, oneOf, exact } from 'prop-types'; | ||
import { object, bool, oneOfType, exact, number, string, oneOf, func } from 'prop-types'; | ||
@@ -4,0 +4,0 @@ var stylePropTypes = function stylePropTypes(name) { |
@@ -22,3 +22,3 @@ import { unstable_batchedUpdates } from 'react-dom'; | ||
var getTransition = function getTransition(transition, name) { | ||
return !!(transition && transition[name]) || transition === true; | ||
return transition === true || !!(transition && transition[name]); | ||
}; | ||
@@ -98,3 +98,3 @@ var safeCall = function safeCall(fn, arg) { | ||
'aria-disabled': isDisabled || undefined, | ||
tabIndex: isDisabled ? undefined : isHovering ? 0 : -1 | ||
tabIndex: isHovering ? 0 : -1 | ||
}; | ||
@@ -101,0 +101,0 @@ } |
{ | ||
"name": "@szhsin/react-menu", | ||
"version": "3.1.1", | ||
"version": "3.1.2", | ||
"description": "React component for building accessible menu, dropdown, submenu, context menu and more.", | ||
@@ -50,5 +50,5 @@ "author": "Zheng Song", | ||
"devDependencies": { | ||
"@babel/core": "^7.18.2", | ||
"@babel/preset-env": "^7.18.2", | ||
"@babel/preset-react": "^7.17.12", | ||
"@babel/core": "^7.18.9", | ||
"@babel/preset-env": "^7.18.9", | ||
"@babel/preset-react": "^7.18.6", | ||
"@rollup/plugin-babel": "^5.3.1", | ||
@@ -58,21 +58,21 @@ "@rollup/plugin-node-resolve": "^13.3.0", | ||
"@testing-library/react": "^13.3.0", | ||
"@types/react": "^18.0.7", | ||
"@types/react": "^18.0.15", | ||
"babel-plugin-pure-annotations": "^0.1.2", | ||
"babel-plugin-transform-react-remove-prop-types": "^0.4.24", | ||
"dtslint": "^4.2.1", | ||
"eslint": "^8.17.0", | ||
"eslint": "^8.20.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-jest": "^26.1.5", | ||
"eslint-plugin-react": "^7.30.0", | ||
"eslint-plugin-react-hooks": "^4.5.0", | ||
"eslint-plugin-jest": "^26.6.0", | ||
"eslint-plugin-react": "^7.30.1", | ||
"eslint-plugin-react-hooks": "^4.6.0", | ||
"eslint-plugin-react-hooks-addons": "^0.3.1", | ||
"jest": "^28.1.0", | ||
"jest-environment-jsdom": "^28.1.0", | ||
"jest": "^28.1.3", | ||
"jest-environment-jsdom": "^28.1.3", | ||
"npm-run-all": "^4.1.5", | ||
"prettier": "^2.6.2", | ||
"react": "^18.1.0", | ||
"react-dom": "^18.1.0", | ||
"rollup": "^2.75.6", | ||
"sass": "^1.51.0", | ||
"typescript": "^4.7.2" | ||
"prettier": "^2.7.1", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"rollup": "^2.77.2", | ||
"sass": "^1.54.0", | ||
"typescript": "^4.7.4" | ||
}, | ||
@@ -79,0 +79,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
190905
5289