A text field that reads a typed time, such as "7:30pm" or "19:30".
import { TimeField } from '@oztix/roadie-components/time-field'
Type a time the way you would say it: "7:30pm", "7pm", "19:30" or "noon". A time with no "am" or "pm" reads on a 24-hour clock, so "7:30" is morning. The text is read when the field loses focus or on Enter. The value is 'HH:MM' on a 24-hour clock, such as '19:30', or null. A time has no date and no zone, so pair it with a date where it matters, or use DatePicker with granularity='minute'.
hourCycle sets how the time reads. 12 reads "7:30pm", the house style for anything a buyer sees, and 24 reads "19:30" for dense staff screens. Either clock can be typed into either field.
Wrap it in Field for the label and helper text. It takes invalid, required and disabled from the field, and Field.ErrorText says why typed text isn't a time.
minuteStep sets how far ArrowUp and ArrowDown move the time. A typed time off the step shows an error, such as "Choose a time in 15-minute steps". Set times at Wobbly Teacup Room run on the quarter hour.
<DatePicker granularity='minute' timeZone={venue.timeZone} />
Do
When the time belongs to a moment, such as doors on a show night, pick the date and time together in the venue's zone.
Don’t
Don't store a time on its own and join it to a date later in the browser's zone. Near midnight and across daylight saving that lands on the wrong moment.
ArrowUp and ArrowDown step the time by minuteStep, wrapping at midnight.Enter. While text is being edited, Enter commits it instead of submitting the form, and Escape puts back the last time.aria-invalid, and inside a Field points aria-describedby at Field.ErrorText.Field with Field.ErrorText so the reason is shown and read out.A text field that reads a typed time, such as "7:30pm" or "19:30".
The time, as `'HH:MM'` on a 24-hour clock. Pair with `onValueChange`.
The time to start from when uncontrolled.
Called when typed text is committed, on blur or Enter, or a step is taken, with `'HH:MM'`, or null when the text is empty or names no time.
Marks the field as invalid. Inherits from `Field` when omitted.
Defaults to 'md'.
Defaults to 'normal'.
`12` reads "7:30pm" and `24` reads "19:30". Either is typed in.
Defaults to 12.
Minutes per step. The arrow keys step by it, and a typed time off the step shows an error.
Defaults to 1.
Defaults to 'en-AU'.