@visactor/vtable-gantt 1.23.3 → 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 (51) hide show
  1. package/cjs/Gantt.d.ts +8 -0
  2. package/cjs/Gantt.js +91 -9
  3. package/cjs/Gantt.js.map +1 -1
  4. package/cjs/gantt-helper.js +1 -2
  5. package/cjs/gantt-helper.js.map +1 -1
  6. package/cjs/index.d.ts +1 -1
  7. package/cjs/index.js +1 -1
  8. package/cjs/index.js.map +1 -1
  9. package/cjs/plugins/index.js.map +1 -1
  10. package/cjs/scenegraph/dependency-link.js +28 -38
  11. package/cjs/scenegraph/dependency-link.js.map +1 -1
  12. package/cjs/scenegraph/grid.js +8 -7
  13. package/cjs/scenegraph/grid.js.map +1 -1
  14. package/cjs/scenegraph/mark-line.js +10 -12
  15. package/cjs/scenegraph/mark-line.js.map +1 -1
  16. package/cjs/scenegraph/task-bar.js +3 -7
  17. package/cjs/scenegraph/task-bar.js.map +1 -1
  18. package/cjs/scenegraph/timeline-header.js +1 -4
  19. package/cjs/scenegraph/timeline-header.js.map +1 -1
  20. package/cjs/state/state-manager.js +22 -18
  21. package/cjs/state/state-manager.js.map +1 -1
  22. package/cjs/tools/isx.d.ts +1 -1
  23. package/cjs/ts-types/gantt-engine.d.ts +2 -0
  24. package/cjs/ts-types/gantt-engine.js.map +1 -1
  25. package/dist/vtable-gantt.js +1256 -801
  26. package/dist/vtable-gantt.min.js +2 -2
  27. package/es/Gantt.d.ts +8 -0
  28. package/es/Gantt.js +92 -8
  29. package/es/Gantt.js.map +1 -1
  30. package/es/gantt-helper.js +1 -2
  31. package/es/gantt-helper.js.map +1 -1
  32. package/es/index.d.ts +1 -1
  33. package/es/index.js +1 -1
  34. package/es/index.js.map +1 -1
  35. package/es/plugins/index.js.map +1 -1
  36. package/es/scenegraph/dependency-link.js +29 -27
  37. package/es/scenegraph/dependency-link.js.map +1 -1
  38. package/es/scenegraph/grid.js +6 -8
  39. package/es/scenegraph/grid.js.map +1 -1
  40. package/es/scenegraph/mark-line.js +10 -11
  41. package/es/scenegraph/mark-line.js.map +1 -1
  42. package/es/scenegraph/task-bar.js +4 -5
  43. package/es/scenegraph/task-bar.js.map +1 -1
  44. package/es/scenegraph/timeline-header.js +2 -3
  45. package/es/scenegraph/timeline-header.js.map +1 -1
  46. package/es/state/state-manager.js +22 -18
  47. package/es/state/state-manager.js.map +1 -1
  48. package/es/tools/isx.d.ts +1 -1
  49. package/es/ts-types/gantt-engine.d.ts +2 -0
  50. package/es/ts-types/gantt-engine.js.map +1 -1
  51. package/package.json +4 -4
@@ -34894,500 +34894,6 @@
34894
34894
  registed || (registed = !0, preLoadAllModule(), isBrowserEnv() ? loadBrowserEnv(container) : isNodeEnv() && loadNodeEnv(container), registerArc(), registerCircle(), registerGroup(), registerImage(), registerLine(), registerRect(), registerRichtext(), registerShadowRoot(), registerSymbol(), registerText(), registerFlexLayoutPlugin(), loadPoptip(), registerFlexLayoutPlugin());
34895
34895
  }
34896
34896
 
