@jsb188/schedule 1.1.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 (60) hide show
  1. package/package.json +62 -0
  2. package/src/constants/schedule.ts +549 -0
  3. package/src/css.d.ts +7 -0
  4. package/src/libs/gantt-geometry.ts +771 -0
  5. package/src/libs/gantt-histogram.ts +124 -0
  6. package/src/libs/gantt-keyboard.ts +113 -0
  7. package/src/libs/gantt-state.ts +57 -0
  8. package/src/libs/gantt-url.ts +63 -0
  9. package/src/modules/Gantt.helpers.ts +119 -0
  10. package/src/modules/Gantt.tsx +584 -0
  11. package/src/types/schedule.d.ts +1149 -0
  12. package/src/ui/ActivityFormUI.tsx +133 -0
  13. package/src/ui/GanttEditorsUI.tsx +102 -0
  14. package/src/ui/GanttHistogramUI.tsx +236 -0
  15. package/src/ui/GanttUI.tsx +792 -0
  16. package/src/ui/ProjectFormUI.tsx +250 -0
  17. package/src/ui/ProjectMobileListUI.tsx +80 -0
  18. package/src/ui/ProjectToolbarUI.tsx +54 -0
  19. package/src/ui/RelationshipListUI.tsx +176 -0
  20. package/src/ui/ScheduleRunUI.tsx +173 -0
  21. package/src/ui/ScheduleSettingsUI.tsx +420 -0
  22. package/src/utils/coverage.helpers.ts +679 -0
  23. package/src/utils/coverage.ts +630 -0
  24. package/src/utils/cpm.helpers.ts +674 -0
  25. package/src/utils/cpm.ts +907 -0
  26. package/src/utils/cpmLeveling.helpers.ts +564 -0
  27. package/src/utils/cpmLeveling.ts +367 -0
  28. package/src/utils/defaults.ts +8 -0
  29. package/src/utils/eligibility.ts +457 -0
  30. package/src/utils/planCsv.ts +344 -0
  31. package/src/utils/predecessorText.ts +96 -0
  32. package/src/utils/recurrence.ts +616 -0
  33. package/src/utils/request.ts +153 -0
  34. package/src/utils/resource.ts +182 -0
  35. package/src/utils/rule.ts +216 -0
  36. package/src/utils/run.ts +43 -0
  37. package/src/utils/series.ts +161 -0
  38. package/src/utils/slot.ts +208 -0
  39. package/src/utils/workTime.ts +1382 -0
  40. package/tests/coverage.fixtures.ts +111 -0
  41. package/tests/coverage.test.ts +503 -0
  42. package/tests/cpm.bench.test.ts +154 -0
  43. package/tests/cpm.test.ts +354 -0
  44. package/tests/cpmCorrectness.test.ts +327 -0
  45. package/tests/cpmLeveling.test.ts +471 -0
  46. package/tests/eligibility.test.ts +320 -0
  47. package/tests/gantt-geometry.test.ts +367 -0
  48. package/tests/gantt-histogram.test.ts +78 -0
  49. package/tests/gantt-keyboard.test.ts +69 -0
  50. package/tests/helpers/cpmFixtures.ts +101 -0
  51. package/tests/projectInputs.test.ts +165 -0
  52. package/tests/recurrence.test.ts +68 -0
  53. package/tests/request.test.ts +99 -0
  54. package/tests/resource.test.ts +95 -0
  55. package/tests/rule.test.ts +98 -0
  56. package/tests/series.test.ts +120 -0
  57. package/tests/workTime.test.ts +1007 -0
  58. package/tests/workTimeContracts.test.ts +111 -0
  59. package/tsconfig.json +13 -0
  60. package/vitest.config.ts +8 -0
