react-big-schedule 5.5.2-beta.4 → 6.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.
@@ -1,20 +1,8 @@
1
- "use strict";
1
+ import { MinusSquareOutlined, PlusSquareOutlined } from '@ant-design/icons';
2
+ import PropTypes from 'prop-types';
3
+ import React from 'react';
2
4
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _icons = require("@ant-design/icons");
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
- var _react = _interopRequireDefault(require("react"));
10
- var _jsxRuntime = require("react/jsx-runtime");
11
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
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 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; }
14
- 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; }
15
- 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; }
16
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
17
- 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); } /**
5
+ /**
18
6
  * Render the scheduler's resource table with hierarchical indentation, optional expand/collapse controls,
19
7
  * clickable slot names, and support for custom slot templates or an injected resource-cell renderer.
20
8
  *
@@ -31,63 +19,67 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
31
19
  * `<td>` when provided; receives props `{ schedulerData, item, indents, slotClickedFunc, handleToggleExpand }`.
32
20
  * @returns {JSX.Element} The rendered resource table element.
33
21
  */
34
- function ResourceView(_ref) {
35
- var schedulerData = _ref.schedulerData,
36
- contentScrollbarHeight = _ref.contentScrollbarHeight,
37
- slotClickedFunc = _ref.slotClickedFunc,
38
- slotItemTemplateResolver = _ref.slotItemTemplateResolver,
39
- toggleExpandFunc = _ref.toggleExpandFunc,
40
- CustomResourceCell = _ref.CustomResourceCell,
41
- isSelecting = _ref.isSelecting,
42
- selectedResourceIds = _ref.selectedResourceIds;
43
- var renderData = schedulerData.renderData;
44
- var width = schedulerData.getResourceTableWidth() - 2;
45
- var paddingBottom = contentScrollbarHeight;
46
- var displayRenderData = renderData.filter(function (o) {
47
- return o.render;
48
- });
49
- var handleToggleExpand = function handleToggleExpand(item) {
22
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
23
+ function ResourceView({
24
+ schedulerData,
25
+ contentScrollbarHeight,
26
+ slotClickedFunc,
27
+ slotItemTemplateResolver,
28
+ toggleExpandFunc,
29
+ CustomResourceCell,
30
+ isSelecting,
31
+ selectedResourceIds
32
+ }) {
33
+ const {
34
+ renderData
35
+ } = schedulerData;
36
+ const width = schedulerData.getResourceTableWidth() - 2;
37
+ const paddingBottom = contentScrollbarHeight;
38
+ const displayRenderData = renderData.filter(o => o.render);
39
+ const handleToggleExpand = item => {
50
40
  if (toggleExpandFunc) {
51
41
  toggleExpandFunc(schedulerData, item.slotId);
52
42
  }
53
43
  };
54
- var renderSlotItem = function renderSlotItem(item, indents) {
55
- var indent = /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
44
+ const renderSlotItem = (item, indents) => {
45
+ let indent = /*#__PURE__*/_jsx("span", {
56
46
  className: "expander-space"
57
- }, "es".concat(item.indent));
58
- var iconProps = {
59
- onClick: function onClick() {
60
- return handleToggleExpand(item);
61
- }
47
+ }, `es${item.indent}`);
48
+ const iconProps = {
49
+ onClick: () => handleToggleExpand(item)
62
50
  };
63
51
  if (item.hasChildren) {
64
- 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));
52
+ indent = item.expanded ? /*#__PURE__*/_jsx(MinusSquareOutlined, {
53
+ ...iconProps
54
+ }, `es${item.indent}`) : /*#__PURE__*/_jsx(PlusSquareOutlined, {
55
+ ...iconProps
56
+ }, `es${item.indent}`);
65
57
  }
66
58
  indents.push(indent);
67
- var tdStyle = {
59
+ const tdStyle = {
68
60
  height: item.rowHeight,
69
61
  backgroundColor: item.groupOnly ? schedulerData.config.groupOnlySlotColor : undefined,
70
62
  borderLeft: '3px solid transparent'
71
63
  };
72
- var selectedBorderColor = schedulerData.config.selectedSlotBorderColor || '#1677ff';
73
- var selectedShadowColor = schedulerData.config.selectedSlotShadowColor || '#91caff';
74
- var selectedSlotColor = schedulerData.config.selectedSlotColor || '#e6f4ff';
75
- var hasSelectedResourceId = selectedResourceIds instanceof Set ? selectedResourceIds.has(item.slotId) : Array.isArray(selectedResourceIds) && selectedResourceIds.includes(item.slotId);
76
- var isRowSelected = isSelecting && hasSelectedResourceId;
64
+ const selectedBorderColor = schedulerData.config.selectedSlotBorderColor || '#1677ff';
65
+ const selectedShadowColor = schedulerData.config.selectedSlotShadowColor || '#91caff';
66
+ const selectedSlotColor = schedulerData.config.selectedSlotColor || '#e6f4ff';
67
+ const hasSelectedResourceId = selectedResourceIds instanceof Set ? selectedResourceIds.has(item.slotId) : Array.isArray(selectedResourceIds) && selectedResourceIds.includes(item.slotId);
68
+ const isRowSelected = isSelecting && hasSelectedResourceId;
77
69
  if (isRowSelected) {
78
- tdStyle.borderLeft = "3px solid ".concat(selectedBorderColor);
79
- tdStyle.boxShadow = "inset 0 0 0 1px ".concat(selectedShadowColor);
70
+ tdStyle.borderLeft = `3px solid ${selectedBorderColor}`;
71
+ tdStyle.boxShadow = `inset 0 0 0 1px ${selectedShadowColor}`;
80
72
  if (!item.groupOnly) {
81
73
  tdStyle.backgroundColor = selectedSlotColor;
82
74
  }
83
75
  }
84
76
  if (CustomResourceCell) {
85
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("tr", {
77
+ return /*#__PURE__*/_jsx("tr", {
86
78
  "aria-selected": isRowSelected,
87
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("td", {
79
+ children: /*#__PURE__*/_jsx("td", {
88
80
  "data-resource-id": item.slotId,
89
81
  style: tdStyle,
90
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(CustomResourceCell, {
82
+ children: /*#__PURE__*/_jsx(CustomResourceCell, {
91
83
  schedulerData: schedulerData,
92
84
  item: item,
93
85
  indents: indents,
@@ -97,22 +89,20 @@ function ResourceView(_ref) {
97
89
  })
98
90
  }, item.slotId);
99
91
  }
100
- var slotCell = slotClickedFunc ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
92
+ const slotCell = slotClickedFunc ? /*#__PURE__*/_jsxs("span", {
101
93
  className: "slot-cell",
102
- children: [indents, /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
94
+ children: [indents, /*#__PURE__*/_jsx("button", {
103
95
  type: "button",
104
96
  style: {
105
97
  cursor: 'pointer'
106
98
  },
107
99
  className: "slot-text rbs-txt-btn-dis",
108
- onClick: function onClick() {
109
- return slotClickedFunc(schedulerData, item);
110
- },
100
+ onClick: () => slotClickedFunc(schedulerData, item),
111
101
  children: item.slotName
112
102
  })]
113
- }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
103
+ }) : /*#__PURE__*/_jsxs("span", {
114
104
  className: "slot-cell",
115
- children: [indents, /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
105
+ children: [indents, /*#__PURE__*/_jsx("button", {
116
106
  type: "button",
117
107
  className: "slot-text rbs-txt-btn-dis",
118
108
  style: {
@@ -121,7 +111,7 @@ function ResourceView(_ref) {
121
111
  children: item.slotName
122
112
  })]
123
113
  });
124
- var slotItem = /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
114
+ let slotItem = /*#__PURE__*/_jsx("div", {
125
115
  title: item.slotTitle || item.slotName,
126
116
  className: "overflow-text header2-text",
127
117
  style: {
@@ -130,50 +120,50 @@ function ResourceView(_ref) {
130
120
  children: slotCell
131
121
  });
132
122
  if (slotItemTemplateResolver) {
133
- var resolvedTemplate = slotItemTemplateResolver(schedulerData, item, slotClickedFunc, width, 'overflow-text header2-text');
123
+ const resolvedTemplate = slotItemTemplateResolver(schedulerData, item, slotClickedFunc, width, 'overflow-text header2-text');
134
124
  if (resolvedTemplate) {
135
125
  slotItem = resolvedTemplate;
136
126
  }
137
127
  }
138
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("tr", {
128
+ return /*#__PURE__*/_jsx("tr", {
139
129
  "aria-selected": isRowSelected,
140
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("td", {
130
+ children: /*#__PURE__*/_jsx("td", {
141
131
  "data-resource-id": item.slotId,
142
132
  style: tdStyle,
143
133
  children: slotItem
144
134
  })
145
135
  }, item.slotId);
146
136
  };
147
- var resourceList = displayRenderData.map(function (item) {
148
- var indents = [];
149
- for (var i = 0; i < item.indent; i += 1) {
150
- indents.push(/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
137
+ const resourceList = displayRenderData.map(item => {
138
+ const indents = [];
139
+ for (let i = 0; i < item.indent; i += 1) {
140
+ indents.push(/*#__PURE__*/_jsx("span", {
151
141
  className: "expander-space"
152
- }, "es".concat(i)));
142
+ }, `es${i}`));
153
143
  }
154
144
  return renderSlotItem(item, indents);
155
145
  });
156
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("section", {
146
+ return /*#__PURE__*/_jsx("section", {
157
147
  style: {
158
- paddingBottom: paddingBottom
148
+ paddingBottom
159
149
  },
160
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("table", {
150
+ children: /*#__PURE__*/_jsx("table", {
161
151
  className: "resource-table",
162
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("tbody", {
152
+ children: /*#__PURE__*/_jsx("tbody", {
163
153
  children: resourceList
164
154
  })
165
155
  })
166
156
  });
167
157
  }
168
158
  ResourceView.propTypes = {
169
- schedulerData: _propTypes["default"].object.isRequired,
170
- schedulerDataVersion: _propTypes["default"].number,
171
- contentScrollbarHeight: _propTypes["default"].number.isRequired,
172
- slotClickedFunc: _propTypes["default"].func,
173
- slotItemTemplateResolver: _propTypes["default"].func,
174
- toggleExpandFunc: _propTypes["default"].func,
175
- CustomResourceCell: _propTypes["default"].func,
176
- isSelecting: _propTypes["default"].bool,
177
- selectedResourceIds: _propTypes["default"].oneOfType([_propTypes["default"].arrayOf(_propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number])), _propTypes["default"].instanceOf(Set)])
159
+ schedulerData: PropTypes.object.isRequired,
160
+ schedulerDataVersion: PropTypes.number,
161
+ contentScrollbarHeight: PropTypes.number.isRequired,
162
+ slotClickedFunc: PropTypes.func,
163
+ slotItemTemplateResolver: PropTypes.func,
164
+ toggleExpandFunc: PropTypes.func,
165
+ CustomResourceCell: PropTypes.func,
166
+ isSelecting: PropTypes.bool,
167
+ selectedResourceIds: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])), PropTypes.instanceOf(Set)])
178
168
  };
179
- var _default = exports["default"] = /*#__PURE__*/_react["default"].memo(ResourceView);
169
+ export default /*#__PURE__*/React.memo(ResourceView);