Skip to content

Commit

Permalink
chore: merge branch 'main' into 1127-bugfix-datefield
Browse files Browse the repository at this point in the history
  • Loading branch information
epr3 committed Jul 18, 2024
2 parents 8205f6d + c157cb8 commit 539e024
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 3 deletions.
8 changes: 8 additions & 0 deletions docs/content/components/date-range-picker.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,14 @@ Interactable container for displaying the cell dates. Clicking it selects the da
attribute: '[data-highlighted]',
values: 'Present when the date is highlighted by the user as they select a range.',
},
{
attribute: '[data-highlighted-start]',
values: 'Present when the date is the start of the range that is highlighted by the user.',
},
{
attribute: '[data-highlighted-end]',
values: 'Present when the date is the end of the range that is highlighted by the user.',
},
{
attribute: '[data-focused]',
values: 'Present when focused',
Expand Down
2 changes: 1 addition & 1 deletion docs/content/components/dialog.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ If you want to hide the title, wrap it inside our Visually Hidden utility like t

An optional accessible description to be announced when the dialog is opened.

If you want to hide the description, wrap it inside our Visually Hidden utility like this `<VisuallyHidden asChild>`. If you want to remove the description entirely, remove this part and pass `aria-describedby="undefined}` to `DialogContent`.
If you want to hide the description, wrap it inside our Visually Hidden utility like this `<VisuallyHidden asChild>`. If you want to remove the description entirely, remove this part and pass `aria-describedby="undefined"` to `DialogContent`.

<!-- @include: @/meta/DialogDescription.md -->

Expand Down
8 changes: 8 additions & 0 deletions docs/content/components/range-calendar.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,14 @@ Interactable container for displaying the cell dates. Clicking it selects the da
attribute: '[data-highlighted]',
values: 'Present when the date is highlighted by the user as they select a range.',
},
{
attribute: '[data-highlighted-start]',
values: 'Present when the date is the start of the range that is highlighted by the user.',
},
{
attribute: '[data-highlighted-end]',
values: 'Present when the date is the end of the range that is highlighted by the user.',
},
{
attribute: '[data-focused]',
values: 'Present when focused',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ const isUnavailable = computed(() => rootContext.isDateUnavailable?.(props.day))
const isSelectedDate = computed(() => rootContext.isSelected(props.day))
const isSelectionStart = computed(() => rootContext.isSelectionStart(props.day))
const isSelectionEnd = computed(() => rootContext.isSelectionEnd(props.day))
const isHighlightStart = computed(() => rootContext.isHighlightedStart(props.day))
const isHighlightEnd = computed(() => rootContext.isHighlightedEnd(props.day))
const isHighlighted = computed(() => rootContext.highlightedRange.value
? isBetweenInclusive(props.day, rootContext.highlightedRange.value.start, rootContext.highlightedRange.value.end)
: false)
Expand Down Expand Up @@ -196,6 +198,8 @@ function handleArrowKey(e: KeyboardEvent) {
:data-highlighted="isHighlighted ? '' : undefined"
:data-selection-start="isSelectionStart ? true : undefined"
:data-selection-end="isSelectionEnd ? true : undefined"
:data-highlighted-start="isHighlightStart ? true : undefined"
:data-highlighted-end="isHighlightEnd ? true : undefined"
:data-selected="isSelectedDate ? true : undefined"
:data-outside-visible-view="isOutsideVisibleView ? '' : undefined"
:data-value="day.toString()"
Expand Down
7 changes: 6 additions & 1 deletion packages/radix-vue/src/RangeCalendar/RangeCalendarRoot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ type RangeCalendarRootContext = {
isSelected: (date: DateValue) => boolean
isSelectionEnd: (date: DateValue) => boolean
isSelectionStart: (date: DateValue) => boolean
isHighlightedStart: (date: DateValue) => boolean
isHighlightedEnd: (date: DateValue) => boolean
prevPage: (step?: CalendarIncrement, prevPageFunc?: (date: DateValue) => DateValue) => void
nextPage: (step?: CalendarIncrement, nextPageFunc?: (date: DateValue) => DateValue) => void
isNextButtonDisabled: (step?: CalendarIncrement, nextPageFunc?: (date: DateValue) => DateValue) => boolean
Expand Down Expand Up @@ -129,7 +131,6 @@ const props = withDefaults(defineProps<RangeCalendarRootProps>(), {
locale: 'en',
isDateDisabled: undefined,
isDateUnavailable: undefined,
initialView: 'month',
})
const emits = defineEmits<RangeCalendarRootEmits>()
Expand Down Expand Up @@ -237,6 +238,8 @@ const {
highlightedRange,
isSelectionStart,
isSelectionEnd,
isHighlightedStart,
isHighlightedEnd,
} = useRangeCalendarState({
start: startValue,
end: endValue,
Expand Down Expand Up @@ -327,6 +330,8 @@ provideRangeCalendarRootContext({
onPlaceholderChange,
locale,
dir,
isHighlightedStart,
isHighlightedEnd,
})
onMounted(() => {
Expand Down
14 changes: 14 additions & 0 deletions packages/radix-vue/src/RangeCalendar/useRangeCalendar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,25 @@ export function useRangeCalendarState(props: UseRangeCalendarProps) {
return null
})

const isHighlightedStart = (date: DateValue) => {
if (!highlightedRange.value || !highlightedRange.value.start)
return false
return isSameDay(highlightedRange.value.start, date)
}

const isHighlightedEnd = (date: DateValue) => {
if (!highlightedRange.value || !highlightedRange.value.end)
return false
return isSameDay(highlightedRange.value.end, date)
}

return {
isInvalid,
isSelected,
highlightedRange,
isSelectionStart,
isSelectionEnd,
isHighlightedStart,
isHighlightedEnd,
}
}
2 changes: 1 addition & 1 deletion packages/radix-vue/src/shared/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface SingleOrMultipleProps<ValidValue = string | string[], ExplicitType = S
/**
* Determines whether a "single" or "multiple" items can be pressed at a time.
*
* This prop will be ignored if any of `v-model` or `defaultValue` is an defined, as the type will be inferred from the value.
* This prop will be ignored if any of `v-model` or `defaultValue` is defined, as the type will be inferred from the value.
*/
type?: ValidValue extends string
? 'single'
Expand Down

0 comments on commit 539e024

Please sign in to comment.