UNPKG

@public-ui/components

Version:

Contains all web components that belong to KoliBri - The accessible HTML-Standard.

4 lines 2.79 kB
/*! * KoliBri - The accessible HTML-Standard */ import{U as isDevMode,L as Log,x as getDocument,A as getWindow,W as koliBriA11yColorContrast,R as koliBriQuerySelector,X as koliBriQuerySelectorAll,Y as koliBriQuerySelectorColors,Z as KoliBriUtils,p as parseJson,_ as stringifyJson,O as getExperimentalMode,$ as getColorContrastAnalysis}from"./common.js";import{i as initKoliBri,r as renderDevAdvice}from"./dev.utils.js";const getKoliBri=()=>{let o=getWindow().KoliBri;return void 0===o&&(o={},Object.defineProperty(getWindow(),"KoliBri",{value:o,writable:!1})),o};function prototypeKoliBri(o,t){try{Object.defineProperty(getKoliBri(),o,{get:function(){return t}})}catch(t){Log.debug(`KoliBri property ${o} is already bind.`)}}const metaModeLog=(o,t)=>Log.debug(`${o} ${t?"":"not "}activated`),initialize=()=>{if(initKoliBri(),isDevMode()&&(renderDevAdvice(),prototypeKoliBri("a11yColorContrast",koliBriA11yColorContrast),prototypeKoliBri("querySelector",koliBriQuerySelector),prototypeKoliBri("querySelectorAll",koliBriQuerySelectorAll),prototypeKoliBri("querySelectorColors",koliBriQuerySelectorColors),prototypeKoliBri("utils",function(){return KoliBriUtils}),prototypeKoliBri("parseJson",parseJson),prototypeKoliBri("stringifyJson",stringifyJson),metaModeLog("Development mode",isDevMode()),metaModeLog("Experimental mode",getExperimentalMode()),metaModeLog("Color contrast analysis",getColorContrastAnalysis()),setTimeout(()=>{try{const o=getDocument(),t=null==o?void 0:o.body;if(o&&t&&"function"==typeof o.createElement){const e=o.createElement("svg");e.setAttribute("aria-label","KoliBri-DevTools"),e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.setAttribute("role","toolbar"),e.setAttribute("style","position: fixed;color: black;font-size: 200%;bottom: 0.25rem;right: 0.25rem;"),e.innerHTML='<svg\n xmlns="http://www.w3.org/2000/svg"\n width="50"\n height="50"\n viewBox="0 0 600 600"\n>\n <path d="M353 322L213 304V434L353 322Z" fill="#047" />\n <path d="M209 564V304L149 434L209 564Z" fill="#047" />\n <path d="M357 316L417 250L361 210L275 244L357 316Z" fill="#047" />\n <path d="M353 318L35 36L213 300L353 318Z" fill="#047" />\n <path d="M329 218L237 92L250 222L272 241L329 218Z" fill="#047" />\n <path d="M391 286L565 272L421 252L391 286Z" fill="#047" />\n</svg>',t.appendChild(e)}}catch(o){Log.debug(["Could not initialize DevTools UI (likely in SSR/test environment):",o])}},100),getColorContrastAnalysis())){const o=setTimeout(()=>{clearTimeout(o);try{const o=getDocument(),t=null==o?void 0:o.body;o&&t&&"function"==typeof o.createElement&&setInterval(()=>{KoliBriUtils.queryHtmlElementColors(o.createElement("div"),koliBriA11yColorContrast(t),!1,!1)},1e4)}catch(o){Log.debug(["Could not initialize color contrast analysis:",o])}},2500)}};export{initialize};