MCPcopy Create free account
hub / github.com/adobe/react-spectrum / CalendarCell

Function CalendarCell

starters/hooks/src/RangeCalendar.tsx:87–135  ·  view source on GitHub ↗
({state, date}: {state: RangeCalendarState; date: CalendarDate})

Source from the content-addressed store, hash-verified

85}
86
87function CalendarCell({state, date}: {state: RangeCalendarState; date: CalendarDate}) {
88 let ref = useRef<HTMLDivElement>(null);
89 let {
90 cellProps,
91 buttonProps,
92 isSelected,
93 isOutsideVisibleRange,
94 isDisabled,
95 isUnavailable,
96 isPressed,
97 formattedDate
98 } = useCalendarCell({date}, state, ref);
99 let {hoverProps, isHovered} = useHover({});
100 let {focusProps, isFocusVisible} = useFocusRing();
101
102 // Compute the range endpoints from the highlighted range.
103 let isSelectionStart = state.highlightedRange
104 ? isSameDay(date, state.highlightedRange.start)
105 : false;
106 let isSelectionEnd = state.highlightedRange ? isSameDay(date, state.highlightedRange.end) : false;
107
108 return (
109 <td {...cellProps}>
110 <div
111 {...mergeProps(buttonProps, focusProps)}
112 ref={ref}
113 hidden={isOutsideVisibleRange}
114 className="react-aria-CalendarCell"
115 data-selected={isSelected || undefined}
116 data-selection-start={isSelectionStart || undefined}
117 data-selection-end={isSelectionEnd || undefined}
118 data-disabled={isDisabled || undefined}
119 data-unavailable={isUnavailable || undefined}
120 data-pressed={isPressed || undefined}
121 data-focus-visible={isFocusVisible || undefined}>
122 <span
123 {...hoverProps}
124 className="button-base"
125 data-variant="quiet"
126 data-selected={isSelectionStart || isSelectionEnd || undefined}
127 data-hovered={isHovered || undefined}
128 data-pressed={isPressed || undefined}
129 data-disabled={isDisabled || undefined}>
130 {formattedDate}
131 </span>
132 </div>
133 </td>
134 );
135}

Callers

nothing calls this directly

Calls 5

useHoverFunction · 0.90
useFocusRingFunction · 0.90
isSameDayFunction · 0.90
mergePropsFunction · 0.90
useCalendarCellFunction · 0.85

Tested by

no test coverage detected