Scheduler
Month-view scheduling component: renders event chips (title + color bar) inside day cells; events read/write channel plus addEvent / updateEvent / removeEvent CRUD methods; clicking a chip dispatches oas-event-click, clicking a day dispatches oas-day-click (host attaches an editor), and data changes made through the CRUD methods dispatch oas-events-change (writing via setAttribute('events', …) does not).
Basic Usage
Week start & locale (first-day-of-week + locale)
Month view + event chips (title / color bar / +N collapse)
Week / Day Views
Week view (time axis + timed event blocks; all-day row on top)
Day view (single-column time axis) + oas-view-change
Week/day views show a time axis (start-hour / end-hour, default 8–20): events with start/end are positioned as blocks by time; untimed events go to the all-day row on top; time-overlapping events are automatically split into side-by-side lanes (equal width within a cluster, with gaps, no more complete overlap); events earlier than start-hour or later than end-hour are clipped to the range, so blocks never leave the track or cover the column header; switching views via the header buttons dispatches oas-view-change. Event blocks support drag-to-move (drop on a target column/time to change date + start, keeping duration) and two-edge drag-resize (top edge changes start, bottom edge changes end, both in 15-minute steps); dragging the top edge past the end clamps it to end - 15 minutes, written back with oas-events-change on settle. Snapping applies only to the edge being dragged; the other edge and pre-existing non-grid times are left unchanged. Overlapping events still coexist in lanes (legitimate; writes are not blocked); only an invalid same-day range with start >= end is rejected.
Conflict Check & Keyboard (week/day views)
conflict-check: dashed outline on same-day overlapping blocks + oas-event-conflict
conflict-check (presence boolean, off by default) enables overlap detection for single-day timed events on the same day: overlapping blocks get a dashed danger outline (.event.conflict) plus the scheduler.conflict readable hint, and each affected event dispatches oas-event-conflict (detail: { id, conflicts }, where conflicts lists the ids of overlapping events). Dispatch is idempotent: the same data snapshot never re-dispatches; after a data change it re-dispatches per id only when the signature changes; when a conflict resolves, the related ids receive one empty-array payload for the host to clear its markers. Dispatch happens synchronously inside the component's update() (the first frame is emitted on mount): the host must attach its listener before writing/changing data; a listener attached later misses the first frame — remove and re-add conflict-check to reset the signature channel and re-emit the current snapshot. Detection uses half-open intervals (back-to-back does not count, same as the lane criterion) over the whole calendar (not just the visible view); repeats are not expanded into occurrences and multi-day timed/all-day events are not included. The conflict outline is purely visual — overlapping events still coexist in lanes and drag/resize writes are unaffected.
Focused event blocks are keyboard-operable: ← / → shift date by a whole day (mirrored visually under RTL), Alt+← / Alt+→ resize end (±15-minute steps, never past start, clamped at 24:00); writes go through updateEvent() (single-step undo snapshot + oas-events-change), the view follows when a block moves out of the current week/day so focus is preserved, and aria-keyshortcuts declares the shortcuts.
Recurrence & Reminders
Recurrence rules (RRULE subset: daily/weekly/monthly + interval + until)
repeat expands occurrences from date by freq × interval (daily by day interval, weekly by week, monthly by same day-of-month), with until as the inclusive end; el.events still reads the raw entries (expansion happens only at render time). Monthly/weekly rules may also use byMonth (1-12), byMonthDay (1-31), bySetPos (for example -1), byDay (weekly, 0=Sunday…6=Saturday), and exDates (excluded dates, YYYY-MM-DD). Local occurrence filtering supports byMonth / byMonthDay / byDay / exDates, plus monthly byMonthDay + bySetPos; other bySetPos cases are emitted to ICS RRULE as-is. repeat does not combine with endDate: when both are present the component ignores endDate and expands occurrences as per-day entries, so the event cannot be skipped by both rendering paths.
Multi-day all-day bars (continuous in week view; drag to shift as a whole)
In week view, an all-day event with endDate renders as one continuous bar in the all-day band (instead of one chip per day); overlapping bars are stacked into rows so the end handle is not covered by a bar above. Drag the bar horizontally to shift date / endDate by whole columns; the component dispatches oas-events-change. Drag the bar's end handle to change only endDate (keeping date / start / end); when the bar is focused, Alt+← / Alt+→ resizes the end by one day (mirrored in RTL), while plain ← / → still shifts the whole bar. Timed multi-day bars keep at least two days (next-day end); when shrunk before the visible week the view follows, and an all-day bar shrunk to one day returns to a regular all-day chip. If it leaves the current week the view follows, so the bar is not unmounted under focus. Timed multi-day events also render as one continuous bar in the top multi-day band, with a start–end time label; the day time grid no longer duplicates per-day blocks.
Each updateEvent (including drag/resize) keeps the previous snapshot: use el.canUndo to check whether a change can be reverted and el.undo() to revert the latest one, which dispatches oas-events-change. Replacing events or calling add/remove clears the snapshot so undo never crosses external data changes.
Reminders (remind minutes; oas-remind when due)
For events with remind (minutes), the component dispatches oas-remind (detail: { id, event }) at start − remind minutes (untimed events count as 00:00). Past/removed/disconnected events never fire.
Host-expanded repeats: the base event has no repeat; each occurrence is sent with a unique id
In windowed mode prefer this host-expanded form: the component will not expand the base event a second time.
Timezone & Agenda View
Agenda view (28-day chronological list from anchor)
view="agenda" lists events grouped by day for 28 days from the anchor (recurring events expanded): timed events show start–end, untimed events are labeled all-day; clicking a row dispatches oas-event-click, clicking a day header dispatches oas-day-click.
Timezone (affects the today marker and the now line)
timezone accepts an IANA name (e.g. Asia/Shanghai / America/New_York / UTC) and currently only affects the today marker and the now-line position (via Intl timeZone); title/column-header formatting always follows the host's local timezone. Invalid values fall back to local. Full timezone-aware formatting (translating column headers and event times into the target zone) requires a dedicated proposal before implementation.
Resource Views & Drag-to-Create
Single-day resource view (view=resource: rows = resources, horizontal = hours)
Week x resource matrix (view=resource-week)
Resource timeline (view=resource-timeline: rows = resources, continuous multi-day axis, events = cross-column bars)
Resource groups + secondary timezone (group + secondary-timezone)
Drag to create (drag a range on an empty time cell → oas-create)
RTL (dir=rtl: resource timeline and resource column mirror)
view="resource" renders a single-day schedule with resources as rows and hours across; view="resource-week" is a week x resource matrix (rows = resources, columns = 7 days of the week). Events are assigned to a resource row via their resource field; absent or unknown ids go to the "Unassigned" row. Dragging a range (>=15 minutes) on an empty time cell dispatches oas-create (detail: { date, start, end, resource? }) — the component does not create the event; the host calls addEvent. A shorter drag is treated as a click and dispatches oas-day-click. show-now (on by default) renders a now line at the current time. A non-empty resources[].group inserts a group header row before its resources (once per name, input order preserved); windowed slices do not auto-generate group rows. secondary-timezone appends a second timezone label to the day/week/resource-day time gutter (invalid IANA is ignored with a devWarn).
view="resource-timeline" is the resource timeline (7th tier: rows = resources, columns = one continuous day axis): the horizontal axis is no longer sliced by hour or by cell — multi-day events render as one continuous bar (cross-day events that break into two halves in resource-week stay unbroken here). The axis follows the existing range/nav mechanics — without range-start/range-end it is the current week (7 days, aligned to first-day-of-week); with them, the axis equals the host-managed span (spans beyond 400 days are clipped with a one-time devWarn; the axis is then fixed, so prev/next leave it unchanged — extending is the host's job via range-*). Resource rows, group header rows, the "Unassigned" row and windowed slices follow the same semantics as resource / resource-week; overlapping bars within one resource stack vertically (max 3 lanes, excess clipped, matching the fixed-height row model). Bar interactions mirror the week view's cross-day bars: drag the bar to shift date/endDate with day snapping, drag the end handle to extend only endDate, and once focused use ←/→ to shift and Alt+←/Alt+→ to resize the end (mirrored visually under RTL); bars shifted out of the axis page the view to keep focus. Clicking a row header or empty lane space dispatches oas-day-click (with the resource id; lane clicks resolve the date from the click column); timed events carry a start–end label on the bar; repeat events have no endDate semantics and render one single-day bar per occurrence.
CRUD (method channel)
addEvent / updateEvent / removeEvent + oas-events-change feedback
Click Feedback (host integration)
oas-event-click / oas-day-click host integration
Clicking an event chip dispatches oas-event-click (detail: { id, event }, without triggering the day click); clicking an empty day cell dispatches oas-day-click (detail: { date }) — the host opens an editor/form there; the component ships no built-in edit form.
Large datasets (virtualization)
In the resource view the resource rows, and in the day view the hour axis, render for the visible window only: the number of rendered rows/ticks does not grow with the dataset size, and spacers preserve the scroll range (total height invariant). After a scroll rebuild focus is restored by event id, and window rebuilds are suppressed while a drag/create gesture is active (so pointer capture is not destroyed). The resource view is capped by --oas-scheduler-resource-max-height (default 640px, matching the timeline); beyond that it scrolls internally and virtualizes. Resource rows and the timeline carry aria-rowcount and absolute aria-rowindex.
Print preview
Print: @media print hides the toolbar and removes agenda/resource scroll caps (opens the system print dialog)
Server-side resource row window (windowed) and printing
The resource views (resource / resource-week / resource-timeline) support server-side slices: windowed + total + window-start, with resources carrying only [window-start, window-start + resources.length). The component emits oas-window-request (absolute, half-open row range) when the visible window is not covered; the host responds with a new slice and updates window-start. aria-rowcount uses total, and aria-rowindex uses absolute row numbers.
- In windowed mode the component does not append an "Unassigned" row automatically; the host can provide the reserved id
__unassigned__, and events with no/unknownresourceare grouped there. - Repeat events inside the loaded slice are still expanded locally; when the host expands occurrences it must strip
repeatfrom the base event (or stop sending the base series), otherwise the same day renders twice. Give each occurrence a unique id. - Print CSS (
@media print) hides the toolbar/view buttons and removes scroll caps (including agenda);beforeprinttemporarily disables row/hour virtualization and prints the loaded slice (windowed omits spacer blank pages), andafterprintrestores window rendering.
<oas-scheduler
view="resource"
windowed
total="500"
window-start="100"
resources='[{"id":"r100","title":"Resource 100"}]'
events='[{"date":"2026-08-10","title":"Standup","start":"09:00","end":"09:30","resource":"r100"}]'
></oas-scheduler>Date-window hosting & fetching
The component now supports native date-window hosting: provide range-start / range-end (ISO dates, inclusive end) and it emits oas-range-request ({ startMs, endMs, reason }) when the visible range is not covered; update events and range-* to close the loop. Requests are de-duplicated. Visible ranges: month = actual 6-week grid, week/resource-week = 7 days, day/resource = the day, agenda = 28 days, resource-timeline = its axis span (7 days unmanaged; when range hosting is on, the axis equals the managed span and is covered by definition).
import type { OASScheduler } from '@oas-ui/ui'
const el = document.querySelector('oas-scheduler') as OASScheduler
el.addEventListener('oas-range-request', async (e) => {
const { startMs, endMs } = (e as CustomEvent).detail
const iso = (ms: number) => {
const d = new Date(ms)
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`
}
const start = iso(startMs)
const endExclusive = iso(endMs)
const end = iso(endMs - 1)
const res = await fetch(`/api/events?start=${start}&end=${endExclusive}`)
el.events = await res.json()
el.setAttribute('range-start', start)
el.setAttribute('range-end', end)
})Without
range-*nothing is emitted; hosts may still derive the range frompage-show-date+view. Resource-row windowing keeps usingoas-window-request; both can coexist.
If you prefer manual range derivation (legacy integration), keep using:
import type { OASScheduler } from '@oas-ui/ui'
const el = document.querySelector('oas-scheduler') as OASScheduler
let ac: AbortController | null = null
async function loadWindow() {
ac?.abort()
ac = new AbortController()
const anchor = el.getAttribute('page-show-date') // YYYY-MM-DD
const view = el.getAttribute('view') ?? 'month'
const days = view === 'day' ? 1 : view === 'week' || view === 'resource-week' ? 7 : view === 'agenda' ? 28 : 31
const start = new Date(`${anchor}T00:00:00`)
const end = new Date(start.getFullYear(), start.getMonth(), start.getDate() + days - 1)
const iso = (d: Date) => d.toISOString().slice(0, 10)
const res = await fetch(`/api/events?start=${iso(start)}&end=${iso(end)}`, { signal: ac.signal })
el.events = await res.json()
}
el.addEventListener('oas-view-change', loadWindow)
document.querySelector('[data-prev]')?.addEventListener('click', () => {
el.setAttribute('page-show-date', prevAnchor(el.getAttribute('page-show-date')!))
loadWindow()
})If the host expands
repeat, strip it from base events and give every occurrence a unique id. Keep a small buffer around window boundaries to avoid a blank frame when paging.
ICS Export
Download current events as .ics (UTC + Asia/Shanghai)
import { eventsToIcs } from '@oas-ui/ui'
const ics = el.exportIcs() // current events
const standalone = eventsToIcs(events, { calendarName: 'My Calendar' })
el.downloadIcs('my.ics', { timeMode: 'utc', timezone: 'Asia/Shanghai' })- Events without
startexport as all-day events (DTSTART/DTEND;VALUE=DATE, end = next day;endDatesupports multi-day all-day events). timeMode:floating(default, local wall time) /utc(converted withtimezone,Zsuffix) /tzid(TZIDplus a fixed-offsetVTIMEZONE; useutcfor DST-accurate conversion).repeatmaps toRRULE:FREQ/INTERVAL/COUNT/BYDAY/BYMONTH/BYMONTHDAY/BYSETPOS/UNTIL(untilis inclusive,BYDAYis emitted in ascending 0-6 order); eachexDatesentry emits anEXDATEwith the same value type asDTSTART:EXDATE;VALUE=DATE:YYYYMMDDfor all-day events andEXDATE:YYYYMMDDTHHmmssfor timed events (withZinutcmode andTZIDintzidmode);remindemitsVALARMandcoloremitsX-OAS-COLOR.eventsToIcs(events, { rangeStart, rangeEnd })exports only events intersecting the inclusive range;el.exportIcs(options)/el.downloadIcs(filename, options)pass the same fields through.- Text is RFC 5545 escaped; output uses CRLF and 75-byte folding; invalid-date events are skipped. The
nowoption fixesDTSTAMP.
API
oas-scheduler
Attributes
| Attribute | Description | Type | Default |
|---|---|---|---|
conflict-check | Same-day timed event conflict check (boolean, off by default): detects same-day time overlaps among single-day timed events — overlapping blocks get a .conflict dashed danger outline plus the scheduler.conflict readable hint, and oas-event-conflict is dispatched; detection uses half-open intervals (back-to-back does not count, same as the lane criterion) over the whole calendar (not just the visible view); repeats are not expanded into occurrences and multi-day timed/all-day events are not included; the outline is purely visual and never blocks drag/resize writes | string | — |
end-hour | Time axis end hour (> start-hour and <= 24, default 20) | string | 20 |
events | Schedule events (JSON): [{ id?, date: YYYY-MM-DD, endDate?, title, color?, start?, end?, repeat? { freq, interval?, until?, count?, byDay? }, resource? }] — chips rendered in day cells (title + color bar), collapsed to +N beyond 2 | SchedulerEvent[] | [] |
first-day-of-week | First day of week (0-6); defaults to locale-derived | string | — |
locale | Localization (overrides config-provider injection and global locale) | string | — |
page-show-date | Panel month anchor (controlled): yyyy-MM-dd; re-anchors the shown month on change | string | — |
range-end | Host-managed range end (ISO date, inclusive); emits oas-range-request when the visible range is not covered | string | — |
range-start | Host-managed range start (ISO date, inclusive); together with range-end enables oas-range-request hosting | string | — |
resources | Resources (JSON): [{ id, title, color?, group? }] — resource views group by resource; events whose resource is absent or unknown go to the 'Unassigned' row; a non-empty group inserts a group header row | SchedulerResource[] | [] |
secondary-timezone | Secondary timezone (IANA): appends a second timezone label to day/week/resource-day time gutters; invalid values are ignored with a devWarn | string | — |
show-now | Current-time line (on by default; false disables): renders a now line for today in week/day and single-day resource views | string | true |
start-hour | Time axis start hour (0-23, default 8) | string | 8 |
timezone | Timezone (IANA, e.g. Asia/Shanghai; empty = local): affects title/column date formatting and the today marker (via Intl timeZone); invalid values fall back to local | string | — |
total | Total resource row count in windowed mode (must be positive); used for aria-rowcount and absolute row indices. | string | — |
view | View: month (default) / week / day / agenda / resource / resource-week; week/day views show a time axis with positioned event blocks (untimed events go to the all-day row); agenda shows a 28-day chronological list; resource is a single-day horizontal resource timeline, resource-week a week x resource matrix; 'resource-timeline' resource timeline (rows = resources, horizontal continuous day axis spanning multiple days, events as continuous cross-column bars; axis = current week or the range-managed span) | SchedulerView | month |
window-start | Absolute row index of the first loaded row in windowed mode. | string | 0 |
windowed | Server-side resource row window mode (boolean, off by default): for resource / resource-week, resources carries only the [window-start, window-start + resources.length) slice; emits oas-window-request (absolute, half-open range) when the visible window is uncovered. The component does not auto-append an Unassigned row; the host may provide the reserved id __unassigned__. | boolean | — |
Property (JS property; see each row for attribute reflection)
| Property | Description | Type | Default |
|---|---|---|---|
canUndo | Whether a single-step event change can be undone (read-only; use with undo()) | boolean | — |
events | Schedule events (SchedulerEvent[]): el.events reads (copy incl. auto ids); el.events = [...] writes (syncs the events attribute + re-renders + dispatches oas-events-change) | SchedulerEvent[] | [] |
resources | Resources (SchedulerResource[]): el.resources reads (copy); el.resources = [...] writes (syncs the resources attribute + re-renders) | SchedulerResource[] | [] |
Methods
| Method | Signature | Description |
|---|---|---|
exportIcs | exportIcs(options?: IcsExportOptions): string | Export the current events as an ICS string (instance convenience channel for the pure eventsToIcs function; does not trigger a re-render) |
downloadIcs | downloadIcs(filename: unknown, options?: IcsExportOptions): string | Download the current events as an ICS file (browser environment; returns the generated ICS string for tests / host reuse) |
addEvent | addEvent(ev: SchedulerEvent): string | Add an event: returns the assigned id |
updateEvent | updateEvent(id: string, patch: Partial<SchedulerEvent>): boolean | Update an event by id (shallow-merges the patch, then runs sanitize; returns false when not found or when a same-day range has start >= end) |
undo | undo(): boolean | Undo the most recent updateEvent (including drag-move, two-edge time resize, multi-day end resize, and keyboard date-shift/resize on timed blocks); returns false when there is no snapshot, otherwise writes back and dispatches oas-events-change |
removeEvent | removeEvent(id: string): boolean | Remove an event by id; returns false when not found |
Events
| Event | Description |
|---|---|
oas-create | Dispatched when an empty time cell is dragged out to a range of >=15 minutes, detail: { date, start, end, resource? } — the component does not create the event; the host calls addEvent. A shorter drag is treated as oas-day-click |
oas-day-click | Dispatched when an empty day cell is clicked, detail: { date, resource? } (resource row id in resource views) — host attaches an add form |
oas-event-click | Dispatched when an event chip is clicked, detail: { id, event } (does not trigger the day click) |
oas-event-conflict | Conflict snapshot dispatch while conflict-check is on (dispatched synchronously inside update(), first frame on mount; the host must attach its listener before writing data — a late listener can remove and re-add conflict-check to reset the signature channel and re-emit. Idempotent: the same data snapshot never re-dispatches, re-dispatched per id only when the signature changes, empty arrays sent to related ids on resolution), detail: { id, conflicts } (ids of events overlapping this one on the same day and time range) |
oas-events-change | Dispatched on any events change (set/addEvent/updateEvent/removeEvent/undo), detail: |
oas-range-request | Host-managed date window: emitted when the visible range is not covered by range-start/range-end; detail: { startMs, endMs, reason }; no-op without range-* |
oas-remind | Dispatched when an event reminder is due, detail: { id, event } (fires at start - remind minutes via built-in timers) |
oas-view-change | Dispatched on view switch (month/week/day/agenda), detail: { view }; not dispatched on initial attribute absorption |
oas-window-request | Emitted in windowed mode when the visible resource-row window is not covered by the loaded slice; detail: { start, end, reason } (absolute, half-open; the same window is not emitted twice). |
CSS Variables
| CSS Variable | Default |
|---|---|
--oas-scheduler-resource-max-height | 640px |