calendar-utils

  • Version 0.8.5
  • Published
  • 120 kB
  • No dependencies
  • MIT license

Install

npm i calendar-utils
yarn add calendar-utils
pnpm add calendar-utils

Overview

Utility functions to generate views for calendars

Index

Variables

variable SECONDS_IN_DAY

const SECONDS_IN_DAY: number;

    Functions

    function getAllDayWeekEvents

    getAllDayWeekEvents: (
    dateAdapter: DateAdapter,
    {
    events,
    excluded,
    precision,
    absolutePositionedEvents,
    viewStart,
    viewEnd,
    }: GetAllDayEventArgs
    ) => WeekViewAllDayEventRow[];

      function getDifferenceInDaysWithExclusions

      getDifferenceInDaysWithExclusions: (
      dateAdapter: DateAdapter,
      { date1, date2, excluded }: { date1: Date; date2: Date; excluded: number[] }
      ) => number;

        function getEventsInPeriod

        getEventsInPeriod: (
        dateAdapter: DateAdapter,
        { events, periodStart, periodEnd }: GetEventsInPeriodArgs
        ) => CalendarEvent[];

          function getMonthView

          getMonthView: (
          dateAdapter: DateAdapter,
          {
          events,
          viewDate,
          weekStartsOn,
          excluded,
          viewStart,
          viewEnd,
          weekendDays,
          }: GetMonthViewArgs
          ) => MonthView;

            function getWeekView

            getWeekView: (
            dateAdapter: DateAdapter,
            {
            events,
            viewDate,
            weekStartsOn,
            excluded,
            precision,
            absolutePositionedEvents,
            hourSegments,
            hourDuration,
            dayStart,
            dayEnd,
            weekendDays,
            segmentHeight,
            minimumEventHeight,
            viewStart,
            viewEnd,
            }: GetWeekViewArgs
            ) => WeekView;

              function getWeekViewHeader

              getWeekViewHeader: (
              dateAdapter: DateAdapter,
              {
              viewDate,
              weekStartsOn,
              excluded,
              weekendDays,
              viewStart,
              viewEnd,
              }: GetWeekViewHeaderArgs
              ) => WeekDay[];

                function validateEvents

                validateEvents: (
                events: CalendarEvent[],
                log: (...args: any[]) => void
                ) => boolean;

                  Interfaces

                  interface CalendarEvent

                  interface CalendarEvent<MetaType = any> {}

                    property actions

                    actions?: EventAction[];

                      property allDay

                      allDay?: boolean;

                        property color

                        color?: EventColor;

                          property cssClass

                          cssClass?: string;

                            property draggable

                            draggable?: boolean;

                              property end

                              end?: Date;

                                property id

                                id?: string | number;

                                  property meta

                                  meta?: MetaType;

                                    property resizable

                                    resizable?: {
                                    beforeStart?: boolean;
                                    afterEnd?: boolean;
                                    };

                                      property start

                                      start: Date;

                                        property title

                                        title: string;

                                          interface EventAction

                                          interface EventAction {}

                                            property a11yLabel

                                            a11yLabel?: string;

                                              property cssClass

                                              cssClass?: string;

                                                property id

                                                id?: string | number;

                                                  property label

                                                  label: string;

                                                    method onClick

                                                    onClick: ({
                                                    event,
                                                    sourceEvent,
                                                    }: {
                                                    event: CalendarEvent;
                                                    sourceEvent: MouseEvent | KeyboardEvent;
                                                    }) => any;

                                                      interface EventColor

                                                      interface EventColor {}

                                                        property primary

                                                        primary: string;

                                                          property secondary

                                                          secondary: string;

                                                            interface GetDayViewArgs

                                                            interface GetDayViewArgs {}

                                                              property dayEnd

                                                              dayEnd: {
                                                              hour: number;
                                                              minute: number;
                                                              };

                                                                property dayStart

                                                                dayStart: {
                                                                hour: number;
                                                                minute: number;
                                                                };

                                                                  property events

                                                                  events?: CalendarEvent[];

                                                                    property eventWidth

                                                                    eventWidth: number;

                                                                      property hourDuration

                                                                      hourDuration: number;

                                                                        property hourSegments

                                                                        hourSegments: number;

                                                                          property minimumEventHeight

                                                                          minimumEventHeight: number;

                                                                            property segmentHeight

                                                                            segmentHeight: number;

                                                                              property viewDate

                                                                              viewDate: Date;

                                                                                interface GetEventsInPeriodArgs

                                                                                interface GetEventsInPeriodArgs {}

                                                                                  property events

                                                                                  events: CalendarEvent[];

                                                                                    property periodEnd

                                                                                    periodEnd: Date;

                                                                                      property periodStart

                                                                                      periodStart: Date;

                                                                                        interface GetMonthViewArgs

                                                                                        interface GetMonthViewArgs {}

                                                                                          property events

                                                                                          events?: CalendarEvent[];

                                                                                            property excluded

                                                                                            excluded?: number[];

                                                                                              property viewDate

                                                                                              viewDate: Date;

                                                                                                property viewEnd

                                                                                                viewEnd?: Date;

                                                                                                  property viewStart

                                                                                                  viewStart?: Date;

                                                                                                    property weekendDays

                                                                                                    weekendDays?: number[];

                                                                                                      property weekStartsOn

                                                                                                      weekStartsOn: number;

                                                                                                        interface GetWeekViewArgs

                                                                                                        interface GetWeekViewArgs {}

                                                                                                          property absolutePositionedEvents

                                                                                                          absolutePositionedEvents?: boolean;

                                                                                                            property dayEnd

                                                                                                            dayEnd: Time;

                                                                                                              property dayStart

                                                                                                              dayStart: Time;

                                                                                                                property events

                                                                                                                events?: CalendarEvent[];

                                                                                                                  property excluded

                                                                                                                  excluded?: number[];

                                                                                                                    property hourDuration

                                                                                                                    hourDuration?: number;

                                                                                                                      property hourSegments

                                                                                                                      hourSegments?: number;

                                                                                                                        property minimumEventHeight

                                                                                                                        minimumEventHeight?: number;

                                                                                                                          property precision

                                                                                                                          precision?: 'minutes' | 'days';

                                                                                                                            property segmentHeight

                                                                                                                            segmentHeight: number;

                                                                                                                              property viewDate

                                                                                                                              viewDate: Date;

                                                                                                                                property viewEnd

                                                                                                                                viewEnd?: Date;

                                                                                                                                  property viewStart

                                                                                                                                  viewStart?: Date;

                                                                                                                                    property weekendDays

                                                                                                                                    weekendDays?: number[];

                                                                                                                                      property weekStartsOn

                                                                                                                                      weekStartsOn: number;

                                                                                                                                        interface GetWeekViewHeaderArgs

                                                                                                                                        interface GetWeekViewHeaderArgs {}

                                                                                                                                          property excluded

                                                                                                                                          excluded?: number[];

                                                                                                                                            property viewDate

                                                                                                                                            viewDate: Date;

                                                                                                                                              property viewEnd

                                                                                                                                              viewEnd?: Date;

                                                                                                                                                property viewStart

                                                                                                                                                viewStart?: Date;

                                                                                                                                                  property weekendDays

                                                                                                                                                  weekendDays?: number[];

                                                                                                                                                    property weekStartsOn

                                                                                                                                                    weekStartsOn: number;

                                                                                                                                                      interface MonthView

                                                                                                                                                      interface MonthView {}

                                                                                                                                                        property days

                                                                                                                                                        days: MonthViewDay[];

                                                                                                                                                          property period

                                                                                                                                                          period: ViewPeriod;

                                                                                                                                                            property rowOffsets

                                                                                                                                                            rowOffsets: number[];

                                                                                                                                                              property totalDaysVisibleInWeek

                                                                                                                                                              totalDaysVisibleInWeek: number;

                                                                                                                                                                interface MonthViewDay

                                                                                                                                                                interface MonthViewDay<MetaType = any> extends WeekDay {}

                                                                                                                                                                  property backgroundColor

                                                                                                                                                                  backgroundColor?: string;

                                                                                                                                                                    property badgeTotal

                                                                                                                                                                    badgeTotal: number;

                                                                                                                                                                      property events

                                                                                                                                                                      events: CalendarEvent[];

                                                                                                                                                                        property inMonth

                                                                                                                                                                        inMonth: boolean;

                                                                                                                                                                          property meta

                                                                                                                                                                          meta?: MetaType;

                                                                                                                                                                            interface ViewPeriod

                                                                                                                                                                            interface ViewPeriod {}

                                                                                                                                                                              property end

                                                                                                                                                                              end: Date;

                                                                                                                                                                                property events

                                                                                                                                                                                events: CalendarEvent[];

                                                                                                                                                                                  property start

                                                                                                                                                                                  start: Date;

                                                                                                                                                                                    interface WeekDay

                                                                                                                                                                                    interface WeekDay {}

                                                                                                                                                                                      property cssClass

                                                                                                                                                                                      cssClass?: string;

                                                                                                                                                                                        property date

                                                                                                                                                                                        date: Date;

                                                                                                                                                                                          property day

                                                                                                                                                                                          day: number;

                                                                                                                                                                                            property isFuture

                                                                                                                                                                                            isFuture: boolean;

                                                                                                                                                                                              property isPast

                                                                                                                                                                                              isPast: boolean;

                                                                                                                                                                                                property isToday

                                                                                                                                                                                                isToday: boolean;

                                                                                                                                                                                                  property isWeekend

                                                                                                                                                                                                  isWeekend: boolean;

                                                                                                                                                                                                    interface WeekView

                                                                                                                                                                                                    interface WeekView {}

                                                                                                                                                                                                      property allDayEventRows

                                                                                                                                                                                                      allDayEventRows: WeekViewAllDayEventRow[];

                                                                                                                                                                                                        property hourColumns

                                                                                                                                                                                                        hourColumns: WeekViewHourColumn[];

                                                                                                                                                                                                          property period

                                                                                                                                                                                                          period: ViewPeriod;

                                                                                                                                                                                                            interface WeekViewAllDayEvent

                                                                                                                                                                                                            interface WeekViewAllDayEvent {}

                                                                                                                                                                                                              property endsAfterWeek

                                                                                                                                                                                                              endsAfterWeek: boolean;

                                                                                                                                                                                                                property event

                                                                                                                                                                                                                event: CalendarEvent;

                                                                                                                                                                                                                  property offset

                                                                                                                                                                                                                  offset: number;

                                                                                                                                                                                                                    property span

                                                                                                                                                                                                                    span: number;

                                                                                                                                                                                                                      property startsBeforeWeek

                                                                                                                                                                                                                      startsBeforeWeek: boolean;

                                                                                                                                                                                                                        interface WeekViewAllDayEventRow

                                                                                                                                                                                                                        interface WeekViewAllDayEventRow {}

                                                                                                                                                                                                                          property id

                                                                                                                                                                                                                          id?: string;

                                                                                                                                                                                                                            property row

                                                                                                                                                                                                                            row: WeekViewAllDayEvent[];

                                                                                                                                                                                                                              interface WeekViewHour

                                                                                                                                                                                                                              interface WeekViewHour {}

                                                                                                                                                                                                                                property segments

                                                                                                                                                                                                                                segments: WeekViewHourSegment[];

                                                                                                                                                                                                                                  interface WeekViewHourColumn

                                                                                                                                                                                                                                  interface WeekViewHourColumn {}

                                                                                                                                                                                                                                    property date

                                                                                                                                                                                                                                    date: Date;

                                                                                                                                                                                                                                      property events

                                                                                                                                                                                                                                      events: WeekViewTimeEvent[];

                                                                                                                                                                                                                                        property hours

                                                                                                                                                                                                                                        hours: WeekViewHour[];

                                                                                                                                                                                                                                          interface WeekViewHourSegment

                                                                                                                                                                                                                                          interface WeekViewHourSegment {}

                                                                                                                                                                                                                                            property cssClass

                                                                                                                                                                                                                                            cssClass?: string;

                                                                                                                                                                                                                                              property date

                                                                                                                                                                                                                                              date: Date;

                                                                                                                                                                                                                                                property displayDate

                                                                                                                                                                                                                                                displayDate: Date;

                                                                                                                                                                                                                                                  property isStart

                                                                                                                                                                                                                                                  isStart: boolean;

                                                                                                                                                                                                                                                    interface WeekViewTimeEvent

                                                                                                                                                                                                                                                    interface WeekViewTimeEvent {}

                                                                                                                                                                                                                                                      property endsAfterDay

                                                                                                                                                                                                                                                      endsAfterDay: boolean;

                                                                                                                                                                                                                                                        property event

                                                                                                                                                                                                                                                        event: CalendarEvent;

                                                                                                                                                                                                                                                          property height

                                                                                                                                                                                                                                                          height: number;

                                                                                                                                                                                                                                                            property left

                                                                                                                                                                                                                                                            left: number;

                                                                                                                                                                                                                                                              property startsBeforeDay

                                                                                                                                                                                                                                                              startsBeforeDay: boolean;

                                                                                                                                                                                                                                                                property top

                                                                                                                                                                                                                                                                top: number;

                                                                                                                                                                                                                                                                  property width

                                                                                                                                                                                                                                                                  width: number;

                                                                                                                                                                                                                                                                    Enums

                                                                                                                                                                                                                                                                    enum DAYS_OF_WEEK

                                                                                                                                                                                                                                                                    enum DAYS_OF_WEEK {
                                                                                                                                                                                                                                                                    SUNDAY = 0,
                                                                                                                                                                                                                                                                    MONDAY = 1,
                                                                                                                                                                                                                                                                    TUESDAY = 2,
                                                                                                                                                                                                                                                                    WEDNESDAY = 3,
                                                                                                                                                                                                                                                                    THURSDAY = 4,
                                                                                                                                                                                                                                                                    FRIDAY = 5,
                                                                                                                                                                                                                                                                    SATURDAY = 6,
                                                                                                                                                                                                                                                                    }

                                                                                                                                                                                                                                                                      member FRIDAY

                                                                                                                                                                                                                                                                      FRIDAY = 5

                                                                                                                                                                                                                                                                        member MONDAY

                                                                                                                                                                                                                                                                        MONDAY = 1

                                                                                                                                                                                                                                                                          member SATURDAY

                                                                                                                                                                                                                                                                          SATURDAY = 6

                                                                                                                                                                                                                                                                            member SUNDAY

                                                                                                                                                                                                                                                                            SUNDAY = 0

                                                                                                                                                                                                                                                                              member THURSDAY

                                                                                                                                                                                                                                                                              THURSDAY = 4

                                                                                                                                                                                                                                                                                member TUESDAY

                                                                                                                                                                                                                                                                                TUESDAY = 2

                                                                                                                                                                                                                                                                                  member WEDNESDAY

                                                                                                                                                                                                                                                                                  WEDNESDAY = 3

                                                                                                                                                                                                                                                                                    enum EventValidationErrorMessage

                                                                                                                                                                                                                                                                                    enum EventValidationErrorMessage {
                                                                                                                                                                                                                                                                                    NotArray = 'Events must be an array',
                                                                                                                                                                                                                                                                                    StartPropertyMissing = 'Event is missing the `start` property',
                                                                                                                                                                                                                                                                                    StartPropertyNotDate = 'Event `start` property should be a javascript date object. Do `new Date(event.start)` to fix it.',
                                                                                                                                                                                                                                                                                    EndPropertyNotDate = 'Event `end` property should be a javascript date object. Do `new Date(event.end)` to fix it.',
                                                                                                                                                                                                                                                                                    EndsBeforeStart = 'Event `start` property occurs after the `end`',
                                                                                                                                                                                                                                                                                    }

                                                                                                                                                                                                                                                                                      member EndPropertyNotDate

                                                                                                                                                                                                                                                                                      EndPropertyNotDate = 'Event `end` property should be a javascript date object. Do `new Date(event.end)` to fix it.'

                                                                                                                                                                                                                                                                                        member EndsBeforeStart

                                                                                                                                                                                                                                                                                        EndsBeforeStart = 'Event `start` property occurs after the `end`'

                                                                                                                                                                                                                                                                                          member NotArray

                                                                                                                                                                                                                                                                                          NotArray = 'Events must be an array'

                                                                                                                                                                                                                                                                                            member StartPropertyMissing

                                                                                                                                                                                                                                                                                            StartPropertyMissing = 'Event is missing the `start` property'

                                                                                                                                                                                                                                                                                              member StartPropertyNotDate

                                                                                                                                                                                                                                                                                              StartPropertyNotDate = 'Event `start` property should be a javascript date object. Do `new Date(event.start)` to fix it.'

                                                                                                                                                                                                                                                                                                Package Files (1)

                                                                                                                                                                                                                                                                                                Dependencies (0)

                                                                                                                                                                                                                                                                                                No dependencies.

                                                                                                                                                                                                                                                                                                Dev Dependencies (23)

                                                                                                                                                                                                                                                                                                Peer Dependencies (0)

                                                                                                                                                                                                                                                                                                No peer dependencies.

                                                                                                                                                                                                                                                                                                Badge

                                                                                                                                                                                                                                                                                                To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                                                                                                                                                You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/calendar-utils.

                                                                                                                                                                                                                                                                                                • Markdown
                                                                                                                                                                                                                                                                                                  [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/calendar-utils)
                                                                                                                                                                                                                                                                                                • HTML
                                                                                                                                                                                                                                                                                                  <a href="https://www.jsdocs.io/package/calendar-utils"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>