@@ -0,0 +1,792 @@
1
+ import i18n from '@jsb188/app/i18n/index.ts';
2
+ import { cn } from '@jsb188/app/utils/string.ts';
3
+ import { Icon } from '@jsb188/react-web/svgs/Icon';
4
+ import {
5
+ memo,
6
+ useId,
7
+ useMemo,
8
+ useRef,
9
+ useState,
10
+ type MouseEvent,
11
+ type PointerEvent,
12
+ type ReactNode,
13
+ } from 'react';
14
+ import {
15
+ GANTT_BAR_HEIGHT,
16
+ GANTT_HEADER_HEIGHT,
17
+ GANTT_ROW_HEIGHT,
18
+ GANTT_TABLE_INDENT,
19
+ type GanttBarObj,
20
+ type GanttLinkObj,
21
+ type GanttRowObj,
22
+ type GanttScaleObj,
23
+ type GanttNonWorkingColumn,
24
+ } from '../libs/gantt-geometry.ts';
25
+ import {
26
+ useGanttRowSelected,
27
+ type GanttSelectionAtom,
28
+ } from '../libs/gantt-state.ts';
29
+
30
+ export interface GanttColumnObj {
31
+ key: string;
32
+ label: string;
33
+ width: number;
34
+ alignRight?: boolean;
35
+ editor?: 'text' | 'number' | 'date';
36
+ }
37
+ export interface GanttRowTextObj {
38
+ duration: string;
39
+ start: string;
40
+ finish: string;
41
+ float: string;
42
+ values?: Record<string, string>;
43
+ [key: string]: string | Record<string, string> | undefined;
44
+ }
45
+ export interface GanttTableUIProps {
46
+ rows: GanttRowObj[];
47
+ visibleRowTexts: GanttRowTextObj[];
48
+ columns: GanttColumnObj[];
49
+ selection: GanttSelectionAtom;
50
+ visibleStart: number;
51
+ visibleEnd: number;
52
+ editable?: boolean;
53
+ renderCell?: (row: GanttRowObj, key: string, text: string) => ReactNode;
54
+ onSelectRow?: (
55
+ row: GanttRowObj,
56
+ event: MouseEvent | React.KeyboardEvent,
57
+ ) => void;
58
+ onToggleCollapse?: (wbsId: string) => void;
59
+ onEditCell?: (
60
+ row: GanttRowObj,
61
+ key: string,
62
+ value: string,
63
+ ) => boolean | void | Promise<boolean | void>;
64
+ onNavigate?: (
65
+ rowId: string,
66
+ columnKey: string,
67
+ direction: number,
68
+ vertical: boolean,
69
+ ) => void;
70
+ onMoveRows?: (
71
+ rowIds: string[],
72
+ wbsId: string | null,
73
+ afterActivityId?: string,
74
+ ) => void;
75
+ }
76
+
77
+ /* Render translated column headings at the same widths as the virtualized grid. */
78
+ export const GanttTableHeaderUI = memo(
79
+ (p: {
80
+ columns: GanttColumnObj[];
81
+ onResize?: (
82
+ event: PointerEvent<HTMLDivElement>,
83
+ column: GanttColumnObj,
84
+ ) => void;
85
+ }) => (
86
+ <div
87
+ role="row"
88
+ className="no_shrink h_item bg bd_b_1 bd_b_bd"
89
+ style={{ height: GANTT_HEADER_HEIGHT }}
90
+ >
91
+ {p.columns.map((column) => (
92
+ <div
93
+ role="columnheader"
94
+ key={column.key}
95
+ className="rel no_shrink h_item h_f of bd_r_1 bd_r_bd px_4"
96
+ style={{ width: column.width }}
97
+ >
98
+ <span className="ellip ft_xxs cl_lt">{column.label}</span>
99
+ {p.onResize && (
100
+ <div
101
+ role="separator"
102
+ aria-orientation="vertical"
103
+ aria-label={column.label}
104
+ className="abs cs_resize"
105
+ style={{ right: 0, top: 0, width: 5, height: '100%' }}
106
+ onPointerDown={(event) => p.onResize?.(event, column)}
107
+ />
108
+ )}
109
+ </div>
110
+ ))}
111
+ </div>
112
+ ),
113
+ );
114
+
115
+ /* Keep an inline edit local until blur or Enter; Escape leaves the committed value intact. */
116
+ const GanttCellUI = memo(
117
+ (p: {
118
+ row: GanttRowObj;
119
+ column: GanttColumnObj;
120
+ text: string;
121
+ value: string;
122
+ editable?: boolean;
123
+ onEditCell?: GanttTableUIProps['onEditCell'];
124
+ onNavigate?: GanttTableUIProps['onNavigate'];
125
+ children?: ReactNode;
126
+ }) => {
127
+ const [editing, setEditing] = useState(false);
128
+ const [draft, setDraft] = useState(p.value);
129
+ const finished = useRef(false);
130
+ const generation = useRef(0);
131
+ const inputRef = useRef<HTMLInputElement>(null);
132
+ const cellRef = useRef<HTMLDivElement>(null);
133
+ const [busy, setBusy] = useState(false);
134
+ const [rejected, setRejected] = useState(false);
135
+ const canEdit =
136
+ p.editable &&
137
+ p.column.editor &&
138
+ p.onEditCell &&
139
+ (p.row.kind !== 'WBS' || ['code', 'name'].includes(p.column.key));
140
+ /* Commit at most once when Enter is followed by the input losing focus. */
141
+ const commit = async () => {
142
+ if (finished.current) return false;
143
+ finished.current = true;
144
+ const attempt = ++generation.current;
145
+ if (draft === p.value) {
146
+ setEditing(false);
147
+ return true;
148
+ }
149
+ setBusy(true);
150
+ setRejected(false);
151
+ let accepted: boolean | void = false;
152
+ try {
153
+ accepted = await p.onEditCell?.(p.row, p.column.key, draft);
154
+ } catch {
155
+ accepted = false;
156
+ }
157
+ if (attempt !== generation.current) return false;
158
+ setBusy(false);
159
+ if (accepted === false) {
160
+ finished.current = false;
161
+ setRejected(true);
162
+ inputRef.current?.focus();
163
+ } else setEditing(false);
164
+ return accepted !== false;
165
+ };
166
+ /* Begin editing from the latest committed value. */
167
+ const begin = (initial?: string) => {
168
+ if (!canEdit) return;
169
+ finished.current = false;
170
+ setRejected(false);
171
+ setBusy(false);
172
+ setDraft(initial ?? p.value);
173
+ setEditing(true);
174
+ };
175
+ /* Move between mounted editable cells without changing server data or chart selection. */
176
+ const focusAdjacent = (direction: number, vertical = false) => {
177
+ p.onNavigate?.(p.row.id, p.column.key, direction, vertical);
178
+ };
179
+ return (
180
+ <div
181
+ ref={cellRef}
182
+ role="gridcell"
183
+ data-gantt-column={p.column.key}
184
+ tabIndex={0}
185
+ className={cn(
186
+ 'no_shrink h_item h_f of bd_r_1 bd_r_bd px_4',
187
+ p.column.alignRight && 'h_right',
188
+ )}
189
+ style={{
190
+ width: p.column.width,
191
+ paddingLeft:
192
+ p.column.key === 'name' ? 8 + p.row.depth * GANTT_TABLE_INDENT : 8,
193
+ }}
194
+ onDoubleClick={() => begin()}
195
+ onKeyDown={(event) => {
196
+ if (editing || event.ctrlKey || event.metaKey || event.altKey) return;
197
+ if (event.key === 'Enter' || event.key === 'F2') {
198
+ event.preventDefault();
199
+ event.stopPropagation();
200
+ begin();
201
+ } else if (
202
+ event.key.length === 1 &&
203
+ ![' ', '+', '-'].includes(event.key)
204
+ ) {
205
+ event.preventDefault();
206
+ event.stopPropagation();
207
+ begin(event.key);
208
+ }
209
+ }}
210
+ >
211
+ {p.children}
212
+ {editing ? (
213
+ <input
214
+ ref={inputRef}
215
+ autoFocus
216
+ aria-label={p.column.label}
217
+ aria-invalid={rejected}
218
+ aria-busy={busy}
219
+ readOnly={busy}
220
+ title={rejected ? i18n.t('schedule.settings.error') : undefined}
221
+ className={cn(
222
+ 'invis_input w_f ft_xxs',
223
+ rejected ? 'ol_err' : 'ol_primary',
224
+ )}
225
+ type={p.column.editor}
226
+ value={draft}
227
+ onClick={(event) => event.stopPropagation()}
228
+ onChange={(event) => setDraft(event.target.value)}
229
+ onBlur={commit}
230
+ onKeyDown={(event) => {
231
+ event.stopPropagation();
232
+ if (event.key === 'Enter') {
233
+ event.preventDefault();
234
+ void commit().then((accepted) => {
235
+ if (accepted) focusAdjacent(event.shiftKey ? -1 : 1, true);
236
+ });
237
+ }
238
+ if (event.key === 'Tab') {
239
+ event.preventDefault();
240
+ void commit().then((accepted) => {
241
+ if (accepted) focusAdjacent(event.shiftKey ? -1 : 1);
242
+ });
243
+ }
244
+ if (event.key === 'Escape') {
245
+ finished.current = true;
246
+ generation.current += 1;
247
+ cellRef.current?.focus();
248
+ setBusy(false);
249
+ setEditing(false);
250
+ }
251
+ }}
252
+ />
253
+ ) : (
254
+ <span
255
+ className={cn(
256
+ 'ellip ft_xxs',
257
+ p.row.kind === 'WBS' && 'ft_semibold',
258
+ p.column.key === 'float' && p.row.isCritical && 'cl_err',
259
+ )}
260
+ >
261
+ {p.text}
262
+ </span>
263
+ )}
264
+ </div>
265
+ );
266
+ },
267
+ );
268
+
269
+ /* Observe selection only for this mounted row and expose keyboard and pointer editing. */
270
+ const GanttTableRowUI = memo(
271
+ (
272
+ p: Omit<
273
+ GanttTableUIProps,
274
+ 'rows' | 'visibleRowTexts' | 'visibleStart' | 'visibleEnd'
275
+ > & { row: GanttRowObj; texts: GanttRowTextObj; index: number },
276
+ ) => {
277
+ const selected = useGanttRowSelected(p.selection, p.row.id);
278
+ return (
279
+ <div
280
+ role="row"
281
+ aria-rowindex={p.index + 2}
282
+ aria-selected={selected}
283
+ data-gantt-row={p.row.id}
284
+ className={cn(
285
+ 'abs h_item bd_b_1 bd_b_bd pointer',
286
+ selected ? 'bg_active' : p.row.kind === 'WBS' ? 'bg_alt' : 'bg',
287
+ )}
288
+ style={{
289
+ top: p.index * GANTT_ROW_HEIGHT,
290
+ height: GANTT_ROW_HEIGHT,
291
+ left: 0,
292
+ }}
293
+ onClick={(event) => p.onSelectRow?.(p.row, event)}
294
+ draggable={!!p.onMoveRows && p.editable}
295
+ onDragStart={(event) => {
296
+ event.dataTransfer.setData(
297
+ 'application/x-schedule-activity',
298
+ p.row.id,
299
+ );
300
+ }}
301
+ onDragOver={(event) => {
302
+ if (p.onMoveRows && p.editable) event.preventDefault();
303
+ }}
304
+ onDrop={(event) => {
305
+ event.preventDefault();
306
+ const id = event.dataTransfer.getData(
307
+ 'application/x-schedule-activity',
308
+ );
309
+ if (id && id !== p.row.id)
310
+ p.onMoveRows?.(
311
+ [id],
312
+ p.row.kind === 'WBS' ? p.row.id : p.row.wbsId,
313
+ p.row.kind === 'ACTIVITY' ? p.row.id : undefined,
314
+ );
315
+ }}
316
+ >
317
+ {p.columns.map((column) => {
318
+ const raw =
319
+ column.key === 'name'
320
+ ? p.row.name
321
+ : column.key === 'code'
322
+ ? p.row.code
323
+ : p.texts[column.key];
324
+ const text = typeof raw === 'string' ? raw : '';
325
+ const custom = p.renderCell?.(p.row, column.key, text);
326
+ if (custom !== undefined && typeof custom !== 'string')
327
+ return (
328
+ <div
329
+ key={column.key}
330
+ role="gridcell"
331
+ tabIndex={0}
332
+ data-gantt-column={column.key}
333
+ className="no_shrink h_item h_f of bd_r_1 bd_r_bd px_4"
334
+ style={{ width: column.width }}
335
+ >
336
+ {custom}
337
+ </div>
338
+ );
339
+ return (
340
+ <GanttCellUI
341
+ key={column.key}
342
+ row={p.row}
343
+ column={column}
344
+ text={typeof custom === 'string' ? custom : text}
345
+ value={
346
+ p.texts.values?.[column.key] ??
347
+ (typeof custom === 'string' ? custom : text)
348
+ }
349
+ editable={p.editable}
350
+ onEditCell={p.onEditCell}
351
+ onNavigate={p.onNavigate}
352
+ >
353
+ {column.key === 'name' && p.row.kind === 'WBS' ? (
354
+ <button
355
+ type="button"
356
+ className="no_shrink h_center ic_xs"
357
+ aria-label={p.row.name}
358
+ aria-expanded={!p.row.collapsed}
359
+ onClick={(event) => {
360
+ event.stopPropagation();
361
+ p.onToggleCollapse?.(p.row.id);
362
+ }}
363
+ >
364
+ <Icon
365
+ name={p.row.collapsed ? 'chevron-right' : 'chevron-down'}
366
+ />
367
+ </button>
368
+ ) : null}
369
+ {column.key === 'name' && p.row.unreviewed ? (
370
+ <span className="ic_xs cl_warn no_shrink">
371
+ <Icon name="alert-circle" />
372
+ </span>
373
+ ) : null}
374
+ </GanttCellUI>
375
+ );
376
+ })}
377
+ </div>
378
+ );
379
+ },
380
+ );
381
+
382
+ /* Mount only the viewport rows while retaining the full scroll extent and row positions. */
383
+ export const GanttTableUI = memo((p: GanttTableUIProps) => {
384
+ const { rows, visibleRowTexts, visibleStart, visibleEnd, ...rowProps } = p;
385
+ const width = p.columns.reduce((sum, column) => sum + column.width, 0);
386
+ return (
387
+ <div
388
+ role="rowgroup"
389
+ className="rel"
390
+ style={{ width, height: rows.length * GANTT_ROW_HEIGHT }}
391
+ >
392
+ {rows.slice(visibleStart, visibleEnd).map((row, offset) => (
393
+ <GanttTableRowUI
394
+ key={row.id}
395
+ {...rowProps}
396
+ row={row}
397
+ texts={visibleRowTexts[offset]}
398
+ index={visibleStart + offset}
399
+ />
400
+ ))}
401
+ </div>
402
+ );
403
+ });
404
+
405
+ export interface GanttHeaderUIProps {
406
+ scale: GanttScaleObj;
407
+ left: number;
408
+ width: number;
409
+ }
410
+
411
+ /* Cull translated time-axis ticks horizontally along with the scrolling chart. */
412
+ export const GanttHeaderUI = memo((p: GanttHeaderUIProps) => (
413
+ <div
414
+ className="no_shrink bg bd_b_1 bd_b_bd"
415
+ style={{ height: GANTT_HEADER_HEIGHT, width: p.scale.totalWidth }}
416
+ >
417
+ {[p.scale.majorTicks, p.scale.minorTicks].map((ticks, index) => (
418
+ <div
419
+ key={index}
420
+ className="rel bd_b_1 bd_b_bd"
421
+ style={{ height: GANTT_HEADER_HEIGHT / 2 }}
422
+ >
423
+ {ticks
424
+ .filter(
425
+ (tick) =>
426
+ tick.x + tick.width >= p.left - 100 &&
427
+ tick.x <= p.left + p.width + 100,
428
+ )
429
+ .map((tick) => (
430
+ <div
431
+ key={tick.x}
432
+ className="abs h_item h_f of bd_r_1 bd_r_bd px_4"
433
+ style={{ left: tick.x, width: tick.width, top: 0 }}
434
+ >
435
+ <span className="ellip ft_xxs cl_lt">
436
+ {tick.width >= 22 ? tick.label : ''}
437
+ </span>
438
+ </div>
439
+ ))}
440
+ </div>
441
+ ))}
442
+ </div>
443
+ ));
444
+
445
+ export interface GanttTimelineUIProps {
446
+ nonWorkingColumns?: GanttNonWorkingColumn[];
447
+ rows: GanttRowObj[];
448
+ bars: GanttBarObj[];
449
+ links: GanttLinkObj[];
450
+ scale: GanttScaleObj;
451
+ selection: GanttSelectionAtom;
452
+ visibleStart: number;
453
+ visibleEnd: number;
454
+ left: number;
455
+ width: number;
456
+ todayX?: number | null;
457
+ dataDateX?: number | null;
458
+ editable?: boolean;
459
+ onSelectRow?: GanttTableUIProps['onSelectRow'];
460
+ onBarPointerDown?: (
461
+ event: PointerEvent<HTMLDivElement>,
462
+ row: GanttRowObj,
463
+ bar: GanttBarObj,
464
+ kind:
465
+ | 'MOVE'
466
+ | 'RESIZE_START'
467
+ | 'RESIZE_FINISH'
468
+ | 'LINK_START'
469
+ | 'LINK_FINISH',
470
+ ) => void;
471
+ }
472
+
473
+ /* Draw one row's selection stripe without subscribing sibling rows to the same selection. */
474
+ const GanttTimelineRowUI = memo(
475
+ (p: {
476
+ row: GanttRowObj;
477
+ index: number;
478
+ selection: GanttSelectionAtom;
479
+ onSelectRow?: GanttTableUIProps['onSelectRow'];
480
+ }) => {
481
+ const selected = useGanttRowSelected(p.selection, p.row.id);
482
+ return (
483
+ <div
484
+ className={cn(
485
+ 'abs w_f bd_b_1 bd_b_bd',
486
+ selected ? 'bg_active' : p.row.kind === 'WBS' ? 'bg_alt' : '',
487
+ )}
488
+ style={{
489
+ top: p.index * GANTT_ROW_HEIGHT,
490
+ height: GANTT_ROW_HEIGHT,
491
+ left: 0,
492
+ }}
493
+ onClick={(event) => p.onSelectRow?.(p.row, event)}
494
+ />
495
+ );
496
+ },
497
+ );
498
+
499
+ /* Draw only visible bars, baseline shadows, float tails and intersecting dependency paths. */
500
+ export const GanttTimelineUI = memo((p: GanttTimelineUIProps) => {
501
+ const arrowId = useId().replaceAll(':', '');
502
+ const height = p.rows.length * GANTT_ROW_HEIGHT;
503
+ // Keep the SVG drawing surface bounded even when the chart spans thousands of rows.
504
+ const linkViewport = {
505
+ left: Math.max(0, p.left - 100),
506
+ top: p.visibleStart * GANTT_ROW_HEIGHT,
507
+ width: Math.max(
508
+ 1,
509
+ Math.min(p.scale.totalWidth - Math.max(0, p.left - 100), p.width + 200),
510
+ ),
511
+ height: Math.max(1, (p.visibleEnd - p.visibleStart) * GANTT_ROW_HEIGHT),
512
+ };
513
+ const bars = useMemo(
514
+ () =>
515
+ p.bars.filter(
516
+ (bar) =>
517
+ bar.rowIndex >= p.visibleStart &&
518
+ bar.rowIndex < p.visibleEnd &&
519
+ Math.max(
520
+ bar.x + bar.width,
521
+ (bar.baselineX || 0) + (bar.baselineWidth || 0),
522
+ (bar.floatX || 0) + (bar.floatWidth || 0),
523
+ ) >=
524
+ p.left - 100 &&
525
+ Math.min(bar.x, bar.baselineX ?? bar.x, bar.delayX ?? bar.x) <=
526
+ p.left + p.width + 100,
527
+ ),
528
+ [p.bars, p.visibleStart, p.visibleEnd, p.left, p.width],
529
+ );
530
+ const links = useMemo(
531
+ () =>
532
+ p.links.filter(
533
+ (link) =>
534
+ Math.max(link.fromRowIndex, link.toRowIndex) >= p.visibleStart &&
535
+ Math.min(link.fromRowIndex, link.toRowIndex) < p.visibleEnd &&
536
+ link.maxX >= p.left - 100 &&
537
+ link.minX <= p.left + p.width + 100,
538
+ ),
539
+ [p.links, p.visibleStart, p.visibleEnd, p.left, p.width],
540
+ );
541
+ return (
542
+ <div
543
+ className="rel no_shrink"
544
+ style={{ width: p.scale.totalWidth, height, minHeight: height }}
545
+ >
546
+ {(p.nonWorkingColumns || [])
547
+ .filter(
548
+ (column) =>
549
+ column.x + column.width >= p.left && column.x <= p.left + p.width,
550
+ )
551
+ .map((column) => (
552
+ <div
553
+ key={column.x}
554
+ title={column.note || undefined}
555
+ className={cn(
556
+ 'abs bg_alt',
557
+ column.isException && 'bd_dashed bd_l_1 bd_l_lt',
558
+ )}
559
+ style={{ left: column.x, width: column.width, top: 0, height }}
560
+ />
561
+ ))}
562
+ {p.scale.majorTicks
563
+ .filter((tick) => tick.x >= p.left && tick.x <= p.left + p.width)
564
+ .map((tick) => (
565
+ <div
566
+ key={tick.x}
567
+ className="abs bd_l_1 bd_l_bd"
568
+ style={{ left: tick.x, top: 0, height }}
569
+ />
570
+ ))}
571
+ {p.rows.slice(p.visibleStart, p.visibleEnd).map((row, index) => (
572
+ <GanttTimelineRowUI
573
+ key={row.id}
574
+ row={row}
575
+ index={p.visibleStart + index}
576
+ selection={p.selection}
577
+ onSelectRow={p.onSelectRow}
578
+ />
579
+ ))}
580
+ {bars.map((bar) => {
581
+ const row = p.rows[bar.rowIndex];
582
+ const top =
583
+ bar.rowIndex * GANTT_ROW_HEIGHT +
584
+ (GANTT_ROW_HEIGHT - GANTT_BAR_HEIGHT) / 2;
585
+ const movable =
586
+ p.editable &&
587
+ row.kind === 'ACTIVITY' &&
588
+ !bar.isComplete &&
589
+ !bar.isSummary;
590
+ return (
591
+ <div key={row.id}>
592
+ {bar.delayX != null && bar.delayWidth > 0 ? (
593
+ <div
594
+ className="abs pattern_stripes bg_medium"
595
+ style={{
596
+ left: bar.delayX,
597
+ width: bar.delayWidth,
598
+ top,
599
+ height: GANTT_BAR_HEIGHT,
600
+ opacity: 0.35,
601
+ pointerEvents: 'none',
602
+ }}
603
+ />
604
+ ) : null}
605
+ {bar.baselineX != null && bar.baselineWidth != null ? (
606
+ <div
607
+ className="abs bg_medium r_sm"
608
+ style={{
609
+ left: bar.baselineX,
610
+ width: bar.baselineWidth,
611
+ top: top + GANTT_BAR_HEIGHT - 3,
612
+ height: 4,
613
+ opacity: 0.7,
614
+ pointerEvents: 'none',
615
+ }}
616
+ />
617
+ ) : null}
618
+ {bar.floatX != null && !!bar.floatWidth ? (
619
+ <div
620
+ className="abs bd_t_1 bd_t_bd bd_dotted"
621
+ style={{
622
+ left: bar.floatX,
623
+ width: bar.floatWidth,
624
+ top: top + GANTT_BAR_HEIGHT / 2,
625
+ pointerEvents: 'none',
626
+ }}
627
+ />
628
+ ) : null}
629
+ <div
630
+ data-gantt-activity={row.id}
631
+ title={row.name}
632
+ role="button"
633
+ tabIndex={0}
634
+ aria-label={row.name}
635
+ className={cn(
636
+ 'abs r_sm',
637
+ bar.isComplete
638
+ ? 'bg_medium'
639
+ : bar.isCritical
640
+ ? 'bg_err'
641
+ : bar.isSummary
642
+ ? 'bg_contrast'
643
+ : 'bg_primary',
644
+ movable && 'cs_grab',
645
+ row.unreviewed && 'pattern_stripes',
646
+ )}
647
+ style={{
648
+ left: bar.x - (bar.isMilestone ? 6 : 0),
649
+ top: top + (bar.isSummary ? 4 : 0),
650
+ width: bar.isMilestone ? 12 : bar.width,
651
+ height: bar.isMilestone
652
+ ? 12
653
+ : bar.isSummary
654
+ ? 6
655
+ : GANTT_BAR_HEIGHT,
656
+ transform: bar.isMilestone ? 'rotate(45deg)' : undefined,
657
+ touchAction: movable ? 'none' : undefined,
658
+ }}
659
+ onClick={(event) => p.onSelectRow?.(row, event)}
660
+ onKeyDown={(event) => {
661
+ if (event.key === 'Enter' || event.key === ' ') {
662
+ event.preventDefault();
663
+ p.onSelectRow?.(row, event);
664
+ }
665
+ }}
666
+ onPointerDown={
667
+ movable
668
+ ? (event) => p.onBarPointerDown?.(event, row, bar, 'MOVE')
669
+ : undefined
670
+ }
671
+ >
672
+ {bar.progressWidth > 0 && !bar.isMilestone ? (
673
+ <div
674
+ className="abs bg_contrast r_sm"
675
+ style={{
676
+ left: 0,
677
+ top: 0,
678
+ width: bar.progressWidth,
679
+ height: '100%',
680
+ opacity: 0.3,
681
+ pointerEvents: 'none',
682
+ }}
683
+ />
684
+ ) : null}
685
+ {movable && !bar.isMilestone ? (
686
+ <>
687
+ <div
688
+ role="button"
689
+ aria-label={row.name}
690
+ className="abs cs_resize"
691
+ style={{ left: 0, top: 0, width: 5, height: '100%' }}
692
+ onPointerDown={(event) => {
693
+ event.stopPropagation();
694
+ p.onBarPointerDown?.(event, row, bar, 'RESIZE_START');
695
+ }}
696
+ />
697
+ <div
698
+ role="button"
699
+ aria-label={row.name}
700
+ className="abs cs_resize"
701
+ style={{ right: 0, top: 0, width: 5, height: '100%' }}
702
+ onPointerDown={(event) => {
703
+ event.stopPropagation();
704
+ p.onBarPointerDown?.(event, row, bar, 'RESIZE_FINISH');
705
+ }}
706
+ />
707
+ </>
708
+ ) : null}
709
+ {p.editable && row.kind === 'ACTIVITY' ? (
710
+ <>
711
+ <div
712
+ className="abs r bg_contrast pointer"
713
+ style={{ left: -9, top: 4, width: 6, height: 6 }}
714
+ onPointerDown={(event) => {
715
+ event.stopPropagation();
716
+ p.onBarPointerDown?.(event, row, bar, 'LINK_START');
717
+ }}
718
+ />
719
+ <div
720
+ className="abs r bg_contrast pointer"
721
+ style={{ right: -9, top: 4, width: 6, height: 6 }}
722
+ onPointerDown={(event) => {
723
+ event.stopPropagation();
724
+ p.onBarPointerDown?.(event, row, bar, 'LINK_FINISH');
725
+ }}
726
+ />
727
+ </>
728
+ ) : null}
729
+ </div>
730
+ </div>
731
+ );
732
+ })}
733
+ <svg
734
+ className="abs"
735
+ data-gantt-links
736
+ viewBox={`${linkViewport.left} ${linkViewport.top} ${linkViewport.width} ${linkViewport.height}`}
737
+ style={{
738
+ left: linkViewport.left,
739
+ top: linkViewport.top,
740
+ width: linkViewport.width,
741
+ height: linkViewport.height,
742
+ pointerEvents: 'none',
743
+ }}
744
+ aria-hidden="true"
745
+ >
746
+ <defs>
747
+ <marker
748
+ id={arrowId}
749
+ viewBox="0 0 10 10"
750
+ refX="9"
751
+ refY="5"
752
+ markerWidth="4"
753
+ markerHeight="4"
754
+ orient="auto-start-reverse"
755
+ >
756
+ <path
757
+ d="M 0 0 L 10 5 L 0 10 z"
758
+ fill="currentColor"
759
+ />
760
+ </marker>
761
+ </defs>
762
+ {links.map((link) => (
763
+ <path
764
+ key={link.id}
765
+ d={link.path}
766
+ className={link.isCritical ? 'cl_err' : 'cl_lt'}
767
+ fill="none"
768
+ stroke="currentColor"
769
+ strokeWidth={link.isDriving ? 1.5 : 1}
770
+ strokeDasharray={link.isDriving ? undefined : '3 2'}
771
+ markerEnd={`url(#${arrowId})`}
772
+ />
773
+ ))}
774
+ </svg>
775
+ {[p.dataDateX, p.todayX].map((x, index) =>
776
+ x == null ? null : (
777
+ <div
778
+ key={index}
779
+ className={cn('abs', index ? 'bg_err' : 'bg_contrast')}
780
+ style={{
781
+ left: x,
782
+ top: 0,
783
+ width: index ? 1 : 2,
784
+ height,
785
+ pointerEvents: 'none',
786
+ }}
787
+ />
788
+ ),
789
+ )}
790
+ </div>
791
+ );
792
+ });