34897
- function throttle$1(func, delay) {
34898
- let timer = null;
34899
- return function (...args) {
34900
- if (!timer) {
34901
- func.apply(this, args);
34902
- timer = setTimeout(() => {
34903
- timer = null;
34904
- }, delay);
34905
- }
34906
- };
34907
- }
34908
- function getTodayNearDay(dayOffset, format) {
34909
- const today = new Date();
34910
- const todayTime = today.getTime();
34911
- const oneDayTime = 24 * 60 * 60 * 1000;
34912
- const targetTime = todayTime + dayOffset * oneDayTime;
34913
- const date = new Date(targetTime);
34914
- if (format) {
34915
- const year = date.getFullYear().toString();
34916
- const month = (date.getMonth() + 1).toString().padStart(2, '0');
34917
- const day = date.getDate().toString().padStart(2, '0');
34918
- format = format.replace('yyyy', year);
34919
- format = format.replace('mm', month);
34920
- format = format.replace('dd', day);
34921
- return format;
34922
- }
34923
- return date;
34924
- }
34925
- function formatDate(date, format) {
34926
- const year = date.getFullYear().toString();
34927
- const month = (date.getMonth() + 1).toString().padStart(2, '0');
34928
- const day = date.getDate().toString().padStart(2, '0');
34929
- format = format.replace('yyyy', year);
34930
- format = format.replace('mm', month);
34931
- format = format.replace('dd', day);
34932
- if (format.length > 10) {
34933
- const hour = date.getHours().toString().padStart(2, '0');
34934
- const minute = date.getMinutes().toString().padStart(2, '0');
34935
- const second = date.getSeconds().toString().padStart(2, '0');
34936
- format = format.replace('hh', hour);
34937
- format = format.replace('mm', minute);
34938
- format = format.replace('ss', second);
34939
- }
34940
- return format;
34941
- }
34942
- function validateDate(dateParts, format) {
34943
- const yearIndex = format.indexOf('yyyy');
34944
- const monthIndex = format.indexOf('mm');
34945
- const dayIndex = format.indexOf('dd');
34946
- const dateYearIndex = yearIndex < monthIndex ? (yearIndex < dayIndex ? 0 : 1) : monthIndex < dayIndex ? 1 : 2;
34947
- const dateMonthIndex = monthIndex < yearIndex ? (monthIndex < dayIndex ? 0 : 1) : monthIndex < dayIndex ? 1 : 2;
34948
- const dateDayIndex = dayIndex < yearIndex ? (dayIndex < monthIndex ? 0 : 1) : dayIndex < monthIndex ? 1 : 2;
34949
- const year = parseInt(dateParts[dateYearIndex], 10);
34950
- const month = parseInt(dateParts[dateMonthIndex], 10) - 1;
34951
- const day = parseInt(dateParts[dateDayIndex], 10);
34952
- if (isNaN(year) || year < 1) {
34953
- return false;
34954
- }
34955
- if (isNaN(month) || month < 0 || month > 11) {
34956
- return false;
34957
- }
34958
- const daysInMonth = [31, isLeapYear(year) ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
34959
- if (isNaN(day) || day < 1 || day > daysInMonth[month]) {
34960
- return false;
34961
- }
34962
- return true;
34963
- }
34964
- function validateTime(dateParts, format) {
34965
- if (format.includes('hh') || format.includes('mm') || format.includes('ss')) {
34966
- const timeIndex = format.indexOf('hh') > -1 ? format.indexOf('hh') : format.indexOf('HH');
34967
- const hour = parseInt(dateParts[timeIndex], 10);
34968
- const minute = parseInt(dateParts[timeIndex + 1], 10);
34969
- const second = dateParts.length > timeIndex + 2 ? parseInt(dateParts[timeIndex + 2], 10) : 0;
34970
- if (isNaN(hour) || hour < 0 || hour > 23) {
34971
- return false;
34972
- }
34973
- if (isNaN(minute) || minute < 0 || minute > 59) {
34974
- return false;
34975
- }
34976
- if (isNaN(second) || second < 0 || second > 59) {
34977
- return false;
34978
- }
34979
- }
34980
- return true;
34981
- }
34982
- function isLeapYear(year) {
34983
- return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
34984
- }
34985
- function parseDateFormat(dateString) {
34986
- const formats = [
34987
- 'yyyy-mm-dd',
34988
- 'dd-mm-yyyy',
34989
- 'mm/dd/yyyy',
34990
- 'yyyy/mm/dd',
34991
- 'dd/mm/yyyy',
34992
- 'yyyy.mm.dd',
34993
- 'mm.dd.yyyy',
34994
- 'dd.mm.yyyy'
34995
- ];
34996
- const timeFormat = ['hh:mm:ss', 'hh:mm'];
34997
- dateString = dateString.trim();
34998
- const dates = dateString.split(' ');
34999
- const date = dates[0];
35000
- const time = dates[1];
35001
- let dateFormatMatched;
35002
- let timeFormatMatched;
35003
- if (date) {
35004
- for (let i = 0; i < formats.length; i++) {
35005
- const format = formats[i];
35006
- const dateParts = date.split(getSeparator(format));
35007
- const isValid = validateDate(dateParts, format);
35008
- if (dateParts.length === 3 && isValid) {
35009
- dateFormatMatched = format;
35010
- break;
35011
- }
35012
- }
35013
- }
35014
- if (dateFormatMatched) {
35015
- if (time) {
35016
- for (let i = 0; i < timeFormat.length; i++) {
35017
- const format = timeFormat[i];
35018
- const timeParts = time.split(getSeparator(format));
35019
- const formatParts = format.split(getSeparator(format));
35020
- const isValid = validateTime(timeParts, format);
35021
- if (isValid && timeParts.length === formatParts.length) {
35022
- timeFormatMatched = format;
35023
- break;
35024
- }
35025
- }
35026
- }
35027
- }
35028
- if (date && time && dateFormatMatched && timeFormatMatched) {
35029
- return dateFormatMatched + ' ' + timeFormatMatched;
35030
- }
35031
- if (date && !time) {
35032
- return dateFormatMatched;
35033
- }
35034
- return 'yyyy-mm-dd hh:mm:ss';
35035
- }
35036
- function getSeparator(format) {
35037
- const separators = format.match(/[^\w]/g);
35038
- if (separators) {
35039
- const escapedSeparators = separators.map(s => '\\' + s).join('|');
35040
- return new RegExp(escapedSeparators, 'g');
35041
- }
35042
- return /[^\w]/;
35043
- }
35044
- function parseStringTemplate(template, data) {
35045
- const result = template.replace(/\{([^}]+)\}/g, (match, key) => {
35046
- const keys = key.split('.');
35047
- let value = data;
35048
- for (const k of keys) {
35049
- if (value.hasOwnProperty(k)) {
35050
- value = value[k];
35051
- }
35052
- else {
35053
- value = match;
35054
- break;
35055
- }
35056
- }
35057
- return value;
35058
- });
35059
- return result;
35060
- }
35061
- function toBoxArray$2(obj) {
35062
- if (!Array.isArray(obj)) {
35063
- return [obj, obj, obj, obj];
35064
- }
35065
- if (obj.length === 3) {
35066
- return [obj[0], obj[1], obj[2], obj[1]];
35067
- }
35068
- if (obj.length === 2) {
35069
- return [obj[0], obj[1], obj[0], obj[1]];
35070
- }
35071
- if (obj.length === 1) {
35072
- return [obj[0], obj[0], obj[0], obj[0]];
35073
- }
35074
- return [obj[0], obj[1], obj[2], obj[3]];
35075
- }
35076
- function getWeekNumber(currentDate) {
35077
- const startOfYear = new Date(currentDate.getFullYear(), 0, 1);
35078
- const weekNumber = Math.ceil(((currentDate.getTime() + 1 - startOfYear.getTime()) / 86400000 + 1) / 7);
35079
- return weekNumber;
35080
- }
35081
- function getWeekday(dateString, format = 'long') {
35082
- const days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
35083
- const date = new Date(dateString);
35084
- if (format === 'short') {
35085
- return days[date.getDay()].substr(0, 3);
35086
- }
35087
- else if (format === 'long') {
35088
- return days[date.getDay()];
35089
- }
35090
- return 'Invalid format specified. Please use "short" or "long".';
35091
- }
35092
- function isPropertyWritable(obj, prop) {
35093
- const descriptor = Object.getOwnPropertyDescriptor(obj, prop);
35094
- if (!descriptor) {
35095
- return false;
35096
- }
35097
- return !!descriptor.set || descriptor.writable === true;
35098
- }
35099
- function createDateAtMidnight(dateStr, forceMidnight = false) {
35100
- let date;
35101
- if (dateStr) {
35102
- date = new Date(dateStr);
35103
- if (typeof dateStr === 'string') {
35104
- if (dateStr.length > 10) {
35105
- if (forceMidnight) {
35106
- date.setHours(0, 0, 0, 0);
35107
- }
35108
- return date;
35109
- }
35110
- date.setHours(0, 0, 0, 0);
35111
- }
35112
- }
35113
- else {
35114
- date = new Date();
35115
- }
35116
- if (forceMidnight) {
35117
- date.setHours(0, 0, 0, 0);
35118
- }
35119
- return date;
35120
- }
35121
- function createDateAtLastMinute(dateStr, forceSetMinute = false) {
35122
- let date;
35123
- if (dateStr) {
35124
- date = new Date(dateStr);
35125
- if (typeof dateStr === 'string') {
35126
- if (dateStr.length > 10) {
35127
- if (forceSetMinute) {
35128
- date.setMinutes(59, 59, 999);
35129
- }
35130
- return date;
35131
- }
35132
- date.setMinutes(59, 59, 999);
35133
- }
35134
- }
35135
- else {
35136
- date = new Date();
35137
- }
35138
- if (forceSetMinute) {
35139
- date.setMinutes(59, 59, 999);
35140
- }
35141
- return date;
35142
- }
35143
- function createDateAtLastSecond(dateStr, forceSetSecond = false) {
35144
- let date;
35145
- if (dateStr) {
35146
- date = new Date(dateStr);
35147
- if (typeof dateStr === 'string') {
35148
- if (dateStr.length > 10) {
35149
- if (forceSetSecond) {
35150
- date.setSeconds(59, 999);
35151
- }
35152
- return date;
35153
- }
35154
- date.setSeconds(59, 999);
35155
- }
35156
- }
35157
- else {
35158
- date = new Date();
35159
- }
35160
- if (forceSetSecond) {
35161
- date.setSeconds(59, 999);
35162
- }
35163
- return date;
35164
- }
35165
- function createDateAtLastMillisecond(dateStr, forceSetMillisecond = false) {
35166
- let date;
35167
- if (dateStr) {
35168
- date = new Date(dateStr);
35169
- if (typeof dateStr === 'string') {
35170
- if (dateStr.length > 10) {
35171
- if (forceSetMillisecond) {
35172
- date.setMilliseconds(999);
35173
- }
35174
- return date;
35175
- }
35176
- date.setMilliseconds(999);
35177
- }
35178
- }
35179
- else {
35180
- date = new Date();
35181
- }
35182
- if (forceSetMillisecond) {
35183
- date.setMilliseconds(999);
35184
- }
35185
- return date;
35186
- }
35187
- function createDateAtLastHour(dateStr, forceLastHour = false) {
35188
- let date;
35189
- if (dateStr) {
35190
- date = new Date(dateStr);
35191
- if (typeof dateStr === 'string') {
35192
- if (dateStr.length > 10) {
35193
- if (forceLastHour) {
35194
- date.setHours(23, 59, 59, 999);
35195
- }
35196
- return date;
35197
- }
35198
- date.setHours(23, 59, 59, 999);
35199
- }
35200
- }
35201
- else {
35202
- date = new Date();
35203
- }
35204
- if (forceLastHour) {
35205
- date.setHours(23, 59, 59, 999);
35206
- }
35207
- return date;
35208
- }
35209
- function getEndDateByTimeUnit(startDate, date, timeScale, step) {
35210
- let endDate = new Date(date);
35211
- switch (timeScale) {
35212
- case 'second':
35213
- endDate.setMilliseconds(999);
35214
- break;
35215
- case 'minute':
35216
- endDate.setSeconds(59, 999);
35217
- break;
35218
- case 'hour':
35219
- endDate.setMinutes(59, 59, 999);
35220
- break;
35221
- case 'day':
35222
- endDate.setHours(23, 59, 59, 999);
35223
- break;
35224
- case 'week':
35225
- const day = endDate.getDay();
35226
- const diffToEndOfWeek = 6 - day;
35227
- endDate.setDate(endDate.getDate() + diffToEndOfWeek);
35228
- endDate.setHours(23, 59, 59, 999);
35229
- break;
35230
- case 'month':
35231
- const lastDayOfMonth = new Date(endDate.getFullYear(), endDate.getMonth() + 1, 0).getDate();
35232
- endDate.setDate(lastDayOfMonth);
35233
- endDate.setHours(23, 59, 59, 999);
35234
- break;
35235
- case 'quarter':
35236
- const currentMonth = endDate.getMonth();
35237
- const endMonthOfQuarter = currentMonth - (currentMonth % 3) + 2;
35238
- const lastDayOfQuarter = new Date(endDate.getFullYear(), endMonthOfQuarter + 1, 0).getDate();
35239
- endDate.setMonth(endMonthOfQuarter, lastDayOfQuarter);
35240
- endDate.setHours(23, 59, 59, 999);
35241
- break;
35242
- case 'year':
35243
- endDate.setMonth(11, 31);
35244
- endDate.setHours(23, 59, 59, 999);
35245
- break;
35246
- default:
35247
- throw new Error('Invalid time scale');
35248
- }
35249
- const count = computeCountToTimeScale(endDate, startDate, timeScale, step, 1);
35250
- const targetCount = Math.ceil(count);
35251
- if (targetCount > count) {
35252
- const dif = (targetCount - count) * step;
35253
- const msInSecond = 1000;
35254
- const msInMinute = msInSecond * 60;
35255
- const msInHour = msInMinute * 60;
35256
- const msInDay = msInHour * 24;
35257
- const msInWeek = msInDay * 7;
35258
- new Date(endDate.getTime() + 1);
35259
- switch (timeScale) {
35260
- case 'second':
35261
- endDate.setTime(endDate.getTime() + dif * msInSecond);
35262
- break;
35263
- case 'minute':
35264
- endDate.setTime(endDate.getTime() + dif * msInMinute);
35265
- break;
35266
- case 'hour':
35267
- endDate.setTime(endDate.getTime() + dif * msInHour);
35268
- break;
35269
- case 'day':
35270
- endDate.setTime(endDate.getTime() + dif * msInDay);
35271
- break;
35272
- case 'week':
35273
- endDate.setTime(endDate.getTime() + dif * msInWeek);
35274
- break;
35275
- case 'month':
35276
- endDate = new Date(endDate.getFullYear(), endDate.getMonth() + 1 + Math.round(dif), 0);
35277
- endDate.setHours(23, 59, 59, 999);
35278
- break;
35279
- case 'quarter':
35280
- const currentMonth = endDate.getMonth();
35281
- const endMonthOfQuarter = currentMonth - (currentMonth % 3) + 2;
35282
- endDate = new Date(endDate.getFullYear(), endMonthOfQuarter + Math.round(dif * 3) + 1, 0);
35283
- endDate.setHours(23, 59, 59, 999);
35284
- break;
35285
- case 'year':
35286
- endDate.setFullYear(endDate.getFullYear() + Math.floor(dif));
35287
- endDate.setHours(23, 59, 59, 999);
35288
- break;
35289
- default:
35290
- throw new Error('Invalid time scale');
35291
- }
35292
- }
35293
- return endDate;
35294
- }
35295
- function getStartDateByTimeUnit(date, timeScale, startOfWeekSetting = 'monday') {
35296
- const startDate = new Date(date);
35297
- switch (timeScale) {
35298
- case 'second':
35299
- startDate.setMilliseconds(0);
35300
- break;
35301
- case 'minute':
35302
- startDate.setSeconds(0, 0);
35303
- break;
35304
- case 'hour':
35305
- startDate.setMinutes(0, 0, 0);
35306
- break;
35307
- case 'day':
35308
- startDate.setHours(0, 0, 0, 0);
35309
- break;
35310
- case 'week':
35311
- const day = startDate.getDay();
35312
- let diffToStartOfWeek = day;
35313
- if (startOfWeekSetting === 'monday') {
35314
- diffToStartOfWeek = day === 0 ? -6 : 1 - day;
35315
- }
35316
- else {
35317
- diffToStartOfWeek = -day;
35318
- }
35319
- startDate.setDate(startDate.getDate() + diffToStartOfWeek);
35320
- startDate.setHours(0, 0, 0, 0);
35321
- break;
35322
- case 'month':
35323
- startDate.setDate(1);
35324
- startDate.setHours(0, 0, 0, 0);
35325
- break;
35326
- case 'quarter':
35327
- const currentMonth = startDate.getMonth();
35328
- const startMonthOfQuarter = currentMonth - (currentMonth % 3);
35329
- startDate.setMonth(startMonthOfQuarter, 1);
35330
- startDate.setHours(0, 0, 0, 0);
35331
- break;
35332
- case 'year':
35333
- startDate.setMonth(0, 1);
35334
- startDate.setHours(0, 0, 0, 0);
35335
- break;
35336
- default:
35337
- throw new Error('Invalid time scale');
35338
- }
35339
- return startDate;
35340
- }
35341
- function computeCountToTimeScale(date, startDate, timeScale, step, diffMS = 0) {
35342
- const msInSecond = 1000;
35343
- const msInMinute = msInSecond * 60;
35344
- const msInHour = msInMinute * 60;
35345
- const msInDay = msInHour * 24;
35346
- const msInWeek = msInDay * 7;
35347
- let difference;
35348
- const adjusted_date = new Date(date.getTime() + diffMS);
35349
- switch (timeScale) {
35350
- case 'second':
35351
- difference = (adjusted_date.getTime() - startDate.getTime()) / msInSecond;
35352
- break;
35353
- case 'minute':
35354
- difference = (adjusted_date.getTime() - startDate.getTime()) / msInMinute;
35355
- break;
35356
- case 'hour':
35357
- difference = (adjusted_date.getTime() - startDate.getTime()) / msInHour;
35358
- break;
35359
- case 'day':
35360
- difference = (adjusted_date.getTime() - startDate.getTime()) / msInDay;
35361
- break;
35362
- case 'week':
35363
- difference = (adjusted_date.getTime() - startDate.getTime()) / msInWeek;
35364
- break;
35365
- case 'month':
35366
- const startDaysInMonth = new Date(startDate.getFullYear(), startDate.getMonth() + 1, 0).getDate();
35367
- const adjustedDaysInMonth = new Date(adjusted_date.getFullYear(), adjusted_date.getMonth() + 1, 0).getDate();
35368
- difference =
35369
- (adjusted_date.getFullYear() - startDate.getFullYear()) * 12 +
35370
- (adjusted_date.getMonth() - startDate.getMonth());
35371
- difference += adjusted_date.getDate() / adjustedDaysInMonth - startDate.getDate() / startDaysInMonth;
35372
- break;
35373
- case 'quarter':
35374
- difference =
35375
- (adjusted_date.getFullYear() - startDate.getFullYear()) * 4 +
35376
- (adjusted_date.getMonth() - startDate.getMonth()) / 3;
35377
- difference +=
35378
- (adjusted_date.getDate() - startDate.getDate()) /
35379
- (3 * new Date(adjusted_date.getFullYear(), adjusted_date.getMonth() + 1, 0).getDate());
35380
- break;
35381
- case 'year':
35382
- difference = adjusted_date.getFullYear() - startDate.getFullYear();
35383
- difference += (adjusted_date.getMonth() - startDate.getMonth()) / 12;
35384
- break;
35385
- default:
35386
- throw new Error('Invalid time scale');
35387
- }
35388
- return difference / step;
35389
- }
35390
-
35391
34897
  class Grid {
35392
34898
  gridStyle;
35393
34899
  scrollLeft;
@@ -35468,9 +34974,7 @@
35468
34974
  this.verticalLineGroup.name = 'grid-vertical';
35469
34975
  this.group.appendChild(this.verticalLineGroup);
35470
34976
  const dependenceOnTimeScale = this._scene._gantt.parsedOptions.reverseSortedTimelineScales.find(scale => scale.unit === verticalLineDependenceOnTimeScale) ?? this._scene._gantt.parsedOptions.reverseSortedTimelineScales[0];
35471
- const { unit: minUnit, step } = this._scene._gantt.parsedOptions.reverseSortedTimelineScales[0];
35472
34977
  const { timelineDates } = dependenceOnTimeScale;
35473
- const timelineColWidth = this._scene._gantt.parsedOptions.timelineColWidth;
35474
34978
  if (typeof gridStyle.verticalLine === 'function') {
35475
34979
  for (let i = 0; i < timelineDates?.length - 1; i++) {
35476
34980
  const { endDate } = timelineDates[i];
@@ -35480,8 +34984,8 @@
35480
34984
  date: timelineDates[i].endDate,
35481
34985
  ganttInstance: this._scene._gantt
35482
34986
  });
35483
- const x = Math.ceil(computeCountToTimeScale(endDate, this._scene._gantt.parsedOptions.minDate, minUnit, step, 1) *
35484
- 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);
35485
34989
  const line = createLine({
35486
34990
  pickable: false,
35487
34991
  stroke: verticalLine_style.lineColor,
@@ -35499,8 +35003,8 @@
35499
35003
  const verticalLine_style = gridStyle.verticalLine;
35500
35004
  for (let i = 0; i < timelineDates?.length - 1; i++) {
35501
35005
  const { endDate } = timelineDates[i];
35502
- const x = Math.ceil(computeCountToTimeScale(endDate, this._scene._gantt.parsedOptions.minDate, minUnit, step, 1) *
35503
- 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);
35504
35008
  const line = createLine({
35505
35009
  pickable: false,
35506
35010
  stroke: verticalLine_style.lineColor,
@@ -35584,7 +35088,6 @@
35584
35088
  this.verticalBackgroundRectsGroup.name = 'grid-vertical-background';
35585
35089
  this.group.appendChild(this.verticalBackgroundRectsGroup);
35586
35090
  const { timelineDates, unit, step } = this._scene._gantt.parsedOptions.reverseSortedTimelineScales[0];
35587
- const timelineColWidth = this._scene._gantt.parsedOptions.timelineColWidth;
35588
35091
  if (verticalBackgroundColor || weekendBackgroundColor) {
35589
35092
  for (let i = 0; i <= timelineDates?.length - 1; i++) {
35590
35093
  let backgroundColor;
@@ -35606,13 +35109,14 @@
35606
35109
  backgroundColor = verticalBackgroundColor[i % verticalBackgroundColor.length];
35607
35110
  }
35608
35111
  if (backgroundColor) {
35609
- 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);
35610
35114
  const rect = createRect({
35611
35115
  pickable: false,
35612
35116
  fill: backgroundColor,
35613
35117
  x,
35614
35118
  y: 0,
35615
- width: timelineColWidth,
35119
+ width,
35616
35120
  height: this.allGridHeight
35617
35121
  });
35618
35122
  this.verticalBackgroundRectsGroup.appendChild(rect);
@@ -35826,165 +35330,659 @@
35826
35330
  this.vScrollBar.render();
35827
35331
  this.vScrollBar.hideAll();
35828
35332
  }
35829
- refresh() {
35333
+ refresh() {
35334
+ }
35335
+ hideVerticalScrollBar() {
35336
+ const visable = this._gantt.parsedOptions.scrollStyle.visible;
35337
+ if (visable !== 'focus' && visable !== 'scrolling') {
35338
+ return;
35339
+ }
35340
+ this.vScrollBar.setAttribute('visible', false);
35341
+ this.vScrollBar.hideAll();
35342
+ this._gantt.scenegraph.updateNextFrame();
35343
+ }
35344
+ showVerticalScrollBar(autoHide) {
35345
+ const visable = this._gantt.parsedOptions.scrollStyle.visible;
35346
+ if (visable !== 'focus' && visable !== 'scrolling') {
35347
+ return;
35348
+ }
35349
+ this.vScrollBar.setAttribute('visible', true);
35350
+ this.vScrollBar.showAll();
35351
+ this._gantt.scenegraph.updateNextFrame();
35352
+ if (autoHide) {
35353
+ clearTimeout(this._clearVerticalScrollBar);
35354
+ this._clearVerticalScrollBar = setTimeout(() => {
35355
+ this.hideVerticalScrollBar();
35356
+ }, 1000);
35357
+ }
35358
+ }
35359
+ hideHorizontalScrollBar() {
35360
+ const visable = this._gantt.parsedOptions.scrollStyle.visible;
35361
+ if (visable !== 'focus' && visable !== 'scrolling') {
35362
+ return;
35363
+ }
35364
+ this.hScrollBar.setAttribute('visible', false);
35365
+ this.hScrollBar.hideAll();
35366
+ this._gantt.scenegraph.updateNextFrame();
35367
+ }
35368
+ showHorizontalScrollBar(autoHide) {
35369
+ const visable = this._gantt.parsedOptions.scrollStyle.visible;
35370
+ if (visable !== 'focus' && visable !== 'scrolling') {
35371
+ return;
35372
+ }
35373
+ this.hScrollBar.setAttribute('visible', true);
35374
+ this.hScrollBar.showAll();
35375
+ this._gantt.scenegraph.updateNextFrame();
35376
+ if (autoHide) {
35377
+ clearTimeout(this._clearHorizontalScrollBar);
35378
+ this._clearHorizontalScrollBar = setTimeout(() => {
35379
+ this.hideHorizontalScrollBar();
35380
+ }, 1000);
35381
+ }
35382
+ }
35383
+ updateVerticalScrollBarPos(topRatio) {
35384
+ const range = this.vScrollBar.attribute.range;
35385
+ const size = range[1] - range[0];
35386
+ const range0 = topRatio * (1 - size);
35387
+ this.vScrollBar.setAttribute('range', [range0, range0 + size]);
35388
+ const bounds = this.vScrollBar.AABBBounds && this.vScrollBar.globalAABBBounds;
35389
+ this.vScrollBar._viewPosition = {
35390
+ x: bounds.x1,
35391
+ y: bounds.y1
35392
+ };
35393
+ }
35394
+ updateHorizontalScrollBarPos(leftRatio) {
35395
+ const range = this.hScrollBar.attribute.range;
35396
+ const size = range[1] - range[0];
35397
+ const range0 = leftRatio * (1 - size);
35398
+ this.hScrollBar.setAttribute('range', [range0, range0 + size]);
35399
+ const bounds = this.hScrollBar.AABBBounds && this.hScrollBar.globalAABBBounds;
35400
+ this.hScrollBar._viewPosition = {
35401
+ x: bounds.x1,
35402
+ y: bounds.y1
35403
+ };
35404
+ }
35405
+ updateScrollBar() {
35406
+ const oldHorizontalBarPos = this._gantt.stateManager.scroll.horizontalBarPos;
35407
+ const oldVerticalBarPos = this._gantt.stateManager.scroll.verticalBarPos;
35408
+ const scrollStyle = this._gantt.parsedOptions.scrollStyle;
35409
+ const width = scrollStyle?.width;
35410
+ const visible = scrollStyle?.visible;
35411
+ const tableWidth = Math.ceil(this._gantt.scenegraph.ganttGroup.attribute.width);
35412
+ const tableHeight = Math.ceil(this._gantt.scenegraph.ganttGroup.attribute.height);
35413
+ const totalHeight = this._gantt.getAllRowsHeight();
35414
+ const totalWidth = this._gantt.getAllDateColsWidth();
35415
+ const frozenRowsHeight = this._gantt.getAllHeaderRowsHeight();
35416
+ if (totalWidth > tableWidth) {
35417
+ const y = Math.min(tableHeight, totalHeight);
35418
+ const rangeEnd = Math.max(0.05, tableWidth / totalWidth);
35419
+ const hoverOn = scrollStyle.hoverOn;
35420
+ let attrY = 0;
35421
+ if (scrollStyle.barToSide) {
35422
+ attrY =
35423
+ this._gantt.tableNoFrameHeight -
35424
+ (hoverOn ? width : -this._gantt.scenegraph.ganttGroup.attribute.y) +
35425
+ this._gantt.tableY;
35426
+ }
35427
+ else {
35428
+ attrY = y - (hoverOn ? width : -this._gantt.scenegraph.ganttGroup.attribute.y) + this._gantt.tableY;
35429
+ }
35430
+ this.hScrollBar.setAttributes({
35431
+ x: this._gantt.scenegraph.ganttGroup.attribute.x,
35432
+ y: attrY,
35433
+ width: tableWidth,
35434
+ range: [0, rangeEnd],
35435
+ visible: visible === 'always'
35436
+ });
35437
+ const bounds = this.hScrollBar.AABBBounds && this.hScrollBar.globalAABBBounds;
35438
+ this.hScrollBar._viewPosition = {
35439
+ x: bounds.x1,
35440
+ y: bounds.y1
35441
+ };
35442
+ if (visible === 'always') {
35443
+ this.hScrollBar.showAll();
35444
+ }
35445
+ }
35446
+ else {
35447
+ this.hScrollBar.setAttributes({
35448
+ x: -this._gantt.tableNoFrameWidth * 2,
35449
+ y: -this._gantt.tableNoFrameHeight * 2,
35450
+ width: 0,
35451
+ visible: false
35452
+ });
35453
+ }
35454
+ if (totalHeight > tableHeight) {
35455
+ const x = Math.min(tableWidth, totalWidth) + this._gantt.scenegraph.ganttGroup.attribute.x;
35456
+ const rangeEnd = Math.max(0.05, (tableHeight - frozenRowsHeight) / (totalHeight - frozenRowsHeight));
35457
+ let attrX = 0;
35458
+ const hoverOn = this._gantt.parsedOptions.scrollStyle.hoverOn;
35459
+ if (this._gantt.parsedOptions.scrollStyle.barToSide) {
35460
+ attrX = this._gantt.tableNoFrameWidth - (hoverOn ? width : -this._gantt.scenegraph.ganttGroup.attribute.x);
35461
+ }
35462
+ else {
35463
+ attrX = x - (hoverOn ? width : -this._gantt.scenegraph.ganttGroup.attribute.x);
35464
+ }
35465
+ this.vScrollBar.setAttributes({
35466
+ x: attrX,
35467
+ y: frozenRowsHeight + (!hoverOn ? this._gantt.scenegraph.ganttGroup.attribute.y : 0) + this._gantt.tableY,
35468
+ height: tableHeight - frozenRowsHeight,
35469
+ range: [0, rangeEnd],
35470
+ visible: visible === 'always'
35471
+ });
35472
+ const bounds = this.vScrollBar.AABBBounds && this.vScrollBar.globalAABBBounds;
35473
+ this.vScrollBar._viewPosition = {
35474
+ x: bounds.x1,
35475
+ y: bounds.y1
35476
+ };
35477
+ if (visible === 'always') {
35478
+ this.vScrollBar.showAll();
35479
+ }
35480
+ }
35481
+ else {
35482
+ this.vScrollBar.setAttributes({
35483
+ x: -this._gantt.tableNoFrameWidth * 2,
35484
+ y: -this._gantt.tableNoFrameHeight * 2,
35485
+ height: 0,
35486
+ visible: false
35487
+ });
35488
+ }
35489
+ this._gantt.stateManager.setScrollLeft(oldHorizontalBarPos);
35490
+ this._gantt.stateManager.setScrollTop(oldVerticalBarPos);
35491
+ }
35492
+ }
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);
35830
35737
  }
35831
- hideVerticalScrollBar() {
35832
- const visable = this._gantt.parsedOptions.scrollStyle.visible;
35833
- if (visable !== 'focus' && visable !== 'scrolling') {
35834
- return;
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);
35835
35752
  }
35836
- this.vScrollBar.setAttribute('visible', false);
35837
- this.vScrollBar.hideAll();
35838
- this._gantt.scenegraph.updateNextFrame();
35839
35753
  }
35840
- showVerticalScrollBar(autoHide) {
35841
- const visable = this._gantt.parsedOptions.scrollStyle.visible;
35842
- if (visable !== 'focus' && visable !== 'scrolling') {
35843
- return;
35844
- }
35845
- this.vScrollBar.setAttribute('visible', true);
35846
- this.vScrollBar.showAll();
35847
- this._gantt.scenegraph.updateNextFrame();
35848
- if (autoHide) {
35849
- clearTimeout(this._clearVerticalScrollBar);
35850
- this._clearVerticalScrollBar = setTimeout(() => {
35851
- this.hideVerticalScrollBar();
35852
- }, 1000);
35853
- }
35754
+ else {
35755
+ date = new Date();
35854
35756
  }
35855
- hideHorizontalScrollBar() {
35856
- const visable = this._gantt.parsedOptions.scrollStyle.visible;
35857
- if (visable !== 'focus' && visable !== 'scrolling') {
35858
- return;
35859
- }
35860
- this.hScrollBar.setAttribute('visible', false);
35861
- this.hScrollBar.hideAll();
35862
- this._gantt.scenegraph.updateNextFrame();
35757
+ if (forceSetSecond) {
35758
+ date.setSeconds(59, 999);
35863
35759
  }
35864
- showHorizontalScrollBar(autoHide) {
35865
- const visable = this._gantt.parsedOptions.scrollStyle.visible;
35866
- if (visable !== 'focus' && visable !== 'scrolling') {
35867
- return;
35868
- }
35869
- this.hScrollBar.setAttribute('visible', true);
35870
- this.hScrollBar.showAll();
35871
- this._gantt.scenegraph.updateNextFrame();
35872
- if (autoHide) {
35873
- clearTimeout(this._clearHorizontalScrollBar);
35874
- this._clearHorizontalScrollBar = setTimeout(() => {
35875
- this.hideHorizontalScrollBar();
35876
- }, 1000);
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);
35877
35774
  }
35878
35775
  }
35879
- updateVerticalScrollBarPos(topRatio) {
35880
- const range = this.vScrollBar.attribute.range;
35881
- const size = range[1] - range[0];
35882
- const range0 = topRatio * (1 - size);
35883
- this.vScrollBar.setAttribute('range', [range0, range0 + size]);
35884
- const bounds = this.vScrollBar.AABBBounds && this.vScrollBar.globalAABBBounds;
35885
- this.vScrollBar._viewPosition = {
35886
- x: bounds.x1,
35887
- y: bounds.y1
35888
- };
35776
+ else {
35777
+ date = new Date();
35889
35778
  }
35890
- updateHorizontalScrollBarPos(leftRatio) {
35891
- const range = this.hScrollBar.attribute.range;
35892
- const size = range[1] - range[0];
35893
- const range0 = leftRatio * (1 - size);
35894
- this.hScrollBar.setAttribute('range', [range0, range0 + size]);
35895
- const bounds = this.hScrollBar.AABBBounds && this.hScrollBar.globalAABBBounds;
35896
- this.hScrollBar._viewPosition = {
35897
- x: bounds.x1,
35898
- y: bounds.y1
35899
- };
35779
+ if (forceSetMillisecond) {
35780
+ date.setMilliseconds(999);
35900
35781
  }
35901
- updateScrollBar() {
35902
- const oldHorizontalBarPos = this._gantt.stateManager.scroll.horizontalBarPos;
35903
- const oldVerticalBarPos = this._gantt.stateManager.scroll.verticalBarPos;
35904
- const scrollStyle = this._gantt.parsedOptions.scrollStyle;
35905
- const width = scrollStyle?.width;
35906
- const visible = scrollStyle?.visible;
35907
- const tableWidth = Math.ceil(this._gantt.scenegraph.ganttGroup.attribute.width);
35908
- const tableHeight = Math.ceil(this._gantt.scenegraph.ganttGroup.attribute.height);
35909
- const totalHeight = this._gantt.getAllRowsHeight();
35910
- const totalWidth = this._gantt.getAllDateColsWidth();
35911
- const frozenRowsHeight = this._gantt.getAllHeaderRowsHeight();
35912
- if (totalWidth > tableWidth) {
35913
- const y = Math.min(tableHeight, totalHeight);
35914
- const rangeEnd = Math.max(0.05, tableWidth / totalWidth);
35915
- const hoverOn = scrollStyle.hoverOn;
35916
- let attrY = 0;
35917
- if (scrollStyle.barToSide) {
35918
- attrY =
35919
- this._gantt.tableNoFrameHeight -
35920
- (hoverOn ? width : -this._gantt.scenegraph.ganttGroup.attribute.y) +
35921
- this._gantt.tableY;
35922
- }
35923
- else {
35924
- attrY = y - (hoverOn ? width : -this._gantt.scenegraph.ganttGroup.attribute.y) + this._gantt.tableY;
35925
- }
35926
- this.hScrollBar.setAttributes({
35927
- x: this._gantt.scenegraph.ganttGroup.attribute.x,
35928
- y: attrY,
35929
- width: tableWidth,
35930
- range: [0, rangeEnd],
35931
- visible: visible === 'always'
35932
- });
35933
- const bounds = this.hScrollBar.AABBBounds && this.hScrollBar.globalAABBBounds;
35934
- this.hScrollBar._viewPosition = {
35935
- x: bounds.x1,
35936
- y: bounds.y1
35937
- };
35938
- if (visible === 'always') {
35939
- this.hScrollBar.showAll();
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;
35940
35794
  }
35795
+ date.setHours(23, 59, 59, 999);
35941
35796
  }
35942
- else {
35943
- this.hScrollBar.setAttributes({
35944
- x: -this._gantt.tableNoFrameWidth * 2,
35945
- y: -this._gantt.tableNoFrameHeight * 2,
35946
- width: 0,
35947
- visible: false
35948
- });
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');
35949
35888
  }
35950
- if (totalHeight > tableHeight) {
35951
- const x = Math.min(tableWidth, totalWidth) + this._gantt.scenegraph.ganttGroup.attribute.x;
35952
- const rangeEnd = Math.max(0.05, (tableHeight - frozenRowsHeight) / (totalHeight - frozenRowsHeight));
35953
- let attrX = 0;
35954
- const hoverOn = this._gantt.parsedOptions.scrollStyle.hoverOn;
35955
- if (this._gantt.parsedOptions.scrollStyle.barToSide) {
35956
- attrX = this._gantt.tableNoFrameWidth - (hoverOn ? width : -this._gantt.scenegraph.ganttGroup.attribute.x);
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;
35957
35912
  }
35958
35913
  else {
35959
- attrX = x - (hoverOn ? width : -this._gantt.scenegraph.ganttGroup.attribute.x);
35960
- }
35961
- this.vScrollBar.setAttributes({
35962
- x: attrX,
35963
- y: frozenRowsHeight + (!hoverOn ? this._gantt.scenegraph.ganttGroup.attribute.y : 0) + this._gantt.tableY,
35964
- height: tableHeight - frozenRowsHeight,
35965
- range: [0, rangeEnd],
35966
- visible: visible === 'always'
35967
- });
35968
- const bounds = this.vScrollBar.AABBBounds && this.vScrollBar.globalAABBBounds;
35969
- this.vScrollBar._viewPosition = {
35970
- x: bounds.x1,
35971
- y: bounds.y1
35972
- };
35973
- if (visible === 'always') {
35974
- this.vScrollBar.showAll();
35914
+ diffToStartOfWeek = -day;
35975
35915
  }
35976
- }
35977
- else {
35978
- this.vScrollBar.setAttributes({
35979
- x: -this._gantt.tableNoFrameWidth * 2,
35980
- y: -this._gantt.tableNoFrameHeight * 2,
35981
- height: 0,
35982
- visible: false
35983
- });
35984
- }
35985
- this._gantt.stateManager.setScrollLeft(oldHorizontalBarPos);
35986
- this._gantt.stateManager.setScrollTop(oldVerticalBarPos);
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');
35987
35984
  }
35985
+ return difference / step;
35988
35986
  }
35989
35987
 
35990
35988
  function handleWhell$1(event, state, gantt, isWheelEvent = true) {
@@ -36179,10 +36177,7 @@
36179
36177
  const isNode$1 = typeof window === 'undefined' || typeof window.window === 'undefined';
36180
36178
  const DayTimes = 1000 * 60 * 60 * 24;
36181
36179
  function getDateIndexByX(x, gantt) {
36182
- const totalX = x + gantt.stateManager.scroll.horizontalBarPos;
36183
- const firstDateColWidth = gantt.getDateColWidth(0);
36184
- const dateIndex = Math.floor((totalX - firstDateColWidth) / gantt.parsedOptions.timelineColWidth) + 1;
36185
- return dateIndex;
36180
+ return gantt.getDateIndexByX(x);
36186
36181
  }
36187
36182
  function generateMarkLine(markLine) {
36188
36183
  if (!markLine) {
@@ -37097,7 +37092,6 @@
37097
37092
  this.group = dateHeader;
37098
37093
  dateHeader.name = 'date-header-container';
37099
37094
  scene.ganttGroup.addChild(this.group);
37100
- const { unit: minUnit, step } = scene._gantt.parsedOptions.reverseSortedTimelineScales[0];
37101
37095
  let y = 0;
37102
37096
  for (let i = 0; i < scene._gantt.timeLineHeaderLevel; i++) {
37103
37097
  const { timelineDates, customLayout, visible } = scene._gantt.parsedOptions.sortedTimelineScales[i];
@@ -37116,10 +37110,8 @@
37116
37110
  dateHeader.addChild(rowHeader);
37117
37111
  for (let j = 0; j < timelineDates?.length; j++) {
37118
37112
  const { days, endDate, startDate, title, dateIndex, unit } = timelineDates[j];
37119
- const x = Math.ceil(computeCountToTimeScale(startDate, scene._gantt.parsedOptions.minDate, minUnit, step) *
37120
- scene._gantt.parsedOptions.timelineColWidth);
37121
- const right_x = Math.ceil(computeCountToTimeScale(endDate, scene._gantt.parsedOptions.minDate, minUnit, step, 1) *
37122
- 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));
37123
37115
  const width = right_x - x;
37124
37116
  const date = new Group$2({
37125
37117
  x,
@@ -38774,6 +38766,8 @@
38774
38766
  RESIZE_COLUMN_END: "resize_column_end",
38775
38767
  RESIZE_ROW: "resize_row",
38776
38768
  RESIZE_ROW_END: "resize_row_end",
38769
+ MERGE_CELLS: "merge_cells",
38770
+ UNMERGE_CELLS: "unmerge_cells",
38777
38771
  CHANGE_HEADER_POSITION_START: "change_header_position_start",
38778
38772
  CHANGE_HEADER_POSITION: "change_header_position",
38779
38773
  CHANGING_HEADER_POSITION: "changing_header_position",
@@ -41267,7 +41261,7 @@
41267
41261
  }
41268
41262
  clearFilteredChildren(record) {
41269
41263
  var _a, _b;
41270
- record.filteredChildren = void 0;
41264
+ record.filteredChildren = void 0, delete record.filteredChildren;
41271
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]);
41272
41266
  }
41273
41267
  filterRecord(record) {
@@ -41370,8 +41364,9 @@
41370
41364
  fieldPromiseCallBack(_index, _field, _value) {}
41371
41365
  recordPromiseCallBack(_index, _record) {}
41372
41366
  canChangeOrder(sourceIndex, targetIndex) {
41373
- var _a;
41367
+ var _a, _b;
41374
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;
41375
41370
  if (this.hasHierarchyStateExpand) {
41376
41371
  let sourceIndexs = this.currentPagerIndexedData[sourceIndex],
41377
41372
  targetIndexs = this.currentPagerIndexedData[targetIndex];
@@ -45374,7 +45369,7 @@
45374
45369
  function updateCell$1(col, row, table, addNew, isShadow, forceFastUpdate) {
45375
45370
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
45376
45371
  const oldCellGroup = table.scenegraph.highPerformanceGetCell(col, row, !0);
45377
- if ("cell" !== oldCellGroup.role && !addNew) return;
45372
+ if ("cell" !== oldCellGroup.role && "shadow-cell" !== oldCellGroup.role && !addNew) return;
45378
45373
  const cellLocation = table.getCellLocation(col, row);
45379
45374
  let isMerge,
45380
45375
  range,
@@ -52824,7 +52819,7 @@
52824
52819
  }), scene.tableGroup.role = "table";
52825
52820
  const colHeaderGroup = createContainerGroup(0, 0, !scene.table.internalProps.enableTreeStickCell);
52826
52821
  colHeaderGroup.role = "col-header", scene.colHeaderGroup = colHeaderGroup;
52827
- const cornerHeaderGroup = createContainerGroup(0, 0, !scene.table.options.enableTreeStickCell);
52822
+ const cornerHeaderGroup = createContainerGroup(0, 0, !scene.table.internalProps.enableTreeStickCell);
52828
52823
  cornerHeaderGroup.role = "corner-header", scene.cornerHeaderGroup = cornerHeaderGroup;
52829
52824
  const rowHeaderGroup = createContainerGroup(0, 0, !0);
52830
52825
  rowHeaderGroup.role = "row-header", scene.rowHeaderGroup = rowHeaderGroup;
@@ -55622,13 +55617,13 @@
55622
55617
  setSortState(sortState) {
55623
55618
  const state = this;
55624
55619
  const sort = (sortState = !sortState || Array.isArray(sortState) ? sortState : [sortState]) && sortState.reduce((prev, item) => {
55625
- var _a, _b, _c;
55620
+ var _a, _b, _c, _d, _e;
55626
55621
  const column = null === (_a = function (columns) {
55627
55622
  const result = [];
55628
55623
  return function flatten(cols, parentStartIndex = 0) {
55629
55624
  cols.forEach(col => {
55630
55625
  var _a;
55631
- 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;
55632
55627
  col.columns ? flatten(col.columns, startIndex) : result.push(Object.assign(Object.assign({}, col), {
55633
55628
  startIndex: startIndex
55634
55629
  }));
@@ -55638,12 +55633,12 @@
55638
55633
  return this.table.internalProps.transpose ? prev.push({
55639
55634
  field: item.field,
55640
55635
  order: item.order,
55641
- 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),
55642
55637
  col: null == column ? void 0 : column.level
55643
55638
  }) : prev.push({
55644
55639
  field: item.field,
55645
55640
  order: item.order,
55646
- 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),
55647
55642
  row: null == column ? void 0 : column.level
55648
55643
  }), prev;
55649
55644
  }, []);
@@ -56155,13 +56150,16 @@
56155
56150
  this.select.selectInline = selectInline;
56156
56151
  }
56157
56152
  updateSortState(sortState) {
56158
- var _a, _b, _c, _d, _e, _f, _g, _h;
56159
- 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;
56160
56159
  for (let index = 0; index < sortState.length; index++) {
56161
- 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;
56162
- const oldSortCol = this.table.internalProps.multipleSort ? null : (null === (_c = this.sort[index]) || void 0 === _c ? void 0 : _c.col) || null,
56163
- oldSortRow = this.table.internalProps.multipleSort ? null : (null === (_d = this.sort[index]) || void 0 === _d ? void 0 : _d.row) || null;
56164
- "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;
56165
56163
  this.setSortState(sortState.slice(0, index + 1));
56166
56164
  const cellAddress = this.table.internalProps.layoutMap.getHeaderCellAddressByField(sortState[index].field);
56167
56165
  this.sort[index].col = cellAddress.col, this.sort[index].row = cellAddress.row;
@@ -56174,7 +56172,7 @@
56174
56172
  order: this.sort[index].order,
56175
56173
  oldSortCol: oldSortCol,
56176
56174
  oldSortRow: oldSortRow,
56177
- 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
56178
56176
  });
56179
56177
  }
56180
56178
  const normalHeaders = [];
@@ -56188,7 +56186,7 @@
56188
56186
  row: null,
56189
56187
  iconMark: null,
56190
56188
  order: null,
56191
- 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),
56192
56190
  oldSortRow: column.level,
56193
56191
  oldIconMark: null
56194
56192
  });
@@ -60441,7 +60439,7 @@
60441
60439
  }
60442
60440
  constructor(container, options = {}) {
60443
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;
60444
- 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", 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");
60445
60443
  this.pluginManager = new PluginManager$1(this, options), this.fireListeners(TABLE_EVENT_TYPE.BEFORE_INIT, {
60446
60444
  options: options,
60447
60445
  container: container
@@ -61379,12 +61377,15 @@
61379
61377
  dispose() {
61380
61378
  this.release();
61381
61379
  }
61380
+ clearCorrectTimer() {
61381
+ this._scrollToRowCorrectTimer && (clearTimeout(this._scrollToRowCorrectTimer), this._scrollToRowCorrectTimer = null);
61382
+ }
61382
61383
  release() {
61383
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;
61384
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();
61385
61386
  const internalProps = this.internalProps;
61386
61387
  if (this.isReleased) return;
61387
- 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 => {
61388
61389
  null == legend || legend.release();
61389
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 => {
61390
61391
  var _a;
@@ -61689,6 +61690,30 @@
61689
61690
  lastSelectRange = currentSelectRanges[currentSelectRanges.length - 1];
61690
61691
  lastSelectRange && (lastSelectRange.end.row = rowIndex), this.stateManager.updateSelectPos(this.colCount - 1, rowIndex, !1, isCtrl, !1, makeSelectCellVisible, !0), this.stateManager.select.selecting = !1;
61691
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
+ }
61692
61717
  get recordsCount() {
61693
61718
  var _a;
61694
61719
  return null === (_a = this.records) || void 0 === _a ? void 0 : _a.length;
@@ -61834,7 +61859,7 @@
61834
61859
  getCustomMerge(col, row) {
61835
61860
  if (this.internalProps.customMergeCell) {
61836
61861
  const customMerge = this.internalProps.customMergeCell(col, row, this);
61837
- if (customMerge && customMerge.range && (isValid$1(customMerge.text) || customMerge.customLayout || this.customRender)) {
61862
+ if (customMerge && customMerge.range) {
61838
61863
  if (customMerge.style) {
61839
61864
  const styleClass = this.internalProps.bodyHelper.getStyleClass("text"),
61840
61865
  style = customMerge.style,
@@ -62545,12 +62570,34 @@
62545
62570
  this.eventManager.enableScroll();
62546
62571
  }
62547
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
+ }
62548
62589
  scrollToRow(row, animationOption) {
62549
- animationOption ? this.animationManager.scrollTo({
62550
- row: row
62551
- }, animationOption) : this.scrollToCell({
62552
- row: row
62553
- });
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);
62554
62601
  }
62555
62602
  scrollToCol(col, animationOption) {
62556
62603
  animationOption ? this.animationManager.scrollTo({
@@ -62569,8 +62616,8 @@
62569
62616
  }
62570
62617
  if (isValid$1(cellAddr.row) && cellAddr.row >= this.frozenRowCount) {
62571
62618
  const frozenHeight = this.getFrozenRowsHeight(),
62572
- top = this.getRowsHeight(0, cellAddr.row - 1);
62573
- 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);
62574
62621
  }
62575
62622
  this.render();
62576
62623
  }
@@ -63218,9 +63265,24 @@
63218
63265
  return layout._cellRangeMap.set(`$${col}$${row}`, cellRange), cellRange;
63219
63266
  }
63220
63267
  function getTreeTitleMerge(col, row, cellRange, layout) {
63268
+ var _a;
63221
63269
  if ("tree" !== layout.rowHierarchyType) return;
63222
- const cellRecord = layout._table.getCellRawRecord(col, row);
63223
- 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
+ }
63224
63286
  }
63225
63287
  function getCellRangeTranspose(col, row, layout) {
63226
63288
  var _a, _b, _c, _d;
@@ -64137,7 +64199,7 @@
64137
64199
  this.listenersId.push(doubleClickEventId, clickEventId, selectedChangedEventId);
64138
64200
  }
64139
64201
  startEditCell(col, row, value, editElement) {
64140
- 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;
64141
64203
  if (this.editingEditor) return;
64142
64204
  const editor = this.table.getEditor(col, row);
64143
64205
  if (editor) {
@@ -64153,7 +64215,8 @@
64153
64215
  col: col,
64154
64216
  row: row
64155
64217
  }), this.table._makeVisibleCell(col, row), this.editingEditor = editor;
64156
- 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),
64157
64220
  rect = this.table.getCellRangeRelativeRect(this.table.getCellRange(col, row)),
64158
64221
  referencePosition = {
64159
64222
  rect: {
@@ -64163,9 +64226,9 @@
64163
64226
  height: rect.height
64164
64227
  }
64165
64228
  };
64166
- 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, () => {
64167
64230
  this.completeEdit();
64168
- }), null === (_l = editor.onStart) || void 0 === _l || _l.call(editor, {
64231
+ }), null === (_m = editor.onStart) || void 0 === _m || _m.call(editor, {
64169
64232
  value: dataValue,
64170
64233
  endEdit: () => {
64171
64234
  this.completeEdit();
@@ -64179,7 +64242,7 @@
64179
64242
  }
64180
64243
  }
64181
64244
  completeEdit(e) {
64182
- var _a, _b;
64245
+ var _a, _b, _c;
64183
64246
  if (!this.editingEditor) return !0;
64184
64247
  if (this.isValidatingValue) return !1;
64185
64248
  this.cacheLastSelectedCellEditor = {};
@@ -64193,9 +64256,10 @@
64193
64256
  if (this.editingEditor.getValue, this.editingEditor.validateValue) {
64194
64257
  this.isValidatingValue = !0;
64195
64258
  const newValue = this.editingEditor.getValue(),
64196
- 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),
64197
64261
  target = null == e ? void 0 : e.target,
64198
- 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));
64199
64263
  return isPromise(maybePromiseOrValue) ? (this.isValidatingValue = !0, new Promise((resolve, reject) => {
64200
64264
  maybePromiseOrValue.then(result => {
64201
64265
  dealWithValidateValue(result, this, oldValue, resolve);
@@ -64209,14 +64273,17 @@
64209
64273
  doExit() {
64210
64274
  var _a, _b, _c, _d, _e, _f, _g, _h;
64211
64275
  const changedValue = null === (_b = (_a = this.editingEditor).getValue) || void 0 === _b ? void 0 : _b.call(_a),
64212
- range = this.table.getCellRange(this.editCell.col, this.editCell.row),
64213
- changedValues = [];
64214
- for (let row = range.start.row; row <= range.end.row; row++) {
64215
- const rowChangedValues = [];
64216
- for (let col = range.start.col; col <= range.end.col; col++) rowChangedValues.push(changedValue);
64217
- 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);
64218
64285
  }
64219
- 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;
64220
64287
  }
64221
64288
  cancelEdit() {
64222
64289
  var _a, _b, _c, _d;
@@ -64276,7 +64343,18 @@
64276
64343
  step((generator = generator.apply(thisArg, _arguments || [])).next());
64277
64344
  });
64278
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
+ }
64279
64356
  function listTableChangeCellValue(col, row, value, workOnEditableCell, triggerEvent, table, noTriggerChangeCellValuesEvent) {
64357
+ var _a, _b;
64280
64358
  if (workOnEditableCell && table.isHasEditorDefine(col, row) || !1 === workOnEditableCell) {
64281
64359
  const recordShowIndex = table.getRecordShowIndexByCell(col, row),
64282
64360
  recordIndex = recordShowIndex >= 0 ? table.dataSource.getIndexKey(recordShowIndex) : void 0,
@@ -64286,8 +64364,12 @@
64286
64364
  beforeChangeValue = table.getCellRawValue(col, row),
64287
64365
  oldValue = table.getCellOriginValue(col, row);
64288
64366
  table.isHeader(col, row) ? table.internalProps.layoutMap.updateColumnTitle(col, row, value) : table.dataSource.changeFieldValue(value, recordShowIndex, field, col, row, table);
64289
- const range = table.getCellRange(col, row),
64290
- 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);
64291
64373
  if (aggregators) {
64292
64374
  if (Array.isArray(aggregators)) for (let i = 0; i < (null == aggregators ? void 0 : aggregators.length); i++) aggregators[i].recalculate();else aggregators.recalculate();
64293
64375
  const aggregatorCells = table.internalProps.layoutMap.getAggregatorCellAddress(range.start.col, range.start.row, range.end.col, range.end.row);
@@ -64510,7 +64592,13 @@
64510
64592
  (void 0 === recordIndex || recordIndex > table.dataSource.sourceLength) && (recordIndex = table.dataSource.sourceLength);
64511
64593
  const headerCount = table.transpose ? table.rowHeaderLevelCount : table.columnHeaderLevelCount,
64512
64594
  syncToOriginalRecords = !!(null === (_f = table.options) || void 0 === _f ? void 0 : _f.syncRecordOperationsToSourceRecords);
64513
- 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
+ }
64514
64602
  const oldRowCount = table.rowCount;
64515
64603
  if (table.refreshRowColCount(), 0 === table.scenegraph.proxy.totalActualBodyRowCount) return table.scenegraph.clearCells(), table.scenegraph.createSceneGraph(), !0;
64516
64604
  const newRowCount = table.transpose ? table.colCount : table.rowCount;
@@ -64588,7 +64676,13 @@
64588
64676
  void 0 === recordIndex || recordIndex > table.dataSource.sourceLength ? recordIndex = table.dataSource.sourceLength : recordIndex < 0 && (recordIndex = 0);
64589
64677
  const headerCount = table.transpose ? table.rowHeaderLevelCount : table.columnHeaderLevelCount,
64590
64678
  syncToOriginalRecords = !!(null === (_f = table.options) || void 0 === _f ? void 0 : _f.syncRecordOperationsToSourceRecords);
64591
- 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
+ }
64592
64686
  const oldRowCount = table.transpose ? table.colCount : table.rowCount;
64593
64687
  if (table.refreshRowColCount(), 0 === table.scenegraph.proxy.totalActualBodyRowCount) return table.scenegraph.clearCells(), table.scenegraph.createSceneGraph(), !0;
64594
64688
  const newRowCount = table.transpose ? table.colCount : table.rowCount;
@@ -64657,7 +64751,7 @@
64657
64751
  }
64658
64752
  }
64659
64753
  function listTableDeleteRecords(recordIndexs, table) {
64660
- 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;
64661
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) {
64662
64756
  const deletedRecordIndexs = null === (_d = (_c = table.dataSource).deleteRecordsForTree) || void 0 === _d ? void 0 : _d.call(_c, recordIndexs);
64663
64757
  if (0 === deletedRecordIndexs.length) return;
@@ -64669,8 +64763,17 @@
64669
64763
  const syncToOriginalRecords = !!(null === (_f = table.options) || void 0 === _f ? void 0 : _f.syncRecordOperationsToSourceRecords),
64670
64764
  deletedRecordIndexs = table.dataSource.deleteRecords(recordIndexs, syncToOriginalRecords);
64671
64765
  if (0 === deletedRecordIndexs.length) return;
64766
+ Array.isArray(table.options.customMergeCell) && (table.internalProps.customMergeCell = getCustomMergeCellFunc(table.options.customMergeCell));
64672
64767
  for (let index = 0; index < deletedRecordIndexs.length; index++) adjustCheckBoxStateMapWithDeleteRecordIndex(table, deletedRecordIndexs[index], 1);
64673
- 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
+ }
64674
64777
  const oldRowCount = table.transpose ? table.colCount : table.rowCount;
64675
64778
  table.refreshRowColCount();
64676
64779
  const newRowCount = table.transpose ? table.colCount : table.rowCount,
@@ -64708,7 +64811,7 @@
64708
64811
  col: 0,
64709
64812
  row: row
64710
64813
  });
64711
- 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);
64712
64815
  }
64713
64816
  } else {
64714
64817
  const delRows = [],
@@ -64726,6 +64829,42 @@
64726
64829
  });
64727
64830
  }
64728
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
+ }
64729
64868
  for (let row = headerCount; row < headerCount + topAggregationCount; row++) table.transpose ? updateRows.push({
64730
64869
  col: row,
64731
64870
  row: 0
@@ -64740,7 +64879,7 @@
64740
64879
  col: 0,
64741
64880
  row: row
64742
64881
  });
64743
- 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);
64744
64883
  }
64745
64884
  }
