Comparing version 9.5.5 to 9.6.0
@@ -72,2 +72,6 @@ import type * as React from 'react'; | ||
export declare type MenuRef = { | ||
/** | ||
* Focus active child if any, or the first child which is not disabled will be focused. | ||
* @param options | ||
*/ | ||
focus: (options?: FocusOptions) => void; | ||
@@ -74,0 +78,0 @@ list: HTMLUListElement; |
@@ -24,3 +24,3 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
import useKeyRecords, { OVERFLOW_KEY } from './hooks/useKeyRecords'; | ||
import { IdContext } from './context/IdContext'; | ||
import { getMenuId, IdContext } from './context/IdContext'; | ||
import PrivateContext from './context/PrivateContext'; | ||
@@ -111,12 +111,2 @@ import { useImperativeHandle } from 'react'; | ||
var containerRef = React.useRef(); | ||
useImperativeHandle(ref, function () { | ||
return { | ||
list: containerRef.current, | ||
focus: function focus(options) { | ||
var _containerRef$current; | ||
(_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.focus(options); | ||
} | ||
}; | ||
}); | ||
var uuid = useUUID(id); | ||
@@ -231,2 +221,20 @@ var isRtl = direction === 'rtl'; // ========================= Warn ========================= | ||
setMergedActiveKey(undefined); | ||
}); | ||
useImperativeHandle(ref, function () { | ||
return { | ||
list: containerRef.current, | ||
focus: function focus(options) { | ||
var _childList$find; | ||
var shouldFocusKey = mergedActiveKey !== null && mergedActiveKey !== void 0 ? mergedActiveKey : (_childList$find = childList.find(function (node) { | ||
return !node.props.disabled; | ||
})) === null || _childList$find === void 0 ? void 0 : _childList$find.key; | ||
if (shouldFocusKey) { | ||
var _containerRef$current, _containerRef$current2, _containerRef$current3; | ||
(_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : (_containerRef$current2 = _containerRef$current.querySelector("li[data-menu-id='".concat(getMenuId(uuid, shouldFocusKey), "']"))) === null || _containerRef$current2 === void 0 ? void 0 : (_containerRef$current3 = _containerRef$current2.focus) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.call(_containerRef$current2, options); | ||
} | ||
} | ||
}; | ||
}); // ======================== Select ======================== | ||
@@ -233,0 +241,0 @@ // >>>>> Select keys |
@@ -72,2 +72,6 @@ import type * as React from 'react'; | ||
export declare type MenuRef = { | ||
/** | ||
* Focus active child if any, or the first child which is not disabled will be focused. | ||
* @param options | ||
*/ | ||
focus: (options?: FocusOptions) => void; | ||
@@ -74,0 +78,0 @@ list: HTMLUListElement; |
@@ -143,12 +143,2 @@ "use strict"; | ||
var containerRef = React.useRef(); | ||
(0, React.useImperativeHandle)(ref, function () { | ||
return { | ||
list: containerRef.current, | ||
focus: function focus(options) { | ||
var _containerRef$current; | ||
(_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : _containerRef$current.focus(options); | ||
} | ||
}; | ||
}); | ||
var uuid = (0, _useUUID.default)(id); | ||
@@ -263,2 +253,20 @@ var isRtl = direction === 'rtl'; // ========================= Warn ========================= | ||
setMergedActiveKey(undefined); | ||
}); | ||
(0, React.useImperativeHandle)(ref, function () { | ||
return { | ||
list: containerRef.current, | ||
focus: function focus(options) { | ||
var _childList$find; | ||
var shouldFocusKey = mergedActiveKey !== null && mergedActiveKey !== void 0 ? mergedActiveKey : (_childList$find = childList.find(function (node) { | ||
return !node.props.disabled; | ||
})) === null || _childList$find === void 0 ? void 0 : _childList$find.key; | ||
if (shouldFocusKey) { | ||
var _containerRef$current, _containerRef$current2, _containerRef$current3; | ||
(_containerRef$current = containerRef.current) === null || _containerRef$current === void 0 ? void 0 : (_containerRef$current2 = _containerRef$current.querySelector("li[data-menu-id='".concat((0, _IdContext.getMenuId)(uuid, shouldFocusKey), "']"))) === null || _containerRef$current2 === void 0 ? void 0 : (_containerRef$current3 = _containerRef$current2.focus) === null || _containerRef$current3 === void 0 ? void 0 : _containerRef$current3.call(_containerRef$current2, options); | ||
} | ||
} | ||
}; | ||
}); // ======================== Select ======================== | ||
@@ -265,0 +273,0 @@ // >>>>> Select keys |
{ | ||
"name": "rc-menu", | ||
"version": "9.5.5", | ||
"version": "9.6.0", | ||
"description": "menu ui component for react", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4796
225333
110