makula-schedule 2.2.3 → 2.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -62,6 +62,9 @@ var DnDContext = exports["default"] = /*#__PURE__*/_createClass(function DnDCont
62
62
  if (cellUnit !== _default.CellUnit.Hour) {
63
63
  endTime = localeDayjs(new Date(resourceEvents.headerItems[leftIndex].start)).hour(23).minute(59).second(59).format(_default.DATETIME_FORMAT);
64
64
  }
65
+ if (component && component.clearShadowState) {
66
+ component.clearShadowState();
67
+ }
65
68
  return {
66
69
  slotId: resourceEvents.slotId,
67
70
  slotName: resourceEvents.slotName,
@@ -126,6 +129,32 @@ var DnDContext = exports["default"] = /*#__PURE__*/_createClass(function DnDCont
126
129
  if (movingEvent) {
127
130
  movingEvent(schedulerData, slotId, slotName, newStart, newEnd, action, type, item);
128
131
  }
132
+
133
+ // Compute and set drop shadow position
134
+ if (config.snapToGrid && component && component.setShadowState) {
135
+ var shadowStartDayjs = localeDayjs(newStart);
136
+ var shadowEndDayjs = localeDayjs(newEnd);
137
+ var shadowLeftIndex = -1;
138
+ var shadowSpan = 0;
139
+ resourceEvents.headerItems.forEach(function (header, idx) {
140
+ var headerStart = new Date(header.start);
141
+ var headerEnd = new Date(header.end);
142
+ if (headerEnd > shadowStartDayjs.toDate() && headerStart < shadowEndDayjs.toDate()) {
143
+ if (shadowLeftIndex === -1) shadowLeftIndex = idx;
144
+ shadowSpan += 1;
145
+ }
146
+ });
147
+ if (shadowLeftIndex >= 0 && shadowSpan > 0) {
148
+ var shadowLeft = shadowLeftIndex * cellWidth + (shadowLeftIndex > 0 ? 2 : 3);
149
+ var shadowWidth = shadowSpan * cellWidth - (shadowLeftIndex > 0 ? 5 : 6) > 0 ? shadowSpan * cellWidth - (shadowLeftIndex > 0 ? 5 : 6) : 0;
150
+ component.setShadowState({
151
+ left: shadowLeft,
152
+ width: shadowWidth,
153
+ top: 1,
154
+ bgColor: isEvent ? item.bgColor : config.defaultEventBgColor
155
+ });
156
+ }
157
+ }
129
158
  },
130
159
  canDrop: function canDrop(props, monitor) {
131
160
  var schedulerData = props.schedulerData,
@@ -625,6 +625,20 @@ var EventItem = /*#__PURE__*/function (_Component) {
625
625
  return _this2.endResizer = _ref7;
626
626
  }
627
627
  });
628
+ var showOverflowArrows = config.overflowArrowsEnabled !== false;
629
+ var arrowStyle = {
630
+ lineHeight: "".concat(config.eventItemHeight, "px")
631
+ };
632
+ var showLeftArrow = showOverflowArrows && !isStart;
633
+ var showRightArrow = showOverflowArrows && !isEnd;
634
+ var leftArrow = showLeftArrow ? /*#__PURE__*/_react["default"].createElement("span", {
635
+ className: "event-overflow-arrow event-overflow-arrow-left",
636
+ style: arrowStyle
637
+ }, "\u2039") : null;
638
+ var rightArrow = showRightArrow ? /*#__PURE__*/_react["default"].createElement("span", {
639
+ className: "event-overflow-arrow event-overflow-arrow-right",
640
+ style: arrowStyle
641
+ }, "\u203A") : null;
628
642
  var eventItemTemplate = /*#__PURE__*/_react["default"].createElement("div", {
629
643
  className: "".concat(roundCls, " event-item"),
630
644
  key: eventItem.id,
@@ -639,7 +653,7 @@ var EventItem = /*#__PURE__*/function (_Component) {
639
653
  }
640
654
  }, eventTitle));
