Skip to content

Commit 25b432c

Browse files
committed
feat(DateInput, TimeInput, DateTimeInput): the sheets' wheels draw as one picker
The month and year wheels of the DateInput sheet and the time wheels of the TimeInput and DateTimeInput sheets sit in a WheelGroup: one selection band spans every column, and each column's dimmed rows lean toward the picker's centre, as UIPickerView draws them. The pointer drag hook the native wheels used goes with them.
1 parent ece20fb commit 25b432c

9 files changed

Lines changed: 154 additions & 321 deletions

File tree

‎.changeset/wheel-group-inputs.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@astryxdesign/core': patch
3+
---
4+
5+
[fix] The wheels in the TimeInput, DateTimeInput and DateInput bottom sheets now draw as one picker, as on iOS. One selection band spans every column, and each column's dimmed rows lean toward the picker's centre instead of their own.
6+
7+
@vjeux

‎packages/core/src/DateInput/DateInputTouch.test.tsx‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,14 @@ describe('DateInput — month/year wheels', () => {
14421442
expect(screen.getByRole('listbox', {name: 'Year'})).toBeInTheDocument();
14431443
});
14441444

1445+
it('draws the month and year wheels as one picker, with one band', () => {
1446+
renderAndOpen();
1447+
openWheels();
1448+
expect(panel('wheels').querySelectorAll('[data-wheel-band]')).toHaveLength(
1449+
1,
1450+
);
1451+
});
1452+
14451453
/**
14461454
* The arrows step the calendar, and the calendar is not on screen. They
14471455
* keep their layout box rather than unmounting: they are the tallest thing

‎packages/core/src/DateInput/MonthYearWheels.tsx‎

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,17 @@ import {useMemo} from 'react';
2626
import * as stylex from '@stylexjs/stylex';
2727
import {useLocale} from '../i18n';
2828
import {DATE_FORMAT_MONTH_ONLY, plainDateFormat} from '../utils';
29-
import {spacingVars} from '../theme/tokens.stylex';
3029
import {dateInputTouchGeometry} from './tokens.stylex';
3130
import {Wheel, type WheelOption} from './Wheel';
31+
import {WheelGroup} from './WheelGroup';
3232
import {fromMonthIndex, toMonthIndex} from './monthGeometry';
3333

3434
const styles = stylex.create({
35-
// The picker (UIPickerView's 216 px) centred in the pane.
35+
// The picker (UIPickerView's 216 px) centred in the month pane.
3636
wheels: {
3737
display: 'flex',
3838
alignItems: 'center',
3939
blockSize: dateInputTouchGeometry.paneBlockSize,
40-
gap: spacingVars['--spacing-2'],
4140
},
4241
});
4342

@@ -126,25 +125,29 @@ export function MonthYearWheels({
126125

127126
return (
128127
<div {...stylex.props(styles.wheels)}>
129-
<Wheel
130-
label={monthLabel}
131-
options={monthOptions}
132-
value={month}
133-
isActive={isActive}
134-
onChange={nextMonth => onChange(toMonthIndex(year, nextMonth))}
135-
/>
136-
<Wheel
137-
label={yearLabel}
138-
options={yearOptions}
139-
value={year}
140-
isActive={isActive}
141-
onChange={nextYear => {
142-
// Jan 31 -> Feb has no equivalent here (months carry no day), but a
143-
// year change can still land outside the range; clamp to it.
144-
const candidate = toMonthIndex(nextYear, month);
145-
onChange(Math.min(Math.max(candidate, minMonthIndex), maxMonthIndex));
146-
}}
147-
/>
128+
<WheelGroup>
129+
<Wheel
130+
label={monthLabel}
131+
options={monthOptions}
132+
value={month}
133+
isActive={isActive}
134+
onChange={nextMonth => onChange(toMonthIndex(year, nextMonth))}
135+
/>
136+
<Wheel
137+
label={yearLabel}
138+
options={yearOptions}
139+
value={year}
140+
isActive={isActive}
141+
onChange={nextYear => {
142+
// Jan 31 -> Feb has no equivalent here (months carry no day), but a
143+
// year change can still land outside the range; clamp to it.
144+
const candidate = toMonthIndex(nextYear, month);
145+
onChange(
146+
Math.min(Math.max(candidate, minMonthIndex), maxMonthIndex),
147+
);
148+
}}
149+
/>
150+
</WheelGroup>
148151
</div>
149152
);
150153
}

‎packages/core/src/DateInput/WheelGroup.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
* @output Exports WheelGroup — UIPickerView's frame around picker columns: one
99
* selection band across every column, the picker's height, and the one
1010
* vanishing point all columns are drawn towards
11-
* @position Internal component; the frame of picker Wheels drawn side by side
11+
* @position Internal component; wraps the Wheels in MonthYearWheels.tsx,
12+
* TouchTimeField.tsx and TouchDateTimeField.tsx
1213
*
1314
* UIPickerView draws one band under all its columns (inset from the picker's
1415
* sides) and centres every column's table on the picker, so the dimmed rows

‎packages/core/src/DateInput/usePointerDragScroll.ts‎

Lines changed: 0 additions & 220 deletions
This file was deleted.

‎packages/core/src/DateTimeInput/DateTimeInputTouch.test.tsx‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,18 @@ describe('DateTimeInput touch surface', () => {
367367
);
368368
});
369369

370+
it('draws the time wheels as one picker, with one band across them', () => {
371+
withMonthLayout(() => {
372+
const {container} = render(
373+
<DateTimeInput label="Meeting" onChange={() => {}} />,
374+
);
375+
openDateSheet();
376+
switchToTimePanel();
377+
const timePanel = container.querySelector('[data-panel="time"]')!;
378+
expect(timePanel.querySelectorAll('[data-wheel-band]')).toHaveLength(1);
379+
});
380+
});
381+
370382
it('switches between inert date and time panels with the pill control', () => {
371383
withMonthLayout(() => {
372384
const {container} = render(

0 commit comments

Comments
 (0)