-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add shouldForceLeadingZeros prop to DatePicker #4671
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
Conversation
Build successful! 🎉 |
## API Changes
unknown top level export { type: 'identifier', name: 'Column' } @react-aria/datepickerAriaDateFieldProps AriaDateFieldProps<T extends DateValue> {
granularity?: Granularity
hideTimeZone?: boolean = false
hourCycle?: number | number
isDateUnavailable?: (DateValue) => boolean
maxValue?: DateValue
minValue?: DateValue
placeholderValue?: DateValue
+ shouldForceLeadingZeros?: boolean
} AriaDatePickerProps AriaDatePickerProps<T extends DateValue> {
granularity?: Granularity
hideTimeZone?: boolean = false
hourCycle?: number | number
isDateUnavailable?: (DateValue) => boolean
maxValue?: DateValue
minValue?: DateValue
pageBehavior?: PageBehavior = visible
placeholderValue?: DateValue
+ shouldForceLeadingZeros?: boolean
} AriaDateRangePickerProps AriaDateRangePickerProps<T extends DateValue> {
allowsNonContiguousRanges?: boolean
granularity?: Granularity
hideTimeZone?: boolean = false
hourCycle?: number | number
isDateUnavailable?: (DateValue) => boolean
maxValue?: DateValue
minValue?: DateValue
pageBehavior?: PageBehavior = visible
placeholderValue?: DateValue
+ shouldForceLeadingZeros?: boolean
} AriaTimeFieldProps AriaTimeFieldProps<T extends TimeValue> {
granularity?: 'hour' | 'minute' | 'second' = 'minute'
hideTimeZone?: boolean
hourCycle?: number | number
maxValue?: TimeValue
minValue?: TimeValue
placeholderValue?: TimeValue
+ shouldForceLeadingZeros?: boolean
} @react-spectrum/datepickerDatePicker SpectrumDateFieldProps<T extends DateValue> {
granularity?: Granularity
hideTimeZone?: boolean = false
hourCycle?: number | number
isDateUnavailable?: (DateValue) => boolean
isQuiet?: boolean = false
maxValue?: DateValue
minValue?: DateValue
placeholderValue?: DateValue
+ shouldForceLeadingZeros?: boolean
showFormatHelpText?: boolean = false
} DateRangePicker SpectrumDatePickerProps<T extends DateValue> {
granularity?: Granularity
hideTimeZone?: boolean = false
hourCycle?: number | number
isDateUnavailable?: (DateValue) => boolean
isQuiet?: boolean = false
maxValue?: DateValue
maxVisibleMonths?: number = 1
minValue?: DateValue
pageBehavior?: PageBehavior = visible
placeholderValue?: DateValue
shouldFlip?: boolean = true
+ shouldForceLeadingZeros?: boolean
showFormatHelpText?: boolean = false
} TimeField SpectrumDateRangePickerProps<T extends DateValue> {
allowsNonContiguousRanges?: boolean
granularity?: Granularity
hideTimeZone?: boolean = false
hourCycle?: number | number
isDateUnavailable?: (DateValue) => boolean
isQuiet?: boolean = false
maxValue?: DateValue
maxVisibleMonths?: number = 1
minValue?: DateValue
pageBehavior?: PageBehavior = visible
placeholderValue?: DateValue
shouldFlip?: boolean = true
+ shouldForceLeadingZeros?: boolean
showFormatHelpText?: boolean = false
} DateField SpectrumTimeFieldProps<T extends TimeValue> {
granularity?: 'hour' | 'minute' | 'second' = 'minute'
hideTimeZone?: boolean
hourCycle?: number | number
isQuiet?: boolean = false
maxValue?: TimeValue
minValue?: TimeValue
placeholderValue?: TimeValue
+ shouldForceLeadingZeros?: boolean
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm, tested on iOS
@@ -78,6 +78,12 @@ HourCycle24.story = { | |||
name: 'hourCycle: 24' | |||
}; | |||
|
|||
export const ForceLeadingZeros = () => render({defaultValue: {start: new CalendarDate(2020, 2, 3), end: new CalendarDate(2020, 5, 4)}, shouldForceLeadingZeros: true}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a new story when it's already in the controls?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DateRangePicker and TimeField don't have controls for some reason. I added to the controls for DatePicker and DateField. Seems like we need to convert the others over at some point.
Closes #4668
This adds a
shouldForceLeadingZeros
prop to DatePicker, DateRangePicker, DateField, and TimeField which forces leading zeros to always show in the month, day, and hour fields, regardless of the locale preference. This was also requested in #4247. We would discourage overriding this across all locales, but it can be useful to configure in some scenarios.