11import type { App , Plugin , ExtractPropTypes , PropType , HTMLAttributes } from 'vue' ;
22import { provide , defineComponent , ref , watch , computed , toRef } from 'vue' ;
33import PropTypes from '../_util/vue-types' ;
4+ import classNames from '../_util/classNames' ;
45
56import type { SpinProps } from '../spin' ;
67import Spin from '../spin' ;
@@ -19,6 +20,9 @@ import type { Breakpoint } from '../_util/responsiveObserve';
1920import { responsiveArray } from '../_util/responsiveObserve' ;
2021import eagerComputed from '../_util/eagerComputed' ;
2122
23+ // CSSINJS
24+ import useStyle from './style' ;
25+
2226export type { ListItemProps } from './Item' ;
2327export type { ListItemMetaProps } from './ItemMeta' ;
2428
@@ -79,6 +83,7 @@ import type { RenderEmptyHandler } from '../config-provider/renderEmpty';
7983const List = defineComponent ( {
8084 compatConfig : { MODE : 3 } ,
8185 name : 'AList' ,
86+ inheritAttrs : false ,
8287 Item,
8388 props : initDefaultProps ( listProps ( ) , {
8489 dataSource : [ ] ,
@@ -88,7 +93,7 @@ const List = defineComponent({
8893 pagination : false ,
8994 } ) ,
9095 slots : [ 'extra' , 'loadMore' , 'renderItem' , 'header' , 'footer' ] ,
91- setup ( props , { slots } ) {
96+ setup ( props , { slots, attrs } ) {
9297 provide ( ListContextKey , {
9398 grid : toRef ( props , 'grid' ) ,
9499 itemLayout : toRef ( props , 'itemLayout' ) ,
@@ -98,6 +103,10 @@ const List = defineComponent({
98103 total : 0 ,
99104 } ;
100105 const { prefixCls, direction, renderEmpty } = useConfigInject ( 'list' , props ) ;
106+
107+ // Style
108+ const [ wrapSSR , hashId ] = useStyle ( prefixCls ) ;
109+
101110 const paginationObj = computed ( ( ) =>
102111 props . pagination && typeof props . pagination === 'object' ? props . pagination : { } ,
103112 ) ;
@@ -260,10 +269,14 @@ const List = defineComponent({
260269 const header = props . header ?? slots . header ?.( ) ;
261270 const children = flattenChildren ( slots . default ?.( ) ) ;
262271 const isSomethingAfterLastItem = ! ! ( loadMore || props . pagination || footer ) ;
263- const classString = {
264- ...classObj . value ,
265- [ `${ prefixCls . value } -something-after-last-item` ] : isSomethingAfterLastItem ,
266- } ;
272+ const classString = classNames (
273+ {
274+ ...classObj . value ,
275+ [ `${ prefixCls . value } -something-after-last-item` ] : isSomethingAfterLastItem ,
276+ } ,
277+ attrs . class ,
278+ hashId . value ,
279+ ) ;
267280 const paginationContent = props . pagination ? (
268281 < div class = { `${ prefixCls . value } -pagination` } >
269282 < Pagination
@@ -295,8 +308,8 @@ const List = defineComponent({
295308 }
296309
297310 const paginationPosition = paginationProps . value . position || 'bottom' ;
298- return (
299- < div class = { classString } >
311+ return wrapSSR (
312+ < div { ... attrs } class = { classString } >
300313 { ( paginationPosition === 'top' || paginationPosition === 'both' ) && paginationContent }
301314 { header && < div class = { `${ prefixCls . value } -header` } > { header } </ div > }
302315 < Spin { ...loadingProp . value } >
@@ -307,7 +320,7 @@ const List = defineComponent({
307320 { loadMore ||
308321 ( ( paginationPosition === 'bottom' || paginationPosition === 'both' ) &&
309322 paginationContent ) }
310- </ div >
323+ </ div > ,
311324 ) ;
312325 } ;
313326 } ,
0 commit comments