@visactor/vtable-gantt 1.17.3-alpha.10 → 1.17.3-alpha.12

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.
@@ -26541,1208 +26541,403 @@
26541
26541
  registed || (registed = !0, preLoadAllModule(), isBrowserEnv() ? loadBrowserEnv(container) : isNodeEnv() && loadNodeEnv(container), registerArc(), registerCircle(), registerGroup(), registerImage(), registerLine(), registerRect(), registerRichtext(), registerShadowRoot(), registerSymbol(), registerText(), registerFlexLayoutPlugin(), loadPoptip(), registerFlexLayoutPlugin());
26542
26542
  }
26543
26543
 
26544
- const defaultTaskBarStyle = {
26545
- barColor: 'blue',
26546
- completedBarColor: 'gray',
26547
- width: 30,
26548
- cornerRadius: 3,
26549
- borderWidth: 0,
26550
- fontFamily: 'Arial',
26551
- fontSize: 14
26552
- };
26553
- function setWidthToDefaultTaskBarStyle(width) {
26554
- defaultTaskBarStyle.width = width;
26544
+ function throttle$1(func, delay) {
26545
+ let timer = null;
26546
+ return function (...args) {
26547
+ if (!timer) {
26548
+ func.apply(this, args);
26549
+ timer = setTimeout(() => {
26550
+ timer = null;
26551
+ }, delay);
26552
+ }
26553
+ };
26555
26554
  }
26556
- const isNode$1 = typeof window === 'undefined' || typeof window.window === 'undefined';
26557
- const DayTimes = 1000 * 60 * 60 * 24;
26558
- function getDateIndexByX(x, gantt) {
26559
- const totalX = x + gantt.stateManager.scroll.horizontalBarPos;
26560
- const firstDateColWidth = gantt.getDateColWidth(0);
26561
- const dateIndex = Math.floor((totalX - firstDateColWidth) / gantt.parsedOptions.timelineColWidth) + 1;
26562
- return dateIndex;
26555
+ function getTodayNearDay(dayOffset, format) {
26556
+ const today = new Date();
26557
+ const todayTime = today.getTime();
26558
+ const oneDayTime = 24 * 60 * 60 * 1000;
26559
+ const targetTime = todayTime + dayOffset * oneDayTime;
26560
+ const date = new Date(targetTime);
26561
+ if (format) {
26562
+ const year = date.getFullYear().toString();
26563
+ const month = (date.getMonth() + 1).toString().padStart(2, '0');
26564
+ const day = date.getDate().toString().padStart(2, '0');
26565
+ format = format.replace('yyyy', year);
26566
+ format = format.replace('mm', month);
26567
+ format = format.replace('dd', day);
26568
+ return format;
26569
+ }
26570
+ return date;
26563
26571
  }
26564
- function generateMarkLine(markLine) {
26565
- if (!markLine) {
26566
- return [];
26572
+ function formatDate(date, format) {
26573
+ const year = date.getFullYear().toString();
26574
+ const month = (date.getMonth() + 1).toString().padStart(2, '0');
26575
+ const day = date.getDate().toString().padStart(2, '0');
26576
+ format = format.replace('yyyy', year);
26577
+ format = format.replace('mm', month);
26578
+ format = format.replace('dd', day);
26579
+ if (format.length > 10) {
26580
+ const hour = date.getHours().toString().padStart(2, '0');
26581
+ const minute = date.getMinutes().toString().padStart(2, '0');
26582
+ const second = date.getSeconds().toString().padStart(2, '0');
26583
+ format = format.replace('hh', hour);
26584
+ format = format.replace('mm', minute);
26585
+ format = format.replace('ss', second);
26567
26586
  }
26568
- if (markLine === true) {
26569
- return [
26570
- {
26571
- date: createDateAtMidnight().toLocaleDateString(),
26572
- scrollToMarkLine: true,
26573
- position: 'left',
26574
- style: {
26575
- lineColor: 'red',
26576
- lineWidth: 1
26577
- }
26587
+ return format;
26588
+ }
26589
+ function validateDate(dateParts, format) {
26590
+ const yearIndex = format.indexOf('yyyy');
26591
+ const monthIndex = format.indexOf('mm');
26592
+ const dayIndex = format.indexOf('dd');
26593
+ const dateYearIndex = yearIndex < monthIndex ? (yearIndex < dayIndex ? 0 : 1) : monthIndex < dayIndex ? 1 : 2;
26594
+ const dateMonthIndex = monthIndex < yearIndex ? (monthIndex < dayIndex ? 0 : 1) : monthIndex < dayIndex ? 1 : 2;
26595
+ const dateDayIndex = dayIndex < yearIndex ? (dayIndex < monthIndex ? 0 : 1) : dayIndex < monthIndex ? 1 : 2;
26596
+ const year = parseInt(dateParts[dateYearIndex], 10);
26597
+ const month = parseInt(dateParts[dateMonthIndex], 10) - 1;
26598
+ const day = parseInt(dateParts[dateDayIndex], 10);
26599
+ if (isNaN(year) || year < 1) {
26600
+ return false;
26601
+ }
26602
+ if (isNaN(month) || month < 0 || month > 11) {
26603
+ return false;
26604
+ }
26605
+ const daysInMonth = [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
26606
+ if (isNaN(day) || day < 1 || day > daysInMonth[month]) {
26607
+ return false;
26608
+ }
26609
+ return true;
26610
+ }
26611
+ function validateTime(dateParts, format) {
26612
+ if (format.includes('hh') || format.includes('mm') || format.includes('ss')) {
26613
+ const timeIndex = format.indexOf('hh') > -1 ? format.indexOf('hh') : format.indexOf('HH');
26614
+ const hour = parseInt(dateParts[timeIndex], 10);
26615
+ const minute = parseInt(dateParts[timeIndex + 1], 10);
26616
+ const second = dateParts.length > timeIndex + 2 ? parseInt(dateParts[timeIndex + 2], 10) : 0;
26617
+ if (isNaN(hour) || hour < 0 || hour > 23) {
26618
+ return false;
26619
+ }
26620
+ if (isNaN(minute) || minute < 0 || minute > 59) {
26621
+ return false;
26622
+ }
26623
+ if (isNaN(second) || second < 0 || second > 59) {
26624
+ return false;
26625
+ }
26626
+ }
26627
+ return true;
26628
+ }
26629
+ function isLeapYear(year) {
26630
+ return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
26631
+ }
26632
+ function parseDateFormat(dateString) {
26633
+ const formats = [
26634
+ 'yyyy-mm-dd',
26635
+ 'dd-mm-yyyy',
26636
+ 'mm/dd/yyyy',
26637
+ 'yyyy/mm/dd',
26638
+ 'dd/mm/yyyy',
26639
+ 'yyyy.mm.dd',
26640
+ 'mm.dd.yyyy',
26641
+ 'dd.mm.yyyy'
26642
+ ];
26643
+ const timeFormat = ['hh:mm:ss', 'hh:mm'];
26644
+ dateString = dateString.trim();
26645
+ const dates = dateString.split(' ');
26646
+ const date = dates[0];
26647
+ const time = dates[1];
26648
+ let dateFormatMatched;
26649
+ let timeFormatMatched;
26650
+ if (date) {
26651
+ for (let i = 0; i < formats.length; i++) {
26652
+ const format = formats[i];
26653
+ const dateParts = date.split(getSeparator(format));
26654
+ const isValid = validateDate(dateParts, format);
26655
+ if (dateParts.length === 3 && isValid) {
26656
+ dateFormatMatched = format;
26657
+ break;
26578
26658
  }
26579
- ];
26659
+ }
26580
26660
  }
26581
- else if (Array.isArray(markLine)) {
26582
- return markLine.map((item, index) => {
26583
- return {
26584
- ...item,
26585
- date: item.date,
26586
- scrollToMarkLine: item.scrollToMarkLine,
26587
- position: item.position ?? 'left',
26588
- style: {
26589
- lineColor: item.style?.lineColor || 'red',
26590
- lineWidth: item.style?.lineWidth || 1,
26591
- lineDash: item.style?.lineDash
26661
+ if (dateFormatMatched) {
26662
+ if (time) {
26663
+ for (let i = 0; i < timeFormat.length; i++) {
26664
+ const format = timeFormat[i];
26665
+ const timeParts = time.split(getSeparator(format));
26666
+ const formatParts = format.split(getSeparator(format));
26667
+ const isValid = validateTime(timeParts, format);
26668
+ if (isValid && timeParts.length === formatParts.length) {
26669
+ timeFormatMatched = format;
26670
+ break;
26592
26671
  }
26593
- };
26594
- });
26595
- }
26596
- return [
26597
- {
26598
- ...markLine,
26599
- date: markLine.date,
26600
- scrollToMarkLine: markLine.scrollToMarkLine ?? true,
26601
- position: markLine.position ?? 'left',
26602
- style: {
26603
- lineColor: markLine.style?.lineColor || 'red',
26604
- lineWidth: markLine.style?.lineWidth || 1,
26605
- lineDash: markLine.style?.lineDash
26606
26672
  }
26607
26673
  }
26608
- ];
26674
+ }
26675
+ if (date && time && dateFormatMatched && timeFormatMatched) {
26676
+ return dateFormatMatched + ' ' + timeFormatMatched;
26677
+ }
26678
+ if (date && !time) {
26679
+ return dateFormatMatched;
26680
+ }
26681
+ return 'yyyy-mm-dd hh:mm:ss';
26609
26682
  }
26610
- function getHorizontalScrollBarSize$1(scrollStyle) {
26611
- if (scrollStyle?.hoverOn ||
26612
- (scrollStyle?.horizontalVisible && scrollStyle?.horizontalVisible === 'none') ||
26613
- (!scrollStyle?.horizontalVisible && scrollStyle?.visible === 'none')) {
26614
- return 0;
26683
+ function getSeparator(format) {
26684
+ const separators = format.match(/[^\w]/g);
26685
+ if (separators) {
26686
+ const escapedSeparators = separators.map(s => '\\' + s).join('|');
26687
+ return new RegExp(escapedSeparators, 'g');
26615
26688
  }
26616
- return scrollStyle?.width ?? 7;
26689
+ return /[^\w]/;
26617
26690
  }
26618
- function getVerticalScrollBarSize$1(scrollStyle) {
26619
- if (scrollStyle?.hoverOn ||
26620
- (scrollStyle?.verticalVisible && scrollStyle?.verticalVisible === 'none') ||
26621
- (!scrollStyle?.verticalVisible && scrollStyle?.visible === 'none')) {
26622
- return 0;
26691
+ function parseStringTemplate(template, data) {
26692
+ const result = template.replace(/\{([^}]+)\}/g, (match, key) => {
26693
+ const keys = key.split('.');
26694
+ let value = data;
26695
+ for (const k of keys) {
26696
+ if (value.hasOwnProperty(k)) {
26697
+ value = value[k];
26698
+ }
26699
+ else {
26700
+ value = match;
26701
+ break;
26702
+ }
26703
+ }
26704
+ return value;
26705
+ });
26706
+ return result;
26707
+ }
26708
+ function toBoxArray$2(obj) {
26709
+ if (!Array.isArray(obj)) {
26710
+ return [obj, obj, obj, obj];
26623
26711
  }
26624
- return scrollStyle?.width ?? 7;
26712
+ if (obj.length === 3) {
26713
+ return [obj[0], obj[1], obj[2], obj[1]];
26714
+ }
26715
+ if (obj.length === 2) {
26716
+ return [obj[0], obj[1], obj[0], obj[1]];
26717
+ }
26718
+ if (obj.length === 1) {
26719
+ return [obj[0], obj[0], obj[0], obj[0]];
26720
+ }
26721
+ return [obj[0], obj[1], obj[2], obj[3]];
26625
26722
  }
26626
- function initOptions(gantt) {
26627
- const options = gantt.options;
26628
- gantt.parsedOptions.tasksShowMode = options?.tasksShowMode ?? TasksShowMode.Tasks_Separate;
26629
- gantt.parsedOptions.pixelRatio = options?.pixelRatio ?? 1;
26630
- gantt.parsedOptions.rowHeight = options?.rowHeight ?? 40;
26631
- gantt.parsedOptions.timelineColWidth = options?.timelineHeader?.colWidth ?? 60;
26632
- gantt.parsedOptions.startDateField = options.taskBar?.startDateField ?? 'startDate';
26633
- gantt.parsedOptions.endDateField = options.taskBar?.endDateField ?? 'endDate';
26634
- gantt.parsedOptions.progressField = options.taskBar?.progressField ?? 'progress';
26635
- const { unit: minTimeUnit, startOfWeek, step } = gantt.parsedOptions.reverseSortedTimelineScales[0];
26636
- gantt.parsedOptions.minDate = options?.minDate
26637
- ? getStartDateByTimeUnit(new Date(options.minDate), minTimeUnit, startOfWeek)
26638
- : undefined;
26639
- gantt.parsedOptions.maxDate = options?.maxDate
26640
- ? getEndDateByTimeUnit(gantt.parsedOptions.minDate, new Date(options.maxDate), minTimeUnit, step)
26641
- : undefined;
26642
- gantt.parsedOptions._minDateTime = gantt.parsedOptions.minDate?.getTime();
26643
- gantt.parsedOptions._maxDateTime = gantt.parsedOptions.maxDate?.getTime();
26644
- gantt.parsedOptions.overscrollBehavior = options?.overscrollBehavior ?? 'auto';
26645
- gantt.parsedOptions.underlayBackgroundColor = options?.underlayBackgroundColor ?? '#FFF';
26646
- gantt.parsedOptions.scrollStyle = Object.assign({}, {
26647
- scrollRailColor: 'rgba(100, 100, 100, 0.2)',
26648
- scrollSliderColor: 'rgba(100, 100, 100, 0.5)',
26649
- scrollSliderCornerRadius: 4,
26650
- width: 10,
26651
- visible: 'always',
26652
- hoverOn: true,
26653
- barToSide: false
26654
- }, options?.scrollStyle);
26655
- gantt.parsedOptions.timelineHeaderHorizontalLineStyle = options?.timelineHeader?.horizontalLine;
26656
- gantt.parsedOptions.timelineHeaderVerticalLineStyle = options?.timelineHeader?.verticalLine;
26657
- gantt.parsedOptions.timelineHeaderBackgroundColor = options?.timelineHeader?.backgroundColor;
26658
- gantt.parsedOptions.timeLineHeaderRowHeights = [];
26659
- gantt.parsedOptions.timelineHeaderStyles = [];
26660
- for (let i = 0; i < gantt.parsedOptions.sortedTimelineScales.length ?? 0; i++) {
26661
- const style = gantt.parsedOptions.sortedTimelineScales[i].style;
26662
- gantt.parsedOptions.timelineHeaderStyles.push(Object.assign({
26663
- fontSize: 20,
26664
- fontWeight: 'bold',
26665
- textAlign: 'center',
26666
- textBaseline: 'middle',
26667
- color: '#000',
26668
- backgroundColor: '#fff'
26669
- }, style));
26670
- gantt.parsedOptions.timeLineHeaderRowHeights.push(gantt.parsedOptions.sortedTimelineScales[i].rowHeight ?? options?.headerRowHeight ?? 40);
26723
+ function getWeekNumber(currentDate) {
26724
+ const startOfYear = new Date(currentDate.getFullYear(), 0, 1);
26725
+ const weekNumber = Math.ceil(((currentDate.getTime() + 1 - startOfYear.getTime()) / 86400000 + 1) / 7);
26726
+ return weekNumber;
26727
+ }
26728
+ function getWeekday(dateString, format = 'long') {
26729
+ const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
26730
+ const date = new Date(dateString);
26731
+ if (format === 'short') {
26732
+ return days[date.getDay()].substr(0, 3);
26671
26733
  }
26672
- gantt.parsedOptions.grid = Object.assign({}, options?.grid);
26673
- setWidthToDefaultTaskBarStyle((gantt.parsedOptions.rowHeight * 3) / 4);
26674
- gantt.parsedOptions.taskBarStyle =
26675
- options?.taskBar?.barStyle && typeof options?.taskBar?.barStyle === 'function'
26676
- ? options.taskBar.barStyle
26677
- : Object.assign({}, defaultTaskBarStyle, options?.taskBar?.barStyle);
26678
- gantt.parsedOptions.taskBarMilestoneStyle = Object.assign(typeof gantt.parsedOptions.taskBarStyle === 'function'
26679
- ? {}
26680
- : {
26681
- width: gantt.parsedOptions.taskBarStyle.width,
26682
- borderColor: gantt.parsedOptions.taskBarStyle.borderColor,
26683
- borderLineWidth: gantt.parsedOptions.taskBarStyle.borderLineWidth ?? 1,
26684
- fillColor: gantt.parsedOptions.taskBarStyle.barColor,
26685
- cornerRadius: 0
26686
- }, options?.taskBar?.milestoneStyle);
26687
- gantt.parsedOptions.taskBarMilestoneHypotenuse = gantt.parsedOptions.taskBarMilestoneStyle.width * Math.sqrt(2);
26688
- gantt.parsedOptions.dateFormat = options?.dateFormat;
26689
- gantt.parsedOptions.taskBarHoverStyle = Object.assign({
26690
- barOverlayColor: 'rgba(99, 144, 0, 0.4)'
26691
- }, options?.taskBar?.hoverBarStyle);
26692
- gantt.parsedOptions.taskBarSelectable = options?.taskBar?.selectable ?? true;
26693
- gantt.parsedOptions.taskBarSelectedStyle = Object.assign(typeof gantt.parsedOptions.taskBarStyle === 'function'
26694
- ? {
26695
- shadowBlur: 6,
26696
- shadowOffsetX: 0,
26697
- shadowOffsetY: 0,
26698
- borderLineWidth: 1
26699
- }
26700
- : {
26701
- shadowBlur: 6,
26702
- shadowOffsetX: 0,
26703
- shadowOffsetY: 0,
26704
- shadowColor: gantt.parsedOptions.taskBarStyle.barColor,
26705
- borderColor: gantt.parsedOptions.taskBarStyle.barColor,
26706
- borderLineWidth: 1
26707
- }, options?.taskBar?.selectedBarStyle);
26708
- gantt.parsedOptions.taskBarLabelText = options?.taskBar?.labelText ?? '';
26709
- gantt.parsedOptions.taskBarMoveable = options?.taskBar?.moveable ?? true;
26710
- gantt.parsedOptions.moveTaskBarToExtendDateRange = options?.taskBar?.moveToExtendDateRange ?? true;
26711
- gantt.parsedOptions.taskBarResizable = options?.taskBar?.resizable ?? true;
26712
- gantt.parsedOptions.taskBarDragOrder = options?.taskBar?.dragOrder ?? true;
26713
- gantt.parsedOptions.taskBarLabelStyle = {
26714
- fontFamily: options?.taskBar?.labelTextStyle?.fontFamily ?? 'Arial',
26715
- fontSize: options?.taskBar?.labelTextStyle?.fontSize ?? 20,
26716
- color: options?.taskBar?.labelTextStyle?.color ?? '#F01',
26717
- textAlign: options?.taskBar?.labelTextStyle?.textAlign ?? 'left',
26718
- textBaseline: options?.taskBar?.labelTextStyle?.textBaseline ?? 'middle',
26719
- padding: options?.taskBar?.labelTextStyle?.padding ?? [0, 0, 0, 10],
26720
- textOverflow: options?.taskBar?.labelTextStyle?.textOverflow
26721
- };
26722
- gantt.parsedOptions.taskBarCustomLayout = options?.taskBar?.customLayout;
26723
- gantt.parsedOptions.taskBarCreatable =
26724
- options?.taskBar?.scheduleCreatable ??
26725
- !!(gantt.parsedOptions.tasksShowMode === TasksShowMode.Sub_Tasks_Separate ||
26726
- gantt.parsedOptions.tasksShowMode === TasksShowMode.Tasks_Separate);
26727
- gantt.parsedOptions.taskBarCreationButtonStyle = Object.assign({
26728
- lineColor: 'rgb(99, 144, 0)',
26729
- lineWidth: 1,
26730
- lineDash: [5, 5],
26731
- cornerRadius: 4,
26732
- backgroundColor: '#FFF'
26733
- }, options?.taskBar?.scheduleCreation?.buttonStyle);
26734
- gantt.parsedOptions.taskBarCreationCustomLayout = options?.taskBar?.scheduleCreation?.customLayout;
26735
- gantt.parsedOptions.taskBarCreationMaxWidth = options?.taskBar?.scheduleCreation?.maxWidth;
26736
- gantt.parsedOptions.taskBarCreationMinWidth = options?.taskBar?.scheduleCreation?.minWidth;
26737
- gantt.parsedOptions.outerFrameStyle = Object.assign({
26738
- borderColor: '#e1e4e8',
26739
- borderLineWidth: 1,
26740
- cornerRadius: 4
26741
- }, options.frame?.outerFrameStyle);
26742
- gantt.parsedOptions.markLine = generateMarkLine(options?.markLine);
26743
- if (gantt.parsedOptions.markLine?.length ?? 0) {
26744
- if (gantt.parsedOptions.markLine?.every(item => item.scrollToMarkLine === undefined)) {
26745
- gantt.parsedOptions.markLine[0].scrollToMarkLine = true;
26746
- }
26747
- if (gantt.parsedOptions.markLine?.find(item => item.scrollToMarkLine)) {
26748
- gantt.parsedOptions.scrollToMarkLineDate = getStartDateByTimeUnit(new Date(gantt.parsedOptions.markLine?.find(item => item.scrollToMarkLine).date), minTimeUnit, startOfWeek);
26749
- }
26734
+ else if (format === 'long') {
26735
+ return days[date.getDay()];
26750
26736
  }
26751
- gantt.parsedOptions.verticalSplitLineHighlight = options.frame?.verticalSplitLineHighlight;
26752
- gantt.parsedOptions.verticalSplitLine = Object.assign({
26753
- lineColor: gantt.parsedOptions.outerFrameStyle?.borderColor,
26754
- lineWidth: gantt.parsedOptions.outerFrameStyle?.borderLineWidth
26755
- }, options.frame?.verticalSplitLine);
26756
- gantt.parsedOptions.horizontalSplitLine = options.frame?.horizontalSplitLine;
26757
- gantt.parsedOptions.verticalSplitLineMoveable = options.frame?.verticalSplitLineMoveable;
26758
- gantt.parsedOptions.taskKeyField = options.taskKeyField ?? 'id';
26759
- gantt.parsedOptions.dependencyLinks = options.dependency?.links ?? [];
26760
- gantt.parsedOptions.dependencyLinkCreatable = options.dependency?.linkCreatable ?? false;
26761
- gantt.parsedOptions.dependencyLinkSelectable = options.dependency?.linkSelectable ?? true;
26762
- gantt.parsedOptions.dependencyLinkDeletable = options.dependency?.linkDeletable ?? false;
26763
- gantt.parsedOptions.dependencyLinkLineStyle = Object.assign({
26764
- lineColor: 'red',
26765
- lineWidth: 1
26766
- }, options.dependency?.linkLineStyle);
26767
- gantt.parsedOptions.dependencyLinkSelectedLineStyle = Object.assign({
26768
- shadowBlur: 4,
26769
- shadowOffset: 0,
26770
- shadowColor: gantt.parsedOptions.dependencyLinkLineStyle.lineColor,
26771
- lineColor: gantt.parsedOptions.dependencyLinkLineStyle.lineColor,
26772
- lineWidth: gantt.parsedOptions.dependencyLinkLineStyle.lineWidth
26773
- }, options?.dependency?.linkSelectedLineStyle);
26774
- gantt.parsedOptions.dependencyLinkLineCreatePointStyle = Object.assign({
26775
- strokeColor: 'red',
26776
- fillColor: 'white',
26777
- radius: 5,
26778
- strokeWidth: 1
26779
- }, options?.dependency?.linkCreatePointStyle);
26780
- gantt.parsedOptions.dependencyLinkLineCreatingPointStyle = Object.assign({
26781
- strokeColor: 'red',
26782
- fillColor: 'red',
26783
- radius: 5,
26784
- strokeWidth: 1
26785
- }, options?.dependency?.linkCreatingPointStyle);
26786
- gantt.parsedOptions.dependencyLinkLineCreatingStyle = Object.assign({
26787
- lineColor: 'red',
26788
- lineWidth: 1,
26789
- lineDash: [5, 5]
26790
- }, options?.dependency?.linkCreatingLineStyle);
26791
- gantt.parsedOptions.eventOptions = options?.eventOptions;
26792
- gantt.parsedOptions.keyboardOptions = options?.keyboardOptions;
26793
- gantt.parsedOptions.markLineCreateOptions = options?.markLineCreateOptions;
26737
+ return 'Invalid format specified. Please use "short" or "long".';
26794
26738
  }
26795
- function updateOptionsWhenScaleChanged(gantt) {
26796
- const options = gantt.options;
26797
- const { unit: minTimeUnit, startOfWeek, step } = gantt.parsedOptions.reverseSortedTimelineScales[0];
26798
- gantt.parsedOptions.minDate = getStartDateByTimeUnit(new Date(gantt.parsedOptions.minDate), minTimeUnit, startOfWeek);
26799
- gantt.parsedOptions.maxDate = getEndDateByTimeUnit(gantt.parsedOptions.minDate, new Date(gantt.parsedOptions.maxDate), minTimeUnit, step);
26800
- gantt.parsedOptions._minDateTime = gantt.parsedOptions.minDate?.getTime();
26801
- gantt.parsedOptions._maxDateTime = gantt.parsedOptions.maxDate?.getTime();
26802
- gantt.parsedOptions.timeLineHeaderRowHeights = [];
26803
- gantt.parsedOptions.timelineHeaderStyles = [];
26804
- for (let i = 0; i < gantt.parsedOptions.sortedTimelineScales.length ?? 0; i++) {
26805
- const style = gantt.parsedOptions.sortedTimelineScales[i].style;
26806
- gantt.parsedOptions.timelineHeaderStyles.push(Object.assign({
26807
- fontSize: 20,
26808
- fontWeight: 'bold',
26809
- textAlign: 'center',
26810
- textBaseline: 'middle',
26811
- color: '#000',
26812
- backgroundColor: '#fff'
26813
- }, style));
26814
- gantt.parsedOptions.timeLineHeaderRowHeights.push(gantt.parsedOptions.sortedTimelineScales[i].rowHeight ?? options?.headerRowHeight ?? 40);
26739
+ function isPropertyWritable(obj, prop) {
26740
+ const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
26741
+ if (!descriptor) {
26742
+ return false;
26815
26743
  }
26744
+ return !!descriptor.set || descriptor.writable === true;
26816
26745
  }
26817
- function generateTimeLineDate(currentDate, endDate, scale) {
26818
- const { unit, step, format } = scale;
26819
- const timelineDates = [];
26820
- while (currentDate < endDate) {
26821
- if (unit === 'day') {
26822
- const year = currentDate.getFullYear();
26823
- const month = currentDate.getMonth();
26824
- const day = currentDate.getDate();
26825
- const end = createDateAtLastHour(new Date(year, month, day + step - 1), true);
26826
- if (end.getTime() > endDate.getTime()) {
26827
- end.setTime(endDate.getTime());
26746
+ function createDateAtMidnight(dateStr, forceMidnight = false) {
26747
+ let date;
26748
+ if (dateStr) {
26749
+ date = new Date(dateStr);
26750
+ if (typeof dateStr === 'string') {
26751
+ if (dateStr.length > 10) {
26752
+ if (forceMidnight) {
26753
+ date.setHours(0, 0, 0, 0);
26754
+ }
26755
+ return date;
26828
26756
  }
26829
- const start = currentDate;
26830
- const formattedDate = format?.({ dateIndex: day, startDate: start, endDate: end });
26831
- const columnTitle = formattedDate || day.toString();
26832
- const dayCellConfig = {
26833
- days: Math.abs(end.getTime() - currentDate.getTime() + 1) / DayTimes,
26834
- startDate: start,
26835
- endDate: end,
26836
- step,
26837
- unit: 'day',
26838
- title: columnTitle,
26839
- dateIndex: day
26840
- };
26841
- timelineDates.push(dayCellConfig);
26842
- currentDate = new Date(year, month, day + step);
26757
+ date.setHours(0, 0, 0, 0);
26843
26758
  }
26844
- else if (unit === 'month') {
26845
- const year = currentDate.getFullYear();
26846
- const month = currentDate.getMonth();
26847
- const end = createDateAtLastHour(new Date(year, month + step, 0), true);
26848
- if (end.getTime() > endDate.getTime()) {
26849
- end.setTime(endDate.getTime());
26759
+ }
26760
+ else {
26761
+ date = new Date();
26762
+ }
26763
+ if (forceMidnight) {
26764
+ date.setHours(0, 0, 0, 0);
26765
+ }
26766
+ return date;
26767
+ }
26768
+ function createDateAtLastMinute(dateStr, forceSetMinute = false) {
26769
+ let date;
26770
+ if (dateStr) {
26771
+ date = new Date(dateStr);
26772
+ if (typeof dateStr === 'string') {
26773
+ if (dateStr.length > 10) {
26774
+ if (forceSetMinute) {
26775
+ date.setMinutes(59, 59, 999);
26776
+ }
26777
+ return date;
26850
26778
  }
26851
- const start = currentDate;
26852
- const formattedDate = format?.({ dateIndex: month + 1, startDate: start, endDate: end });
26853
- const columnTitle = formattedDate || (month + 1).toString();
26854
- const dayCellConfig = {
26855
- days: Math.abs(end.getTime() - currentDate.getTime() + 1) / DayTimes,
26856
- startDate: start,
26857
- step,
26858
- unit: 'month',
26859
- endDate: end,
26860
- title: columnTitle,
26861
- dateIndex: month + 1
26862
- };
26863
- timelineDates.push(dayCellConfig);
26864
- currentDate = new Date(year, month + step, 1);
26865
- }
26866
- else if (unit === 'quarter') {
26867
- const year = currentDate.getFullYear();
26868
- const quarter = Math.floor(currentDate.getMonth() / 3);
26869
- const end = createDateAtLastHour(new Date(year, (quarter + step) * 3, 0), true);
26870
- if (end.getTime() > endDate.getTime()) {
26871
- end.setTime(endDate.getTime());
26872
- }
26873
- const start = currentDate;
26874
- const formattedDate = format?.({ dateIndex: quarter + 1, startDate: start, endDate: end });
26875
- const columnTitle = formattedDate || (quarter + 1).toString();
26876
- const dayCellConfig = {
26877
- days: Math.abs(end.getTime() - currentDate.getTime() + 1) / (1000 * 60 * 60 * 24),
26878
- startDate: start,
26879
- step,
26880
- unit: 'quarter',
26881
- endDate: end,
26882
- title: columnTitle,
26883
- dateIndex: quarter + 1
26884
- };
26885
- timelineDates.push(dayCellConfig);
26886
- currentDate = new Date(year, (quarter + step) * 3, 1);
26887
- }
26888
- else if (unit === 'year') {
26889
- const year = currentDate.getFullYear();
26890
- const end = createDateAtLastHour(new Date(year + step - 1, 11, 31), true);
26891
- if (end.getTime() > endDate.getTime()) {
26892
- end.setTime(endDate.getTime());
26893
- }
26894
- const start = currentDate;
26895
- const formattedDate = format?.({ dateIndex: year, startDate: start, endDate: end });
26896
- const columnTitle = formattedDate || year.toString();
26897
- const dayCellConfig = {
26898
- days: Math.abs(end.getTime() - currentDate.getTime() + 1) / DayTimes,
26899
- startDate: start,
26900
- endDate: end,
26901
- step,
26902
- unit: 'year',
26903
- title: columnTitle,
26904
- dateIndex: year
26905
- };
26906
- timelineDates.push(dayCellConfig);
26907
- currentDate = new Date(year + step, 0, 1);
26908
- }
26909
- else if (unit === 'week') {
26910
- const startOfWeekSetting = scale.startOfWeek ?? 'monday';
26911
- let dayOfWeek = currentDate.getDay();
26912
- if (startOfWeekSetting === 'monday') {
26913
- dayOfWeek = dayOfWeek === 0 ? 6 : dayOfWeek - 1;
26914
- }
26915
- const startOfWeek = createDateAtMidnight(currentDate);
26916
- const dateEnd = createDateAtLastHour(currentDate.getTime() + (7 * step - dayOfWeek) * 24 * 60 * 60 * 1000 - 1, true);
26917
- if (dateEnd > endDate) {
26918
- dateEnd.setTime(endDate.getTime());
26919
- }
26920
- const weekNumber = getWeekNumber(startOfWeek);
26921
- const columnTitle = format?.({ dateIndex: weekNumber, startDate: startOfWeek, endDate: dateEnd }) || weekNumber.toString();
26922
- const dayCellConfig = {
26923
- days: (dateEnd.getTime() - startOfWeek.getTime() + 1) / DayTimes,
26924
- startDate: startOfWeek,
26925
- endDate: dateEnd,
26926
- step,
26927
- unit: 'week',
26928
- title: columnTitle,
26929
- dateIndex: weekNumber
26930
- };
26931
- timelineDates.push(dayCellConfig);
26932
- currentDate.setTime(createDateAtMidnight(currentDate.getTime() + (7 * step - dayOfWeek) * 24 * 60 * 60 * 1000, true).getTime());
26933
- }
26934
- else if (unit === 'hour') {
26935
- const year = currentDate.getFullYear();
26936
- const month = currentDate.getMonth();
26937
- const day = currentDate.getDate();
26938
- const hour = currentDate.getHours();
26939
- const end = createDateAtLastMinute(new Date(year, month, day, hour + step - 1), true);
26940
- if (end.getTime() > endDate.getTime()) {
26941
- end.setTime(endDate.getTime());
26942
- }
26943
- const start = currentDate;
26944
- const formattedDate = format?.({ dateIndex: hour, startDate: start, endDate: end });
26945
- const columnTitle = formattedDate || hour.toString();
26946
- const dayCellConfig = {
26947
- days: Math.abs(end.getTime() - currentDate.getTime() + 1) / DayTimes,
26948
- startDate: start,
26949
- endDate: end,
26950
- step,
26951
- unit: 'hour',
26952
- title: columnTitle,
26953
- dateIndex: currentDate.getHours()
26954
- };
26955
- timelineDates.push(dayCellConfig);
26956
- currentDate = new Date(year, month, day, hour + step);
26957
- }
26958
- else if (unit === 'minute') {
26959
- const year = currentDate.getFullYear();
26960
- const month = currentDate.getMonth();
26961
- const day = currentDate.getDate();
26962
- const hour = currentDate.getHours();
26963
- const minute = currentDate.getMinutes();
26964
- const end = createDateAtLastSecond(new Date(year, month, day, hour, minute + step - 1), true);
26965
- if (end.getTime() > endDate.getTime()) {
26966
- end.setTime(endDate.getTime());
26967
- }
26968
- const start = currentDate;
26969
- const formattedDate = format?.({ dateIndex: minute, startDate: start, endDate: end });
26970
- const columnTitle = formattedDate || minute.toString();
26971
- const dayCellConfig = {
26972
- days: Math.abs(end.getTime() - currentDate.getTime() + 1) / DayTimes,
26973
- startDate: start,
26974
- endDate: end,
26975
- step,
26976
- unit: 'minute',
26977
- title: columnTitle,
26978
- dateIndex: currentDate.getMinutes()
26979
- };
26980
- timelineDates.push(dayCellConfig);
26981
- currentDate = new Date(year, month, day, hour, minute + step);
26982
- }
26983
- else if (unit === 'second') {
26984
- const year = currentDate.getFullYear();
26985
- const month = currentDate.getMonth();
26986
- const day = currentDate.getDate();
26987
- const hour = currentDate.getHours();
26988
- const minute = currentDate.getMinutes();
26989
- const second = currentDate.getSeconds();
26990
- const end = createDateAtLastMillisecond(new Date(year, month, day, hour, minute, second + step - 1), true);
26991
- if (end.getTime() > endDate.getTime()) {
26992
- end.setTime(endDate.getTime());
26993
- }
26994
- const start = currentDate;
26995
- const formattedDate = format?.({ dateIndex: second, startDate: start, endDate: end });
26996
- const columnTitle = formattedDate || second.toString();
26997
- const dayCellConfig = {
26998
- days: Math.abs(end.getTime() - currentDate.getTime() + 1) / DayTimes,
26999
- startDate: start,
27000
- endDate: end,
27001
- step,
27002
- unit: 'second',
27003
- title: columnTitle,
27004
- dateIndex: currentDate.getSeconds()
27005
- };
27006
- timelineDates.push(dayCellConfig);
27007
- currentDate = new Date(year, month, day, hour, minute, second + step);
26779
+ date.setMinutes(59, 59, 999);
27008
26780
  }
27009
26781
  }
27010
- return timelineDates;
27011
- }
27012
- function getTextPos(padding, textAlign, textBaseline, width, height) {
27013
- let textX = padding[3] ?? 10;
27014
- if (textAlign === 'right' || textAlign === 'end') {
27015
- textX = width - 0 - (padding[1] ?? 10);
27016
- }
27017
- else if (textAlign === 'center') {
27018
- textX = 0 + (width - 0 + (padding[3] ?? 10) - (padding[1] ?? 10)) / 2;
27019
- }
27020
- let textY = 0 + (padding[0] ?? 10);
27021
- if (textBaseline === 'bottom' || textBaseline === 'alphabetic' || textBaseline === 'ideographic') {
27022
- textY = height - 0 - (padding[2] ?? 10);
27023
- }
27024
- else if (textBaseline === 'middle') {
27025
- textY = 0 + (height - 0 - (padding[0] ?? 10) - (padding[2] ?? 10)) / 2 + (padding[0] ?? 10);
26782
+ else {
26783
+ date = new Date();
27026
26784
  }
27027
- return {
27028
- x: textX,
27029
- y: textY
27030
- };
27031
- }
27032
- function convertProgress(progress) {
27033
- if (typeof progress === 'string') {
27034
- progress = progress.replace('%', '');
27035
- progress = parseFloat(progress);
26785
+ if (forceSetMinute) {
26786
+ date.setMinutes(59, 59, 999);
27036
26787
  }
27037
- return Math.round(progress);
26788
+ return date;
27038
26789
  }
27039
- function createSplitLineAndResizeLine(gantt) {
27040
- if (gantt.taskListTableInstance) {
27041
- gantt.verticalSplitResizeLine = document.createElement('div');
27042
- gantt.verticalSplitResizeLine.style.position = 'absolute';
27043
- gantt.verticalSplitResizeLine.style.top = gantt.tableY + 'px';
27044
- gantt.verticalSplitResizeLine.style.left =
27045
- (gantt.taskTableWidth ? gantt.taskTableWidth - 7 + gantt.parsedOptions.verticalSplitLine.lineWidth / 2 : 0) +
27046
- 'px';
27047
- gantt.verticalSplitResizeLine.style.width = '14px';
27048
- gantt.verticalSplitResizeLine.style.height = gantt.drawHeight + 'px';
27049
- gantt.verticalSplitResizeLine.style.backgroundColor = 'rgba(0,0,0,0)';
27050
- gantt.verticalSplitResizeLine.style.zIndex = '100';
27051
- gantt.parsedOptions.verticalSplitLineMoveable && (gantt.verticalSplitResizeLine.style.cursor = 'col-resize');
27052
- gantt.verticalSplitResizeLine.style.userSelect = 'none';
27053
- gantt.verticalSplitResizeLine.style.opacity = '1';
27054
- const verticalSplitLine = document.createElement('div');
27055
- verticalSplitLine.style.position = 'absolute';
27056
- verticalSplitLine.style.top = '0px';
27057
- verticalSplitLine.style.left = `${(14 - gantt.parsedOptions.verticalSplitLine.lineWidth) / 2}px`;
27058
- verticalSplitLine.style.width = gantt.parsedOptions.verticalSplitLine.lineWidth + 'px';
27059
- verticalSplitLine.style.height = '100%';
27060
- verticalSplitLine.style.backgroundColor = gantt.parsedOptions.verticalSplitLine.lineColor;
27061
- verticalSplitLine.style.zIndex = '100';
27062
- verticalSplitLine.style.userSelect = 'none';
27063
- verticalSplitLine.style.pointerEvents = 'none';
27064
- verticalSplitLine.style.transition = 'background-color 0.3s';
27065
- gantt.verticalSplitResizeLine.appendChild(verticalSplitLine);
27066
- if (gantt.parsedOptions.verticalSplitLineHighlight) {
27067
- const highlightLine = document.createElement('div');
27068
- highlightLine.style.position = 'absolute';
27069
- highlightLine.style.top = '0px';
27070
- highlightLine.style.left = `${(14 - gantt.parsedOptions.verticalSplitLineHighlight.lineWidth ?? 2) / 2}px`;
27071
- highlightLine.style.width = (gantt.parsedOptions.verticalSplitLineHighlight.lineWidth ?? 2) + 'px';
27072
- highlightLine.style.height = '100%';
27073
- highlightLine.style.backgroundColor = gantt.parsedOptions.verticalSplitLineHighlight.lineColor;
27074
- highlightLine.style.zIndex = '100';
27075
- highlightLine.style.cursor = 'col-resize';
27076
- highlightLine.style.userSelect = 'none';
27077
- highlightLine.style.pointerEvents = 'none';
27078
- highlightLine.style.opacity = '0';
27079
- highlightLine.style.transition = 'background-color 0.3s';
27080
- gantt.verticalSplitResizeLine.appendChild(highlightLine);
26790
+ function createDateAtLastSecond(dateStr, forceSetSecond = false) {
26791
+ let date;
26792
+ if (dateStr) {
26793
+ date = new Date(dateStr);
26794
+ if (typeof dateStr === 'string') {
26795
+ if (dateStr.length > 10) {
26796
+ if (forceSetSecond) {
26797
+ date.setSeconds(59, 999);
26798
+ }
26799
+ return date;
26800
+ }
26801
+ date.setSeconds(59, 999);
27081
26802
  }
27082
- gantt.container.appendChild(gantt.verticalSplitResizeLine);
27083
26803
  }
27084
- }
27085
- function updateSplitLineAndResizeLine(gantt) {
27086
- if (gantt.verticalSplitResizeLine) {
27087
- gantt.verticalSplitResizeLine.style.position = 'absolute';
27088
- gantt.verticalSplitResizeLine.style.top = gantt.tableY + 'px';
27089
- gantt.verticalSplitResizeLine.style.left = gantt.taskTableWidth
27090
- ? `${gantt.taskTableWidth - 7 + gantt.parsedOptions.verticalSplitLine.lineWidth / 2}px`
27091
- : '0px';
27092
- gantt.verticalSplitResizeLine.style.width = '14px';
27093
- gantt.verticalSplitResizeLine.style.height = gantt.drawHeight + 'px';
27094
- gantt.verticalSplitResizeLine.style.backgroundColor = 'rgba(0,0,0,0)';
27095
- gantt.verticalSplitResizeLine.style.zIndex = '100';
27096
- gantt.parsedOptions.verticalSplitLineMoveable && (gantt.verticalSplitResizeLine.style.cursor = 'col-resize');
27097
- gantt.verticalSplitResizeLine.style.userSelect = 'none';
27098
- gantt.verticalSplitResizeLine.style.opacity = '1';
27099
- const verticalSplitLine = gantt.verticalSplitResizeLine.childNodes[0];
27100
- verticalSplitLine.style.position = 'absolute';
27101
- verticalSplitLine.style.top = '0px';
27102
- verticalSplitLine.style.left = `${(14 - gantt.parsedOptions.verticalSplitLine.lineWidth) / 2}px`;
27103
- verticalSplitLine.style.width = gantt.parsedOptions.verticalSplitLine.lineWidth + 'px';
27104
- verticalSplitLine.style.height = '100%';
27105
- verticalSplitLine.style.backgroundColor = gantt.parsedOptions.verticalSplitLine.lineColor;
27106
- verticalSplitLine.style.zIndex = '100';
27107
- verticalSplitLine.style.userSelect = 'none';
27108
- verticalSplitLine.style.pointerEvents = 'none';
27109
- verticalSplitLine.style.transition = 'background-color 0.3s';
27110
- if (gantt.verticalSplitResizeLine.childNodes[1]) {
27111
- const highlightLine = gantt.verticalSplitResizeLine.childNodes[1];
27112
- highlightLine.style.position = 'absolute';
27113
- highlightLine.style.top = '0px';
27114
- highlightLine.style.left = `${(14 - gantt.parsedOptions.verticalSplitLineHighlight.lineWidth ?? 2) / 2}px`;
27115
- highlightLine.style.width = (gantt.parsedOptions.verticalSplitLineHighlight.lineWidth ?? 2) + 'px';
27116
- highlightLine.style.height = '100%';
27117
- highlightLine.style.backgroundColor = gantt.parsedOptions.verticalSplitLineHighlight.lineColor;
27118
- highlightLine.style.zIndex = '100';
27119
- highlightLine.style.cursor = 'col-resize';
27120
- highlightLine.style.userSelect = 'none';
27121
- highlightLine.style.pointerEvents = 'none';
27122
- highlightLine.style.opacity = '0';
27123
- highlightLine.style.transition = 'background-color 0.3s';
27124
- }
26804
+ else {
26805
+ date = new Date();
26806
+ }
26807
+ if (forceSetSecond) {
26808
+ date.setSeconds(59, 999);
27125
26809
  }
26810
+ return date;
27126
26811
  }
27127
- function findRecordByTaskKey(records, taskKeyField, taskKey, childrenField = 'children') {
27128
- for (let i = 0; i < records.length; i++) {
27129
- if ((Array.isArray(taskKey) && taskKey.length === 1 && records[i][taskKeyField] === taskKey[0]) ||
27130
- records[i][taskKeyField] === taskKey) {
27131
- return { record: records[i], index: [i] };
27132
- }
27133
- else if (records[i][childrenField]?.length) {
27134
- if (Array.isArray(taskKey) && taskKey[0] === records[i][taskKeyField]) {
27135
- const result = findRecordByTaskKey(records[i][childrenField], taskKeyField, taskKey.slice(1));
27136
- if (result) {
27137
- result.index.unshift(i);
27138
- return result;
27139
- }
27140
- }
27141
- else if (!Array.isArray(taskKey)) {
27142
- const result = findRecordByTaskKey(records[i][childrenField], taskKeyField, taskKey);
27143
- if (result) {
27144
- result.index.unshift(i);
27145
- return result;
26812
+ function createDateAtLastMillisecond(dateStr, forceSetMillisecond = false) {
26813
+ let date;
26814
+ if (dateStr) {
26815
+ date = new Date(dateStr);
26816
+ if (typeof dateStr === 'string') {
26817
+ if (dateStr.length > 10) {
26818
+ if (forceSetMillisecond) {
26819
+ date.setMilliseconds(999);
27146
26820
  }
26821
+ return date;
27147
26822
  }
26823
+ date.setMilliseconds(999);
27148
26824
  }
27149
26825
  }
27150
- }
27151
- function clearRecordLinkInfos(records, childrenField = 'children') {
27152
- for (let i = 0; i < records.length; i++) {
27153
- if (records[i][childrenField]?.length) {
27154
- clearRecordLinkInfos(records[i][childrenField], childrenField);
27155
- }
27156
- else {
27157
- delete records[i].vtable_gantt_linkedTo;
27158
- delete records[i].vtable_gantt_linkedFrom;
27159
- }
26826
+ else {
26827
+ date = new Date();
27160
26828
  }
27161
- }
27162
- function clearRecordShowIndex(records, childrenField = 'children') {
27163
- for (let i = 0; i < records.length; i++) {
27164
- if (records[i][childrenField]?.length) {
27165
- clearRecordShowIndex(records[i][childrenField], childrenField);
27166
- }
27167
- else {
27168
- delete records[i].vtable_gantt_showIndex;
27169
- }
26829
+ if (forceSetMillisecond) {
26830
+ date.setMilliseconds(999);
27170
26831
  }
26832
+ return date;
27171
26833
  }
27172
- function getTaskIndexsByTaskY(y, gantt) {
27173
- let task_index;
27174
- let sub_task_index;
27175
- if (gantt.taskListTableInstance) {
27176
- const rowInfo = gantt.taskListTableInstance.getTargetRowAt(y + gantt.headerHeight);
27177
- if (rowInfo) {
27178
- const { row } = rowInfo;
27179
- task_index = row - gantt.taskListTableInstance.columnHeaderLevelCount;
27180
- const beforeRowsHeight = gantt.getRowsHeightByIndex(0, task_index - 1);
27181
- if (gantt.parsedOptions.tasksShowMode === TasksShowMode.Sub_Tasks_Inline ||
27182
- gantt.parsedOptions.tasksShowMode === TasksShowMode.Sub_Tasks_Arrange ||
27183
- gantt.parsedOptions.tasksShowMode === TasksShowMode.Sub_Tasks_Compact ||
27184
- gantt.parsedOptions.tasksShowMode === TasksShowMode.Sub_Tasks_Separate) {
27185
- sub_task_index = Math.floor((y - beforeRowsHeight) / gantt.parsedOptions.rowHeight);
26834
+ function createDateAtLastHour(dateStr, forceLastHour = false) {
26835
+ let date;
26836
+ if (dateStr) {
26837
+ date = new Date(dateStr);
26838
+ if (typeof dateStr === 'string') {
26839
+ if (dateStr.length > 10) {
26840
+ if (forceLastHour) {
26841
+ date.setHours(23, 59, 59, 999);
26842
+ }
26843
+ return date;
27186
26844
  }
26845
+ date.setHours(23, 59, 59, 999);
27187
26846
  }
27188
26847
  }
27189
26848
  else {
27190
- task_index = Math.floor(y / gantt.parsedOptions.rowHeight);
27191
- }
27192
- return { task_index, sub_task_index };
27193
- }
27194
- function computeRowsCountByRecordDateForCompact(gantt, record) {
27195
- if (!record.children || record.children.length === 1) {
27196
- if (record.children?.length === 1) {
27197
- record.children[0].vtable_gantt_showIndex = 0;
27198
- }
27199
- else {
27200
- record.vtable_gantt_showIndex = 0;
27201
- }
27202
- return 1;
26849
+ date = new Date();
27203
26850
  }
27204
- const sortedChildren = record.children.slice().sort((a, b) => {
27205
- const { startDate: aStartDate } = formatRecordDateConsiderHasHour(gantt, a);
27206
- const { startDate: bStartDate } = formatRecordDateConsiderHasHour(gantt, b);
27207
- return aStartDate.getTime() - bStartDate.getTime();
27208
- });
27209
- const rows = [];
27210
- for (let i = 0; i <= sortedChildren.length - 1; i++) {
27211
- const newRecord = sortedChildren[i];
27212
- const { startDate, endDate } = formatRecordDateConsiderHasHour(gantt, newRecord);
27213
- let placed = false;
27214
- for (let j = 0; j < rows.length; j++) {
27215
- if (startDate.getTime() > rows[j]) {
27216
- rows[j] = endDate.getTime();
27217
- placed = true;
27218
- newRecord.vtable_gantt_showIndex = j;
27219
- break;
27220
- }
27221
- }
27222
- if (!placed) {
27223
- rows.push(endDate.getTime());
27224
- newRecord.vtable_gantt_showIndex = rows.length - 1;
27225
- }
26851
+ if (forceLastHour) {
26852
+ date.setHours(23, 59, 59, 999);
27226
26853
  }
27227
- return rows.length;
27228
- }
27229
- function isOverlapping(startDate, endDate, rowTasks, gantt) {
27230
- return rowTasks.some(rowTask => {
27231
- const { startDate: startDate2, endDate: endDate2 } = formatRecordDateConsiderHasHour(gantt, rowTask);
27232
- return startDate <= endDate2 && startDate2 <= endDate;
27233
- });
26854
+ return date;
27234
26855
  }
27235
- function computeRowsCountByRecordDate(gantt, record) {
27236
- if (!record.children || record.children.length === 1) {
27237
- if (record.children?.length === 1) {
27238
- record.children[0].vtable_gantt_showIndex = 0;
27239
- }
27240
- else {
27241
- record.vtable_gantt_showIndex = 0;
27242
- }
27243
- return 1;
26856
+ function getEndDateByTimeUnit(startDate, date, timeScale, step) {
26857
+ let endDate = new Date(date);
26858
+ switch (timeScale) {
26859
+ case 'second':
26860
+ endDate.setMilliseconds(999);
26861
+ break;
26862
+ case 'minute':
26863
+ endDate.setSeconds(59, 999);
26864
+ break;
26865
+ case 'hour':
26866
+ endDate.setMinutes(59, 59, 999);
26867
+ break;
26868
+ case 'day':
26869
+ endDate.setHours(23, 59, 59, 999);
26870
+ break;
26871
+ case 'week':
26872
+ const day = endDate.getDay();
26873
+ const diffToEndOfWeek = 6 - day;
26874
+ endDate.setDate(endDate.getDate() + diffToEndOfWeek);
26875
+ endDate.setHours(23, 59, 59, 999);
26876
+ break;
26877
+ case 'month':
26878
+ const lastDayOfMonth = new Date(endDate.getFullYear(), endDate.getMonth() + 1, 0).getDate();
26879
+ endDate.setDate(lastDayOfMonth);
26880
+ endDate.setHours(23, 59, 59, 999);
26881
+ break;
26882
+ case 'quarter':
26883
+ const currentMonth = endDate.getMonth();
26884
+ const endMonthOfQuarter = currentMonth - (currentMonth % 3) + 2;
26885
+ const lastDayOfQuarter = new Date(endDate.getFullYear(), endMonthOfQuarter + 1, 0).getDate();
26886
+ endDate.setMonth(endMonthOfQuarter, lastDayOfQuarter);
26887
+ endDate.setHours(23, 59, 59, 999);
26888
+ break;
26889
+ case 'year':
26890
+ endDate.setMonth(11, 31);
26891
+ endDate.setHours(23, 59, 59, 999);
26892
+ break;
26893
+ default:
26894
+ throw new Error('Invalid time scale');
27244
26895
  }
27245
- const rows = [];
27246
- for (let i = 0; i <= record.children.length - 1; i++) {
27247
- const newRecord = record.children[i];
27248
- const { startDate, endDate } = formatRecordDateConsiderHasHour(gantt, newRecord);
27249
- let placed = false;
27250
- for (let j = 0; j < rows.length; j++) {
27251
- const rowTasks = record.children.filter((t) => t !== newRecord && t.vtable_gantt_showIndex === j);
27252
- if (!isOverlapping(startDate, endDate, rowTasks, gantt)) {
27253
- rows[j] = endDate.getTime();
27254
- placed = true;
27255
- newRecord.vtable_gantt_showIndex = j;
26896
+ const count = computeCountToTimeScale(endDate, startDate, timeScale, step, 1);
26897
+ const targetCount = Math.ceil(count);
26898
+ if (targetCount > count) {
26899
+ const dif = (targetCount - count) * step;
26900
+ const msInSecond = 1000;
26901
+ const msInMinute = msInSecond * 60;
26902
+ const msInHour = msInMinute * 60;
26903
+ const msInDay = msInHour * 24;
26904
+ const msInWeek = msInDay * 7;
26905
+ new Date(endDate.getTime() + 1);
26906
+ switch (timeScale) {
26907
+ case 'second':
26908
+ endDate.setTime(endDate.getTime() + dif * msInSecond);
27256
26909
  break;
27257
- }
27258
- }
27259
- if (!placed) {
27260
- rows.push(endDate.getTime());
27261
- newRecord.vtable_gantt_showIndex = rows.length - 1;
26910
+ case 'minute':
26911
+ endDate.setTime(endDate.getTime() + dif * msInMinute);
26912
+ break;
26913
+ case 'hour':
26914
+ endDate.setTime(endDate.getTime() + dif * msInHour);
26915
+ break;
26916
+ case 'day':
26917
+ endDate.setTime(endDate.getTime() + dif * msInDay);
26918
+ break;
26919
+ case 'week':
26920
+ endDate.setTime(endDate.getTime() + dif * msInWeek);
26921
+ break;
26922
+ case 'month':
26923
+ endDate = new Date(endDate.getFullYear(), endDate.getMonth() + 1 + Math.round(dif), 0);
26924
+ endDate.setHours(23, 59, 59, 999);
26925
+ break;
26926
+ case 'quarter':
26927
+ const currentMonth = endDate.getMonth();
26928
+ const endMonthOfQuarter = currentMonth - (currentMonth % 3) + 2;
26929
+ endDate = new Date(endDate.getFullYear(), endMonthOfQuarter + Math.round(dif * 3) + 1, 0);
26930
+ endDate.setHours(23, 59, 59, 999);
26931
+ break;
26932
+ case 'year':
26933
+ endDate.setFullYear(endDate.getFullYear() + Math.floor(dif));
26934
+ endDate.setHours(23, 59, 59, 999);
26935
+ break;
26936
+ default:
26937
+ throw new Error('Invalid time scale');
27262
26938
  }
27263
26939
  }
27264
- return rows.length;
27265
- }
27266
- function formatRecordDateConsiderHasHour(gantt, record) {
27267
- const { timeScaleIncludeHour, startDateField, endDateField } = gantt.parsedOptions;
27268
- const startDate = record[startDateField];
27269
- const endDate = record[endDateField];
27270
- if (timeScaleIncludeHour) {
27271
- return { startDate: createDateAtMidnight(startDate), endDate: createDateAtLastHour(endDate) };
27272
- }
27273
- return { startDate: createDateAtMidnight(startDate, true), endDate: createDateAtLastHour(endDate, true) };
27274
- }
27275
- function updateOptionsWhenRecordChanged(gantt) {
27276
- const options = gantt.options;
27277
- const { unit: minTimeUnit, startOfWeek } = gantt.parsedOptions.reverseSortedTimelineScales[0];
27278
- gantt.parsedOptions.markLine = generateMarkLine(options?.markLine);
27279
- if (gantt.parsedOptions.markLine?.length ?? 0) {
27280
- if (gantt.parsedOptions.markLine?.every(item => item.scrollToMarkLine === undefined)) {
27281
- gantt.parsedOptions.markLine[0].scrollToMarkLine = true;
27282
- }
27283
- if (gantt.parsedOptions.markLine?.find(item => item.scrollToMarkLine)) {
27284
- gantt.parsedOptions.scrollToMarkLineDate = getStartDateByTimeUnit(new Date(gantt.parsedOptions.markLine?.find(item => item.scrollToMarkLine).date), minTimeUnit, startOfWeek);
27285
- }
27286
- }
27287
- gantt.parsedOptions.dependencyLinks = options.dependency?.links;
27288
- }
27289
- function updateOptionsWhenDateRangeChanged(gantt) {
27290
- const options = gantt.options;
27291
- const { unit: minTimeUnit, startOfWeek, step } = gantt.parsedOptions.reverseSortedTimelineScales[0];
27292
- gantt.parsedOptions.minDate = options?.minDate
27293
- ? getStartDateByTimeUnit(new Date(options.minDate), minTimeUnit, startOfWeek)
27294
- : undefined;
27295
- gantt.parsedOptions.maxDate = options?.maxDate
27296
- ? getEndDateByTimeUnit(gantt.parsedOptions.minDate, new Date(options.maxDate), minTimeUnit, step)
27297
- : undefined;
27298
- gantt.parsedOptions._minDateTime = gantt.parsedOptions.minDate?.getTime();
27299
- gantt.parsedOptions._maxDateTime = gantt.parsedOptions.maxDate?.getTime();
27300
- }
27301
- function updateOptionsWhenMarkLineChanged(gantt) {
27302
- const options = gantt.options;
27303
- gantt.parsedOptions.markLine = generateMarkLine(options?.markLine);
27304
- }
27305
- function _getTaskInfoByXYForCreateSchedule(eventX, eventY, gantt) {
27306
- const taskIndex = getTaskIndexsByTaskY(eventY - gantt.headerHeight + gantt.stateManager.scrollTop, gantt);
27307
- const recordParent = gantt.getRecordByIndex(taskIndex.task_index);
27308
- const dateIndex = getDateIndexByX(eventX, gantt);
27309
- const dateRange = gantt.getDateRangeByIndex(dateIndex);
27310
- if (recordParent?.children) {
27311
- const taskIndex = getTaskIndexsByTaskY(eventY - gantt.headerHeight + gantt.stateManager.scrollTop, gantt);
27312
- for (let i = 0; i < recordParent.children.length; i++) {
27313
- const { startDate, endDate, taskDays, progress, taskRecord } = gantt.getTaskInfoByTaskListIndex(taskIndex.task_index, i);
27314
- if (((gantt.parsedOptions.tasksShowMode === TasksShowMode.Sub_Tasks_Compact ||
27315
- gantt.parsedOptions.tasksShowMode === TasksShowMode.Sub_Tasks_Arrange) &&
27316
- taskRecord.vtable_gantt_showIndex === taskIndex.sub_task_index) ||
27317
- gantt.parsedOptions.tasksShowMode === TasksShowMode.Sub_Tasks_Inline) {
27318
- if (dateRange.startDate.getTime() >= startDate.getTime() && dateRange.endDate.getTime() <= endDate.getTime()) {
27319
- return { startDate, endDate, taskDays, progress, taskRecord };
27320
- }
27321
- }
27322
- }
27323
- }
27324
- }
27325
- function getNodeClickPos(marklineIconNode, gantt) {
27326
- const left = marklineIconNode.globalTransMatrix.e +
27327
- gantt.taskListTableInstance.tableNoFrameWidth +
27328
- gantt.taskListTableInstance.tableX +
27329
- gantt.tableX;
27330
- const top = marklineIconNode.globalTransMatrix.f;
27331
- const width = marklineIconNode.attribute.width;
27332
- const height = marklineIconNode.attribute.height;
27333
- return {
27334
- left,
27335
- top,
27336
- width,
27337
- height
27338
- };
27339
- }
27340
- function judgeIfHasMarkLine(data, markLine) {
27341
- const beginTime = data.startDate.getTime();
27342
- const endTime = data.endDate.getTime();
27343
- return markLine.some(item => {
27344
- const marklineTime = new Date(item.date).getTime();
27345
- return marklineTime >= beginTime && marklineTime <= endTime;
27346
- });
27347
- }
27348
-
27349
- function throttle$1(func, delay) {
27350
- let timer = null;
27351
- return function (...args) {
27352
- if (!timer) {
27353
- func.apply(this, args);
27354
- timer = setTimeout(() => {
27355
- timer = null;
27356
- }, delay);
27357
- }
27358
- };
27359
- }
27360
- function getTodayNearDay(dayOffset, format) {
27361
- const today = new Date();
27362
- const todayTime = today.getTime();
27363
- const oneDayTime = 24 * 60 * 60 * 1000;
27364
- const targetTime = todayTime + dayOffset * oneDayTime;
27365
- const date = new Date(targetTime);
27366
- if (format) {
27367
- const year = date.getFullYear().toString();
27368
- const month = (date.getMonth() + 1).toString().padStart(2, '0');
27369
- const day = date.getDate().toString().padStart(2, '0');
27370
- format = format.replace('yyyy', year);
27371
- format = format.replace('mm', month);
27372
- format = format.replace('dd', day);
27373
- return format;
27374
- }
27375
- return date;
27376
- }
27377
- function formatDate(date, format) {
27378
- const year = date.getFullYear().toString();
27379
- const month = (date.getMonth() + 1).toString().padStart(2, '0');
27380
- const day = date.getDate().toString().padStart(2, '0');
27381
- format = format.replace('yyyy', year);
27382
- format = format.replace('mm', month);
27383
- format = format.replace('dd', day);
27384
- if (format.length > 10) {
27385
- const hour = date.getHours().toString().padStart(2, '0');
27386
- const minute = date.getMinutes().toString().padStart(2, '0');
27387
- const second = date.getSeconds().toString().padStart(2, '0');
27388
- format = format.replace('hh', hour);
27389
- format = format.replace('mm', minute);
27390
- format = format.replace('ss', second);
27391
- }
27392
- return format;
27393
- }
27394
- function validateDate(dateParts, format) {
27395
- const yearIndex = format.indexOf('yyyy');
27396
- const monthIndex = format.indexOf('mm');
27397
- const dayIndex = format.indexOf('dd');
27398
- const dateYearIndex = yearIndex < monthIndex ? (yearIndex < dayIndex ? 0 : 1) : monthIndex < dayIndex ? 1 : 2;
27399
- const dateMonthIndex = monthIndex < yearIndex ? (monthIndex < dayIndex ? 0 : 1) : monthIndex < dayIndex ? 1 : 2;
27400
- const dateDayIndex = dayIndex < yearIndex ? (dayIndex < monthIndex ? 0 : 1) : dayIndex < monthIndex ? 1 : 2;
27401
- const year = parseInt(dateParts[dateYearIndex], 10);
27402
- const month = parseInt(dateParts[dateMonthIndex], 10) - 1;
27403
- const day = parseInt(dateParts[dateDayIndex], 10);
27404
- if (isNaN(year) || year < 1) {
27405
- return false;
27406
- }
27407
- if (isNaN(month) || month < 0 || month > 11) {
27408
- return false;
27409
- }
27410
- const daysInMonth = [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
27411
- if (isNaN(day) || day < 1 || day > daysInMonth[month]) {
27412
- return false;
27413
- }
27414
- return true;
27415
- }
27416
- function validateTime(dateParts, format) {
27417
- if (format.includes('hh') || format.includes('mm') || format.includes('ss')) {
27418
- const timeIndex = format.indexOf('hh') > -1 ? format.indexOf('hh') : format.indexOf('HH');
27419
- const hour = parseInt(dateParts[timeIndex], 10);
27420
- const minute = parseInt(dateParts[timeIndex + 1], 10);
27421
- const second = dateParts.length > timeIndex + 2 ? parseInt(dateParts[timeIndex + 2], 10) : 0;
27422
- if (isNaN(hour) || hour < 0 || hour > 23) {
27423
- return false;
27424
- }
27425
- if (isNaN(minute) || minute < 0 || minute > 59) {
27426
- return false;
27427
- }
27428
- if (isNaN(second) || second < 0 || second > 59) {
27429
- return false;
27430
- }
27431
- }
27432
- return true;
27433
- }
27434
- function isLeapYear(year) {
27435
- return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
27436
- }
27437
- function parseDateFormat(dateString) {
27438
- const formats = [
27439
- 'yyyy-mm-dd',
27440
- 'dd-mm-yyyy',
27441
- 'mm/dd/yyyy',
27442
- 'yyyy/mm/dd',
27443
- 'dd/mm/yyyy',
27444
- 'yyyy.mm.dd',
27445
- 'mm.dd.yyyy',
27446
- 'dd.mm.yyyy'
27447
- ];
27448
- const timeFormat = ['hh:mm:ss', 'hh:mm'];
27449
- dateString = dateString.trim();
27450
- const dates = dateString.split(' ');
27451
- const date = dates[0];
27452
- const time = dates[1];
27453
- let dateFormatMatched;
27454
- let timeFormatMatched;
27455
- if (date) {
27456
- for (let i = 0; i < formats.length; i++) {
27457
- const format = formats[i];
27458
- const dateParts = date.split(getSeparator(format));
27459
- const isValid = validateDate(dateParts, format);
27460
- if (dateParts.length === 3 && isValid) {
27461
- dateFormatMatched = format;
27462
- break;
27463
- }
27464
- }
27465
- }
27466
- if (dateFormatMatched) {
27467
- if (time) {
27468
- for (let i = 0; i < timeFormat.length; i++) {
27469
- const format = timeFormat[i];
27470
- const timeParts = time.split(getSeparator(format));
27471
- const formatParts = format.split(getSeparator(format));
27472
- const isValid = validateTime(timeParts, format);
27473
- if (isValid && timeParts.length === formatParts.length) {
27474
- timeFormatMatched = format;
27475
- break;
27476
- }
27477
- }
27478
- }
27479
- }
27480
- if (date && time && dateFormatMatched && timeFormatMatched) {
27481
- return dateFormatMatched + ' ' + timeFormatMatched;
27482
- }
27483
- if (date && !time) {
27484
- return dateFormatMatched;
27485
- }
27486
- return 'yyyy-mm-dd hh:mm:ss';
27487
- }
27488
- function getSeparator(format) {
27489
- const separators = format.match(/[^\w]/g);
27490
- if (separators) {
27491
- const escapedSeparators = separators.map(s => '\\' + s).join('|');
27492
- return new RegExp(escapedSeparators, 'g');
27493
- }
27494
- return /[^\w]/;
27495
- }
27496
- function parseStringTemplate(template, data) {
27497
- const result = template.replace(/\{([^}]+)\}/g, (match, key) => {
27498
- const keys = key.split('.');
27499
- let value = data;
27500
- for (const k of keys) {
27501
- if (value.hasOwnProperty(k)) {
27502
- value = value[k];
27503
- }
27504
- else {
27505
- value = match;
27506
- break;
27507
- }
27508
- }
27509
- return value;
27510
- });
27511
- return result;
27512
- }
27513
- function toBoxArray$2(obj) {
27514
- if (!Array.isArray(obj)) {
27515
- return [obj, obj, obj, obj];
27516
- }
27517
- if (obj.length === 3) {
27518
- return [obj[0], obj[1], obj[2], obj[1]];
27519
- }
27520
- if (obj.length === 2) {
27521
- return [obj[0], obj[1], obj[0], obj[1]];
27522
- }
27523
- if (obj.length === 1) {
27524
- return [obj[0], obj[0], obj[0], obj[0]];
27525
- }
27526
- return [obj[0], obj[1], obj[2], obj[3]];
27527
- }
27528
- function getWeekNumber(currentDate) {
27529
- const startOfYear = new Date(currentDate.getFullYear(), 0, 1);
27530
- const weekNumber = Math.ceil(((currentDate.getTime() + 1 - startOfYear.getTime()) / 86400000 + 1) / 7);
27531
- return weekNumber;
27532
- }
27533
- function getWeekday(dateString, format = 'long') {
27534
- const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
27535
- const date = new Date(dateString);
27536
- if (format === 'short') {
27537
- return days[date.getDay()].substr(0, 3);
27538
- }
27539
- else if (format === 'long') {
27540
- return days[date.getDay()];
27541
- }
27542
- return 'Invalid format specified. Please use "short" or "long".';
27543
- }
27544
- function isPropertyWritable(obj, prop) {
27545
- const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
27546
- if (!descriptor) {
27547
- return false;
27548
- }
27549
- return !!descriptor.set || descriptor.writable === true;
27550
- }
27551
- function createDateAtMidnight(dateStr, forceMidnight = false) {
27552
- let date;
27553
- if (dateStr) {
27554
- date = new Date(dateStr);
27555
- if (typeof dateStr === 'string') {
27556
- if (dateStr.length > 10) {
27557
- if (forceMidnight) {
27558
- date.setHours(0, 0, 0, 0);
27559
- }
27560
- return date;
27561
- }
27562
- date.setHours(0, 0, 0, 0);
27563
- }
27564
- }
27565
- else {
27566
- date = new Date();
27567
- }
27568
- if (forceMidnight) {
27569
- date.setHours(0, 0, 0, 0);
27570
- }
27571
- return date;
27572
- }
27573
- function createDateAtLastMinute(dateStr, forceSetMinute = false) {
27574
- let date;
27575
- if (dateStr) {
27576
- date = new Date(dateStr);
27577
- if (typeof dateStr === 'string') {
27578
- if (dateStr.length > 10) {
27579
- if (forceSetMinute) {
27580
- date.setMinutes(59, 59, 999);
27581
- }
27582
- return date;
27583
- }
27584
- date.setMinutes(59, 59, 999);
27585
- }
27586
- }
27587
- else {
27588
- date = new Date();
27589
- }
27590
- if (forceSetMinute) {
27591
- date.setMinutes(59, 59, 999);
27592
- }
27593
- return date;
27594
- }
27595
- function createDateAtLastSecond(dateStr, forceSetSecond = false) {
27596
- let date;
27597
- if (dateStr) {
27598
- date = new Date(dateStr);
27599
- if (typeof dateStr === 'string') {
27600
- if (dateStr.length > 10) {
27601
- if (forceSetSecond) {
27602
- date.setSeconds(59, 999);
27603
- }
27604
- return date;
27605
- }
27606
- date.setSeconds(59, 999);
27607
- }
27608
- }
27609
- else {
27610
- date = new Date();
27611
- }
27612
- if (forceSetSecond) {
27613
- date.setSeconds(59, 999);
27614
- }
27615
- return date;
27616
- }
27617
- function createDateAtLastMillisecond(dateStr, forceSetMillisecond = false) {
27618
- let date;
27619
- if (dateStr) {
27620
- date = new Date(dateStr);
27621
- if (typeof dateStr === 'string') {
27622
- if (dateStr.length > 10) {
27623
- if (forceSetMillisecond) {
27624
- date.setMilliseconds(999);
27625
- }
27626
- return date;
27627
- }
27628
- date.setMilliseconds(999);
27629
- }
27630
- }
27631
- else {
27632
- date = new Date();
27633
- }
27634
- if (forceSetMillisecond) {
27635
- date.setMilliseconds(999);
27636
- }
27637
- return date;
27638
- }
27639
- function createDateAtLastHour(dateStr, forceLastHour = false) {
27640
- let date;
27641
- if (dateStr) {
27642
- date = new Date(dateStr);
27643
- if (typeof dateStr === 'string') {
27644
- if (dateStr.length > 10) {
27645
- if (forceLastHour) {
27646
- date.setHours(23, 59, 59, 999);
27647
- }
27648
- return date;
27649
- }
27650
- date.setHours(23, 59, 59, 999);
27651
- }
27652
- }
27653
- else {
27654
- date = new Date();
27655
- }
27656
- if (forceLastHour) {
27657
- date.setHours(23, 59, 59, 999);
27658
- }
27659
- return date;
27660
- }
27661
- function getEndDateByTimeUnit(startDate, date, timeScale, step) {
27662
- let endDate = new Date(date);
27663
- switch (timeScale) {
27664
- case 'second':
27665
- endDate.setMilliseconds(999);
27666
- break;
27667
- case 'minute':
27668
- endDate.setSeconds(59, 999);
27669
- break;
27670
- case 'hour':
27671
- endDate.setMinutes(59, 59, 999);
27672
- break;
27673
- case 'day':
27674
- endDate.setHours(23, 59, 59, 999);
27675
- break;
27676
- case 'week':
27677
- const day = endDate.getDay();
27678
- const diffToEndOfWeek = 6 - day;
27679
- endDate.setDate(endDate.getDate() + diffToEndOfWeek);
27680
- endDate.setHours(23, 59, 59, 999);
27681
- break;
27682
- case 'month':
27683
- const lastDayOfMonth = new Date(endDate.getFullYear(), endDate.getMonth() + 1, 0).getDate();
27684
- endDate.setDate(lastDayOfMonth);
27685
- endDate.setHours(23, 59, 59, 999);
27686
- break;
27687
- case 'quarter':
27688
- const currentMonth = endDate.getMonth();
27689
- const endMonthOfQuarter = currentMonth - (currentMonth % 3) + 2;
27690
- const lastDayOfQuarter = new Date(endDate.getFullYear(), endMonthOfQuarter + 1, 0).getDate();
27691
- endDate.setMonth(endMonthOfQuarter, lastDayOfQuarter);
27692
- endDate.setHours(23, 59, 59, 999);
27693
- break;
27694
- case 'year':
27695
- endDate.setMonth(11, 31);
27696
- endDate.setHours(23, 59, 59, 999);
27697
- break;
27698
- default:
27699
- throw new Error('Invalid time scale');
27700
- }
27701
- const count = computeCountToTimeScale(endDate, startDate, timeScale, step, 1);
27702
- const targetCount = Math.ceil(count);
27703
- if (targetCount > count) {
27704
- const dif = (targetCount - count) * step;
27705
- const msInSecond = 1000;
27706
- const msInMinute = msInSecond * 60;
27707
- const msInHour = msInMinute * 60;
27708
- const msInDay = msInHour * 24;
27709
- const msInWeek = msInDay * 7;
27710
- new Date(endDate.getTime() + 1);
27711
- switch (timeScale) {
27712
- case 'second':
27713
- endDate.setTime(endDate.getTime() + dif * msInSecond);
27714
- break;
27715
- case 'minute':
27716
- endDate.setTime(endDate.getTime() + dif * msInMinute);
27717
- break;
27718
- case 'hour':
27719
- endDate.setTime(endDate.getTime() + dif * msInHour);
27720
- break;
27721
- case 'day':
27722
- endDate.setTime(endDate.getTime() + dif * msInDay);
27723
- break;
27724
- case 'week':
27725
- endDate.setTime(endDate.getTime() + dif * msInWeek);
27726
- break;
27727
- case 'month':
27728
- endDate = new Date(endDate.getFullYear(), endDate.getMonth() + 1 + Math.round(dif), 0);
27729
- endDate.setHours(23, 59, 59, 999);
27730
- break;
27731
- case 'quarter':
27732
- const currentMonth = endDate.getMonth();
27733
- const endMonthOfQuarter = currentMonth - (currentMonth % 3) + 2;
27734
- endDate = new Date(endDate.getFullYear(), endMonthOfQuarter + Math.round(dif * 3) + 1, 0);
27735
- endDate.setHours(23, 59, 59, 999);
27736
- break;
27737
- case 'year':
27738
- endDate.setFullYear(endDate.getFullYear() + Math.floor(dif));
27739
- endDate.setHours(23, 59, 59, 999);
27740
- break;
27741
- default:
27742
- throw new Error('Invalid time scale');
27743
- }
27744
- }
27745
- return endDate;
26940
+ return endDate;
27746
26941
  }
27747
26942
  function getStartDateByTimeUnit(date, timeScale, startOfWeekSetting = 'monday') {
27748
26943
  const startDate = new Date(date);
@@ -27825,11 +27020,9 @@
27825
27020
  case 'quarter':
27826
27021
  difference =
27827
27022
  (adjusted_date.getFullYear() - startDate.getFullYear()) * 4 +
27828
- Math.floor(adjusted_date.getMonth() / 3) -
27829
- Math.floor(startDate.getMonth() / 3);
27023
+ (adjusted_date.getMonth() - startDate.getMonth()) / 3;
27830
27024
  difference +=
27831
- (adjusted_date.getTime() - startDate.getTime()) /
27832
- DayTimes /
27025
+ (adjusted_date.getDate() - startDate.getDate()) /
27833
27026
  (3 * new Date(adjusted_date.getFullYear(), adjusted_date.getMonth() + 1, 0).getDate());
27834
27027
  break;
27835
27028
  case 'year':
@@ -28435,156 +27628,961 @@
28435
27628
  this._gantt.stateManager.setScrollTop(oldVerticalBarPos);
28436
27629
  }
28437
27630
  }
28438
-
28439
- function handleWhell$1(event, state, gantt, isWheelEvent = true) {
28440
- let { deltaX, deltaY } = event;
28441
- if (event.shiftKey && event.deltaY) {
28442
- deltaX = deltaY;
28443
- deltaY = 0;
27631
+
27632
+ function handleWhell$1(event, state, gantt, isWheelEvent = true) {
27633
+ let { deltaX, deltaY } = event;
27634
+ if (event.shiftKey && event.deltaY) {
27635
+ deltaX = deltaY;
27636
+ deltaY = 0;
27637
+ }
27638
+ const [optimizedDeltaX, optimizedDeltaY] = optimizeScrollXY$1(deltaX, deltaY, { horizontal: 1, vertical: 1 });
27639
+ if (optimizedDeltaX) {
27640
+ state.setScrollLeft(state.scroll.horizontalBarPos + optimizedDeltaX);
27641
+ gantt.scenegraph.scrollbarComponent.showHorizontalScrollBar(true);
27642
+ }
27643
+ if (optimizedDeltaY) {
27644
+ state.setScrollTop(state.scroll.verticalBarPos + optimizedDeltaY);
27645
+ gantt.scenegraph.scrollbarComponent.showVerticalScrollBar(true);
27646
+ }
27647
+ isWheelEvent && state.resetInteractionState();
27648
+ if (event.cancelable &&
27649
+ (state._gantt.parsedOptions.overscrollBehavior === 'none' ||
27650
+ (Math.abs(deltaY) >= Math.abs(deltaX) && deltaY !== 0 && isVerticalScrollable$1(deltaY, state)) ||
27651
+ (Math.abs(deltaY) <= Math.abs(deltaX) && deltaX !== 0 && isHorizontalScrollable$1(deltaX, state)))) {
27652
+ event.preventDefault();
27653
+ }
27654
+ }
27655
+ function optimizeScrollXY$1(x, y, ratio) {
27656
+ const ANGLE = 2;
27657
+ const angle = Math.abs(x / y);
27658
+ const deltaX = angle <= 1 / ANGLE ? 0 : x;
27659
+ const deltaY = angle > ANGLE ? 0 : y;
27660
+ return [Math.ceil(deltaX * (ratio.horizontal ?? 0)), Math.ceil(deltaY * (ratio.vertical ?? 0))];
27661
+ }
27662
+ function isVerticalScrollable$1(deltaY, state) {
27663
+ const totalHeight = state._gantt.getAllRowsHeight() - state._gantt.scenegraph.height;
27664
+ if (totalHeight === 0) {
27665
+ return false;
27666
+ }
27667
+ return !isScrollToTop$1(deltaY, state) && !isScrollToBottom$1(deltaY, state);
27668
+ }
27669
+ function isHorizontalScrollable$1(deltaX, state) {
27670
+ const totalWidth = state._gantt.getAllDateColsWidth() - state._gantt.scenegraph.width;
27671
+ if (totalWidth === 0) {
27672
+ return false;
27673
+ }
27674
+ return !isScrollToLeft$1(deltaX, state) && !isScrollToRight$1(deltaX, state);
27675
+ }
27676
+ function isScrollToTop$1(deltaY, state) {
27677
+ const totalHeight = state._gantt.getAllRowsHeight() - state._gantt.scenegraph.height;
27678
+ return totalHeight !== 0 && deltaY <= 0 && state.scroll.verticalBarPos < 1;
27679
+ }
27680
+ function isScrollToBottom$1(deltaY, state) {
27681
+ const totalHeight = state._gantt.getAllRowsHeight() - state._gantt.scenegraph.height;
27682
+ return totalHeight !== 0 && deltaY >= 0 && Math.abs(state.scroll.verticalBarPos - totalHeight) < 1;
27683
+ }
27684
+ function isScrollToLeft$1(deltaX, state) {
27685
+ const totalWidth = state._gantt.getAllDateColsWidth() - state._gantt.scenegraph.width;
27686
+ return totalWidth !== 0 && deltaX <= 0 && state.scroll.horizontalBarPos < 1;
27687
+ }
27688
+ function isScrollToRight$1(deltaX, state) {
27689
+ const totalWidth = state._gantt.getAllDateColsWidth() - state._gantt.scenegraph.width;
27690
+ return totalWidth !== 0 && deltaX >= 0 && Math.abs(state.scroll.horizontalBarPos - totalWidth) < 1;
27691
+ }
27692
+ function bindScrollBarListener$1(eventManager) {
27693
+ const table = eventManager._gantt;
27694
+ const stateManager = table.stateManager;
27695
+ const scenegraph = table.scenegraph;
27696
+ scenegraph.scrollbarComponent.vScrollBar.addEventListener('pointerover', (e) => {
27697
+ scenegraph.scrollbarComponent.showVerticalScrollBar();
27698
+ });
27699
+ scenegraph.scrollbarComponent.hScrollBar.addEventListener('pointerover', (e) => {
27700
+ scenegraph.scrollbarComponent.showHorizontalScrollBar();
27701
+ });
27702
+ scenegraph.scrollbarComponent.vScrollBar.addEventListener('pointerout', (e) => {
27703
+ if (stateManager.interactionState === InteractionState$1.scrolling) {
27704
+ return;
27705
+ }
27706
+ scenegraph.scrollbarComponent.hideVerticalScrollBar();
27707
+ });
27708
+ scenegraph.scrollbarComponent.hScrollBar.addEventListener('pointerout', (e) => {
27709
+ if (stateManager.interactionState === InteractionState$1.scrolling) {
27710
+ return;
27711
+ }
27712
+ scenegraph.scrollbarComponent.hideHorizontalScrollBar();
27713
+ });
27714
+ scenegraph.scrollbarComponent.vScrollBar.addEventListener('pointermove', (e) => {
27715
+ e.stopPropagation();
27716
+ });
27717
+ scenegraph.scrollbarComponent.vScrollBar.addEventListener('scrollDown', (e) => {
27718
+ scenegraph._gantt.eventManager.isDown = true;
27719
+ });
27720
+ scenegraph.scrollbarComponent.vScrollBar.addEventListener('pointerup', () => {
27721
+ scenegraph._gantt.eventManager.isDraging = false;
27722
+ if (stateManager.interactionState === InteractionState$1.scrolling) {
27723
+ stateManager.updateInteractionState(InteractionState$1.default);
27724
+ }
27725
+ });
27726
+ scenegraph.scrollbarComponent.vScrollBar.addEventListener('pointerupoutside', () => {
27727
+ if (stateManager.interactionState === InteractionState$1.scrolling) {
27728
+ stateManager.updateInteractionState(InteractionState$1.default);
27729
+ }
27730
+ });
27731
+ scenegraph.scrollbarComponent.vScrollBar.addEventListener('scrollUp', (e) => {
27732
+ scenegraph._gantt.eventManager.isDraging = false;
27733
+ });
27734
+ scenegraph.scrollbarComponent.hScrollBar.addEventListener('pointermove', (e) => {
27735
+ e.stopPropagation();
27736
+ });
27737
+ scenegraph.scrollbarComponent.hScrollBar.addEventListener('pointerdown', (e) => {
27738
+ e.stopPropagation();
27739
+ });
27740
+ scenegraph.scrollbarComponent.hScrollBar.addEventListener('scrollDown', (e) => {
27741
+ scenegraph._gantt.eventManager.isDown = true;
27742
+ if (stateManager.interactionState !== InteractionState$1.scrolling) {
27743
+ stateManager.updateInteractionState(InteractionState$1.scrolling);
27744
+ }
27745
+ });
27746
+ scenegraph.scrollbarComponent.hScrollBar.addEventListener('pointerup', () => {
27747
+ if (stateManager.interactionState === InteractionState$1.scrolling) {
27748
+ stateManager.updateInteractionState(InteractionState$1.default);
27749
+ }
27750
+ });
27751
+ scenegraph.scrollbarComponent.hScrollBar.addEventListener('pointerupoutside', () => {
27752
+ if (stateManager.interactionState === InteractionState$1.scrolling) {
27753
+ stateManager.updateInteractionState(InteractionState$1.default);
27754
+ }
27755
+ });
27756
+ scenegraph.scrollbarComponent.hScrollBar.addEventListener('scrollUp', (e) => {
27757
+ scenegraph._gantt.eventManager.isDraging = false;
27758
+ });
27759
+ const throttleVerticalWheel = throttle$1(stateManager.updateVerticalScrollBar, 20);
27760
+ const throttleHorizontalWheel = throttle$1(stateManager.updateHorizontalScrollBar, 20);
27761
+ scenegraph.scrollbarComponent.vScrollBar.addEventListener('scrollDrag', (e) => {
27762
+ if (scenegraph._gantt.eventManager.isDown) {
27763
+ scenegraph._gantt.eventManager.isDraging = true;
27764
+ }
27765
+ if (stateManager.interactionState !== InteractionState$1.scrolling) {
27766
+ stateManager.updateInteractionState(InteractionState$1.scrolling);
27767
+ }
27768
+ const ratio = e.detail.value[0] / (1 - e.detail.value[1] + e.detail.value[0]);
27769
+ throttleVerticalWheel(ratio, e);
27770
+ });
27771
+ scenegraph.scrollbarComponent.hScrollBar.addEventListener('scrollDrag', (e) => {
27772
+ if (scenegraph._gantt.eventManager.isDown) {
27773
+ scenegraph._gantt.eventManager.isDraging = true;
27774
+ }
27775
+ stateManager.fastScrolling = true;
27776
+ if (stateManager.interactionState !== InteractionState$1.scrolling) {
27777
+ stateManager.updateInteractionState(InteractionState$1.scrolling);
27778
+ }
27779
+ const ratio = e.detail.value[0] / (1 - e.detail.value[1] + e.detail.value[0]);
27780
+ throttleHorizontalWheel(ratio);
27781
+ });
27782
+ }
27783
+
27784
+ const defaultTaskBarStyle = {
27785
+ barColor: 'blue',
27786
+ completedBarColor: 'gray',
27787
+ width: 30,
27788
+ cornerRadius: 3,
27789
+ borderWidth: 0,
27790
+ fontFamily: 'Arial',
27791
+ fontSize: 14
27792
+ };
27793
+ function setWidthToDefaultTaskBarStyle(width) {
27794
+ defaultTaskBarStyle.width = width;
27795
+ }
27796
+ const isNode$1 = typeof window === 'undefined' || typeof window.window === 'undefined';
27797
+ const DayTimes = 1000 * 60 * 60 * 24;
27798
+ function getDateIndexByX(x, gantt) {
27799
+ const totalX = x + gantt.stateManager.scroll.horizontalBarPos;
27800
+ const firstDateColWidth = gantt.getDateColWidth(0);
27801
+ const dateIndex = Math.floor((totalX - firstDateColWidth) / gantt.parsedOptions.timelineColWidth) + 1;
27802
+ return dateIndex;
27803
+ }
27804
+ function generateMarkLine(markLine) {
27805
+ if (!markLine) {
27806
+ return [];
27807
+ }
27808
+ if (markLine === true) {
27809
+ return [
27810
+ {
27811
+ date: createDateAtMidnight().toLocaleDateString(),
27812
+ scrollToMarkLine: true,
27813
+ position: 'left',
27814
+ style: {
27815
+ lineColor: 'red',
27816
+ lineWidth: 1
27817
+ }
27818
+ }
27819
+ ];
27820
+ }
27821
+ else if (Array.isArray(markLine)) {
27822
+ return markLine.map((item, index) => {
27823
+ return {
27824
+ ...item,
27825
+ date: item.date,
27826
+ scrollToMarkLine: item.scrollToMarkLine,
27827
+ position: item.position ?? 'left',
27828
+ style: {
27829
+ lineColor: item.style?.lineColor || 'red',
27830
+ lineWidth: item.style?.lineWidth || 1,
27831
+ lineDash: item.style?.lineDash
27832
+ }
27833
+ };
27834
+ });
27835
+ }
27836
+ return [
27837
+ {
27838
+ ...markLine,
27839
+ date: markLine.date,
27840
+ scrollToMarkLine: markLine.scrollToMarkLine ?? true,
27841
+ position: markLine.position ?? 'left',
27842
+ style: {
27843
+ lineColor: markLine.style?.lineColor || 'red',
27844
+ lineWidth: markLine.style?.lineWidth || 1,
27845
+ lineDash: markLine.style?.lineDash
27846
+ }
27847
+ }
27848
+ ];
27849
+ }
27850
+ function getHorizontalScrollBarSize$1(scrollStyle) {
27851
+ if (scrollStyle?.hoverOn ||
27852
+ (scrollStyle?.horizontalVisible && scrollStyle?.horizontalVisible === 'none') ||
27853
+ (!scrollStyle?.horizontalVisible && scrollStyle?.visible === 'none')) {
27854
+ return 0;
27855
+ }
27856
+ return scrollStyle?.width ?? 7;
27857
+ }
27858
+ function getVerticalScrollBarSize$1(scrollStyle) {
27859
+ if (scrollStyle?.hoverOn ||
27860
+ (scrollStyle?.verticalVisible && scrollStyle?.verticalVisible === 'none') ||
27861
+ (!scrollStyle?.verticalVisible && scrollStyle?.visible === 'none')) {
27862
+ return 0;
27863
+ }
27864
+ return scrollStyle?.width ?? 7;
27865
+ }
27866
+ function initOptions(gantt) {
27867
+ const options = gantt.options;
27868
+ gantt.parsedOptions.tasksShowMode = options?.tasksShowMode ?? TasksShowMode.Tasks_Separate;
27869
+ gantt.parsedOptions.pixelRatio = options?.pixelRatio ?? 1;
27870
+ gantt.parsedOptions.rowHeight = options?.rowHeight ?? 40;
27871
+ gantt.parsedOptions.timelineColWidth = options?.timelineHeader?.colWidth ?? 60;
27872
+ gantt.parsedOptions.startDateField = options.taskBar?.startDateField ?? 'startDate';
27873
+ gantt.parsedOptions.endDateField = options.taskBar?.endDateField ?? 'endDate';
27874
+ gantt.parsedOptions.progressField = options.taskBar?.progressField ?? 'progress';
27875
+ const { unit: minTimeUnit, startOfWeek, step } = gantt.parsedOptions.reverseSortedTimelineScales[0];
27876
+ gantt.parsedOptions.minDate = options?.minDate
27877
+ ? getStartDateByTimeUnit(new Date(options.minDate), minTimeUnit, startOfWeek)
27878
+ : undefined;
27879
+ gantt.parsedOptions.maxDate = options?.maxDate
27880
+ ? getEndDateByTimeUnit(gantt.parsedOptions.minDate, new Date(options.maxDate), minTimeUnit, step)
27881
+ : undefined;
27882
+ gantt.parsedOptions._minDateTime = gantt.parsedOptions.minDate?.getTime();
27883
+ gantt.parsedOptions._maxDateTime = gantt.parsedOptions.maxDate?.getTime();
27884
+ gantt.parsedOptions.overscrollBehavior = options?.overscrollBehavior ?? 'auto';
27885
+ gantt.parsedOptions.underlayBackgroundColor = options?.underlayBackgroundColor ?? '#FFF';
27886
+ gantt.parsedOptions.scrollStyle = Object.assign({}, {
27887
+ scrollRailColor: 'rgba(100, 100, 100, 0.2)',
27888
+ scrollSliderColor: 'rgba(100, 100, 100, 0.5)',
27889
+ scrollSliderCornerRadius: 4,
27890
+ width: 10,
27891
+ visible: 'always',
27892
+ hoverOn: true,
27893
+ barToSide: false
27894
+ }, options?.scrollStyle);
27895
+ gantt.parsedOptions.timelineHeaderHorizontalLineStyle = options?.timelineHeader?.horizontalLine;
27896
+ gantt.parsedOptions.timelineHeaderVerticalLineStyle = options?.timelineHeader?.verticalLine;
27897
+ gantt.parsedOptions.timelineHeaderBackgroundColor = options?.timelineHeader?.backgroundColor;
27898
+ gantt.parsedOptions.timeLineHeaderRowHeights = [];
27899
+ gantt.parsedOptions.timelineHeaderStyles = [];
27900
+ for (let i = 0; i < gantt.parsedOptions.sortedTimelineScales.length ?? 0; i++) {
27901
+ const style = gantt.parsedOptions.sortedTimelineScales[i].style;
27902
+ gantt.parsedOptions.timelineHeaderStyles.push(Object.assign({
27903
+ fontSize: 20,
27904
+ fontWeight: 'bold',
27905
+ textAlign: 'center',
27906
+ textBaseline: 'middle',
27907
+ color: '#000',
27908
+ backgroundColor: '#fff'
27909
+ }, style));
27910
+ gantt.parsedOptions.timeLineHeaderRowHeights.push(gantt.parsedOptions.sortedTimelineScales[i].rowHeight ?? options?.headerRowHeight ?? 40);
27911
+ }
27912
+ gantt.parsedOptions.grid = Object.assign({}, options?.grid);
27913
+ setWidthToDefaultTaskBarStyle((gantt.parsedOptions.rowHeight * 3) / 4);
27914
+ gantt.parsedOptions.taskBarStyle =
27915
+ options?.taskBar?.barStyle && typeof options?.taskBar?.barStyle === 'function'
27916
+ ? options.taskBar.barStyle
27917
+ : Object.assign({}, defaultTaskBarStyle, options?.taskBar?.barStyle);
27918
+ gantt.parsedOptions.taskBarMilestoneStyle = Object.assign(typeof gantt.parsedOptions.taskBarStyle === 'function'
27919
+ ? {}
27920
+ : {
27921
+ width: gantt.parsedOptions.taskBarStyle.width,
27922
+ borderColor: gantt.parsedOptions.taskBarStyle.borderColor,
27923
+ borderLineWidth: gantt.parsedOptions.taskBarStyle.borderLineWidth ?? 1,
27924
+ fillColor: gantt.parsedOptions.taskBarStyle.barColor,
27925
+ cornerRadius: 0
27926
+ }, options?.taskBar?.milestoneStyle);
27927
+ gantt.parsedOptions.taskBarMilestoneHypotenuse = gantt.parsedOptions.taskBarMilestoneStyle.width * Math.sqrt(2);
27928
+ gantt.parsedOptions.dateFormat = options?.dateFormat;
27929
+ gantt.parsedOptions.taskBarHoverStyle = Object.assign({
27930
+ barOverlayColor: 'rgba(99, 144, 0, 0.4)'
27931
+ }, options?.taskBar?.hoverBarStyle);
27932
+ gantt.parsedOptions.taskBarSelectable = options?.taskBar?.selectable ?? true;
27933
+ gantt.parsedOptions.taskBarSelectedStyle = Object.assign(typeof gantt.parsedOptions.taskBarStyle === 'function'
27934
+ ? {
27935
+ shadowBlur: 6,
27936
+ shadowOffsetX: 0,
27937
+ shadowOffsetY: 0,
27938
+ borderLineWidth: 1
27939
+ }
27940
+ : {
27941
+ shadowBlur: 6,
27942
+ shadowOffsetX: 0,
27943
+ shadowOffsetY: 0,
27944
+ shadowColor: gantt.parsedOptions.taskBarStyle.barColor,
27945
+ borderColor: gantt.parsedOptions.taskBarStyle.barColor,
27946
+ borderLineWidth: 1
27947
+ }, options?.taskBar?.selectedBarStyle);
27948
+ gantt.parsedOptions.taskBarLabelText = options?.taskBar?.labelText ?? '';
27949
+ gantt.parsedOptions.taskBarMoveable = options?.taskBar?.moveable ?? true;
27950
+ gantt.parsedOptions.moveTaskBarToExtendDateRange = options?.taskBar?.moveToExtendDateRange ?? true;
27951
+ gantt.parsedOptions.taskBarResizable = options?.taskBar?.resizable ?? true;
27952
+ gantt.parsedOptions.taskBarDragOrder = options?.taskBar?.dragOrder ?? true;
27953
+ gantt.parsedOptions.taskBarLabelStyle = {
27954
+ fontFamily: options?.taskBar?.labelTextStyle?.fontFamily ?? 'Arial',
27955
+ fontSize: options?.taskBar?.labelTextStyle?.fontSize ?? 20,
27956
+ color: options?.taskBar?.labelTextStyle?.color ?? '#F01',
27957
+ textAlign: options?.taskBar?.labelTextStyle?.textAlign ?? 'left',
27958
+ textBaseline: options?.taskBar?.labelTextStyle?.textBaseline ?? 'middle',
27959
+ padding: options?.taskBar?.labelTextStyle?.padding ?? [0, 0, 0, 10],
27960
+ textOverflow: options?.taskBar?.labelTextStyle?.textOverflow
27961
+ };
27962
+ gantt.parsedOptions.taskBarCustomLayout = options?.taskBar?.customLayout;
27963
+ gantt.parsedOptions.taskBarCreatable =
27964
+ options?.taskBar?.scheduleCreatable ??
27965
+ !!(gantt.parsedOptions.tasksShowMode === TasksShowMode.Sub_Tasks_Separate ||
27966
+ gantt.parsedOptions.tasksShowMode === TasksShowMode.Tasks_Separate);
27967
+ gantt.parsedOptions.taskBarCreationButtonStyle = Object.assign({
27968
+ lineColor: 'rgb(99, 144, 0)',
27969
+ lineWidth: 1,
27970
+ lineDash: [5, 5],
27971
+ cornerRadius: 4,
27972
+ backgroundColor: '#FFF'
27973
+ }, options?.taskBar?.scheduleCreation?.buttonStyle);
27974
+ gantt.parsedOptions.taskBarCreationCustomLayout = options?.taskBar?.scheduleCreation?.customLayout;
27975
+ gantt.parsedOptions.taskBarCreationMaxWidth = options?.taskBar?.scheduleCreation?.maxWidth;
27976
+ gantt.parsedOptions.taskBarCreationMinWidth = options?.taskBar?.scheduleCreation?.minWidth;
27977
+ gantt.parsedOptions.outerFrameStyle = Object.assign({
27978
+ borderColor: '#e1e4e8',
27979
+ borderLineWidth: 1,
27980
+ cornerRadius: 4
27981
+ }, options.frame?.outerFrameStyle);
27982
+ gantt.parsedOptions.markLine = generateMarkLine(options?.markLine);
27983
+ if (gantt.parsedOptions.markLine?.length ?? 0) {
27984
+ if (gantt.parsedOptions.markLine?.every(item => item.scrollToMarkLine === undefined)) {
27985
+ gantt.parsedOptions.markLine[0].scrollToMarkLine = true;
27986
+ }
27987
+ if (gantt.parsedOptions.markLine?.find(item => item.scrollToMarkLine)) {
27988
+ gantt.parsedOptions.scrollToMarkLineDate = getStartDateByTimeUnit(new Date(gantt.parsedOptions.markLine?.find(item => item.scrollToMarkLine).date), minTimeUnit, startOfWeek);
27989
+ }
27990
+ }
27991
+ gantt.parsedOptions.verticalSplitLineHighlight = options.frame?.verticalSplitLineHighlight;
27992
+ gantt.parsedOptions.verticalSplitLine = Object.assign({
27993
+ lineColor: gantt.parsedOptions.outerFrameStyle?.borderColor,
27994
+ lineWidth: gantt.parsedOptions.outerFrameStyle?.borderLineWidth
27995
+ }, options.frame?.verticalSplitLine);
27996
+ gantt.parsedOptions.horizontalSplitLine = options.frame?.horizontalSplitLine;
27997
+ gantt.parsedOptions.verticalSplitLineMoveable = options.frame?.verticalSplitLineMoveable;
27998
+ gantt.parsedOptions.taskKeyField = options.taskKeyField ?? 'id';
27999
+ gantt.parsedOptions.dependencyLinks = options.dependency?.links ?? [];
28000
+ gantt.parsedOptions.dependencyLinkCreatable = options.dependency?.linkCreatable ?? false;
28001
+ gantt.parsedOptions.dependencyLinkSelectable = options.dependency?.linkSelectable ?? true;
28002
+ gantt.parsedOptions.dependencyLinkDeletable = options.dependency?.linkDeletable ?? false;
28003
+ gantt.parsedOptions.dependencyLinkLineStyle = Object.assign({
28004
+ lineColor: 'red',
28005
+ lineWidth: 1
28006
+ }, options.dependency?.linkLineStyle);
28007
+ gantt.parsedOptions.dependencyLinkSelectedLineStyle = Object.assign({
28008
+ shadowBlur: 4,
28009
+ shadowOffset: 0,
28010
+ shadowColor: gantt.parsedOptions.dependencyLinkLineStyle.lineColor,
28011
+ lineColor: gantt.parsedOptions.dependencyLinkLineStyle.lineColor,
28012
+ lineWidth: gantt.parsedOptions.dependencyLinkLineStyle.lineWidth
28013
+ }, options?.dependency?.linkSelectedLineStyle);
28014
+ gantt.parsedOptions.dependencyLinkLineCreatePointStyle = Object.assign({
28015
+ strokeColor: 'red',
28016
+ fillColor: 'white',
28017
+ radius: 5,
28018
+ strokeWidth: 1
28019
+ }, options?.dependency?.linkCreatePointStyle);
28020
+ gantt.parsedOptions.dependencyLinkLineCreatingPointStyle = Object.assign({
28021
+ strokeColor: 'red',
28022
+ fillColor: 'red',
28023
+ radius: 5,
28024
+ strokeWidth: 1
28025
+ }, options?.dependency?.linkCreatingPointStyle);
28026
+ gantt.parsedOptions.dependencyLinkLineCreatingStyle = Object.assign({
28027
+ lineColor: 'red',
28028
+ lineWidth: 1,
28029
+ lineDash: [5, 5]
28030
+ }, options?.dependency?.linkCreatingLineStyle);
28031
+ gantt.parsedOptions.eventOptions = options?.eventOptions;
28032
+ gantt.parsedOptions.keyboardOptions = options?.keyboardOptions;
28033
+ gantt.parsedOptions.markLineCreateOptions = options?.markLineCreateOptions;
28034
+ }
28035
+ function updateOptionsWhenScaleChanged(gantt) {
28036
+ const options = gantt.options;
28037
+ const { unit: minTimeUnit, startOfWeek, step } = gantt.parsedOptions.reverseSortedTimelineScales[0];
28038
+ gantt.parsedOptions.minDate = getStartDateByTimeUnit(new Date(gantt.parsedOptions.minDate), minTimeUnit, startOfWeek);
28039
+ gantt.parsedOptions.maxDate = getEndDateByTimeUnit(gantt.parsedOptions.minDate, new Date(gantt.parsedOptions.maxDate), minTimeUnit, step);
28040
+ gantt.parsedOptions._minDateTime = gantt.parsedOptions.minDate?.getTime();
28041
+ gantt.parsedOptions._maxDateTime = gantt.parsedOptions.maxDate?.getTime();
28042
+ gantt.parsedOptions.timeLineHeaderRowHeights = [];
28043
+ gantt.parsedOptions.timelineHeaderStyles = [];
28044
+ for (let i = 0; i < gantt.parsedOptions.sortedTimelineScales.length ?? 0; i++) {
28045
+ const style = gantt.parsedOptions.sortedTimelineScales[i].style;
28046
+ gantt.parsedOptions.timelineHeaderStyles.push(Object.assign({
28047
+ fontSize: 20,
28048
+ fontWeight: 'bold',
28049
+ textAlign: 'center',
28050
+ textBaseline: 'middle',
28051
+ color: '#000',
28052
+ backgroundColor: '#fff'
28053
+ }, style));
28054
+ gantt.parsedOptions.timeLineHeaderRowHeights.push(gantt.parsedOptions.sortedTimelineScales[i].rowHeight ?? options?.headerRowHeight ?? 40);
28055
+ }
28056
+ }
28057
+ function generateTimeLineDate(currentDate, endDate, scale) {
28058
+ const { unit, step, format } = scale;
28059
+ const timelineDates = [];
28060
+ while (currentDate < endDate) {
28061
+ if (unit === 'day') {
28062
+ const year = currentDate.getFullYear();
28063
+ const month = currentDate.getMonth();
28064
+ const day = currentDate.getDate();
28065
+ const end = createDateAtLastHour(new Date(year, month, day + step - 1), true);
28066
+ if (end.getTime() > endDate.getTime()) {
28067
+ end.setTime(endDate.getTime());
28068
+ }
28069
+ const start = currentDate;
28070
+ const formattedDate = format?.({ dateIndex: day, startDate: start, endDate: end });
28071
+ const columnTitle = formattedDate || day.toString();
28072
+ const dayCellConfig = {
28073
+ days: Math.abs(end.getTime() - currentDate.getTime() + 1) / DayTimes,
28074
+ startDate: start,
28075
+ endDate: end,
28076
+ step,
28077
+ unit: 'day',
28078
+ title: columnTitle,
28079
+ dateIndex: day
28080
+ };
28081
+ timelineDates.push(dayCellConfig);
28082
+ currentDate = new Date(year, month, day + step);
28083
+ }
28084
+ else if (unit === 'month') {
28085
+ const year = currentDate.getFullYear();
28086
+ const month = currentDate.getMonth();
28087
+ const end = createDateAtLastHour(new Date(year, month + step, 0), true);
28088
+ if (end.getTime() > endDate.getTime()) {
28089
+ end.setTime(endDate.getTime());
28090
+ }
28091
+ const start = currentDate;
28092
+ const formattedDate = format?.({ dateIndex: month + 1, startDate: start, endDate: end });
28093
+ const columnTitle = formattedDate || (month + 1).toString();
28094
+ const dayCellConfig = {
28095
+ days: Math.abs(end.getTime() - currentDate.getTime() + 1) / DayTimes,
28096
+ startDate: start,
28097
+ step,
28098
+ unit: 'month',
28099
+ endDate: end,
28100
+ title: columnTitle,
28101
+ dateIndex: month + 1
28102
+ };
28103
+ timelineDates.push(dayCellConfig);
28104
+ currentDate = new Date(year, month + step, 1);
28105
+ }
28106
+ else if (unit === 'quarter') {
28107
+ const year = currentDate.getFullYear();
28108
+ const quarter = Math.floor(currentDate.getMonth() / 3);
28109
+ const end = createDateAtLastHour(new Date(year, (quarter + step) * 3, 0), true);
28110
+ if (end.getTime() > endDate.getTime()) {
28111
+ end.setTime(endDate.getTime());
28112
+ }
28113
+ const start = currentDate;
28114
+ const formattedDate = format?.({ dateIndex: quarter + 1, startDate: start, endDate: end });
28115
+ const columnTitle = formattedDate || (quarter + 1).toString();
28116
+ const dayCellConfig = {
28117
+ days: Math.abs(end.getTime() - currentDate.getTime() + 1) / (1000 * 60 * 60 * 24),
28118
+ startDate: start,
28119
+ step,
28120
+ unit: 'quarter',
28121
+ endDate: end,
28122
+ title: columnTitle,
28123
+ dateIndex: quarter + 1
28124
+ };
28125
+ timelineDates.push(dayCellConfig);
28126
+ currentDate = new Date(year, (quarter + step) * 3, 1);
28127
+ }
28128
+ else if (unit === 'year') {
28129
+ const year = currentDate.getFullYear();
28130
+ const end = createDateAtLastHour(new Date(year + step - 1, 11, 31), true);
28131
+ if (end.getTime() > endDate.getTime()) {
28132
+ end.setTime(endDate.getTime());
28133
+ }
28134
+ const start = currentDate;
28135
+ const formattedDate = format?.({ dateIndex: year, startDate: start, endDate: end });
28136
+ const columnTitle = formattedDate || year.toString();
28137
+ const dayCellConfig = {
28138
+ days: Math.abs(end.getTime() - currentDate.getTime() + 1) / DayTimes,
28139
+ startDate: start,
28140
+ endDate: end,
28141
+ step,
28142
+ unit: 'year',
28143
+ title: columnTitle,
28144
+ dateIndex: year
28145
+ };
28146
+ timelineDates.push(dayCellConfig);
28147
+ currentDate = new Date(year + step, 0, 1);
28148
+ }
28149
+ else if (unit === 'week') {
28150
+ const startOfWeekSetting = scale.startOfWeek ?? 'monday';
28151
+ let dayOfWeek = currentDate.getDay();
28152
+ if (startOfWeekSetting === 'monday') {
28153
+ dayOfWeek = dayOfWeek === 0 ? 6 : dayOfWeek - 1;
28154
+ }
28155
+ const startOfWeek = createDateAtMidnight(currentDate);
28156
+ const dateEnd = createDateAtLastHour(currentDate.getTime() + (7 * step - dayOfWeek) * 24 * 60 * 60 * 1000 - 1, true);
28157
+ if (dateEnd > endDate) {
28158
+ dateEnd.setTime(endDate.getTime());
28159
+ }
28160
+ const weekNumber = getWeekNumber(startOfWeek);
28161
+ const columnTitle = format?.({ dateIndex: weekNumber, startDate: startOfWeek, endDate: dateEnd }) || weekNumber.toString();
28162
+ const dayCellConfig = {
28163
+ days: (dateEnd.getTime() - startOfWeek.getTime() + 1) / DayTimes,
28164
+ startDate: startOfWeek,
28165
+ endDate: dateEnd,
28166
+ step,
28167
+ unit: 'week',
28168
+ title: columnTitle,
28169
+ dateIndex: weekNumber
28170
+ };
28171
+ timelineDates.push(dayCellConfig);
28172
+ currentDate.setTime(createDateAtMidnight(currentDate.getTime() + (7 * step - dayOfWeek) * 24 * 60 * 60 * 1000, true).getTime());
28173
+ }
28174
+ else if (unit === 'hour') {
28175
+ const year = currentDate.getFullYear();
28176
+ const month = currentDate.getMonth();
28177
+ const day = currentDate.getDate();
28178
+ const hour = currentDate.getHours();
28179
+ const end = createDateAtLastMinute(new Date(year, month, day, hour + step - 1), true);
28180
+ if (end.getTime() > endDate.getTime()) {
28181
+ end.setTime(endDate.getTime());
28182
+ }
28183
+ const start = currentDate;
28184
+ const formattedDate = format?.({ dateIndex: hour, startDate: start, endDate: end });
28185
+ const columnTitle = formattedDate || hour.toString();
28186
+ const dayCellConfig = {
28187
+ days: Math.abs(end.getTime() - currentDate.getTime() + 1) / DayTimes,
28188
+ startDate: start,
28189
+ endDate: end,
28190
+ step,
28191
+ unit: 'hour',
28192
+ title: columnTitle,
28193
+ dateIndex: currentDate.getHours()
28194
+ };
28195
+ timelineDates.push(dayCellConfig);
28196
+ currentDate = new Date(year, month, day, hour + step);
28197
+ }
28198
+ else if (unit === 'minute') {
28199
+ const year = currentDate.getFullYear();
28200
+ const month = currentDate.getMonth();
28201
+ const day = currentDate.getDate();
28202
+ const hour = currentDate.getHours();
28203
+ const minute = currentDate.getMinutes();
28204
+ const end = createDateAtLastSecond(new Date(year, month, day, hour, minute + step - 1), true);
28205
+ if (end.getTime() > endDate.getTime()) {
28206
+ end.setTime(endDate.getTime());
28207
+ }
28208
+ const start = currentDate;
28209
+ const formattedDate = format?.({ dateIndex: minute, startDate: start, endDate: end });
28210
+ const columnTitle = formattedDate || minute.toString();
28211
+ const dayCellConfig = {
28212
+ days: Math.abs(end.getTime() - currentDate.getTime() + 1) / DayTimes,
28213
+ startDate: start,
28214
+ endDate: end,
28215
+ step,
28216
+ unit: 'minute',
28217
+ title: columnTitle,
28218
+ dateIndex: currentDate.getMinutes()
28219
+ };
28220
+ timelineDates.push(dayCellConfig);
28221
+ currentDate = new Date(year, month, day, hour, minute + step);
28222
+ }
28223
+ else if (unit === 'second') {
28224
+ const year = currentDate.getFullYear();
28225
+ const month = currentDate.getMonth();
28226
+ const day = currentDate.getDate();
28227
+ const hour = currentDate.getHours();
28228
+ const minute = currentDate.getMinutes();
28229
+ const second = currentDate.getSeconds();
28230
+ const end = createDateAtLastMillisecond(new Date(year, month, day, hour, minute, second + step - 1), true);
28231
+ if (end.getTime() > endDate.getTime()) {
28232
+ end.setTime(endDate.getTime());
28233
+ }
28234
+ const start = currentDate;
28235
+ const formattedDate = format?.({ dateIndex: second, startDate: start, endDate: end });
28236
+ const columnTitle = formattedDate || second.toString();
28237
+ const dayCellConfig = {
28238
+ days: Math.abs(end.getTime() - currentDate.getTime() + 1) / DayTimes,
28239
+ startDate: start,
28240
+ endDate: end,
28241
+ step,
28242
+ unit: 'second',
28243
+ title: columnTitle,
28244
+ dateIndex: currentDate.getSeconds()
28245
+ };
28246
+ timelineDates.push(dayCellConfig);
28247
+ currentDate = new Date(year, month, day, hour, minute, second + step);
28248
+ }
28249
+ }
28250
+ return timelineDates;
28251
+ }
28252
+ function getTextPos(padding, textAlign, textBaseline, width, height) {
28253
+ let textX = padding[3] ?? 10;
28254
+ if (textAlign === 'right' || textAlign === 'end') {
28255
+ textX = width - 0 - (padding[1] ?? 10);
28444
28256
  }
28445
- const [optimizedDeltaX, optimizedDeltaY] = optimizeScrollXY$1(deltaX, deltaY, { horizontal: 1, vertical: 1 });
28446
- if (optimizedDeltaX) {
28447
- state.setScrollLeft(state.scroll.horizontalBarPos + optimizedDeltaX);
28448
- gantt.scenegraph.scrollbarComponent.showHorizontalScrollBar(true);
28257
+ else if (textAlign === 'center') {
28258
+ textX = 0 + (width - 0 + (padding[3] ?? 10) - (padding[1] ?? 10)) / 2;
28449
28259
  }
28450
- if (optimizedDeltaY) {
28451
- state.setScrollTop(state.scroll.verticalBarPos + optimizedDeltaY);
28452
- gantt.scenegraph.scrollbarComponent.showVerticalScrollBar(true);
28260
+ let textY = 0 + (padding[0] ?? 10);
28261
+ if (textBaseline === 'bottom' || textBaseline === 'alphabetic' || textBaseline === 'ideographic') {
28262
+ textY = height - 0 - (padding[2] ?? 10);
28453
28263
  }
28454
- isWheelEvent && state.resetInteractionState();
28455
- if (event.cancelable &&
28456
- (state._gantt.parsedOptions.overscrollBehavior === 'none' ||
28457
- (Math.abs(deltaY) >= Math.abs(deltaX) && deltaY !== 0 && isVerticalScrollable$1(deltaY, state)) ||
28458
- (Math.abs(deltaY) <= Math.abs(deltaX) && deltaX !== 0 && isHorizontalScrollable$1(deltaX, state)))) {
28459
- event.preventDefault();
28264
+ else if (textBaseline === 'middle') {
28265
+ textY = 0 + (height - 0 - (padding[0] ?? 10) - (padding[2] ?? 10)) / 2 + (padding[0] ?? 10);
28460
28266
  }
28267
+ return {
28268
+ x: textX,
28269
+ y: textY
28270
+ };
28461
28271
  }
28462
- function optimizeScrollXY$1(x, y, ratio) {
28463
- const ANGLE = 2;
28464
- const angle = Math.abs(x / y);
28465
- const deltaX = angle <= 1 / ANGLE ? 0 : x;
28466
- const deltaY = angle > ANGLE ? 0 : y;
28467
- return [Math.ceil(deltaX * (ratio.horizontal ?? 0)), Math.ceil(deltaY * (ratio.vertical ?? 0))];
28272
+ function convertProgress(progress) {
28273
+ if (typeof progress === 'string') {
28274
+ progress = progress.replace('%', '');
28275
+ progress = parseFloat(progress);
28276
+ }
28277
+ return Math.round(progress);
28468
28278
  }
28469
- function isVerticalScrollable$1(deltaY, state) {
28470
- const totalHeight = state._gantt.getAllRowsHeight() - state._gantt.scenegraph.height;
28471
- if (totalHeight === 0) {
28472
- return false;
28279
+ function createSplitLineAndResizeLine(gantt) {
28280
+ if (gantt.taskListTableInstance) {
28281
+ gantt.verticalSplitResizeLine = document.createElement('div');
28282
+ gantt.verticalSplitResizeLine.style.position = 'absolute';
28283
+ gantt.verticalSplitResizeLine.style.top = gantt.tableY + 'px';
28284
+ gantt.verticalSplitResizeLine.style.left =
28285
+ (gantt.taskTableWidth ? gantt.taskTableWidth - 7 + gantt.parsedOptions.verticalSplitLine.lineWidth / 2 : 0) +
28286
+ 'px';
28287
+ gantt.verticalSplitResizeLine.style.width = '14px';
28288
+ gantt.verticalSplitResizeLine.style.height = gantt.drawHeight + 'px';
28289
+ gantt.verticalSplitResizeLine.style.backgroundColor = 'rgba(0,0,0,0)';
28290
+ gantt.verticalSplitResizeLine.style.zIndex = '100';
28291
+ gantt.parsedOptions.verticalSplitLineMoveable && (gantt.verticalSplitResizeLine.style.cursor = 'col-resize');
28292
+ gantt.verticalSplitResizeLine.style.userSelect = 'none';
28293
+ gantt.verticalSplitResizeLine.style.opacity = '1';
28294
+ const verticalSplitLine = document.createElement('div');
28295
+ verticalSplitLine.style.position = 'absolute';
28296
+ verticalSplitLine.style.top = '0px';
28297
+ verticalSplitLine.style.left = `${(14 - gantt.parsedOptions.verticalSplitLine.lineWidth) / 2}px`;
28298
+ verticalSplitLine.style.width = gantt.parsedOptions.verticalSplitLine.lineWidth + 'px';
28299
+ verticalSplitLine.style.height = '100%';
28300
+ verticalSplitLine.style.backgroundColor = gantt.parsedOptions.verticalSplitLine.lineColor;
28301
+ verticalSplitLine.style.zIndex = '100';
28302
+ verticalSplitLine.style.userSelect = 'none';
28303
+ verticalSplitLine.style.pointerEvents = 'none';
28304
+ verticalSplitLine.style.transition = 'background-color 0.3s';
28305
+ gantt.verticalSplitResizeLine.appendChild(verticalSplitLine);
28306
+ if (gantt.parsedOptions.verticalSplitLineHighlight) {
28307
+ const highlightLine = document.createElement('div');
28308
+ highlightLine.style.position = 'absolute';
28309
+ highlightLine.style.top = '0px';
28310
+ highlightLine.style.left = `${(14 - gantt.parsedOptions.verticalSplitLineHighlight.lineWidth ?? 2) / 2}px`;
28311
+ highlightLine.style.width = (gantt.parsedOptions.verticalSplitLineHighlight.lineWidth ?? 2) + 'px';
28312
+ highlightLine.style.height = '100%';
28313
+ highlightLine.style.backgroundColor = gantt.parsedOptions.verticalSplitLineHighlight.lineColor;
28314
+ highlightLine.style.zIndex = '100';
28315
+ highlightLine.style.cursor = 'col-resize';
28316
+ highlightLine.style.userSelect = 'none';
28317
+ highlightLine.style.pointerEvents = 'none';
28318
+ highlightLine.style.opacity = '0';
28319
+ highlightLine.style.transition = 'background-color 0.3s';
28320
+ gantt.verticalSplitResizeLine.appendChild(highlightLine);
28321
+ }
28322
+ gantt.container.appendChild(gantt.verticalSplitResizeLine);
28473
28323
  }
28474
- return !isScrollToTop$1(deltaY, state) && !isScrollToBottom$1(deltaY, state);
28475
28324
  }
28476
- function isHorizontalScrollable$1(deltaX, state) {
28477
- const totalWidth = state._gantt.getAllDateColsWidth() - state._gantt.scenegraph.width;
28478
- if (totalWidth === 0) {
28479
- return false;
28325
+ function updateSplitLineAndResizeLine(gantt) {
28326
+ if (gantt.verticalSplitResizeLine) {
28327
+ gantt.verticalSplitResizeLine.style.position = 'absolute';
28328
+ gantt.verticalSplitResizeLine.style.top = gantt.tableY + 'px';
28329
+ gantt.verticalSplitResizeLine.style.left = gantt.taskTableWidth
28330
+ ? `${gantt.taskTableWidth - 7 + gantt.parsedOptions.verticalSplitLine.lineWidth / 2}px`
28331
+ : '0px';
28332
+ gantt.verticalSplitResizeLine.style.width = '14px';
28333
+ gantt.verticalSplitResizeLine.style.height = gantt.drawHeight + 'px';
28334
+ gantt.verticalSplitResizeLine.style.backgroundColor = 'rgba(0,0,0,0)';
28335
+ gantt.verticalSplitResizeLine.style.zIndex = '100';
28336
+ gantt.parsedOptions.verticalSplitLineMoveable && (gantt.verticalSplitResizeLine.style.cursor = 'col-resize');
28337
+ gantt.verticalSplitResizeLine.style.userSelect = 'none';
28338
+ gantt.verticalSplitResizeLine.style.opacity = '1';
28339
+ const verticalSplitLine = gantt.verticalSplitResizeLine.childNodes[0];
28340
+ verticalSplitLine.style.position = 'absolute';
28341
+ verticalSplitLine.style.top = '0px';
28342
+ verticalSplitLine.style.left = `${(14 - gantt.parsedOptions.verticalSplitLine.lineWidth) / 2}px`;
28343
+ verticalSplitLine.style.width = gantt.parsedOptions.verticalSplitLine.lineWidth + 'px';
28344
+ verticalSplitLine.style.height = '100%';
28345
+ verticalSplitLine.style.backgroundColor = gantt.parsedOptions.verticalSplitLine.lineColor;
28346
+ verticalSplitLine.style.zIndex = '100';
28347
+ verticalSplitLine.style.userSelect = 'none';
28348
+ verticalSplitLine.style.pointerEvents = 'none';
28349
+ verticalSplitLine.style.transition = 'background-color 0.3s';
28350
+ if (gantt.verticalSplitResizeLine.childNodes[1]) {
28351
+ const highlightLine = gantt.verticalSplitResizeLine.childNodes[1];
28352
+ highlightLine.style.position = 'absolute';
28353
+ highlightLine.style.top = '0px';
28354
+ highlightLine.style.left = `${(14 - gantt.parsedOptions.verticalSplitLineHighlight.lineWidth ?? 2) / 2}px`;
28355
+ highlightLine.style.width = (gantt.parsedOptions.verticalSplitLineHighlight.lineWidth ?? 2) + 'px';
28356
+ highlightLine.style.height = '100%';
28357
+ highlightLine.style.backgroundColor = gantt.parsedOptions.verticalSplitLineHighlight.lineColor;
28358
+ highlightLine.style.zIndex = '100';
28359
+ highlightLine.style.cursor = 'col-resize';
28360
+ highlightLine.style.userSelect = 'none';
28361
+ highlightLine.style.pointerEvents = 'none';
28362
+ highlightLine.style.opacity = '0';
28363
+ highlightLine.style.transition = 'background-color 0.3s';
28364
+ }
28480
28365
  }
28481
- return !isScrollToLeft$1(deltaX, state) && !isScrollToRight$1(deltaX, state);
28482
28366
  }
28483
- function isScrollToTop$1(deltaY, state) {
28484
- const totalHeight = state._gantt.getAllRowsHeight() - state._gantt.scenegraph.height;
28485
- return totalHeight !== 0 && deltaY <= 0 && state.scroll.verticalBarPos < 1;
28367
+ function findRecordByTaskKey(records, taskKeyField, taskKey, childrenField = 'children') {
28368
+ for (let i = 0; i < records.length; i++) {
28369
+ if ((Array.isArray(taskKey) && taskKey.length === 1 && records[i][taskKeyField] === taskKey[0]) ||
28370
+ records[i][taskKeyField] === taskKey) {
28371
+ return { record: records[i], index: [i] };
28372
+ }
28373
+ else if (records[i][childrenField]?.length) {
28374
+ if (Array.isArray(taskKey) && taskKey[0] === records[i][taskKeyField]) {
28375
+ const result = findRecordByTaskKey(records[i][childrenField], taskKeyField, taskKey.slice(1));
28376
+ if (result) {
28377
+ result.index.unshift(i);
28378
+ return result;
28379
+ }
28380
+ }
28381
+ else if (!Array.isArray(taskKey)) {
28382
+ const result = findRecordByTaskKey(records[i][childrenField], taskKeyField, taskKey);
28383
+ if (result) {
28384
+ result.index.unshift(i);
28385
+ return result;
28386
+ }
28387
+ }
28388
+ }
28389
+ }
28486
28390
  }
28487
- function isScrollToBottom$1(deltaY, state) {
28488
- const totalHeight = state._gantt.getAllRowsHeight() - state._gantt.scenegraph.height;
28489
- return totalHeight !== 0 && deltaY >= 0 && Math.abs(state.scroll.verticalBarPos - totalHeight) < 1;
28391
+ function clearRecordLinkInfos(records, childrenField = 'children') {
28392
+ for (let i = 0; i < records.length; i++) {
28393
+ if (records[i][childrenField]?.length) {
28394
+ clearRecordLinkInfos(records[i][childrenField], childrenField);
28395
+ }
28396
+ else {
28397
+ delete records[i].vtable_gantt_linkedTo;
28398
+ delete records[i].vtable_gantt_linkedFrom;
28399
+ }
28400
+ }
28490
28401
  }
28491
- function isScrollToLeft$1(deltaX, state) {
28492
- const totalWidth = state._gantt.getAllDateColsWidth() - state._gantt.scenegraph.width;
28493
- return totalWidth !== 0 && deltaX <= 0 && state.scroll.horizontalBarPos < 1;
28402
+ function clearRecordShowIndex(records, childrenField = 'children') {
28403
+ for (let i = 0; i < records.length; i++) {
28404
+ if (records[i][childrenField]?.length) {
28405
+ clearRecordShowIndex(records[i][childrenField], childrenField);
28406
+ }
28407
+ else {
28408
+ delete records[i].vtable_gantt_showIndex;
28409
+ }
28410
+ }
28494
28411
  }
28495
- function isScrollToRight$1(deltaX, state) {
28496
- const totalWidth = state._gantt.getAllDateColsWidth() - state._gantt.scenegraph.width;
28497
- return totalWidth !== 0 && deltaX >= 0 && Math.abs(state.scroll.horizontalBarPos - totalWidth) < 1;
28412
+ function getTaskIndexsByTaskY(y, gantt) {
28413
+ let task_index;
28414
+ let sub_task_index;
28415
+ if (gantt.taskListTableInstance) {
28416
+ const rowInfo = gantt.taskListTableInstance.getTargetRowAt(y + gantt.headerHeight);
28417
+ if (rowInfo) {
28418
+ const { row } = rowInfo;
28419
+ task_index = row - gantt.taskListTableInstance.columnHeaderLevelCount;
28420
+ const beforeRowsHeight = gantt.getRowsHeightByIndex(0, task_index - 1);
28421
+ if (gantt.parsedOptions.tasksShowMode === TasksShowMode.Sub_Tasks_Inline ||
28422
+ gantt.parsedOptions.tasksShowMode === TasksShowMode.Sub_Tasks_Arrange ||
28423
+ gantt.parsedOptions.tasksShowMode === TasksShowMode.Sub_Tasks_Compact ||
28424
+ gantt.parsedOptions.tasksShowMode === TasksShowMode.Sub_Tasks_Separate) {
28425
+ sub_task_index = Math.floor((y - beforeRowsHeight) / gantt.parsedOptions.rowHeight);
28426
+ }
28427
+ }
28428
+ }
28429
+ else {
28430
+ task_index = Math.floor(y / gantt.parsedOptions.rowHeight);
28431
+ }
28432
+ return { task_index, sub_task_index };
28498
28433
  }
28499
- function bindScrollBarListener$1(eventManager) {
28500
- const table = eventManager._gantt;
28501
- const stateManager = table.stateManager;
28502
- const scenegraph = table.scenegraph;
28503
- scenegraph.scrollbarComponent.vScrollBar.addEventListener('pointerover', (e) => {
28504
- scenegraph.scrollbarComponent.showVerticalScrollBar();
28505
- });
28506
- scenegraph.scrollbarComponent.hScrollBar.addEventListener('pointerover', (e) => {
28507
- scenegraph.scrollbarComponent.showHorizontalScrollBar();
28508
- });
28509
- scenegraph.scrollbarComponent.vScrollBar.addEventListener('pointerout', (e) => {
28510
- if (stateManager.interactionState === InteractionState$1.scrolling) {
28511
- return;
28434
+ function computeRowsCountByRecordDateForCompact(gantt, record) {
28435
+ if (!record.children || record.children.length === 1) {
28436
+ if (record.children?.length === 1) {
28437
+ record.children[0].vtable_gantt_showIndex = 0;
28512
28438
  }
28513
- scenegraph.scrollbarComponent.hideVerticalScrollBar();
28514
- });
28515
- scenegraph.scrollbarComponent.hScrollBar.addEventListener('pointerout', (e) => {
28516
- if (stateManager.interactionState === InteractionState$1.scrolling) {
28517
- return;
28439
+ else {
28440
+ record.vtable_gantt_showIndex = 0;
28518
28441
  }
28519
- scenegraph.scrollbarComponent.hideHorizontalScrollBar();
28520
- });
28521
- scenegraph.scrollbarComponent.vScrollBar.addEventListener('pointermove', (e) => {
28522
- e.stopPropagation();
28523
- });
28524
- scenegraph.scrollbarComponent.vScrollBar.addEventListener('scrollDown', (e) => {
28525
- scenegraph._gantt.eventManager.isDown = true;
28442
+ return 1;
28443
+ }
28444
+ const sortedChildren = record.children.slice().sort((a, b) => {
28445
+ const { startDate: aStartDate } = formatRecordDateConsiderHasHour(gantt, a);
28446
+ const { startDate: bStartDate } = formatRecordDateConsiderHasHour(gantt, b);
28447
+ return aStartDate.getTime() - bStartDate.getTime();
28526
28448
  });
28527
- scenegraph.scrollbarComponent.vScrollBar.addEventListener('pointerup', () => {
28528
- scenegraph._gantt.eventManager.isDraging = false;
28529
- if (stateManager.interactionState === InteractionState$1.scrolling) {
28530
- stateManager.updateInteractionState(InteractionState$1.default);
28449
+ const rows = [];
28450
+ for (let i = 0; i <= sortedChildren.length - 1; i++) {
28451
+ const newRecord = sortedChildren[i];
28452
+ const { startDate, endDate } = formatRecordDateConsiderHasHour(gantt, newRecord);
28453
+ let placed = false;
28454
+ for (let j = 0; j < rows.length; j++) {
28455
+ if (startDate.getTime() > rows[j]) {
28456
+ rows[j] = endDate.getTime();
28457
+ placed = true;
28458
+ newRecord.vtable_gantt_showIndex = j;
28459
+ break;
28460
+ }
28531
28461
  }
28532
- });
28533
- scenegraph.scrollbarComponent.vScrollBar.addEventListener('pointerupoutside', () => {
28534
- if (stateManager.interactionState === InteractionState$1.scrolling) {
28535
- stateManager.updateInteractionState(InteractionState$1.default);
28462
+ if (!placed) {
28463
+ rows.push(endDate.getTime());
28464
+ newRecord.vtable_gantt_showIndex = rows.length - 1;
28536
28465
  }
28466
+ }
28467
+ return rows.length;
28468
+ }
28469
+ function isOverlapping(startDate, endDate, rowTasks, gantt) {
28470
+ return rowTasks.some(rowTask => {
28471
+ const { startDate: startDate2, endDate: endDate2 } = formatRecordDateConsiderHasHour(gantt, rowTask);
28472
+ return startDate <= endDate2 && startDate2 <= endDate;
28537
28473
  });
28538
- scenegraph.scrollbarComponent.vScrollBar.addEventListener('scrollUp', (e) => {
28539
- scenegraph._gantt.eventManager.isDraging = false;
28540
- });
28541
- scenegraph.scrollbarComponent.hScrollBar.addEventListener('pointermove', (e) => {
28542
- e.stopPropagation();
28543
- });
28544
- scenegraph.scrollbarComponent.hScrollBar.addEventListener('pointerdown', (e) => {
28545
- e.stopPropagation();
28546
- });
28547
- scenegraph.scrollbarComponent.hScrollBar.addEventListener('scrollDown', (e) => {
28548
- scenegraph._gantt.eventManager.isDown = true;
28549
- if (stateManager.interactionState !== InteractionState$1.scrolling) {
28550
- stateManager.updateInteractionState(InteractionState$1.scrolling);
28474
+ }
28475
+ function computeRowsCountByRecordDate(gantt, record) {
28476
+ if (!record.children || record.children.length === 1) {
28477
+ if (record.children?.length === 1) {
28478
+ record.children[0].vtable_gantt_showIndex = 0;
28551
28479
  }
28552
- });
28553
- scenegraph.scrollbarComponent.hScrollBar.addEventListener('pointerup', () => {
28554
- if (stateManager.interactionState === InteractionState$1.scrolling) {
28555
- stateManager.updateInteractionState(InteractionState$1.default);
28480
+ else {
28481
+ record.vtable_gantt_showIndex = 0;
28556
28482
  }
28557
- });
28558
- scenegraph.scrollbarComponent.hScrollBar.addEventListener('pointerupoutside', () => {
28559
- if (stateManager.interactionState === InteractionState$1.scrolling) {
28560
- stateManager.updateInteractionState(InteractionState$1.default);
28483
+ return 1;
28484
+ }
28485
+ const rows = [];
28486
+ for (let i = 0; i <= record.children.length - 1; i++) {
28487
+ const newRecord = record.children[i];
28488
+ const { startDate, endDate } = formatRecordDateConsiderHasHour(gantt, newRecord);
28489
+ let placed = false;
28490
+ for (let j = 0; j < rows.length; j++) {
28491
+ const rowTasks = record.children.filter((t) => t !== newRecord && t.vtable_gantt_showIndex === j);
28492
+ if (!isOverlapping(startDate, endDate, rowTasks, gantt)) {
28493
+ rows[j] = endDate.getTime();
28494
+ placed = true;
28495
+ newRecord.vtable_gantt_showIndex = j;
28496
+ break;
28497
+ }
28561
28498
  }
28562
- });
28563
- scenegraph.scrollbarComponent.hScrollBar.addEventListener('scrollUp', (e) => {
28564
- scenegraph._gantt.eventManager.isDraging = false;
28565
- });
28566
- const throttleVerticalWheel = throttle$1(stateManager.updateVerticalScrollBar, 20);
28567
- const throttleHorizontalWheel = throttle$1(stateManager.updateHorizontalScrollBar, 20);
28568
- scenegraph.scrollbarComponent.vScrollBar.addEventListener('scrollDrag', (e) => {
28569
- if (scenegraph._gantt.eventManager.isDown) {
28570
- scenegraph._gantt.eventManager.isDraging = true;
28499
+ if (!placed) {
28500
+ rows.push(endDate.getTime());
28501
+ newRecord.vtable_gantt_showIndex = rows.length - 1;
28571
28502
  }
28572
- if (stateManager.interactionState !== InteractionState$1.scrolling) {
28573
- stateManager.updateInteractionState(InteractionState$1.scrolling);
28503
+ }
28504
+ return rows.length;
28505
+ }
28506
+ function formatRecordDateConsiderHasHour(gantt, record) {
28507
+ const { timeScaleIncludeHour, startDateField, endDateField } = gantt.parsedOptions;
28508
+ const startDate = record[startDateField];
28509
+ const endDate = record[endDateField];
28510
+ if (timeScaleIncludeHour) {
28511
+ return { startDate: createDateAtMidnight(startDate), endDate: createDateAtLastHour(endDate) };
28512
+ }
28513
+ return { startDate: createDateAtMidnight(startDate, true), endDate: createDateAtLastHour(endDate, true) };
28514
+ }
28515
+ function updateOptionsWhenRecordChanged(gantt) {
28516
+ const options = gantt.options;
28517
+ const { unit: minTimeUnit, startOfWeek } = gantt.parsedOptions.reverseSortedTimelineScales[0];
28518
+ gantt.parsedOptions.markLine = generateMarkLine(options?.markLine);
28519
+ if (gantt.parsedOptions.markLine?.length ?? 0) {
28520
+ if (gantt.parsedOptions.markLine?.every(item => item.scrollToMarkLine === undefined)) {
28521
+ gantt.parsedOptions.markLine[0].scrollToMarkLine = true;
28574
28522
  }
28575
- const ratio = e.detail.value[0] / (1 - e.detail.value[1] + e.detail.value[0]);
28576
- throttleVerticalWheel(ratio, e);
28577
- });
28578
- scenegraph.scrollbarComponent.hScrollBar.addEventListener('scrollDrag', (e) => {
28579
- if (scenegraph._gantt.eventManager.isDown) {
28580
- scenegraph._gantt.eventManager.isDraging = true;
28523
+ if (gantt.parsedOptions.markLine?.find(item => item.scrollToMarkLine)) {
28524
+ gantt.parsedOptions.scrollToMarkLineDate = getStartDateByTimeUnit(new Date(gantt.parsedOptions.markLine?.find(item => item.scrollToMarkLine).date), minTimeUnit, startOfWeek);
28581
28525
  }
28582
- stateManager.fastScrolling = true;
28583
- if (stateManager.interactionState !== InteractionState$1.scrolling) {
28584
- stateManager.updateInteractionState(InteractionState$1.scrolling);
28526
+ }
28527
+ gantt.parsedOptions.dependencyLinks = options.dependency?.links;
28528
+ }
28529
+ function updateOptionsWhenDateRangeChanged(gantt) {
28530
+ const options = gantt.options;
28531
+ const { unit: minTimeUnit, startOfWeek, step } = gantt.parsedOptions.reverseSortedTimelineScales[0];
28532
+ gantt.parsedOptions.minDate = options?.minDate
28533
+ ? getStartDateByTimeUnit(new Date(options.minDate), minTimeUnit, startOfWeek)
28534
+ : undefined;
28535
+ gantt.parsedOptions.maxDate = options?.maxDate
28536
+ ? getEndDateByTimeUnit(gantt.parsedOptions.minDate, new Date(options.maxDate), minTimeUnit, step)
28537
+ : undefined;
28538
+ gantt.parsedOptions._minDateTime = gantt.parsedOptions.minDate?.getTime();
28539
+ gantt.parsedOptions._maxDateTime = gantt.parsedOptions.maxDate?.getTime();
28540
+ }
28541
+ function updateOptionsWhenMarkLineChanged(gantt) {
28542
+ const options = gantt.options;
28543
+ gantt.parsedOptions.markLine = generateMarkLine(options?.markLine);
28544
+ }
28545
+ function _getTaskInfoByXYForCreateSchedule(eventX, eventY, gantt) {
28546
+ const taskIndex = getTaskIndexsByTaskY(eventY - gantt.headerHeight + gantt.stateManager.scrollTop, gantt);
28547
+ const recordParent = gantt.getRecordByIndex(taskIndex.task_index);
28548
+ const dateIndex = getDateIndexByX(eventX, gantt);
28549
+ const dateRange = gantt.getDateRangeByIndex(dateIndex);
28550
+ if (recordParent?.children) {
28551
+ const taskIndex = getTaskIndexsByTaskY(eventY - gantt.headerHeight + gantt.stateManager.scrollTop, gantt);
28552
+ for (let i = 0; i < recordParent.children.length; i++) {
28553
+ const { startDate, endDate, taskDays, progress, taskRecord } = gantt.getTaskInfoByTaskListIndex(taskIndex.task_index, i);
28554
+ if (((gantt.parsedOptions.tasksShowMode === TasksShowMode.Sub_Tasks_Compact ||
28555
+ gantt.parsedOptions.tasksShowMode === TasksShowMode.Sub_Tasks_Arrange) &&
28556
+ taskRecord.vtable_gantt_showIndex === taskIndex.sub_task_index) ||
28557
+ gantt.parsedOptions.tasksShowMode === TasksShowMode.Sub_Tasks_Inline) {
28558
+ if (dateRange.startDate.getTime() >= startDate.getTime() && dateRange.endDate.getTime() <= endDate.getTime()) {
28559
+ return { startDate, endDate, taskDays, progress, taskRecord };
28560
+ }
28561
+ }
28585
28562
  }
28586
- const ratio = e.detail.value[0] / (1 - e.detail.value[1] + e.detail.value[0]);
28587
- throttleHorizontalWheel(ratio);
28563
+ }
28564
+ }
28565
+ function getNodeClickPos(marklineIconNode, gantt) {
28566
+ const left = marklineIconNode.globalTransMatrix.e +
28567
+ gantt.taskListTableInstance.tableNoFrameWidth +
28568
+ gantt.taskListTableInstance.tableX +
28569
+ gantt.tableX;
28570
+ const top = marklineIconNode.globalTransMatrix.f;
28571
+ const width = marklineIconNode.attribute.width;
28572
+ const height = marklineIconNode.attribute.height;
28573
+ return {
28574
+ left,
28575
+ top,
28576
+ width,
28577
+ height
28578
+ };
28579
+ }
28580
+ function judgeIfHasMarkLine(data, markLine) {
28581
+ const beginTime = data.startDate.getTime();
28582
+ const endTime = data.endDate.getTime();
28583
+ return markLine.some(item => {
28584
+ const marklineTime = new Date(item.date).getTime();
28585
+ return marklineTime >= beginTime && marklineTime <= endTime;
28588
28586
  });
28589
28587
  }
28590
28588
 
@@ -36959,7 +36957,7 @@
36959
36957
  }
36960
36958
  function getCellCornerRadius(col, row, table) {
36961
36959
  const tableCornerRadius = table.theme.frameStyle.cornerRadius;
36962
- if (Array.isArray(tableCornerRadius)) {
36960
+ if (table.theme.cellInnerBorder) if (Array.isArray(tableCornerRadius)) {
36963
36961
  if (0 === col && 0 === row) return [tableCornerRadius[0], 0, 0, 0];
36964
36962
  if (col === table.colCount - 1 && 0 === row) return [0, tableCornerRadius[1], 0, 0];
36965
36963
  if (0 === col && row === table.rowCount - 1) return [0, 0, 0, tableCornerRadius[3]];
@@ -42127,12 +42125,12 @@
42127
42125
  isWidthNumber = !Array.isArray(strokeArrayWidth),
42128
42126
  isStrokeTrue = !Array.isArray(stroke),
42129
42127
  isSplitDraw = Array.isArray(strokeArrayColor) || widthInfo.isSplitDraw;
42130
- context.setStrokeStyle(rect, rect.attribute, x, y, rectAttribute);
42128
+ context.stroke(), context.setStrokeStyle(rect, rect.attribute, x, y, rectAttribute);
42131
42129
  const {
42132
42130
  lineDash = groupAttribute.lineDash
42133
42131
  } = group.attribute;
42134
42132
  let isDash = !1;
42135
- lineDash.length && lineDash.some(dash => Array.isArray(dash)) && (isDash = !0), context.moveTo(x, y);
42133
+ lineDash.length && lineDash.some(dash => Array.isArray(dash)) && (isDash = !0), context.beginPath(), context.moveTo(x, y);
42136
42134
  const strokeTop = (isStrokeTrue || stroke[0]) && (isWidthNumber || strokeArrayWidth[0]),
42137
42135
  strokeRight = (isStrokeTrue || stroke[1]) && (isWidthNumber || strokeArrayWidth[1]),
42138
42136
  strokeBottom = (isStrokeTrue || stroke[2]) && (isWidthNumber || strokeArrayWidth[2]),
@@ -42153,7 +42151,7 @@
42153
42151
  isWidthNumber ? widthInfo.width : strokeArrayWidth[3], isWidthNumber ? widthInfo.width : strokeArrayWidth[3];
42154
42152
  context.moveTo(x1, y1), context.lineTo(x2, y2), (isSplitDraw || isDash) && (strokeArrayColor && strokeArrayColor[3] ? context.strokeStyle = strokeArrayColor[3] : strokeArrayColor && !strokeArrayColor[3] && (context.strokeStyle = "transparent"), isWidthNumber || (context.lineWidth = strokeArrayWidth[3]), context.lineDashOffset = context.currentMatrix.f / context.currentMatrix.d, isDash && context.setLineDash(null !== (_d = lineDash[3]) && void 0 !== _d ? _d : []), context.stroke(), context.beginPath(), context.moveTo(x, y));
42155
42153
  } else 3 === i && context.moveTo(x, y);
42156
- isSplitDraw || isDash || (!isWidthNumber && widthInfo.width && (context.lineWidth = widthInfo.width), context.stroke()), context.lineDashOffset = 0, context.setLineDash([]), context.closePath();
42154
+ context.closePath(), isSplitDraw || isDash || (!isWidthNumber && widthInfo.width && (context.lineWidth = widthInfo.width), context.stroke()), context.lineDashOffset = 0, context.setLineDash([]), context.beginPath();
42157
42155
  }
42158
42156
 
42159
42157
  var __decorate$1 = undefined && undefined.__decorate || function (decorators, target, key, desc) {
@@ -43537,7 +43535,7 @@
43537
43535
  };
43538
43536
  class SceneProxy {
43539
43537
  constructor(table) {
43540
- this.isRelease = !1, this.mode = "column", this.rowLimit = 200, this.currentRow = 0, this.rowStart = 0, this.rowEnd = 0, this.referenceRow = 0, this.screenTopRow = 0, this.deltaY = 0, this.deltaHeight = 0, this.colLimit = 100, this.screenLeftCol = 0, this.deltaX = 0, this.deltaWidth = 0, this.cellCache = new Map(), this.table = table, this.table.isPivotChart() ? (this.rowLimit = Math.max(100, Math.ceil(2 * table.tableNoFrameHeight / table.defaultRowHeight)), this.colLimit = Math.max(100, Math.ceil(2 * table.tableNoFrameWidth / table.defaultColWidth))) : this.table.isAutoRowHeight() ? this.rowLimit = Math.max(100, Math.ceil(2 * table.tableNoFrameHeight / table.defaultRowHeight)) : ("autoWidth" === this.table.widthMode || (this.rowLimit = Math.max(200, Math.ceil(2 * table.tableNoFrameHeight / table.defaultRowHeight))), this.colLimit = Math.max(100, Math.ceil(2 * table.tableNoFrameWidth / table.defaultColWidth))), this.table.internalProps.transpose ? this.mode = "row" : this.table.isPivotTable() && (this.mode = "pivot"), this.table.options.maintainedDataCount && (this.rowLimit = this.table.options.maintainedDataCount);
43538
+ this.isRelease = !1, this.mode = "column", this.rowLimit = 200, this.currentRow = 0, this.rowStart = 0, this.rowEnd = 0, this.referenceRow = 0, this.screenTopRow = 0, this.deltaY = 0, this.deltaHeight = 0, this.colLimit = 100, this.screenLeftCol = 0, this.deltaX = 0, this.deltaWidth = 0, this.cellCache = new Map(), this.table = table, this.table.isPivotChart() ? (this.rowLimit = Math.max(100, Math.ceil(2 * table.tableNoFrameHeight / table.defaultRowHeight)), this.colLimit = Math.max(100, Math.ceil(2 * table.tableNoFrameWidth / table.defaultColWidth))) : this.table.isAutoRowHeight() ? this.rowLimit = Math.max(100, Math.ceil(2 * table.tableNoFrameHeight / table.defaultRowHeight)) : ("autoWidth" === this.table.widthMode || (this.rowLimit = Math.max(200, Math.ceil(2 * table.tableNoFrameHeight / table.defaultRowHeight))), this.colLimit = Math.max(100, Math.ceil(2 * table.tableNoFrameWidth / table.defaultColWidth))), this.table.internalProps.transpose ? this.mode = "row" : this.table.isPivotTable() && (this.mode = "pivot"), this.table.options.maintainedDataCount && (this.rowLimit = this.table.options.maintainedDataCount), this.table.options.maintainedColumnCount && (this.colLimit = this.table.options.maintainedColumnCount);
43541
43539
  }
43542
43540
  get bodyLeftCol() {
43543
43541
  return this.table.frozenColCount;
@@ -44044,7 +44042,7 @@
44044
44042
  }
44045
44043
  isExtend && extendSelectRange();
44046
44044
  };
44047
- ifExtendSelectRange && extendSelectRange(), scene.selectingRangeComponents.forEach((selectComp, key) => {
44045
+ ifExtendSelectRange && (extendSelectRange(), selectRange.start.col > selectRange.end.col ? (selectRange.start.col = Math.max(startCol, endCol), selectRange.end.col = Math.min(startCol, endCol)) : (selectRange.start.col = Math.min(startCol, endCol), selectRange.end.col = Math.max(startCol, endCol)), selectRange.start.row > selectRange.end.row ? (selectRange.start.row = Math.max(startRow, endRow), selectRange.end.row = Math.min(startRow, endRow)) : (selectRange.start.row = Math.min(startRow, endRow), selectRange.end.row = Math.max(startRow, endRow))), scene.selectingRangeComponents.forEach((selectComp, key) => {
44048
44046
  var _a;
44049
44047
  selectComp.rect.delete(), null === (_a = selectComp.fillhandle) || void 0 === _a || _a.delete();
44050
44048
  }), scene.selectingRangeComponents = new Map();
@@ -44134,7 +44132,7 @@
44134
44132
  }
44135
44133
 
44136
44134
  function createCellSelectBorder(scene, start_Col, start_Row, end_Col, end_Row, selectRangeType, selectId, strokes) {
44137
- var _a, _b, _c, _d, _e, _f, _g, _h;
44135
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
44138
44136
  let isHasFillHandleRect = !!(null === (_a = scene.table.options.excelOptions) || void 0 === _a ? void 0 : _a.fillHandle);
44139
44137
  if ((null === (_b = scene.table.stateManager.select.ranges) || void 0 === _b ? void 0 : _b.length) > 1) isHasFillHandleRect = !1, scene.removeFillHandleFromSelectComponents();else if (1 === (null === (_c = scene.table.stateManager.select.ranges) || void 0 === _c ? void 0 : _c.length)) {
44140
44138
  const maxRow = Math.max(scene.table.stateManager.select.ranges[0].start.row, scene.table.stateManager.select.ranges[0].end.row),
@@ -44160,7 +44158,8 @@
44160
44158
  y: firstCellBound.y1 - scene.tableGroup.attribute.y,
44161
44159
  width: 0,
44162
44160
  height: 0,
44163
- visible: !0
44161
+ visible: !0,
44162
+ cornerRadius: getCornerRadius(selectRangeType, null === (_j = scene.table.theme.frameStyle) || void 0 === _j ? void 0 : _j.cornerRadius, start_Col, start_Row, end_Col, end_Row, scene.table)
44164
44163
  });
44165
44164
  let fillhandle;
44166
44165
  isHasFillHandleRect && (fillhandle = createRect({
@@ -44178,6 +44177,15 @@
44178
44177
  role: selectRangeType
44179
44178
  }), scene.tableGroup.insertAfter(rect, "body" === selectRangeType ? scene.bodyGroup : "columnHeader" === selectRangeType ? scene.colHeaderGroup : "rowHeader" === selectRangeType ? scene.rowHeaderGroup : "cornerHeader" === selectRangeType ? scene.cornerHeaderGroup : "rightTopCorner" === selectRangeType ? scene.rightTopCornerGroup : "rightFrozen" === selectRangeType ? scene.rightFrozenGroup : "leftBottomCorner" === selectRangeType ? scene.leftBottomCornerGroup : "bottomFrozen" === selectRangeType ? scene.bottomFrozenGroup : scene.rightBottomCornerGroup), isHasFillHandleRect && scene.tableGroup.insertAfter(fillhandle, "body" === selectRangeType ? scene.bodyGroup : "columnHeader" === selectRangeType ? scene.colHeaderGroup : "rowHeader" === selectRangeType ? scene.rowHeaderGroup : "cornerHeader" === selectRangeType ? scene.cornerHeaderGroup : "rightTopCorner" === selectRangeType ? scene.rightTopCornerGroup : "rightFrozen" === selectRangeType ? scene.rightFrozenGroup : "leftBottomCorner" === selectRangeType ? scene.leftBottomCornerGroup : "bottomFrozen" === selectRangeType ? scene.bottomFrozenGroup : scene.rightBottomCornerGroup);
44180
44179
  }
44180
+ function getCornerRadius(selectRangeType, cornerRadius, start_Col, start_Row, end_Col, end_Row, table) {
44181
+ if (!cornerRadius) return;
44182
+ const cornerRadiusArray = Array.isArray(cornerRadius) ? cornerRadius : [cornerRadius, cornerRadius, cornerRadius, cornerRadius],
44183
+ tableEndCol = table.colCount - 1,
44184
+ tableEndRow = table.rowCount - 1,
44185
+ result = [0, 0, 0, 0];
44186
+ let changed = !1;
44187
+ return 0 === start_Col && 0 === start_Row ? (result[0] = cornerRadiusArray[0], changed = !0) : end_Col === tableEndCol && end_Row === tableEndRow ? (result[2] = cornerRadiusArray[2], changed = !0) : 0 === start_Col && end_Row === tableEndRow ? (result[3] = cornerRadiusArray[3], changed = !0) : end_Col === tableEndCol && 0 === start_Row && (result[1] = cornerRadiusArray[1], changed = !0), changed ? result : void 0;
44188
+ }
44181
44189
 
44182
44190
  function moveSelectingRangeComponentsToSelectedRangeComponents(scene) {
44183
44191
  scene.selectingRangeComponents.forEach((rangeComponent, key) => {
@@ -44273,7 +44281,7 @@
44273
44281
  const minRow = Math.min(...addRows);
44274
44282
  scene.proxy.rowUpdatePos = Math.min(minRow, scene.proxy.rowUpdatePos);
44275
44283
  }
44276
- scene.proxy.rowUpdateDirection = "down", scene.proxy.updateCellGroups(2 * scene.proxy.screenRowCount), updateBottomFrozeCellGroups();
44284
+ scene.proxy.rowUpdateDirection = "up", scene.proxy.updateCellGroups(2 * scene.proxy.screenRowCount), updateBottomFrozeCellGroups();
44277
44285
  } else removeRows.length && (setRowSeriesNumberCellNeedUpdate(removeRows[removeRows.length - 1], scene), scene.proxy.updateCellGroups(2 * scene.proxy.screenRowCount), updateBottomFrozeCellGroups());
44278
44286
  scene.proxy.progress();
44279
44287
  const newTotalHeight = table.getRowsHeight(table.frozenRowCount, table.rowCount - 1 - table.bottomFrozenRowCount);
@@ -44540,7 +44548,7 @@
44540
44548
  }
44541
44549
 
44542
44550
  function dealFrozen(scene) {
44543
- var _a, _b;
44551
+ var _a, _b, _c, _d;
44544
44552
  if (scene.table.frozenColCount > scene.table.rowHeaderLevelCount) {
44545
44553
  scene.rowHeaderGroup.setAttribute("height", scene.bodyGroup.attribute.height), scene.rowHeaderGroup.setAttribute("y", scene.bodyGroup.attribute.y), scene.cornerHeaderGroup.setAttribute("height", scene.colHeaderGroup.attribute.height);
44546
44554
  for (let i = 0; i < scene.table.frozenColCount - scene.table.rowHeaderLevelCount; i++) moveColumnFromBodyToRowHeader(scene), moveColumnFromColHeaderToCornerHeader(scene), moveColumnFromBottomToLeftBottomCorner(scene);
@@ -44548,10 +44556,10 @@
44548
44556
  scene.bodyGroup.setAttribute("height", scene.rowHeaderGroup.attribute.height), scene.bodyGroup.setAttribute("y", scene.rowHeaderGroup.attribute.y), scene.colHeaderGroup.setAttribute("height", scene.cornerHeaderGroup.attribute.height);
44549
44557
  for (let i = 0; i < scene.table.rowHeaderLevelCount - scene.table.frozenColCount; i++) moveColumnFromRowHeaderToBody(scene), moveColumnFromCornerHeaderToColHeader(scene), moveColumnFromLeftBottomCornerToBottom(scene);
44550
44558
  }
44551
- scene.bodyGroup.setAttribute("x", scene.rowHeaderGroup.attribute.width), scene.colHeaderGroup.setAttribute("x", scene.cornerHeaderGroup.attribute.width), scene.updateContainer(), scene.updateBorderSizeAndPosition(), scene.isPivot || scene.table.transpose ? scene.table.options.frozenColCount ? scene.component.setFrozenColumnShadow(scene.table.frozenColCount - 1) : scene.table.options.frozenColCount && scene.component.setRightFrozenColumnShadow(scene.table.colCount - scene.table.rightFrozenColCount) : (scene.component.setFrozenColumnShadow(scene.table.frozenColCount - 1), scene.component.setRightFrozenColumnShadow(scene.table.colCount - scene.table.rightFrozenColCount)), scene.hasFrozen = !0, scene.frozenColCount = scene.table.frozenColCount, scene.frozenRowCount = null !== (_b = null === (_a = scene.colHeaderGroup.firstChild) || void 0 === _a ? void 0 : _a.childrenCount) && void 0 !== _b ? _b : 0;
44559
+ scene.bodyGroup.setAttribute("x", scene.rowHeaderGroup.attribute.width), scene.colHeaderGroup.setAttribute("x", scene.cornerHeaderGroup.attribute.width), scene.updateContainer(), scene.updateBorderSizeAndPosition(), scene.isPivot || scene.table.transpose ? scene.table.options.frozenColCount ? scene.component.setFrozenColumnShadow(scene.table.frozenColCount - 1) : scene.table.options.frozenColCount && scene.component.setRightFrozenColumnShadow(scene.table.colCount - scene.table.rightFrozenColCount) : (scene.component.setFrozenColumnShadow(scene.table.frozenColCount - 1), scene.component.setRightFrozenColumnShadow(scene.table.colCount - scene.table.rightFrozenColCount)), scene.hasFrozen = !0, scene.frozenColCount = scene.table.frozenColCount, scene.frozenRowCount = null !== (_d = null !== (_b = null === (_a = scene.colHeaderGroup.firstChild) || void 0 === _a ? void 0 : _a.childrenCount) && void 0 !== _b ? _b : null === (_c = scene.cornerHeaderGroup.firstChild) || void 0 === _c ? void 0 : _c.childrenCount) && void 0 !== _d ? _d : scene.table.frozenRowCount;
44552
44560
  }
44553
44561
  function resetFrozen(scene) {
44554
- var _a, _b, _c, _d;
44562
+ var _a, _b, _c, _d, _e, _f;
44555
44563
  if (scene.frozenColCount > scene.table.frozenColCount) {
44556
44564
  scene.bodyGroup.setAttribute("height", scene.rowHeaderGroup.attribute.height), scene.bodyGroup.setAttribute("y", scene.rowHeaderGroup.attribute.y), scene.colHeaderGroup.setAttribute("height", scene.cornerHeaderGroup.attribute.height);
44557
44565
  for (let i = 0; i < scene.frozenColCount - scene.table.frozenColCount; i++) moveColumnFromRowHeaderToBody(scene), moveColumnFromCornerHeaderToColHeader(scene), moveColumnFromLeftBottomCornerToBottom(scene);
@@ -44559,7 +44567,7 @@
44559
44567
  scene.rowHeaderGroup.setAttribute("height", scene.bodyGroup.attribute.height), scene.rowHeaderGroup.setAttribute("y", scene.bodyGroup.attribute.y), scene.cornerHeaderGroup.setAttribute("height", scene.colHeaderGroup.attribute.height);
44560
44568
  for (let i = 0; i < scene.table.frozenColCount - scene.frozenColCount; i++) moveColumnFromBodyToRowHeader(scene), moveColumnFromColHeaderToCornerHeader(scene), moveColumnFromBottomToLeftBottomCorner(scene);
44561
44569
  }
44562
- updateReactComponentContainer(scene), scene.recreateAllSelectRangeComponents(), scene.frozenColCount = scene.table.frozenColCount, scene.frozenRowCount = null !== (_b = null === (_a = scene.colHeaderGroup.firstChild) || void 0 === _a ? void 0 : _a.childrenCount) && void 0 !== _b ? _b : 0, scene.proxy.colStart = null !== (_d = null === (_c = scene.bodyGroup.firstChild) || void 0 === _c ? void 0 : _c.col) && void 0 !== _d ? _d : scene.table.frozenColCount, scene.bodyGroup.setAttribute("x", scene.rowHeaderGroup.attribute.width), scene.colHeaderGroup.setAttribute("x", scene.cornerHeaderGroup.attribute.width), scene.updateContainer(), scene.updateBorderSizeAndPosition(), scene.isPivot || scene.table.transpose ? scene.table.options.frozenColCount ? scene.component.setFrozenColumnShadow(scene.table.frozenColCount - 1) : scene.table.options.rightFrozenColCount && scene.component.setRightFrozenColumnShadow(scene.table.colCount - scene.table.rightFrozenColCount) : (scene.component.setFrozenColumnShadow(scene.table.frozenColCount - 1), scene.component.setRightFrozenColumnShadow(scene.table.colCount - scene.table.rightFrozenColCount)), scene.hasFrozen = !0;
44570
+ updateReactComponentContainer(scene), scene.recreateAllSelectRangeComponents(), scene.frozenColCount = scene.table.frozenColCount, scene.frozenRowCount = null !== (_d = null !== (_b = null === (_a = scene.colHeaderGroup.firstChild) || void 0 === _a ? void 0 : _a.childrenCount) && void 0 !== _b ? _b : null === (_c = scene.cornerHeaderGroup.firstChild) || void 0 === _c ? void 0 : _c.childrenCount) && void 0 !== _d ? _d : scene.table.frozenRowCount, scene.proxy.colStart = null !== (_f = null === (_e = scene.bodyGroup.firstChild) || void 0 === _e ? void 0 : _e.col) && void 0 !== _f ? _f : scene.table.frozenColCount, scene.bodyGroup.setAttribute("x", scene.rowHeaderGroup.attribute.width), scene.colHeaderGroup.setAttribute("x", scene.cornerHeaderGroup.attribute.width), scene.updateContainer(), scene.updateBorderSizeAndPosition(), scene.isPivot || scene.table.transpose ? scene.table.options.frozenColCount ? scene.component.setFrozenColumnShadow(scene.table.frozenColCount - 1) : scene.table.options.rightFrozenColCount && scene.component.setRightFrozenColumnShadow(scene.table.colCount - scene.table.rightFrozenColCount) : (scene.component.setFrozenColumnShadow(scene.table.frozenColCount - 1), scene.component.setRightFrozenColumnShadow(scene.table.colCount - scene.table.rightFrozenColCount)), scene.hasFrozen = !0;
44563
44571
  }
44564
44572
  function moveColumnFromBodyToRowHeader(scene) {
44565
44573
  const column = scene.bodyGroup.firstChild instanceof Group$1 ? scene.bodyGroup.firstChild : null;
@@ -46411,7 +46419,7 @@
46411
46419
  } : table.getCellRange(col, row);
46412
46420
  currentRange.start.col < cellRange.end.col ? currentRange.end.col = cellRange.end.col : currentRange.start.col > cellRange.start.col && (currentRange.end.col = cellRange.start.col), currentRange.start.row < cellRange.end.row ? currentRange.end.row = cellRange.end.row : currentRange.start.row > cellRange.start.row && (currentRange.end.row = cellRange.start.row), "body" === state.select.headerSelectMode && (table.isRowHeader(col, row) ? (currentRange.start.col = table.rowHeaderLevelCount + table.leftRowSeriesNumberCount, currentRange.end.col = table.colCount - 1) : table.isColumnHeader(col, row) ? (currentRange.start.row = table.columnHeaderLevelCount, currentRange.end.row = table.rowCount - 1) : table.internalProps.layoutMap.isSeriesNumberInBody(col, row) ? (currentRange.start.col = table.leftRowSeriesNumberCount, currentRange.end.col = table.colCount - 1) : table.isCornerHeader(col, row) ? (currentRange.start.col = table.rowHeaderLevelCount + table.leftRowSeriesNumberCount, currentRange.start.row = table.columnHeaderLevelCount, currentRange.end.col = table.colCount - 1, currentRange.end.row = table.rowCount - 1) : table.isSeriesNumber(col, row) && (currentRange.start.col = table.leftRowSeriesNumberCount, currentRange.start.row = table.columnHeaderLevelCount, currentRange.end.col = table.colCount - 1, currentRange.end.row = table.rowCount - 1)), skipBodyMerge && (currentRange.skipBodyMerge = !0);
46413
46421
  }
46414
- scenegraph.updateCellSelectBorder(currentRange, extendSelectRange);
46422
+ currentRange && currentRange.start.row <= table.rowCount - 1 && currentRange.end.row <= table.rowCount - 1 && currentRange.start.col <= table.colCount - 1 && currentRange.end.col <= table.colCount - 1 && scenegraph.updateCellSelectBorder(currentRange, extendSelectRange);
46415
46423
  }
46416
46424
  }
46417
46425
  } else {
@@ -46609,7 +46617,7 @@
46609
46617
  }
46610
46618
  cellPos.col = col, cellPos.row = row;
46611
46619
  const currentRange = null === (_b = state.select.ranges) || void 0 === _b ? void 0 : _b[state.select.ranges.length - 1];
46612
- currentRange && scenegraph.updateCellSelectBorder(currentRange, extendSelectRange);
46620
+ currentRange && currentRange.start.row <= table.rowCount - 1 && currentRange.end.row <= table.rowCount - 1 && currentRange.start.col <= table.colCount - 1 && currentRange.end.col <= table.colCount - 1 && scenegraph.updateCellSelectBorder(currentRange, extendSelectRange);
46613
46621
  }
46614
46622
  }
46615
46623
  } else cellPos.col = -1, cellPos.row = -1, state.select.ranges = [], scenegraph.deleteAllSelectBorder();
@@ -47672,76 +47680,108 @@
47672
47680
  var _a, _b;
47673
47681
  const totalHeight = this.table.getAllRowsHeight(),
47674
47682
  oldVerticalBarPos = this.scroll.verticalBarPos;
47675
- this.scroll.verticalBarPos = Math.ceil(yRatio * (totalHeight - this.table.scenegraph.height)), isValid$3(this.scroll.verticalBarPos) && !isNaN(this.scroll.verticalBarPos) || (this.scroll.verticalBarPos = 0), this.table.scenegraph.setY(-this.scroll.verticalBarPos, 1 === yRatio), this.scroll.verticalBarPos -= this.table.scenegraph.proxy.deltaY, this.table.scenegraph.proxy.deltaY = 0, this.updateHoverPos(-1, -1), this.table.fireListeners(TABLE_EVENT_TYPE.SCROLL, {
47683
+ let verticalBarPos = Math.ceil(yRatio * (totalHeight - this.table.scenegraph.height));
47684
+ isValid$3(verticalBarPos) && !isNaN(verticalBarPos) || (verticalBarPos = 0);
47685
+ const dy = verticalBarPos - this.table.scenegraph.proxy.deltaY - oldVerticalBarPos;
47686
+ if (this.table.fireListeners(TABLE_EVENT_TYPE.SCROLL, {
47676
47687
  event: void 0,
47677
- scrollTop: this.scroll.verticalBarPos,
47688
+ scrollTop: verticalBarPos - this.table.scenegraph.proxy.deltaY,
47678
47689
  scrollLeft: this.scroll.horizontalBarPos,
47679
47690
  scrollHeight: null === (_a = this.table.theme.scrollStyle) || void 0 === _a ? void 0 : _a.width,
47680
47691
  scrollWidth: null === (_b = this.table.theme.scrollStyle) || void 0 === _b ? void 0 : _b.width,
47681
47692
  viewHeight: this.table.tableNoFrameHeight,
47682
47693
  viewWidth: this.table.tableNoFrameWidth,
47683
47694
  scrollDirection: "vertical",
47684
- scrollRatioY: yRatio
47685
- }), oldVerticalBarPos !== this.scroll.verticalBarPos && this.checkVerticalScrollBarEnd();
47695
+ scrollRatioY: yRatio,
47696
+ dy: dy
47697
+ }).some(value => !1 === value)) {
47698
+ const yRatio = this.scroll.verticalBarPos / (totalHeight - this.table.scenegraph.height);
47699
+ this.table.scenegraph.component.updateVerticalScrollBarPos(yRatio);
47700
+ } else this.scroll.verticalBarPos = verticalBarPos, this.table.scenegraph.setY(-this.scroll.verticalBarPos, 1 === yRatio), this.scroll.verticalBarPos -= this.table.scenegraph.proxy.deltaY, this.table.scenegraph.proxy.deltaY = 0, this.updateHoverPos(-1, -1), oldVerticalBarPos !== this.scroll.verticalBarPos && this.checkVerticalScrollBarEnd();
47686
47701
  }
47687
47702
  updateHorizontalScrollBar(xRatio) {
47688
47703
  var _a, _b;
47689
47704
  const totalWidth = this.table.getAllColsWidth(),
47690
47705
  oldHorizontalBarPos = this.scroll.horizontalBarPos;
47691
- this.scroll.horizontalBarPos = Math.ceil(xRatio * (totalWidth - this.table.scenegraph.width)), isValid$3(this.scroll.horizontalBarPos) && !isNaN(this.scroll.horizontalBarPos) || (this.scroll.horizontalBarPos = 0), this.table.scenegraph.setX(-this.scroll.horizontalBarPos, 1 === xRatio), this.scroll.horizontalBarPos -= this.table.scenegraph.proxy.deltaX, this.table.scenegraph.proxy.deltaX = 0, this.updateHoverPos(-1, -1), this.table.fireListeners(TABLE_EVENT_TYPE.SCROLL, {
47706
+ let horizontalBarPos = Math.ceil(xRatio * (totalWidth - this.table.scenegraph.width));
47707
+ isValid$3(horizontalBarPos) && !isNaN(horizontalBarPos) || (horizontalBarPos = 0);
47708
+ const dx = horizontalBarPos - this.table.scenegraph.proxy.deltaX - oldHorizontalBarPos;
47709
+ if (this.table.fireListeners(TABLE_EVENT_TYPE.SCROLL, {
47692
47710
  event: void 0,
47693
47711
  scrollTop: this.scroll.verticalBarPos,
47694
- scrollLeft: this.scroll.horizontalBarPos,
47712
+ scrollLeft: horizontalBarPos - this.table.scenegraph.proxy.deltaX,
47695
47713
  scrollHeight: null === (_a = this.table.theme.scrollStyle) || void 0 === _a ? void 0 : _a.width,
47696
47714
  scrollWidth: null === (_b = this.table.theme.scrollStyle) || void 0 === _b ? void 0 : _b.width,
47697
47715
  viewHeight: this.table.tableNoFrameHeight,
47698
47716
  viewWidth: this.table.tableNoFrameWidth,
47699
47717
  scrollDirection: "horizontal",
47700
- scrollRatioX: xRatio
47701
- }), oldHorizontalBarPos !== this.scroll.horizontalBarPos && this.checkHorizontalScrollBarEnd();
47718
+ scrollRatioX: xRatio,
47719
+ dx: dx
47720
+ }).some(value => !1 === value)) {
47721
+ const xRatio = this.scroll.horizontalBarPos / (totalWidth - this.table.scenegraph.width);
47722
+ this.table.scenegraph.component.updateHorizontalScrollBarPos(xRatio);
47723
+ } else this.scroll.horizontalBarPos = horizontalBarPos, this.table.scenegraph.setX(-this.scroll.horizontalBarPos, 1 === xRatio), this.scroll.horizontalBarPos -= this.table.scenegraph.proxy.deltaX, this.table.scenegraph.proxy.deltaX = 0, this.updateHoverPos(-1, -1), oldHorizontalBarPos !== this.scroll.horizontalBarPos && this.checkHorizontalScrollBarEnd();
47702
47724
  }
47703
47725
  setScrollTop(top, event) {
47704
47726
  let triggerEvent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !0;
47705
- var _a, _b, _c;
47727
+ var _a, _b, _c, _d, _e;
47706
47728
  const totalHeight = this.table.getAllRowsHeight(),
47707
47729
  sizeTolerance = (null === (_a = this.table.options.customConfig) || void 0 === _a ? void 0 : _a._disableColumnAndRowSizeRound) ? 1 : 0;
47708
- top = Math.max(0, Math.min(top, totalHeight - this.table.scenegraph.height - sizeTolerance)), ((top = Math.ceil(top)) !== this.scroll.verticalBarPos || this.table.isPivotChart()) && this.updateHoverPos(-1, -1);
47709
- const oldVerticalBarPos = this.scroll.verticalBarPos;
47710
- this.scroll.verticalBarPos = top, isValid$3(this.scroll.verticalBarPos) && !isNaN(this.scroll.verticalBarPos) || (this.scroll.verticalBarPos = 0), this.table.scenegraph.setY(-top);
47711
- const yRatio = top / (totalHeight - this.table.scenegraph.height);
47712
- this.table.scenegraph.component.updateVerticalScrollBarPos(yRatio), oldVerticalBarPos !== top && triggerEvent && (this.table.fireListeners(TABLE_EVENT_TYPE.SCROLL, {
47713
- event: null == event ? void 0 : event.nativeEvent,
47714
- scrollTop: this.scroll.verticalBarPos,
47715
- scrollLeft: this.scroll.horizontalBarPos,
47716
- scrollHeight: null === (_b = this.table.theme.scrollStyle) || void 0 === _b ? void 0 : _b.width,
47717
- scrollWidth: null === (_c = this.table.theme.scrollStyle) || void 0 === _c ? void 0 : _c.width,
47718
- viewHeight: this.table.tableNoFrameHeight,
47719
- viewWidth: this.table.tableNoFrameWidth,
47720
- scrollDirection: "vertical",
47721
- scrollRatioY: yRatio
47722
- }), this.checkVerticalScrollBarEnd());
47730
+ top = Math.max(0, Math.min(top, totalHeight - this.table.scenegraph.height - sizeTolerance)), top = Math.ceil(top);
47731
+ const oldVerticalBarPos = this.scroll.verticalBarPos,
47732
+ yRatio = top / (totalHeight - this.table.scenegraph.height);
47733
+ if ((oldVerticalBarPos !== top || !0 === (null === (_c = null === (_b = this.table.options) || void 0 === _b ? void 0 : _b.customConfig) || void 0 === _c ? void 0 : _c.scrollEventAlwaysTrigger)) && triggerEvent) {
47734
+ let verticalBarPos = top;
47735
+ isValid$3(verticalBarPos) && !isNaN(verticalBarPos) || (verticalBarPos = 0);
47736
+ const dy = verticalBarPos - oldVerticalBarPos;
47737
+ if (this.table.fireListeners(TABLE_EVENT_TYPE.SCROLL, {
47738
+ event: null == event ? void 0 : event.nativeEvent,
47739
+ scrollTop: verticalBarPos,
47740
+ scrollLeft: this.scroll.horizontalBarPos,
47741
+ scrollHeight: null === (_d = this.table.theme.scrollStyle) || void 0 === _d ? void 0 : _d.width,
47742
+ scrollWidth: null === (_e = this.table.theme.scrollStyle) || void 0 === _e ? void 0 : _e.width,
47743
+ viewHeight: this.table.tableNoFrameHeight,
47744
+ viewWidth: this.table.tableNoFrameWidth,
47745
+ scrollDirection: "vertical",
47746
+ scrollRatioY: yRatio,
47747
+ dy: dy
47748
+ }).some(value => !1 === value)) {
47749
+ const yRatio = this.scroll.verticalBarPos / (totalHeight - this.table.scenegraph.height);
47750
+ return void this.table.scenegraph.component.updateVerticalScrollBarPos(yRatio);
47751
+ }
47752
+ }
47753
+ (top !== this.scroll.verticalBarPos || this.table.isPivotChart()) && this.updateHoverPos(-1, -1), this.scroll.verticalBarPos = top, isValid$3(this.scroll.verticalBarPos) && !isNaN(this.scroll.verticalBarPos) || (this.scroll.verticalBarPos = 0), this.table.scenegraph.setY(-top), this.table.scenegraph.component.updateVerticalScrollBarPos(yRatio), oldVerticalBarPos !== top && triggerEvent && this.checkVerticalScrollBarEnd();
47723
47754
  }
47724
47755
  setScrollLeft(left, event) {
47725
47756
  let triggerEvent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : !0;
47726
- var _a, _b, _c;
47757
+ var _a, _b, _c, _d, _e;
47727
47758
  this.table.scrollLeft;
47728
47759
  const totalWidth = this.table.getAllColsWidth(),
47729
47760
  sizeTolerance = (this.table.getFrozenColsWidth(), (null === (_a = this.table.options.customConfig) || void 0 === _a ? void 0 : _a._disableColumnAndRowSizeRound) ? 1 : 0);
47730
- left = Math.max(0, Math.min(left, totalWidth - this.table.scenegraph.width - sizeTolerance)), (left = Math.ceil(left)) !== this.scroll.horizontalBarPos && this.updateHoverPos(-1, -1);
47731
- const oldHorizontalBarPos = this.scroll.horizontalBarPos;
47732
- this.scroll.horizontalBarPos = left, isValid$3(this.scroll.horizontalBarPos) && !isNaN(this.scroll.horizontalBarPos) || (this.scroll.horizontalBarPos = 0), this.table.scenegraph.setX(-left);
47733
- const xRatio = left / (totalWidth - this.table.scenegraph.width);
47734
- this.table.scenegraph.component.updateHorizontalScrollBarPos(xRatio), oldHorizontalBarPos !== left && triggerEvent && (this.table.fireListeners(TABLE_EVENT_TYPE.SCROLL, {
47735
- event: null == event ? void 0 : event.nativeEvent,
47736
- scrollTop: this.scroll.verticalBarPos,
47737
- scrollLeft: this.scroll.horizontalBarPos,
47738
- scrollHeight: null === (_b = this.table.theme.scrollStyle) || void 0 === _b ? void 0 : _b.width,
47739
- scrollWidth: null === (_c = this.table.theme.scrollStyle) || void 0 === _c ? void 0 : _c.width,
47740
- viewHeight: this.table.tableNoFrameHeight,
47741
- viewWidth: this.table.tableNoFrameWidth,
47742
- scrollDirection: "horizontal",
47743
- scrollRatioX: xRatio
47744
- }), this.checkHorizontalScrollBarEnd());
47761
+ left = Math.max(0, Math.min(left, totalWidth - this.table.scenegraph.width - sizeTolerance)), left = Math.ceil(left);
47762
+ const oldHorizontalBarPos = this.scroll.horizontalBarPos,
47763
+ xRatio = left / (totalWidth - this.table.scenegraph.width);
47764
+ if ((oldHorizontalBarPos !== left || !0 === (null === (_c = null === (_b = this.table.options) || void 0 === _b ? void 0 : _b.customConfig) || void 0 === _c ? void 0 : _c.scrollEventAlwaysTrigger)) && triggerEvent) {
47765
+ let horizontalBarPos = left;
47766
+ isValid$3(horizontalBarPos) && !isNaN(horizontalBarPos) || (horizontalBarPos = 0);
47767
+ const dx = horizontalBarPos - oldHorizontalBarPos;
47768
+ if (this.table.fireListeners(TABLE_EVENT_TYPE.SCROLL, {
47769
+ event: null == event ? void 0 : event.nativeEvent,
47770
+ scrollTop: this.scroll.verticalBarPos,
47771
+ scrollLeft: horizontalBarPos,
47772
+ scrollHeight: null === (_d = this.table.theme.scrollStyle) || void 0 === _d ? void 0 : _d.width,
47773
+ scrollWidth: null === (_e = this.table.theme.scrollStyle) || void 0 === _e ? void 0 : _e.width,
47774
+ viewHeight: this.table.tableNoFrameHeight,
47775
+ viewWidth: this.table.tableNoFrameWidth,
47776
+ scrollDirection: "horizontal",
47777
+ scrollRatioX: xRatio,
47778
+ dx: dx
47779
+ }).some(value => !1 === value)) {
47780
+ const xRatio = this.scroll.horizontalBarPos / (totalWidth - this.table.scenegraph.width);
47781
+ return void this.table.scenegraph.component.updateHorizontalScrollBarPos(xRatio);
47782
+ }
47783
+ }
47784
+ left !== this.scroll.horizontalBarPos && this.updateHoverPos(-1, -1), this.scroll.horizontalBarPos = left, isValid$3(this.scroll.horizontalBarPos) && !isNaN(this.scroll.horizontalBarPos) || (this.scroll.horizontalBarPos = 0), this.table.scenegraph.setX(-left), this.table.scenegraph.component.updateHorizontalScrollBarPos(xRatio), oldHorizontalBarPos !== left && triggerEvent && this.checkHorizontalScrollBarEnd();
47745
47785
  }
47746
47786
  hideVerticalScrollBar() {
47747
47787
  this.table.scenegraph.component.hideVerticalScrollBar();
@@ -48374,7 +48414,7 @@
48374
48414
  callback: globalPointerdownCallback
48375
48415
  }), vglobal.addEventListener("pointerup", globalPointerupCallback), vglobal.addEventListener("pointerdown", globalPointerdownCallback), table.scenegraph.tableGroup.addEventListener("pointerdown", e => {
48376
48416
  var _a, _b, _c, _d, _e;
48377
- table.hasListeners(TABLE_EVENT_TYPE.MOUSEDOWN_TABLE) && table.fireListeners(TABLE_EVENT_TYPE.MOUSEDOWN_TABLE, {
48417
+ if (table.hasListeners(TABLE_EVENT_TYPE.MOUSEDOWN_TABLE) && table.fireListeners(TABLE_EVENT_TYPE.MOUSEDOWN_TABLE, {
48378
48418
  event: e.nativeEvent
48379
48419
  }), table.eventManager.isDown = !0, table.eventManager.LastBodyPointerXY = {
48380
48420
  x: e.x,
@@ -48382,7 +48422,7 @@
48382
48422
  }, table.eventManager.LastPointerXY = {
48383
48423
  x: e.x,
48384
48424
  y: e.y
48385
- };
48425
+ }, 0 !== e.button) return;
48386
48426
  const eventArgsSet = getCellEventArgsSet(e);
48387
48427
  if (eventManager.downIcon = void 0, stateManager.interactionState !== InteractionState.default) return;
48388
48428
  if (table.isPivotChart() && "chart" !== (null === (_a = null == eventArgsSet ? void 0 : eventArgsSet.eventArgs) || void 0 === _a ? void 0 : _a.target.type) && table.scenegraph.updateChartState(null), (null === (_b = eventArgsSet.eventArgs) || void 0 === _b ? void 0 : _b.target) !== (null === (_c = stateManager.residentHoverIcon) || void 0 === _c ? void 0 : _c.icon) && stateManager.hideMenu(), "chart" === (null === (_d = null == eventArgsSet ? void 0 : eventArgsSet.eventArgs) || void 0 === _d ? void 0 : _d.target.type)) return;
@@ -48958,7 +48998,7 @@
48958
48998
  }
48959
48999
  }), handler.on(table.getElement(), "contextmenu", e => {
48960
49000
  var _a;
48961
- !1 !== (null === (_a = table.eventOptions) || void 0 === _a ? void 0 : _a.preventDefaultContextMenu) && e.preventDefault();
49001
+ !1 !== (null === (_a = table.eventOptions) || void 0 === _a ? void 0 : _a.preventDefaultContextMenu) ? e.preventDefault() : globalPointerupCallback(e);
48962
49002
  }), table.options.canvas || handler.on(table.getContainer(), "resize", e => {
48963
49003
  var _a;
48964
49004
  table.isReleased || 0 === e.width && 0 === e.height || ((table.autoFillWidth || table.autoFillHeight) && (null === (_a = table.editorManager) || void 0 === _a || _a.completeEdit()), isValid$3(table.options.pixelRatio) || table.setPixelRatio(getPixelRatio$1()), e.windowSizeNotChange || table.resize());
@@ -49389,6 +49429,75 @@
49389
49429
  });
49390
49430
  }
49391
49431
 
49432
+ function bindIconClickEvent(table) {
49433
+ table.on(TABLE_EVENT_TYPE.ICON_CLICK, iconInfo => {
49434
+ var _a;
49435
+ const {
49436
+ col: col,
49437
+ row: row,
49438
+ x: x,
49439
+ y: y,
49440
+ funcType: funcType,
49441
+ icon: icon,
49442
+ event: event
49443
+ } = iconInfo,
49444
+ {
49445
+ stateManager: stateManager
49446
+ } = table;
49447
+ if (funcType === IconFuncTypeEnum.dropDown) stateManager.triggerDropDownMenu(col, row, x, y, event);else if (funcType === IconFuncTypeEnum.sort) stateManager.triggerSort(col, row, icon, event);else if (funcType === IconFuncTypeEnum.frozen) stateManager.triggerFreeze(col, row, icon);else if (funcType === IconFuncTypeEnum.drillDown) drillClick(table);else if (funcType === IconFuncTypeEnum.collapse || funcType === IconFuncTypeEnum.expand) {
49448
+ const isHasSelected = !!(null === (_a = stateManager.select.ranges) || void 0 === _a ? void 0 : _a.length);
49449
+ stateManager.updateSelectPos(-1, -1), stateManager.endSelectCells(!0, isHasSelected), table.toggleHierarchyState(col, row);
49450
+ }
49451
+ });
49452
+ }
49453
+
49454
+ function bindDropdownMenuClickEvent(table) {
49455
+ table.on(TABLE_EVENT_TYPE.DROPDOWN_MENU_CLICK, () => {
49456
+ table.stateManager.hideMenu();
49457
+ });
49458
+ }
49459
+
49460
+ function bindDBClickAutoColumnWidthEvent(table) {
49461
+ table.on(TABLE_EVENT_TYPE.DBLCLICK_CELL, e => {
49462
+ var _a, _b, _c;
49463
+ if (e.federatedEvent) {
49464
+ const eventArgsSet = getCellEventArgsSet(e.federatedEvent),
49465
+ resizeCol = table.scenegraph.getResizeColAt(eventArgsSet.abstractPos.x, eventArgsSet.abstractPos.y, null === (_a = eventArgsSet.eventArgs) || void 0 === _a ? void 0 : _a.targetCell),
49466
+ disableDblclickAutoResizeColWidth = null !== (_b = table.options.disableDblclickAutoResizeColWidth) && void 0 !== _b ? _b : null === (_c = table.options.resize) || void 0 === _c ? void 0 : _c.disableDblclickAutoResizeColWidth;
49467
+ if (table.eventManager.checkCellFillhandle(eventArgsSet)) table.fireListeners(TABLE_EVENT_TYPE.DBLCLICK_FILL_HANDLE, {});else if (table._canResizeColumn(resizeCol.col, resizeCol.row) && resizeCol.col >= 0 && !disableDblclickAutoResizeColWidth) {
49468
+ table.scenegraph.updateAutoColWidth(resizeCol.col), table.internalProps._widthResizedColMap.add(resizeCol.col), table.scenegraph.updateChartSizeForResizeColWidth(resizeCol.col);
49469
+ const state = table.stateManager;
49470
+ state.columnResize.col < state.table.frozenColCount && !state.table.isPivotTable() && !state.table.transpose && state.table.scenegraph.component.setFrozenColumnShadow(state.table.frozenColCount - 1, state.columnResize.isRightFrozen);
49471
+ const colWidths = [];
49472
+ for (let col = 0; col < table.colCount; col++) colWidths.push(table.getColWidth(col));
49473
+ table.fireListeners(TABLE_EVENT_TYPE.RESIZE_COLUMN_END, {
49474
+ col: resizeCol.col,
49475
+ colWidths: colWidths
49476
+ });
49477
+ }
49478
+ }
49479
+ });
49480
+ }
49481
+
49482
+ function rightButtonClickEvent(table) {
49483
+ table.on(TABLE_EVENT_TYPE.CONTEXTMENU_CELL, e => {
49484
+ const {
49485
+ col: col,
49486
+ row: row
49487
+ } = e,
49488
+ ranges = table.getSelectedCellRanges();
49489
+ let cellInRange = !1;
49490
+ if (ranges.length > 0) for (let i = 0; i < ranges.length; i++) {
49491
+ const range = ranges[i];
49492
+ if (col >= range.start.col && col <= range.end.col && row >= range.start.row && row <= range.end.row) {
49493
+ cellInRange = !0;
49494
+ break;
49495
+ }
49496
+ }
49497
+ cellInRange || table.selectCell(col, row);
49498
+ });
49499
+ }
49500
+
49392
49501
  let EventManager$1 = class EventManager {
49393
49502
  constructor(table) {
49394
49503
  this.isDown = !1, this.isDraging = !1, this.globalEventListeners = [], this._enableTableScroll = !0, this.table = table, this.handleTextStickBindId = [], this.inertiaScroll = new InertiaScroll(table.stateManager), "node" === Env.mode || table.options.disableInteraction || (this.bindOuterEvent(), setTimeout(() => {
@@ -49413,44 +49522,7 @@
49413
49522
  }, 0);
49414
49523
  }
49415
49524
  bindSelfEvent() {
49416
- if (this.table.isReleased) return;
49417
- const stateManager = this.table.stateManager;
49418
- this.table.on(TABLE_EVENT_TYPE.ICON_CLICK, iconInfo => {
49419
- var _a;
49420
- const {
49421
- col: col,
49422
- row: row,
49423
- x: x,
49424
- y: y,
49425
- funcType: funcType,
49426
- icon: icon,
49427
- event: event
49428
- } = iconInfo;
49429
- if (funcType === IconFuncTypeEnum.dropDown) stateManager.triggerDropDownMenu(col, row, x, y, event);else if (funcType === IconFuncTypeEnum.sort) stateManager.triggerSort(col, row, icon, event);else if (funcType === IconFuncTypeEnum.frozen) stateManager.triggerFreeze(col, row, icon);else if (funcType === IconFuncTypeEnum.drillDown) drillClick(this.table);else if (funcType === IconFuncTypeEnum.collapse || funcType === IconFuncTypeEnum.expand) {
49430
- const isHasSelected = !!(null === (_a = stateManager.select.ranges) || void 0 === _a ? void 0 : _a.length);
49431
- stateManager.updateSelectPos(-1, -1), stateManager.endSelectCells(!0, isHasSelected), this.table.toggleHierarchyState(col, row);
49432
- }
49433
- }), this.table.on(TABLE_EVENT_TYPE.DROPDOWN_MENU_CLICK, () => {
49434
- stateManager.hideMenu();
49435
- }), this.updateEventBinder(), bindMediaClick(this.table), this.table.on(TABLE_EVENT_TYPE.DBLCLICK_CELL, e => {
49436
- var _a, _b, _c;
49437
- if (e.federatedEvent) {
49438
- const eventArgsSet = getCellEventArgsSet(e.federatedEvent),
49439
- resizeCol = this.table.scenegraph.getResizeColAt(eventArgsSet.abstractPos.x, eventArgsSet.abstractPos.y, null === (_a = eventArgsSet.eventArgs) || void 0 === _a ? void 0 : _a.targetCell),
49440
- disableDblclickAutoResizeColWidth = null !== (_b = this.table.options.disableDblclickAutoResizeColWidth) && void 0 !== _b ? _b : null === (_c = this.table.options.resize) || void 0 === _c ? void 0 : _c.disableDblclickAutoResizeColWidth;
49441
- if (this.table.eventManager.checkCellFillhandle(eventArgsSet)) this.table.fireListeners(TABLE_EVENT_TYPE.DBLCLICK_FILL_HANDLE, {});else if (this.table._canResizeColumn(resizeCol.col, resizeCol.row) && resizeCol.col >= 0 && !disableDblclickAutoResizeColWidth) {
49442
- this.table.scenegraph.updateAutoColWidth(resizeCol.col), this.table.internalProps._widthResizedColMap.add(resizeCol.col), this.table.scenegraph.updateChartSizeForResizeColWidth(resizeCol.col);
49443
- const state = this.table.stateManager;
49444
- state.columnResize.col < state.table.frozenColCount && !state.table.isPivotTable() && !state.table.transpose && state.table.scenegraph.component.setFrozenColumnShadow(state.table.frozenColCount - 1, state.columnResize.isRightFrozen);
49445
- const colWidths = [];
49446
- for (let col = 0; col < this.table.colCount; col++) colWidths.push(this.table.getColWidth(col));
49447
- this.table.fireListeners(TABLE_EVENT_TYPE.RESIZE_COLUMN_END, {
49448
- col: resizeCol.col,
49449
- colWidths: colWidths
49450
- });
49451
- }
49452
- }
49453
- }), this.table.isPivotTable() && checkHaveDrill(this.table) && bindDrillEvent(this.table), bindSparklineHoverEvent(this.table), bindAxisClickEvent(this.table), bindAxisHoverEvent(this.table), bindGroupTitleCheckboxChange(this.table), bindButtonClickEvent(this.table);
49525
+ this.table.isReleased || (bindIconClickEvent(this.table), bindDropdownMenuClickEvent(this.table), this.updateEventBinder(), bindMediaClick(this.table), bindDBClickAutoColumnWidthEvent(this.table), this.table.isPivotTable() && checkHaveDrill(this.table) && bindDrillEvent(this.table), bindSparklineHoverEvent(this.table), bindAxisClickEvent(this.table), bindAxisHoverEvent(this.table), bindGroupTitleCheckboxChange(this.table), bindButtonClickEvent(this.table), rightButtonClickEvent(this.table));
49454
49526
  }
49455
49527
  dealTableHover(eventArgsSet) {
49456
49528
  if (!eventArgsSet) return void this.table.stateManager.updateHoverPos(-1, -1);
@@ -52201,7 +52273,7 @@
52201
52273
  constructor(container) {
52202
52274
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
52203
52275
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
52204
- if (super(), this.showFrozenIcon = !0, this.version = "1.17.3-alpha.10", 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");
52276
+ if (super(), this.showFrozenIcon = !0, this.version = "1.17.3-alpha.12", 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");
52205
52277
  !1 === (null === (_a = options.customConfig) || void 0 === _a ? void 0 : _a.imageAnonymous) && (vglobal.isImageAnonymous = !1);
52206
52278
  const {
52207
52279
  frozenColCount = 0,
@@ -52249,7 +52321,7 @@
52249
52321
  right: 0,
52250
52322
  left: 0,
52251
52323
  bottom: 0
52252
- }, padding && ("number" == typeof padding ? (this.padding.top = padding, this.padding.left = padding, this.padding.bottom = padding, this.padding.right = padding) : (padding.top && (this.padding.top = padding.top), padding.bottom && (this.padding.bottom = padding.bottom), padding.left && (this.padding.left = padding.left), padding.right && (this.padding.right = padding.right))), isValid$3(canvasHeight) && isValid$3(canvasWidth) && (this.canvasSizeSeted = !0), this.tableNoFrameWidth = 0, this.tableNoFrameHeight = 0, this.canvasWidth = isNumber$4(canvasWidth) ? canvasWidth : void 0, this.canvasHeight = isNumber$4(canvasHeight) ? canvasHeight : void 0, this.columnWidthComputeMode = null !== (_b = options.columnWidthComputeMode) && void 0 !== _b ? _b : "normal";
52324
+ }, padding && ("number" == typeof padding ? (this.padding.top = padding, this.padding.left = padding, this.padding.bottom = padding, this.padding.right = padding) : (padding.top && (this.padding.top = padding.top), padding.bottom && (this.padding.bottom = padding.bottom), padding.left && (this.padding.left = padding.left), padding.right && (this.padding.right = padding.right))), (isValid$3(canvasHeight) || isValid$3(canvasWidth)) && (this.canvasSizeSeted = !0), this.tableNoFrameWidth = 0, this.tableNoFrameHeight = 0, this.canvasWidth = isNumber$4(canvasWidth) ? canvasWidth : void 0, this.canvasHeight = isNumber$4(canvasHeight) ? canvasHeight : void 0, this.columnWidthComputeMode = null !== (_b = options.columnWidthComputeMode) && void 0 !== _b ? _b : "normal";
52253
52325
  const internalProps = this.internalProps = {};
52254
52326
  void 0 !== showFrozenIcon && (this.showFrozenIcon = showFrozenIcon), "number" == typeof allowFrozenColCount && allowFrozenColCount <= 0 && (this.showFrozenIcon = !1), this.options.canvas ? ("node" !== Env.mode && (internalProps.element = this.options.canvas.parentElement, internalProps.element.style.position = "relative"), internalProps.focusControl = new FocusInput(this, internalProps.element), internalProps.canvas = this.options.canvas, internalProps.context = internalProps.canvas.getContext("2d")) : "node" !== Env.mode && (internalProps.element = createRootElement$1(this.padding), internalProps.focusControl = new FocusInput(this, internalProps.element), internalProps.canvas = document.createElement("canvas"), internalProps.element.appendChild(internalProps.canvas), internalProps.context = internalProps.canvas.getContext("2d"), (null === (_c = options.customConfig) || void 0 === _c ? void 0 : _c.createReactContainer) && createReactContainer(this)), internalProps.handler = new EventHandler$1(), isNumber$4(this.options.resizeTime) && (internalProps.handler.resizeTime = this.options.resizeTime), internalProps.pixelRatio = pixelRatio, internalProps.frozenColCount = frozenColCount, internalProps.frozenRowCount = frozenRowCount, internalProps.unfreezeAllOnExceedsMaxWidth = null == unfreezeAllOnExceedsMaxWidth || unfreezeAllOnExceedsMaxWidth, internalProps.defaultRowHeight = defaultRowHeight, internalProps.defaultHeaderRowHeight = null != defaultHeaderRowHeight ? defaultHeaderRowHeight : defaultRowHeight, internalProps.defaultColWidth = defaultColWidth, internalProps.defaultHeaderColWidth = null != defaultHeaderColWidth ? defaultHeaderColWidth : defaultColWidth, internalProps.keyboardOptions = keyboardOptions, internalProps.eventOptions = eventOptions, internalProps.rowSeriesNumber = rowSeriesNumber, internalProps.columnResizeMode = null !== (_d = null == resize ? void 0 : resize.columnResizeMode) && void 0 !== _d ? _d : columnResizeMode, internalProps.rowResizeMode = null !== (_e = null == resize ? void 0 : resize.rowResizeMode) && void 0 !== _e ? _e : rowResizeMode, internalProps.dragHeaderMode = null !== (_g = null !== (_f = null == dragOrder ? void 0 : dragOrder.dragHeaderMode) && void 0 !== _f ? _f : dragHeaderMode) && void 0 !== _g ? _g : "none", internalProps.renderChartAsync = renderChartAsync, setBatchRenderChartCount(renderChartAsyncBatchCount), internalProps.overscrollBehavior = null != overscrollBehavior ? overscrollBehavior : "auto", internalProps._rowHeightsMap = new NumberRangeMap(this), internalProps._rowRangeHeightsMap = new Map(), internalProps._colRangeWidthsMap = new Map(), internalProps._widthResizedColMap = new Set(), internalProps._heightResizedRowMap = new Set(), this.colWidthsMap = new NumberMap(), this.colContentWidthsMap = new NumberMap(), this.colWidthsLimit = {};
52255
52327
  const that = this;
@@ -52556,7 +52628,7 @@
52556
52628
  }
52557
52629
  }
52558
52630
  _updateSize() {
52559
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1;
52631
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5;
52560
52632
  const {
52561
52633
  padding: padding
52562
52634
  } = this;
@@ -52566,28 +52638,31 @@
52566
52638
  const element = this.getElement();
52567
52639
  let widthWithoutPadding = 0,
52568
52640
  heightWithoutPadding = 0;
52569
- if (this.canvasSizeSeted) widthWithoutPadding = this.canvasWidth, heightWithoutPadding = this.canvasHeight;else if (element.parentElement) {
52641
+ const isDefWidth = isValid$3(this.canvasWidth),
52642
+ isDefHeight = isValid$3(this.canvasHeight);
52643
+ this.canvasSizeSeted && (isDefWidth && (widthWithoutPadding = this.canvasWidth), isDefHeight && (heightWithoutPadding = this.canvasHeight));
52644
+ if ((!isDefWidth || !isDefHeight) && element.parentElement) {
52570
52645
  const computedStyle = element.parentElement.style || window.getComputedStyle(element.parentElement);
52571
- 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);
52646
+ isDefWidth || (widthWithoutPadding = element.parentElement.offsetWidth - (parseInt(computedStyle.paddingLeft, 10) || 0) - (parseInt(computedStyle.paddingRight, 10) || 0)), isDefHeight || (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);
52572
52647
  }
52573
52648
  element.style.width = widthWithoutPadding && widthWithoutPadding - padding.left - padding.right + "px" || "0px", element.style.height = heightWithoutPadding && heightWithoutPadding - padding.top - padding.bottom + "px" || "0px";
52574
52649
  const {
52575
52650
  canvas: canvas
52576
52651
  } = this.internalProps;
52577
- 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`);
52652
+ 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) ? (null === (_g = this.options) || void 0 === _g ? void 0 : _g.viewBox) && !(null === (_h = this.options) || void 0 === _h ? void 0 : _h.canvas) && 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`), (null === (_j = this.options) || void 0 === _j ? void 0 : _j.viewBox) && (widthP = this.options.viewBox.x2 - this.options.viewBox.x1, heightP = this.options.viewBox.y2 - this.options.viewBox.y1), (null === (_k = null == this ? void 0 : this.scenegraph) || void 0 === _k ? void 0 : _k.stage) && (this.options.viewBox ? this.scenegraph.stage.setViewBox(this.options.viewBox, !1) : this.scenegraph.stage.resize(widthP, heightP));
52578
52653
  } else "node" === Env.mode && (widthP = this.canvasWidth - 1, heightP = this.canvasHeight - 1);
52579
52654
  const width = Math.floor(widthP - getVerticalScrollBarSize(this.getTheme().scrollStyle)),
52580
52655
  height = Math.floor(heightP - getHorizontalScrollBarSize(this.getTheme().scrollStyle));
52581
- if (null === (_g = this.internalProps.theme) || void 0 === _g ? void 0 : _g.frameStyle) {
52582
- const lineWidths = toBoxArray(null !== (_j = null === (_h = this.internalProps.theme.frameStyle) || void 0 === _h ? void 0 : _h.borderLineWidth) && void 0 !== _j ? _j : [null]),
52583
- shadowWidths = toBoxArray(null !== (_l = null === (_k = this.internalProps.theme.frameStyle) || void 0 === _k ? void 0 : _k.shadowBlur) && void 0 !== _l ? _l : [0]);
52584
- (null === (_m = this.theme.frameStyle) || void 0 === _m ? void 0 : _m.innerBorder) ? (this.tableX = 0, this.tableY = 0, this.tableNoFrameWidth = width - (null !== (_o = shadowWidths[1]) && void 0 !== _o ? _o : 0), this.tableNoFrameHeight = height - (null !== (_p = shadowWidths[2]) && void 0 !== _p ? _p : 0)) : (this.tableX = (null !== (_q = lineWidths[3]) && void 0 !== _q ? _q : 0) + (null !== (_r = shadowWidths[3]) && void 0 !== _r ? _r : 0), this.tableY = (null !== (_s = lineWidths[0]) && void 0 !== _s ? _s : 0) + (null !== (_t = shadowWidths[0]) && void 0 !== _t ? _t : 0), this.tableNoFrameWidth = width - ((null !== (_u = lineWidths[1]) && void 0 !== _u ? _u : 0) + (null !== (_v = shadowWidths[1]) && void 0 !== _v ? _v : 0)) - ((null !== (_w = lineWidths[3]) && void 0 !== _w ? _w : 0) + (null !== (_x = shadowWidths[3]) && void 0 !== _x ? _x : 0)), this.tableNoFrameHeight = height - ((null !== (_y = lineWidths[0]) && void 0 !== _y ? _y : 0) + (null !== (_z = shadowWidths[0]) && void 0 !== _z ? _z : 0)) - ((null !== (_0 = lineWidths[2]) && void 0 !== _0 ? _0 : 0) + (null !== (_1 = shadowWidths[2]) && void 0 !== _1 ? _1 : 0)));
52656
+ if (null === (_l = this.internalProps.theme) || void 0 === _l ? void 0 : _l.frameStyle) {
52657
+ const lineWidths = toBoxArray(null !== (_o = null === (_m = this.internalProps.theme.frameStyle) || void 0 === _m ? void 0 : _m.borderLineWidth) && void 0 !== _o ? _o : [null]),
52658
+ shadowWidths = toBoxArray(null !== (_q = null === (_p = this.internalProps.theme.frameStyle) || void 0 === _p ? void 0 : _p.shadowBlur) && void 0 !== _q ? _q : [0]);
52659
+ (null === (_r = this.theme.frameStyle) || void 0 === _r ? void 0 : _r.innerBorder) ? (this.tableX = 0, this.tableY = 0, this.tableNoFrameWidth = width - (null !== (_s = shadowWidths[1]) && void 0 !== _s ? _s : 0), this.tableNoFrameHeight = height - (null !== (_t = shadowWidths[2]) && void 0 !== _t ? _t : 0)) : (this.tableX = (null !== (_u = lineWidths[3]) && void 0 !== _u ? _u : 0) + (null !== (_v = shadowWidths[3]) && void 0 !== _v ? _v : 0), this.tableY = (null !== (_w = lineWidths[0]) && void 0 !== _w ? _w : 0) + (null !== (_x = shadowWidths[0]) && void 0 !== _x ? _x : 0), this.tableNoFrameWidth = width - ((null !== (_y = lineWidths[1]) && void 0 !== _y ? _y : 0) + (null !== (_z = shadowWidths[1]) && void 0 !== _z ? _z : 0)) - ((null !== (_0 = lineWidths[3]) && void 0 !== _0 ? _0 : 0) + (null !== (_1 = shadowWidths[3]) && void 0 !== _1 ? _1 : 0)), this.tableNoFrameHeight = height - ((null !== (_2 = lineWidths[0]) && void 0 !== _2 ? _2 : 0) + (null !== (_3 = shadowWidths[0]) && void 0 !== _3 ? _3 : 0)) - ((null !== (_4 = lineWidths[2]) && void 0 !== _4 ? _4 : 0) + (null !== (_5 = shadowWidths[2]) && void 0 !== _5 ? _5 : 0)));
52585
52660
  }
52586
52661
  }
52587
52662
  updateViewBox(newViewBox) {
52588
- var _a, _b, _c, _d, _e, _f, _g, _h;
52589
- const oldWidth = null !== (_d = null !== (_b = null === (_a = this.options) || void 0 === _a ? void 0 : _a.viewBox.x2) && void 0 !== _b ? _b : 0 - (null === (_c = this.options) || void 0 === _c ? void 0 : _c.viewBox.x1)) && void 0 !== _d ? _d : 0,
52590
- oldHeight = null !== (_h = null !== (_f = null === (_e = this.options) || void 0 === _e ? void 0 : _e.viewBox.y2) && void 0 !== _f ? _f : 0 - (null === (_g = this.options) || void 0 === _g ? void 0 : _g.viewBox.y1)) && void 0 !== _h ? _h : 0,
52663
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
52664
+ const oldWidth = (null !== (_c = null === (_b = null === (_a = this.options) || void 0 === _a ? void 0 : _a.viewBox) || void 0 === _b ? void 0 : _b.x2) && void 0 !== _c ? _c : 0) - (null !== (_f = null === (_e = null === (_d = this.options) || void 0 === _d ? void 0 : _d.viewBox) || void 0 === _e ? void 0 : _e.x1) && void 0 !== _f ? _f : 0),
52665
+ oldHeight = (null !== (_j = null === (_h = null === (_g = this.options) || void 0 === _g ? void 0 : _g.viewBox) || void 0 === _h ? void 0 : _h.y2) && void 0 !== _j ? _j : 0) - (null !== (_m = null === (_l = null === (_k = this.options) || void 0 === _k ? void 0 : _k.viewBox) || void 0 === _l ? void 0 : _l.y1) && void 0 !== _m ? _m : 0),
52591
52666
  newWidth = newViewBox.x2 - newViewBox.x1,
52592
52667
  newHeight = newViewBox.y2 - newViewBox.y1;
52593
52668
  this.options.viewBox = newViewBox, oldWidth !== newWidth || oldHeight !== newHeight ? this.resize() : this.scenegraph.stage.setViewBox(this.options.viewBox, !0);
@@ -55546,9 +55621,9 @@
55546
55621
  }, null), this._headerObjectsIncludeHided = this._addHeaders(0, columns, []), this._headerObjects = this._headerObjectsIncludeHided.filter(col => !0 !== col.define.hide), this._headerObjectMap = this._headerObjects.reduce((o, e) => (o[e.id] = e, o), {}), this.rowHierarchyType = checkHasTreeDefine(this) ? "tree" : "grid", this._hasAggregation = checkHasAggregation(this), this._hasAggregationOnBottomCount = checkHasAggregationOnBottom(this), this._hasAggregationOnTopCount = checkHasAggregationOnTop(this), this.handleRowSeriesNumber(table.internalProps.rowSeriesNumber);
55547
55622
  }
55548
55623
  handleRowSeriesNumber(rowSeriesNumber) {
55549
- var _a, _b;
55624
+ var _a;
55550
55625
  rowSeriesNumber && (Array.isArray(rowSeriesNumber) ? this.rowSeriesNumberColumn = rowSeriesNumber.map((seriesNumber, index) => {
55551
- var _a, _b, _c;
55626
+ var _a, _b;
55552
55627
  return {
55553
55628
  id: this.seqId++,
55554
55629
  title: seriesNumber.title,
@@ -55556,11 +55631,11 @@
55556
55631
  field: "_vtable_rowSeries_number_" + index
55557
55632
  }, seriesNumber),
55558
55633
  cellType: null !== (_a = seriesNumber.cellType) && void 0 !== _a ? _a : "text",
55559
- headerType: null !== (_b = rowSeriesNumber.cellType) && void 0 !== _b ? _b : "text",
55634
+ headerType: "checkbox" === seriesNumber.cellType ? "checkbox" : "text",
55560
55635
  style: seriesNumber.style,
55561
55636
  width: seriesNumber.width,
55562
55637
  format: seriesNumber.format,
55563
- field: null !== (_c = seriesNumber.field) && void 0 !== _c ? _c : "_vtable_rowSeries_number_" + index,
55638
+ field: null !== (_b = seriesNumber.field) && void 0 !== _b ? _b : "_vtable_rowSeries_number_" + index,
55564
55639
  icon: seriesNumber.icon,
55565
55640
  headerIcon: seriesNumber.headerIcon,
55566
55641
  isChildNode: !1
@@ -55572,7 +55647,7 @@
55572
55647
  field: "_vtable_rowSeries_number"
55573
55648
  }, rowSeriesNumber),
55574
55649
  cellType: null !== (_a = rowSeriesNumber.cellType) && void 0 !== _a ? _a : "text",
55575
- headerType: null !== (_b = rowSeriesNumber.cellType) && void 0 !== _b ? _b : "text",
55650
+ headerType: "checkbox" === rowSeriesNumber.cellType ? "checkbox" : "text",
55576
55651
  style: rowSeriesNumber.style,
55577
55652
  width: rowSeriesNumber.width,
55578
55653
  format: rowSeriesNumber.format,
@@ -65212,7 +65287,7 @@
65212
65287
  themes: themes$1
65213
65288
  });
65214
65289
 
65215
- const version = "1.17.3-alpha.10";
65290
+ const version = "1.17.3-alpha.12";
65216
65291
 
65217
65292
  exports.Gantt = Gantt;
65218
65293
  exports.TYPES = index$3;