@visactor/vtable-gantt 1.14.0 → 1.14.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.
@@ -25702,8 +25702,6 @@
25702
25702
  }
25703
25703
 
25704
25704
  class Grid {
25705
- vertical;
25706
- horizontal;
25707
25705
  gridStyle;
25708
25706
  scrollLeft;
25709
25707
  scrollTop;
@@ -25716,13 +25714,13 @@
25716
25714
  group;
25717
25715
  verticalLineGroup;
25718
25716
  horizontalLineGroup;
25717
+ verticalBackgroundRectsGroup;
25718
+ horizontalBackgroundRectsGroup;
25719
25719
  allGridHeight;
25720
25720
  allGridWidth;
25721
25721
  _scene;
25722
25722
  constructor(scene) {
25723
25723
  this._scene = scene;
25724
- this.vertical = !!scene._gantt.parsedOptions.grid.verticalLine;
25725
- this.horizontal = !!scene._gantt.parsedOptions.grid.horizontalLine;
25726
25724
  this.scrollLeft = 0;
25727
25725
  this.scrollTop = 0;
25728
25726
  this.x = 0;
@@ -25743,6 +25741,8 @@
25743
25741
  });
25744
25742
  this.group.name = 'grid-container';
25745
25743
  scene.tableGroup.addChild(this.group);
25744
+ this.createVerticalBackgroundRects();
25745
+ this.createHorizontalBackgroundRects();
25746
25746
  this.createVerticalLines();
25747
25747
  this.createHorizontalLines();
25748
25748
  this.createTimeLineHeaderBottomLine();
@@ -25768,7 +25768,7 @@
25768
25768
  }
