mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2026-01-12 19:46:19 +03:00
21 lines
508 B
TypeScript
21 lines
508 B
TypeScript
import { KeyPath } from "./types.js";
|
|
|
|
const replaceSpacesRegex = / /g;
|
|
|
|
const getAriaPropsFromKeyPath = (
|
|
keyPath: KeyPath
|
|
) => {
|
|
let ariaControls = '';
|
|
let ariaLabel = 'JSON Tree Node: ';
|
|
for(let i = keyPath.length - 1; i >= 0; i--) {
|
|
const key = keyPath[i];
|
|
ariaControls += `${key}`.replace(replaceSpacesRegex, '-');
|
|
ariaLabel += `${key} `;
|
|
}
|
|
|
|
ariaLabel = ariaLabel.trim();
|
|
|
|
return { ariaControls, ariaLabel };
|
|
}
|
|
|
|
export default getAriaPropsFromKeyPath; |