Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(VStepperVertical): correct slots types #20537

Merged
merged 3 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions packages/vuetify/src/components/VStepper/VStepperItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ import type { RippleDirectiveBinding } from '@/directives/ripple'

export type StepperItem = string | Record<string, any>

export type StepperItemSlot = {
export type StepperItemSlot<T = any> = {
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<T = any> = {
default: StepperItemSlot<T>
icon: StepperItemSlot<T>
title: StepperItemSlot<T>
subtitle: StepperItemSlot<T>
}

export type ValidationRule = () => string | boolean
Expand Down
40 changes: 22 additions & 18 deletions packages/vuetify/src/labs/VStepperVertical/VStepperVertical.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> = {
actions: StepperVerticalItemActionSlot<T>
default: VStepperSlot & { step: T }
icon: StepperItemSlot<T>
title: StepperItemSlot<T>
subtitle: StepperItemSlot<T>
prev: StepperVerticalItemActionSlot<T>
next: StepperVerticalItemActionSlot<T>
} & {
[key: `header-item.${string}`]: StepperItemSlot
[key: `item.${string}`]: StepperItem
[key: `header-item.${string}`]: StepperItemSlot<T>
[key: `item.${string}`]: StepperItemSlot<T>
}

export const makeVStepperVerticalProps = propsFactory({
Expand All @@ -46,7 +47,13 @@ export const makeVStepperVerticalProps = propsFactory({
}), ['static']),
}, 'VStepperVertical')

export const VStepperVertical = genericComponent<VStepperVerticalSlots>()({
export const VStepperVertical = genericComponent<new <T = number>(
props: {
modelValue?: T
'onUpdate:modelValue'?: (value: T) => void
},
slots: VStepperVerticalSlots<T>,
) => GenericProps<typeof props, typeof slots>>()({
name: 'VStepperVertical',

props: makeVStepperVerticalProps(),
Expand Down Expand Up @@ -108,10 +115,7 @@ export const VStepperVertical = genericComponent<VStepperVerticalSlots>()({
>
{{
...slots,
default: ({
prev,
next,
}) => {
default: ({ prev, next }) => {
return (
<>
{ items.value.map(({ raw, ...item }) => (
Expand Down
31 changes: 16 additions & 15 deletions packages/vuetify/src/labs/VStepperVertical/VStepperVerticalItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<T = any> = StepperItemSlot<T> & {
next: () => void
prev: () => void
}

export type VStepperVerticalItemSlots<T = any> = {
default: StepperItemSlot<T>
icon: StepperItemSlot<T>
subtitle: StepperItemSlot<T>
title: StepperItemSlot<T>
text: StepperItemSlot<T>
prev: StepperVerticalItemActionSlot<T>
next: StepperVerticalItemActionSlot<T>
actions: StepperVerticalItemActionSlot<T>
}

export const makeVStepperVerticalItemProps = propsFactory({
Expand Down Expand Up @@ -82,14 +84,13 @@ export const VStepperVerticalItem = genericComponent<VStepperVerticalItemSlots>(
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')
Expand Down