gantt-lib 0.145.0 → 0.145.1
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/core/scheduling/index.d.mts +1 -1
- package/dist/core/scheduling/index.d.ts +1 -1
- package/dist/{index-Hg8BjZ_h.d.mts → index-Cue-aV4x.d.mts} +2 -0
- package/dist/{index-Hg8BjZ_h.d.ts → index-Cue-aV4x.d.ts} +2 -0
- package/dist/index.d.mts +8 -6
- package/dist/index.d.ts +8 -6
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +24 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -733,6 +733,29 @@ var ACTIVITY_LANES_PADDING = 2;
|
|
|
733
733
|
var DAY_MS2 = 24 * 60 * 60 * 1e3;
|
|
734
734
|
function packIntervals(intervals) {
|
|
735
735
|
const sorted = [...intervals].sort((a, b) => a.start - b.start);
|
|
736
|
+
if (intervals.some((item) => item.laneGroup !== void 0)) {
|
|
737
|
+
const groups = /* @__PURE__ */ new Map();
|
|
738
|
+
for (const item of intervals) {
|
|
739
|
+
const key = item.laneGroup ?? item;
|
|
740
|
+
const group = groups.get(key) ?? [];
|
|
741
|
+
group.push(item);
|
|
742
|
+
groups.set(key, group);
|
|
743
|
+
}
|
|
744
|
+
const lanes = [];
|
|
745
|
+
const assigned = /* @__PURE__ */ new Map();
|
|
746
|
+
for (const group of groups.values()) {
|
|
747
|
+
const compatible = lanes.findIndex((lane) => group.every((item) => !lane.some((other) => item.start < other.end && other.start < item.end)));
|
|
748
|
+
const preferred = compatible < 0 ? lanes.length : compatible;
|
|
749
|
+
for (const item of [...group].sort((a, b) => a.start - b.start)) {
|
|
750
|
+
const free = (lane2) => !lanes[lane2]?.some((other) => item.start < other.end && other.start < item.end);
|
|
751
|
+
let lane = free(preferred) ? preferred : lanes.findIndex((_, index) => free(index));
|
|
752
|
+
if (lane < 0) lane = lanes.length;
|
|
753
|
+
(lanes[lane] ?? (lanes[lane] = [])).push(item);
|
|
754
|
+
assigned.set(item, lane);
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
return sorted.map((item) => ({ ...item, lane: assigned.get(item) }));
|
|
758
|
+
}
|
|
736
759
|
const laneEnds = [];
|
|
737
760
|
return sorted.map((item) => {
|
|
738
761
|
let lane = 0;
|
|
@@ -751,6 +774,7 @@ function computeActivityLanes(activities, monthStart, dayWidth) {
|
|
|
751
774
|
const bar = calculateTaskBar(parseUTCDate(activity.startDate), parseUTCDate(activity.endDate), monthStart, dayWidth);
|
|
752
775
|
return {
|
|
753
776
|
id: activity.id,
|
|
777
|
+
laneGroup: activity.laneGroup,
|
|
754
778
|
name: activity.name,
|
|
755
779
|
color: activity.color,
|
|
756
780
|
lag: activity.lag,
|