@@ -10,8 +10,8 @@ import DensityIcon from './DensityIcon'
10
10
import type { ActionType , ProTableProps , OptionSearchProps , LabelTooltipType } from '../../typing'
11
11
import { useIntl } from '#/provider'
12
12
import type { IntlType } from '#/provider'
13
- import { VueNodePropType } from '#/types'
14
- import type { VueKey , VueNode } from '#/types'
13
+ import { VueNodeOrRenderPropType , VueNodePropType } from '#/types'
14
+ import type { VueKey , VueNode , VueNodeOrRender } from '#/types'
15
15
import { computed , defineComponent , watchEffect } from 'vue'
16
16
import type { ExtractPropTypes , PropType , Ref } from 'vue'
17
17
import type { ChangeEvent } from 'ant-design-vue/es/_util/EventInterface'
@@ -20,6 +20,7 @@ import { useContainer } from '#/table/container'
20
20
import { getRender } from '#/layout/utils'
21
21
import type { ToolBarRender } from '#/table/renderTypes'
22
22
import ColumnSetting from '#/table/components/ColumnSetting'
23
+ import { isFunction } from '@vueuse/shared'
23
24
24
25
export type OptionConfig = {
25
26
density ?: boolean
@@ -42,7 +43,7 @@ export type OptionsFunctionType = (e: MouseEvent, action?: ActionType) => void
42
43
export type OptionsType = OptionsFunctionType | boolean
43
44
44
45
export const toolBarProps = ( ) => ( {
45
- headerTitle : VueNodePropType as PropType < VueNode > ,
46
+ headerTitle : VueNodeOrRenderPropType as PropType < VueNodeOrRender > ,
46
47
tooltip : [ String , Object ] as PropType < LabelTooltipType > ,
47
48
toolbar : Object as PropType < ListToolBarProps > ,
48
49
toolBarRender : Function as PropType < ToolBarRender > ,
@@ -234,9 +235,15 @@ const ToolBar = defineComponent({
234
235
: [ ]
235
236
} )
236
237
238
+ const titleDom = computed ( ( ) => {
239
+ const headerRender = getRender < VueNode > ( props , slots , 'headerTitle' )
240
+ // @ts -ignore
241
+ return isFunction ( headerRender ) ? headerRender ( ) : headerRender
242
+ } )
243
+
237
244
return ( ) => (
238
245
< ListToolBar
239
- title = { props . headerTitle }
246
+ title = { titleDom . value }
240
247
tooltip = { props . tooltip }
241
248
search = { searchConfig . value }
242
249
onSearch = { props . onSearch }
@@ -256,7 +263,7 @@ const toolbarRenderProps = () => ({
256
263
tooltip : [ String , Object ] as PropType < string | LabelTooltipType > ,
257
264
selectedRows : Array as PropType < any [ ] > ,
258
265
selectedRowKeys : Array as PropType < VueKey [ ] > ,
259
- headerTitle : VueNodePropType as PropType < VueNode > ,
266
+ headerTitle : VueNodeOrRenderPropType as PropType < VueNodeOrRender > ,
260
267
toolbar : Object as PropType < ProTableProps [ 'toolbar' ] > ,
261
268
options : [ Object , Boolean ] as PropType < ProTableProps [ 'options' ] > ,
262
269
toolBarRender : Function as PropType < ToolBarProps [ 'toolBarRender' ] > ,
0 commit comments