Skip to content

Commit 327a2c9

Browse files
committed
feat: allow tag prop to accept Component
closes #20806
1 parent 794a2e6 commit 327a2c9

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

packages/vuetify/src/composables/icons.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@ import { computed, inject, unref } from 'vue'
66
import { consoleWarn, defineComponent, genericComponent, mergeDeep, propsFactory } from '@/util'
77

88
// Types
9-
import type { ComponentPublicInstance, FunctionalComponent, InjectionKey, PropType, Ref } from 'vue'
10-
11-
export type JSXComponent<Props = any> =
12-
| { new (): ComponentPublicInstance<Props> }
13-
| FunctionalComponent<Props>
9+
import type { InjectionKey, PropType, Ref } from 'vue'
10+
import type { JSXComponent } from '@/util'
1411

1512
export type IconValue =
1613
| string
@@ -58,7 +55,7 @@ export interface IconAliases {
5855
}
5956

6057
export interface IconProps {
61-
tag: string
58+
tag: string | JSXComponent
6259
icon?: IconValue
6360
disabled?: Boolean
6461
}
@@ -90,7 +87,7 @@ export const makeIconProps = propsFactory({
9087
},
9188
// Could not remove this and use makeTagProps, types complained because it is not required
9289
tag: {
93-
type: String,
90+
type: [String, Object, Function] as PropType<string | JSXComponent>,
9491
required: true,
9592
},
9693
}, 'icon')

packages/vuetify/src/composables/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export type { DefaultsInstance } from './defaults'
1616
export type { DisplayBreakpoint, DisplayInstance, DisplayThresholds } from './display'
1717
export type { SubmitEventPromise } from './form'
1818
export type { GoToInstance } from './goto'
19-
export type { IconAliases, IconProps, IconSet, IconOptions, JSXComponent } from './icons'
19+
export type { IconAliases, IconProps, IconSet, IconOptions } from './icons'
2020
export type { LocaleInstance, LocaleMessages, RtlInstance, LocaleOptions, RtlOptions } from './locale'
2121
export type { ThemeDefinition, ThemeInstance } from './theme'
22+
export type { JSXComponent } from '@/util'
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
// Utilities
22
import { propsFactory } from '@/util'
33

4+
// Types
5+
import type { PropType } from 'vue'
6+
import type { JSXComponent } from '@/util'
7+
48
// Types
59
export interface TagProps {
6-
tag: string
10+
tag: string | JSXComponent
711
}
812

913
// Composables
1014
export const makeTagProps = propsFactory({
1115
tag: {
12-
type: String,
16+
type: [String, Object, Function] as PropType<string | JSXComponent>,
1317
default: 'div',
1418
},
1519
}, 'tag')

packages/vuetify/src/util/defineComponent.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,3 +327,7 @@ export type ComponentInstance<T> = T extends { new (): ComponentPublicInstance<a
327327
type ShortEmitsToObject<E> = E extends Record<string, any[]> ? {
328328
[K in keyof E]: (...args: E[K]) => any;
329329
} : E;
330+
331+
export type JSXComponent<Props = any> =
332+
| { new (): ComponentPublicInstance<Props> }
333+
| FunctionalComponent<Props>

0 commit comments

Comments
 (0)