Skip to content

chore: s2 date followup #8537

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

Merged
merged 11 commits into from
Jul 16, 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
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/ar-AE.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "المزيد من العناصر"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/bg-BG.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "Още елементи"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/cs-CZ.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "Další položky"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/da-DK.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "Flere elementer"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/de-DE.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "Weitere Elemente"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/el-GR.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "Περισσότερα στοιχεία"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/es-ES.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "Más elementos"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/et-EE.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "Veel üksusi"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/fi-FI.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "Lisää kohteita"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/fr-FR.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "Plus d’éléments"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/he-IL.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "פריטים נוספים"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/hr-HR.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "Više stavki"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/hu-HU.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "További elemek"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/it-IT.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "Altri elementi"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/ja-JP.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "その他の項目"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/ko-KR.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "기타 항목"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/lt-LT.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "Daugiau elementų"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/lv-LV.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "Vairāk vienumu"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/nb-NO.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "Flere elementer"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/nl-NL.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "Meer items"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/pl-PL.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "Więcej elementów"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/pt-BR.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "Mais itens"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/pt-PT.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "Mais artigos"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/ro-RO.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "Mai multe articole"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/ru-RU.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "Дополнительные элементы"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/sk-SK.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "Ďalšie položky"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/sl-SI.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "Več elementov"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/sr-SP.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "Više stavki"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/sv-SE.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "Fler artiklar"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/tr-TR.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "Daha fazla öğe"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/uk-UA.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "Більше елементів"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/zh-CN.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "更多项目"
}
2 changes: 1 addition & 1 deletion packages/@react-spectrum/actiongroup/intl/zh-TW.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"more": "More items"
"more": "更多項目"
}
19 changes: 10 additions & 9 deletions packages/@react-spectrum/s2/src/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ export const Calendar = /*#__PURE__*/ (forwardRef as forwardRefType)(function Ca
display: 'flex',
flexDirection: 'row',
gap: 24,
width: 'full'
width: 'full',
alignItems: 'start'
})}>
{Array.from({length: visibleMonths}).map((_, i) => (
<CalendarGrid months={i} key={i} />
Expand Down Expand Up @@ -454,18 +455,17 @@ const CalendarCell = (props: Omit<CalendarCellProps, 'children'> & {firstDayOfWe
let isFirstWeek = weekIndex === 0;
let isFirstChild = dayIndex === 0;
let isLastChild = dayIndex === 6;
let isNextDaySelected = state.isSelected(props.date.add({days: 1}));
return (
<AriaCalendarCell
date={props.date}
className={(renderProps) => cellStyles({...renderProps, isFirstChild, isLastChild, isFirstWeek})}>
{(renderProps) => <CalendarCellInner {...props} weekIndex={weekIndex} dayIndex={dayIndex} state={state} isRangeSelection={!!rangeCalendarStateContext} isNextDaySelected={isNextDaySelected} isLastChild={isLastChild} renderProps={renderProps} />}
{(renderProps) => <CalendarCellInner {...props} weekIndex={weekIndex} dayIndex={dayIndex} state={state} isRangeSelection={!!rangeCalendarStateContext} renderProps={renderProps} />}
</AriaCalendarCell>
);
};

const CalendarCellInner = (props: Omit<CalendarCellProps, 'children'> & {isNextDaySelected: boolean, isLastChild: boolean, isRangeSelection: boolean, state: CalendarState | RangeCalendarState, weekIndex: number, dayIndex: number, renderProps?: CalendarCellRenderProps, date: DateValue}): ReactElement => {
let {weekIndex, dayIndex, date, renderProps, state, isRangeSelection, isNextDaySelected, isLastChild} = props;
const CalendarCellInner = (props: Omit<CalendarCellProps, 'children'> & {isRangeSelection: boolean, state: CalendarState | RangeCalendarState, weekIndex: number, dayIndex: number, renderProps?: CalendarCellRenderProps, date: DateValue}): ReactElement => {
let {weekIndex, dayIndex, date, renderProps, state, isRangeSelection} = props;
let {getDatesInWeek} = state;
let ref = useRef<HTMLDivElement>(null);
let {isUnavailable, formattedDate, isSelected} = renderProps!;
Expand All @@ -484,13 +484,14 @@ const CalendarCellInner = (props: Omit<CalendarCellProps, 'children'> & {isNextD
selectionSpan = dayIndex;
}

let prevDay = date.subtract({days: 1});
let nextDay = date.add({days: 1});
let isBackgroundStyleApplied = (
isSelected
&& (isLastChild || !isNextDaySelected)
&& isRangeSelection
&& (state.isSelected(date.subtract({days: 1}))
|| state.isSelected(date.add({days: 1}))
));
&& (state.isSelected(prevDay)
|| (nextDay.month === date.month && state.isSelected(nextDay)))
);

return (
<div
Expand Down
28 changes: 23 additions & 5 deletions packages/@react-spectrum/s2/src/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
DateValue,
Dialog,
FormContext,
OverlayTriggerStateContext,
Provider,
TimeValue
} from 'react-aria-components';
Expand All @@ -40,7 +41,7 @@ import {useSpectrumContextProps} from './useSpectrumContextProps';

export interface DatePickerProps<T extends DateValue> extends
Omit<AriaDatePickerProps<T>, 'children' | 'className' | 'style' | keyof GlobalDOMAttributes>,
Pick<CalendarProps<T>, 'visibleMonths' | 'createCalendar'>,
Pick<CalendarProps<T>, 'createCalendar' | 'pageBehavior' | 'isDateUnavailable'>,
StyleProps,
SpectrumLabelableProps,
HelpTextProps {
Expand All @@ -49,7 +50,12 @@ export interface DatePickerProps<T extends DateValue> extends
*
* @default 'M'
*/
size?: 'S' | 'M' | 'L' | 'XL'
size?: 'S' | 'M' | 'L' | 'XL',
/**
* The maximum number of months to display at once in the calendar popover, if screen space permits.
* @default 1
*/
maxVisibleMonths?: number
}

export const DatePickerContext = createContext<ContextValue<Partial<DatePickerProps<any>>, HTMLDivElement>>(null);
Expand Down Expand Up @@ -132,9 +138,11 @@ export const DatePicker = /*#__PURE__*/ (forwardRef as forwardRefType)(function
UNSAFE_className,
styles,
placeholderValue,
visibleMonths,
maxVisibleMonths = 1,
firstDayOfWeek,
createCalendar,
pageBehavior,
isDateUnavailable,
...dateFieldProps
} = props;
let formContext = useContext(FormContext);
Expand Down Expand Up @@ -196,7 +204,12 @@ export const DatePicker = /*#__PURE__*/ (forwardRef as forwardRefType)(function
<CalendarButton isOpen={isOpen} size={size} setButtonHasFocus={setButtonHasFocus} />
</FieldGroup>
<CalendarPopover>
<Calendar visibleMonths={visibleMonths} createCalendar={createCalendar} firstDayOfWeek={firstDayOfWeek} />
<Calendar
visibleMonths={maxVisibleMonths}
createCalendar={createCalendar}
firstDayOfWeek={firstDayOfWeek}
isDateUnavailable={isDateUnavailable}
pageBehavior={pageBehavior} />
{showTimeField && (
<div className={style({display: 'flex', gap: 16, contain: 'inline-size'})}>
<TimeField
Expand Down Expand Up @@ -241,7 +254,12 @@ export function CalendarPopover(props: PropsWithChildren): ReactElement {
gap: 16
})}>
<Dialog>
{props.children}
<Provider
values={[
[OverlayTriggerStateContext, null]
]}>
{props.children}
</Provider>
</Dialog>
</PopoverBase>
);
Expand Down
20 changes: 16 additions & 4 deletions packages/@react-spectrum/s2/src/DateRangePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {useSpectrumContextProps} from './useSpectrumContextProps';

export interface DateRangePickerProps<T extends DateValue> extends
Omit<AriaDateRangePickerProps<T>, 'children' | 'className' | 'style' | keyof GlobalDOMAttributes>,
Pick<RangeCalendarProps<T>, 'visibleMonths' | 'createCalendar'>,
Pick<RangeCalendarProps<T>, 'createCalendar' | 'pageBehavior' | 'isDateUnavailable'>,
StyleProps,
SpectrumLabelableProps,
HelpTextProps {
Expand All @@ -42,7 +42,12 @@ export interface DateRangePickerProps<T extends DateValue> extends
*
* @default 'M'
*/
size?: 'S' | 'M' | 'L' | 'XL'
size?: 'S' | 'M' | 'L' | 'XL',
/**
* The maximum number of months to display at once in the calendar popover, if screen space permits.
* @default 1
*/
maxVisibleMonths?: number
}

export const DateRangePickerContext = createContext<ContextValue<Partial<DateRangePickerProps<any>>, HTMLDivElement>>(null);
Expand All @@ -66,9 +71,11 @@ export const DateRangePicker = /*#__PURE__*/ (forwardRef as forwardRefType)(func
UNSAFE_className,
styles,
placeholderValue,
visibleMonths = 1,
maxVisibleMonths = 1,
firstDayOfWeek,
createCalendar,
pageBehavior,
isDateUnavailable,
...dateFieldProps
} = props;
let formContext = useContext(FormContext);
Expand Down Expand Up @@ -136,7 +143,12 @@ export const DateRangePicker = /*#__PURE__*/ (forwardRef as forwardRefType)(func
</div>
</FieldGroup>
<CalendarPopover>
<RangeCalendar visibleMonths={visibleMonths} createCalendar={createCalendar} firstDayOfWeek={firstDayOfWeek} />
<RangeCalendar
visibleMonths={maxVisibleMonths}
createCalendar={createCalendar}
firstDayOfWeek={firstDayOfWeek}
isDateUnavailable={isDateUnavailable}
pageBehavior={pageBehavior} />
{showTimeField && (
<div className={style({display: 'flex', gap: 16, contain: 'inline-size'})}>
<TimeField
Expand Down
5 changes: 3 additions & 2 deletions packages/@react-spectrum/s2/src/RangeCalendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,16 @@ export const RangeCalendar = /*#__PURE__*/ (forwardRef as forwardRefType)(functi
display: 'flex',
flexDirection: 'row',
gap: 24,
width: 'full'
width: 'full',
alignItems: 'start'
})}>
{Array.from({length: visibleMonths}).map((_, i) => (
<CalendarGrid months={i} key={i} />
))}
</div>
{isInvalid && (
<Text slot="errorMessage" className={helpTextStyles({isInvalid, isDisabled, size: 'M'})}>
{errorMessage || stringFormatter.format('invalidSelection', {selectedCount: 2})}
{errorMessage || stringFormatter.format('calendar.invalidSelection', {selectedCount: 2})}
</Text>
)}
</>
Expand Down
Loading