@public-ui/components
Version:
Contains all web components that belong to KoliBri - The accessible HTML-Standard.
28 lines (27 loc) • 1.16 kB
JavaScript
/*!
* KoliBri - The accessible HTML-Standard
*/
import { containsOnlyNumbers, hasEnoughReadableChars } from "../props";
import { a11yHint } from "../utils";
export const validateInputSelectOptions = (option) => {
if (typeof option === 'object' && option !== null) {
if (typeof option.label === 'string' && option.label.length > 0) {
option.disabled = option.disabled === true;
option.label = `${option.label}`.trim();
if (hasEnoughReadableChars(option.label, 3) === false && containsOnlyNumbers(option.label) === false) {
a11yHint(`A differing Aria-Label (${option.label}) is inaccessible. A differing Aria-Label should consist of at least three readable characters.`);
}
if (Array.isArray(option.options)) {
return (option.options.find((item) => {
return validateInputSelectOptions(item) === false;
}) === undefined);
}
return true;
}
else if (typeof option.label === 'number') {
return true;
}
}
return false;
};
//# sourceMappingURL=options.js.map