@operato/gantt 2.0.0-beta.5 → 7.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +107 -0
  2. package/dist/src/gantt-chart-controller.d.ts +32 -0
  3. package/dist/src/gantt-chart-controller.js +395 -0
  4. package/dist/src/gantt-chart-controller.js.map +1 -0
  5. package/dist/src/locales.d.ts +52 -0
  6. package/dist/src/locales.js +79 -0
  7. package/dist/src/locales.js.map +1 -0
  8. package/dist/src/ox-gantt-chart.d.ts +11 -20
  9. package/dist/src/ox-gantt-chart.js +141 -435
  10. package/dist/src/ox-gantt-chart.js.map +1 -1
  11. package/dist/src/ox-gantt-resize-splitter.d.ts +2 -3
  12. package/dist/src/ox-gantt-resize-splitter.js +15 -22
  13. package/dist/src/ox-gantt-resize-splitter.js.map +1 -1
  14. package/dist/src/ox-gantt.d.ts +17 -3
  15. package/dist/src/ox-gantt.js +169 -29
  16. package/dist/src/ox-gantt.js.map +1 -1
  17. package/dist/src/ox-task-tooltip.d.ts +12 -0
  18. package/dist/src/ox-task-tooltip.js +132 -0
  19. package/dist/src/ox-task-tooltip.js.map +1 -0
  20. package/dist/src/types.d.ts +11 -4
  21. package/dist/src/types.js.map +1 -1
  22. package/dist/src/utils.d.ts +3 -3
  23. package/dist/src/utils.js.map +1 -1
  24. package/dist/stories/ox-gantt.stories.d.ts +19 -2
  25. package/dist/stories/ox-gantt.stories.js +104 -90
  26. package/dist/stories/ox-gantt.stories.js.map +1 -1
  27. package/dist/tsconfig.tsbuildinfo +1 -1
  28. package/package.json +7 -4
  29. package/src/gantt-chart-controller.ts +473 -0
  30. package/src/locales.ts +78 -0
  31. package/src/ox-gantt-chart.ts +151 -484
  32. package/src/ox-gantt-resize-splitter.ts +18 -25
  33. package/src/ox-gantt.ts +174 -31
  34. package/src/ox-task-tooltip.ts +120 -0
  35. package/src/types.ts +13 -5
  36. package/src/utils.ts +4 -4
  37. package/stories/ox-gantt.stories.ts +118 -91
  38. package/themes/grist-theme.css +0 -2
  39. package/translations/en.json +11 -1
  40. package/translations/ja.json +11 -1
  41. package/translations/ko.json +11 -1
  42. package/translations/ms.json +11 -1
  43. package/translations/zh.json +11 -1
  44. package/dist/src/locale.d.ts +0 -1
  45. package/dist/src/locale.js +0 -49
  46. package/dist/src/locale.js.map +0 -1
  47. package/src/locale.ts +0 -51
