carbon-react
Version:
A library of reusable React components for easily building user interfaces.
2 lines (1 loc) • 736 B
JavaScript
import"react";import t from"../../../../__internal__/utils/helpers/events/events.js";import{MENU_ITEM as e,SCROLLABLE_BLOCK_PARENT as n}from"../locators.js";function o(t,o){if(t&&o)return o.find((o=>{var i,r,l,u,s;return!!(null==o?void 0:o.getAttribute("data-component"))&&[e,n].includes(o.getAttribute("data-component"))&&(null===(i=null===(r=null==(l=o)||null===(s=l.textContent)||void 0===s||null===(u=s.split("\n"))||void 0===u?void 0:u.map((t=>t.trim())).join(" "))||void 0===r?void 0:r.toLowerCase())||void 0===i?void 0:i.startsWith(t.toLowerCase()))}))}function i(e,n){return t.isHomeKey(e)?(e.preventDefault(),0):t.isEndKey(e)?(e.preventDefault(),n.length-1):void 0}export{o as characterNavigation,i as menuKeyboardNavigation};