gantt-lib 0.117.0 → 0.117.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.
- package/dist/index.d.mts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1448,19 +1448,22 @@ declare const calculateOrthogonalPath: (from: {
|
|
|
1448
1448
|
y: number;
|
|
1449
1449
|
}) => string;
|
|
1450
1450
|
|
|
1451
|
+
type HierarchyTask = Task$1 & {
|
|
1452
|
+
sortOrder?: number;
|
|
1453
|
+
};
|
|
1451
1454
|
/**
|
|
1452
1455
|
* Build a stable depth-first task order from parentId links.
|
|
1453
1456
|
* Sibling order follows the order in the input array.
|
|
1454
1457
|
* Tasks with missing parents are treated as root tasks.
|
|
1455
1458
|
*/
|
|
1456
|
-
declare function flattenHierarchy<T extends
|
|
1459
|
+
declare function flattenHierarchy<T extends HierarchyTask>(tasks: T[]): T[];
|
|
1457
1460
|
/**
|
|
1458
1461
|
* Normalize hierarchy-aware display fields.
|
|
1459
1462
|
* Parent task dates and progress are always recomputed from children,
|
|
1460
1463
|
* taking precedence over any hardcoded parent values from the input.
|
|
1461
1464
|
* Also normalizes task dates to ensure startDate is always before or equal to endDate.
|
|
1462
1465
|
*/
|
|
1463
|
-
declare function normalizeHierarchyTasks<T extends
|
|
1466
|
+
declare function normalizeHierarchyTasks<T extends HierarchyTask>(tasks: T[]): T[];
|
|
1464
1467
|
|
|
1465
1468
|
interface ResourceTimelineLayoutOptions {
|
|
1466
1469
|
monthStart: Date;
|
package/dist/index.d.ts
CHANGED
|
@@ -1448,19 +1448,22 @@ declare const calculateOrthogonalPath: (from: {
|
|
|
1448
1448
|
y: number;
|
|
1449
1449
|
}) => string;
|
|
1450
1450
|
|
|
1451
|
+
type HierarchyTask = Task$1 & {
|
|
1452
|
+
sortOrder?: number;
|
|
1453
|
+
};
|
|
1451
1454
|
/**
|
|
1452
1455
|
* Build a stable depth-first task order from parentId links.
|
|
1453
1456
|
* Sibling order follows the order in the input array.
|
|
1454
1457
|
* Tasks with missing parents are treated as root tasks.
|
|
1455
1458
|
*/
|
|
1456
|
-
declare function flattenHierarchy<T extends
|
|
1459
|
+
declare function flattenHierarchy<T extends HierarchyTask>(tasks: T[]): T[];
|
|
1457
1460
|
/**
|
|
1458
1461
|
* Normalize hierarchy-aware display fields.
|
|
1459
1462
|
* Parent task dates and progress are always recomputed from children,
|
|
1460
1463
|
* taking precedence over any hardcoded parent values from the input.
|
|
1461
1464
|
* Also normalizes task dates to ensure startDate is always before or equal to endDate.
|
|
1462
1465
|
*/
|
|
1463
|
-
declare function normalizeHierarchyTasks<T extends
|
|
1466
|
+
declare function normalizeHierarchyTasks<T extends HierarchyTask>(tasks: T[]): T[];
|
|
1464
1467
|
|
|
1465
1468
|
interface ResourceTimelineLayoutOptions {
|
|
1466
1469
|
monthStart: Date;
|
package/dist/index.js
CHANGED
|
@@ -1669,12 +1669,27 @@ function validateDependencies(tasks) {
|
|
|
1669
1669
|
function flattenHierarchy(tasks) {
|
|
1670
1670
|
const byId = new Map(tasks.map((task) => [task.id, task]));
|
|
1671
1671
|
const byParent = /* @__PURE__ */ new Map();
|
|
1672
|
+
const originalIndexById = new Map(tasks.map((task, index) => [task.id, index]));
|
|
1672
1673
|
for (const task of tasks) {
|
|
1673
1674
|
const normalizedParentId = task.parentId && byId.has(task.parentId) ? task.parentId : void 0;
|
|
1674
1675
|
const siblings = byParent.get(normalizedParentId) ?? [];
|
|
1675
1676
|
siblings.push(task);
|
|
1676
1677
|
byParent.set(normalizedParentId, siblings);
|
|
1677
1678
|
}
|
|
1679
|
+
for (const siblings of byParent.values()) {
|
|
1680
|
+
siblings.sort((left, right) => {
|
|
1681
|
+
const leftSortOrder = left.sortOrder;
|
|
1682
|
+
const rightSortOrder = right.sortOrder;
|
|
1683
|
+
if (leftSortOrder !== void 0 || rightSortOrder !== void 0) {
|
|
1684
|
+
const normalizedLeftSortOrder = leftSortOrder ?? Number.MAX_SAFE_INTEGER;
|
|
1685
|
+
const normalizedRightSortOrder = rightSortOrder ?? Number.MAX_SAFE_INTEGER;
|
|
1686
|
+
if (normalizedLeftSortOrder !== normalizedRightSortOrder) {
|
|
1687
|
+
return normalizedLeftSortOrder - normalizedRightSortOrder;
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
return (originalIndexById.get(left.id) ?? 0) - (originalIndexById.get(right.id) ?? 0);
|
|
1691
|
+
});
|
|
1692
|
+
}
|
|
1678
1693
|
const result = [];
|
|
1679
1694
|
const visited = /* @__PURE__ */ new Set();
|
|
1680
1695
|
const walk = (parentId) => {
|