gantt-task-react-powern 0.6.30 → 0.6.31
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/dist/helpers/date-helper.d.ts +16 -0
- package/dist/index.js +59 -21
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +59 -21
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
|
@@ -5,6 +5,22 @@ declare type DateHelperScales = "year" | "quarter" | "month" | "day" | "hour" |
|
|
|
5
5
|
export declare const getCachedDateTimeFormat: (locString: string | string[], opts?: DateTimeFormatOptions) => DateTimeFormat;
|
|
6
6
|
export declare const addToDate: (date: Date, quantity: number, scale: DateHelperScales) => Date;
|
|
7
7
|
export declare const startOfDate: (date: Date, scale: DateHelperScales) => Date;
|
|
8
|
+
/**
|
|
9
|
+
* Default number of columns the chart aims to render across the chart pane
|
|
10
|
+
* for each view mode. The Gantt component sizes columns so that this many
|
|
11
|
+
* fit at the current pane width when the view mode is selected.
|
|
12
|
+
*
|
|
13
|
+
* Modes not listed (Hour / QuarterDay / HalfDay / Year) fall through to the
|
|
14
|
+
* legacy `columnWidth` default.
|
|
15
|
+
*/
|
|
16
|
+
export declare const VIEW_MODE_DEFAULT_VISIBLE_COUNT: Partial<Record<ViewMode, number>>;
|
|
17
|
+
/**
|
|
18
|
+
* Maximum number of columns the chart will show at once, even when the user
|
|
19
|
+
* widens the chart pane with the resize bar. The Gantt component clamps
|
|
20
|
+
* column width upward so visible count never exceeds this — overflow becomes
|
|
21
|
+
* horizontal scroll.
|
|
22
|
+
*/
|
|
23
|
+
export declare const VIEW_MODE_MAX_VISIBLE_COUNT: Partial<Record<ViewMode, number>>;
|
|
8
24
|
export declare const ganttDateRange: (tasks: Task[], viewMode: ViewMode, preStepsCount: number, quarterStart?: number) => Date[];
|
|
9
25
|
export declare const seedDates: (startDate: Date, endDate: Date, viewMode: ViewMode) => Date[];
|
|
10
26
|
export declare const getLocaleMonth: (date: Date, locale: string) => string;
|
package/dist/index.js
CHANGED
|
@@ -75,6 +75,7 @@ function _createForOfIteratorHelperLoose(o, allowArrayLike) {
|
|
|
75
75
|
ViewMode["Year"] = "Year";
|
|
76
76
|
})(exports.ViewMode || (exports.ViewMode = {}));
|
|
77
77
|
|
|
78
|
+
var _VIEW_MODE_DEFAULT_VI, _VIEW_MODE_MAX_VISIBL;
|
|
78
79
|
var intlDTCache = {};
|
|
79
80
|
var getCachedDateTimeFormat = function getCachedDateTimeFormat(locString, opts) {
|
|
80
81
|
if (opts === void 0) {
|
|
@@ -116,6 +117,8 @@ var getFiscalQuarterStartDate = function getFiscalQuarterStartDate(date, quarter
|
|
|
116
117
|
return new Date(year, qStartMonth, 1);
|
|
117
118
|
};
|
|
118
119
|
|
|
120
|
+
var VIEW_MODE_DEFAULT_VISIBLE_COUNT = (_VIEW_MODE_DEFAULT_VI = {}, _VIEW_MODE_DEFAULT_VI[exports.ViewMode.Day] = 14, _VIEW_MODE_DEFAULT_VI[exports.ViewMode.Week] = 6, _VIEW_MODE_DEFAULT_VI[exports.ViewMode.Month] = 6, _VIEW_MODE_DEFAULT_VI[exports.ViewMode.Quarter] = 4, _VIEW_MODE_DEFAULT_VI);
|
|
121
|
+
var VIEW_MODE_MAX_VISIBLE_COUNT = (_VIEW_MODE_MAX_VISIBL = {}, _VIEW_MODE_MAX_VISIBL[exports.ViewMode.Day] = 30, _VIEW_MODE_MAX_VISIBL[exports.ViewMode.Week] = 13, _VIEW_MODE_MAX_VISIBL[exports.ViewMode.Month] = 12, _VIEW_MODE_MAX_VISIBL[exports.ViewMode.Quarter] = 8, _VIEW_MODE_MAX_VISIBL);
|
|
119
122
|
var ganttDateRange = function ganttDateRange(tasks, viewMode, preStepsCount, quarterStart) {
|
|
120
123
|
var _tasks$, _tasks$2, _tasks$3, _tasks$4;
|
|
121
124
|
|
|
@@ -3805,6 +3808,8 @@ var HorizontalScroll = function HorizontalScroll(_ref) {
|
|
|
3805
3808
|
};
|
|
3806
3809
|
|
|
3807
3810
|
var Gantt = function Gantt(_ref) {
|
|
3811
|
+
var _ref3;
|
|
3812
|
+
|
|
3808
3813
|
var tasks = _ref.tasks,
|
|
3809
3814
|
_ref$leafTasks = _ref.leafTasks,
|
|
3810
3815
|
leafTasks = _ref$leafTasks === void 0 ? [] : _ref$leafTasks,
|
|
@@ -3816,8 +3821,7 @@ var Gantt = function Gantt(_ref) {
|
|
|
3816
3821
|
endDate = _ref$endDate === void 0 ? new Date() : _ref$endDate,
|
|
3817
3822
|
_ref$headerHeight = _ref.headerHeight,
|
|
3818
3823
|
headerHeight = _ref$headerHeight === void 0 ? 50 : _ref$headerHeight,
|
|
3819
|
-
|
|
3820
|
-
columnWidth = _ref$columnWidth === void 0 ? 60 : _ref$columnWidth,
|
|
3824
|
+
columnWidthProp = _ref.columnWidth,
|
|
3821
3825
|
_ref$listCellWidth = _ref.listCellWidth,
|
|
3822
3826
|
listCellWidth = _ref$listCellWidth === void 0 ? "155px" : _ref$listCellWidth,
|
|
3823
3827
|
_ref$rowHeight = _ref.rowHeight,
|
|
@@ -3898,6 +3902,7 @@ var Gantt = function Gantt(_ref) {
|
|
|
3898
3902
|
var wrapperRef = React.useRef(null);
|
|
3899
3903
|
var taskListRef = React.useRef(null);
|
|
3900
3904
|
var isDraggingTable = React.useRef(false);
|
|
3905
|
+
var userResizedRef = React.useRef(false);
|
|
3901
3906
|
var dragStartX = React.useRef(0);
|
|
3902
3907
|
var dragStartWidth = React.useRef(0);
|
|
3903
3908
|
var dragMaxWidth = React.useRef(Infinity);
|
|
@@ -3954,6 +3959,7 @@ var Gantt = function Gantt(_ref) {
|
|
|
3954
3959
|
var _taskListRef$current$, _taskListRef$current, _ref2, _tableHorizontalConta, _tableHorizontalConta2, _tableInnerScrollRef$, _wrapperRef$current$o, _wrapperRef$current;
|
|
3955
3960
|
|
|
3956
3961
|
isDraggingTable.current = true;
|
|
3962
|
+
userResizedRef.current = true;
|
|
3957
3963
|
dragStartX.current = e.clientX;
|
|
3958
3964
|
dragStartWidth.current = tableContainerWidth != null ? tableContainerWidth : (_taskListRef$current$ = (_taskListRef$current = taskListRef.current) === null || _taskListRef$current === void 0 ? void 0 : _taskListRef$current.offsetWidth) != null ? _taskListRef$current$ : 0;
|
|
3959
3965
|
dragMaxWidth.current = (_ref2 = (_tableHorizontalConta = (_tableHorizontalConta2 = tableHorizontalContainerRef.current) === null || _tableHorizontalConta2 === void 0 ? void 0 : _tableHorizontalConta2.scrollWidth) != null ? _tableHorizontalConta : (_tableInnerScrollRef$ = tableInnerScrollRef.current) === null || _tableInnerScrollRef$ === void 0 ? void 0 : _tableInnerScrollRef$.scrollWidth) != null ? _ref2 : Math.max(100, ((_wrapperRef$current$o = (_wrapperRef$current = wrapperRef.current) === null || _wrapperRef$current === void 0 ? void 0 : _wrapperRef$current.offsetWidth) != null ? _wrapperRef$current$o : Infinity) - 200);
|
|
@@ -4020,38 +4026,70 @@ var Gantt = function Gantt(_ref) {
|
|
|
4020
4026
|
failedTask = _useState11[0],
|
|
4021
4027
|
setFailedTask = _useState11[1];
|
|
4022
4028
|
|
|
4029
|
+
var _useState12 = React.useState(null),
|
|
4030
|
+
computedColumnWidth = _useState12[0],
|
|
4031
|
+
setComputedColumnWidth = _useState12[1];
|
|
4032
|
+
|
|
4033
|
+
var computedForViewModeRef = React.useRef(null);
|
|
4034
|
+
React.useEffect(function () {
|
|
4035
|
+
if (columnWidthProp != null) return;
|
|
4036
|
+
if (svgContainerWidth <= 0) return;
|
|
4037
|
+
var alreadySnappedForView = computedForViewModeRef.current === viewMode && computedColumnWidth != null;
|
|
4038
|
+
if (userResizedRef.current && alreadySnappedForView) return;
|
|
4039
|
+
var target = VIEW_MODE_DEFAULT_VISIBLE_COUNT[viewMode];
|
|
4040
|
+
if (!target) return;
|
|
4041
|
+
var next = Math.max(20, Math.floor(svgContainerWidth / target));
|
|
4042
|
+
|
|
4043
|
+
if (next !== computedColumnWidth) {
|
|
4044
|
+
setComputedColumnWidth(next);
|
|
4045
|
+
}
|
|
4046
|
+
|
|
4047
|
+
computedForViewModeRef.current = viewMode;
|
|
4048
|
+
}, [viewMode, svgContainerWidth, columnWidthProp, computedColumnWidth]);
|
|
4049
|
+
var columnWidth = (_ref3 = columnWidthProp != null ? columnWidthProp : computedColumnWidth) != null ? _ref3 : 60;
|
|
4023
4050
|
var effectiveColumnWidth = React.useMemo(function () {
|
|
4024
4051
|
if (svgContainerWidth <= 0 || dateSetup.dates.length <= 0) return columnWidth;
|
|
4052
|
+
|
|
4053
|
+
if (columnWidthProp == null) {
|
|
4054
|
+
var maxVisible = VIEW_MODE_MAX_VISIBLE_COUNT[viewMode];
|
|
4055
|
+
|
|
4056
|
+
if (maxVisible) {
|
|
4057
|
+
return Math.max(columnWidth, Math.ceil(svgContainerWidth / maxVisible));
|
|
4058
|
+
}
|
|
4059
|
+
|
|
4060
|
+
return columnWidth;
|
|
4061
|
+
}
|
|
4062
|
+
|
|
4025
4063
|
return Math.max(columnWidth, Math.ceil(svgContainerWidth / dateSetup.dates.length));
|
|
4026
|
-
}, [columnWidth, svgContainerWidth, dateSetup.dates.length]);
|
|
4064
|
+
}, [columnWidth, columnWidthProp, viewMode, svgContainerWidth, dateSetup.dates.length]);
|
|
4027
4065
|
var svgWidth = effectiveColumnWidth < 55 ? (dateSetup.dates.length + 0.5) * effectiveColumnWidth : dateSetup.dates.length * effectiveColumnWidth;
|
|
4028
4066
|
var ganttFullHeight = React.useMemo(function () {
|
|
4029
4067
|
return barTasks.length * rowHeight;
|
|
4030
4068
|
}, [barTasks.length, rowHeight]);
|
|
4031
4069
|
|
|
4032
|
-
var
|
|
4033
|
-
scrollY =
|
|
4034
|
-
setScrollY =
|
|
4035
|
-
|
|
4036
|
-
var _useState13 = React.useState(-1),
|
|
4037
|
-
scrollX = _useState13[0],
|
|
4038
|
-
setScrollX = _useState13[1];
|
|
4070
|
+
var _useState13 = React.useState(0),
|
|
4071
|
+
scrollY = _useState13[0],
|
|
4072
|
+
setScrollY = _useState13[1];
|
|
4039
4073
|
|
|
4040
|
-
var _useState14 = React.useState(
|
|
4041
|
-
|
|
4042
|
-
|
|
4074
|
+
var _useState14 = React.useState(-1),
|
|
4075
|
+
scrollX = _useState14[0],
|
|
4076
|
+
setScrollX = _useState14[1];
|
|
4043
4077
|
|
|
4044
|
-
var _useState15 = React.useState(
|
|
4045
|
-
|
|
4046
|
-
|
|
4078
|
+
var _useState15 = React.useState(false),
|
|
4079
|
+
ignoreScrollEvent = _useState15[0],
|
|
4080
|
+
setIgnoreScrollEvent = _useState15[1];
|
|
4047
4081
|
|
|
4048
4082
|
var _useState16 = React.useState(0),
|
|
4049
|
-
|
|
4050
|
-
|
|
4083
|
+
lastTouchX = _useState16[0],
|
|
4084
|
+
setLastTouchX = _useState16[1];
|
|
4085
|
+
|
|
4086
|
+
var _useState17 = React.useState(0),
|
|
4087
|
+
lastTouchY = _useState17[0],
|
|
4088
|
+
setLastTouchY = _useState17[1];
|
|
4051
4089
|
|
|
4052
|
-
var
|
|
4053
|
-
isProcessing =
|
|
4054
|
-
setIsProcessing =
|
|
4090
|
+
var _useState18 = React.useState(false),
|
|
4091
|
+
isProcessing = _useState18[0],
|
|
4092
|
+
setIsProcessing = _useState18[1];
|
|
4055
4093
|
|
|
4056
4094
|
var buffer = rowHeight * 10;
|
|
4057
4095
|
var visibleStartY = scrollY - buffer;
|