From 02302590c8ec4feb4ae14ac36e8c756fac879f2b Mon Sep 17 00:00:00 2001 From: SonTT19 <49301480+SonTT19@users.noreply.github.com> Date: Fri, 24 Jan 2025 13:11:18 +0700 Subject: [PATCH] fix(VStepperVertical): correct slots types (#20537) fixes #20213 fixes #20803 Co-authored-by: Kael --- .../src/components/VStepper/VStepperItem.tsx | 14 +++---- .../VStepperVertical/VStepperVertical.tsx | 40 ++++++++++--------- .../VStepperVertical/VStepperVerticalItem.tsx | 31 +++++++------- 3 files changed, 45 insertions(+), 40 deletions(-) diff --git a/packages/vuetify/src/components/VStepper/VStepperItem.tsx b/packages/vuetify/src/components/VStepper/VStepperItem.tsx index 686993a1885..8f9e8bd1d75 100644 --- a/packages/vuetify/src/components/VStepper/VStepperItem.tsx +++ b/packages/vuetify/src/components/VStepper/VStepperItem.tsx @@ -24,20 +24,20 @@ import type { RippleDirectiveBinding } from '@/directives/ripple' export type StepperItem = string | Record -export type StepperItemSlot = { +export type StepperItemSlot = { canEdit: boolean hasError: boolean hasCompleted: boolean title?: string | number subtitle?: string | number - step: any + step: T } -export type VStepperItemSlots = { - default: StepperItemSlot - icon: StepperItemSlot - title: StepperItemSlot - subtitle: StepperItemSlot +export type VStepperItemSlots = { + default: StepperItemSlot + icon: StepperItemSlot + title: StepperItemSlot + subtitle: StepperItemSlot } export type ValidationRule = () => string | boolean diff --git a/packages/vuetify/src/labs/VStepperVertical/VStepperVertical.tsx b/packages/vuetify/src/labs/VStepperVertical/VStepperVertical.tsx index ba3ee62ef8a..87199cdca4a 100644 --- a/packages/vuetify/src/labs/VStepperVertical/VStepperVertical.tsx +++ b/packages/vuetify/src/labs/VStepperVertical/VStepperVertical.tsx @@ -12,21 +12,22 @@ import { computed, ref, toRefs } from 'vue' import { genericComponent, getPropertyFromItem, omit, propsFactory, useRender } from '@/util' // Types +import type { StepperVerticalItemActionSlot } from './VStepperVerticalItem' import type { VStepperSlot } from '@/components/VStepper/VStepper' -import type { StepperItem, StepperItemSlot } from '@/components/VStepper/VStepperItem' - -export type VStepperVerticalSlots = { - actions: StepperItemSlot - default: VStepperSlot & { step: unknown } - icon: StepperItemSlot - title: StepperItemSlot - subtitle: StepperItemSlot - item: StepperItem - prev: StepperItemSlot - next: StepperItemSlot +import type { StepperItemSlot } from '@/components/VStepper/VStepperItem' +import type { GenericProps } from '@/util' + +export type VStepperVerticalSlots = { + actions: StepperVerticalItemActionSlot + default: VStepperSlot & { step: T } + icon: StepperItemSlot + title: StepperItemSlot + subtitle: StepperItemSlot + prev: StepperVerticalItemActionSlot + next: StepperVerticalItemActionSlot } & { - [key: `header-item.${string}`]: StepperItemSlot - [key: `item.${string}`]: StepperItem + [key: `header-item.${string}`]: StepperItemSlot + [key: `item.${string}`]: StepperItemSlot } export const makeVStepperVerticalProps = propsFactory({ @@ -46,7 +47,13 @@ export const makeVStepperVerticalProps = propsFactory({ }), ['static']), }, 'VStepperVertical') -export const VStepperVertical = genericComponent()({ +export const VStepperVertical = genericComponent( + props: { + modelValue?: T + 'onUpdate:modelValue'?: (value: T) => void + }, + slots: VStepperVerticalSlots, +) => GenericProps>()({ name: 'VStepperVertical', props: makeVStepperVerticalProps(), @@ -108,10 +115,7 @@ export const VStepperVertical = genericComponent()({ > {{ ...slots, - default: ({ - prev, - next, - }) => { + default: ({ prev, next }) => { return ( <> { items.value.map(({ raw, ...item }) => ( diff --git a/packages/vuetify/src/labs/VStepperVertical/VStepperVerticalItem.tsx b/packages/vuetify/src/labs/VStepperVertical/VStepperVerticalItem.tsx index e2d719e06da..3499cc07372 100644 --- a/packages/vuetify/src/labs/VStepperVertical/VStepperVerticalItem.tsx +++ b/packages/vuetify/src/labs/VStepperVertical/VStepperVerticalItem.tsx @@ -16,18 +16,20 @@ import { genericComponent, omit, propsFactory, useRender } from '@/util' // Types import type { StepperItemSlot } from '@/components/VStepper/VStepperItem' -export type VStepperVerticalItemSlots = { - default: StepperItemSlot - icon: StepperItemSlot - subtitle: StepperItemSlot - title: StepperItemSlot - text: StepperItemSlot - prev: StepperItemSlot - next: StepperItemSlot - actions: StepperItemSlot & { - next: () => void - prev: () => void - } +export type StepperVerticalItemActionSlot = StepperItemSlot & { + next: () => void + prev: () => void +} + +export type VStepperVerticalItemSlots = { + default: StepperItemSlot + icon: StepperItemSlot + subtitle: StepperItemSlot + title: StepperItemSlot + text: StepperItemSlot + prev: StepperVerticalItemActionSlot + next: StepperVerticalItemActionSlot + actions: StepperVerticalItemActionSlot } export const makeVStepperVerticalItemProps = propsFactory({ @@ -82,14 +84,13 @@ export const VStepperVerticalItem = genericComponent( title: props.title, subtitle: props.subtitle, step: step.value, - value: props.value, - })) + } satisfies StepperItemSlot)) const actionProps = computed(() => ({ ...slotProps.value, prev: onClickPrev, next: onClickNext, - })) + } satisfies StepperVerticalItemActionSlot)) function onClickNext () { emit('click:next')