@kubit-ui-web/react-components
Version:
Kubit React Components is a customizable, accessible library of React web components, designed to enhance your application's user experience
29 lines • 1.31 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildScreenReaderText = void 0;
const concatPrefixSuffix = (index, maxSteps, currentStep, currentLiAriaLabel, prefixSuffixAriaLabel) => {
let ariaLabel;
if (prefixSuffixAriaLabel?.prefix) {
const subString1 = `${prefixSuffixAriaLabel.prefix?.step} ${index + 1}`;
const subString2 = `${prefixSuffixAriaLabel.prefix?.of} ${maxSteps} ${currentLiAriaLabel}`;
ariaLabel = `${subString1} ${subString2}`;
}
else {
ariaLabel = currentLiAriaLabel;
}
if (index < currentStep && prefixSuffixAriaLabel?.suffix?.completed) {
ariaLabel = ariaLabel.concat(' ', prefixSuffixAriaLabel.suffix?.completed);
}
else if (index === currentStep && prefixSuffixAriaLabel?.suffix?.current) {
ariaLabel = ariaLabel.concat(' ', prefixSuffixAriaLabel.suffix?.current);
}
return ariaLabel;
};
const buildScreenReaderText = (index, currentStep, maxSteps, prefixSuffixAriaLabel, curentLiAriaLabel, isVertical) => {
if (!isVertical) {
return undefined;
}
return concatPrefixSuffix(index, maxSteps, currentStep, curentLiAriaLabel, prefixSuffixAriaLabel);
};
exports.buildScreenReaderText = buildScreenReaderText;
//# sourceMappingURL=screnReader.js.map