gantt-renderer 0.10.0 → 0.12.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.
- package/CHANGELOG.md +19 -0
- package/dist/index.d.mts +23 -5
- package/dist/index.mjs +47 -10
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
# [0.12.0](https://github.com/doberkofler/gantt-renderer/compare/v0.11.0...v0.12.0) (2026-05-18)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **gantt:** align timeline right edge to full scale bucket ([614cd66](https://github.com/doberkofler/gantt-renderer/commit/614cd66e93ae7c7a7c6a71034feafce19299aad7))
|
|
7
|
+
|
|
8
|
+
# [0.11.0](https://github.com/doberkofler/gantt-renderer/compare/v0.10.0...v0.11.0) (2026-05-13)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **gantt:** default fireCallback to false on select, collapseAll, and expandAll ([2572d4c](https://github.com/doberkofler/gantt-renderer/commit/2572d4c0c75b672b5f2d98d9a1dfde5fb30a421d))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* **gantt:** add getOpenStates instance method ([8c8b09c](https://github.com/doberkofler/gantt-renderer/commit/8c8b09cf323b45cc237e969ea190fb7cd7cb5428))
|
|
19
|
+
|
|
1
20
|
# [0.10.0](https://github.com/doberkofler/gantt-renderer/compare/v0.9.0...v0.10.0) (2026-05-13)
|
|
2
21
|
|
|
3
22
|
|
package/dist/index.d.mts
CHANGED
|
@@ -552,8 +552,12 @@ type GanttInstance<TTaskData = never, TLinkData = never> = {
|
|
|
552
552
|
setOptions: (opts: Partial<GanttOptions>) => void;
|
|
553
553
|
setCallbacks: (cbs: GanttCallbacks<TTaskData, TLinkData>) => void;
|
|
554
554
|
select: (id: number | null, fireCallback?: boolean) => void;
|
|
555
|
-
collapseAll: () => void;
|
|
556
|
-
expandAll: () => void;
|
|
555
|
+
collapseAll: (fireCallback?: boolean) => void;
|
|
556
|
+
expandAll: (fireCallback?: boolean) => void;
|
|
557
|
+
getOpenStates: () => {
|
|
558
|
+
id: number;
|
|
559
|
+
open: boolean;
|
|
560
|
+
}[];
|
|
557
561
|
destroy: () => void;
|
|
558
562
|
};
|
|
559
563
|
/**
|
|
@@ -612,22 +616,36 @@ declare class GanttChart<TTaskData = never, TLinkData = never> implements GanttI
|
|
|
612
616
|
* Programmatically selects or deselects a task.
|
|
613
617
|
*
|
|
614
618
|
* @param id - The task ID to select, or `null` to clear the selection.
|
|
615
|
-
* @param fireCallback - Whether to fire the `onTaskClick` callback. Default `
|
|
619
|
+
* @param fireCallback - Whether to fire the `onTaskClick` callback. Default `false`.
|
|
616
620
|
* @throws {GanttError} When the instance has been destroyed.
|
|
617
621
|
*/
|
|
618
622
|
select(id: number | null, fireCallback?: boolean): void;
|
|
619
623
|
/**
|
|
620
624
|
* Collapses all expandable groups in the task tree.
|
|
621
625
|
*
|
|
626
|
+
* @param fireCallback - Whether to fire the `onExpandCollapseAll` callback. Default `false`.
|
|
622
627
|
* @throws {GanttError} When the instance has been destroyed.
|
|
623
628
|
*/
|
|
624
|
-
collapseAll(): void;
|
|
629
|
+
collapseAll(fireCallback?: boolean): void;
|
|
625
630
|
/**
|
|
626
631
|
* Expands all expandable groups in the task tree.
|
|
627
632
|
*
|
|
633
|
+
* @param fireCallback - Whether to fire the `onExpandCollapseAll` callback. Default `false`.
|
|
634
|
+
* @throws {GanttError} When the instance has been destroyed.
|
|
635
|
+
*/
|
|
636
|
+
expandAll(fireCallback?: boolean): void;
|
|
637
|
+
/**
|
|
638
|
+
* Returns the current expand/collapse state of every expandable node
|
|
639
|
+
* (project tasks that have children). The result is ordered by the
|
|
640
|
+
* input task list order.
|
|
641
|
+
*
|
|
642
|
+
* @returns An array of `{id, open}` objects for expandable nodes only.
|
|
628
643
|
* @throws {GanttError} When the instance has been destroyed.
|
|
629
644
|
*/
|
|
630
|
-
|
|
645
|
+
getOpenStates(): {
|
|
646
|
+
id: number;
|
|
647
|
+
open: boolean;
|
|
648
|
+
}[];
|
|
631
649
|
/**
|
|
632
650
|
* Removes the chart DOM and internal listeners, rendering the instance
|
|
633
651
|
* unusable. Subsequent calls to any public method will throw.
|
package/dist/index.mjs
CHANGED
|
@@ -706,6 +706,20 @@ function nextScaleBoundary(date, scale) {
|
|
|
706
706
|
case "year": return new Date(Date.UTC(date.getUTCFullYear() + 1, 0, 1));
|
|
707
707
|
}
|
|
708
708
|
}
|
|
709
|
+
/**
|
|
710
|
+
* Rounds a date up to the end boundary of the containing scale bucket.
|
|
711
|
+
* If the date is already on a boundary, it is returned unchanged.
|
|
712
|
+
*
|
|
713
|
+
* @param date - The date to round.
|
|
714
|
+
* @param scale - The target {@link TimeScale}.
|
|
715
|
+
* @param weekStartsOn - First day of the week (`0`-Sun, `1`-Mon, `6`-Sat). Defaults to `1` (Monday).
|
|
716
|
+
* @returns A boundary-aligned date at or after the input.
|
|
717
|
+
*/
|
|
718
|
+
function ceilToScaleBoundary(date, scale, weekStartsOn = 1) {
|
|
719
|
+
const start = snapToScaleBoundary(date, scale, weekStartsOn);
|
|
720
|
+
if (start.getTime() === date.getTime()) return start;
|
|
721
|
+
return nextScaleBoundary(start, scale);
|
|
722
|
+
}
|
|
709
723
|
//#endregion
|
|
710
724
|
//#region src/lib/timeline/pixelMapper.ts
|
|
711
725
|
/**
|
|
@@ -3316,10 +3330,10 @@ var GanttChart = class {
|
|
|
3316
3330
|
* Programmatically selects or deselects a task.
|
|
3317
3331
|
*
|
|
3318
3332
|
* @param id - The task ID to select, or `null` to clear the selection.
|
|
3319
|
-
* @param fireCallback - Whether to fire the `onTaskClick` callback. Default `
|
|
3333
|
+
* @param fireCallback - Whether to fire the `onTaskClick` callback. Default `false`.
|
|
3320
3334
|
* @throws {GanttError} When the instance has been destroyed.
|
|
3321
3335
|
*/
|
|
3322
|
-
select(id, fireCallback =
|
|
3336
|
+
select(id, fireCallback = false) {
|
|
3323
3337
|
this.#assertAlive();
|
|
3324
3338
|
if (id === null) this.#selectedId = null;
|
|
3325
3339
|
else {
|
|
@@ -3340,11 +3354,12 @@ var GanttChart = class {
|
|
|
3340
3354
|
/**
|
|
3341
3355
|
* Collapses all expandable groups in the task tree.
|
|
3342
3356
|
*
|
|
3357
|
+
* @param fireCallback - Whether to fire the `onExpandCollapseAll` callback. Default `false`.
|
|
3343
3358
|
* @throws {GanttError} When the instance has been destroyed.
|
|
3344
3359
|
*/
|
|
3345
|
-
collapseAll() {
|
|
3360
|
+
collapseAll(fireCallback = false) {
|
|
3346
3361
|
this.#assertAlive();
|
|
3347
|
-
const changed = this.#buildExpandCollapseAllPayload(false);
|
|
3362
|
+
const changed = fireCallback ? this.#buildExpandCollapseAllPayload(false) : [];
|
|
3348
3363
|
this.#expandedIds.clear();
|
|
3349
3364
|
if (this.#rafPending && this.#rafId !== null) {
|
|
3350
3365
|
cancelAnimationFrame(this.#rafId);
|
|
@@ -3360,11 +3375,12 @@ var GanttChart = class {
|
|
|
3360
3375
|
/**
|
|
3361
3376
|
* Expands all expandable groups in the task tree.
|
|
3362
3377
|
*
|
|
3378
|
+
* @param fireCallback - Whether to fire the `onExpandCollapseAll` callback. Default `false`.
|
|
3363
3379
|
* @throws {GanttError} When the instance has been destroyed.
|
|
3364
3380
|
*/
|
|
3365
|
-
expandAll() {
|
|
3381
|
+
expandAll(fireCallback = false) {
|
|
3366
3382
|
this.#assertAlive();
|
|
3367
|
-
const changed = this.#buildExpandCollapseAllPayload(true);
|
|
3383
|
+
const changed = fireCallback ? this.#buildExpandCollapseAllPayload(true) : [];
|
|
3368
3384
|
this.#expandedIds.clear();
|
|
3369
3385
|
if (this.#input !== null) for (const id of getExpandableTaskIds(this.#input.tasks)) this.#expandedIds.add(id);
|
|
3370
3386
|
if (this.#rafPending && this.#rafId !== null) {
|
|
@@ -3392,6 +3408,25 @@ var GanttChart = class {
|
|
|
3392
3408
|
return changed;
|
|
3393
3409
|
}
|
|
3394
3410
|
/**
|
|
3411
|
+
* Returns the current expand/collapse state of every expandable node
|
|
3412
|
+
* (project tasks that have children). The result is ordered by the
|
|
3413
|
+
* input task list order.
|
|
3414
|
+
*
|
|
3415
|
+
* @returns An array of `{id, open}` objects for expandable nodes only.
|
|
3416
|
+
* @throws {GanttError} When the instance has been destroyed.
|
|
3417
|
+
*/
|
|
3418
|
+
getOpenStates() {
|
|
3419
|
+
this.#assertAlive();
|
|
3420
|
+
if (this.#input === null) return [];
|
|
3421
|
+
const expandableIds = getExpandableTaskIds(this.#input.tasks);
|
|
3422
|
+
const result = [];
|
|
3423
|
+
for (const task of this.#input.tasks) if (expandableIds.has(task.id)) result.push({
|
|
3424
|
+
id: task.id,
|
|
3425
|
+
open: this.#expandedIds.has(task.id)
|
|
3426
|
+
});
|
|
3427
|
+
return result;
|
|
3428
|
+
}
|
|
3429
|
+
/**
|
|
3395
3430
|
* Removes the chart DOM and internal listeners, rendering the instance
|
|
3396
3431
|
* unusable. Subsequent calls to any public method will throw.
|
|
3397
3432
|
*/
|
|
@@ -3471,8 +3506,10 @@ var GanttChart = class {
|
|
|
3471
3506
|
#computeState(input) {
|
|
3472
3507
|
const allRows = flattenTree(buildTaskTree(input.tasks), this.#expandedIds);
|
|
3473
3508
|
const [vpStart, vpEnd] = this.#opts.viewportStart !== void 0 && this.#opts.viewportEnd !== void 0 ? [this.#opts.viewportStart, this.#opts.viewportEnd] : deriveViewport(allRows, 48);
|
|
3509
|
+
const weekStartsOn = this.#locale.weekStartsOn ?? 1;
|
|
3510
|
+
const renderViewportEnd = ceilToScaleBoundary(vpEnd, this.#scale, weekStartsOn);
|
|
3474
3511
|
const mapper = createPixelMapper(this.#scale, vpStart);
|
|
3475
|
-
const totalWidth = Math.ceil(mapper.toX(
|
|
3512
|
+
const totalWidth = Math.ceil(mapper.toX(renderViewportEnd)) + 1;
|
|
3476
3513
|
const layouts = computeLayout(allRows, mapper);
|
|
3477
3514
|
const links = routeLinks(input.links, layouts);
|
|
3478
3515
|
const containerH = this.#height - HEADER_H;
|
|
@@ -3493,7 +3530,7 @@ var GanttChart = class {
|
|
|
3493
3530
|
allRows,
|
|
3494
3531
|
mapper,
|
|
3495
3532
|
viewportStart: vpStart,
|
|
3496
|
-
viewportEnd:
|
|
3533
|
+
viewportEnd: renderViewportEnd,
|
|
3497
3534
|
totalWidth,
|
|
3498
3535
|
layouts,
|
|
3499
3536
|
links,
|
|
@@ -3573,11 +3610,11 @@ var GanttChart = class {
|
|
|
3573
3610
|
const collapseBtn = headerEl.querySelector(".gantt-header-collapse-btn");
|
|
3574
3611
|
if (expandBtn !== null) expandBtn.addEventListener("click", (e) => {
|
|
3575
3612
|
e.stopPropagation();
|
|
3576
|
-
this.expandAll();
|
|
3613
|
+
this.expandAll(true);
|
|
3577
3614
|
});
|
|
3578
3615
|
if (collapseBtn !== null) collapseBtn.addEventListener("click", (e) => {
|
|
3579
3616
|
e.stopPropagation();
|
|
3580
|
-
this.collapseAll();
|
|
3617
|
+
this.collapseAll(true);
|
|
3581
3618
|
});
|
|
3582
3619
|
}
|
|
3583
3620
|
#scheduleRender() {
|