react-big-schedule 5.3.1 → 5.4.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.
@@ -13,13 +13,30 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
13
13
  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; }
14
14
  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; }
15
15
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
16
- 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); }
16
+ 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); } /**
17
+ * Render the scheduler's resource table with hierarchical indentation, optional expand/collapse controls,
18
+ * clickable slot names, and support for custom slot templates or an injected resource-cell renderer.
19
+ *
20
+ * @param {object} schedulerData - Scheduler state and helpers; must include `renderData`,
21
+ * `getResourceTableWidth`, and `config`.
22
+ * @param {number} contentScrollbarHeight - Height used to set the container's bottom padding.
23
+ * @param {Function} [slotClickedFunc] - Called as `slotClickedFunc(schedulerData, item)` when a slot name is clicked.
24
+ * @param {Function} [slotItemTemplateResolver] - Called as `slotItemTemplateResolver
25
+ * (schedulerData, item, slotClickedFunc, width, className)` to provide a custom slot cell element;
26
+ * if a value is returned it replaces the default slot cell.
27
+ * @param {Function} [toggleExpandFunc] - Called as `toggleExpandFunc(schedulerData, slotId)`
28
+ * to toggle expansion for items with children.
29
+ * @param {Function} [CustomResourceCell] - Optional React component rendered inside the resource
30
+ * `<td>` when provided; receives props `{ schedulerData, item, indents, slotClickedFunc, handleToggleExpand }`.
31
+ * @returns {JSX.Element} The rendered resource table element.
32
+ */
17
33
  function ResourceView(_ref) {
18
34
  var schedulerData = _ref.schedulerData,
19
35
  contentScrollbarHeight = _ref.contentScrollbarHeight,
20
36
  slotClickedFunc = _ref.slotClickedFunc,
21
37
  slotItemTemplateResolver = _ref.slotItemTemplateResolver,
22
- toggleExpandFunc = _ref.toggleExpandFunc;
38
+ toggleExpandFunc = _ref.toggleExpandFunc,
39
+ CustomResourceCell = _ref.CustomResourceCell;
23
40
  var renderData = schedulerData.renderData;
24
41
  var width = schedulerData.getResourceTableWidth() - 2;
25
42
  var paddingBottom = contentScrollbarHeight;
@@ -44,6 +61,25 @@ function ResourceView(_ref) {
44
61
  indent = item.expanded ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.MinusSquareOutlined, _objectSpread({}, iconProps), "es".concat(item.indent)) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_icons.PlusSquareOutlined, _objectSpread({}, iconProps), "es".concat(item.indent));
45
62
  }
46
63
  indents.push(indent);
64
+ var tdStyle = {
65
+ height: item.rowHeight,
66
+ backgroundColor: item.groupOnly ? schedulerData.config.groupOnlySlotColor : undefined
67
+ };
68
+ if (CustomResourceCell) {
69
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("tr", {
70
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("td", {
71
+ "data-resource-id": item.slotId,
72
+ style: tdStyle,
73
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(CustomResourceCell, {
74
+ schedulerData: schedulerData,
75
+ item: item,
76
+ indents: indents,
77
+ slotClickedFunc: slotClickedFunc,
78
+ handleToggleExpand: handleToggleExpand
79
+ })
80
+ })
81
+ }, item.slotId);
82
+ }
47
83
  var slotCell = slotClickedFunc ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
48
84
  className: "slot-cell",
49
85
  children: [indents, /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
@@ -82,10 +118,6 @@ function ResourceView(_ref) {
82
118
  slotItem = resolvedTemplate;
83
119
  }
84
120
  }
