@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
25 lines • 1.15 kB
JavaScript
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;
};
export const buildScreenReaderText = (index, currentStep, maxSteps, prefixSuffixAriaLabel, curentLiAriaLabel, isVertical) => {
if (!isVertical) {
return undefined;
}
return concatPrefixSuffix(index, maxSteps, currentStep, curentLiAriaLabel, prefixSuffixAriaLabel);
};
//# sourceMappingURL=screnReader.js.map