64746
64885
  }
@@ -64752,7 +64891,7 @@
64752
64891
  const syncToOriginalRecords = !!(null === (_f = table.options) || void 0 === _f ? void 0 : _f.syncRecordOperationsToSourceRecords),
64753
64892
  updateRecordIndexs = table.dataSource.updateRecords(records, recordIndexs, syncToOriginalRecords);
64754
64893
  if (0 === updateRecordIndexs.length) return;
64755
- 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);
64756
64895
  const recordIndexsMinToMax = updateRecordIndexs.map(index => table.getBodyRowIndexByRecordIndex(index)).sort((a, b) => a - b);
64757
64896
  if (table.pagination) {
64758
64897
  const {
@@ -65075,10 +65214,33 @@
65075
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();
65076
65215
  }
65077
65216
  addColumns(toAddColumns, colIndex, isMaintainArrayData = !0) {
65078
- var _a;
65217
+ var _a, _b;
65079
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
+ }
65080
65242
  void 0 === colIndex ? (colIndex = columns.length, columns.push(...toAddColumns)) : columns.splice(colIndex, 0, ...toAddColumns);
65081
- 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);
65082
65244
  this.internalProps._colRangeWidthsMap.clear();
65083
65245
  const resizedColIndexs = Array.from(this.internalProps._widthResizedColMap.keys());
