@worktile/gantt 12.0.1 → 12.0.2

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