25769
25769
  createVerticalLines() {
25770
25770
  const gridStyle = this._scene._gantt.parsedOptions.grid;
25771
- if (this.vertical) {
25771
+ if (gridStyle.verticalLine) {
25772
25772
  this.verticalLineGroup = new Group$2({
25773
25773
  x: 0,
25774
25774
  y: 0,
@@ -25820,7 +25820,7 @@
25820
25820
  }
25821
25821
  createHorizontalLines() {
25822
25822
  const gridStyle = this._scene._gantt.parsedOptions.grid;
25823
- if (this.horizontal) {
25823
+ if (gridStyle.horizontalLine) {
25824
25824
  this.horizontalLineGroup = new Group$2({
25825
25825
  x: 0,
25826
25826
  y: 0,
@@ -25871,6 +25871,92 @@
25871
25871
  }
25872
25872
  }
25873
25873
  }
25874
+ createVerticalBackgroundRects() {
25875
+ const verticalBackgroundColor = this._scene._gantt.parsedOptions.grid.verticalBackgroundColor;
25876
+ const weekendBackgroundColor = this._scene._gantt.parsedOptions.grid.weekendBackgroundColor;
25877
+ if (verticalBackgroundColor || weekendBackgroundColor) {
25878
+ this.verticalBackgroundRectsGroup = new Group$2({
25879
+ x: 0,
25880
+ y: 0,
25881
+ width: this.allGridWidth,
25882
+ height: this.allGridHeight
25883
+ });
25884
+ this.verticalBackgroundRectsGroup.name = 'grid-vertical-background';
25885
+ this.group.appendChild(this.verticalBackgroundRectsGroup);
25886
+ const { timelineDates, unit, step } = this._scene._gantt.parsedOptions.reverseSortedTimelineScales[0];
25887
+ const timelineColWidth = this._scene._gantt.parsedOptions.timelineColWidth;
25888
+ if (verticalBackgroundColor || weekendBackgroundColor) {
25889
+ for (let i = 0; i <= timelineDates?.length - 1; i++) {
25890
+ let backgroundColor;
25891
+ if (weekendBackgroundColor &&
25892
+ unit === 'day' &&
25893
+ step === 1 &&
25894
+ (timelineDates[i].startDate.getDay() === 0 || timelineDates[i].startDate.getDay() === 6)) {
25895
+ backgroundColor = weekendBackgroundColor;
25896
+ }
25897
+ else if (typeof verticalBackgroundColor === 'function') {
25898
+ backgroundColor = verticalBackgroundColor({
25899
+ index: i,
25900
+ dateIndex: timelineDates[i].dateIndex,
25901
+ date: timelineDates[i].endDate,
25902
+ ganttInstance: this._scene._gantt
25903
+ });
25904
+ }
25905
+ else if (verticalBackgroundColor) {
25906
+ backgroundColor = verticalBackgroundColor[i % verticalBackgroundColor.length];
25907
+ }
25908
+ if (backgroundColor) {
25909
+ const x = Math.ceil(timelineColWidth * i);
25910
+ const rect = createRect({
25911
+ pickable: false,
25912
+ fill: backgroundColor,
25913
+ x,
25914
+ y: 0,
25915
+ width: timelineColWidth,
25916
+ height: this.allGridHeight
25917
+ });
25918
+ this.verticalBackgroundRectsGroup.appendChild(rect);
25919
+ }
25920
+ }
25921
+ }
25922
+ }
25923
+ }
25924
+ createHorizontalBackgroundRects() {
25925
+ const horizontalBackgroundColor = this._scene._gantt.parsedOptions.grid.horizontalBackgroundColor;
25926
+ if (horizontalBackgroundColor) {
25927
+ this.horizontalBackgroundRectsGroup = new Group$2({
25928
+ x: 0,
25929
+ y: 0,
25930
+ width: this.allGridWidth,
25931
+ height: this.allGridHeight
25932
+ });
25933
+ this.horizontalBackgroundRectsGroup.name = 'grid-horizontal-background';
25934
+ this.group.appendChild(this.horizontalBackgroundRectsGroup);
25935
+ let y = 0;
25936
+ for (let i = 0; i <= this.rowCount - 1; i++) {
25937
+ let backgroundColor;
25938
+ if (typeof horizontalBackgroundColor === 'function') {
25939
+ backgroundColor = horizontalBackgroundColor({
25940
+ index: i,
25941
+ ganttInstance: this._scene._gantt
25942
+ });
25943
+ }
25944
+ else {
25945
+ backgroundColor = horizontalBackgroundColor[i % horizontalBackgroundColor.length];
25946
+ }
25947
+ const rect = createRect({
25948
+ pickable: false,
25949
+ fill: backgroundColor,
25950
+ x: 0,
25951
+ y,
25952
+ width: this.allGridWidth,
25953
+ height: this._scene._gantt.getRowHeightByIndex(i)
25954
+ });
25955
+ this.horizontalBackgroundRectsGroup.appendChild(rect);
25956
+ y += this._scene._gantt.getRowHeightByIndex(i);
25957
+ }
25958
+ }
25959
+ }
25874
25960
  refresh() {
25875
25961
  this.width = this._scene.tableGroup.attribute.width;
25876
25962
  this.height = this._scene.tableGroup.attribute.height - this._scene.timelineHeader.group.attribute.height;
@@ -25882,8 +25968,9 @@
25882
25968
  this.rowCount = this._scene._gantt.itemCount;
25883
25969
  this.allGridWidth = this._scene._gantt.getAllDateColsWidth();
25884
25970
  this.allGridHeight = this._scene._gantt.getAllTaskBarsHeight();
25885
- this.verticalLineGroup?.parent.removeChild(this.verticalLineGroup);
25886
- this.horizontalLineGroup?.parent.removeChild(this.horizontalLineGroup);
25971
+ this.group.removeAllChild();
25972
+ this.createVerticalBackgroundRects();
25973
+ this.createHorizontalBackgroundRects();
25887
25974
  this.createVerticalLines();
25888
25975
  this.createHorizontalLines();
25889
25976
  this.createTimeLineHeaderBottomLine();
@@ -25891,10 +25978,14 @@
25891
25978
  setX(x) {
25892
25979
  this.verticalLineGroup?.setAttribute('x', x);
25893
25980
  this.horizontalLineGroup?.setAttribute('x', x);
25981
+ this.verticalBackgroundRectsGroup?.setAttribute('x', x);
25982
+ this.horizontalBackgroundRectsGroup?.setAttribute('x', x);
25894
25983
  }
25895
25984
  setY(y) {
25896
25985
  this.verticalLineGroup?.setAttribute('y', y);
25897
25986
  this.horizontalLineGroup?.setAttribute('y', y);
25987
+ this.verticalBackgroundRectsGroup?.setAttribute('y', y);
25988
+ this.horizontalBackgroundRectsGroup?.setAttribute('y', y);
25898
25989
  }
25899
25990
  resize() {
25900
25991
  this.width = this._scene.tableGroup.attribute.width;
@@ -30927,6 +31018,14 @@
30927
31018
  taskDays: linkedFromTaskTaskDays
30928
31019
  } = gantt.getTaskInfoByTaskListIndex(linkedFromTaskShowIndex));
30929
31020
  }
31021
+ if (!linkedFromTaskStartDate ||
31022
+ !linkedFromTaskEndDate ||
31023
+ !linkedToTaskStartDate ||
31024
+ !linkedToTaskEndDate ||
31025
+ !linkLineNode ||
31026
+ !lineArrowNode) {
31027
+ return;
31028
+ }
30930
31029
  const { linePoints, arrowPoints } = updateLinkLinePoints(type, linkedFromTaskStartDate, linkedFromTaskEndDate, linkedFromTaskShowIndex, linkedFromTaskTaskDays, linkedFromTaskRecord.record.type === 'milestone', null, 0, linkedToTaskStartDate, linkedToTaskEndDate, linkedToTaskShowIndex, linkedToTaskTaskDays, linkedToTaskRecord.record.type === 'milestone', target, diffY ?? 0, this._gantt);
30931
31030
  linkLineNode.setAttribute('points', linePoints);
30932
31031
  lineArrowNode.setAttribute('points', arrowPoints);
@@ -31017,6 +31116,14 @@
31017
31116
  } = gantt.getTaskInfoByTaskListIndex(linkedFromTaskShowIndex));
31018
31117
  }
31019
31118
  const { linePoints, arrowPoints } = updateLinkLinePoints(type, linkedFromTaskStartDate, linkedFromTaskEndDate, linkedFromTaskShowIndex, linkedFromTaskTaskDays, linkedFromTaskRecord.record.type === 'milestone', target, diffY ?? 0, linkedToTaskStartDate, linkedToTaskEndDate, linkedToTaskShowIndex, linkedToTaskTaskDays, linkedToTaskRecord.record.type === 'milestone', null, 0, this._gantt);
31119
+ if (!linkedFromTaskStartDate ||
31120
+ !linkedFromTaskEndDate ||
31121
+ !linkedToTaskStartDate ||
31122
+ !linkedToTaskEndDate ||
31123
+ !linkLineNode ||
31124
+ !lineArrowNode) {
31125
+ return;
31126
+ }
31020
31127
  linkLineNode.setAttribute('points', linePoints);
31021
31128
  lineArrowNode.setAttribute('points', arrowPoints);
31022
31129
  }
@@ -45905,7 +46012,7 @@
45905
46012
  table: table
45906
46013
  } = state;
