@public-ui/components
Version:
Contains all web components that belong to KoliBri - The accessible HTML-Standard.
82 lines (78 loc) • 2.96 kB
JavaScript
/*!
* KoliBri - The accessible HTML-Standard
*/
import './common.js';
import { L as Log, n as getDocument, v as setExperimentalMode, x as setColorContrastAnalysis, A as getWindow, r as isTestMode } from './prop.validators.js';
import { Env } from '@stencil/core/internal/client';
const initMeta = () => {
try {
const document = getDocument();
if (!document || typeof document.querySelector !== 'function') {
return;
}
const meta = document.querySelector('meta[name="kolibri"]');
if (meta && meta.hasAttribute('content')) {
const content = meta.getAttribute('content');
if (typeof content === 'string') {
setExperimentalMode(content.includes('experimental-mode=true'));
setColorContrastAnalysis(content.includes('color-contrast-analysis=true'));
}
}
}
catch (_a) {
}
};
const getKoliBri = () => {
let kolibri = getWindow().KoliBri;
if (kolibri === undefined) {
kolibri = {};
Object.defineProperty(getWindow(), 'KoliBri', {
value: kolibri,
writable: false,
});
}
return kolibri;
};
const initKoliBri = () => {
initMeta();
Log.debug(`
,--. ,--. ,--. ,--. ,-----. ,--.
| .' / ,---. | | \`--' | |) /_ ,--.--. \`--'
| . ' | .-. | | | ,--. | .-. \\ | .--' ,--.
| |\\ \\ | '-' | | | | | | '--' / | | | |
\`--' \`--´ \`---´ \`--' \`--' \`------´ \`--' \`--'
🚹 The accessible HTML-Standard | 👉 https://public-ui.github.io | ${Env.kolibriVersion}
`, {
forceLog: true,
});
};
const renderDevAdvice = () => {
if (getKoliBri().adviceShown !== true) {
Object.defineProperty(getKoliBri(), 'adviceShown', {
get: function () {
return true;
},
});
Log.debug(`
You are using the KoliBri component library. If you have any suggestions for improvement or find a problem, please contact us:
Ticket: https://github.com/public-ui/kolibri/issues/new/choose (for privacy reasons, please use email)
Email: kolibri@itzbund.de
`);
}
};
let nonce = () => Math.floor(Math.random() * 16777215).toString(16);
if (isTestMode()) {
nonce = () => 'nonce';
}
const createUniqueId = (prefix) => `${prefix}-${nonce()}`;
const createRelatedUniqueId = (baseId, suffix) => {
const separatorIndex = baseId.lastIndexOf('-');
if (separatorIndex === -1)
return `${baseId}-${suffix}`;
const lastSegment = baseId.slice(separatorIndex + 1);
const isNonce = lastSegment === 'nonce' || /^[0-9a-f]+$/.test(lastSegment);
return isNonce ? `${baseId.slice(0, separatorIndex)}-${suffix}-${lastSegment}` : `${baseId}-${suffix}`;
};
export { createRelatedUniqueId as a, createUniqueId as c, initKoliBri as i, nonce as n, renderDevAdvice as r };
//# sourceMappingURL=dev.utils.js.map
//# sourceMappingURL=dev.utils.js.map