65084
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));
@@ -65091,15 +65253,46 @@
65091
65253
  }
65092
65254
  this.updateColumns(columns, {
65093
65255
  clearRowHeightCache: !1
65094
- }), 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, {
65095
65260
  columnIndex: colIndex,
65096
65261
  columnCount: toAddColumns.length,
65097
65262
  columns: columns
65098
65263
  });
65099
65264
  }
65100
65265
  deleteColumns(deleteColIndexs, isMaintainArrayData = !0) {
65266
+ var _a;
65101
65267
  const columns = this.options.columns;
65102
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));
65103
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++) {
65104
65297
  const record = this.records[j];
65105
65298
  Array.isArray(record) && record.splice(deleteColIndexs[i], 1);
@@ -65115,7 +65308,9 @@
65115
65308
  clearRowHeightCache: !1
65116
65309
  }), this.fireListeners(TABLE_EVENT_TYPE.DELETE_COLUMN, {
65117
65310
  deleteColIndexs: deleteColIndexs,
65118
- columns: columns
65311
+ columns: columns,
65312
+ deletedColumns: deletedColumns,
65313
+ deletedRecordValues: deletedRecordValues
65119
65314
  });
65120
65315
  }
65121
65316
  get columns() {
@@ -65503,9 +65698,9 @@
65503
65698
  }
