@visactor/vtable-gantt 1.23.3-alpha.0 → 1.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/cjs/Gantt.d.ts +18 -0
  2. package/cjs/Gantt.js +135 -9
  3. package/cjs/Gantt.js.map +1 -1
  4. package/cjs/gantt-helper.d.ts +7 -0
  5. package/cjs/gantt-helper.js +75 -66
  6. package/cjs/gantt-helper.js.map +1 -1
  7. package/cjs/index.d.ts +1 -1
  8. package/cjs/index.js +1 -1
  9. package/cjs/index.js.map +1 -1
  10. package/cjs/plugins/index.js.map +1 -1
  11. package/cjs/scenegraph/dependency-link.js +28 -38
  12. package/cjs/scenegraph/dependency-link.js.map +1 -1
  13. package/cjs/scenegraph/grid.js +8 -7
  14. package/cjs/scenegraph/grid.js.map +1 -1
  15. package/cjs/scenegraph/mark-line.js +10 -12
  16. package/cjs/scenegraph/mark-line.js.map +1 -1
  17. package/cjs/scenegraph/task-bar.d.ts +4 -1
  18. package/cjs/scenegraph/task-bar.js +73 -23
  19. package/cjs/scenegraph/task-bar.js.map +1 -1
  20. package/cjs/scenegraph/timeline-header.js +1 -4
  21. package/cjs/scenegraph/timeline-header.js.map +1 -1
  22. package/cjs/state/state-manager.js +22 -18
  23. package/cjs/state/state-manager.js.map +1 -1
  24. package/cjs/tools/isx.d.ts +1 -1
  25. package/cjs/ts-types/gantt-engine.d.ts +7 -0
  26. package/cjs/ts-types/gantt-engine.js.map +1 -1
  27. package/dist/vtable-gantt.js +1374 -694
  28. package/dist/vtable-gantt.min.js +2 -2
  29. package/es/Gantt.d.ts +18 -0
  30. package/es/Gantt.js +135 -8
  31. package/es/Gantt.js.map +1 -1
  32. package/es/gantt-helper.d.ts +7 -0
  33. package/es/gantt-helper.js +74 -63
  34. package/es/gantt-helper.js.map +1 -1
  35. package/es/index.d.ts +1 -1
  36. package/es/index.js +1 -1
  37. package/es/index.js.map +1 -1
  38. package/es/plugins/index.js.map +1 -1
  39. package/es/scenegraph/dependency-link.js +29 -27
  40. package/es/scenegraph/dependency-link.js.map +1 -1
  41. package/es/scenegraph/grid.js +6 -8
  42. package/es/scenegraph/grid.js.map +1 -1
  43. package/es/scenegraph/mark-line.js +10 -11
  44. package/es/scenegraph/mark-line.js.map +1 -1
  45. package/es/scenegraph/task-bar.d.ts +4 -1
  46. package/es/scenegraph/task-bar.js +74 -23
  47. package/es/scenegraph/task-bar.js.map +1 -1
  48. package/es/scenegraph/timeline-header.js +2 -3
  49. package/es/scenegraph/timeline-header.js.map +1 -1
  50. package/es/state/state-manager.js +22 -18
  51. package/es/state/state-manager.js.map +1 -1
  52. package/es/tools/isx.d.ts +1 -1
  53. package/es/ts-types/gantt-engine.d.ts +7 -0
  54. package/es/ts-types/gantt-engine.js.map +1 -1
  55. package/package.json +6 -6
@@ -685,28 +685,59 @@
685
685
  }
686
686
  addEventListener(type, listener, options) {
687
687
  if (!listener) return;
688
+ const capture = this._resolveCapture(options),
689
+ once = this._resolveOnce(options),
690
+ listenerTypeMap = this._getOrCreateListenerTypeMap(type),
691
+ wrappedMap = this._getOrCreateWrappedMap(listenerTypeMap, listener);
692
+ if (wrappedMap.has(capture)) return;
688
693
  const wrappedListener = event => {
689
694
  const transformedEvent = this._eventListenerTransformer(event);
690
- "function" == typeof listener ? listener(transformedEvent) : listener.handleEvent && listener.handleEvent(transformedEvent);
695
+ "function" == typeof listener ? listener(transformedEvent) : listener.handleEvent && listener.handleEvent(transformedEvent), once && this._deleteListenerRecord(type, listener, capture);
691
696
  };
692
- this._listenerMap.has(type) || this._listenerMap.set(type, new Map()), this._listenerMap.get(type).set(listener, wrappedListener), this._nativeAddEventListener(type, wrappedListener, options);
697
+ wrappedMap.set(capture, {
698
+ wrappedListener: wrappedListener,
699
+ options: options
700
+ }), this._nativeAddEventListener(type, wrappedListener, options);
693
701
  }
694
702
  removeEventListener(type, listener, options) {
695
- var _a;
703
+ var _a, _b;
696
704
  if (!listener) return;
697
- const wrappedListener = null === (_a = this._listenerMap.get(type)) || void 0 === _a ? void 0 : _a.get(listener);
698
- wrappedListener && (this._nativeRemoveEventListener(type, wrappedListener, options), this._listenerMap.get(type).delete(listener), 0 === this._listenerMap.get(type).size && this._listenerMap.delete(type));
705
+ const capture = this._resolveCapture(options),
706
+ wrappedRecord = null === (_b = null === (_a = this._listenerMap.get(type)) || void 0 === _a ? void 0 : _a.get(listener)) || void 0 === _b ? void 0 : _b.get(capture);
707
+ wrappedRecord && (this._nativeRemoveEventListener(type, wrappedRecord.wrappedListener, capture), this._deleteListenerRecord(type, listener, capture));
699
708
  }
700
709
  dispatchEvent(event) {
701
710
  return this._nativeDispatchEvent(event);
702
711
  }
703
712
  clearAllEventListeners() {
704
- this._listenerMap.forEach((listenersMap, type) => {
705
- listenersMap.forEach((wrappedListener, originalListener) => {
706
- this._nativeRemoveEventListener(type, wrappedListener, void 0);
713
+ this._listenerMap.forEach((listenerMap, type) => {
714
+ listenerMap.forEach(wrappedMap => {
715
+ wrappedMap.forEach((wrappedRecord, capture) => {
716
+ this._nativeRemoveEventListener(type, wrappedRecord.wrappedListener, capture);
717
+ });
707
718
  });
708
719
  }), this._listenerMap.clear();
709
720
  }
721
+ _resolveCapture(options) {
722
+ return "boolean" == typeof options ? options : !!(null == options ? void 0 : options.capture);
723
+ }
724
+ _resolveOnce(options) {
725
+ return "object" == typeof options && !!(null == options ? void 0 : options.once);
726
+ }
727
+ _getOrCreateListenerTypeMap(type) {
728
+ let listenerTypeMap = this._listenerMap.get(type);
729
+ return listenerTypeMap || (listenerTypeMap = new Map(), this._listenerMap.set(type, listenerTypeMap)), listenerTypeMap;
730
+ }
731
+ _getOrCreateWrappedMap(listenerTypeMap, listener) {
732
+ let wrappedMap = listenerTypeMap.get(listener);
733
+ return wrappedMap || (wrappedMap = new Map(), listenerTypeMap.set(listener, wrappedMap)), wrappedMap;
734
+ }
735
+ _deleteListenerRecord(type, listener, capture) {
736
+ const listenerTypeMap = this._listenerMap.get(type);
737
+ if (!listenerTypeMap) return;
738
+ const wrappedMap = listenerTypeMap.get(listener);
739
+ wrappedMap && (wrappedMap.delete(capture), 0 === wrappedMap.size && listenerTypeMap.delete(listener), 0 === listenerTypeMap.size && this._listenerMap.delete(type));
740
+ }
710
741
  _nativeAddEventListener(type, listener, options) {
711
742
  throw new Error("_nativeAddEventListener must be implemented by derived classes");
712
743
  }
@@ -7220,7 +7251,9 @@
7220
7251
  var _a;
7221
7252
  if (event.manager !== this) throw new Error("It is illegal to free an event not managed by this EventManager!");
7222
7253
  const constructor = event.constructor;
7223
- this.eventPool.has(constructor) || this.eventPool.set(constructor, []), null === (_a = this.eventPool.get(constructor)) || void 0 === _a || _a.push(event);
7254
+ this.eventPool.has(constructor) || (this.eventPool.get(constructor).forEach(e => {
7255
+ e.eventPhase = event.NONE, e.currentTarget = null, e.path = [], e.detailPath = [], e.target = null;
7256
+ }), this.eventPool.set(constructor, [])), null === (_a = this.eventPool.get(constructor)) || void 0 === _a || _a.push(event);
7224
7257
  }
7225
7258
  notifyListeners(e, type) {
7226
7259
  const listeners = e.currentTarget._events[type];
@@ -9824,7 +9857,7 @@
9824
9857
  });
9825
9858
  }
9826
9859
  release() {
9827
- this.releaseStatus = "released", this.stopAnimates(), application.graphicService.onRelease(this);
9860
+ this.releaseStatus = "released", this.stopAnimates(), application.graphicService.onRelease(this), super.release();
9828
9861
  }
9829
9862
  _emitCustomEvent(type, context) {
9830
9863
  var _a, _b;
@@ -17330,12 +17363,12 @@
17330
17363
  throw new Error("暂不支持");
17331
17364
  }
17332
17365
  release() {
17333
- var _a, _b;
17366
+ var _a, _b, _d;
17334
17367
  super.release(), this.hooks.beforeRender.unTap("constructor", this.beforeRender), this.hooks.afterRender.unTap("constructor", this.afterRender), this.eventSystem && this.eventSystem.release(), this.layerService.releaseStage(this), this.pluginService.release(), this.forEach(layer => {
17335
17368
  layer.release();
17336
17369
  }), this.interactiveLayer && (this.interactiveLayer.forEachChildren(item => {
17337
17370
  item.setStage && item.setStage(null, null), this.interactiveLayer.removeChild(item);
17338
- }), this.interactiveLayer.release()), this.window.release(), null === (_a = this._ticker) || void 0 === _a || _a.remTimeline(null == this ? void 0 : this.timeline), null === (_b = this._ticker) || void 0 === _b || _b.removeListener("tick", this.afterTickCb), this.renderService.renderTreeRoots = [];
17371
+ }), this.interactiveLayer.release()), this.window.release(), null === (_a = this._ticker) || void 0 === _a || _a.remTimeline(null == this ? void 0 : this.timeline), null === (_b = this._ticker) || void 0 === _b || _b.removeListener("tick", this.afterTickCb), this.params.ticker || null === (_d = this._ticker) || void 0 === _d || _d.release(), this.renderService.renderTreeRoots = [];
17339
17372
  }
17340
17373
  setStage(stage) {}
17341
17374
  dirty(b, matrix) {
@@ -31994,7 +32027,7 @@
31994
32027
  });
31995
32028
  }
31996
32029
  clearVGlobalEvents() {
31997
- ("browser" === vglobal.env ? vglobal : this.stage).addEventListener("touchmove", this._handleTouchMove, {
32030
+ ("browser" === vglobal.env ? vglobal : this.stage).removeEventListener("touchmove", this._handleTouchMove, {
31998
32031
  passive: !1
31999
32032
  });
32000
32033
  }
@@ -33920,7 +33953,7 @@
33920
33953
  };
33921
33954
  }
