@worktile/gantt 12.0.1 → 12.1.1

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 (232) hide show
  1. package/README.md +13 -116
  2. package/bundles/worktile-gantt.umd.js +3369 -0
  3. package/bundles/worktile-gantt.umd.js.map +1 -0
  4. package/class/date-point.d.ts +15 -0
  5. package/{packages/gantt/src/class/event.ts → class/event.d.ts} +6 -12
  6. package/class/group.d.ts +22 -0
  7. package/{packages/gantt/src/class/index.ts → class/index.d.ts} +0 -0
  8. package/class/item.d.ts +70 -0
  9. package/class/view-type.d.ts +7 -0
  10. package/components/bar/bar-drag.d.ts +37 -0
  11. package/components/bar/bar.component.d.ts +26 -0
  12. package/components/calendar/calendar.component.d.ts +28 -0
  13. package/components/drag-backdrop/drag-backdrop.component.d.ts +9 -0
  14. package/components/icon/icon.component.d.ts +13 -0
  15. package/components/icon/icons.d.ts +8 -0
  16. package/components/links/links.component.d.ts +47 -0
  17. package/components/main/gantt-main.component.d.ts +21 -0
  18. package/components/range/range.component.d.ts +13 -0
  19. package/components/table/gantt-table.component.d.ts +37 -0
  20. package/esm2015/class/date-point.js +10 -0
  21. package/esm2015/class/event.js +13 -0
  22. package/esm2015/class/group.js +17 -0
  23. package/esm2015/class/index.js +6 -0
  24. package/esm2015/class/item.js +78 -0
  25. package/esm2015/class/view-type.js +9 -0
  26. package/esm2015/components/bar/bar-drag.js +269 -0
  27. package/esm2015/components/bar/bar.component.js +98 -0
  28. package/esm2015/components/calendar/calendar.component.js +86 -0
  29. package/esm2015/components/drag-backdrop/drag-backdrop.component.js +21 -0
  30. package/esm2015/components/icon/icon.component.js +38 -0
  31. package/esm2015/components/icon/icons.js +87 -0
  32. package/esm2015/components/links/links.component.js +213 -0
  33. package/esm2015/components/main/gantt-main.component.js +53 -0
  34. package/esm2015/components/range/range.component.js +37 -0
  35. package/esm2015/components/table/gantt-table.component.js +149 -0
  36. package/esm2015/gantt-abstract.js +3 -0
  37. package/esm2015/gantt-dom.service.js +103 -0
  38. package/esm2015/gantt-drag-container.js +60 -0
  39. package/esm2015/gantt-item-upper.js +58 -0
  40. package/esm2015/gantt-print.service.js +94 -0
  41. package/esm2015/gantt-upper.js +280 -0
  42. package/esm2015/gantt.component.js +135 -0
  43. package/esm2015/gantt.config.js +13 -0
  44. package/esm2015/gantt.module.js +85 -0
  45. package/esm2015/gantt.pipe.js +43 -0
  46. package/esm2015/gantt.styles.js +15 -0
  47. package/esm2015/public-api.js +19 -0
  48. package/esm2015/root.component.js +123 -0
  49. package/esm2015/table/gantt-column.component.js +37 -0
  50. package/esm2015/table/gantt-table.component.js +20 -0
  51. package/esm2015/utils/date.js +160 -0
  52. package/esm2015/utils/helpers.js +55 -0
  53. package/esm2015/views/day.js +54 -0
  54. package/esm2015/views/factory.js +23 -0
  55. package/esm2015/views/month.js +48 -0
  56. package/esm2015/views/quarter.js +51 -0
  57. package/esm2015/views/view.js +123 -0
  58. package/esm2015/views/week.js +49 -0
  59. package/esm2015/views/year.js +50 -0
  60. package/esm2015/worktile-gantt.js +5 -0
  61. package/fesm2015/worktile-gantt.js +2697 -0
  62. package/fesm2015/worktile-gantt.js.map +1 -0
  63. package/{packages/gantt/src/gantt-abstract.ts → gantt-abstract.d.ts} +1 -3
  64. package/gantt-dom.service.d.ts +32 -0
  65. package/gantt-drag-container.d.ts +24 -0
  66. package/gantt-item-upper.d.ts +20 -0
  67. package/gantt-print.service.d.ts +13 -0
  68. package/gantt-upper.d.ts +69 -0
  69. package/gantt.component.d.ts +30 -0
  70. package/gantt.config.d.ts +23 -0
  71. package/gantt.module.d.ts +21 -0
  72. package/gantt.pipe.d.ts +18 -0
  73. package/gantt.styles.d.ts +15 -0
  74. package/main.bundle.scss +645 -0
  75. package/package.json +16 -113
  76. package/{packages/gantt/src/public-api.ts → public-api.d.ts} +1 -4
  77. package/root.component.d.ts +28 -0
  78. package/table/gantt-column.component.d.ts +15 -0
  79. package/table/gantt-table.component.d.ts +10 -0
  80. package/utils/date.d.ts +59 -0
  81. package/utils/helpers.d.ts +12 -0
  82. package/views/day.d.ts +14 -0
  83. package/views/factory.d.ts +8 -0
  84. package/views/month.d.ts +12 -0
  85. package/views/quarter.d.ts +12 -0
  86. package/views/view.d.ts +58 -0
  87. package/views/week.d.ts +12 -0
  88. package/views/year.d.ts +12 -0
  89. package/worktile-gantt.d.ts +5 -0
  90. package/.all-contributorsrc +0 -53
  91. package/.angulardoc.json +0 -4
  92. package/.circleci/config.yml +0 -17
  93. package/.coveralls.yml +0 -1
  94. package/.docgenirc.js +0 -64
  95. package/.editorconfig +0 -22
  96. package/.prettierrc +0 -24
  97. package/.travis.yml +0 -23
  98. package/CHANGELOG.md +0 -564
  99. package/Dockerfile +0 -4
  100. package/LICENSE +0 -21
  101. package/angular.json +0 -136
  102. package/docs/guides/basic/components.md +0 -54
  103. package/docs/guides/basic/event.md +0 -70
  104. package/docs/guides/basic/index.md +0 -4
  105. package/docs/guides/basic/style.md +0 -68
  106. package/docs/guides/basic/type.md +0 -70
  107. package/docs/guides/basic/usage.md +0 -189
  108. package/docs/guides/index.md +0 -5
  109. package/docs/guides/intro/getting-started.md +0 -79
  110. package/docs/guides/intro/index.md +0 -51
  111. package/docs/index.md +0 -0
  112. package/example/browserslist +0 -12
  113. package/example/src/app/app-routing.module.ts +0 -26
  114. package/example/src/app/app.component.html +0 -2
  115. package/example/src/app/app.component.ts +0 -11
  116. package/example/src/app/app.module.ts +0 -57
  117. package/example/src/app/components/components.component.html +0 -6
  118. package/example/src/app/components/components.component.ts +0 -33
  119. package/example/src/app/configuration/parameters/api/zh-cn.js +0 -350
  120. package/example/src/app/configuration/parameters/doc/zh-cn.md +0 -5
  121. package/example/src/app/gantt/gantt.component.html +0 -51
  122. package/example/src/app/gantt/gantt.component.ts +0 -119
  123. package/example/src/app/gantt-advanced/component/flat.component.html +0 -30
  124. package/example/src/app/gantt-advanced/component/flat.component.ts +0 -72
  125. package/example/src/app/gantt-advanced/component/flat.scss +0 -31
  126. package/example/src/app/gantt-advanced/gantt-advanced.component.html +0 -32
  127. package/example/src/app/gantt-advanced/gantt-advanced.component.ts +0 -34
  128. package/example/src/app/gantt-advanced/mocks.ts +0 -158
  129. package/example/src/app/gantt-groups/gantt-groups.component.html +0 -42
  130. package/example/src/app/gantt-groups/gantt-groups.component.ts +0 -62
  131. package/example/src/app/gantt-range/gantt-range.component.html +0 -66
  132. package/example/src/app/gantt-range/gantt-range.component.ts +0 -67
  133. package/example/src/app/gantt-range/mocks.ts +0 -150
  134. package/example/src/app/helper.ts +0 -38
  135. package/example/src/assets/.gitkeep +0 -0
  136. package/example/src/environments/environment.prod.ts +0 -3
  137. package/example/src/environments/environment.ts +0 -16
  138. package/example/src/favicon.ico +0 -0
  139. package/example/src/index.html +0 -13
  140. package/example/src/main.ts +0 -12
  141. package/example/src/polyfills.ts +0 -63
  142. package/example/src/styles.scss +0 -56
  143. package/example/tsconfig.app.json +0 -18
  144. package/nginx.conf +0 -17
  145. package/packages/gantt/README.md +0 -24
  146. package/packages/gantt/karma.conf.js +0 -46
  147. package/packages/gantt/ng-package.json +0 -7
  148. package/packages/gantt/ng-package.prod.json +0 -7
  149. package/packages/gantt/package.json +0 -16
  150. package/packages/gantt/src/class/date-point.ts +0 -14
  151. package/packages/gantt/src/class/group.ts +0 -36
  152. package/packages/gantt/src/class/item.ts +0 -129
  153. package/packages/gantt/src/class/test/group.spec.ts +0 -21
  154. package/packages/gantt/src/class/test/item.spec.ts +0 -102
  155. package/packages/gantt/src/class/view-type.ts +0 -7
  156. package/packages/gantt/src/components/bar/bar-drag.ts +0 -298
  157. package/packages/gantt/src/components/bar/bar.component.html +0 -17
  158. package/packages/gantt/src/components/bar/bar.component.scss +0 -169
  159. package/packages/gantt/src/components/bar/bar.component.ts +0 -109
  160. package/packages/gantt/src/components/bar/test/bar.component.spec.ts +0 -54
  161. package/packages/gantt/src/components/bar/test/bar.drag.spec.ts +0 -196
  162. package/packages/gantt/src/components/calendar/calendar.component.html +0 -52
  163. package/packages/gantt/src/components/calendar/calendar.component.scss +0 -77
  164. package/packages/gantt/src/components/calendar/calendar.component.ts +0 -100
  165. package/packages/gantt/src/components/drag-backdrop/drag-backdrop.component.html +0 -6
  166. package/packages/gantt/src/components/drag-backdrop/drag-backdrop.component.scss +0 -48
  167. package/packages/gantt/src/components/drag-backdrop/drag-backdrop.component.ts +0 -13
  168. package/packages/gantt/src/components/icon/icon.component.scss +0 -13
  169. package/packages/gantt/src/components/icon/icon.component.ts +0 -28
  170. package/packages/gantt/src/components/icon/icons.ts +0 -86
  171. package/packages/gantt/src/components/links/links.component.html +0 -19
  172. package/packages/gantt/src/components/links/links.component.scss +0 -27
  173. package/packages/gantt/src/components/links/links.component.ts +0 -263
  174. package/packages/gantt/src/components/main/gantt-main.component.html +0 -35
  175. package/packages/gantt/src/components/main/gantt-main.component.ts +0 -35
  176. package/packages/gantt/src/components/range/range.component.html +0 -8
  177. package/packages/gantt/src/components/range/range.component.scss +0 -35
  178. package/packages/gantt/src/components/range/range.component.ts +0 -27
  179. package/packages/gantt/src/components/range/test/range.component.spec.ts +0 -80
  180. package/packages/gantt/src/components/table/gantt-table.component.html +0 -105
  181. package/packages/gantt/src/components/table/gantt-table.component.scss +0 -144
  182. package/packages/gantt/src/components/table/gantt-table.component.ts +0 -166
  183. package/packages/gantt/src/components/table/test/table.spec.ts +0 -129
  184. package/packages/gantt/src/gantt-dom.service.ts +0 -134
  185. package/packages/gantt/src/gantt-drag-container.ts +0 -73
  186. package/packages/gantt/src/gantt-item-upper.ts +0 -50
  187. package/packages/gantt/src/gantt-print.service.ts +0 -104
  188. package/packages/gantt/src/gantt-upper.ts +0 -289
  189. package/packages/gantt/src/gantt.component.html +0 -18
  190. package/packages/gantt/src/gantt.component.scss +0 -77
  191. package/packages/gantt/src/gantt.component.ts +0 -134
  192. package/packages/gantt/src/gantt.module.ts +0 -47
  193. package/packages/gantt/src/gantt.pipe.ts +0 -31
  194. package/packages/gantt/src/gantt.styles.ts +0 -28
  195. package/packages/gantt/src/root.component.html +0 -12
  196. package/packages/gantt/src/root.component.ts +0 -121
  197. package/packages/gantt/src/styles/index.scss +0 -9
  198. package/packages/gantt/src/styles/variables.scss +0 -46
  199. package/packages/gantt/src/table/gantt-column.component.ts +0 -25
  200. package/packages/gantt/src/table/gantt-table.component.ts +0 -14
  201. package/packages/gantt/src/table/test/table.spec.ts +0 -56
  202. package/packages/gantt/src/test/gantt.component.spec.ts +0 -404
  203. package/packages/gantt/src/test/mocks/data.ts +0 -303
  204. package/packages/gantt/src/test.ts +0 -21
  205. package/packages/gantt/src/utils/date.ts +0 -276
  206. package/packages/gantt/src/utils/helpers.ts +0 -66
  207. package/packages/gantt/src/utils/test/date.spec.ts +0 -105
  208. package/packages/gantt/src/utils/test/helpers.spec.ts +0 -73
  209. package/packages/gantt/src/utils/testing.ts +0 -64
  210. package/packages/gantt/src/views/day.ts +0 -74
  211. package/packages/gantt/src/views/factory.ts +0 -25
  212. package/packages/gantt/src/views/month.ts +0 -66
  213. package/packages/gantt/src/views/quarter.ts +0 -68
  214. package/packages/gantt/src/views/test/day.spec.ts +0 -45
  215. package/packages/gantt/src/views/test/factory.spec.ts +0 -41
  216. package/packages/gantt/src/views/test/mock.ts +0 -14
  217. package/packages/gantt/src/views/test/month.spec.ts +0 -45
  218. package/packages/gantt/src/views/test/quarter.spec.ts +0 -45
  219. package/packages/gantt/src/views/test/view.spec.ts +0 -144
  220. package/packages/gantt/src/views/test/week.spec.ts +0 -45
  221. package/packages/gantt/src/views/test/year.spec.ts +0 -45
  222. package/packages/gantt/src/views/view.ts +0 -186
  223. package/packages/gantt/src/views/week.ts +0 -66
  224. package/packages/gantt/src/views/year.ts +0 -62
  225. package/packages/gantt/tsconfig.lib.json +0 -20
  226. package/packages/gantt/tsconfig.lib.prod.json +0 -9
  227. package/packages/gantt/tsconfig.schematics.json +0 -25
  228. package/packages/gantt/tsconfig.spec.json +0 -17
  229. package/packages/gantt/tslint.json +0 -18
  230. package/scss-bundle.config.json +0 -7
  231. package/tsconfig.json +0 -26
  232. package/tslint.json +0 -51
