@blockle/blocks 0.14.1 → 0.14.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -145,15 +145,34 @@ function createAsChildTemplate(defaultElement) {
|
|
|
145
145
|
});
|
|
146
146
|
const slot = childrenArray[slotIndex];
|
|
147
147
|
if (!slot) {
|
|
148
|
-
if (process.env.NODE_ENV
|
|
148
|
+
if (process.env.NODE_ENV !== "production") {
|
|
149
149
|
console.error("Template: No Slot provided");
|
|
150
150
|
}
|
|
151
151
|
return null;
|
|
152
152
|
}
|
|
153
|
-
if (!react.isValidElement(slot)
|
|
153
|
+
if (!react.isValidElement(slot)) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
if (!react.isValidElement(slot.props.children)) {
|
|
157
|
+
if (process.env.NODE_ENV !== "production") {
|
|
158
|
+
if (react.Children.toArray(slot.props.children).length === 0) {
|
|
159
|
+
console.error("When using asChild, at least one child is required");
|
|
160
|
+
} else {
|
|
161
|
+
console.error("When using asChild, only one child is allowed");
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
if (!react.isValidElement(slot.props.children)) {
|
|
154
167
|
return null;
|
|
155
168
|
}
|
|
156
169
|
const nextChildren = [...childrenArray];
|
|
170
|
+
if (nextChildren.length === 1 && !slot.props.children.props.children) {
|
|
171
|
+
return react.cloneElement(slot.props.children, {
|
|
172
|
+
...mergeProps(rootProps, slot.props.children.props),
|
|
173
|
+
ref: composeRefs(ref, slot.props.children.ref)
|
|
174
|
+
});
|
|
175
|
+
}
|
|
157
176
|
nextChildren[slotIndex] = slot.props.children.props.children;
|
|
158
177
|
return react.cloneElement(
|
|
159
178
|
slot.props.children,
|
|
@@ -144,15 +144,34 @@ function createAsChildTemplate(defaultElement) {
|
|
|
144
144
|
});
|
|
145
145
|
const slot = childrenArray[slotIndex];
|
|
146
146
|
if (!slot) {
|
|
147
|
-
if (process.env.NODE_ENV
|
|
147
|
+
if (process.env.NODE_ENV !== "production") {
|
|
148
148
|
console.error("Template: No Slot provided");
|
|
149
149
|
}
|
|
150
150
|
return null;
|
|
151
151
|
}
|
|
152
|
-
if (!isValidElement(slot)
|
|
152
|
+
if (!isValidElement(slot)) {
|
|
153
|
+
return null;
|
|
154
|
+
}
|
|
155
|
+
if (!isValidElement(slot.props.children)) {
|
|
156
|
+
if (process.env.NODE_ENV !== "production") {
|
|
157
|
+
if (Children.toArray(slot.props.children).length === 0) {
|
|
158
|
+
console.error("When using asChild, at least one child is required");
|
|
159
|
+
} else {
|
|
160
|
+
console.error("When using asChild, only one child is allowed");
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
if (!isValidElement(slot.props.children)) {
|
|
153
166
|
return null;
|
|
154
167
|
}
|
|
155
168
|
const nextChildren = [...childrenArray];
|
|
169
|
+
if (nextChildren.length === 1 && !slot.props.children.props.children) {
|
|
170
|
+
return cloneElement(slot.props.children, {
|
|
171
|
+
...mergeProps(rootProps, slot.props.children.props),
|
|
172
|
+
ref: composeRefs(ref, slot.props.children.ref)
|
|
173
|
+
});
|
|
174
|
+
}
|
|
156
175
|
nextChildren[slotIndex] = slot.props.children.props.children;
|
|
157
176
|
return cloneElement(
|
|
158
177
|
slot.props.children,
|