45907
46014
  let source, target;
45908
- if (table.internalProps.transpose ? (sourceIndex = table.getRecordShowIndexByCell(sourceIndex, 0), targetIndex = table.getRecordShowIndexByCell(targetIndex, 0)) : (source = table.getRecordIndexByCell(0, sourceIndex), target = table.getRecordIndexByCell(0, targetIndex)), isNumber$2(source) && isNumber$2(target)) {
46015
+ if (table.internalProps.transpose ? (sourceIndex = table.getRecordShowIndexByCell(sourceIndex, 0), targetIndex = table.getRecordShowIndexByCell(targetIndex, 0)) : (source = table.isPivotTable() ? void 0 : table.getRecordIndexByCell(0, sourceIndex), target = table.isPivotTable() ? void 0 : table.getRecordIndexByCell(0, targetIndex)), isNumber$2(source) && isNumber$2(target)) {
45909
46016
  if (sourceIndex > targetIndex) {
45910
46017
  const sourceRecord = checkedState.get(sourceIndex.toString());
45911
46018
  for (let i = sourceIndex; i > targetIndex; i--) checkedState.set(i.toString(), checkedState.get((i - 1).toString()));
@@ -50735,7 +50842,7 @@
50735
50842
  constructor(container) {
50736
50843
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
50737
50844
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
50738
- if (super(), this.showFrozenIcon = !0, this.version = "1.14.0", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), !container && "node" !== options.mode && !options.canvas) throw new Error("vtable's container is undefined");
50845
+ if (super(), this.showFrozenIcon = !0, this.version = "1.14.1", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), !container && "node" !== options.mode && !options.canvas) throw new Error("vtable's container is undefined");
50739
50846
  const {
50740
50847
  frozenColCount = 0,
50741
50848
  frozenRowCount: frozenRowCount,
@@ -51040,15 +51147,13 @@
51040
51147
  heightWithoutPadding = 0;
51041
51148
  if (this.canvasSizeSeted) widthWithoutPadding = this.canvasWidth, heightWithoutPadding = this.canvasHeight;else if (element.parentElement) {
51042
51149
  const computedStyle = element.parentElement.style || window.getComputedStyle(element.parentElement);
51043
- widthWithoutPadding = element.parentElement.offsetWidth - parseInt(computedStyle.paddingLeft || "0px", 10) - parseInt(computedStyle.paddingRight || "0px", 10), heightWithoutPadding = element.parentElement.offsetHeight - parseInt(computedStyle.paddingTop || "0px", 10) - parseInt(computedStyle.paddingBottom || "0px", 20);
51150
+ widthWithoutPadding = element.parentElement.offsetWidth - parseInt(computedStyle.paddingLeft || "0px", 10) - parseInt(computedStyle.paddingRight || "0px", 10), heightWithoutPadding = element.parentElement.offsetHeight - parseInt(computedStyle.paddingTop || "0px", 10) - parseInt(computedStyle.paddingBottom || "0px", 20), widthWithoutPadding = (null != widthWithoutPadding ? widthWithoutPadding : 1) - (this.options.tableSizeAntiJitter ? 1 : 0), heightWithoutPadding = (null != heightWithoutPadding ? heightWithoutPadding : 1) - (this.options.tableSizeAntiJitter ? 1 : 0);
51044
51151
  }
51045
- const width1 = null != widthWithoutPadding ? widthWithoutPadding : 0,
51046
- height1 = null != heightWithoutPadding ? heightWithoutPadding : 0;
51047
- element.style.width = width1 && width1 - padding.left - padding.right + "px" || "0px", element.style.height = height1 && height1 - padding.top - padding.bottom + "px" || "0px";
51152
+ element.style.width = widthWithoutPadding && widthWithoutPadding - padding.left - padding.right + "px" || "0px", element.style.height = heightWithoutPadding && heightWithoutPadding - padding.top - padding.bottom + "px" || "0px";
51048
51153
  const {
51049
51154
  canvas: canvas
51050
51155
  } = this.internalProps;
51051
- widthP = null !== (_c = null === (_b = canvas.parentElement) || void 0 === _b ? void 0 : _b.offsetWidth) && void 0 !== _c ? _c : 0, heightP = null !== (_e = null === (_d = canvas.parentElement) || void 0 === _d ? void 0 : _d.offsetHeight) && void 0 !== _e ? _e : 0, (null === (_f = null == this ? void 0 : this.scenegraph) || void 0 === _f ? void 0 : _f.stage) ? this.scenegraph.stage.resize(widthP, heightP) : (canvas.style.width = "", canvas.style.height = "", canvas.width = widthP, canvas.height = heightP, canvas.style.width = `${widthP}px`, canvas.style.height = `${heightP}px`);
51156
+ widthP = (null !== (_c = null === (_b = canvas.parentElement) || void 0 === _b ? void 0 : _b.offsetWidth) && void 0 !== _c ? _c : 1) - (this.options.tableSizeAntiJitter ? 1 : 0), heightP = (null !== (_e = null === (_d = canvas.parentElement) || void 0 === _d ? void 0 : _d.offsetHeight) && void 0 !== _e ? _e : 1) - (this.options.tableSizeAntiJitter ? 1 : 0), (null === (_f = null == this ? void 0 : this.scenegraph) || void 0 === _f ? void 0 : _f.stage) ? this.scenegraph.stage.resize(widthP, heightP) : (canvas.style.width = "", canvas.style.height = "", canvas.width = widthP, canvas.height = heightP, canvas.style.width = `${widthP}px`, canvas.style.height = `${heightP}px`);
51052
51157
  } else "node" === Env.mode && (widthP = this.canvasWidth - 1, heightP = this.canvasHeight - 1);
51053
51158
  const width = Math.floor(widthP - getVerticalScrollBarSize(this.getTheme().scrollStyle)),
51054
51159
  height = Math.floor(heightP - getHorizontalScrollBarSize(this.getTheme().scrollStyle));
@@ -54143,12 +54248,13 @@
54143
54248
  newHeight = computeRowHeight(row, 0, table.colCount - 1, table);
54144
54249
  table.scenegraph.updateRowHeight(row, newHeight - oldHeight);
54145
54250
  }
54146
- table.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, {
54251
+ const changedValue = table.getCellOriginValue(col, row);
54252
+ oldValue !== changedValue && table.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, {
54147
54253
  col: col,
54148
54254
  row: row,
54149
54255
  rawValue: beforeChangeValue,
54150
54256
  currentValue: oldValue,
54151
- changedValue: table.getCellOriginValue(col, row)
54257
+ changedValue: changedValue
54152
54258
  }), table.scenegraph.updateNextFrame();
54153
54259
  }
