From 2dfa44cc2a415d06dd9fe34dfe2703308db1abd1 Mon Sep 17 00:00:00 2001 From: ITBoomBKStudio Date: Sat, 25 Oct 2025 00:50:03 +0200 Subject: [PATCH 1/3] fix(system-rsc): correct slot detection in getSlots() --- .../core/system-rsc/src/extend-variants.js | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/packages/core/system-rsc/src/extend-variants.js b/packages/core/system-rsc/src/extend-variants.js index f91957acab..16e3d7cea5 100644 --- a/packages/core/system-rsc/src/extend-variants.js +++ b/packages/core/system-rsc/src/extend-variants.js @@ -5,21 +5,32 @@ import clsx from "clsx"; import {mapPropsVariants} from "./utils"; 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)) { + 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({ From 029355241db85efa5e5758170bf6e85b165b048c Mon Sep 17 00:00:00 2001 From: ITBoomBKStudio Date: Sat, 25 Oct 2025 17:34:53 +0200 Subject: [PATCH 2/3] fix(system-rsc): getSlots() brief JSDoc comment added --- packages/core/system-rsc/src/extend-variants.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/core/system-rsc/src/extend-variants.js b/packages/core/system-rsc/src/extend-variants.js index 16e3d7cea5..a199400e1f 100644 --- a/packages/core/system-rsc/src/extend-variants.js +++ b/packages/core/system-rsc/src/extend-variants.js @@ -4,6 +4,12 @@ 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) { if (!variants || typeof variants !== "object") return {}; @@ -13,6 +19,7 @@ function getSlots(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" || From c878267fd37f3a4d013c8c8be13881661ec2f6e5 Mon Sep 17 00:00:00 2001 From: ITBoomBKStudio Date: Sun, 26 Oct 2025 14:55:22 +0100 Subject: [PATCH 3/3] chore(system-rsc): add changeset for getSlots() slot detection fix --- .changeset/four-guests-sneeze.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/four-guests-sneeze.md diff --git a/.changeset/four-guests-sneeze.md b/.changeset/four-guests-sneeze.md new file mode 100644 index 0000000000..c6f4661953 --- /dev/null +++ b/.changeset/four-guests-sneeze.md @@ -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.