Skip to content

Commit

Permalink
feat(Calendar/DatePicker): expose more attribute as slotProps
Browse files Browse the repository at this point in the history
  • Loading branch information
zernonia committed Feb 18, 2025
1 parent 9d9582b commit 357b6b8
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 2 deletions.
25 changes: 25 additions & 0 deletions docs/content/meta/CalendarCellTrigger.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,30 @@
'name': 'disabled',
'description': '<p>Current disable state</p>\n',
'type': 'boolean'
},
{
'name': 'selected',
'description': '<p>Current selected state</p>\n',
'type': 'boolean'
},
{
'name': 'today',
'description': '<p>Current today state</p>\n',
'type': 'boolean'
},
{
'name': 'outsideView',
'description': '<p>Current outside view state</p>\n',
'type': 'boolean'
},
{
'name': 'outsideVisibleView',
'description': '<p>Current outside visible view state</p>\n',
'type': 'boolean'
},
{
'name': 'unavailable',
'description': '<p>Current unavailable state</p>\n',
'type': 'boolean'
}
]" />
25 changes: 25 additions & 0 deletions docs/content/meta/DatePickerCellTrigger.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,30 @@
'name': 'disabled',
'description': '<p>Current disable state</p>\n',
'type': 'boolean'
},
{
'name': 'selected',
'description': '<p>Current selected state</p>\n',
'type': 'boolean'
},
{
'name': 'today',
'description': '<p>Current today state</p>\n',
'type': 'boolean'
},
{
'name': 'outsideView',
'description': '<p>Current outside view state</p>\n',
'type': 'boolean'
},
{
'name': 'outsideVisibleView',
'description': '<p>Current outside visible view state</p>\n',
'type': 'boolean'
},
{
'name': 'unavailable',
'description': '<p>Current unavailable state</p>\n',
'type': 'boolean'
}
]" />
50 changes: 50 additions & 0 deletions docs/content/meta/DateRangePickerCellTrigger.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,55 @@
'name': 'disabled',
'description': '<p>Current disable state</p>\n',
'type': 'boolean'
},
{
'name': 'selected',
'description': '<p>Current selected state</p>\n',
'type': 'boolean'
},
{
'name': 'today',
'description': '<p>Current today state</p>\n',
'type': 'boolean'
},
{
'name': 'outsideView',
'description': '<p>Current outside view state</p>\n',
'type': 'boolean'
},
{
'name': 'outsideVisibleView',
'description': '<p>Current outside visible view state</p>\n',
'type': 'boolean'
},
{
'name': 'unavailable',
'description': '<p>Current unavailable state</p>\n',
'type': 'boolean'
},
{
'name': 'highlighted',
'description': '<p>Current highlighted state</p>\n',
'type': 'boolean'
},
{
'name': 'highlightedStart',
'description': '<p>Current highlighted start state</p>\n',
'type': 'boolean'
},
{
'name': 'highlightedEnd',
'description': '<p>Current highlighted end state</p>\n',
'type': 'boolean'
},
{
'name': 'selectionStart',
'description': '<p>Current selection start state</p>\n',
'type': 'boolean'
},
{
'name': 'selectionEnd',
'description': '<p>Current selection end state</p>\n',
'type': 'boolean'
}
]" />
50 changes: 50 additions & 0 deletions docs/content/meta/RangeCalendarCellTrigger.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,55 @@
'name': 'disabled',
'description': '<p>Current disable state</p>\n',
'type': 'boolean'
},
{
'name': 'selected',
'description': '<p>Current selected state</p>\n',
'type': 'boolean'
},
{
'name': 'today',
'description': '<p>Current today state</p>\n',
'type': 'boolean'
},
{
'name': 'outsideView',
'description': '<p>Current outside view state</p>\n',
'type': 'boolean'
},
{
'name': 'outsideVisibleView',
'description': '<p>Current outside visible view state</p>\n',
'type': 'boolean'
},
{
'name': 'unavailable',
'description': '<p>Current unavailable state</p>\n',
'type': 'boolean'
},
{
'name': 'highlighted',
'description': '<p>Current highlighted state</p>\n',
'type': 'boolean'
},
{
'name': 'highlightedStart',
'description': '<p>Current highlighted start state</p>\n',
'type': 'boolean'
},
{
'name': 'highlightedEnd',
'description': '<p>Current highlighted end state</p>\n',
'type': 'boolean'
},
{
'name': 'selectionStart',
'description': '<p>Current selection start state</p>\n',
'type': 'boolean'
},
{
'name': 'selectionEnd',
'description': '<p>Current selection end state</p>\n',
'type': 'boolean'
}
]" />
17 changes: 16 additions & 1 deletion packages/core/src/Calendar/CalendarCellTrigger.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ export interface CalendarCellTriggerSlot {
dayValue: string
/** Current disable state */
disabled: boolean
/** Current selected state */
selected: boolean
/** Current today state */
today: boolean
/** Current outside view state */
outsideView: boolean
/** Current outside visible view state */
outsideVisibleView: boolean
/** Current unavailable state */
unavailable: boolean
}) => any
}
</script>
Expand Down Expand Up @@ -56,7 +66,7 @@ const labelText = computed(() => {
const isDisabled = computed(() => rootContext.isDateDisabled(props.day))
const isUnavailable = computed(() =>
rootContext.isDateUnavailable?.(props.day),
rootContext.isDateUnavailable?.(props.day) ?? false,
)
const isDateToday = computed(() => {
return isToday(props.day, getLocalTimeZone())
Expand Down Expand Up @@ -179,6 +189,11 @@ function handleArrowKey(e: KeyboardEvent) {
<slot
:day-value="dayValue"
:disabled="isDisabled"
:today="isDateToday"
:selected="isSelectedDate"
:outside-view="isOutsideView"
:outside-visible-view="isOutsideVisibleView"
:unavailable="isUnavailable"
>
{{ dayValue }}
</slot>
Expand Down
33 changes: 32 additions & 1 deletion packages/core/src/RangeCalendar/RangeCalendarCellTrigger.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,27 @@ export interface RangeCalendarCellTriggerSlot {
dayValue: string
/** Current disable state */
disabled: boolean
/** Current selected state */
selected: boolean
/** Current today state */
today: boolean
/** Current outside view state */
outsideView: boolean
/** Current outside visible view state */
outsideVisibleView: boolean
/** Current unavailable state */
unavailable: boolean
/** Current highlighted state */
highlighted: boolean
/** Current highlighted start state */
highlightedStart: boolean
/** Current highlighted end state */
highlightedEnd: boolean
/** Current selection start state */
selectionStart: boolean
/** Current selection end state */
selectionEnd: boolean
}) => any
}
</script>
Expand All @@ -47,7 +68,7 @@ const labelText = computed(() => rootContext.formatter.custom(toDate(props.day),
}))
const isDisabled = computed(() => rootContext.isDateDisabled(props.day))
const isUnavailable = computed(() => rootContext.isDateUnavailable?.(props.day))
const isUnavailable = computed(() => rootContext.isDateUnavailable?.(props.day) ?? false)
const isSelectedDate = computed(() => rootContext.isSelected(props.day))
const isSelectionStart = computed(() => rootContext.isSelectionStart(props.day))
const isSelectionEnd = computed(() => rootContext.isSelectionEnd(props.day))
Expand Down Expand Up @@ -223,6 +244,16 @@ function handleArrowKey(e: KeyboardEvent) {
<slot
:day-value="dayValue"
:disabled="isDisabled"
:today="isDateToday"
:selected="isSelectedDate"
:outside-view="isOutsideView"
:outside-visible-view="isOutsideVisibleView"
:unavailable="isUnavailable"
:highlighted="isHighlighted && !isUnavailable"
:highlighted-start="isHighlightStart"
:highlighted-end="isHighlightEnd"
:selection-start="isSelectionStart"
:selection-end="isSelectionEnd"
>
{{ dayValue }}
</slot>
Expand Down

0 comments on commit 357b6b8

Please sign in to comment.