@@ -2,8 +2,11 @@ import { sveltify } from '@svelte-preprocess-react';
22import { ReactSlot } from '@svelte-preprocess-react/react-slot' ;
33import type { SetSlotParams } from '@svelte-preprocess-react/slot' ;
44import React , { useMemo } from 'react' ;
5+ import { useFunction } from '@utils/hooks/useFunction' ;
56import { useTargets } from '@utils/hooks/useTargets' ;
7+ import { omitUndefinedProps } from '@utils/omitUndefinedProps' ;
68import { renderItems } from '@utils/renderItems' ;
9+ import { renderParamsSlot } from '@utils/renderParamsSlot' ;
710import { Card as ACard , type GetProps } from 'antd' ;
811
912import {
@@ -21,6 +24,8 @@ export const Card = sveltify<
2124 'cover' ,
2225 'extra' ,
2326 'tabBarExtraContent' ,
27+ 'tabBarExtraContent.left' ,
28+ 'tabBarExtraContent.right' ,
2429 'title' ,
2530 'tabProps.addIcon' ,
2631 'tabProps.removeIcon' ,
@@ -33,15 +38,81 @@ export const Card = sveltify<
3338> (
3439 withTabsItemsContextProvider (
3540 [ 'tabList' ] ,
36- ( { children, containsGrid, slots, tabList, tabProps, ...props } ) => {
41+ ( {
42+ children,
43+ containsGrid,
44+ slots,
45+ tabList,
46+ tabProps,
47+ setSlotParams,
48+ ...props
49+ } ) => {
3750 const targets = useTargets ( children , 'actions' ) ;
3851 const {
3952 items : { tabList : tabListItems } ,
4053 } = useTabsItems < [ 'tabList' ] > ( ) ;
54+ const { indicator, more, renderTabBar } = tabProps || { } ;
55+ const indicatorSizeFunction = useFunction ( indicator ?. size ) ;
56+ const getMorePopupContainerFunction = useFunction (
57+ more ?. getPopupContainer
58+ ) ;
59+ const renderTabBarFunction = useFunction ( renderTabBar ) ;
4160 return (
4261 < ACard
4362 { ...props }
44- tabProps = { tabProps }
63+ tabProps = { {
64+ ...( tabProps || { } ) ,
65+ indicator : indicatorSizeFunction
66+ ? {
67+ ...indicator ,
68+ size : indicatorSizeFunction ,
69+ }
70+ : indicator ,
71+ renderTabBar : slots [ 'tabProps.renderTabBar' ]
72+ ? renderParamsSlot ( {
73+ slots,
74+ setSlotParams,
75+ key : 'tabProps.renderTabBar' ,
76+ } )
77+ : renderTabBarFunction ,
78+ more : omitUndefinedProps ( {
79+ ...( more || { } ) ,
80+ getPopupContainer :
81+ getMorePopupContainerFunction || more ?. getPopupContainer ,
82+ icon : slots [ 'tabProps.more.icon' ] ? (
83+ < ReactSlot slot = { slots [ 'tabProps.more.icon' ] } />
84+ ) : (
85+ more ?. icon
86+ ) ,
87+ } ) ,
88+ tabBarExtraContent : slots [ 'tabProps.tabBarExtraContent' ] ? (
89+ < ReactSlot slot = { slots [ 'tabProps.tabBarExtraContent' ] } />
90+ ) : slots [ 'tabProps.tabBarExtraContent.left' ] ||
91+ slots [ 'tabProps.tabBarExtraContent.right' ] ? (
92+ {
93+ left : slots [ 'tabProps.tabBarExtraContent.left' ] ? (
94+ < ReactSlot slot = { slots [ 'tabProps.tabBarExtraContent.left' ] } />
95+ ) : undefined ,
96+ right : slots [ 'tabProps.tabBarExtraContent.right' ] ? (
97+ < ReactSlot
98+ slot = { slots [ 'tabProps.tabBarExtraContent.right' ] }
99+ />
100+ ) : undefined ,
101+ }
102+ ) : (
103+ tabProps ?. tabBarExtraContent
104+ ) ,
105+ addIcon : slots [ 'tabProps.addIcon' ] ? (
106+ < ReactSlot slot = { slots [ 'tabProps.addIcon' ] } />
107+ ) : (
108+ tabProps ?. addIcon
109+ ) ,
110+ removeIcon : slots [ 'tabProps.removeIcon' ] ? (
111+ < ReactSlot slot = { slots [ 'tabProps.removeIcon' ] } />
112+ ) : (
113+ tabProps ?. removeIcon
114+ ) ,
115+ } }
45116 tabList = { useMemo ( ( ) => {
46117 return (
47118 tabList ||
@@ -54,8 +125,18 @@ export const Card = sveltify<
54125 extra = { slots . extra ? < ReactSlot slot = { slots . extra } /> : props . extra }
55126 cover = { slots . cover ? < ReactSlot slot = { slots . cover } /> : props . cover }
56127 tabBarExtraContent = {
57- slots . tabBarExtraContent ? (
58- < ReactSlot slot = { slots . tabBarExtraContent } />
128+ slots [ 'tabBarExtraContent' ] ? (
129+ < ReactSlot slot = { slots [ 'tabBarExtraContent' ] } />
130+ ) : slots [ 'tabBarExtraContent.left' ] ||
131+ slots [ 'tabBarExtraContent.right' ] ? (
132+ {
133+ left : slots [ 'tabBarExtraContent.left' ] ? (
134+ < ReactSlot slot = { slots [ 'tabBarExtraContent.left' ] } />
135+ ) : undefined ,
136+ right : slots [ 'tabBarExtraContent.right' ] ? (
137+ < ReactSlot slot = { slots [ 'tabBarExtraContent.right' ] } />
138+ ) : undefined ,
139+ }
59140 ) : (
60141 props . tabBarExtraContent
61142 )
0 commit comments