makula-schedule 1.1.9 → 2.0.1
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 +30 -61
- package/dist/components/index.js +38 -16
- package/dist/config/i18n.js +80 -0
- package/dist/config/scheduler.js +13 -0
- 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); }
|
|
@@ -47,23 +48,46 @@ var SchedulerData = exports["default"] = /*#__PURE__*/function () {
|
|
|
47
48
|
this.schedulerHeaderHeight = 0;
|
|
48
49
|
this._shouldReloadViewType = false;
|
|
49
50
|
this.calendarPopoverLocale = undefined;
|
|
50
|
-
_dayjs["default"].extend(_isoWeek["default"]);
|
|
51
51
|
_dayjs["default"].extend(_quarterOfYear["default"]);
|
|
52
52
|
_dayjs["default"].extend(_weekday["default"]);
|
|
53
53
|
_dayjs["default"].extend(_utc["default"]);
|
|
54
|
+
_dayjs["default"].extend(_isoWeek["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,16 +1001,9 @@ 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
|
-
if (date1.getDate() === date2.getDate() && date1.getMonth() === date2.getMonth()) {
|
|
1006
|
+
if (date1.getDate() === date2.getDate() && date1.getMonth() === date2.getMonth() && date1.getFullYear() === date2.getFullYear()) {
|
|
1039
1007
|
return 1;
|
|
1040
1008
|
}
|
|
1041
1009
|
}
|
|
@@ -1081,6 +1049,8 @@ var SchedulerData = exports["default"] = /*#__PURE__*/function () {
|
|
|
1081
1049
|
} else if (this.viewType === _default.ViewType.Week || this.viewType === _default.ViewType.Month || this.viewType === _default.ViewType.Quarter || this.viewType === _default.ViewType.Year) {
|
|
1082
1050
|
var startDate = windowStart < eventStart ? eventStart : windowStart;
|
|
1083
1051
|
var endDate = windowEnd > eventEnd ? eventEnd : windowEnd;
|
|
1052
|
+
startDate.setHours(0, 0, 0, 0);
|
|
1053
|
+
endDate.setHours(23, 59, 59);
|
|
1084
1054
|
span = Math.ceil(timeBetween(startDate, endDate, 'days'));
|
|
1085
1055
|
} else {
|
|
1086
1056
|
if (this.cellUnit === _default.CellUnit.Day) {
|
|
@@ -1212,7 +1182,6 @@ var SchedulerData = exports["default"] = /*#__PURE__*/function () {
|
|
|
1212
1182
|
var previousHeaderEnd = new Date(previousHeader.end);
|
|
1213
1183
|
if (previousHeaderEnd <= eventStart || previousHeaderStart >= eventEnd) render = true;
|
|
1214
1184
|
}
|
|
1215
|
-
// console.log(`span: ${span}`)
|
|
1216
1185
|
header.events[pos] = _this6._createHeaderEvent(render, span, item);
|
|
1217
1186
|
}
|
|
1218
1187
|
});
|
package/dist/components/index.js
CHANGED
|
@@ -104,6 +104,29 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
104
104
|
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
105
105
|
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
106
106
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } // eslint-disable-next-line no-unused-vars
|
|
107
|
+
/**
|
|
108
|
+
* Render the scheduler UI with resource and agenda views, responsive sizing, and drag-and-drop support.
|
|
109
|
+
*
|
|
110
|
+
* @param {object} props - Component properties.
|
|
111
|
+
* @param {SchedulerData} props.schedulerData - Scheduler state and configuration used to drive rendering and behavior.
|
|
112
|
+
* @param {Array<DnDSource>} [props.dndSources] - Additional drag-and-drop sources to merge into the
|
|
113
|
+
* scheduler's DnD context.
|
|
114
|
+
* @param {React.RefObject<HTMLElement>} [props.parentRef] - Parent element ref used when sizing
|
|
115
|
+
* is driven by the parent container.
|
|
116
|
+
* @param {function(SchedulerData):void} props.prevClick - Callback invoked to navigate to the previous range.
|
|
117
|
+
* @param {function(SchedulerData):void} props.nextClick - Callback invoked to navigate to the next range.
|
|
118
|
+
* @param {function(SchedulerData, object):void} props.onViewChange - Callback invoked when the view type,
|
|
119
|
+
* agenda toggle, or perspective changes.
|
|
120
|
+
* @param {function(SchedulerData, string|Date):void} props.onSelectDate - Callback invoked when a date is selected.
|
|
121
|
+
* @param {React.ReactNode} [props.leftCustomHeader] - Optional custom content rendered on the left side of the header.
|
|
122
|
+
* @param {React.ReactNode} [props.rightCustomHeader] - Optional custom content rendered on the
|
|
123
|
+
* right side of the header.
|
|
124
|
+
* @param {function} [props.CustomResourceHeader] - Optional component used to render the resource header cell.
|
|
125
|
+
* @param {object} [props.configTableHeaderStyle] - Optional inline style object applied
|
|
126
|
+
* to the resource header container.
|
|
127
|
+
* @returns {JSX.Element} The scheduler root element tree to be rendered.
|
|
128
|
+
*/
|
|
129
|
+
|
|
107
130
|
function Scheduler(props) {
|
|
108
131
|
var schedulerData = props.schedulerData,
|
|
109
132
|
dndSources = props.dndSources,
|
|
@@ -116,7 +139,6 @@ function Scheduler(props) {
|
|
|
116
139
|
rightCustomHeader = props.rightCustomHeader,
|
|
117
140
|
ViewButtonRender = props.ViewButtonRender,
|
|
118
141
|
CustomLoader = props.CustomLoader,
|
|
119
|
-
showWeekNumber = props.showWeekNumber,
|
|
120
142
|
CustomResourceHeader = props.CustomResourceHeader,
|
|
121
143
|
CustomResourceCell = props.CustomResourceCell,
|
|
122
144
|
configTableHeaderStyle = props.configTableHeaderStyle;
|
|
@@ -417,10 +439,13 @@ function Scheduler(props) {
|
|
|
417
439
|
contentScrollbarWidth = state.contentScrollbarWidth,
|
|
418
440
|
resourceScrollbarHeight = state.resourceScrollbarHeight,
|
|
419
441
|
resourceScrollbarWidth = state.resourceScrollbarWidth;
|
|
442
|
+
var showWeekNumber = config.showWeekNumber,
|
|
443
|
+
weekNumberRowHeight = config.weekNumberRowHeight;
|
|
420
444
|
var tbodyContent = /*#__PURE__*/_react["default"].createElement("tr", null);
|
|
421
445
|
if (showAgenda) {
|
|
422
446
|
tbodyContent = /*#__PURE__*/_react["default"].createElement(_AgendaView["default"], props);
|
|
423
447
|
} else {
|
|
448
|
+
var _config$headerBorderC, _config$headerBorderC2, _config$weekNumberLab, _config$headerBorderC3;
|
|
424
449
|
var resourceTableWidth = schedulerData.getResourceTableWidth();
|
|
425
450
|
var schedulerContainerWidth = width - (config.resourceViewEnabled ? resourceTableWidth : 0);
|
|
426
451
|
var schedulerWidth = schedulerData.getContentTableWidth() - 1;
|
|
@@ -455,11 +480,12 @@ function Scheduler(props) {
|
|
|
455
480
|
margin: "0px -".concat(contentScrollbarWidth, "px 0px 0px")
|
|
456
481
|
};
|
|
457
482
|
if (config.schedulerMaxHeight > 0) {
|
|
483
|
+
var totalHeaderHeight = config.tableHeaderHeight + (showWeekNumber ? weekNumberRowHeight : 0);
|
|
458
484
|
schedulerContentStyle = _objectSpread(_objectSpread({}, schedulerContentStyle), {}, {
|
|
459
|
-
maxHeight: config.schedulerMaxHeight -
|
|
485
|
+
maxHeight: config.schedulerMaxHeight - totalHeaderHeight
|
|
460
486
|
});
|
|
461
487
|
resourceContentStyle = _objectSpread(_objectSpread({}, resourceContentStyle), {}, {
|
|
462
|
-
maxHeight: config.schedulerMaxHeight -
|
|
488
|
+
maxHeight: config.schedulerMaxHeight - totalHeaderHeight
|
|
463
489
|
});
|
|
464
490
|
} else if (config.responsiveByParent && schedulerData.documentHeight > 0) {
|
|
465
491
|
// Responsive height minus SchedulerHeader
|
|
@@ -482,30 +508,29 @@ function Scheduler(props) {
|
|
|
482
508
|
className: "resource-view"
|
|
483
509
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
484
510
|
style: _objectSpread({
|
|
485
|
-
borderBottom:
|
|
486
|
-
height:
|
|
511
|
+
borderBottom: "1px solid ".concat((_config$headerBorderC = config.headerBorderColor) !== null && _config$headerBorderC !== void 0 ? _config$headerBorderC : '#e9e9e9'),
|
|
512
|
+
height: config.tableHeaderHeight + (showWeekNumber ? weekNumberRowHeight : 0)
|
|
487
513
|
}, configTableHeaderStyle)
|
|
488
514
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
489
515
|
style: {
|
|
490
516
|
overflowX: 'scroll',
|
|
491
517
|
overflowY: 'hidden',
|
|
492
|
-
margin: "0px 0px -".concat(contentScrollbarHeight, "px")
|
|
493
|
-
overflow: 'visible'
|
|
518
|
+
margin: "0px 0px -".concat(contentScrollbarHeight, "px")
|
|
494
519
|
}
|
|
495
520
|
}, /*#__PURE__*/_react["default"].createElement("table", {
|
|
496
521
|
className: "resource-table"
|
|
497
522
|
}, /*#__PURE__*/_react["default"].createElement("thead", null, showWeekNumber && /*#__PURE__*/_react["default"].createElement("tr", {
|
|
498
523
|
style: {
|
|
499
|
-
height:
|
|
524
|
+
height: weekNumberRowHeight
|
|
500
525
|
}
|
|
501
526
|
}, /*#__PURE__*/_react["default"].createElement("th", {
|
|
502
527
|
style: {
|
|
503
|
-
borderBottom:
|
|
528
|
+
borderBottom: "1px solid ".concat((_config$headerBorderC2 = config.headerBorderColor) !== null && _config$headerBorderC2 !== void 0 ? _config$headerBorderC2 : '#e9e9e9'),
|
|
504
529
|
fontSize: '0.85em',
|
|
505
530
|
opacity: 0.7,
|
|
506
531
|
padding: '4px 8px'
|
|
507
532
|
}
|
|
508
|
-
},
|
|
533
|
+
}, (_config$weekNumberLab = config.weekNumberLabel) !== null && _config$weekNumberLab !== void 0 ? _config$weekNumberLab : 'Week No.')), /*#__PURE__*/_react["default"].createElement("tr", {
|
|
509
534
|
style: {
|
|
510
535
|
height: config.tableHeaderHeight
|
|
511
536
|
}
|
|
@@ -531,8 +556,8 @@ function Scheduler(props) {
|
|
|
531
556
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
532
557
|
style: {
|
|
533
558
|
overflow: 'hidden',
|
|
534
|
-
borderBottom:
|
|
535
|
-
height:
|
|
559
|
+
borderBottom: "1px solid ".concat((_config$headerBorderC3 = config.headerBorderColor) !== null && _config$headerBorderC3 !== void 0 ? _config$headerBorderC3 : '#e9e9e9'),
|
|
560
|
+
height: config.tableHeaderHeight + (showWeekNumber ? weekNumberRowHeight : 0)
|
|
536
561
|
}
|
|
537
562
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
538
563
|
style: {
|
|
@@ -555,9 +580,7 @@ function Scheduler(props) {
|
|
|
555
580
|
}
|
|
556
581
|
}, /*#__PURE__*/_react["default"].createElement("table", {
|
|
557
582
|
className: "scheduler-bg-table"
|
|
558
|
-
}, /*#__PURE__*/_react["default"].createElement(_HeaderView["default"],
|
|
559
|
-
showWeekNumber: showWeekNumber
|
|
560
|
-
})))))), /*#__PURE__*/_react["default"].createElement("div", {
|
|
583
|
+
}, /*#__PURE__*/_react["default"].createElement(_HeaderView["default"], props))))), /*#__PURE__*/_react["default"].createElement("div", {
|
|
561
584
|
style: schedulerContentStyle,
|
|
562
585
|
ref: schedulerContentRef,
|
|
563
586
|
onMouseOver: onSchedulerContentMouseOver,
|
|
@@ -643,7 +666,6 @@ Scheduler.propTypes = {
|
|
|
643
666
|
onScrollRight: _propTypes["default"].func,
|
|
644
667
|
onScrollTop: _propTypes["default"].func,
|
|
645
668
|
onScrollBottom: _propTypes["default"].func,
|
|
646
|
-
showWeekNumber: _propTypes["default"].bool,
|
|
647
669
|
CustomResourceHeader: _propTypes["default"].func,
|
|
648
670
|
CustomResourceCell: _propTypes["default"].func,
|
|
649
671
|
configTableHeaderStyle: _propTypes["default"].object
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getDefaultLabels = getDefaultLabels;
|
|
7
|
+
exports.getLabel = getLabel;
|
|
8
|
+
exports.resetLabelsProvider = resetLabelsProvider;
|
|
9
|
+
exports.setLabelsProvider = setLabelsProvider;
|
|
10
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
|
+
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; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
14
|
+
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); }
|
|
15
|
+
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); }
|
|
16
|
+
/**
|
|
17
|
+
* i18n configuration and labels provider
|
|
18
|
+
*
|
|
19
|
+
* This module provides a centralized way to manage user-facing strings in the scheduler.
|
|
20
|
+
* Users can provide localized labels either through the config or by setting a custom
|
|
21
|
+
* labels provider function.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
// Default English labels
|
|
25
|
+
var defaultLabels = {
|
|
26
|
+
resourceName: 'Resource Name',
|
|
27
|
+
taskName: 'Task Name',
|
|
28
|
+
agendaViewHeader: 'Agenda',
|
|
29
|
+
weekNumberLabel: 'Week No.'
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// Current labels provider (can be a function or object)
|
|
33
|
+
var labelsProvider = null;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Get the current label for a given key
|
|
37
|
+
* @param {string} key - The label key (e.g., 'resourceName', 'taskName')
|
|
38
|
+
* @param {string} locale - Optional locale code for locale-specific translations
|
|
39
|
+
* @returns {string} The localized label or the default English label
|
|
40
|
+
*/
|
|
41
|
+
function getLabel(key) {
|
|
42
|
+
var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
|
|
43
|
+
// If a custom provider function is set, use it
|
|
44
|
+
if (typeof labelsProvider === 'function') {
|
|
45
|
+
var label = labelsProvider(key, locale);
|
|
46
|
+
return label !== undefined && label !== null ? label : defaultLabels[key];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// If a labels object provider is set, use it with fallback
|
|
50
|
+
if (labelsProvider && _typeof(labelsProvider) === 'object') {
|
|
51
|
+
var _label = labelsProvider[key];
|
|
52
|
+
return _label !== undefined && _label !== null ? _label : defaultLabels[key];
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Fall back to default English labels
|
|
56
|
+
return defaultLabels[key];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Set a custom labels provider
|
|
61
|
+
* @param {Function|Object} provider - Either a function(key, locale) -> string or an object with label key-value pairs
|
|
62
|
+
*/
|
|
63
|
+
function setLabelsProvider(provider) {
|
|
64
|
+
labelsProvider = provider;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Get all default labels
|
|
69
|
+
* @returns {Object} Object with all default English labels
|
|
70
|
+
*/
|
|
71
|
+
function getDefaultLabels() {
|
|
72
|
+
return _objectSpread({}, defaultLabels);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Reset to default English labels
|
|
77
|
+
*/
|
|
78
|
+
function resetLabelsProvider() {
|
|
79
|
+
labelsProvider = null;
|
|
80
|
+
}
|
package/dist/config/scheduler.js
CHANGED
|
@@ -5,6 +5,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
7
|
var _default2 = require("./default");
|
|
8
|
+
/**
|
|
9
|
+
* Default scheduler configuration
|
|
10
|
+
*
|
|
11
|
+
* User-facing strings (resourceName, taskName, agendaViewHeader, weekNumberLabel)
|
|
12
|
+
* are set to English defaults but can be overridden through:
|
|
13
|
+
* 1. Passing a custom config object when creating SchedulerData
|
|
14
|
+
* 2. Using setLabelsProvider() from the i18n module to set a custom labels provider
|
|
15
|
+
* 3. Directly modifying config properties after instantiation
|
|
16
|
+
*/
|
|
8
17
|
var _default = exports["default"] = {
|
|
9
18
|
schedulerWidth: '100%',
|
|
10
19
|
besidesWidth: 20,
|
|
@@ -49,6 +58,9 @@ var _default = exports["default"] = {
|
|
|
49
58
|
summaryColor: '#666',
|
|
50
59
|
summaryPos: _default2.SummaryPos.TopRight,
|
|
51
60
|
groupOnlySlotColor: '#F8F8F8',
|
|
61
|
+
headerBorderColor: '#e9e9e9',
|
|
62
|
+
weekNumberRowHeight: 24,
|
|
63
|
+
showWeekNumber: false,
|
|
52
64
|
startResizable: true,
|
|
53
65
|
endResizable: true,
|
|
54
66
|
movable: true,
|
|
@@ -72,6 +84,7 @@ var _default = exports["default"] = {
|
|
|
72
84
|
resourceName: 'Resource Name',
|
|
73
85
|
taskName: 'Task Name',
|
|
74
86
|
agendaViewHeader: 'Agenda',
|
|
87
|
+
weekNumberLabel: 'Week No.',
|
|
75
88
|
addMorePopoverHeaderFormat: 'MMM D, YYYY dddd',
|
|
76
89
|
eventItemPopoverDateFormat: 'MMM D',
|
|
77
90
|
nonAgendaDayCellHeaderFormat: 'ha',
|
package/dist/index.d.ts
CHANGED
|
@@ -137,7 +137,7 @@ export interface CustomResourceCellProps<EventType extends EventItem = EventItem
|
|
|
137
137
|
item: ResourceEvent<EventType, ResourceType>;
|
|
138
138
|
indents: React.ReactNode[];
|
|
139
139
|
slotClickedFunc?: (schedulerData: SchedulerData<EventType>, slot: ResourceEvent<EventType, ResourceType>) => void;
|
|
140
|
-
|
|
140
|
+
handleToggleExpand: (item: ResourceEvent<EventType, ResourceType>) => void;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
export interface AddMorePopoverProps<EventType extends EventItem = EventItem> {
|
|
@@ -415,6 +415,10 @@ export interface SchedulerDataConfig {
|
|
|
415
415
|
minuteStep?: number;
|
|
416
416
|
views?: View[];
|
|
417
417
|
responsiveByParent?: boolean;
|
|
418
|
+
showWeekNumber?: boolean;
|
|
419
|
+
weekNumberRowHeight?: number;
|
|
420
|
+
weekNumberLabel?: string;
|
|
421
|
+
headerBorderColor?: string;
|
|
418
422
|
}
|
|
419
423
|
|
|
420
424
|
export enum SummaryPos {
|
package/dist/index.js
CHANGED
|
@@ -69,6 +69,30 @@ Object.defineProperty(exports, "ViewType", {
|
|
|
69
69
|
return _index.ViewType;
|
|
70
70
|
}
|
|
71
71
|
});
|
|
72
|
+
Object.defineProperty(exports, "getDefaultLabels", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function get() {
|
|
75
|
+
return _i18n.getDefaultLabels;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(exports, "getLabel", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
get: function get() {
|
|
81
|
+
return _i18n.getLabel;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
Object.defineProperty(exports, "resetLabelsProvider", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
get: function get() {
|
|
87
|
+
return _i18n.resetLabelsProvider;
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
Object.defineProperty(exports, "setLabelsProvider", {
|
|
91
|
+
enumerable: true,
|
|
92
|
+
get: function get() {
|
|
93
|
+
return _i18n.setLabelsProvider;
|
|
94
|
+
}
|
|
95
|
+
});
|
|
72
96
|
Object.defineProperty(exports, "wrapperFun", {
|
|
73
97
|
enumerable: true,
|
|
74
98
|
get: function get() {
|
|
@@ -76,4 +100,5 @@ Object.defineProperty(exports, "wrapperFun", {
|
|
|
76
100
|
}
|
|
77
101
|
});
|
|
78
102
|
require("./css/style.css");
|
|
79
|
-
var _index = require("./components/index");
|
|
103
|
+
var _index = require("./components/index");
|
|
104
|
+
var _i18n = require("./config/i18n");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "makula-schedule",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
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",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"url": "https://github.com/Makula-Technology-GmbH/makula-scheduler/issues"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
|
+
"access": "public",
|
|
52
53
|
"registry": "https://registry.npmjs.org/"
|
|
53
54
|
},
|
|
54
55
|
"scripts": {
|
|
@@ -69,43 +70,43 @@
|
|
|
69
70
|
"antd": "^4.24.0",
|
|
70
71
|
"dayjs": "^1.11.19",
|
|
71
72
|
"prop-types": "^15.8.1",
|
|
72
|
-
"react
|
|
73
|
-
"
|
|
74
|
-
"react": "^
|
|
75
|
-
"
|
|
73
|
+
"react": "^19.2.4",
|
|
74
|
+
"react-dom": "^19.2.4",
|
|
75
|
+
"react-router-dom": "^7.13.0",
|
|
76
|
+
"rrule": "^2.8.1"
|
|
76
77
|
},
|
|
77
78
|
"peerDependencies": {
|
|
78
79
|
"react-dnd": ">=14.0.0",
|
|
79
80
|
"react-dnd-html5-backend": ">=14.0.0"
|
|
80
81
|
},
|
|
81
82
|
"devDependencies": {
|
|
82
|
-
"@babel/cli": "^7.28.
|
|
83
|
+
"@babel/cli": "^7.28.6",
|
|
83
84
|
"@babel/core": "^7.28.5",
|
|
84
|
-
"@babel/eslint-parser": "^7.28.
|
|
85
|
-
"@babel/preset-env": "^7.
|
|
85
|
+
"@babel/eslint-parser": "^7.28.6",
|
|
86
|
+
"@babel/preset-env": "^7.29.0",
|
|
86
87
|
"@babel/preset-react": "^7.28.5",
|
|
87
88
|
"babel-loader": "^10.0.0",
|
|
88
89
|
"copy-webpack-plugin": "^13.0.1",
|
|
89
|
-
"css-loader": "^7.1.
|
|
90
|
+
"css-loader": "^7.1.3",
|
|
90
91
|
"eslint": "^9.39.2",
|
|
91
92
|
"eslint-config-prettier": "^10.1.8",
|
|
92
93
|
"eslint-plugin-import": "^2.32.0",
|
|
93
94
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
94
|
-
"eslint-plugin-prettier": "^5.5.
|
|
95
|
+
"eslint-plugin-prettier": "^5.5.5",
|
|
95
96
|
"eslint-plugin-react": "^7.37.5",
|
|
96
97
|
"eslint-plugin-react-hooks": "^7.0.1",
|
|
97
98
|
"eslint-webpack-plugin": "^5.0.2",
|
|
98
99
|
"fs-extra": "^11.3.3",
|
|
99
100
|
"glob-all": "^3.3.1",
|
|
100
|
-
"html-webpack-plugin": "^5.6.
|
|
101
|
+
"html-webpack-plugin": "^5.6.6",
|
|
101
102
|
"mini-css-extract-plugin": "^2.9.4",
|
|
102
103
|
"postcss": "^8.5.6",
|
|
103
104
|
"postcss-loader": "^8.2.0",
|
|
104
|
-
"prettier": "^3.
|
|
105
|
+
"prettier": "^3.8.0",
|
|
105
106
|
"purgecss-webpack-plugin": "^8.0.0",
|
|
106
107
|
"style-loader": "^4.0.0",
|
|
107
108
|
"webpack": "^5.104.1",
|
|
108
109
|
"webpack-cli": "^6.0.1",
|
|
109
|
-
"webpack-dev-server": "^5.2.
|
|
110
|
+
"webpack-dev-server": "^5.2.3"
|
|
110
111
|
}
|
|
111
112
|
}
|