85
- var tdStyle = {
86
- height: item.rowHeight,
87
- backgroundColor: item.groupOnly ? schedulerData.config.groupOnlySlotColor : undefined
88
- };
89
121
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("tr", {
90
122
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("td", {
91
123
  "data-resource-id": item.slotId,
@@ -120,6 +152,7 @@ ResourceView.propTypes = {
120
152
  contentScrollbarHeight: _propTypes["default"].number.isRequired,
121
153
  slotClickedFunc: _propTypes["default"].func,
122
154
  slotItemTemplateResolver: _propTypes["default"].func,
123
- toggleExpandFunc: _propTypes["default"].func
155
+ toggleExpandFunc: _propTypes["default"].func,
156
+ CustomResourceCell: _propTypes["default"].func
124
157
  };
125
158
  var _default = exports["default"] = ResourceView;
@@ -846,54 +846,6 @@ var SchedulerData = exports["default"] = /*#__PURE__*/function () {
846
846
  }
847
847
  this.headers = headers;
848
848
  }
849
-
850
- // Fix Optimited code
851
- // _createHeaders() {
852
- // const headers = [];
853
- // const start = this.localeDayjs(new Date(this.startDate));
854
- // const end = this.localeDayjs(new Date(this.endDate));
855
-
856
- // const processHeader = (header, format, unit, incrementFn) => {
857
- // let head = header;
858
- // while (head >= start && head <= end) {
859
- // const time = head.format(format);
860
- // if (unit === CellUnit.Day) {
861
- // const dayOfWeek = head.weekday();
862
- // if (this.config.displayWeekend || (dayOfWeek !== 0 && dayOfWeek !== 6)) {
863
- // const nonWorkingTime = this.behaviors.isNonWorkingTimeFunc(this, time);
864
- // headers.push({ time, nonWorkingTime });
865
- // }
866
- // } else {
867
- // headers.push({ time });
868
- // }
869
- // head = head.add(1, incrementFn);
870
- // }
871
- // };
872
-
873
- // if (this.showAgenda) {
874
- // headers.push({ time: start.format(DATETIME_FORMAT), nonWorkingTime: false });
875
- // } else if (this.cellUnit === CellUnit.Hour) {
876
- // const hourIncrement = this.config.minuteStep < 60 ? 'minutes' : 'hours';
877
- // const minuteSteps = this.getMinuteStepsInHour();
878
- // let header = start.hour() === 0 ? start.add(this.config.dayStartFrom, 'hours') : start;
879
- // while (header <= end) {
880
- // const hour = header.hour();
881
- // if (hour >= this.config.dayStartFrom && hour <= this.config.dayStopTo) {
882
- // const time = header.format(DATETIME_FORMAT);
883
- // const nonWorkingTime = this.behaviors.isNonWorkingTimeFunc(this, time);
884
- // headers.push({ time, nonWorkingTime });
885
- // }
886
- // header = header.add(minuteSteps, hourIncrement);
887
- // }
888
- // } else {
889
- // const header = start;
890
- // const format = this.cellUnit === CellUnit.Day ? DATETIME_FORMAT : DATE_FORMAT;
891
- // const incrementFn = this.cellUnit === CellUnit.Day ? 'days' : `${this.cellUnit}s`;
892
- // processHeader(header, format, this.cellUnit, incrementFn);
893
- // }
894
-
895
- // this.headers = headers;
896
- // }
897
849
  }, {
898
850
  key: "_createInitHeaderEvents",
899
851
  value: function _createInitHeaderEvents(header) {
@@ -103,14 +103,12 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
103
103
  function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
104
104
  function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
105
105
  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; } /**
106
- * Render a configurable scheduler UI with optional resource and agenda views,
107
- * responsive sizing, and drag-and-drop support.
106
+ * Render the scheduler UI with resource and agenda views, responsive sizing, and drag-and-drop support.
108
107
  *
109
108
  * @param {object} props - Component properties.
110
- * @param {SchedulerData} props.schedulerData - Core scheduler state and configuration used
111
- * to drive rendering and behavior.
112
- * @param {Array<DnDSource>} [props.dndSources] - Additional drag-and-drop sources to merge
113
- * into the scheduler's DnD context.
109
+ * @param {SchedulerData} props.schedulerData - Scheduler state and configuration used to drive rendering and behavior.
110
+ * @param {Array<DnDSource>} [props.dndSources] - Additional drag-and-drop sources to merge into the
111
+ * scheduler's DnD context.
114
112
  * @param {React.RefObject<HTMLElement>} [props.parentRef] - Parent element ref used when sizing
115
113
  * is driven by the parent container.
116
114
  * @param {function(SchedulerData):void} props.prevClick - Callback invoked to navigate to the previous range.
@@ -121,7 +119,10 @@ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length)
121
119
  * @param {React.ReactNode} [props.leftCustomHeader] - Optional custom content rendered on the left side of the header.
122
120
  * @param {React.ReactNode} [props.rightCustomHeader] - Optional custom content rendered on the
123
121
  * right side of the header.
124
- * @returns {JSX.Element} The scheduler element tree to be rendered.
122
+ * @param {function} [props.CustomResourceHeader] - Optional component used to render the resource header cell.
123
+ * @param {object} [props.configTableHeaderStyle] - Optional inline style object applied
124
+ * to the resource header container.
125
+ * @returns {JSX.Element} The scheduler root element tree to be rendered.
125
126
  */
126
127
  function Scheduler(props) {
127
128
  var schedulerData = props.schedulerData,
@@ -132,7 +133,9 @@ function Scheduler(props) {
132
133
  onViewChange = props.onViewChange,
133
134
  onSelectDate = props.onSelectDate,
134
135
  leftCustomHeader = props.leftCustomHeader,
135
- rightCustomHeader = props.rightCustomHeader;
136
+ rightCustomHeader = props.rightCustomHeader,
137
+ CustomResourceHeader = props.CustomResourceHeader,
138
+ configTableHeaderStyle = props.configTableHeaderStyle;
136
139
 
137
140
  // Initialize DnD context
138
141
  var initDndContext = function initDndContext() {
@@ -499,10 +502,10 @@ function Scheduler(props) {
499
502
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
500
503
  className: "resource-view",
501
504
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
502
- style: {
505
+ style: _objectSpread({
503
506
  borderBottom: "1px solid ".concat((_config$headerBorderC = config.headerBorderColor) !== null && _config$headerBorderC !== void 0 ? _config$headerBorderC : '#e9e9e9'),
504
507
  height: config.tableHeaderHeight + (showWeekNumber ? weekNumberRowHeight : 0)
505
- },
508
+ }, configTableHeaderStyle),
506
509
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
507
510
  style: {
508
511
  overflowX: 'scroll',
@@ -531,7 +534,7 @@ function Scheduler(props) {
531
534
  },
532
535
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("th", {
533
536
  className: "header3-text",
534
- children: resourceName
537
+ children: CustomResourceHeader ? /*#__PURE__*/(0, _jsxRuntime.jsx)(CustomResourceHeader, {}) : resourceName
535
538
  })
536
539
  })]
537
540
  })
@@ -687,5 +690,8 @@ Scheduler.propTypes = {
687
690
  onScrollLeft: _propTypes["default"].func,
688
691
  onScrollRight: _propTypes["default"].func,
689
692
  onScrollTop: _propTypes["default"].func,
690
- onScrollBottom: _propTypes["default"].func
693
+ onScrollBottom: _propTypes["default"].func,
694
+ CustomResourceHeader: _propTypes["default"].func,
695
+ CustomResourceCell: _propTypes["default"].func,
696
+ configTableHeaderStyle: _propTypes["default"].object
691
697
  };
package/dist/index.d.ts CHANGED
@@ -119,6 +119,17 @@ export interface SchedulerProps<EventType extends EventItem = EventItem> {
119
119
  rightCustomHeader?: React.ReactNode;
120
120
  dndSources?: DnDSource[];
121
121
  parentRef?: React.RefObject<any>;
122
+ CustomResourceHeader?: React.ComponentType<any>;
123
+ CustomResourceCell?: React.ComponentType<CustomResourceCellProps<EventType>>;
124
+ configTableHeaderStyle?: CSSProperties;
125
+ }
126
+
127
+ export interface CustomResourceCellProps<EventType extends EventItem = EventItem> {
128
+ schedulerData: SchedulerData<EventType>;
129
+ item: ResourceEvent<EventType>;
130
+ indents: React.ReactNode[];
131
+ slotClickedFunc?: (schedulerData: SchedulerData<EventType>, slot: ResourceEvent<EventType>) => void;
132
+ handleToggleExpand: (item: ResourceEvent<EventType>) => void;
122
133
  }
123
134
 
124
135
  export interface AddMorePopoverProps<EventType extends EventItem = EventItem> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-big-schedule",
3
- "version": "5.3.1",
3
+ "version": "5.4.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",