@@ -0,0 +1,2697 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, EventEmitter, Directive, Inject, Input, Output, ContentChild, HostBinding, Component, Pipe, ViewChild, Injectable, Optional, forwardRef, ChangeDetectionStrategy, ContentChildren, NgModule } from '@angular/core';
3
+ import * as i2 from '@angular/common';
4
+ import { CommonModule } from '@angular/common';
5
+ import { take, skip, takeUntil, startWith, map, pairwise, auditTime, finalize } from 'rxjs/operators';
6
+ import { BehaviorSubject, Subject, merge, fromEvent } from 'rxjs';
7
+ import { fromUnixTime, getWeek, getDaysInMonth, differenceInCalendarDays, setDate, addSeconds, addMinutes, addHours, addDays, addWeeks, addMonths, addQuarters, addYears, startOfDay, startOfWeek, startOfMonth, startOfQuarter, startOfYear, endOfDay, endOfWeek, endOfMonth, endOfQuarter, endOfYear, getUnixTime, format, isWeekend, isToday, differenceInDays, differenceInCalendarQuarters, eachMonthOfInterval, eachYearOfInterval, eachWeekOfInterval, eachDayOfInterval, differenceInCalendarYears } from 'date-fns';
8
+ export { addDays, addHours, addMinutes, addMonths, addQuarters, addSeconds, addWeeks, addYears, differenceInCalendarDays, differenceInCalendarQuarters, differenceInDays, eachDayOfInterval, eachMonthOfInterval, eachWeekOfInterval, endOfDay, endOfMonth, endOfQuarter, endOfWeek, endOfYear, format, fromUnixTime, getDaysInMonth, getUnixTime, getWeek, isToday, isWeekend, setDate, startOfDay, startOfMonth, startOfQuarter, startOfWeek, startOfYear } from 'date-fns';
9
+ import { coerceCssPixelValue } from '@angular/cdk/coercion';
10
+ import * as i1 from '@angular/cdk/drag-drop';
11
+ import { DragDropModule } from '@angular/cdk/drag-drop';
12
+ import html2canvas from 'html2canvas';
13
+
14
+ class GanttDatePoint {
15
+ constructor(start, text, x, y, additions) {
16
+ this.start = start;
17
+ this.text = text;
18
+ this.x = x;
19
+ this.y = y;
20
+ this.additions = additions;
21
+ }
22
+ }
23
+
24
+ class GanttDragEvent {
25
+ }
26
+ class GanttTableEvent {
27
+ }
28
+ class GanttLinkDragEvent {
29
+ }
30
+ class GanttLoadOnScrollEvent {
31
+ }
32
+ class GanttLineClickEvent {
33
+ }
34
+ class GanttBarClickEvent {
35
+ }
36
+
37
+ class GanttDate {
38
+ constructor(date) {
39
+ if (date) {
40
+ if (date instanceof Date) {
41
+ this.value = date;
42
+ }
43
+ else if (typeof date === 'string' || typeof date === 'number') {
44
+ if (date.toString().length < 13) {
45
+ this.value = fromUnixTime(+date);
46
+ }
47
+ else {
48
+ this.value = new Date(date);
49
+ }
50
+ }
51
+ else {
52
+ throw new Error(`The input date type is not supported expect Date | string
53
+ | number | { date: number; with_time: 0 | 1}, actual ${JSON.stringify(date)}`);
54
+ }
55
+ }
56
+ else {
57
+ this.value = new Date();
58
+ }
59
+ }
60
+ getYear() {
61
+ return this.value.getFullYear();
62
+ }
63
+ getMonth() {
64
+ return this.value.getMonth();
65
+ }
66
+ getDay() {
67
+ return this.value.getDay();
68
+ }
69
+ getTime() {
70
+ return this.value.getTime();
71
+ }
72
+ getDate() {
73
+ return this.value.getDate();
74
+ }
75
+ getHours() {
76
+ return this.value.getHours();
77
+ }
78
+ getMinutes() {
79
+ return this.value.getMinutes();
80
+ }
81
+ getSeconds() {
82
+ return this.value.getSeconds();
83
+ }
84
+ getMilliseconds() {
85
+ return this.value.getMilliseconds();
86
+ }
87
+ getWeek(options = { weekStartsOn: 1 }) {
88
+ return getWeek(this.value, options);
89
+ }
90
+ getDaysInMonth() {
91
+ return getDaysInMonth(this.value);
92
+ }
93
+ getDaysInQuarter() {
94
+ return differenceInCalendarDays(this.endOfQuarter().addSeconds(1).value, this.startOfQuarter().value);
95
+ }
96
+ getDaysInYear() {
97
+ return differenceInCalendarDays(this.endOfYear().addSeconds(1).value, this.startOfYear().value);
98
+ }
99
+ setDate(dayOfMonth) {
100
+ return new GanttDate(setDate(this.value, dayOfMonth));
101
+ }
102
+ clone() {
103
+ return new GanttDate(new Date(this.value));
104
+ }
105
+ add(amount, unit) {
106
+ switch (unit) {
107
+ case 'second':
108
+ return new GanttDate(this.value).addSeconds(amount);
109
+ case 'minute':
110
+ return new GanttDate(this.value).addMinutes(amount);
111
+ case 'hour':
112
+ return new GanttDate(this.value).addHours(amount);
113
+ case 'day':
114
+ return new GanttDate(this.value).addDays(amount);
115
+ case 'week':
116
+ return new GanttDate(this.value).addWeeks(amount);
117
+ case 'month':
118
+ return new GanttDate(this.value).addMonths(amount);
119
+ case 'quarter':
120
+ return new GanttDate(this.value).addQuarters(amount);
121
+ case 'year':
122
+ return new GanttDate(this.value).addYears(amount);
123
+ default:
124
+ return new GanttDate(this.value).addSeconds(amount);
125
+ }
126
+ }
127
+ addSeconds(amount) {
128
+ return new GanttDate(addSeconds(this.value, amount));
129
+ }
130
+ addMinutes(amount) {
131
+ return new GanttDate(addMinutes(this.value, amount));
132
+ }
133
+ addHours(amount) {
134
+ return new GanttDate(addHours(this.value, amount));
135
+ }
136
+ addDays(amount) {
137
+ return new GanttDate(addDays(this.value, amount));
138
+ }
139
+ addWeeks(amount) {
140
+ return new GanttDate(addWeeks(this.value, amount));
141
+ }
142
+ addMonths(amount) {
143
+ return new GanttDate(addMonths(this.value, amount));
144
+ }
145
+ addQuarters(amount) {
146
+ return new GanttDate(addQuarters(this.value, amount));
147
+ }
148
+ addYears(amount) {
149
+ return new GanttDate(addYears(this.value, amount));
150
+ }
151
+ startOfDay() {
152
+ return new GanttDate(startOfDay(this.value));
153
+ }
154
+ startOfWeek(options) {
155
+ return new GanttDate(startOfWeek(this.value, options));
156
+ }
157
+ startOfMonth() {
158
+ return new GanttDate(startOfMonth(this.value));
159
+ }
160
+ startOfQuarter() {
161
+ return new GanttDate(startOfQuarter(this.value));
162
+ }
163
+ startOfYear() {
164
+ return new GanttDate(startOfYear(this.value));
165
+ }
166
+ endOfDay() {
167
+ return new GanttDate(endOfDay(this.value));
168
+ }
169
+ endOfWeek(options) {
170
+ return new GanttDate(endOfWeek(this.value, options));
171
+ }
172
+ endOfMonth() {
173
+ return new GanttDate(endOfMonth(this.value));
174
+ }
175
+ endOfQuarter() {
176
+ return new GanttDate(endOfQuarter(this.value));
177
+ }
178
+ endOfYear() {
179
+ return new GanttDate(endOfYear(this.value));
180
+ }
181
+ getUnixTime() {
182
+ return getUnixTime(this.value);
183
+ }
184
+ format(mat, options) {
185
+ return format(this.value, mat, options);
186
+ }
187
+ isWeekend() {
188
+ return isWeekend(this.value);
189
+ }
190
+ isToday() {
191
+ return isToday(this.value);
192
+ }
193
+ }
194
+
195
+ var GanttViewType;
196
+ (function (GanttViewType) {
197
+ GanttViewType["day"] = "day";
198
+ GanttViewType["quarter"] = "quarter";
199
+ GanttViewType["month"] = "month";
200
+ GanttViewType["year"] = "year";
201
+ GanttViewType["week"] = "week";
202
+ })(GanttViewType || (GanttViewType = {}));
203
+
204
+ var GanttItemType;
205
+ (function (GanttItemType) {
206
+ GanttItemType["bar"] = "bar";
207
+ GanttItemType["range"] = "range";
208
+ GanttItemType["custom"] = "custom";
209
+ })(GanttItemType || (GanttItemType = {}));
210
+ class GanttItemInternal {
211
+ constructor(item, options) {
212
+ this.refs$ = new BehaviorSubject(null);
213
+ this.origin = item;
214
+ this.id = this.origin.id;
215
+ this.links = this.origin.links || [];
216
+ this.color = this.origin.color;
217
+ this.barStyle = this.origin.barStyle;
218
+ this.linkable = this.origin.linkable === undefined ? true : this.origin.linkable;
219
+ this.draggable = this.origin.draggable === undefined ? true : this.origin.draggable;
220
+ this.expandable = this.origin.expandable || (this.origin.children || []).length > 0;
221
+ this.expanded = this.origin.expanded === undefined ? false : this.origin.expanded;
222
+ this.start = item.start ? new GanttDate(item.start) : null;
223
+ this.end = item.end ? new GanttDate(item.end) : null;
224
+ this.viewType = options && options.viewType ? options.viewType : GanttViewType.month;
225
+ this.children = (item.children || []).map((subItem) => {
226
+ return new GanttItemInternal(subItem, { viewType: this.viewType });
227
+ });
228
+ this.type = this.origin.type || GanttItemType.bar;
229
+ this.progress = this.origin.progress;
230
+ // fill one month when start or end is null
231
+ this.fillItemStartOrEnd(item);
232
+ }
233
+ get refs() {
234
+ return this.refs$.getValue();
235
+ }
236
+ fillItemStartOrEnd(item) {
237
+ let addInterval;
238
+ switch (this.viewType) {
239
+ case GanttViewType.day:
240
+ case GanttViewType.week:
241
+ addInterval = 0;
242
+ break;
243
+ default:
244
+ addInterval = 30;
245
+ break;
246
+ }
247
+ if (item.start && !item.end) {
248
+ this.end = new GanttDate(item.start).addDays(addInterval).endOfDay();
249
+ }
250
+ if (!item.start && item.end) {
251
+ this.start = new GanttDate(item.end).addDays(-addInterval).startOfDay();
252
+ }
253
+ }
254
+ updateRefs(refs) {
255
+ this.refs$.next(refs);
256
+ }
257
+ updateDate(start, end) {
258
+ this.start = start.startOfDay();
259
+ this.end = end.endOfDay();
260
+ this.origin.start = this.start.getUnixTime();
261
+ this.origin.end = this.end.getUnixTime();
262
+ }
263
+ addChildren(items) {
264
+ this.origin.children = items;
265
+ this.children = (items || []).map((subItem) => {
266
+ return new GanttItemInternal(subItem, { viewType: this.viewType });
267
+ });
268
+ }
269
+ setExpand(expanded) {
270
+ this.expanded = expanded;
271
+ this.origin.expanded = expanded;
272
+ }
273
+ addLink(linkId) {
274
+ this.links = [...this.links, linkId];
275
+ this.origin.links = this.links;
276
+ }
277
+ }
278
+
279
+ class GanttGroupInternal {
280
+ constructor(group) {
281
+ this.refs = {};
282
+ this.id = group.id;
283
+ this.origin = group;
284
+ this.title = group.title;
285
+ this.expanded = group.expanded === undefined ? true : group.expanded;
286
+ this.items = [];
287
+ this.mergedItems = [[]];
288
+ this.class = group.class || '';
289
+ }
290
+ setExpand(expanded) {
291
+ this.expanded = expanded;
292
+ this.origin.expanded = expanded;
293
+ }
294
+ }
295
+
296
+ const defaultConfig = {
297
+ dateFormat: {
298
+ week: '第w周',
299
+ month: 'M月',
300
+ quarter: 'QQQ',
301
+ year: 'yyyy年',
302
+ yearMonth: 'yyyy年MM月',
303
+ yearQuarter: 'yyyy年QQQ',
304
+ }
305
+ };
306
+ const GANTT_GLOBAL_CONFIG = new InjectionToken('GANTT_GLOBAL_CONFIG');
307
+
308
+ const primaryDatePointTop = 18;
309
+ const secondaryDatePointTop = 36;
310
+ const viewOptions$5 = {
311
+ min: new GanttDate().addYears(-1).startOfYear(),
312
+ max: new GanttDate().addYears(1).endOfYear(),
313
+ dateFormat: defaultConfig.dateFormat
314
+ };
315
+ class GanttView {
316
+ constructor(start, end, options) {
317
+ this.showTimeline = true;
318
+ this.options = Object.assign({}, viewOptions$5, options);
319
+ const startDate = start.isCustom
320
+ ? this.startOf(start.date)
321
+ : this.startOf(start.date.value < this.options.start.value ? start.date : this.options.start);
322
+ const endDate = end.isCustom
323
+ ? this.endOf(end.date)
324
+ : this.endOf(end.date.value > this.options.end.value ? end.date : this.options.end);
325
+ this.start$ = new BehaviorSubject(startDate);
326
+ this.end$ = new BehaviorSubject(endDate);
327
+ this.initialize();
328
+ }
329
+ get start() {
330
+ return this.start$.getValue();
331
+ }
332
+ get end() {
333
+ return this.end$.getValue();
334
+ }
335
+ getDateIntervalWidth(start, end) {
336
+ let result = 0;
337
+ const days = differenceInDays(end.value, start.value);
338
+ for (let i = 0; i < Math.abs(days); i++) {
339
+ result += this.getDayOccupancyWidth(start.addDays(i));
340
+ }
341
+ result = days >= 0 ? result : -result;
342
+ return Number(result.toFixed(3));
343
+ }
344
+ initialize() {
345
+ this.primaryDatePoints = this.getPrimaryDatePoints();
346
+ this.secondaryDatePoints = this.getSecondaryDatePoints();
347
+ this.width = this.getWidth();
348
+ this.cellWidth = this.getCellWidth();
349
+ this.primaryWidth = this.getPrimaryWidth();
350
+ }
351
+ addStartDate() {
352
+ const start = this.startOf(this.start.add(this.options.addAmount * -1, this.options.addUnit));
353
+ if (start.value >= this.options.min.value) {
354
+ const origin = this.start;
355
+ this.start$.next(start);
356
+ this.initialize();
357
+ return { start: this.start, end: origin };
358
+ }
359
+ return null;
360
+ }
361
+ addEndDate() {
362
+ const end = this.endOf(this.end.add(this.options.addAmount, this.options.addUnit));
363
+ if (end.value <= this.options.max.value) {
364
+ const origin = this.end;
365
+ this.end$.next(end);
366
+ this.initialize();
367
+ return { start: origin, end: this.end };
368
+ }
369
+ return null;
370
+ }
371
+ updateDate(start, end) {
372
+ start = this.startOf(start);
373
+ end = this.endOf(end);
374
+ if (start.value < this.start.value) {
375
+ this.start$.next(start);
376
+ }
377
+ if (end.value > this.end.value) {
378
+ this.end$.next(end);
379
+ }
380
+ this.initialize();
381
+ }
382
+ // 获取View的宽度
383
+ getWidth() {
384
+ return this.getCellWidth() * this.secondaryDatePoints.length;
385
+ }
386
+ // 获取单个网格的宽度
387
+ getCellWidth() {
388
+ return this.options.cellWidth;
389
+ }
390
+ // 获取当前时间的X坐标
391
+ getTodayXPoint() {
392
+ const toady = new GanttDate().startOfDay();
393
+ if (toady.value > this.start.value && toady.value < this.end.value) {
394
+ const x = this.getXPointByDate(toady) + this.getDayOccupancyWidth(toady) / 2;
395
+ return x;
396
+ }
397
+ else {
398
+ return null;
399
+ }
400
+ }
401
+ // 获取指定时间的X坐标
402
+ getXPointByDate(date) {
403
+ return this.getDateIntervalWidth(this.start, date);
404
+ }
405
+ // 根据X坐标获取对应时间
406
+ getDateByXPoint(x) {
407
+ const indexOfSecondaryDate = Math.floor(x / this.getCellWidth());
408
+ const matchDate = this.secondaryDatePoints[indexOfSecondaryDate];
409
+ const dayWidth = this.getDayOccupancyWidth(matchDate === null || matchDate === void 0 ? void 0 : matchDate.start);
410
+ if (dayWidth === this.getCellWidth()) {
411
+ return matchDate === null || matchDate === void 0 ? void 0 : matchDate.start;
412
+ }
413
+ else {
414
+ const day = Math.floor((x % this.getCellWidth()) / dayWidth) + 1;
415
+ if (this.getCellWidth() / dayWidth === 7) {
416
+ return matchDate === null || matchDate === void 0 ? void 0 : matchDate.start.addDays(day);
417
+ }
418
+ return matchDate === null || matchDate === void 0 ? void 0 : matchDate.start.setDate(day);
419
+ }
420
+ }
421
+ // 获取指定时间范围的宽度
422
+ getDateRangeWidth(start, end) {
423
+ // addSeconds(1) 是因为计算相差天会以一个整天来计算 end时间一般是59分59秒不是一个整天,所以需要加1
424
+ return this.getDateIntervalWidth(start, end.addSeconds(1));
425
+ }
426
+ }
427
+
428
+ const viewOptions$4 = {
429
+ start: new GanttDate().startOfQuarter().addQuarters(-1),
430
+ end: new GanttDate().endOfQuarter().addQuarters(2),
431
+ cellWidth: 280,
432
+ addAmount: 1,
433
+ addUnit: 'quarter'
434
+ };
435
+ class GanttViewMonth extends GanttView {
436
+ constructor(start, end, options) {
437
+ super(start, end, Object.assign({}, viewOptions$4, options));
438
+ }
439
+ startOf(date) {
440
+ return date.startOfQuarter();
441
+ }
442
+ endOf(date) {
443
+ return date.endOfQuarter();
444
+ }
445
+ getPrimaryWidth() {
446
+ return this.getCellWidth() * 3;
447
+ }
448
+ getDayOccupancyWidth(date) {
449
+ return this.cellWidth / date.getDaysInMonth();
450
+ }
451
+ getPrimaryDatePoints() {
452
+ const quarters = differenceInCalendarQuarters(this.end.addSeconds(1).value, this.start.value);
453
+ const points = [];
454
+ for (let i = 0; i < quarters; i++) {
455
+ const start = this.start.addQuarters(i);
456
+ const point = new GanttDatePoint(start, start.format(this.options.dateFormat.yearQuarter), (this.getCellWidth() * 3) / 2 + i * (this.getCellWidth() * 3), primaryDatePointTop);
457
+ points.push(point);
458
+ }
459
+ return points;
460
+ }
461
+ getSecondaryDatePoints() {
462
+ const months = eachMonthOfInterval({ start: this.start.value, end: this.end.value });
463
+ const points = [];
464
+ for (let i = 0; i < months.length; i++) {
465
+ const start = new GanttDate(months[i]);
466
+ const point = new GanttDatePoint(start, start.format(this.options.dateFormat.month), i * this.getCellWidth() + this.getCellWidth() / 2, secondaryDatePointTop);
467
+ points.push(point);
468
+ }
469
+ return points;
470
+ }
471
+ }
472
+
473
+ const viewOptions$3 = {
474
+ start: new GanttDate().addYears(-1).startOfYear(),
475
+ end: new GanttDate().addYears(1).endOfYear(),
476
+ min: new GanttDate().addYears(-2).startOfYear(),
477
+ max: new GanttDate().addYears(2).endOfYear(),
478
+ cellWidth: 500,
479
+ addAmount: 1,
480
+ addUnit: 'year'
481
+ };
482
+ class GanttViewQuarter extends GanttView {
483
+ constructor(start, end, options) {
484
+ super(start, end, Object.assign({}, viewOptions$3, options));
485
+ }
486
+ startOf(date) {
487
+ return date.startOfYear();
488
+ }
489
+ endOf(date) {
490
+ return date.endOfYear();
491
+ }
492
+ getPrimaryWidth() {
493
+ return this.getCellWidth() * 4;
494
+ }
495
+ getDayOccupancyWidth(date) {
496
+ return this.cellWidth / date.getDaysInQuarter();
497
+ }
498
+ getPrimaryDatePoints() {
499
+ const years = eachYearOfInterval({ start: this.start.value, end: this.end.value });
500
+ const points = [];
501
+ for (let i = 0; i < years.length; i++) {
502
+ const start = new GanttDate(years[i]);
503
+ const point = new GanttDatePoint(start, `${start.format(this.options.dateFormat.year)}`, (this.getCellWidth() * 4) / 2 + i * (this.getCellWidth() * 4), primaryDatePointTop);
504
+ points.push(point);
505
+ }
506
+ return points;
507
+ }
508
+ getSecondaryDatePoints() {
509
+ const quarters = differenceInCalendarQuarters(this.end.value, this.start.value);
510
+ const points = [];
511
+ for (let i = 0; i <= quarters; i++) {
512
+ const start = this.start.addQuarters(i);
513
+ const point = new GanttDatePoint(start, start.format(this.options.dateFormat.quarter), i * this.getCellWidth() + this.getCellWidth() / 2, secondaryDatePointTop);
514
+ points.push(point);
515
+ }
516
+ return points;
517
+ }
518
+ }
519
+
520
+ const viewOptions$2 = {
521
+ cellWidth: 35,
522
+ start: new GanttDate().startOfYear().startOfWeek({ weekStartsOn: 1 }),
523
+ end: new GanttDate().endOfYear().endOfWeek({ weekStartsOn: 1 }),
524
+ addAmount: 1,
525
+ addUnit: 'month'
526
+ };
527
+ class GanttViewDay extends GanttView {
528
+ constructor(start, end, options) {
529
+ super(start, end, Object.assign({}, viewOptions$2, options));
530
+ this.showWeekBackdrop = true;
531
+ this.showTimeline = false;
532
+ }
533
+ startOf(date) {
534
+ return date.startOfWeek({ weekStartsOn: 1 });
535
+ }
536
+ endOf(date) {
537
+ return date.endOfWeek({ weekStartsOn: 1 });
538
+ }
539
+ getPrimaryWidth() {
540
+ return this.getCellWidth() * 7;
541
+ }
542
+ getDayOccupancyWidth() {
543
+ return this.cellWidth;
544
+ }
545
+ getPrimaryDatePoints() {
546
+ const weeks = eachWeekOfInterval({ start: this.start.value, end: this.end.addSeconds(1).value }, { weekStartsOn: 1 });
547
+ const points = [];
548
+ for (let i = 0; i < weeks.length; i++) {
549
+ const weekStart = new GanttDate(weeks[i]);
550
+ const increaseWeek = weekStart.getDaysInMonth() - weekStart.getDate() >= 3 ? 0 : 1;
551
+ const point = new GanttDatePoint(weekStart, weekStart.addWeeks(increaseWeek).format(this.options.dateFormat.yearMonth), (this.getCellWidth() * 7) / 2 + i * (this.getCellWidth() * 7), primaryDatePointTop);
552
+ points.push(point);
553
+ }
554
+ return points;
555
+ }
556
+ getSecondaryDatePoints() {
557
+ const days = eachDayOfInterval({ start: this.start.value, end: this.end.value });
558
+ const points = [];
559
+ for (let i = 0; i < days.length; i++) {
560
+ const start = new GanttDate(days[i]);
561
+ const point = new GanttDatePoint(start, start.getDate().toString(), i * this.getCellWidth() + this.getCellWidth() / 2, secondaryDatePointTop, {
562
+ isWeekend: start.isWeekend(),
563
+ isToday: start.isToday()
564
+ });
565
+ points.push(point);
566
+ }
567
+ return points;
568
+ }
569
+ }
570
+
571
+ const viewOptions$1 = {
572
+ cellWidth: 280,
573
+ start: new GanttDate().startOfYear().startOfWeek({ weekStartsOn: 1 }),
574
+ end: new GanttDate().endOfYear().endOfWeek({ weekStartsOn: 1 }),
575
+ addAmount: 1,
576
+ addUnit: 'month'
577
+ };
578
+ class GanttViewWeek extends GanttView {
579
+ constructor(start, end, options) {
580
+ super(start, end, Object.assign({}, viewOptions$1, options));
581
+ }
582
+ startOf(date) {
583
+ return date.startOfWeek({ weekStartsOn: 1 });
584
+ }
585
+ endOf(date) {
586
+ return date.endOfWeek({ weekStartsOn: 1 });
587
+ }
588
+ getPrimaryWidth() {
589
+ return this.getCellWidth();
590
+ }
591
+ getDayOccupancyWidth() {
592
+ return this.cellWidth / 7;
593
+ }
594
+ getPrimaryDatePoints() {
595
+ const weeks = eachWeekOfInterval({ start: this.start.value, end: this.end.addSeconds(1).value }, { weekStartsOn: 1 });
596
+ const points = [];
597
+ for (let i = 0; i < weeks.length; i++) {
598
+ const weekStart = new GanttDate(weeks[i]);
599
+ const increaseWeek = weekStart.getDaysInMonth() - weekStart.getDate() >= 3 ? 0 : 1;
600
+ const point = new GanttDatePoint(weekStart, weekStart.addWeeks(increaseWeek).format(this.options.dateFormat.year), this.getCellWidth() / 2 + i * this.getCellWidth(), primaryDatePointTop);
601
+ points.push(point);
602
+ }
603
+ return points;
604
+ }
605
+ getSecondaryDatePoints() {
606
+ const weeks = eachWeekOfInterval({ start: this.start.value, end: this.end.value });
607
+ const points = [];
608
+ for (let i = 0; i < weeks.length; i++) {
609
+ const start = new GanttDate(weeks[i]);
610
+ const point = new GanttDatePoint(start, `${start.format(this.options.dateFormat.week)}`, i * this.getCellWidth() + this.getCellWidth() / 2, secondaryDatePointTop);
611
+ points.push(point);
612
+ }
613
+ return points;
614
+ }
615
+ }
616
+
617
+ const viewOptions = {
618
+ cellWidth: 480,
619
+ start: new GanttDate().addYears(-2).startOfYear(),
620
+ end: new GanttDate().addYears(2).endOfYear(),
621
+ addAmount: 1,
622
+ addUnit: 'year'
623
+ };
624
+ class GanttViewYear extends GanttView {
625
+ constructor(start, end, options) {
626
+ super(start, end, Object.assign({}, viewOptions, options));
627
+ }
628
+ startOf(date) {
629
+ return date.startOfYear();
630
+ }
631
+ endOf(date) {
632
+ return date.endOfYear();
633
+ }
634
+ getPrimaryWidth() {
635
+ return this.getCellWidth();
636
+ }
637
+ getDayOccupancyWidth(date) {
638
+ return this.cellWidth / date.getDaysInYear();
639
+ }
640
+ getPrimaryDatePoints() {
641
+ const years = eachYearOfInterval({ start: this.start.value, end: this.end.value });
642
+ const points = [];
643
+ for (let i = 0; i < years.length; i++) {
644
+ const start = new GanttDate(years[i]);
645
+ const point = new GanttDatePoint(start, ``, this.getCellWidth() / 2 + i * this.getCellWidth(), primaryDatePointTop);
646
+ points.push(point);
647
+ }
648
+ return points;
649
+ }
650
+ getSecondaryDatePoints() {
651
+ const years = differenceInCalendarYears(this.end.value, this.start.value);
652
+ const points = [];
653
+ const pointTop = 27;
654
+ for (let i = 0; i <= years; i++) {
655
+ const start = this.start.addYears(i);
656
+ const point = new GanttDatePoint(start, `${start.format(this.options.dateFormat.year)}`, i * this.getCellWidth() + this.getCellWidth() / 2, pointTop);
657
+ points.push(point);
658
+ }
659
+ return points;
660
+ }
661
+ }
662
+
663
+ function createViewFactory(type, start, end, options) {
664
+ switch (type) {
665
+ case GanttViewType.month:
666
+ return new GanttViewMonth(start, end, options);
667
+ case GanttViewType.week:
668
+ return new GanttViewWeek(start, end, options);
669
+ case GanttViewType.quarter:
670
+ return new GanttViewQuarter(start, end, options);
671
+ case GanttViewType.day:
672
+ return new GanttViewDay(start, end, options);
673
+ case GanttViewType.year:
674
+ return new GanttViewYear(start, end, options);
675
+ default:
676
+ throw new Error('gantt view type invalid');
677
+ }
678
+ }
679
+
680
+ const defaultStyles = {
681
+ lineHeight: 44,
682
+ barHeight: 22
683
+ };
684
+ const headerHeight = 44;
685
+ const sideWidth = 400;
686
+ const sideMiddleWidth = 500;
687
+ const sideMaxWidth = 600;
688
+ const sideMinWidth = 400;
689
+ const barBackground = '#348fe4';
690
+ const rangeHeight = 17;
691
+ const todayHeight = 24;
692
+ const todayWidth = 35;
693
+ const todayBorderRadius = 4;
694
+
695
+ function isNumber(value) {
696
+ return typeof value === 'number';
697
+ }
698
+ function isString(value) {
699
+ return typeof value === 'string';
700
+ }
701
+ function isUndefined(value) {
702
+ return value === undefined;
703
+ }
704
+ function hexToRgb(color, opacity = 1) {
705
+ if (/^#/g.test(color)) {
706
+ return `rgba(${parseInt(color.slice(1, 3), 16)},${parseInt(color.slice(3, 5), 16)},${parseInt(color.slice(5, 7), 16)},${opacity})`;
707
+ }
708
+ else {
709
+ return color;
710
+ }
711
+ }
712
+ function uniqBy(array, key) {
713
+ const valuesMap = {};
714
+ const result = [];
715
+ (array || []).forEach((value) => {
716
+ const _key = value[key];
717
+ if (!valuesMap[_key]) {
718
+ valuesMap[_key] = value;
719
+ result.push(value);
720
+ }
721
+ });
722
+ return result;
723
+ }
724
+ function flatten(array) {
725
+ return array.reduce((pre, cur) => {
726
+ return pre.concat(Array.isArray(cur) ? flatten(cur) : cur);
727
+ }, []);
728
+ }
729
+ function recursiveItems(items) {
730
+ const result = [];
731
+ (items || []).forEach((item) => {
732
+ result.push(item);
733
+ if (item.expanded && item.children) {
734
+ result.push(...recursiveItems(item.children));
735
+ }
736
+ });
737
+ return result;
738
+ }
739
+ function getFlatItems(items) {
740
+ const result = [];
741
+ (items || []).forEach((item) => {
742
+ result.push(item);
743
+ if (item.children) {
744
+ result.push(...getFlatItems(item.children));
745
+ }
746
+ });
747
+ return result;
748
+ }
749
+
750
+ class GanttUpper {
751
+ constructor(elementRef, cdr, ngZone, config) {
752
+ this.elementRef = elementRef;
753
+ this.cdr = cdr;
754
+ this.ngZone = ngZone;
755
+ this.config = config;
756
+ this.originItems = [];
757
+ this.originGroups = [];
758
+ this.viewType = GanttViewType.month;
759
+ this.showTodayLine = true;
760
+ this.viewOptions = {};
761
+ this.loadOnScroll = new EventEmitter();
762
+ this.dragStarted = new EventEmitter();
763
+ this.dragMoved = new EventEmitter();
764
+ this.dragEnded = new EventEmitter();
765
+ this.barClick = new EventEmitter();
766
+ this.linkDragEnded = new EventEmitter();
767
+ this.items = [];
768
+ this.groups = [];
769
+ this.viewChange = new EventEmitter();
770
+ this.expandChange = new EventEmitter();
771
+ this.firstChange = true;
772
+ this.unsubscribe$ = new Subject();
773
+ this.ganttClass = true;
774
+ }
775
+ get element() {
776
+ return this.elementRef.nativeElement;
777
+ }
778
+ createView() {
779
+ const viewDate = this.getViewDate();
780
+ this.view = createViewFactory(this.viewType, viewDate.start, viewDate.end, this.viewOptions);
781
+ }
782
+ setupGroups() {
783
+ const collapsedIds = this.groups.filter((group) => group.expanded === false).map((group) => group.id);
784
+ this.groupsMap = {};
785
+ this.groups = [];
786
+ this.originGroups.forEach((origin) => {
787
+ const group = new GanttGroupInternal(origin);
788
+ group.expanded = !collapsedIds.includes(group.id);
789
+ this.groupsMap[group.id] = group;
790
+ this.groups.push(group);
791
+ });
792
+ }
793
+ setupItems() {
794
+ this.originItems = uniqBy(this.originItems, 'id');
795
+ this.items = [];
796
+ if (this.groups.length > 0) {
797
+ this.originItems.forEach((origin) => {
798
+ const group = this.groupsMap[origin.group_id];
799
+ if (group) {
800
+ const item = new GanttItemInternal(origin, { viewType: this.viewType });
801
+ group.items.push(item);
802
+ }
803
+ });
804
+ }
805
+ else {
806
+ this.originItems.forEach((origin) => {
807
+ const item = new GanttItemInternal(origin, { viewType: this.viewType });
808
+ this.items.push(item);
809
+ });
810
+ }
811
+ }
812
+ setupExpandedState() {
813
+ this.originItems = uniqBy(this.originItems, 'id');
814
+ let items = [];
815
+ const flatOriginItems = getFlatItems(this.originItems);
816
+ if (this.items.length > 0) {
817
+ items = recursiveItems(this.items);
818
+ }
819
+ else {
820
+ items = flatten(this.groups.map((group) => recursiveItems(group.items)));
821
+ }
822
+ items.forEach((item) => {
823
+ if (item.origin.expanded) {
824
+ const newItem = flatOriginItems.find((originItem) => originItem.id === item.id);
825
+ if (newItem) {
826
+ if (newItem.expanded === undefined) {
827
+ newItem.expanded = true;
828
+ }
829
+ }
830
+ }
831
+ });
832
+ }
833
+ getViewDate() {
834
+ let start = this.start;
835
+ let end = this.end;
836
+ if (!this.start || !this.end) {
837
+ this.originItems.forEach((item) => {
838
+ if (item.start && !this.start) {
839
+ start = start ? Math.min(start, item.start) : item.start;
840
+ }
841
+ if (item.end && !this.end) {
842
+ end = end ? Math.max(end, item.end) : item.end;
843
+ }
844
+ });
845
+ }
846
+ return {
847
+ start: {
848
+ date: new GanttDate(start),
849
+ isCustom: this.start ? true : false
850
+ },
851
+ end: {
852
+ date: new GanttDate(end),
853
+ isCustom: this.end ? true : false
854
+ }
855
+ };
856
+ }
857
+ computeRefs() {
858
+ this.groups.forEach((group) => {
859
+ const groupItems = recursiveItems(group.items);
860
+ this.computeItemsRefs(...groupItems);
861
+ });
862
+ const items = recursiveItems(this.items);
863
+ this.computeItemsRefs(...items);
864
+ }
865
+ expandGroups(expanded) {
866
+ this.groups.forEach((group) => {
867
+ group.setExpand(expanded);
868
+ });
869
+ this.expandChange.next();
870
+ this.cdr.detectChanges();
871
+ }
872
+ onInit() {
873
+ this.styles = Object.assign({}, defaultStyles, this.styles);
874
+ this.viewOptions.dateFormat = Object.assign({}, defaultConfig.dateFormat, this.config.dateFormat, this.viewOptions.dateFormat);
875
+ this.createView();
876
+ this.setupGroups();
877
+ this.setupItems();
878
+ this.computeRefs();
879
+ this.firstChange = false;
880
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
881
+ this.element.style.opacity = '1';
882
+ this.dragContainer.dragStarted.subscribe((event) => {
883
+ this.dragStarted.emit(event);
884
+ });
885
+ this.dragContainer.dragMoved.subscribe((event) => {
886
+ this.dragMoved.emit(event);
887
+ });
888
+ this.dragContainer.dragEnded.subscribe((event) => {
889
+ this.dragEnded.emit(event);
890
+ this.computeRefs();
891
+ this.detectChanges();
892
+ });
893
+ });
894
+ this.view.start$.pipe(skip(1), takeUntil(this.unsubscribe$)).subscribe(() => {
895
+ this.computeRefs();
896
+ });
897
+ }
898
+ onChanges(changes) {
899
+ if (!this.firstChange) {
900
+ if (changes.viewType && changes.viewType.currentValue) {
901
+ this.createView();
902
+ this.setupGroups();
903
+ this.setupItems();
904
+ this.computeRefs();
905
+ this.viewChange.emit(this.view);
906
+ }
907
+ if (changes.originItems || changes.originGroups) {
908
+ this.setupExpandedState();
909
+ this.setupGroups();
910
+ this.setupItems();
911
+ this.computeRefs();
912
+ }
913
+ }
914
+ }
915
+ onDestroy() {
916
+ this.unsubscribe$.next();
917
+ this.unsubscribe$.complete();
918
+ }
919
+ computeItemsRefs(...items) {
920
+ items.forEach((item) => {
921
+ item.updateRefs({
922
+ width: item.start && item.end ? this.view.getDateRangeWidth(item.start.startOfDay(), item.end.endOfDay()) : 0,
923
+ x: item.start ? this.view.getXPointByDate(item.start) : 0,
924
+ y: (this.styles.lineHeight - this.styles.barHeight) / 2 - 1
925
+ });
926
+ });
927
+ }
928
+ trackBy(index, item) {
929
+ return item.id || index;
930
+ }
931
+ detectChanges() {
932
+ this.cdr.detectChanges();
933
+ }
934
+ expandGroup(group) {
935
+ group.setExpand(!group.expanded);
936
+ this.expandChange.emit();
937
+ this.cdr.detectChanges();
938
+ }
939
+ // public functions
940
+ expandAll() {
941
+ this.expandGroups(true);
942
+ }
943
+ collapseAll() {
944
+ this.expandGroups(false);
945
+ }
946
+ getGanttItem(id) {
947
+ return this.getGanttItems([id])[0] || null;
948
+ }
949
+ getGanttItems(ids) {
950
+ let items = [];
951
+ if (this.items.length > 0) {
952
+ items = recursiveItems(this.items);
953
+ }
954
+ else {
955
+ items = flatten(this.groups.map((group) => recursiveItems(group.items)));
956
+ }
957
+ return items.filter((item) => ids.includes(item.id));
958
+ }
959
+ }
960
+ GanttUpper.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttUpper, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: GANTT_GLOBAL_CONFIG }], target: i0.ɵɵFactoryTarget.Directive });
961
+ GanttUpper.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.1.2", type: GanttUpper, inputs: { originItems: ["items", "originItems"], originGroups: ["groups", "originGroups"], viewType: "viewType", start: "start", end: "end", showTodayLine: "showTodayLine", draggable: "draggable", styles: "styles", viewOptions: "viewOptions", disabledLoadOnScroll: "disabledLoadOnScroll" }, outputs: { loadOnScroll: "loadOnScroll", dragStarted: "dragStarted", dragMoved: "dragMoved", dragEnded: "dragEnded", barClick: "barClick" }, host: { properties: { "class.gantt": "this.ganttClass" } }, queries: [{ propertyName: "barTemplate", first: true, predicate: ["bar"], descendants: true, static: true }, { propertyName: "rangeTemplate", first: true, predicate: ["range"], descendants: true, static: true }, { propertyName: "itemTemplate", first: true, predicate: ["item"], descendants: true, static: true }, { propertyName: "groupTemplate", first: true, predicate: ["group"], descendants: true, static: true }, { propertyName: "groupHeaderTemplate", first: true, predicate: ["groupHeader"], descendants: true, static: true }], ngImport: i0 });
962
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttUpper, decorators: [{
963
+ type: Directive
964
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: undefined, decorators: [{
965
+ type: Inject,
966
+ args: [GANTT_GLOBAL_CONFIG]
967
+ }] }]; }, propDecorators: { originItems: [{
968
+ type: Input,
969
+ args: ['items']
970
+ }], originGroups: [{
971
+ type: Input,
972
+ args: ['groups']
973
+ }], viewType: [{
974
+ type: Input
975
+ }], start: [{
976
+ type: Input
977
+ }], end: [{
978
+ type: Input
979
+ }], showTodayLine: [{
980
+ type: Input
981
+ }], draggable: [{
982
+ type: Input
983
+ }], styles: [{
984
+ type: Input
985
+ }], viewOptions: [{
986
+ type: Input
987
+ }], disabledLoadOnScroll: [{
988
+ type: Input
989
+ }], loadOnScroll: [{
990
+ type: Output
991
+ }], dragStarted: [{
992
+ type: Output
993
+ }], dragMoved: [{
994
+ type: Output
995
+ }], dragEnded: [{
996
+ type: Output
997
+ }], barClick: [{
998
+ type: Output
999
+ }], barTemplate: [{
1000
+ type: ContentChild,
1001
+ args: ['bar', { static: true }]
1002
+ }], rangeTemplate: [{
1003
+ type: ContentChild,
1004
+ args: ['range', { static: true }]
1005
+ }], itemTemplate: [{
1006
+ type: ContentChild,
1007
+ args: ['item', { static: true }]
1008
+ }], groupTemplate: [{
1009
+ type: ContentChild,
1010
+ args: ['group', { static: true }]
1011
+ }], groupHeaderTemplate: [{
1012
+ type: ContentChild,
1013
+ args: ['groupHeader', { static: true }]
1014
+ }], ganttClass: [{
1015
+ type: HostBinding,
1016
+ args: ['class.gantt']
1017
+ }] } });
1018
+ const GANTT_UPPER_TOKEN = new InjectionToken('GANTT_UPPER_TOKEN');
1019
+
1020
+ class NgxGanttTableColumnComponent {
1021
+ constructor(ganttUpper) {
1022
+ this.ganttUpper = ganttUpper;
1023
+ }
1024
+ set width(width) {
1025
+ this.columnWidth = coerceCssPixelValue(width);
1026
+ }
1027
+ ngOnInit() { }
1028
+ }
1029
+ NgxGanttTableColumnComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttTableColumnComponent, deps: [{ token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
1030
+ NgxGanttTableColumnComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: NgxGanttTableColumnComponent, selector: "ngx-gantt-column", inputs: { width: "width", name: "name" }, queries: [{ propertyName: "templateRef", first: true, predicate: ["cell"], descendants: true, static: true }, { propertyName: "headerTemplateRef", first: true, predicate: ["header"], descendants: true, static: true }], ngImport: i0, template: '', isInline: true });
1031
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttTableColumnComponent, decorators: [{
1032
+ type: Component,
1033
+ args: [{
1034
+ selector: 'ngx-gantt-column',
1035
+ template: ''
1036
+ }]
1037
+ }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
1038
+ type: Inject,
1039
+ args: [GANTT_UPPER_TOKEN]
1040
+ }] }]; }, propDecorators: { width: [{
1041
+ type: Input
1042
+ }], name: [{
1043
+ type: Input
1044
+ }], templateRef: [{
1045
+ type: ContentChild,
1046
+ args: ['cell', { static: true }]
1047
+ }], headerTemplateRef: [{
1048
+ type: ContentChild,
1049
+ args: ['header', { static: true }]
1050
+ }] } });
1051
+
1052
+ class NgxGanttTableComponent {
1053
+ constructor() {
1054
+ this.columnChanges = new EventEmitter();
1055
+ }
1056
+ ngOnInit() { }
1057
+ }
1058
+ NgxGanttTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttTableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1059
+ NgxGanttTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: NgxGanttTableComponent, selector: "ngx-gantt-table", outputs: { columnChanges: "columnChanges" }, ngImport: i0, template: '', isInline: true });
1060
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttTableComponent, decorators: [{
1061
+ type: Component,
1062
+ args: [{
1063
+ selector: 'ngx-gantt-table',
1064
+ template: ''
1065
+ }]
1066
+ }], ctorParameters: function () { return []; }, propDecorators: { columnChanges: [{
1067
+ type: Output
1068
+ }] } });
1069
+
1070
+ const GANTT_ABSTRACT_TOKEN = new InjectionToken('gantt-abstract-token');
1071
+
1072
+ const angleRight = `<svg xmlns="http://www.w3.org/2000/svg" fit="" preserveAspectRatio="xMidYMid meet" focusable="false"><g id="amnavigation/angle-right" stroke-width="1" fill-rule="evenodd"><path d="M7.978 11.498l-.005.005L2.3 5.831 3.13 5l4.848 4.848L12.826 5l.83.831-5.673 5.672-.005-.005z" transform="rotate(-90 7.978 8.252)"></path></g></svg>`;
1073
+ const angleDown = `<svg xmlns="http://www.w3.org/2000/svg" fit="" preserveAspectRatio="xMidYMid meet" focusable="false"><g id="aknavigation/angle-down" stroke-width="1" fill-rule="evenodd"><path d="M7.978 11.997l-.005.006L2.3 6.33l.83-.831 4.848 4.848L12.826 5.5l.83.83-5.673 5.673-.005-.006z" ></path></g></svg>`;
1074
+ const plusSquare = `<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fit="" preserveAspectRatio="xMidYMid meet" focusable="false"><g id="kxaction/plus-square" stroke-width="1" fill-rule="evenodd"><path d="M2 0h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2zm0 1.2a.8.8 0 0 0-.8.8v12a.8.8 0 0 0 .8.8h12a.8.8 0 0 0 .8-.8V2a.8.8 0 0 0-.8-.8H2zm5.45 6.2V4.75h1.2V7.4h2.65v1.2H8.65v2.65h-1.2V8.6H4.8V7.4h2.65z"></path></g></svg>`;
1075
+ const minusSquare = `<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" fit="" preserveAspectRatio="xMidYMid meet" focusable="false"><g id="jnaction/minus-square" stroke-width="1" fill-rule="evenodd"><path d="M2 0h12a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2zm0 1.2a.8.8 0 0 0-.8.8v12a.8.8 0 0 0 .8.8h12a.8.8 0 0 0 .8-.8V2a.8.8 0 0 0-.8-.8H2zm2.8 6.2h6.5v1.2H4.8V7.4z"></path></g></svg>`;
1076
+ const loadingIcon = `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50" xml:space="preserve">
1077
+ <path fill="#aaa" d="M25.251,6.461c-10.318,0-18.683,8.365-18.683,18.683h4.068c0-8.071,6.543-14.615,14.615-14.615V6.461z" transform="rotate(275.098 25 25)">
1078
+ <animateTransform attributeType="xml" attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="0.6s" repeatCount="indefinite"></animateTransform>
1079
+ </path>
1080
+ </svg>`;
1081
+ const emptyIcon = `<svg
1082
+ width="148px"
1083
+ height="134px"
1084
+ viewBox="0 0 148 134"
1085
+ version="1.1"
1086
+ xmlns="http://www.w3.org/2000/svg"
1087
+ xmlns:xlink="http://www.w3.org/1999/xlink"
1088
+ >
1089
+ <defs>
1090
+ <filter x="0.0%" y="0.0%" width="100.0%" height="100.0%" filterUnits="objectBoundingBox" id="filter-1">
1091
+ <feGaussianBlur stdDeviation="0" in="SourceGraphic"></feGaussianBlur>
1092
+ </filter>
1093
+ </defs>
1094
+ <g id="148x134" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
1095
+ <g id="编组-6" transform="translate(1.000000, 1.000000)">
1096
+ <ellipse
1097
+ id="椭圆形"
1098
+ fill="#EDEEF2"
1099
+ opacity="0.3"
1100
+ filter="url(#filter-1)"
1101
+ cx="73.0800017"
1102
+ cy="115.920003"
1103
+ rx="73.0800017"
1104
+ ry="16.8000004"
1105
+ ></ellipse>
1106
+ <g id="编组-5" transform="translate(15.120000, 0.000000)">
1107
+ <polygon
1108
+ id="矩形"
1109
+ fill="#E2E4E9"
1110
+ points="19.2789848 49.5600011 99.1200023 48.7200011 117.600003 75.9297673 117.600003 92.313049 0 92.313049 0 75.0356267"
1111
+ ></polygon>
1112
+ <path
1113
+ d="M23.5200005,0 L94.0800002,0 C97.7913538,2.06413823e-16 100.8,3.00864655 100.8,6.72000015 L100.8,99.1200023 L100.8,99.1200023 L16.8000004,99.1200023 L16.8000004,6.72000015 C16.8000004,3.00864655 19.8086469,1.56994302e-15 23.5200005,0 Z"
1114
+ id="矩形"
1115
+ fill="#F9FAFB"
1116
+ ></path>
1117
+ <path
1118
+ d="M30.9200007,12.4400003 L86.6800019,12.4400003 C88.5356787,12.4400003 90.040002,13.9443236 90.040002,15.8000004 L90.040002,42.000001 C90.040002,43.8556778 88.5356787,45.360001 86.6800019,45.360001 L30.9200007,45.360001 C29.0643239,45.360001 27.5600006,43.8556778 27.5600006,42.000001 L27.5600006,15.8000004 C27.5600006,13.9443236 29.0643239,12.4400003 30.9200007,12.4400003 Z"
1119
+ id="矩形"
1120
+ fill="#E8EAEE"
1121
+ ></path>
1122
+ <text
1123
+ id="&lt;/null&gt;"
1124
+ font-family="PingFangSC-Medium, PingFang SC"
1125
+ font-size="15.1200003"
1126
+ font-weight="400"
1127
+ fill="#BCBECD"
1128
+ >
1129
+ <tspan x="33.6000008" y="32.8000004">&lt;/null&gt;</tspan>
1130
+ </text>
1131
+ <rect id="矩形" fill="#E8EAEE" x="27.5600006" y="52.0800012" width="61.4800014" height="5.04000011" rx="2.52000006"></rect>
1132
+ <rect
1133
+ id="矩形备份"
1134
+ fill="#E8EAEE"
1135
+ x="27.5600006"
1136
+ y="63.8400014"
1137
+ width="61.4800014"
1138
+ height="5.04000011"
1139
+ rx="2.52000006"
1140
+ ></rect>
1141
+ <path
1142
+ d="M0,75.6000017 L29.280235,75.6000017 C32.0637502,75.6000017 34.3202352,77.8564866 34.3202352,80.6400018 L34.3202352,86.2591426 C34.3202352,89.0426578 36.5767201,91.2991427 39.3602353,91.2991427 L78.4136737,91.2991427 C81.1971889,91.2991427 83.4536738,89.0426578 83.4536738,86.2591426 L83.4536738,80.6400018 C83.4536738,77.8564866 85.7101587,75.6000017 88.4936739,75.6000017 L117.600003,75.6000017 L117.600003,75.6000017 L117.600003,110.880003 C117.600003,115.519195 113.839194,119.280003 109.200002,119.280003 L8.40000019,119.280003 C3.76080819,119.280003 -6.53729019e-15,115.519195 0,110.880003 L0,75.6000017 L0,75.6000017 Z"
1143
+ id="矩形"
1144
+ fill="#EDEFF2"
1145
+ ></path>
1146
+ </g>
1147
+ </g>
1148
+ </g>
1149
+ </svg>`;
1150
+ const icons = {
1151
+ 'angle-right': angleRight,
1152
+ 'angle-down': angleDown,
1153
+ 'plus-square': plusSquare,
1154
+ 'minus-square': minusSquare,
1155
+ loading: loadingIcon,
1156
+ empty: emptyIcon
1157
+ };
1158
+
1159
+ class GanttIconComponent {
1160
+ constructor(elementRef) {
1161
+ this.elementRef = elementRef;
1162
+ this.isIcon = true;
1163
+ }
1164
+ set iconName(name) {
1165
+ this.setSvg(name);
1166
+ }
1167
+ ngOnInit() { }
1168
+ ngAfterViewInit() { }
1169
+ setSvg(name) {
1170
+ const iconSvg = icons[name];
1171
+ if (iconSvg) {
1172
+ this.elementRef.nativeElement.innerHTML = iconSvg;
1173
+ }
1174
+ else {
1175
+ this.elementRef.nativeElement.innerHTML = '';
1176
+ }
1177
+ }
1178
+ }
1179
+ GanttIconComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttIconComponent, deps: [{ token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1180
+ GanttIconComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: GanttIconComponent, selector: "gantt-icon", inputs: { iconName: "iconName" }, host: { properties: { "class.gantt-icon": "this.isIcon" } }, ngImport: i0, template: '', isInline: true });
1181
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttIconComponent, decorators: [{
1182
+ type: Component,
1183
+ args: [{
1184
+ selector: 'gantt-icon',
1185
+ template: ''
1186
+ }]
1187
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }]; }, propDecorators: { isIcon: [{
1188
+ type: HostBinding,
1189
+ args: ['class.gantt-icon']
1190
+ }], iconName: [{
1191
+ type: Input
1192
+ }] } });
1193
+
1194
+ class IsGanttRangeItemPipe {
1195
+ transform(value) {
1196
+ return value === GanttItemType.range;
1197
+ }
1198
+ }
1199
+ IsGanttRangeItemPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttRangeItemPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1200
+ IsGanttRangeItemPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttRangeItemPipe, name: "isGanttRangeItem" });
1201
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttRangeItemPipe, decorators: [{
1202
+ type: Pipe,
1203
+ args: [{
1204
+ name: 'isGanttRangeItem'
1205
+ }]
1206
+ }] });
1207
+ class IsGanttBarItemPipe {
1208
+ transform(value) {
1209
+ return value === GanttItemType.bar;
1210
+ }
1211
+ }
1212
+ IsGanttBarItemPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttBarItemPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1213
+ IsGanttBarItemPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttBarItemPipe, name: "isGanttBarItem" });
1214
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttBarItemPipe, decorators: [{
1215
+ type: Pipe,
1216
+ args: [{
1217
+ name: 'isGanttBarItem'
1218
+ }]
1219
+ }] });
1220
+ class IsGanttCustomItemPipe {
1221
+ transform(value) {
1222
+ return value === GanttItemType.custom;
1223
+ }
1224
+ }
1225
+ IsGanttCustomItemPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttCustomItemPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1226
+ IsGanttCustomItemPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttCustomItemPipe, name: "isGanttCustomItem" });
1227
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: IsGanttCustomItemPipe, decorators: [{
1228
+ type: Pipe,
1229
+ args: [{
1230
+ name: 'isGanttCustomItem'
1231
+ }]
1232
+ }] });
1233
+
1234
+ const defaultColumnWidth = 100;
1235
+ const minColumnWidth = 80;
1236
+ class GanttTableComponent {
1237
+ constructor(gantt, elementRef) {
1238
+ this.gantt = gantt;
1239
+ this.elementRef = elementRef;
1240
+ this.ganttTableClass = true;
1241
+ this.ganttTableEmptyClass = false;
1242
+ }
1243
+ set columns(columns) {
1244
+ columns.forEach((column) => {
1245
+ if (!column.columnWidth) {
1246
+ column.columnWidth = coerceCssPixelValue(defaultColumnWidth);
1247
+ }
1248
+ });
1249
+ this.columnList = columns;
1250
+ }
1251
+ ngOnInit() { }
1252
+ ngOnChanges(changes) {
1253
+ var _a, _b;
1254
+ if (!((_a = changes.groups.currentValue) === null || _a === void 0 ? void 0 : _a.length) && !((_b = changes.items.currentValue) === null || _b === void 0 ? void 0 : _b.length)) {
1255
+ this.ganttTableEmptyClass = true;
1256
+ }
1257
+ else {
1258
+ this.ganttTableEmptyClass = false;
1259
+ }
1260
+ }
1261
+ dragFixed(config) {
1262
+ if (config.movedWidth < config.minWidth) {
1263
+ config.target.style.transform = `translate3d(${config.minWidth - config.originWidth}px, 0, 0)`;
1264
+ }
1265
+ }
1266
+ expandGroup(group) {
1267
+ this.gantt.expandGroup(group);
1268
+ }
1269
+ expandChildren(item) {
1270
+ this.gantt.expandChildren(item);
1271
+ }
1272
+ dragStarted(event) {
1273
+ const target = event.source.element.nativeElement;
1274
+ this.dragStartLeft = target.getBoundingClientRect().left;
1275
+ }
1276
+ dragMoved(event, column) {
1277
+ const target = event.source.element.nativeElement;
1278
+ const left = target.getBoundingClientRect().left;
1279
+ let originWidth;
1280
+ let movedWidth;
1281
+ let minWidth;
1282
+ if (column) {
1283
+ originWidth = parseInt(column.columnWidth, 10);
1284
+ movedWidth = originWidth + (left - this.dragStartLeft);
1285
+ minWidth = minColumnWidth;
1286
+ }
1287
+ else {
1288
+ originWidth = this.elementRef.nativeElement.getBoundingClientRect().width;
1289
+ movedWidth = originWidth + (left - this.dragStartLeft);
1290
+ minWidth = minColumnWidth * this.columnList.length;
1291
+ }
1292
+ this.dragFixed({
1293
+ target,
1294
+ originWidth,
1295
+ movedWidth,
1296
+ minWidth
1297
+ });
1298
+ this.showAuxiliaryLine(event);
1299
+ }
1300
+ columnDragEnded(event, column) {
1301
+ const target = event.source.element.nativeElement;
1302
+ const left = target.getBoundingClientRect().left;
1303
+ const width = parseInt(column.columnWidth, 10) + (left - this.dragStartLeft);
1304
+ const columnWidth = Math.max(width || 0, minColumnWidth);
1305
+ column.columnWidth = coerceCssPixelValue(columnWidth);
1306
+ if (this.gantt.table) {
1307
+ this.gantt.table.columnChanges.emit({ columns: this.columnList });
1308
+ }
1309
+ this.hideAuxiliaryLine();
1310
+ event.source.reset();
1311
+ }
1312
+ tableDragEnded(event) {
1313
+ const target = event.source.element.nativeElement;
1314
+ const left = target.getBoundingClientRect().left;
1315
+ const tableWidth = this.elementRef.nativeElement.getBoundingClientRect().width;
1316
+ const dragWidth = left - this.dragStartLeft;
1317
+ this.columnList.forEach((column) => {
1318
+ const lastColumnWidth = parseInt(column.columnWidth, 10);
1319
+ const distributeWidth = parseInt(String(dragWidth * (lastColumnWidth / tableWidth)), 10);
1320
+ const columnWidth = Math.max(lastColumnWidth + distributeWidth || 0, minColumnWidth);
1321
+ column.columnWidth = coerceCssPixelValue(columnWidth);
1322
+ });
1323
+ if (this.gantt.table) {
1324
+ this.gantt.table.columnChanges.emit({ columns: this.columnList });
1325
+ }
1326
+ this.hideAuxiliaryLine();
1327
+ event.source.reset();
1328
+ }
1329
+ showAuxiliaryLine(event) {
1330
+ const tableRect = this.elementRef.nativeElement.getBoundingClientRect();
1331
+ const targetRect = event.source.element.nativeElement.getBoundingClientRect();
1332
+ const distance = { x: targetRect.left - tableRect.left, y: targetRect.top - tableRect.top };
1333
+ this.draglineElementRef.nativeElement.style.left = `${distance.x}px`;
1334
+ this.draglineElementRef.nativeElement.style.display = 'block';
1335
+ }
1336
+ hideAuxiliaryLine() {
1337
+ this.draglineElementRef.nativeElement.style.display = 'none';
1338
+ }
1339
+ trackBy(index, item) {
1340
+ return item.id || index;
1341
+ }
1342
+ }
1343
+ GanttTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttTableComponent, deps: [{ token: GANTT_ABSTRACT_TOKEN }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1344
+ GanttTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: GanttTableComponent, selector: "gantt-table", inputs: { groups: "groups", items: "items", columns: "columns", groupTemplate: "groupTemplate", emptyTemplate: "emptyTemplate" }, host: { properties: { "class.gantt-table": "this.ganttTableClass", "class.gantt-table-empty": "this.ganttTableEmptyClass" } }, viewQueries: [{ propertyName: "draglineElementRef", first: true, predicate: ["dragLine"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0, template: "<div class=\"gantt-table-header gantt-table-row\">\n <div class=\"gantt-table-column\" *ngFor=\"let column of columnList; let i = index\" [style.width]=\"column.columnWidth\">\n <ng-container *ngIf=\"column.headerTemplateRef; else default\" [ngTemplateOutlet]=\"column.headerTemplateRef\"></ng-container>\n <ng-template #default>\n {{ column.name }}\n </ng-template>\n <div\n class=\"gantt-table-drag-trigger\"\n cdkDrag\n cdkDragLockAxis=\"x\"\n cdkDragBoundary=\".gantt\"\n (cdkDragMoved)=\"dragMoved($event, column)\"\n (cdkDragStarted)=\"dragStarted($event)\"\n (cdkDragEnded)=\"columnDragEnded($event, column)\"\n ></div>\n </div>\n</div>\n<div class=\"gantt-table-body\">\n <ng-container *ngIf=\"!groups.length && !items.length\">\n <ng-container *ngIf=\"!emptyTemplate\">\n <gantt-icon class=\"empty-icon\" iconName=\"empty\"></gantt-icon>\n <div class=\"empty-text\">\u6CA1\u6709\u6570\u636E</div>\n </ng-container>\n <ng-template [ngTemplateOutlet]=\"emptyTemplate\"></ng-template>\n </ng-container>\n\n <ng-container *ngIf=\"groups && groups.length > 0; else itemsTemplate\">\n <ng-container *ngFor=\"let group of groups; trackBy: trackBy\">\n <div class=\"gantt-table-group\" [ngClass]=\"group.class\">\n <div class=\"gantt-table-group-title\" [class.expanded]=\"group.expanded\" (click)=\"expandGroup(group)\">\n <gantt-icon class=\"expand-icon\" [iconName]=\"group.expanded ? 'angle-down' : 'angle-right'\"></gantt-icon>\n <ng-container *ngIf=\"groupTemplate; else default\">\n <ng-template\n [ngTemplateOutlet]=\"groupTemplate\"\n [ngTemplateOutletContext]=\"{ $implicit: group.origin, group: group.origin }\"\n ></ng-template>\n </ng-container>\n <ng-template #default>\n <span class=\"group-title\">{{ group.title }}</span>\n </ng-template>\n </div>\n </div>\n\n <ng-container *ngIf=\"group.expanded\">\n <ng-template\n [ngTemplateOutlet]=\"ganttItems\"\n [ngTemplateOutletContext]=\"{ group: group, items: group.items, level: 0 }\"\n ></ng-template>\n </ng-container>\n </ng-container>\n </ng-container>\n</div>\n\n<div\n class=\"gantt-table-drag-trigger\"\n cdkDrag\n cdkDragLockAxis=\"x\"\n cdkDragBoundary=\".gantt\"\n (cdkDragMoved)=\"dragMoved($event)\"\n (cdkDragStarted)=\"dragStarted($event)\"\n (cdkDragEnded)=\"tableDragEnded($event)\"\n></div>\n\n<div #dragLine class=\"gantt-table-drag-auxiliary-line\"></div>\n\n<ng-template #itemsTemplate>\n <ng-template [ngTemplateOutlet]=\"ganttItems\" [ngTemplateOutletContext]=\"{ items: items, level: 0 }\"></ng-template>\n</ng-template>\n\n<ng-template #ganttItems let-group=\"group\" let-items=\"items\" let-level=\"level\">\n <ng-container *ngFor=\"let item of items; trackBy: trackBy\">\n <div\n class=\"gantt-table-item gantt-table-row\"\n [class.gantt-table-item-first-level-group]=\"level === 0 && (item.type | isGanttRangeItem)\"\n [class.gantt-table-item-with-group]=\"group\"\n [style.height.px]=\"gantt.styles.lineHeight\"\n [style.lineHeight.px]=\"gantt.styles.lineHeight\"\n >\n <div class=\"gantt-table-column\" *ngFor=\"let column of columnList; let first = first\" [style.width]=\"column.columnWidth\">\n <div *ngIf=\"first\" class=\"gantt-expand-icon\" [style.marginLeft.px]=\"level * 20\">\n <ng-container *ngIf=\"level < gantt.maxLevel - 1 && item.expandable\">\n <gantt-icon\n *ngIf=\"!item.loading\"\n class=\"expand-icon\"\n [iconName]=\"item.expanded ? 'angle-down' : 'angle-right'\"\n (click)=\"expandChildren(item)\"\n ></gantt-icon>\n <gantt-icon *ngIf=\"item.loading\" [iconName]=\"'loading'\"></gantt-icon>\n </ng-container>\n </div>\n <div class=\"gantt-table-column-content\">\n <ng-template\n [ngTemplateOutlet]=\"column.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: item.origin, item: item.origin }\"\n ></ng-template>\n </div>\n </div>\n </div>\n <ng-template\n *ngIf=\"item.children && item.expanded\"\n [ngTemplateOutlet]=\"ganttItems\"\n [ngTemplateOutletContext]=\"{ items: item.children, level: level + 1, group: group }\"\n ></ng-template>\n </ng-container>\n</ng-template>\n", components: [{ type: GanttIconComponent, selector: "gantt-icon", inputs: ["iconName"] }], directives: [{ type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i1.CdkDrag, selector: "[cdkDrag]", inputs: ["cdkDragDisabled", "cdkDragStartDelay", "cdkDragLockAxis", "cdkDragConstrainPosition", "cdkDragPreviewClass", "cdkDragBoundary", "cdkDragRootElement", "cdkDragData", "cdkDragFreeDragPosition"], outputs: ["cdkDragStarted", "cdkDragReleased", "cdkDragEnded", "cdkDragEntered", "cdkDragExited", "cdkDragDropped", "cdkDragMoved"], exportAs: ["cdkDrag"] }, { type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }], pipes: { "isGanttRangeItem": IsGanttRangeItemPipe } });
1345
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttTableComponent, decorators: [{
1346
+ type: Component,
1347
+ args: [{
1348
+ selector: 'gantt-table',
1349
+ templateUrl: './gantt-table.component.html'
1350
+ }]
1351
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1352
+ type: Inject,
1353
+ args: [GANTT_ABSTRACT_TOKEN]
1354
+ }] }, { type: i0.ElementRef }]; }, propDecorators: { groups: [{
1355
+ type: Input
1356
+ }], items: [{
1357
+ type: Input
1358
+ }], columns: [{
1359
+ type: Input
1360
+ }], groupTemplate: [{
1361
+ type: Input
1362
+ }], emptyTemplate: [{
1363
+ type: Input
1364
+ }], draglineElementRef: [{
1365
+ type: ViewChild,
1366
+ args: ['dragLine', { static: true }]
1367
+ }], ganttTableClass: [{
1368
+ type: HostBinding,
1369
+ args: ['class.gantt-table']
1370
+ }], ganttTableEmptyClass: [{
1371
+ type: HostBinding,
1372
+ args: ['class.gantt-table-empty']
1373
+ }] } });
1374
+
1375
+ const scrollThreshold = 50;
1376
+ var ScrollDirection;
1377
+ (function (ScrollDirection) {
1378
+ ScrollDirection[ScrollDirection["NONE"] = 0] = "NONE";
1379
+ ScrollDirection[ScrollDirection["LEFT"] = 1] = "LEFT";
1380
+ ScrollDirection[ScrollDirection["RIGHT"] = 2] = "RIGHT";
1381
+ })(ScrollDirection || (ScrollDirection = {}));
1382
+ class GanttDomService {
1383
+ constructor() {
1384
+ this.unsubscribe$ = new Subject();
1385
+ }
1386
+ monitorScrollChange() {
1387
+ merge(fromEvent(this.mainContainer, 'scroll'), fromEvent(this.sideContainer, 'scroll'))
1388
+ .pipe(takeUntil(this.unsubscribe$))
1389
+ .subscribe((event) => {
1390
+ this.syncScroll(event);
1391
+ });
1392
+ fromEvent(this.mainContainer, 'scroll')
1393
+ .pipe(startWith(), takeUntil(this.unsubscribe$))
1394
+ .subscribe((event) => {
1395
+ // if (this.mainContainer.scrollLeft > 0) {
1396
+ // this.side.classList.add('gantt-side-has-shadow');
1397
+ // } else {
1398
+ // this.side.classList.remove('gantt-side-has-shadow');
1399
+ // }
1400
+ });
1401
+ }
1402
+ syncScroll(event) {
1403
+ const target = event.currentTarget;
1404
+ this.calendarOverlay.scrollLeft = this.mainContainer.scrollLeft;
1405
+ this.sideContainer.scrollTop = target.scrollTop;
1406
+ this.mainContainer.scrollTop = target.scrollTop;
1407
+ }
1408
+ disableBrowserWheelEvent() {
1409
+ const container = this.mainContainer;
1410
+ fromEvent(container, 'wheel')
1411
+ .pipe(takeUntil(this.unsubscribe$))
1412
+ .subscribe((event) => {
1413
+ const delta = event.deltaX;
1414
+ if (!delta) {
1415
+ return;
1416
+ }
1417
+ if ((container.scrollLeft + container.offsetWidth === container.scrollWidth && delta > 0) ||
1418
+ (container.scrollLeft === 0 && delta < 0)) {
1419
+ event.preventDefault();
1420
+ }
1421
+ });
1422
+ }
1423
+ initialize(root) {
1424
+ this.root = root.nativeElement;
1425
+ this.side = this.root.getElementsByClassName('gantt-side')[0];
1426
+ this.container = this.root.getElementsByClassName('gantt-container')[0];
1427
+ this.sideContainer = this.root.getElementsByClassName('gantt-side-container')[0];
1428
+ this.mainContainer = this.root.getElementsByClassName('gantt-main-container')[0];
1429
+ this.calendarOverlay = this.root.getElementsByClassName('gantt-calendar-overlay')[0];
1430
+ this.monitorScrollChange();
1431
+ this.disableBrowserWheelEvent();
1432
+ }
1433
+ getViewerScroll() {
1434
+ return fromEvent(this.mainContainer, 'scroll').pipe(map(() => this.mainContainer.scrollLeft), pairwise(), map(([previous, current]) => {
1435
+ const event = {
1436
+ target: this.mainContainer,
1437
+ direction: ScrollDirection.NONE
1438
+ };
1439
+ if (current - previous < 0) {
1440
+ if (this.mainContainer.scrollLeft < scrollThreshold && this.mainContainer.scrollLeft > 0) {
1441
+ event.direction = ScrollDirection.LEFT;
1442
+ }
1443
+ }
1444
+ if (current - previous > 0) {
1445
+ if (this.mainContainer.scrollWidth - this.mainContainer.clientWidth - this.mainContainer.scrollLeft < scrollThreshold) {
1446
+ event.direction = ScrollDirection.RIGHT;
1447
+ }
1448
+ }
1449
+ return event;
1450
+ }));
1451
+ }
1452
+ getResize() {
1453
+ return fromEvent(window, 'resize').pipe(auditTime(150));
1454
+ }
1455
+ scrollMainContainer(left) {
1456
+ if (isNumber(left)) {
1457
+ const scrollLeft = left - this.mainContainer.clientWidth / 2;
1458
+ this.mainContainer.scrollLeft = scrollLeft > scrollThreshold ? scrollLeft : 0;
1459
+ this.calendarOverlay.scrollLeft = this.mainContainer.scrollLeft;
1460
+ }
1461
+ }
1462
+ ngOnDestroy() {
1463
+ this.unsubscribe$.next();
1464
+ this.unsubscribe$.complete();
1465
+ }
1466
+ }
1467
+ GanttDomService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDomService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1468
+ GanttDomService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDomService });
1469
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDomService, decorators: [{
1470
+ type: Injectable
1471
+ }], ctorParameters: function () { return []; } });
1472
+
1473
+ class GanttDragContainer {
1474
+ constructor() {
1475
+ this.dragStarted = new EventEmitter();
1476
+ this.dragMoved = new EventEmitter();
1477
+ this.dragEnded = new EventEmitter();
1478
+ this.linkDragStarted = new EventEmitter();
1479
+ this.linkDragEntered = new EventEmitter();
1480
+ this.linkDragEnded = new EventEmitter();
1481
+ }
1482
+ emitLinkDragStarted(from, item) {
1483
+ this.linkDraggingId = item.id;
1484
+ this.linkDragFrom = from;
1485
+ this.linkDragSource = this.linkDragFrom === 'source' ? item : null;
1486
+ this.linkDragTarget = this.linkDragFrom === 'target' ? item : null;
1487
+ this.linkDragStarted.emit({
1488
+ source: this.linkDragSource && this.linkDragSource.origin,
1489
+ target: this.linkDragTarget && this.linkDragTarget.origin
1490
+ });
1491
+ }
1492
+ emitLinkDragEntered(item) {
1493
+ if (this.linkDragFrom === 'source') {
1494
+ this.linkDragTarget = item;
1495
+ }
1496
+ else {
1497
+ this.linkDragSource = item;
1498
+ }
1499
+ this.linkDragEntered.emit({
1500
+ source: this.linkDragSource.origin,
1501
+ target: this.linkDragTarget.origin
1502
+ });
1503
+ }
1504
+ emitLinkDragLeaved() {
1505
+ if (this.linkDragFrom === 'source') {
1506
+ this.linkDragTarget = null;
1507
+ }
1508
+ else {
1509
+ this.linkDragSource = null;
1510
+ }
1511
+ }
1512
+ emitLinkDragEnded() {
1513
+ this.linkDraggingId = null;
1514
+ if (this.linkDragSource && this.linkDragTarget) {
1515
+ this.linkDragSource.addLink(this.linkDragTarget.id);
1516
+ this.linkDragEnded.emit({
1517
+ source: this.linkDragSource.origin,
1518
+ target: this.linkDragTarget.origin
1519
+ });
1520
+ }
1521
+ this.linkDragSource = null;
1522
+ this.linkDragTarget = null;
1523
+ }
1524
+ }
1525
+ GanttDragContainer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDragContainer, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1526
+ GanttDragContainer.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDragContainer });
1527
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDragContainer, decorators: [{
1528
+ type: Injectable
1529
+ }], ctorParameters: function () { return []; } });
1530
+
1531
+ class GanttPrintService {
1532
+ constructor() { }
1533
+ setInlineStyles(targetElem) {
1534
+ const svgElements = Array.from(targetElem.getElementsByTagName('svg'));
1535
+ for (const svgElement of svgElements) {
1536
+ this.recursElementChildren(svgElement);
1537
+ }
1538
+ }
1539
+ recursElementChildren(node) {
1540
+ const transformProperties = [
1541
+ 'fill',
1542
+ 'color',
1543
+ 'font-size',
1544
+ 'stroke',
1545
+ 'font',
1546
+ 'text-anchor',
1547
+ 'stroke-dasharray',
1548
+ 'shape-rendering',
1549
+ 'stroke-width'
1550
+ ];
1551
+ if (!node.style) {
1552
+ return;
1553
+ }
1554
+ const styles = getComputedStyle(node);
1555
+ for (const transformProperty of transformProperties) {
1556
+ node.style[transformProperty] = styles[transformProperty];
1557
+ }
1558
+ for (const child of Array.from(node.childNodes)) {
1559
+ this.recursElementChildren(child);
1560
+ }
1561
+ }
1562
+ register(root) {
1563
+ this.root = root.nativeElement;
1564
+ this.mainContainer = this.root.getElementsByClassName('gantt-main-container')[0];
1565
+ }
1566
+ print(name = 'download', ignoreElementClass) {
1567
+ const root = this.root;
1568
+ const mainContainer = this.mainContainer;
1569
+ // set print width
1570
+ const printWidth = root.offsetWidth;
1571
+ // set print height
1572
+ const printHeight = root.offsetHeight - mainContainer.offsetHeight + mainContainer.scrollHeight;
1573
+ html2canvas(root, {
1574
+ logging: false,
1575
+ allowTaint: true,
1576
+ useCORS: true,
1577
+ width: printWidth,
1578
+ height: printHeight,
1579
+ ignoreElements: (element) => {
1580
+ if (ignoreElementClass && element.classList.contains(ignoreElementClass)) {
1581
+ return true;
1582
+ }
1583
+ if (element.classList.contains('gantt-calendar-today-overlay')) {
1584
+ return true;
1585
+ }
1586
+ },
1587
+ onclone: (cloneDocument) => {
1588
+ const ganttClass = root.className;
1589
+ const cloneGanttDom = cloneDocument.querySelector(`.${ganttClass.replace(/\s+/g, '.')}`);
1590
+ const cloneGanttContainerDom = cloneDocument.querySelector('.gantt-container');
1591
+ const cloneCalendarOverlay = cloneDocument.querySelector('.gantt-calendar-overlay-main');
1592
+ const cloneLinksOverlay = cloneDocument.querySelector('.gantt-links-overlay-main');
1593
+ // change targetDom width
1594
+ cloneGanttDom.style.width = `${printWidth}px`;
1595
+ cloneGanttDom.style.height = `${printHeight}px`;
1596
+ cloneGanttDom.style.overflow = `unset`;
1597
+ cloneGanttContainerDom.style.backgroundColor = '#fff';
1598
+ cloneCalendarOverlay.setAttribute('height', `${printHeight}`);
1599
+ cloneCalendarOverlay.setAttribute('style', `background: transparent`);
1600
+ if (cloneLinksOverlay) {
1601
+ cloneLinksOverlay.setAttribute('height', `${printHeight}`);
1602
+ cloneLinksOverlay.setAttribute('style', `height: ${printHeight}px`);
1603
+ }
1604
+ // setInlineStyles for svg
1605
+ this.setInlineStyles(cloneGanttDom);
1606
+ }
1607
+ }).then((canvas) => {
1608
+ const link = document.createElement('a');
1609
+ const dataUrl = canvas.toDataURL('image/png');
1610
+ link.download = `${name}.png`;
1611
+ link.href = dataUrl;
1612
+ link.click();
1613
+ });
1614
+ }
1615
+ }
1616
+ GanttPrintService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttPrintService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1617
+ GanttPrintService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttPrintService });
1618
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttPrintService, decorators: [{
1619
+ type: Injectable
1620
+ }], ctorParameters: function () { return []; } });
1621
+
1622
+ const mainHeight = 5000;
1623
+ class GanttCalendarComponent {
1624
+ constructor(ganttUpper, ngZone, elementRef) {
1625
+ this.ganttUpper = ganttUpper;
1626
+ this.ngZone = ngZone;
1627
+ this.elementRef = elementRef;
1628
+ this.unsubscribe$ = new Subject();
1629
+ this.headerHeight = headerHeight;
1630
+ this.mainHeight = mainHeight;
1631
+ this.todayHeight = todayHeight;
1632
+ this.todayWidth = todayWidth;
1633
+ this.todayBorderRadius = todayBorderRadius;
1634
+ this.viewTypes = GanttViewType;
1635
+ this.className = true;
1636
+ }
1637
+ get view() {
1638
+ return this.ganttUpper.view;
1639
+ }
1640
+ setTodayPoint() {
1641
+ const x = this.view.getTodayXPoint();
1642
+ const today = new GanttDate().getDate();
1643
+ const todayEle = this.elementRef.nativeElement.getElementsByClassName('gantt-calendar-today-overlay')[0];
1644
+ const rect = this.elementRef.nativeElement.getElementsByClassName('today-rect')[0];
1645
+ const line = this.elementRef.nativeElement.getElementsByClassName('today-line')[0];
1646
+ if (isNumber(x)) {
1647
+ if (rect) {
1648
+ rect.style.left = `${x - todayWidth / 2}px`;
1649
+ rect.style.top = `${headerHeight - todayHeight}px`;
1650
+ rect.innerHTML = today.toString();
1651
+ }
1652
+ if (line) {
1653
+ line.style.left = `${x}px`;
1654
+ line.style.top = `${headerHeight}px`;
1655
+ line.style.bottom = `${-mainHeight}px`;
1656
+ }
1657
+ }
1658
+ else {
1659
+ todayEle.style.display = 'none';
1660
+ }
1661
+ }
1662
+ ngOnInit() {
1663
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
1664
+ merge(this.ganttUpper.viewChange, this.ganttUpper.view.start$)
1665
+ .pipe(takeUntil(this.unsubscribe$))
1666
+ .subscribe(() => {
1667
+ this.setTodayPoint();
1668
+ });
1669
+ });
1670
+ }
1671
+ ngAfterViewInit() { }
1672
+ ngOnChanges(changes) { }
1673
+ trackBy(index, point) {
1674
+ return point.text || index;
1675
+ }
1676
+ ngOnDestroy() {
1677
+ this.unsubscribe$.next();
1678
+ this.unsubscribe$.complete();
1679
+ }
1680
+ }
1681
+ GanttCalendarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttCalendarComponent, deps: [{ token: GANTT_UPPER_TOKEN }, { token: i0.NgZone }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
1682
+ GanttCalendarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: GanttCalendarComponent, selector: "gantt-calendar-overlay", host: { properties: { "class.gantt-calendar-overlay": "this.className" } }, usesOnChanges: true, ngImport: i0, template: "<div class=\"gantt-calendar-today-overlay\" [style.width.px]=\"view.width\">\n <span class=\"today-rect\" [hidden]=\"ganttUpper.viewType !== viewTypes.day\"> </span>\n <span class=\"today-line\" *ngIf=\"ganttUpper.showTodayLine\"> </span>\n</div>\n\n<svg class=\"gantt-calendar-overlay-main\" [attr.width]=\"view.width\" [attr.height]=\"headerHeight\">\n <g>\n <text class=\"primary-text\" *ngFor=\"let point of view.primaryDatePoints; trackBy: trackBy\" [attr.x]=\"point.x\" [attr.y]=\"point.y\">\n {{ point.text }}\n </text>\n <ng-container *ngFor=\"let point of view.secondaryDatePoints; trackBy: trackBy\">\n <text class=\"secondary-text\" [class.secondary-text-weekend]=\"point.additions?.isWeekend\" [attr.x]=\"point.x\" [attr.y]=\"point.y\">\n {{ point.text }}\n </text>\n </ng-container>\n\n <g>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n\n <g>\n <line [attr.x1]=\"0\" [attr.x2]=\"view.width\" [attr.y1]=\"headerHeight\" [attr.y2]=\"headerHeight\" class=\"header-line\"></line>\n </g>\n </g>\n <g>\n <g *ngIf=\"view.showTimeline\">\n <line\n *ngFor=\"let point of view.secondaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.cellWidth\"\n [attr.x2]=\"(i + 1) * view.cellWidth\"\n [attr.y1]=\"headerHeight\"\n [attr.y2]=\"mainHeight\"\n class=\"secondary-line\"\n ></line>\n <line\n *ngFor=\"let point of view.primaryDatePoints; let i = index; trackBy: trackBy\"\n [attr.x1]=\"(i + 1) * view.primaryWidth\"\n [attr.x2]=\"(i + 1) * view.primaryWidth\"\n [attr.y1]=\"0\"\n [attr.y2]=\"mainHeight\"\n class=\"primary-line\"\n ></line>\n </g>\n </g>\n</svg>\n", directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
1683
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttCalendarComponent, decorators: [{
1684
+ type: Component,
1685
+ args: [{
1686
+ selector: 'gantt-calendar-overlay',
1687
+ templateUrl: './calendar.component.html'
1688
+ }]
1689
+ }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
1690
+ type: Inject,
1691
+ args: [GANTT_UPPER_TOKEN]
1692
+ }] }, { type: i0.NgZone }, { type: i0.ElementRef }]; }, propDecorators: { className: [{
1693
+ type: HostBinding,
1694
+ args: ['class.gantt-calendar-overlay']
1695
+ }] } });
1696
+
1697
+ class GanttDragBackdropComponent {
1698
+ constructor() {
1699
+ this.backdropClass = true;
1700
+ }
1701
+ ngOnInit() { }
1702
+ }
1703
+ GanttDragBackdropComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDragBackdropComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1704
+ GanttDragBackdropComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: GanttDragBackdropComponent, selector: "gantt-drag-backdrop", host: { properties: { "class.gantt-drag-backdrop": "this.backdropClass" } }, ngImport: i0, template: "<div class=\"gantt-drag-mask\">\n <div class=\"date-range\">\n <span class=\"start\"></span>\n <span class=\"end\"></span>\n </div>\n</div>\n" });
1705
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttDragBackdropComponent, decorators: [{
1706
+ type: Component,
1707
+ args: [{
1708
+ selector: 'gantt-drag-backdrop',
1709
+ templateUrl: `./drag-backdrop.component.html`
1710
+ }]
1711
+ }], ctorParameters: function () { return []; }, propDecorators: { backdropClass: [{
1712
+ type: HostBinding,
1713
+ args: ['class.gantt-drag-backdrop']
1714
+ }] } });
1715
+
1716
+ class NgxGanttRootComponent {
1717
+ constructor(elementRef, ngZone, dom, dragContainer, ganttUpper, printService) {
1718
+ this.elementRef = elementRef;
1719
+ this.ngZone = ngZone;
1720
+ this.dom = dom;
1721
+ this.dragContainer = dragContainer;
1722
+ this.ganttUpper = ganttUpper;
1723
+ this.printService = printService;
1724
+ this.ganttClass = true;
1725
+ this.unsubscribe$ = new Subject();
1726
+ this.ganttUpper.dragContainer = dragContainer;
1727
+ }
1728
+ get view() {
1729
+ return this.ganttUpper.view;
1730
+ }
1731
+ ngOnInit() {
1732
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
1733
+ this.dom.initialize(this.elementRef);
1734
+ if (this.printService) {
1735
+ this.printService.register(this.elementRef);
1736
+ }
1737
+ this.setupScrollClass();
1738
+ this.setupResize();
1739
+ this.setupViewScroll();
1740
+ // 优化初始化时Scroll滚动体验问题,通过透明度解决,默认透明度为0,滚动结束后恢复
1741
+ this.elementRef.nativeElement.style.opacity = '1';
1742
+ this.ganttUpper.viewChange.pipe(startWith(null)).subscribe(() => {
1743
+ this.scrollToToday();
1744
+ });
1745
+ });
1746
+ }
1747
+ setupViewScroll() {
1748
+ if (this.ganttUpper.disabledLoadOnScroll) {
1749
+ return;
1750
+ }
1751
+ this.dom
1752
+ .getViewerScroll()
1753
+ .pipe(takeUntil(this.unsubscribe$))
1754
+ .subscribe((event) => {
1755
+ if (event.direction === ScrollDirection.LEFT) {
1756
+ const dates = this.view.addStartDate();
1757
+ if (dates) {
1758
+ event.target.scrollLeft += this.view.getDateRangeWidth(dates.start, dates.end);
1759
+ this.ngZone.run(() => {
1760
+ this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() });
1761
+ });
1762
+ }
1763
+ }
1764
+ if (event.direction === ScrollDirection.RIGHT) {
1765
+ const dates = this.view.addEndDate();
1766
+ if (dates) {
1767
+ this.ngZone.run(() => {
1768
+ this.ganttUpper.loadOnScroll.emit({ start: dates.start.getUnixTime(), end: dates.end.getUnixTime() });
1769
+ });
1770
+ }
1771
+ }
1772
+ });
1773
+ }
1774
+ setupResize() {
1775
+ this.dom
1776
+ .getResize()
1777
+ .pipe(takeUntil(this.unsubscribe$))
1778
+ .subscribe(() => {
1779
+ this.setupScrollClass();
1780
+ });
1781
+ }
1782
+ setupScrollClass() {
1783
+ const mainContainer = this.dom.mainContainer;
1784
+ const height = mainContainer.offsetHeight;
1785
+ const scrollHeight = mainContainer.scrollHeight;
1786
+ if (scrollHeight > height) {
1787
+ this.elementRef.nativeElement.className = 'gantt gantt-scroll';
1788
+ }
1789
+ else {
1790
+ this.elementRef.nativeElement.className = 'gantt';
1791
+ }
1792
+ }
1793
+ scrollToToday() {
1794
+ const x = this.view.getTodayXPoint();
1795
+ this.dom.scrollMainContainer(x);
1796
+ }
1797
+ }
1798
+ NgxGanttRootComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttRootComponent, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }, { token: GanttDomService }, { token: GanttDragContainer }, { token: GANTT_UPPER_TOKEN }, { token: GanttPrintService, optional: true }], target: i0.ɵɵFactoryTarget.Component });
1799
+ NgxGanttRootComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: NgxGanttRootComponent, selector: "ngx-gantt-root", inputs: { sideWidth: "sideWidth" }, host: { properties: { "class.gantt": "this.ganttClass" } }, providers: [GanttDomService, GanttDragContainer], queries: [{ propertyName: "sideTemplate", first: true, predicate: ["sideTemplate"], descendants: true, static: true }, { propertyName: "mainTemplate", first: true, predicate: ["mainTemplate"], descendants: true, static: true }], ngImport: i0, template: "<div class=\"gantt-side\" [style.width.px]=\"sideWidth\">\n <div class=\"gantt-side-container\">\n <ng-template [ngTemplateOutlet]=\"sideTemplate\"></ng-template>\n </div>\n</div>\n<div class=\"gantt-container\">\n <gantt-calendar-overlay></gantt-calendar-overlay>\n <gantt-drag-backdrop></gantt-drag-backdrop>\n <div class=\"gantt-main\">\n <ng-template [ngTemplateOutlet]=\"mainTemplate\"></ng-template>\n </div>\n</div>\n", components: [{ type: GanttCalendarComponent, selector: "gantt-calendar-overlay" }, { type: GanttDragBackdropComponent, selector: "gantt-drag-backdrop" }], directives: [{ type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
1800
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttRootComponent, decorators: [{
1801
+ type: Component,
1802
+ args: [{
1803
+ selector: 'ngx-gantt-root',
1804
+ templateUrl: './root.component.html',
1805
+ providers: [GanttDomService, GanttDragContainer]
1806
+ }]
1807
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }, { type: GanttDomService }, { type: GanttDragContainer }, { type: GanttUpper, decorators: [{
1808
+ type: Inject,
1809
+ args: [GANTT_UPPER_TOKEN]
1810
+ }] }, { type: GanttPrintService, decorators: [{
1811
+ type: Optional
1812
+ }] }]; }, propDecorators: { sideWidth: [{
1813
+ type: Input
1814
+ }], ganttClass: [{
1815
+ type: HostBinding,
1816
+ args: ['class.gantt']
1817
+ }], sideTemplate: [{
1818
+ type: ContentChild,
1819
+ args: ['sideTemplate', { static: true }]
1820
+ }], mainTemplate: [{
1821
+ type: ContentChild,
1822
+ args: ['mainTemplate', { static: true }]
1823
+ }] } });
1824
+
1825
+ var LinkColors;
1826
+ (function (LinkColors) {
1827
+ LinkColors["default"] = "#cacaca";
1828
+ LinkColors["blocked"] = "#FF7575";
1829
+ LinkColors["active"] = "#348FE4";
1830
+ })(LinkColors || (LinkColors = {}));
1831
+ class GanttLinksComponent {
1832
+ constructor(ganttUpper, cdr, elementRef, ganttDragContainer) {
1833
+ this.ganttUpper = ganttUpper;
1834
+ this.cdr = cdr;
1835
+ this.elementRef = elementRef;
1836
+ this.ganttDragContainer = ganttDragContainer;
1837
+ this.groups = [];
1838
+ this.items = [];
1839
+ this.lineClick = new EventEmitter();
1840
+ this.links = [];
1841
+ this.linkItems = [];
1842
+ this.bezierWeight = -0.5;
1843
+ this.firstChange = true;
1844
+ this.unsubscribe$ = new Subject();
1845
+ this.ganttLinksOverlay = true;
1846
+ }
1847
+ ngOnInit() {
1848
+ this.buildLinks();
1849
+ this.firstChange = false;
1850
+ this.ganttDragContainer.dragStarted.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
1851
+ this.elementRef.nativeElement.style.visibility = 'hidden';
1852
+ });
1853
+ merge(this.ganttUpper.viewChange, this.ganttUpper.expandChange, this.ganttUpper.view.start$, this.ganttUpper.dragEnded, this.ganttUpper.linkDragEnded)
1854
+ .pipe(takeUntil(this.unsubscribe$), skip(1))
1855
+ .subscribe(() => {
1856
+ this.elementRef.nativeElement.style.visibility = 'visible';
1857
+ this.buildLinks();
1858
+ this.cdr.detectChanges();
1859
+ });
1860
+ }
1861
+ ngOnChanges() {
1862
+ if (!this.firstChange) {
1863
+ this.buildLinks();
1864
+ }
1865
+ }
1866
+ computeItemPosition() {
1867
+ const lineHeight = this.ganttUpper.styles.lineHeight;
1868
+ const barHeight = this.ganttUpper.styles.barHeight;
1869
+ this.linkItems = [];
1870
+ if (this.groups.length > 0) {
1871
+ let itemNum = 0;
1872
+ let groupNum = 0;
1873
+ this.groups.forEach((group) => {
1874
+ groupNum++;
1875
+ if (group.expanded) {
1876
+ const items = recursiveItems(group.items);
1877
+ items.forEach((item, itemIndex) => {
1878
+ const y = (groupNum + itemNum + itemIndex) * lineHeight + item.refs.y + barHeight / 2;
1879
+ this.linkItems.push(Object.assign(Object.assign({}, item), { before: {
1880
+ x: item.refs.x,
1881
+ y
1882
+ }, after: {
1883
+ x: item.refs.x + item.refs.width,
1884
+ y
1885
+ } }));
1886
+ });
1887
+ itemNum += items.length;
1888
+ }
1889
+ });
1890
+ }
1891
+ else {
1892
+ const items = recursiveItems(this.items);
1893
+ items.forEach((item, itemIndex) => {
1894
+ const y = itemIndex * lineHeight + item.refs.y + barHeight / 2;
1895
+ this.linkItems.push(Object.assign(Object.assign({}, item), { before: {
1896
+ x: item.refs.x,
1897
+ y
1898
+ }, after: {
1899
+ x: item.refs.x + item.refs.width,
1900
+ y
1901
+ } }));
1902
+ });
1903
+ }
1904
+ }
1905
+ generatePath(source, target) {
1906
+ if (source.before && source.after && target.before && target.after) {
1907
+ const x1 = source.after.x;
1908
+ const y1 = source.after.y;
1909
+ const x4 = target.before.x;
1910
+ const y4 = target.before.y;
1911
+ const dx = Math.abs(x4 - x1) * this.bezierWeight;
1912
+ const x2 = x1 - dx;
1913
+ const x3 = x4 + dx;
1914
+ const centerX = (x1 + x4) / 2;
1915
+ const centerY = (y1 + y4) / 2;
1916
+ let controlX = this.ganttUpper.styles.lineHeight / 2;
1917
+ const controlY = this.ganttUpper.styles.lineHeight / 2;
1918
+ if (x1 >= x4) {
1919
+ if (y4 > y1) {
1920
+ if (Math.abs(y4 - y1) <= this.ganttUpper.styles.lineHeight) {
1921
+ return `M ${x1} ${y1}
1922
+ C ${x1 + controlX} ${y1} ${x1 + controlX} ${y1 + controlX} ${x1} ${y1 + controlY}
1923
+ L ${x1} ${y1 + controlY} ${centerX} ${centerY}
1924
+
1925
+ M ${x4} ${y4}
1926
+ C ${x4 - controlX} ${y4} ${x4 - controlX} ${y4 - controlX} ${x4} ${y4 - controlY}
1927
+ L ${x4} ${y4 - controlY} ${centerX} ${centerY}`;
1928
+ }
1929
+ else {
1930
+ controlX = this.ganttUpper.styles.lineHeight;
1931
+ return `M ${x1} ${y1}
1932
+ C ${x1 + controlX} ${y1} ${x1 + controlX} ${y1 + controlX} ${centerX} ${centerY}
1933
+
1934
+
1935
+ M ${x4} ${y4}
1936
+ C ${x4 - controlX} ${y4} ${x4 - controlX} ${y4 - controlX} ${centerX} ${centerY}`;
1937
+ }
1938
+ }
1939
+ else {
1940
+ if (Math.abs(y4 - y1) <= this.ganttUpper.styles.lineHeight) {
1941
+ return `M ${x1} ${y1}
1942
+ C ${x1 + controlX} ${y1} ${x1 + controlX} ${y1 - controlX} ${x1} ${y1 - controlY}
1943
+ L ${x1} ${y1 - controlY} ${centerX} ${centerY}
1944
+
1945
+ M ${x4} ${y4}
1946
+ C ${x4 - controlX} ${y4} ${x4 - controlX} ${y4 + controlX} ${x4} ${y4 + controlY}
1947
+ L ${x4} ${y4 + controlY} ${centerX} ${centerY}
1948
+ `;
1949
+ }
1950
+ else {
1951
+ controlX = this.ganttUpper.styles.lineHeight;
1952
+ return `M ${x1} ${y1}
1953
+ C ${x1 + controlX} ${y1} ${x1 + controlX} ${y1 - controlX} ${centerX} ${centerY}
1954
+
1955
+ M ${x4} ${y4}
1956
+ C ${x4 - controlX} ${y4} ${x4 - controlX} ${y4 + controlX} ${centerX} ${centerY}`;
1957
+ }
1958
+ }
1959
+ }
1960
+ return `M ${x1} ${y1} C ${x2} ${y1} ${x3} ${y4} ${x4} ${y4}`;
1961
+ }
1962
+ }
1963
+ buildLinks() {
1964
+ this.computeItemPosition();
1965
+ this.links = [];
1966
+ this.linkItems.forEach((source) => {
1967
+ if (source.origin.start || source.origin.end) {
1968
+ source.links.forEach((linkId) => {
1969
+ const target = this.linkItems.find((item) => item.id === linkId);
1970
+ if (target && (target.origin.start || target.origin.end)) {
1971
+ this.links.push({
1972
+ path: this.generatePath(source, target),
1973
+ source: source.origin,
1974
+ target: target.origin,
1975
+ color: source.end.getTime() > target.start.getTime() ? LinkColors.blocked : LinkColors.default
1976
+ });
1977
+ }
1978
+ });
1979
+ }
1980
+ });
1981
+ }
1982
+ trackBy(index) {
1983
+ return index;
1984
+ }
1985
+ onLineClick(event, link) {
1986
+ this.lineClick.emit({
1987
+ event,
1988
+ source: link.source,
1989
+ target: link.target
1990
+ });
1991
+ }
1992
+ mouseEnterPath(link) {
1993
+ if (link.color === LinkColors.default) {
1994
+ link.color = LinkColors.active;
1995
+ }
1996
+ }
1997
+ mouseLeavePath(link) {
1998
+ if (link.color === LinkColors.active) {
1999
+ link.color = LinkColors.default;
2000
+ }
2001
+ }
2002
+ ngOnDestroy() {
2003
+ this.unsubscribe$.next();
2004
+ this.unsubscribe$.complete();
2005
+ }
2006
+ }
2007
+ GanttLinksComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttLinksComponent, deps: [{ token: GANTT_UPPER_TOKEN }, { token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: GanttDragContainer }], target: i0.ɵɵFactoryTarget.Component });
2008
+ GanttLinksComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: GanttLinksComponent, selector: "gantt-links-overlay", inputs: { groups: "groups", items: "items" }, outputs: { lineClick: "lineClick" }, host: { properties: { "class.gantt-links-overlay": "this.ganttLinksOverlay" } }, usesOnChanges: true, ngImport: i0, template: "<svg [attr.width]=\"ganttUpper.view.width\" class=\"gantt-links-overlay-main\">\n <ng-container *ngFor=\"let link of links; let i = index; trackBy: trackBy\">\n <path [attr.d]=\"link.path\" fill=\"transparent\" stroke-width=\"2\" [attr.stroke]=\"link.color\" pointer-events=\"none\"></path>\n <g>\n <path\n class=\"link-line\"\n (click)=\"onLineClick($event, link)\"\n (mouseenter)=\"mouseEnterPath(link)\"\n (mouseleave)=\"mouseLeavePath(link)\"\n [attr.d]=\"link.path\"\n stroke=\"transparent\"\n stroke-width=\"9\"\n fill=\"none\"\n cursor=\"pointer\"\n ></path>\n </g>\n </ng-container>\n <line class=\"link-dragging-line\"></line>\n</svg>\n", directives: [{ type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
2009
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttLinksComponent, decorators: [{
2010
+ type: Component,
2011
+ args: [{
2012
+ selector: 'gantt-links-overlay',
2013
+ templateUrl: './links.component.html'
2014
+ }]
2015
+ }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
2016
+ type: Inject,
2017
+ args: [GANTT_UPPER_TOKEN]
2018
+ }] }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: GanttDragContainer }]; }, propDecorators: { groups: [{
2019
+ type: Input
2020
+ }], items: [{
2021
+ type: Input
2022
+ }], lineClick: [{
2023
+ type: Output
2024
+ }], ganttLinksOverlay: [{
2025
+ type: HostBinding,
2026
+ args: ['class.gantt-links-overlay']
2027
+ }] } });
2028
+
2029
+ class GanttItemUpper {
2030
+ constructor(elementRef, ganttUpper) {
2031
+ this.elementRef = elementRef;
2032
+ this.ganttUpper = ganttUpper;
2033
+ this.firstChange = true;
2034
+ this.unsubscribe$ = new Subject();
2035
+ }
2036
+ onInit() {
2037
+ this.firstChange = false;
2038
+ this.item.refs$.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
2039
+ this.setPositions();
2040
+ });
2041
+ }
2042
+ onChanges() {
2043
+ if (!this.firstChange) {
2044
+ this.setPositions();
2045
+ }
2046
+ }
2047
+ setPositions() {
2048
+ const itemElement = this.elementRef.nativeElement;
2049
+ itemElement.style.left = this.item.refs.x + 'px';
2050
+ itemElement.style.top = this.item.refs.y + 'px';
2051
+ itemElement.style.width = this.item.refs.width + 'px';
2052
+ if (this.item.type === GanttItemType.bar) {
2053
+ itemElement.style.height = this.ganttUpper.styles.barHeight + 'px';
2054
+ }
2055
+ else if (this.item.type === GanttItemType.range) {
2056
+ itemElement.style.height = rangeHeight + 'px';
2057
+ }
2058
+ else {
2059
+ }
2060
+ }
2061
+ onDestroy() {
2062
+ this.unsubscribe$.next();
2063
+ this.unsubscribe$.complete();
2064
+ }
2065
+ }
2066
+ GanttItemUpper.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttItemUpper, deps: [{ token: i0.ElementRef }, { token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Directive });
2067
+ GanttItemUpper.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.1.2", type: GanttItemUpper, inputs: { template: "template", item: "item" }, ngImport: i0 });
2068
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttItemUpper, decorators: [{
2069
+ type: Directive
2070
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: GanttUpper, decorators: [{
2071
+ type: Inject,
2072
+ args: [GANTT_UPPER_TOKEN]
2073
+ }] }]; }, propDecorators: { template: [{
2074
+ type: Input
2075
+ }], item: [{
2076
+ type: Input
2077
+ }] } });
2078
+
2079
+ class NgxGanttRangeComponent extends GanttItemUpper {
2080
+ constructor(elementRef, ganttUpper) {
2081
+ super(elementRef, ganttUpper);
2082
+ this.ganttRangeClass = true;
2083
+ }
2084
+ ngOnInit() {
2085
+ super.onInit();
2086
+ }
2087
+ ngOnChanges() {
2088
+ super.onChanges();
2089
+ }
2090
+ ngOnDestroy() {
2091
+ super.onDestroy();
2092
+ }
2093
+ }
2094
+ NgxGanttRangeComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttRangeComponent, deps: [{ token: i0.ElementRef }, { token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
2095
+ NgxGanttRangeComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: NgxGanttRangeComponent, selector: "ngx-gantt-range,gantt-range", host: { properties: { "class.gantt-range": "this.ganttRangeClass" } }, usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<ng-container *ngIf=\"item.start && item.end\">\n <div class=\"gantt-range-main\">\n <div class=\"gantt-range-main-progress\" *ngIf=\"item.progress >= 0\" [style.width.%]=\"item.progress * 100\"></div>\n </div>\n <div class=\"gantt-range-triangle left\"></div>\n <div class=\"gantt-range-triangle right\"></div>\n <ng-template [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ item: item.origin, refs: item.refs }\"></ng-template>\n</ng-container>\n", directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
2096
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttRangeComponent, decorators: [{
2097
+ type: Component,
2098
+ args: [{
2099
+ selector: 'ngx-gantt-range,gantt-range',
2100
+ templateUrl: './range.component.html'
2101
+ }]
2102
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: GanttUpper, decorators: [{
2103
+ type: Inject,
2104
+ args: [GANTT_UPPER_TOKEN]
2105
+ }] }]; }, propDecorators: { ganttRangeClass: [{
2106
+ type: HostBinding,
2107
+ args: ['class.gantt-range']
2108
+ }] } });
2109
+
2110
+ const dragMinWidth = 10;
2111
+ const activeClass = 'gantt-bar-active';
2112
+ const linkDropClass = 'gantt-bar-link-drop';
2113
+ function createSvgElement(qualifiedName, className) {
2114
+ const element = document.createElementNS('http://www.w3.org/2000/svg', qualifiedName);
2115
+ element.classList.add(className);
2116
+ return element;
2117
+ }
2118
+ class GanttBarDrag {
2119
+ constructor(dragDrop, dom, dragContainer) {
2120
+ this.dragDrop = dragDrop;
2121
+ this.dom = dom;
2122
+ this.dragContainer = dragContainer;
2123
+ this.dragRefs = [];
2124
+ this.destroy$ = new Subject();
2125
+ }
2126
+ get dragDisabled() {
2127
+ return !this.item.draggable || !this.ganttUpper.draggable;
2128
+ }
2129
+ get linkDragDisabled() {
2130
+ return !this.item.linkable || !this.ganttUpper.linkable;
2131
+ }
2132
+ createMouseEvents() {
2133
+ fromEvent(this.barElement, 'mouseenter')
2134
+ .pipe(takeUntil(this.destroy$))
2135
+ .subscribe(() => {
2136
+ if (this.dragContainer.linkDraggingId && this.dragContainer.linkDraggingId !== this.item.id) {
2137
+ if (this.item.linkable) {
2138
+ this.barElement.classList.add(linkDropClass);
2139
+ this.dragContainer.emitLinkDragEntered(this.item);
2140
+ }
2141
+ }
2142
+ else {
2143
+ this.barElement.classList.add(activeClass);
2144
+ }
2145
+ });
2146
+ fromEvent(this.barElement, 'mouseleave')
2147
+ .pipe(takeUntil(this.destroy$))
2148
+ .subscribe(() => {
2149
+ if (!this.dragContainer.linkDraggingId) {
2150
+ this.barElement.classList.remove(activeClass);
2151
+ }
2152
+ else {
2153
+ this.dragContainer.emitLinkDragLeaved();
2154
+ }
2155
+ this.barElement.classList.remove(linkDropClass);
2156
+ });
2157
+ }
2158
+ createBarDrag() {
2159
+ const dragRef = this.dragDrop.createDrag(this.barElement);
2160
+ dragRef.lockAxis = 'x';
2161
+ dragRef.started.subscribe(() => {
2162
+ this.setDraggingStyles();
2163
+ this.dragContainer.dragStarted.emit({ item: this.item.origin });
2164
+ });
2165
+ dragRef.moved.subscribe((event) => {
2166
+ const x = this.item.refs.x + event.distance.x;
2167
+ const days = differenceInCalendarDays(this.item.end.value, this.item.start.value);
2168
+ const start = this.ganttUpper.view.getDateByXPoint(x);
2169
+ const end = start.addDays(days);
2170
+ this.openDragBackdrop(this.barElement, this.ganttUpper.view.getDateByXPoint(x), end);
2171
+ this.item.updateDate(start, end);
2172
+ this.dragContainer.dragMoved.emit({ item: this.item.origin });
2173
+ });
2174
+ dragRef.ended.subscribe((event) => {
2175
+ const days = differenceInCalendarDays(this.item.end.value, this.item.start.value);
2176
+ const start = this.ganttUpper.view.getDateByXPoint(this.item.refs.x + event.distance.x);
2177
+ const end = start.addDays(days);
2178
+ this.item.updateDate(start, end);
2179
+ this.clearDraggingStyles();
2180
+ this.closeDragBackdrop();
2181
+ event.source.reset();
2182
+ this.dragContainer.dragEnded.emit({ item: this.item.origin });
2183
+ });
2184
+ this.barDragRef = dragRef;
2185
+ return dragRef;
2186
+ }
2187
+ createBarHandleDrags() {
2188
+ const dragRefs = [];
2189
+ const handles = this.barElement.querySelectorAll('.drag-handles .handle');
2190
+ handles.forEach((handle, index) => {
2191
+ const isBefore = index === 0;
2192
+ const dragRef = this.dragDrop.createDrag(handle);
2193
+ dragRef.lockAxis = 'x';
2194
+ dragRef.withBoundaryElement(this.dom.root);
2195
+ dragRef.started.subscribe(() => {
2196
+ this.setDraggingStyles();
2197
+ this.dragContainer.dragStarted.emit({ item: this.item.origin });
2198
+ });
2199
+ dragRef.moved.subscribe((event) => {
2200
+ if (isBefore) {
2201
+ const x = this.item.refs.x + event.distance.x;
2202
+ const width = this.item.refs.width + event.distance.x * -1;
2203
+ if (width > dragMinWidth) {
2204
+ this.barElement.style.width = width + 'px';
2205
+ this.barElement.style.left = x + 'px';
2206
+ this.openDragBackdrop(this.barElement, this.ganttUpper.view.getDateByXPoint(x), this.ganttUpper.view.getDateByXPoint(x + width));
2207
+ this.item.updateDate(this.ganttUpper.view.getDateByXPoint(x), this.item.end);
2208
+ }
2209
+ }
2210
+ else {
2211
+ const width = this.item.refs.width + event.distance.x;
2212
+ if (width > dragMinWidth) {
2213
+ this.barElement.style.width = width + 'px';
2214
+ this.openDragBackdrop(this.barElement, this.ganttUpper.view.getDateByXPoint(this.item.refs.x), this.ganttUpper.view.getDateByXPoint(this.item.refs.x + width));
2215
+ }
2216
+ this.item.updateDate(this.item.start, this.ganttUpper.view.getDateByXPoint(this.item.refs.x + width));
2217
+ }
2218
+ this.dragContainer.dragMoved.emit({ item: this.item.origin });
2219
+ event.source.reset();
2220
+ });
2221
+ dragRef.ended.subscribe((event) => {
2222
+ if (isBefore) {
2223
+ const width = this.item.refs.width + event.distance.x * -1;
2224
+ if (width > dragMinWidth) {
2225
+ this.item.updateDate(this.ganttUpper.view.getDateByXPoint(this.item.refs.x + event.distance.x), this.item.end);
2226
+ }
2227
+ else {
2228
+ this.item.updateDate(this.item.end.startOfDay(), this.item.end);
2229
+ }
2230
+ }
2231
+ else {
2232
+ const width = this.item.refs.width + event.distance.x;
2233
+ if (width > dragMinWidth) {
2234
+ this.item.updateDate(this.item.start, this.ganttUpper.view.getDateByXPoint(this.item.refs.x + this.item.refs.width + event.distance.x));
2235
+ }
2236
+ else {
2237
+ this.item.updateDate(this.item.start, this.item.start.endOfDay());
2238
+ }
2239
+ }
2240
+ this.clearDraggingStyles();
2241
+ this.closeDragBackdrop();
2242
+ this.dragContainer.dragEnded.emit({ item: this.item.origin });
2243
+ });
2244
+ dragRefs.push(dragRef);
2245
+ });
2246
+ return dragRefs;
2247
+ }
2248
+ createLinkHandleDrags() {
2249
+ const dragRefs = [];
2250
+ const handles = this.barElement.querySelectorAll('.link-handles .handle');
2251
+ handles.forEach((handle, index) => {
2252
+ const isBefore = index === 0;
2253
+ const dragRef = this.dragDrop.createDrag(handle);
2254
+ dragRef.withBoundaryElement(this.dom.root);
2255
+ dragRef.beforeStarted.subscribe(() => {
2256
+ handle.style.pointerEvents = 'none';
2257
+ if (this.barDragRef) {
2258
+ this.barDragRef.disabled = true;
2259
+ }
2260
+ this.createLinkDraggingLine();
2261
+ this.dragContainer.emitLinkDragStarted(isBefore ? 'target' : 'source', this.item);
2262
+ });
2263
+ dragRef.moved.subscribe(() => {
2264
+ const positions = this.calcLinkLinePositions(handle, isBefore);
2265
+ this.linkDraggingLine.setAttribute('x1', positions.x1.toString());
2266
+ this.linkDraggingLine.setAttribute('y1', positions.y1.toString());
2267
+ this.linkDraggingLine.setAttribute('x2', positions.x2.toString());
2268
+ this.linkDraggingLine.setAttribute('y2', positions.y2.toString());
2269
+ });
2270
+ dragRef.ended.subscribe((event) => {
2271
+ event.source.reset();
2272
+ handle.style.pointerEvents = '';
2273
+ if (this.barDragRef) {
2274
+ this.barDragRef.disabled = false;
2275
+ }
2276
+ this.barElement.classList.remove(activeClass);
2277
+ this.destroyLinkDraggingLine();
2278
+ this.dragContainer.emitLinkDragEnded();
2279
+ });
2280
+ dragRefs.push(dragRef);
2281
+ });
2282
+ return dragRefs;
2283
+ }
2284
+ openDragBackdrop(dragElement, start, end) {
2285
+ const dragMaskElement = this.dom.root.querySelector('.gantt-drag-mask');
2286
+ const dragBackdropElement = this.dom.root.querySelector('.gantt-drag-backdrop');
2287
+ const rootRect = this.dom.root.getBoundingClientRect();
2288
+ const dragRect = dragElement.getBoundingClientRect();
2289
+ const left = dragRect.left - rootRect.left - this.dom.side.clientWidth;
2290
+ const width = dragRect.right - dragRect.left;
2291
+ dragMaskElement.style.left = left + 'px';
2292
+ dragMaskElement.style.width = width + 'px';
2293
+ dragMaskElement.querySelector('.start').innerHTML = start.format('MM-dd');
2294
+ dragMaskElement.querySelector('.end').innerHTML = end.format('MM-dd');
2295
+ dragMaskElement.style.display = 'block';
2296
+ dragBackdropElement.style.display = 'block';
2297
+ }
2298
+ closeDragBackdrop() {
2299
+ const dragMaskElement = this.dom.root.querySelector('.gantt-drag-mask');
2300
+ const dragBackdropElement = this.dom.root.querySelector('.gantt-drag-backdrop');
2301
+ dragMaskElement.style.display = 'none';
2302
+ dragBackdropElement.style.display = 'none';
2303
+ }
2304
+ setDraggingStyles() {
2305
+ this.barElement.style.pointerEvents = 'none';
2306
+ this.barElement.classList.add('gantt-bar-draggable-drag');
2307
+ }
2308
+ clearDraggingStyles() {
2309
+ this.barElement.style.pointerEvents = '';
2310
+ this.barElement.classList.remove('gantt-bar-draggable-drag');
2311
+ }
2312
+ calcLinkLinePositions(target, isBefore) {
2313
+ const rootRect = this.dom.root.getBoundingClientRect();
2314
+ const targetRect = target.getBoundingClientRect();
2315
+ const layerRect = target.parentElement.parentElement.getBoundingClientRect();
2316
+ return {
2317
+ x1: layerRect.left + (isBefore ? 0 : layerRect.width) - rootRect.left,
2318
+ y1: layerRect.top + layerRect.height / 2 - rootRect.top,
2319
+ x2: targetRect.left - rootRect.left + targetRect.width / 2,
2320
+ y2: targetRect.top - rootRect.top + targetRect.height / 2
2321
+ };
2322
+ }
2323
+ createLinkDraggingLine() {
2324
+ if (!this.linkDraggingLine) {
2325
+ const svgElement = createSvgElement('svg', 'gantt-link-drag-container');
2326
+ const linElement = createSvgElement('line', 'link-dragging-line');
2327
+ svgElement.appendChild(linElement);
2328
+ this.dom.root.appendChild(svgElement);
2329
+ this.linkDraggingLine = linElement;
2330
+ }
2331
+ }
2332
+ destroyLinkDraggingLine() {
2333
+ if (this.linkDraggingLine) {
2334
+ this.linkDraggingLine.parentElement.remove();
2335
+ this.linkDraggingLine = null;
2336
+ }
2337
+ }
2338
+ createDrags(elementRef, item, ganttUpper) {
2339
+ this.item = item;
2340
+ this.barElement = elementRef.nativeElement;
2341
+ this.ganttUpper = ganttUpper;
2342
+ if (!item.draggable || (this.dragDisabled && this.linkDragDisabled)) {
2343
+ return;
2344
+ }
2345
+ else {
2346
+ this.createMouseEvents();
2347
+ if (!this.dragDisabled) {
2348
+ const dragRef = this.createBarDrag();
2349
+ const dragHandlesRefs = this.createBarHandleDrags();
2350
+ this.dragRefs.push(dragRef, ...dragHandlesRefs);
2351
+ }
2352
+ if (!this.linkDragDisabled) {
2353
+ const linkDragRefs = this.createLinkHandleDrags();
2354
+ this.dragRefs.push(...linkDragRefs);
2355
+ }
2356
+ }
2357
+ }
2358
+ ngOnDestroy() {
2359
+ this.closeDragBackdrop();
2360
+ this.dragRefs.forEach((dragRef) => dragRef.dispose());
2361
+ this.destroy$.next();
2362
+ this.destroy$.complete();
2363
+ }
2364
+ }
2365
+ GanttBarDrag.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttBarDrag, deps: [{ token: i1.DragDrop }, { token: GanttDomService }, { token: GanttDragContainer }], target: i0.ɵɵFactoryTarget.Injectable });
2366
+ GanttBarDrag.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttBarDrag });
2367
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttBarDrag, decorators: [{
2368
+ type: Injectable
2369
+ }], ctorParameters: function () { return [{ type: i1.DragDrop }, { type: GanttDomService }, { type: GanttDragContainer }]; } });
2370
+
2371
+ function linearGradient(sideOrCorner, color, stop) {
2372
+ return `linear-gradient(${sideOrCorner},${color} 0%,${stop} 40%)`;
2373
+ }
2374
+ class NgxGanttBarComponent extends GanttItemUpper {
2375
+ constructor(dragContainer, drag, elementRef, ganttUpper) {
2376
+ super(elementRef, ganttUpper);
2377
+ this.dragContainer = dragContainer;
2378
+ this.drag = drag;
2379
+ this.ganttUpper = ganttUpper;
2380
+ this.barClick = new EventEmitter();
2381
+ this.ganttItemClass = true;
2382
+ this.color = 'red';
2383
+ }
2384
+ ngOnInit() {
2385
+ super.onInit();
2386
+ this.dragContainer.dragEnded.pipe(takeUntil(this.unsubscribe$)).subscribe(() => {
2387
+ this.setContentBackground();
2388
+ });
2389
+ }
2390
+ ngAfterViewInit() {
2391
+ this.drag.createDrags(this.elementRef, this.item, this.ganttUpper);
2392
+ this.setContentBackground();
2393
+ }
2394
+ ngOnChanges() {
2395
+ super.onChanges();
2396
+ }
2397
+ onBarClick(event) {
2398
+ this.barClick.emit({ event, item: this.item.origin });
2399
+ }
2400
+ setContentBackground() {
2401
+ const contentElement = this.contentElementRef.nativeElement;
2402
+ const color = this.item.color || barBackground;
2403
+ const style = this.item.barStyle || {};
2404
+ if (this.item.origin.start && this.item.origin.end) {
2405
+ style.background = color;
2406
+ style.borderRadius = '';
2407
+ }
2408
+ if (this.item.origin.start && !this.item.origin.end) {
2409
+ style.background = linearGradient('to left', hexToRgb(color, 0.55), hexToRgb(color, 1));
2410
+ style.borderRadius = '4px 12.5px 12.5px 4px';
2411
+ }
2412
+ if (!this.item.origin.start && this.item.origin.end) {
2413
+ style.background = linearGradient('to right', hexToRgb(color, 0.55), hexToRgb(color, 1));
2414
+ style.borderRadius = '12.5px 4px 4px 12.5px';
2415
+ }
2416
+ if (this.item.progress >= 0) {
2417
+ const contentProgressElement = contentElement.querySelector('.gantt-bar-content-progress');
2418
+ style.background = hexToRgb(color, 0.3);
2419
+ style.borderRadius = '';
2420
+ contentProgressElement.style.background = color;
2421
+ }
2422
+ for (const key in style) {
2423
+ if (style.hasOwnProperty(key)) {
2424
+ contentElement.style[key] = style[key];
2425
+ }
2426
+ }
2427
+ }
2428
+ stopPropagation(event) {
2429
+ event.stopPropagation();
2430
+ }
2431
+ ngOnDestroy() {
2432
+ super.onDestroy();
2433
+ }
2434
+ }
2435
+ NgxGanttBarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttBarComponent, deps: [{ token: GanttDragContainer }, { token: GanttBarDrag }, { token: i0.ElementRef }, { token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
2436
+ NgxGanttBarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: NgxGanttBarComponent, selector: "ngx-gantt-bar,gantt-bar", outputs: { barClick: "barClick" }, host: { properties: { "class.gantt-bar": "this.ganttItemClass" } }, providers: [GanttBarDrag], viewQueries: [{ propertyName: "contentElementRef", first: true, predicate: ["content"], descendants: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<div class=\"gantt-bar-layer\">\n <div *ngIf=\"item.draggable && ganttUpper.draggable\" class=\"drag-handles\">\n <ng-container>\n <span class=\"handle\" (mousedown)=\"stopPropagation($event)\"></span>\n <span class=\"handle\" (mousedown)=\"stopPropagation($event)\"></span>\n </ng-container>\n </div>\n <div *ngIf=\"item.linkable && ganttUpper.linkable\" class=\"link-handles\">\n <span class=\"handle\"><span class=\"point\"></span></span>\n <span class=\"handle\"> <span class=\"point\"></span></span>\n </div>\n</div>\n<div class=\"gantt-bar-border\"></div>\n<div #content class=\"gantt-bar-content\" (click)=\"onBarClick($event)\">\n <div class=\"gantt-bar-content-progress\" *ngIf=\"item.progress >= 0\" [style.width.%]=\"item.progress * 100\"></div>\n <ng-template [ngTemplateOutlet]=\"template\" [ngTemplateOutletContext]=\"{ item: item.origin, refs: item.refs }\"></ng-template>\n</div>\n", directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }] });
2437
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttBarComponent, decorators: [{
2438
+ type: Component,
2439
+ args: [{
2440
+ selector: 'ngx-gantt-bar,gantt-bar',
2441
+ templateUrl: './bar.component.html',
2442
+ providers: [GanttBarDrag]
2443
+ }]
2444
+ }], ctorParameters: function () { return [{ type: GanttDragContainer }, { type: GanttBarDrag }, { type: i0.ElementRef }, { type: GanttUpper, decorators: [{
2445
+ type: Inject,
2446
+ args: [GANTT_UPPER_TOKEN]
2447
+ }] }]; }, propDecorators: { barClick: [{
2448
+ type: Output
2449
+ }], contentElementRef: [{
2450
+ type: ViewChild,
2451
+ args: ['content']
2452
+ }], ganttItemClass: [{
2453
+ type: HostBinding,
2454
+ args: ['class.gantt-bar']
2455
+ }] } });
2456
+
2457
+ class GanttMainComponent {
2458
+ constructor(ganttUpper) {
2459
+ this.ganttUpper = ganttUpper;
2460
+ this.barClick = new EventEmitter();
2461
+ this.lineClick = new EventEmitter();
2462
+ this.ganttMainClass = true;
2463
+ }
2464
+ ngOnInit() { }
2465
+ trackBy(index, item) {
2466
+ return item.id || index;
2467
+ }
2468
+ }
2469
+ GanttMainComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttMainComponent, deps: [{ token: GANTT_UPPER_TOKEN }], target: i0.ɵɵFactoryTarget.Component });
2470
+ GanttMainComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: GanttMainComponent, selector: "gantt-main", inputs: { groups: "groups", items: "items", groupHeaderTemplate: "groupHeaderTemplate", itemTemplate: "itemTemplate", barTemplate: "barTemplate", rangeTemplate: "rangeTemplate" }, outputs: { barClick: "barClick", lineClick: "lineClick" }, host: { properties: { "class.gantt-main-container": "this.ganttMainClass" } }, ngImport: i0, template: "<gantt-links-overlay [groups]=\"groups\" [items]=\"items\" (lineClick)=\"lineClick.emit($event)\"></gantt-links-overlay>\n<!-- groups -->\n<div class=\"gantt-main-groups\" *ngIf=\"groups && groups.length > 0; else itemsTemplate\" [style.width.px]=\"ganttUpper.view.width\">\n <ng-container *ngFor=\"let group of groups; trackBy: trackBy\">\n <div class=\"gantt-group\" [ngClass]=\"group.class\">\n <ng-template [ngTemplateOutlet]=\"groupHeaderTemplate\" [ngTemplateOutletContext]=\"{ group: group }\"></ng-template>\n </div>\n <div *ngIf=\"group.expanded\" class=\"gantt-items\">\n <ng-template [ngTemplateOutlet]=\"ganttItems\" [ngTemplateOutletContext]=\"{ items: group.items }\"></ng-template>\n </div>\n </ng-container>\n</div>\n<!-- items -->\n<ng-template #itemsTemplate>\n <div class=\"gantt-main-items\" [style.width.px]=\"ganttUpper.view.width\">\n <ng-template [ngTemplateOutlet]=\"ganttItems\" [ngTemplateOutletContext]=\"{ items: items }\"></ng-template>\n </div>\n</ng-template>\n\n<ng-template #ganttItems let-items=\"items\">\n <ng-container *ngFor=\"let item of items; trackBy: trackBy\">\n <div class=\"gantt-item\" [style.height.px]=\"ganttUpper.styles.lineHeight\">\n <ng-container *ngIf=\"item.type | isGanttCustomItem\">\n <ng-template [ngTemplateOutlet]=\"itemTemplate\" [ngTemplateOutletContext]=\"{ item: item.origin, refs: item.refs }\"></ng-template>\n </ng-container>\n <gantt-range *ngIf=\"item.type | isGanttRangeItem\" [template]=\"rangeTemplate\" [item]=\"item\"></gantt-range>\n <gantt-bar *ngIf=\"item.type | isGanttBarItem\" [item]=\"item\" [template]=\"barTemplate\" (barClick)=\"barClick.emit($event)\"></gantt-bar>\n </div>\n <ng-template\n *ngIf=\"item.children && item.expanded\"\n [ngTemplateOutlet]=\"ganttItems\"\n [ngTemplateOutletContext]=\"{ items: item.children }\"\n ></ng-template>\n </ng-container>\n</ng-template>\n", components: [{ type: GanttLinksComponent, selector: "gantt-links-overlay", inputs: ["groups", "items"], outputs: ["lineClick"] }, { type: NgxGanttRangeComponent, selector: "ngx-gantt-range,gantt-range" }, { type: NgxGanttBarComponent, selector: "ngx-gantt-bar,gantt-bar", outputs: ["barClick"] }], directives: [{ type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }], pipes: { "isGanttCustomItem": IsGanttCustomItemPipe, "isGanttRangeItem": IsGanttRangeItemPipe, "isGanttBarItem": IsGanttBarItemPipe } });
2471
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: GanttMainComponent, decorators: [{
2472
+ type: Component,
2473
+ args: [{
2474
+ selector: 'gantt-main',
2475
+ templateUrl: './gantt-main.component.html'
2476
+ }]
2477
+ }], ctorParameters: function () { return [{ type: GanttUpper, decorators: [{
2478
+ type: Inject,
2479
+ args: [GANTT_UPPER_TOKEN]
2480
+ }] }]; }, propDecorators: { groups: [{
2481
+ type: Input
2482
+ }], items: [{
2483
+ type: Input
2484
+ }], groupHeaderTemplate: [{
2485
+ type: Input
2486
+ }], itemTemplate: [{
2487
+ type: Input
2488
+ }], barTemplate: [{
2489
+ type: Input
2490
+ }], rangeTemplate: [{
2491
+ type: Input
2492
+ }], barClick: [{
2493
+ type: Output
2494
+ }], lineClick: [{
2495
+ type: Output
2496
+ }], ganttMainClass: [{
2497
+ type: HostBinding,
2498
+ args: ['class.gantt-main-container']
2499
+ }] } });
2500
+
2501
+ class NgxGanttComponent extends GanttUpper {
2502
+ constructor(elementRef, cdr, ngZone, config) {
2503
+ super(elementRef, cdr, ngZone, config);
2504
+ this.maxLevel = 2;
2505
+ this.linkDragStarted = new EventEmitter();
2506
+ this.linkDragEnded = new EventEmitter();
2507
+ this.lineClick = new EventEmitter();
2508
+ this.ngUnsubscribe$ = new Subject();
2509
+ this.sideTableWidth = sideWidth;
2510
+ }
2511
+ ngOnInit() {
2512
+ super.onInit();
2513
+ this.ngZone.onStable.pipe(take(1)).subscribe(() => {
2514
+ this.dragContainer.linkDragStarted.pipe(takeUntil(this.ngUnsubscribe$)).subscribe((event) => {
2515
+ this.linkDragStarted.emit(event);
2516
+ });
2517
+ this.dragContainer.linkDragEnded.pipe(takeUntil(this.ngUnsubscribe$)).subscribe((event) => {
2518
+ this.linkDragEnded.emit(event);
2519
+ });
2520
+ });
2521
+ }
2522
+ ngAfterViewInit() {
2523
+ this.columns.changes.pipe(startWith(true), takeUntil(this.ngUnsubscribe$)).subscribe(() => {
2524
+ this.columns.forEach((column) => {
2525
+ if (!column.columnWidth) {
2526
+ column.columnWidth = coerceCssPixelValue(defaultColumnWidth);
2527
+ }
2528
+ });
2529
+ this.cdr.detectChanges();
2530
+ });
2531
+ }
2532
+ ngOnChanges(changes) {
2533
+ super.onChanges(changes);
2534
+ }
2535
+ expandChildren(item) {
2536
+ if (!item.expanded) {
2537
+ item.setExpand(true);
2538
+ if (this.async && this.childrenResolve && item.children.length === 0) {
2539
+ item.loading = true;
2540
+ this.childrenResolve(item.origin)
2541
+ .pipe(take(1), finalize(() => {
2542
+ item.loading = false;
2543
+ this.expandChange.emit();
2544
+ this.cdr.detectChanges();
2545
+ }))
2546
+ .subscribe((items) => {
2547
+ item.addChildren(items);
2548
+ this.computeItemsRefs(...item.children);
2549
+ });
2550
+ }
2551
+ else {
2552
+ this.computeItemsRefs(...item.children);
2553
+ this.expandChange.emit();
2554
+ }
2555
+ }
2556
+ else {
2557
+ item.setExpand(false);
2558
+ this.expandChange.emit();
2559
+ }
2560
+ }
2561
+ ngOnDestroy() {
2562
+ super.onDestroy();
2563
+ }
2564
+ }
2565
+ NgxGanttComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttComponent, deps: [{ token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: GANTT_GLOBAL_CONFIG }], target: i0.ɵɵFactoryTarget.Component });
2566
+ NgxGanttComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.2", type: NgxGanttComponent, selector: "ngx-gantt", inputs: { maxLevel: "maxLevel", async: "async", childrenResolve: "childrenResolve", linkable: "linkable" }, outputs: { linkDragStarted: "linkDragStarted", linkDragEnded: "linkDragEnded", lineClick: "lineClick" }, providers: [
2567
+ {
2568
+ provide: GANTT_UPPER_TOKEN,
2569
+ useExisting: NgxGanttComponent
2570
+ },
2571
+ {
2572
+ provide: GANTT_ABSTRACT_TOKEN,
2573
+ useExisting: forwardRef(() => NgxGanttComponent)
2574
+ }
2575
+ ], queries: [{ propertyName: "table", first: true, predicate: NgxGanttTableComponent, descendants: true }, { propertyName: "tableEmptyTemplate", first: true, predicate: ["tableEmpty"], descendants: true, static: true }, { propertyName: "columns", predicate: NgxGanttTableColumnComponent, descendants: true }], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<ngx-gantt-root>\n <ng-template #sideTemplate>\n <gantt-table [groups]=\"groups\" [items]=\"items\" [columns]=\"columns\" [groupTemplate]=\"groupTemplate\" [emptyTemplate]=\"tableEmptyTemplate\"></gantt-table>\n </ng-template>\n <ng-template #mainTemplate>\n <gantt-main\n [groups]=\"groups\"\n [items]=\"items\"\n [groupHeaderTemplate]=\"groupHeaderTemplate\"\n [itemTemplate]=\"itemTemplate\"\n [barTemplate]=\"barTemplate\"\n [rangeTemplate]=\"rangeTemplate\"\n (barClick)=\"barClick.emit($event)\"\n (lineClick)=\"lineClick.emit($event)\"\n >\n </gantt-main>\n </ng-template>\n</ngx-gantt-root>\n", components: [{ type: NgxGanttRootComponent, selector: "ngx-gantt-root", inputs: ["sideWidth"] }, { type: GanttTableComponent, selector: "gantt-table", inputs: ["groups", "items", "columns", "groupTemplate", "emptyTemplate"] }, { type: GanttMainComponent, selector: "gantt-main", inputs: ["groups", "items", "groupHeaderTemplate", "itemTemplate", "barTemplate", "rangeTemplate"], outputs: ["barClick", "lineClick"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
2576
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttComponent, decorators: [{
2577
+ type: Component,
2578
+ args: [{
2579
+ selector: 'ngx-gantt',
2580
+ templateUrl: './gantt.component.html',
2581
+ changeDetection: ChangeDetectionStrategy.OnPush,
2582
+ providers: [
2583
+ {
2584
+ provide: GANTT_UPPER_TOKEN,
2585
+ useExisting: NgxGanttComponent
2586
+ },
2587
+ {
2588
+ provide: GANTT_ABSTRACT_TOKEN,
2589
+ useExisting: forwardRef(() => NgxGanttComponent)
2590
+ }
2591
+ ]
2592
+ }]
2593
+ }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: i0.NgZone }, { type: undefined, decorators: [{
2594
+ type: Inject,
2595
+ args: [GANTT_GLOBAL_CONFIG]
2596
+ }] }]; }, propDecorators: { maxLevel: [{
2597
+ type: Input
2598
+ }], async: [{
2599
+ type: Input
2600
+ }], childrenResolve: [{
2601
+ type: Input
2602
+ }], linkable: [{
2603
+ type: Input
2604
+ }], linkDragStarted: [{
2605
+ type: Output
2606
+ }], linkDragEnded: [{
2607
+ type: Output
2608
+ }], lineClick: [{
2609
+ type: Output
2610
+ }], table: [{
2611
+ type: ContentChild,
2612
+ args: [NgxGanttTableComponent]
2613
+ }], columns: [{
2614
+ type: ContentChildren,
2615
+ args: [NgxGanttTableColumnComponent, { descendants: true }]
2616
+ }], tableEmptyTemplate: [{
2617
+ type: ContentChild,
2618
+ args: ['tableEmpty', { static: true }]
2619
+ }] } });
2620
+
2621
+ class NgxGanttModule {
2622
+ }
2623
+ NgxGanttModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2624
+ NgxGanttModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttModule, declarations: [NgxGanttComponent,
2625
+ NgxGanttTableComponent,
2626
+ NgxGanttTableColumnComponent,
2627
+ GanttTableComponent,
2628
+ GanttMainComponent,
2629
+ GanttCalendarComponent,
2630
+ GanttLinksComponent,
2631
+ NgxGanttBarComponent,
2632
+ GanttIconComponent,
2633
+ GanttDragBackdropComponent,
2634
+ NgxGanttRangeComponent,
2635
+ NgxGanttRootComponent,
2636
+ IsGanttRangeItemPipe,
2637
+ IsGanttBarItemPipe,
2638
+ IsGanttCustomItemPipe], imports: [CommonModule, DragDropModule], exports: [NgxGanttComponent,
2639
+ NgxGanttTableComponent,
2640
+ NgxGanttTableColumnComponent,
2641
+ NgxGanttRootComponent,
2642
+ NgxGanttBarComponent,
2643
+ NgxGanttRangeComponent] });
2644
+ NgxGanttModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttModule, providers: [
2645
+ {
2646
+ provide: GANTT_GLOBAL_CONFIG,
2647
+ useValue: defaultConfig
2648
+ }
2649
+ ], imports: [[CommonModule, DragDropModule]] });
2650
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.2", ngImport: i0, type: NgxGanttModule, decorators: [{
2651
+ type: NgModule,
2652
+ args: [{
2653
+ imports: [CommonModule, DragDropModule],
2654
+ exports: [
2655
+ NgxGanttComponent,
2656
+ NgxGanttTableComponent,
2657
+ NgxGanttTableColumnComponent,
2658
+ NgxGanttRootComponent,
2659
+ NgxGanttBarComponent,
2660
+ NgxGanttRangeComponent
2661
+ ],
2662
+ declarations: [
2663
+ NgxGanttComponent,
2664
+ NgxGanttTableComponent,
2665
+ NgxGanttTableColumnComponent,
2666
+ GanttTableComponent,
2667
+ GanttMainComponent,
2668
+ GanttCalendarComponent,
2669
+ GanttLinksComponent,
2670
+ NgxGanttBarComponent,
2671
+ GanttIconComponent,
2672
+ GanttDragBackdropComponent,
2673
+ NgxGanttRangeComponent,
2674
+ NgxGanttRootComponent,
2675
+ IsGanttRangeItemPipe,
2676
+ IsGanttBarItemPipe,
2677
+ IsGanttCustomItemPipe
2678
+ ],
2679
+ providers: [
2680
+ {
2681
+ provide: GANTT_GLOBAL_CONFIG,
2682
+ useValue: defaultConfig
2683
+ }
2684
+ ]
2685
+ }]
2686
+ }] });
2687
+
2688
+ /*
2689
+ * Public API Surface of gantt
2690
+ */
2691
+
2692
+ /**
2693
+ * Generated bundle index. Do not edit.
2694
+ */
2695
+
2696
+ export { GANTT_GLOBAL_CONFIG, GANTT_UPPER_TOKEN, GanttBarClickEvent, GanttDate, GanttDatePoint, GanttDragEvent, GanttGroupInternal, GanttItemInternal, GanttItemType, GanttItemUpper, GanttLineClickEvent, GanttLinkDragEvent, GanttLoadOnScrollEvent, GanttPrintService, GanttTableEvent, GanttUpper, GanttView, GanttViewType, IsGanttBarItemPipe, IsGanttCustomItemPipe, IsGanttRangeItemPipe, NgxGanttBarComponent, NgxGanttComponent, NgxGanttModule, NgxGanttRangeComponent, NgxGanttRootComponent, NgxGanttTableColumnComponent, NgxGanttTableComponent, defaultConfig, primaryDatePointTop, secondaryDatePointTop };
2697
+ //# sourceMappingURL=worktile-gantt.js.map