@public-ui/components
Version:
Contains all web components that belong to KoliBri - The accessible HTML-Standard.
103 lines (99 loc) • 4.18 kB
JavaScript
/*!
* KoliBri - The accessible HTML-Standard
*/
;
var common = require('./common-DPb6NWR4.js');
var dev_utils = require('./dev.utils-BeTuwcHU.js');
require('./index-BrhW8s5h.js');
const getKoliBri = () => {
let kolibri = common.getWindow().KoliBri;
if (kolibri === undefined) {
kolibri = {};
Object.defineProperty(common.getWindow(), 'KoliBri', {
value: kolibri,
writable: false,
});
}
return kolibri;
};
function prototypeKoliBri(name, cb) {
try {
Object.defineProperty(getKoliBri(), name, {
get: function () {
return cb;
},
});
}
catch (_a) {
common.Log.debug(`KoliBri property ${name} is already bind.`);
}
}
const metaModeLog = (name, active) => common.Log.debug(`${name} ${active ? '' : 'not '}activated`);
const initialize = () => {
dev_utils.initKoliBri();
if (common.isDevMode()) {
dev_utils.renderDevAdvice();
prototypeKoliBri('a11yColorContrast', common.koliBriA11yColorContrast);
prototypeKoliBri('querySelector', common.koliBriQuerySelector);
prototypeKoliBri('querySelectorAll', common.koliBriQuerySelectorAll);
prototypeKoliBri('querySelectorColors', common.koliBriQuerySelectorColors);
prototypeKoliBri('utils', function () {
return common.KoliBriUtils;
});
prototypeKoliBri('parseJson', common.parseJson);
prototypeKoliBri('stringifyJson', common.stringifyJson);
metaModeLog('Development mode', common.isDevMode());
metaModeLog('Experimental mode', common.getExperimentalMode());
metaModeLog('Color contrast analysis', common.getColorContrastAnalysis());
setTimeout(() => {
try {
const document = common.getDocument();
const body = document === null || document === void 0 ? void 0 : document.body;
if (document && body && typeof document.createElement === 'function') {
const div = document.createElement('svg');
div.setAttribute('aria-label', 'KoliBri-DevTools');
div.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
div.setAttribute('role', 'toolbar');
div.setAttribute('style', 'position: fixed;color: black;font-size: 200%;bottom: 0.25rem;right: 0.25rem;');
div.innerHTML = `<svg
xmlns="http://www.w3.org/2000/svg"
width="50"
height="50"
viewBox="0 0 600 600"
>
<path d="M353 322L213 304V434L353 322Z" fill="#047" />
<path d="M209 564V304L149 434L209 564Z" fill="#047" />
<path d="M357 316L417 250L361 210L275 244L357 316Z" fill="#047" />
<path d="M353 318L35 36L213 300L353 318Z" fill="#047" />
<path d="M329 218L237 92L250 222L272 241L329 218Z" fill="#047" />
<path d="M391 286L565 272L421 252L391 286Z" fill="#047" />
</svg>`;
body.appendChild(div);
}
}
catch (error) {
common.Log.debug(['Could not initialize DevTools UI (likely in SSR/test environment):', error]);
}
}, 100);
if (common.getColorContrastAnalysis()) {
const timeout = setTimeout(() => {
clearTimeout(timeout);
try {
const document = common.getDocument();
const body = document === null || document === void 0 ? void 0 : document.body;
if (document && body && typeof document.createElement === 'function') {
setInterval(() => {
common.KoliBriUtils.queryHtmlElementColors(document.createElement('div'), common.koliBriA11yColorContrast(body), false, false);
}, 10000);
}
}
catch (error) {
common.Log.debug(['Could not initialize color contrast analysis:', error]);
}
}, 2500);
}
}
};
exports.initialize = initialize;
//# sourceMappingURL=devtools-ZghKOdoO.js.map
//# sourceMappingURL=devtools-ZghKOdoO.js.map