Skip to content

Commit

Permalink
feat(step): 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 f4220cf commit be2d9d5
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/steps/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { default as NStep, stepProps } from './src/Step'
export type { StepProps } from './src/Step'
export type { StepProps, StepSlots } from './src/Step'
export { default as NSteps, stepsProps } from './src/Steps'
export type { StepsProps } from './src/Steps'
export type { StepsProps, StepsSlots } from './src/Steps'
10 changes: 9 additions & 1 deletion src/steps/src/Step.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
defineComponent,
h,
inject,
type PropType
type PropType,
type SlotsType
} from 'vue'
import { NBaseIcon, NIconSwitchTransition } from '../../_internal'
import {
Expand Down Expand Up @@ -36,9 +37,16 @@ export const stepProps = {

export type StepProps = ExtractPublicPropTypes<typeof stepProps>

export interface StepSlots {
default?: any
icon?: any
title?: any
}

export default defineComponent({
name: 'Step',
props: stepProps,
slots: Object as SlotsType<StepSlots>,
setup(props) {
const NSteps = inject(stepsInjectionKey, null)

Expand Down
8 changes: 8 additions & 0 deletions src/steps/src/Steps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
provide,
type Ref,
type Slots,
type SlotsType,
type VNode,
type VNodeChild
} from 'vue'
Expand Down Expand Up @@ -60,11 +61,18 @@ export interface StepsInjection {

export type StepsProps = ExtractPublicPropTypes<typeof stepsProps>

export interface StepsSlots {
default?: any
'finish-icon'?: any
'error-icon'?: any
}

export const stepsInjectionKey = createInjectionKey<StepsInjection>('n-steps')

export default defineComponent({
name: 'Steps',
props: stepsProps,
slots: Object as SlotsType<StepsSlots>,
setup(props, { slots }) {
const { mergedClsPrefixRef, mergedRtlRef } = useConfig(props)
const rtlEnabledRef = useRtl('Steps', mergedRtlRef, mergedClsPrefixRef)
Expand Down

0 comments on commit be2d9d5

Please sign in to comment.