Skip to content

Commit

Permalink
feat(VDateInput): actions slot (#20858)
Browse files Browse the repository at this point in the history
resolves #20690
closes #20857
  • Loading branch information
J-Sek authored Jan 16, 2025
1 parent 0f833be commit 70deee7
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions packages/vuetify/src/labs/VDateInput/VDateInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ import { computed, shallowRef } from 'vue'
import { genericComponent, omit, propsFactory, useRender, wrapInArray } from '@/util'

// Types
export interface VDateInputSlots {
export type VDateInputActionsSlot = {
save: () => void
cancel: () => void
isPristine: boolean
}

export type VDateInputSlots = {
actions: VDateInputActionsSlot
default: never
}

Expand All @@ -34,7 +41,7 @@ export const makeVDateInputProps = propsFactory({
}), ['active']),
}, 'VDateInput')

export const VDateInput = genericComponent()({
export const VDateInput = genericComponent<VDateInputSlots>()({
name: 'VDateInput',

props: makeVDateInputProps(),
Expand Down Expand Up @@ -127,9 +134,10 @@ export const VDateInput = genericComponent()({
{ ...confirmEditProps }
v-model={ model.value }
onSave={ onSave }
onCancel={ () => menu.value = false }
>
{{
default: ({ actions, model: proxyModel }) => {
default: ({ actions, model: proxyModel, save, cancel, isPristine }) => {
return (
<VDatePicker
{ ...datePickerProps }
Expand All @@ -146,7 +154,7 @@ export const VDateInput = genericComponent()({
onMousedown={ (e: MouseEvent) => e.preventDefault() }
>
{{
actions: !props.hideActions ? actions : undefined,
actions: !props.hideActions ? () => slots.actions?.({ save, cancel, isPristine }) ?? actions() : undefined,
}}
</VDatePicker>
)
Expand Down

0 comments on commit 70deee7

Please sign in to comment.