@public-ui/components
Version:
Contains all web components that belong to KoliBri - The accessible HTML-Standard.
5 lines • 1.54 kB
JavaScript
/*!
* KoliBri - The accessible HTML-Standard
*/
const t=5e3;function e(e){return new Promise(((n,a)=>{let i;const o=new MutationObserver((()=>{if(e.hasAttribute("data-themed")){if(i){clearTimeout(i)}o.disconnect();n()}}));o.observe(e,{attributes:true,attributeFilter:["data-themed"]});if(e.hasAttribute("data-themed")){o.disconnect();n();return}i=setTimeout((()=>{o.disconnect();a(new Error("Timeout waiting for data-themed attribute"))}),t)}))}const n=3;async function a(t,n){try{if(!t.hasAttribute("data-themed")){await e(t)}await n()}catch(t){throw new Error(`The interactive element inside the KoliBri web component could not be clicked. Try calling the click method on the web component after a short delay again.`)}}function i(t){if(!t)return false;const e=t.getBoundingClientRect();return e.width>0&&e.height>0}async function o(t){let e=0;do{if(t){t.click()}await new Promise((t=>requestAnimationFrame(t)));e++}while(!i(t)&&e<n)}const r=10;async function c(t,n){try{if(!t.hasAttribute("data-themed")){await e(t)}await n()}catch(t){throw new Error(`The interactive element inside the KoliBri web component could not be focused. Try calling the focus method on the web component after a short delay again.`)}}function s(t){const e=t.getRootNode();if(e instanceof ShadowRoot){return e.activeElement===t}return document.activeElement===t}async function u(t){let e=0;do{if(t){t.focus()}await new Promise((t=>requestAnimationFrame(t)));e++}while(!s(t)&&e<r)}export{a,u as b,c as d,o as s};
//# sourceMappingURL=element-focus-CRwW4N4R.js.map