flowbite-react
Version:
Official React components built for Flowbite and Tailwind CSS
36 lines (33 loc) • 1.06 kB
JavaScript
;
const cache = /* @__PURE__ */ new Map();
function convertUtilitiesToV4(classNames) {
if (!classNames.trim().length) {
return classNames;
}
const cacheKey = classNames;
const cacheValue = cache.get(cacheKey);
if (cacheValue) {
return cacheValue;
}
let result = classNames;
for (const [regex, replacement] of regexMap) {
result = result.replace(regex, replacement);
}
cache.set(cacheKey, result);
return result;
}
const regexMap = [
[/\b(shadow-sm)\b/g, "shadow-xs"],
[/(?<!-)(shadow)(?!-)\b/g, "shadow-sm"],
[/\b(drop-shadow-sm)\b/g, "drop-shadow-xs"],
[/\b(drop-shadow)\b(?!-)/g, "drop-shadow-sm"],
[/\b(blur-sm)\b/g, "blur-xs"],
[/\b(blur)\b(?!-)/g, "blur-sm"],
[/\b(rounded-sm)\b/g, "rounded-xs"],
[/\b(rounded)\b(?!-)/g, "rounded-sm"],
// TODO: revisit this - it breaks anything focused using tab
// [/\b(outline-none)\b/g, "outline-hidden"],
[/\b(ring)\b(?!-)/g, "ring-3"]
];
exports.convertUtilitiesToV4 = convertUtilitiesToV4;
//# sourceMappingURL=convert-utilities-to-v4.cjs.map