65504
65699
  }
65505
65700
  updateSortState(sortState, executeSort = !0) {
65506
- var _a;
65507
- 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;
65508
- (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 => {
65509
65704
  const sortFunc = this._getSortFuncFromHeaderOption(this.internalProps.columns, item.field);
65510
65705
  this.internalProps.layoutMap.headerObjects.find(col => col && col.field === item.field);
65511
65706
  return {
@@ -65513,13 +65708,20 @@
65513
65708
  order: item.order,
65514
65709
  orderFn: null != sortFunc ? sortFunc : defaultOrderFn
65515
65710
  };
65516
- })), 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);
65517
65719
  }
65518
65720
  updateFilterRules(filterRules, options = {
65519
65721
  clearRowHeightCache: !0
65520
65722
  }) {
65521
65723
  var _a, _b, _c;
65522
- 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();
65523
65725
  }
65524
65726
  getFilteredRecords() {
65525
65727
  return this.dataSource.records;
@@ -65794,30 +65996,112 @@
65794
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();
65795
65997
  }
65796
65998
  addRecord(record, recordIndex, triggerEvent = !0) {
65797
- 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
+ }
65798
66025
  const success = listTableAddRecord(record, recordIndex, this);
65799
- 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, {
65800
66030
  records: [record],
65801
66031
  recordIndex: recordIndex,
65802
66032
  recordCount: 1
65803
66033
  });
