makula-schedule 2.0.0 → 2.1.0

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.
@@ -159,19 +159,32 @@ var EventItem = /*#__PURE__*/function (_Component) {
159
159
  leftIndex = _this$props3.leftIndex,
160
160
  rightIndex = _this$props3.rightIndex,
161
161
  schedulerData = _this$props3.schedulerData;
162
+ var config = schedulerData.config;
162
163
  var cellWidth = schedulerData.getContentCellWidth();
163
164
  var offset = leftIndex > 0 ? 5 : 6;
164
165
  var minWidth = cellWidth - offset;
165
166
  var maxWidth = rightIndex * cellWidth - offset;
166
167
  var startX = _this.state.startX;
167
- var newLeft = left + clientX - startX;
168
- var newWidth = width + startX - clientX;
169
- if (newWidth < minWidth) {
170
- newWidth = minWidth;
171
- newLeft = (rightIndex - 1) * cellWidth + (rightIndex - 1 > 0 ? 2 : 3);
172
- } else if (newWidth > maxWidth) {
173
- newWidth = maxWidth;
174
- newLeft = 3;
168
+ var newLeft;
169
+ var newWidth;
170
+ if (config.snapToGrid) {
171
+ var deltaX = clientX - startX;
172
+ var snappedCells = Math.round(deltaX / cellWidth);
173
+ var newLeftIndex = leftIndex + snappedCells;
174
+ var clampedLeftIndex = Math.max(0, Math.min(newLeftIndex, rightIndex - 1));
175
+ var clampedOffset = clampedLeftIndex > 0 ? 5 : 6;
176
+ newLeft = clampedLeftIndex * cellWidth + (clampedLeftIndex > 0 ? 2 : 3);
177
+ newWidth = (rightIndex - clampedLeftIndex) * cellWidth - clampedOffset;
178
+ } else {
179
+ newLeft = left + clientX - startX;
180
+ newWidth = width + startX - clientX;
181
+ if (newWidth < minWidth) {
182
+ newWidth = minWidth;
183
+ newLeft = (rightIndex - 1) * cellWidth + (rightIndex - 1 > 0 ? 2 : 3);
184
+ } else if (newWidth > maxWidth) {
185
+ newWidth = maxWidth;
186
+ newLeft = 3;
187
+ }
175
188
  }
176
189
  _this.setState({
177
190
  left: newLeft,
@@ -321,15 +334,26 @@ var EventItem = /*#__PURE__*/function (_Component) {
321
334
  var _this$props6 = _this.props,
322
335
  width = _this$props6.width,
323
336
  leftIndex = _this$props6.leftIndex,
337
+ rightIndex = _this$props6.rightIndex,
324
338
  schedulerData = _this$props6.schedulerData;
325
- var headers = schedulerData.headers;
339
+ var headers = schedulerData.headers,
340
+ config = schedulerData.config;
326
341
  var cellWidth = schedulerData.getContentCellWidth();
327
342
  var offset = leftIndex > 0 ? 5 : 6;
328
343
  var minWidth = cellWidth - offset;
329
344
  var maxWidth = (headers.length - leftIndex) * cellWidth - offset;
330
345
  var endX = _this.state.endX;
331
- var newWidth = width + clientX - endX;
332
- if (newWidth < minWidth) newWidth = minWidth;else if (newWidth > maxWidth) newWidth = maxWidth;
346
+ var newWidth;
347
+ if (config.snapToGrid) {
348
+ var deltaX = clientX - endX;
349
+ var snappedCells = Math.round(deltaX / cellWidth);
350
+ var currentSpan = rightIndex - leftIndex;
351
+ var newSpan = Math.max(1, Math.min(currentSpan + snappedCells, headers.length - leftIndex));
352
+ newWidth = newSpan * cellWidth - offset;
353
+ } else {
354
+ newWidth = width + clientX - endX;
355
+ if (newWidth < minWidth) newWidth = minWidth;else if (newWidth > maxWidth) newWidth = maxWidth;
356
+ }
333
357
  _this.setState({
334
358
  width: newWidth
335
359
  });
@@ -48,10 +48,10 @@ var SchedulerData = exports["default"] = /*#__PURE__*/function () {
48
48
  this.schedulerHeaderHeight = 0;
49
49
  this._shouldReloadViewType = false;
50
50
  this.calendarPopoverLocale = undefined;
51
- _dayjs["default"].extend(_isoWeek["default"]);
52
51
  _dayjs["default"].extend(_quarterOfYear["default"]);
53
52
  _dayjs["default"].extend(_weekday["default"]);
54
53
  _dayjs["default"].extend(_utc["default"]);
54
+ _dayjs["default"].extend(_isoWeek["default"]);
55
55
  this.localeDayjs = _dayjs["default"];
56
56
  this.config = newConfig === undefined ? _scheduler["default"] : _objectSpread(_objectSpread({}, _scheduler["default"]), newConfig);
57
57
  this._updateLabelsFromI18n();
@@ -1003,7 +1003,7 @@ var SchedulerData = exports["default"] = /*#__PURE__*/function () {
1003
1003
  if (this.showAgenda) return 1;
1004
1004
  var timeBetween = function timeBetween(date1, date2, timeIn) {
1005
1005
  if (timeIn === 'days' || timeIn === 'day') {
1006
- if (date1.getDate() === date2.getDate() && date1.getMonth() === date2.getMonth()) {
1006
+ if (date1.getDate() === date2.getDate() && date1.getMonth() === date2.getMonth() && date1.getFullYear() === date2.getFullYear()) {
1007
1007
  return 1;
1008
1008
  }
1009
1009
  }
@@ -1049,6 +1049,8 @@ var SchedulerData = exports["default"] = /*#__PURE__*/function () {
1049
1049
  } else if (this.viewType === _default.ViewType.Week || this.viewType === _default.ViewType.Month || this.viewType === _default.ViewType.Quarter || this.viewType === _default.ViewType.Year) {
1050
1050
  var startDate = windowStart < eventStart ? eventStart : windowStart;
1051
1051
  var endDate = windowEnd > eventEnd ? eventEnd : windowEnd;
1052
+ startDate.setHours(0, 0, 0, 0);
1053
+ endDate.setHours(23, 59, 59);
1052
1054
  span = Math.ceil(timeBetween(startDate, endDate, 'days'));
1053
1055
  } else {
1054
1056
  if (this.cellUnit === _default.CellUnit.Day) {
@@ -80,6 +80,7 @@ var _default = exports["default"] = {
80
80
  relativeMove: true,
81
81
  defaultExpanded: true,
82
82
  dragAndDropEnabled: true,
83
+ snapToGrid: false,
83
84
  schedulerHeaderEventsFuncsTimeoutMs: 100,
84
85
  resourceName: 'Resource Name',
85
86
  taskName: 'Task Name',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "makula-schedule",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
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",