mirror of
https://github.com/smartxworks/sunmao-ui.git
synced 2024-11-27 08:39:59 +08:00
Merge pull request #216 from webzard-io/fix/windlike-patch
fix: set slot to different types depend on slot children's num
This commit is contained in:
commit
951f8c8dd7
@ -74,7 +74,7 @@ export default implementRuntimeComponent({
|
||||
</TabList>
|
||||
<TabPanels>
|
||||
{tabNames.map((_, idx) => {
|
||||
const ele = slotsElements.content ? slotsElements.content[idx] : placeholder;
|
||||
const ele = slotsElements.content ? ([] as React.ReactElement[]).concat(slotsElements.content)[idx] : placeholder;
|
||||
return (
|
||||
<TabPanel
|
||||
key={idx}
|
||||
|
@ -150,15 +150,17 @@ const _ImplWrapper = React.forwardRef<HTMLDivElement, ImplWrapperProps>((props,
|
||||
if (!childrenMap[c.id]) {
|
||||
return {};
|
||||
}
|
||||
const res: Record<string, React.ReactElement[]> = {};
|
||||
const res: Record<string, React.ReactElement[] | React.ReactElement> = {};
|
||||
for (const slot in childrenMap[c.id]) {
|
||||
res[slot] = childrenMap[c.id][slot].map(child => {
|
||||
const slotChildren = childrenMap[c.id][slot].map(child => {
|
||||
if (!childrenCache.get(child)) {
|
||||
const ele = <ImplWrapper key={child.id} {...props} component={child} />;
|
||||
childrenCache.set(child, ele);
|
||||
}
|
||||
return childrenCache.get(child)!;
|
||||
});
|
||||
|
||||
res[slot] = slotChildren.length === 1 ? slotChildren[0] : slotChildren;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ export type ComponentImplProps<
|
||||
> = ImplWrapperProps<KSlot> &
|
||||
TraitResult<KStyleSlot, KEvent>['props'] &
|
||||
RuntimeFunctions<TState, TMethods> & {
|
||||
slotsElements: Record<KSlot, React.ReactElement[]>;
|
||||
slotsElements: Record<KSlot, React.ReactElement[] | React.ReactElement>;
|
||||
};
|
||||
|
||||
export type ComponentImpl<
|
||||
|
Loading…
Reference in New Issue
Block a user