54154
54260
  }
@@ -54194,12 +54300,14 @@
54194
54300
  } = table.internalProps.layoutMap.getBody(startCol + j, startRow + i),
54195
54301
  beforeChangeValue = beforeChangeValues[i][j],
54196
54302
  oldValue = oldValues[i][j];
54197
- table.isHeader(startCol + j, startRow + i) ? table.internalProps.layoutMap.updateColumnTitle(startCol + j, startRow + i, value) : table.dataSource.changeFieldValue(value, recordIndex, field, startCol + j, startRow + i, table), table.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, {
54303
+ table.isHeader(startCol + j, startRow + i) ? table.internalProps.layoutMap.updateColumnTitle(startCol + j, startRow + i, value) : table.dataSource.changeFieldValue(value, recordIndex, field, startCol + j, startRow + i, table);
54304
+ const changedValue = table.getCellOriginValue(startCol + j, startRow + i);
54305
+ oldValue !== changedValue && table.fireListeners(TABLE_EVENT_TYPE.CHANGE_CELL_VALUE, {
54198
54306
  col: startCol + j,
54199
54307
  row: startRow + i,
54200
54308
  rawValue: beforeChangeValue,
54201
54309
  currentValue: oldValue,
54202
- changedValue: table.getCellOriginValue(startCol + j, startRow + i)
54310
+ changedValue: changedValue
54203
54311
  });
54204
54312
  }
