Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
  dist
  package.json
  README.md
Size: Mime:
  README.md

lib-calendar

The calendar component used across Doodle frontends.

Publish

Publish via Github Releases using tagflow tag conventions.

  • Create a release with a release tag on Github Releases tab with the prefix pub e.g. pub.[release_number].
  • Add the release tag in the title with a short title for the new release.
  • Please describe what changes are in the release in the description section and link the relevant JIRA ticket/s.

Development

Create a link for @doodle/calendar

yarn install
yarn build
yarn link

Use the link in your project

yarn link @doodle/calendar

Playground

To run calendar playground:

yarn play

Fix for linking

Include the following line in resolve.alias in webpack.config.js in your consuming project. Otherwise, react may get included twice in your local build and things will break. (react is coming as part of the storybook dependencies)

react: path.resolve(__dirname, '../node_modules', 'react')

The equivalent fix for jest.config.js is...

moduleNameMapper: {
  '^react$': '<rootDir>/node_modules/react/index.js',
},

Resolutions

  1. js-yaml: the latest version of babel-plugin-inline-react-svg (1.1.1) indirectly requires an outdated version of js-yaml that contains a critical security vulnerability: https://www.npmjs.com/advisories/813

Library used in projects

Projects currently using lib-calendar.

These project versions are found on a branch which is separate from master in the library so as not to cause conflicts between projects.

Note: this is still WIP. Once the branch is in place, its name will be added to this section

These project versions are found on master.

Library Documentation

Settings and layout

Props Type Default Value Description
culture String "en" A culture code in ISO 639-1 standard for the calendar.
language String "en" -
step Number 30 Number that defines how many minutes are in one table cell.
timeslots Number 2 Number that defines how many cells are between time gutter hours.
slotDuration Number 1000 * 60 (1min) Slot duration in milliseconds e.g. meetme duration option.
errorMessage String 'Sorry, error occurred. Please reload the page and try again.' String with error message.

Date data

Props Type Default Value Description
date Date Date.now() The current date value of the calendar. Determines the visible view range.
scrollToTime Date null Determines how far down the scroll pane is initially scrolled down.
minNotice Date null Minimal border-date of booking.
maxHorizon Date null Top border-date of booking.
min Date - Start hour of calendar.
max Date - End hour of calendar.

Styles, messages & formats

Props Type Default Value Description
messages Object messages: { allDay: 'all day' } String array of messages in user locale language.
style Object {} Custom styles for calendar.
format Object timeGutterFormat, timeHoverFormat timeGutterFormatGenericCalendar: 'h:MM A', timeGutterFormat: 'h A', timeHoverFormat: 'h:MM A',

Boolean Props

Props Type Default Value Description
clickSelection Boolean false Allows mouse click selection over ranges of dates/times.
withDragAndDrop Boolean false A flag if view drag and drop availability is enabled.
withResizing Boolean false A flag if view resizing availability is enabled.
isHeaderDatesShow Boolean true A flag to render dates in calendar header or not.
dragSelection Boolean/String false Allows mouse selection over ranges of dates/times.
isGenericCalendarMode Boolean false A flag to render generic calendar.
viewChangeEnabled Boolean true A flag if view changing availability is enabled. Note: currently only week view is supported

Callbacks

Props Type Default Value Description
onScroll Function - A callback fired when the user scrolls inside the calendar.
handleWeekChange ({ start, end }) Function - A callback used for navigation in the calendar.
handleDragSelection Function - A callback fired when user selects a slot by dragging.
isAllowedTime Function - A callback fired to check the availability of slot creation. This works on hover.
handleTimeslotExclusion Function - A callback which returns a boolean value. If the value is true, the time is available for the creation of slots. This is used for choosing timeslot styles. Note: The calendar already excludes timeslots that are already in past.
logError Function - A callback used for error logging.
onEventDrop ({ event, start, end, allDay }) Function - A callback fired when draggable events are moved to another place.
onEventResize(type, { event, start, end, allDay }) Function - A callback fired when resizable events are being resized.
onInteraction(ongoingInteraction, interactionDataObject) Function - A callback called during interaction. Only applies to dragging (interactionDataObject.action = 'move') or resizing (interactionDataObject.action = 'resize').

To show slots

Props Type Default Value Description
startAccessor Function event => new Date (event.start) The start date/time of the event. Must resolve to a JavaScript Date object.
endAccessor Function event => new Date (event.end) The end date/time of the event. Must resolve to a JavaScript Date object. Note: this prop should be used to position event that ends at midnight properly at the end of the previous day.
allDayAccessor Function event => event.allday An event property name that determines whether the event should be considered all-day event, ignore its time and place the event-slot inside 'rbc-allday-cell'.
draggableAccessor String null An event property name that defines if event is draggable or not.
resizableAccessor String null An event property name that defines if event is resizable or not.
data * Array [] An array of event objects to display in the calendar.

* data passed as a prop (minimum properties required for an event are start and end}

 {
   start: 'Sun Mar 30 2020 01:00:00 GMT+0300 (Moscow Standard Time)',
   end: 'Sun Mar 30 2020 02:00:00 GMT+0300 (Moscow Standard Time)',
 },

Components

Here, there is the ability to customise how different sections of the calendar render by providing custom Components.

components: {
 event: () => <Event />,
 eventWrapper: () => <EventWrapper />,
 dayWrapper:() => <DayWrapper />, // not used in doodle projects
 dateCellWrapper: () => <DateCellWrapper />,
 optionsToolbar: () => <OptionsToolbar />, // not used in doodle projects
 toolbar: () => <Toolbar />,
}

event

Defines how Event should look.

If a custom design for an event is needed:

  • Create event component
  • Pass function to components prop. Function returns event component.
components={
{ event: elProps => <CustomEvent eventProp={elProps.event} />}
}

eventWrapper

E.g. The Meetme projects differs between a slot and an event e.g. slot should take 100% width while the event could be positioned on the lower layer - z-index: 0.

dateCellWrapper

E.g. Add a title or functionality for date cell.

toolbar

Defines how the toolbar should look.


Properties that should be defined before calendar mounting

Props Type Default Value Description
clickSelection Boolean false Allows mouse click selection over ranges of dates/times.
withDragAndDrop Boolean false A flag if view drag and drop availability is enabled.
isHeaderDatesShow Boolean true A flag to render dates in calendar header or not.
isGenericCalendarMode Boolean false A flag to render generic calendar.