1- import type { CSSProperties , ExtractPropTypes , PropType } from 'vue' ;
1+ import type { CSSProperties , ExtractPropTypes } from 'vue' ;
22import { computed , watchEffect , defineComponent , ref , watch , toRaw } from 'vue' ;
33import PropTypes from '../_util/vue-types' ;
44import { getPropsSlot } from '../_util/props-util' ;
@@ -8,7 +8,15 @@ import Operation from './operation';
88import LocaleReceiver from '../locale-provider/LocaleReceiver' ;
99import defaultLocale from '../locale/en_US' ;
1010import type { VueNode } from '../_util/type' ;
11- import { withInstall } from '../_util/type' ;
11+ import {
12+ withInstall ,
13+ stringType ,
14+ arrayType ,
15+ someType ,
16+ booleanType ,
17+ objectType ,
18+ functionType ,
19+ } from '../_util/type' ;
1220import useConfigInject from '../config-provider/hooks/useConfigInject' ;
1321import type { TransferListBodyProps } from './ListBody' ;
1422import type { PaginationType } from './interface' ;
@@ -17,6 +25,9 @@ import type { RenderEmptyHandler } from '../config-provider/renderEmpty';
1725import type { InputStatus } from '../_util/statusUtils' ;
1826import { getStatusClassNames , getMergedStatus } from '../_util/statusUtils' ;
1927
28+ // CSSINJS
29+ import useStyle from './style' ;
30+
2031export type { TransferListProps } from './list' ;
2132export type { TransferOperationProps } from './operation' ;
2233export type { TransferSearchProps } from './search' ;
@@ -69,40 +80,41 @@ export interface TransferLocale {
6980export const transferProps = ( ) => ( {
7081 id : String ,
7182 prefixCls : String ,
72- dataSource : { type : Array as PropType < TransferItem [ ] > , default : [ ] } ,
73- disabled : { type : Boolean , default : undefined } ,
74- targetKeys : { type : Array as PropType < string [ ] > , default : undefined } ,
75- selectedKeys : { type : Array as PropType < string [ ] > , default : undefined } ,
76- render : { type : Function as PropType < TransferRender < TransferItem > > } ,
77- listStyle : {
78- type : [ Function , Object ] as PropType < ( ( style : ListStyle ) => CSSProperties ) | CSSProperties > ,
79- default : ( ) => ( { } ) ,
80- } ,
81- operationStyle : { type : Object as PropType < CSSProperties > , default : undefined as CSSProperties } ,
82- titles : { type : Array as PropType < string [ ] > } ,
83- operations : { type : Array as PropType < string [ ] > } ,
84- showSearch : { type : Boolean , default : false } ,
85- filterOption : { type : Function as PropType < ( inputValue : string , item : TransferItem ) => boolean > } ,
83+ dataSource : arrayType < TransferItem [ ] > ( [ ] ) ,
84+ disabled : booleanType ( ) ,
85+ targetKeys : arrayType < string [ ] > ( ) ,
86+ selectedKeys : arrayType < string [ ] > ( ) ,
87+ render : functionType < TransferRender < TransferItem > > ( ) ,
88+ listStyle : someType < ( ( style : ListStyle ) => CSSProperties ) | CSSProperties > (
89+ [ Function , Object ] ,
90+ ( ) => ( { } ) ,
91+ ) ,
92+ operationStyle : objectType < CSSProperties > ( undefined as CSSProperties ) ,
93+ titles : arrayType < string [ ] > ( ) ,
94+ operations : arrayType < string [ ] > ( ) ,
95+ showSearch : booleanType ( false ) ,
96+ filterOption : functionType < ( inputValue : string , item : TransferItem ) => boolean > ( ) ,
8697 searchPlaceholder : String ,
8798 notFoundContent : PropTypes . any ,
88- locale : { type : Object as PropType < Partial < TransferLocale > > , default : ( ) => ( { } ) } ,
89- rowKey : { type : Function as PropType < ( record : TransferItem ) => string > } ,
90- showSelectAll : { type : Boolean , default : undefined } ,
91- selectAllLabels : { type : Array as PropType < SelectAllLabel [ ] > } ,
92- children : { type : Function as PropType < ( props : TransferListBodyProps ) => VueNode > } ,
93- oneWay : { type : Boolean , default : undefined } ,
94- pagination : { type : [ Object , Boolean ] as PropType < PaginationType > , default : undefined } ,
95- status : String as PropType < InputStatus > ,
96- onChange : Function as PropType <
97- ( targetKeys : string [ ] , direction : TransferDirection , moveKeys : string [ ] ) => void
98- > ,
99- onSelectChange : Function as PropType <
99+ locale : objectType ( ) ,
100+ rowKey : functionType < ( record : TransferItem ) => string > ( ) ,
101+ showSelectAll : booleanType ( ) ,
102+ selectAllLabels : arrayType < SelectAllLabel [ ] > ( ) ,
103+ children : functionType < ( props : TransferListBodyProps ) => VueNode > ( ) ,
104+ oneWay : booleanType ( ) ,
105+ pagination : someType < PaginationType > ( [ Object , Boolean ] ) ,
106+ status : stringType < InputStatus > ( ) ,
107+ onChange :
108+ functionType <
109+ ( targetKeys : string [ ] , direction : TransferDirection , moveKeys : string [ ] ) => void
110+ > ( ) ,
111+ onSelectChange : functionType <
100112 ( sourceSelectedKeys : string [ ] , targetSelectedKeys : string [ ] ) => void
101113 > ,
102- onSearch : Function as PropType < ( direction : TransferDirection , value : string ) => void > ,
103- onScroll : Function as PropType < ( direction : TransferDirection , e : UIEvent ) => void > ,
104- 'onUpdate:targetKeys' : Function as PropType < ( keys : string [ ] ) => void > ,
105- 'onUpdate:selectedKeys' : Function as PropType < ( keys : string [ ] ) => void > ,
114+ onSearch : functionType < ( direction : TransferDirection , value : string ) => void > ( ) ,
115+ onScroll : functionType < ( direction : TransferDirection , e : UIEvent ) => void > ( ) ,
116+ 'onUpdate:targetKeys' : functionType < ( keys : string [ ] ) => void > ( ) ,
117+ 'onUpdate:selectedKeys' : functionType < ( keys : string [ ] ) => void > ( ) ,
106118} ) ;
107119
108120export type TransferProps = Partial < ExtractPropTypes < ReturnType < typeof transferProps > > > ;
@@ -125,6 +137,10 @@ const Transfer = defineComponent({
125137 // emits: ['update:targetKeys', 'update:selectedKeys', 'change', 'search', 'scroll', 'selectChange'],
126138 setup ( props , { emit, attrs, slots, expose } ) {
127139 const { configProvider, prefixCls, direction } = useConfigInject ( 'transfer' , props ) ;
140+
141+ // style
142+ const [ wrapSSR , hashId ] = useStyle ( prefixCls ) ;
143+
128144 const sourceSelectedKeys = ref ( [ ] ) ;
129145 const targetSelectedKeys = ref ( [ ] ) ;
130146
@@ -349,14 +365,15 @@ const Transfer = defineComponent({
349365 [ `${ prefixCls . value } -rtl` ] : direction . value === 'rtl' ,
350366 } ,
351367 getStatusClassNames ( prefixCls . value , mergedStatus . value , formItemInputContext . hasFeedback ) ,
368+ hashId . value ,
352369 ) ;
353370 const titles = props . titles ;
354371 const leftTitle =
355372 ( titles && titles [ 0 ] ) ?? slots . leftTitle ?.( ) ?? ( locale . titles || [ '' , '' ] ) [ 0 ] ;
356373 const rightTitle =
357374 ( titles && titles [ 1 ] ) ?? slots . rightTitle ?.( ) ?? ( locale . titles || [ '' , '' ] ) [ 1 ] ;
358375 return (
359- < div class = { cls } style = { style as CSSProperties } id = { id } >
376+ < div { ... attrs } class = { cls } style = { style as CSSProperties } id = { id } >
360377 < List
361378 key = "leftList"
362379 prefixCls = { `${ prefixCls . value } -list` }
@@ -422,13 +439,14 @@ const Transfer = defineComponent({
422439 </ div >
423440 ) ;
424441 } ;
425- return ( ) => (
426- < LocaleReceiver
427- componentName = "Transfer"
428- defaultLocale = { defaultLocale . Transfer }
429- children = { renderTransfer }
430- />
431- ) ;
442+ return ( ) =>
443+ wrapSSR (
444+ < LocaleReceiver
445+ componentName = "Transfer"
446+ defaultLocale = { defaultLocale . Transfer }
447+ children = { renderTransfer }
448+ /> ,
449+ ) ;
432450 } ,
433451} ) ;
434452
0 commit comments