apexgantt 3.2.0 → 3.3.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.
@@ -14330,6 +14330,32 @@ class DataManager {
14330
14330
  }
14331
14331
  getDateRange(add = 0, viewMode) {
14332
14332
  const tasks = this.getTasks();
14333
+ if (tasks.length === 0) {
14334
+ const today = dayjs();
14335
+ const startDate = today.startOf(viewMode);
14336
+ let defaultRange = 1;
14337
+ switch (viewMode) {
14338
+ case "day":
14339
+ defaultRange = 30;
14340
+ break;
14341
+ case "week":
14342
+ defaultRange = 12;
14343
+ break;
14344
+ case "month":
14345
+ defaultRange = 12;
14346
+ break;
14347
+ case "quarter":
14348
+ defaultRange = 4;
14349
+ break;
14350
+ case "year":
14351
+ defaultRange = 5;
14352
+ break;
14353
+ default:
14354
+ defaultRange = 12;
14355
+ }
14356
+ const endDate = startDate.add(defaultRange + add, viewMode);
14357
+ return [startDate, endDate];
14358
+ }
14333
14359
  const startDates = tasks.map((task) => dayjs(task.startTime));
14334
14360
  const endDates = tasks.filter((task) => !!task.endTime).map((task) => dayjs(task.endTime));
14335
14361
  return [dayjs.min(startDates), dayjs.max(endDates).add(add, viewMode)];
@@ -16534,12 +16560,11 @@ class GanttStateManager {
16534
16560
  */
16535
16561
  captureState(element, dataManager, viewMode) {
16536
16562
  const horizontalScroll = element.querySelector(".timeline-horizontal-scroll");
16537
- const tasksBodyWrapper = element.querySelector(".tasks-body-wrapper");
16538
- const timelineBodyWrapper = element.querySelector(".timeline-body-wrapper");
16563
+ const splitViewContainer = element.querySelector(".split-view-container");
16539
16564
  this.state.scrollPosition = {
16540
16565
  horizontal: (horizontalScroll == null ? void 0 : horizontalScroll.scrollLeft) || 0,
16541
- tasksVertical: (tasksBodyWrapper == null ? void 0 : tasksBodyWrapper.scrollTop) || 0,
16542
- timelineVertical: (timelineBodyWrapper == null ? void 0 : timelineBodyWrapper.scrollTop) || 0
16566
+ tasksVertical: (splitViewContainer == null ? void 0 : splitViewContainer.scrollTop) || 0,
16567
+ timelineVertical: (splitViewContainer == null ? void 0 : splitViewContainer.scrollTop) || 0
16543
16568
  };
16544
16569
  this.state.viewMode = viewMode;
16545
16570
  this.state.collapsedTasks = new Set(
@@ -16553,20 +16578,16 @@ class GanttStateManager {
16553
16578
  if (!skipScroll) {
16554
16579
  requestAnimationFrame(() => {
16555
16580
  const horizontalScroll = element.querySelector(".timeline-horizontal-scroll");
16556
- const tasksBodyWrapper = element.querySelector(".tasks-body-wrapper");
16557
- const timelineBodyWrapper = element.querySelector(".timeline-body-wrapper");
16581
+ const splitViewContainer = element.querySelector(".split-view-container");
16558
16582
  if (horizontalScroll) {
16559
16583
  horizontalScroll.scrollLeft = this.state.scrollPosition.horizontal;
16560
16584
  }
16561
- if (tasksBodyWrapper) {
16562
- tasksBodyWrapper.scrollTop = this.state.scrollPosition.tasksVertical;
16585
+ if (splitViewContainer) {
16586
+ splitViewContainer.scrollTop = this.state.scrollPosition.tasksVertical;
16563
16587
  }
16564
- if (timelineBodyWrapper) {
16565
- timelineBodyWrapper.scrollTop = this.state.scrollPosition.timelineVertical;
16566
- const timelineHeader = element.querySelector(".timeline-header");
16567
- if (timelineHeader) {
16568
- timelineHeader.scrollLeft = this.state.scrollPosition.horizontal;
16569
- }
16588
+ const timelineHeader = element.querySelector(".timeline-header");
16589
+ if (timelineHeader) {
16590
+ timelineHeader.scrollLeft = this.state.scrollPosition.horizontal;
16570
16591
  }
16571
16592
  });
16572
16593
  }
@@ -16754,6 +16775,7 @@ class ApexGantt extends BaseChart {
16754
16775
  this.splitBarResizeHandler = null;
16755
16776
  this.containerResizeObserver = null;
16756
16777
  this.lastKnownWidth = 0;
16778
+ this.lastKnownHeight = 0;
16757
16779
  this.resizeDebounceTimer = null;
16758
16780
  const themeDefaults = getDefaultOptions(options == null ? void 0 : options.theme);
16759
16781
  let processedSeries;
@@ -16989,16 +17011,11 @@ class ApexGantt extends BaseChart {
16989
17011
  this.setCSSVariables();
16990
17012
  this.initializeTooltip();
16991
17013
  this.element.innerHTML = "";
16992
- const existingDimensions = this.hasExplicitDimensions();
17014
+ this.hasExplicitDimensions();
16993
17015
  const normalizedHeight = this.normalizeDimension(height2);
16994
17016
  const normalizedWidth = this.normalizeDimension(width2);
16995
17017
  this.element.style.width = normalizedWidth;
16996
- if (normalizedHeight === "100%" && existingDimensions.height) {
16997
- const computedHeight = window.getComputedStyle(this.element).height;
16998
- this.element.style.height = computedHeight;
16999
- } else {
17000
- this.element.style.height = normalizedHeight;
17001
- }
17018
+ this.element.style.height = normalizedHeight;
17002
17019
  this.element.style.display = "flex";
17003
17020
  this.element.style.flexDirection = "column";
17004
17021
  this.element.style.boxSizing = "border-box";
@@ -17620,6 +17637,10 @@ class ApexGantt extends BaseChart {
17620
17637
  if (!ganttContainer || !timelineBody || !tasksBody) {
17621
17638
  return;
17622
17639
  }
17640
+ const oldEmptyTimelineRows = timelineBody.querySelectorAll(".timeline-empty-row");
17641
+ oldEmptyTimelineRows.forEach((row) => row.remove());
17642
+ const oldEmptyTaskRows = tasksBody.querySelectorAll(".tasks-empty-row");
17643
+ oldEmptyTaskRows.forEach((row) => row.remove());
17623
17644
  const containerHeight = ganttContainer.clientHeight;
17624
17645
  const existingRows = timelineBody.querySelectorAll(".timeline-data-row:not(.timeline-empty-row)");
17625
17646
  const existingRowCount = existingRows.length;
@@ -17628,8 +17649,17 @@ class ApexGantt extends BaseChart {
17628
17649
  const emptyRowsNeeded = Math.max(0, totalRowsNeeded - existingRowCount);
17629
17650
  if (emptyRowsNeeded === 0)
17630
17651
  return;
17652
+ let cellCount = 0;
17631
17653
  const firstRow = timelineBody.querySelector(".timeline-data-row");
17632
- const cellCount = firstRow ? firstRow.querySelectorAll(".timeline-data-cell").length : 0;
17654
+ if (firstRow) {
17655
+ cellCount = firstRow.querySelectorAll(".timeline-data-cell").length;
17656
+ } else {
17657
+ const timelineHeader = ganttContainer.querySelector(".timeline-header");
17658
+ if (timelineHeader) {
17659
+ const headerCells = timelineHeader.querySelectorAll(".timeline-header-cell");
17660
+ cellCount = headerCells.length;
17661
+ }
17662
+ }
17633
17663
  if (cellCount === 0)
17634
17664
  return;
17635
17665
  for (let i = 0; i < emptyRowsNeeded; i++) {
@@ -17785,7 +17815,7 @@ class ApexGantt extends BaseChart {
17785
17815
  return value;
17786
17816
  }
17787
17817
  /**
17788
- * resize observer for container to handle responsive width changes
17818
+ * resize observer for container to handle responsive width and height changes
17789
17819
  */
17790
17820
  setupContainerResizeObserver() {
17791
17821
  if (!this.element) {
@@ -17795,16 +17825,23 @@ class ApexGantt extends BaseChart {
17795
17825
  this.containerResizeObserver.disconnect();
17796
17826
  }
17797
17827
  const normalizedWidth = this.normalizeDimension(this.options.width);
17828
+ const normalizedHeight = this.normalizeDimension(this.options.height);
17798
17829
  const isPercentageWidth = typeof normalizedWidth === "string" && normalizedWidth.includes("%");
17799
- if (!isPercentageWidth) {
17830
+ const isPercentageHeight = typeof normalizedHeight === "string" && normalizedHeight.includes("%");
17831
+ if (!isPercentageWidth && !isPercentageHeight) {
17800
17832
  return;
17801
17833
  }
17802
17834
  this.lastKnownWidth = this.element.offsetWidth;
17835
+ this.lastKnownHeight = this.element.offsetHeight;
17803
17836
  this.containerResizeObserver = new ResizeObserver((entries) => {
17804
17837
  for (const entry of entries) {
17805
17838
  const newWidth = entry.contentRect.width;
17806
- if (Math.abs(newWidth - this.lastKnownWidth) > 1) {
17839
+ const newHeight = entry.contentRect.height;
17840
+ const widthChanged = Math.abs(newWidth - this.lastKnownWidth) > 1;
17841
+ const heightChanged = Math.abs(newHeight - this.lastKnownHeight) > 1;
17842
+ if (widthChanged || heightChanged) {
17807
17843
  this.lastKnownWidth = newWidth;
17844
+ this.lastKnownHeight = newHeight;
17808
17845
  this.handleContainerResize();
17809
17846
  }
17810
17847
  }
@@ -17825,7 +17862,10 @@ class ApexGantt extends BaseChart {
17825
17862
  return;
17826
17863
  }
17827
17864
  const normalizedWidth = this.normalizeDimension(this.options.width);
17828
- if (typeof normalizedWidth === "string" && normalizedWidth.includes("%")) {
17865
+ const normalizedHeight = this.normalizeDimension(this.options.height);
17866
+ const isPercentageWidth = typeof normalizedWidth === "string" && normalizedWidth.includes("%");
17867
+ const isPercentageHeight = typeof normalizedHeight === "string" && normalizedHeight.includes("%");
17868
+ if (isPercentageWidth) {
17829
17869
  const computedWidth = window.getComputedStyle(this.element.parentElement || this.element).width;
17830
17870
  const currentElementWidth = window.getComputedStyle(this.element).width;
17831
17871
  if (computedWidth !== currentElementWidth) {
@@ -17836,6 +17876,11 @@ class ApexGantt extends BaseChart {
17836
17876
  });
17837
17877
  }
17838
17878
  }
17879
+ if (isPercentageHeight) {
17880
+ requestAnimationFrame(() => {
17881
+ this.fillEmptyRowsAfterRender();
17882
+ });
17883
+ }
17839
17884
  }
17840
17885
  destroy() {
17841
17886
  try {