641
655
  if (eventItemTemplateResolver !== undefined) {
642
- eventItemTemplate = eventItemTemplateResolver(schedulerData, eventItem, bgColor, isStart, isEnd, 'event-item', config.eventItemHeight, undefined);
656
+ eventItemTemplate = eventItemTemplateResolver(schedulerData, eventItem, bgColor, isStart, isEnd, 'event-item', config.eventItemHeight, undefined, showLeftArrow, showRightArrow);
643
657
  }
644
658
  var a = /*#__PURE__*/_react["default"].createElement("a", {
645
659
  className: "timeline-event",
@@ -653,7 +667,7 @@ var EventItem = /*#__PURE__*/function (_Component) {
653
667
  onClick: function onClick() {
654
668
  if (eventItemClick) eventItemClick(schedulerData, eventItem);
655
669
  }
656
- }, eventItemTemplate, startResizeDiv, endResizeDiv);
670
+ }, leftArrow, eventItemTemplate, startResizeDiv, endResizeDiv, rightArrow);
657
671
  var getMousePositionOptionsData = function getMousePositionOptionsData() {
658
672
  var popoverOffsetX = 0;
659
673
  var mousePositionPlacement = '';
@@ -252,6 +252,16 @@ var ResourceEvents = /*#__PURE__*/function (_Component) {
252
252
  }
253
253
  }
254
254
  });
