From 32e230722b24341ec00ecbfff7f6b467aeb941e5 Mon Sep 17 00:00:00 2001 From: Darragh Mc Kay <darraghmckay@gmail.com> Date: Thu, 31 Mar 2022 13:52:18 +0100 Subject: [PATCH] fix: support custom components with drag and drop and reload components --- .gitignore | 4 ++++ .size-snapshot.json | 22 +++++++++---------- package.json | 14 ++++++------ .../dragAndDrop/EventContainerWrapper.js | 3 +-- src/addons/dragAndDrop/withDragAndDrop.js | 10 +++++++++ 5 files changed, 33 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 94dda071e..ec04d5c01 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,7 @@ node_modules # Mac OS X .DS_Store + +# Storybook + +storybook-static/* diff --git a/.size-snapshot.json b/.size-snapshot.json index 335bd8a15..0ff75fbb6 100644 --- a/.size-snapshot.json +++ b/.size-snapshot.json @@ -24,26 +24,26 @@ } }, "react-big-calendar.js": { - "bundled": 1583435, - "minified": 445376, - "gzipped": 137501 + "bundled": 1583146, + "minified": 445045, + "gzipped": 137434 }, "react-big-calendar.min.js": { - "bundled": 283187, - "minified": 281738, - "gzipped": 88836 + "bundled": 283219, + "minified": 281770, + "gzipped": 88846 }, "react-big-calendar.esm.js": { - "bundled": 199459, - "minified": 93011, - "gzipped": 24119, + "bundled": 199400, + "minified": 93023, + "gzipped": 24120, "treeshaked": { "rollup": { - "code": 66234, + "code": 66246, "import_statements": 1804 }, "webpack": { - "code": 70014 + "code": 70026 } } } diff --git a/package.json b/package.json index c8156dfdc..54f87c6a6 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,14 @@ { - "name": "react-big-calendar", - "version": "0.40.0", + "name": "@noloco/react-big-calendar", + "version": "0.40.2", "description": "Calendar! with events", "author": { - "name": "Jason Quense", - "email": "monastic.panic@gmail.com" + "name": "Noloco", + "email": "eingineering@noloco.io" }, "repository": { "type": "git", - "url": "git+https://github.com/jquense/react-big-calendar.git" + "url": "git+https://github.com/noloco-io/react-big-calendar.git" }, "license": "MIT", "main": "lib/index.js", @@ -129,7 +129,7 @@ "uncontrollable": "^7.2.1" }, "bugs": { - "url": "https://github.com/jquense/react-big-calendar/issues" + "url": "https://github.com/noloco-io/react-big-calendar/issues" }, - "homepage": "https://github.com/jquense/react-big-calendar#readme" + "homepage": "https://github.com/noloco-io/react-big-calendar#readme" } diff --git a/src/addons/dragAndDrop/EventContainerWrapper.js b/src/addons/dragAndDrop/EventContainerWrapper.js index 3e7c04b5b..440988fd2 100644 --- a/src/addons/dragAndDrop/EventContainerWrapper.js +++ b/src/addons/dragAndDrop/EventContainerWrapper.js @@ -8,7 +8,6 @@ import Selection, { } from '../../Selection' import TimeGridEvent from '../../TimeGridEvent' import { dragAccessors, eventTimes, pointInColumn } from './common' -import NoopWrapper from '../../NoopWrapper' class EventContainerWrapper extends React.Component { static propTypes = { @@ -254,7 +253,7 @@ class EventContainerWrapper extends React.Component { className="rbc-addons-dnd-drag-preview" style={{ top, height, width: 100 }} getters={getters} - components={{ ...components, eventWrapper: NoopWrapper }} + components={components} accessors={{ ...accessors, ...dragAccessors }} continuesPrior={startsBeforeDay} continuesAfter={startsAfterDay} diff --git a/src/addons/dragAndDrop/withDragAndDrop.js b/src/addons/dragAndDrop/withDragAndDrop.js index 8dfd8da6b..7d86a05f4 100644 --- a/src/addons/dragAndDrop/withDragAndDrop.js +++ b/src/addons/dragAndDrop/withDragAndDrop.js @@ -50,6 +50,16 @@ export default function withDragAndDrop(Calendar) { this.state = { interacting: false } } + componentDidUpdate(prevProps) { + if (prevProps.components !== this.props.components) { + this.components = mergeComponents(this.props.components, { + eventWrapper: EventWrapper, + eventContainerWrapper: EventContainerWrapper, + weekWrapper: WeekWrapper, + }) + } + } + getDnDContextValue() { return { draggable: {