Skip to content

Commit 175f82e

Browse files
committed
Build
1 parent 54b2a48 commit 175f82e

19 files changed

+434
-379
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ Expects either a vanilla JS array or an immutable JS array, consisting of object
7777
canMove: true,
7878
canResize: false,
7979
canChangeGroup: false,
80-
className: 'weekend'
80+
className: 'weekend',
81+
itemProps: {
82+
'data-custom-attribute': 'Random content'
83+
}
8184
}
8285
```
8386

build/dist/react-calendar-timeline.js

Lines changed: 201 additions & 178 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/dist/react-calendar-timeline.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/dist/react-calendar-timeline.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/dist/react-calendar-timeline.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@
4848
end: endValue,
4949
canMove: startValue > new Date().getTime(),
5050
canResize: endValue > new Date().getTime(),
51-
className: (moment(startDate).day() === 6 || moment(startDate).day() === 0) ? 'item-weekend' : ''
51+
className: (moment(startDate).day() === 6 || moment(startDate).day() === 0) ? 'item-weekend' : '',
52+
itemProps: {
53+
'data-tip': faker.hacker.phrase()
54+
}
5255
})
5356
}
5457

modules/lib/Timeline.js

Lines changed: 99 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ var ReactCalendarTimeline = function (_Component) {
8484
function ReactCalendarTimeline(props) {
8585
_classCallCheck(this, ReactCalendarTimeline);
8686

87-
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(ReactCalendarTimeline).call(this, props));
87+
var _this = _possibleConstructorReturn(this, (ReactCalendarTimeline.__proto__ || Object.getPrototypeOf(ReactCalendarTimeline)).call(this, props));
8888

8989
_initialiseProps.call(_this);
9090

@@ -131,13 +131,11 @@ var ReactCalendarTimeline = function (_Component) {
131131
resizingItem: null
132132
};
133133

134-
var _this$stackItems = _this.stackItems(props.items, props.groups, _this.state.canvasTimeStart, _this.state.visibleTimeStart, _this.state.visibleTimeEnd, _this.state.width);
135-
136-
var dimensionItems = _this$stackItems.dimensionItems;
137-
var height = _this$stackItems.height;
138-
var groupHeights = _this$stackItems.groupHeights;
139-
var groupTops = _this$stackItems.groupTops;
140-
134+
var _this$stackItems = _this.stackItems(props.items, props.groups, _this.state.canvasTimeStart, _this.state.visibleTimeStart, _this.state.visibleTimeEnd, _this.state.width),
135+
dimensionItems = _this$stackItems.dimensionItems,
136+
height = _this$stackItems.height,
137+
groupHeights = _this$stackItems.groupHeights,
138+
groupTops = _this$stackItems.groupTops;
141139

142140
_this.state.dimensionItems = dimensionItems;
143141
_this.state.height = height;
@@ -181,13 +179,11 @@ var ReactCalendarTimeline = function (_Component) {
181179
// FIXME currently when the component creates a scroll the scrollbar is not used in the initial width calculation, resizing fixes this
182180
var width = this.refs.container.clientWidth - this.props.sidebarWidth;
183181

184-
var _stackItems = this.stackItems(this.props.items, this.props.groups, this.state.canvasTimeStart, this.state.visibleTimeStart, this.state.visibleTimeEnd, width);
185-
186-
var dimensionItems = _stackItems.dimensionItems;
187-
var height = _stackItems.height;
188-
var groupHeights = _stackItems.groupHeights;
189-
var groupTops = _stackItems.groupTops;
190-
182+
var _stackItems = this.stackItems(this.props.items, this.props.groups, this.state.canvasTimeStart, this.state.visibleTimeStart, this.state.visibleTimeEnd, width),
183+
dimensionItems = _stackItems.dimensionItems,
184+
height = _stackItems.height,
185+
groupHeights = _stackItems.groupHeights,
186+
groupTops = _stackItems.groupTops;
191187

192188
this.setState({
193189
width: width,
@@ -202,10 +198,10 @@ var ReactCalendarTimeline = function (_Component) {
202198
}, {
203199
key: 'componentWillReceiveProps',
204200
value: function componentWillReceiveProps(nextProps) {
205-
var visibleTimeStart = nextProps.visibleTimeStart;
206-
var visibleTimeEnd = nextProps.visibleTimeEnd;
207-
var items = nextProps.items;
208-
var groups = nextProps.groups;
201+
var visibleTimeStart = nextProps.visibleTimeStart,
202+
visibleTimeEnd = nextProps.visibleTimeEnd,
203+
items = nextProps.items,
204+
groups = nextProps.groups;
209205

210206

211207
if (visibleTimeStart && visibleTimeEnd) {
@@ -219,19 +215,17 @@ var ReactCalendarTimeline = function (_Component) {
219215
}, {
220216
key: 'updateDimensions',
221217
value: function updateDimensions(items, groups) {
222-
var _state = this.state;
223-
var canvasTimeStart = _state.canvasTimeStart;
224-
var visibleTimeStart = _state.visibleTimeStart;
225-
var visibleTimeEnd = _state.visibleTimeEnd;
226-
var width = _state.width;
227-
228-
var _stackItems2 = this.stackItems(items, groups, canvasTimeStart, visibleTimeStart, visibleTimeEnd, width);
229-
230-
var dimensionItems = _stackItems2.dimensionItems;
231-
var height = _stackItems2.height;
232-
var groupHeights = _stackItems2.groupHeights;
233-
var groupTops = _stackItems2.groupTops;
234-
218+
var _state = this.state,
219+
canvasTimeStart = _state.canvasTimeStart,
220+
visibleTimeStart = _state.visibleTimeStart,
221+
visibleTimeEnd = _state.visibleTimeEnd,
222+
width = _state.width;
223+
224+
var _stackItems2 = this.stackItems(items, groups, canvasTimeStart, visibleTimeStart, visibleTimeEnd, width),
225+
dimensionItems = _stackItems2.dimensionItems,
226+
height = _stackItems2.height,
227+
groupHeights = _stackItems2.groupHeights,
228+
groupTops = _stackItems2.groupTops;
235229

236230
this.setState({ dimensionItems: dimensionItems, height: height, groupHeights: groupHeights, groupTops: groupTops });
237231
}
@@ -277,12 +271,11 @@ var ReactCalendarTimeline = function (_Component) {
277271
if (resetCanvas || forceUpdateDimensions) {
278272
var canvasTimeStart = newState.canvasTimeStart ? newState.canvasTimeStart : oldCanvasTimeStart;
279273

280-
var _stackItems3 = this.stackItems(items, groups, canvasTimeStart, visibleTimeStart, visibleTimeEnd, this.state.width);
281-
282-
var dimensionItems = _stackItems3.dimensionItems;
283-
var height = _stackItems3.height;
284-
var groupHeights = _stackItems3.groupHeights;
285-
var groupTops = _stackItems3.groupTops;
274+
var _stackItems3 = this.stackItems(items, groups, canvasTimeStart, visibleTimeStart, visibleTimeEnd, this.state.width),
275+
dimensionItems = _stackItems3.dimensionItems,
276+
height = _stackItems3.height,
277+
groupHeights = _stackItems3.groupHeights,
278+
groupTops = _stackItems3.groupTops;
286279

287280
newState.dimensionItems = dimensionItems;
288281
newState.height = height;
@@ -309,10 +302,10 @@ var ReactCalendarTimeline = function (_Component) {
309302
}, {
310303
key: 'changeZoom',
311304
value: function changeZoom(scale) {
312-
var offset = arguments.length <= 1 || arguments[1] === undefined ? 0.5 : arguments[1];
313-
var _props = this.props;
314-
var minZoom = _props.minZoom;
315-
var maxZoom = _props.maxZoom;
305+
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.5;
306+
var _props = this.props,
307+
minZoom = _props.minZoom,
308+
maxZoom = _props.maxZoom;
316309

317310
var oldZoom = this.state.visibleTimeEnd - this.state.visibleTimeStart;
318311
var newZoom = Math.min(Math.max(Math.round(oldZoom * scale), minZoom), maxZoom); // min 1 min, max 20 years
@@ -323,13 +316,13 @@ var ReactCalendarTimeline = function (_Component) {
323316
}, {
324317
key: 'rowAndTimeFromEvent',
325318
value: function rowAndTimeFromEvent(e) {
326-
var _props2 = this.props;
327-
var lineHeight = _props2.lineHeight;
328-
var dragSnap = _props2.dragSnap;
329-
var _state2 = this.state;
330-
var width = _state2.width;
331-
var visibleTimeStart = _state2.visibleTimeStart;
332-
var visibleTimeEnd = _state2.visibleTimeEnd;
319+
var _props2 = this.props,
320+
lineHeight = _props2.lineHeight,
321+
dragSnap = _props2.dragSnap;
322+
var _state2 = this.state,
323+
width = _state2.width,
324+
visibleTimeStart = _state2.visibleTimeStart,
325+
visibleTimeEnd = _state2.visibleTimeEnd;
333326

334327

335328
var parentPosition = (0, _utils.getParentPosition)(e.currentTarget);
@@ -402,6 +395,7 @@ var ReactCalendarTimeline = function (_Component) {
402395
canMove: this.props.canMove,
403396
canResize: this.props.canResize,
404397
useResizeHandle: this.props.useResizeHandle,
398+
canSelect: this.props.canSelect,
405399
moveResizeValidator: this.props.moveResizeValidator,
406400
topOffset: this.state.topOffset,
407401
itemSelect: this.selectItem,
@@ -466,20 +460,20 @@ var ReactCalendarTimeline = function (_Component) {
466460
}, {
467461
key: 'stackItems',
468462
value: function stackItems(items, groups, canvasTimeStart, visibleTimeStart, visibleTimeEnd, width) {
469-
var _props3 = this.props;
470-
var keys = _props3.keys;
471-
var dragSnap = _props3.dragSnap;
472-
var lineHeight = _props3.lineHeight;
473-
var headerLabelGroupHeight = _props3.headerLabelGroupHeight;
474-
var headerLabelHeight = _props3.headerLabelHeight;
475-
var stackItems = _props3.stackItems;
476-
var itemHeightRatio = _props3.itemHeightRatio;
477-
var _state3 = this.state;
478-
var draggingItem = _state3.draggingItem;
479-
var dragTime = _state3.dragTime;
480-
var resizingItem = _state3.resizingItem;
481-
var resizeEnd = _state3.resizeEnd;
482-
var newGroupOrder = _state3.newGroupOrder;
463+
var _props3 = this.props,
464+
keys = _props3.keys,
465+
dragSnap = _props3.dragSnap,
466+
lineHeight = _props3.lineHeight,
467+
headerLabelGroupHeight = _props3.headerLabelGroupHeight,
468+
headerLabelHeight = _props3.headerLabelHeight,
469+
stackItems = _props3.stackItems,
470+
itemHeightRatio = _props3.itemHeightRatio;
471+
var _state3 = this.state,
472+
draggingItem = _state3.draggingItem,
473+
dragTime = _state3.dragTime,
474+
resizingItem = _state3.resizingItem,
475+
resizeEnd = _state3.resizeEnd,
476+
newGroupOrder = _state3.newGroupOrder;
483477

484478
var zoom = visibleTimeEnd - visibleTimeStart;
485479
var canvasTimeEnd = canvasTimeStart + zoom * 3;
@@ -498,38 +492,36 @@ var ReactCalendarTimeline = function (_Component) {
498492

499493
var stackingMethod = stackItems ? _utils.stack : _utils.nostack;
500494

501-
var _stackingMethod = stackingMethod(dimensionItems, groupOrders, lineHeight, headerHeight);
502-
503-
var height = _stackingMethod.height;
504-
var groupHeights = _stackingMethod.groupHeights;
505-
var groupTops = _stackingMethod.groupTops;
506-
495+
var _stackingMethod = stackingMethod(dimensionItems, groupOrders, lineHeight, headerHeight),
496+
height = _stackingMethod.height,
497+
groupHeights = _stackingMethod.groupHeights,
498+
groupTops = _stackingMethod.groupTops;
507499

508500
return { dimensionItems: dimensionItems, height: height, groupHeights: groupHeights, groupTops: groupTops };
509501
}
510502
}, {
511503
key: 'render',
512504
value: function render() {
513-
var _props4 = this.props;
514-
var items = _props4.items;
515-
var groups = _props4.groups;
516-
var headerLabelGroupHeight = _props4.headerLabelGroupHeight;
517-
var headerLabelHeight = _props4.headerLabelHeight;
518-
var sidebarWidth = _props4.sidebarWidth;
519-
var timeSteps = _props4.timeSteps;
520-
var _state4 = this.state;
521-
var draggingItem = _state4.draggingItem;
522-
var resizingItem = _state4.resizingItem;
523-
var isDragging = _state4.isDragging;
524-
var width = _state4.width;
525-
var visibleTimeStart = _state4.visibleTimeStart;
526-
var visibleTimeEnd = _state4.visibleTimeEnd;
527-
var canvasTimeStart = _state4.canvasTimeStart;
528-
var _state5 = this.state;
529-
var dimensionItems = _state5.dimensionItems;
530-
var height = _state5.height;
531-
var groupHeights = _state5.groupHeights;
532-
var groupTops = _state5.groupTops;
505+
var _props4 = this.props,
506+
items = _props4.items,
507+
groups = _props4.groups,
508+
headerLabelGroupHeight = _props4.headerLabelGroupHeight,
509+
headerLabelHeight = _props4.headerLabelHeight,
510+
sidebarWidth = _props4.sidebarWidth,
511+
timeSteps = _props4.timeSteps;
512+
var _state4 = this.state,
513+
draggingItem = _state4.draggingItem,
514+
resizingItem = _state4.resizingItem,
515+
isDragging = _state4.isDragging,
516+
width = _state4.width,
517+
visibleTimeStart = _state4.visibleTimeStart,
518+
visibleTimeEnd = _state4.visibleTimeEnd,
519+
canvasTimeStart = _state4.canvasTimeStart;
520+
var _state5 = this.state,
521+
dimensionItems = _state5.dimensionItems,
522+
height = _state5.height,
523+
groupHeights = _state5.groupHeights,
524+
groupTops = _state5.groupTops;
533525

534526
var zoom = visibleTimeEnd - visibleTimeStart;
535527
var canvasTimeEnd = canvasTimeStart + zoom * 3;
@@ -786,12 +778,10 @@ var _initialiseProps = function _initialiseProps() {
786778
if (_this3.state.selectedItem) {
787779
_this3.selectItem(null);
788780
} else if (_this3.props.onCanvasClick) {
789-
var _rowAndTimeFromEvent = _this3.rowAndTimeFromEvent(e);
790-
791-
var _rowAndTimeFromEvent2 = _slicedToArray(_rowAndTimeFromEvent, 2);
792-
793-
var row = _rowAndTimeFromEvent2[0];
794-
var time = _rowAndTimeFromEvent2[1];
781+
var _rowAndTimeFromEvent = _this3.rowAndTimeFromEvent(e),
782+
_rowAndTimeFromEvent2 = _slicedToArray(_rowAndTimeFromEvent, 2),
783+
row = _rowAndTimeFromEvent2[0],
784+
time = _rowAndTimeFromEvent2[1];
795785

796786
if (row >= 0 && row < _this3.props.groups.length) {
797787
var groupId = (0, _utils._get)(_this3.props.groups[row], _this3.props.keys.groupIdKey);
@@ -837,9 +827,9 @@ var _initialiseProps = function _initialiseProps() {
837827
this.handleMouseDown = function (e) {
838828
var topOffset = _this3.state.topOffset;
839829
var pageY = e.pageY;
840-
var _props5 = _this3.props;
841-
var headerLabelGroupHeight = _props5.headerLabelGroupHeight;
842-
var headerLabelHeight = _props5.headerLabelHeight;
830+
var _props5 = _this3.props,
831+
headerLabelGroupHeight = _props5.headerLabelGroupHeight,
832+
headerLabelHeight = _props5.headerLabelHeight;
843833

844834
var headerHeight = headerLabelGroupHeight + headerLabelHeight;
845835

@@ -860,19 +850,19 @@ var _initialiseProps = function _initialiseProps() {
860850
};
861851

862852
this.handleDoubleClick = function (e) {
863-
var _state6 = _this3.state;
864-
var canvasTimeStart = _state6.canvasTimeStart;
865-
var width = _state6.width;
866-
var visibleTimeStart = _state6.visibleTimeStart;
867-
var visibleTimeEnd = _state6.visibleTimeEnd;
868-
var groupTops = _state6.groupTops;
869-
var topOffset = _state6.topOffset;
853+
var _state6 = _this3.state,
854+
canvasTimeStart = _state6.canvasTimeStart,
855+
width = _state6.width,
856+
visibleTimeStart = _state6.visibleTimeStart,
857+
visibleTimeEnd = _state6.visibleTimeEnd,
858+
groupTops = _state6.groupTops,
859+
topOffset = _state6.topOffset;
870860

871861
var zoom = visibleTimeEnd - visibleTimeStart;
872862
var canvasTimeEnd = canvasTimeStart + zoom * 3;
873863
var canvasWidth = width * 3;
874-
var pageX = e.pageX;
875-
var pageY = e.pageY;
864+
var pageX = e.pageX,
865+
pageY = e.pageY;
876866

877867
var ratio = (canvasTimeEnd - canvasTimeStart) / canvasWidth;
878868
var boundingRect = _this3.refs.scrollComponent.getBoundingClientRect();
@@ -941,6 +931,7 @@ ReactCalendarTimeline.propTypes = {
941931
canMove: _react2.default.PropTypes.bool,
942932
canResize: _react2.default.PropTypes.bool,
943933
useResizeHandle: _react2.default.PropTypes.bool,
934+
canSelect: _react2.default.PropTypes.bool,
944935

945936
stackItems: _react2.default.PropTypes.bool,
946937

@@ -995,6 +986,7 @@ ReactCalendarTimeline.defaultProps = {
995986
canMove: true,
996987
canResize: true,
997988
useResizeHandle: false,
989+
canSelect: true,
998990

999991
stackItems: false,
1000992

0 commit comments

Comments
 (0)