Skip to content

Commit

Permalink
fix: support custom components with drag and drop and reload components
Browse files Browse the repository at this point in the history
  • Loading branch information
darraghmckay committed Mar 31, 2022
1 parent abe167e commit 32e2307
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 20 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ node_modules

# Mac OS X
.DS_Store

# Storybook

storybook-static/*
22 changes: 11 additions & 11 deletions .size-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]"
"name": "Noloco",
"email": "[email protected]"
},
"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",
Expand Down Expand Up @@ -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"
}
3 changes: 1 addition & 2 deletions src/addons/dragAndDrop/EventContainerWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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}
Expand Down
10 changes: 10 additions & 0 deletions src/addons/dragAndDrop/withDragAndDrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 32e2307

Please sign in to comment.