Examples
Recurring event form
Built with the mantine-form skill
Create recurring event
Build a form for creating a recurring event in a team calendar app.
Event:
- title (required) and description (textarea, optional)
- start and end as date and time; end must be after start; the end defaults to one hour after the start when the start changes and the end was not edited
- "All day" switch: when on, start and end are dates only and the time parts are hidden
- timezone (select from a hard-coded list of 12 IANA timezones with city labels; default to the browser timezone when it is in the list, otherwise UTC)
- location (optional)
Recurrence:
- repeat: does not repeat, daily, weekly, monthly, yearly
- interval: every N days / weeks / months / years (1 to 99), shown for every repeat except "does not repeat"
- weekly: weekdays to repeat on (at least one; defaults to the weekday of the start date)
- monthly: on the same day of the month, or on the same weekday of the month (for example "second Tuesday"), both derived from the start date
- ends: never, after N occurrences (1 to 500), or on a date (after the start date)
- exceptions: dates to skip, added with a date picker and shown as a removable list; an exception must be within the series and unique
- a read-only preview of the next 5 occurrences computed from the rule and the exceptions, updated as the fields change; shows "No occurrences" when the rule produces none
Validation:
- title, start, end and timezone are required
- end after start (same-day events compare the time)
- interval, occurrences count, ends-on date and exceptions follow the limits above
- weekly repeat needs at least one weekday
Behavior:
- the recurrence fields appear and disappear with the selected repeat option; values of hidden fields are not submitted
- submit validates everything and focuses the first invalid field
- on submit show a short notification (event title and first occurrence) and display the event JSON (title, description, start, end as ISO strings, allDay, timezone, location, recurrence with only the fields that apply, exceptions) under the form; keep the form as is
Write tests for the component.