65804
66034
  }
65805
66035
  addRecords(records, recordIndex, triggerEvent = !0) {
65806
- 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
+ }
65807
66063
  const success = listTableAddRecords(records, recordIndex, this);
65808
- "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, {
65809
66068
  records: records,
65810
66069
  recordIndex: recordIndex,
65811
66070
  recordCount: records.length
65812
66071
  });
65813
66072
  }
65814
66073
  deleteRecords(recordIndexs, triggerEvent = !0) {
65815
- var _a;
65816
- const deletedRecords = [];
65817
- (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 => {
65818
66081
  let record = null;
65819
66082
  record = "number" == typeof index ? this.dataSource.get(index) : [], deletedRecords.push(record);
65820
- }), 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();
65821
66105
  const rowIndexs = [];
65822
66106
  for (let i = 0; i < recordIndexs.length; i++) rowIndexs.push(this.getBodyRowIndexByRecordIndex(recordIndexs[i]) + this.columnHeaderLevelCount);
65823
66107
  triggerEvent && this.fireListeners(TABLE_EVENT_TYPE.DELETE_RECORD, {
@@ -65825,7 +66109,16 @@
65825
66109
  records: deletedRecords,
65826
66110
  rowIndexs: rowIndexs,
65827
66111
  deletedCount: (Array.isArray(recordIndexs[0]), recordIndexs.length)
65828
- });
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));
65829
66122
  }
65830
66123
  updateRecords(records, recordIndexs, triggerEvent = !0) {
65831
66124
  listTableUpdateRecords(records, recordIndexs, this), triggerEvent && this.fireListeners(TABLE_EVENT_TYPE.UPDATE_RECORD, {
@@ -65929,7 +66222,12 @@
65929
66222
  }
65930
66223
  }), this.internalProps.customMergeCell = getCustomMergeCellFunc(this.options.customMergeCell);
65931
66224
  for (let i = startCol; i <= endCol; i++) for (let j = startRow; j <= endRow; j++) this.scenegraph.updateCellContent(i, j);
65932
- 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
+ });
65933
66231
  }
65934
66232
  unmergeCells(startCol, startRow, endCol, endRow) {
65935
66233
  this.options.customMergeCell ? "function" == typeof this.options.customMergeCell && (this.options.customMergeCell = []) : this.options.customMergeCell = [], this.options.customMergeCell = this.options.customMergeCell.filter(item => {
@@ -65940,7 +66238,12 @@
65940
66238
  return !(start.col === startCol && start.row === startRow && end.col === endCol && end.row === endRow);
65941
66239
  }), this.internalProps.customMergeCell = getCustomMergeCellFunc(this.options.customMergeCell);
65942
66240
  for (let i = startCol; i <= endCol; i++) for (let j = startRow; j <= endRow; j++) this.scenegraph.updateCellContent(i, j);
65943
- 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
+ });
65944
66247
  }
65945
66248
  }
65946
66249
 
@@ -70209,8 +70512,7 @@
70209
70512
  (!isMilestone && (taskDays <= 0 || !startDate || !endDate || startDate.getTime() > endDate.getTime()))) {
70210
70513
  return { barGroupBox: null, baselineBar: null };
70211
70514
  }
70212
- const { unit, step } = this._scene._gantt.parsedOptions.reverseSortedTimelineScales[0];
70213
- 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());
70214
70516
  const taskBarStyle = this._scene._gantt.getTaskBarStyle(index, childIndex);
70215
70517
  const taskbarHeight = taskBarStyle.width;
70216
70518
  if (isValid$1(taskBarStyle.minSize)) {
@@ -70218,9 +70520,7 @@
70218
70520
  }
70219
70521
  const oneTaskHeigth = this._scene._gantt.parsedOptions.rowHeight;
70220
70522
  const milestoneTaskBarHeight = this._scene._gantt.parsedOptions.taskBarMilestoneStyle.width;
70221
- const x = computeCountToTimeScale(startDate, this._scene._gantt.parsedOptions.minDate, unit, step) *
70222
- this._scene._gantt.parsedOptions.timelineColWidth -
70223
- (isMilestone ? milestoneTaskBarHeight / 2 : 0);
70523
+ const x = this._scene._gantt.getXByTime(startDate.getTime()) - (isMilestone ? milestoneTaskBarHeight / 2 : 0);
70224
70524
  let y = this._scene._gantt.getRowsHeightByIndex(0, index - 1) +
