Skip to content

Commit

Permalink
feat(descriptions): add slots type (tusen-ai#6599)
Browse files Browse the repository at this point in the history
  • Loading branch information
nailiable committed Dec 7, 2024
1 parent bbe901d commit 0139b74
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/descriptions/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
export { descriptionsProps, default as NDescriptions } from './src/Descriptions'
export type { DescriptionProps, DescriptionsProps } from './src/Descriptions'
export type {
DescriptionProps,
DescriptionsProps,
DescriptionsSlots
} from './src/Descriptions'
export {
descriptionsItemProps,
default as NDescriptionsItem
} from './src/DescriptionsItem'
export type { DescriptionItemProps } from './src/DescriptionsItem'
export type {
DescriptionItemProps,
DescriptionItemSlots
} from './src/DescriptionsItem'
7 changes: 7 additions & 0 deletions src/descriptions/src/Descriptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
defineComponent,
h,
type PropType,
type SlotsType,
type VNode
} from 'vue'
import { useConfig, useTheme, useThemeClass } from '../../_mixins'
Expand Down Expand Up @@ -58,9 +59,15 @@ export type DescriptionsProps = ExtractPublicPropTypes<typeof descriptionsProps>
/** @deprecated You should use `DescriptionsProps` */
export type DescriptionProps = DescriptionsProps

export interface DescriptionsSlots {
default?: any
header?: any
}

export default defineComponent({
name: 'Descriptions',
props: descriptionsProps,
slots: Object as SlotsType<DescriptionsSlots>,
setup(props) {
const { mergedClsPrefixRef, inlineThemeDisabled } = useConfig(props)
const themeRef = useTheme(
Expand Down
13 changes: 12 additions & 1 deletion src/descriptions/src/DescriptionsItem.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import type { ExtractPublicPropTypes } from '../../_utils'
import { type CSSProperties, defineComponent, type PropType } from 'vue'
import {
type CSSProperties,
defineComponent,
type PropType,
type SlotsType
} from 'vue'
import { DESCRIPTION_ITEM_FLAG } from './utils'

export const descriptionsItemProps = {
Expand All @@ -18,10 +23,16 @@ export type DescriptionItemProps = ExtractPublicPropTypes<
typeof descriptionsItemProps
>

export interface DescriptionItemSlots {
default?: any
label?: any
}

export default defineComponent({
name: 'DescriptionsItem',
[DESCRIPTION_ITEM_FLAG]: true,
props: descriptionsItemProps,
slots: Object as SlotsType<DescriptionItemSlots>,
render() {
return null
}
Expand Down

0 comments on commit 0139b74

Please sign in to comment.