255
+ _defineProperty(_this, "setShadowState", function (shadow) {
256
+ _this.setState({
257
+ shadowState: shadow
258
+ });
259
+ });
260
+ _defineProperty(_this, "clearShadowState", function () {
261
+ _this.setState({
262
+ shadowState: null
263
+ });
264
+ });
255
265
  _defineProperty(_this, "eventContainerRef", function (element) {
256
266
  _this.eventContainer = element;
257
267
  // Also set the drop ref if it exists
@@ -263,7 +273,8 @@ var ResourceEvents = /*#__PURE__*/function (_Component) {
263
273
  _this.state = {
264
274
  isSelecting: false,
265
275
  left: 0,
266
- width: 0
276
+ width: 0,
277
+ shadowState: null
267
278
  };
268
279
  _this.supportTouch = false; // 'ontouchstart' in window;
269
280
  return _this;
@@ -306,7 +317,8 @@ var ResourceEvents = /*#__PURE__*/function (_Component) {
306
317
  var _this$state2 = this.state,
307
318
  isSelecting = _this$state2.isSelecting,
308
319
  left = _this$state2.left,
309
- width = _this$state2.width;
320
+ width = _this$state2.width,
321
+ shadowState = _this$state2.shadowState;
310
322
  var cellWidth = schedulerData.getContentCellWidth();
311
323
  var cellMaxEvents = schedulerData.getCellMaxEvents();
312
324
  var rowWidth = schedulerData.getContentTableWidth();
@@ -369,6 +381,17 @@ var ResourceEvents = /*#__PURE__*/function (_Component) {
369
381
  } else {
370
382
  _width = evt.span * cellWidth - (index > 0 ? 5 : 6) > 0 ? evt.span * cellWidth - (index > 0 ? 5 : 6) : 0;
371
383
  }
384
+ if (config.overflowArrowsEnabled !== false) {
385
+ if (!isStart) {
386
+ var originalLeft = _left;
387
+ _left = index * cellWidth;
388
+ _width += originalLeft - _left;
389
+ }
390
+ if (!isEnd) {
391
+ var rightEdge = (index + evt.span) * cellWidth;
392
+ _width = rightEdge - _left;
393
+ }
394
+ }
372
395
  var top = marginTop + idx * config.eventItemLineHeight;
373
396
  var eventItem = /*#__PURE__*/_react["default"].createElement(_EventItem["default"], _extends({}, _this2.props, {
374
397
  key: "".concat(evt.eventItem.id, "_").concat(headerItem.time),
@@ -418,13 +441,23 @@ var ResourceEvents = /*#__PURE__*/function (_Component) {
418
441
  }
419
442
  }
420
443
  });
444
+ var dropShadow = shadowState && config.snapToGrid ? /*#__PURE__*/_react["default"].createElement("div", {
445
+ className: "event-drop-shadow",
446
+ style: {
447
+ left: shadowState.left,
448
+ width: shadowState.width,
449
+ top: shadowState.top,
450
+ height: config.eventItemHeight,
451
+ backgroundColor: shadowState.bgColor || config.defaultEventBgColor
452
+ }
453
+ }) : null;
421
454
  var eventContainer = /*#__PURE__*/_react["default"].createElement("div", {
422
455
  ref: this.eventContainerRef,
423
456
  className: "event-container",
424
457
  style: {
425
458
  height: resourceEvents.rowHeight
426
459
  }
427
- }, selectedArea, eventList);
460
+ }, selectedArea, dropShadow, eventList);
428
461
  return /*#__PURE__*/_react["default"].createElement("tr", null, /*#__PURE__*/_react["default"].createElement("td", {
429
462
  style: {
430
463
  width: rowWidth
@@ -498,6 +531,11 @@ var ResourceEventsWithDnD = function ResourceEventsWithDnD(props) {
498
531
  isOver = _useDrop2$.isOver,
499
532
  canDrop = _useDrop2$.canDrop,
500
533
  dropRef = _useDrop2[1];
534
+ (0, _react.useEffect)(function () {
535
+ if (!isOver && componentRef.current) {
536
+ componentRef.current.clearShadowState();
537
+ }
538
+ }, [isOver]);
501
539
  return /*#__PURE__*/_react["default"].createElement(ResourceEvents, _extends({
502
540
  ref: componentRef
503
541
  }, props, {
@@ -80,6 +80,7 @@ var _default = exports["default"] = {
80
80
  relativeMove: true,
81
81
  defaultExpanded: true,
82
82
  dragAndDropEnabled: true,
83
+ overflowArrowsEnabled: true,
83
84
  snapToGrid: false,
84
85
  schedulerHeaderEventsFuncsTimeoutMs: 100,
85
86
  resourceName: 'Resource Name',
package/dist/index.d.ts CHANGED
@@ -24,7 +24,9 @@ export interface SchedulerProps<EventType extends EventItem = EventItem> {
24
24
  isEnd: boolean,
25
25
  mustAddCssClass: string,
26
26
  mustBeHeight: number,
27
- agendaMaxEventWidth: number
27
+ agendaMaxEventWidth: number,
28
+ showLeftArrow?: boolean,
29
+ showRightArrow?: boolean
28
30
  ) => void;
29
31
  CustomEventPopover?: (
30
32
  schedulerData: SchedulerData<EventType>,
@@ -404,6 +406,7 @@ export interface SchedulerDataConfig {
404
406
  relativeMove?: boolean;
405
407
  defaultExpanded?: boolean;
406
408
  dragAndDropEnabled?: boolean;
409
+ overflowArrowsEnabled?: boolean;
407
410
  snapToGrid?: boolean;
408
411
  schedulerHeaderEventsFuncsTimeoutMs?: number;
409
412
  resourceName?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "makula-schedule",
3
- "version": "2.2.3",
3
+ "version": "2.2.5",
4
4
  "description": "React Big Schedule is a powerful and intuitive scheduler and resource planning solution built with React. Seamlessly integrate this modern browser-compatible component into your applications to effectively manage time, appointments, and resources. With drag-and-drop functionality, interactive UI, and granular views, react-big-schedule empowers users to effortlessly schedule and allocate resources with precision. Enhance productivity and streamline your workflow with this React-based solution, designed to optimize time management and simplify calendar-based operations. Perfect for applications requiring advanced scheduling capabilities, react-big-schedule offers a seamless and intuitive experience for managing appointments, resource allocation, and time slots. Unlock the potential of your React projects with react-big-schedule and revolutionize the way you handle scheduling and resource planning. It is the updated version of react-big-scheduler",
5
5
  "keywords": [
6
6
  "react-big-schedule",