70225
70525
  (this._scene._gantt.parsedOptions.tasksShowMode === TasksShowMode.Sub_Tasks_Separate
70226
70526
  ? (childIndex ?? 0) * oneTaskHeigth
@@ -70235,10 +70535,9 @@
70235
70535
  let taskBarYOffset = 0;
70236
70536
  if (hasBaseline && !isMilestone) {
70237
70537
  const baselineStyle = this._scene._gantt.getBaselineStyle(index, childIndex);
70238
- const baselineX = computeCountToTimeScale(baselineInfo.baselineStartDate, this._scene._gantt.parsedOptions.minDate, unit, step) *
70239
- this._scene._gantt.parsedOptions.timelineColWidth;
70240
- const baselineWidth = computeCountToTimeScale(baselineInfo.baselineEndDate, baselineInfo.baselineStartDate, unit, step, 1) *
70241
- this._scene._gantt.parsedOptions.timelineColWidth;
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());
70242
70541
  let baselineY;
70243
70542
  const taskBarPaddingTop = taskBarStyle.paddingTop ?? undefined;
70244
70543
  const baselinePaddingTop = baselineStyle.paddingTop ?? undefined;
@@ -70849,22 +71148,24 @@
70849
71148
  const date = this._scene._gantt.parsedOptions.timeScaleIncludeHour
70850
71149
  ? createDateAtMidnight(line.date)
70851
71150
  : createDateAtMidnight(line.date, true);
70852
- const { unit, step } = this._scene._gantt.parsedOptions.reverseSortedTimelineScales[0];
70853
- const unitCount = computeCountToTimeScale(date, minDate, unit, step);
70854
- let positionOffset = 0;
70855
- if (line.position === 'right') {
70856
- positionOffset = 1;
71151
+ const dateTime = date.getTime();
71152
+ if (dateTime < this._scene._gantt.parsedOptions._minDateTime ||
71153
+ dateTime > this._scene._gantt.parsedOptions._maxDateTime) {
71154
+ return;
70857
71155
  }
70858
- else if (line.position === 'middle') {
70859
- 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);
71162
+ }
71163
+ else if (line.position === 'right') {
71164
+ dateX = cellStartX + cellWidth;
70860
71165
  }
70861
- else if (line.position === 'date') {
70862
- const date = createDateAtMidnight(line.date);
70863
- const unitCount = computeCountToTimeScale(date, minDate, unit, step);
70864
- const cellIndex = Math.floor(unitCount);
70865
- positionOffset = unitCount - cellIndex;
71166
+ else if (line.position === 'middle') {
71167
+ dateX = cellStartX + cellWidth / 2;
70866
71168
  }
70867
- const dateX = this._scene._gantt.parsedOptions.timelineColWidth * (Math.floor(unitCount) + positionOffset);
70868
71169
  const markLineGroup = new Group$2({
70869
71170
  pickable: false,
70870
71171
  x: dateX - this.markLineContainerWidth / 2,
@@ -70886,7 +71187,7 @@
70886
71187
  });
70887
71188
  markLineGroup.appendChild(lineObj);
70888
71189
  if (line.content) {
70889
- const textMaxLineWidth = this._scene._gantt.parsedOptions.timelineColWidth;
71190
+ const textMaxLineWidth = Math.max(this._scene._gantt.getDateColWidth(cellIndex), 1);
70890
71191
  const textContainerHeight = contentStyle.lineHeight || 18;
70891
71192
  const textGroup = new Group$2({
70892
71193
  x: this.markLineContainerWidth / 2,
@@ -71475,22 +71776,21 @@
71475
71776
  }
71476
71777
  }
71477
71778
  function generateLinkLinePoints(type, linkedFromTaskStartDate, linkedFromTaskEndDate, linkedFromTaskRecordRowIndex, linkedFromTaskTaskDays, linkedFromTaskIsMilestone, linkedToTaskStartDate, linkedToTaskEndDate, linkedToTaskRecordRowIndex, linkedToTaskTaskDays, linkedToTaskIsMilestone, gantt) {
71478
- const { unit, step } = gantt.parsedOptions.reverseSortedTimelineScales[0];
71479
- const { minDate, rowHeight, timelineColWidth } = gantt.parsedOptions;
71779
+ const { rowHeight } = gantt.parsedOptions;
71480
71780
  const taskBarMilestoneHypotenuse = gantt.parsedOptions.taskBarMilestoneHypotenuse;
71481
71781
  const distanceToTaskBar = gantt.parsedOptions.dependencyLinkDistanceToTaskBar ?? 20;
71482
71782
  const arrowWidth = 10;
71483
71783
  const arrowHeight = 5;
71484
71784
  let linePoints = [];
71485
71785
  let arrowPoints = [];
71786
+ const getStartX = (d) => gantt.getXByTime(d.getTime());
71787
+ const getEndX = (d) => gantt.getXByTime(d.getTime() + 1);
71486
71788
  if (type === DependencyType.FinishToStart) {
71487
- let linkFromPointX = computeCountToTimeScale(linkedFromTaskEndDate, minDate, unit, step, 1) * timelineColWidth;
71789
+ let linkFromPointX = getEndX(linkedFromTaskEndDate);
71488
71790
  if (linkedFromTaskIsMilestone) {
71489
- linkFromPointX =
71490
- computeCountToTimeScale(linkedFromTaskStartDate, minDate, unit, step, 1) * timelineColWidth +
71491
- taskBarMilestoneHypotenuse / 2;
71791
+ linkFromPointX = getStartX(linkedFromTaskStartDate) + taskBarMilestoneHypotenuse / 2;
71492
71792
  }
71493
- let linkToPointX = computeCountToTimeScale(linkedToTaskStartDate, minDate, unit, step) * timelineColWidth;
71793
+ let linkToPointX = getStartX(linkedToTaskStartDate);
71494
71794
  if (linkedToTaskIsMilestone) {
71495
71795
  linkToPointX -= taskBarMilestoneHypotenuse / 2;
71496
71796
  }
@@ -71549,15 +71849,13 @@
71549
71849
  ];
71550
71850
  }
71551
71851
  else if (type === DependencyType.StartToFinish) {
71552
- let linkFromPointX = computeCountToTimeScale(linkedFromTaskStartDate, minDate, unit, step) * timelineColWidth;
71852
+ let linkFromPointX = getStartX(linkedFromTaskStartDate);
71553
71853
  if (linkedFromTaskIsMilestone) {
71554
71854
  linkFromPointX -= taskBarMilestoneHypotenuse / 2;
71555
71855
  }
71556
- let linkToPointX = computeCountToTimeScale(linkedToTaskEndDate, minDate, unit, step, 1) * timelineColWidth;
71856
+ let linkToPointX = getEndX(linkedToTaskEndDate);
71557
71857
  if (linkedToTaskIsMilestone) {
71558
- linkToPointX =
71559
- computeCountToTimeScale(linkedToTaskStartDate, minDate, unit, step, 1) * timelineColWidth +
71560
- taskBarMilestoneHypotenuse / 2;
71858
+ linkToPointX = getStartX(linkedToTaskStartDate) + taskBarMilestoneHypotenuse / 2;
71561
71859
  }
71562
71860
  linePoints = [
71563
71861
  {
@@ -71614,11 +71912,11 @@
71614
71912
  ];
71615
71913
  }
71616
71914
  else if (type === DependencyType.StartToStart) {
71617
- let linkFromPointX = computeCountToTimeScale(linkedFromTaskStartDate, minDate, unit, step) * timelineColWidth;
71915
+ let linkFromPointX = getStartX(linkedFromTaskStartDate);
71618
71916
  if (linkedFromTaskIsMilestone) {
71619
71917
  linkFromPointX -= taskBarMilestoneHypotenuse / 2;
71620
71918
  }
71621
- let linkToPointX = computeCountToTimeScale(linkedToTaskStartDate, minDate, unit, step) * timelineColWidth;
71919
+ let linkToPointX = getStartX(linkedToTaskStartDate);
71622
71920
  if (linkedToTaskIsMilestone) {
71623
71921
  linkToPointX -= taskBarMilestoneHypotenuse / 2;
71624
71922
  }
@@ -71677,17 +71975,13 @@
71677
71975
  ];
71678
71976
  }
71679
71977
  else if (type === DependencyType.FinishToFinish) {
71680
- let linkFromPointX = computeCountToTimeScale(linkedFromTaskEndDate, minDate, unit, step, 1) * timelineColWidth;
71978
+ let linkFromPointX = getEndX(linkedFromTaskEndDate);
71681
71979
  if (linkedFromTaskIsMilestone) {
71682
- linkFromPointX =
71683
- computeCountToTimeScale(linkedFromTaskStartDate, minDate, unit, step, 1) * timelineColWidth +
71684
- taskBarMilestoneHypotenuse / 2;
71980
+ linkFromPointX = getStartX(linkedFromTaskStartDate) + taskBarMilestoneHypotenuse / 2;
71685
71981
  }
71686
- let linkToPointX = computeCountToTimeScale(linkedToTaskEndDate, minDate, unit, step, 1) * timelineColWidth;
71982
+ let linkToPointX = getEndX(linkedToTaskEndDate);
71687
71983
  if (linkedToTaskIsMilestone) {
71688
- linkToPointX =
71689
- computeCountToTimeScale(linkedToTaskStartDate, minDate, unit, step, 1) * timelineColWidth +
71690
- taskBarMilestoneHypotenuse / 2;
71984
+ linkToPointX = getStartX(linkedToTaskStartDate) + taskBarMilestoneHypotenuse / 2;
71691
71985
  }
71692
71986
  linePoints = [
71693
71987
  {
@@ -71744,8 +72038,7 @@
71744
72038
  return { linePoints, arrowPoints };
71745
72039
  }
71746
72040
  function updateLinkLinePoints(type, linkedFromTaskStartDate, linkedFromTaskEndDate, linkedFromTaskRecordRowIndex, linkedFromTaskTaskDays, linkedFromTaskIsMilestone, linkedFromMovedTaskBarNode, fromNodeDiffY, linkedToTaskStartDate, linkedToTaskEndDate, linkedToTaskRecordRowIndex, linkedToTaskTaskDays, linkedToTaskIsMilestone, linkedToMovedTaskBarNode, toNodeDiffY, gantt) {
71747
- const { unit, step } = gantt.parsedOptions.reverseSortedTimelineScales[0];
71748
- const { minDate, rowHeight, timelineColWidth } = gantt.parsedOptions;
72041
+ const { rowHeight } = gantt.parsedOptions;
71749
72042
  const taskBarMilestoneHypotenuse = gantt.parsedOptions.taskBarMilestoneHypotenuse;
71750
72043
  const milestoneTaskbarHeight = gantt.parsedOptions.taskBarMilestoneStyle.width;
71751
72044
  const distanceToTaskBar = gantt.parsedOptions.dependencyLinkDistanceToTaskBar ?? 20;
@@ -71753,21 +72046,22 @@
71753
72046
  const arrowHeight = 5;
71754
72047
  let linePoints = [];
71755
72048
  let arrowPoints = [];
72049
+ const getStartX = (d) => gantt.getXByTime(d.getTime());
72050
+ const getEndX = (d) => gantt.getXByTime(d.getTime() + 1);
71756
72051
  if (type === DependencyType.FinishToStart) {
71757
72052
  let linkFromPointX = linkedFromMovedTaskBarNode
71758
72053
  ? linkedFromMovedTaskBarNode.attribute.x + linkedFromMovedTaskBarNode.attribute.width
71759
- : computeCountToTimeScale(linkedFromTaskEndDate, minDate, unit, step, 1) * timelineColWidth;
72054
+ : getEndX(linkedFromTaskEndDate);
71760
72055
  if (linkedFromTaskIsMilestone) {
71761
72056
  linkFromPointX = linkedFromMovedTaskBarNode
71762
72057
  ? linkedFromMovedTaskBarNode.attribute.x +
71763
72058
  linkedFromMovedTaskBarNode.attribute.width +
71764
72059
  (taskBarMilestoneHypotenuse - milestoneTaskbarHeight) / 2
71765
- : computeCountToTimeScale(linkedFromTaskStartDate, minDate, unit, step, 1) * timelineColWidth +
71766
- taskBarMilestoneHypotenuse / 2;
72060
+ : getStartX(linkedFromTaskStartDate) + taskBarMilestoneHypotenuse / 2;
71767
72061
  }
71768
72062
  let linkToPointX = linkedToMovedTaskBarNode
71769
72063
  ? linkedToMovedTaskBarNode.attribute.x
71770
- : computeCountToTimeScale(linkedToTaskStartDate, minDate, unit, step) * timelineColWidth;
72064
+ : getStartX(linkedToTaskStartDate);
71771
72065
  if (linkedToTaskIsMilestone) {
71772
72066
  linkToPointX -= (taskBarMilestoneHypotenuse - milestoneTaskbarHeight) / 2;
71773
72067
  }
@@ -71830,20 +72124,19 @@
71830
72124
  else if (type === DependencyType.StartToFinish) {
71831
72125
  let linkFromPointX = linkedFromMovedTaskBarNode
71832
72126
  ? linkedFromMovedTaskBarNode.attribute.x
71833
- : computeCountToTimeScale(linkedFromTaskStartDate, minDate, unit, step) * timelineColWidth;
72127
+ : getStartX(linkedFromTaskStartDate);
71834
72128
  if (linkedFromTaskIsMilestone) {
71835
72129
  linkFromPointX -= (taskBarMilestoneHypotenuse - milestoneTaskbarHeight) / 2;
71836
72130
  }
71837
72131
  let linkToPointX = linkedToMovedTaskBarNode
71838
72132
  ? linkedToMovedTaskBarNode.attribute.x + linkedToMovedTaskBarNode.attribute.width
71839
- : computeCountToTimeScale(linkedToTaskEndDate, minDate, unit, step, 1) * timelineColWidth;
72133
+ : getEndX(linkedToTaskEndDate);
71840
72134
  if (linkedToTaskIsMilestone) {
71841
72135
  linkToPointX = linkedToMovedTaskBarNode
71842
72136
  ? linkedToMovedTaskBarNode.attribute.x +
71843
72137
  linkedToMovedTaskBarNode.attribute.width +
71844
72138
  (taskBarMilestoneHypotenuse - milestoneTaskbarHeight) / 2
71845
- : computeCountToTimeScale(linkedToTaskStartDate, minDate, unit, step, 1) * timelineColWidth +
71846
- taskBarMilestoneHypotenuse / 2;
72139
+ : getStartX(linkedToTaskStartDate) + taskBarMilestoneHypotenuse / 2;
71847
72140
  }
71848
72141
  linePoints = [
71849
72142
  {
@@ -71904,13 +72197,13 @@
71904
72197
  else if (type === DependencyType.StartToStart) {
71905
72198
  let linkFromPointX = linkedFromMovedTaskBarNode
71906
72199
  ? linkedFromMovedTaskBarNode.attribute.x
71907
- : computeCountToTimeScale(linkedFromTaskStartDate, minDate, unit, step) * timelineColWidth;
72200
+ : getStartX(linkedFromTaskStartDate);
71908
72201
  if (linkedFromTaskIsMilestone) {
71909
72202
  linkFromPointX -= (taskBarMilestoneHypotenuse - milestoneTaskbarHeight) / 2;
71910
72203
  }
71911
72204
  let linkToPointX = linkedToMovedTaskBarNode
71912
72205
  ? linkedToMovedTaskBarNode.attribute.x
71913
- : computeCountToTimeScale(linkedToTaskStartDate, minDate, unit, step) * timelineColWidth;
72206
+ : getStartX(linkedToTaskStartDate);
71914
72207
  if (linkedToTaskIsMilestone) {
71915
72208
  linkToPointX -= (taskBarMilestoneHypotenuse - milestoneTaskbarHeight) / 2;
71916
72209
  }
@@ -71973,25 +72266,23 @@
71973
72266
  else if (type === DependencyType.FinishToFinish) {
71974
72267
  let linkFromPointX = linkedFromMovedTaskBarNode
71975
72268
  ? linkedFromMovedTaskBarNode.attribute.x + linkedFromMovedTaskBarNode.attribute.width
71976
- : computeCountToTimeScale(linkedFromTaskEndDate, minDate, unit, step, 1) * timelineColWidth;
72269
+ : getEndX(linkedFromTaskEndDate);
71977
72270
  if (linkedFromTaskIsMilestone) {
71978
72271
  linkFromPointX = linkedFromMovedTaskBarNode
71979
72272
  ? linkedFromMovedTaskBarNode.attribute.x +
71980
72273
  linkedFromMovedTaskBarNode.attribute.width +
71981
72274
  (taskBarMilestoneHypotenuse - milestoneTaskbarHeight) / 2
71982
- : computeCountToTimeScale(linkedFromTaskStartDate, minDate, unit, step, 1) * timelineColWidth +
71983
- taskBarMilestoneHypotenuse / 2;
72275
+ : getStartX(linkedFromTaskStartDate) + taskBarMilestoneHypotenuse / 2;
71984
72276
  }
71985
72277
  let linkToPointX = linkedToMovedTaskBarNode
71986
72278
  ? linkedToMovedTaskBarNode.attribute.x + linkedToMovedTaskBarNode.attribute.width
71987
- : computeCountToTimeScale(linkedToTaskEndDate, minDate, unit, step, 1) * timelineColWidth;
72279
+ : getEndX(linkedToTaskEndDate);
71988
72280
  if (linkedToTaskIsMilestone) {
71989
72281
  linkToPointX = linkedToMovedTaskBarNode
71990
72282
  ? linkedToMovedTaskBarNode.attribute.x +
71991
72283
  linkedToMovedTaskBarNode.attribute.width +
71992
72284
  (taskBarMilestoneHypotenuse - milestoneTaskbarHeight) / 2
71993
- : computeCountToTimeScale(linkedToTaskStartDate, minDate, unit, step, 1) * timelineColWidth +
71994
- taskBarMilestoneHypotenuse / 2;
72285
+ : getStartX(linkedToTaskStartDate) + taskBarMilestoneHypotenuse / 2;
71995
72286
  }
71996
72287
  linePoints = [
71997
72288
  {
@@ -74311,7 +74602,7 @@
74311
74602
  gantt._updateSize();
74312
74603
  gantt.scenegraph.refreshAll();
74313
74604
  target = this.moveTaskBar.target = gantt.scenegraph.taskBar.getTaskBarNodeByIndex(this.moveTaskBar.target.task_index, this.moveTaskBar.target.sub_task_index);
74314
- gantt.scrollLeft = gantt.parsedOptions.timelineColWidth - 1;
74605
+ gantt.scrollLeft = Math.max(0, gantt.getDateColWidth(0) - 1);
74315
74606
  gantt.eventManager.lastDragPointerXYOnWindow.x = e.x;
74316
74607
  if (target.record?.type === 'milestone') {
74317
74608
  moveTaskBar(target, gantt.scrollLeft - target.attribute.x, 0, this);
@@ -74321,7 +74612,9 @@
74321
74612
  }
74322
74613
  }
74323
74614
  else {
74324
- 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;
74325
74618
  this.moveTaskBar.moveTaskBarXInertia.startInertia(this.moveTaskBar.moveTaskBarXSpeed, 0, 1);
74326
74619
  this.moveTaskBar.moveTaskBarXInertia.setScrollHandle((dx, dy) => {
74327
74620
  this.moveTaskBar.deltaX += dx;
@@ -74359,7 +74652,9 @@
74359
74652
  }
74360
74653
  }
74361
74654
  else {
74362
- 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;
74363
74658
  this.moveTaskBar.moveTaskBarXInertia.startInertia(this.moveTaskBar.moveTaskBarXSpeed, 0, 1);
74364
74659
  this.moveTaskBar.moveTaskBarXInertia.setScrollHandle((dx, dy) => {
74365
74660
  this.moveTaskBar.deltaX += dx;
@@ -76158,6 +76453,10 @@
76158
76453
  parsedOptions = {};
76159
76454
  millisecondsPerPixel;
76160
76455
  zoomScaleManager;
76456
+ _timelineColWidths = [];
76457
+ _timelineColX = [];
76458
+ _timelineColStartTimes = [];
76459
+ _timelineColEndTimes = [];
76161
76460
  recalculateTimeScale() {
76162
76461
  if (this.zoomScaleManager) {
76163
76462
  this.zoomScaleManager.recalculateTimeScale();
@@ -76572,6 +76871,151 @@
76572
76871
  scale.timelineDates = generateTimeLineDate(new Date(this.parsedOptions.minDate), this.parsedOptions.maxDate, scale);
76573
76872
  }
76574
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));
76575
77019
  }
76576
77020
  getRowHeightByIndex(index) {
76577
77021
  if (this.taskListTableInstance) {
@@ -76600,6 +77044,10 @@
76600
77044
  }, 0);
76601
77045
  }
76602
77046
  getAllDateColsWidth() {
77047
+ const xPrefix = this._timelineColX;
77048
+ if (xPrefix?.length) {
77049
+ return xPrefix[xPrefix.length - 1] ?? 0;
77050
+ }
76603
77051
  return (this.parsedOptions.timelineColWidth *
76604
77052
  (this.parsedOptions.reverseSortedTimelineScales[0].timelineDates?.length ?? 0));
76605
77053
  }
@@ -77001,10 +77449,7 @@
77001
77449
  }
77002
77450
  _scrollToMarkLine() {
77003
77451
  if (this.parsedOptions.scrollToMarkLineDate && this.parsedOptions.minDate) {
77004
- const minDate = this.parsedOptions.minDate;
77005
- const { unit, step } = this.parsedOptions.reverseSortedTimelineScales[0];
77006
- const count = computeCountToTimeScale(this.parsedOptions.scrollToMarkLineDate, minDate, unit, step);
77007
- const targetDayDistance = count * this.parsedOptions.timelineColWidth;
77452
+ const targetDayDistance = this.getXByTime(this.parsedOptions.scrollToMarkLineDate.getTime());
77008
77453
  const left = targetDayDistance - this.tableNoFrameWidth / 2;
77009
77454
  this.stateManager.setScrollLeft(left);
77010
77455
  }
@@ -77013,10 +77458,7 @@
77013
77458
  if (!date || !this.parsedOptions.minDate) {
77014
77459
  return;
77015
77460
  }
77016
- const minDate = this.parsedOptions.minDate;
77017
- const { unit, step } = this.parsedOptions.reverseSortedTimelineScales[0];
77018
- const count = computeCountToTimeScale(date, minDate, unit, step);
77019
- const targetDayDistance = count * this.parsedOptions.timelineColWidth;
77461
+ const targetDayDistance = this.getXByTime(date.getTime());
77020
77462
  const left = targetDayDistance - this.tableNoFrameWidth / 2;
77021
77463
  this.stateManager.setScrollLeft(left);
77022
77464
  }
@@ -77068,9 +77510,22 @@
77068
77510
  };
77069
77511
  }
77070
77512
  getDateColWidth(dateIndex) {
77513
+ const widths = this._timelineColWidths;
77514
+ if (widths?.length && dateIndex >= 0 && dateIndex < widths.length) {
77515
+ return widths[dateIndex] ?? 0;
77516
+ }
77071
77517
  return this.parsedOptions.timelineColWidth;
77072
77518
  }
77073
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
+ }
77074
77529
  return (endDateIndex - startDateIndex + 1) * this.parsedOptions.timelineColWidth;
77075
77530
  }
77076
77531
  getDateRangeByIndex(index) {
@@ -77192,7 +77647,7 @@
77192
77647
  PluginManager: PluginManager
77193
77648
  });
77194
77649
 
77195
- const version = "1.23.3";
77650
+ const version = "1.24.0";
77196
77651
 
77197
77652
  exports.Gantt = Gantt;
77198
77653
  exports.TYPES = index$4;