@nocobase/plugin-gantt 2.1.0-beta.36 → 2.1.0-beta.38

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 (146) hide show
  1. package/client-v2.d.ts +2 -0
  2. package/client-v2.js +3 -0
  3. package/dist/client/index.js +1 -1
  4. package/dist/client-v2/143.1a8cf1cd5ce17b64.js +10 -0
  5. package/dist/client-v2/416.b7bb09162520e448.js +10 -0
  6. package/dist/client-v2/617.de3dc437887f3f07.js +10 -0
  7. package/dist/client-v2/872.e640aca77c79d895.js +10 -0
  8. package/dist/client-v2/index.d.ts +10 -0
  9. package/dist/client-v2/index.js +10 -0
  10. package/dist/client-v2/locale.d.ts +78 -0
  11. package/dist/client-v2/models/GanttBlockModel.d.ts +98 -0
  12. package/dist/client-v2/models/GanttBlockModel.helpers.d.ts +31 -0
  13. package/dist/client-v2/models/GanttBlockModel.settings.d.ts +9 -0
  14. package/dist/client-v2/models/actions/GanttActionModels.d.ts +33 -0
  15. package/dist/client-v2/models/actions/GanttPopupModels.d.ts +26 -0
  16. package/dist/client-v2/models/components/GanttBlock.d.ts +13 -0
  17. package/dist/client-v2/models/components/GanttBlock.helpers.d.ts +22 -0
  18. package/dist/client-v2/models/components/GanttBlock.styles.d.ts +22 -0
  19. package/dist/client-v2/models/components/GanttBlock.tree.d.ts +46 -0
  20. package/dist/client-v2/models/components/getLabelFormatValue.d.ts +11 -0
  21. package/dist/client-v2/models/index.d.ts +11 -0
  22. package/dist/client-v2/plugin.d.ts +13 -0
  23. package/dist/externalVersion.js +7 -6
  24. package/dist/locale/de-DE.json +2 -0
  25. package/dist/locale/en-US.json +25 -1
  26. package/dist/locale/es-ES.json +2 -0
  27. package/dist/locale/fr-FR.json +2 -0
  28. package/dist/locale/hu-HU.json +2 -0
  29. package/dist/locale/id-ID.json +2 -0
  30. package/dist/locale/it-IT.json +2 -0
  31. package/dist/locale/ja-JP.json +2 -0
  32. package/dist/locale/ko-KR.json +2 -0
  33. package/dist/locale/nl-NL.json +2 -0
  34. package/dist/locale/pt-BR.json +2 -0
  35. package/dist/locale/ru-RU.json +2 -0
  36. package/dist/locale/tr-TR.json +2 -0
  37. package/dist/locale/uk-UA.json +2 -0
  38. package/dist/locale/vi-VN.json +2 -0
  39. package/dist/locale/zh-CN.json +25 -1
  40. package/dist/locale/zh-TW.json +4 -0
  41. package/dist/node_modules/@ctrl/tinycolor/LICENSE +7 -0
  42. package/dist/node_modules/@ctrl/tinycolor/dist/bundles/tinycolor.umd.min.js +2 -0
  43. package/dist/node_modules/@ctrl/tinycolor/dist/conversion.d.ts +61 -0
  44. package/dist/node_modules/@ctrl/tinycolor/dist/conversion.js +250 -0
  45. package/dist/node_modules/@ctrl/tinycolor/dist/css-color-names.d.ts +4 -0
  46. package/dist/node_modules/@ctrl/tinycolor/dist/css-color-names.js +157 -0
  47. package/dist/node_modules/@ctrl/tinycolor/dist/format-input.d.ts +37 -0
  48. package/dist/node_modules/@ctrl/tinycolor/dist/format-input.js +189 -0
  49. package/dist/node_modules/@ctrl/tinycolor/dist/from-ratio.d.ts +14 -0
  50. package/dist/node_modules/@ctrl/tinycolor/dist/from-ratio.js +30 -0
  51. package/dist/node_modules/@ctrl/tinycolor/dist/index.d.ts +207 -0
  52. package/dist/node_modules/@ctrl/tinycolor/dist/index.js +512 -0
  53. package/dist/node_modules/@ctrl/tinycolor/dist/interfaces.d.ts +46 -0
  54. package/dist/node_modules/@ctrl/tinycolor/dist/interfaces.js +2 -0
  55. package/dist/node_modules/@ctrl/tinycolor/dist/module/conversion.js +235 -0
  56. package/dist/node_modules/@ctrl/tinycolor/dist/module/css-color-names.js +154 -0
  57. package/dist/node_modules/@ctrl/tinycolor/dist/module/format-input.js +183 -0
  58. package/dist/node_modules/@ctrl/tinycolor/dist/module/from-ratio.js +25 -0
  59. package/dist/node_modules/@ctrl/tinycolor/dist/module/index.js +508 -0
  60. package/dist/node_modules/@ctrl/tinycolor/dist/module/interfaces.js +1 -0
  61. package/dist/node_modules/@ctrl/tinycolor/dist/module/public_api.js +12 -0
  62. package/dist/node_modules/@ctrl/tinycolor/dist/module/random.js +278 -0
  63. package/dist/node_modules/@ctrl/tinycolor/dist/module/readability.js +80 -0
  64. package/dist/node_modules/@ctrl/tinycolor/dist/module/to-ms-filter.js +16 -0
  65. package/dist/node_modules/@ctrl/tinycolor/dist/module/umd_api.js +20 -0
  66. package/dist/node_modules/@ctrl/tinycolor/dist/module/util.js +82 -0
  67. package/dist/node_modules/@ctrl/tinycolor/dist/public_api.d.ts +11 -0
  68. package/dist/node_modules/@ctrl/tinycolor/dist/public_api.js +1 -0
  69. package/dist/node_modules/@ctrl/tinycolor/dist/random.d.ts +24 -0
  70. package/dist/node_modules/@ctrl/tinycolor/dist/random.js +282 -0
  71. package/dist/node_modules/@ctrl/tinycolor/dist/readability.d.ts +46 -0
  72. package/dist/node_modules/@ctrl/tinycolor/dist/readability.js +86 -0
  73. package/dist/node_modules/@ctrl/tinycolor/dist/to-ms-filter.d.ts +5 -0
  74. package/dist/node_modules/@ctrl/tinycolor/dist/to-ms-filter.js +20 -0
  75. package/dist/node_modules/@ctrl/tinycolor/dist/umd_api.d.ts +23 -0
  76. package/dist/node_modules/@ctrl/tinycolor/dist/umd_api.js +22 -0
  77. package/dist/node_modules/@ctrl/tinycolor/dist/util.d.ts +36 -0
  78. package/dist/node_modules/@ctrl/tinycolor/dist/util.js +92 -0
  79. package/dist/node_modules/@ctrl/tinycolor/package.json +1 -0
  80. package/dist/shared/components/calendar/calendar.d.ts +22 -0
  81. package/dist/shared/components/calendar/calendar.js +417 -0
  82. package/dist/shared/components/calendar/style.d.ts +14 -0
  83. package/dist/shared/components/calendar/style.js +79 -0
  84. package/dist/shared/components/calendar/top-part-of-calendar.d.ts +19 -0
  85. package/dist/shared/components/calendar/top-part-of-calendar.js +57 -0
  86. package/dist/shared/components/gantt/style.d.ts +14 -0
  87. package/dist/shared/components/gantt/style.js +74 -0
  88. package/dist/shared/components/gantt/task-gantt-content.d.ts +35 -0
  89. package/dist/shared/components/gantt/task-gantt-content.js +337 -0
  90. package/dist/shared/components/gantt/task-gantt.d.ts +24 -0
  91. package/dist/shared/components/gantt/task-gantt.js +128 -0
  92. package/dist/shared/components/grid/grid-body.d.ts +21 -0
  93. package/dist/shared/components/grid/grid-body.js +114 -0
  94. package/dist/shared/components/grid/grid.d.ts +12 -0
  95. package/dist/shared/components/grid/grid.js +50 -0
  96. package/dist/shared/components/grid/style.d.ts +14 -0
  97. package/dist/shared/components/grid/style.js +54 -0
  98. package/dist/shared/components/other/arrow.d.ts +20 -0
  99. package/dist/shared/components/other/arrow.js +90 -0
  100. package/dist/shared/components/other/horizontal-scroll.d.ts +16 -0
  101. package/dist/shared/components/other/horizontal-scroll.js +64 -0
  102. package/dist/shared/components/other/style.d.ts +16 -0
  103. package/dist/shared/components/other/style.js +125 -0
  104. package/dist/shared/components/other/tooltip.d.ts +36 -0
  105. package/dist/shared/components/other/tooltip.js +137 -0
  106. package/dist/shared/components/other/vertical-scroll.d.ts +17 -0
  107. package/dist/shared/components/other/vertical-scroll.js +74 -0
  108. package/dist/shared/components/task-item/bar/bar-date-handle.d.ts +19 -0
  109. package/dist/shared/components/task-item/bar/bar-date-handle.js +62 -0
  110. package/dist/shared/components/task-item/bar/bar-display.d.ts +29 -0
  111. package/dist/shared/components/task-item/bar/bar-display.js +98 -0
  112. package/dist/shared/components/task-item/bar/bar-progress-handle.d.ts +15 -0
  113. package/dist/shared/components/task-item/bar/bar-progress-handle.js +49 -0
  114. package/dist/shared/components/task-item/bar/bar-small.d.ts +11 -0
  115. package/dist/shared/components/task-item/bar/bar-small.js +85 -0
  116. package/dist/shared/components/task-item/bar/bar.d.ts +11 -0
  117. package/dist/shared/components/task-item/bar/bar.js +113 -0
  118. package/dist/shared/components/task-item/bar/style.d.ts +10 -0
  119. package/dist/shared/components/task-item/bar/style.js +58 -0
  120. package/dist/shared/components/task-item/milestone/milestone.d.ts +11 -0
  121. package/dist/shared/components/task-item/milestone/milestone.js +72 -0
  122. package/dist/shared/components/task-item/milestone/style.d.ts +10 -0
  123. package/dist/shared/components/task-item/milestone/style.js +45 -0
  124. package/dist/shared/components/task-item/project/project.d.ts +11 -0
  125. package/dist/shared/components/task-item/project/project.js +77 -0
  126. package/dist/shared/components/task-item/project/style.d.ts +11 -0
  127. package/dist/shared/components/task-item/project/style.js +51 -0
  128. package/dist/shared/components/task-item/style.d.ts +12 -0
  129. package/dist/shared/components/task-item/style.js +74 -0
  130. package/dist/shared/components/task-item/task-item.d.ts +23 -0
  131. package/dist/shared/components/task-item/task-item.js +132 -0
  132. package/dist/shared/helpers/bar-helper.d.ts +22 -0
  133. package/dist/shared/helpers/bar-helper.js +415 -0
  134. package/dist/shared/helpers/date-helper.d.ts +27 -0
  135. package/dist/shared/helpers/date-helper.js +231 -0
  136. package/dist/shared/helpers/other-helper.d.ts +17 -0
  137. package/dist/shared/helpers/other-helper.js +97 -0
  138. package/dist/shared/types/bar-task.d.ts +30 -0
  139. package/dist/shared/types/bar-task.js +24 -0
  140. package/dist/shared/types/date-setup.d.ts +13 -0
  141. package/dist/shared/types/date-setup.js +24 -0
  142. package/dist/shared/types/gantt-task-actions.d.ts +16 -0
  143. package/dist/shared/types/gantt-task-actions.js +24 -0
  144. package/dist/shared/types/public-types.d.ts +145 -0
  145. package/dist/shared/types/public-types.js +46 -0
  146. package/package.json +2 -2
