···1616export const LabelText = TextField.LabelText
17171818/**
1919- * Date-only input. Accepts a date in the format YYYY-MM-DD, and reports date
2020- * changes in the same format.
1919+ * Date-only input. Accepts a string in the format YYYY-MM-DD, or a Date object.
2020+ * Date objects are converted to strings in the format YYYY-MM-DD.
2121+ * Returns a string in the format YYYY-MM-DD.
2122 *
2222- * For dates of unknown format, convert with the
2323+ * To generate a string in the format YYYY-MM-DD from a Date object, use the
2324 * `utils.toSimpleDateString(Date)` export of this file.
2425 */
2526export function DateField({
···2930 label,
3031 isInvalid,
3132 accessibilityHint,
3333+ maximumDate,
3234}: DateFieldProps) {
3335 const {_} = useLingui()
3436 const t = useTheme()
···5658 isInvalid={isInvalid}
5759 accessibilityHint={accessibilityHint}
5860 />
5959- <Dialog.Outer control={control} testID={testID}>
6161+ <Dialog.Outer
6262+ control={control}
6363+ testID={testID}
6464+ nativeOptions={{preventExpansion: true}}>
6065 <Dialog.Handle />
6161- <Dialog.Inner label={label}>
6666+ <Dialog.ScrollableInner label={label}>
6267 <View style={a.gap_lg}>
6368 <View style={[a.relative, a.w_full, a.align_center]}>
6469 <DatePicker
6570 timeZoneOffsetInMinutes={0}
6671 theme={t.name === 'light' ? 'light' : 'dark'}
6767- date={new Date(value)}
7272+ date={new Date(toSimpleDateString(value))}
6873 onDateChange={onChangeInternal}
6974 mode="date"
7075 testID={`${testID}-datepicker`}
7176 aria-label={label}
7277 accessibilityLabel={label}
7378 accessibilityHint={accessibilityHint}
7979+ maximumDate={
8080+ maximumDate
8181+ ? new Date(toSimpleDateString(maximumDate))
8282+ : undefined
8383+ }
7484 />
7585 </View>
7686 <Button
···8494 </ButtonText>
8595 </Button>
8696 </View>
8787- </Dialog.Inner>
9797+ </Dialog.ScrollableInner>
8898 </Dialog.Outer>
8999 </>
90100 )
+5-2
src/components/forms/DateField/index.web.tsx
···11import React from 'react'
22import {StyleSheet, TextInput, TextInputProps} from 'react-native'
33-// @ts-ignore
33+// @ts-expect-error untyped
44import {unstable_createElement} from 'react-native-web'
5566import {DateFieldProps} from '#/components/forms/DateField/types'
···3939 isInvalid,
4040 testID,
4141 accessibilityHint,
4242+ maximumDate,
4243}: DateFieldProps) {
4344 const handleOnChange = React.useCallback(
4445 (e: any) => {
···5657 <TextField.Root isInvalid={isInvalid}>
5758 <TextField.Icon icon={CalendarDays} />
5859 <Input
5959- value={value}
6060+ value={toSimpleDateString(value)}
6061 label={label}
6162 onChange={handleOnChange}
6263 onChangeText={() => {}}
6364 testID={testID}
6465 accessibilityHint={accessibilityHint}
6666+ // @ts-expect-error not typed as <input type="date"> even though it is one
6767+ max={maximumDate ? toSimpleDateString(maximumDate) : undefined}
6568 />
6669 </TextField.Root>
6770 )