Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/four-guests-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@heroui/system-rsc": minor
---

fix(system-rsc): correct slot detection in getSlots() to ensure proper slot key extraction and consistent compoundVariants behavior.
48 changes: 33 additions & 15 deletions packages/core/system-rsc/src/extend-variants.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,40 @@ import clsx from "clsx";

import {mapPropsVariants} from "./utils";

/**
* Extracts slot names from variant configurations.
* Traverses: variants -> variant groups -> variant configs -> slot names
* @param {Object} variants - Nested object: { variantName: { value: { slotName: "...", ... } } }
* @returns {Object} Map of slot names to empty strings
*/
function getSlots(variants) {
return variants
? Object.values(variants)
.flatMap(Object.values)
.reduce((acc, slot) => {
if (typeof slot === "object" && slot !== null && !(slot instanceof String)) {
Object.keys(slot).forEach((key) => {
if (!acc.hasOwnProperty(key)) {
acc[key] = "";
}
});
}

return acc;
}, {})
: {};
if (!variants || typeof variants !== "object") return {};

const acc = Object.create(null);

for (const group of Object.values(variants)) {
if (!group || typeof group !== "object") continue;

for (const config of Object.values(group)) {
// Skip non-objects, arrays (which would yield numeric indices), and String objects
if (
!config ||
typeof config !== "object" ||
Array.isArray(config) ||
config instanceof String
) {
continue;
}

for (const slotName of Object.keys(config)) {
if (!Object.prototype.hasOwnProperty.call(acc, slotName)) {
acc[slotName] = "";
}
}
}
}

return acc;
}

function getClassNamesWithProps({
Expand Down
Loading