Calendar
Usage
MeCalendar takes a CalendarProps payload and draws the whole calendar screen from it: a sidebar with the mini calendar and the calendars by group, a toolbar with navigation and the view switcher, the grid, and the overlays that edit it. The block fetches nothing and writes nothing. It emits rangeChange when the visible span changes, the consumer answers with the events of that span, and every edit comes back as an emit for the consumer to persist.
The block knows no screen. The Miisy Scheduling (Agendamento) is one payload of it, kept in packages/ui/app/review/calendars/scheduling.ts and rendered by the review route /calendar?doc=scheduling of the packages/ui dev server.
MeCalendar fills its parent (h-full): give it a box with a height.
The preview does not apply its emits, so a saved or deleted event does not stay on the grid: that is the consumer's job, shown below.
<template>
<MeCalendar
v-bind="payload"
:events="events"
@range-change="range => load(range.start, range.end)"
@save="onSave"
@delete="event => remove(event.id)"
/>
</template>
Payload
CalendarProps is the contract. It is plain data: a payload that arrives as JSON can be checked with calendarPropsZ before it reaches the block.
| Prop | Default | Type |
|---|---|---|
meta | CalendarMeta title at the top of the sidebar, subtitle; views offered by the switcher (all four when omitted); view, the initial one (week when offered, else views[0]); date, the initial day as YYYY-MM-DD (today when omitted); weekStartsOn 0 (Sunday, default) or 1; hours: { start, end }, the rows drawn in day and week (end exclusive, 0 to 24 by default); slotMinutes 15, 30 (default) or 60, the grid's step and the step of the form's time selects; shortcuts, on unless false. | |
calendars | CalendarSource[] { id, name, color, group?, visible?, actions?, values? }. color is a token name, never a hex: CALENDAR_COLORS, the seven Nuxt UI aliases plus chart-1 to chart-6. actions is the calendar's menu (CalendarAction[], see Sidebar actions). values holds the calendar form's own fields, to prefill Calendar form. | |
groups | [] | CalendarGroup[] { id, label }, the sidebar headings (Meus calendários, Outros calendários). A calendar without group prints under none. |
events | CalendarEvent[] { id, calendarId, title, description?, start, end, allDay?, resources?, color?, document?, href?, fields? }. start and end are local ISO datetimes with no zone (2026-10-21T11:00); an all-day event's end is the midnight after its last day. color overrides the calendar's, document is the { label, href } link of the record the event belongs to, fields are extra facts the popover prints. | |
actions | CalendarActions newEvent and editEvent (CalendarEventForm or false), eventClick ('edit' | 'href' | 'emit'), newCalendar and editCalendar. See Editing and Calendar form. | |
search | on | CalendarSearch | false { placeholder?, keys? }, keys among title, description and resources (all three when omitted). false hides the toolbar icon and the cmd+k shortcut. See Search. |
toolbar | CalendarToolbarProps actions, the document bar's shape (MeButtonBar props with CalendarAction[], four visible and the rest in Mais ações); options, the ⋮ menu as CalendarOption[][]. | |
sidebar | search on | CalendarSidebar search: the box fixed at the top of the sidebar, true, false or { placeholder }; filters: facets over an event key, CalendarFilterGroup[] ({ id, label, by, items }). An event whose value for by is unchecked leaves the grid; an event with no value for it stays. |
manage | [] | CalendarManagedList[] Lists the block manages in a drawer, resources and holidays. See Managed lists. |
loading | false | boolean A thin progress bar over the grid while the consumer fetches a range. |
Models
| Model | Type |
|---|---|
v-model:view | CalendarViewKey 'day' | 'week' | 'month' | 'list'. Unbound, the block starts from meta.view. |
v-model:date | string YYYY-MM-DD, the day the grid is anchored on. Unbound, meta.date, else today. |
v-model:visible-calendars | string[] The ids drawn. Unbound, every calendar whose visible is not false. Persisting it (a cookie, a user setting) is the consumer's choice. |
v-model:filters | string[] The facet items turned off in the sidebar, as groupId:itemId. Unbound, none. |
Views and navigation
Four views, the ones the switcher offers through meta.views:
- Day and week: a column per day, the all-day band on top, the hour rows of
meta.hoursin steps ofslotMinutes, today's column tinted and a line at the current time. Overlapping events share the column side by side. - Month: six week rows with event chips and a
+Nwhen a day holds more than fits; the days of the neighbor months are dimmed and still show their events. - List: the span's events grouped by day, with an empty state when there are none.
The toolbar carries previous and next, Hoje, the period title, the view switcher as a pill segmented control, the search icon, toolbar.actions and the ⋮ options. The keyboard does the same unless meta.shortcuts is false: t today, d w m l the views, n a new event, the arrows previous and next, cmd+k the search. No shortcut fires while an input has focus or an overlay is open.
The layout follows the container's breakpoints, Tailwind's own:
- Below
lg(1024px) the 272px sidebar leaves the layout and opens in a slideover from a toolbar button. - Below
md(768px) the week draws three days, the month draws dots instead of chips, the toolbar is one row titled by the month, and the editors open as a bottom drawer and a fullscreen modal.
rangeChange({ start, end, view }) fires on mount and on every change of the span, end exclusive. In month it covers the dimmed days too, so a consumer that fetches by it has every event the grid can draw.
Editing
Popover first, modal on demand:
- A single click on an event selects it. A double click opens the quick editor, a popover anchored to the event with title, calendar, all day, start, end and description, plus Delete and Save. Its expand button opens the full modal.
- A double click on an empty slot draws a draft block (
Novo eventowith its time, two slots long) and opens the quick editor on it. The block follows the editor's title, calendar and times as they change. A draft nobody touched disappears on cancel, Escape or an outside click; a draft with a title becomes the event on an outside click. - The "+" button,
nand New event in a calendar's menu (prefilled with that calendar) open the modal with the full form: the deliberate path gets every field.
The modal is UModal with UForm. The period is intrinsic and always drawn: title (required, up to 100 characters), date, start and end (selects every slotMinutes, in the locale's hour format), all day (which hides the hours). The form's fields follow, rendered by MeFieldRow, the same renderer the document chassis uses. The reserved ids land on the event's own keys: calendarId (a select over calendars), color (a select over CALENDAR_COLORS), description and resources. Any other id is handed back in values as is. miniDay: true adds the day's agenda beside the form, read-only, with the event being edited live as its times change. The footer is Cancel (ghost), Delete (ghost, error, edit only) and Save (solid primary). End before start is reported inline, under the field.
actions.eventClick decides what a click does: edit (the default when editEvent exists) as above, href follows the event's link, emit only emits eventClick and leaves the rest to the consumer. Without editEvent and without href, the double click opens a read-only view of the event: time, calendar, resources, the document link and fields.
Search
The search is MeAdvancedSearch, the EletroDS wrapper over UCommandPalette, opened by the toolbar icon or cmd+k, with its Genius and recent-search groups hidden. The block is its provider and fills four groups:
| Group | Items | Picking one |
|---|---|---|
| Actions | New event (N), Go to today (T) | Runs it. |
| Views | Day, Week, Month, List, the current one marked | Switches the view. |
| Calendars | Every calendar with its color and a check when visible | Toggles its visibility; the palette stays open. |
| Events | The loaded events of the visible calendars, matched on search.keys, with calendar and resources as the second line and day and time trailing | Moves date to the event's day, keeps the view and opens its editor. |
The search is local, over the loaded range. The Events group lists at most 12 matches, UCommandPalette's default result limit, because MeAdvancedSearch does not forward a fuse option yet. MW-92351 adds it; the block will then raise the limit.
Sidebar and toolbar actions
A calendar's menu is its actions, CalendarAction[] (MeButtonBar actions with a name and a color among the seven aliases). toolbar.actions.actions and toolbar.options take the same name. The block emits calendarAction(name, calendar) and toolbarAction(name), except for what it runs itself:
onlyThishides every other calendar, with aMostrar todosundo in the toast.newEventopens the new event modal prefilled with that calendar.configurationopens the calendar form whenactions.editCalendarexists, andnewCalendarin the toolbar does the same withactions.newCalendar.- An option with
manage: '<list id>'opens that managed list's drawer.
Managed lists
manage declares the lists a calendar keeps beside its events: the Miisy's resources (the docks and bays an event books) and holidays. Each is a CalendarManagedList:
{
id: 'resources',
label: 'Recursos',
kind: 'resource', // 'resource' | 'holiday' | 'generic'
groupBy: 'group', // 'group' files items under item.group, 'month' under the month of item.date
createLabel: 'Novo recurso',
fields: [{ id: 'label', label: 'Recurso', type: DocumentFieldType.text, required: true }, { id: 'active', label: 'Ativo', type: DocumentFieldType.checkbox }],
items: [{ id: 'vaga-46-predio-2', label: 'Vaga 46 - Prédio 2', group: 'Prédio 2', active: true }]
}
A toolbar option that names the list ({ name: 'resource', label: 'Recursos', manage: 'resources' }) opens it in a drawer (USlideover): a search box on top, the items grouped with a count in the header, no pagination. Create and edit happen inline in the drawer, never in a modal over a modal; active is a switch on the row, and delete is a low-weight icon with an inline confirmation. Every change is emitted as manage({ list, action, item }) and the consumer persists it.
A holiday list also prints its items in the all-day band of the calendars they name (calendarIds), so a holiday is visible on the days it blocks. A holiday needs a date.
Calendar form
actions.newCalendar and actions.editCalendar are CalendarEventForms drawn in a modal, for the toolbar's newCalendar option and the calendar menu's configuration. Name and color are intrinsic, the color as the token palette; the rest are the form's fields (description, sharing as a select). The edit form opens prefilled with the calendar and its values. Save emits calendarSave({ values, calendar? }), with no calendar for a new one; the edit form's delete emits calendarDelete(calendar). Without the form, the option and the menu action are emitted as plain actions.
Form fields are CalendarFormField: the document chassis's DocumentField plus the id the form keys the value by, rendered by MeFieldRow. A select lists config.items, and config.multiple makes it a multi select.
Emits
| Event | Payload | Description |
|---|---|---|
update:view, update:date | CalendarViewKey, string | The view switcher and navigation (v-model). |
rangeChange | { start, end, view }: CalendarRange | On mount and on every change of the drawn span. The request for events. |
update:visibleCalendars | string[] | A sidebar checkbox, Só este, or a calendar picked in the search. |
update:filters | string[] | A facet checkbox in the sidebar, as groupId:itemId. |
save | { values: CalendarEventValues, event?: CalendarEvent } | Save in the modal or the quick editor. values carries title, start, end, allDay and every form field by id; event is present on an edit. The undo of a delete comes back as a save without event. |
delete | event: CalendarEvent | Delete in the modal or in the quick editor. |
eventClick | event: CalendarEvent | Only with actions.eventClick: 'emit'. |
calendarAction | name: string, calendar: CalendarSource | A calendar's menu item, except the reserved names. |
toolbarAction | name: string | A toolbar action or option, except the reserved ones and options with manage. |
manage | { list, action, item }: CalendarManageChange | A create, update, delete or toggle in a managed list's drawer. item as it is after the change (for a delete, as it was). |
calendarSave | { values: CalendarSourceValues, calendar?: CalendarSource } | The calendar form's Save. No calendar: a new one. A calendar no longer in calendars: the undo of a delete, to put back under the same id. |
calendarDelete | calendar: CalendarSource | The edit calendar form's delete. |
Validation
calendarPropsZ mirrors CalendarProps with strict objects: an unknown key is an issue, never dropped. On top of the shapes it checks what the types cannot: end after start, meta.view among meta.views, every event's calendarId among calendars, every calendar's group among groups, unique ids for calendars, events and form fields, eventClick: 'edit' only with an editEvent, links relative or http(s), and a date on every holiday.
import { calendarPropsZ } from '@mercadoeletronico/eds-next'
const result = calendarPropsZ.safeParse(payload)
if (!result.success) console.warn(result.error.issues)
In development the block runs the same check on its own props and prints one console.warn per distinct set of issues. It never throws, and production builds skip it.
Feedback and motion
Every deliberate action raises a toast through Nuxt UI's useToast (for an event, its day and time as the description): event created, updated and deleted, calendar created, updated and deleted, a managed item created, updated, deleted, activated or deactivated, and Só este. Deletes carry a Desfazer action (the toast stays 7s), Só este a Mostrar todos. Emits stay silent to the reader: what to say about them is the consumer's call. The toasts need a UApp around the app, which a Nuxt UI app already renders.
Motion lasts 150 to 220ms, ease-out, and runs only under motion-safe: (prefers-reduced-motion: no-preference): the grid slides 20px in the direction of previous and next, a view switch fades, a created event pulses and a deleted one fades out, and overlays scale or slide in. With reduced motion, none of it runs.
MeCalendarPage
MeCalendarPage is the block wired as a page: MeLayout with MeHeader on top and MeCalendar filling everything under it. It takes every MeCalendar prop, the four models and every emit unchanged, plus a header (DocumentHeaderConfig, the mock header every template ships when omitted) and a footer slot under the calendar. There is no MeSubheader: the title is the sidebar's.
<template>
<MeCalendarPage
v-model:view="view"
v-model:date="date"
v-bind="payload"
:header="header"
@range-change="range => load(range.start, range.end)"
/>
</template>
MeCalendarPage does not render its own UApp: the app around it already does, and a second one draws every toast twice. Use MeCalendar alone when the screen already has its shell.