1 | "use strict";
|
2 |
|
3 | exports.__esModule = true;
|
4 | exports.useActiveDescendant = exports.setActiveDescendant = void 0;
|
5 |
|
6 | var _react = require("react");
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | const setActiveDescendant = (ref, activeId) => {
|
14 | if (!ref) return;
|
15 | ref.removeAttribute('aria-activedescendant');
|
16 | if (activeId) ref.setAttribute('aria-activedescendant', activeId);
|
17 | };
|
18 |
|
19 | exports.setActiveDescendant = setActiveDescendant;
|
20 |
|
21 | const useActiveDescendant = (ref, id, visible, deps) => {
|
22 | (0, _react.useEffect)(() => {
|
23 | setActiveDescendant(ref.current, visible ? id : '');
|
24 | }, [ref, id, visible, ...deps]);
|
25 | };
|
26 |
|
27 | exports.useActiveDescendant = useActiveDescendant; |
\ | No newline at end of file |