package/CHANGELOG.md CHANGED
@@ -3,6 +3,113 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [7.0.0-rc.0](https://github.com/hatiolab/operato/compare/v2.0.0-beta.35...v7.0.0-rc.0) (2024-06-21)
7
+
8
+
9
+ ### :bug: Bug Fix
10
+
11
+ * styles using material-design token ([1bfca4e](https://github.com/hatiolab/operato/commit/1bfca4e00834db5c6ce4514e858b7637916dfbd6))
12
+
13
+
14
+
15
+ ## [2.0.0-beta.35](https://github.com/hatiolab/operato/compare/v2.0.0-beta.34...v2.0.0-beta.35) (2024-06-19)
16
+
17
+ **Note:** Version bump only for package @operato/gantt
18
+
19
+
20
+
21
+
22
+
23
+ ## [2.0.0-beta.23](https://github.com/hatiolab/operato/compare/v2.0.0-beta.22...v2.0.0-beta.23) (2024-06-13)
24
+
25
+
26
+ ### :bug: Bug Fix
27
+
28
+ * export package.json ([538e6e0](https://github.com/hatiolab/operato/commit/538e6e050f5a3d77b8ed805968d66a9093a7d5e9))
29
+
30
+
31
+
32
+ ## [2.0.0-beta.22](https://github.com/hatiolab/operato/compare/v2.0.0-beta.21...v2.0.0-beta.22) (2024-06-13)
33
+
34
+
35
+ ### :bug: Bug Fix
36
+
37
+ * operato tag for all package.json ([2334960](https://github.com/hatiolab/operato/commit/2334960db2186ade87ee590796a269fe5f5e9419))
38
+
39
+
40
+
41
+ ## [2.0.0-beta.20](https://github.com/hatiolab/operato/compare/v2.0.0-beta.19...v2.0.0-beta.20) (2024-06-11)
42
+
43
+
44
+ ### :bug: Bug Fix
45
+
46
+ * support function for defaultValue in ox-property-editor ([efe7590](https://github.com/hatiolab/operato/commit/efe7590a41d223d92ef7b96c3e1b49c3691599d0))
47
+
48
+
49
+
50
+ ## [2.0.0-beta.19](https://github.com/hatiolab/operato/compare/v2.0.0-beta.18...v2.0.0-beta.19) (2024-06-11)
51
+
52
+
53
+ ### :rocket: New Features
54
+
55
+ * gantt chart ([3daba7f](https://github.com/hatiolab/operato/commit/3daba7fbd8c270dc01c72b8d6602de75b370d59e))
56
+
57
+
58
+
59
+ ## [2.0.0-beta.18](https://github.com/hatiolab/operato/compare/v2.0.0-beta.17...v2.0.0-beta.18) (2024-06-11)
60
+
61
+
62
+ ### :rocket: New Features
63
+
64
+ * ox-input-table-column-config ([39be540](https://github.com/hatiolab/operato/commit/39be54054e210f6ce5d55499dffe78f4426d0d76))
65
+
66
+
67
+
68
+ ## [2.0.0-beta.17](https://github.com/hatiolab/operato/compare/v2.0.0-beta.16...v2.0.0-beta.17) (2024-06-11)
69
+
70
+
71
+ ### :rocket: New Features
72
+
73
+ * ox-input-table-column-config ([0b84541](https://github.com/hatiolab/operato/commit/0b84541ec63fc71538292abd9e81d8c38baee44c))
74
+
75
+
76
+
77
+ ## [2.0.0-beta.15](https://github.com/hatiolab/operato/compare/v2.0.0-beta.14...v2.0.0-beta.15) (2024-06-10)
78
+
79
+
80
+ ### :bug: Bug Fix
81
+
82
+ * gantt 의 그리드라인이 공백이 없도록 함 ([9cd6f33](https://github.com/hatiolab/operato/commit/9cd6f335b21f6383ae41e6f15df733ea81f4fd74))
83
+ * revert i18next version ([75975f7](https://github.com/hatiolab/operato/commit/75975f7295febfbbb2d02774249ca2b742019ba9))
84
+ * splitter는 마우스 움직이는 범위를 gannt 안에서만 허용하도록 함 ([dd2164e](https://github.com/hatiolab/operato/commit/dd2164e01bd8544e6a66d3e5e892609dd4fbea77))
85
+
86
+
87
+ ### :rocket: New Features
88
+
89
+ * gantt chart taskbar tooltip ([758ecd4](https://github.com/hatiolab/operato/commit/758ecd4b7d6b2b77b98cf13d6e4b36c822f4ff12))
90
+ * gantt chart taskbar tooltip 위치 보정 ([1b36b40](https://github.com/hatiolab/operato/commit/1b36b4015c501ee492bf1b1d22355edcce976033))
91
+ * make gantt table section column mergable ([02a91ca](https://github.com/hatiolab/operato/commit/02a91ca89c40156ba43d4db221dc72e7ceccf914))
92
+ * make gantt table section column mergable ([f4dc900](https://github.com/hatiolab/operato/commit/f4dc90022d9dbae01ef8bc8f58d66ed0a0b561a6))
93
+
94
+
95
+
96
+ ## [2.0.0-beta.14](https://github.com/hatiolab/operato/compare/v2.0.0-beta.13...v2.0.0-beta.14) (2024-06-10)
97
+
98
+
99
+ ### :bug: Bug Fix
100
+
101
+ * gantt ([2ba0fc3](https://github.com/hatiolab/operato/commit/2ba0fc3b6928502c5667e59178391affa7b73294))
102
+
103
+
104
+
105
+ ## [2.0.0-beta.13](https://github.com/hatiolab/operato/compare/v2.0.0-beta.12...v2.0.0-beta.13) (2024-06-09)
106
+
107
+ **Note:** Version bump only for package @operato/gantt
108
+
109
+
110
+
111
+
112
+
6
113
  ## [2.0.0-beta.5](https://github.com/hatiolab/operato/compare/v2.0.0-beta.4...v2.0.0-beta.5) (2024-06-04)
7
114
 
8
115
 
@@ -0,0 +1,32 @@
1
+ import { LitElement, ReactiveController, ReactiveControllerHost } from 'lit';
2
+ import * as d3 from 'd3';
3
+ import { TimeScale, Task, TaskTag } from './types';
4
+ import { OxTaskTooltip } from './ox-task-tooltip';
5
+ export declare class GanttChartController implements ReactiveController {
6
+ private host;
7
+ private fromTime;
8
+ private toTime;
9
+ private totalDays;
10
+ private _timeScale?;
11
+ private touchStartY?;
12
+ private scrollStartY?;
13
+ baseWidth: number;
14
+ level: TimeScale;
15
+ selectedTaskId?: string;
16
+ tasks: Task[];
17
+ extendGridLines: boolean;
18
+ constructor(host: ReactiveControllerHost & LitElement, fromDate: string, toDate: string, axisScale: TimeScale);
19
+ hostConnected(): void;
20
+ get timeScale(): d3.ScaleTime<number, number, never>;
21
+ updateRange(fromDate: string, toDate: string): void;
22
+ setTasks(tasks: Task[]): void;
23
+ updateTimeScale(): void;
24
+ getChartWidth(): number;
25
+ getScale(): number;
26
+ drawAxes(svgHeader: SVGElement): void;
27
+ drawBody(svgBody: SVGElement, tooltip: OxTaskTooltip): void;
28
+ getTaskColor(tags: TaskTag[]): string;
29
+ handleWheelForBody(event: WheelEvent, container: HTMLDivElement): void;
30
+ handleTouchStartForBody(event: TouchEvent, container: HTMLDivElement): void;
31
+ handleTouchMoveForBody(event: TouchEvent, container: HTMLDivElement): void;
32
+ }
@@ -0,0 +1,395 @@
1
+ import * as d3 from 'd3';
2
+ export class GanttChartController {
3
+ constructor(host, fromDate, toDate, axisScale) {
4
+ this.baseWidth = 30;
5
+ this.tasks = [];
6
+ this.extendGridLines = false;
7
+ this.host = host;
8
+ this.fromTime = new Date(fromDate);
9
+ this.toTime = new Date(toDate);
10
+ this.level = axisScale;
11
+ this.totalDays = d3.timeDay.count(this.fromTime, d3.timeDay.offset(this.toTime, 1));
12
+ this.host.addController(this);
13
+ }
14
+ hostConnected() {
15
+ this.updateTimeScale();
16
+ }
17
+ get timeScale() {
18
+ if (!this._timeScale) {
19
+ this._timeScale = d3
20
+ .scaleTime()
21
+ .domain([d3.timeDay.floor(this.fromTime), d3.timeDay.offset(this.toTime, 1)])
22
+ .range([0, this.getChartWidth()]);
23
+ }
24
+ return this._timeScale;
25
+ }
26
+ updateRange(fromDate, toDate) {
27
+ this.fromTime = new Date(fromDate);
28
+ this.toTime = new Date(toDate);
29
+ this.totalDays = d3.timeDay.count(this.fromTime, d3.timeDay.offset(this.toTime, 1));
30
+ this._timeScale = undefined;
31
+ this.host.requestUpdate();
32
+ }
33
+ setTasks(tasks) {
34
+ this.tasks = tasks;
35
+ this.host.requestUpdate();
36
+ }
37
+ updateTimeScale() {
38
+ this.timeScale.range([0, this.getChartWidth()]);
39
+ }
40
+ getChartWidth() {
41
+ return (this.totalDays * this.baseWidth) / this.getScale();
42
+ }
43
+ getScale() {
44
+ if (this.level == 'quarter-week') {
45
+ return 7 / 2;
46
+ }
47
+ else if (this.level == 'year-month') {
48
+ return 30 / 2;
49
+ }
50
+ else if (this.level == 'year-quarter') {
51
+ return 90 / 2;
52
+ }
53
+ return 1;
54
+ }
55
+ drawAxes(svgHeader) {
56
+ const header = d3.select(svgHeader);
57
+ header.selectAll('*').remove();
58
+ header.attr('width', this.getChartWidth());
59
+ const addGridLines = (ticks, yStart, yEnd) => {
60
+ ticks.forEach(tick => {
61
+ const startX = this.timeScale(tick);
62
+ header
63
+ .append('line')
64
+ .attr('x1', startX)
65
+ .attr('x2', startX)
66
+ .attr('y1', yStart)
67
+ .attr('y2', yEnd)
68
+ .attr('stroke', 'var(--ox-gantt-color-gridlines, var(--md-sys-color-on-secondary-container))')
69
+ .attr('stroke-width', 1);
70
+ });
71
+ };
72
+ const centerLabel = (selection, tickInterval) => {
73
+ selection.selectAll('text').attr('transform', (d) => {
74
+ const tickIntervalWidth = this.timeScale(tickInterval.offset(d, 1)) - this.timeScale(d);
75
+ return `translate(${tickIntervalWidth / 2}, -2)`;
76
+ });
77
+ };
78
+ if (this.level === 'week-day') {
79
+ const weekAxis = d3
80
+ .axisTop(this.timeScale)
81
+ .ticks(d3.timeWeek.every(1))
82
+ .tickFormat(d3.timeFormat('%B %d'))
83
+ .tickSize(0);
84
+ const weekTicks = d3.timeWeek
85
+ .every(1)
86
+ .range(d3.timeWeek.floor(this.fromTime), d3.timeWeek.offset(this.toTime, 1));
87
+ addGridLines(weekTicks, 0, 20);
88
+ const weekAxisG = header
89
+ .append('g')
90
+ .classed('week-axis no-select md-typescale-label-small', true)
91
+ .attr('transform', `translate(0, 20)`)
92
+ .call(weekAxis);
93
+ centerLabel(weekAxisG, d3.timeWeek);
94
+ const dayAxis = d3
95
+ .axisTop(this.timeScale)
96
+ .ticks(d3.timeDay.every(1))
97
+ .tickFormat(d3.timeFormat('%d'))
98
+ .tickSize(0);
99
+ const dayTicks = d3.timeDay.every(1).range(d3.timeDay.floor(this.fromTime), d3.timeDay.offset(this.toTime, 1));
100
+ addGridLines(dayTicks, 20, 40);
101
+ const dayAxisG = header
102
+ .append('g')
103
+ .classed('day-axis no-select md-typescale-label-small', true)
104
+ .attr('transform', `translate(0, 40)`)
105
+ .call(dayAxis);
106
+ centerLabel(dayAxisG, d3.timeDay);
107
+ }
108
+ else if (this.level === 'quarter-week') {
109
+ const quarterAxis = d3
110
+ .axisTop(this.timeScale)
111
+ .ticks(d3.timeMonth.every(3))
112
+ .tickFormat(d3.timeFormat('%Y %b'))
113
+ .tickSize(0);
114
+ const quarterTicks = d3.timeMonth
115
+ .every(3)
116
+ .range(d3.timeMonth.floor(this.fromTime), d3.timeMonth.offset(this.toTime, 3));
117
+ addGridLines(quarterTicks, 0, 20);
118
+ const quarterAxisG = header
119
+ .append('g')
120
+ .classed('quarter-axis no-select md-typescale-label-small', true)
121
+ .attr('transform', `translate(0, 20)`)
122
+ .call(quarterAxis);
123
+ centerLabel(quarterAxisG, d3.timeMonth.every(3));
124
+ const weekAxis = d3
125
+ .axisTop(this.timeScale)
126
+ .ticks(d3.timeWeek.every(1))
127
+ .tickFormat(d3.timeFormat('%b %d'))
128
+ .tickSize(0);
129
+ const weekTicks = d3.timeWeek
130
+ .every(1)
131
+ .range(d3.timeWeek.floor(this.fromTime), d3.timeWeek.offset(this.toTime, 1));
132
+ addGridLines(weekTicks, 20, 40);
133
+ const weekAxisG = header
134
+ .append('g')
135
+ .classed('week-axis no-select md-typescale-label-small', true)
136
+ .attr('transform', `translate(0, 40)`)
137
+ .call(weekAxis);
138
+ centerLabel(weekAxisG, d3.timeWeek);
139
+ }
140
+ else if (this.level === 'year-month') {
141
+ const yearAxis = d3
142
+ .axisTop(this.timeScale)
143
+ .ticks(d3.timeYear.every(1))
144
+ .tickFormat(d3.timeFormat('%Y'))
145
+ .tickSize(0);
146
+ const yearTicks = d3.timeYear
147
+ .every(1)
148
+ .range(d3.timeYear.floor(this.fromTime), d3.timeYear.offset(this.toTime, 1));
149
+ addGridLines(yearTicks, 0, 20);
150
+ const yearAxisG = header
151
+ .append('g')
152
+ .classed('year-axis no-select md-typescale-label-small', true)
153
+ .attr('transform', `translate(0, 20)`)
154
+ .call(yearAxis);
155
+ centerLabel(yearAxisG, d3.timeYear.every(1));
156
+ const monthAxis = d3
157
+ .axisTop(this.timeScale)
158
+ .ticks(d3.timeMonth.every(1))
159
+ .tickFormat(d3.timeFormat('%b'))
160
+ .tickSize(0);
161
+ const monthTicks = d3.timeMonth
162
+ .every(1)
163
+ .range(d3.timeMonth.floor(this.fromTime), d3.timeMonth.offset(this.toTime, 1));
164
+ addGridLines(monthTicks, 20, 40);
165
+ const monthAxisG = header
166
+ .append('g')
167
+ .classed('month-axis no-select md-typescale-label-small', true)
168
+ .attr('transform', `translate(0, 40)`)
169
+ .call(monthAxis);
170
+ centerLabel(monthAxisG, d3.timeMonth.every(1));
171
+ }
172
+ else if (this.level === 'year-quarter') {
173
+ const yearAxis = d3
174
+ .axisTop(this.timeScale)
175
+ .ticks(d3.timeYear.every(1))
176
+ .tickFormat(d3.timeFormat('%Y'))
177
+ .tickSize(0);
178
+ const yearTicks = d3.timeYear
179
+ .every(1)
180
+ .range(d3.timeYear.floor(this.fromTime), d3.timeYear.offset(this.toTime, 1));
181
+ addGridLines(yearTicks, 0, 20);
182
+ const yearAxisG = header
183
+ .append('g')
184
+ .classed('year-axis no-select md-typescale-label-small', true)
185
+ .attr('transform', `translate(0, 20)`)
186
+ .call(yearAxis);
187
+ centerLabel(yearAxisG, d3.timeYear.every(1));
188
+ const quarterAxis = d3
189
+ .axisTop(this.timeScale)
190
+ .ticks(d3.timeMonth.every(3))
191
+ .tickFormat(d3.timeFormat('%Y %b'))
192
+ .tickSize(0);
193
+ const quarterTicks = d3.timeMonth
194
+ .every(3)
195
+ .range(d3.timeMonth.floor(this.fromTime), d3.timeMonth.offset(this.toTime, 3));
196
+ addGridLines(quarterTicks, 20, 40);
197
+ const quarterAxisG = header
198
+ .append('g')
199
+ .classed('quarter-axis no-select md-typescale-label-small', true)
200
+ .attr('transform', `translate(0, 40)`)
201
+ .call(quarterAxis);
202
+ centerLabel(quarterAxisG, d3.timeMonth.every(3));
203
+ }
204
+ }
205
+ drawBody(svgBody, tooltip) {
206
+ const body = d3.select(svgBody);
207
+ body.selectAll('*').remove();
208
+ body.attr('width', this.getChartWidth());
209
+ if (this.extendGridLines) {
210
+ const addGridLines = (ticks) => {
211
+ ticks.forEach(tick => {
212
+ const startX = this.timeScale(tick);
213
+ body
214
+ .append('line')
215
+ .attr('x1', startX)
216
+ .attr('x2', startX)
217
+ .attr('y1', 0)
218
+ .attr('y2', Number(svgBody.getBoundingClientRect().height) || 0)
219
+ .attr('stroke', 'var(--ox-gantt-color-gridlines, var(--md-sys-color-outline))')
220
+ .attr('stroke-width', 1);
221
+ });
222
+ };
223
+ if (this.level === 'week-day') {
224
+ const dayTicks = d3.timeDay.every(1).range(d3.timeDay.floor(this.fromTime), d3.timeDay.offset(this.toTime, 1));
225
+ addGridLines(dayTicks);
226
+ }
227
+ else if (this.level === 'quarter-week') {
228
+ const weekTicks = d3.timeWeek
229
+ .every(1)
230
+ .range(d3.timeWeek.floor(this.fromTime), d3.timeWeek.offset(this.toTime, 1));
231
+ addGridLines(weekTicks);
232
+ }
233
+ else if (this.level === 'year-month') {
234
+ const monthTicks = d3.timeMonth
235
+ .every(1)
236
+ .range(d3.timeMonth.floor(this.fromTime), d3.timeMonth.offset(this.toTime, 1));
237
+ addGridLines(monthTicks);
238
+ }
239
+ else if (this.level === 'year-quarter') {
240
+ const quarterTicks = d3.timeMonth
241
+ .every(3)
242
+ .range(d3.timeMonth.floor(this.fromTime), d3.timeMonth.offset(this.toTime, 3));
243
+ addGridLines(quarterTicks);
244
+ }
245
+ }
246
+ const taskPositions = {};
247
+ this.tasks.forEach((task, index) => {
248
+ const startDate = new Date(task.startDate);
249
+ const endDate = new Date(task.endDate);
250
+ const startX = this.timeScale(d3.timeDay.floor(d3.min([startDate, endDate])));
251
+ const endX = this.timeScale(d3.timeDay.offset(d3.timeDay.ceil(d3.max([startDate, endDate])), -1));
252
+ const taskWidth = endX - startX + this.baseWidth / this.getScale();
253
+ const taskY = index * 30 + 7.5;
254
+ const showTooltip = (event) => {
255
+ tooltip.title = task.title;
256
+ tooltip.startDate = startDate.toISOString().split('T')[0];
257
+ tooltip.endDate = endDate.toISOString().split('T')[0];
258
+ tooltip.progress = task.progress ?? 0;
259
+ tooltip.type = task.type;
260
+ tooltip.show(event.clientX, event.clientY);
261
+ };
262
+ const hideTooltip = () => {
263
+ tooltip.hide();
264
+ };
265
+ if (this.selectedTaskId === task.id) {
266
+ body
267
+ .append('rect')
268
+ .attr('x', 0)
269
+ .attr('y', taskY - 7.5)
270
+ .attr('width', this.getChartWidth())
271
+ .attr('height', 30)
272
+ .attr('fill', 'var(--ox-gantt-selected-row-background-color, var(--md-sys-color-surface-variant))');
273
+ }
274
+ const taskBar = body
275
+ .append('rect')
276
+ .attr('x', startX)
277
+ .attr('y', taskY)
278
+ .attr('width', taskWidth)
279
+ .attr('height', 15)
280
+ .attr('fill', this.getTaskColor(task.tags || []))
281
+ .attr('stroke', 'black')
282
+ .attr('stroke-width', 1);
283
+ taskBar
284
+ .on('click', () => {
285
+ this.selectedTaskId = task.id;
286
+ const customEvent = new CustomEvent('task-clicked', {
287
+ detail: { taskId: task.id },
288
+ bubbles: true,
289
+ composed: true
290
+ });
291
+ this.host.dispatchEvent(customEvent);
292
+ this.host.requestUpdate();
293
+ })
294
+ .on('mouseover', showTooltip)
295
+ .on('mouseout', hideTooltip);
296
+ if (task.progress !== undefined) {
297
+ const progressWidth = taskWidth * (task.progress / 100);
298
+ const progressBar = body
299
+ .append('rect')
300
+ .attr('x', startX)
301
+ .attr('y', taskY + 7.5 - 3.75)
302
+ .attr('width', progressWidth)
303
+ .attr('height', 7.5)
304
+ .attr('fill', 'lightgreen');
305
+ progressBar
306
+ .on('click', () => {
307
+ this.selectedTaskId = task.id;
308
+ const customEvent = new CustomEvent('task-clicked', {
309
+ detail: { taskId: task.id },
310
+ bubbles: true,
311
+ composed: true
312
+ });
313
+ this.host.dispatchEvent(customEvent);
314
+ this.host.requestUpdate();
315
+ })
316
+ .on('mouseover', showTooltip)
317
+ .on('mouseout', hideTooltip);
318
+ }
319
+ taskPositions[task.id] = { x: endX + this.baseWidth / this.getScale(), y: taskY + 7.5, width: taskWidth };
320
+ });
321
+ this.tasks.forEach(task => {
322
+ if (task.dependsOn && taskPositions[task.dependsOn]) {
323
+ const prevTask = taskPositions[task.dependsOn];
324
+ const currTask = taskPositions[task.id];
325
+ body
326
+ .append('path')
327
+ .attr('d', `
328
+ M${prevTask.x},${prevTask.y}
329
+ L${prevTask.x + 10},${prevTask.y}
330
+ ${prevTask.x + 10 < currTask.x - 10 - currTask.width
331
+ ? `
332
+ L${(prevTask.x + currTask.x - currTask.width) / 2},${prevTask.y}
333
+ L${(prevTask.x + currTask.x - currTask.width) / 2},${currTask.y}
334
+ `
335
+ : `
336
+ L${prevTask.x + 10},${(prevTask.y + currTask.y) / 2}
337
+ L${currTask.x - 10 - currTask.width},${(prevTask.y + currTask.y) / 2}
338
+ `}
339
+ L${currTask.x - 10 - currTask.width},${currTask.y}
340
+ L${currTask.x - currTask.width},${currTask.y}
341
+ `)
342
+ .attr('stroke', 'black')
343
+ .attr('fill', 'none')
344
+ .attr('stroke-width', 1);
345
+ }
346
+ });
347
+ }
348
+ getTaskColor(tags) {
349
+ if (tags.includes('critical')) {
350
+ return 'red';
351
+ }
352
+ else if (tags.includes('milestone')) {
353
+ return 'blue';
354
+ }
355
+ else if (tags.includes('done')) {
356
+ return 'green';
357
+ }
358
+ else {
359
+ return 'grey';
360
+ }
361
+ }
362
+ handleWheelForBody(event, container) {
363
+ event.preventDefault();
364
+ event.stopPropagation();
365
+ if (event.altKey || event.ctrlKey || event.shiftKey || event.metaKey) {
366
+ container.scrollLeft += event.shiftKey ? event.deltaX : event.deltaY;
367
+ }
368
+ else {
369
+ container.scrollTop += event.deltaY;
370
+ }
371
+ const customEvent = new CustomEvent('scroll', {
372
+ detail: { offset: event.shiftKey ? container.scrollLeft : container.scrollTop },
373
+ bubbles: true,
374
+ composed: true
375
+ });
376
+ this.host.dispatchEvent(customEvent);
377
+ }
378
+ handleTouchStartForBody(event, container) {
379
+ event.stopPropagation();
380
+ this.touchStartY = event.touches[0].clientY;
381
+ this.scrollStartY = container.scrollTop;
382
+ }
383
+ handleTouchMoveForBody(event, container) {
384
+ const touchCurrentY = event.touches[0].clientY;
385
+ const deltaY = this.touchStartY - touchCurrentY;
386
+ container.scrollTop = this.scrollStartY + deltaY;
387
+ const customEvent = new CustomEvent('scroll', {
388
+ detail: { offset: container.scrollTop },
389
+ bubbles: true,
390
+ composed: true
391
+ });
392
+ this.host.dispatchEvent(customEvent);
393
+ }
394
+ }
395
+ //# sourceMappingURL=gantt-chart-controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gantt-chart-controller.js","sourceRoot":"","sources":["../../src/gantt-chart-controller.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAA;AAIxB,MAAM,OAAO,oBAAoB;IAiB/B,YAAY,IAAyC,EAAE,QAAgB,EAAE,MAAc,EAAE,SAAoB;QAPtG,cAAS,GAAW,EAAE,CAAA;QAItB,UAAK,GAAW,EAAE,CAAA;QAClB,oBAAe,GAAY,KAAK,CAAA;QAGrC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,QAAQ,GAAG,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAA;QAClC,IAAI,CAAC,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,CAAC,CAAA;QAC9B,IAAI,CAAC,KAAK,GAAG,SAAS,CAAA;QACtB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,EAA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,SAAS,IAAI,KAAK,CAAC,MAAM,CAAA;QACrC,CAAC;QAED,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,QAAQ,EAAE;YAC5C,MAAM,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,EAAE;YAC/E,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;SACf,CAAC,CAAA;QAEF,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAA;IACtC,CAAC;IAED,uBAAuB,CAAC,KAAiB,EAAE,SAAyB;QAClE,KAAK,CAAC,eAAe,EAAE,CAAA;QAEvB,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAA;QAC3C,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC,SAAS,CAAA;IACzC,CAAC;IAED,sBAAsB,CAAC,KAAiB,EAAE,SAAyB;QACjE,MAAM,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAA;QAC9C,MAAM,MAAM,GAAG,IAAI,CAAC,WAAY,GAAG,aAAa,CAAA;QAChD,SAAS,CAAC,SAAS,GAAG,IAAI,CAAC,YAAa,GAAG,MAAM,CAAA;QAEjD,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,QAAQ,EAAE;YAC5C,MAAM,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,SAAS,EAAE;YACvC,OAAO,EAAE,IAAI;YACb,QAAQ,EAAE,IAAI;SACf,CAAC,CAAA;QACF,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAA;IACtC,CAAC;CACF","sourcesContent":["import { LitElement, ReactiveController, ReactiveControllerHost } from 'lit'\nimport * as d3 from 'd3'\nimport { TimeScale, Task, TaskTag } from './types'\nimport { OxTaskTooltip } from './ox-task-tooltip'\n\nexport class GanttChartController implements ReactiveController {\n private host: ReactiveControllerHost & LitElement\n private fromTime: Date\n private toTime: Date\n private totalDays: number\n private _timeScale?: d3.ScaleTime<number, number, never>\n\n private touchStartY?: number\n private scrollStartY?: number\n\n public baseWidth: number = 30\n public level: TimeScale\n public selectedTaskId?: string\n\n public tasks: Task[] = []\n public extendGridLines: boolean = false\n\n constructor(host: ReactiveControllerHost & LitElement, fromDate: string, toDate: string, axisScale: TimeScale) {\n this.host = host\n this.fromTime = new Date(fromDate)\n this.toTime = new Date(toDate)\n this.level = axisScale\n this.totalDays = d3.timeDay.count(this.fromTime, d3.timeDay.offset(this.toTime, 1))\n this.host.addController(this)\n }\n\n hostConnected() {\n this.updateTimeScale()\n }\n\n get timeScale() {\n if (!this._timeScale) {\n this._timeScale = d3\n .scaleTime()\n .domain([d3.timeDay.floor(this.fromTime), d3.timeDay.offset(this.toTime, 1)])\n .range([0, this.getChartWidth()])\n }\n return this._timeScale\n }\n\n updateRange(fromDate: string, toDate: string) {\n this.fromTime = new Date(fromDate)\n this.toTime = new Date(toDate)\n this.totalDays = d3.timeDay.count(this.fromTime, d3.timeDay.offset(this.toTime, 1))\n this._timeScale = undefined\n this.host.requestUpdate()\n }\n\n setTasks(tasks: Task[]) {\n this.tasks = tasks\n this.host.requestUpdate()\n }\n\n updateTimeScale() {\n this.timeScale.range([0, this.getChartWidth()])\n }\n\n getChartWidth() {\n return (this.totalDays * this.baseWidth) / this.getScale()\n }\n\n getScale() {\n if (this.level == 'quarter-week') {\n return 7 / 2\n } else if (this.level == 'year-month') {\n return 30 / 2\n } else if (this.level == 'year-quarter') {\n return 90 / 2\n }\n return 1\n }\n\n drawAxes(svgHeader: SVGElement) {\n const header = d3.select(svgHeader)\n\n header.selectAll('*').remove()\n header.attr('width', this.getChartWidth())\n\n const addGridLines = (ticks: Date[], yStart: number, yEnd: number) => {\n ticks.forEach(tick => {\n const startX = this.timeScale(tick)\n header\n .append('line')\n .attr('x1', startX)\n .attr('x2', startX)\n .attr('y1', yStart)\n .attr('y2', yEnd)\n .attr('stroke', 'var(--ox-gantt-color-gridlines, var(--md-sys-color-on-secondary-container))')\n .attr('stroke-width', 1)\n })\n }\n\n const centerLabel = (\n selection: d3.Selection<SVGGElement, unknown, null, any>,\n tickInterval: d3.CountableTimeInterval\n ) => {\n selection.selectAll('text').attr('transform', (d: any) => {\n const tickIntervalWidth = this.timeScale(tickInterval.offset(d, 1)) - this.timeScale(d)\n return `translate(${tickIntervalWidth / 2}, -2)`\n })\n }\n\n if (this.level === 'week-day') {\n const weekAxis = d3\n .axisTop(this.timeScale)\n .ticks(d3.timeWeek.every(1))\n .tickFormat(d3.timeFormat('%B %d') as any)\n .tickSize(0)\n const weekTicks = d3.timeWeek\n .every(1)!\n .range(d3.timeWeek.floor(this.fromTime), d3.timeWeek.offset(this.toTime, 1))\n addGridLines(weekTicks, 0, 20)\n\n const weekAxisG = header\n .append('g')\n .classed('week-axis no-select md-typescale-label-small', true)\n .attr('transform', `translate(0, 20)`)\n .call(weekAxis)\n\n centerLabel(weekAxisG, d3.timeWeek)\n\n const dayAxis = d3\n .axisTop(this.timeScale)\n .ticks(d3.timeDay.every(1))\n .tickFormat(d3.timeFormat('%d') as any)\n .tickSize(0)\n\n const dayTicks = d3.timeDay.every(1)!.range(d3.timeDay.floor(this.fromTime), d3.timeDay.offset(this.toTime, 1))\n addGridLines(dayTicks, 20, 40)\n\n const dayAxisG = header\n .append('g')\n .classed('day-axis no-select md-typescale-label-small', true)\n .attr('transform', `translate(0, 40)`)\n .call(dayAxis)\n\n centerLabel(dayAxisG, d3.timeDay)\n } else if (this.level === 'quarter-week') {\n const quarterAxis = d3\n .axisTop(this.timeScale)\n .ticks(d3.timeMonth.every(3))\n .tickFormat(d3.timeFormat('%Y %b') as any)\n .tickSize(0)\n\n const quarterTicks = d3.timeMonth\n .every(3)!\n .range(d3.timeMonth.floor(this.fromTime), d3.timeMonth.offset(this.toTime, 3))\n addGridLines(quarterTicks, 0, 20)\n\n const quarterAxisG = header\n .append('g')\n .classed('quarter-axis no-select md-typescale-label-small', true)\n .attr('transform', `translate(0, 20)`)\n .call(quarterAxis)\n\n centerLabel(quarterAxisG, d3.timeMonth.every(3) as any)\n\n const weekAxis = d3\n .axisTop(this.timeScale)\n .ticks(d3.timeWeek.every(1))\n .tickFormat(d3.timeFormat('%b %d') as any)\n .tickSize(0)\n const weekTicks = d3.timeWeek\n .every(1)!\n .range(d3.timeWeek.floor(this.fromTime), d3.timeWeek.offset(this.toTime, 1))\n addGridLines(weekTicks, 20, 40)\n\n const weekAxisG = header\n .append('g')\n .classed('week-axis no-select md-typescale-label-small', true)\n .attr('transform', `translate(0, 40)`)\n .call(weekAxis)\n\n centerLabel(weekAxisG, d3.timeWeek)\n } else if (this.level === 'year-month') {\n const yearAxis = d3\n .axisTop(this.timeScale)\n .ticks(d3.timeYear.every(1))\n .tickFormat(d3.timeFormat('%Y') as any)\n .tickSize(0)\n\n const yearTicks = d3.timeYear\n .every(1)!\n .range(d3.timeYear.floor(this.fromTime), d3.timeYear.offset(this.toTime, 1))\n addGridLines(yearTicks, 0, 20)\n\n const yearAxisG = header\n .append('g')\n .classed('year-axis no-select md-typescale-label-small', true)\n .attr('transform', `translate(0, 20)`)\n .call(yearAxis)\n\n centerLabel(yearAxisG, d3.timeYear.every(1)! as any)\n\n const monthAxis = d3\n .axisTop(this.timeScale)\n .ticks(d3.timeMonth.every(1))\n .tickFormat(d3.timeFormat('%b') as any)\n .tickSize(0)\n\n const monthTicks = d3.timeMonth\n .every(1)!\n .range(d3.timeMonth.floor(this.fromTime), d3.timeMonth.offset(this.toTime, 1))\n addGridLines(monthTicks, 20, 40)\n\n const monthAxisG = header\n .append('g')\n .classed('month-axis no-select md-typescale-label-small', true)\n .attr('transform', `translate(0, 40)`)\n .call(monthAxis)\n\n centerLabel(monthAxisG, d3.timeMonth.every(1) as any)\n } else if (this.level === 'year-quarter') {\n const yearAxis = d3\n .axisTop(this.timeScale)\n .ticks(d3.timeYear.every(1))\n .tickFormat(d3.timeFormat('%Y') as any)\n .tickSize(0)\n\n const yearTicks = d3.timeYear\n .every(1)!\n .range(d3.timeYear.floor(this.fromTime), d3.timeYear.offset(this.toTime, 1))\n addGridLines(yearTicks, 0, 20)\n\n const yearAxisG = header\n .append('g')\n .classed('year-axis no-select md-typescale-label-small', true)\n .attr('transform', `translate(0, 20)`)\n .call(yearAxis)\n\n centerLabel(yearAxisG, d3.timeYear.every(1)! as any)\n\n const quarterAxis = d3\n .axisTop(this.timeScale)\n .ticks(d3.timeMonth.every(3))\n .tickFormat(d3.timeFormat('%Y %b') as any)\n .tickSize(0)\n\n const quarterTicks = d3.timeMonth\n .every(3)!\n .range(d3.timeMonth.floor(this.fromTime), d3.timeMonth.offset(this.toTime, 3))\n addGridLines(quarterTicks, 20, 40)\n\n const quarterAxisG = header\n .append('g')\n .classed('quarter-axis no-select md-typescale-label-small', true)\n .attr('transform', `translate(0, 40)`)\n .call(quarterAxis)\n\n centerLabel(quarterAxisG, d3.timeMonth.every(3) as any)\n }\n }\n\n drawBody(svgBody: SVGElement, tooltip: OxTaskTooltip) {\n const body = d3.select(svgBody)\n\n body.selectAll('*').remove()\n body.attr('width', this.getChartWidth())\n\n if (this.extendGridLines) {\n const addGridLines = (ticks: Date[]) => {\n ticks.forEach(tick => {\n const startX = this.timeScale(tick)\n body\n .append('line')\n .attr('x1', startX)\n .attr('x2', startX)\n .attr('y1', 0)\n .attr('y2', Number(svgBody.getBoundingClientRect().height) || 0)\n .attr('stroke', 'var(--ox-gantt-color-gridlines, var(--md-sys-color-outline))')\n .attr('stroke-width', 1)\n })\n }\n\n if (this.level === 'week-day') {\n const dayTicks = d3.timeDay.every(1)!.range(d3.timeDay.floor(this.fromTime), d3.timeDay.offset(this.toTime, 1))\n addGridLines(dayTicks)\n } else if (this.level === 'quarter-week') {\n const weekTicks = d3.timeWeek\n .every(1)!\n .range(d3.timeWeek.floor(this.fromTime), d3.timeWeek.offset(this.toTime, 1))\n addGridLines(weekTicks)\n } else if (this.level === 'year-month') {\n const monthTicks = d3.timeMonth\n .every(1)!\n .range(d3.timeMonth.floor(this.fromTime), d3.timeMonth.offset(this.toTime, 1))\n addGridLines(monthTicks)\n } else if (this.level === 'year-quarter') {\n const quarterTicks = d3.timeMonth\n .every(3)!\n .range(d3.timeMonth.floor(this.fromTime), d3.timeMonth.offset(this.toTime, 3))\n addGridLines(quarterTicks)\n }\n }\n\n const taskPositions: { [key: string]: { x: number; y: number; width: number } } = {}\n\n this.tasks.forEach((task, index) => {\n const startDate = new Date(task.startDate)\n const endDate = new Date(task.endDate)\n\n const startX = this.timeScale(d3.timeDay.floor(d3.min([startDate, endDate])!))\n const endX = this.timeScale(d3.timeDay.offset(d3.timeDay.ceil(d3.max([startDate, endDate])!), -1))\n\n const taskWidth = endX - startX + this.baseWidth / this.getScale()\n const taskY = index * 30 + 7.5\n\n const showTooltip = (event: MouseEvent) => {\n tooltip.title = task.title\n tooltip.startDate = startDate.toISOString().split('T')[0]\n tooltip.endDate = endDate.toISOString().split('T')[0]\n tooltip.progress = task.progress ?? 0\n tooltip.type = task.type\n\n tooltip.show(event.clientX, event.clientY)\n }\n\n const hideTooltip = () => {\n tooltip.hide()\n }\n\n if (this.selectedTaskId === task.id) {\n body\n .append('rect')\n .attr('x', 0)\n .attr('y', taskY - 7.5)\n .attr('width', this.getChartWidth())\n .attr('height', 30)\n .attr('fill', 'var(--ox-gantt-selected-row-background-color, var(--md-sys-color-surface-variant))')\n }\n\n const taskBar = body\n .append('rect')\n .attr('x', startX)\n .attr('y', taskY)\n .attr('width', taskWidth)\n .attr('height', 15)\n .attr('fill', this.getTaskColor(task.tags || []))\n .attr('stroke', 'black')\n .attr('stroke-width', 1)\n\n taskBar\n .on('click', () => {\n this.selectedTaskId = task.id\n const customEvent = new CustomEvent('task-clicked', {\n detail: { taskId: task.id },\n bubbles: true,\n composed: true\n })\n this.host.dispatchEvent(customEvent)\n this.host.requestUpdate()\n })\n .on('mouseover', showTooltip)\n .on('mouseout', hideTooltip)\n\n if (task.progress !== undefined) {\n const progressWidth = taskWidth * (task.progress / 100)\n const progressBar = body\n .append('rect')\n .attr('x', startX)\n .attr('y', taskY + 7.5 - 3.75)\n .attr('width', progressWidth)\n .attr('height', 7.5)\n .attr('fill', 'lightgreen')\n\n progressBar\n .on('click', () => {\n this.selectedTaskId = task.id\n const customEvent = new CustomEvent('task-clicked', {\n detail: { taskId: task.id },\n bubbles: true,\n composed: true\n })\n this.host.dispatchEvent(customEvent)\n this.host.requestUpdate()\n })\n .on('mouseover', showTooltip)\n .on('mouseout', hideTooltip)\n }\n\n taskPositions[task.id] = { x: endX + this.baseWidth / this.getScale(), y: taskY + 7.5, width: taskWidth }\n })\n\n this.tasks.forEach(task => {\n if (task.dependsOn && taskPositions[task.dependsOn]) {\n const prevTask = taskPositions[task.dependsOn]\n const currTask = taskPositions[task.id]\n\n body\n .append('path')\n .attr(\n 'd',\n `\n M${prevTask.x},${prevTask.y}\n L${prevTask.x + 10},${prevTask.y}\n ${\n prevTask.x + 10 < currTask.x - 10 - currTask.width\n ? `\n L${(prevTask.x + currTask.x - currTask.width) / 2},${prevTask.y}\n L${(prevTask.x + currTask.x - currTask.width) / 2},${currTask.y}\n `\n : `\n L${prevTask.x + 10},${(prevTask.y + currTask.y) / 2}\n L${currTask.x - 10 - currTask.width},${(prevTask.y + currTask.y) / 2}\n `\n }\n L${currTask.x - 10 - currTask.width},${currTask.y}\n L${currTask.x - currTask.width},${currTask.y}\n `\n )\n .attr('stroke', 'black')\n .attr('fill', 'none')\n .attr('stroke-width', 1)\n }\n })\n }\n\n getTaskColor(tags: TaskTag[]): string {\n if (tags.includes('critical')) {\n return 'red'\n } else if (tags.includes('milestone')) {\n return 'blue'\n } else if (tags.includes('done')) {\n return 'green'\n } else {\n return 'grey'\n }\n }\n\n handleWheelForBody(event: WheelEvent, container: HTMLDivElement) {\n event.preventDefault()\n event.stopPropagation()\n\n if (event.altKey || event.ctrlKey || event.shiftKey || event.metaKey) {\n container.scrollLeft += event.shiftKey ? event.deltaX : event.deltaY\n } else {\n container.scrollTop += event.deltaY\n }\n\n const customEvent = new CustomEvent('scroll', {\n detail: { offset: event.shiftKey ? container.scrollLeft : container.scrollTop },\n bubbles: true,\n composed: true\n })\n\n this.host.dispatchEvent(customEvent)\n }\n\n handleTouchStartForBody(event: TouchEvent, container: HTMLDivElement) {\n event.stopPropagation()\n\n this.touchStartY = event.touches[0].clientY\n this.scrollStartY = container.scrollTop\n }\n\n handleTouchMoveForBody(event: TouchEvent, container: HTMLDivElement) {\n const touchCurrentY = event.touches[0].clientY\n const deltaY = this.touchStartY! - touchCurrentY\n container.scrollTop = this.scrollStartY! + deltaY\n\n const customEvent = new CustomEvent('scroll', {\n detail: { offset: container.scrollTop },\n bubbles: true,\n composed: true\n })\n this.host.dispatchEvent(customEvent)\n }\n}\n"]}
@@ -0,0 +1,52 @@
1
+ export declare const locales: {
2
+ 'en-US': {
3
+ dateTime: string;
4
+ date: string;
5
+ time: string;
6
+ periods: string[];
7
+ days: string[];
8
+ shortDays: string[];
9
+ months: string[];
10
+ shortMonths: string[];
11
+ };
12
+ 'ko-KR': {
13
+ dateTime: string;
14
+ date: string;
15
+ time: string;
16
+ periods: string[];
17
+ days: string[];
18
+ shortDays: string[];
19
+ months: string[];
20
+ shortMonths: string[];
21
+ };
22
+ 'ja-JP': {
23
+ dateTime: string;
24
+ date: string;
25
+ time: string;
26
+ periods: string[];
27
+ days: string[];
28
+ shortDays: string[];
29
+ months: string[];
30
+ shortMonths: string[];
31
+ };
32
+ 'zh-CN': {
33
+ dateTime: string;
34
+ date: string;
35
+ time: string;
36
+ periods: string[];
37
+ days: string[];
38
+ shortDays: string[];
39
+ months: string[];
40
+ shortMonths: string[];
41
+ };
42
+ 'ms-MY': {
43
+ dateTime: string;
44
+ date: string;
45
+ time: string;
46
+ periods: string[];
47
+ days: string[];
48
+ shortDays: string[];
49
+ months: string[];
50
+ shortMonths: string[];
51
+ };
52
+ };