1
1
// import EnUS from './locale/en-US';
2
2
import type { DraggableProps , DraggableFC } from './draggable.types' ;
3
- import { createElement , forwardRef , FC } from 'react' ;
4
3
// import { useLocale } from '~/config-provider/useLocale';
5
4
import type { RequiredPart } from '@tool-pack/types' ;
5
+ import { TransitionGroup } from '~/transition-group' ;
6
+ import { createElement , forwardRef } from 'react' ;
6
7
import { getClassNames } from '@tool-pack/basic' ;
7
8
import { useDraggableChildren } from './hooks' ;
9
+ import type { ReactElement , FC } from 'react' ;
8
10
import { getClasses } from '@pkg/shared' ;
9
11
10
12
export const cls = getClasses ( 'draggable' , [ 'ghost' , 'item' ] , [ ] ) ;
@@ -18,18 +20,29 @@ export const _Draggable: FC<DraggableProps> = forwardRef<
18
20
DraggableProps
19
21
> ( ( props , ref ) => {
20
22
// const locale = useLocale('draggable', EnUS);
21
- const { attrs = { } , tag } = props as RequiredPart <
22
- DraggableProps ,
23
- keyof typeof defaultProps
24
- > ;
23
+ const {
24
+ transition,
25
+ attrs = { } ,
26
+ tag,
27
+ } = props as RequiredPart < DraggableProps , keyof typeof defaultProps > ;
25
28
const children = useDraggableChildren ( props ) ;
29
+ const className = getClassNames ( cls . root , attrs . className ) ;
30
+
31
+ if ( transition && children ) {
32
+ const transitionProps = transition === true ? undefined : transition ;
33
+ return (
34
+ < TransitionGroup { ...transitionProps } className = { className } tag = { tag } >
35
+ { children as ReactElement [ ] }
36
+ </ TransitionGroup >
37
+ ) ;
38
+ }
26
39
27
40
if ( tag === null ) return children ;
28
41
return createElement (
29
42
tag ,
30
43
{
31
44
...attrs ,
32
- className : getClassNames ( cls . root , attrs . className ) ,
45
+ className,
33
46
ref,
34
47
} ,
35
48
children ,
0 commit comments