@@ -0,0 +1,415 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var bar_helper_exports = {};
28
+ __export(bar_helper_exports, {
29
+ convertToBarTasks: () => convertToBarTasks,
30
+ getProgressPoint: () => getProgressPoint,
31
+ handleTaskBySVGMouseEvent: () => handleTaskBySVGMouseEvent,
32
+ progressByProgressWidth: () => progressByProgressWidth,
33
+ progressWithByParams: () => progressWithByParams
34
+ });
35
+ module.exports = __toCommonJS(bar_helper_exports);
36
+ const convertToBarTasks = (tasks, dates, columnWidth, rowHeight, taskHeight, barCornerRadius, handleWidth, rtl, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor) => {
37
+ let barTasks = tasks.map((t, i) => {
38
+ return convertToBarTask(
39
+ t,
40
+ i,
41
+ dates,
42
+ columnWidth,
43
+ rowHeight,
44
+ taskHeight,
45
+ barCornerRadius,
46
+ handleWidth,
47
+ rtl,
48
+ barProgressColor,
49
+ barProgressSelectedColor,
50
+ barBackgroundColor,
51
+ barBackgroundSelectedColor,
52
+ projectProgressColor,
53
+ projectProgressSelectedColor,
54
+ projectBackgroundColor,
55
+ projectBackgroundSelectedColor,
56
+ milestoneBackgroundColor,
57
+ milestoneBackgroundSelectedColor
58
+ );
59
+ });
60
+ barTasks = barTasks.map((task) => {
61
+ const dependencies = task.dependencies || [];
62
+ for (let j = 0; j < dependencies.length; j++) {
63
+ const dependence = barTasks.findIndex((value) => value.id === dependencies[j]);
64
+ if (dependence !== -1) barTasks[dependence].barChildren.push(task);
65
+ }
66
+ return task;
67
+ });
68
+ return barTasks;
69
+ };
70
+ const convertToBarTask = (task, index, dates, columnWidth, rowHeight, taskHeight, barCornerRadius, handleWidth, rtl, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor, projectProgressColor, projectProgressSelectedColor, projectBackgroundColor, projectBackgroundSelectedColor, milestoneBackgroundColor, milestoneBackgroundSelectedColor) => {
71
+ let barTask;
72
+ switch (task.type) {
73
+ case "milestone":
74
+ barTask = convertToMilestone(
75
+ task,
76
+ index,
77
+ dates,
78
+ columnWidth,
79
+ rowHeight,
80
+ taskHeight,
81
+ barCornerRadius,
82
+ handleWidth,
83
+ milestoneBackgroundColor,
84
+ milestoneBackgroundSelectedColor
85
+ );
86
+ break;
87
+ case "project":
88
+ barTask = convertToBar(
89
+ task,
90
+ index,
91
+ dates,
92
+ columnWidth,
93
+ rowHeight,
94
+ taskHeight * 0.5,
95
+ barCornerRadius,
96
+ handleWidth,
97
+ rtl,
98
+ projectProgressColor,
99
+ projectProgressSelectedColor,
100
+ projectBackgroundColor,
101
+ projectBackgroundSelectedColor
102
+ );
103
+ break;
104
+ default:
105
+ barTask = convertToBar(
106
+ task,
107
+ index,
108
+ dates,
109
+ columnWidth,
110
+ rowHeight,
111
+ taskHeight,
112
+ barCornerRadius,
113
+ handleWidth,
114
+ rtl,
115
+ barProgressColor,
116
+ barProgressSelectedColor,
117
+ barBackgroundColor,
118
+ barBackgroundSelectedColor
119
+ );
120
+ break;
121
+ }
122
+ return barTask;
123
+ };
124
+ const convertToBar = (task, index, dates, columnWidth, rowHeight, taskHeight, barCornerRadius, handleWidth, rtl, barProgressColor, barProgressSelectedColor, barBackgroundColor, barBackgroundSelectedColor) => {
125
+ let x1;
126
+ let x2;
127
+ if (rtl) {
128
+ x2 = taskXCoordinateRTL(task.start, dates, columnWidth);
129
+ x1 = taskXCoordinateRTL(task.end, dates, columnWidth);
130
+ } else {
131
+ x1 = taskXCoordinate(task.start, dates, columnWidth);
132
+ x2 = taskXCoordinate(task.end, dates, columnWidth);
133
+ }
134
+ let typeInternal = task.type;
135
+ if (typeInternal === "task" && x2 - x1 < handleWidth * 2) {
136
+ typeInternal = "smalltask";
137
+ x2 = x1 > 0 ? x1 + handleWidth * 2 : x1;
138
+ }
139
+ const [progressWidth, progressX] = progressWithByParams(x1, x2, task.progress, rtl);
140
+ const y = task.type === "project" ? taskYCoordinate(index, rowHeight, taskHeight) + 8 : taskYCoordinate(index, rowHeight, taskHeight);
141
+ const hideChildren = task.type === "project" ? task.hideChildren : void 0;
142
+ const styles = {
143
+ backgroundColor: barBackgroundColor,
144
+ backgroundSelectedColor: barBackgroundSelectedColor,
145
+ progressColor: barProgressColor,
146
+ progressSelectedColor: barProgressSelectedColor,
147
+ ...task.styles
148
+ };
149
+ return {
150
+ ...task,
151
+ typeInternal,
152
+ x1,
153
+ x2,
154
+ y,
155
+ index,
156
+ progressX,
157
+ progressWidth,
158
+ barCornerRadius,
159
+ handleWidth,
160
+ hideChildren,
161
+ height: taskHeight,
162
+ barChildren: [],
163
+ styles
164
+ };
165
+ };
166
+ const convertToMilestone = (task, index, dates, columnWidth, rowHeight, taskHeight, barCornerRadius, handleWidth, milestoneBackgroundColor, milestoneBackgroundSelectedColor) => {
167
+ const x = taskXCoordinate(task.start, dates, columnWidth);
168
+ const y = taskYCoordinate(index, rowHeight, taskHeight);
169
+ const x1 = x - taskHeight * 0.5;
170
+ const x2 = x + taskHeight * 0.5;
171
+ const rotatedHeight = taskHeight / 1.414;
172
+ const styles = {
173
+ backgroundColor: milestoneBackgroundColor,
174
+ backgroundSelectedColor: milestoneBackgroundSelectedColor,
175
+ progressColor: "",
176
+ progressSelectedColor: "",
177
+ ...task.styles
178
+ };
179
+ return {
180
+ ...task,
181
+ end: task.start,
182
+ x1,
183
+ x2,
184
+ y,
185
+ index,
186
+ progressX: 0,
187
+ progressWidth: 0,
188
+ barCornerRadius,
189
+ handleWidth,
190
+ typeInternal: task.type,
191
+ progress: 0,
192
+ height: rotatedHeight,
193
+ hideChildren: void 0,
194
+ barChildren: [],
195
+ styles
196
+ };
197
+ };
198
+ const taskXCoordinate = (xDate, dates, columnWidth) => {
199
+ var _a, _b, _c;
200
+ const index = dates.findIndex((d) => (d == null ? void 0 : d.getTime()) >= (xDate == null ? void 0 : xDate.getTime())) - 1;
201
+ const remainderMillis = (xDate == null ? void 0 : xDate.getTime()) - ((_a = dates[index]) == null ? void 0 : _a.getTime());
202
+ const percentOfInterval = remainderMillis / (((_b = dates[index + 1]) == null ? void 0 : _b.getTime()) - ((_c = dates[index]) == null ? void 0 : _c.getTime()));
203
+ const x = index * columnWidth + percentOfInterval * columnWidth;
204
+ return isNaN(x) ? 0 : x;
205
+ };
206
+ const taskXCoordinateRTL = (xDate, dates, columnWidth) => {
207
+ let x = taskXCoordinate(xDate, dates, columnWidth);
208
+ x += columnWidth;
209
+ return isNaN(x) ? 0 : x;
210
+ };
211
+ const taskYCoordinate = (index, rowHeight, taskHeight) => {
212
+ const y = index * rowHeight + (rowHeight - taskHeight) / 2;
213
+ return isNaN(y) ? 0 : y;
214
+ };
215
+ const progressWithByParams = (taskX1, taskX2, progress, rtl) => {
216
+ const progressWidth = (taskX2 - taskX1) * progress * 0.01;
217
+ let progressX;
218
+ if (rtl) {
219
+ progressX = taskX2 - progressWidth;
220
+ } else {
221
+ progressX = taskX1;
222
+ }
223
+ return [progressWidth, progressX];
224
+ };
225
+ const progressByProgressWidth = (progressWidth, barTask) => {
226
+ const barWidth = barTask.x2 - barTask.x1;
227
+ const progressPercent = Math.round(progressWidth * 100 / barWidth);
228
+ if (progressPercent >= 100) return 100;
229
+ else if (progressPercent <= 0) return 0;
230
+ else return progressPercent;
231
+ };
232
+ const progressByX = (x, task) => {
233
+ if (x >= task.x2) return 100;
234
+ else if (x <= task.x1) return 0;
235
+ else {
236
+ const barWidth = task.x2 - task.x1;
237
+ const progressPercent = Math.round((x - task.x1) * 100 / barWidth);
238
+ return progressPercent;
239
+ }
240
+ };
241
+ const progressByXRTL = (x, task) => {
242
+ if (x >= task.x2) return 0;
243
+ else if (x <= task.x1) return 100;
244
+ else {
245
+ const barWidth = task.x2 - task.x1;
246
+ const progressPercent = Math.round((task.x2 - x) * 100 / barWidth);
247
+ return progressPercent;
248
+ }
249
+ };
250
+ const getProgressPoint = (progressX, taskY, taskHeight) => {
251
+ const point = [
252
+ progressX - 5,
253
+ taskY + taskHeight,
254
+ progressX + 5,
255
+ taskY + taskHeight,
256
+ progressX,
257
+ taskY + taskHeight - 8.66
258
+ ];
259
+ return point.join(",");
260
+ };
261
+ const startByX = (x, xStep, task) => {
262
+ if (x >= task.x2 - task.handleWidth * 2) {
263
+ x = task.x2 - task.handleWidth * 2;
264
+ }
265
+ const steps = Math.round((x - task.x1) / xStep);
266
+ const additionalXValue = steps * xStep;
267
+ const newX = task.x1 + additionalXValue;
268
+ return newX;
269
+ };
270
+ const endByX = (x, xStep, task) => {
271
+ if (x <= task.x1 + task.handleWidth * 2) {
272
+ x = task.x1 + task.handleWidth * 2;
273
+ }
274
+ const steps = Math.round((x - task.x2) / xStep);
275
+ const additionalXValue = steps * xStep;
276
+ const newX = task.x2 + additionalXValue;
277
+ return newX;
278
+ };
279
+ const moveByX = (x, xStep, task) => {
280
+ const steps = Math.round((x - task.x1) / xStep);
281
+ const additionalXValue = steps * xStep;
282
+ const newX1 = task.x1 + additionalXValue;
283
+ const newX2 = newX1 + task.x2 - task.x1;
284
+ return [newX1, newX2];
285
+ };
286
+ const dateByX = (x, taskX, taskDate, xStep, timeStep) => {
287
+ var _a, _b;
288
+ let newDate = new Date((x - taskX) / xStep * timeStep + ((_a = taskDate == null ? void 0 : taskDate.getTime) == null ? void 0 : _a.call(taskDate)));
289
+ newDate = new Date(((_b = newDate == null ? void 0 : newDate.getTime) == null ? void 0 : _b.call(newDate)) + ((newDate == null ? void 0 : newDate.getTimezoneOffset()) - (taskDate == null ? void 0 : taskDate.getTimezoneOffset())) * 6e4);
290
+ return newDate;
291
+ };
292
+ const handleTaskBySVGMouseEvent = (svgX, action, selectedTask, xStep, timeStep, initEventX1Delta, rtl) => {
293
+ let result;
294
+ switch (selectedTask.type) {
295
+ case "milestone":
296
+ result = handleTaskBySVGMouseEventForMilestone(svgX, action, selectedTask, xStep, timeStep, initEventX1Delta);
297
+ break;
298
+ default:
299
+ result = handleTaskBySVGMouseEventForBar(svgX, action, selectedTask, xStep, timeStep, initEventX1Delta, rtl);
300
+ break;
301
+ }
302
+ return result;
303
+ };
304
+ const handleTaskBySVGMouseEventForBar = (svgX, action, selectedTask, xStep, timeStep, initEventX1Delta, rtl) => {
305
+ const changedTask = { ...selectedTask };
306
+ let isChanged = false;
307
+ switch (action) {
308
+ case "progress":
309
+ if (rtl) {
310
+ changedTask.progress = progressByXRTL(svgX, selectedTask);
311
+ } else {
312
+ changedTask.progress = progressByX(svgX, selectedTask);
313
+ }
314
+ isChanged = changedTask.progress !== selectedTask.progress;
315
+ if (isChanged) {
316
+ const [progressWidth, progressX] = progressWithByParams(
317
+ changedTask.x1,
318
+ changedTask.x2,
319
+ changedTask.progress,
320
+ rtl
321
+ );
322
+ changedTask.progressWidth = progressWidth;
323
+ changedTask.progressX = progressX;
324
+ }
325
+ break;
326
+ case "start": {
327
+ const newX1 = startByX(svgX, xStep, selectedTask);
328
+ changedTask.x1 = newX1;
329
+ isChanged = changedTask.x1 !== selectedTask.x1;
330
+ if (isChanged) {
331
+ if (rtl) {
332
+ changedTask.end = dateByX(newX1, selectedTask.x1, selectedTask.end, xStep, timeStep);
333
+ } else {
334
+ changedTask.start = dateByX(newX1, selectedTask.x1, selectedTask.start, xStep, timeStep);
335
+ }
336
+ const [progressWidth, progressX] = progressWithByParams(
337
+ changedTask.x1,
338
+ changedTask.x2,
339
+ changedTask.progress,
340
+ rtl
341
+ );
342
+ changedTask.progressWidth = progressWidth;
343
+ changedTask.progressX = progressX;
344
+ }
345
+ break;
346
+ }
347
+ case "end": {
348
+ const newX2 = endByX(svgX, xStep, selectedTask);
349
+ changedTask.x2 = newX2;
350
+ isChanged = changedTask.x2 !== selectedTask.x2;
351
+ if (isChanged) {
352
+ if (rtl) {
353
+ changedTask.start = dateByX(newX2, selectedTask.x2, selectedTask.start, xStep, timeStep);
354
+ } else {
355
+ changedTask.end = dateByX(newX2, selectedTask.x2, selectedTask.end, xStep, timeStep);
356
+ }
357
+ const [progressWidth, progressX] = progressWithByParams(
358
+ changedTask.x1,
359
+ changedTask.x2,
360
+ changedTask.progress,
361
+ rtl
362
+ );
363
+ changedTask.progressWidth = progressWidth;
364
+ changedTask.progressX = progressX;
365
+ }
366
+ break;
367
+ }
368
+ case "move": {
369
+ const [newMoveX1, newMoveX2] = moveByX(svgX - initEventX1Delta, xStep, selectedTask);
370
+ isChanged = newMoveX1 !== selectedTask.x1;
371
+ if (isChanged) {
372
+ changedTask.start = dateByX(newMoveX1, selectedTask.x1, selectedTask.start, xStep, timeStep);
373
+ changedTask.end = dateByX(newMoveX2, selectedTask.x2, selectedTask.end, xStep, timeStep);
374
+ changedTask.x1 = newMoveX1;
375
+ changedTask.x2 = newMoveX2;
376
+ const [progressWidth, progressX] = progressWithByParams(
377
+ changedTask.x1,
378
+ changedTask.x2,
379
+ changedTask.progress,
380
+ rtl
381
+ );
382
+ changedTask.progressWidth = progressWidth;
383
+ changedTask.progressX = progressX;
384
+ }
385
+ break;
386
+ }
387
+ }
388
+ return { isChanged, changedTask };
389
+ };
390
+ const handleTaskBySVGMouseEventForMilestone = (svgX, action, selectedTask, xStep, timeStep, initEventX1Delta) => {
391
+ const changedTask = { ...selectedTask };
392
+ let isChanged = false;
393
+ switch (action) {
394
+ case "move": {
395
+ const [newMoveX1, newMoveX2] = moveByX(svgX - initEventX1Delta, xStep, selectedTask);
396
+ isChanged = newMoveX1 !== selectedTask.x1;
397
+ if (isChanged) {
398
+ changedTask.start = dateByX(newMoveX1, selectedTask.x1, selectedTask.start, xStep, timeStep);
399
+ changedTask.end = changedTask.start;
400
+ changedTask.x1 = newMoveX1;
401
+ changedTask.x2 = newMoveX2;
402
+ }
403
+ break;
404
+ }
405
+ }
406
+ return { isChanged, changedTask };
407
+ };
408
+ // Annotate the CommonJS export names for ESM import in node:
409
+ 0 && (module.exports = {
410
+ convertToBarTasks,
411
+ getProgressPoint,
412
+ handleTaskBySVGMouseEvent,
413
+ progressByProgressWidth,
414
+ progressWithByParams
415
+ });
@@ -0,0 +1,27 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { Task, ViewMode } from '../types/public-types';
10
+ declare const DateTimeFormat: {
11
+ (locales?: string | string[], options?: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;
12
+ new (locales?: string | string[], options?: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;
13
+ supportedLocalesOf(locales: string | string[], options?: Intl.DateTimeFormatOptions): string[];
14
+ readonly prototype: Intl.DateTimeFormat;
15
+ };
16
+ type DateTimeFormat = typeof DateTimeFormat;
17
+ type DateHelperScales = 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'millisecond';
18
+ export declare const getCachedDateTimeFormat: (locString: string | string[], opts?: any) => DateTimeFormat;
19
+ export declare const addToDate: (date: Date, quantity: number, scale: DateHelperScales) => Date;
20
+ export declare const startOfDate: (date: Date, scale: DateHelperScales) => Date;
21
+ export declare const ganttDateRange: (tasks: Task[], viewMode: ViewMode, preStepsCount: number) => Date[];
22
+ export declare const seedDates: (startDate: Date, endDate: Date, viewMode: ViewMode) => Date[];
23
+ export declare const getLocaleMonth: (date: Date, locale: string) => any;
24
+ export declare const getLocalDayOfWeek: (date: Date, locale: string, format?: 'long' | 'short' | 'narrow' | undefined) => any;
25
+ export declare const getWeekNumberISO8601: (date: Date) => string;
26
+ export declare const getDaysInMonth: (month: number, year: number) => number;
27
+ export {};
@@ -0,0 +1,231 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var date_helper_exports = {};
28
+ __export(date_helper_exports, {
29
+ addToDate: () => addToDate,
30
+ ganttDateRange: () => ganttDateRange,
31
+ getCachedDateTimeFormat: () => getCachedDateTimeFormat,
32
+ getDaysInMonth: () => getDaysInMonth,
33
+ getLocalDayOfWeek: () => getLocalDayOfWeek,
34
+ getLocaleMonth: () => getLocaleMonth,
35
+ getWeekNumberISO8601: () => getWeekNumberISO8601,
36
+ seedDates: () => seedDates,
37
+ startOfDate: () => startOfDate
38
+ });
39
+ module.exports = __toCommonJS(date_helper_exports);
40
+ var import_public_types = require("../types/public-types");
41
+ const DateTimeFormat = Intl.DateTimeFormat;
42
+ const DateTimeFormatOptions = Intl.DateTimeFormatOptions;
43
+ const intlDTCache = {};
44
+ const getCachedDateTimeFormat = (locString, opts = {}) => {
45
+ const key = JSON.stringify([locString, opts]);
46
+ let dtf = intlDTCache[key];
47
+ if (!dtf) {
48
+ dtf = new Intl.DateTimeFormat(locString, opts);
49
+ intlDTCache[key] = dtf;
50
+ }
51
+ return dtf;
52
+ };
53
+ const addToDate = (date, quantity, scale) => {
54
+ const newDate = new Date(
55
+ date.getFullYear() + (scale === "year" ? quantity : 0),
56
+ date.getMonth() + (scale === "month" ? quantity : 0),
57
+ date.getDate() + (scale === "day" ? quantity : 0),
58
+ date.getHours() + (scale === "hour" ? quantity : 0),
59
+ date.getMinutes() + (scale === "minute" ? quantity : 0),
60
+ date.getSeconds() + (scale === "second" ? quantity : 0),
61
+ date.getMilliseconds() + (scale === "millisecond" ? quantity : 0)
62
+ );
63
+ return newDate;
64
+ };
65
+ const startOfDate = (date, scale) => {
66
+ const scores = ["millisecond", "second", "minute", "hour", "day", "month", "year"];
67
+ const shouldReset = (_scale) => {
68
+ const maxScore = scores.indexOf(scale);
69
+ return scores.indexOf(_scale) <= maxScore;
70
+ };
71
+ const newDate = new Date(
72
+ date == null ? void 0 : date.getFullYear(),
73
+ shouldReset("year") ? 0 : date.getMonth(),
74
+ shouldReset("month") ? 1 : date.getDate(),
75
+ shouldReset("day") ? 0 : date.getHours(),
76
+ shouldReset("hour") ? 0 : date.getMinutes(),
77
+ shouldReset("minute") ? 0 : date.getSeconds(),
78
+ shouldReset("second") ? 0 : date.getMilliseconds()
79
+ );
80
+ return newDate;
81
+ };
82
+ const ganttDateRange = (tasks, viewMode, preStepsCount) => {
83
+ var _a, _b;
84
+ let newStartDate = ((_a = tasks[0]) == null ? void 0 : _a.start) || /* @__PURE__ */ new Date();
85
+ let newEndDate = ((_b = tasks[0]) == null ? void 0 : _b.start) || /* @__PURE__ */ new Date();
86
+ for (const task of tasks) {
87
+ if (task.start < newStartDate) {
88
+ newStartDate = task.start;
89
+ }
90
+ if (task.end > newEndDate) {
91
+ newEndDate = task.end;
92
+ }
93
+ }
94
+ switch (viewMode) {
95
+ case import_public_types.ViewMode.Year:
96
+ newStartDate = addToDate(newStartDate, -1, "year");
97
+ newStartDate = startOfDate(newStartDate, "year");
98
+ newEndDate = addToDate(newEndDate, 1, "year");
99
+ newEndDate = startOfDate(newEndDate, "year");
100
+ break;
101
+ case import_public_types.ViewMode.QuarterYear:
102
+ newStartDate = addToDate(newStartDate, -3, "month");
103
+ newStartDate = startOfDate(newStartDate, "month");
104
+ newEndDate = addToDate(newEndDate, 3, "year");
105
+ newEndDate = startOfDate(newEndDate, "year");
106
+ break;
107
+ case import_public_types.ViewMode.Month:
108
+ newStartDate = addToDate(newStartDate, -1 * preStepsCount, "month");
109
+ newStartDate = startOfDate(newStartDate, "month");
110
+ newEndDate = addToDate(newEndDate, 1, "year");
111
+ newEndDate = startOfDate(newEndDate, "year");
112
+ break;
113
+ case import_public_types.ViewMode.Week:
114
+ newStartDate = startOfDate(newStartDate, "day");
115
+ newStartDate = addToDate(getMonday(newStartDate), -7 * preStepsCount, "day");
116
+ newEndDate = startOfDate(newEndDate, "day");
117
+ newEndDate = addToDate(newEndDate, 1.5, "month");
118
+ break;
119
+ case import_public_types.ViewMode.Day:
120
+ newStartDate = startOfDate(newStartDate, "day");
121
+ newStartDate = addToDate(newStartDate, -1 * preStepsCount, "day");
122
+ newEndDate = startOfDate(newEndDate, "day");
123
+ newEndDate = addToDate(newEndDate, 19, "day");
124
+ break;
125
+ case import_public_types.ViewMode.QuarterDay:
126
+ newStartDate = startOfDate(newStartDate, "day");
127
+ newStartDate = addToDate(newStartDate, -1 * preStepsCount, "day");
128
+ newEndDate = startOfDate(newEndDate, "day");
129
+ newEndDate = addToDate(newEndDate, 66, "hour");
130
+ break;
131
+ case import_public_types.ViewMode.HalfDay:
132
+ newStartDate = startOfDate(newStartDate, "day");
133
+ newStartDate = addToDate(newStartDate, -1 * preStepsCount, "day");
134
+ newEndDate = startOfDate(newEndDate, "day");
135
+ newEndDate = addToDate(newEndDate, 108, "hour");
136
+ break;
137
+ case import_public_types.ViewMode.Hour:
138
+ newStartDate = startOfDate(newStartDate, "hour");
139
+ newStartDate = addToDate(newStartDate, -1 * preStepsCount, "hour");
140
+ newEndDate = startOfDate(newEndDate, "day");
141
+ newEndDate = addToDate(newEndDate, 1, "day");
142
+ break;
143
+ }
144
+ return [newStartDate, newEndDate];
145
+ };
146
+ const seedDates = (startDate, endDate, viewMode) => {
147
+ let currentDate = new Date(startDate);
148
+ const dates = [currentDate];
149
+ while (currentDate < endDate) {
150
+ switch (viewMode) {
151
+ case import_public_types.ViewMode.Year:
152
+ currentDate = addToDate(currentDate, 1, "year");
153
+ break;
154
+ case import_public_types.ViewMode.QuarterYear:
155
+ currentDate = addToDate(currentDate, 3, "month");
156
+ break;
157
+ case import_public_types.ViewMode.Month:
158
+ currentDate = addToDate(currentDate, 1, "month");
159
+ break;
160
+ case import_public_types.ViewMode.Week:
161
+ currentDate = addToDate(currentDate, 7, "day");
162
+ break;
163
+ case import_public_types.ViewMode.Day:
164
+ currentDate = addToDate(currentDate, 1, "day");
165
+ break;
166
+ case import_public_types.ViewMode.HalfDay:
167
+ currentDate = addToDate(currentDate, 12, "hour");
168
+ break;
169
+ case import_public_types.ViewMode.QuarterDay:
170
+ currentDate = addToDate(currentDate, 6, "hour");
171
+ break;
172
+ case import_public_types.ViewMode.Hour:
173
+ currentDate = addToDate(currentDate, 1, "hour");
174
+ break;
175
+ }
176
+ dates.push(currentDate);
177
+ }
178
+ return dates;
179
+ };
180
+ const getLocaleMonth = (date, locale) => {
181
+ let bottomValue = getCachedDateTimeFormat(locale, {
182
+ month: "long"
183
+ //@ts-ignore
184
+ }).format(date);
185
+ bottomValue = bottomValue.replace(bottomValue[0], bottomValue[0].toLocaleUpperCase());
186
+ return bottomValue;
187
+ };
188
+ const getLocalDayOfWeek = (date, locale, format) => {
189
+ let bottomValue = getCachedDateTimeFormat(locale, {
190
+ weekday: format
191
+ //@ts-ignore
192
+ }).format(date);
193
+ bottomValue = bottomValue.replace(bottomValue[0], bottomValue[0].toLocaleUpperCase());
194
+ return bottomValue;
195
+ };
196
+ const getMonday = (date) => {
197
+ const day = date.getDay();
198
+ const diff = date.getDate() - day + (day === 0 ? -6 : 1);
199
+ return new Date(date.setDate(diff));
200
+ };
201
+ const getWeekNumberISO8601 = (date) => {
202
+ const tmpDate = new Date(date.valueOf());
203
+ const dayNumber = (tmpDate.getDay() + 6) % 7;
204
+ tmpDate.setDate(tmpDate.getDate() - dayNumber + 3);
205
+ const firstThursday = tmpDate.valueOf();
206
+ tmpDate.setMonth(0, 1);
207
+ if (tmpDate.getDay() !== 4) {
208
+ tmpDate.setMonth(0, 1 + (4 - tmpDate.getDay() + 7) % 7);
209
+ }
210
+ const weekNumber = (1 + Math.ceil((firstThursday - tmpDate.valueOf()) / 6048e5)).toString();
211
+ if (weekNumber.length === 1) {
212
+ return `0${weekNumber}`;
213
+ } else {
214
+ return weekNumber;
215
+ }
216
+ };
217
+ const getDaysInMonth = (month, year) => {
218
+ return new Date(year, month + 1, 0).getDate();
219
+ };
220
+ // Annotate the CommonJS export names for ESM import in node:
221
+ 0 && (module.exports = {
222
+ addToDate,
223
+ ganttDateRange,
224
+ getCachedDateTimeFormat,
225
+ getDaysInMonth,
226
+ getLocalDayOfWeek,
227
+ getLocaleMonth,
228
+ getWeekNumberISO8601,
229
+ seedDates,
230
+ startOfDate
231
+ });
@@ -0,0 +1,17 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ /// <reference types="react" />
10
+ import { BarTask } from '../types/bar-task';
11
+ import { Task } from '../types/public-types';
12
+ export declare function isKeyboardEvent(event: React.MouseEvent | React.KeyboardEvent | React.FocusEvent): event is React.KeyboardEvent;
13
+ export declare function isMouseEvent(event: React.MouseEvent | React.KeyboardEvent | React.FocusEvent): event is React.MouseEvent;
14
+ export declare function isBarTask(task: Task | BarTask): task is BarTask;
15
+ export declare function removeHiddenTasks(tasks: Task[]): Task[];
16
+ export declare const sortTasks: (taskA: Task, taskB: Task) => 0 | 1 | -1;
17
+ export declare const getYmd: (date: Date) => string | 0;