@mogura/moguchart-core 0.8.1 → 0.9.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/README.en.md +4 -0
- package/README.md +3 -1
- package/dist/moguchart-core.mjs +66 -56
- package/dist/moguchart-core.umd.js +19 -18
- package/package.json +11 -3
package/README.en.md
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
# @mogura/moguchart-core
|
|
2
2
|
|
|
3
|
+
[日本語](./README.md) | [Demo](https://moguchart-core.vercel.app/)
|
|
4
|
+
|
|
3
5
|
A lightweight yet feature-rich Gantt chart Web Component built with Lit. Works with Vue, React, Angular, Svelte, and any other framework.
|
|
4
6
|
|
|
7
|
+
- **Demo**: [https://moguchart-core.vercel.app/](https://moguchart-core.vercel.app/)
|
|
8
|
+
|
|
5
9
|
## Features
|
|
6
10
|
|
|
7
11
|
- 🚀 **Framework-agnostic**: Built as Web Components (Custom Elements), works in any environment.
|
package/README.md
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
# @mogura/moguchart-core
|
|
2
2
|
|
|
3
|
-
[English](./README.en.md)
|
|
3
|
+
[English](./README.en.md) | [Demo](https://moguchart-core.vercel.app/)
|
|
4
4
|
|
|
5
5
|
Vue, React, Angular, Svelte など、どのフレームワークでも動作する、軽量で高機能な Web Components 製ガントチャートコンポーネントです。Lit で構築されています。
|
|
6
6
|
|
|
7
|
+
- **デモ**: [https://moguchart-core.vercel.app/](https://moguchart-core.vercel.app/)
|
|
8
|
+
|
|
7
9
|
## 特徴
|
|
8
10
|
|
|
9
11
|
- 🚀 **フレームワーク非依存**: Web Components (Custom Elements) として実装されており、あらゆる環境で動作します。
|
package/dist/moguchart-core.mjs
CHANGED
|
@@ -214,7 +214,7 @@ var k = {
|
|
|
214
214
|
let n = t.getFullYear(), i = t.getMonth(), a = e.getFullYear(), o = e.getMonth(), s = (a - n) * 12 + (o - i), c = new Date(n, i + 1, 0).getDate(), l = (t.getDate() - 1 + t.getHours() / 24 + t.getMinutes() / 1440) / c, u = new Date(a, o + 1, 0).getDate();
|
|
215
215
|
return (s + (e.getDate() - 1 + e.getHours() / 24 + e.getMinutes() / 1440) / u - l) * r;
|
|
216
216
|
}
|
|
217
|
-
return (e.getTime() - t.getTime()) /
|
|
217
|
+
return (e.getTime() - t.getTime()) / 864e5 * n;
|
|
218
218
|
}, N = (e, t, n, r) => {
|
|
219
219
|
if (r !== void 0) {
|
|
220
220
|
let n = t.getFullYear(), i = t.getMonth(), a = new Date(n, i + 1, 0).getDate(), o = (t.getDate() - 1 + t.getHours() / 24 + t.getMinutes() / 1440) / a, s = e / r + o, c = i + Math.floor(s), l = n + Math.floor(c / 12);
|
|
@@ -263,10 +263,10 @@ var F = (e, t) => ({
|
|
|
263
263
|
][r];
|
|
264
264
|
};
|
|
265
265
|
function L(e, t) {
|
|
266
|
-
return (t.getTime() - e.getTime()) /
|
|
266
|
+
return (t.getTime() - e.getTime()) / 864e5;
|
|
267
267
|
}
|
|
268
268
|
var R = (e, t, n) => {
|
|
269
|
-
let r = n ?? k, i = t.getTime() - e.getTime(), a = Math.floor(i /
|
|
269
|
+
let r = n ?? k, i = t.getTime() - e.getTime(), a = Math.floor(i / 864e5), o = i % 864e5, s = Math.floor(o / 36e5), c = o % 36e5, l = Math.floor(c / 6e4), u = "";
|
|
270
270
|
return a > 0 && (u += r.duration.days(a)), s > 0 && (u += r.duration.hours(s)), l > 0 && (u += r.duration.minutes(l)), u || r.duration.zero;
|
|
271
271
|
}, z = {
|
|
272
272
|
BAR: "#3b82f6",
|
|
@@ -277,7 +277,7 @@ var R = (e, t, n) => {
|
|
|
277
277
|
BORDER: "#e2e8f0"
|
|
278
278
|
}.BAR;
|
|
279
279
|
//#endregion
|
|
280
|
-
//#region \0@oxc-project+runtime@0.
|
|
280
|
+
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/decorate.js
|
|
281
281
|
function B(e, t, n, r) {
|
|
282
282
|
var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
|
|
283
283
|
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
|
|
@@ -487,7 +487,7 @@ var V, H = class extends e {
|
|
|
487
487
|
onResizeStart(e, t) {
|
|
488
488
|
e.stopPropagation();
|
|
489
489
|
let n = e.target, r = this.task.movable ?? "both", i = this.task.resizable, a = !this.option.readOnly;
|
|
490
|
-
if (a &&= i === void 0 ?
|
|
490
|
+
if (a &&= i === void 0 ? r !== "y" && r !== "none" : i, !a) return;
|
|
491
491
|
let o = this.shadowRoot?.querySelector(".bar");
|
|
492
492
|
if (!o) return;
|
|
493
493
|
o.style.pointerEvents = "none";
|
|
@@ -586,7 +586,7 @@ var V, H = class extends e {
|
|
|
586
586
|
r === "y" && (p = 0), r === "x" && (m = 0), this.multiDragActive && !this.multiDragSameRow && (m = 0);
|
|
587
587
|
let h = p;
|
|
588
588
|
if (this.option.calendar.pxPerMonth) {
|
|
589
|
-
let e = N(this.getX(o) + p, this.option.calendar.start, 50, this.option.calendar.pxPerMonth), t = (e.getFullYear() - o.getFullYear()) * 12 + (e.getMonth() - o.getMonth()) + (e.getDate() > 15
|
|
589
|
+
let e = N(this.getX(o) + p, this.option.calendar.start, 50, this.option.calendar.pxPerMonth), t = (e.getFullYear() - o.getFullYear()) * 12 + (e.getMonth() - o.getMonth()) + +(e.getDate() > 15), n = new Date(o);
|
|
590
590
|
n.setMonth(n.getMonth() + t), h = this.getX(n) - this.getX(o);
|
|
591
591
|
} else {
|
|
592
592
|
let e = this.option.calendar.pxPerDay / 1440 * c;
|
|
@@ -638,7 +638,7 @@ var V, H = class extends e {
|
|
|
638
638
|
else if (u) {
|
|
639
639
|
let e = u.clientX - i, t = e;
|
|
640
640
|
if (this.option.calendar.pxPerMonth) {
|
|
641
|
-
let n = N(this.getX(o) + e, this.option.calendar.start, 50, this.option.calendar.pxPerMonth), r = (n.getFullYear() - o.getFullYear()) * 12 + (n.getMonth() - o.getMonth()) + (n.getDate() > 15
|
|
641
|
+
let n = N(this.getX(o) + e, this.option.calendar.start, 50, this.option.calendar.pxPerMonth), r = (n.getFullYear() - o.getFullYear()) * 12 + (n.getMonth() - o.getMonth()) + +(n.getDate() > 15), i = new Date(o);
|
|
642
642
|
i.setMonth(i.getMonth() + r), t = this.getX(i) - this.getX(o);
|
|
643
643
|
} else {
|
|
644
644
|
let n = this.option.calendar.pxPerDay / 1440 * c;
|
|
@@ -815,7 +815,7 @@ var V, H = class extends e {
|
|
|
815
815
|
render() {
|
|
816
816
|
if (!this.task || !this.option) return n``;
|
|
817
817
|
let e = this.getX(this.task.start), t = this.getX(this.task.end) - e, r = this.option.bar?.height ?? 28, i = this.option.bar?.margin ?? 4, a = this.option.bar?.cornerRadius ?? 4, o = this.lane * (r + i) + i, s = this.option.readOnly, c = this.task.movable ?? "both", l = this.task.resizable, u = !s && c !== "none", d = !s;
|
|
818
|
-
return d &&= l === void 0 ?
|
|
818
|
+
return d &&= l === void 0 ? c !== "y" && c !== "none" : l, n`
|
|
819
819
|
<div
|
|
820
820
|
class="task-group"
|
|
821
821
|
style="
|
|
@@ -1140,7 +1140,7 @@ var U = class extends e {
|
|
|
1140
1140
|
let u = this._cachedDays, d = this._cachedMonths, f = this._cachedYears, p = `
|
|
1141
1141
|
background-image: linear-gradient(90deg, transparent ${this.option.calendar.pxPerDay - 1}px, ${e.border} ${this.option.calendar.pxPerDay - 1}px);
|
|
1142
1142
|
background-size: ${this.option.calendar.pxPerDay}px 100%;
|
|
1143
|
-
`, m = this.option.calendar.pxPerDay / 24, h = this.option.calendar.pxPerDay, g = this.option.customTheme?.showTimeDateLine ?? e.monthGridLine ?? e.border, _ = this.option.calendar.start, v = (_.getHours() * 60 * 60 * 1e3 + _.getMinutes() * 60 * 1e3 + _.getSeconds() * 1e3) /
|
|
1143
|
+
`, m = this.option.calendar.pxPerDay / 24, h = this.option.calendar.pxPerDay, g = this.option.customTheme?.showTimeDateLine ?? e.monthGridLine ?? e.border, _ = this.option.calendar.start, v = (_.getHours() * 60 * 60 * 1e3 + _.getMinutes() * 60 * 1e3 + _.getSeconds() * 1e3) / 864e5 * h, y = v % m, b = v === 0 ? "0px 0" : `${-v}px 0`, x = y === 0 ? "0px 0" : `${-y}px 0`, S = `
|
|
1144
1144
|
background-image: linear-gradient(90deg, transparent ${h - 1}px, ${g} ${h - 1}px), linear-gradient(90deg, transparent ${m - 1}px, ${e.border} ${m - 1}px);
|
|
1145
1145
|
background-size: ${h}px 100%, ${m}px 100%;
|
|
1146
1146
|
background-position: ${b}, ${x};
|
|
@@ -1150,7 +1150,7 @@ var U = class extends e {
|
|
|
1150
1150
|
for (n.setHours(0, 0, 0, 0); n.getTime() < t.getTime();) {
|
|
1151
1151
|
let r = n.getTime() < e.getTime() ? e : n, i = new Date(n);
|
|
1152
1152
|
i.setDate(i.getDate() + 1);
|
|
1153
|
-
let a = i.getTime() > t.getTime() ? t : i, o = r.getHours(), s = a.getHours(), c = a.getMinutes() > 0 || a.getSeconds() > 0 || a.getMilliseconds() > 0, l = s === 0 && !c ? 24 : c ? s + 1 : s, u = (a.getTime() - r.getTime()) /
|
|
1153
|
+
let a = i.getTime() > t.getTime() ? t : i, o = r.getHours(), s = a.getHours(), c = a.getMinutes() > 0 || a.getSeconds() > 0 || a.getMilliseconds() > 0, l = s === 0 && !c ? 24 : c ? s + 1 : s, u = (a.getTime() - r.getTime()) / 36e5;
|
|
1154
1154
|
C.push({
|
|
1155
1155
|
date: new Date(n),
|
|
1156
1156
|
hStart: o,
|
|
@@ -1411,23 +1411,27 @@ var W = class extends e {
|
|
|
1411
1411
|
}
|
|
1412
1412
|
render() {
|
|
1413
1413
|
let e = F(this.theme, this.option.customTheme), t = this.option.calendar.start.getTime(), r = this.option.calendar.end.getTime(), i = this.option.calendar.pxPerDay ?? 50, a = this.option.calendar.pxPerMonth;
|
|
1414
|
-
(!this._cachedCells || t !== this._cachedCellsStartTime || r !== this._cachedCellsEndTime || i !== this._cachedCellsPxPerDay || a !== this._cachedCellsPxPerMonth || this.theme !== this._cachedCellsTheme)
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1414
|
+
if (!this._cachedCells || t !== this._cachedCellsStartTime || r !== this._cachedCellsEndTime || i !== this._cachedCellsPxPerDay || a !== this._cachedCellsPxPerMonth || this.theme !== this._cachedCellsTheme) {
|
|
1415
|
+
this._cachedCellsStartTime = t, this._cachedCellsEndTime = r, this._cachedCellsPxPerDay = i, this._cachedCellsPxPerMonth = a, this._cachedCellsTheme = this.theme;
|
|
1416
|
+
let n = Array.from({ length: Math.ceil(this.totalDays) }, (e, t) => {
|
|
1417
|
+
let n = new Date(this.option.calendar.start);
|
|
1418
|
+
return n.setDate(n.getDate() + t), n;
|
|
1419
|
+
});
|
|
1420
|
+
this._cachedCells = n.map((t) => {
|
|
1421
|
+
let n = I(t, e, this.option.calendar.isHoliday), r = new Date(t);
|
|
1422
|
+
r.setDate(t.getDate() + 1);
|
|
1423
|
+
let o = M(t, this.option.calendar.start, i, a);
|
|
1424
|
+
return {
|
|
1425
|
+
width: M(r, this.option.calendar.start, i, a) - o,
|
|
1426
|
+
color: n,
|
|
1427
|
+
date: t
|
|
1428
|
+
};
|
|
1429
|
+
});
|
|
1430
|
+
}
|
|
1427
1431
|
let o = this.option.customRendering?.chartBackground;
|
|
1428
1432
|
return o ? n`
|
|
1429
1433
|
${this._cachedCells.map(({ width: e, color: t, date: r }, i) => {
|
|
1430
|
-
let a = r.getDay(), s = this.option.calendar.isHoliday ? this.option.calendar.isHoliday(r) : !1, c =
|
|
1434
|
+
let a = r.getDay(), s = this.option.calendar.isHoliday ? this.option.calendar.isHoliday(r) : !1, c = {
|
|
1431
1435
|
date: r,
|
|
1432
1436
|
width: e,
|
|
1433
1437
|
height: this.clientHeight || 0,
|
|
@@ -1437,14 +1441,14 @@ var W = class extends e {
|
|
|
1437
1441
|
isHoliday: s,
|
|
1438
1442
|
defaultColor: t,
|
|
1439
1443
|
index: i
|
|
1440
|
-
});
|
|
1441
|
-
return typeof
|
|
1444
|
+
}, l = o(c);
|
|
1445
|
+
return typeof l == "string" ? n`<div
|
|
1442
1446
|
class="bg-cell"
|
|
1443
1447
|
style="width: ${e}px; background-color: ${t};"
|
|
1444
|
-
><div style="position: absolute; inset: 0;">${n`${
|
|
1448
|
+
><div style="position: absolute; inset: 0;">${n`${l}`}</div></div>` : n`<div
|
|
1445
1449
|
class="bg-cell"
|
|
1446
1450
|
style="width: ${e}px; background-color: ${t};"
|
|
1447
|
-
><div style="position: absolute; inset: 0;">${
|
|
1451
|
+
><div style="position: absolute; inset: 0;">${l}</div></div>`;
|
|
1448
1452
|
})}
|
|
1449
1453
|
` : n`
|
|
1450
1454
|
${this._cachedCells.map(({ width: e, color: t }) => n`<div
|
|
@@ -1709,7 +1713,10 @@ var G = class extends e {
|
|
|
1709
1713
|
updated(e) {
|
|
1710
1714
|
if (super.updated(e), !(e.has("row") || e.has("option") || e.has("isSelected") || e.has("theme"))) return;
|
|
1711
1715
|
let t = this.shadowRoot?.querySelector(".row-header-content");
|
|
1712
|
-
|
|
1716
|
+
if (t) {
|
|
1717
|
+
let e = this.option.customRendering?.rowHeaderContent ? this.option.customRendering.rowHeaderContent(this.row) : this.row.name;
|
|
1718
|
+
r(e, t);
|
|
1719
|
+
}
|
|
1713
1720
|
}
|
|
1714
1721
|
render() {
|
|
1715
1722
|
let e = F(this.theme, this.option.customTheme), t = [...this.row.tasks];
|
|
@@ -1764,7 +1771,7 @@ var G = class extends e {
|
|
|
1764
1771
|
}
|
|
1765
1772
|
if (_ = this._cachedMonthGridLines, this.option.calendar.showMonthsRow) g = "";
|
|
1766
1773
|
else if (this.option.calendar.showTime) {
|
|
1767
|
-
let t = this.option.calendar.pxPerDay / 24, n = this.option.snapDuration ?? 60, r = this.option.calendar.pxPerDay / 1440 * n, i = this.option.calendar.pxPerDay, a = this.option.customTheme?.showTimeDateLine ?? e.monthGridLine ?? e.gridLine, o = this.option.calendar.start, s = (o.getHours() * 60 * 60 * 1e3 + o.getMinutes() * 60 * 1e3 + o.getSeconds() * 1e3) /
|
|
1774
|
+
let t = this.option.calendar.pxPerDay / 24, n = this.option.snapDuration ?? 60, r = this.option.calendar.pxPerDay / 1440 * n, i = this.option.calendar.pxPerDay, a = this.option.customTheme?.showTimeDateLine ?? e.monthGridLine ?? e.gridLine, o = this.option.calendar.start, s = (o.getHours() * 60 * 60 * 1e3 + o.getMinutes() * 60 * 1e3 + o.getSeconds() * 1e3) / 864e5 * i, c = s % t, l = s % r, u = s === 0 ? "0px 0" : `${-s}px 0`, d = c === 0 ? "0px 0" : `${-c}px 0`, f = l === 0 ? "0px 0" : `${-l}px 0`, p = [
|
|
1768
1775
|
`linear-gradient(90deg, transparent ${i - 1}px, ${a} ${i - 1}px)`,
|
|
1769
1776
|
`linear-gradient(90deg, transparent ${t - 1}px, ${e.gridLine} ${t - 1}px)`,
|
|
1770
1777
|
`linear-gradient(90deg, transparent ${r - 1}px, ${e.subGridLine} ${r - 1}px)`
|
|
@@ -1783,7 +1790,7 @@ var G = class extends e {
|
|
|
1783
1790
|
background-position: ${h.join(", ")};
|
|
1784
1791
|
`;
|
|
1785
1792
|
} else {
|
|
1786
|
-
let t = this.option.calendar.pxPerDay, n = this.option.calendar.start, r = (n.getHours() * 60 * 60 * 1e3 + n.getMinutes() * 60 * 1e3 + n.getSeconds() * 1e3) /
|
|
1793
|
+
let t = this.option.calendar.pxPerDay, n = this.option.calendar.start, r = (n.getHours() * 60 * 60 * 1e3 + n.getMinutes() * 60 * 1e3 + n.getSeconds() * 1e3) / 864e5 * t, i = r === 0 ? "0px 0" : `${-r}px 0`;
|
|
1787
1794
|
g = `
|
|
1788
1795
|
background-image: linear-gradient(90deg, transparent ${t - 1}px, ${e.gridLine} ${t - 1}px);
|
|
1789
1796
|
background-size: ${t}px 100%;
|
|
@@ -1844,6 +1851,7 @@ var G = class extends e {
|
|
|
1844
1851
|
@contextmenu="${this.handleHeaderContextMenu}"
|
|
1845
1852
|
@mouseenter="${this.handleHeaderMouseEnter}"
|
|
1846
1853
|
@mouseleave="${this.handleHeaderMouseLeave}"
|
|
1854
|
+
@row-header-mouseleave="${this.handleHeaderMouseLeave}"
|
|
1847
1855
|
>
|
|
1848
1856
|
<div
|
|
1849
1857
|
class="row-header-content"
|
|
@@ -1888,10 +1896,10 @@ var G = class extends e {
|
|
|
1888
1896
|
`;
|
|
1889
1897
|
})}
|
|
1890
1898
|
${f.map(({ marker: e, lane: t }) => {
|
|
1891
|
-
let r = this.getDateX(e.date), i = e.color ?? "#ef4444", a = this.resolveMarkerFontSize(e.fontSize), s = Math.min(o, Math.max(8, Math.round(a * 1.2))), c = e.anchor === "center", l = (c ? m / 2 - s : (m - s) / 2) + t * d, u = e.anchor === "start" || e.anchor === "end" ? r : r - s / 2, f = e.anchor === "end", p = f;
|
|
1899
|
+
let r = this.getDateX(e.date), i = e.color ?? "#ef4444", a = this.resolveMarkerFontSize(e.fontSize), s = Math.min(o, Math.max(8, Math.round(a * 1.2))), c = e.anchor === "center", l = (c ? m / 2 - s : (m - s) / 2) + t * d, u = e.anchor === "start" || e.anchor === "end" ? r : r - s / 2, f = e.anchor === "end", p = f, h = this.row.selectedMarkerId === e.id;
|
|
1892
1900
|
return n`
|
|
1893
1901
|
<div
|
|
1894
|
-
class="marker-wrapper${
|
|
1902
|
+
class="marker-wrapper${h ? " marker-selected" : ""}${f ? " marker-anchor-end" : ""}"
|
|
1895
1903
|
style="
|
|
1896
1904
|
position: absolute;
|
|
1897
1905
|
left: ${u}px;
|
|
@@ -1976,7 +1984,8 @@ function K(e, t, n, r, i, a, o, s) {
|
|
|
1976
1984
|
`Q ${i} ${r} ${i + o} ${r}`,
|
|
1977
1985
|
`L ${n} ${r}`
|
|
1978
1986
|
].join(" ");
|
|
1979
|
-
}
|
|
1987
|
+
}
|
|
1988
|
+
{
|
|
1980
1989
|
let i = Math.max(12, s + 4), c = e + i, l = n - i, u = (t + r) / 2, d = Math.abs(t - r) < a ? u + a + o : u, f = d - t, p = r - d, m = f >= 0 ? 1 : -1, h = p >= 0 ? 1 : -1, g = l - c, _ = g >= 0 ? 1 : -1, v = Math.min(s, i, Math.abs(f) / 2), y = Math.min(s, Math.abs(f) / 2, Math.abs(g) / 2), b = Math.min(s, Math.abs(g) / 2, Math.abs(p) / 2), x = Math.min(s, Math.abs(p) / 2, i);
|
|
1981
1990
|
return [
|
|
1982
1991
|
`M ${e} ${t}`,
|
|
@@ -2278,7 +2287,8 @@ async function X(e, t = "png", n = {}) {
|
|
|
2278
2287
|
compress: !0
|
|
2279
2288
|
});
|
|
2280
2289
|
return t.addImage(e, "JPEG", 0, 0, c, l, void 0, "FAST"), i && t.save(`${r}.pdf`), t.output("blob");
|
|
2281
|
-
}
|
|
2290
|
+
}
|
|
2291
|
+
{
|
|
2282
2292
|
let e = u.toDataURL("image/png");
|
|
2283
2293
|
return i && Y(e, `${r}.png`), e;
|
|
2284
2294
|
}
|
|
@@ -2438,9 +2448,7 @@ var Q = class extends e {
|
|
|
2438
2448
|
case "Home":
|
|
2439
2449
|
this.focusFirstOrLastTaskInRow("first"), e.preventDefault();
|
|
2440
2450
|
break;
|
|
2441
|
-
case "End":
|
|
2442
|
-
this.focusFirstOrLastTaskInRow("last"), e.preventDefault();
|
|
2443
|
-
break;
|
|
2451
|
+
case "End": this.focusFirstOrLastTaskInRow("last"), e.preventDefault();
|
|
2444
2452
|
}
|
|
2445
2453
|
};
|
|
2446
2454
|
}
|
|
@@ -2464,7 +2472,7 @@ var Q = class extends e {
|
|
|
2464
2472
|
}), this.resizeObserver.observe(this), e && this.resizeObserver.observe(e), this._scrollContainer = this.shadowRoot?.querySelector(".scroll-container"), this._scrollContainer?.addEventListener("wheel", this.handleWheel, { passive: !1 });
|
|
2465
2473
|
}
|
|
2466
2474
|
connectedCallback() {
|
|
2467
|
-
super.connectedCallback(), this._systemThemeMediaQuery = window.matchMedia ? window.matchMedia("(prefers-color-scheme: dark)") : null, this._systemThemeMediaQuery?.addEventListener("change", this.handleSystemThemeChange), this.hasAttribute("tabindex") || this.setAttribute("tabindex", "0"), this.setAttribute("role", "grid"), this.setAttribute("aria-label", "Gantt Chart"), this.addEventListener("keydown", this.handleKeyDown), this.option?.theme === "system" || this.option?.theme !== "light" && this.option?.theme !== "dark" ? this.
|
|
2475
|
+
super.connectedCallback(), this._systemThemeMediaQuery = window.matchMedia ? window.matchMedia("(prefers-color-scheme: dark)") : null, this._systemThemeMediaQuery?.addEventListener("change", this.handleSystemThemeChange), this.hasAttribute("tabindex") || this.setAttribute("tabindex", "0"), this.setAttribute("role", "grid"), this.setAttribute("aria-label", "Gantt Chart"), this.addEventListener("keydown", this.handleKeyDown), this.theme = this.option?.theme === "system" || this.option?.theme !== "light" && this.option?.theme !== "dark" ? this._systemThemeMediaQuery?.matches ? "dark" : "light" : this.option.theme;
|
|
2468
2476
|
}
|
|
2469
2477
|
disconnectedCallback() {
|
|
2470
2478
|
super.disconnectedCallback(), this.resizeObserver?.disconnect(), this.stopCurrentTimeTimer(), this._systemThemeMediaQuery?.removeEventListener("change", this.handleSystemThemeChange), this.removeEventListener("keydown", this.handleKeyDown), this._scrollContainer?.removeEventListener("wheel", this.handleWheel), this._scrollContainer = null;
|
|
@@ -2487,7 +2495,7 @@ var Q = class extends e {
|
|
|
2487
2495
|
let t = this.option.customRendering?.tooltip ? this.option.customRendering.tooltip(this.tooltip.task) : void 0;
|
|
2488
2496
|
if (t) typeof t == "string" ? e.textContent = t : r(t, e);
|
|
2489
2497
|
else {
|
|
2490
|
-
let t = this.option.locale ?? k, i = !!this.option.calendar.pxPerMonth, a = Math.round((this.tooltip.task.end.getTime() - this.tooltip.task.start.getTime()) /
|
|
2498
|
+
let t = this.option.locale ?? k, i = !!this.option.calendar.pxPerMonth, a = Math.round((this.tooltip.task.end.getTime() - this.tooltip.task.start.getTime()) / 864e5);
|
|
2491
2499
|
if (i) {
|
|
2492
2500
|
let i = new Date(this.tooltip.task.end);
|
|
2493
2501
|
i.setMonth(i.getMonth() - 1), r(n`
|
|
@@ -2579,8 +2587,8 @@ var Q = class extends e {
|
|
|
2579
2587
|
let t = e.clientX, n = this.currentRowHeaderWidth, r = e.target;
|
|
2580
2588
|
r.setPointerCapture(e.pointerId);
|
|
2581
2589
|
let i = this.option.rowHeader?.minWidth ?? 50, a = this.option.rowHeader?.maxWidth ?? 2 ** 53 - 1, o = (e) => {
|
|
2582
|
-
let r =
|
|
2583
|
-
this.currentRowHeaderWidth = Math.max(i, Math.min(a,
|
|
2590
|
+
let r = e.clientX - t, o = n + r;
|
|
2591
|
+
this.currentRowHeaderWidth = Math.max(i, Math.min(a, o));
|
|
2584
2592
|
}, s = () => {
|
|
2585
2593
|
this.isResizingHeader = !1, r.releasePointerCapture(e.pointerId), r.removeEventListener("pointermove", o), r.removeEventListener("pointerup", s);
|
|
2586
2594
|
let t = Math.round(this.currentRowHeaderWidth);
|
|
@@ -2646,7 +2654,7 @@ var Q = class extends e {
|
|
|
2646
2654
|
let f = -1, p, m = -1;
|
|
2647
2655
|
if (this.rows.find((e, n) => {
|
|
2648
2656
|
let r = e.tasks.findIndex((e) => e.id === t);
|
|
2649
|
-
return r
|
|
2657
|
+
return r !== -1 && (f = n, p = e.tasks[r], m = r, !0);
|
|
2650
2658
|
}), f === -1 || !p) return;
|
|
2651
2659
|
let { layouts: h } = this.calculateLayout(), g = this.displayRows.findIndex((e) => e.id === this.rows[f].id);
|
|
2652
2660
|
if (g === -1) return;
|
|
@@ -2679,11 +2687,11 @@ var Q = class extends e {
|
|
|
2679
2687
|
currentStart: u,
|
|
2680
2688
|
currentEnd: d,
|
|
2681
2689
|
mode: o
|
|
2682
|
-
},
|
|
2690
|
+
}, this.draggingTaskIds = c ? [...this.selectedTasks] : []), c ? (this.multiDragDx = i ?? 0, this.multiDragSameRow = l, this.multiDragDy = l ? s : 0) : (this.multiDragDx !== 0 || this.multiDragDy !== 0) && (this.multiDragDx = 0, this.multiDragDy = 0), !c || l) {
|
|
2683
2691
|
let e = w >= 0 ? w : null;
|
|
2684
2692
|
this.dragTargetRowIndex !== e && (this.dragTargetRowIndex = e);
|
|
2685
2693
|
}
|
|
2686
|
-
|
|
2694
|
+
this.dragOverlayInfo = c ? {
|
|
2687
2695
|
id: t,
|
|
2688
2696
|
name: (this.option.locale ?? k).dragOverlay.movingTasks(this.selectedTasks.size),
|
|
2689
2697
|
start: n,
|
|
@@ -2693,7 +2701,7 @@ var Q = class extends e {
|
|
|
2693
2701
|
visible: !0,
|
|
2694
2702
|
clientX: e.detail.x,
|
|
2695
2703
|
clientY: e.detail.y
|
|
2696
|
-
} :
|
|
2704
|
+
} : {
|
|
2697
2705
|
id: t,
|
|
2698
2706
|
name: e.detail.name,
|
|
2699
2707
|
start: n,
|
|
@@ -2924,10 +2932,12 @@ var Q = class extends e {
|
|
|
2924
2932
|
}
|
|
2925
2933
|
if (!this.option.enableRowReordering) return;
|
|
2926
2934
|
let n = e.dataTransfer?.getData("text/plain"), r = this.dragOverRowId, i = this.dragOverPosition;
|
|
2927
|
-
if (this.dragOverRowId = null, this.dragOverPosition = null, this.dragPreview = null, n && r && n !== r && i)
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2935
|
+
if (this.dragOverRowId = null, this.dragOverPosition = null, this.dragPreview = null, n && r && n !== r && i) {
|
|
2936
|
+
if (this.selectedRows.has(n) && this.selectedRows.size > 1) {
|
|
2937
|
+
let e = Array.from(this.selectedRows);
|
|
2938
|
+
this.reorderRows(e, r, i);
|
|
2939
|
+
} else this.reorderRows(n, r, i);
|
|
2940
|
+
}
|
|
2931
2941
|
}
|
|
2932
2942
|
handleExternalTaskDrop(e, t) {
|
|
2933
2943
|
try {
|
|
@@ -3080,7 +3090,7 @@ var Q = class extends e {
|
|
|
3080
3090
|
let e = (n.getFullYear() - t.getFullYear()) * 12 + (n.getMonth() - t.getMonth()), r = i / Math.max(1, e);
|
|
3081
3091
|
this.zoomTo(r);
|
|
3082
3092
|
} else {
|
|
3083
|
-
let e = n.getTime() - t.getTime(), r = i / Math.max(1, e /
|
|
3093
|
+
let e = n.getTime() - t.getTime(), r = i / Math.max(1, e / 864e5);
|
|
3084
3094
|
this.zoomTo(r);
|
|
3085
3095
|
}
|
|
3086
3096
|
requestAnimationFrame(() => {
|
|
@@ -3104,7 +3114,7 @@ var Q = class extends e {
|
|
|
3104
3114
|
}
|
|
3105
3115
|
}
|
|
3106
3116
|
clearSelection() {
|
|
3107
|
-
this.selectedRows.size
|
|
3117
|
+
(this.selectedRows.size !== 0 || this.selectedTasks.size !== 0) && (this.selectedRows.size > 0 && (this.selectedRows = /* @__PURE__ */ new Set(), this.dispatchEvent(new CustomEvent("row-selection-change", {
|
|
3108
3118
|
detail: { selectedIds: [] },
|
|
3109
3119
|
bubbles: !0,
|
|
3110
3120
|
composed: !0
|
|
@@ -3184,7 +3194,7 @@ var Q = class extends e {
|
|
|
3184
3194
|
}));
|
|
3185
3195
|
}
|
|
3186
3196
|
selectSingleTask(e) {
|
|
3187
|
-
this.selectedTasks = new Set([e]), this.dispatchEvent(new CustomEvent("bar-selection-change", {
|
|
3197
|
+
this.selectedTasks = /* @__PURE__ */ new Set([e]), this.dispatchEvent(new CustomEvent("bar-selection-change", {
|
|
3188
3198
|
detail: { selectedIds: [e] },
|
|
3189
3199
|
bubbles: !0,
|
|
3190
3200
|
composed: !0
|
|
@@ -3233,7 +3243,7 @@ var Q = class extends e {
|
|
|
3233
3243
|
visible: !1
|
|
3234
3244
|
}, this.hideDragOverlay());
|
|
3235
3245
|
let r;
|
|
3236
|
-
n ? (r = new Set(this.selectedTasks), r.has(t.id) ? r.delete(t.id) : r.add(t.id)) : r = new Set([t.id]), this.selectedTasks = r, this.dispatchEvent(new CustomEvent("bar-selection-change", {
|
|
3246
|
+
n ? (r = new Set(this.selectedTasks), r.has(t.id) ? r.delete(t.id) : r.add(t.id)) : r = /* @__PURE__ */ new Set([t.id]), this.selectedTasks = r, this.dispatchEvent(new CustomEvent("bar-selection-change", {
|
|
3237
3247
|
detail: { selectedIds: [...r] },
|
|
3238
3248
|
bubbles: !0,
|
|
3239
3249
|
composed: !0
|
|
@@ -3241,7 +3251,7 @@ var Q = class extends e {
|
|
|
3241
3251
|
}
|
|
3242
3252
|
handleBarContextMenu(e) {
|
|
3243
3253
|
let { task: t } = e.detail;
|
|
3244
|
-
this.selectedTasks.has(t.id) || (this.selectedTasks = new Set([t.id]), this.dispatchEvent(new CustomEvent("bar-selection-change", {
|
|
3254
|
+
this.selectedTasks.has(t.id) || (this.selectedTasks = /* @__PURE__ */ new Set([t.id]), this.dispatchEvent(new CustomEvent("bar-selection-change", {
|
|
3245
3255
|
detail: { selectedIds: [t.id] },
|
|
3246
3256
|
bubbles: !0,
|
|
3247
3257
|
composed: !0
|
|
@@ -3326,7 +3336,7 @@ var Q = class extends e {
|
|
|
3326
3336
|
t = !0;
|
|
3327
3337
|
break;
|
|
3328
3338
|
}
|
|
3329
|
-
return t ? (this.selectedTasks = new Set([e]), this.dispatchEvent(new CustomEvent("bar-selection-change", {
|
|
3339
|
+
return t ? (this.selectedTasks = /* @__PURE__ */ new Set([e]), this.dispatchEvent(new CustomEvent("bar-selection-change", {
|
|
3330
3340
|
detail: { selectedIds: [e] },
|
|
3331
3341
|
bubbles: !0,
|
|
3332
3342
|
composed: !0
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("lit"),require("lit/decorators.js"),require("dayjs"),require("lit/directives/repeat.js"),require("lodash-es"),require("html2canvas-pro"),require("jspdf")):typeof define==`function`&&define.amd?define([`exports`,`lit`,`lit/decorators.js`,`dayjs`,`lit/directives/repeat.js`,`lodash-es`,`html2canvas-pro`,`jspdf`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.MoguchartCore={},e.Lit,e.Lit,e.dayjs,e.Lit,e._,e.html2canvas,e.jsPDF))})(this,function(e,t,n,r,i,a,o,s){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var c=Object.create,l=Object.defineProperty,u=Object.getOwnPropertyDescriptor,d=Object.getOwnPropertyNames,f=Object.getPrototypeOf,p=Object.prototype.hasOwnProperty,m=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=d(t),a=0,o=i.length,s;a<o;a++)s=i[a],!p.call(e,s)&&s!==n&&l(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=u(t,s))||r.enumerable});return e},h=(e,t,n)=>(n=e==null?{}:c(f(e)),m(t||!e||!e.__esModule||!p.call(e,`default`)?l(n,`default`,{value:e,enumerable:!0}):n,e));r=h(r,1),o=h(o,1);var g=[`diagonal-stripe`,`diagonal-stripe-thin`,`diagonal-stripe-thick`,`diagonal-stripe-reverse`,`vertical-stripe`,`horizontal-stripe`,`checkerboard`,`dots`,`triangle`,`circle`,`grid`,`diagonal-grid`],_={type:`diagonal-stripe`},v={type:`diagonal-stripe-reverse`},y={type:`vertical-stripe`},b={type:`horizontal-stripe`},x={type:`checkerboard`},S={type:`dots`},C={type:`triangle`},w={type:`circle`},T={type:`grid`},E={type:`diagonal-grid`},D={type:`diagonal-stripe-thin`},O={type:`diagonal-stripe-thick`},k={type:`dots-dense`};function A(e){if(!e?.type)return``;let t=e.color||`rgba(255, 255, 255, 0.3)`,n=e.type===`dots`?`6px`:`8px`;switch(e.type){case`diagonal-stripe`:return`
|
|
2
2
|
background-image: linear-gradient(45deg, ${t} 25%, transparent 25%, transparent 50%, ${t} 50%, ${t} 75%, transparent 75%, transparent);
|
|
3
3
|
background-size: ${n} ${n};
|
|
4
4
|
background-repeat: repeat;
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
background-image: linear-gradient(${t} 1px, transparent 1px), linear-gradient(90deg, ${t} 1px, transparent 1px);
|
|
52
52
|
background-size: ${n} ${n};
|
|
53
53
|
background-repeat: repeat;
|
|
54
|
-
`;default:return``}}var j={monthFormat:`YYYY年M月`,monthRowFormat:`M月`,dateFormat:e=>`${e.getFullYear()}/${e.getMonth()+1}/${e.getDate()}`,timeUnitDateFormat:e=>`${e.getFullYear()}年${e.getMonth()+1}月${e.getDate()}日`,dateTimeFormat:e=>{let t=`${e.getFullYear()}/${e.getMonth()+1}/${e.getDate()}`,n=e.getHours(),r=e.getMinutes();return n===0&&r===0?t:`${t} ${n.toString().padStart(2,`0`)}:${r.toString().padStart(2,`0`)}`},yearMonthFormat:e=>`${e.getFullYear()}/${e.getMonth()+1}`,duration:{days:e=>`${e}日`,hours:e=>`${e}時間`,minutes:e=>`${e}分`,zero:`0分`},tooltip:{duration:e=>`所要日数: ${e}日`},dragOverlay:{noTitle:`タイトルなし`,moveTo:e=>`移動先: ${e}`,movingTasks:e=>`${e}件のタスクを移動中`}},M={monthFormat:`MMM YYYY`,monthRowFormat:`MMM`,dateFormat:e=>`${e.getMonth()+1}/${e.getDate()}/${e.getFullYear()}`,timeUnitDateFormat:e=>`${[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`,dateTimeFormat:e=>{let t=`${e.getMonth()+1}/${e.getDate()}/${e.getFullYear()}`,n=e.getHours(),r=e.getMinutes();return n===0&&r===0?t:`${t} ${n.toString().padStart(2,`0`)}:${r.toString().padStart(2,`0`)}`},yearMonthFormat:e=>`${e.getFullYear()}/${e.getMonth()+1}`,duration:{days:e=>`${e} day${e===1?``:`s`}`,hours:e=>`${e} hour${e===1?``:`s`}`,minutes:e=>`${e} minute${e===1?``:`s`}`,zero:`0 minutes`},tooltip:{duration:e=>`Duration: ${e} day${e===1?``:`s`}`},dragOverlay:{noTitle:`No Title`,moveTo:e=>`Move to: ${e}`,movingTasks:e=>`Moving ${e} task${e===1?``:`s`}`}},N={light:{bg:`#f1f5f9`,text:`#0f172a`,border:`#cbd5e1`,gridLine:`#cbd5e1`,subGridLine:`#e2e8f0`,monthGridLine:`#94a3b8`,yearGridLine:`#64748b`,dragTarget:`#e0f2fe`,tooltipBg:`rgba(0, 0, 0, 0.8)`,tooltipText:`white`,dragOverlayBg:`rgba(0, 0, 0, 0.85)`,dragOverlayText:`white`,dragOverlaySubText:`#cbd5e1`,dragOverlayDivider:`#666`,dependencyLine:`#94a3b8`,calendarBg:`#e2e8f0`,saturday:`#dbeafe`,sunday:`#fee2e2`,holiday:`#fee2e2`,rowHeaderBg:`#e2e8f0`,rowSelected:`#bfdbfe`,rowSelectedHeader:`#dbeafe`,rowHiddenBg:`repeating-linear-gradient(45deg, #f3f4f6, #f3f4f6 10px, #e5e7eb 10px, #e5e7eb 20px)`,currentTimeLine:`rgba(239, 68, 68, 0.5)`,currentTimeLineText:`#ffffff`,criticalPath:`rgba(220, 38, 38, 0.85)`},dark:{bg:`#1e293b`,text:`#f8fafc`,border:`#263040`,gridLine:`#334155`,subGridLine:`#263040`,monthGridLine:`#475569`,yearGridLine:`#64748b`,dragTarget:`rgba(51, 65, 85, 0.5)`,tooltipBg:`rgba(255, 255, 255, 0.9)`,tooltipText:`#0f172a`,dragOverlayBg:`rgba(255, 255, 255, 0.9)`,dragOverlayText:`#0f172a`,dragOverlaySubText:`#64748b`,dragOverlayDivider:`#cbd5e1`,dependencyLine:`#475569`,calendarBg:`#0f172a`,saturday:`rgba(59, 130, 246, 0.15)`,sunday:`rgba(239, 68, 68, 0.15)`,holiday:`rgba(239, 68, 68, 0.15)`,rowHeaderBg:`#0f172a`,rowSelected:`#283548`,rowSelectedHeader:`#1c2738`,rowHiddenBg:`repeating-linear-gradient(45deg, #0f172a, #0f172a 10px, #1e293b 10px, #1e293b 20px)`,currentTimeLine:`rgba(239, 68, 68, 0.5)`,currentTimeLineText:`#ffffff`,criticalPath:`rgba(248, 113, 113, 0.85)`}},P=(e,t,n,r)=>{if(r!==void 0){let n=t.getFullYear(),i=t.getMonth(),a=e.getFullYear(),o=e.getMonth(),s=(a-n)*12+(o-i),c=new Date(n,i+1,0).getDate(),l=(t.getDate()-1+t.getHours()/24+t.getMinutes()/1440)/c,u=new Date(a,o+1,0).getDate();return(s+(e.getDate()-1+e.getHours()/24+e.getMinutes()/1440)/u-l)*r}return(e.getTime()-t.getTime())/
|
|
54
|
+
`;default:return``}}var j={monthFormat:`YYYY年M月`,monthRowFormat:`M月`,dateFormat:e=>`${e.getFullYear()}/${e.getMonth()+1}/${e.getDate()}`,timeUnitDateFormat:e=>`${e.getFullYear()}年${e.getMonth()+1}月${e.getDate()}日`,dateTimeFormat:e=>{let t=`${e.getFullYear()}/${e.getMonth()+1}/${e.getDate()}`,n=e.getHours(),r=e.getMinutes();return n===0&&r===0?t:`${t} ${n.toString().padStart(2,`0`)}:${r.toString().padStart(2,`0`)}`},yearMonthFormat:e=>`${e.getFullYear()}/${e.getMonth()+1}`,duration:{days:e=>`${e}日`,hours:e=>`${e}時間`,minutes:e=>`${e}分`,zero:`0分`},tooltip:{duration:e=>`所要日数: ${e}日`},dragOverlay:{noTitle:`タイトルなし`,moveTo:e=>`移動先: ${e}`,movingTasks:e=>`${e}件のタスクを移動中`}},M={monthFormat:`MMM YYYY`,monthRowFormat:`MMM`,dateFormat:e=>`${e.getMonth()+1}/${e.getDate()}/${e.getFullYear()}`,timeUnitDateFormat:e=>`${[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`][e.getMonth()]} ${e.getDate()}, ${e.getFullYear()}`,dateTimeFormat:e=>{let t=`${e.getMonth()+1}/${e.getDate()}/${e.getFullYear()}`,n=e.getHours(),r=e.getMinutes();return n===0&&r===0?t:`${t} ${n.toString().padStart(2,`0`)}:${r.toString().padStart(2,`0`)}`},yearMonthFormat:e=>`${e.getFullYear()}/${e.getMonth()+1}`,duration:{days:e=>`${e} day${e===1?``:`s`}`,hours:e=>`${e} hour${e===1?``:`s`}`,minutes:e=>`${e} minute${e===1?``:`s`}`,zero:`0 minutes`},tooltip:{duration:e=>`Duration: ${e} day${e===1?``:`s`}`},dragOverlay:{noTitle:`No Title`,moveTo:e=>`Move to: ${e}`,movingTasks:e=>`Moving ${e} task${e===1?``:`s`}`}},N={light:{bg:`#f1f5f9`,text:`#0f172a`,border:`#cbd5e1`,gridLine:`#cbd5e1`,subGridLine:`#e2e8f0`,monthGridLine:`#94a3b8`,yearGridLine:`#64748b`,dragTarget:`#e0f2fe`,tooltipBg:`rgba(0, 0, 0, 0.8)`,tooltipText:`white`,dragOverlayBg:`rgba(0, 0, 0, 0.85)`,dragOverlayText:`white`,dragOverlaySubText:`#cbd5e1`,dragOverlayDivider:`#666`,dependencyLine:`#94a3b8`,calendarBg:`#e2e8f0`,saturday:`#dbeafe`,sunday:`#fee2e2`,holiday:`#fee2e2`,rowHeaderBg:`#e2e8f0`,rowSelected:`#bfdbfe`,rowSelectedHeader:`#dbeafe`,rowHiddenBg:`repeating-linear-gradient(45deg, #f3f4f6, #f3f4f6 10px, #e5e7eb 10px, #e5e7eb 20px)`,currentTimeLine:`rgba(239, 68, 68, 0.5)`,currentTimeLineText:`#ffffff`,criticalPath:`rgba(220, 38, 38, 0.85)`},dark:{bg:`#1e293b`,text:`#f8fafc`,border:`#263040`,gridLine:`#334155`,subGridLine:`#263040`,monthGridLine:`#475569`,yearGridLine:`#64748b`,dragTarget:`rgba(51, 65, 85, 0.5)`,tooltipBg:`rgba(255, 255, 255, 0.9)`,tooltipText:`#0f172a`,dragOverlayBg:`rgba(255, 255, 255, 0.9)`,dragOverlayText:`#0f172a`,dragOverlaySubText:`#64748b`,dragOverlayDivider:`#cbd5e1`,dependencyLine:`#475569`,calendarBg:`#0f172a`,saturday:`rgba(59, 130, 246, 0.15)`,sunday:`rgba(239, 68, 68, 0.15)`,holiday:`rgba(239, 68, 68, 0.15)`,rowHeaderBg:`#0f172a`,rowSelected:`#283548`,rowSelectedHeader:`#1c2738`,rowHiddenBg:`repeating-linear-gradient(45deg, #0f172a, #0f172a 10px, #1e293b 10px, #1e293b 20px)`,currentTimeLine:`rgba(239, 68, 68, 0.5)`,currentTimeLineText:`#ffffff`,criticalPath:`rgba(248, 113, 113, 0.85)`}},P=(e,t,n,r)=>{if(r!==void 0){let n=t.getFullYear(),i=t.getMonth(),a=e.getFullYear(),o=e.getMonth(),s=(a-n)*12+(o-i),c=new Date(n,i+1,0).getDate(),l=(t.getDate()-1+t.getHours()/24+t.getMinutes()/1440)/c,u=new Date(a,o+1,0).getDate();return(s+(e.getDate()-1+e.getHours()/24+e.getMinutes()/1440)/u-l)*r}return(e.getTime()-t.getTime())/864e5*n},F=(e,t,n,r)=>{if(r!==void 0){let n=t.getFullYear(),i=t.getMonth(),a=new Date(n,i+1,0).getDate(),o=(t.getDate()-1+t.getHours()/24+t.getMinutes()/1440)/a,s=e/r+o,c=i+Math.floor(s),l=n+Math.floor(c/12);c%=12,c<0&&(c+=12,--l);let u=(s-Math.floor(s))*new Date(l,c+1,0).getDate(),d=1+Math.floor(u),f=(u-Math.floor(u))*24,p=Math.floor(f),m=Math.round((f-p)*60);return new Date(l,c,d,p,m)}let i=e/n;return new Date(t.getTime()+i*24*60*60*1e3)};function I(e){if(!e.length)return{tasksWithLanes:[],laneCount:1};let t=[...e].sort((e,t)=>e.start.getTime()-t.start.getTime()),n=[],r=new Map;for(let e of t){let t=-1;for(let r=0;r<n.length;r++)if(e.start>=n[r]){n[r]=e.end,t=r;break}t===-1&&(n.push(e.end),t=n.length-1),r.set(e.id,t)}return{tasksWithLanes:e.map(e=>({...e,lane:r.get(e.id)??0})),laneCount:n.length||1}}var L=(e,t)=>({...N[e]||N.light,...t}),R=(e,t,n)=>{let r=e.getDay();return n&&n(e)?t.holiday:[t.sunday,t.monday??``,t.tuesday??``,t.wednesday??``,t.thursday??``,t.friday??``,t.saturday][r]};function z(e,t){return(t.getTime()-e.getTime())/864e5}var B=(e,t,n)=>{let r=n??j,i=t.getTime()-e.getTime(),a=Math.floor(i/864e5),o=i%864e5,s=Math.floor(o/36e5),c=o%36e5,l=Math.floor(c/6e4),u=``;return a>0&&(u+=r.duration.days(a)),s>0&&(u+=r.duration.hours(s)),l>0&&(u+=r.duration.minutes(l)),u||r.duration.zero},V={BAR:`#3b82f6`,LABEL_BACKGROUND:`#fafafa`,SATURDAY:`#dbeafe`,SUNDAY:`#fee2e2`,HOLIDAY:`#fee2e2`,BORDER:`#e2e8f0`}.BAR;function H(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var U,W=class extends t.LitElement{static{U=this}constructor(...e){super(...e),this.lane=0,this.selected=!1,this.focused=!1,this.multiDragDx=0,this.multiDragDy=0,this.multiDragActive=!1,this.multiDragSameRow=!1,this.connectorDropTarget=!1,this.isExporting=!1,this.isCriticalPath=!1,this._currentDragCursor=null,this._dragAnimationFrame=null,this._wasDragging=!1,this._connectorEdgeThreshold=30,this.handleKeyDown=e=>{(e.key===`Control`||e.key===`Alt`)&&this.updateCursor(!0)},this.handleKeyUp=e=>{(e.key===`Control`||e.key===`Alt`)&&this.updateCursor(!1)},this.onMouseMoveOnBar=e=>{let t=this.shadowRoot?.querySelector(`.task-group`);if(!t||this.option.readOnly||this.option.dependency?.showConnectors===!1)return;let n=t.getBoundingClientRect(),r=e.clientX-n.left,i=r<=this._connectorEdgeThreshold,a=r>=n.width-this._connectorEdgeThreshold,o=this.shadowRoot?.querySelector(`.connector-left`),s=this.shadowRoot?.querySelector(`.connector-right`);o&&o.classList.toggle(`show-connector`,i),s&&s.classList.toggle(`show-connector`,a)}}static{this.styles=t.css`
|
|
55
55
|
:host {
|
|
56
56
|
display: block;
|
|
57
57
|
position: absolute;
|
|
@@ -215,7 +215,7 @@
|
|
|
215
215
|
filter: brightness(1.08);
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
|
-
`}getX(e){return P(e,this.option.calendar.start,this.option.calendar.pxPerDay??50,this.option.calendar.pxPerMonth)}setupDragEvents(e,t,n,r){let i=()=>{e.releasePointerCapture(t),window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`keydown`,s)},a=e=>{n(e)},o=e=>{i(),r(!1,e)},s=e=>{e.key===`Escape`&&(i(),r(!0))};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`keydown`,s)}onResizeStart(e,t){e.stopPropagation();let n=e.target,r=this.task.movable??`both`,i=this.task.resizable,a=!this.option.readOnly;if(a&&=i===void 0
|
|
218
|
+
`}getX(e){return P(e,this.option.calendar.start,this.option.calendar.pxPerDay??50,this.option.calendar.pxPerMonth)}setupDragEvents(e,t,n,r){let i=()=>{e.releasePointerCapture(t),window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`keydown`,s)},a=e=>{n(e)},o=e=>{i(),r(!1,e)},s=e=>{e.key===`Escape`&&(i(),r(!0))};window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o),window.addEventListener(`keydown`,s)}onResizeStart(e,t){e.stopPropagation();let n=e.target,r=this.task.movable??`both`,i=this.task.resizable,a=!this.option.readOnly;if(a&&=i===void 0?r!==`y`&&r!==`none`:i,!a)return;let o=this.shadowRoot?.querySelector(`.bar`);if(!o)return;o.style.pointerEvents=`none`;let s=this.shadowRoot?.querySelector(`.task-group`);s?.classList.add(`dragging`),n.setPointerCapture(e.pointerId);let c=e.clientX,l=new Date(this.task.start),u=new Date(this.task.end),d=new Date(l),f=new Date(u);this.setupDragEvents(n,e.pointerId,e=>{let n=e.clientX-c,r=new Date(l),i=new Date(u),a=this.option.calendar.pxPerDay??50,o=this.option.calendar.pxPerMonth,p=Math.max(this.option.snapDuration??1440,1);if(o){let e=this.getX(l),s=this.getX(u);if(t===`left`){let t=F(e+n,this.option.calendar.start,a,o);t.getDate()>15&&t.setMonth(t.getMonth()+1),t.setDate(1),t.setHours(0,0,0,0),r=t,r>=i&&(r=new Date(i),r.setMonth(r.getMonth()-1))}else{let e=F(s+n,this.option.calendar.start,a,o);e.getDate()>15&&e.setMonth(e.getMonth()+1),e.setDate(1),e.setHours(0,0,0,0),i=e,i<=r&&(i=new Date(r),i.setMonth(i.getMonth()+1))}}else{let e=a/1440,o=e*p,s=Math.round(n/o)*o,c=Math.round(s/e);t===`left`?(r=new Date(l.getTime()+c*60*1e3),r>=i&&(r=new Date(i.getTime()-p*60*1e3))):(i=new Date(u.getTime()+c*60*1e3),i<=r&&(i=new Date(r.getTime()+p*60*1e3)))}if(d=r,f=i,s){let e=this.getX(r),t=this.getX(i)-e;s.style.left=`${e}px`,s.style.width=`${t}px`}this._dragAnimationFrame&&cancelAnimationFrame(this._dragAnimationFrame),this._dragAnimationFrame=requestAnimationFrame(()=>{this.dispatchEvent(new CustomEvent(`task-update`,{detail:{...this.task,start:r,end:i,dy:0,isDragging:!0,x:e.clientX,y:e.clientY},bubbles:!0,composed:!0}))})},e=>{if(s?.classList.remove(`dragging`),o.style.pointerEvents=``,this._dragAnimationFrame&&=(cancelAnimationFrame(this._dragAnimationFrame),null),e){if(s){let e=this.getX(l),t=this.getX(u)-e;s.style.left=`${e}px`,s.style.width=`${t}px`}this.requestUpdate(),this.dispatchEvent(new CustomEvent(`task-update`,{detail:{...this.task,start:l,end:u,dy:0,isDragging:!1},bubbles:!0,composed:!0}))}else requestAnimationFrame(()=>{this.dispatchEvent(new CustomEvent(`task-update`,{detail:{...this.task,start:d,end:f,dy:0,isDragging:!1},bubbles:!0,composed:!0}))})})}static{this.DRAG_THRESHOLD=3}onMoveStart(e){if(e.button===2)return;e.stopPropagation();let t=e.target,n=this.shadowRoot?.querySelector(`.task-group`);if(!t||!n)return;let r=this.task.movable??`both`;if(r===`none`)return;t.setPointerCapture(e.pointerId);let i=e.clientX,a=e.clientY,o=new Date(this.task.start),s=new Date(this.task.end),c=this.option.snapDuration??1440,l=!1;this.setupDragEvents(t,e.pointerId,e=>{let u=e.clientX-i,d=e.clientY-a;if(!l){if(Math.abs(u)<U.DRAG_THRESHOLD&&Math.abs(d)<U.DRAG_THRESHOLD)return;l=!0;let r=e.ctrlKey||e.altKey?`copy`:`grabbing`;this._currentDragCursor=r,t.style.cursor=r,n.classList.add(`dragging`)}let f=e.ctrlKey||e.altKey?`copy`:`grabbing`;this._currentDragCursor=f,t.style.cursor=f;let p=u,m=d;r===`y`&&(p=0),r===`x`&&(m=0),this.multiDragActive&&!this.multiDragSameRow&&(m=0);let h=p;if(this.option.calendar.pxPerMonth){let e=F(this.getX(o)+p,this.option.calendar.start,50,this.option.calendar.pxPerMonth),t=(e.getFullYear()-o.getFullYear())*12+(e.getMonth()-o.getMonth())+ +(e.getDate()>15),n=new Date(o);n.setMonth(n.getMonth()+t),h=this.getX(n)-this.getX(o)}else{let e=this.option.calendar.pxPerDay/1440*c;h=Math.round(p/e)*e}n.style.transform=`translate(${h}px, ${m}px)`,this._dragAnimationFrame&&cancelAnimationFrame(this._dragAnimationFrame),this._dragAnimationFrame=requestAnimationFrame(()=>{let t=e.ctrlKey||e.altKey;this.dispatchEvent(new CustomEvent(`task-update`,{detail:{...this.task,start:o,end:s,dx:h,dy:m,isDragging:!0,x:e.clientX,y:e.clientY,mode:t?`copy`:`move`},bubbles:!0,composed:!0}))})},(e,u)=>{if(this._currentDragCursor=null,n.classList.remove(`dragging`),n.style.transform=``,t.style.cursor=``,this._dragAnimationFrame&&=(cancelAnimationFrame(this._dragAnimationFrame),null),!l){u&&(this.dispatchEvent(new CustomEvent(`bar-click`,{detail:{task:this.task,event:u,isMultiSelect:u.metaKey||u.ctrlKey},bubbles:!0,composed:!0})),this._wasDragging=!0);return}if(e)this.requestUpdate(),this.dispatchEvent(new CustomEvent(`task-update`,{detail:{...this.task,start:o,end:s,dx:0,dy:0,isDragging:!1},bubbles:!0,composed:!0}));else if(u){let e=u.clientX-i,t=e;if(this.option.calendar.pxPerMonth){let n=F(this.getX(o)+e,this.option.calendar.start,50,this.option.calendar.pxPerMonth),r=(n.getFullYear()-o.getFullYear())*12+(n.getMonth()-o.getMonth())+ +(n.getDate()>15),i=new Date(o);i.setMonth(i.getMonth()+r),t=this.getX(i)-this.getX(o)}else{let n=this.option.calendar.pxPerDay/1440*c;t=Math.round(e/n)*n}let n=u.clientY-a;if(r===`y`&&(t=0),r===`x`&&(n=0),this.multiDragActive&&!this.multiDragSameRow&&(n=0),t===0&&Math.abs(n)<5){this.dispatchEvent(new CustomEvent(`bar-click`,{detail:{task:this.task,event:u,isMultiSelect:u.metaKey||u.ctrlKey},bubbles:!0,composed:!0})),this._wasDragging=!0;return}let l=u.ctrlKey||u.altKey;this._wasDragging=!0,this.multiDragActive||this.dispatchEvent(new CustomEvent(`bar-click`,{detail:{task:this.task,event:u,isMultiSelect:!1},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`task-update`,{detail:{...this.task,start:o,end:s,dx:t,dy:n,isDragging:!1,mode:l?`copy`:`move`},bubbles:!0,composed:!0}))}})}updated(e){super.updated(e);let t=this.shadowRoot?.querySelector(`.bar`);if(t&&(this.option.customRendering?.barContent,this.dispatchEvent(new CustomEvent(`render-bar-content`,{detail:{container:t,task:this.task},bubbles:!0,composed:!0})),this._currentDragCursor?t.style.cursor=this._currentDragCursor:this.option.readOnly||(t.style.cursor=``)),e.has(`multiDragDx`)||e.has(`multiDragDy`)){let e=this.shadowRoot?.querySelector(`.task-group`);e&&(this.multiDragDx!==0||this.multiDragDy!==0?(e.style.transform=`translate(${this.multiDragDx}px, ${this.multiDragDy}px)`,e.style.opacity=`0.6`,e.style.pointerEvents=`none`):(e.style.transform=``,e.style.opacity=``,e.style.pointerEvents=``))}}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener(`keydown`,this.handleKeyDown),window.removeEventListener(`keyup`,this.handleKeyUp)}updateCursor(e){let t=this.shadowRoot?.querySelector(`.bar`);t&&!this._currentDragCursor&&(t.style.cursor=e?`copy`:``)}onMouseEnter(e){let t=e.currentTarget;if(t.classList.contains(`dragging`))return;this.option.readOnly||(window.addEventListener(`keydown`,this.handleKeyDown),window.addEventListener(`keyup`,this.handleKeyUp),(e.ctrlKey||e.altKey)&&this.updateCursor(!0),t.addEventListener(`mousemove`,this.onMouseMoveOnBar));let n=t.getBoundingClientRect();this.dispatchEvent(new CustomEvent(`bar-mouseenter`,{detail:{task:this.task,x:n.left+n.width/2,y:n.top,barBottom:n.bottom},bubbles:!0,composed:!0}))}onMouseLeave(){let e=this.shadowRoot?.querySelector(`.task-group`);if(!this.option.readOnly){window.removeEventListener(`keydown`,this.handleKeyDown),window.removeEventListener(`keyup`,this.handleKeyUp),this.updateCursor(!1),e&&e.removeEventListener(`mousemove`,this.onMouseMoveOnBar);let t=this.shadowRoot?.querySelector(`.connector-left`),n=this.shadowRoot?.querySelector(`.connector-right`);t&&t.classList.remove(`show-connector`),n&&n.classList.remove(`show-connector`)}this.dispatchEvent(new CustomEvent(`bar-mouseleave`,{bubbles:!0,composed:!0}))}onDblClick(e){this.dispatchEvent(new CustomEvent(`task-dblclick`,{detail:{task:this.task,event:e},bubbles:!0,composed:!0}))}onClick(e){if(e.stopPropagation(),this._wasDragging){this._wasDragging=!1;return}this.dispatchEvent(new CustomEvent(`bar-click`,{detail:{task:this.task,event:e,isMultiSelect:e.metaKey||e.ctrlKey},bubbles:!0,composed:!0}))}onConnectorDragStart(e,t){e.stopPropagation(),e.preventDefault();let n=e.target;if(n.setPointerCapture(e.pointerId),!this.shadowRoot?.querySelector(`.task-group`))return;let r=this.option.bar?.height??28,i=this.option.bar?.margin??4,a=this.getX(this.task.start),o=this.getX(this.task.end)-a,s=this.lane*(r+i)+i,c=t===`start`?a:a+o,l=s+r/2;this.dispatchEvent(new CustomEvent(`connector-drag-start`,{detail:{taskId:this.task.id,endpoint:t,startX:c,startY:l,clientX:e.clientX,clientY:e.clientY},bubbles:!0,composed:!0})),this.setupDragEvents(n,e.pointerId,e=>{this.dispatchEvent(new CustomEvent(`connector-drag-move`,{detail:{taskId:this.task.id,endpoint:t,startX:c,startY:l,clientX:e.clientX,clientY:e.clientY},bubbles:!0,composed:!0}))},e=>{this.dispatchEvent(new CustomEvent(`connector-drag-end`,{detail:{taskId:this.task.id,endpoint:t,cancelled:e},bubbles:!0,composed:!0}))})}onContextMenu(e){if(e.ctrlKey){e.preventDefault(),e.stopPropagation();return}e.preventDefault(),e.stopPropagation(),this.dispatchEvent(new CustomEvent(`task-contextmenu`,{detail:{task:this.task,event:e},bubbles:!0,composed:!0}))}render(){if(!this.task||!this.option)return t.html``;let e=this.getX(this.task.start),n=this.getX(this.task.end)-e,r=this.option.bar?.height??28,i=this.option.bar?.margin??4,a=this.option.bar?.cornerRadius??4,o=this.lane*(r+i)+i,s=this.option.readOnly,c=this.task.movable??`both`,l=this.task.resizable,u=!s&&c!==`none`,d=!s;return d&&=l===void 0?c!==`y`&&c!==`none`:l,t.html`
|
|
219
219
|
<div
|
|
220
220
|
class="task-group"
|
|
221
221
|
style="
|
|
@@ -378,11 +378,11 @@
|
|
|
378
378
|
`}getDateX(e){return P(e,this.option.calendar.start,this.option.calendar.pxPerDay,this.option.calendar.pxPerMonth)}formatTime(e){return`${e.getHours().toString().padStart(2,`0`)}:${e.getMinutes().toString().padStart(2,`0`)}`}_buildWeeks(e,t){let n=e=>{let n=new Date(e.getTime());n.setHours(0,0,0,0);let r=(n.getDay()-t+7)%7,i=new Date(n.getTime());i.setDate(i.getDate()-r);let a=new Date(i.getFullYear(),0,1),o=Math.floor((i.getTime()-a.getTime())/864e5);return Math.floor(o/7)+1},r=[];return e.forEach(e=>{let i=e.getDay()===t,a=r[r.length-1];a&&!i?a.count++:r.push({weekNumber:n(e),startDate:new Date(e),count:1})}),r}render(){let e=L(this.theme,this.option.customTheme),n=this.option.calendar.start.getTime(),i=this.option.calendar.end.getTime(),a=this.option.calendar.pxPerDay,o=this.option.calendar.pxPerMonth,s=this.option.calendar.weekStartDay??1,c=!this._cachedDays||n!==this._cachedStartTime||i!==this._cachedEndTime,l=a!==this._cachedPxPerDay||o!==this._cachedPxPerMonth;if(c){this._cachedStartTime=n,this._cachedEndTime=i,this._cachedPxPerDay=a,this._cachedPxPerMonth=o;let e=Array.from({length:Math.ceil(this.totalDays)},(e,t)=>{let n=new Date(this.option.calendar.start);return n.setDate(n.getDate()+t),n});this._cachedDays=e;let t=[];e.forEach(e=>{let n=e.getFullYear(),r=e.getMonth(),i=t[t.length-1];if(i&&i.year===n&&i.month===r)i.count++,i.end=new Date(e),i.end.setDate(i.end.getDate()+1);else{let i=new Date(e);i.setHours(0,0,0,0);let a=new Date(e);a.setDate(a.getDate()+1),t.push({year:n,month:r,count:1,start:i,end:a})}}),t.forEach(e=>{e.start&&e.end&&(e.width=this.getDateX(e.end)-this.getDateX(e.start))}),this._cachedMonths=t;let r=[];e.forEach(e=>{let t=e.getFullYear(),n=r[r.length-1];if(n&&n.year===t)n.count++,n.end=new Date(e),n.end.setDate(n.end.getDate()+1);else{let n=new Date(e);n.setHours(0,0,0,0);let i=new Date(e);i.setDate(i.getDate()+1),r.push({year:t,count:1,start:n,end:i})}}),r.forEach(e=>{e.start&&e.end&&(e.width=this.getDateX(e.end)-this.getDateX(e.start))}),this._cachedYears=r,this._cachedWeekStartDay=s,this._cachedWeeks=this._buildWeeks(e,s)}else l?(this._cachedPxPerDay=a,this._cachedPxPerMonth=o,this._cachedMonths.forEach(e=>{e.start&&e.end&&(e.width=this.getDateX(e.end)-this.getDateX(e.start))}),this._cachedYears.forEach(e=>{e.start&&e.end&&(e.width=this.getDateX(e.end)-this.getDateX(e.start))}),s!==this._cachedWeekStartDay&&(this._cachedWeekStartDay=s,this._cachedWeeks=this._buildWeeks(this._cachedDays,s))):s!==this._cachedWeekStartDay&&(this._cachedWeekStartDay=s,this._cachedWeeks=this._buildWeeks(this._cachedDays,s));let u=this._cachedDays,d=this._cachedMonths,f=this._cachedYears,p=`
|
|
379
379
|
background-image: linear-gradient(90deg, transparent ${this.option.calendar.pxPerDay-1}px, ${e.border} ${this.option.calendar.pxPerDay-1}px);
|
|
380
380
|
background-size: ${this.option.calendar.pxPerDay}px 100%;
|
|
381
|
-
`,m=this.option.calendar.pxPerDay/24,h=this.option.calendar.pxPerDay,g=this.option.customTheme?.showTimeDateLine??e.monthGridLine??e.border,_=this.option.calendar.start,v=(_.getHours()*60*60*1e3+_.getMinutes()*60*1e3+_.getSeconds()*1e3)/
|
|
381
|
+
`,m=this.option.calendar.pxPerDay/24,h=this.option.calendar.pxPerDay,g=this.option.customTheme?.showTimeDateLine??e.monthGridLine??e.border,_=this.option.calendar.start,v=(_.getHours()*60*60*1e3+_.getMinutes()*60*1e3+_.getSeconds()*1e3)/864e5*h,y=v%m,b=v===0?`0px 0`:`${-v}px 0`,x=y===0?`0px 0`:`${-y}px 0`,S=`
|
|
382
382
|
background-image: linear-gradient(90deg, transparent ${h-1}px, ${g} ${h-1}px), linear-gradient(90deg, transparent ${m-1}px, ${e.border} ${m-1}px);
|
|
383
383
|
background-size: ${h}px 100%, ${m}px 100%;
|
|
384
384
|
background-position: ${b}, ${x};
|
|
385
|
-
`,C=[];if(this.option.calendar.showTime){let e=this.option.calendar.start,t=this.option.calendar.end,n=new Date(e);for(n.setHours(0,0,0,0);n.getTime()<t.getTime();){let r=n.getTime()<e.getTime()?e:n,i=new Date(n);i.setDate(i.getDate()+1);let a=i.getTime()>t.getTime()?t:i,o=r.getHours(),s=a.getHours(),c=a.getMinutes()>0||a.getSeconds()>0||a.getMilliseconds()>0,l=s===0&&!c?24:c?s+1:s,u=(a.getTime()-r.getTime())/
|
|
385
|
+
`,C=[];if(this.option.calendar.showTime){let e=this.option.calendar.start,t=this.option.calendar.end,n=new Date(e);for(n.setHours(0,0,0,0);n.getTime()<t.getTime();){let r=n.getTime()<e.getTime()?e:n,i=new Date(n);i.setDate(i.getDate()+1);let a=i.getTime()>t.getTime()?t:i,o=r.getHours(),s=a.getHours(),c=a.getMinutes()>0||a.getSeconds()>0||a.getMilliseconds()>0,l=s===0&&!c?24:c?s+1:s,u=(a.getTime()-r.getTime())/36e5;C.push({date:new Date(n),hStart:o,hEnd:l,widthPx:u*m}),n=new Date(i)}}let w=d[d.length-1],T=this.option.calendar.pxPerMonth!==void 0&&w?.end?this.getDateX(w.end):this.getDateX(this.option.calendar.end);return t.html`
|
|
386
386
|
<style>
|
|
387
387
|
:host {
|
|
388
388
|
background: ${e.calendarBg};
|
|
@@ -555,14 +555,14 @@
|
|
|
555
555
|
position: relative;
|
|
556
556
|
overflow: hidden;
|
|
557
557
|
}
|
|
558
|
-
`}render(){let e=L(this.theme,this.option.customTheme),n=this.option.calendar.start.getTime(),r=this.option.calendar.end.getTime(),i=this.option.calendar.pxPerDay??50,a=this.option.calendar.pxPerMonth;(!this._cachedCells||n!==this._cachedCellsStartTime||r!==this._cachedCellsEndTime||i!==this._cachedCellsPxPerDay||a!==this._cachedCellsPxPerMonth||this.theme!==this._cachedCellsTheme)
|
|
559
|
-
${this._cachedCells.map(({width:e,color:n,date:r},i)=>{let a=r.getDay(),s=this.option.calendar.isHoliday?this.option.calendar.isHoliday(r):!1,c=
|
|
558
|
+
`}render(){let e=L(this.theme,this.option.customTheme),n=this.option.calendar.start.getTime(),r=this.option.calendar.end.getTime(),i=this.option.calendar.pxPerDay??50,a=this.option.calendar.pxPerMonth;if(!this._cachedCells||n!==this._cachedCellsStartTime||r!==this._cachedCellsEndTime||i!==this._cachedCellsPxPerDay||a!==this._cachedCellsPxPerMonth||this.theme!==this._cachedCellsTheme){this._cachedCellsStartTime=n,this._cachedCellsEndTime=r,this._cachedCellsPxPerDay=i,this._cachedCellsPxPerMonth=a,this._cachedCellsTheme=this.theme;let t=Array.from({length:Math.ceil(this.totalDays)},(e,t)=>{let n=new Date(this.option.calendar.start);return n.setDate(n.getDate()+t),n});this._cachedCells=t.map(t=>{let n=R(t,e,this.option.calendar.isHoliday),r=new Date(t);r.setDate(t.getDate()+1);let o=P(t,this.option.calendar.start,i,a);return{width:P(r,this.option.calendar.start,i,a)-o,color:n,date:t}})}let o=this.option.customRendering?.chartBackground;return o?t.html`
|
|
559
|
+
${this._cachedCells.map(({width:e,color:n,date:r},i)=>{let a=r.getDay(),s=this.option.calendar.isHoliday?this.option.calendar.isHoliday(r):!1,c={date:r,width:e,height:this.clientHeight||0,rowId:this.rowId,isSaturday:a===6,isSunday:a===0,isHoliday:s,defaultColor:n,index:i},l=o(c);return typeof l==`string`?t.html`<div
|
|
560
560
|
class="bg-cell"
|
|
561
561
|
style="width: ${e}px; background-color: ${n};"
|
|
562
|
-
><div style="position: absolute; inset: 0;">${t.html`${
|
|
562
|
+
><div style="position: absolute; inset: 0;">${t.html`${l}`}</div></div>`:t.html`<div
|
|
563
563
|
class="bg-cell"
|
|
564
564
|
style="width: ${e}px; background-color: ${n};"
|
|
565
|
-
><div style="position: absolute; inset: 0;">${
|
|
565
|
+
><div style="position: absolute; inset: 0;">${l}</div></div>`})}
|
|
566
566
|
`:t.html`
|
|
567
567
|
${this._cachedCells.map(({width:e,color:n})=>t.html`<div
|
|
568
568
|
style="width: ${e}px; background-color: ${n}; flex-shrink: 0;"
|
|
@@ -665,11 +665,11 @@
|
|
|
665
665
|
height: 100%;
|
|
666
666
|
pointer-events: none;
|
|
667
667
|
}
|
|
668
|
-
`}handleDragStart(e){if(this.handleHeaderMouseLeave(),this.isSelected||this.dispatchEvent(new CustomEvent(`row-clicked`,{detail:{rowId:this.row.id,event:e},bubbles:!0,composed:!0})),e.dataTransfer){e.dataTransfer.setData(`text/plain`,this.row.id),e.dataTransfer.effectAllowed=`move`;let t=L(this.theme,this.option.customTheme),n=document.createElement(`div`);n.style.position=`absolute`,n.style.top=`-1000px`,n.style.left=`-1000px`,n.style.display=`flex`,n.style.flexDirection=`column`,n.style.zIndex=`9999`,n.style.width=`fit-content`,n.style.boxShadow=`0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)`,n.style.border=`1px solid ${t.border}`,n.style.borderRadius=`4px`,n.style.overflow=`hidden`;let r=[];if(this.isSelected){let e=this.getRootNode(),t=Array.from(e.querySelectorAll(`gantt-row[isselected]`));r=t.length>0?t:[this]}else r=[this];let i=r.slice(0,10);if(i.forEach((e,r)=>{let a=e.shadowRoot?.querySelector(`.row-header`);if(a){let o=a.cloneNode(!0),s=window.getComputedStyle(a);o.style.width=s.width,o.style.minWidth=s.minWidth,o.style.height=`${e.offsetHeight}px`,o.style.boxSizing=s.boxSizing,o.style.background=s.backgroundColor,o.style.color=s.color,o.style.fontSize=s.fontSize,o.style.display=s.display,o.style.alignItems=s.alignItems,o.style.padding=s.padding,o.style.border=`none`,o.style.borderBottom=r<i.length-1?`1px solid ${t.border}`:`none`,o.style.cursor=`grabbing`,n.appendChild(o)}}),r.length>10){let e=document.createElement(`div`);e.style.padding=`4px 8px`,e.style.background=t.bg,e.style.color=t.text,e.style.fontSize=`11px`,e.style.textAlign=`center`,e.textContent=`+ ${r.length-10} more`,n.appendChild(e)}document.body.appendChild(n),e.dataTransfer.setDragImage(n,0,0),setTimeout(()=>{document.body.removeChild(n)},0)}}handleHeaderClick(e){this.dispatchEvent(new CustomEvent(`row-clicked`,{detail:{rowId:this.row.id,event:e},bubbles:!0,composed:!0})),e.stopPropagation()}handleHeaderContextMenu(e){e.preventDefault(),this.dispatchEvent(new CustomEvent(`row-header-contextmenu`,{detail:{rowId:this.row.id,row:this.row,event:e,target:e.currentTarget},bubbles:!0,composed:!0}))}handleHeaderDblClick(e){this.dispatchEvent(new CustomEvent(`row-header-dblclick`,{detail:{rowId:this.row.id,row:this.row,event:e,target:e.currentTarget},bubbles:!0,composed:!0}))}handleHeaderMouseEnter(e){let n=this.option.customRendering?.rowHeaderTooltip;if(!n)return;let r=this.option.tooltipDelay??500,i=e.currentTarget,a=()=>{let e=n(this.row);if(!e)return;let r=document.createElement(`div`);r.style.position=`fixed`,r.style.zIndex=`9999`,r.style.pointerEvents=`none`,r.style.opacity=`0`,r.style.transition=`opacity 0.15s ease`,r.style.maxWidth=`360px`,r.style.borderRadius=`8px`,r.style.padding=`8px 12px`,r.style.fontSize=`12px`,r.style.lineHeight=`1.5`,r.style.boxShadow=`0 4px 12px rgba(0,0,0,0.15)`;let a=L(this.theme,this.option.customTheme);r.style.backgroundColor=a.tooltipBg,r.style.color=a.tooltipText,typeof e==`string`?r.textContent=e:e instanceof HTMLElement?r.appendChild(e):(0,t.render)(e,r),document.body.appendChild(r),this._rowHeaderTooltipEl=r;let o=i.getBoundingClientRect(),s=r.getBoundingClientRect(),c=o.right+6,l=o.top;c+s.width>window.innerWidth-6&&(c=o.left-s.width-6),l+s.height>window.innerHeight-6&&(l=window.innerHeight-s.height-6),l<6&&(l=6),r.style.left=`${c}px`,r.style.top=`${l}px`,requestAnimationFrame(()=>{r.style.opacity=`1`})};r>0?this._rowHeaderTooltipTimer=window.setTimeout(a,r):a()}handleHeaderMouseLeave(){this._rowHeaderTooltipTimer!==void 0&&(window.clearTimeout(this._rowHeaderTooltipTimer),this._rowHeaderTooltipTimer=void 0),this._rowHeaderTooltipEl&&=(this._rowHeaderTooltipEl.remove(),null)}updated(e){if(super.updated(e),!(e.has(`row`)||e.has(`option`)||e.has(`isSelected`)||e.has(`theme`)))return;let n=this.shadowRoot?.querySelector(`.row-header-content`);n
|
|
668
|
+
`}handleDragStart(e){if(this.handleHeaderMouseLeave(),this.isSelected||this.dispatchEvent(new CustomEvent(`row-clicked`,{detail:{rowId:this.row.id,event:e},bubbles:!0,composed:!0})),e.dataTransfer){e.dataTransfer.setData(`text/plain`,this.row.id),e.dataTransfer.effectAllowed=`move`;let t=L(this.theme,this.option.customTheme),n=document.createElement(`div`);n.style.position=`absolute`,n.style.top=`-1000px`,n.style.left=`-1000px`,n.style.display=`flex`,n.style.flexDirection=`column`,n.style.zIndex=`9999`,n.style.width=`fit-content`,n.style.boxShadow=`0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)`,n.style.border=`1px solid ${t.border}`,n.style.borderRadius=`4px`,n.style.overflow=`hidden`;let r=[];if(this.isSelected){let e=this.getRootNode(),t=Array.from(e.querySelectorAll(`gantt-row[isselected]`));r=t.length>0?t:[this]}else r=[this];let i=r.slice(0,10);if(i.forEach((e,r)=>{let a=e.shadowRoot?.querySelector(`.row-header`);if(a){let o=a.cloneNode(!0),s=window.getComputedStyle(a);o.style.width=s.width,o.style.minWidth=s.minWidth,o.style.height=`${e.offsetHeight}px`,o.style.boxSizing=s.boxSizing,o.style.background=s.backgroundColor,o.style.color=s.color,o.style.fontSize=s.fontSize,o.style.display=s.display,o.style.alignItems=s.alignItems,o.style.padding=s.padding,o.style.border=`none`,o.style.borderBottom=r<i.length-1?`1px solid ${t.border}`:`none`,o.style.cursor=`grabbing`,n.appendChild(o)}}),r.length>10){let e=document.createElement(`div`);e.style.padding=`4px 8px`,e.style.background=t.bg,e.style.color=t.text,e.style.fontSize=`11px`,e.style.textAlign=`center`,e.textContent=`+ ${r.length-10} more`,n.appendChild(e)}document.body.appendChild(n),e.dataTransfer.setDragImage(n,0,0),setTimeout(()=>{document.body.removeChild(n)},0)}}handleHeaderClick(e){this.dispatchEvent(new CustomEvent(`row-clicked`,{detail:{rowId:this.row.id,event:e},bubbles:!0,composed:!0})),e.stopPropagation()}handleHeaderContextMenu(e){e.preventDefault(),this.dispatchEvent(new CustomEvent(`row-header-contextmenu`,{detail:{rowId:this.row.id,row:this.row,event:e,target:e.currentTarget},bubbles:!0,composed:!0}))}handleHeaderDblClick(e){this.dispatchEvent(new CustomEvent(`row-header-dblclick`,{detail:{rowId:this.row.id,row:this.row,event:e,target:e.currentTarget},bubbles:!0,composed:!0}))}handleHeaderMouseEnter(e){let n=this.option.customRendering?.rowHeaderTooltip;if(!n)return;let r=this.option.tooltipDelay??500,i=e.currentTarget,a=()=>{let e=n(this.row);if(!e)return;let r=document.createElement(`div`);r.style.position=`fixed`,r.style.zIndex=`9999`,r.style.pointerEvents=`none`,r.style.opacity=`0`,r.style.transition=`opacity 0.15s ease`,r.style.maxWidth=`360px`,r.style.borderRadius=`8px`,r.style.padding=`8px 12px`,r.style.fontSize=`12px`,r.style.lineHeight=`1.5`,r.style.boxShadow=`0 4px 12px rgba(0,0,0,0.15)`;let a=L(this.theme,this.option.customTheme);r.style.backgroundColor=a.tooltipBg,r.style.color=a.tooltipText,typeof e==`string`?r.textContent=e:e instanceof HTMLElement?r.appendChild(e):(0,t.render)(e,r),document.body.appendChild(r),this._rowHeaderTooltipEl=r;let o=i.getBoundingClientRect(),s=r.getBoundingClientRect(),c=o.right+6,l=o.top;c+s.width>window.innerWidth-6&&(c=o.left-s.width-6),l+s.height>window.innerHeight-6&&(l=window.innerHeight-s.height-6),l<6&&(l=6),r.style.left=`${c}px`,r.style.top=`${l}px`,requestAnimationFrame(()=>{r.style.opacity=`1`})};r>0?this._rowHeaderTooltipTimer=window.setTimeout(a,r):a()}handleHeaderMouseLeave(){this._rowHeaderTooltipTimer!==void 0&&(window.clearTimeout(this._rowHeaderTooltipTimer),this._rowHeaderTooltipTimer=void 0),this._rowHeaderTooltipEl&&=(this._rowHeaderTooltipEl.remove(),null)}updated(e){if(super.updated(e),!(e.has(`row`)||e.has(`option`)||e.has(`isSelected`)||e.has(`theme`)))return;let n=this.shadowRoot?.querySelector(`.row-header-content`);if(n){let e=this.option.customRendering?.rowHeaderContent?this.option.customRendering.rowHeaderContent(this.row):this.row.name;(0,t.render)(e,n)}}render(){let e=L(this.theme,this.option.customTheme),n=[...this.row.tasks];if(this.externalDragTask){let e={...this.externalDragTask.task,start:this.externalDragTask.currentStart,end:this.externalDragTask.currentEnd,style:`${this.externalDragTask.task.style||``}; opacity: 0.6; pointer-events: none;`};n=[...n,e]}let r,a,o=this.row.tasks.find(e=>this.draggingTask&&e.id===this.draggingTask.id);if(this.draggingTask?.mode===`copy`&&o){let e=n.filter(e=>e.id!==this.draggingTask.id);e.push({...o,id:`${o.id}-static`,movable:`none`,resizable:!1,style:`${o.style||``}; opacity: 0.5;`});let t=I(e);r=t.tasksWithLanes,a=t.laneCount;let i=r.find(e=>e.id===`${o.id}-static`);i&&r.push({...o,lane:i.lane})}else{let e=I(n);r=e.tasksWithLanes,a=e.laneCount}let s=this.option.bar?.height??28,c=this.option.bar?.margin??4,l=this.row.markers??[],u=Math.min(s,12),d=u+2,f=this.calculateMarkerLanes(l,u),p=f.length>0?Math.max(...f.map(e=>e.lane))+1:0,m=a*(s+c)+c,h=m+(p>1?(p-1)*d:0);this.style.height=`${h}px`;let g=``,_=null,v=this.option.calendar.start.getTime(),y=this.option.calendar.end.getTime(),b=this.option.calendar.pxPerDay,x=this.option.calendar.pxPerMonth??0;if(!this._cachedMonthGridLines||v!==this._cachedMonthGridStartTime||y!==this._cachedMonthGridEndTime||b!==this._cachedMonthGridPxPerDay||x!==this._cachedMonthGridPxPerMonth){this._cachedMonthGridStartTime=v,this._cachedMonthGridEndTime=y,this._cachedMonthGridPxPerDay=b,this._cachedMonthGridPxPerMonth=x;let e=new Date(this.option.calendar.start),t=this.getDateX(e),n=this.option.calendar.end,r=new Date(n.getFullYear(),n.getMonth()+1,1),i=this.option.calendar.pxPerMonth===void 0?this.getDateX(n):this.getDateX(r),a=[],o=new Date(e);for(o.setDate(1),o.setHours(0,0,0,0);o<=r;){let e=this.getDateX(o);if(e>t&&e<=i){let t=o.getMonth()===0;a.push({left:e,isYearBoundary:t})}o.setMonth(o.getMonth()+1)}this._cachedMonthGridLines=a}if(_=this._cachedMonthGridLines,this.option.calendar.showMonthsRow)g=``;else if(this.option.calendar.showTime){let t=this.option.calendar.pxPerDay/24,n=this.option.snapDuration??60,r=this.option.calendar.pxPerDay/1440*n,i=this.option.calendar.pxPerDay,a=this.option.customTheme?.showTimeDateLine??e.monthGridLine??e.gridLine,o=this.option.calendar.start,s=(o.getHours()*60*60*1e3+o.getMinutes()*60*1e3+o.getSeconds()*1e3)/864e5*i,c=s%t,l=s%r,u=s===0?`0px 0`:`${-s}px 0`,d=c===0?`0px 0`:`${-c}px 0`,f=l===0?`0px 0`:`${-l}px 0`,p=[`linear-gradient(90deg, transparent ${i-1}px, ${a} ${i-1}px)`,`linear-gradient(90deg, transparent ${t-1}px, ${e.gridLine} ${t-1}px)`,`linear-gradient(90deg, transparent ${r-1}px, ${e.subGridLine} ${r-1}px)`],m=[`${i}px 100%`,`${t}px 100%`,`${r}px 100%`],h=[u,d,f];g=`
|
|
669
669
|
background-image: ${p.join(`, `)};
|
|
670
670
|
background-size: ${m.join(`, `)};
|
|
671
671
|
background-position: ${h.join(`, `)};
|
|
672
|
-
`}else{let t=this.option.calendar.pxPerDay,n=this.option.calendar.start,r=(n.getHours()*60*60*1e3+n.getMinutes()*60*1e3+n.getSeconds()*1e3)/
|
|
672
|
+
`}else{let t=this.option.calendar.pxPerDay,n=this.option.calendar.start,r=(n.getHours()*60*60*1e3+n.getMinutes()*60*1e3+n.getSeconds()*1e3)/864e5*t,i=r===0?`0px 0`:`${-r}px 0`;g=`
|
|
673
673
|
background-image: linear-gradient(90deg, transparent ${t-1}px, ${e.gridLine} ${t-1}px);
|
|
674
674
|
background-size: ${t}px 100%;
|
|
675
675
|
background-position: ${i};
|
|
@@ -726,6 +726,7 @@
|
|
|
726
726
|
@contextmenu="${this.handleHeaderContextMenu}"
|
|
727
727
|
@mouseenter="${this.handleHeaderMouseEnter}"
|
|
728
728
|
@mouseleave="${this.handleHeaderMouseLeave}"
|
|
729
|
+
@row-header-mouseleave="${this.handleHeaderMouseLeave}"
|
|
729
730
|
>
|
|
730
731
|
<div
|
|
731
732
|
class="row-header-content"
|
|
@@ -753,9 +754,9 @@
|
|
|
753
754
|
.isCriticalPath="${this.criticalPathTaskIds.includes(e.id)}"
|
|
754
755
|
/>
|
|
755
756
|
`})}
|
|
756
|
-
${f.map(({marker:e,lane:n})=>{let r=this.getDateX(e.date),i=e.color??`#ef4444`,a=this.resolveMarkerFontSize(e.fontSize),o=Math.min(s,Math.max(8,Math.round(a*1.2))),c=e.anchor===`center`,l=(c?m/2-o:(m-o)/2)+n*d,u=e.anchor===`start`||e.anchor===`end`?r:r-o/2,f=e.anchor===`end`,p=f;return t.html`
|
|
757
|
+
${f.map(({marker:e,lane:n})=>{let r=this.getDateX(e.date),i=e.color??`#ef4444`,a=this.resolveMarkerFontSize(e.fontSize),o=Math.min(s,Math.max(8,Math.round(a*1.2))),c=e.anchor===`center`,l=(c?m/2-o:(m-o)/2)+n*d,u=e.anchor===`start`||e.anchor===`end`?r:r-o/2,f=e.anchor===`end`,p=f,h=this.row.selectedMarkerId===e.id;return t.html`
|
|
757
758
|
<div
|
|
758
|
-
class="marker-wrapper${
|
|
759
|
+
class="marker-wrapper${h?` marker-selected`:``}${f?` marker-anchor-end`:``}"
|
|
759
760
|
style="
|
|
760
761
|
position: absolute;
|
|
761
762
|
left: ${u}px;
|
|
@@ -794,7 +795,7 @@
|
|
|
794
795
|
`})}
|
|
795
796
|
</div>
|
|
796
797
|
</div>
|
|
797
|
-
`}};H([(0,n.property)({type:Object})],q.prototype,`row`,void 0),H([(0,n.property)({type:Object})],q.prototype,`option`,void 0),H([(0,n.property)({type:Boolean})],q.prototype,`isDragTarget`,void 0),H([(0,n.property)({type:Object})],q.prototype,`draggingTask`,void 0),H([(0,n.property)({type:Array})],q.prototype,`draggingTaskIds`,void 0),H([(0,n.property)({type:Number})],q.prototype,`multiDragDx`,void 0),H([(0,n.property)({type:Number})],q.prototype,`multiDragDy`,void 0),H([(0,n.property)({type:Boolean})],q.prototype,`multiDragSameRow`,void 0),H([(0,n.property)({type:Object})],q.prototype,`externalDragTask`,void 0),H([(0,n.property)({type:String})],q.prototype,`theme`,void 0),H([(0,n.property)({type:Boolean,reflect:!0})],q.prototype,`isSelected`,void 0),H([(0,n.property)({type:String})],q.prototype,`dropPosition`,void 0),H([(0,n.property)({type:Array})],q.prototype,`selectedTaskIds`,void 0),H([(0,n.property)({type:String})],q.prototype,`focusedTaskId`,void 0),H([(0,n.property)({type:Boolean,reflect:!0})],q.prototype,`isExporting`,void 0),H([(0,n.property)({type:Array})],q.prototype,`criticalPathTaskIds`,void 0),q=H([(0,n.customElement)(`gantt-row`)],q);function J(e,t,n,r,i,a,o,s){let c=n=>{if(Math.abs(t-r)<1)return`M ${e} ${t} L ${n} ${r}`;if(e<n){let i=(e+n)/2,a=r>t?1:-1,o=Math.min(s,i-e,n-i,Math.abs(r-t)/2);return[`M ${e} ${t}`,`L ${i-o} ${t}`,`Q ${i} ${t} ${i} ${t+a*o}`,`L ${i} ${r-a*o}`,`Q ${i} ${r} ${i+o} ${r}`,`L ${n} ${r}`].join(` `)}
|
|
798
|
+
`}};H([(0,n.property)({type:Object})],q.prototype,`row`,void 0),H([(0,n.property)({type:Object})],q.prototype,`option`,void 0),H([(0,n.property)({type:Boolean})],q.prototype,`isDragTarget`,void 0),H([(0,n.property)({type:Object})],q.prototype,`draggingTask`,void 0),H([(0,n.property)({type:Array})],q.prototype,`draggingTaskIds`,void 0),H([(0,n.property)({type:Number})],q.prototype,`multiDragDx`,void 0),H([(0,n.property)({type:Number})],q.prototype,`multiDragDy`,void 0),H([(0,n.property)({type:Boolean})],q.prototype,`multiDragSameRow`,void 0),H([(0,n.property)({type:Object})],q.prototype,`externalDragTask`,void 0),H([(0,n.property)({type:String})],q.prototype,`theme`,void 0),H([(0,n.property)({type:Boolean,reflect:!0})],q.prototype,`isSelected`,void 0),H([(0,n.property)({type:String})],q.prototype,`dropPosition`,void 0),H([(0,n.property)({type:Array})],q.prototype,`selectedTaskIds`,void 0),H([(0,n.property)({type:String})],q.prototype,`focusedTaskId`,void 0),H([(0,n.property)({type:Boolean,reflect:!0})],q.prototype,`isExporting`,void 0),H([(0,n.property)({type:Array})],q.prototype,`criticalPathTaskIds`,void 0),q=H([(0,n.customElement)(`gantt-row`)],q);function J(e,t,n,r,i,a,o,s){let c=n=>{if(Math.abs(t-r)<1)return`M ${e} ${t} L ${n} ${r}`;if(e<n){let i=(e+n)/2,a=r>t?1:-1,o=Math.min(s,i-e,n-i,Math.abs(r-t)/2);return[`M ${e} ${t}`,`L ${i-o} ${t}`,`Q ${i} ${t} ${i} ${t+a*o}`,`L ${i} ${r-a*o}`,`Q ${i} ${r} ${i+o} ${r}`,`L ${n} ${r}`].join(` `)}{let i=Math.max(12,s+4),c=e+i,l=n-i,u=(t+r)/2,d=Math.abs(t-r)<a?u+a+o:u,f=d-t,p=r-d,m=f>=0?1:-1,h=p>=0?1:-1,g=l-c,_=g>=0?1:-1,v=Math.min(s,i,Math.abs(f)/2),y=Math.min(s,Math.abs(f)/2,Math.abs(g)/2),b=Math.min(s,Math.abs(g)/2,Math.abs(p)/2),x=Math.min(s,Math.abs(p)/2,i);return[`M ${e} ${t}`,`L ${c-v} ${t}`,`Q ${c} ${t} ${c} ${t+m*v}`,`L ${c} ${d-m*y}`,`Q ${c} ${d} ${c+_*y} ${d}`,`L ${l-_*b} ${d}`,`Q ${l} ${d} ${l} ${d+h*b}`,`L ${l} ${r-h*x}`,`Q ${l} ${r} ${l+x} ${r}`,`L ${n} ${r}`].join(` `)}};return{pathD:c(i),hitPathD:c(n)}}var Y=t.css`
|
|
798
799
|
:host {
|
|
799
800
|
display: block;
|
|
800
801
|
width: 100%;
|
|
@@ -993,13 +994,13 @@
|
|
|
993
994
|
.header-resizer.resizing {
|
|
994
995
|
background-color: ${n.border};
|
|
995
996
|
}
|
|
996
|
-
`}function Z(e,t){let n=document.createElement(`a`);n.href=e,n.download=t,n.click()}async function ee(e,t=`png`,n={}){let{filename:r=`gantt-chart`,download:i=!1,scale:a=2,splitHeight:c}=n,l=e.shadowRoot?.querySelector(`.scroll-container`),u=l?l.scrollWidth:e.scrollWidth,d=l?l.scrollHeight:e.scrollHeight,f=await(0,o.default)(e,{backgroundColor:`#ffffff`,scale:a,width:u,height:d,windowWidth:u,windowHeight:d});if(c&&d>c){let t=50,n=e.shadowRoot?.querySelector(`gantt-calendar`);n&&n.offsetHeight>0?t=n.offsetHeight:e.calendarHeight&&(t=e.calendarHeight);let r=f.height/d,i=d-t,a=c-t,o=[];typeof e.getRowPositions==`function`&&(o=e.getRowPositions().map(e=>e.bottom));let s=[0],l=0;if(a>0)for(;l<i;){let e=l+a;if(e>=i){s.push(i);break}let t=-1;for(let n=0;n<o.length;n++){let r=o[n];r>l&&r<=e&&(t=Math.max(t,r))}if(t===-1)for(let e=0;e<o.length;e++){let n=o[e];if(n>l){t=n;break}}(t===-1||t===l)&&(t=e),s.push(t),l=t}else s.push(i);let u=s.length-1;if(u>0){let e=Math.floor(t*r),n=f.width,i=0,a=[];for(let n=0;n<u;n++){let o=s[n],c=s[n+1],l=Math.round((t+o)*r),u=Math.round((t+c)*r),d=u-l;a.push({srcStart:l,srcEnd:u,destHeight:d}),i+=e+d}let o=document.createElement(`canvas`);o.width=n,o.height=i;let c=o.getContext(`2d`);if(c){let t=0;for(let r=0;r<u;r++){c.drawImage(f,0,0,n,e,0,t,n,e),t+=e;let i=a[r];c.drawImage(f,0,i.srcStart,n,i.destHeight,0,t,n,i.destHeight),t+=i.destHeight}f=o,d=i/r}else console.warn(`[export] Failed to get 2D context for new canvas. It might be too large.`)}}if(t===`pdf`){let e=f.toDataURL(`image/jpeg`,.9),t=new s.jsPDF({orientation:u>d?`l`:`p`,unit:`px`,format:[u,d],compress:!0});return t.addImage(e,`JPEG`,0,0,u,d,void 0,`FAST`),i&&t.save(`${r}.pdf`),t.output(`blob`)}else{let e=f.toDataURL(`image/png`);return i&&Z(e,`${r}.png`),e}}function Q(e){let t=new Map,n=new Map,r=new Map;for(let n of e)for(let e of n.tasks){let n=e.dependencies??[],i=e.start instanceof Date?e.start.getTime():new Date(e.start).getTime(),a=e.end instanceof Date?e.end.getTime():new Date(e.end).getTime();isNaN(i)||isNaN(a)||(t.set(e.id,{start:i,end:a,duration:a-i,dependencies:n}),r.set(e.id,0))}let i=new Set;for(let[e,a]of t){let o=0;for(let r of a.dependencies)if(t.has(r)){o++;let t=n.get(r)??[];t.push(e),n.set(r,t),i.add(e),i.add(r)}r.set(e,o)}if(i.size<2)return new Set;let a=[];for(let e of i)(r.get(e)??0)===0&&a.push(e);let o=[];for(;a.length>0;){let e=a.shift();o.push(e);for(let t of n.get(e)??[]){if(!i.has(t))continue;let e=(r.get(t)??0)-1;r.set(t,e),e===0&&a.push(t)}}if(o.length<i.size){let e=new Set(o);for(let t of i)e.has(t)||i.delete(t);if(i.size<2)return new Set}let s=new Map,c=new Map;for(let e of o){let n=t.get(e);if(!n)continue;let r=n.dependencies.filter(e=>s.has(e));if(r.length===0)s.set(e,n.end),c.set(e,null);else{let t=-1/0,i=null;for(let e of r){let r=s.get(e)+n.duration;r>t&&(t=r,i=e)}n.end>t&&(t=n.end),s.set(e,t),c.set(e,i)}}let l=[];for(let e of o)(n.get(e)??[]).filter(e=>i.has(e)).length===0&&l.push(e);if(l.length===0)return new Set;let u=l[0],d=s.get(l[0])??0;for(let e=1;e<l.length;e++){let t=s.get(l[e])??0;t>d&&(d=t,u=l[e])}let f=new Set,p=u;for(;p!==null;)f.add(p),p=c.get(p)??null;return f.size<=1?new Set:f}var $=class extends t.LitElement{constructor(...e){super(...e),this.rows=[],this.theme=`light`,this.selectedRowIds=[],this.selectedTaskIds=[],this.externalDraggingTask=null,this.selectedRows=new Set,this.selectedTasks=new Set,this.lastClickedRowId=null,this.virtualScrollTop=0,this.dragTargetRowIndex=null,this.draggingTask=null,this.draggingTaskIds=[],this.multiDragDx=0,this.multiDragDy=0,this.multiDragSameRow=!1,this.viewportHeight=400,this.dragOverlayInfo=null,this.calendarHeight=0,this.tooltip=null,this.dragOverRowId=null,this.dragOverPosition=null,this.currentTime=new Date,this.dragPreview=null,this.currentRowHeaderWidth=150,this.isResizingHeader=!1,this.hoveredMilestoneId=null,this.cursorLineX=null,this.connectorDrag=null,this._systemThemeMediaQuery=null,this.isExporting=!1,this.focusedTaskId=null,this.focusedRowId=null,this.zoomPxPerDay=null,this.zoomPxPerMonth=null,this._layoutCache=null,this.resizeObserver=null,this._cachedSelectedTaskIds=[],this._cachedSelectedTasksSize=-1,this._cachedCurrentOption=null,this._lastOptionRef=null,this._lastLabelWidth=-1,this._lastZoomPxPerDay=null,this._lastZoomPxPerMonth=null,this._scrollContainer=null,this.handleSystemThemeChange=e=>{(this.option?.theme===`system`||this.option?.theme!==`light`&&this.option?.theme!==`dark`)&&(this.theme=e.matches?`dark`:`light`)},this.handleScroll=e=>{let t=e.target;this.updateScrollTop(t.scrollTop),this.hoverTimer!==void 0&&window.clearTimeout(this.hoverTimer),this.tooltip&&={...this.tooltip,visible:!1}},this.updateScrollTop=(0,a.throttle)(e=>{this.virtualScrollTop=e},100),this.handleContainerMouseMove=e=>{if(!this.option.calendar.showCursorLine)return;let t=this.shadowRoot?.querySelector(`.scroll-container`);if(!t)return;let n=t.getBoundingClientRect(),r=e.clientX-n.left+t.scrollLeft;if(r<this.currentRowHeaderWidth){this.cursorLineX=null;return}this.cursorLineX=r},this.handleContainerMouseLeave=()=>{this.cursorLineX=null},this.handleWheel=e=>{if(!e.ctrlKey&&!e.metaKey||this.option.zoom?.enabled!==!0)return;e.preventDefault();let t=this._scrollContainer;if(!t)return;let n=t.getBoundingClientRect(),r=this.currentRowHeaderWidth,i=e.clientX-n.left+t.scrollLeft-r,a=this.effectivePxPerMonth!==void 0,o=a?this.effectivePxPerMonth:this.effectivePxPerDay,s=this.option.zoom?.step??1.2,c=a?20:2,l=a?600:200,u=this.option.zoom?.min??c,d=this.option.zoom?.max??l,f=e.deltaY>0?1/s:s,p=Math.max(u,Math.min(d,o*f));if(p===o)return;a?this.zoomPxPerMonth=p:this.zoomPxPerDay=p;let m=p/o;this.updateComplete.then(()=>{let e=i*m-i;t.scrollLeft+=e}),this.dispatchEvent(new CustomEvent(`zoom-change`,{detail:{pxPerDay:a?this.effectivePxPerDay:p,pxPerMonth:a?p:void 0},bubbles:!0,composed:!0}))},this.handleKeyDown=e=>{if(this.option.keyboard?.enabled===!1)return;let t=e.composedPath()[0];if(!(t!==this&&t?.tagName&&[`INPUT`,`TEXTAREA`,`SELECT`].includes(t.tagName)))switch(e.key){case`ArrowRight`:e.shiftKey&&!this.option.readOnly?this.moveSelectedTasksByKeyboard(1):this.moveFocusHorizontal(1),e.preventDefault();break;case`ArrowLeft`:e.shiftKey&&!this.option.readOnly?this.moveSelectedTasksByKeyboard(-1):this.moveFocusHorizontal(-1),e.preventDefault();break;case`ArrowDown`:this.moveFocusVertical(1),e.preventDefault();break;case`ArrowUp`:this.moveFocusVertical(-1),e.preventDefault();break;case`Enter`:case` `:this.focusedTaskId&&(e.ctrlKey||e.metaKey?this.toggleTaskSelection(this.focusedTaskId):this.selectSingleTask(this.focusedTaskId)),e.preventDefault();break;case`Escape`:this.clearSelection(),this.focusedTaskId=null,this.focusedRowId=null;break;case`Delete`:case`Backspace`:!this.option.readOnly&&this.selectedTasks.size>0&&this.dispatchEvent(new CustomEvent(`task-delete`,{detail:{taskIds:[...this.selectedTasks],event:e},bubbles:!0,composed:!0})),e.preventDefault();break;case`Home`:this.focusFirstOrLastTaskInRow(`first`),e.preventDefault();break;case`End`:this.focusFirstOrLastTaskInRow(`last`),e.preventDefault();break}}}get displayRows(){return this.option.showHiddenRows?this.rows:this.rows.filter(e=>e.visible!==!1)}get effectivePxPerDay(){return this.zoomPxPerDay??this.option.calendar.pxPerDay??50}get effectivePxPerMonth(){return this.zoomPxPerMonth??this.option.calendar.pxPerMonth}static{this.styles=Y}firstUpdated(){this.setupCurrentTimeTimer();let e=this.shadowRoot?.getElementById(`calendar`);this.resizeObserver=new ResizeObserver(t=>{for(let n of t)n.target===this?this.viewportHeight=n.contentRect.height:n.target===e&&(this.calendarHeight=n.target.offsetHeight)}),this.resizeObserver.observe(this),e&&this.resizeObserver.observe(e),this._scrollContainer=this.shadowRoot?.querySelector(`.scroll-container`),this._scrollContainer?.addEventListener(`wheel`,this.handleWheel,{passive:!1})}connectedCallback(){super.connectedCallback(),this._systemThemeMediaQuery=window.matchMedia?window.matchMedia(`(prefers-color-scheme: dark)`):null,this._systemThemeMediaQuery?.addEventListener(`change`,this.handleSystemThemeChange),this.hasAttribute(`tabindex`)||this.setAttribute(`tabindex`,`0`),this.setAttribute(`role`,`grid`),this.setAttribute(`aria-label`,`Gantt Chart`),this.addEventListener(`keydown`,this.handleKeyDown),this.option?.theme===`system`||this.option?.theme!==`light`&&this.option?.theme!==`dark`?this.theme=this._systemThemeMediaQuery?.matches?`dark`:`light`:this.theme=this.option.theme}disconnectedCallback(){super.disconnectedCallback(),this.resizeObserver?.disconnect(),this.stopCurrentTimeTimer(),this._systemThemeMediaQuery?.removeEventListener(`change`,this.handleSystemThemeChange),this.removeEventListener(`keydown`,this.handleKeyDown),this._scrollContainer?.removeEventListener(`wheel`,this.handleWheel),this._scrollContainer=null}willUpdate(e){if(e.has(`option`)&&(this.option?.theme===`light`||this.option?.theme===`dark`?this.theme=this.option.theme:this._systemThemeMediaQuery&&(this.theme=this._systemThemeMediaQuery.matches?`dark`:`light`)),e.has(`option`)&&(this.setupCurrentTimeTimer(),this.isResizingHeader||(this.currentRowHeaderWidth=this.option.rowHeader?.width??150),this.zoomPxPerDay=null,this.zoomPxPerMonth=null),(e.has(`rows`)||e.has(`option`)||e.has(`currentRowHeaderWidth`)||e.has(`zoomPxPerDay`)||e.has(`zoomPxPerMonth`))&&(this._layoutCache=null),e.has(`selectedRowIds`)){let e=new Set(this.selectedRowIds);(e.size!==this.selectedRows.size||![...e].every(e=>this.selectedRows.has(e)))&&(this.selectedRows=e)}if(e.has(`selectedTaskIds`)){let e=new Set(this.selectedTaskIds);(e.size!==this.selectedTasks.size||![...e].every(e=>this.selectedTasks.has(e)))&&(this.selectedTasks=e)}(e.has(`selectedTasks`)||this._cachedSelectedTasksSize!==this.selectedTasks.size)&&(this._cachedSelectedTaskIds=[...this.selectedTasks],this._cachedSelectedTasksSize=this.selectedTasks.size)}updated(e){if(super.updated(e),this.tooltip){let e=this.shadowRoot?.querySelector(`.tooltip`);if(e){let n=this.option.customRendering?.tooltip?this.option.customRendering.tooltip(this.tooltip.task):void 0;if(n)typeof n==`string`?e.textContent=n:(0,t.render)(n,e);else{let n=this.option.locale??j,r=!!this.option.calendar.pxPerMonth,i=Math.round((this.tooltip.task.end.getTime()-this.tooltip.task.start.getTime())/(1e3*60*60*24));if(r){let r=new Date(this.tooltip.task.end);r.setMonth(r.getMonth()-1),(0,t.render)(t.html`
|
|
997
|
+
`}function Z(e,t){let n=document.createElement(`a`);n.href=e,n.download=t,n.click()}async function ee(e,t=`png`,n={}){let{filename:r=`gantt-chart`,download:i=!1,scale:a=2,splitHeight:c}=n,l=e.shadowRoot?.querySelector(`.scroll-container`),u=l?l.scrollWidth:e.scrollWidth,d=l?l.scrollHeight:e.scrollHeight,f=await(0,o.default)(e,{backgroundColor:`#ffffff`,scale:a,width:u,height:d,windowWidth:u,windowHeight:d});if(c&&d>c){let t=50,n=e.shadowRoot?.querySelector(`gantt-calendar`);n&&n.offsetHeight>0?t=n.offsetHeight:e.calendarHeight&&(t=e.calendarHeight);let r=f.height/d,i=d-t,a=c-t,o=[];typeof e.getRowPositions==`function`&&(o=e.getRowPositions().map(e=>e.bottom));let s=[0],l=0;if(a>0)for(;l<i;){let e=l+a;if(e>=i){s.push(i);break}let t=-1;for(let n=0;n<o.length;n++){let r=o[n];r>l&&r<=e&&(t=Math.max(t,r))}if(t===-1)for(let e=0;e<o.length;e++){let n=o[e];if(n>l){t=n;break}}(t===-1||t===l)&&(t=e),s.push(t),l=t}else s.push(i);let u=s.length-1;if(u>0){let e=Math.floor(t*r),n=f.width,i=0,a=[];for(let n=0;n<u;n++){let o=s[n],c=s[n+1],l=Math.round((t+o)*r),u=Math.round((t+c)*r),d=u-l;a.push({srcStart:l,srcEnd:u,destHeight:d}),i+=e+d}let o=document.createElement(`canvas`);o.width=n,o.height=i;let c=o.getContext(`2d`);if(c){let t=0;for(let r=0;r<u;r++){c.drawImage(f,0,0,n,e,0,t,n,e),t+=e;let i=a[r];c.drawImage(f,0,i.srcStart,n,i.destHeight,0,t,n,i.destHeight),t+=i.destHeight}f=o,d=i/r}else console.warn(`[export] Failed to get 2D context for new canvas. It might be too large.`)}}if(t===`pdf`){let e=f.toDataURL(`image/jpeg`,.9),t=new s.jsPDF({orientation:u>d?`l`:`p`,unit:`px`,format:[u,d],compress:!0});return t.addImage(e,`JPEG`,0,0,u,d,void 0,`FAST`),i&&t.save(`${r}.pdf`),t.output(`blob`)}{let e=f.toDataURL(`image/png`);return i&&Z(e,`${r}.png`),e}}function Q(e){let t=new Map,n=new Map,r=new Map;for(let n of e)for(let e of n.tasks){let n=e.dependencies??[],i=e.start instanceof Date?e.start.getTime():new Date(e.start).getTime(),a=e.end instanceof Date?e.end.getTime():new Date(e.end).getTime();isNaN(i)||isNaN(a)||(t.set(e.id,{start:i,end:a,duration:a-i,dependencies:n}),r.set(e.id,0))}let i=new Set;for(let[e,a]of t){let o=0;for(let r of a.dependencies)if(t.has(r)){o++;let t=n.get(r)??[];t.push(e),n.set(r,t),i.add(e),i.add(r)}r.set(e,o)}if(i.size<2)return new Set;let a=[];for(let e of i)(r.get(e)??0)===0&&a.push(e);let o=[];for(;a.length>0;){let e=a.shift();o.push(e);for(let t of n.get(e)??[]){if(!i.has(t))continue;let e=(r.get(t)??0)-1;r.set(t,e),e===0&&a.push(t)}}if(o.length<i.size){let e=new Set(o);for(let t of i)e.has(t)||i.delete(t);if(i.size<2)return new Set}let s=new Map,c=new Map;for(let e of o){let n=t.get(e);if(!n)continue;let r=n.dependencies.filter(e=>s.has(e));if(r.length===0)s.set(e,n.end),c.set(e,null);else{let t=-1/0,i=null;for(let e of r){let r=s.get(e)+n.duration;r>t&&(t=r,i=e)}n.end>t&&(t=n.end),s.set(e,t),c.set(e,i)}}let l=[];for(let e of o)(n.get(e)??[]).filter(e=>i.has(e)).length===0&&l.push(e);if(l.length===0)return new Set;let u=l[0],d=s.get(l[0])??0;for(let e=1;e<l.length;e++){let t=s.get(l[e])??0;t>d&&(d=t,u=l[e])}let f=new Set,p=u;for(;p!==null;)f.add(p),p=c.get(p)??null;return f.size<=1?new Set:f}var $=class extends t.LitElement{constructor(...e){super(...e),this.rows=[],this.theme=`light`,this.selectedRowIds=[],this.selectedTaskIds=[],this.externalDraggingTask=null,this.selectedRows=new Set,this.selectedTasks=new Set,this.lastClickedRowId=null,this.virtualScrollTop=0,this.dragTargetRowIndex=null,this.draggingTask=null,this.draggingTaskIds=[],this.multiDragDx=0,this.multiDragDy=0,this.multiDragSameRow=!1,this.viewportHeight=400,this.dragOverlayInfo=null,this.calendarHeight=0,this.tooltip=null,this.dragOverRowId=null,this.dragOverPosition=null,this.currentTime=new Date,this.dragPreview=null,this.currentRowHeaderWidth=150,this.isResizingHeader=!1,this.hoveredMilestoneId=null,this.cursorLineX=null,this.connectorDrag=null,this._systemThemeMediaQuery=null,this.isExporting=!1,this.focusedTaskId=null,this.focusedRowId=null,this.zoomPxPerDay=null,this.zoomPxPerMonth=null,this._layoutCache=null,this.resizeObserver=null,this._cachedSelectedTaskIds=[],this._cachedSelectedTasksSize=-1,this._cachedCurrentOption=null,this._lastOptionRef=null,this._lastLabelWidth=-1,this._lastZoomPxPerDay=null,this._lastZoomPxPerMonth=null,this._scrollContainer=null,this.handleSystemThemeChange=e=>{(this.option?.theme===`system`||this.option?.theme!==`light`&&this.option?.theme!==`dark`)&&(this.theme=e.matches?`dark`:`light`)},this.handleScroll=e=>{let t=e.target;this.updateScrollTop(t.scrollTop),this.hoverTimer!==void 0&&window.clearTimeout(this.hoverTimer),this.tooltip&&={...this.tooltip,visible:!1}},this.updateScrollTop=(0,a.throttle)(e=>{this.virtualScrollTop=e},100),this.handleContainerMouseMove=e=>{if(!this.option.calendar.showCursorLine)return;let t=this.shadowRoot?.querySelector(`.scroll-container`);if(!t)return;let n=t.getBoundingClientRect(),r=e.clientX-n.left+t.scrollLeft;if(r<this.currentRowHeaderWidth){this.cursorLineX=null;return}this.cursorLineX=r},this.handleContainerMouseLeave=()=>{this.cursorLineX=null},this.handleWheel=e=>{if(!e.ctrlKey&&!e.metaKey||this.option.zoom?.enabled!==!0)return;e.preventDefault();let t=this._scrollContainer;if(!t)return;let n=t.getBoundingClientRect(),r=this.currentRowHeaderWidth,i=e.clientX-n.left+t.scrollLeft-r,a=this.effectivePxPerMonth!==void 0,o=a?this.effectivePxPerMonth:this.effectivePxPerDay,s=this.option.zoom?.step??1.2,c=a?20:2,l=a?600:200,u=this.option.zoom?.min??c,d=this.option.zoom?.max??l,f=e.deltaY>0?1/s:s,p=Math.max(u,Math.min(d,o*f));if(p===o)return;a?this.zoomPxPerMonth=p:this.zoomPxPerDay=p;let m=p/o;this.updateComplete.then(()=>{let e=i*m-i;t.scrollLeft+=e}),this.dispatchEvent(new CustomEvent(`zoom-change`,{detail:{pxPerDay:a?this.effectivePxPerDay:p,pxPerMonth:a?p:void 0},bubbles:!0,composed:!0}))},this.handleKeyDown=e=>{if(this.option.keyboard?.enabled===!1)return;let t=e.composedPath()[0];if(!(t!==this&&t?.tagName&&[`INPUT`,`TEXTAREA`,`SELECT`].includes(t.tagName)))switch(e.key){case`ArrowRight`:e.shiftKey&&!this.option.readOnly?this.moveSelectedTasksByKeyboard(1):this.moveFocusHorizontal(1),e.preventDefault();break;case`ArrowLeft`:e.shiftKey&&!this.option.readOnly?this.moveSelectedTasksByKeyboard(-1):this.moveFocusHorizontal(-1),e.preventDefault();break;case`ArrowDown`:this.moveFocusVertical(1),e.preventDefault();break;case`ArrowUp`:this.moveFocusVertical(-1),e.preventDefault();break;case`Enter`:case` `:this.focusedTaskId&&(e.ctrlKey||e.metaKey?this.toggleTaskSelection(this.focusedTaskId):this.selectSingleTask(this.focusedTaskId)),e.preventDefault();break;case`Escape`:this.clearSelection(),this.focusedTaskId=null,this.focusedRowId=null;break;case`Delete`:case`Backspace`:!this.option.readOnly&&this.selectedTasks.size>0&&this.dispatchEvent(new CustomEvent(`task-delete`,{detail:{taskIds:[...this.selectedTasks],event:e},bubbles:!0,composed:!0})),e.preventDefault();break;case`Home`:this.focusFirstOrLastTaskInRow(`first`),e.preventDefault();break;case`End`:this.focusFirstOrLastTaskInRow(`last`),e.preventDefault()}}}get displayRows(){return this.option.showHiddenRows?this.rows:this.rows.filter(e=>e.visible!==!1)}get effectivePxPerDay(){return this.zoomPxPerDay??this.option.calendar.pxPerDay??50}get effectivePxPerMonth(){return this.zoomPxPerMonth??this.option.calendar.pxPerMonth}static{this.styles=Y}firstUpdated(){this.setupCurrentTimeTimer();let e=this.shadowRoot?.getElementById(`calendar`);this.resizeObserver=new ResizeObserver(t=>{for(let n of t)n.target===this?this.viewportHeight=n.contentRect.height:n.target===e&&(this.calendarHeight=n.target.offsetHeight)}),this.resizeObserver.observe(this),e&&this.resizeObserver.observe(e),this._scrollContainer=this.shadowRoot?.querySelector(`.scroll-container`),this._scrollContainer?.addEventListener(`wheel`,this.handleWheel,{passive:!1})}connectedCallback(){super.connectedCallback(),this._systemThemeMediaQuery=window.matchMedia?window.matchMedia(`(prefers-color-scheme: dark)`):null,this._systemThemeMediaQuery?.addEventListener(`change`,this.handleSystemThemeChange),this.hasAttribute(`tabindex`)||this.setAttribute(`tabindex`,`0`),this.setAttribute(`role`,`grid`),this.setAttribute(`aria-label`,`Gantt Chart`),this.addEventListener(`keydown`,this.handleKeyDown),this.theme=this.option?.theme===`system`||this.option?.theme!==`light`&&this.option?.theme!==`dark`?this._systemThemeMediaQuery?.matches?`dark`:`light`:this.option.theme}disconnectedCallback(){super.disconnectedCallback(),this.resizeObserver?.disconnect(),this.stopCurrentTimeTimer(),this._systemThemeMediaQuery?.removeEventListener(`change`,this.handleSystemThemeChange),this.removeEventListener(`keydown`,this.handleKeyDown),this._scrollContainer?.removeEventListener(`wheel`,this.handleWheel),this._scrollContainer=null}willUpdate(e){if(e.has(`option`)&&(this.option?.theme===`light`||this.option?.theme===`dark`?this.theme=this.option.theme:this._systemThemeMediaQuery&&(this.theme=this._systemThemeMediaQuery.matches?`dark`:`light`)),e.has(`option`)&&(this.setupCurrentTimeTimer(),this.isResizingHeader||(this.currentRowHeaderWidth=this.option.rowHeader?.width??150),this.zoomPxPerDay=null,this.zoomPxPerMonth=null),(e.has(`rows`)||e.has(`option`)||e.has(`currentRowHeaderWidth`)||e.has(`zoomPxPerDay`)||e.has(`zoomPxPerMonth`))&&(this._layoutCache=null),e.has(`selectedRowIds`)){let e=new Set(this.selectedRowIds);(e.size!==this.selectedRows.size||![...e].every(e=>this.selectedRows.has(e)))&&(this.selectedRows=e)}if(e.has(`selectedTaskIds`)){let e=new Set(this.selectedTaskIds);(e.size!==this.selectedTasks.size||![...e].every(e=>this.selectedTasks.has(e)))&&(this.selectedTasks=e)}(e.has(`selectedTasks`)||this._cachedSelectedTasksSize!==this.selectedTasks.size)&&(this._cachedSelectedTaskIds=[...this.selectedTasks],this._cachedSelectedTasksSize=this.selectedTasks.size)}updated(e){if(super.updated(e),this.tooltip){let e=this.shadowRoot?.querySelector(`.tooltip`);if(e){let n=this.option.customRendering?.tooltip?this.option.customRendering.tooltip(this.tooltip.task):void 0;if(n)typeof n==`string`?e.textContent=n:(0,t.render)(n,e);else{let n=this.option.locale??j,r=!!this.option.calendar.pxPerMonth,i=Math.round((this.tooltip.task.end.getTime()-this.tooltip.task.start.getTime())/864e5);if(r){let r=new Date(this.tooltip.task.end);r.setMonth(r.getMonth()-1),(0,t.render)(t.html`
|
|
997
998
|
<div style="font-weight: bold;">${this.tooltip.task.name}</div>
|
|
998
999
|
<div class="tooltip-row">
|
|
999
1000
|
${n.yearMonthFormat(this.tooltip.task.start)} - ${n.yearMonthFormat(r)}
|
|
1000
1001
|
</div>
|
|
1001
1002
|
<div class="tooltip-row">${n.tooltip.duration(i)}</div>
|
|
1002
|
-
`,e)}else
|
|
1003
|
+
`,e)}else(0,t.render)(t.html`
|
|
1003
1004
|
<div style="font-weight: bold;">${this.tooltip.task.name}</div>
|
|
1004
1005
|
<div class="tooltip-row">
|
|
1005
1006
|
${n.dateFormat(this.tooltip.task.start)} - ${n.dateFormat(this.tooltip.task.end)}
|
|
@@ -1015,7 +1016,7 @@
|
|
|
1015
1016
|
(${B(this.dragOverlayInfo.currentStart,this.dragOverlayInfo.currentEnd,this.option.locale)})
|
|
1016
1017
|
</div>
|
|
1017
1018
|
${r?t.html`<div class="drag-info-sub" style="margin-top: 4px; border-top: 1px solid ${e.dragOverlayDivider}; padding-top: 4px; width: 100%;">${(this.option.locale??j).dragOverlay.moveTo(r.name)}</div>`:``}
|
|
1018
|
-
`,n)}if(this.dragOverlayInfo.clientY!==void 0){let e=this.dragOverlayInfo.clientX??0,t=this.dragOverlayInfo.clientY,r=this.getBoundingClientRect();if(e<r.left||e>r.right||t<r.top||t>r.bottom){n.classList.remove(`visible`);return}let i=n.offsetWidth||200,a=n.offsetHeight||60,o=window.innerWidth,s=window.innerHeight,c=e-i/2;c=Math.max(8,Math.min(c,o-i-8));let l=t-a-40;l<8&&(l=t+40),l+a>s-8&&(l=s-a-8),n.style.left=`${c}px`,n.style.transform=`none`,n.style.top=`${l}px`,n.style.bottom=`auto`}}hideDragOverlay(){let e=this.shadowRoot?.querySelector(`.drag-info-overlay`);e&&e.classList.remove(`visible`)}setupCurrentTimeTimer(){this.stopCurrentTimeTimer();let e=this.option.calendar.currentTimeUpdateInterval;e&&e>0&&(this.currentTimeTimer=window.setInterval(()=>{this.currentTime=new Date},e))}stopCurrentTimeTimer(){this.currentTimeTimer!==void 0&&(window.clearInterval(this.currentTimeTimer),this.currentTimeTimer=void 0)}handleHeaderResizeStart(e){e.preventDefault(),e.stopPropagation(),this.isResizingHeader=!0;let t=e.clientX,n=this.currentRowHeaderWidth,r=e.target;r.setPointerCapture(e.pointerId);let i=this.option.rowHeader?.minWidth??50,a=this.option.rowHeader?.maxWidth??2**53-1,o=e=>{let r=n+(e.clientX-t);this.currentRowHeaderWidth=Math.max(i,Math.min(a,r))},s=()=>{this.isResizingHeader=!1,r.releasePointerCapture(e.pointerId),r.removeEventListener(`pointermove`,o),r.removeEventListener(`pointerup`,s);let t=Math.round(this.currentRowHeaderWidth);this.currentRowHeaderWidth=t,this.dispatchEvent(new CustomEvent(`row-header-resize`,{detail:{width:t},bubbles:!0,composed:!0}))};r.addEventListener(`pointermove`,o),r.addEventListener(`pointerup`,s)}getDateX(e){return P(e,this.option.calendar.start,this.effectivePxPerDay,this.effectivePxPerMonth)}calculateLayout(){if(this._layoutCache)return this._layoutCache;let e=0,t=this.currentRowHeaderWidth,n=new Map,r={layouts:this.displayRows.map(r=>{let{tasksWithLanes:i,laneCount:a}=I(r.tasks),o=this.option.bar?.height??28,s=this.option.bar?.margin??4;i.forEach(r=>{let i=this.getDateX(r.start)+t,a=this.getDateX(r.end)+t-i,c=e+r.lane*(o+s)+s;n.set(r.id,{x:i,y:c,width:a,height:o,dependencies:r.dependencies})});let c=a*(o+s)+s,l={top:e,height:c};return e+=c,l}),taskCoords:n,totalHeight:e};return this._layoutCache=r,r}isMultiDrag(e){return this.selectedTasks.size>=2&&this.selectedTasks.has(e)}isMultiDragSameRow(){if(this.selectedTasks.size<2)return!1;let e=null;for(let t of this.rows)for(let n of t.tasks)if(this.selectedTasks.has(n.id)){if(e===null)e=t.id;else if(e!==t.id)return!1}return e!==null}handleTaskUpdate(e){e.stopPropagation();let{id:t,start:n,end:r,dx:i,isDragging:a,mode:o}=e.detail,{dy:s}=e.detail,c=this.isMultiDrag(t),l=c&&this.isMultiDragSameRow();c&&!l&&(s=0);let u=n,d=r;if(i!==void 0){let e=this.effectivePxPerDay,t=this.effectivePxPerMonth,a=this.getDateX(n),o=this.getDateX(r);u=F(a+i,this.option.calendar.start,e,t),d=F(o+i,this.option.calendar.start,e,t)}(this.option.calendar.pxPerMonth||this.option.snapDuration&&this.option.snapDuration>=43200)&&(u.getDate()>15&&u.setMonth(u.getMonth()+1),u.setDate(1),u.setHours(0,0,0,0),d.getDate()>15&&d.setMonth(d.getMonth()+1),d.setDate(1),d.setHours(0,0,0,0));let f=-1,p,m=-1;if(this.rows.find((e,n)=>{let r=e.tasks.findIndex(e=>e.id===t);return r===-1?!1:(f=n,p=e.tasks[r],m=r,!0)}),f===-1||!p)return;let{layouts:h}=this.calculateLayout(),g=this.displayRows.findIndex(e=>e.id===this.rows[f].id);if(g===-1)return;let _=h[g].top,{tasksWithLanes:v}=I(this.rows[f].tasks),y=v.find(e=>e.id===t),b=y?y.lane:0,x=this.option.bar?.height??28,S=this.option.bar?.margin??4,C=_+(b*(x+S)+S)+s+x/2,w=-1;for(let e=0;e<h.length;e++){let t=h[e];if(C>=t.top&&C<t.top+t.height){w=e;break}}let T=w===-1?void 0:this.displayRows[w].id,E=c?[...this.selectedTasks]:void 0;if(this.dispatchEvent(new CustomEvent(`task-update`,{detail:{...e.detail,dy:s,start:u,end:d,targetRowId:T,selectedTaskIds:E},bubbles:!0,composed:!0})),a){if(this.hoverTimer!==void 0&&window.clearTimeout(this.hoverTimer),this.tooltip&&=null,(!this.draggingTask||this.draggingTask.id!==t)&&(this.draggingTask={id:t,name:e.detail.name,start:n,end:r,currentStart:u,currentEnd:d,mode:o},c?this.draggingTaskIds=[...this.selectedTasks]:this.draggingTaskIds=[]),c?(this.multiDragDx=i??0,this.multiDragSameRow=l,l?this.multiDragDy=s:this.multiDragDy=0):(this.multiDragDx!==0||this.multiDragDy!==0)&&(this.multiDragDx=0,this.multiDragDy=0),!c||l){let e=w>=0?w:null;this.dragTargetRowIndex!==e&&(this.dragTargetRowIndex=e)}c?this.dragOverlayInfo={id:t,name:(this.option.locale??j).dragOverlay.movingTasks(this.selectedTasks.size),start:n,end:r,currentStart:u,currentEnd:d,visible:!0,clientX:e.detail.x,clientY:e.detail.y}:this.dragOverlayInfo={id:t,name:e.detail.name,start:n,end:r,currentStart:u,currentEnd:d,targetRow:w>=0?this.displayRows[w]:void 0,visible:!0,clientX:e.detail.x,clientY:e.detail.y},this.updateDragOverlay();return}let D=this.draggingTaskIds.length>=2,O=this.multiDragSameRow;this.draggingTask=null,this.draggingTaskIds=[],this.multiDragDx=0,this.multiDragDy=0,this.multiDragSameRow=!1,this.dragTargetRowIndex=null,this.dragOverlayInfo&&(this.dragOverlayInfo={...this.dragOverlayInfo,visible:!1},this.hideDragOverlay()),this.tooltip&&={...this.tooltip,visible:!1};let k=-1;if(w!==-1){let e=this.displayRows[w];k=this.rows.findIndex(t=>t.id===e.id)}if(D&&i!==void 0){let e=this.effectivePxPerDay,t=this.effectivePxPerMonth;if(O&&k!==-1&&f!==k){let n=[...this.rows],r={...n[f]},a={...n[k]};r.tasks=[...r.tasks],a.tasks=[...a.tasks];let o=[];r.tasks=r.tasks.filter(n=>{if(this.selectedTasks.has(n.id)){let r=this.getDateX(n.start),a=this.getDateX(n.end),s=F(r+i,this.option.calendar.start,e,t),c=F(a+i,this.option.calendar.start,e,t);return(this.option.calendar.pxPerMonth||this.option.snapDuration&&this.option.snapDuration>=43200)&&(s.getDate()>15&&s.setMonth(s.getMonth()+1),s.setDate(1),s.setHours(0,0,0,0),c.getDate()>15&&c.setMonth(c.getMonth()+1),c.setDate(1),c.setHours(0,0,0,0)),o.push({...n,start:s,end:c}),!1}return!0}),a.tasks.push(...o),n[f]=r,n[k]=a,requestAnimationFrame(()=>{this.rows=n,this.dispatchEvent(new CustomEvent(`rows-change`,{detail:this.rows,bubbles:!0,composed:!0}))})}else{let n=this.rows.map(n=>n.tasks.some(e=>this.selectedTasks.has(e.id))?{...n,tasks:n.tasks.map(n=>{if(!this.selectedTasks.has(n.id))return n;let r=this.getDateX(n.start),a=this.getDateX(n.end),o=F(r+i,this.option.calendar.start,e,t),s=F(a+i,this.option.calendar.start,e,t);return(this.option.calendar.pxPerMonth||this.option.snapDuration&&this.option.snapDuration>=43200)&&(o.getDate()>15&&o.setMonth(o.getMonth()+1),o.setDate(1),o.setHours(0,0,0,0),s.getDate()>15&&s.setMonth(s.getMonth()+1),s.setDate(1),s.setHours(0,0,0,0)),{...n,start:o,end:s}})}:n);requestAnimationFrame(()=>{this.rows=n,this.dispatchEvent(new CustomEvent(`rows-change`,{detail:this.rows,bubbles:!0,composed:!0}))})}return}if(o===`copy`){if(k!==-1){let e=[...this.rows],t={...e[k]};t.tasks=[...t.tasks];let n=`task-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,r={...p,id:n,start:u,end:d,dependencies:[]};t.tasks.push(r),e[k]=t,requestAnimationFrame(()=>{this.rows=e,this.dispatchEvent(new CustomEvent(`rows-change`,{detail:this.rows,bubbles:!0,composed:!0}))})}}else{let e=[...this.rows],t={...e[f]};if(t.tasks=[...t.tasks],e[f]=t,k!==-1&&f!==k){let n={...e[k]};n.tasks=[...n.tasks],e[k]=n;let[r]=t.tasks.splice(m,1);n.tasks.push({...r,start:u,end:d})}else t.tasks[m]={...p,start:u,end:d};requestAnimationFrame(()=>{this.rows=e,this.dispatchEvent(new CustomEvent(`rows-change`,{detail:this.rows,bubbles:!0,composed:!0}))})}}handleBarMouseEnter(e){if(this.draggingTask||this.option.showTooltip===!1)return;this.hoverTimer!==void 0&&window.clearTimeout(this.hoverTimer);let t=this.option.tooltipDelay??500;t>0?this.hoverTimer=window.setTimeout(()=>{this.tooltip={...e.detail,visible:!0,below:!1}},t):this.tooltip={...e.detail,visible:!0,below:!1}}handleBarMouseLeave(){this.hoverTimer!==void 0&&window.clearTimeout(this.hoverTimer),this.tooltip&&={...this.tooltip,visible:!1}}async reorderRows(e,t,n){let r=Array.isArray(e)?e:[e],i=Array.from(this.shadowRoot?.querySelectorAll(`gantt-row`)??[]),a=new Map;i.forEach(e=>{e.row&&a.set(e.row.id,e.getBoundingClientRect().top)});let o=[...this.rows],s=[];if(o.findIndex(e=>e.id===t)===-1)return;r.forEach(e=>{let t=o.findIndex(t=>t.id===e);t!==-1&&s.push(o[t])});let c=o.filter(e=>!r.includes(e.id));if(r.includes(t))return;let l=c.findIndex(e=>e.id===t);n===`bottom`&&l++,c.splice(l,0,...s),this.rows=c,await this.updateComplete,Array.from(this.shadowRoot?.querySelectorAll(`gantt-row`)??[]).forEach(e=>{if(e.row){let t=a.get(e.row.id);if(t!==void 0){let n=t-e.getBoundingClientRect().top;n!==0&&e.animate([{transform:`translateY(${n}px)`,zIndex:`1`},{transform:`translateY(0)`,zIndex:`1`}],{duration:300,easing:`ease-out`})}}}),this.dispatchEvent(new CustomEvent(`row-reordered`,{detail:{sourceId:r[0],sourceIds:r,targetId:t,position:n,rows:this.rows},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`rows-change`,{detail:this.rows,bubbles:!0,composed:!0}))}handleContainerDragOver(e){e.preventDefault();let t=e.dataTransfer&&e.dataTransfer.types.includes(`application/json`);if(t&&(e.dataTransfer.dropEffect=`copy`),!this.option.enableRowReordering&&!t)return;let n=this.shadowRoot?.querySelector(`.scroll-container`);if(!n)return;let r=n.getBoundingClientRect(),i=e.clientY-r.top+n.scrollTop-this.calendarHeight,{layouts:a}=this.calculateLayout(),o=-1;for(let e=0;e<a.length;e++){let t=a[e];if(i>=t.top&&i<t.top+t.height){o=e;break}}if(o!==-1){let s=this.displayRows[o];if(t){if((this.dragOverRowId!==s.id||this.dragOverPosition!==null)&&(this.dragOverRowId=s.id,this.dragOverPosition=null),this.externalDraggingTask){let t=this.currentRowHeaderWidth,i=n.scrollLeft,a=e.clientX-r.left+i-t,o=this.effectivePxPerDay,c=this.effectivePxPerMonth,l=this.option.snapDuration??1440,u=o/1440*l,d=F(Math.round(a/u)*u,this.option.calendar.start,o,c),f=this.externalDraggingTask.end.getTime()-this.externalDraggingTask.start.getTime(),p=new Date(d.getTime()+f);(!this.dragPreview||this.dragPreview.rowId!==s.id||this.dragPreview.currentStart.getTime()!==d.getTime())&&(this.dragPreview={task:this.externalDraggingTask,currentStart:d,currentEnd:p,rowId:s.id})}}else{let e=a[o],t=i-e.top<e.height/2?`top`:`bottom`;(this.dragOverRowId!==s.id||this.dragOverPosition!==t)&&(this.dragOverRowId=s.id,this.dragOverPosition=t)}}else this.dragOverRowId=null,this.dragOverPosition=null,this.dragPreview=null}handleContainerDragLeave(e){let t=this.shadowRoot?.querySelector(`.scroll-container`),n=e.relatedTarget;t&&t.contains(n)||(this.dragOverRowId=null,this.dragOverPosition=null,this.dragPreview=null)}handleContainerDrop(e){e.preventDefault();let t=e.dataTransfer?.getData(`application/json`);if(t){this.handleExternalTaskDrop(e,t),this.dragOverRowId=null,this.dragOverPosition=null,this.dragPreview=null;return}if(!this.option.enableRowReordering)return;let n=e.dataTransfer?.getData(`text/plain`),r=this.dragOverRowId,i=this.dragOverPosition;if(this.dragOverRowId=null,this.dragOverPosition=null,this.dragPreview=null,n&&r&&n!==r&&i)if(this.selectedRows.has(n)&&this.selectedRows.size>1){let e=Array.from(this.selectedRows);this.reorderRows(e,r,i)}else this.reorderRows(n,r,i)}handleExternalTaskDrop(e,t){try{let n=JSON.parse(t);if(!n||typeof n!=`object`||typeof n.id!=`string`||typeof n.name!=`string`||!n.start||!n.end){console.warn(`Invalid dropped task data: missing required fields (id, name, start, end)`);return}let r=new Date(n.start),i=new Date(n.end);if(isNaN(r.getTime())||isNaN(i.getTime())){console.warn(`Invalid dropped task data: start or end is not a valid date`);return}let a={...n,start:r,end:i},o=this.shadowRoot?.querySelector(`.scroll-container`);if(!o)return;let s=o.getBoundingClientRect(),c=o.scrollLeft,l=o.scrollTop,u=this.currentRowHeaderWidth,d=e.clientX-s.left+c-u,f=this.effectivePxPerDay,p=this.effectivePxPerMonth,m=F(d,this.option.calendar.start,f,p),h=e.clientY-s.top+l-this.calendarHeight,{layouts:g}=this.calculateLayout(),_;for(let e=0;e<g.length;e++){let t=g[e];if(h>=t.top&&h<t.top+t.height){_=this.displayRows[e].id;break}}_&&this.dispatchEvent(new CustomEvent(`task-drop`,{detail:{task:a,dropDate:m,targetRowId:_},bubbles:!0,composed:!0}))}catch(e){console.warn(`Failed to parse dropped task data`,e)}}handleRowClicked(e){let{rowId:t,event:n}=e.detail,{shiftKey:r,ctrlKey:i,metaKey:a}=n,o=new Set(this.selectedRows);if(r&&this.lastClickedRowId){let e=this.rows.findIndex(e=>e.id===this.lastClickedRowId),n=this.rows.findIndex(e=>e.id===t);if(e!==-1&&n!==-1){let t=Math.min(e,n),r=Math.max(e,n);for(let e=t;e<=r;e++)o.add(this.rows[e].id)}}else if(i||a)o.has(t)?o.delete(t):o.add(t),this.lastClickedRowId=t;else{if(o.has(t)){this.lastClickedRowId=t;return}o.clear(),o.add(t),this.lastClickedRowId=t}this.selectedRows=o,this.dispatchEvent(new CustomEvent(`row-selection-change`,{detail:{selectedIds:Array.from(this.selectedRows)},bubbles:!0,composed:!0}))}handleRowContextMenu(e){this.selectedRows.has(e.detail.rowId)||this.handleRowClicked(e)}handleContainerClick(e){e.defaultPrevented||this.clearSelection()}handleContainerContextMenu(e){if(e.defaultPrevented)return;e.preventDefault();let t=this.shadowRoot?.querySelector(`.scroll-container`);if(!t)return;let n=t.getBoundingClientRect(),r=t.scrollLeft,i=t.scrollTop,a=this.currentRowHeaderWidth,o=e.clientY-n.top+i-this.calendarHeight,{layouts:s}=this.calculateLayout(),c;for(let e=0;e<s.length;e++){let t=s[e];if(o>=t.top&&o<t.top+t.height){c=this.displayRows[e].id;break}}if(c){let t=e.clientX-n.left+r-a,i=this.effectivePxPerDay,o=this.effectivePxPerMonth,s=F(t,this.option.calendar.start,i,o);this.dispatchEvent(new CustomEvent(`chart-contextmenu`,{detail:{event:e,date:s,rowId:c},bubbles:!0,composed:!0}))}this.clearSelection()}hitTest(e,t){let n=this.shadowRoot?.querySelector(`.scroll-container`);if(!n)return null;let r=n.getBoundingClientRect(),i=n.scrollLeft,a=n.scrollTop,o=this.currentRowHeaderWidth,s=t-r.top+a-this.calendarHeight,{layouts:c}=this.calculateLayout(),l;for(let e=0;e<c.length;e++){let t=c[e];if(s>=t.top&&s<t.top+t.height){l=this.displayRows[e].id;break}}if(!l)return null;let u=e-r.left+i-o,d=this.effectivePxPerDay,f=this.effectivePxPerMonth,p=F(u,this.option.calendar.start,d,f);return{rowId:l,date:p}}getRowPositions(){let{layouts:e}=this.calculateLayout();return e.map(e=>({top:e.top,height:e.height,bottom:e.top+e.height}))}async exportImage(e=`png`,t={}){this.isExporting=!0,await this.updateComplete,await new Promise(e=>requestAnimationFrame(e));try{return await ee(this,e,t)}finally{this.isExporting=!1,await this.updateComplete}}zoomTo(e){let t=this.effectivePxPerMonth!==void 0,n=t?20:2,r=t?600:200,i=this.option.zoom?.min??n,a=this.option.zoom?.max??r,o=Math.max(i,Math.min(a,e));t?this.zoomPxPerMonth=o:this.zoomPxPerDay=o,this.dispatchEvent(new CustomEvent(`zoom-change`,{detail:{pxPerDay:t?this.effectivePxPerDay:o,pxPerMonth:t?o:void 0},bubbles:!0,composed:!0}))}zoomToFit(){let e=this.shadowRoot?.querySelector(`.scroll-container`);if(!e)return;let t=null,n=null;for(let e of this.displayRows)for(let r of e.tasks)(!t||r.start<t)&&(t=r.start),(!n||r.end>n)&&(n=r.end);if(!t||!n)return;let r=this.currentRowHeaderWidth,i=e.clientWidth-r;if(!(i<=0)){if(this.effectivePxPerMonth!==void 0){let e=(n.getFullYear()-t.getFullYear())*12+(n.getMonth()-t.getMonth()),r=i/Math.max(1,e);this.zoomTo(r)}else{let e=n.getTime()-t.getTime(),r=i/Math.max(1,e/(1e3*60*60*24));this.zoomTo(r)}requestAnimationFrame(()=>{let n=this.getDateX(t)+r;e.scrollLeft=Math.max(0,n-10)})}}resetZoom(){let e=this.zoomPxPerDay!==null||this.zoomPxPerMonth!==null;if(this.zoomPxPerDay=null,this.zoomPxPerMonth=null,e){let e=this.option.calendar.pxPerMonth!==void 0;this.dispatchEvent(new CustomEvent(`zoom-change`,{detail:{pxPerDay:this.option.calendar.pxPerDay??50,pxPerMonth:e?this.option.calendar.pxPerMonth:void 0},bubbles:!0,composed:!0}))}}clearSelection(){this.selectedRows.size===0&&this.selectedTasks.size===0||(this.selectedRows.size>0&&(this.selectedRows=new Set,this.dispatchEvent(new CustomEvent(`row-selection-change`,{detail:{selectedIds:[]},bubbles:!0,composed:!0}))),this.selectedTasks.size>0&&(this.selectedTasks=new Set,this.dispatchEvent(new CustomEvent(`bar-selection-change`,{detail:{selectedIds:[]},bubbles:!0,composed:!0}))))}moveFocusHorizontal(e){let t=this.displayRows;if(t.length===0)return;if(!this.focusedTaskId||!this.focusedRowId){this.focusFirstAvailableTask();return}let n=t.findIndex(e=>e.id===this.focusedRowId);if(n===-1){this.focusFirstAvailableTask();return}let r=t[n],i=[...r.tasks].sort((e,t)=>e.start.getTime()-t.start.getTime()),a=i.findIndex(e=>e.id===this.focusedTaskId);if(a===-1){i.length>0&&this.setFocus(i[0].id,r.id);return}let o=a+e;o>=0&&o<i.length?this.setFocus(i[o].id,r.id):this.moveFocusVertical(e)}moveFocusVertical(e){let t=this.displayRows;if(t.length===0)return;if(!this.focusedTaskId||!this.focusedRowId){this.focusFirstAvailableTask();return}let n=t.findIndex(e=>e.id===this.focusedRowId);if(n===-1){this.focusFirstAvailableTask();return}for(let r=n+e;r>=0&&r<t.length;r+=e){let n=t[r];if(n.tasks.length>0){let t=[...n.tasks].sort((e,t)=>e.start.getTime()-t.start.getTime()),r=e>0?t[0]:t[t.length-1];this.setFocus(r.id,n.id);return}}}focusFirstAvailableTask(){for(let e of this.displayRows)if(e.tasks.length>0){let t=[...e.tasks].sort((e,t)=>e.start.getTime()-t.start.getTime());this.setFocus(t[0].id,e.id);return}}focusFirstOrLastTaskInRow(e){if(!this.focusedRowId){this.focusFirstAvailableTask();return}let t=this.displayRows.find(e=>e.id===this.focusedRowId);if(!t||t.tasks.length===0)return;let n=[...t.tasks].sort((e,t)=>e.start.getTime()-t.start.getTime()),r=e===`first`?n[0]:n[n.length-1];this.setFocus(r.id,t.id)}setFocus(e,t){this.focusedTaskId=e,this.focusedRowId=t,this.scrollToTask(e)}toggleTaskSelection(e){let t=new Set(this.selectedTasks);t.has(e)?t.delete(e):t.add(e),this.selectedTasks=t,this.dispatchEvent(new CustomEvent(`bar-selection-change`,{detail:{selectedIds:[...t]},bubbles:!0,composed:!0}))}selectSingleTask(e){this.selectedTasks=new Set([e]),this.dispatchEvent(new CustomEvent(`bar-selection-change`,{detail:{selectedIds:[e]},bubbles:!0,composed:!0}))}moveSelectedTasksByKeyboard(e){if(this.selectedTasks.size===0)return;let t=(this.option.keyboard?.moveStep??this.option.snapDuration??1440)*60*1e3*e,n=this.rows.map(e=>e.tasks.some(e=>this.selectedTasks.has(e.id))?{...e,tasks:e.tasks.map(e=>this.selectedTasks.has(e.id)?{...e,start:new Date(e.start.getTime()+t),end:new Date(e.end.getTime()+t)}:e)}:e);for(let e of this.rows)for(let n of e.tasks){if(!this.selectedTasks.has(n.id))continue;let r=new Date(n.start.getTime()+t),i=new Date(n.end.getTime()+t);this.dispatchEvent(new CustomEvent(`task-update`,{detail:{id:n.id,name:n.name,start:r,end:i,dx:0,dy:0,isDragging:!1,mode:`move`,targetRowId:e.id},bubbles:!0,composed:!0}))}this.rows=n,this.dispatchEvent(new CustomEvent(`rows-change`,{detail:this.rows,bubbles:!0,composed:!0}))}handleBarClick(e){e.stopPropagation();let{task:t,isMultiSelect:n}=e.detail;this.draggingTask=null,this.dragTargetRowIndex=null,this.dragOverlayInfo&&(this.dragOverlayInfo={...this.dragOverlayInfo,visible:!1},this.hideDragOverlay());let r;n?(r=new Set(this.selectedTasks),r.has(t.id)?r.delete(t.id):r.add(t.id)):r=new Set([t.id]),this.selectedTasks=r,this.dispatchEvent(new CustomEvent(`bar-selection-change`,{detail:{selectedIds:[...r]},bubbles:!0,composed:!0}))}handleBarContextMenu(e){let{task:t}=e.detail;this.selectedTasks.has(t.id)||(this.selectedTasks=new Set([t.id]),this.dispatchEvent(new CustomEvent(`bar-selection-change`,{detail:{selectedIds:[t.id]},bubbles:!0,composed:!0})))}handleConnectorDragStart(e){let{taskId:t,endpoint:n,clientX:r,clientY:i}=e.detail;e.stopPropagation();let{taskCoords:a}=this.calculateLayout(),o=a.get(t),s=this.currentRowHeaderWidth,c=e.detail.startX+s,l=e.detail.startY;o&&(c=n===`start`?o.x:o.x+o.width,l=o.y+o.height/2),this.connectorDrag={sourceTaskId:t,sourceEndpoint:n,startX:c,startY:l,currentClientX:r,currentClientY:i,targetTaskId:null,targetEndpoint:null},this.tooltip&&=null}handleConnectorDragMove(e){if(!this.connectorDrag)return;e.stopPropagation();let{clientX:t,clientY:n}=e.detail,r=this.shadowRoot?.querySelector(`.scroll-container`);if(!r)return;let i=r.getBoundingClientRect(),a=t-i.left+r.scrollLeft,o=n-i.top+r.scrollTop-this.calendarHeight,{taskCoords:s}=this.calculateLayout(),c=null,l=null,u=30;for(let[e,t]of s){if(e===this.connectorDrag.sourceTaskId)continue;let n=t.y+t.height/2,r=t.x,i=t.x+t.width,s=Math.sqrt((a-r)**2+(o-n)**2),d=Math.sqrt((a-i)**2+(o-n)**2);s<u&&(u=s,c=e,l=`start`),d<u&&(u=d,c=e,l=`end`)}let d=this.connectorDrag.targetTaskId;d!==c&&(d&&this._setConnectorDropTarget(d,!1),c&&this._setConnectorDropTarget(c,!0)),this.connectorDrag={...this.connectorDrag,currentClientX:t,currentClientY:n,targetTaskId:c,targetEndpoint:l}}handleConnectorDragEnd(e){if(!this.connectorDrag)return;e.stopPropagation();let{cancelled:t}=e.detail,{sourceTaskId:n,sourceEndpoint:r,targetTaskId:i,targetEndpoint:a}=this.connectorDrag;i&&this._setConnectorDropTarget(i,!1),!t&&i&&a&&this.dispatchEvent(new CustomEvent(`dependency-create`,{detail:{sourceTaskId:n,sourceEndpoint:r,targetTaskId:i,targetEndpoint:a},bubbles:!0,composed:!0})),this.connectorDrag=null}_setConnectorDropTarget(e,t){let n=this.shadowRoot?.querySelectorAll(`gantt-row`);if(n)for(let r of n){let n=r.shadowRoot?.querySelectorAll(`gantt-bar`);if(n){for(let r of n)if(r.task?.id===e){r.connectorDropTarget=t;return}}}}handleDependencyLineClick(e,t,n){this.dispatchEvent(new CustomEvent(`dependency-click`,{detail:{event:e,sourceTaskId:n,targetTaskId:t},bubbles:!0,composed:!0}))}selectTask(e){let t=!1;for(let n of this.displayRows)if(n.tasks.some(t=>t.id===e)){t=!0;break}return t?(this.selectedTasks=new Set([e]),this.dispatchEvent(new CustomEvent(`bar-selection-change`,{detail:{selectedIds:[e]},bubbles:!0,composed:!0})),this.scrollToTask(e),!0):!1}scrollToTask(e){let{taskCoords:t}=this.calculateLayout(),n=t.get(e);if(!n)return;let r=this.shadowRoot?.querySelector(`.scroll-container`);if(!r)return;let i=this.currentRowHeaderWidth,a=n.y+this.calendarHeight,o=a+n.height,s=r.scrollTop,c=r.scrollTop+r.clientHeight;if(a<s||o>c){let e=a-r.clientHeight/2+n.height/2;r.scrollTo({top:Math.max(0,e),behavior:`smooth`})}let l=n.x,u=n.x+n.width,d=r.scrollLeft+i,f=r.scrollLeft+r.clientWidth;if(l<d||u>f){let e=l-i-20;r.scrollTo({left:Math.max(0,e),behavior:`smooth`})}}render(){let e=L(this.theme,this.option.customTheme),{layouts:n,taskCoords:r,totalHeight:a}=this.calculateLayout(),o=this.currentRowHeaderWidth;(this._lastOptionRef!==this.option||this._lastLabelWidth!==o||this._lastZoomPxPerDay!==this.zoomPxPerDay||this._lastZoomPxPerMonth!==this.zoomPxPerMonth)&&(this._cachedCurrentOption={...this.option,rowHeader:{...this.option.rowHeader,width:o},calendar:{...this.option.calendar,pxPerDay:this.effectivePxPerDay,pxPerMonth:this.effectivePxPerMonth}},this._lastOptionRef=this.option,this._lastLabelWidth=o,this._lastZoomPxPerDay=this.zoomPxPerDay,this._lastZoomPxPerMonth=this.zoomPxPerMonth);let s=this._cachedCurrentOption,c=0,l=this.displayRows.length-1;if(!this.isExporting){for(let e=0;e<n.length;e++)if(n[e].top+n[e].height>this.virtualScrollTop){c=Math.max(0,e-5);break}for(let e=c;e<n.length;e++)if(n[e].top>this.virtualScrollTop+this.viewportHeight){l=Math.min(this.displayRows.length-1,e+5);break}}let u=this.displayRows.slice(c,l+1),d=this.isExporting?0:n[c]?n[c].top:0,f=n[l],p=f?f.top+f.height:0,m=Math.max(0,a-p),h=a>this.viewportHeight,g=[],_=this.option.readOnly===!0,v=this.option.dependency?.showArrows!==!1,y=this.option.dependency?.arrowSize??8,b=this.option.dependency?.lineStyle??`orthogonal`,x=this.option.dependency?.cornerRadius??8,S=this.option.dependency?.showCriticalPath===!0,C=S?Q(this.displayRows):new Set;for(let[e,n]of r)if(n.dependencies)for(let i of n.dependencies){let a=r.get(i);if(a){let r=a.x+a.width,o=a.y+a.height/2,s=n.x,c=n.y+n.height/2,l=r<s,u=v?s-y:s,d=l?Math.max(r,u):u,f,p,m,h=this.option.bar?.height??28,w=this.option.bar?.margin??4;if(Math.abs(o-c)<1&&l)f=d>r?`M ${r} ${o} L ${d} ${c}`:``,p=s>r?`M ${r} ${o} L ${s} ${c}`:``;else if(b===`orthogonal`){let e=J(r,o,s,c,d,h,w,x);f=e.pathD,p=e.hitPathD}else if(l){let e=(r+d)/2;f=`M ${r} ${o} C ${e} ${o} ${e} ${c} ${d} ${c}`,p=`M ${r} ${o} C ${(r+s)/2} ${o} ${(r+s)/2} ${c} ${s} ${c}`}else{let e=Math.max(12,(r-s)*.15),t=(o+c)/2,n=Math.abs(o-c)<h?t+h+w:t;f=`M ${r} ${o} C ${r+e} ${o}, ${r+e} ${n}, ${(r+d)/2} ${n} S ${d-e} ${c}, ${d} ${c}`,p=`M ${r} ${o} C ${r+e} ${o}, ${r+e} ${n}, ${(r+s)/2} ${n} S ${s-e} ${c}, ${s} ${c}`}m=v?`M ${d} ${c} L ${s} ${c}`:``,g.push(t.svg`<g class="dependency-group">
|
|
1019
|
+
`,n)}if(this.dragOverlayInfo.clientY!==void 0){let e=this.dragOverlayInfo.clientX??0,t=this.dragOverlayInfo.clientY,r=this.getBoundingClientRect();if(e<r.left||e>r.right||t<r.top||t>r.bottom){n.classList.remove(`visible`);return}let i=n.offsetWidth||200,a=n.offsetHeight||60,o=window.innerWidth,s=window.innerHeight,c=e-i/2;c=Math.max(8,Math.min(c,o-i-8));let l=t-a-40;l<8&&(l=t+40),l+a>s-8&&(l=s-a-8),n.style.left=`${c}px`,n.style.transform=`none`,n.style.top=`${l}px`,n.style.bottom=`auto`}}hideDragOverlay(){let e=this.shadowRoot?.querySelector(`.drag-info-overlay`);e&&e.classList.remove(`visible`)}setupCurrentTimeTimer(){this.stopCurrentTimeTimer();let e=this.option.calendar.currentTimeUpdateInterval;e&&e>0&&(this.currentTimeTimer=window.setInterval(()=>{this.currentTime=new Date},e))}stopCurrentTimeTimer(){this.currentTimeTimer!==void 0&&(window.clearInterval(this.currentTimeTimer),this.currentTimeTimer=void 0)}handleHeaderResizeStart(e){e.preventDefault(),e.stopPropagation(),this.isResizingHeader=!0;let t=e.clientX,n=this.currentRowHeaderWidth,r=e.target;r.setPointerCapture(e.pointerId);let i=this.option.rowHeader?.minWidth??50,a=this.option.rowHeader?.maxWidth??2**53-1,o=e=>{let r=e.clientX-t,o=n+r;this.currentRowHeaderWidth=Math.max(i,Math.min(a,o))},s=()=>{this.isResizingHeader=!1,r.releasePointerCapture(e.pointerId),r.removeEventListener(`pointermove`,o),r.removeEventListener(`pointerup`,s);let t=Math.round(this.currentRowHeaderWidth);this.currentRowHeaderWidth=t,this.dispatchEvent(new CustomEvent(`row-header-resize`,{detail:{width:t},bubbles:!0,composed:!0}))};r.addEventListener(`pointermove`,o),r.addEventListener(`pointerup`,s)}getDateX(e){return P(e,this.option.calendar.start,this.effectivePxPerDay,this.effectivePxPerMonth)}calculateLayout(){if(this._layoutCache)return this._layoutCache;let e=0,t=this.currentRowHeaderWidth,n=new Map,r={layouts:this.displayRows.map(r=>{let{tasksWithLanes:i,laneCount:a}=I(r.tasks),o=this.option.bar?.height??28,s=this.option.bar?.margin??4;i.forEach(r=>{let i=this.getDateX(r.start)+t,a=this.getDateX(r.end)+t-i,c=e+r.lane*(o+s)+s;n.set(r.id,{x:i,y:c,width:a,height:o,dependencies:r.dependencies})});let c=a*(o+s)+s,l={top:e,height:c};return e+=c,l}),taskCoords:n,totalHeight:e};return this._layoutCache=r,r}isMultiDrag(e){return this.selectedTasks.size>=2&&this.selectedTasks.has(e)}isMultiDragSameRow(){if(this.selectedTasks.size<2)return!1;let e=null;for(let t of this.rows)for(let n of t.tasks)if(this.selectedTasks.has(n.id)){if(e===null)e=t.id;else if(e!==t.id)return!1}return e!==null}handleTaskUpdate(e){e.stopPropagation();let{id:t,start:n,end:r,dx:i,isDragging:a,mode:o}=e.detail,{dy:s}=e.detail,c=this.isMultiDrag(t),l=c&&this.isMultiDragSameRow();c&&!l&&(s=0);let u=n,d=r;if(i!==void 0){let e=this.effectivePxPerDay,t=this.effectivePxPerMonth,a=this.getDateX(n),o=this.getDateX(r);u=F(a+i,this.option.calendar.start,e,t),d=F(o+i,this.option.calendar.start,e,t)}(this.option.calendar.pxPerMonth||this.option.snapDuration&&this.option.snapDuration>=43200)&&(u.getDate()>15&&u.setMonth(u.getMonth()+1),u.setDate(1),u.setHours(0,0,0,0),d.getDate()>15&&d.setMonth(d.getMonth()+1),d.setDate(1),d.setHours(0,0,0,0));let f=-1,p,m=-1;if(this.rows.find((e,n)=>{let r=e.tasks.findIndex(e=>e.id===t);return r!==-1&&(f=n,p=e.tasks[r],m=r,!0)}),f===-1||!p)return;let{layouts:h}=this.calculateLayout(),g=this.displayRows.findIndex(e=>e.id===this.rows[f].id);if(g===-1)return;let _=h[g].top,{tasksWithLanes:v}=I(this.rows[f].tasks),y=v.find(e=>e.id===t),b=y?y.lane:0,x=this.option.bar?.height??28,S=this.option.bar?.margin??4,C=_+(b*(x+S)+S)+s+x/2,w=-1;for(let e=0;e<h.length;e++){let t=h[e];if(C>=t.top&&C<t.top+t.height){w=e;break}}let T=w===-1?void 0:this.displayRows[w].id,E=c?[...this.selectedTasks]:void 0;if(this.dispatchEvent(new CustomEvent(`task-update`,{detail:{...e.detail,dy:s,start:u,end:d,targetRowId:T,selectedTaskIds:E},bubbles:!0,composed:!0})),a){if(this.hoverTimer!==void 0&&window.clearTimeout(this.hoverTimer),this.tooltip&&=null,(!this.draggingTask||this.draggingTask.id!==t)&&(this.draggingTask={id:t,name:e.detail.name,start:n,end:r,currentStart:u,currentEnd:d,mode:o},this.draggingTaskIds=c?[...this.selectedTasks]:[]),c?(this.multiDragDx=i??0,this.multiDragSameRow=l,this.multiDragDy=l?s:0):(this.multiDragDx!==0||this.multiDragDy!==0)&&(this.multiDragDx=0,this.multiDragDy=0),!c||l){let e=w>=0?w:null;this.dragTargetRowIndex!==e&&(this.dragTargetRowIndex=e)}this.dragOverlayInfo=c?{id:t,name:(this.option.locale??j).dragOverlay.movingTasks(this.selectedTasks.size),start:n,end:r,currentStart:u,currentEnd:d,visible:!0,clientX:e.detail.x,clientY:e.detail.y}:{id:t,name:e.detail.name,start:n,end:r,currentStart:u,currentEnd:d,targetRow:w>=0?this.displayRows[w]:void 0,visible:!0,clientX:e.detail.x,clientY:e.detail.y},this.updateDragOverlay();return}let D=this.draggingTaskIds.length>=2,O=this.multiDragSameRow;this.draggingTask=null,this.draggingTaskIds=[],this.multiDragDx=0,this.multiDragDy=0,this.multiDragSameRow=!1,this.dragTargetRowIndex=null,this.dragOverlayInfo&&(this.dragOverlayInfo={...this.dragOverlayInfo,visible:!1},this.hideDragOverlay()),this.tooltip&&={...this.tooltip,visible:!1};let k=-1;if(w!==-1){let e=this.displayRows[w];k=this.rows.findIndex(t=>t.id===e.id)}if(D&&i!==void 0){let e=this.effectivePxPerDay,t=this.effectivePxPerMonth;if(O&&k!==-1&&f!==k){let n=[...this.rows],r={...n[f]},a={...n[k]};r.tasks=[...r.tasks],a.tasks=[...a.tasks];let o=[];r.tasks=r.tasks.filter(n=>{if(this.selectedTasks.has(n.id)){let r=this.getDateX(n.start),a=this.getDateX(n.end),s=F(r+i,this.option.calendar.start,e,t),c=F(a+i,this.option.calendar.start,e,t);return(this.option.calendar.pxPerMonth||this.option.snapDuration&&this.option.snapDuration>=43200)&&(s.getDate()>15&&s.setMonth(s.getMonth()+1),s.setDate(1),s.setHours(0,0,0,0),c.getDate()>15&&c.setMonth(c.getMonth()+1),c.setDate(1),c.setHours(0,0,0,0)),o.push({...n,start:s,end:c}),!1}return!0}),a.tasks.push(...o),n[f]=r,n[k]=a,requestAnimationFrame(()=>{this.rows=n,this.dispatchEvent(new CustomEvent(`rows-change`,{detail:this.rows,bubbles:!0,composed:!0}))})}else{let n=this.rows.map(n=>n.tasks.some(e=>this.selectedTasks.has(e.id))?{...n,tasks:n.tasks.map(n=>{if(!this.selectedTasks.has(n.id))return n;let r=this.getDateX(n.start),a=this.getDateX(n.end),o=F(r+i,this.option.calendar.start,e,t),s=F(a+i,this.option.calendar.start,e,t);return(this.option.calendar.pxPerMonth||this.option.snapDuration&&this.option.snapDuration>=43200)&&(o.getDate()>15&&o.setMonth(o.getMonth()+1),o.setDate(1),o.setHours(0,0,0,0),s.getDate()>15&&s.setMonth(s.getMonth()+1),s.setDate(1),s.setHours(0,0,0,0)),{...n,start:o,end:s}})}:n);requestAnimationFrame(()=>{this.rows=n,this.dispatchEvent(new CustomEvent(`rows-change`,{detail:this.rows,bubbles:!0,composed:!0}))})}return}if(o===`copy`){if(k!==-1){let e=[...this.rows],t={...e[k]};t.tasks=[...t.tasks];let n=`task-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,r={...p,id:n,start:u,end:d,dependencies:[]};t.tasks.push(r),e[k]=t,requestAnimationFrame(()=>{this.rows=e,this.dispatchEvent(new CustomEvent(`rows-change`,{detail:this.rows,bubbles:!0,composed:!0}))})}}else{let e=[...this.rows],t={...e[f]};if(t.tasks=[...t.tasks],e[f]=t,k!==-1&&f!==k){let n={...e[k]};n.tasks=[...n.tasks],e[k]=n;let[r]=t.tasks.splice(m,1);n.tasks.push({...r,start:u,end:d})}else t.tasks[m]={...p,start:u,end:d};requestAnimationFrame(()=>{this.rows=e,this.dispatchEvent(new CustomEvent(`rows-change`,{detail:this.rows,bubbles:!0,composed:!0}))})}}handleBarMouseEnter(e){if(this.draggingTask||this.option.showTooltip===!1)return;this.hoverTimer!==void 0&&window.clearTimeout(this.hoverTimer);let t=this.option.tooltipDelay??500;t>0?this.hoverTimer=window.setTimeout(()=>{this.tooltip={...e.detail,visible:!0,below:!1}},t):this.tooltip={...e.detail,visible:!0,below:!1}}handleBarMouseLeave(){this.hoverTimer!==void 0&&window.clearTimeout(this.hoverTimer),this.tooltip&&={...this.tooltip,visible:!1}}async reorderRows(e,t,n){let r=Array.isArray(e)?e:[e],i=Array.from(this.shadowRoot?.querySelectorAll(`gantt-row`)??[]),a=new Map;i.forEach(e=>{e.row&&a.set(e.row.id,e.getBoundingClientRect().top)});let o=[...this.rows],s=[];if(o.findIndex(e=>e.id===t)===-1)return;r.forEach(e=>{let t=o.findIndex(t=>t.id===e);t!==-1&&s.push(o[t])});let c=o.filter(e=>!r.includes(e.id));if(r.includes(t))return;let l=c.findIndex(e=>e.id===t);n===`bottom`&&l++,c.splice(l,0,...s),this.rows=c,await this.updateComplete,Array.from(this.shadowRoot?.querySelectorAll(`gantt-row`)??[]).forEach(e=>{if(e.row){let t=a.get(e.row.id);if(t!==void 0){let n=t-e.getBoundingClientRect().top;n!==0&&e.animate([{transform:`translateY(${n}px)`,zIndex:`1`},{transform:`translateY(0)`,zIndex:`1`}],{duration:300,easing:`ease-out`})}}}),this.dispatchEvent(new CustomEvent(`row-reordered`,{detail:{sourceId:r[0],sourceIds:r,targetId:t,position:n,rows:this.rows},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`rows-change`,{detail:this.rows,bubbles:!0,composed:!0}))}handleContainerDragOver(e){e.preventDefault();let t=e.dataTransfer&&e.dataTransfer.types.includes(`application/json`);if(t&&(e.dataTransfer.dropEffect=`copy`),!this.option.enableRowReordering&&!t)return;let n=this.shadowRoot?.querySelector(`.scroll-container`);if(!n)return;let r=n.getBoundingClientRect(),i=e.clientY-r.top+n.scrollTop-this.calendarHeight,{layouts:a}=this.calculateLayout(),o=-1;for(let e=0;e<a.length;e++){let t=a[e];if(i>=t.top&&i<t.top+t.height){o=e;break}}if(o!==-1){let s=this.displayRows[o];if(t){if((this.dragOverRowId!==s.id||this.dragOverPosition!==null)&&(this.dragOverRowId=s.id,this.dragOverPosition=null),this.externalDraggingTask){let t=this.currentRowHeaderWidth,i=n.scrollLeft,a=e.clientX-r.left+i-t,o=this.effectivePxPerDay,c=this.effectivePxPerMonth,l=this.option.snapDuration??1440,u=o/1440*l,d=F(Math.round(a/u)*u,this.option.calendar.start,o,c),f=this.externalDraggingTask.end.getTime()-this.externalDraggingTask.start.getTime(),p=new Date(d.getTime()+f);(!this.dragPreview||this.dragPreview.rowId!==s.id||this.dragPreview.currentStart.getTime()!==d.getTime())&&(this.dragPreview={task:this.externalDraggingTask,currentStart:d,currentEnd:p,rowId:s.id})}}else{let e=a[o],t=i-e.top<e.height/2?`top`:`bottom`;(this.dragOverRowId!==s.id||this.dragOverPosition!==t)&&(this.dragOverRowId=s.id,this.dragOverPosition=t)}}else this.dragOverRowId=null,this.dragOverPosition=null,this.dragPreview=null}handleContainerDragLeave(e){let t=this.shadowRoot?.querySelector(`.scroll-container`),n=e.relatedTarget;t&&t.contains(n)||(this.dragOverRowId=null,this.dragOverPosition=null,this.dragPreview=null)}handleContainerDrop(e){e.preventDefault();let t=e.dataTransfer?.getData(`application/json`);if(t){this.handleExternalTaskDrop(e,t),this.dragOverRowId=null,this.dragOverPosition=null,this.dragPreview=null;return}if(!this.option.enableRowReordering)return;let n=e.dataTransfer?.getData(`text/plain`),r=this.dragOverRowId,i=this.dragOverPosition;if(this.dragOverRowId=null,this.dragOverPosition=null,this.dragPreview=null,n&&r&&n!==r&&i){if(this.selectedRows.has(n)&&this.selectedRows.size>1){let e=Array.from(this.selectedRows);this.reorderRows(e,r,i)}else this.reorderRows(n,r,i)}}handleExternalTaskDrop(e,t){try{let n=JSON.parse(t);if(!n||typeof n!=`object`||typeof n.id!=`string`||typeof n.name!=`string`||!n.start||!n.end){console.warn(`Invalid dropped task data: missing required fields (id, name, start, end)`);return}let r=new Date(n.start),i=new Date(n.end);if(isNaN(r.getTime())||isNaN(i.getTime())){console.warn(`Invalid dropped task data: start or end is not a valid date`);return}let a={...n,start:r,end:i},o=this.shadowRoot?.querySelector(`.scroll-container`);if(!o)return;let s=o.getBoundingClientRect(),c=o.scrollLeft,l=o.scrollTop,u=this.currentRowHeaderWidth,d=e.clientX-s.left+c-u,f=this.effectivePxPerDay,p=this.effectivePxPerMonth,m=F(d,this.option.calendar.start,f,p),h=e.clientY-s.top+l-this.calendarHeight,{layouts:g}=this.calculateLayout(),_;for(let e=0;e<g.length;e++){let t=g[e];if(h>=t.top&&h<t.top+t.height){_=this.displayRows[e].id;break}}_&&this.dispatchEvent(new CustomEvent(`task-drop`,{detail:{task:a,dropDate:m,targetRowId:_},bubbles:!0,composed:!0}))}catch(e){console.warn(`Failed to parse dropped task data`,e)}}handleRowClicked(e){let{rowId:t,event:n}=e.detail,{shiftKey:r,ctrlKey:i,metaKey:a}=n,o=new Set(this.selectedRows);if(r&&this.lastClickedRowId){let e=this.rows.findIndex(e=>e.id===this.lastClickedRowId),n=this.rows.findIndex(e=>e.id===t);if(e!==-1&&n!==-1){let t=Math.min(e,n),r=Math.max(e,n);for(let e=t;e<=r;e++)o.add(this.rows[e].id)}}else if(i||a)o.has(t)?o.delete(t):o.add(t),this.lastClickedRowId=t;else{if(o.has(t)){this.lastClickedRowId=t;return}o.clear(),o.add(t),this.lastClickedRowId=t}this.selectedRows=o,this.dispatchEvent(new CustomEvent(`row-selection-change`,{detail:{selectedIds:Array.from(this.selectedRows)},bubbles:!0,composed:!0}))}handleRowContextMenu(e){this.selectedRows.has(e.detail.rowId)||this.handleRowClicked(e)}handleContainerClick(e){e.defaultPrevented||this.clearSelection()}handleContainerContextMenu(e){if(e.defaultPrevented)return;e.preventDefault();let t=this.shadowRoot?.querySelector(`.scroll-container`);if(!t)return;let n=t.getBoundingClientRect(),r=t.scrollLeft,i=t.scrollTop,a=this.currentRowHeaderWidth,o=e.clientY-n.top+i-this.calendarHeight,{layouts:s}=this.calculateLayout(),c;for(let e=0;e<s.length;e++){let t=s[e];if(o>=t.top&&o<t.top+t.height){c=this.displayRows[e].id;break}}if(c){let t=e.clientX-n.left+r-a,i=this.effectivePxPerDay,o=this.effectivePxPerMonth,s=F(t,this.option.calendar.start,i,o);this.dispatchEvent(new CustomEvent(`chart-contextmenu`,{detail:{event:e,date:s,rowId:c},bubbles:!0,composed:!0}))}this.clearSelection()}hitTest(e,t){let n=this.shadowRoot?.querySelector(`.scroll-container`);if(!n)return null;let r=n.getBoundingClientRect(),i=n.scrollLeft,a=n.scrollTop,o=this.currentRowHeaderWidth,s=t-r.top+a-this.calendarHeight,{layouts:c}=this.calculateLayout(),l;for(let e=0;e<c.length;e++){let t=c[e];if(s>=t.top&&s<t.top+t.height){l=this.displayRows[e].id;break}}if(!l)return null;let u=e-r.left+i-o,d=this.effectivePxPerDay,f=this.effectivePxPerMonth,p=F(u,this.option.calendar.start,d,f);return{rowId:l,date:p}}getRowPositions(){let{layouts:e}=this.calculateLayout();return e.map(e=>({top:e.top,height:e.height,bottom:e.top+e.height}))}async exportImage(e=`png`,t={}){this.isExporting=!0,await this.updateComplete,await new Promise(e=>requestAnimationFrame(e));try{return await ee(this,e,t)}finally{this.isExporting=!1,await this.updateComplete}}zoomTo(e){let t=this.effectivePxPerMonth!==void 0,n=t?20:2,r=t?600:200,i=this.option.zoom?.min??n,a=this.option.zoom?.max??r,o=Math.max(i,Math.min(a,e));t?this.zoomPxPerMonth=o:this.zoomPxPerDay=o,this.dispatchEvent(new CustomEvent(`zoom-change`,{detail:{pxPerDay:t?this.effectivePxPerDay:o,pxPerMonth:t?o:void 0},bubbles:!0,composed:!0}))}zoomToFit(){let e=this.shadowRoot?.querySelector(`.scroll-container`);if(!e)return;let t=null,n=null;for(let e of this.displayRows)for(let r of e.tasks)(!t||r.start<t)&&(t=r.start),(!n||r.end>n)&&(n=r.end);if(!t||!n)return;let r=this.currentRowHeaderWidth,i=e.clientWidth-r;if(!(i<=0)){if(this.effectivePxPerMonth!==void 0){let e=(n.getFullYear()-t.getFullYear())*12+(n.getMonth()-t.getMonth()),r=i/Math.max(1,e);this.zoomTo(r)}else{let e=n.getTime()-t.getTime(),r=i/Math.max(1,e/864e5);this.zoomTo(r)}requestAnimationFrame(()=>{let n=this.getDateX(t)+r;e.scrollLeft=Math.max(0,n-10)})}}resetZoom(){let e=this.zoomPxPerDay!==null||this.zoomPxPerMonth!==null;if(this.zoomPxPerDay=null,this.zoomPxPerMonth=null,e){let e=this.option.calendar.pxPerMonth!==void 0;this.dispatchEvent(new CustomEvent(`zoom-change`,{detail:{pxPerDay:this.option.calendar.pxPerDay??50,pxPerMonth:e?this.option.calendar.pxPerMonth:void 0},bubbles:!0,composed:!0}))}}clearSelection(){(this.selectedRows.size!==0||this.selectedTasks.size!==0)&&(this.selectedRows.size>0&&(this.selectedRows=new Set,this.dispatchEvent(new CustomEvent(`row-selection-change`,{detail:{selectedIds:[]},bubbles:!0,composed:!0}))),this.selectedTasks.size>0&&(this.selectedTasks=new Set,this.dispatchEvent(new CustomEvent(`bar-selection-change`,{detail:{selectedIds:[]},bubbles:!0,composed:!0}))))}moveFocusHorizontal(e){let t=this.displayRows;if(t.length===0)return;if(!this.focusedTaskId||!this.focusedRowId){this.focusFirstAvailableTask();return}let n=t.findIndex(e=>e.id===this.focusedRowId);if(n===-1){this.focusFirstAvailableTask();return}let r=t[n],i=[...r.tasks].sort((e,t)=>e.start.getTime()-t.start.getTime()),a=i.findIndex(e=>e.id===this.focusedTaskId);if(a===-1){i.length>0&&this.setFocus(i[0].id,r.id);return}let o=a+e;o>=0&&o<i.length?this.setFocus(i[o].id,r.id):this.moveFocusVertical(e)}moveFocusVertical(e){let t=this.displayRows;if(t.length===0)return;if(!this.focusedTaskId||!this.focusedRowId){this.focusFirstAvailableTask();return}let n=t.findIndex(e=>e.id===this.focusedRowId);if(n===-1){this.focusFirstAvailableTask();return}for(let r=n+e;r>=0&&r<t.length;r+=e){let n=t[r];if(n.tasks.length>0){let t=[...n.tasks].sort((e,t)=>e.start.getTime()-t.start.getTime()),r=e>0?t[0]:t[t.length-1];this.setFocus(r.id,n.id);return}}}focusFirstAvailableTask(){for(let e of this.displayRows)if(e.tasks.length>0){let t=[...e.tasks].sort((e,t)=>e.start.getTime()-t.start.getTime());this.setFocus(t[0].id,e.id);return}}focusFirstOrLastTaskInRow(e){if(!this.focusedRowId){this.focusFirstAvailableTask();return}let t=this.displayRows.find(e=>e.id===this.focusedRowId);if(!t||t.tasks.length===0)return;let n=[...t.tasks].sort((e,t)=>e.start.getTime()-t.start.getTime()),r=e===`first`?n[0]:n[n.length-1];this.setFocus(r.id,t.id)}setFocus(e,t){this.focusedTaskId=e,this.focusedRowId=t,this.scrollToTask(e)}toggleTaskSelection(e){let t=new Set(this.selectedTasks);t.has(e)?t.delete(e):t.add(e),this.selectedTasks=t,this.dispatchEvent(new CustomEvent(`bar-selection-change`,{detail:{selectedIds:[...t]},bubbles:!0,composed:!0}))}selectSingleTask(e){this.selectedTasks=new Set([e]),this.dispatchEvent(new CustomEvent(`bar-selection-change`,{detail:{selectedIds:[e]},bubbles:!0,composed:!0}))}moveSelectedTasksByKeyboard(e){if(this.selectedTasks.size===0)return;let t=(this.option.keyboard?.moveStep??this.option.snapDuration??1440)*60*1e3*e,n=this.rows.map(e=>e.tasks.some(e=>this.selectedTasks.has(e.id))?{...e,tasks:e.tasks.map(e=>this.selectedTasks.has(e.id)?{...e,start:new Date(e.start.getTime()+t),end:new Date(e.end.getTime()+t)}:e)}:e);for(let e of this.rows)for(let n of e.tasks){if(!this.selectedTasks.has(n.id))continue;let r=new Date(n.start.getTime()+t),i=new Date(n.end.getTime()+t);this.dispatchEvent(new CustomEvent(`task-update`,{detail:{id:n.id,name:n.name,start:r,end:i,dx:0,dy:0,isDragging:!1,mode:`move`,targetRowId:e.id},bubbles:!0,composed:!0}))}this.rows=n,this.dispatchEvent(new CustomEvent(`rows-change`,{detail:this.rows,bubbles:!0,composed:!0}))}handleBarClick(e){e.stopPropagation();let{task:t,isMultiSelect:n}=e.detail;this.draggingTask=null,this.dragTargetRowIndex=null,this.dragOverlayInfo&&(this.dragOverlayInfo={...this.dragOverlayInfo,visible:!1},this.hideDragOverlay());let r;n?(r=new Set(this.selectedTasks),r.has(t.id)?r.delete(t.id):r.add(t.id)):r=new Set([t.id]),this.selectedTasks=r,this.dispatchEvent(new CustomEvent(`bar-selection-change`,{detail:{selectedIds:[...r]},bubbles:!0,composed:!0}))}handleBarContextMenu(e){let{task:t}=e.detail;this.selectedTasks.has(t.id)||(this.selectedTasks=new Set([t.id]),this.dispatchEvent(new CustomEvent(`bar-selection-change`,{detail:{selectedIds:[t.id]},bubbles:!0,composed:!0})))}handleConnectorDragStart(e){let{taskId:t,endpoint:n,clientX:r,clientY:i}=e.detail;e.stopPropagation();let{taskCoords:a}=this.calculateLayout(),o=a.get(t),s=this.currentRowHeaderWidth,c=e.detail.startX+s,l=e.detail.startY;o&&(c=n===`start`?o.x:o.x+o.width,l=o.y+o.height/2),this.connectorDrag={sourceTaskId:t,sourceEndpoint:n,startX:c,startY:l,currentClientX:r,currentClientY:i,targetTaskId:null,targetEndpoint:null},this.tooltip&&=null}handleConnectorDragMove(e){if(!this.connectorDrag)return;e.stopPropagation();let{clientX:t,clientY:n}=e.detail,r=this.shadowRoot?.querySelector(`.scroll-container`);if(!r)return;let i=r.getBoundingClientRect(),a=t-i.left+r.scrollLeft,o=n-i.top+r.scrollTop-this.calendarHeight,{taskCoords:s}=this.calculateLayout(),c=null,l=null,u=30;for(let[e,t]of s){if(e===this.connectorDrag.sourceTaskId)continue;let n=t.y+t.height/2,r=t.x,i=t.x+t.width,s=Math.sqrt((a-r)**2+(o-n)**2),d=Math.sqrt((a-i)**2+(o-n)**2);s<u&&(u=s,c=e,l=`start`),d<u&&(u=d,c=e,l=`end`)}let d=this.connectorDrag.targetTaskId;d!==c&&(d&&this._setConnectorDropTarget(d,!1),c&&this._setConnectorDropTarget(c,!0)),this.connectorDrag={...this.connectorDrag,currentClientX:t,currentClientY:n,targetTaskId:c,targetEndpoint:l}}handleConnectorDragEnd(e){if(!this.connectorDrag)return;e.stopPropagation();let{cancelled:t}=e.detail,{sourceTaskId:n,sourceEndpoint:r,targetTaskId:i,targetEndpoint:a}=this.connectorDrag;i&&this._setConnectorDropTarget(i,!1),!t&&i&&a&&this.dispatchEvent(new CustomEvent(`dependency-create`,{detail:{sourceTaskId:n,sourceEndpoint:r,targetTaskId:i,targetEndpoint:a},bubbles:!0,composed:!0})),this.connectorDrag=null}_setConnectorDropTarget(e,t){let n=this.shadowRoot?.querySelectorAll(`gantt-row`);if(n)for(let r of n){let n=r.shadowRoot?.querySelectorAll(`gantt-bar`);if(n){for(let r of n)if(r.task?.id===e){r.connectorDropTarget=t;return}}}}handleDependencyLineClick(e,t,n){this.dispatchEvent(new CustomEvent(`dependency-click`,{detail:{event:e,sourceTaskId:n,targetTaskId:t},bubbles:!0,composed:!0}))}selectTask(e){let t=!1;for(let n of this.displayRows)if(n.tasks.some(t=>t.id===e)){t=!0;break}return t?(this.selectedTasks=new Set([e]),this.dispatchEvent(new CustomEvent(`bar-selection-change`,{detail:{selectedIds:[e]},bubbles:!0,composed:!0})),this.scrollToTask(e),!0):!1}scrollToTask(e){let{taskCoords:t}=this.calculateLayout(),n=t.get(e);if(!n)return;let r=this.shadowRoot?.querySelector(`.scroll-container`);if(!r)return;let i=this.currentRowHeaderWidth,a=n.y+this.calendarHeight,o=a+n.height,s=r.scrollTop,c=r.scrollTop+r.clientHeight;if(a<s||o>c){let e=a-r.clientHeight/2+n.height/2;r.scrollTo({top:Math.max(0,e),behavior:`smooth`})}let l=n.x,u=n.x+n.width,d=r.scrollLeft+i,f=r.scrollLeft+r.clientWidth;if(l<d||u>f){let e=l-i-20;r.scrollTo({left:Math.max(0,e),behavior:`smooth`})}}render(){let e=L(this.theme,this.option.customTheme),{layouts:n,taskCoords:r,totalHeight:a}=this.calculateLayout(),o=this.currentRowHeaderWidth;(this._lastOptionRef!==this.option||this._lastLabelWidth!==o||this._lastZoomPxPerDay!==this.zoomPxPerDay||this._lastZoomPxPerMonth!==this.zoomPxPerMonth)&&(this._cachedCurrentOption={...this.option,rowHeader:{...this.option.rowHeader,width:o},calendar:{...this.option.calendar,pxPerDay:this.effectivePxPerDay,pxPerMonth:this.effectivePxPerMonth}},this._lastOptionRef=this.option,this._lastLabelWidth=o,this._lastZoomPxPerDay=this.zoomPxPerDay,this._lastZoomPxPerMonth=this.zoomPxPerMonth);let s=this._cachedCurrentOption,c=0,l=this.displayRows.length-1;if(!this.isExporting){for(let e=0;e<n.length;e++)if(n[e].top+n[e].height>this.virtualScrollTop){c=Math.max(0,e-5);break}for(let e=c;e<n.length;e++)if(n[e].top>this.virtualScrollTop+this.viewportHeight){l=Math.min(this.displayRows.length-1,e+5);break}}let u=this.displayRows.slice(c,l+1),d=this.isExporting?0:n[c]?n[c].top:0,f=n[l],p=f?f.top+f.height:0,m=Math.max(0,a-p),h=a>this.viewportHeight,g=[],_=this.option.readOnly===!0,v=this.option.dependency?.showArrows!==!1,y=this.option.dependency?.arrowSize??8,b=this.option.dependency?.lineStyle??`orthogonal`,x=this.option.dependency?.cornerRadius??8,S=this.option.dependency?.showCriticalPath===!0,C=S?Q(this.displayRows):new Set;for(let[e,n]of r)if(n.dependencies)for(let i of n.dependencies){let a=r.get(i);if(a){let r=a.x+a.width,o=a.y+a.height/2,s=n.x,c=n.y+n.height/2,l=r<s,u=v?s-y:s,d=l?Math.max(r,u):u,f,p,m,h=this.option.bar?.height??28,w=this.option.bar?.margin??4;if(Math.abs(o-c)<1&&l)f=d>r?`M ${r} ${o} L ${d} ${c}`:``,p=s>r?`M ${r} ${o} L ${s} ${c}`:``;else if(b===`orthogonal`){let e=J(r,o,s,c,d,h,w,x);f=e.pathD,p=e.hitPathD}else if(l){let e=(r+d)/2;f=`M ${r} ${o} C ${e} ${o} ${e} ${c} ${d} ${c}`,p=`M ${r} ${o} C ${(r+s)/2} ${o} ${(r+s)/2} ${c} ${s} ${c}`}else{let e=Math.max(12,(r-s)*.15),t=(o+c)/2,n=Math.abs(o-c)<h?t+h+w:t;f=`M ${r} ${o} C ${r+e} ${o}, ${r+e} ${n}, ${(r+d)/2} ${n} S ${d-e} ${c}, ${d} ${c}`,p=`M ${r} ${o} C ${r+e} ${o}, ${r+e} ${n}, ${(r+s)/2} ${n} S ${s-e} ${c}, ${s} ${c}`}m=v?`M ${d} ${c} L ${s} ${c}`:``,g.push(t.svg`<g class="dependency-group">
|
|
1019
1020
|
${_?``:t.svg`<path class="dependency-hit-area" d="${p}" @click="${t=>{t.stopPropagation(),this.handleDependencyLineClick(t,e,i)}}" />`}
|
|
1020
1021
|
<path class="dependency-line ${S&&C.has(e)&&C.has(i)?`critical-path`:``}" d="${f}" />
|
|
1021
1022
|
${v?t.svg`<path class="dependency-line dependency-arrow-line ${S&&C.has(e)&&C.has(i)?`critical-path`:``}" d="${m}" marker-end="url(#dependency-arrowhead)" />`:``}
|
|
@@ -1190,4 +1191,4 @@
|
|
|
1190
1191
|
style="top: ${this.tooltip.below?this.tooltip.barBottom:this.tooltip.y}px; left: ${this.tooltip.x}px;"
|
|
1191
1192
|
/>
|
|
1192
1193
|
`:``}
|
|
1193
|
-
`}};H([(0,n.property)({type:Array})],$.prototype,`rows`,void 0),H([(0,n.property)({type:Object})],$.prototype,`option`,void 0),H([(0,n.property)({type:String,reflect:!0})],$.prototype,`theme`,void 0),H([(0,n.property)({type:Array})],$.prototype,`selectedRowIds`,void 0),H([(0,n.property)({type:Array})],$.prototype,`selectedTaskIds`,void 0),H([(0,n.property)({attribute:!1})],$.prototype,`externalDraggingTask`,void 0),H([(0,n.state)()],$.prototype,`selectedRows`,void 0),H([(0,n.state)()],$.prototype,`selectedTasks`,void 0),H([(0,n.state)()],$.prototype,`lastClickedRowId`,void 0),H([(0,n.state)()],$.prototype,`virtualScrollTop`,void 0),H([(0,n.state)()],$.prototype,`dragTargetRowIndex`,void 0),H([(0,n.state)()],$.prototype,`draggingTask`,void 0),H([(0,n.state)()],$.prototype,`draggingTaskIds`,void 0),H([(0,n.state)()],$.prototype,`multiDragDx`,void 0),H([(0,n.state)()],$.prototype,`multiDragDy`,void 0),H([(0,n.state)()],$.prototype,`multiDragSameRow`,void 0),H([(0,n.state)()],$.prototype,`viewportHeight`,void 0),H([(0,n.state)()],$.prototype,`calendarHeight`,void 0),H([(0,n.state)()],$.prototype,`tooltip`,void 0),H([(0,n.state)()],$.prototype,`dragOverRowId`,void 0),H([(0,n.state)()],$.prototype,`dragOverPosition`,void 0),H([(0,n.state)()],$.prototype,`currentTime`,void 0),H([(0,n.state)()],$.prototype,`dragPreview`,void 0),H([(0,n.state)()],$.prototype,`currentRowHeaderWidth`,void 0),H([(0,n.state)()],$.prototype,`isResizingHeader`,void 0),H([(0,n.state)()],$.prototype,`hoveredMilestoneId`,void 0),H([(0,n.state)()],$.prototype,`cursorLineX`,void 0),H([(0,n.state)()],$.prototype,`connectorDrag`,void 0),H([(0,n.state)()],$.prototype,`isExporting`,void 0),H([(0,n.state)()],$.prototype,`focusedTaskId`,void 0),H([(0,n.state)()],$.prototype,`focusedRowId`,void 0),H([(0,n.state)()],$.prototype,`zoomPxPerDay`,void 0),H([(0,n.state)()],$.prototype,`zoomPxPerMonth`,void 0),$=H([(0,n.customElement)(`gantt-chart`)],$),e.ALL_BAR_PATTERNS=g,Object.defineProperty(e
|
|
1194
|
+
`}};H([(0,n.property)({type:Array})],$.prototype,`rows`,void 0),H([(0,n.property)({type:Object})],$.prototype,`option`,void 0),H([(0,n.property)({type:String,reflect:!0})],$.prototype,`theme`,void 0),H([(0,n.property)({type:Array})],$.prototype,`selectedRowIds`,void 0),H([(0,n.property)({type:Array})],$.prototype,`selectedTaskIds`,void 0),H([(0,n.property)({attribute:!1})],$.prototype,`externalDraggingTask`,void 0),H([(0,n.state)()],$.prototype,`selectedRows`,void 0),H([(0,n.state)()],$.prototype,`selectedTasks`,void 0),H([(0,n.state)()],$.prototype,`lastClickedRowId`,void 0),H([(0,n.state)()],$.prototype,`virtualScrollTop`,void 0),H([(0,n.state)()],$.prototype,`dragTargetRowIndex`,void 0),H([(0,n.state)()],$.prototype,`draggingTask`,void 0),H([(0,n.state)()],$.prototype,`draggingTaskIds`,void 0),H([(0,n.state)()],$.prototype,`multiDragDx`,void 0),H([(0,n.state)()],$.prototype,`multiDragDy`,void 0),H([(0,n.state)()],$.prototype,`multiDragSameRow`,void 0),H([(0,n.state)()],$.prototype,`viewportHeight`,void 0),H([(0,n.state)()],$.prototype,`calendarHeight`,void 0),H([(0,n.state)()],$.prototype,`tooltip`,void 0),H([(0,n.state)()],$.prototype,`dragOverRowId`,void 0),H([(0,n.state)()],$.prototype,`dragOverPosition`,void 0),H([(0,n.state)()],$.prototype,`currentTime`,void 0),H([(0,n.state)()],$.prototype,`dragPreview`,void 0),H([(0,n.state)()],$.prototype,`currentRowHeaderWidth`,void 0),H([(0,n.state)()],$.prototype,`isResizingHeader`,void 0),H([(0,n.state)()],$.prototype,`hoveredMilestoneId`,void 0),H([(0,n.state)()],$.prototype,`cursorLineX`,void 0),H([(0,n.state)()],$.prototype,`connectorDrag`,void 0),H([(0,n.state)()],$.prototype,`isExporting`,void 0),H([(0,n.state)()],$.prototype,`focusedTaskId`,void 0),H([(0,n.state)()],$.prototype,`focusedRowId`,void 0),H([(0,n.state)()],$.prototype,`zoomPxPerDay`,void 0),H([(0,n.state)()],$.prototype,`zoomPxPerMonth`,void 0),$=H([(0,n.customElement)(`gantt-chart`)],$),e.ALL_BAR_PATTERNS=g,Object.defineProperty(e,"GanttBarElement",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"GanttCalendarElement",{enumerable:!0,get:function(){return G}}),Object.defineProperty(e,"GanttChartElement",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"GanttRowElement",{enumerable:!0,get:function(){return q}}),e.PATTERN_CHECKERBOARD=x,e.PATTERN_CIRCLE=w,e.PATTERN_DIAGONAL_GRID=E,e.PATTERN_DIAGONAL_STRIPE=_,e.PATTERN_DIAGONAL_STRIPE_REVERSE=v,e.PATTERN_DOTS=S,e.PATTERN_DOTS_DENSE=k,e.PATTERN_GRID=T,e.PATTERN_HORIZONTAL_STRIPE=b,e.PATTERN_STRIPE_THICK=O,e.PATTERN_STRIPE_THIN=D,e.PATTERN_TRIANGLE=C,e.PATTERN_VERTICAL_STRIPE=y,e.computeCriticalPath=Q,e.enLocale=M,e.getPatternStyle=A,e.jaLocale=j});
|
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mogura/moguchart-core",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "0.9.0",
|
|
5
|
+
"packageManager": "pnpm@11.21.0",
|
|
6
|
+
"description": "軽量でフレームワーク非依存のWeb Components製ガントチャートコンポーネント (Lit)。A lightweight, framework-agnostic Gantt chart Web Component for Vue, React, Angular, and Svelte.",
|
|
5
7
|
"license": "MIT",
|
|
6
8
|
"author": "Murakami Hiroyuki",
|
|
7
9
|
"repository": {
|
|
@@ -18,9 +20,14 @@
|
|
|
18
20
|
"keywords": [
|
|
19
21
|
"gantt",
|
|
20
22
|
"gantt-chart",
|
|
21
|
-
"
|
|
23
|
+
"ガントチャート",
|
|
24
|
+
"ガント",
|
|
25
|
+
"工程表",
|
|
26
|
+
"スケジュール",
|
|
22
27
|
"web-components",
|
|
23
28
|
"lit",
|
|
29
|
+
"vue-gantt",
|
|
30
|
+
"react-gantt",
|
|
24
31
|
"project-management",
|
|
25
32
|
"timeline",
|
|
26
33
|
"scheduler"
|
|
@@ -29,6 +36,7 @@
|
|
|
29
36
|
"files": [
|
|
30
37
|
"dist",
|
|
31
38
|
"LICENSE",
|
|
39
|
+
"README.md",
|
|
32
40
|
"README.en.md"
|
|
33
41
|
],
|
|
34
42
|
"main": "./dist/moguchart-core.umd.js",
|