UNPKG

@empathyco/x-components

Version:
31 lines (29 loc) 981 B
/** * Checks if the user is on an iOS device (iPhone, iPad, or iPod). * * @returns `true` if the user is on iOS, `false` otherwise. * * @public */ const isIOS = () => { const userAgent = navigator.userAgent.toLowerCase(); return /iphone|ipad|ipod/.test(userAgent) && !/windows phone/.test(userAgent); }; /** * Removes focus from the search input element if it is currently focused. * This function checks if the active element in the document matches the * selector '.x-search-input' and, if so, blurs the element to remove focus. * * @public */ const removeSearchInputFocus = () => { const shadowHost = document.querySelector('.x-root-container'); if (shadowHost?.shadowRoot) { shadowHost.shadowRoot.querySelector('.x-search-input')?.blur(); } else if (document.activeElement?.matches('.x-search-input')) { document.activeElement.blur(); } }; export { isIOS, removeSearchInputFocus }; //# sourceMappingURL=ios-utils.js.map