54205
54313
  }
@@ -60941,11 +61049,8 @@
60941
61049
  const taskRecord = this._gantt.getRecordByIndex(taskIndex, sub_task_index);
60942
61050
  const progress = taskRecord[progressField];
60943
61051
  let diffWidth = this._gantt.stateManager.resizeTaskBar.onIconName === 'left' ? -dx : dx;
60944
- let taskBarSize = taskBarGroup.attribute.width + diffWidth;
60945
- if (diffWidth < 0 && taskBarSize <= this._gantt.parsedOptions.timelineColWidth) {
60946
- diffWidth = this._gantt.parsedOptions.timelineColWidth - taskBarGroup.attribute.width;
60947
- taskBarSize += diffWidth;
60948
- }
61052
+ const taskBarSize = Math.max(1, taskBarGroup.attribute.width + diffWidth);
61053
+ diffWidth = taskBarSize - taskBarGroup.attribute.width;
60949
61054
  resizeOrMoveTaskBar(taskBarGroup, this._gantt.stateManager.resizeTaskBar.onIconName === 'left' ? -diffWidth : 0, 0, taskBarSize, this);
60950
61055
  clipGroupBox.setAttribute('width', taskBarGroup.attribute.width);
60951
61056
  rect?.setAttribute('width', taskBarGroup.attribute.width);
@@ -62186,7 +62291,7 @@
62186
62291
  themes: themes$1
62187
62292
  });
62188
62293
 
62189
- const version = "1.14.0";
62294
+ const version = "1.14.1";
62190
62295
 
62191
62296
  exports.Gantt = Gantt;
62192
62297
  exports.TYPES = index$3;