makula-schedule 1.1.8 → 2.0.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.
- package/README.md +1 -3
- package/dist/components/HeaderView.js +120 -113
- package/dist/components/ResourceEvents.js +36 -1
- package/dist/components/ResourceView.js +35 -20
- package/dist/components/SchedulerData.js +26 -59
- package/dist/components/index.js +38 -16
- package/dist/config/i18n.js +80 -0
- package/dist/config/scheduler.js +13 -0
- package/dist/css/style.css +9148 -3
- package/dist/index.d.ts +5 -1
- package/dist/index.js +26 -1
- package/package.json +14 -13
package/README.md
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
# Scheduler for React
|
|
2
2
|
|
|
3
|
-
[![NPM version][npm-image]][npm-url] [![MIT License][mit-image]][mit-url] [![
|
|
3
|
+
[![NPM version][npm-image]][npm-url] [![MIT License][mit-image]][mit-url] [![CodeFactor][codeFactor-badge]][codeFactor-link]
|
|
4
4
|
|
|
5
5
|
[npm-image]: http://img.shields.io/npm/v/react-big-schedule.svg
|
|
6
6
|
[npm-url]: http://npmjs.org/package/react-big-schedule
|
|
7
7
|
[mit-image]: https://img.shields.io/badge/License-MIT-green.svg
|
|
8
8
|
[mit-url]: https://github.com/ansulagrawal/react-big-schedule/blob/master/LICENSE
|
|
9
|
-
[codeql-image]: https://github.com/ansulagrawal/react-big-schedule/actions/workflows/github-code-scanning/codeql/badge.svg?branch=master
|
|
10
|
-
[codeql-url]: https://github.com/ansulagrawal/react-big-schedule/actions/workflows/github-code-scanning/codeql
|
|
11
9
|
[codeFactor-badge]: https://www.codefactor.io/repository/github/ansulagrawal/react-big-schedule/badge
|
|
12
10
|
[codeFactor-link]: https://www.codefactor.io/repository/github/ansulagrawal/react-big-schedule
|
|
13
11
|
|
|
@@ -5,167 +5,174 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
7
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
-
var _react =
|
|
8
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
var _default2 = require("../config/default");
|
|
10
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
10
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
13
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
14
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
15
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // eslint-disable-next-line no-unused-vars
|
|
16
|
+
/**
|
|
17
|
+
* Render the table header rows for a scheduler view, including an optional week-number row and the main header cells.
|
|
18
|
+
* @param {Object} props.schedulerData - Scheduler configuration and utilities (headers array,
|
|
19
|
+
* cell unit, formatting, sizing, and locale/date functions).
|
|
20
|
+
* @param {Function} [props.nonAgendaCellHeaderTemplateResolver] - Optional resolver to customize
|
|
21
|
+
* rendering of individual header cells. Called with (schedulerData, headerItem, formattedList, style).
|
|
22
|
+
* @returns {JSX.Element} A <thead> element containing the optional week-number row and the
|
|
23
|
+
* main header row for the scheduler table.
|
|
24
|
+
*/
|
|
13
25
|
function HeaderView(_ref) {
|
|
14
26
|
var schedulerData = _ref.schedulerData,
|
|
15
|
-
nonAgendaCellHeaderTemplateResolver = _ref.nonAgendaCellHeaderTemplateResolver
|
|
16
|
-
showWeekNumber = _ref.showWeekNumber;
|
|
27
|
+
nonAgendaCellHeaderTemplateResolver = _ref.nonAgendaCellHeaderTemplateResolver;
|
|
17
28
|
var headers = schedulerData.headers,
|
|
18
29
|
cellUnit = schedulerData.cellUnit,
|
|
19
30
|
config = schedulerData.config,
|
|
20
31
|
localeDayjs = schedulerData.localeDayjs;
|
|
32
|
+
var showWeekNumber = config.showWeekNumber,
|
|
33
|
+
_config$weekNumberRow = config.weekNumberRowHeight,
|
|
34
|
+
weekNumberRowHeight = _config$weekNumberRow === void 0 ? 24 : _config$weekNumberRow;
|
|
21
35
|
var headerHeight = schedulerData.getTableHeaderHeight();
|
|
22
36
|
var cellWidth = schedulerData.getContentCellWidth();
|
|
23
37
|
var minuteStepsInHour = schedulerData.getMinuteStepsInHour();
|
|
24
|
-
var headerList = [];
|
|
25
|
-
var weekNumberRow = [];
|
|
26
|
-
var style;
|
|
27
38
|
|
|
28
|
-
//
|
|
29
|
-
var
|
|
39
|
+
// Week number row generation
|
|
40
|
+
var weekNumberRow = (0, _react.useMemo)(function () {
|
|
30
41
|
if (!showWeekNumber) return null;
|
|
31
42
|
var weekGroups = [];
|
|
43
|
+
var currentWeekKey = null;
|
|
32
44
|
var currentWeek = null;
|
|
45
|
+
var currentYear = null;
|
|
33
46
|
var colspan = 0;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var
|
|
37
|
-
var
|
|
38
|
-
if (
|
|
39
|
-
currentWeek = weekNum;
|
|
40
|
-
colspan = 1;
|
|
41
|
-
startIndex = index;
|
|
42
|
-
} else if (currentWeek === weekNum) {
|
|
47
|
+
headers.forEach(function (item) {
|
|
48
|
+
var year = localeDayjs(new Date(item.time)).year();
|
|
49
|
+
var weekNum = localeDayjs(new Date(item.time)).isoWeek();
|
|
50
|
+
var weekKey = "".concat(year, "-").concat(weekNum);
|
|
51
|
+
if (currentWeekKey === weekKey) {
|
|
43
52
|
colspan += 1;
|
|
44
53
|
} else {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
54
|
+
if (currentWeekKey !== null) {
|
|
55
|
+
weekGroups.push({
|
|
56
|
+
week: currentWeek,
|
|
57
|
+
year: currentYear,
|
|
58
|
+
colspan: colspan
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
currentWeekKey = weekKey;
|
|
50
62
|
currentWeek = weekNum;
|
|
63
|
+
currentYear = year;
|
|
51
64
|
colspan = 1;
|
|
52
|
-
startIndex = index;
|
|
53
65
|
}
|
|
54
66
|
});
|
|
55
67
|
|
|
56
68
|
// Push the last week group
|
|
57
|
-
if (
|
|
69
|
+
if (currentWeekKey !== null) {
|
|
58
70
|
weekGroups.push({
|
|
59
71
|
week: currentWeek,
|
|
60
|
-
|
|
61
|
-
|
|
72
|
+
year: currentYear,
|
|
73
|
+
colspan: colspan
|
|
62
74
|
});
|
|
63
75
|
}
|
|
76
|
+
var cellStyle = {
|
|
77
|
+
fontSize: '0.85em',
|
|
78
|
+
opacity: 0.7,
|
|
79
|
+
borderBottom: "1px solid ".concat(config.headerBorderColor || '#e9e9e9'),
|
|
80
|
+
padding: '4px 8px',
|
|
81
|
+
textAlign: 'center'
|
|
82
|
+
};
|
|
64
83
|
return weekGroups.map(function (group, idx) {
|
|
65
|
-
var cellStyle = {
|
|
66
|
-
fontSize: '0.85em',
|
|
67
|
-
opacity: 0.7,
|
|
68
|
-
borderBottom: '1px solid #e9e9e9',
|
|
69
|
-
padding: '4px 8px',
|
|
70
|
-
textAlign: 'center'
|
|
71
|
-
};
|
|
72
84
|
return /*#__PURE__*/_react["default"].createElement("th", {
|
|
73
|
-
key: "week-".concat(group.week, "-").concat(idx),
|
|
85
|
+
key: "week-".concat(group.year, "-").concat(group.week, "-").concat(idx),
|
|
74
86
|
colSpan: group.colspan,
|
|
75
87
|
style: cellStyle
|
|
76
88
|
}, "W", group.week);
|
|
77
89
|
});
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
width: cellWidth * minuteStepsInHour,
|
|
85
|
-
color: config.nonWorkingTimeHeadColor,
|
|
86
|
-
backgroundColor: config.nonWorkingTimeHeadBgColor
|
|
87
|
-
} : {
|
|
88
|
-
width: cellWidth * minuteStepsInHour
|
|
89
|
-
};
|
|
90
|
-
if (index === headers.length - minuteStepsInHour) {
|
|
91
|
-
style = item.nonWorkingTime ? {
|
|
92
|
-
color: config.nonWorkingTimeHeadColor,
|
|
93
|
-
backgroundColor: config.nonWorkingTimeHeadBgColor
|
|
94
|
-
} : {};
|
|
95
|
-
}
|
|
96
|
-
var pFormattedList = config.nonAgendaDayCellHeaderFormat.split('|').map(function (pitem) {
|
|
97
|
-
return datetime.format(pitem);
|
|
98
|
-
});
|
|
99
|
-
var element;
|
|
100
|
-
if (typeof nonAgendaCellHeaderTemplateResolver === 'function') {
|
|
101
|
-
element = nonAgendaCellHeaderTemplateResolver(schedulerData, item, pFormattedList, style);
|
|
102
|
-
} else {
|
|
103
|
-
var pList = pFormattedList.map(function (formattedItem, pIndex) {
|
|
104
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
105
|
-
key: pIndex
|
|
106
|
-
}, formattedItem);
|
|
107
|
-
});
|
|
108
|
-
element = /*#__PURE__*/_react["default"].createElement("th", {
|
|
109
|
-
key: "header-".concat(item.time),
|
|
110
|
-
className: "header3-text",
|
|
111
|
-
style: style
|
|
112
|
-
}, /*#__PURE__*/_react["default"].createElement("div", null, pList));
|
|
113
|
-
}
|
|
114
|
-
headerList.push(element);
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
} else {
|
|
118
|
-
headerList = headers.map(function (item, index) {
|
|
119
|
-
var datetime = localeDayjs(new Date(item.time));
|
|
120
|
-
style = item.nonWorkingTime ? {
|
|
121
|
-
width: cellWidth,
|
|
122
|
-
color: config.nonWorkingTimeHeadColor,
|
|
123
|
-
backgroundColor: config.nonWorkingTimeHeadBgColor
|
|
124
|
-
} : {
|
|
125
|
-
width: cellWidth
|
|
126
|
-
};
|
|
127
|
-
if (index === headers.length - 1) style = item.nonWorkingTime ? {
|
|
90
|
+
}, [showWeekNumber, headers, localeDayjs]);
|
|
91
|
+
|
|
92
|
+
// Extract common style creation logic
|
|
93
|
+
var createCellStyle = (0, _react.useCallback)(function (item, width, isLastCell) {
|
|
94
|
+
if (isLastCell) {
|
|
95
|
+
return item.nonWorkingTime ? {
|
|
128
96
|
color: config.nonWorkingTimeHeadColor,
|
|
129
97
|
backgroundColor: config.nonWorkingTimeHeadBgColor
|
|
130
98
|
} : {};
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
99
|
+
}
|
|
100
|
+
return item.nonWorkingTime ? {
|
|
101
|
+
width: width,
|
|
102
|
+
color: config.nonWorkingTimeHeadColor,
|
|
103
|
+
backgroundColor: config.nonWorkingTimeHeadBgColor
|
|
104
|
+
} : {
|
|
105
|
+
width: width
|
|
106
|
+
};
|
|
107
|
+
}, [config]);
|
|
108
|
+
|
|
109
|
+
// Extract cell format selection logic
|
|
110
|
+
var getCellFormat = (0, _react.useCallback)(function (cellUnitParam) {
|
|
111
|
+
var formatMap = _defineProperty(_defineProperty(_defineProperty({}, _default2.CellUnit.Week, config.nonAgendaWeekCellHeaderFormat), _default2.CellUnit.Month, config.nonAgendaMonthCellHeaderFormat), _default2.CellUnit.Year, config.nonAgendaYearCellHeaderFormat);
|
|
112
|
+
return formatMap[cellUnitParam] || config.nonAgendaOtherCellHeaderFormat;
|
|
113
|
+
}, [config]);
|
|
114
|
+
|
|
115
|
+
// Render cell content helper
|
|
116
|
+
var renderCellContent = (0, _react.useCallback)(function (item, formattedList, style) {
|
|
117
|
+
if (typeof nonAgendaCellHeaderTemplateResolver === 'function') {
|
|
118
|
+
return nonAgendaCellHeaderTemplateResolver(schedulerData, item, formattedList, style);
|
|
119
|
+
}
|
|
120
|
+
var content = formattedList.map(function (text, idx) {
|
|
121
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
122
|
+
key: "".concat(item.time, "-").concat(idx, "-").concat(text)
|
|
123
|
+
}, text);
|
|
124
|
+
});
|
|
125
|
+
return /*#__PURE__*/_react["default"].createElement("th", {
|
|
126
|
+
key: "header-".concat(item.time),
|
|
127
|
+
className: "header3-text",
|
|
128
|
+
style: style
|
|
129
|
+
}, /*#__PURE__*/_react["default"].createElement("div", null, content));
|
|
130
|
+
}, [nonAgendaCellHeaderTemplateResolver, schedulerData]);
|
|
131
|
+
|
|
132
|
+
// Memoize header list generation
|
|
133
|
+
var headerList = (0, _react.useMemo)(function () {
|
|
134
|
+
if (cellUnit === _default2.CellUnit.Hour) {
|
|
135
|
+
var result = [];
|
|
136
|
+
var _lastIndex = headers.length - minuteStepsInHour;
|
|
137
|
+
headers.forEach(function (item, index) {
|
|
138
|
+
if (index % minuteStepsInHour !== 0) return;
|
|
139
|
+
var datetime = localeDayjs(new Date(item.time));
|
|
140
|
+
var width = cellWidth * minuteStepsInHour;
|
|
141
|
+
var isLastCell = index === _lastIndex;
|
|
142
|
+
var style = createCellStyle(item, width, isLastCell);
|
|
143
|
+
var formattedList = config.nonAgendaDayCellHeaderFormat.split('|').map(function (format) {
|
|
144
|
+
return datetime.format(format);
|
|
145
|
+
});
|
|
146
|
+
result.push(renderCellContent(item, formattedList, style));
|
|
134
147
|
});
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
148
|
+
return result;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Non-hour cell units
|
|
152
|
+
var cellFormat = getCellFormat(cellUnit);
|
|
153
|
+
var lastIndex = headers.length - 1;
|
|
154
|
+
return headers.map(function (item, index) {
|
|
155
|
+
var datetime = localeDayjs(new Date(item.time));
|
|
156
|
+
var isLastCell = index === lastIndex;
|
|
157
|
+
var style = createCellStyle(item, cellWidth, isLastCell);
|
|
158
|
+
var formattedList = cellFormat.split('|').map(function (format) {
|
|
159
|
+
return datetime.format(format);
|
|
142
160
|
});
|
|
143
|
-
return
|
|
144
|
-
key: "header-".concat(item.time),
|
|
145
|
-
className: "header3-text",
|
|
146
|
-
style: style
|
|
147
|
-
}, /*#__PURE__*/_react["default"].createElement("div", null, pList));
|
|
161
|
+
return renderCellContent(item, formattedList, style);
|
|
148
162
|
});
|
|
149
|
-
}
|
|
150
|
-
weekNumberRow
|
|
151
|
-
return /*#__PURE__*/_react["default"].createElement("thead", null, showWeekNumber && weekNumberRow && /*#__PURE__*/_react["default"].createElement("tr", {
|
|
163
|
+
}, [cellUnit, headers, minuteStepsInHour, cellWidth, config, localeDayjs, createCellStyle, getCellFormat, renderCellContent]);
|
|
164
|
+
return /*#__PURE__*/_react["default"].createElement("thead", null, weekNumberRow && /*#__PURE__*/_react["default"].createElement("tr", {
|
|
152
165
|
style: {
|
|
153
|
-
height:
|
|
166
|
+
height: weekNumberRowHeight
|
|
154
167
|
}
|
|
155
168
|
}, weekNumberRow), /*#__PURE__*/_react["default"].createElement("tr", {
|
|
156
169
|
style: {
|
|
157
170
|
height: headerHeight
|
|
158
|
-
}
|
|
159
|
-
className: "no-scrollbar"
|
|
171
|
+
}
|
|
160
172
|
}, headerList));
|
|
161
173
|
}
|
|
162
174
|
HeaderView.propTypes = {
|
|
163
175
|
schedulerData: _propTypes["default"].object.isRequired,
|
|
164
|
-
nonAgendaCellHeaderTemplateResolver: _propTypes["default"].func
|
|
165
|
-
showWeekNumber: _propTypes["default"].bool
|
|
176
|
+
nonAgendaCellHeaderTemplateResolver: _propTypes["default"].func
|
|
166
177
|
};
|
|
167
|
-
|
|
168
|
-
// HeaderView.defaultProps = {
|
|
169
|
-
// nonAgendaCellHeaderTemplateResolver: null,
|
|
170
|
-
// };
|
|
171
178
|
var _default = exports["default"] = HeaderView;
|
|
@@ -334,9 +334,44 @@ var ResourceEvents = /*#__PURE__*/function (_Component) {
|
|
|
334
334
|
var isEnd = eventEnd <= durationEnd;
|
|
335
335
|
var _left = index * cellWidth + (index > 0 ? 2 : 3);
|
|
336
336
|
var _width = evt.span * cellWidth - (index > 0 ? 5 : 6) > 0 ? evt.span * cellWidth - (index > 0 ? 5 : 6) : 0;
|
|
337
|
+
var dayStart = localeDayjs(new Date(headerItem.start)).startOf('day');
|
|
338
|
+
var dayDurationMinutes = 1440;
|
|
339
|
+
var baseCellWidth = cellWidth - (index > 0 ? 5 : 6);
|
|
340
|
+
if (cellUnit === _default2.CellUnit.Day) {
|
|
341
|
+
if (evt.span === 1) {
|
|
342
|
+
var startOffsetMinutes = eventStart.diff(dayStart, 'minute');
|
|
343
|
+
var eventDurationMinutes = eventEnd.diff(eventStart, 'minute');
|
|
344
|
+
var startPercentage = startOffsetMinutes / dayDurationMinutes;
|
|
345
|
+
var durationPercentage = eventDurationMinutes / dayDurationMinutes;
|
|
346
|
+
var leftOffset = baseCellWidth * startPercentage;
|
|
347
|
+
var eventWidth = baseCellWidth * durationPercentage;
|
|
348
|
+
_left = index * cellWidth + (index > 0 ? 2 : 3) + leftOffset;
|
|
349
|
+
_width = Math.max(1, eventWidth); // ensure minimum width of 1px
|
|
350
|
+
} else {
|
|
351
|
+
var headerStart = localeDayjs(new Date(headerItem.start));
|
|
352
|
+
var headerEnd = localeDayjs(new Date(headerItem.end));
|
|
353
|
+
var isFirstDay = eventStart >= headerStart && eventStart < headerEnd;
|
|
354
|
+
if (isFirstDay) {
|
|
355
|
+
var eventStartDayStart = eventStart.startOf('day');
|
|
356
|
+
var eventEndDayEnd = eventEnd.endOf('day');
|
|
357
|
+
var totalSpanMinutes = eventEndDayEnd.diff(eventStartDayStart, 'minute');
|
|
358
|
+
var eventStartOffsetMinutes = eventStart.diff(eventStartDayStart, 'minute');
|
|
359
|
+
var _eventDurationMinutes = eventEnd.diff(eventStart, 'minute');
|
|
360
|
+
var _startPercentage = eventStartOffsetMinutes / dayDurationMinutes;
|
|
361
|
+
var _durationPercentage = totalSpanMinutes > 0 ? _eventDurationMinutes / totalSpanMinutes : 1;
|
|
362
|
+
var totalWidth = evt.span * cellWidth - (index > 0 ? 5 : 6);
|
|
363
|
+
var _leftOffset = cellWidth * _startPercentage;
|
|
364
|
+
var _eventWidth = totalWidth * _durationPercentage;
|
|
365
|
+
_left = index * cellWidth + (index > 0 ? 2 : 3) + _leftOffset;
|
|
366
|
+
_width = Math.max(1, _eventWidth);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
} else {
|
|
370
|
+
_width = evt.span * cellWidth - (index > 0 ? 5 : 6) > 0 ? evt.span * cellWidth - (index > 0 ? 5 : 6) : 0;
|
|
371
|
+
}
|
|
337
372
|
var top = marginTop + idx * config.eventItemLineHeight;
|
|
338
373
|
var eventItem = /*#__PURE__*/_react["default"].createElement(_EventItem["default"], _extends({}, _this2.props, {
|
|
339
|
-
key: evt.eventItem.id,
|
|
374
|
+
key: "".concat(evt.eventItem.id, "_").concat(headerItem.time),
|
|
340
375
|
eventItem: evt.eventItem,
|
|
341
376
|
dndSource: dndSource,
|
|
342
377
|
isStart: isStart,
|
|
@@ -9,6 +9,23 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
11
11
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } // eslint-disable-next-line no-unused-vars
|
|
12
|
+
/**
|
|
13
|
+
* Render the scheduler's resource table with hierarchical indentation, optional expand/collapse controls,
|
|
14
|
+
* clickable slot names, and support for custom slot templates or an injected resource-cell renderer.
|
|
15
|
+
*
|
|
16
|
+
* @param {object} schedulerData - Scheduler state and helpers; must include `renderData`,
|
|
17
|
+
* `getResourceTableWidth`, and `config`.
|
|
18
|
+
* @param {number} contentScrollbarHeight - Height used to set the container's bottom padding.
|
|
19
|
+
* @param {Function} [slotClickedFunc] - Called as `slotClickedFunc(schedulerData, item)` when a slot name is clicked.
|
|
20
|
+
* @param {Function} [slotItemTemplateResolver] - Called as `slotItemTemplateResolver
|
|
21
|
+
* (schedulerData, item, slotClickedFunc, width, className)` to provide a custom slot cell element;
|
|
22
|
+
* if a value is returned it replaces the default slot cell.
|
|
23
|
+
* @param {Function} [toggleExpandFunc] - Called as `toggleExpandFunc(schedulerData, slotId)`
|
|
24
|
+
* to toggle expansion for items with children.
|
|
25
|
+
* @param {Function} [CustomResourceCell] - Optional React component rendered inside the resource
|
|
26
|
+
* `<td>` when provided; receives props `{ schedulerData, item, indents, slotClickedFunc, handleToggleExpand }`.
|
|
27
|
+
* @returns {JSX.Element} The rendered resource table element.
|
|
28
|
+
*/
|
|
12
29
|
function ResourceView(_ref) {
|
|
13
30
|
var schedulerData = _ref.schedulerData,
|
|
14
31
|
contentScrollbarHeight = _ref.contentScrollbarHeight,
|
|
@@ -45,6 +62,24 @@ function ResourceView(_ref) {
|
|
|
45
62
|
}, iconProps));
|
|
46
63
|
}
|
|
47
64
|
indents.push(indent);
|
|
65
|
+
var tdStyle = {
|
|
66
|
+
height: item.rowHeight,
|
|
67
|
+
backgroundColor: item.groupOnly ? schedulerData.config.groupOnlySlotColor : undefined
|
|
68
|
+
};
|
|
69
|
+
if (CustomResourceCell) {
|
|
70
|
+
return /*#__PURE__*/_react["default"].createElement("tr", {
|
|
71
|
+
key: item.slotId
|
|
72
|
+
}, /*#__PURE__*/_react["default"].createElement("td", {
|
|
73
|
+
"data-resource-id": item.slotId,
|
|
74
|
+
style: tdStyle
|
|
75
|
+
}, /*#__PURE__*/_react["default"].createElement(CustomResourceCell, {
|
|
76
|
+
schedulerData: schedulerData,
|
|
77
|
+
item: item,
|
|
78
|
+
indents: indents,
|
|
79
|
+
slotClickedFunc: slotClickedFunc,
|
|
80
|
+
handleToggleExpand: handleToggleExpand
|
|
81
|
+
})));
|
|
82
|
+
}
|
|
48
83
|
var slotCell = slotClickedFunc ? /*#__PURE__*/_react["default"].createElement("span", {
|
|
49
84
|
className: "slot-cell"
|
|
50
85
|
}, indents, /*#__PURE__*/_react["default"].createElement("button", {
|
|
@@ -78,26 +113,6 @@ function ResourceView(_ref) {
|
|
|
78
113
|
slotItem = resolvedTemplate;
|
|
79
114
|
}
|
|
80
115
|
}
|
|
81
|
-
var tdStyle = {
|
|
82
|
-
height: item.rowHeight,
|
|
83
|
-
backgroundColor: item.groupOnly ? schedulerData.config.groupOnlySlotColor : undefined
|
|
84
|
-
};
|
|
85
|
-
if (CustomResourceCell) {
|
|
86
|
-
return /*#__PURE__*/_react["default"].createElement("tr", {
|
|
87
|
-
key: item.slotId
|
|
88
|
-
}, /*#__PURE__*/_react["default"].createElement("td", {
|
|
89
|
-
"data-resource-id": item.slotId,
|
|
90
|
-
style: tdStyle
|
|
91
|
-
}, /*#__PURE__*/_react["default"].createElement(CustomResourceCell, {
|
|
92
|
-
schedulerData: schedulerData,
|
|
93
|
-
item: item,
|
|
94
|
-
indents: indents,
|
|
95
|
-
slotClickedFunc: slotClickedFunc,
|
|
96
|
-
toggleExpandFunc: function toggleExpandFunc() {
|
|
97
|
-
return handleToggleExpand(item);
|
|
98
|
-
}
|
|
99
|
-
})));
|
|
100
|
-
}
|
|
101
116
|
return /*#__PURE__*/_react["default"].createElement("tr", {
|
|
102
117
|
key: item.slotId
|
|
103
118
|
}, /*#__PURE__*/_react["default"].createElement("td", {
|
|
@@ -12,6 +12,7 @@ var _weekday = _interopRequireDefault(require("dayjs/plugin/weekday"));
|
|
|
12
12
|
var _rrule = require("rrule");
|
|
13
13
|
var _default = require("../config/default");
|
|
14
14
|
var _scheduler = _interopRequireDefault(require("../config/scheduler"));
|
|
15
|
+
var _i18n = require("../config/i18n");
|
|
15
16
|
var _behaviors = _interopRequireDefault(require("../helper/behaviors"));
|
|
16
17
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
17
18
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
@@ -53,17 +54,40 @@ var SchedulerData = exports["default"] = /*#__PURE__*/function () {
|
|
|
53
54
|
_dayjs["default"].extend(_utc["default"]);
|
|
54
55
|
this.localeDayjs = _dayjs["default"];
|
|
55
56
|
this.config = newConfig === undefined ? _scheduler["default"] : _objectSpread(_objectSpread({}, _scheduler["default"]), newConfig);
|
|
57
|
+
this._updateLabelsFromI18n();
|
|
56
58
|
this._validateMinuteStep(this.config.minuteStep);
|
|
57
59
|
this.behaviors = newBehaviors === undefined ? _behaviors["default"] : _objectSpread(_objectSpread({}, _behaviors["default"]), newBehaviors);
|
|
58
60
|
this._resolveDate(0, date);
|
|
59
61
|
this._createHeaders();
|
|
60
62
|
this._createRenderData();
|
|
61
63
|
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Update user-facing labels from the i18n provider
|
|
67
|
+
* This allows apps to provide localized labels via setLabelsProvider()
|
|
68
|
+
* @private
|
|
69
|
+
*/
|
|
62
70
|
return _createClass(SchedulerData, [{
|
|
71
|
+
key: "_updateLabelsFromI18n",
|
|
72
|
+
value: function _updateLabelsFromI18n(locale) {
|
|
73
|
+
// Get labels from the i18n provider if available
|
|
74
|
+
var defaults = (0, _i18n.getDefaultLabels)();
|
|
75
|
+
var applyIfProvided = function applyIfProvided(key, current) {
|
|
76
|
+
var value = (0, _i18n.getLabel)(key, locale);
|
|
77
|
+
if (value === undefined || value === null) return current;
|
|
78
|
+
return value !== defaults[key] ? value : current;
|
|
79
|
+
};
|
|
80
|
+
this.config.resourceName = applyIfProvided('resourceName', this.config.resourceName);
|
|
81
|
+
this.config.taskName = applyIfProvided('taskName', this.config.taskName);
|
|
82
|
+
this.config.agendaViewHeader = applyIfProvided('agendaViewHeader', this.config.agendaViewHeader);
|
|
83
|
+
this.config.weekNumberLabel = applyIfProvided('weekNumberLabel', this.config.weekNumberLabel);
|
|
84
|
+
}
|
|
85
|
+
}, {
|
|
63
86
|
key: "setSchedulerLocale",
|
|
64
87
|
value: function setSchedulerLocale(preset) {
|
|
65
88
|
if (!preset) return;
|
|
66
89
|
this.localeDayjs.locale(preset);
|
|
90
|
+
this._updateLabelsFromI18n(preset);
|
|
67
91
|
this._shouldReloadViewType = true;
|
|
68
92
|
this.setViewType(this.viewType, this.showAgenda, this.isEventPerspective);
|
|
69
93
|
}
|
|
@@ -702,11 +726,10 @@ var SchedulerData = exports["default"] = /*#__PURE__*/function () {
|
|
|
702
726
|
case _default.ViewType.Week:
|
|
703
727
|
if (date !== undefined) {
|
|
704
728
|
this.startDate = this.selectDate.startOf('isoWeek');
|
|
705
|
-
this.endDate = this.startDate.endOf('isoWeek');
|
|
706
729
|
} else {
|
|
707
730
|
this.startDate = this.startDate.add(num, 'weeks');
|
|
708
|
-
this.endDate = this.startDate.endOf('isoWeek');
|
|
709
731
|
}
|
|
732
|
+
this.endDate = this.startDate.endOf('isoWeek');
|
|
710
733
|
break;
|
|
711
734
|
case _default.ViewType.Day:
|
|
712
735
|
this.startDate = date !== undefined ? this.selectDate : this.startDate.add(num, 'days');
|
|
@@ -823,54 +846,6 @@ var SchedulerData = exports["default"] = /*#__PURE__*/function () {
|
|
|
823
846
|
}
|
|
824
847
|
this.headers = headers;
|
|
825
848
|
}
|
|
826
|
-
|
|
827
|
-
// Fix Optimited code
|
|
828
|
-
// _createHeaders() {
|
|
829
|
-
// const headers = [];
|
|
830
|
-
// const start = this.localeDayjs(new Date(this.startDate));
|
|
831
|
-
// const end = this.localeDayjs(new Date(this.endDate));
|
|
832
|
-
|
|
833
|
-
// const processHeader = (header, format, unit, incrementFn) => {
|
|
834
|
-
// let head = header;
|
|
835
|
-
// while (head >= start && head <= end) {
|
|
836
|
-
// const time = head.format(format);
|
|
837
|
-
// if (unit === CellUnit.Day) {
|
|
838
|
-
// const dayOfWeek = head.weekday();
|
|
839
|
-
// if (this.config.displayWeekend || (dayOfWeek !== 0 && dayOfWeek !== 6)) {
|
|
840
|
-
// const nonWorkingTime = this.behaviors.isNonWorkingTimeFunc(this, time);
|
|
841
|
-
// headers.push({ time, nonWorkingTime });
|
|
842
|
-
// }
|
|
843
|
-
// } else {
|
|
844
|
-
// headers.push({ time });
|
|
845
|
-
// }
|
|
846
|
-
// head = head.add(1, incrementFn);
|
|
847
|
-
// }
|
|
848
|
-
// };
|
|
849
|
-
|
|
850
|
-
// if (this.showAgenda) {
|
|
851
|
-
// headers.push({ time: start.format(DATETIME_FORMAT), nonWorkingTime: false });
|
|
852
|
-
// } else if (this.cellUnit === CellUnit.Hour) {
|
|
853
|
-
// const hourIncrement = this.config.minuteStep < 60 ? 'minutes' : 'hours';
|
|
854
|
-
// const minuteSteps = this.getMinuteStepsInHour();
|
|
855
|
-
// let header = start.hour() === 0 ? start.add(this.config.dayStartFrom, 'hours') : start;
|
|
856
|
-
// while (header <= end) {
|
|
857
|
-
// const hour = header.hour();
|
|
858
|
-
// if (hour >= this.config.dayStartFrom && hour <= this.config.dayStopTo) {
|
|
859
|
-
// const time = header.format(DATETIME_FORMAT);
|
|
860
|
-
// const nonWorkingTime = this.behaviors.isNonWorkingTimeFunc(this, time);
|
|
861
|
-
// headers.push({ time, nonWorkingTime });
|
|
862
|
-
// }
|
|
863
|
-
// header = header.add(minuteSteps, hourIncrement);
|
|
864
|
-
// }
|
|
865
|
-
// } else {
|
|
866
|
-
// const header = start;
|
|
867
|
-
// const format = this.cellUnit === CellUnit.Day ? DATETIME_FORMAT : DATE_FORMAT;
|
|
868
|
-
// const incrementFn = this.cellUnit === CellUnit.Day ? 'days' : `${this.cellUnit}s`;
|
|
869
|
-
// processHeader(header, format, this.cellUnit, incrementFn);
|
|
870
|
-
// }
|
|
871
|
-
|
|
872
|
-
// this.headers = headers;
|
|
873
|
-
// }
|
|
874
849
|
}, {
|
|
875
850
|
key: "_createInitHeaderEvents",
|
|
876
851
|
value: function _createInitHeaderEvents(header) {
|
|
@@ -954,7 +929,7 @@ var SchedulerData = exports["default"] = /*#__PURE__*/function () {
|
|
|
954
929
|
var headerEvents = headers.map(function (header) {
|
|
955
930
|
return _this5._createInitHeaderEvents(header);
|
|
956
931
|
});
|
|
957
|
-
var slotRenderData = _objectSpread({
|
|
932
|
+
var slotRenderData = _objectSpread(_objectSpread({}, slot), {}, {
|
|
958
933
|
slotId: slot.id,
|
|
959
934
|
slotName: slot.name,
|
|
960
935
|
slotTitle: slot.title,
|
|
@@ -1026,13 +1001,6 @@ var SchedulerData = exports["default"] = /*#__PURE__*/function () {
|
|
|
1026
1001
|
key: "_getSpan",
|
|
1027
1002
|
value: function _getSpan(startTime, endTime, headers) {
|
|
1028
1003
|
if (this.showAgenda) return 1;
|
|
1029
|
-
|
|
1030
|
-
// function startOfWeek(date) {
|
|
1031
|
-
// const day = date.getDay();
|
|
1032
|
-
// const diff = date.getDate() - day;
|
|
1033
|
-
// return new Date(date.getFullYear(), date.getMonth(), diff);
|
|
1034
|
-
// }
|
|
1035
|
-
|
|
1036
1004
|
var timeBetween = function timeBetween(date1, date2, timeIn) {
|
|
1037
1005
|
if (timeIn === 'days' || timeIn === 'day') {
|
|
1038
1006
|
if (date1.getDate() === date2.getDate() && date1.getMonth() === date2.getMonth()) {
|
|
@@ -1212,7 +1180,6 @@ var SchedulerData = exports["default"] = /*#__PURE__*/function () {
|
|
|
1212
1180
|
var previousHeaderEnd = new Date(previousHeader.end);
|
|
1213
1181
|
if (previousHeaderEnd <= eventStart || previousHeaderStart >= eventEnd) render = true;
|
|
1214
1182
|
}
|
|
1215
|
-
// console.log(`span: ${span}`)
|
|
1216
1183
|
header.events[pos] = _this6._createHeaderEvent(render, span, item);
|
|
1217
1184
|
}
|
|
1218
1185
|
});
|