Fragiola

API: core (@fragiola/calendar)

Settings

Every setting of the calendar document, with its default, from the display zone and locale, the weeks, the time grid's slots, the edit rules and the features'.

The settings are part of the document (settings), each one optional: the defaults fill the rest. The model holds them resolved (model.state.settings, model.get("settings"), a CalendarSettings), and settings.set changes them with a SettingsPatch. Which settings a user may change, and the controls for them, are yours.

import { createCalendarModel } from "@fragiola/calendar";

const model = createCalendarModel({
    version: 1,
    events: [],
    settings: {
        timeZone: "Europe/London",
        locale: "en-GB",
        firstDayOfWeek: 1,
        slotMinTime: "07:00",
        slotMaxTime: "20:00",
        dayMaxEvents: 3,
    },
});

model.run("settings.set", { settings: { hiddenDays: [0, 6] } }); // a work week
model.run("settings.set", { settings: { firstDayOfWeek: null } }); // back to the locale's

A null in a patch removes an optional setting, so its default applies again. With the root (React, Vue or Angular), the settings prop (an input in Angular) sends the changed value as a whole patch (Controlled state).

Defaults

DEFAULT_SETTINGS holds the settings of a document that gives none (FullCalendar's documented defaults where the calendar decides nothing of its own). A setting the table says has no default stays absent: its default is another value (the locale's first day, the slot, no limit).

Display and weeks

settingtypedefaultdescription
timeZonestring"local"the display zone: an IANA name, or "local" (the host's, LOCAL_TIME_ZONE)
localestring"en-US"BCP 47: formatting and the week's rules
firstDayOfWeekWeekdaythe locale'sthe first day of a week, 0 = Sunday
hiddenDaysWeekday[][]days of the week no view shows
weekNumbers"iso" | "locale""locale"how weeks are numbered
fixedWeekCountbooleantruewhether a month view always shows six weeks
validRangeValidRangeJsonnonethe dates the calendar may navigate to

Time grid

settingtypedefaultdescription
slotDurationnumber30a slot, in minutes
slotMinTimestring"00:00"the first time shown, HH:mm
slotMaxTimestring"24:00"the end of what is shown, HH:mm up to 24:00
snapDurationnumberthe slotthe step a drag or a selection snaps to, in minutes
eventMinDurationnumber15the least minutes an occurrence counts for in the overlap layout
nextDayThresholdstring"00:00"the wall clock a timed end must reach to show on its last day

Day grid and order

settingtypedefaultdescription
dayMaxEventsnumber | "auto" | nullnullthe occurrences a day shows before "+N more"; "auto": what fits (measured); null: all
eventOrderstring"start,-duration,allDay,title"how occurrences tie-break: fields, - for descending, an unknown one read from data

Durations

settingtypedefaultdescription
defaultTimedDurationnumber60minutes: a timed event made from an all-day one, or added without an end
defaultAllDayDurationnumber1days: an all-day event made from a timed one, or added without an end
allDayMaintainDurationbooleanfalsewhether a move between all-day and timed keeps the duration

Edit rules

The defaults of every event's flags. For each flag the chain is: the event's flag, the event's editable, its calendar's editable, the settings' flag, the settings' editable (Drag and drop).

settingtypedefaultdescription
editablebooleantruethe default of every event's editable
startEditablebooleaneditablethe default of startEditable
durationEditablebooleaneditablethe default of durationEditable
deletablebooleaneditablethe default of deletable

The features' settings

A feature's setting in a model without the feature is invalid_payload (in settings.set) or a document issue, naming the feature.

settingtypefeaturedescription
businessHoursBusinessHours[]constraints()the working hours, in the display zone
eventConstraintEventConstraintconstraints()where events may be added, moved and resized to
selectConstraintEventConstraintconstraints()where a range may be selected
overlapboolean | Record<string, boolean>constraints()whether events may overlap: all of them, or per calendar id (default true)
eventSourcesEventSource[]eventSources()the event sources (The JSON document)

BusinessHours, one rule of businessHours:

fieldtypedescription
daysOfWeekWeekday[]the days it covers, 0 = Sunday
startTimestringHH:mm
endTimestringHH:mm, after startTime, up to 24:00

An EventConstraint is "business-hours" (which needs businessHours) or a non-empty list of ConstraintRange, the event within one of them:

fieldtypedescription
startstringa date (that day's start in the display zone) or a date-time; open when absent
endstringthe same, exclusive; open when absent
import { createCalendarModel } from "@fragiola/calendar";
import { constraints } from "@fragiola/calendar/constraints";

const model = createCalendarModel(
    {
        version: 1,
        events: [],
        settings: {
            businessHours: [
                { daysOfWeek: [1, 2, 3, 4, 5], startTime: "09:00", endTime: "17:00" },
            ],
            eventConstraint: "business-hours",
            overlap: { focus: false },
        },
    },
    { features: [constraints()] },
);

Here events stay within weekday working hours, and no event may overlap one of the focus calendar (Constraints and business hours).