@@ -2,14 +2,11 @@ import { LegacyRef, MouseEvent, Ref } from 'react'
22import { Link } from 'react-router-dom'
33
44import { Tooltip } from '@Common/Tooltip'
5- import { ComponentSizeType } from '@Shared/constants'
65
7- import { Button , ButtonProps , ButtonVariantType } from '../Button'
86import { Icon } from '../Icon'
9- import { NumbersCount } from '../NumbersCount'
107import { getTooltipProps } from '../SelectPicker/common'
11- import { DTSwitch , DTSwitchProps } from '../Switch '
12- import { ActionMenuItemProps , ActionMenuItemType } from './types'
8+ import { TrailingItem } from '../TrailingItem '
9+ import { ActionMenuItemProps } from './types'
1310
1411const COMMON_ACTION_MENU_ITEM_CLASS = 'w-100 flex left top dc__gap-8 py-6 px-8'
1512
@@ -48,24 +45,6 @@ export const ActionMenuItem = <T extends string | number>({
4845 onClick ( item , e )
4946 }
5047
51- const handleTrailingSwitchChange =
52- ( { type : trailingItemType , config } : ActionMenuItemType < T > [ 'trailingItem' ] ) : DTSwitchProps [ 'onChange' ] =>
53- ( e ) => {
54- if ( trailingItemType === 'switch' ) {
55- e . stopPropagation ( )
56- config . onChange ( e )
57- }
58- }
59-
60- const handleTrailingButtonClick =
61- ( { type : trailingItemType , config } : ActionMenuItemType < T > [ 'trailingItem' ] ) : ButtonProps [ 'onClick' ] =>
62- ( e ) => {
63- e . stopPropagation ( )
64- if ( trailingItemType === 'button' && config . onClick ) {
65- config . onClick ( e )
66- }
67- }
68-
6948 // RENDERERS
7049 const renderIcon = ( iconProps : typeof startIcon ) =>
7150 iconProps && (
@@ -79,42 +58,7 @@ export const ActionMenuItem = <T extends string | number>({
7958 return null
8059 }
8160
82- const { type : trailingItemType , config } = trailingItem
83-
84- switch ( trailingItemType ) {
85- case 'icon' :
86- return renderIcon ( config )
87- case 'text' : {
88- const { value, icon } = config
89- return (
90- < span className = "flex dc__gap-2 mt-2" >
91- < span className = "fs-12 lh-1-5 fw-4 cn-7" > { value } </ span >
92- { icon && < Icon name = { icon . name } color = { icon . color || ( isNegativeType ? 'R500' : 'N700' ) } /> }
93- </ span >
94- )
95- }
96- case 'counter' :
97- return < NumbersCount count = { config . value } />
98- case 'switch' :
99- return (
100- < DTSwitch
101- { ...config }
102- onChange = { handleTrailingSwitchChange ( trailingItem ) }
103- size = { ComponentSizeType . small }
104- />
105- )
106- case 'button' :
107- return (
108- < Button
109- { ...( config as ButtonProps ) }
110- onClick = { handleTrailingButtonClick ( trailingItem ) }
111- variant = { ButtonVariantType . borderLess }
112- size = { ComponentSizeType . xxs }
113- />
114- )
115- default :
116- return null
117- }
61+ return < TrailingItem { ...trailingItem } variant = { type } />
11862 }
11963
12064 const renderContent = ( ) => (
0 commit comments