33922
33955
  release(all) {
33923
- super.release(all), ("browser" === vglobal.env ? vglobal : this.stage).addEventListener("touchmove", this._handleTouchMove, {
33956
+ super.release(all), ("browser" === vglobal.env ? vglobal : this.stage).removeEventListener("touchmove", this._handleTouchMove, {
33924
33957
  passive: !1
33925
33958
  }), this._clearAllDragEvents();
33926
33959
  }
@@ -34861,500 +34894,6 @@
34861
34894
  registed || (registed = !0, preLoadAllModule(), isBrowserEnv() ? loadBrowserEnv(container) : isNodeEnv() && loadNodeEnv(container), registerArc(), registerCircle(), registerGroup(), registerImage(), registerLine(), registerRect(), registerRichtext(), registerShadowRoot(), registerSymbol(), registerText(), registerFlexLayoutPlugin(), loadPoptip(), registerFlexLayoutPlugin());
34862
34895
  }
34863
34896
 
34864
- function throttle$1(func, delay) {
34865
- let timer = null;
34866
- return function (...args) {
34867
- if (!timer) {
34868
- func.apply(this, args);
34869
- timer = setTimeout(() => {
34870
- timer = null;
34871
- }, delay);
34872
- }
34873
- };
34874
- }
34875
- function getTodayNearDay(dayOffset, format) {
34876
- const today = new Date();
34877
- const todayTime = today.getTime();
34878
- const oneDayTime = 24 * 60 * 60 * 1000;
34879
- const targetTime = todayTime + dayOffset * oneDayTime;
34880
- const date = new Date(targetTime);
34881
- if (format) {
34882
- const year = date.getFullYear().toString();
34883
- const month = (date.getMonth() + 1).toString().padStart(2, '0');
34884
- const day = date.getDate().toString().padStart(2, '0');
34885
- format = format.replace('yyyy', year);
34886
- format = format.replace('mm', month);
34887
- format = format.replace('dd', day);
34888
- return format;
34889
- }
34890
- return date;
34891
- }
34892
- function formatDate(date, format) {
34893
- const year = date.getFullYear().toString();
34894
- const month = (date.getMonth() + 1).toString().padStart(2, '0');
34895
- const day = date.getDate().toString().padStart(2, '0');
34896
- format = format.replace('yyyy', year);
34897
- format = format.replace('mm', month);
34898
- format = format.replace('dd', day);
34899
- if (format.length > 10) {
34900
- const hour = date.getHours().toString().padStart(2, '0');
34901
- const minute = date.getMinutes().toString().padStart(2, '0');
34902
- const second = date.getSeconds().toString().padStart(2, '0');
34903
- format = format.replace('hh', hour);
34904
- format = format.replace('mm', minute);
34905
- format = format.replace('ss', second);
34906
- }
34907
- return format;
34908
- }
34909
- function validateDate(dateParts, format) {
34910
- const yearIndex = format.indexOf('yyyy');
34911
- const monthIndex = format.indexOf('mm');
34912
- const dayIndex = format.indexOf('dd');
34913
- const dateYearIndex = yearIndex < monthIndex ? (yearIndex < dayIndex ? 0 : 1) : monthIndex < dayIndex ? 1 : 2;
34914
- const dateMonthIndex = monthIndex < yearIndex ? (monthIndex < dayIndex ? 0 : 1) : monthIndex < dayIndex ? 1 : 2;
34915
- const dateDayIndex = dayIndex < yearIndex ? (dayIndex < monthIndex ? 0 : 1) : dayIndex < monthIndex ? 1 : 2;
34916
- const year = parseInt(dateParts[dateYearIndex], 10);
34917
- const month = parseInt(dateParts[dateMonthIndex], 10) - 1;
34918
- const day = parseInt(dateParts[dateDayIndex], 10);
34919
- if (isNaN(year) || year < 1) {
34920
- return false;
34921
- }
34922
- if (isNaN(month) || month < 0 || month > 11) {
34923
- return false;
34924
- }
34925
- const daysInMonth = [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
34926
- if (isNaN(day) || day < 1 || day > daysInMonth[month]) {
34927
- return false;
34928
- }
34929
- return true;
34930
- }
34931
- function validateTime(dateParts, format) {
34932
- if (format.includes('hh') || format.includes('mm') || format.includes('ss')) {
34933
- const timeIndex = format.indexOf('hh') > -1 ? format.indexOf('hh') : format.indexOf('HH');
34934
- const hour = parseInt(dateParts[timeIndex], 10);
34935
- const minute = parseInt(dateParts[timeIndex + 1], 10);
34936
- const second = dateParts.length > timeIndex + 2 ? parseInt(dateParts[timeIndex + 2], 10) : 0;
34937
- if (isNaN(hour) || hour < 0 || hour > 23) {
34938
- return false;
34939
- }
34940
- if (isNaN(minute) || minute < 0 || minute > 59) {
34941
- return false;
34942
- }
34943
- if (isNaN(second) || second < 0 || second > 59) {
34944
- return false;
34945
- }
34946
- }
34947
- return true;
34948
- }
34949
- function isLeapYear(year) {
34950
- return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
34951
- }
34952
- function parseDateFormat(dateString) {
34953
- const formats = [
34954
- 'yyyy-mm-dd',
34955
- 'dd-mm-yyyy',
34956
- 'mm/dd/yyyy',
34957
- 'yyyy/mm/dd',
34958
- 'dd/mm/yyyy',
34959
- 'yyyy.mm.dd',
34960
- 'mm.dd.yyyy',
34961
- 'dd.mm.yyyy'
34962
- ];
34963
- const timeFormat = ['hh:mm:ss', 'hh:mm'];
34964
- dateString = dateString.trim();
34965
- const dates = dateString.split(' ');
34966
- const date = dates[0];
34967
- const time = dates[1];
34968
- let dateFormatMatched;
34969
- let timeFormatMatched;
34970
- if (date) {
34971
- for (let i = 0; i < formats.length; i++) {
34972
- const format = formats[i];
34973
- const dateParts = date.split(getSeparator(format));
34974
- const isValid = validateDate(dateParts, format);
34975
- if (dateParts.length === 3 && isValid) {
34976
- dateFormatMatched = format;
34977
- break;
34978
- }
34979
- }
34980
- }
34981
- if (dateFormatMatched) {
34982
- if (time) {
34983
- for (let i = 0; i < timeFormat.length; i++) {
34984
- const format = timeFormat[i];
34985
- const timeParts = time.split(getSeparator(format));
34986
- const formatParts = format.split(getSeparator(format));
34987
- const isValid = validateTime(timeParts, format);
34988
- if (isValid && timeParts.length === formatParts.length) {
34989
- timeFormatMatched = format;
34990
- break;
34991
- }
34992
- }
34993
- }
34994
- }
34995
- if (date && time && dateFormatMatched && timeFormatMatched) {
34996
- return dateFormatMatched + ' ' + timeFormatMatched;
34997
- }
34998
- if (date && !time) {
34999
- return dateFormatMatched;
35000
- }
35001
- return 'yyyy-mm-dd hh:mm:ss';
35002
- }
35003
- function getSeparator(format) {
35004
- const separators = format.match(/[^\w]/g);
35005
- if (separators) {
35006
- const escapedSeparators = separators.map(s => '\\' + s).join('|');
35007
- return new RegExp(escapedSeparators, 'g');
35008
- }
35009
- return /[^\w]/;
35010
- }
35011
- function parseStringTemplate(template, data) {
35012
- const result = template.replace(/\{([^}]+)\}/g, (match, key) => {
35013
- const keys = key.split('.');
35014
- let value = data;
35015
- for (const k of keys) {
35016
- if (value.hasOwnProperty(k)) {
35017
- value = value[k];
35018
- }
35019
- else {
35020
- value = match;
35021
- break;
35022
- }
35023
- }
35024
- return value;
35025
- });
35026
- return result;
35027
- }
35028
- function toBoxArray$2(obj) {
35029
- if (!Array.isArray(obj)) {
35030
- return [obj, obj, obj, obj];
35031
- }
35032
- if (obj.length === 3) {
35033
- return [obj[0], obj[1], obj[2], obj[1]];
35034
- }
35035
- if (obj.length === 2) {
35036
- return [obj[0], obj[1], obj[0], obj[1]];
35037
- }
35038
- if (obj.length === 1) {
35039
- return [obj[0], obj[0], obj[0], obj[0]];
35040
- }
35041
- return [obj[0], obj[1], obj[2], obj[3]];
35042
- }
35043
- function getWeekNumber(currentDate) {
35044
- const startOfYear = new Date(currentDate.getFullYear(), 0, 1);
35045
- const weekNumber = Math.ceil(((currentDate.getTime() + 1 - startOfYear.getTime()) / 86400000 + 1) / 7);
35046
- return weekNumber;
35047
- }
35048
- function getWeekday(dateString, format = 'long') {
35049
- const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
35050
- const date = new Date(dateString);
35051
- if (format === 'short') {
35052
- return days[date.getDay()].substr(0, 3);
35053
- }
35054
- else if (format === 'long') {
35055
- return days[date.getDay()];
35056
- }
35057
- return 'Invalid format specified. Please use "short" or "long".';
35058
- }
35059
- function isPropertyWritable(obj, prop) {
35060
- const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
35061
- if (!descriptor) {
35062
- return false;
35063
- }
35064
- return !!descriptor.set || descriptor.writable === true;
35065
- }
35066
- function createDateAtMidnight(dateStr, forceMidnight = false) {
35067
- let date;
35068
- if (dateStr) {
35069
- date = new Date(dateStr);
35070
- if (typeof dateStr === 'string') {
35071
- if (dateStr.length > 10) {
35072
- if (forceMidnight) {
35073
- date.setHours(0, 0, 0, 0);
35074
- }
35075
- return date;
35076
- }
35077
- date.setHours(0, 0, 0, 0);
35078
- }
35079
- }
35080
- else {
35081
- date = new Date();
35082
- }
35083
- if (forceMidnight) {
35084
- date.setHours(0, 0, 0, 0);
35085
- }
35086
- return date;
35087
- }
35088
- function createDateAtLastMinute(dateStr, forceSetMinute = false) {
35089
- let date;
35090
- if (dateStr) {
35091
- date = new Date(dateStr);
35092
- if (typeof dateStr === 'string') {
35093
- if (dateStr.length > 10) {
35094
- if (forceSetMinute) {
35095
- date.setMinutes(59, 59, 999);
35096
- }
35097
- return date;
35098
- }
35099
- date.setMinutes(59, 59, 999);
35100
- }
35101
- }
35102
- else {
35103
- date = new Date();
35104
- }
35105
- if (forceSetMinute) {
35106
- date.setMinutes(59, 59, 999);
35107
- }
35108
- return date;
35109
- }
35110
- function createDateAtLastSecond(dateStr, forceSetSecond = false) {
35111
- let date;
35112
- if (dateStr) {
35113
- date = new Date(dateStr);
35114
- if (typeof dateStr === 'string') {
35115
- if (dateStr.length > 10) {
35116
- if (forceSetSecond) {
35117
- date.setSeconds(59, 999);
35118
- }
35119
- return date;
35120
- }
35121
- date.setSeconds(59, 999);
35122
- }
35123
- }
35124
- else {
35125
- date = new Date();
35126
- }
35127
- if (forceSetSecond) {
35128
- date.setSeconds(59, 999);
35129
- }
35130
- return date;
35131
- }
35132
- function createDateAtLastMillisecond(dateStr, forceSetMillisecond = false) {
35133
- let date;
35134
- if (dateStr) {
35135
- date = new Date(dateStr);
35136
- if (typeof dateStr === 'string') {
35137
- if (dateStr.length > 10) {
35138
- if (forceSetMillisecond) {
35139
- date.setMilliseconds(999);
35140
- }
35141
- return date;
35142
- }
35143
- date.setMilliseconds(999);
35144
- }
35145
- }
35146
- else {
35147
- date = new Date();
35148
- }
35149
- if (forceSetMillisecond) {
35150
- date.setMilliseconds(999);
35151
- }
35152
- return date;
35153
- }
35154
- function createDateAtLastHour(dateStr, forceLastHour = false) {
35155
- let date;
35156
- if (dateStr) {
35157
- date = new Date(dateStr);
35158
- if (typeof dateStr === 'string') {
35159
- if (dateStr.length > 10) {
35160
- if (forceLastHour) {
35161
- date.setHours(23, 59, 59, 999);
35162
- }
35163
- return date;
35164
- }
35165
- date.setHours(23, 59, 59, 999);
35166
- }
35167
- }
35168
- else {
35169
- date = new Date();
35170
- }
35171
- if (forceLastHour) {
35172
- date.setHours(23, 59, 59, 999);
35173
- }
35174
- return date;
35175
- }
35176
- function getEndDateByTimeUnit(startDate, date, timeScale, step) {
35177
- let endDate = new Date(date);
35178
- switch (timeScale) {
35179
- case 'second':
35180
- endDate.setMilliseconds(999);
35181
- break;
35182
- case 'minute':
35183
- endDate.setSeconds(59, 999);
35184
- break;
35185
- case 'hour':
35186
- endDate.setMinutes(59, 59, 999);
35187
- break;
35188
- case 'day':
35189
- endDate.setHours(23, 59, 59, 999);
35190
- break;
35191
- case 'week':
35192
- const day = endDate.getDay();
35193
- const diffToEndOfWeek = 6 - day;
35194
- endDate.setDate(endDate.getDate() + diffToEndOfWeek);
35195
- endDate.setHours(23, 59, 59, 999);
35196
- break;
35197
- case 'month':
35198
- const lastDayOfMonth = new Date(endDate.getFullYear(), endDate.getMonth() + 1, 0).getDate();
35199
- endDate.setDate(lastDayOfMonth);
35200
- endDate.setHours(23, 59, 59, 999);
35201
- break;
35202
- case 'quarter':
35203
- const currentMonth = endDate.getMonth();
35204
- const endMonthOfQuarter = currentMonth - (currentMonth % 3) + 2;
35205
- const lastDayOfQuarter = new Date(endDate.getFullYear(), endMonthOfQuarter + 1, 0).getDate();
35206
- endDate.setMonth(endMonthOfQuarter, lastDayOfQuarter);
35207
- endDate.setHours(23, 59, 59, 999);
35208
- break;
35209
- case 'year':
35210
- endDate.setMonth(11, 31);
35211
- endDate.setHours(23, 59, 59, 999);
35212
- break;
35213
- default:
35214
- throw new Error('Invalid time scale');
35215
- }
35216
- const count = computeCountToTimeScale(endDate, startDate, timeScale, step, 1);
35217
- const targetCount = Math.ceil(count);
35218
- if (targetCount > count) {
35219
- const dif = (targetCount - count) * step;
35220
- const msInSecond = 1000;
35221
- const msInMinute = msInSecond * 60;
35222
- const msInHour = msInMinute * 60;
35223
- const msInDay = msInHour * 24;
35224
- const msInWeek = msInDay * 7;
35225
- new Date(endDate.getTime() + 1);
35226
- switch (timeScale) {
35227
- case 'second':
35228
- endDate.setTime(endDate.getTime() + dif * msInSecond);
35229
- break;
35230
- case 'minute':
35231
- endDate.setTime(endDate.getTime() + dif * msInMinute);
35232
- break;
35233
- case 'hour':
35234
- endDate.setTime(endDate.getTime() + dif * msInHour);
35235
- break;
35236
- case 'day':
35237
- endDate.setTime(endDate.getTime() + dif * msInDay);
35238
- break;
35239
- case 'week':
35240
- endDate.setTime(endDate.getTime() + dif * msInWeek);
35241
- break;
35242
- case 'month':
35243
- endDate = new Date(endDate.getFullYear(), endDate.getMonth() + 1 + Math.round(dif), 0);
35244
- endDate.setHours(23, 59, 59, 999);
35245
- break;
35246
- case 'quarter':
35247
- const currentMonth = endDate.getMonth();
35248
- const endMonthOfQuarter = currentMonth - (currentMonth % 3) + 2;
35249
- endDate = new Date(endDate.getFullYear(), endMonthOfQuarter + Math.round(dif * 3) + 1, 0);
35250
- endDate.setHours(23, 59, 59, 999);
35251
- break;
35252
- case 'year':
35253
- endDate.setFullYear(endDate.getFullYear() + Math.floor(dif));
35254
- endDate.setHours(23, 59, 59, 999);
35255
- break;
35256
- default:
35257
- throw new Error('Invalid time scale');
35258
- }
35259
- }
35260
- return endDate;
35261
- }
35262
- function getStartDateByTimeUnit(date, timeScale, startOfWeekSetting = 'monday') {
35263
- const startDate = new Date(date);
35264
- switch (timeScale) {
35265
- case 'second':
35266
- startDate.setMilliseconds(0);
35267
- break;
35268
- case 'minute':
35269
- startDate.setSeconds(0, 0);
35270
- break;
35271
- case 'hour':
35272
- startDate.setMinutes(0, 0, 0);
35273
- break;
35274
- case 'day':
35275
- startDate.setHours(0, 0, 0, 0);
35276
- break;
35277
- case 'week':
35278
- const day = startDate.getDay();
35279
- let diffToStartOfWeek = day;
35280
- if (startOfWeekSetting === 'monday') {
35281
- diffToStartOfWeek = day === 0 ? -6 : 1 - day;
35282
- }
35283
- else {
35284
- diffToStartOfWeek = -day;
35285
- }
35286
- startDate.setDate(startDate.getDate() + diffToStartOfWeek);
35287
- startDate.setHours(0, 0, 0, 0);
35288
- break;
35289
- case 'month':
35290
- startDate.setDate(1);
35291
- startDate.setHours(0, 0, 0, 0);
35292
- break;
35293
- case 'quarter':
35294
- const currentMonth = startDate.getMonth();
35295
- const startMonthOfQuarter = currentMonth - (currentMonth % 3);
35296
- startDate.setMonth(startMonthOfQuarter, 1);
35297
- startDate.setHours(0, 0, 0, 0);
35298
- break;
35299
- case 'year':
35300
- startDate.setMonth(0, 1);
35301
- startDate.setHours(0, 0, 0, 0);
35302
- break;
35303
- default:
35304
- throw new Error('Invalid time scale');
35305
- }
35306
- return startDate;
35307
- }
35308
- function computeCountToTimeScale(date, startDate, timeScale, step, diffMS = 0) {
35309
- const msInSecond = 1000;
35310
- const msInMinute = msInSecond * 60;
35311
- const msInHour = msInMinute * 60;
35312
- const msInDay = msInHour * 24;
35313
- const msInWeek = msInDay * 7;
35314
- let difference;
35315
- const adjusted_date = new Date(date.getTime() + diffMS);
35316
- switch (timeScale) {
35317
- case 'second':
35318
- difference = (adjusted_date.getTime() - startDate.getTime()) / msInSecond;
35319
- break;
35320
- case 'minute':
35321
- difference = (adjusted_date.getTime() - startDate.getTime()) / msInMinute;
35322
- break;
35323
- case 'hour':
35324
- difference = (adjusted_date.getTime() - startDate.getTime()) / msInHour;
35325
- break;
35326
- case 'day':
35327
- difference = (adjusted_date.getTime() - startDate.getTime()) / msInDay;
35328
- break;
35329
- case 'week':
35330
- difference = (adjusted_date.getTime() - startDate.getTime()) / msInWeek;
35331
- break;
35332
- case 'month':
35333
- const startDaysInMonth = new Date(startDate.getFullYear(), startDate.getMonth() + 1, 0).getDate();
35334
- const adjustedDaysInMonth = new Date(adjusted_date.getFullYear(), adjusted_date.getMonth() + 1, 0).getDate();
35335
- difference =
35336
- (adjusted_date.getFullYear() - startDate.getFullYear()) * 12 +
35337
- (adjusted_date.getMonth() - startDate.getMonth());
35338
- difference += adjusted_date.getDate() / adjustedDaysInMonth - startDate.getDate() / startDaysInMonth;
35339
- break;
35340
- case 'quarter':
35341
- difference =
35342
- (adjusted_date.getFullYear() - startDate.getFullYear()) * 4 +
35343
- (adjusted_date.getMonth() - startDate.getMonth()) / 3;
35344
- difference +=
35345
- (adjusted_date.getDate() - startDate.getDate()) /
35346
- (3 * new Date(adjusted_date.getFullYear(), adjusted_date.getMonth() + 1, 0).getDate());
35347
- break;
35348
- case 'year':
35349
- difference = adjusted_date.getFullYear() - startDate.getFullYear();
35350
- difference += (adjusted_date.getMonth() - startDate.getMonth()) / 12;
35351
- break;
35352
- default:
35353
- throw new Error('Invalid time scale');
35354
- }
35355
- return difference / step;
35356
- }
35357
-
35358
34897
  class Grid {
35359
34898
  gridStyle;
35360
34899
  scrollLeft;
@@ -35435,9 +34974,7 @@
35435
34974
  this.verticalLineGroup.name = 'grid-vertical';
35436
34975
  this.group.appendChild(this.verticalLineGroup);
35437
34976
  const dependenceOnTimeScale = this._scene._gantt.parsedOptions.reverseSortedTimelineScales.find(scale => scale.unit === verticalLineDependenceOnTimeScale) ?? this._scene._gantt.parsedOptions.reverseSortedTimelineScales[0];
35438
- const { unit: minUnit, step } = this._scene._gantt.parsedOptions.reverseSortedTimelineScales[0];
35439
34977
  const { timelineDates } = dependenceOnTimeScale;
35440
- const timelineColWidth = this._scene._gantt.parsedOptions.timelineColWidth;
35441
34978
  if (typeof gridStyle.verticalLine === 'function') {
35442
34979
  for (let i = 0; i < timelineDates?.length - 1; i++) {
35443
34980
  const { endDate } = timelineDates[i];
@@ -35447,8 +34984,8 @@
35447
34984
  date: timelineDates[i].endDate,
35448
34985
  ganttInstance: this._scene._gantt
35449
34986
  });
35450
- const x = Math.ceil(computeCountToTimeScale(endDate, this._scene._gantt.parsedOptions.minDate, minUnit, step, 1) *
35451
- timelineColWidth) + (verticalLine_style.lineWidth & 1 ? 0.5 : 0);
34987
+ const x = Math.ceil(this._scene._gantt.getXByTime(endDate.getTime() + 1)) +
34988
+ (verticalLine_style.lineWidth & 1 ? 0.5 : 0);
35452
34989
  const line = createLine({
35453
34990
  pickable: false,
35454
34991
  stroke: verticalLine_style.lineColor,
@@ -35466,8 +35003,8 @@
35466
35003
  const verticalLine_style = gridStyle.verticalLine;
35467
35004
  for (let i = 0; i < timelineDates?.length - 1; i++) {
35468
35005
  const { endDate } = timelineDates[i];
35469
- const x = Math.ceil(computeCountToTimeScale(endDate, this._scene._gantt.parsedOptions.minDate, minUnit, step, 1) *
35470
- timelineColWidth) + (verticalLine_style.lineWidth & 1 ? 0.5 : 0);
35006
+ const x = Math.ceil(this._scene._gantt.getXByTime(endDate.getTime() + 1)) +
35007
+ (verticalLine_style.lineWidth & 1 ? 0.5 : 0);
35471
35008
  const line = createLine({
35472
35009
  pickable: false,
35473
35010
  stroke: verticalLine_style.lineColor,
@@ -35551,7 +35088,6 @@
35551
35088
  this.verticalBackgroundRectsGroup.name = 'grid-vertical-background';
35552
35089
  this.group.appendChild(this.verticalBackgroundRectsGroup);
35553
35090
  const { timelineDates, unit, step } = this._scene._gantt.parsedOptions.reverseSortedTimelineScales[0];
35554
- const timelineColWidth = this._scene._gantt.parsedOptions.timelineColWidth;
35555
35091
  if (verticalBackgroundColor || weekendBackgroundColor) {
35556
35092
  for (let i = 0; i <= timelineDates?.length - 1; i++) {
35557
35093
  let backgroundColor;
@@ -35573,13 +35109,14 @@
35573
35109
  backgroundColor = verticalBackgroundColor[i % verticalBackgroundColor.length];
35574
35110
  }
35575
35111
  if (backgroundColor) {
35576
- const x = Math.ceil(timelineColWidth * i);
35112
+ const x = i >= 1 ? Math.ceil(this._scene._gantt.getDateColsWidth(0, i - 1)) : 0;
35113
+ const width = this._scene._gantt.getDateColWidth(i);
35577
35114
  const rect = createRect({
35578
35115
  pickable: false,
35579
35116
  fill: backgroundColor,
35580
35117
  x,
35581
35118
  y: 0,
35582
- width: timelineColWidth,
35119
+ width,
35583
35120
  height: this.allGridHeight
35584
35121
  });
35585
35122
  this.verticalBackgroundRectsGroup.appendChild(rect);
@@ -35954,6 +35491,500 @@
35954
35491
  }
35955
35492
  }
35956
35493
 
35494
+ function throttle$1(func, delay) {
35495
+ let timer = null;
35496
+ return function (...args) {
35497
+ if (!timer) {
35498
+ func.apply(this, args);
35499
+ timer = setTimeout(() => {
35500
+ timer = null;
35501
+ }, delay);
35502
+ }
35503
+ };
35504
+ }
35505
+ function getTodayNearDay(dayOffset, format) {
35506
+ const today = new Date();
35507
+ const todayTime = today.getTime();
35508
+ const oneDayTime = 24 * 60 * 60 * 1000;
35509
+ const targetTime = todayTime + dayOffset * oneDayTime;
35510
+ const date = new Date(targetTime);
35511
+ if (format) {
35512
+ const year = date.getFullYear().toString();
35513
+ const month = (date.getMonth() + 1).toString().padStart(2, '0');
35514
+ const day = date.getDate().toString().padStart(2, '0');
35515
+ format = format.replace('yyyy', year);
35516
+ format = format.replace('mm', month);
35517
+ format = format.replace('dd', day);
35518
+ return format;
35519
+ }
35520
+ return date;
35521
+ }
35522
+ function formatDate(date, format) {
35523
+ const year = date.getFullYear().toString();
35524
+ const month = (date.getMonth() + 1).toString().padStart(2, '0');
35525
+ const day = date.getDate().toString().padStart(2, '0');
35526
+ format = format.replace('yyyy', year);
35527
+ format = format.replace('mm', month);
35528
+ format = format.replace('dd', day);
35529
+ if (format.length > 10) {
35530
+ const hour = date.getHours().toString().padStart(2, '0');
35531
+ const minute = date.getMinutes().toString().padStart(2, '0');
35532
+ const second = date.getSeconds().toString().padStart(2, '0');
35533
+ format = format.replace('hh', hour);
35534
+ format = format.replace('mm', minute);
35535
+ format = format.replace('ss', second);
35536
+ }
35537
+ return format;
35538
+ }
35539
+ function validateDate(dateParts, format) {
35540
+ const yearIndex = format.indexOf('yyyy');
35541
+ const monthIndex = format.indexOf('mm');
35542
+ const dayIndex = format.indexOf('dd');
35543
+ const dateYearIndex = yearIndex < monthIndex ? (yearIndex < dayIndex ? 0 : 1) : monthIndex < dayIndex ? 1 : 2;
35544
+ const dateMonthIndex = monthIndex < yearIndex ? (monthIndex < dayIndex ? 0 : 1) : monthIndex < dayIndex ? 1 : 2;
35545
+ const dateDayIndex = dayIndex < yearIndex ? (dayIndex < monthIndex ? 0 : 1) : dayIndex < monthIndex ? 1 : 2;
35546
+ const year = parseInt(dateParts[dateYearIndex], 10);
35547
+ const month = parseInt(dateParts[dateMonthIndex], 10) - 1;
35548
+ const day = parseInt(dateParts[dateDayIndex], 10);
35549
+ if (isNaN(year) || year < 1) {
35550
+ return false;
35551
+ }
35552
+ if (isNaN(month) || month < 0 || month > 11) {
35553
+ return false;
35554
+ }
35555
+ const daysInMonth = [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
35556
+ if (isNaN(day) || day < 1 || day > daysInMonth[month]) {
35557
+ return false;
35558
+ }
35559
+ return true;
35560
+ }
35561
+ function validateTime(dateParts, format) {
35562
+ if (format.includes('hh') || format.includes('mm') || format.includes('ss')) {
35563
+ const timeIndex = format.indexOf('hh') > -1 ? format.indexOf('hh') : format.indexOf('HH');
35564
+ const hour = parseInt(dateParts[timeIndex], 10);
35565
+ const minute = parseInt(dateParts[timeIndex + 1], 10);
35566
+ const second = dateParts.length > timeIndex + 2 ? parseInt(dateParts[timeIndex + 2], 10) : 0;
35567
+ if (isNaN(hour) || hour < 0 || hour > 23) {
35568
+ return false;
35569
+ }
35570
+ if (isNaN(minute) || minute < 0 || minute > 59) {
35571
+ return false;
35572
+ }
35573
+ if (isNaN(second) || second < 0 || second > 59) {
35574
+ return false;
35575
+ }
35576
+ }
35577
+ return true;
35578
+ }
35579
+ function isLeapYear(year) {
35580
+ return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
35581
+ }
35582
+ function parseDateFormat(dateString) {
35583
+ const formats = [
35584
+ 'yyyy-mm-dd',
35585
+ 'dd-mm-yyyy',
35586
+ 'mm/dd/yyyy',
35587
+ 'yyyy/mm/dd',
35588
+ 'dd/mm/yyyy',
35589
+ 'yyyy.mm.dd',
35590
+ 'mm.dd.yyyy',
35591
+ 'dd.mm.yyyy'
35592
+ ];
35593
+ const timeFormat = ['hh:mm:ss', 'hh:mm'];
35594
+ dateString = dateString.trim();
35595
+ const dates = dateString.split(' ');
35596
+ const date = dates[0];
35597
+ const time = dates[1];
35598
+ let dateFormatMatched;
35599
+ let timeFormatMatched;
35600
+ if (date) {
35601
+ for (let i = 0; i < formats.length; i++) {
35602
+ const format = formats[i];
35603
+ const dateParts = date.split(getSeparator(format));
35604
+ const isValid = validateDate(dateParts, format);
35605
+ if (dateParts.length === 3 && isValid) {
35606
+ dateFormatMatched = format;
35607
+ break;
35608
+ }
35609
+ }
35610
+ }
35611
+ if (dateFormatMatched) {
35612
+ if (time) {
35613
+ for (let i = 0; i < timeFormat.length; i++) {
35614
+ const format = timeFormat[i];
35615
+ const timeParts = time.split(getSeparator(format));
35616
+ const formatParts = format.split(getSeparator(format));
35617
+ const isValid = validateTime(timeParts, format);
35618
+ if (isValid && timeParts.length === formatParts.length) {
35619
+ timeFormatMatched = format;
35620
+ break;
35621
+ }
35622
+ }
35623
+ }
35624
+ }
35625
+ if (date && time && dateFormatMatched && timeFormatMatched) {
35626
+ return dateFormatMatched + ' ' + timeFormatMatched;
35627
+ }
35628
+ if (date && !time) {
35629
+ return dateFormatMatched;
35630
+ }
35631
+ return 'yyyy-mm-dd hh:mm:ss';
35632
+ }
35633
+ function getSeparator(format) {
35634
+ const separators = format.match(/[^\w]/g);
35635
+ if (separators) {
35636
+ const escapedSeparators = separators.map(s => '\\' + s).join('|');
35637
+ return new RegExp(escapedSeparators, 'g');
35638
+ }
35639
+ return /[^\w]/;
35640
+ }
35641
+ function parseStringTemplate(template, data) {
35642
+ const result = template.replace(/\{([^}]+)\}/g, (match, key) => {
35643
+ const keys = key.split('.');
35644
+ let value = data;
35645
+ for (const k of keys) {
35646
+ if (value.hasOwnProperty(k)) {
35647
+ value = value[k];
35648
+ }
35649
+ else {
35650
+ value = match;
35651
+ break;
35652
+ }
35653
+ }
35654
+ return value;
35655
+ });
35656
+ return result;
35657
+ }
35658
+ function toBoxArray$2(obj) {
35659
+ if (!Array.isArray(obj)) {
35660
+ return [obj, obj, obj, obj];
35661
+ }
35662
+ if (obj.length === 3) {
35663
+ return [obj[0], obj[1], obj[2], obj[1]];
35664
+ }
35665
+ if (obj.length === 2) {
35666
+ return [obj[0], obj[1], obj[0], obj[1]];
35667
+ }
35668
+ if (obj.length === 1) {
35669
+ return [obj[0], obj[0], obj[0], obj[0]];
35670
+ }
35671
+ return [obj[0], obj[1], obj[2], obj[3]];
35672
+ }
35673
+ function getWeekNumber(currentDate) {
35674
+ const startOfYear = new Date(currentDate.getFullYear(), 0, 1);
35675
+ const weekNumber = Math.ceil(((currentDate.getTime() + 1 - startOfYear.getTime()) / 86400000 + 1) / 7);
35676
+ return weekNumber;
35677
+ }
35678
+ function getWeekday(dateString, format = 'long') {
35679
+ const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
35680
+ const date = new Date(dateString);
35681
+ if (format === 'short') {
35682
+ return days[date.getDay()].substr(0, 3);
35683
+ }
35684
+ else if (format === 'long') {
35685
+ return days[date.getDay()];
35686
+ }
35687
+ return 'Invalid format specified. Please use "short" or "long".';
35688
+ }
35689
+ function isPropertyWritable(obj, prop) {
35690
+ const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
35691
+ if (!descriptor) {
35692
+ return false;
35693
+ }
35694
+ return !!descriptor.set || descriptor.writable === true;
35695
+ }
35696
+ function createDateAtMidnight(dateStr, forceMidnight = false) {
35697
+ let date;
35698
+ if (dateStr) {
35699
+ date = new Date(dateStr);
35700
+ if (typeof dateStr === 'string') {
35701
+ if (dateStr.length > 10) {
35702
+ if (forceMidnight) {
35703
+ date.setHours(0, 0, 0, 0);
35704
+ }
35705
+ return date;
35706
+ }
35707
+ date.setHours(0, 0, 0, 0);
35708
+ }
35709
+ }
35710
+ else {
35711
+ date = new Date();
35712
+ }
35713
+ if (forceMidnight) {
35714
+ date.setHours(0, 0, 0, 0);
35715
+ }
35716
+ return date;
35717
+ }
35718
+ function createDateAtLastMinute(dateStr, forceSetMinute = false) {
35719
+ let date;
35720
+ if (dateStr) {
35721
+ date = new Date(dateStr);
35722
+ if (typeof dateStr === 'string') {
35723
+ if (dateStr.length > 10) {
35724
+ if (forceSetMinute) {
35725
+ date.setMinutes(59, 59, 999);
35726
+ }
35727
+ return date;
35728
+ }
35729
+ date.setMinutes(59, 59, 999);
35730
+ }
35731
+ }
35732
+ else {
35733
+ date = new Date();
35734
+ }
35735
+ if (forceSetMinute) {
35736
+ date.setMinutes(59, 59, 999);
35737
+ }
35738
+ return date;
35739
+ }
35740
+ function createDateAtLastSecond(dateStr, forceSetSecond = false) {
35741
+ let date;
35742
+ if (dateStr) {
35743
+ date = new Date(dateStr);
35744
+ if (typeof dateStr === 'string') {
35745
+ if (dateStr.length > 10) {
35746
+ if (forceSetSecond) {
35747
+ date.setSeconds(59, 999);
35748
+ }
35749
+ return date;
35750
+ }
35751
+ date.setSeconds(59, 999);
35752
+ }
35753
+ }
35754
+ else {
35755
+ date = new Date();
35756
+ }
35757
+ if (forceSetSecond) {
35758
+ date.setSeconds(59, 999);
35759
+ }
35760
+ return date;
35761
+ }
35762
+ function createDateAtLastMillisecond(dateStr, forceSetMillisecond = false) {
35763
+ let date;
35764
+ if (dateStr) {
35765
+ date = new Date(dateStr);
35766
+ if (typeof dateStr === 'string') {
35767
+ if (dateStr.length > 10) {
35768
+ if (forceSetMillisecond) {
35769
+ date.setMilliseconds(999);
35770
+ }
35771
+ return date;
35772
+ }
35773
+ date.setMilliseconds(999);
35774
+ }
35775
+ }
35776
+ else {
35777
+ date = new Date();
35778
+ }
35779
+ if (forceSetMillisecond) {
35780
+ date.setMilliseconds(999);
35781
+ }
35782
+ return date;
35783
+ }
35784
+ function createDateAtLastHour(dateStr, forceLastHour = false) {
35785
+ let date;
35786
+ if (dateStr) {
35787
+ date = new Date(dateStr);
35788
+ if (typeof dateStr === 'string') {
35789
+ if (dateStr.length > 10) {
35790
+ if (forceLastHour) {
35791
+ date.setHours(23, 59, 59, 999);
35792
+ }
35793
+ return date;
35794
+ }
35795
+ date.setHours(23, 59, 59, 999);
35796
+ }
35797
+ }
35798
+ else {
35799
+ date = new Date();
35800
+ }
35801
+ if (forceLastHour) {
35802
+ date.setHours(23, 59, 59, 999);
35803
+ }
35804
+ return date;
35805
+ }
35806
+ function getEndDateByTimeUnit(startDate, date, timeScale, step) {
35807
+ let endDate = new Date(date);
35808
+ switch (timeScale) {
35809
+ case 'second':
35810
+ endDate.setMilliseconds(999);
35811
+ break;
35812
+ case 'minute':
35813
+ endDate.setSeconds(59, 999);
35814
+ break;
35815
+ case 'hour':
35816
+ endDate.setMinutes(59, 59, 999);
35817
+ break;
35818
+ case 'day':
35819
+ endDate.setHours(23, 59, 59, 999);
35820
+ break;
35821
+ case 'week':
35822
+ const day = endDate.getDay();
35823
+ const diffToEndOfWeek = 6 - day;
35824
+ endDate.setDate(endDate.getDate() + diffToEndOfWeek);
35825
+ endDate.setHours(23, 59, 59, 999);
35826
+ break;
35827
+ case 'month':
35828
+ const lastDayOfMonth = new Date(endDate.getFullYear(), endDate.getMonth() + 1, 0).getDate();
35829
+ endDate.setDate(lastDayOfMonth);
35830
+ endDate.setHours(23, 59, 59, 999);
35831
+ break;
35832
+ case 'quarter':
35833
+ const currentMonth = endDate.getMonth();
35834
+ const endMonthOfQuarter = currentMonth - (currentMonth % 3) + 2;
35835
+ const lastDayOfQuarter = new Date(endDate.getFullYear(), endMonthOfQuarter + 1, 0).getDate();
35836
+ endDate.setMonth(endMonthOfQuarter, lastDayOfQuarter);
35837
+ endDate.setHours(23, 59, 59, 999);
35838
+ break;
35839
+ case 'year':
35840
+ endDate.setMonth(11, 31);
35841
+ endDate.setHours(23, 59, 59, 999);
35842
+ break;
35843
+ default:
35844
+ throw new Error('Invalid time scale');
35845
+ }
35846
+ const count = computeCountToTimeScale(endDate, startDate, timeScale, step, 1);
35847
+ const targetCount = Math.ceil(count);
35848
+ if (targetCount > count) {
35849
+ const dif = (targetCount - count) * step;
35850
+ const msInSecond = 1000;
35851
+ const msInMinute = msInSecond * 60;
35852
+ const msInHour = msInMinute * 60;
35853
+ const msInDay = msInHour * 24;
35854
+ const msInWeek = msInDay * 7;
35855
+ new Date(endDate.getTime() + 1);
35856
+ switch (timeScale) {
35857
+ case 'second':
35858
+ endDate.setTime(endDate.getTime() + dif * msInSecond);
35859
+ break;
35860
+ case 'minute':
35861
+ endDate.setTime(endDate.getTime() + dif * msInMinute);
35862
+ break;
35863
+ case 'hour':
35864
+ endDate.setTime(endDate.getTime() + dif * msInHour);
35865
+ break;
35866
+ case 'day':
35867
+ endDate.setTime(endDate.getTime() + dif * msInDay);
35868
+ break;
35869
+ case 'week':
35870
+ endDate.setTime(endDate.getTime() + dif * msInWeek);
35871
+ break;
35872
+ case 'month':
35873
+ endDate = new Date(endDate.getFullYear(), endDate.getMonth() + 1 + Math.round(dif), 0);
35874
+ endDate.setHours(23, 59, 59, 999);
35875
+ break;
35876
+ case 'quarter':
35877
+ const currentMonth = endDate.getMonth();
35878
+ const endMonthOfQuarter = currentMonth - (currentMonth % 3) + 2;
35879
+ endDate = new Date(endDate.getFullYear(), endMonthOfQuarter + Math.round(dif * 3) + 1, 0);
35880
+ endDate.setHours(23, 59, 59, 999);
35881
+ break;
35882
+ case 'year':
35883
+ endDate.setFullYear(endDate.getFullYear() + Math.floor(dif));
35884
+ endDate.setHours(23, 59, 59, 999);
35885
+ break;
35886
+ default:
35887
+ throw new Error('Invalid time scale');
35888
+ }
35889
+ }
35890
+ return endDate;
35891
+ }
35892
+ function getStartDateByTimeUnit(date, timeScale, startOfWeekSetting = 'monday') {
35893
+ const startDate = new Date(date);
35894
+ switch (timeScale) {
35895
+ case 'second':
35896
+ startDate.setMilliseconds(0);
35897
+ break;
35898
+ case 'minute':
35899
+ startDate.setSeconds(0, 0);
35900
+ break;
35901
+ case 'hour':
35902
+ startDate.setMinutes(0, 0, 0);
35903
+ break;
35904
+ case 'day':
35905
+ startDate.setHours(0, 0, 0, 0);
35906
+ break;
35907
+ case 'week':
35908
+ const day = startDate.getDay();
35909
+ let diffToStartOfWeek = day;
35910
+ if (startOfWeekSetting === 'monday') {
35911
+ diffToStartOfWeek = day === 0 ? -6 : 1 - day;
35912
+ }
35913
+ else {
35914
+ diffToStartOfWeek = -day;
35915
+ }
35916
+ startDate.setDate(startDate.getDate() + diffToStartOfWeek);
35917
+ startDate.setHours(0, 0, 0, 0);
35918
+ break;
35919
+ case 'month':
35920
+ startDate.setDate(1);
35921
+ startDate.setHours(0, 0, 0, 0);
35922
+ break;
35923
+ case 'quarter':
35924
+ const currentMonth = startDate.getMonth();
35925
+ const startMonthOfQuarter = currentMonth - (currentMonth % 3);
35926
+ startDate.setMonth(startMonthOfQuarter, 1);
35927
+ startDate.setHours(0, 0, 0, 0);
35928
+ break;
35929
+ case 'year':
35930
+ startDate.setMonth(0, 1);
35931
+ startDate.setHours(0, 0, 0, 0);
35932
+ break;
35933
+ default:
35934
+ throw new Error('Invalid time scale');
35935
+ }
35936
+ return startDate;
35937
+ }
35938
+ function computeCountToTimeScale(date, startDate, timeScale, step, diffMS = 0) {
35939
+ const msInSecond = 1000;
35940
+ const msInMinute = msInSecond * 60;
35941
+ const msInHour = msInMinute * 60;
35942
+ const msInDay = msInHour * 24;
35943
+ const msInWeek = msInDay * 7;
35944
+ let difference;
35945
+ const adjusted_date = new Date(date.getTime() + diffMS);
35946
+ switch (timeScale) {
35947
+ case 'second':
35948
+ difference = (adjusted_date.getTime() - startDate.getTime()) / msInSecond;
35949
+ break;
35950
+ case 'minute':
35951
+ difference = (adjusted_date.getTime() - startDate.getTime()) / msInMinute;
35952
+ break;
35953
+ case 'hour':
35954
+ difference = (adjusted_date.getTime() - startDate.getTime()) / msInHour;
35955
+ break;
35956
+ case 'day':
35957
+ difference = (adjusted_date.getTime() - startDate.getTime()) / msInDay;
35958
+ break;
35959
+ case 'week':
35960
+ difference = (adjusted_date.getTime() - startDate.getTime()) / msInWeek;
35961
+ break;
35962
+ case 'month':
35963
+ const startDaysInMonth = new Date(startDate.getFullYear(), startDate.getMonth() + 1, 0).getDate();
35964
+ const adjustedDaysInMonth = new Date(adjusted_date.getFullYear(), adjusted_date.getMonth() + 1, 0).getDate();
35965
+ difference =
35966
+ (adjusted_date.getFullYear() - startDate.getFullYear()) * 12 +
35967
+ (adjusted_date.getMonth() - startDate.getMonth());
35968
+ difference += adjusted_date.getDate() / adjustedDaysInMonth - startDate.getDate() / startDaysInMonth;
35969
+ break;
35970
+ case 'quarter':
35971
+ difference =
35972
+ (adjusted_date.getFullYear() - startDate.getFullYear()) * 4 +
35973
+ (adjusted_date.getMonth() - startDate.getMonth()) / 3;
35974
+ difference +=
35975
+ (adjusted_date.getDate() - startDate.getDate()) /
35976
+ (3 * new Date(adjusted_date.getFullYear(), adjusted_date.getMonth() + 1, 0).getDate());
35977
+ break;
35978
+ case 'year':
35979
+ difference = adjusted_date.getFullYear() - startDate.getFullYear();
35980
+ difference += (adjusted_date.getMonth() - startDate.getMonth()) / 12;
35981
+ break;
35982
+ default:
35983
+ throw new Error('Invalid time scale');
35984
+ }
35985
+ return difference / step;
35986
+ }
35987
+
35957
35988
  function handleWhell$1(event, state, gantt, isWheelEvent = true) {
35958
35989
  let { deltaX, deltaY } = event;
35959
35990
  if (event.ctrlKey) {
@@ -36133,16 +36164,20 @@
36133
36164
  fontFamily: 'Arial',
36134
36165
  fontSize: 14
36135
36166
  };
36167
+ const defaultBaselineStyle = {
36168
+ barColor: '#d3d3d3',
36169
+ completedBarColor: '#a9a9a9',
36170
+ width: 20,
36171
+ cornerRadius: 3,
36172
+ borderWidth: 0
36173
+ };
36136
36174
  function setWidthToDefaultTaskBarStyle(width) {
36137
36175
  defaultTaskBarStyle.width = width;
36138
36176
  }
36139
36177
  const isNode$1 = typeof window === 'undefined' || typeof window.window === 'undefined';
36140
36178
  const DayTimes = 1000 * 60 * 60 * 24;
36141
36179
  function getDateIndexByX(x, gantt) {
36142
- const totalX = x + gantt.stateManager.scroll.horizontalBarPos;
36143
- const firstDateColWidth = gantt.getDateColWidth(0);
36144
- const dateIndex = Math.floor((totalX - firstDateColWidth) / gantt.parsedOptions.timelineColWidth) + 1;
36145
- return dateIndex;
36180
+ return gantt.getDateIndexByX(x);
36146
36181
  }
36147
36182
  function generateMarkLine(markLine) {
36148
36183
  if (!markLine) {
@@ -36216,6 +36251,9 @@
36216
36251
  gantt.parsedOptions.startDateField = options.taskBar?.startDateField ?? 'startDate';
36217
36252
  gantt.parsedOptions.endDateField = options.taskBar?.endDateField ?? 'endDate';
36218
36253
  gantt.parsedOptions.progressField = options.taskBar?.progressField ?? 'progress';
36254
+ gantt.parsedOptions.baselineStartDateField = options.taskBar?.baselineStartDateField;
36255
+ gantt.parsedOptions.baselineEndDateField = options.taskBar?.baselineEndDateField;
36256
+ gantt.parsedOptions.baselinePosition = options.taskBar?.baselinePosition ?? 'bottom';
36219
36257
  gantt.parsedOptions.taskBarClip = options?.taskBar?.clip ?? true;
36220
36258
  gantt.parsedOptions.projectSubTasksExpandable = options?.projectSubTasksExpandable ?? true;
36221
36259
  const { unit: minTimeUnit, startOfWeek, step } = gantt.parsedOptions.reverseSortedTimelineScales[0];
@@ -36268,6 +36306,10 @@
36268
36306
  : options?.taskBar?.projectStyle
36269
36307
  ? Object.assign({}, defaultTaskBarStyle, options?.taskBar?.projectStyle)
36270
36308
  : gantt.parsedOptions.taskBarStyle;
36309
+ gantt.parsedOptions.baselineStyle =
36310
+ options?.taskBar?.baselineStyle && typeof options?.taskBar?.baselineStyle === 'function'
36311
+ ? options.taskBar.baselineStyle
36312
+ : Object.assign({}, defaultBaselineStyle, options?.taskBar?.baselineStyle);
36271
36313
  const defaultMilestoneStyle = {
36272
36314
  labelTextStyle: {
36273
36315
  fontSize: 16,
@@ -37050,7 +37092,6 @@
37050
37092
  this.group = dateHeader;
37051
37093
  dateHeader.name = 'date-header-container';
37052
37094
  scene.ganttGroup.addChild(this.group);
37053
- const { unit: minUnit, step } = scene._gantt.parsedOptions.reverseSortedTimelineScales[0];
37054
37095
  let y = 0;
37055
37096
  for (let i = 0; i < scene._gantt.timeLineHeaderLevel; i++) {
37056
37097
  const { timelineDates, customLayout, visible } = scene._gantt.parsedOptions.sortedTimelineScales[i];
@@ -37069,10 +37110,8 @@
37069
37110
  dateHeader.addChild(rowHeader);
37070
37111
  for (let j = 0; j < timelineDates?.length; j++) {
37071
37112
  const { days, endDate, startDate, title, dateIndex, unit } = timelineDates[j];
37072
- const x = Math.ceil(computeCountToTimeScale(startDate, scene._gantt.parsedOptions.minDate, minUnit, step) *
37073
- scene._gantt.parsedOptions.timelineColWidth);
37074
- const right_x = Math.ceil(computeCountToTimeScale(endDate, scene._gantt.parsedOptions.minDate, minUnit, step, 1) *
37075
- scene._gantt.parsedOptions.timelineColWidth);
37113
+ const x = Math.ceil(scene._gantt.getXByTime(startDate.getTime()));
37114
+ const right_x = Math.ceil(scene._gantt.getXByTime(endDate.getTime() + 1));
37076
37115
  const width = right_x - x;
37077
37116
  const date = new Group$2({
37078
37117
  x,
@@ -37714,6 +37753,7 @@
37714
37753
  };
37715
37754
  }
37716
37755
  on(type, listener) {
37756
+ if (!this.listenersData) return;
37717
37757
  const list = this.listenersData.listeners[type] || (this.listenersData.listeners[type] = []);
37718
37758
  list.push(listener);
37719
37759
  const id = idCount$3++;
@@ -37721,9 +37761,10 @@
37721
37761
  type: type,
37722
37762
  listener: listener,
37723
37763
  remove: () => {
37764
+ if (!this.listenersData) return;
37724
37765
  delete this.listenersData.listenerData[id];
37725
37766
  const index = list.indexOf(listener);
37726
- list.splice(index, 1), this.listenersData.listeners[type].length || delete this.listenersData.listeners[type];
37767
+ list.splice(index, 1), this.listenersData.listeners[type] && !this.listenersData.listeners[type].length && delete this.listenersData.listeners[type];
37727
37768
  }
37728
37769
  }, id;
37729
37770
  }
@@ -38725,6 +38766,8 @@
38725
38766
  RESIZE_COLUMN_END: "resize_column_end",
38726
38767
  RESIZE_ROW: "resize_row",
38727
38768
  RESIZE_ROW_END: "resize_row_end",
38769
+ MERGE_CELLS: "merge_cells",
38770
+ UNMERGE_CELLS: "unmerge_cells",
38728
38771
  CHANGE_HEADER_POSITION_START: "change_header_position_start",
38729
38772
  CHANGE_HEADER_POSITION: "change_header_position",
38730
38773
  CHANGING_HEADER_POSITION: "changing_header_position",
@@ -41218,7 +41261,7 @@
41218
41261
  }
41219
41262
  clearFilteredChildren(record) {
41220
41263
  var _a, _b;
41221
- record.filteredChildren = void 0;
41264
+ record.filteredChildren = void 0, delete record.filteredChildren;
41222
41265
  for (let i = 0; i < (null !== (_b = null === (_a = record.children) || void 0 === _a ? void 0 : _a.length) && void 0 !== _b ? _b : 0); i++) this.clearFilteredChildren(record.children[i]);
41223
41266
  }
41224
41267
  filterRecord(record) {
@@ -41321,8 +41364,9 @@
41321
41364
  fieldPromiseCallBack(_index, _field, _value) {}
41322
41365
  recordPromiseCallBack(_index, _record) {}
41323
41366
  canChangeOrder(sourceIndex, targetIndex) {
41324
- var _a;
41367
+ var _a, _b;
41325
41368
  if (null === (_a = this.dataSourceObj) || void 0 === _a ? void 0 : _a.canChangeOrder) return this.dataSourceObj.canChangeOrder(sourceIndex, targetIndex);
41369
+ if (null === (_b = this.lastSortStates) || void 0 === _b ? void 0 : _b.some(state => "asc" === state.order || "desc" === state.order)) return !1;
41326
41370
  if (this.hasHierarchyStateExpand) {
41327
41371
  let sourceIndexs = this.currentPagerIndexedData[sourceIndex],
41328
41372
  targetIndexs = this.currentPagerIndexedData[targetIndex];
@@ -45325,7 +45369,7 @@
45325
45369
  function updateCell$1(col, row, table, addNew, isShadow, forceFastUpdate) {
45326
45370
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
45327
45371
  const oldCellGroup = table.scenegraph.highPerformanceGetCell(col, row, !0);
45328
- if ("cell" !== oldCellGroup.role && !addNew) return;
45372
+ if ("cell" !== oldCellGroup.role && "shadow-cell" !== oldCellGroup.role && !addNew) return;
45329
45373
  const cellLocation = table.getCellLocation(col, row);
45330
45374
  let isMerge,
45331
45375
  range,
@@ -52775,7 +52819,7 @@
52775
52819
  }), scene.tableGroup.role = "table";
52776
52820
  const colHeaderGroup = createContainerGroup(0, 0, !scene.table.internalProps.enableTreeStickCell);
52777
52821
  colHeaderGroup.role = "col-header", scene.colHeaderGroup = colHeaderGroup;
52778
- const cornerHeaderGroup = createContainerGroup(0, 0, !scene.table.options.enableTreeStickCell);
52822
+ const cornerHeaderGroup = createContainerGroup(0, 0, !scene.table.internalProps.enableTreeStickCell);
52779
52823
  cornerHeaderGroup.role = "corner-header", scene.cornerHeaderGroup = cornerHeaderGroup;
52780
52824
  const rowHeaderGroup = createContainerGroup(0, 0, !0);
52781
52825
  rowHeaderGroup.role = "row-header", scene.rowHeaderGroup = rowHeaderGroup;
@@ -55573,13 +55617,13 @@
55573
55617
  setSortState(sortState) {
55574
55618
  const state = this;
55575
55619
  const sort = (sortState = !sortState || Array.isArray(sortState) ? sortState : [sortState]) && sortState.reduce((prev, item) => {
55576
- var _a, _b, _c;
55620
+ var _a, _b, _c, _d, _e;
55577
55621
  const column = null === (_a = function (columns) {
55578
55622
  const result = [];
55579
55623
  return function flatten(cols, parentStartIndex = 0) {
55580
55624
  cols.forEach(col => {
55581
55625
  var _a;
55582
- const startIndex = col.startInTotal ? null !== (_a = col.startInTotal + state.table.internalProps.layoutMap.leftRowSeriesNumberColumnCount) && void 0 !== _a ? _a : 0 : parentStartIndex;
55626
+ const startIndex = col.startInTotal ? col.startInTotal + (null !== (_a = state.table.internalProps.layoutMap.leftRowSeriesNumberColumnCount) && void 0 !== _a ? _a : 0) : parentStartIndex;
55583
55627
  col.columns ? flatten(col.columns, startIndex) : result.push(Object.assign(Object.assign({}, col), {
55584
55628
  startIndex: startIndex
55585
55629
  }));
@@ -55589,12 +55633,12 @@
55589
55633
  return this.table.internalProps.transpose ? prev.push({
55590
55634
  field: item.field,
55591
55635
  order: item.order,
55592
- row: null !== (_b = (null == column ? void 0 : column.startInTotal) + this.table.internalProps.layoutMap.leftRowSeriesNumberColumnCount) && void 0 !== _b ? _b : 0,
55636
+ row: (null !== (_b = null == column ? void 0 : column.startInTotal) && void 0 !== _b ? _b : 0) + (null !== (_c = this.table.internalProps.layoutMap.leftRowSeriesNumberColumnCount) && void 0 !== _c ? _c : 0),
55593
55637
  col: null == column ? void 0 : column.level
55594
55638
  }) : prev.push({
55595
55639
  field: item.field,
55596
55640
  order: item.order,
55597
- col: null !== (_c = (null == column ? void 0 : column.startInTotal) + this.table.internalProps.layoutMap.leftRowSeriesNumberColumnCount) && void 0 !== _c ? _c : 0,
55641
+ col: (null !== (_d = null == column ? void 0 : column.startInTotal) && void 0 !== _d ? _d : 0) + (null !== (_e = this.table.internalProps.layoutMap.leftRowSeriesNumberColumnCount) && void 0 !== _e ? _e : 0),
55598
55642
  row: null == column ? void 0 : column.level
55599
55643
  }), prev;
55600
55644
  }, []);
@@ -56106,13 +56150,16 @@
56106
56150
  this.select.selectInline = selectInline;
56107
56151
  }
56108
56152
  updateSortState(sortState) {
56109
- var _a, _b, _c, _d, _e, _f, _g, _h;
56110
- sortState = Array.isArray(sortState) ? sortState : [sortState];
56153
+ var _a, _b, _c, _d, _e, _f, _g;
56154
+ const isSame = (sortState = Array.isArray(sortState) ? sortState : [sortState]).length === this.sort.length && sortState.every((item, index) => {
56155
+ var _a, _b;
56156
+ return (null == item ? void 0 : item.field) === (null === (_a = this.sort[index]) || void 0 === _a ? void 0 : _a.field) && (null == item ? void 0 : item.order) === (null === (_b = this.sort[index]) || void 0 === _b ? void 0 : _b.order);
56157
+ });
56158
+ if (isSame) return;
56111
56159
  for (let index = 0; index < sortState.length; index++) {
56112
- if (sortState[index].field === (null === (_a = this.sort[index]) || void 0 === _a ? void 0 : _a.field) && sortState[sortState.length - 1].order === (null === (_b = this.sort[index]) || void 0 === _b ? void 0 : _b.order)) return;
56113
- const oldSortCol = this.table.internalProps.multipleSort ? null : (null === (_c = this.sort[index]) || void 0 === _c ? void 0 : _c.col) || null,
56114
- oldSortRow = this.table.internalProps.multipleSort ? null : (null === (_d = this.sort[index]) || void 0 === _d ? void 0 : _d.row) || null;
56115
- "asc" === (null === (_e = this.sort[index]) || void 0 === _e ? void 0 : _e.order) || null === (_f = this.sort[index]) || void 0 === _f || _f.order;
56160
+ const oldSortCol = this.table.internalProps.multipleSort ? null : (null === (_a = this.sort[index]) || void 0 === _a ? void 0 : _a.col) || null,
56161
+ oldSortRow = this.table.internalProps.multipleSort ? null : (null === (_b = this.sort[index]) || void 0 === _b ? void 0 : _b.row) || null;
56162
+ "asc" === (null === (_c = this.sort[index]) || void 0 === _c ? void 0 : _c.order) || null === (_d = this.sort[index]) || void 0 === _d || _d.order;
56116
56163
  this.setSortState(sortState.slice(0, index + 1));
56117
56164
  const cellAddress = this.table.internalProps.layoutMap.getHeaderCellAddressByField(sortState[index].field);
56118
56165
  this.sort[index].col = cellAddress.col, this.sort[index].row = cellAddress.row;
@@ -56125,7 +56172,7 @@
56125
56172
  order: this.sort[index].order,
56126
56173
  oldSortCol: oldSortCol,
56127
56174
  oldSortRow: oldSortRow,
56128
- oldIconMark: null === (_g = this.sort[index]) || void 0 === _g ? void 0 : _g.icon
56175
+ oldIconMark: null === (_e = this.sort[index]) || void 0 === _e ? void 0 : _e.icon
56129
56176
  });
56130
56177
  }
56131
56178
  const normalHeaders = [];
@@ -56139,7 +56186,7 @@
56139
56186
  row: null,
56140
56187
  iconMark: null,
56141
56188
  order: null,
56142
- oldSortCol: null !== (_h = column.startInTotal + this.table.internalProps.layoutMap.leftRowSeriesNumberColumnCount) && void 0 !== _h ? _h : 0,
56189
+ oldSortCol: (null !== (_f = column.startInTotal) && void 0 !== _f ? _f : 0) + (null !== (_g = this.table.internalProps.layoutMap.leftRowSeriesNumberColumnCount) && void 0 !== _g ? _g : 0),
56143
56190
  oldSortRow: column.level,
56144
56191
  oldIconMark: null
56145
56192
  });
@@ -60392,7 +60439,7 @@
60392
60439
  }
60393
60440
  constructor(container, options = {}) {
60394
60441
  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;
60395
- if (super(), this.showFrozenIcon = !0, this._tableBorderWidth_left = 0, this._tableBorderWidth_right = 0, this._tableBorderWidth_top = 0, this._tableBorderWidth_bottom = 0, this.version = "1.23.3-alpha.0", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), "node" === Env.mode ? (options = container, container = null) : container instanceof HTMLElement || (options = container, container = container.container ? container.container : null), !container && "node" !== options.mode && !options.canvas) throw new Error("vtable's container is undefined");
60442
+ if (super(), this.showFrozenIcon = !0, this._scrollToRowCorrectTimer = null, this._tableBorderWidth_left = 0, this._tableBorderWidth_right = 0, this._tableBorderWidth_top = 0, this._tableBorderWidth_bottom = 0, this.version = "1.24.0", this.id = `VTable${Date.now()}`, this.isReleased = !1, this._chartEventMap = {}, this.throttleInvalidate = throttle2(this.render.bind(this), 200), "node" === Env.mode ? (options = container, container = null) : container instanceof HTMLElement || (options = container, container = container.container ? container.container : null), !container && "node" !== options.mode && !options.canvas) throw new Error("vtable's container is undefined");
60396
60443
  this.pluginManager = new PluginManager$1(this, options), this.fireListeners(TABLE_EVENT_TYPE.BEFORE_INIT, {
60397
60444
  options: options,
60398
60445
  container: container
@@ -61330,12 +61377,15 @@
61330
61377
  dispose() {
61331
61378
  this.release();
61332
61379
  }
61380
+ clearCorrectTimer() {
61381
+ this._scrollToRowCorrectTimer && (clearTimeout(this._scrollToRowCorrectTimer), this._scrollToRowCorrectTimer = null);
61382
+ }
61333
61383
  release() {
61334
61384
  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;
61335
61385
  null === (_c = null === (_b = null === (_a = this.scenegraph) || void 0 === _a ? void 0 : _a.component) || void 0 === _b ? void 0 : _b.vScrollBar) || void 0 === _c || _c.release(), null === (_f = null === (_e = null === (_d = this.scenegraph) || void 0 === _d ? void 0 : _d.component) || void 0 === _e ? void 0 : _e.hScrollBar) || void 0 === _f || _f.release(), this.animationManager.clear(), this.animationManager.ticker.release(), null === (_j = null === (_h = null === (_g = this.scenegraph) || void 0 === _g ? void 0 : _g.stage) || void 0 === _h ? void 0 : _h.ticker) || void 0 === _j || _j.release();
61336
61386
  const internalProps = this.internalProps;
61337
61387
  if (this.isReleased) return;
61338
- null === (_l = null === (_k = internalProps.tooltipHandler) || void 0 === _k ? void 0 : _k.release) || void 0 === _l || _l.call(_k), null === (_o = null === (_m = internalProps.menuHandler) || void 0 === _m ? void 0 : _m.release) || void 0 === _o || _o.call(_m), null === (_p = super.release) || void 0 === _p || _p.call(this), this.pluginManager.release(), null === (_r = null === (_q = internalProps.handler) || void 0 === _q ? void 0 : _q.release) || void 0 === _r || _r.call(_q), this.eventManager.release(), null === (_t = null === (_s = internalProps.focusControl) || void 0 === _s ? void 0 : _s.release) || void 0 === _t || _t.call(_s), null === (_u = internalProps.legends) || void 0 === _u || _u.forEach(legend => {
61388
+ this.clearCorrectTimer(), null === (_l = null === (_k = internalProps.tooltipHandler) || void 0 === _k ? void 0 : _k.release) || void 0 === _l || _l.call(_k), null === (_o = null === (_m = internalProps.menuHandler) || void 0 === _m ? void 0 : _m.release) || void 0 === _o || _o.call(_m), null === (_p = super.release) || void 0 === _p || _p.call(this), this.pluginManager.release(), null === (_r = null === (_q = internalProps.handler) || void 0 === _q ? void 0 : _q.release) || void 0 === _r || _r.call(_q), this.eventManager.release(), null === (_t = null === (_s = internalProps.focusControl) || void 0 === _s ? void 0 : _s.release) || void 0 === _t || _t.call(_s), null === (_u = internalProps.legends) || void 0 === _u || _u.forEach(legend => {
61339
61389
  null == legend || legend.release();
61340
61390
  }), null === (_v = internalProps.title) || void 0 === _v || _v.release(), internalProps.title = null, null === (_w = internalProps.emptyTip) || void 0 === _w || _w.release(), internalProps.emptyTip = null, internalProps.layoutMap.release(), internalProps.releaseList && (internalProps.releaseList.forEach(releaseObj => {
61341
61391
  var _a;
@@ -61640,6 +61690,30 @@
61640
61690
  lastSelectRange = currentSelectRanges[currentSelectRanges.length - 1];
61641
61691
  lastSelectRange && (lastSelectRange.end.row = rowIndex), this.stateManager.updateSelectPos(this.colCount - 1, rowIndex, !1, isCtrl, !1, makeSelectCellVisible, !0), this.stateManager.select.selecting = !1;
61642
61692
  }
61693
+ changeHeaderPosition(args) {
61694
+ var _a, _b, _c, _d, _e;
61695
+ if (!("canMoveHeaderPosition" in this.internalProps.layoutMap) || !0 === (null === (_a = this.options.customConfig) || void 0 === _a ? void 0 : _a.notUpdateInColumnRowMove)) return !1;
61696
+ const prevMoving = this.stateManager.columnMove.movingColumnOrRow;
61697
+ this.stateManager.columnMove.movingColumnOrRow = args.movingColumnOrRow;
61698
+ try {
61699
+ if (!1 === (null === (_c = (_b = this.internalProps.layoutMap).canMoveHeaderPosition) || void 0 === _c ? void 0 : _c.call(_b, args.source, args.target))) return !1;
61700
+ const oldSourceMergeInfo = this.getCellRange(args.source.col, args.source.row),
61701
+ oldTargetMergeInfo = this.getCellRange(args.target.col, args.target.row),
61702
+ moveContext = this._moveHeaderPosition(args.source, args.target);
61703
+ if (!moveContext || moveContext.targetIndex === moveContext.sourceIndex) return !1;
61704
+ this.internalProps.useOneRowHeightFillAll = !1, this.internalProps.layoutMap.clearCellRangeMap();
61705
+ const sourceMergeInfo = this.getCellRange(args.source.col, args.source.row),
61706
+ targetMergeInfo = this.getCellRange(args.target.col, args.target.row),
61707
+ colMin = Math.min(sourceMergeInfo.start.col, targetMergeInfo.start.col, oldSourceMergeInfo.start.col, oldTargetMergeInfo.start.col),
61708
+ colMax = Math.max(sourceMergeInfo.end.col, targetMergeInfo.end.col, oldSourceMergeInfo.end.col, oldTargetMergeInfo.end.col),
61709
+ rowMin = Math.min(sourceMergeInfo.start.row, targetMergeInfo.start.row, oldSourceMergeInfo.start.row, oldTargetMergeInfo.start.row);
61710
+ let rowMax = Math.max(sourceMergeInfo.end.row, targetMergeInfo.end.row, oldSourceMergeInfo.end.row, oldTargetMergeInfo.end.row);
61711
+ if ("row" === moveContext.moveType && "tree" === this.internalProps.layoutMap.rowHierarchyType && (rowMax = moveContext.targetIndex > moveContext.sourceIndex ? rowMax + moveContext.targetSize - 1 : rowMax + moveContext.sourceSize - 1), this.transpose || !this.isSeriesNumberInBody(args.source.col, args.source.row) && "row" !== args.movingColumnOrRow || (this.changeRecordOrder(moveContext.sourceIndex, moveContext.targetIndex), this.stateManager.changeCheckboxAndRadioOrder(moveContext.sourceIndex, moveContext.targetIndex)), "column" === moveContext.moveType) for (let col = colMin; col <= colMax; col++) this._clearColRangeWidthsMap(col);else for (let row = rowMin; row <= rowMax; row++) this._clearRowRangeHeightsMap(row);
61712
+ return this.clearCellStyleCache(), this.isSeriesNumberInBody(args.source.col, args.source.row) || "row" === args.movingColumnOrRow ? this.scenegraph.updateHeaderPosition(this.scenegraph.proxy.colStart, this.scenegraph.proxy.colEnd, this.scenegraph.proxy.rowStart, this.scenegraph.proxy.rowEnd, moveContext.moveType) : "column" === moveContext.moveType ? this.scenegraph.updateHeaderPosition(colMin, colMax, 0, -1, moveContext.moveType) : this.scenegraph.updateHeaderPosition(0, -1, rowMin, rowMax, moveContext.moveType), "adjustFrozenCount" === this.internalProps.frozenColDragHeaderMode && this.isListTable() && (this.isLeftFrozenColumn(args.target.col) && !this.isLeftFrozenColumn(args.source.col) ? this.frozenColCount += sourceMergeInfo.end.col - sourceMergeInfo.start.col + 1 : this.isLeftFrozenColumn(args.source.col) && !this.isLeftFrozenColumn(args.target.col) && (this.frozenColCount -= sourceMergeInfo.end.col - sourceMergeInfo.start.col + 1), this.isRightFrozenColumn(args.target.col) && !this.isRightFrozenColumn(args.source.col) ? this.rightFrozenColCount += sourceMergeInfo.end.col - sourceMergeInfo.start.col + 1 : this.isRightFrozenColumn(args.source.col) && !this.isRightFrozenColumn(args.target.col) && (this.rightFrozenColCount -= sourceMergeInfo.end.col - sourceMergeInfo.start.col + 1)), null === (_e = (_d = this.scenegraph).updateNextFrame) || void 0 === _e || _e.call(_d), !0;
61713
+ } finally {
61714
+ this.stateManager.columnMove.movingColumnOrRow = prevMoving;
61715
+ }
61716
+ }
61643
61717
  get recordsCount() {
61644
61718
  var _a;
61645
61719
  return null === (_a = this.records) || void 0 === _a ? void 0 : _a.length;
@@ -61785,7 +61859,7 @@
61785
61859
  getCustomMerge(col, row) {
61786
61860
  if (this.internalProps.customMergeCell) {
61787
61861
  const customMerge = this.internalProps.customMergeCell(col, row, this);
61788
- if (customMerge && customMerge.range && (isValid$1(customMerge.text) || customMerge.customLayout || this.customRender)) {
61862
+ if (customMerge && customMerge.range) {
61789
61863
  if (customMerge.style) {
61790
61864
  const styleClass = this.internalProps.bodyHelper.getStyleClass("text"),
61791
61865
  style = customMerge.style,
@@ -62496,12 +62570,34 @@
62496
62570
  this.eventManager.enableScroll();
62497
62571
  }
62498
62572
  getGroupTitleLevel(col, row) {}
62573
+ getTargetScrollTop(row) {
62574
+ const drawRange = this.getDrawRange(),
62575
+ frozenHeight = this.getFrozenRowsHeight();
62576
+ return Math.max(0, Math.min(this.getRowsHeight(0, row - 1) - frozenHeight, this.getAllRowsHeight() - drawRange.height));
62577
+ }
62578
+ _scheduleScrollToRowCorrect(row, delay = 0) {
62579
+ this._scrollToRowCorrectTimer = setTimeout(() => {
62580
+ this.clearCorrectTimer();
62581
+ const targetScrollTop = this.getTargetScrollTop(row);
62582
+ if (targetScrollTop !== this.scrollTop) {
62583
+ this.scrollTop = targetScrollTop;
62584
+ const correctedTargetScrollTop = this.getTargetScrollTop(row);
62585
+ correctedTargetScrollTop !== this.scrollTop && (this.scrollTop = correctedTargetScrollTop);
62586
+ }
62587
+ }, delay);
62588
+ }
62499
62589
  scrollToRow(row, animationOption) {
62500
- animationOption ? this.animationManager.scrollTo({
62501
- row: row
62502
- }, animationOption) : this.scrollToCell({
62503
- row: row
62504
- });
62590
+ var _a;
62591
+ const targetRow = Math.min(Math.max(Math.floor(row), 0), this.rowCount - 1);
62592
+ if (this.clearCorrectTimer(), !animationOption) return this.scrollToCell({
62593
+ row: targetRow
62594
+ }), void this._scheduleScrollToRowCorrect(targetRow);
62595
+ const duration = isBoolean$2(animationOption) ? 3e3 : null !== (_a = null == animationOption ? void 0 : animationOption.duration) && void 0 !== _a ? _a : 3e3;
62596
+ this.animationManager.scrollTo({
62597
+ row: targetRow
62598
+ }, animationOption), this._scrollToRowCorrectTimer = setTimeout(() => {
62599
+ this.scrollToRow(targetRow, !1);
62600
+ }, duration);
62505
62601
  }
62506
62602
  scrollToCol(col, animationOption) {
62507
62603
  animationOption ? this.animationManager.scrollTo({
@@ -62520,8 +62616,8 @@
62520
62616
  }
62521
62617
  if (isValid$1(cellAddr.row) && cellAddr.row >= this.frozenRowCount) {
62522
62618
  const frozenHeight = this.getFrozenRowsHeight(),
62523
- top = this.getRowsHeight(0, cellAddr.row - 1);
62524
- this.scrollTop = Math.min(top - frozenHeight, this.getAllRowsHeight() - drawRange.height);
62619
+ top = this.rowHeightsMap.getSumInRange(0, cellAddr.row - 1);
62620
+ this.scrollTop = Math.min(top - frozenHeight, this.rowHeightsMap.getSumInRange(0, this.rowCount - 1) - drawRange.height);
62525
62621
  }
62526
62622
  this.render();
62527
62623
  }
@@ -63169,9 +63265,24 @@
63169
63265
  return layout._cellRangeMap.set(`$${col}$${row}`, cellRange), cellRange;
63170
63266
  }
63171
63267
  function getTreeTitleMerge(col, row, cellRange, layout) {
63268
+ var _a;
63172
63269
  if ("tree" !== layout.rowHierarchyType) return;
63173
- const cellRecord = layout._table.getCellRawRecord(col, row);
63174
- layout._table.internalProps.groupTitleCheckbox && layout._table.internalProps.rowSeriesNumber ? (null == cellRecord ? void 0 : cellRecord.vtableMerge) && col >= layout.leftRowSeriesNumberColumnCount && (cellRange.start.col = layout.rowHeaderLevelCount + layout.leftRowSeriesNumberColumnCount, cellRange.end.col = layout.colCount - 1, cellRange.start.row = cellRange.end.row = row) : (null == cellRecord ? void 0 : cellRecord.vtableMerge) && (cellRange.start.col = layout.rowHeaderLevelCount, cellRange.end.col = layout.colCount - 1, cellRange.start.row = cellRange.end.row = row);
63270
+ const table = layout._table,
63271
+ internalProps = table.internalProps || {},
63272
+ isGroupMode = !!internalProps.groupBy,
63273
+ cellRecord = table.getCellRawRecord(col, row);
63274
+ if (!(null == cellRecord ? void 0 : cellRecord.vtableMerge)) return;
63275
+ const treeTitleStartCol = internalProps.groupTitleCheckbox && internalProps.rowSeriesNumber ? layout.rowHeaderLevelCount + layout.leftRowSeriesNumberColumnCount : layout.rowHeaderLevelCount;
63276
+ if (!(col < treeTitleStartCol) && (cellRange.start.col = treeTitleStartCol, cellRange.end.col = layout.colCount - 1, cellRange.start.row = cellRange.end.row = row, isGroupMode && 1 === (null === (_a = layout.columnObjects) || void 0 === _a ? void 0 : _a.length))) {
63277
+ const onlyColumn = layout.columnObjects[0],
63278
+ field = null == onlyColumn ? void 0 : onlyColumn.field;
63279
+ if (null != field) {
63280
+ let text = cellRecord.vtableMergeName;
63281
+ const groupTitleFieldFormat = internalProps.groupTitleFieldFormat;
63282
+ "function" == typeof groupTitleFieldFormat && (text = groupTitleFieldFormat(cellRecord, col, row, table));
63283
+ null == cellRecord[field] && null != text && (cellRecord[field] = text);
63284
+ }
63285
+ }
63175
63286
  }
63176
63287
  function getCellRangeTranspose(col, row, layout) {
63177
63288
  var _a, _b, _c, _d;
@@ -64088,7 +64199,7 @@
64088
64199
  this.listenersId.push(doubleClickEventId, clickEventId, selectedChangedEventId);
64089
64200
  }
64090
64201
  startEditCell(col, row, value, editElement) {
64091
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
64202
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
64092
64203
  if (this.editingEditor) return;
64093
64204
  const editor = this.table.getEditor(col, row);
64094
64205
  if (editor) {
@@ -64104,7 +64215,8 @@
64104
64215
  col: col,
64105
64216
  row: row
64106
64217
  }), this.table._makeVisibleCell(col, row), this.editingEditor = editor;
64107
- const dataValue = isValid$1(value) ? value : this.table.getCellOriginValue(col, row),
64218
+ const customMergeText = null === (_j = this.table.getCustomMerge(col, row)) || void 0 === _j ? void 0 : _j.text,
64219
+ dataValue = isValid$1(value) ? value : isValid$1(customMergeText) ? customMergeText : this.table.getCellOriginValue(col, row),
64108
64220
  rect = this.table.getCellRangeRelativeRect(this.table.getCellRange(col, row)),
64109
64221
  referencePosition = {
64110
64222
  rect: {
@@ -64114,9 +64226,9 @@
64114
64226
  height: rect.height
64115
64227
  }
64116
64228
  };
64117
- col === this.table.colCount - 1 ? referencePosition.rect.width = rect.width - 1 : referencePosition.rect.width = rect.width + 1, row === this.table.rowCount - 1 ? referencePosition.rect.height = rect.height - 1 : referencePosition.rect.height = rect.height + 1, editor.beginEditing, null === (_j = editor.beginEditing) || void 0 === _j || _j.call(editor, this.table.getElement(), referencePosition, dataValue), editor.bindSuccessCallback, null === (_k = editor.bindSuccessCallback) || void 0 === _k || _k.call(editor, () => {
64229
+ col === this.table.colCount - 1 ? referencePosition.rect.width = rect.width - 1 : referencePosition.rect.width = rect.width + 1, row === this.table.rowCount - 1 ? referencePosition.rect.height = rect.height - 1 : referencePosition.rect.height = rect.height + 1, editor.beginEditing, null === (_k = editor.beginEditing) || void 0 === _k || _k.call(editor, this.table.getElement(), referencePosition, dataValue), editor.bindSuccessCallback, null === (_l = editor.bindSuccessCallback) || void 0 === _l || _l.call(editor, () => {
64118
64230
  this.completeEdit();
64119
- }), null === (_l = editor.onStart) || void 0 === _l || _l.call(editor, {
64231
+ }), null === (_m = editor.onStart) || void 0 === _m || _m.call(editor, {
64120
64232
  value: dataValue,
64121
64233
  endEdit: () => {
64122
64234
  this.completeEdit();
@@ -64130,7 +64242,7 @@
64130
64242
  }
64131
64243
  }
64132
64244
  completeEdit(e) {
64133
- var _a, _b;
64245
+ var _a, _b, _c;
64134
64246
  if (!this.editingEditor) return !0;
64135
64247
  if (this.isValidatingValue) return !1;
64136
64248
  this.cacheLastSelectedCellEditor = {};
@@ -64144,9 +64256,10 @@
64144
64256
  if (this.editingEditor.getValue, this.editingEditor.validateValue) {
64145
64257
  this.isValidatingValue = !0;
64146
64258
  const newValue = this.editingEditor.getValue(),
64147
- oldValue = this.table.getCellOriginValue(this.editCell.col, this.editCell.row),
64259
+ customMergeText = null === (_a = this.table.getCustomMerge(this.editCell.col, this.editCell.row)) || void 0 === _a ? void 0 : _a.text,
64260
+ oldValue = isValid$1(customMergeText) ? customMergeText : this.table.getCellOriginValue(this.editCell.col, this.editCell.row),
64148
64261
  target = null == e ? void 0 : e.target,
64149
- maybePromiseOrValue = null === (_b = (_a = this.editingEditor).validateValue) || void 0 === _b ? void 0 : _b.call(_a, newValue, oldValue, this.editCell, this.table, !!this.table.getElement().contains(target));
64262
+ maybePromiseOrValue = null === (_c = (_b = this.editingEditor).validateValue) || void 0 === _c ? void 0 : _c.call(_b, newValue, oldValue, this.editCell, this.table, !!this.table.getElement().contains(target));
64150
64263
  return isPromise(maybePromiseOrValue) ? (this.isValidatingValue = !0, new Promise((resolve, reject) => {
64151
64264
  maybePromiseOrValue.then(result => {
64152
64265
  dealWithValidateValue(result, this, oldValue, resolve);
@@ -64160,18 +64273,24 @@
64160
64273
  doExit() {
64161
64274
  var _a, _b, _c, _d, _e, _f, _g, _h;
64162
64275
  const changedValue = null === (_b = (_a = this.editingEditor).getValue) || void 0 === _b ? void 0 : _b.call(_a),
64163
- range = this.table.getCellRange(this.editCell.col, this.editCell.row),
64164
- changedValues = [];
64165
- for (let row = range.start.row; row <= range.end.row; row++) {
64166
- const rowChangedValues = [];
64167
- for (let col = range.start.col; col <= range.end.col; col++) rowChangedValues.push(changedValue);
64168
- changedValues.push(rowChangedValues);
64276
+ range = this.table.getCellRange(this.editCell.col, this.editCell.row);
64277
+ if (null === (_d = (_c = this.editingEditor).beforeEnd) || void 0 === _d || _d.call(_c), range.isCustom) this.table.changeCellValue(range.start.col, range.start.row, changedValue);else {
64278
+ const changedValues = [];
64279
+ for (let row = range.start.row; row <= range.end.row; row++) {
64280
+ const rowChangedValues = [];
64281
+ for (let col = range.start.col; col <= range.end.col; col++) rowChangedValues.push(changedValue);
64282
+ changedValues.push(rowChangedValues);
64283
+ }
64284
+ this.table.changeCellValues(range.start.col, range.start.row, changedValues);
64169
64285
  }
64170
- null === (_d = (_c = this.editingEditor).beforeEnd) || void 0 === _d || _d.call(_c), this.table.changeCellValues(range.start.col, range.start.row, changedValues), this.editingEditor.exit, null === (_f = (_e = this.editingEditor).exit) || void 0 === _f || _f.call(_e), null === (_h = (_g = this.editingEditor).onEnd) || void 0 === _h || _h.call(_g), this.editingEditor = null, this.isValidatingValue = !1, this.beginTriggerEditCellMode = null;
64286
+ this.editingEditor.exit, null === (_f = (_e = this.editingEditor).exit) || void 0 === _f || _f.call(_e), null === (_h = (_g = this.editingEditor).onEnd) || void 0 === _h || _h.call(_g), this.editingEditor = null, this.isValidatingValue = !1, this.beginTriggerEditCellMode = null;
64171
64287
  }
64172
64288
  cancelEdit() {
64173
64289
  var _a, _b, _c, _d;
64174
- this.editingEditor && (null === (_b = (_a = this.editingEditor).exit) || void 0 === _b || _b.call(_a), null === (_d = (_c = this.editingEditor).onEnd) || void 0 === _d || _d.call(_c), this.editingEditor = null);
64290
+ this.editingEditor && (null === (_b = (_a = this.editingEditor).exit) || void 0 === _b || _b.call(_a), null === (_d = (_c = this.editingEditor).onEnd) || void 0 === _d || _d.call(_c), this.editingEditor = null), Object.values(this.cacheLastSelectedCellEditor).forEach(editor => {
64291
+ var _a;
64292
+ return null === (_a = null == editor ? void 0 : editor.onEnd) || void 0 === _a ? void 0 : _a.call(editor);
64293
+ }), this.cacheLastSelectedCellEditor = {};
64175
64294
  }
64176
64295
  release() {
64177
64296
  this.listenersId.forEach(id => {
@@ -64224,7 +64343,18 @@
64224
64343
  step((generator = generator.apply(thisArg, _arguments || [])).next());
64225
64344
  });
64226
64345
  };
64346
+ function refreshCustomMergeCellGroups(table) {
64347
+ var _a;
64348
+ if (!Array.isArray(table.options.customMergeCell)) return;
64349
+ table.internalProps.customMergeCell = getCustomMergeCellFunc(table.options.customMergeCell);
64350
+ const merges = table.options.customMergeCell;
64351
+ for (let i = 0; i < merges.length; i++) {
64352
+ const r = null === (_a = merges[i]) || void 0 === _a ? void 0 : _a.range;
64353
+ if (null == r ? void 0 : r.start) for (let col = r.start.col; col <= r.end.col; col++) for (let row = r.start.row; row <= r.end.row; row++) table.scenegraph.updateCellContent(col, row);
64354
+ }
64355
+ }
64227
64356
  function listTableChangeCellValue(col, row, value, workOnEditableCell, triggerEvent, table, noTriggerChangeCellValuesEvent) {
64357
+ var _a, _b;
64228
64358
  if (workOnEditableCell && table.isHasEditorDefine(col, row) || !1 === workOnEditableCell) {
64229
64359
  const recordShowIndex = table.getRecordShowIndexByCell(col, row),
64230
64360
  recordIndex = recordShowIndex >= 0 ? table.dataSource.getIndexKey(recordShowIndex) : void 0,
@@ -64234,8 +64364,12 @@
64234
64364
  beforeChangeValue = table.getCellRawValue(col, row),
64235
64365
  oldValue = table.getCellOriginValue(col, row);
64236
64366
  table.isHeader(col, row) ? table.internalProps.layoutMap.updateColumnTitle(col, row, value) : table.dataSource.changeFieldValue(value, recordShowIndex, field, col, row, table);
64237
- const range = table.getCellRange(col, row),
64238
- aggregators = table.internalProps.layoutMap.getAggregatorsByCell(col, row);
64367
+ const range = table.getCellRange(col, row);
64368
+ if (range.isCustom && range.start.col === col && range.start.row === row && Array.isArray(table.options.customMergeCell) && "function" == typeof table.getCellValue) {
64369
+ const customMerge = null === (_b = null === (_a = table.internalProps) || void 0 === _a ? void 0 : _a.customMergeCell) || void 0 === _b ? void 0 : _b.call(_a, col, row, table);
64370
+ customMerge && (customMerge.text = value);
64371
+ }
64372
+ const aggregators = table.internalProps.layoutMap.getAggregatorsByCell(col, row);
64239
64373
  if (aggregators) {
64240
64374
  if (Array.isArray(aggregators)) for (let i = 0; i < (null == aggregators ? void 0 : aggregators.length); i++) aggregators[i].recalculate();else aggregators.recalculate();
64241
64375
  const aggregatorCells = table.internalProps.layoutMap.getAggregatorCellAddress(range.start.col, range.start.row, range.end.col, range.end.row);
@@ -64458,7 +64592,13 @@
64458
64592
  (void 0 === recordIndex || recordIndex > table.dataSource.sourceLength) && (recordIndex = table.dataSource.sourceLength);
64459
64593
  const headerCount = table.transpose ? table.rowHeaderLevelCount : table.columnHeaderLevelCount,
64460
64594
  syncToOriginalRecords = !!(null === (_f = table.options) || void 0 === _f ? void 0 : _f.syncRecordOperationsToSourceRecords);
64461
- if (table.dataSource.addRecord(record, recordIndex, syncToOriginalRecords), adjustCheckBoxStateMapWithAddRecordIndex(table, recordIndex, 1), syncToOriginalRecords) return table.refreshRowColCount(), table.internalProps.layoutMap.clearCellRangeMap(), table.scenegraph.clearCells(), table.scenegraph.createSceneGraph(), !0;
64595
+ if (table.dataSource.addRecord(record, recordIndex, syncToOriginalRecords), adjustCheckBoxStateMapWithAddRecordIndex(table, recordIndex, 1), syncToOriginalRecords) {
64596
+ if (!table.transpose) {
64597
+ const insertRowIndex = recordIndex + headerCount + table.internalProps.layoutMap.hasAggregationOnTopCount;
64598
+ table.rowHeightsMap.insert(insertRowIndex);
64599
+ }
64600
+ return table.refreshRowColCount(), table.internalProps.layoutMap.clearCellRangeMap(), table.scenegraph.clearCells(), table.scenegraph.createSceneGraph(!0), !0;
64601
+ }
64462
64602
  const oldRowCount = table.rowCount;
64463
64603
  if (table.refreshRowColCount(), 0 === table.scenegraph.proxy.totalActualBodyRowCount) return table.scenegraph.clearCells(), table.scenegraph.createSceneGraph(), !0;
64464
64604
  const newRowCount = table.transpose ? table.colCount : table.rowCount;
@@ -64536,7 +64676,13 @@
64536
64676
  void 0 === recordIndex || recordIndex > table.dataSource.sourceLength ? recordIndex = table.dataSource.sourceLength : recordIndex < 0 && (recordIndex = 0);
64537
64677
  const headerCount = table.transpose ? table.rowHeaderLevelCount : table.columnHeaderLevelCount,
64538
64678
  syncToOriginalRecords = !!(null === (_f = table.options) || void 0 === _f ? void 0 : _f.syncRecordOperationsToSourceRecords);
64539
- if (table.dataSource.addRecords(records, recordIndex, syncToOriginalRecords), adjustCheckBoxStateMapWithAddRecordIndex(table, recordIndex, records.length), syncToOriginalRecords) return table.refreshRowColCount(), table.internalProps.layoutMap.clearCellRangeMap(), table.scenegraph.clearCells(), table.scenegraph.createSceneGraph(), !0;
64679
+ if (table.dataSource.addRecords(records, recordIndex, syncToOriginalRecords), adjustCheckBoxStateMapWithAddRecordIndex(table, recordIndex, records.length), syncToOriginalRecords) {
64680
+ if (!table.transpose) {
64681
+ const insertRowIndex = recordIndex + headerCount + table.internalProps.layoutMap.hasAggregationOnTopCount;
64682
+ for (let i = 0; i < records.length; i++) table.rowHeightsMap.insert(insertRowIndex);
64683
+ }
64684
+ return table.refreshRowColCount(), table.internalProps.layoutMap.clearCellRangeMap(), table.scenegraph.clearCells(), table.scenegraph.createSceneGraph(!0), !0;
64685
+ }
64540
64686
  const oldRowCount = table.transpose ? table.colCount : table.rowCount;
64541
64687
  if (table.refreshRowColCount(), 0 === table.scenegraph.proxy.totalActualBodyRowCount) return table.scenegraph.clearCells(), table.scenegraph.createSceneGraph(), !0;
64542
64688
  const newRowCount = table.transpose ? table.colCount : table.rowCount;
@@ -64605,7 +64751,7 @@
64605
64751
  }
64606
64752
  }
64607
64753
  function listTableDeleteRecords(recordIndexs, table) {
64608
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
64754
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
64609
64755
  if ((null == recordIndexs ? void 0 : recordIndexs.length) > 0) if (table.internalProps.groupBy) null === (_b = (_a = table.dataSource).deleteRecordsForGroup) || void 0 === _b || _b.call(_a, recordIndexs), table.refreshRowColCount(), table.internalProps.layoutMap.clearCellRangeMap(), table.sortState && sortRecords(table), table.scenegraph.clearCells(), table.scenegraph.createSceneGraph();else if ("tree" === table.dataSource.rowHierarchyType) {
64610
64756
  const deletedRecordIndexs = null === (_d = (_c = table.dataSource).deleteRecordsForTree) || void 0 === _d ? void 0 : _d.call(_c, recordIndexs);
64611
64757
  if (0 === deletedRecordIndexs.length) return;
@@ -64617,8 +64763,17 @@
64617
64763
  const syncToOriginalRecords = !!(null === (_f = table.options) || void 0 === _f ? void 0 : _f.syncRecordOperationsToSourceRecords),
64618
64764
  deletedRecordIndexs = table.dataSource.deleteRecords(recordIndexs, syncToOriginalRecords);
64619
64765
  if (0 === deletedRecordIndexs.length) return;
64766
+ Array.isArray(table.options.customMergeCell) && (table.internalProps.customMergeCell = getCustomMergeCellFunc(table.options.customMergeCell));
64620
64767
  for (let index = 0; index < deletedRecordIndexs.length; index++) adjustCheckBoxStateMapWithDeleteRecordIndex(table, deletedRecordIndexs[index], 1);
64621
- if (syncToOriginalRecords) return table.refreshRowColCount(), table.internalProps.layoutMap.clearCellRangeMap(), table.scenegraph.clearCells(), void table.scenegraph.createSceneGraph();
64768
+ if (syncToOriginalRecords) {
64769
+ if (!table.transpose) {
64770
+ const headerCount = table.transpose ? table.rowHeaderLevelCount : table.columnHeaderLevelCount,
64771
+ topAggregationCount = table.internalProps.layoutMap.hasAggregationOnTopCount,
64772
+ sorted = [...deletedRecordIndexs].sort((a, b) => b - a);
64773
+ for (let i = 0; i < sorted.length; i++) table.rowHeightsMap.delete(sorted[i] + headerCount + topAggregationCount);
64774
+ }
64775
+ return table.refreshRowColCount(), table.internalProps.layoutMap.clearCellRangeMap(), table.scenegraph.clearCells(), void table.scenegraph.createSceneGraph(!0);
64776
+ }
64622
64777
  const oldRowCount = table.transpose ? table.colCount : table.rowCount;
64623
64778
  table.refreshRowColCount();
64624
64779
  const newRowCount = table.transpose ? table.colCount : table.rowCount,
@@ -64656,7 +64811,7 @@
64656
64811
  col: 0,
64657
64812
  row: row
64658
64813
  });
64659
- null === (_g = table.reactCustomLayout) || void 0 === _g || _g.clearCache(), table.transpose ? table.scenegraph.updateCol(delRows, [], updateRows) : table.scenegraph.updateRow(delRows, [], updateRows), null === (_h = table.reactCustomLayout) || void 0 === _h || _h.updateAllCustomCell();
64814
+ null === (_g = table.reactCustomLayout) || void 0 === _g || _g.clearCache(), table.transpose ? table.scenegraph.updateCol(delRows, [], updateRows) : table.scenegraph.updateRow(delRows, [], updateRows), null === (_h = table.reactCustomLayout) || void 0 === _h || _h.updateAllCustomCell(), refreshCustomMergeCellGroups(table);
64660
64815
  }
64661
64816
  } else {
64662
64817
  const delRows = [],
@@ -64674,6 +64829,42 @@
64674
64829
  });
64675
64830
  }
64676
64831
  const updateRows = [];
64832
+ if (table.internalProps.customMergeCell) {
64833
+ const proxy = table.scenegraph.proxy,
64834
+ deletedIndexNums = (recordIndexsMinToMax[0], recordIndexsMinToMax.map(recordIndex => recordIndex + headerCount + topAggregationCount)),
64835
+ minIndexNum = deletedIndexNums[0];
64836
+ let updateMin = minIndexNum,
64837
+ updateMax = minIndexNum;
64838
+ if (Array.isArray(table.options.customMergeCell)) {
64839
+ const merges = table.options.customMergeCell,
64840
+ axis = table.transpose ? "col" : "row";
64841
+ merges.forEach(m => {
64842
+ const r = null == m ? void 0 : m.range;
64843
+ if ((null == r ? void 0 : r.start) && (null == r ? void 0 : r.end)) for (let i = 0; i < deletedIndexNums.length; i++) {
64844
+ const deleteIndex = deletedIndexNums[i];
64845
+ if (r.end[axis] >= deleteIndex - 1) {
64846
+ updateMin = Math.min(updateMin, r.start[axis]), updateMax = Math.max(updateMax, r.end[axis]);
64847
+ break;
64848
+ }
64849
+ }
64850
+ });
64851
+ }
64852
+ if (table.transpose) {
64853
+ const start = Math.max(updateMin, null !== (_j = null == proxy ? void 0 : proxy.colStart) && void 0 !== _j ? _j : updateMin),
64854
+ end = Math.min(updateMax, null !== (_k = null == proxy ? void 0 : proxy.colEnd) && void 0 !== _k ? _k : updateMax);
64855
+ for (let col = start; col <= end; col++) updateRows.push({
64856
+ col: col,
64857
+ row: 0
64858
+ });
64859
+ } else {
64860
+ const start = Math.max(updateMin, null !== (_l = null == proxy ? void 0 : proxy.rowStart) && void 0 !== _l ? _l : updateMin),
64861
+ end = Math.min(updateMax, null !== (_m = null == proxy ? void 0 : proxy.rowEnd) && void 0 !== _m ? _m : updateMax);
64862
+ for (let row = start; row <= end; row++) updateRows.push({
64863
+ col: 0,
64864
+ row: row
64865
+ });
64866
+ }
64867
+ }
64677
64868
  for (let row = headerCount; row < headerCount + topAggregationCount; row++) table.transpose ? updateRows.push({
64678
64869
  col: row,
64679
64870
  row: 0
@@ -64688,7 +64879,7 @@
64688
64879
  col: 0,
64689
64880
  row: row
64690
64881
  });
64691
- null === (_j = table.reactCustomLayout) || void 0 === _j || _j.clearCache(), table.transpose ? table.scenegraph.updateCol(delRows, [], updateRows) : table.scenegraph.updateRow(delRows, [], updateRows), null === (_k = table.reactCustomLayout) || void 0 === _k || _k.updateAllCustomCell();
64882
+ null === (_o = table.reactCustomLayout) || void 0 === _o || _o.clearCache(), table.transpose ? table.scenegraph.updateCol(delRows, [], updateRows) : table.scenegraph.updateRow(delRows, [], updateRows), null === (_p = table.reactCustomLayout) || void 0 === _p || _p.updateAllCustomCell(), refreshCustomMergeCellGroups(table);
64692
64883
  }
64693
64884
  }
64694
64885
  }
@@ -64700,7 +64891,7 @@
64700
64891
  const syncToOriginalRecords = !!(null === (_f = table.options) || void 0 === _f ? void 0 : _f.syncRecordOperationsToSourceRecords),
64701
64892
  updateRecordIndexs = table.dataSource.updateRecords(records, recordIndexs, syncToOriginalRecords);
64702
64893
  if (0 === updateRecordIndexs.length) return;
64703
- if (syncToOriginalRecords) return table.refreshRowColCount(), table.internalProps.layoutMap.clearCellRangeMap(), table.scenegraph.clearCells(), void table.scenegraph.createSceneGraph();
64894
+ if (syncToOriginalRecords) return table.refreshRowColCount(), table.internalProps.layoutMap.clearCellRangeMap(), table.scenegraph.clearCells(), void table.scenegraph.createSceneGraph(!0);
64704
64895
  const recordIndexsMinToMax = updateRecordIndexs.map(index => table.getBodyRowIndexByRecordIndex(index)).sort((a, b) => a - b);
64705
64896
  if (table.pagination) {
64706
64897
  const {
@@ -65023,10 +65214,33 @@
65023
65214
  this._hasAutoImageColumn = void 0, this.refreshHeader(), this.records && checkHasAggregationOnColumnDefine(this.internalProps.columns) && this.dataSource.processRecords(null !== (_b = null === (_a = this.dataSource.dataSourceObj) || void 0 === _a ? void 0 : _a.records) && void 0 !== _b ? _b : this.dataSource.dataSourceObj), this.internalProps.useOneRowHeightFillAll = !1, this.headerStyleCache = new Map(), this.bodyStyleCache = new Map(), this.bodyBottomStyleCache = new Map(), this._updateSize(), this.scenegraph.createSceneGraph(), this.stateManager.updateHoverPos(oldHoverState.col, oldHoverState.row), this.renderAsync(), this.eventManager.updateEventBinder();
65024
65215
  }
65025
65216
  addColumns(toAddColumns, colIndex, isMaintainArrayData = !0) {
65026
- var _a;
65217
+ var _a, _b;
65027
65218
  const columns = this.options.columns;
65219
+ if (Array.isArray(this.options.customMergeCell) && (null == toAddColumns ? void 0 : toAddColumns.length)) {
65220
+ const axis = this.transpose ? "row" : "col";
65221
+ let insertIndex = colIndex;
65222
+ void 0 === insertIndex ? insertIndex = columns.length : insertIndex < 0 ? insertIndex = 0 : insertIndex > columns.length && (insertIndex = columns.length);
65223
+ const toAddCount = toAddColumns.length,
65224
+ merges = this.options.customMergeCell.map(m => Object.assign(Object.assign({}, m), {
65225
+ range: {
65226
+ start: Object.assign({}, m.range.start),
65227
+ end: Object.assign({}, m.range.end)
65228
+ }
65229
+ }));
65230
+ for (let i = 0; i < merges.length; i++) {
65231
+ const r = null === (_a = merges[i]) || void 0 === _a ? void 0 : _a.range;
65232
+ if (!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) continue;
65233
+ const start = r.start[axis],
65234
+ end = r.end[axis];
65235
+ end < insertIndex || (start > insertIndex ? (r.start[axis] = start + toAddCount, r.end[axis] = end + toAddCount) : r.end[axis] = end + toAddCount);
65236
+ }
65237
+ this.options.customMergeCell = merges.filter(m => {
65238
+ const r = null == m ? void 0 : m.range;
65239
+ return !(!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) && !(r.end.row < r.start.row || r.end.col < r.start.col) && !(r.start.row === r.end.row && r.start.col === r.end.col);
65240
+ }), this.internalProps.customMergeCell = getCustomMergeCellFunc(this.options.customMergeCell);
65241
+ }
65028
65242
  void 0 === colIndex ? (colIndex = columns.length, columns.push(...toAddColumns)) : columns.splice(colIndex, 0, ...toAddColumns);
65029
- for (let i = 0; i < toAddColumns.length; i++) this.colWidthsMap.addAndReorder(colIndex + i, null !== (_a = toAddColumns[i].width) && void 0 !== _a ? _a : this.internalProps.defaultColWidth);
65243
+ for (let i = 0; i < toAddColumns.length; i++) this.colWidthsMap.addAndReorder(colIndex + i, null !== (_b = toAddColumns[i].width) && void 0 !== _b ? _b : this.internalProps.defaultColWidth);
65030
65244
  this.internalProps._colRangeWidthsMap.clear();
65031
65245
  const resizedColIndexs = Array.from(this.internalProps._widthResizedColMap.keys());
65032
65246
  for (let i = 0; i < resizedColIndexs.length; i++) resizedColIndexs[i] >= colIndex && (this.internalProps._widthResizedColMap.delete(resizedColIndexs[i]), this.internalProps._widthResizedColMap.add(resizedColIndexs[i] + toAddColumns.length));
@@ -65039,15 +65253,46 @@
65039
65253
  }
65040
65254
  this.updateColumns(columns, {
65041
65255
  clearRowHeightCache: !1
65042
- }), this.fireListeners(TABLE_EVENT_TYPE.ADD_COLUMN, {
65256
+ }), Array.isArray(this.options.customMergeCell) && (this.internalProps.customMergeCell = getCustomMergeCellFunc(this.options.customMergeCell), this.options.customMergeCell.forEach(m => {
65257
+ const r = null == m ? void 0 : m.range;
65258
+ if (null == r ? void 0 : r.start) for (let col = r.start.col; col <= r.end.col; col++) for (let row = r.start.row; row <= r.end.row; row++) this.scenegraph.updateCellContent(col, row);
65259
+ }), this.scenegraph.updateNextFrame()), this.fireListeners(TABLE_EVENT_TYPE.ADD_COLUMN, {
65043
65260
  columnIndex: colIndex,
65044
65261
  columnCount: toAddColumns.length,
65045
65262
  columns: columns
65046
65263
  });
65047
65264
  }
65048
65265
  deleteColumns(deleteColIndexs, isMaintainArrayData = !0) {
65266
+ var _a;
65049
65267
  const columns = this.options.columns;
65050
65268
  deleteColIndexs.sort((a, b) => b - a);
65269
+ const deletedColumns = deleteColIndexs.map(idx => cloneDeepSpec(columns[idx], ["children"]));
65270
+ let deletedRecordValues;
65271
+ if (Array.isArray(this.options.customMergeCell) && (null == deleteColIndexs ? void 0 : deleteColIndexs.length)) {
65272
+ const axis = this.transpose ? "row" : "col",
65273
+ deleteIndexNums = deleteColIndexs.slice().sort((a, b) => a - b).map((idx, i) => idx - i),
65274
+ merges = this.options.customMergeCell.map(m => Object.assign(Object.assign({}, m), {
65275
+ range: {
65276
+ start: Object.assign({}, m.range.start),
65277
+ end: Object.assign({}, m.range.end)
65278
+ }
65279
+ }));
65280
+ for (let i = 0; i < deleteIndexNums.length; i++) {
65281
+ const deleteIndex = deleteIndexNums[i];
65282
+ for (let j = 0; j < merges.length; j++) {
65283
+ const r = null === (_a = merges[j]) || void 0 === _a ? void 0 : _a.range;
65284
+ if (!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) continue;
65285
+ const start = r.start[axis],
65286
+ end = r.end[axis];
65287
+ end < deleteIndex || (start > deleteIndex ? (r.start[axis] = start - 1, r.end[axis] = end - 1) : r.end[axis] = end - 1);
65288
+ }
65289
+ }
65290
+ this.options.customMergeCell = merges.filter(m => {
65291
+ const r = null == m ? void 0 : m.range;
65292
+ return !(!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) && !(r.end.row < r.start.row || r.end.col < r.start.col) && !(r.start.row === r.end.row && r.start.col === r.end.col);
65293
+ }), this.internalProps.customMergeCell = getCustomMergeCellFunc(this.options.customMergeCell);
65294
+ }
65295
+ isMaintainArrayData && Array.isArray(this.records) && this.records.length && (deletedRecordValues = this.records.map(record => Array.isArray(record) ? deleteColIndexs.map(idx => record[idx]) : []), deletedRecordValues.every(v => 0 === v.length) && (deletedRecordValues = void 0));
65051
65296
  for (let i = 0; i < deleteColIndexs.length; i++) if (columns.splice(deleteColIndexs[i], 1), this.colWidthsMap.delAndReorder(deleteColIndexs[i]), this.internalProps._widthResizedColMap.delete(deleteColIndexs[i]), isMaintainArrayData) for (let j = 0; j < this.records.length; j++) {
65052
65297
  const record = this.records[j];
65053
65298
  Array.isArray(record) && record.splice(deleteColIndexs[i], 1);
@@ -65063,7 +65308,9 @@
65063
65308
  clearRowHeightCache: !1
65064
65309
  }), this.fireListeners(TABLE_EVENT_TYPE.DELETE_COLUMN, {
65065
65310
  deleteColIndexs: deleteColIndexs,
65066
- columns: columns
65311
+ columns: columns,
65312
+ deletedColumns: deletedColumns,
65313
+ deletedRecordValues: deletedRecordValues
65067
65314
  });
65068
65315
  }
65069
65316
  get columns() {
@@ -65451,9 +65698,9 @@
65451
65698
  }
65452
65699
  }
65453
65700
  updateSortState(sortState, executeSort = !0) {
65454
- var _a;
65455
- if (sortState) this.internalProps.sortState = sortState;else if (this.internalProps.sortState) if (Array.isArray(this.internalProps.sortState)) for (let i = 0; i < this.internalProps.sortState.length; i++) (sortState = null === (_a = this.internalProps.sortState) || void 0 === _a ? void 0 : _a[i]) && (sortState.order = "normal");else this.internalProps.sortState.order = "normal", sortState = this.internalProps.sortState;
65456
- (sortState = Array.isArray(sortState) ? sortState : [sortState]).some(item => item.field) && executeSort && this.internalProps.layoutMap.headerObjects.some(item => !1 !== item.define.sort) && (this.dataSource.sort(sortState.map(item => {
65701
+ var _a, _b, _c, _d, _e;
65702
+ const normalizedSortState = (Array.isArray(sortState) ? sortState : sortState ? [sortState] : []).filter(Boolean);
65703
+ if (normalizedSortState.length ? this.internalProps.sortState = sortState : this.internalProps.sortState = null, executeSort) if (normalizedSortState.length) this.internalProps.layoutMap.headerObjects.some(item => !1 !== item.define.sort) && (this.dataSource.sort(normalizedSortState.map(item => {
65457
65704
  const sortFunc = this._getSortFuncFromHeaderOption(this.internalProps.columns, item.field);
65458
65705
  this.internalProps.layoutMap.headerObjects.find(col => col && col.field === item.field);
65459
65706
  return {
@@ -65461,13 +65708,20 @@
65461
65708
  order: item.order,
65462
65709
  orderFn: null != sortFunc ? sortFunc : defaultOrderFn
65463
65710
  };
65464
- })), this.internalProps.layoutMap.clearCellRangeMap(), this.internalProps.useOneRowHeightFillAll = !1, this.scenegraph.sortCell()), sortState.length && this.stateManager.updateSortState(sortState);
65711
+ })), this.internalProps.layoutMap.clearCellRangeMap(), this.internalProps.useOneRowHeightFillAll = !1, this.scenegraph.sortCell());else {
65712
+ const ds = this.dataSource,
65713
+ sourceLength = null !== (_c = null !== (_b = null !== (_a = null == ds ? void 0 : ds.sourceLength) && void 0 !== _a ? _a : null == ds ? void 0 : ds._sourceLength) && void 0 !== _b ? _b : null == ds ? void 0 : ds.length) && void 0 !== _c ? _c : 0;
65714
+ (null === (_d = null == ds ? void 0 : ds.sortedIndexMap) || void 0 === _d ? void 0 : _d.clear) && ds.sortedIndexMap.clear(), void 0 !== ds.currentIndexedData && (ds.currentIndexedData = Array.from({
65715
+ length: sourceLength
65716
+ }, (_, i) => i)), ds.lastSortStates = [], null === (_e = ds.updatePagination) || void 0 === _e || _e.call(ds, ds.pagination), this.internalProps.layoutMap.clearCellRangeMap(), this.internalProps.useOneRowHeightFillAll = !1, this.scenegraph.sortCell();
65717
+ }
65718
+ this.stateManager.updateSortState(normalizedSortState);
65465
65719
  }
65466
65720
  updateFilterRules(filterRules, options = {
65467
65721
  clearRowHeightCache: !0
65468
65722
  }) {
65469
65723
  var _a, _b, _c;
65470
- this.scenegraph.clearCells(), null === (_b = (_a = this.dataSource).clearForceVisibleRecords) || void 0 === _b || _b.call(_a), this.sortState ? (this.dataSource.updateFilterRulesForSorted(filterRules), sortRecords(this)) : this.dataSource.updateFilterRules(filterRules, null == options ? void 0 : options.onFilterRecordsEnd), this.refreshRowColCount(), this.stateManager.initCheckedState(this.records), this.scenegraph.createSceneGraph(!(null == options ? void 0 : options.clearRowHeightCache)), null === (_c = this.internalProps.emptyTip) || void 0 === _c || _c.resetVisible(), this.resize();
65724
+ this.scenegraph.clearCells(), !1 !== (null == options ? void 0 : options.clearForceVisibleRecords) && (null === (_b = (_a = this.dataSource).clearForceVisibleRecords) || void 0 === _b || _b.call(_a)), this.sortState ? (this.dataSource.updateFilterRulesForSorted(filterRules), sortRecords(this)) : this.dataSource.updateFilterRules(filterRules, null == options ? void 0 : options.onFilterRecordsEnd), this.refreshRowColCount(), this.stateManager.initCheckedState(this.records), this.scenegraph.createSceneGraph(!(null == options ? void 0 : options.clearRowHeightCache)), null === (_c = this.internalProps.emptyTip) || void 0 === _c || _c.resetVisible(), this.resize();
65471
65725
  }
65472
65726
  getFilteredRecords() {
65473
65727
  return this.dataSource.records;
@@ -65742,30 +65996,112 @@
65742
65996
  traverseColumns(this.internalProps.columns), this.refreshRowColCount(), this.internalProps.layoutMap.clearCellRangeMap(), this.internalProps.useOneRowHeightFillAll = !1, this.stateManager.initCheckedState(this.records), this.scenegraph.createSceneGraph(!clearRowHeightCache), null === (_k = this.internalProps.emptyTip) || void 0 === _k || _k.resetVisible(), this.resize();
65743
65997
  }
65744
65998
  addRecord(record, recordIndex, triggerEvent = !0) {
65745
- var _a;
65999
+ var _a, _b;
66000
+ if (Array.isArray(this.options.customMergeCell) && "number" == typeof recordIndex) {
66001
+ const axis = this.transpose ? "col" : "row",
66002
+ headerCount = this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount,
66003
+ topAggregationCount = this.internalProps.layoutMap.hasAggregationOnTopCount;
66004
+ let insertIndex = recordIndex;
66005
+ void 0 === insertIndex || insertIndex > this.dataSource.sourceLength ? insertIndex = this.dataSource.sourceLength : insertIndex < 0 && (insertIndex = 0);
66006
+ const insertIndexNum = insertIndex + headerCount + topAggregationCount,
66007
+ merges = this.options.customMergeCell.map(m => Object.assign(Object.assign({}, m), {
66008
+ range: {
66009
+ start: Object.assign({}, m.range.start),
66010
+ end: Object.assign({}, m.range.end)
66011
+ }
66012
+ }));
66013
+ for (let i = 0; i < merges.length; i++) {
66014
+ const r = null === (_a = merges[i]) || void 0 === _a ? void 0 : _a.range;
66015
+ if (!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) continue;
66016
+ const start = r.start[axis],
66017
+ end = r.end[axis];
66018
+ end < insertIndexNum || (start > insertIndexNum ? (r.start[axis] = start + 1, r.end[axis] = end + 1) : r.end[axis] = end + 1);
66019
+ }
66020
+ this.options.customMergeCell = merges.filter(m => {
66021
+ const r = null == m ? void 0 : m.range;
66022
+ return !(!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) && !(r.end.row < r.start.row || r.end.col < r.start.col) && !(r.start.row === r.end.row && r.start.col === r.end.col);
66023
+ }), this.internalProps.customMergeCell = getCustomMergeCellFunc(this.options.customMergeCell);
66024
+ }
65746
66025
  const success = listTableAddRecord(record, recordIndex, this);
65747
- adjustHeightResizedRowMapWithAddRecordIndex(this, recordIndex, [record]), null === (_a = this.internalProps.emptyTip) || void 0 === _a || _a.resetVisible(), triggerEvent && success && this.fireListeners(TABLE_EVENT_TYPE.ADD_RECORD, {
66026
+ adjustHeightResizedRowMapWithAddRecordIndex(this, recordIndex, [record]), null === (_b = this.internalProps.emptyTip) || void 0 === _b || _b.resetVisible(), success && Array.isArray(this.options.customMergeCell) && (this.internalProps.customMergeCell = getCustomMergeCellFunc(this.options.customMergeCell), this.options.customMergeCell.forEach(m => {
66027
+ const r = null == m ? void 0 : m.range;
66028
+ if (null == r ? void 0 : r.start) for (let col = r.start.col; col <= r.end.col; col++) for (let row = r.start.row; row <= r.end.row; row++) this.scenegraph.updateCellContent(col, row);
66029
+ }), this.scenegraph.updateNextFrame()), triggerEvent && success && this.fireListeners(TABLE_EVENT_TYPE.ADD_RECORD, {
65748
66030
  records: [record],
65749
66031
  recordIndex: recordIndex,
65750
66032
  recordCount: 1
65751
66033
  });
65752
66034
  }
65753
66035
  addRecords(records, recordIndex, triggerEvent = !0) {
65754
- var _a;
66036
+ var _a, _b;
66037
+ if (Array.isArray(this.options.customMergeCell) && "number" == typeof recordIndex && (null == records ? void 0 : records.length)) {
66038
+ const axis = this.transpose ? "col" : "row",
66039
+ headerCount = this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount,
66040
+ topAggregationCount = this.internalProps.layoutMap.hasAggregationOnTopCount;
66041
+ let insertIndex = recordIndex;
66042
+ void 0 === insertIndex || insertIndex > this.dataSource.sourceLength ? insertIndex = this.dataSource.sourceLength : insertIndex < 0 && (insertIndex = 0);
66043
+ const insertIndexNum = insertIndex + headerCount + topAggregationCount,
66044
+ toAddCount = records.length,
66045
+ merges = this.options.customMergeCell.map(m => Object.assign(Object.assign({}, m), {
66046
+ range: {
66047
+ start: Object.assign({}, m.range.start),
66048
+ end: Object.assign({}, m.range.end)
66049
+ }
66050
+ }));
66051
+ for (let i = 0; i < merges.length; i++) {
66052
+ const r = null === (_a = merges[i]) || void 0 === _a ? void 0 : _a.range;
66053
+ if (!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) continue;
66054
+ const start = r.start[axis],
66055
+ end = r.end[axis];
66056
+ end < insertIndexNum || (start > insertIndexNum ? (r.start[axis] = start + toAddCount, r.end[axis] = end + toAddCount) : r.end[axis] = end + toAddCount);
66057
+ }
66058
+ this.options.customMergeCell = merges.filter(m => {
66059
+ const r = null == m ? void 0 : m.range;
66060
+ return !(!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) && !(r.end.row < r.start.row || r.end.col < r.start.col) && !(r.start.row === r.end.row && r.start.col === r.end.col);
66061
+ }), this.internalProps.customMergeCell = getCustomMergeCellFunc(this.options.customMergeCell);
66062
+ }
65755
66063
  const success = listTableAddRecords(records, recordIndex, this);
65756
- "number" == typeof recordIndex && adjustHeightResizedRowMapWithAddRecordIndex(this, recordIndex, records), null === (_a = this.internalProps.emptyTip) || void 0 === _a || _a.resetVisible(), triggerEvent && success && this.fireListeners(TABLE_EVENT_TYPE.ADD_RECORD, {
66064
+ "number" == typeof recordIndex && adjustHeightResizedRowMapWithAddRecordIndex(this, recordIndex, records), null === (_b = this.internalProps.emptyTip) || void 0 === _b || _b.resetVisible(), success && Array.isArray(this.options.customMergeCell) && (this.internalProps.customMergeCell = getCustomMergeCellFunc(this.options.customMergeCell), this.options.customMergeCell.forEach(m => {
66065
+ const r = null == m ? void 0 : m.range;
66066
+ if (null == r ? void 0 : r.start) for (let col = r.start.col; col <= r.end.col; col++) for (let row = r.start.row; row <= r.end.row; row++) this.scenegraph.updateCellContent(col, row);
66067
+ }), this.scenegraph.updateNextFrame()), triggerEvent && success && this.fireListeners(TABLE_EVENT_TYPE.ADD_RECORD, {
65757
66068
  records: records,
65758
66069
  recordIndex: recordIndex,
65759
66070
  recordCount: records.length
65760
66071
  });
65761
66072
  }
65762
66073
  deleteRecords(recordIndexs, triggerEvent = !0) {
65763
- var _a;
65764
- const deletedRecords = [];
65765
- (null == recordIndexs ? void 0 : recordIndexs.length) > 0 && recordIndexs.forEach(index => {
66074
+ var _a, _b;
66075
+ const prevMergeRanges = Array.isArray(this.options.customMergeCell) ? this.options.customMergeCell.map(m => null == m ? void 0 : m.range).filter(Boolean).map(r => ({
66076
+ start: Object.assign({}, r.start),
66077
+ end: Object.assign({}, r.end)
66078
+ })) : [],
66079
+ deletedRecords = [];
66080
+ if ((null == recordIndexs ? void 0 : recordIndexs.length) > 0 && recordIndexs.forEach(index => {
65766
66081
  let record = null;
65767
66082
  record = "number" == typeof index ? this.dataSource.get(index) : [], deletedRecords.push(record);
65768
- }), listTableDeleteRecords(recordIndexs, this), adjustHeightResizedRowMapWithDeleteRecordIndex(this, recordIndexs), null === (_a = this.internalProps.emptyTip) || void 0 === _a || _a.resetVisible();
66083
+ }), Array.isArray(this.options.customMergeCell) && (null == recordIndexs ? void 0 : recordIndexs.length) && "number" == typeof recordIndexs[0]) {
66084
+ const axis = this.transpose ? "col" : "row",
66085
+ headerCount = this.transpose ? this.rowHeaderLevelCount : this.columnHeaderLevelCount,
66086
+ topAggregationCount = this.internalProps.layoutMap.hasAggregationOnTopCount,
66087
+ deleteIndexNums = recordIndexs.slice().sort((a, b) => a - b).map((index, i) => index + headerCount + topAggregationCount - i),
66088
+ merges = this.options.customMergeCell;
66089
+ for (let i = 0; i < deleteIndexNums.length; i++) {
66090
+ const deleteIndex = deleteIndexNums[i];
66091
+ for (let j = 0; j < merges.length; j++) {
66092
+ const r = null === (_a = merges[j]) || void 0 === _a ? void 0 : _a.range;
66093
+ if (!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) continue;
66094
+ const start = r.start[axis],
66095
+ end = r.end[axis];
66096
+ end < deleteIndex || (start > deleteIndex ? (r.start[axis] = start - 1, r.end[axis] = end - 1) : r.end[axis] = end - 1);
66097
+ }
66098
+ }
66099
+ this.options.customMergeCell = merges.filter(m => {
66100
+ const r = null == m ? void 0 : m.range;
66101
+ return !(!(null == r ? void 0 : r.start) || !(null == r ? void 0 : r.end)) && !(r.end.row < r.start.row || r.end.col < r.start.col) && !(r.start.row === r.end.row && r.start.col === r.end.col);
66102
+ });
66103
+ }
66104
+ listTableDeleteRecords(recordIndexs, this), adjustHeightResizedRowMapWithDeleteRecordIndex(this, recordIndexs), null === (_b = this.internalProps.emptyTip) || void 0 === _b || _b.resetVisible();
65769
66105
  const rowIndexs = [];
65770
66106
  for (let i = 0; i < recordIndexs.length; i++) rowIndexs.push(this.getBodyRowIndexByRecordIndex(recordIndexs[i]) + this.columnHeaderLevelCount);
65771
66107
  triggerEvent && this.fireListeners(TABLE_EVENT_TYPE.DELETE_RECORD, {
@@ -65773,7 +66109,16 @@
65773
66109
  records: deletedRecords,
65774
66110
  rowIndexs: rowIndexs,
65775
66111
  deletedCount: (Array.isArray(recordIndexs[0]), recordIndexs.length)
65776
- });
66112
+ }), Array.isArray(this.options.customMergeCell) && (this.internalProps.customMergeCell = getCustomMergeCellFunc(this.options.customMergeCell), this.options.customMergeCell.forEach(m => {
66113
+ const r = null == m ? void 0 : m.range;
66114
+ if (null == r ? void 0 : r.start) for (let col = r.start.col; col <= r.end.col; col++) for (let row = r.start.row; row <= r.end.row; row++) this.scenegraph.updateCellContent(col, row);
66115
+ }), this.scenegraph.updateNextFrame(), setTimeout(() => {
66116
+ if (!this.internalProps || !this.options || !this.scenegraph) return;
66117
+ Array.isArray(this.options.customMergeCell) && (this.internalProps.customMergeCell = getCustomMergeCellFunc(this.options.customMergeCell));
66118
+ [...prevMergeRanges, ...(Array.isArray(this.options.customMergeCell) ? this.options.customMergeCell.map(m => null == m ? void 0 : m.range) : [])].filter(Boolean).forEach(r => {
66119
+ if (null == r ? void 0 : r.start) for (let col = r.start.col; col <= r.end.col; col++) for (let row = r.start.row; row <= r.end.row; row++) this.scenegraph.updateCellContent(col, row);
66120
+ }), this.scenegraph.updateNextFrame();
66121
+ }, 0));
65777
66122
  }
65778
66123
  updateRecords(records, recordIndexs, triggerEvent = !0) {
65779
66124
  listTableUpdateRecords(records, recordIndexs, this), triggerEvent && this.fireListeners(TABLE_EVENT_TYPE.UPDATE_RECORD, {
@@ -65877,7 +66222,12 @@
65877
66222
  }
65878
66223
  }), this.internalProps.customMergeCell = getCustomMergeCellFunc(this.options.customMergeCell);
65879
66224
  for (let i = startCol; i <= endCol; i++) for (let j = startRow; j <= endRow; j++) this.scenegraph.updateCellContent(i, j);
65880
- this.scenegraph.updateNextFrame();
66225
+ this.scenegraph.updateNextFrame(), this.fireListeners(TABLE_EVENT_TYPE.MERGE_CELLS, {
66226
+ startCol: startCol,
66227
+ startRow: startRow,
66228
+ endCol: endCol,
66229
+ endRow: endRow
66230
+ });
65881
66231
  }
65882
66232
  unmergeCells(startCol, startRow, endCol, endRow) {
65883
66233
  this.options.customMergeCell ? "function" == typeof this.options.customMergeCell && (this.options.customMergeCell = []) : this.options.customMergeCell = [], this.options.customMergeCell = this.options.customMergeCell.filter(item => {
@@ -65888,7 +66238,12 @@
65888
66238
  return !(start.col === startCol && start.row === startRow && end.col === endCol && end.row === endRow);
65889
66239
  }), this.internalProps.customMergeCell = getCustomMergeCellFunc(this.options.customMergeCell);
65890
66240
  for (let i = startCol; i <= endCol; i++) for (let j = startRow; j <= endRow; j++) this.scenegraph.updateCellContent(i, j);
65891
- this.scenegraph.updateNextFrame();
66241
+ this.scenegraph.updateNextFrame(), this.fireListeners(TABLE_EVENT_TYPE.UNMERGE_CELLS, {
66242
+ startCol: startCol,
66243
+ startRow: startRow,
66244
+ endCol: endCol,
66245
+ endRow: endRow
66246
+ });
65892
66247
  }
65893
66248
  }
65894
66249
 
@@ -70080,16 +70435,22 @@
70080
70435
  const record = this._scene._gantt.getRecordByIndex(i);
70081
70436
  if (record.children?.length > 0) {
70082
70437
  for (let j = 0; j < record.children?.length; j++) {
70083
- const barGroup = this.initBar(i, j, record.children.length);
70084
- if (barGroup) {
70085
- this.barContainer.appendChild(barGroup);
70438
+ const { barGroupBox, baselineBar } = this.initBar(i, j, record.children.length);
70439
+ if (baselineBar) {
70440
+ this.barContainer.appendChild(baselineBar);
70441
+ }
70442
+ if (barGroupBox) {
70443
+ this.barContainer.appendChild(barGroupBox);
70086
70444
  }
70087
70445
  }
70088
70446
  }
70089
70447
  else {
70090
- const barGroup = this.initBar(i);
70091
- if (barGroup) {
70092
- this.barContainer.appendChild(barGroup);
70448
+ const { barGroupBox, baselineBar } = this.initBar(i);
70449
+ if (baselineBar) {
70450
+ this.barContainer.appendChild(baselineBar);
70451
+ }
70452
+ if (barGroupBox) {
70453
+ this.barContainer.appendChild(barGroupBox);
70093
70454
  }
70094
70455
  }
70095
70456
  continue;
@@ -70105,9 +70466,12 @@
70105
70466
  for (let j = 0; j < record.children?.length; j++) {
70106
70467
  const child_record = record.children[j];
70107
70468
  if (child_record.type !== TaskType.PROJECT) {
70108
- const barGroup = this.initBar(i, [...sub_task_indexs, j], record.children.length);
70109
- if (barGroup) {
70110
- this.barContainer.appendChild(barGroup);
70469
+ const { barGroupBox, baselineBar } = this.initBar(i, [...sub_task_indexs, j], record.children.length);
70470
+ if (baselineBar) {
70471
+ this.barContainer.appendChild(baselineBar);
70472
+ }
70473
+ if (barGroupBox) {
70474
+ this.barContainer.appendChild(barGroupBox);
70111
70475
  }
70112
70476
  }
70113
70477
  else {
@@ -70119,17 +70483,23 @@
70119
70483
  callInitBar(record, sub_task_indexs);
70120
70484
  }
70121
70485
  else {
70122
- const barGroup = this.initBar(i);
70123
- if (barGroup) {
70124
- this.barContainer.appendChild(barGroup);
70486
+ const { barGroupBox, baselineBar } = this.initBar(i);
70487
+ if (baselineBar) {
70488
+ this.barContainer.appendChild(baselineBar);
70489
+ }
70490
+ if (barGroupBox) {
70491
+ this.barContainer.appendChild(barGroupBox);
70125
70492
  }
70126
70493
  }
70127
70494
  continue;
70128
70495
  }
70129
70496
  else {
70130
- const barGroup = this.initBar(i);
70131
- if (barGroup) {
70132
- this.barContainer.appendChild(barGroup);
70497
+ const { barGroupBox, baselineBar } = this.initBar(i);
70498
+ if (baselineBar) {
70499
+ this.barContainer.appendChild(baselineBar);
70500
+ }
70501
+ if (barGroupBox) {
70502
+ this.barContainer.appendChild(barGroupBox);
70133
70503
  }
70134
70504
  }
70135
70505
  }
@@ -70140,10 +70510,9 @@
70140
70510
  const isMilestone = taskRecord.type === TaskType.MILESTONE;
70141
70511
  if ((isMilestone && !startDate) ||
70142
70512
  (!isMilestone && (taskDays <= 0 || !startDate || !endDate || startDate.getTime() > endDate.getTime()))) {
70143
- return null;
70513
+ return { barGroupBox: null, baselineBar: null };
70144
70514
  }
70145
- const { unit, step } = this._scene._gantt.parsedOptions.reverseSortedTimelineScales[0];
70146
- let taskBarSize = computeCountToTimeScale(endDate, startDate, unit, step, 1) * this._scene._gantt.parsedOptions.timelineColWidth;
70515
+ let taskBarSize = this._scene._gantt.getXByTime(endDate.getTime() + 1) - this._scene._gantt.getXByTime(startDate.getTime());
70147
70516
  const taskBarStyle = this._scene._gantt.getTaskBarStyle(index, childIndex);
70148
70517
  const taskbarHeight = taskBarStyle.width;
70149
70518
  if (isValid$1(taskBarStyle.minSize)) {
@@ -70151,17 +70520,104 @@
70151
70520
  }
70152
70521
  const oneTaskHeigth = this._scene._gantt.parsedOptions.rowHeight;
70153
70522
  const milestoneTaskBarHeight = this._scene._gantt.parsedOptions.taskBarMilestoneStyle.width;
70154
- const x = computeCountToTimeScale(startDate, this._scene._gantt.parsedOptions.minDate, unit, step) *
70155
- this._scene._gantt.parsedOptions.timelineColWidth -
70156
- (isMilestone ? milestoneTaskBarHeight / 2 : 0);
70157
- const y = this._scene._gantt.getRowsHeightByIndex(0, index - 1) +
70523
+ const x = this._scene._gantt.getXByTime(startDate.getTime()) - (isMilestone ? milestoneTaskBarHeight / 2 : 0);
70524
+ let y = this._scene._gantt.getRowsHeightByIndex(0, index - 1) +
70158
70525
  (this._scene._gantt.parsedOptions.tasksShowMode === TasksShowMode.Sub_Tasks_Separate
70159
70526
  ? (childIndex ?? 0) * oneTaskHeigth
70160
70527
  : this._scene._gantt.parsedOptions.tasksShowMode === TasksShowMode.Sub_Tasks_Arrange ||
70161
70528
  this._scene._gantt.parsedOptions.tasksShowMode === TasksShowMode.Sub_Tasks_Compact
70162
70529
  ? taskRecord.vtable_gantt_showIndex * oneTaskHeigth
70163
- : 0) +
70164
- (oneTaskHeigth - (isMilestone ? milestoneTaskBarHeight : taskbarHeight)) / 2;
70530
+ : 0);
70531
+ const baselineInfo = this._scene._gantt.getBaselineInfoByTaskListIndex(index, childIndex);
70532
+ const hasBaseline = baselineInfo.baselineStartDate && baselineInfo.baselineEndDate && baselineInfo.baselineDays > 0;
70533
+ const baselinePosition = this._scene._gantt.parsedOptions.baselinePosition;
70534
+ let baselineBar = null;
70535
+ let taskBarYOffset = 0;
70536
+ if (hasBaseline && !isMilestone) {
70537
+ const baselineStyle = this._scene._gantt.getBaselineStyle(index, childIndex);
70538
+ const baselineX = this._scene._gantt.getXByTime(baselineInfo.baselineStartDate.getTime());
70539
+ const baselineWidth = this._scene._gantt.getXByTime(baselineInfo.baselineEndDate.getTime() + 1) -
70540
+ this._scene._gantt.getXByTime(baselineInfo.baselineStartDate.getTime());
70541
+ let baselineY;
70542
+ const taskBarPaddingTop = taskBarStyle.paddingTop ?? undefined;
70543
+ const baselinePaddingTop = baselineStyle.paddingTop ?? undefined;
70544
+ if (baselinePosition === 'overlap') {
70545
+ if (taskBarPaddingTop !== undefined) {
70546
+ baselineY = y + taskBarPaddingTop;
70547
+ }
70548
+ else {
70549
+ baselineY = y + (oneTaskHeigth - baselineStyle.width) / 2;
70550
+ }
70551
+ }
70552
+ else if (baselinePosition === 'top') {
70553
+ const gap = 4;
70554
+ if (baselinePaddingTop !== undefined && taskBarPaddingTop !== undefined) {
70555
+ baselineY = y + baselinePaddingTop;
70556
+ taskBarYOffset = taskBarPaddingTop;
70557
+ }
70558
+ else if (baselinePaddingTop !== undefined) {
70559
+ baselineY = y + baselinePaddingTop;
70560
+ taskBarYOffset = baselinePaddingTop + baselineStyle.width + gap;
70561
+ }
70562
+ else if (taskBarPaddingTop !== undefined) {
70563
+ const totalHeight = baselineStyle.width + gap + taskbarHeight;
70564
+ const startY = (oneTaskHeigth - totalHeight) / 2;
70565
+ baselineY = y + startY;
70566
+ taskBarYOffset = taskBarPaddingTop;
70567
+ }
70568
+ else {
70569
+ const totalHeight = baselineStyle.width + gap + taskbarHeight;
70570
+ const startY = (oneTaskHeigth - totalHeight) / 2;
70571
+ baselineY = y + startY;
70572
+ taskBarYOffset = startY + baselineStyle.width + gap;
70573
+ }
70574
+ }
70575
+ else {
70576
+ const gap = 4;
70577
+ if (taskBarPaddingTop !== undefined && baselinePaddingTop !== undefined) {
70578
+ taskBarYOffset = taskBarPaddingTop;
70579
+ baselineY = y + baselinePaddingTop;
70580
+ }
70581
+ else if (taskBarPaddingTop !== undefined) {
70582
+ taskBarYOffset = taskBarPaddingTop;
70583
+ baselineY = y + taskBarPaddingTop + taskbarHeight + gap;
70584
+ }
70585
+ else if (baselinePaddingTop !== undefined) {
70586
+ const totalHeight = taskbarHeight + gap + baselineStyle.width;
70587
+ const startY = (oneTaskHeigth - totalHeight) / 2;
70588
+ taskBarYOffset = startY;
70589
+ baselineY = y + baselinePaddingTop;
70590
+ }
70591
+ else {
70592
+ const totalHeight = taskbarHeight + gap + baselineStyle.width;
70593
+ const startY = (oneTaskHeigth - totalHeight) / 2;
70594
+ taskBarYOffset = startY;
70595
+ baselineY = y + startY + taskbarHeight + gap;
70596
+ }
70597
+ }
70598
+ baselineBar = createRect({
70599
+ x: baselineX,
70600
+ y: baselineY,
70601
+ width: Math.max(baselineWidth, baselineStyle.minSize || 0),
70602
+ height: baselineStyle.width,
70603
+ fill: baselineStyle.barColor,
70604
+ cornerRadius: baselineStyle.cornerRadius,
70605
+ lineWidth: (baselineStyle.borderLineWidth ?? baselineStyle.borderWidth) * 2,
70606
+ stroke: baselineStyle.borderColor,
70607
+ pickable: false
70608
+ });
70609
+ baselineBar.name = 'baseline-bar';
70610
+ }
70611
+ const taskBarPaddingTop = taskBarStyle.paddingTop ?? undefined;
70612
+ if (hasBaseline && !isMilestone && baselinePosition !== 'overlap') {
70613
+ y = y + taskBarYOffset;
70614
+ }
70615
+ else if (taskBarPaddingTop !== undefined) {
70616
+ y = y + taskBarPaddingTop;
70617
+ }
70618
+ else {
70619
+ y += (oneTaskHeigth - (isMilestone ? milestoneTaskBarHeight : taskbarHeight)) / 2 + taskBarYOffset;
70620
+ }
70165
70621
  const barGroupBox = new GanttTaskBarNode({
70166
70622
  x,
70167
70623
  y,
@@ -70311,17 +70767,20 @@
70311
70767
  barGroupBox.milestoneTextLabel = milestoneLabel;
70312
70768
  barGroupBox.milestoneTextContainer = textContainer;
70313
70769
  }
70314
- return barGroupBox;
70770
+ return { barGroupBox, baselineBar };
70315
70771
  }
70316
70772
  updateTaskBarNode(index, sub_task_index) {
70317
70773
  const taskbarGroup = this.getTaskBarNodeByIndex(index, sub_task_index);
70318
70774
  if (taskbarGroup) {
70319
70775
  this.barContainer.removeChild(taskbarGroup);
70320
70776
  }
70321
- const barGroup = this.initBar(index, sub_task_index);
70322
- if (barGroup) {
70323
- this.barContainer.insertInto(barGroup, index);
70324
- barGroup.updateTextPosition();
70777
+ const { barGroupBox, baselineBar } = this.initBar(index, sub_task_index);
70778
+ if (barGroupBox) {
70779
+ this.barContainer.insertInto(barGroupBox, index);
70780
+ barGroupBox.updateTextPosition();
70781
+ }
70782
+ if (baselineBar) {
70783
+ this.barContainer.insertBefore(baselineBar, barGroupBox);
70325
70784
  }
70326
70785
  }
70327
70786
  initHoverBarIcons() {
@@ -70689,22 +71148,24 @@
70689
71148
  const date = this._scene._gantt.parsedOptions.timeScaleIncludeHour
70690
71149
  ? createDateAtMidnight(line.date)
70691
71150
  : createDateAtMidnight(line.date, true);
70692
- const { unit, step } = this._scene._gantt.parsedOptions.reverseSortedTimelineScales[0];
70693
- const unitCount = computeCountToTimeScale(date, minDate, unit, step);
70694
- let positionOffset = 0;
70695
- if (line.position === 'right') {
70696
- positionOffset = 1;
71151
+ const dateTime = date.getTime();
71152
+ if (dateTime < this._scene._gantt.parsedOptions._minDateTime ||
71153
+ dateTime > this._scene._gantt.parsedOptions._maxDateTime) {
71154
+ return;
70697
71155
  }
70698
- else if (line.position === 'middle') {
70699
- positionOffset = 0.5;
71156
+ const cellIndex = this._scene._gantt.getDateIndexByTime(dateTime);
71157
+ const cellStartX = cellIndex >= 1 ? this._scene._gantt.getDateColsWidth(0, cellIndex - 1) : 0;
71158
+ const cellWidth = this._scene._gantt.getDateColWidth(cellIndex);
71159
+ let dateX = cellStartX;
71160
+ if (line.position === 'date') {
71161
+ dateX = this._scene._gantt.getXByTime(dateTime);
70700
71162
  }
70701
- else if (line.position === 'date') {
70702
- const date = createDateAtMidnight(line.date);
70703
- const unitCount = computeCountToTimeScale(date, minDate, unit, step);
70704
- const cellIndex = Math.floor(unitCount);
70705
- positionOffset = unitCount - cellIndex;
71163
+ else if (line.position === 'right') {
71164
+ dateX = cellStartX + cellWidth;
71165
+ }
71166
+ else if (line.position === 'middle') {
71167
+ dateX = cellStartX + cellWidth / 2;
70706
71168
  }
70707
- const dateX = this._scene._gantt.parsedOptions.timelineColWidth * (Math.floor(unitCount) + positionOffset);
70708
71169
  const markLineGroup = new Group$2({
70709
71170
  pickable: false,
70710
71171
  x: dateX - this.markLineContainerWidth / 2,
@@ -70726,7 +71187,7 @@
70726
71187
  });
70727
71188
  markLineGroup.appendChild(lineObj);
70728
71189
  if (line.content) {
70729
- const textMaxLineWidth = this._scene._gantt.parsedOptions.timelineColWidth;
71190
+ const textMaxLineWidth = Math.max(this._scene._gantt.getDateColWidth(cellIndex), 1);
70730
71191
  const textContainerHeight = contentStyle.lineHeight || 18;
70731
71192
  const textGroup = new Group$2({
70732
71193
  x: this.markLineContainerWidth / 2,
@@ -71315,22 +71776,21 @@
71315
71776
  }
71316
71777
  }
71317
71778
  function generateLinkLinePoints(type, linkedFromTaskStartDate, linkedFromTaskEndDate, linkedFromTaskRecordRowIndex, linkedFromTaskTaskDays, linkedFromTaskIsMilestone, linkedToTaskStartDate, linkedToTaskEndDate, linkedToTaskRecordRowIndex, linkedToTaskTaskDays, linkedToTaskIsMilestone, gantt) {
71318
- const { unit, step } = gantt.parsedOptions.reverseSortedTimelineScales[0];
71319
- const { minDate, rowHeight, timelineColWidth } = gantt.parsedOptions;
71779
+ const { rowHeight } = gantt.parsedOptions;
71320
71780
  const taskBarMilestoneHypotenuse = gantt.parsedOptions.taskBarMilestoneHypotenuse;
71321
71781
  const distanceToTaskBar = gantt.parsedOptions.dependencyLinkDistanceToTaskBar ?? 20;
71322
71782
  const arrowWidth = 10;
71323
71783
  const arrowHeight = 5;
71324
71784
  let linePoints = [];
71325
71785
  let arrowPoints = [];
71786
+ const getStartX = (d) => gantt.getXByTime(d.getTime());
71787
+ const getEndX = (d) => gantt.getXByTime(d.getTime() + 1);
71326
71788
  if (type === DependencyType.FinishToStart) {
71327
- let linkFromPointX = computeCountToTimeScale(linkedFromTaskEndDate, minDate, unit, step, 1) * timelineColWidth;
71789
+ let linkFromPointX = getEndX(linkedFromTaskEndDate);
71328
71790
  if (linkedFromTaskIsMilestone) {
71329
- linkFromPointX =
71330
- computeCountToTimeScale(linkedFromTaskStartDate, minDate, unit, step, 1) * timelineColWidth +
71331
- taskBarMilestoneHypotenuse / 2;
71791
+ linkFromPointX = getStartX(linkedFromTaskStartDate) + taskBarMilestoneHypotenuse / 2;
71332
71792
  }
71333
- let linkToPointX = computeCountToTimeScale(linkedToTaskStartDate, minDate, unit, step) * timelineColWidth;
71793
+ let linkToPointX = getStartX(linkedToTaskStartDate);
71334
71794
  if (linkedToTaskIsMilestone) {
71335
71795
  linkToPointX -= taskBarMilestoneHypotenuse / 2;
71336
71796
  }
@@ -71389,15 +71849,13 @@
71389
71849
  ];
71390
71850
  }
71391
71851
  else if (type === DependencyType.StartToFinish) {
71392
- let linkFromPointX = computeCountToTimeScale(linkedFromTaskStartDate, minDate, unit, step) * timelineColWidth;
71852
+ let linkFromPointX = getStartX(linkedFromTaskStartDate);
71393
71853
  if (linkedFromTaskIsMilestone) {
71394
71854
  linkFromPointX -= taskBarMilestoneHypotenuse / 2;
71395
71855
  }
71396
- let linkToPointX = computeCountToTimeScale(linkedToTaskEndDate, minDate, unit, step, 1) * timelineColWidth;
71856
+ let linkToPointX = getEndX(linkedToTaskEndDate);
71397
71857
  if (linkedToTaskIsMilestone) {
71398
- linkToPointX =
71399
- computeCountToTimeScale(linkedToTaskStartDate, minDate, unit, step, 1) * timelineColWidth +
71400
- taskBarMilestoneHypotenuse / 2;
71858
+ linkToPointX = getStartX(linkedToTaskStartDate) + taskBarMilestoneHypotenuse / 2;
71401
71859
  }
71402
71860
  linePoints = [
71403
71861
  {
@@ -71454,11 +71912,11 @@
71454
71912
  ];
71455
71913
  }
71456
71914
  else if (type === DependencyType.StartToStart) {
71457
- let linkFromPointX = computeCountToTimeScale(linkedFromTaskStartDate, minDate, unit, step) * timelineColWidth;
71915
+ let linkFromPointX = getStartX(linkedFromTaskStartDate);
71458
71916
  if (linkedFromTaskIsMilestone) {
71459
71917
  linkFromPointX -= taskBarMilestoneHypotenuse / 2;
71460
71918
  }
71461
- let linkToPointX = computeCountToTimeScale(linkedToTaskStartDate, minDate, unit, step) * timelineColWidth;
71919
+ let linkToPointX = getStartX(linkedToTaskStartDate);
71462
71920
  if (linkedToTaskIsMilestone) {
71463
71921
  linkToPointX -= taskBarMilestoneHypotenuse / 2;
71464
71922
  }
@@ -71517,17 +71975,13 @@
71517
71975
  ];
71518
71976
  }
71519
71977
  else if (type === DependencyType.FinishToFinish) {
71520
- let linkFromPointX = computeCountToTimeScale(linkedFromTaskEndDate, minDate, unit, step, 1) * timelineColWidth;
71978
+ let linkFromPointX = getEndX(linkedFromTaskEndDate);
71521
71979
  if (linkedFromTaskIsMilestone) {
71522
- linkFromPointX =
71523
- computeCountToTimeScale(linkedFromTaskStartDate, minDate, unit, step, 1) * timelineColWidth +
71524
- taskBarMilestoneHypotenuse / 2;
71980
+ linkFromPointX = getStartX(linkedFromTaskStartDate) + taskBarMilestoneHypotenuse / 2;
71525
71981
  }
71526
- let linkToPointX = computeCountToTimeScale(linkedToTaskEndDate, minDate, unit, step, 1) * timelineColWidth;
71982
+ let linkToPointX = getEndX(linkedToTaskEndDate);
71527
71983
  if (linkedToTaskIsMilestone) {
71528
- linkToPointX =
71529
- computeCountToTimeScale(linkedToTaskStartDate, minDate, unit, step, 1) * timelineColWidth +
71530
- taskBarMilestoneHypotenuse / 2;
71984
+ linkToPointX = getStartX(linkedToTaskStartDate) + taskBarMilestoneHypotenuse / 2;
71531
71985
  }
71532
71986
  linePoints = [
71533
71987
  {
@@ -71584,8 +72038,7 @@
71584
72038
  return { linePoints, arrowPoints };
71585
72039
  }
71586
72040
  function updateLinkLinePoints(type, linkedFromTaskStartDate, linkedFromTaskEndDate, linkedFromTaskRecordRowIndex, linkedFromTaskTaskDays, linkedFromTaskIsMilestone, linkedFromMovedTaskBarNode, fromNodeDiffY, linkedToTaskStartDate, linkedToTaskEndDate, linkedToTaskRecordRowIndex, linkedToTaskTaskDays, linkedToTaskIsMilestone, linkedToMovedTaskBarNode, toNodeDiffY, gantt) {
71587
- const { unit, step } = gantt.parsedOptions.reverseSortedTimelineScales[0];
71588
- const { minDate, rowHeight, timelineColWidth } = gantt.parsedOptions;
72041
+ const { rowHeight } = gantt.parsedOptions;
71589
72042
  const taskBarMilestoneHypotenuse = gantt.parsedOptions.taskBarMilestoneHypotenuse;
71590
72043
  const milestoneTaskbarHeight = gantt.parsedOptions.taskBarMilestoneStyle.width;
71591
72044
  const distanceToTaskBar = gantt.parsedOptions.dependencyLinkDistanceToTaskBar ?? 20;
@@ -71593,21 +72046,22 @@
71593
72046
  const arrowHeight = 5;
71594
72047
  let linePoints = [];
71595
72048
  let arrowPoints = [];
72049
+ const getStartX = (d) => gantt.getXByTime(d.getTime());
72050
+ const getEndX = (d) => gantt.getXByTime(d.getTime() + 1);
71596
72051
  if (type === DependencyType.FinishToStart) {
71597
72052
  let linkFromPointX = linkedFromMovedTaskBarNode
71598
72053
  ? linkedFromMovedTaskBarNode.attribute.x + linkedFromMovedTaskBarNode.attribute.width
71599
- : computeCountToTimeScale(linkedFromTaskEndDate, minDate, unit, step, 1) * timelineColWidth;
72054
+ : getEndX(linkedFromTaskEndDate);
71600
72055
  if (linkedFromTaskIsMilestone) {
71601
72056
  linkFromPointX = linkedFromMovedTaskBarNode
71602
72057
  ? linkedFromMovedTaskBarNode.attribute.x +
71603
72058
  linkedFromMovedTaskBarNode.attribute.width +
71604
72059
  (taskBarMilestoneHypotenuse - milestoneTaskbarHeight) / 2
71605
- : computeCountToTimeScale(linkedFromTaskStartDate, minDate, unit, step, 1) * timelineColWidth +
71606
- taskBarMilestoneHypotenuse / 2;
72060
+ : getStartX(linkedFromTaskStartDate) + taskBarMilestoneHypotenuse / 2;
71607
72061
  }
71608
72062
  let linkToPointX = linkedToMovedTaskBarNode
71609
72063
  ? linkedToMovedTaskBarNode.attribute.x
71610
- : computeCountToTimeScale(linkedToTaskStartDate, minDate, unit, step) * timelineColWidth;
72064
+ : getStartX(linkedToTaskStartDate);
71611
72065
  if (linkedToTaskIsMilestone) {
71612
72066
  linkToPointX -= (taskBarMilestoneHypotenuse - milestoneTaskbarHeight) / 2;
71613
72067
  }
@@ -71670,20 +72124,19 @@
71670
72124
  else if (type === DependencyType.StartToFinish) {
71671
72125
  let linkFromPointX = linkedFromMovedTaskBarNode
71672
72126
  ? linkedFromMovedTaskBarNode.attribute.x
71673
- : computeCountToTimeScale(linkedFromTaskStartDate, minDate, unit, step) * timelineColWidth;
72127
+ : getStartX(linkedFromTaskStartDate);
71674
72128
  if (linkedFromTaskIsMilestone) {
71675
72129
  linkFromPointX -= (taskBarMilestoneHypotenuse - milestoneTaskbarHeight) / 2;
71676
72130
  }
71677
72131
  let linkToPointX = linkedToMovedTaskBarNode
71678
72132
  ? linkedToMovedTaskBarNode.attribute.x + linkedToMovedTaskBarNode.attribute.width
71679
- : computeCountToTimeScale(linkedToTaskEndDate, minDate, unit, step, 1) * timelineColWidth;
72133
+ : getEndX(linkedToTaskEndDate);
71680
72134
  if (linkedToTaskIsMilestone) {
71681
72135
  linkToPointX = linkedToMovedTaskBarNode
71682
72136
  ? linkedToMovedTaskBarNode.attribute.x +
71683
72137
  linkedToMovedTaskBarNode.attribute.width +
71684
72138
  (taskBarMilestoneHypotenuse - milestoneTaskbarHeight) / 2
71685
- : computeCountToTimeScale(linkedToTaskStartDate, minDate, unit, step, 1) * timelineColWidth +
71686
- taskBarMilestoneHypotenuse / 2;
72139
+ : getStartX(linkedToTaskStartDate) + taskBarMilestoneHypotenuse / 2;
71687
72140
  }
71688
72141
  linePoints = [
71689
72142
  {
@@ -71744,13 +72197,13 @@
71744
72197
  else if (type === DependencyType.StartToStart) {
71745
72198
  let linkFromPointX = linkedFromMovedTaskBarNode
71746
72199
  ? linkedFromMovedTaskBarNode.attribute.x
71747
- : computeCountToTimeScale(linkedFromTaskStartDate, minDate, unit, step) * timelineColWidth;
72200
+ : getStartX(linkedFromTaskStartDate);
71748
72201
  if (linkedFromTaskIsMilestone) {
71749
72202
  linkFromPointX -= (taskBarMilestoneHypotenuse - milestoneTaskbarHeight) / 2;
71750
72203
  }
71751
72204
  let linkToPointX = linkedToMovedTaskBarNode
71752
72205
  ? linkedToMovedTaskBarNode.attribute.x
71753
- : computeCountToTimeScale(linkedToTaskStartDate, minDate, unit, step) * timelineColWidth;
72206
+ : getStartX(linkedToTaskStartDate);
71754
72207
  if (linkedToTaskIsMilestone) {
71755
72208
  linkToPointX -= (taskBarMilestoneHypotenuse - milestoneTaskbarHeight) / 2;
71756
72209
  }
@@ -71813,25 +72266,23 @@
71813
72266
  else if (type === DependencyType.FinishToFinish) {
71814
72267
  let linkFromPointX = linkedFromMovedTaskBarNode
71815
72268
  ? linkedFromMovedTaskBarNode.attribute.x + linkedFromMovedTaskBarNode.attribute.width
71816
- : computeCountToTimeScale(linkedFromTaskEndDate, minDate, unit, step, 1) * timelineColWidth;
72269
+ : getEndX(linkedFromTaskEndDate);
71817
72270
  if (linkedFromTaskIsMilestone) {
71818
72271
  linkFromPointX = linkedFromMovedTaskBarNode
71819
72272
  ? linkedFromMovedTaskBarNode.attribute.x +
71820
72273
  linkedFromMovedTaskBarNode.attribute.width +
71821
72274
  (taskBarMilestoneHypotenuse - milestoneTaskbarHeight) / 2
71822
- : computeCountToTimeScale(linkedFromTaskStartDate, minDate, unit, step, 1) * timelineColWidth +
71823
- taskBarMilestoneHypotenuse / 2;
72275
+ : getStartX(linkedFromTaskStartDate) + taskBarMilestoneHypotenuse / 2;
71824
72276
  }
71825
72277
  let linkToPointX = linkedToMovedTaskBarNode
71826
72278
  ? linkedToMovedTaskBarNode.attribute.x + linkedToMovedTaskBarNode.attribute.width
71827
- : computeCountToTimeScale(linkedToTaskEndDate, minDate, unit, step, 1) * timelineColWidth;
72279
+ : getEndX(linkedToTaskEndDate);
71828
72280
  if (linkedToTaskIsMilestone) {
71829
72281
  linkToPointX = linkedToMovedTaskBarNode
71830
72282
  ? linkedToMovedTaskBarNode.attribute.x +
71831
72283
  linkedToMovedTaskBarNode.attribute.width +
71832
72284
  (taskBarMilestoneHypotenuse - milestoneTaskbarHeight) / 2
71833
- : computeCountToTimeScale(linkedToTaskStartDate, minDate, unit, step, 1) * timelineColWidth +
71834
- taskBarMilestoneHypotenuse / 2;
72285
+ : getStartX(linkedToTaskStartDate) + taskBarMilestoneHypotenuse / 2;
71835
72286
  }
71836
72287
  linePoints = [
71837
72288
  {
@@ -74151,7 +74602,7 @@
74151
74602
  gantt._updateSize();
74152
74603
  gantt.scenegraph.refreshAll();
74153
74604
  target = this.moveTaskBar.target = gantt.scenegraph.taskBar.getTaskBarNodeByIndex(this.moveTaskBar.target.task_index, this.moveTaskBar.target.sub_task_index);
74154
- gantt.scrollLeft = gantt.parsedOptions.timelineColWidth - 1;
74605
+ gantt.scrollLeft = Math.max(0, gantt.getDateColWidth(0) - 1);
74155
74606
  gantt.eventManager.lastDragPointerXYOnWindow.x = e.x;
74156
74607
  if (target.record?.type === 'milestone') {
74157
74608
  moveTaskBar(target, gantt.scrollLeft - target.attribute.x, 0, this);
@@ -74161,7 +74612,9 @@
74161
74612
  }
74162
74613
  }
74163
74614
  else {
74164
- this.moveTaskBar.moveTaskBarXSpeed = -gantt.parsedOptions.timelineColWidth / 100;
74615
+ const colCount = gantt.parsedOptions.reverseSortedTimelineScales[0].timelineDates?.length ?? 0;
74616
+ const avgColWidth = gantt.getAllDateColsWidth() / Math.max(1, colCount);
74617
+ this.moveTaskBar.moveTaskBarXSpeed = -avgColWidth / 100;
74165
74618
  this.moveTaskBar.moveTaskBarXInertia.startInertia(this.moveTaskBar.moveTaskBarXSpeed, 0, 1);
74166
74619
  this.moveTaskBar.moveTaskBarXInertia.setScrollHandle((dx, dy) => {
74167
74620
  this.moveTaskBar.deltaX += dx;
@@ -74199,7 +74652,9 @@
74199
74652
  }
74200
74653
  }
74201
74654
  else {
74202
- this.moveTaskBar.moveTaskBarXSpeed = gantt.parsedOptions.timelineColWidth / 100;
74655
+ const colCount = gantt.parsedOptions.reverseSortedTimelineScales[0].timelineDates?.length ?? 0;
74656
+ const avgColWidth = gantt.getAllDateColsWidth() / Math.max(1, colCount);
74657
+ this.moveTaskBar.moveTaskBarXSpeed = avgColWidth / 100;
74203
74658
  this.moveTaskBar.moveTaskBarXInertia.startInertia(this.moveTaskBar.moveTaskBarXSpeed, 0, 1);
74204
74659
  this.moveTaskBar.moveTaskBarXInertia.setScrollHandle((dx, dy) => {
74205
74660
  this.moveTaskBar.deltaX += dx;
@@ -75998,6 +76453,10 @@
75998
76453
  parsedOptions = {};
75999
76454
  millisecondsPerPixel;
76000
76455
  zoomScaleManager;
76456
+ _timelineColWidths = [];
76457
+ _timelineColX = [];
76458
+ _timelineColStartTimes = [];
76459
+ _timelineColEndTimes = [];
76001
76460
  recalculateTimeScale() {
76002
76461
  if (this.zoomScaleManager) {
76003
76462
  this.zoomScaleManager.recalculateTimeScale();
@@ -76324,6 +76783,7 @@
76324
76783
  if (record) {
76325
76784
  return (record.children?.length || 1) * this.parsedOptions.rowHeight;
76326
76785
  }
76786
+ return undefined;
76327
76787
  };
76328
76788
  listTable_options.defaultRowHeight = 'auto';
76329
76789
  listTable_options.customConfig = { forceComputeAllRowHeight: true };
@@ -76335,6 +76795,7 @@
76335
76795
  if (record) {
76336
76796
  return computeRowsCountByRecordDateForCompact(this, record) * this.parsedOptions.rowHeight;
76337
76797
  }
76798
+ return undefined;
76338
76799
  };
76339
76800
  listTable_options.defaultRowHeight = 'auto';
76340
76801
  listTable_options.customConfig = { forceComputeAllRowHeight: true };
@@ -76346,6 +76807,7 @@
76346
76807
  if (record) {
76347
76808
  return computeRowsCountByRecordDate(this, record) * this.parsedOptions.rowHeight;
76348
76809
  }
76810
+ return undefined;
76349
76811
  };
76350
76812
  listTable_options.defaultRowHeight = 'auto';
76351
76813
  listTable_options.customConfig = { forceComputeAllRowHeight: true };
@@ -76409,6 +76871,151 @@
76409
76871
  scale.timelineDates = generateTimeLineDate(new Date(this.parsedOptions.minDate), this.parsedOptions.maxDate, scale);
76410
76872
  }
76411
76873
  }
76874
+ this._rebuildTimelineColXMap();
76875
+ }
76876
+ _rebuildTimelineColXMap() {
76877
+ const minScale = this.parsedOptions.reverseSortedTimelineScales?.[0];
76878
+ const timelineDates = minScale?.timelineDates ?? [];
76879
+ const baseWidth = this.parsedOptions.timelineColWidth ?? 0;
76880
+ const hideWeekend = this.options?.timelineHeader?.hideWeekend === true;
76881
+ const weekendColWidth = this.options?.timelineHeader?.weekendColWidth;
76882
+ const enableWeekendWidth = minScale?.unit === 'day' && minScale?.step === 1 && (hideWeekend || weekendColWidth !== undefined);
76883
+ this._timelineColWidths = new Array(timelineDates.length);
76884
+ this._timelineColX = new Array(timelineDates.length + 1);
76885
+ this._timelineColStartTimes = new Array(timelineDates.length);
76886
+ this._timelineColEndTimes = new Array(timelineDates.length);
76887
+ this._timelineColX[0] = 0;
76888
+ let sumX = 0;
76889
+ for (let i = 0; i < timelineDates.length; i++) {
76890
+ const d = timelineDates[i];
76891
+ const startTime = d.startDate?.getTime?.() ?? 0;
76892
+ const endTime = d.endDate?.getTime?.() ?? startTime;
76893
+ this._timelineColStartTimes[i] = startTime;
76894
+ this._timelineColEndTimes[i] = endTime;
76895
+ let w = baseWidth;
76896
+ if (enableWeekendWidth) {
76897
+ const day = d.startDate.getDay();
76898
+ const isWeekend = day === 0 || day === 6;
76899
+ if (isWeekend) {
76900
+ if (hideWeekend) {
76901
+ w = 0;
76902
+ }
76903
+ else if (typeof weekendColWidth === 'number') {
76904
+ w = weekendColWidth;
76905
+ }
76906
+ else if (typeof weekendColWidth === 'function') {
76907
+ w = weekendColWidth(baseWidth);
76908
+ }
76909
+ }
76910
+ }
76911
+ w = Math.max(0, Number.isFinite(w) ? w : baseWidth);
76912
+ this._timelineColWidths[i] = w;
76913
+ sumX += w;
76914
+ this._timelineColX[i + 1] = sumX;
76915
+ }
76916
+ }
76917
+ getXByTime(time) {
76918
+ const startTimes = this._timelineColStartTimes;
76919
+ const endTimes = this._timelineColEndTimes;
76920
+ const widths = this._timelineColWidths;
76921
+ const xPrefix = this._timelineColX;
76922
+ if (!startTimes?.length || !endTimes?.length || !widths?.length || !xPrefix?.length) {
76923
+ return 0;
76924
+ }
76925
+ if (time <= startTimes[0]) {
76926
+ return 0;
76927
+ }
76928
+ const lastIndex = endTimes.length - 1;
76929
+ if (time > endTimes[lastIndex]) {
76930
+ return xPrefix[lastIndex + 1] ?? 0;
76931
+ }
76932
+ let low = 0;
76933
+ let high = lastIndex;
76934
+ while (low <= high) {
76935
+ const mid = (low + high) >> 1;
76936
+ const st = startTimes[mid];
76937
+ const et = endTimes[mid];
76938
+ if (time < st) {
76939
+ high = mid - 1;
76940
+ }
76941
+ else if (time > et) {
76942
+ low = mid + 1;
76943
+ }
76944
+ else {
76945
+ const duration = Math.max(1, et - st + 1);
76946
+ const offset = (time - st) / duration;
76947
+ return (xPrefix[mid] ?? 0) + (widths[mid] ?? 0) * offset;
76948
+ }
76949
+ }
76950
+ const idx = Math.max(0, Math.min(lastIndex, high));
76951
+ const st = startTimes[idx];
76952
+ const et = endTimes[idx];
76953
+ const duration = Math.max(1, et - st + 1);
76954
+ const offset = Math.max(0, Math.min(1, (time - st) / duration));
76955
+ return (xPrefix[idx] ?? 0) + (widths[idx] ?? 0) * offset;
76956
+ }
76957
+ getDateIndexByTime(time) {
76958
+ const startTimes = this._timelineColStartTimes;
76959
+ const endTimes = this._timelineColEndTimes;
76960
+ if (!startTimes?.length || !endTimes?.length) {
76961
+ return 0;
76962
+ }
76963
+ if (time <= startTimes[0]) {
76964
+ return 0;
76965
+ }
76966
+ const lastIndex = endTimes.length - 1;
76967
+ if (time > endTimes[lastIndex]) {
76968
+ return lastIndex;
76969
+ }
76970
+ let low = 0;
76971
+ let high = lastIndex;
76972
+ while (low <= high) {
76973
+ const mid = (low + high) >> 1;
76974
+ const st = startTimes[mid];
76975
+ const et = endTimes[mid];
76976
+ if (time < st) {
76977
+ high = mid - 1;
76978
+ }
76979
+ else if (time > et) {
76980
+ low = mid + 1;
76981
+ }
76982
+ else {
76983
+ return mid;
76984
+ }
76985
+ }
76986
+ return Math.max(0, Math.min(lastIndex, high));
76987
+ }
76988
+ getDateIndexByX(x) {
76989
+ const totalX = x + this.stateManager.scroll.horizontalBarPos;
76990
+ const xPrefix = this._timelineColX;
76991
+ if (!xPrefix?.length) {
76992
+ return 0;
76993
+ }
76994
+ if (totalX <= 0) {
76995
+ return 0;
76996
+ }
76997
+ const lastIndex = xPrefix.length - 2;
76998
+ const totalWidth = xPrefix[lastIndex + 1] ?? 0;
76999
+ if (totalX >= totalWidth) {
77000
+ return Math.max(0, lastIndex);
77001
+ }
77002
+ let low = 0;
77003
+ let high = lastIndex;
77004
+ while (low <= high) {
77005
+ const mid = (low + high) >> 1;
77006
+ const left = xPrefix[mid] ?? 0;
77007
+ const right = xPrefix[mid + 1] ?? left;
77008
+ if (totalX < left) {
77009
+ high = mid - 1;
77010
+ }
77011
+ else if (totalX >= right) {
77012
+ low = mid + 1;
77013
+ }
77014
+ else {
77015
+ return mid;
77016
+ }
77017
+ }
77018
+ return Math.max(0, Math.min(lastIndex, low));
76412
77019
  }
76413
77020
  getRowHeightByIndex(index) {
76414
77021
  if (this.taskListTableInstance) {
@@ -76437,6 +77044,10 @@
76437
77044
  }, 0);
76438
77045
  }
76439
77046
  getAllDateColsWidth() {
77047
+ const xPrefix = this._timelineColX;
77048
+ if (xPrefix?.length) {
77049
+ return xPrefix[xPrefix.length - 1] ?? 0;
77050
+ }
76440
77051
  return (this.parsedOptions.timelineColWidth *
76441
77052
  (this.parsedOptions.reverseSortedTimelineScales[0].timelineDates?.length ?? 0));
76442
77053
  }
@@ -76533,6 +77144,53 @@
76533
77144
  progress
76534
77145
  };
76535
77146
  }
77147
+ getBaselineInfoByTaskListIndex(taskShowIndex, sub_task_index) {
77148
+ const taskRecord = this.getRecordByIndex(taskShowIndex, sub_task_index);
77149
+ const baselineStartDateField = this.parsedOptions.baselineStartDateField;
77150
+ const baselineEndDateField = this.parsedOptions.baselineEndDateField;
77151
+ if (!baselineStartDateField ||
77152
+ !baselineEndDateField ||
77153
+ !taskRecord?.[baselineStartDateField] ||
77154
+ !taskRecord?.[baselineEndDateField]) {
77155
+ return {
77156
+ baselineStartDate: null,
77157
+ baselineEndDate: null,
77158
+ baselineDays: 0
77159
+ };
77160
+ }
77161
+ const rawBaselineStartDateTime = createDateAtMidnight(taskRecord?.[baselineStartDateField]).getTime();
77162
+ const rawBaselineEndDateTime = createDateAtMidnight(taskRecord?.[baselineEndDateField]).getTime();
77163
+ if (rawBaselineEndDateTime < this.parsedOptions._minDateTime ||
77164
+ rawBaselineStartDateTime > this.parsedOptions._maxDateTime) {
77165
+ return {
77166
+ baselineStartDate: null,
77167
+ baselineEndDate: null,
77168
+ baselineDays: 0
77169
+ };
77170
+ }
77171
+ let baselineStartDate;
77172
+ let baselineEndDate;
77173
+ if (this.parsedOptions.timeScaleIncludeHour) {
77174
+ baselineStartDate = createDateAtMidnight(Math.min(Math.max(this.parsedOptions._minDateTime, rawBaselineStartDateTime), this.parsedOptions._maxDateTime));
77175
+ const rawEnd = taskRecord?.[baselineEndDateField];
77176
+ let hasMillisecondProvided = false;
77177
+ if (typeof rawEnd === 'string') {
77178
+ hasMillisecondProvided = /:\d{2}\.\d+/.test(rawEnd);
77179
+ }
77180
+ const shouldForceMillisecond = !hasMillisecondProvided;
77181
+ baselineEndDate = createDateAtLastMillisecond(Math.max(Math.min(this.parsedOptions._maxDateTime, rawBaselineEndDateTime), this.parsedOptions._minDateTime), shouldForceMillisecond);
77182
+ }
77183
+ else {
77184
+ baselineStartDate = createDateAtMidnight(Math.min(Math.max(this.parsedOptions._minDateTime, rawBaselineStartDateTime), this.parsedOptions._maxDateTime), true);
77185
+ baselineEndDate = createDateAtLastHour(Math.max(Math.min(this.parsedOptions._maxDateTime, rawBaselineEndDateTime), this.parsedOptions._minDateTime), true);
77186
+ }
77187
+ const baselineDays = (baselineEndDate.getTime() - baselineStartDate.getTime() + 1) / (1000 * 60 * 60 * 24);
77188
+ return {
77189
+ baselineStartDate,
77190
+ baselineEndDate,
77191
+ baselineDays
77192
+ };
77193
+ }
76536
77194
  _updateStartDateToTaskRecord(startDate, index, sub_task_index) {
76537
77195
  const taskRecord = this.getRecordByIndex(index, sub_task_index);
76538
77196
  const startDateField = this.parsedOptions.startDateField;
@@ -76791,10 +77449,7 @@
76791
77449
  }
76792
77450
  _scrollToMarkLine() {
76793
77451
  if (this.parsedOptions.scrollToMarkLineDate && this.parsedOptions.minDate) {
76794
- const minDate = this.parsedOptions.minDate;
76795
- const { unit, step } = this.parsedOptions.reverseSortedTimelineScales[0];
76796
- const count = computeCountToTimeScale(this.parsedOptions.scrollToMarkLineDate, minDate, unit, step);
76797
- const targetDayDistance = count * this.parsedOptions.timelineColWidth;
77452
+ const targetDayDistance = this.getXByTime(this.parsedOptions.scrollToMarkLineDate.getTime());
76798
77453
  const left = targetDayDistance - this.tableNoFrameWidth / 2;
76799
77454
  this.stateManager.setScrollLeft(left);
76800
77455
  }
@@ -76803,10 +77458,7 @@
76803
77458
  if (!date || !this.parsedOptions.minDate) {
76804
77459
  return;
76805
77460
  }
76806
- const minDate = this.parsedOptions.minDate;
76807
- const { unit, step } = this.parsedOptions.reverseSortedTimelineScales[0];
76808
- const count = computeCountToTimeScale(date, minDate, unit, step);
76809
- const targetDayDistance = count * this.parsedOptions.timelineColWidth;
77461
+ const targetDayDistance = this.getXByTime(date.getTime());
76810
77462
  const left = targetDayDistance - this.tableNoFrameWidth / 2;
76811
77463
  this.stateManager.setScrollLeft(left);
76812
77464
  }
@@ -76858,9 +77510,22 @@
76858
77510
  };
76859
77511
  }
76860
77512
  getDateColWidth(dateIndex) {
77513
+ const widths = this._timelineColWidths;
77514
+ if (widths?.length && dateIndex >= 0 && dateIndex < widths.length) {
77515
+ return widths[dateIndex] ?? 0;
77516
+ }
76861
77517
  return this.parsedOptions.timelineColWidth;
76862
77518
  }
76863
77519
  getDateColsWidth(startDateIndex, endDateIndex) {
77520
+ const xPrefix = this._timelineColX;
77521
+ if (xPrefix?.length) {
77522
+ const start = Math.max(0, Math.min(startDateIndex, xPrefix.length - 1));
77523
+ const end = Math.max(0, Math.min(endDateIndex + 1, xPrefix.length - 1));
77524
+ if (end <= start) {
77525
+ return 0;
77526
+ }
77527
+ return (xPrefix[end] ?? 0) - (xPrefix[start] ?? 0);
77528
+ }
76864
77529
  return (endDateIndex - startDateIndex + 1) * this.parsedOptions.timelineColWidth;
76865
77530
  }
76866
77531
  getDateRangeByIndex(index) {
@@ -76899,6 +77564,21 @@
76899
77564
  }
76900
77565
  return style;
76901
77566
  }
77567
+ getBaselineStyle(task_index, sub_task_index) {
77568
+ const { startDate, endDate, taskRecord } = this.getTaskInfoByTaskListIndex(task_index, sub_task_index);
77569
+ const style = this.parsedOptions.baselineStyle;
77570
+ if (typeof style === 'function') {
77571
+ const args = {
77572
+ index: task_index,
77573
+ startDate,
77574
+ endDate,
77575
+ taskRecord,
77576
+ ganttInstance: this
77577
+ };
77578
+ return style(args);
77579
+ }
77580
+ return style;
77581
+ }
76902
77582
  formatDate(date, format) {
76903
77583
  return formatDate(date instanceof Date ? date : new Date(date), format);
76904
77584
  }
@@ -76967,7 +77647,7 @@
76967
77647
  PluginManager: PluginManager
76968
77648
  });
76969
77649
 
76970
- const version = "1.23.3-alpha.0";
77650
+ const version = "1.24.0";
76971
77651
 
76972
77652
  exports.Gantt = Gantt;
76973
77653
  exports.TYPES = index$4;