@@ -2,7 +2,7 @@ import { isUndefined } from 'lodash';
22import React , { useCallback , useEffect , useMemo } from 'react' ;
33
44import { usePrefixConfig , useComponentConfig , useCustomContext , useImmer , useRefCallback , useTranslation } from '../../hooks' ;
5- import { getClassName , getHorizontalSideStyle , toId } from '../../utils' ;
5+ import { getClassName , getHorizontalSideStyle , mergeStyle , toId } from '../../utils' ;
66import { DPopup } from '../_popup' ;
77import { DIcon } from '../icon' ;
88import { DDropdownContext } from './Dropdown' ;
@@ -17,6 +17,7 @@ export interface DDropdownSubProps extends React.LiHTMLAttributes<HTMLLIElement>
1717 dIcon ?: React . ReactNode ;
1818 dTitle : React . ReactNode ;
1919 dDisabled ?: boolean ;
20+ __level ?: number ;
2021}
2122
2223export function DDropdownSub ( props : DDropdownSubProps ) {
@@ -25,6 +26,7 @@ export function DDropdownSub(props: DDropdownSubProps) {
2526 dIcon,
2627 dTitle,
2728 dDisabled = false ,
29+ __level = 0 ,
2830 id,
2931 className,
3032 style,
@@ -137,6 +139,9 @@ export function DDropdownSub(props: DDropdownSubProps) {
137139 className = { getClassName ( className , `${ dPrefix } dropdown-sub` , {
138140 'is-disabled' : dDisabled ,
139141 } ) }
142+ style = { mergeStyle ( style , {
143+ paddingLeft : 12 + __level * 16 ,
144+ } ) }
140145 role = "menuitem"
141146 tabIndex = { isUndefined ( tabIndex ) ? - 1 : tabIndex }
142147 aria-haspopup = { true }
@@ -165,7 +170,18 @@ export function DDropdownSub(props: DDropdownSubProps) {
165170 aria-orientation = "vertical"
166171 aria-activedescendant = { activedescendant }
167172 >
168- { React . Children . count ( children ) === 0 ? < span className = { `${ dPrefix } dropdown-sub__empty` } > { t ( 'No Data' ) } </ span > : children }
173+ { React . Children . count ( children ) === 0 ? (
174+ < span
175+ className = { `${ dPrefix } dropdown-sub__empty` }
176+ style = { {
177+ paddingLeft : 12 + __level * 16 ,
178+ } }
179+ >
180+ { t ( 'No Data' ) }
181+ </ span >
182+ ) : (
183+ children
184+ ) }
169185 </ ul >
170186 }
171187 dTrigger = { dropdownPopupTrigger }
0 commit comments