Repository URL to install this package:
|
Version:
3.0.0-rc.2 ▾
|
| dist |
| package.json |
| README.md |
The calendar component used across Doodle frontends.
Publish via Github Releases using tagflow tag conventions.
pub e.g. pub.[release_number].Create a link for @doodle/calendar
yarn install
yarn build
yarn link
Use the link in your project
yarn link @doodle/calendar
To run calendar playground:
yarn play
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',
},
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/813Projects 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.
| 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. |
| 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. |
| 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', |
| 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 |
| 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'). |
| 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)', },
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 />, }
eventDefines how Event should look.
If a custom design for an event is needed:
components prop. Function returns event component.components={ { event: elProps => <CustomEvent eventProp={elProps.event} />} }
eventWrapperE.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.
dateCellWrapperE.g. Add a title or functionality for date cell.
toolbarDefines how the toolbar should look.
| 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. |