1- import { Box , Button , Flex , HStack } from '@chakra-ui/react' ;
1+ import { Box , Button , Checkbox , Flex , HStack } from '@chakra-ui/react' ;
22import Avatar from '../../../common/Avatar' ;
33import MyBox from '../../../common/MyBox' ;
44import React , { useMemo , useRef , useState , useEffect } from 'react' ;
@@ -46,7 +46,10 @@ const ToolCard = ({
4646 onUpdate,
4747 onClickCard,
4848 showActionButton = true ,
49- variant = 'default'
49+ variant = 'default' ,
50+ showSelectCheckbox = false ,
51+ isSelected = false ,
52+ onToggleSelect
5053} : {
5154 item : ToolCardItemType ;
5255 systemTitle ?: string ;
@@ -59,6 +62,9 @@ const ToolCard = ({
5962 onClickCard ?: ( ) => void ;
6063 showActionButton ?: boolean ;
6164 variant ?: 'default' | 'marketplace' ;
65+ showSelectCheckbox ?: boolean ;
66+ isSelected ?: boolean ;
67+ onToggleSelect ?: ( ) => void ;
6268} ) => {
6369 const { t, i18n } = useTranslation ( ) ;
6470 const tagsContainerRef = useRef < HTMLDivElement > ( null ) ;
@@ -143,6 +149,8 @@ const ToolCard = ({
143149 }
144150 } , [ isMarketplaceVariant , item . installed , item . status , mode , t ] ) ;
145151
152+ const hasSelectCheckbox = ! ! onToggleSelect ;
153+
146154 return (
147155 < MyBox
148156 key = { item . id }
@@ -192,16 +200,57 @@ const ToolCard = ({
192200 : { } ) ,
193201 '& .download-count' : {
194202 display : 'none'
195- }
203+ } ,
204+ ...( hasSelectCheckbox
205+ ? {
206+ '& .tool-card-select-checkbox' : {
207+ display : 'flex'
208+ }
209+ }
210+ : { } )
196211 } }
197212 >
213+ { hasSelectCheckbox && (
214+ < Flex
215+ className = "tool-card-select-checkbox"
216+ position = { 'absolute' }
217+ top = { isMarketplaceVariant ? '17px' : 4 }
218+ right = { isMarketplaceVariant ? '17px' : 4 }
219+ zIndex = { 2 }
220+ display = { showSelectCheckbox || isSelected ? 'flex' : 'none' }
221+ alignItems = { 'center' }
222+ justifyContent = { 'center' }
223+ bg = { 'white' }
224+ borderRadius = { '4px' }
225+ onClick = { ( e ) => {
226+ e . stopPropagation ( ) ;
227+ } }
228+ >
229+ < Checkbox
230+ isChecked = { isSelected }
231+ onChange = { ( e ) => {
232+ e . stopPropagation ( ) ;
233+ onToggleSelect ?.( ) ;
234+ } }
235+ />
236+ </ Flex >
237+ ) }
238+
198239 { /* Update badge in top-right corner */ }
199240 { item . update && mode === 'admin' && ! item . isDebug && (
200241 < Flex
201242 alignItems = "center"
202243 position = { 'absolute' }
203244 top = { isMarketplaceVariant ? '17px' : 4 }
204- right = { isMarketplaceVariant ? '17px' : 4 }
245+ right = {
246+ hasSelectCheckbox
247+ ? isMarketplaceVariant
248+ ? '45px'
249+ : 12
250+ : isMarketplaceVariant
251+ ? '17px'
252+ : 4
253+ }
205254 px = { 2 }
206255 py = { 0.5 }
207256 bg = { 'rgb(255, 247, 237)' }
0 commit comments