@mogura/moguchart-core 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/moguchart-core.mjs +133 -120
- package/dist/moguchart-core.umd.js +27 -26
- package/package.json +12 -13
package/dist/moguchart-core.mjs
CHANGED
|
@@ -2,12 +2,11 @@ import { LitElement as e, css as t, html as n, render as r, svg as i, unsafeCSS
|
|
|
2
2
|
import { customElement as o, property as s, state as c } from "lit/decorators.js";
|
|
3
3
|
import l from "dayjs";
|
|
4
4
|
import { repeat as u } from "lit/directives/repeat.js";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import p from "
|
|
8
|
-
import { jsPDF as m } from "jspdf";
|
|
5
|
+
import { throttle as d } from "lodash-es";
|
|
6
|
+
import f from "html2canvas-pro";
|
|
7
|
+
import { jsPDF as p } from "jspdf";
|
|
9
8
|
//#region src/core/patterns.ts
|
|
10
|
-
var
|
|
9
|
+
var m = [
|
|
11
10
|
"diagonal-stripe",
|
|
12
11
|
"diagonal-stripe-thin",
|
|
13
12
|
"diagonal-stripe-thick",
|
|
@@ -20,8 +19,8 @@ var h = [
|
|
|
20
19
|
"circle",
|
|
21
20
|
"grid",
|
|
22
21
|
"diagonal-grid"
|
|
23
|
-
],
|
|
24
|
-
function
|
|
22
|
+
], h = { type: "diagonal-stripe" }, g = { type: "diagonal-stripe-reverse" }, _ = { type: "vertical-stripe" }, v = { type: "horizontal-stripe" }, y = { type: "checkerboard" }, b = { type: "dots" }, x = { type: "triangle" }, S = { type: "circle" }, C = { type: "grid" }, w = { type: "diagonal-grid" }, T = { type: "diagonal-stripe-thin" }, E = { type: "diagonal-stripe-thick" }, D = { type: "dots-dense" };
|
|
23
|
+
function O(e) {
|
|
25
24
|
if (!e?.type) return "";
|
|
26
25
|
let t = e.color || "rgba(255, 255, 255, 0.3)", n = e.type === "dots" ? "6px" : "8px";
|
|
27
26
|
switch (e.type) {
|
|
@@ -96,7 +95,7 @@ function k(e) {
|
|
|
96
95
|
}
|
|
97
96
|
//#endregion
|
|
98
97
|
//#region src/core/i18n.ts
|
|
99
|
-
var
|
|
98
|
+
var k = {
|
|
100
99
|
monthFormat: "YYYY年M月",
|
|
101
100
|
monthRowFormat: "M月",
|
|
102
101
|
dateFormat: (e) => `${e.getFullYear()}/${e.getMonth() + 1}/${e.getDate()}`,
|
|
@@ -118,7 +117,7 @@ var A = {
|
|
|
118
117
|
moveTo: (e) => `移動先: ${e}`,
|
|
119
118
|
movingTasks: (e) => `${e}件のタスクを移動中`
|
|
120
119
|
}
|
|
121
|
-
},
|
|
120
|
+
}, A = {
|
|
122
121
|
monthFormat: "MMM YYYY",
|
|
123
122
|
monthRowFormat: "MMM",
|
|
124
123
|
dateFormat: (e) => `${e.getMonth() + 1}/${e.getDate()}/${e.getFullYear()}`,
|
|
@@ -153,7 +152,7 @@ var A = {
|
|
|
153
152
|
moveTo: (e) => `Move to: ${e}`,
|
|
154
153
|
movingTasks: (e) => `Moving ${e} task${e === 1 ? "" : "s"}`
|
|
155
154
|
}
|
|
156
|
-
},
|
|
155
|
+
}, j = {
|
|
157
156
|
light: {
|
|
158
157
|
bg: "#f1f5f9",
|
|
159
158
|
text: "#0f172a",
|
|
@@ -208,13 +207,13 @@ var A = {
|
|
|
208
207
|
currentTimeLine: "rgba(239, 68, 68, 0.5)",
|
|
209
208
|
currentTimeLineText: "#ffffff"
|
|
210
209
|
}
|
|
211
|
-
},
|
|
210
|
+
}, M = (e, t, n, r) => {
|
|
212
211
|
if (r !== void 0) {
|
|
213
212
|
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();
|
|
214
213
|
return (s + (e.getDate() - 1 + e.getHours() / 24 + e.getMinutes() / 1440) / u - l) * r;
|
|
215
214
|
}
|
|
216
215
|
return (e.getTime() - t.getTime()) / (1e3 * 60 * 60 * 24) * n;
|
|
217
|
-
},
|
|
216
|
+
}, N = (e, t, n, r) => {
|
|
218
217
|
if (r !== void 0) {
|
|
219
218
|
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);
|
|
220
219
|
c %= 12, c < 0 && (c += 12, --l);
|
|
@@ -224,7 +223,7 @@ var A = {
|
|
|
224
223
|
let i = e / n;
|
|
225
224
|
return new Date(t.getTime() + i * 24 * 60 * 60 * 1e3);
|
|
226
225
|
};
|
|
227
|
-
function
|
|
226
|
+
function P(e) {
|
|
228
227
|
if (!e.length) return {
|
|
229
228
|
tasksWithLanes: [],
|
|
230
229
|
laneCount: 1
|
|
@@ -246,10 +245,10 @@ function F(e) {
|
|
|
246
245
|
laneCount: n.length || 1
|
|
247
246
|
};
|
|
248
247
|
}
|
|
249
|
-
var
|
|
250
|
-
...
|
|
248
|
+
var F = (e, t) => ({
|
|
249
|
+
...j[e] || j.light,
|
|
251
250
|
...t
|
|
252
|
-
}),
|
|
251
|
+
}), I = (e, t, n) => {
|
|
253
252
|
let r = e.getDay();
|
|
254
253
|
return n && n(e) ? t.holiday : [
|
|
255
254
|
t.sunday,
|
|
@@ -261,13 +260,13 @@ var I = (e, t) => ({
|
|
|
261
260
|
t.saturday
|
|
262
261
|
][r];
|
|
263
262
|
};
|
|
264
|
-
function
|
|
263
|
+
function L(e, t) {
|
|
265
264
|
return (t.getTime() - e.getTime()) / (1e3 * 60 * 60 * 24);
|
|
266
265
|
}
|
|
267
|
-
var
|
|
268
|
-
let r = n ??
|
|
266
|
+
var R = (e, t, n) => {
|
|
267
|
+
let r = n ?? k, i = t.getTime() - e.getTime(), a = Math.floor(i / (1e3 * 60 * 60 * 24)), o = i % (1e3 * 60 * 60 * 24), s = Math.floor(o / (1e3 * 60 * 60)), c = o % (1e3 * 60 * 60), l = Math.floor(c / (1e3 * 60)), u = "";
|
|
269
268
|
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;
|
|
270
|
-
},
|
|
269
|
+
}, z = {
|
|
271
270
|
BAR: "#3b82f6",
|
|
272
271
|
LABEL_BACKGROUND: "#fafafa",
|
|
273
272
|
SATURDAY: "#dbeafe",
|
|
@@ -277,7 +276,7 @@ var z = (e, t, n) => {
|
|
|
277
276
|
}.BAR;
|
|
278
277
|
//#endregion
|
|
279
278
|
//#region \0@oxc-project+runtime@0.120.0/helpers/decorate.js
|
|
280
|
-
function
|
|
279
|
+
function B(e, t, n, r) {
|
|
281
280
|
var i = arguments.length, a = i < 3 ? t : r === null ? r = Object.getOwnPropertyDescriptor(t, n) : r, o;
|
|
282
281
|
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") a = Reflect.decorate(e, t, n, r);
|
|
283
282
|
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);
|
|
@@ -285,7 +284,7 @@ function V(e, t, n, r) {
|
|
|
285
284
|
}
|
|
286
285
|
//#endregion
|
|
287
286
|
//#region src/components/gantt-bar.ts
|
|
288
|
-
var
|
|
287
|
+
var V = class extends e {
|
|
289
288
|
constructor(...e) {
|
|
290
289
|
super(...e), this.lane = 0, this.selected = !1, this.focused = !1, this.multiDragDx = 0, this.multiDragActive = !1, this.connectorDropTarget = !1, this.isExporting = !1, this._currentDragCursor = null, this._dragAnimationFrame = null, this._wasDragging = !1, this.handleKeyDown = (e) => {
|
|
291
290
|
(e.key === "Control" || e.key === "Alt") && this.updateCursor(!0);
|
|
@@ -324,7 +323,7 @@ var H = class extends e {
|
|
|
324
323
|
position: absolute;
|
|
325
324
|
top: 0;
|
|
326
325
|
left: 0;
|
|
327
|
-
background-color: ${a(
|
|
326
|
+
background-color: ${a(z)};
|
|
328
327
|
}
|
|
329
328
|
:host([selected]) .bar {
|
|
330
329
|
outline: 2px solid #3b82f6;
|
|
@@ -452,7 +451,7 @@ var H = class extends e {
|
|
|
452
451
|
`;
|
|
453
452
|
}
|
|
454
453
|
getX(e) {
|
|
455
|
-
return
|
|
454
|
+
return M(e, this.option.calendar.start, this.option.calendar.pxPerDay ?? 50, this.option.calendar.pxPerMonth);
|
|
456
455
|
}
|
|
457
456
|
setupDragEvents(e, t, n, r) {
|
|
458
457
|
let i = () => {
|
|
@@ -481,10 +480,10 @@ var H = class extends e {
|
|
|
481
480
|
if (o) {
|
|
482
481
|
let e = this.getX(l), s = this.getX(u);
|
|
483
482
|
if (t === "left") {
|
|
484
|
-
let t =
|
|
483
|
+
let t = N(e + n, this.option.calendar.start, a, o);
|
|
485
484
|
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));
|
|
486
485
|
} else {
|
|
487
|
-
let e =
|
|
486
|
+
let e = N(s + n, this.option.calendar.start, a, o);
|
|
488
487
|
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));
|
|
489
488
|
}
|
|
490
489
|
} else {
|
|
@@ -559,7 +558,7 @@ var H = class extends e {
|
|
|
559
558
|
r === "y" && (u = 0), (r === "x" || this.multiDragActive) && (d = 0);
|
|
560
559
|
let f = u;
|
|
561
560
|
if (this.option.calendar.pxPerMonth) {
|
|
562
|
-
let e =
|
|
561
|
+
let e = N(this.getX(s) + u, this.option.calendar.start, 50, this.option.calendar.pxPerMonth), t = (e.getFullYear() - s.getFullYear()) * 12 + (e.getMonth() - s.getMonth()) + (e.getDate() > 15 ? 1 : 0), n = new Date(s);
|
|
563
562
|
n.setMonth(n.getMonth() + t), f = this.getX(n) - this.getX(s);
|
|
564
563
|
} else {
|
|
565
564
|
let e = this.option.calendar.pxPerDay / 1440 * l;
|
|
@@ -599,7 +598,7 @@ var H = class extends e {
|
|
|
599
598
|
else if (i) {
|
|
600
599
|
let e = i.clientX - a, t = e;
|
|
601
600
|
if (this.option.calendar.pxPerMonth) {
|
|
602
|
-
let n =
|
|
601
|
+
let n = N(this.getX(s) + e, this.option.calendar.start, 50, this.option.calendar.pxPerMonth), r = (n.getFullYear() - s.getFullYear()) * 12 + (n.getMonth() - s.getMonth()) + (n.getDate() > 15 ? 1 : 0), i = new Date(s);
|
|
603
602
|
i.setMonth(i.getMonth() + r), t = this.getX(i) - this.getX(s);
|
|
604
603
|
} else {
|
|
605
604
|
let n = this.option.calendar.pxPerDay / 1440 * l;
|
|
@@ -786,7 +785,7 @@ var H = class extends e {
|
|
|
786
785
|
>
|
|
787
786
|
<div
|
|
788
787
|
class="bar"
|
|
789
|
-
style="border-radius: ${a}px; ${this.task.style || ""}; ${
|
|
788
|
+
style="border-radius: ${a}px; ${this.task.style || ""}; ${O(this.task.pattern)}; ${u ? "" : "cursor: pointer;"}"
|
|
790
789
|
@pointerdown="${u ? this.onMoveStart : void 0}"
|
|
791
790
|
>
|
|
792
791
|
${this.option.customRendering?.barContent ? this.option.customRendering.barContent(this.task) : ""}
|
|
@@ -810,23 +809,23 @@ var H = class extends e {
|
|
|
810
809
|
`;
|
|
811
810
|
}
|
|
812
811
|
};
|
|
813
|
-
|
|
812
|
+
B([s({ type: Object })], V.prototype, "task", void 0), B([s({ type: Object })], V.prototype, "option", void 0), B([s({ type: Number })], V.prototype, "lane", void 0), B([s({
|
|
814
813
|
type: Boolean,
|
|
815
814
|
reflect: !0
|
|
816
|
-
})],
|
|
815
|
+
})], V.prototype, "selected", void 0), B([s({
|
|
817
816
|
type: Boolean,
|
|
818
817
|
reflect: !0
|
|
819
|
-
})],
|
|
818
|
+
})], V.prototype, "focused", void 0), B([s({ type: Number })], V.prototype, "multiDragDx", void 0), B([s({ type: Boolean })], V.prototype, "multiDragActive", void 0), B([s({
|
|
820
819
|
type: Boolean,
|
|
821
820
|
reflect: !0,
|
|
822
821
|
attribute: "connector-drop-target"
|
|
823
|
-
})],
|
|
822
|
+
})], V.prototype, "connectorDropTarget", void 0), B([s({
|
|
824
823
|
type: Boolean,
|
|
825
824
|
reflect: !0
|
|
826
|
-
})],
|
|
825
|
+
})], V.prototype, "isExporting", void 0), V = B([o("gantt-bar")], V);
|
|
827
826
|
//#endregion
|
|
828
827
|
//#region src/components/gantt-calendar.ts
|
|
829
|
-
var
|
|
828
|
+
var H = class extends e {
|
|
830
829
|
constructor(...e) {
|
|
831
830
|
super(...e), this.theme = "light", this.currentTime = /* @__PURE__ */ new Date(), this.hoveredMilestoneId = null, this._cachedDays = null, this._cachedMonths = null, this._cachedYears = null, this._cachedWeeks = null, this._cachedStartTime = 0, this._cachedEndTime = 0, this._cachedPxPerDay = 0, this._cachedPxPerMonth = void 0, this._cachedWeekStartDay = -1;
|
|
832
831
|
}
|
|
@@ -835,7 +834,7 @@ var U = class extends e {
|
|
|
835
834
|
if (r && r.remove(), t instanceof HTMLElement) t.classList.add(n), e.appendChild(t);
|
|
836
835
|
else if (typeof t == "string") {
|
|
837
836
|
let r = document.createElement("span");
|
|
838
|
-
r.classList.add(n), r.
|
|
837
|
+
r.classList.add(n), r.textContent = t, e.appendChild(r);
|
|
839
838
|
}
|
|
840
839
|
}
|
|
841
840
|
updated() {
|
|
@@ -885,7 +884,7 @@ var U = class extends e {
|
|
|
885
884
|
});
|
|
886
885
|
}
|
|
887
886
|
get totalDays() {
|
|
888
|
-
return
|
|
887
|
+
return L(this.option.calendar.start, this.option.calendar.end);
|
|
889
888
|
}
|
|
890
889
|
static {
|
|
891
890
|
this.styles = t`
|
|
@@ -1007,7 +1006,7 @@ var U = class extends e {
|
|
|
1007
1006
|
`;
|
|
1008
1007
|
}
|
|
1009
1008
|
getDateX(e) {
|
|
1010
|
-
return
|
|
1009
|
+
return M(e, this.option.calendar.start, this.option.calendar.pxPerDay, this.option.calendar.pxPerMonth);
|
|
1011
1010
|
}
|
|
1012
1011
|
formatTime(e) {
|
|
1013
1012
|
return `${e.getHours().toString().padStart(2, "0")}:${e.getMinutes().toString().padStart(2, "0")}`;
|
|
@@ -1031,7 +1030,7 @@ var U = class extends e {
|
|
|
1031
1030
|
}), r;
|
|
1032
1031
|
}
|
|
1033
1032
|
render() {
|
|
1034
|
-
let e =
|
|
1033
|
+
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, a = this.option.calendar.pxPerMonth, o = this.option.calendar.weekStartDay ?? 1, s = !this._cachedDays || t !== this._cachedStartTime || r !== this._cachedEndTime, c = i !== this._cachedPxPerDay || a !== this._cachedPxPerMonth;
|
|
1035
1034
|
if (s) {
|
|
1036
1035
|
this._cachedStartTime = t, this._cachedEndTime = r, this._cachedPxPerDay = i, this._cachedPxPerMonth = a;
|
|
1037
1036
|
let e = Array.from({ length: Math.ceil(this.totalDays) }, (e, t) => {
|
|
@@ -1142,7 +1141,7 @@ var U = class extends e {
|
|
|
1142
1141
|
style="background: ${e.bg}; border-bottom: 1px solid ${e.border}; position: relative;"
|
|
1143
1142
|
>
|
|
1144
1143
|
${d.map((e) => {
|
|
1145
|
-
let r = (this.option.locale ??
|
|
1144
|
+
let r = (this.option.locale ?? k).monthRowFormat, i = l(new Date(e.year, e.month)).format(r), a = e.width ?? e.count * this.option.calendar.pxPerDay;
|
|
1146
1145
|
return n`<div
|
|
1147
1146
|
class="week-cell"
|
|
1148
1147
|
style="width: ${a}px; text-align: ${t}; padding: 0 2px;"
|
|
@@ -1158,7 +1157,7 @@ var U = class extends e {
|
|
|
1158
1157
|
})() : ""}
|
|
1159
1158
|
${this.option.calendar.showMonths !== !1 && !this.option.calendar.showMonthsRow ? n`<div class="months-container" style="position: relative;">
|
|
1160
1159
|
${d.map((e) => {
|
|
1161
|
-
let t = this.option.calendar.monthFormat || (this.option.locale ??
|
|
1160
|
+
let t = this.option.calendar.monthFormat || (this.option.locale ?? k).monthFormat, r = l(new Date(e.year, e.month)).format(t), i = e.width ?? e.count * this.option.calendar.pxPerDay;
|
|
1162
1161
|
return n`<div
|
|
1163
1162
|
class="month-cell"
|
|
1164
1163
|
style="width: ${i}px;"
|
|
@@ -1194,7 +1193,7 @@ var U = class extends e {
|
|
|
1194
1193
|
})() : ""}
|
|
1195
1194
|
${this.option.calendar.showDays === !1 ? "" : n`<div class="days-container" style="${this.option.calendar.showTime ? "" : p}">
|
|
1196
1195
|
${this.option.calendar.showTime ? C.map((t, r) => {
|
|
1197
|
-
let i =
|
|
1196
|
+
let i = I(t.date, e, this.option.calendar.isHoliday), a = r === C.length - 1, o = e.showTimeDateLine ?? e.monthGridLine ?? e.border, s = (this.option.locale ?? k).timeUnitDateFormat(t.date), c = this.option.calendar.isHoliday ? this.option.calendar.isHoliday(t.date) : !1;
|
|
1198
1197
|
return n`
|
|
1199
1198
|
<div
|
|
1200
1199
|
class="day-cell"
|
|
@@ -1212,7 +1211,7 @@ var U = class extends e {
|
|
|
1212
1211
|
}) : u.map((t, r) => {
|
|
1213
1212
|
let i = this.option.calendar.pxPerDay;
|
|
1214
1213
|
r + 1 > this.totalDays && (i = (this.totalDays - r) * this.option.calendar.pxPerDay);
|
|
1215
|
-
let a =
|
|
1214
|
+
let a = I(t, e, this.option.calendar.isHoliday), o = String(t.getDate()), s = this.option.calendar.isHoliday ? this.option.calendar.isHoliday(t) : !1;
|
|
1216
1215
|
return n`
|
|
1217
1216
|
<div
|
|
1218
1217
|
class="day-cell"
|
|
@@ -1323,15 +1322,15 @@ var U = class extends e {
|
|
|
1323
1322
|
`;
|
|
1324
1323
|
}
|
|
1325
1324
|
};
|
|
1326
|
-
|
|
1325
|
+
B([s({ type: Object })], H.prototype, "option", void 0), B([s({ type: String })], H.prototype, "theme", void 0), B([s({ type: Object })], H.prototype, "currentTime", void 0), B([s({ type: String })], H.prototype, "hoveredMilestoneId", void 0), B([s({ attribute: !1 })], H.prototype, "cornerContent", void 0), B([s({ attribute: !1 })], H.prototype, "calendarMonthContent", void 0), B([s({ attribute: !1 })], H.prototype, "calendarDayContent", void 0), B([s({ attribute: !1 })], H.prototype, "calendarWeekContent", void 0), B([s({ attribute: !1 })], H.prototype, "calendarHourContent", void 0), H = B([o("gantt-calendar")], H);
|
|
1327
1326
|
//#endregion
|
|
1328
1327
|
//#region src/components/gantt-row-background.ts
|
|
1329
|
-
var
|
|
1328
|
+
var U = class extends e {
|
|
1330
1329
|
constructor(...e) {
|
|
1331
1330
|
super(...e), this.theme = "light", this.rowId = "", this._cachedCells = null, this._cachedCellsStartTime = 0, this._cachedCellsEndTime = 0, this._cachedCellsPxPerDay = 0, this._cachedCellsPxPerMonth = void 0, this._cachedCellsTheme = "";
|
|
1332
1331
|
}
|
|
1333
1332
|
get totalDays() {
|
|
1334
|
-
return
|
|
1333
|
+
return L(this.option.calendar.start, this.option.calendar.end);
|
|
1335
1334
|
}
|
|
1336
1335
|
static {
|
|
1337
1336
|
this.styles = t`
|
|
@@ -1354,16 +1353,16 @@ var W = class extends e {
|
|
|
1354
1353
|
`;
|
|
1355
1354
|
}
|
|
1356
1355
|
render() {
|
|
1357
|
-
let e =
|
|
1356
|
+
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;
|
|
1358
1357
|
(!this._cachedCells || t !== this._cachedCellsStartTime || r !== this._cachedCellsEndTime || i !== this._cachedCellsPxPerDay || a !== this._cachedCellsPxPerMonth || this.theme !== this._cachedCellsTheme) && (this._cachedCellsStartTime = t, this._cachedCellsEndTime = r, this._cachedCellsPxPerDay = i, this._cachedCellsPxPerMonth = a, this._cachedCellsTheme = this.theme, this._cachedCells = Array.from({ length: Math.ceil(this.totalDays) }, (e, t) => {
|
|
1359
1358
|
let n = new Date(this.option.calendar.start);
|
|
1360
1359
|
return n.setDate(n.getDate() + t), n;
|
|
1361
1360
|
}).map((t) => {
|
|
1362
|
-
let n =
|
|
1361
|
+
let n = I(t, e, this.option.calendar.isHoliday), r = new Date(t);
|
|
1363
1362
|
r.setDate(t.getDate() + 1);
|
|
1364
|
-
let o =
|
|
1363
|
+
let o = M(t, this.option.calendar.start, i, a);
|
|
1365
1364
|
return {
|
|
1366
|
-
width:
|
|
1365
|
+
width: M(r, this.option.calendar.start, i, a) - o,
|
|
1367
1366
|
color: n,
|
|
1368
1367
|
date: t
|
|
1369
1368
|
};
|
|
@@ -1397,15 +1396,15 @@ var W = class extends e {
|
|
|
1397
1396
|
`;
|
|
1398
1397
|
}
|
|
1399
1398
|
};
|
|
1400
|
-
|
|
1399
|
+
B([s({ type: Object })], U.prototype, "option", void 0), B([s({ type: String })], U.prototype, "theme", void 0), B([s({ type: String })], U.prototype, "rowId", void 0), U = B([o("gantt-row-background")], U);
|
|
1401
1400
|
//#endregion
|
|
1402
1401
|
//#region src/components/gantt-row.ts
|
|
1403
|
-
var
|
|
1402
|
+
var W = class extends e {
|
|
1404
1403
|
constructor(...e) {
|
|
1405
1404
|
super(...e), this.isDragTarget = !1, this.draggingTask = null, this.draggingTaskIds = [], this.multiDragDx = 0, this.externalDragTask = null, this.theme = "light", this.isSelected = !1, this.dropPosition = null, this.selectedTaskIds = [], this.focusedTaskId = null, this.isExporting = !1, this._cachedMonthGridLines = null, this._cachedMonthGridStartTime = 0, this._cachedMonthGridEndTime = 0, this._cachedMonthGridPxPerDay = 0, this._cachedMonthGridPxPerMonth = 0;
|
|
1406
1405
|
}
|
|
1407
1406
|
getDateX(e) {
|
|
1408
|
-
return
|
|
1407
|
+
return M(e, this.option.calendar.start, this.option.calendar.pxPerDay, this.option.calendar.pxPerMonth);
|
|
1409
1408
|
}
|
|
1410
1409
|
getMarkerPath(e, t) {
|
|
1411
1410
|
let n = t / 2;
|
|
@@ -1503,7 +1502,7 @@ var G = class extends e {
|
|
|
1503
1502
|
composed: !0
|
|
1504
1503
|
})), e.dataTransfer) {
|
|
1505
1504
|
e.dataTransfer.setData("text/plain", this.row.id), e.dataTransfer.effectAllowed = "move";
|
|
1506
|
-
let t =
|
|
1505
|
+
let t = F(this.theme, this.option.customTheme), n = document.createElement("div");
|
|
1507
1506
|
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";
|
|
1508
1507
|
let r = [];
|
|
1509
1508
|
if (this.isSelected) {
|
|
@@ -1566,7 +1565,7 @@ var G = class extends e {
|
|
|
1566
1565
|
t && r(this.option.customRendering?.rowHeaderContent ? this.option.customRendering.rowHeaderContent(this.row) : this.row.name, t);
|
|
1567
1566
|
}
|
|
1568
1567
|
render() {
|
|
1569
|
-
let e =
|
|
1568
|
+
let e = F(this.theme, this.option.customTheme), t = [...this.row.tasks];
|
|
1570
1569
|
if (this.externalDragTask) {
|
|
1571
1570
|
let e = {
|
|
1572
1571
|
...this.externalDragTask.task,
|
|
@@ -1586,7 +1585,7 @@ var G = class extends e {
|
|
|
1586
1585
|
resizable: !1,
|
|
1587
1586
|
style: `${a.style || ""}; opacity: 0.5;`
|
|
1588
1587
|
});
|
|
1589
|
-
let n =
|
|
1588
|
+
let n = P(e);
|
|
1590
1589
|
r = n.tasksWithLanes, i = n.laneCount;
|
|
1591
1590
|
let o = r.find((e) => e.id === `${a.id}-static`);
|
|
1592
1591
|
o && r.push({
|
|
@@ -1594,7 +1593,7 @@ var G = class extends e {
|
|
|
1594
1593
|
lane: o.lane
|
|
1595
1594
|
});
|
|
1596
1595
|
} else {
|
|
1597
|
-
let e =
|
|
1596
|
+
let e = P(t);
|
|
1598
1597
|
r = e.tasksWithLanes, i = e.laneCount;
|
|
1599
1598
|
}
|
|
1600
1599
|
let o = this.option.bar?.height ?? 28, s = this.option.bar?.margin ?? 4, c = i * (o + s) + s;
|
|
@@ -1781,16 +1780,16 @@ var G = class extends e {
|
|
|
1781
1780
|
`;
|
|
1782
1781
|
}
|
|
1783
1782
|
};
|
|
1784
|
-
|
|
1783
|
+
B([s({ type: Object })], W.prototype, "row", void 0), B([s({ type: Object })], W.prototype, "option", void 0), B([s({ type: Boolean })], W.prototype, "isDragTarget", void 0), B([s({ type: Object })], W.prototype, "draggingTask", void 0), B([s({ type: Array })], W.prototype, "draggingTaskIds", void 0), B([s({ type: Number })], W.prototype, "multiDragDx", void 0), B([s({ type: Object })], W.prototype, "externalDragTask", void 0), B([s({ type: String })], W.prototype, "theme", void 0), B([s({
|
|
1785
1784
|
type: Boolean,
|
|
1786
1785
|
reflect: !0
|
|
1787
|
-
})],
|
|
1786
|
+
})], W.prototype, "isSelected", void 0), B([s({ type: String })], W.prototype, "dropPosition", void 0), B([s({ type: Array })], W.prototype, "selectedTaskIds", void 0), B([s({ type: String })], W.prototype, "focusedTaskId", void 0), B([s({
|
|
1788
1787
|
type: Boolean,
|
|
1789
1788
|
reflect: !0
|
|
1790
|
-
})],
|
|
1789
|
+
})], W.prototype, "isExporting", void 0), W = B([o("gantt-row")], W);
|
|
1791
1790
|
//#endregion
|
|
1792
1791
|
//#region src/components/gantt-chart-dependency-path.ts
|
|
1793
|
-
function
|
|
1792
|
+
function G(e, t, n, r, i, a, o, s) {
|
|
1794
1793
|
let c = (n) => {
|
|
1795
1794
|
if (Math.abs(t - r) < 1) return `M ${e} ${t} L ${n} ${r}`;
|
|
1796
1795
|
if (e < n) {
|
|
@@ -1826,7 +1825,7 @@ function K(e, t, n, r, i, a, o, s) {
|
|
|
1826
1825
|
}
|
|
1827
1826
|
//#endregion
|
|
1828
1827
|
//#region src/components/gantt-chart-styles.ts
|
|
1829
|
-
var
|
|
1828
|
+
var K = t`
|
|
1830
1829
|
:host {
|
|
1831
1830
|
display: block;
|
|
1832
1831
|
width: 100%;
|
|
@@ -1963,8 +1962,8 @@ var q = t`
|
|
|
1963
1962
|
z-index: 58;
|
|
1964
1963
|
}
|
|
1965
1964
|
`;
|
|
1966
|
-
function
|
|
1967
|
-
let n =
|
|
1965
|
+
function q(e, t) {
|
|
1966
|
+
let n = F(e, t);
|
|
1968
1967
|
return `
|
|
1969
1968
|
:host {
|
|
1970
1969
|
background: ${n.bg};
|
|
@@ -2012,14 +2011,12 @@ function J(e, t) {
|
|
|
2012
2011
|
}
|
|
2013
2012
|
//#endregion
|
|
2014
2013
|
//#region src/components/gantt-chart-export.ts
|
|
2015
|
-
function
|
|
2014
|
+
function J(e, t) {
|
|
2016
2015
|
let n = document.createElement("a");
|
|
2017
2016
|
n.href = e, n.download = t, n.click();
|
|
2018
2017
|
}
|
|
2019
|
-
async function
|
|
2020
|
-
let { filename: r = "gantt-chart", download: i = !1, scale: a = 2, splitHeight: o } = n, s = e.shadowRoot?.querySelector(".scroll-container"), c = s ? s.scrollWidth : e.scrollWidth, l = s ? s.scrollHeight : e.scrollHeight
|
|
2021
|
-
console.log("[export] splitHeight:", o, "scrollHeight:", l);
|
|
2022
|
-
let u = await p(e, {
|
|
2018
|
+
async function Y(e, t = "png", n = {}) {
|
|
2019
|
+
let { filename: r = "gantt-chart", download: i = !1, scale: a = 2, splitHeight: o } = n, s = e.shadowRoot?.querySelector(".scroll-container"), c = s ? s.scrollWidth : e.scrollWidth, l = s ? s.scrollHeight : e.scrollHeight, u = await f(e, {
|
|
2023
2020
|
backgroundColor: "#ffffff",
|
|
2024
2021
|
scale: a,
|
|
2025
2022
|
width: c,
|
|
@@ -2029,7 +2026,7 @@ async function X(e, t = "png", n = {}) {
|
|
|
2029
2026
|
});
|
|
2030
2027
|
if (o && l > o) {
|
|
2031
2028
|
let t = 50, n = e.shadowRoot?.querySelector("gantt-calendar");
|
|
2032
|
-
n && n.offsetHeight > 0 ? t = n.offsetHeight : e.calendarHeight && (t = e.calendarHeight)
|
|
2029
|
+
n && n.offsetHeight > 0 ? t = n.offsetHeight : e.calendarHeight && (t = e.calendarHeight);
|
|
2033
2030
|
let r = u.height / l, i = Math.floor(o * r), a = Math.floor(t * r), s = u.height, c = u.width, d = s - a, f = i - a;
|
|
2034
2031
|
if (f > 0) {
|
|
2035
2032
|
let e = Math.ceil(d / f), t = s + (e - 1) * a, n = document.createElement("canvas");
|
|
@@ -2043,12 +2040,12 @@ async function X(e, t = "png", n = {}) {
|
|
|
2043
2040
|
let e = s - d, t = Math.min(f, e);
|
|
2044
2041
|
o.drawImage(u, 0, d, c, t, 0, p, c, t), d += t, p += t;
|
|
2045
2042
|
}
|
|
2046
|
-
u = n, l = t / r
|
|
2043
|
+
u = n, l = t / r;
|
|
2047
2044
|
} else console.warn("[export] Failed to get 2D context for new canvas. It might be too large.");
|
|
2048
2045
|
}
|
|
2049
2046
|
}
|
|
2050
2047
|
if (t === "pdf") {
|
|
2051
|
-
let e = u.toDataURL("image/jpeg", .9), t = new
|
|
2048
|
+
let e = u.toDataURL("image/jpeg", .9), t = new p({
|
|
2052
2049
|
orientation: c > l ? "l" : "p",
|
|
2053
2050
|
unit: "px",
|
|
2054
2051
|
format: [c, l],
|
|
@@ -2057,12 +2054,12 @@ async function X(e, t = "png", n = {}) {
|
|
|
2057
2054
|
return t.addImage(e, "JPEG", 0, 0, c, l, void 0, "FAST"), i && t.save(`${r}.pdf`), t.output("blob");
|
|
2058
2055
|
} else {
|
|
2059
2056
|
let e = u.toDataURL("image/png");
|
|
2060
|
-
return i &&
|
|
2057
|
+
return i && J(e, `${r}.png`), e;
|
|
2061
2058
|
}
|
|
2062
2059
|
}
|
|
2063
2060
|
//#endregion
|
|
2064
2061
|
//#region src/components/gantt-chart.ts
|
|
2065
|
-
var
|
|
2062
|
+
var X = class extends e {
|
|
2066
2063
|
constructor(...e) {
|
|
2067
2064
|
super(...e), this.rows = [], this.theme = "light", this.selectedRowIds = [], this.selectedTaskIds = [], this.externalDraggingTask = null, this.selectedRows = /* @__PURE__ */ new Set(), this.selectedTasks = /* @__PURE__ */ new Set(), this.lastClickedRowId = null, this.virtualScrollTop = 0, this.dragTargetRowIndex = null, this.draggingTask = null, this.draggingTaskIds = [], this.multiDragDx = 0, this.viewportHeight = 400, this.dragOverlayInfo = null, this.calendarHeight = 0, this.tooltip = null, this.dragOverRowId = null, this.dragOverPosition = null, this.currentTime = /* @__PURE__ */ 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._layoutCache = null, this.resizeObserver = null, this._cachedSelectedTaskIds = [], this._cachedSelectedTasksSize = -1, this._cachedCurrentOption = null, this._lastOptionRef = null, this._lastLabelWidth = -1, this.handleSystemThemeChange = (e) => {
|
|
2068
2065
|
(this.option?.theme === "system" || this.option?.theme !== "light" && this.option?.theme !== "dark") && (this.theme = e.matches ? "dark" : "light");
|
|
@@ -2072,7 +2069,7 @@ var Z = class extends e {
|
|
|
2072
2069
|
...this.tooltip,
|
|
2073
2070
|
visible: !1
|
|
2074
2071
|
};
|
|
2075
|
-
}, this.updateScrollTop =
|
|
2072
|
+
}, this.updateScrollTop = d((e) => {
|
|
2076
2073
|
this.virtualScrollTop = e;
|
|
2077
2074
|
}, 100), this.handleContainerMouseMove = (e) => {
|
|
2078
2075
|
if (!this.option.calendar.showCursorLine) return;
|
|
@@ -2137,7 +2134,7 @@ var Z = class extends e {
|
|
|
2137
2134
|
return this.option.showHiddenRows ? this.rows : this.rows.filter((e) => e.visible !== !1);
|
|
2138
2135
|
}
|
|
2139
2136
|
static {
|
|
2140
|
-
this.styles =
|
|
2137
|
+
this.styles = K;
|
|
2141
2138
|
}
|
|
2142
2139
|
firstUpdated() {
|
|
2143
2140
|
this.setupCurrentTimeTimer();
|
|
@@ -2168,9 +2165,9 @@ var Z = class extends e {
|
|
|
2168
2165
|
let e = this.shadowRoot?.querySelector(".tooltip");
|
|
2169
2166
|
if (e) {
|
|
2170
2167
|
let t = this.option.customRendering?.tooltip ? this.option.customRendering.tooltip(this.tooltip.task) : void 0;
|
|
2171
|
-
if (t)
|
|
2168
|
+
if (t) typeof t == "string" ? e.textContent = t : r(t, e);
|
|
2172
2169
|
else {
|
|
2173
|
-
let t = this.option.locale ??
|
|
2170
|
+
let t = this.option.locale ?? k, i = !!this.option.calendar.pxPerMonth, a = Math.round((this.tooltip.task.end.getTime() - this.tooltip.task.start.getTime()) / (1e3 * 60 * 60 * 24));
|
|
2174
2171
|
if (i) {
|
|
2175
2172
|
let i = new Date(this.tooltip.task.end);
|
|
2176
2173
|
i.setMonth(i.getMonth() - 1), r(n`
|
|
@@ -2193,31 +2190,33 @@ var Z = class extends e {
|
|
|
2193
2190
|
}
|
|
2194
2191
|
updateDragOverlay() {
|
|
2195
2192
|
if (!this.dragOverlayInfo || this.option.showDragInfoOverlay === !1) return;
|
|
2196
|
-
let e =
|
|
2193
|
+
let e = F(this.theme, this.option.customTheme), t = this.shadowRoot?.querySelector(".drag-info-overlay");
|
|
2197
2194
|
if (!t) return;
|
|
2198
|
-
t.classList.toggle("visible", this.dragOverlayInfo.visible)
|
|
2199
|
-
let { targetRow:
|
|
2195
|
+
t.classList.toggle("visible", this.dragOverlayInfo.visible);
|
|
2196
|
+
let { targetRow: i } = this.dragOverlayInfo, a = this.option.customRendering?.dragInfo ? this.option.customRendering.dragInfo({
|
|
2200
2197
|
id: this.dragOverlayInfo.id,
|
|
2201
2198
|
name: this.dragOverlayInfo.name,
|
|
2202
2199
|
start: this.dragOverlayInfo.start,
|
|
2203
2200
|
end: this.dragOverlayInfo.end
|
|
2204
|
-
}, this.dragOverlayInfo.currentStart, this.dragOverlayInfo.currentEnd,
|
|
2205
|
-
if (
|
|
2206
|
-
|
|
2207
|
-
|
|
2201
|
+
}, this.dragOverlayInfo.currentStart, this.dragOverlayInfo.currentEnd, i) : void 0;
|
|
2202
|
+
if (a) r(a, t);
|
|
2203
|
+
else {
|
|
2204
|
+
let a = this.option.locale ?? k, o = !!this.option.calendar.pxPerMonth, s, c;
|
|
2205
|
+
if (o) {
|
|
2208
2206
|
let e = new Date(this.dragOverlayInfo.currentEnd);
|
|
2209
|
-
e.setMonth(e.getMonth() - 1),
|
|
2210
|
-
} else
|
|
2211
|
-
|
|
2207
|
+
e.setMonth(e.getMonth() - 1), s = a.yearMonthFormat(this.dragOverlayInfo.currentStart), c = a.yearMonthFormat(e);
|
|
2208
|
+
} else s = a.dateTimeFormat(this.dragOverlayInfo.currentStart), c = a.dateTimeFormat(this.dragOverlayInfo.currentEnd);
|
|
2209
|
+
r(n`
|
|
2212
2210
|
<div style="font-weight: bold;">
|
|
2213
|
-
${this.dragOverlayInfo.name ||
|
|
2211
|
+
${this.dragOverlayInfo.name || a.dragOverlay.noTitle}
|
|
2214
2212
|
</div>
|
|
2215
2213
|
<div class="drag-info-sub">
|
|
2216
|
-
${
|
|
2217
|
-
${
|
|
2218
|
-
(${
|
|
2214
|
+
${s} -
|
|
2215
|
+
${c}
|
|
2216
|
+
(${R(this.dragOverlayInfo.currentStart, this.dragOverlayInfo.currentEnd, this.option.locale)})
|
|
2219
2217
|
</div>
|
|
2220
|
-
${
|
|
2218
|
+
${i ? n`<div class="drag-info-sub" style="margin-top: 4px; border-top: 1px solid ${e.dragOverlayDivider}; padding-top: 4px; width: 100%;">${(this.option.locale ?? k).dragOverlay.moveTo(i.name)}</div>` : ""}
|
|
2219
|
+
`, t);
|
|
2221
2220
|
}
|
|
2222
2221
|
if (this.dragOverlayInfo.clientY !== void 0) {
|
|
2223
2222
|
let e = this.dragOverlayInfo.clientX ?? 0, n = this.dragOverlayInfo.clientY, r = this.getBoundingClientRect();
|
|
@@ -2264,13 +2263,13 @@ var Z = class extends e {
|
|
|
2264
2263
|
r.addEventListener("pointermove", o), r.addEventListener("pointerup", s);
|
|
2265
2264
|
}
|
|
2266
2265
|
getDateX(e) {
|
|
2267
|
-
return
|
|
2266
|
+
return M(e, this.option.calendar.start, this.option.calendar.pxPerDay ?? 50, this.option.calendar.pxPerMonth);
|
|
2268
2267
|
}
|
|
2269
2268
|
calculateLayout() {
|
|
2270
2269
|
if (this._layoutCache) return this._layoutCache;
|
|
2271
2270
|
let e = 0, t = this.currentRowHeaderWidth, n = /* @__PURE__ */ new Map(), r = {
|
|
2272
2271
|
layouts: this.displayRows.map((r) => {
|
|
2273
|
-
let { tasksWithLanes: i, laneCount: a } =
|
|
2272
|
+
let { tasksWithLanes: i, laneCount: a } = P(r.tasks), o = this.option.bar?.height ?? 28, s = this.option.bar?.margin ?? 4;
|
|
2274
2273
|
i.forEach((r) => {
|
|
2275
2274
|
let i = this.getDateX(r.start) + t, a = this.getDateX(r.end) + t - i, c = e + r.lane * (o + s) + s;
|
|
2276
2275
|
n.set(r.id, {
|
|
@@ -2302,7 +2301,7 @@ var Z = class extends e {
|
|
|
2302
2301
|
let l = n, u = r;
|
|
2303
2302
|
if (i !== void 0) {
|
|
2304
2303
|
let e = this.option.calendar.pxPerDay ?? 50, t = this.option.calendar.pxPerMonth, a = this.getDateX(n), o = this.getDateX(r);
|
|
2305
|
-
l =
|
|
2304
|
+
l = N(a + i, this.option.calendar.start, e, t), u = N(o + i, this.option.calendar.start, e, t);
|
|
2306
2305
|
}
|
|
2307
2306
|
(this.option.calendar.pxPerMonth || this.option.snapDuration && this.option.snapDuration >= 43200) && (l.getDate() > 15 && l.setMonth(l.getMonth() + 1), l.setDate(1), l.setHours(0, 0, 0, 0), u.getDate() > 15 && u.setMonth(u.getMonth() + 1), u.setDate(1), u.setHours(0, 0, 0, 0));
|
|
2308
2307
|
let d = -1, f, p = -1;
|
|
@@ -2312,7 +2311,7 @@ var Z = class extends e {
|
|
|
2312
2311
|
}), d === -1 || !f) return;
|
|
2313
2312
|
let { layouts: m } = this.calculateLayout(), h = this.displayRows.findIndex((e) => e.id === this.rows[d].id);
|
|
2314
2313
|
if (h === -1) return;
|
|
2315
|
-
let g = m[h].top, { tasksWithLanes: _ } =
|
|
2314
|
+
let g = m[h].top, { tasksWithLanes: _ } = P(this.rows[d].tasks), v = _.find((e) => e.id === t), y = v ? v.lane : 0, b = this.option.bar?.height ?? 28, x = this.option.bar?.margin ?? 4, S = g + (y * (b + x) + x) + s + b / 2, C = -1;
|
|
2316
2315
|
for (let e = 0; e < m.length; e++) {
|
|
2317
2316
|
let t = m[e];
|
|
2318
2317
|
if (S >= t.top && S < t.top + t.height) {
|
|
@@ -2347,7 +2346,7 @@ var Z = class extends e {
|
|
|
2347
2346
|
}
|
|
2348
2347
|
c ? this.dragOverlayInfo = {
|
|
2349
2348
|
id: t,
|
|
2350
|
-
name: (this.option.locale ??
|
|
2349
|
+
name: (this.option.locale ?? k).dragOverlay.movingTasks(this.selectedTasks.size),
|
|
2351
2350
|
start: n,
|
|
2352
2351
|
end: r,
|
|
2353
2352
|
currentStart: l,
|
|
@@ -2387,7 +2386,7 @@ var Z = class extends e {
|
|
|
2387
2386
|
...n,
|
|
2388
2387
|
tasks: n.tasks.map((n) => {
|
|
2389
2388
|
if (!this.selectedTasks.has(n.id)) return n;
|
|
2390
|
-
let r = this.getDateX(n.start), a = this.getDateX(n.end), o =
|
|
2389
|
+
let r = this.getDateX(n.start), a = this.getDateX(n.end), o = N(r + i, this.option.calendar.start, e, t), s = N(a + i, this.option.calendar.start, e, t);
|
|
2391
2390
|
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)), {
|
|
2392
2391
|
...n,
|
|
2393
2392
|
start: o,
|
|
@@ -2533,7 +2532,7 @@ var Z = class extends e {
|
|
|
2533
2532
|
let s = this.displayRows[o];
|
|
2534
2533
|
if (t) {
|
|
2535
2534
|
if ((this.dragOverRowId !== s.id || this.dragOverPosition !== null) && (this.dragOverRowId = s.id, this.dragOverPosition = null), this.externalDraggingTask) {
|
|
2536
|
-
let t = this.currentRowHeaderWidth, i = n.scrollLeft, a = e.clientX - r.left + i - t, o = this.option.calendar.pxPerDay ?? 50, c = this.option.calendar.pxPerMonth, l = this.option.snapDuration ?? 1440, u = o / 1440 * l, d =
|
|
2535
|
+
let t = this.currentRowHeaderWidth, i = n.scrollLeft, a = e.clientX - r.left + i - t, o = this.option.calendar.pxPerDay ?? 50, c = this.option.calendar.pxPerMonth, l = this.option.snapDuration ?? 1440, u = o / 1440 * l, d = N(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);
|
|
2537
2536
|
(!this.dragPreview || this.dragPreview.rowId !== s.id || this.dragPreview.currentStart.getTime() !== d.getTime()) && (this.dragPreview = {
|
|
2538
2537
|
task: this.externalDraggingTask,
|
|
2539
2538
|
currentStart: d,
|
|
@@ -2567,21 +2566,35 @@ var Z = class extends e {
|
|
|
2567
2566
|
}
|
|
2568
2567
|
handleExternalTaskDrop(e, t) {
|
|
2569
2568
|
try {
|
|
2570
|
-
let n = JSON.parse(t)
|
|
2571
|
-
if (!
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2569
|
+
let n = JSON.parse(t);
|
|
2570
|
+
if (!n || typeof n != "object" || typeof n.id != "string" || typeof n.name != "string" || !n.start || !n.end) {
|
|
2571
|
+
console.warn("Invalid dropped task data: missing required fields (id, name, start, end)");
|
|
2572
|
+
return;
|
|
2573
|
+
}
|
|
2574
|
+
let r = new Date(n.start), i = new Date(n.end);
|
|
2575
|
+
if (isNaN(r.getTime()) || isNaN(i.getTime())) {
|
|
2576
|
+
console.warn("Invalid dropped task data: start or end is not a valid date");
|
|
2577
|
+
return;
|
|
2578
|
+
}
|
|
2579
|
+
let a = {
|
|
2580
|
+
...n,
|
|
2581
|
+
start: r,
|
|
2582
|
+
end: i
|
|
2583
|
+
}, o = this.shadowRoot?.querySelector(".scroll-container");
|
|
2584
|
+
if (!o) return;
|
|
2585
|
+
let s = o.getBoundingClientRect(), c = o.scrollLeft, l = o.scrollTop, u = this.currentRowHeaderWidth, d = e.clientX - s.left + c - u, f = this.option.calendar.pxPerDay ?? 50, p = this.option.calendar.pxPerMonth, m = N(d, this.option.calendar.start, f, p), h = e.clientY - s.top + l - this.calendarHeight, { layouts: g } = this.calculateLayout(), _;
|
|
2586
|
+
for (let e = 0; e < g.length; e++) {
|
|
2587
|
+
let t = g[e];
|
|
2588
|
+
if (h >= t.top && h < t.top + t.height) {
|
|
2589
|
+
_ = this.displayRows[e].id;
|
|
2577
2590
|
break;
|
|
2578
2591
|
}
|
|
2579
2592
|
}
|
|
2580
|
-
|
|
2593
|
+
_ && this.dispatchEvent(new CustomEvent("task-drop", {
|
|
2581
2594
|
detail: {
|
|
2582
|
-
task:
|
|
2583
|
-
dropDate:
|
|
2584
|
-
targetRowId:
|
|
2595
|
+
task: a,
|
|
2596
|
+
dropDate: m,
|
|
2597
|
+
targetRowId: _
|
|
2585
2598
|
},
|
|
2586
2599
|
bubbles: !0,
|
|
2587
2600
|
composed: !0
|
|
@@ -2632,7 +2645,7 @@ var Z = class extends e {
|
|
|
2632
2645
|
}
|
|
2633
2646
|
}
|
|
2634
2647
|
if (c) {
|
|
2635
|
-
let t = e.clientX - n.left + r - a, i = this.option.calendar.pxPerDay ?? 50, o = this.option.calendar.pxPerMonth, s =
|
|
2648
|
+
let t = e.clientX - n.left + r - a, i = this.option.calendar.pxPerDay ?? 50, o = this.option.calendar.pxPerMonth, s = N(t, this.option.calendar.start, i, o);
|
|
2636
2649
|
this.dispatchEvent(new CustomEvent("chart-contextmenu", {
|
|
2637
2650
|
detail: {
|
|
2638
2651
|
event: e,
|
|
@@ -2657,7 +2670,7 @@ var Z = class extends e {
|
|
|
2657
2670
|
}
|
|
2658
2671
|
}
|
|
2659
2672
|
if (!l) return null;
|
|
2660
|
-
let u = e - r.left + i - o, d = this.option.calendar.pxPerDay ?? 50, f = this.option.calendar.pxPerMonth, p =
|
|
2673
|
+
let u = e - r.left + i - o, d = this.option.calendar.pxPerDay ?? 50, f = this.option.calendar.pxPerMonth, p = N(u, this.option.calendar.start, d, f);
|
|
2661
2674
|
return {
|
|
2662
2675
|
rowId: l,
|
|
2663
2676
|
date: p
|
|
@@ -2666,7 +2679,7 @@ var Z = class extends e {
|
|
|
2666
2679
|
async exportImage(e = "png", t = {}) {
|
|
2667
2680
|
this.isExporting = !0, await this.updateComplete, await new Promise((e) => requestAnimationFrame(e));
|
|
2668
2681
|
try {
|
|
2669
|
-
return await
|
|
2682
|
+
return await Y(this, e, t);
|
|
2670
2683
|
} finally {
|
|
2671
2684
|
this.isExporting = !1, await this.updateComplete;
|
|
2672
2685
|
}
|
|
@@ -2923,7 +2936,7 @@ var Z = class extends e {
|
|
|
2923
2936
|
}
|
|
2924
2937
|
}
|
|
2925
2938
|
render() {
|
|
2926
|
-
let e =
|
|
2939
|
+
let e = F(this.theme, this.option.customTheme), { layouts: t, taskCoords: r, totalHeight: a } = this.calculateLayout(), o = this.currentRowHeaderWidth;
|
|
2927
2940
|
(this._lastOptionRef !== this.option || this._lastLabelWidth !== o) && (this._cachedCurrentOption = {
|
|
2928
2941
|
...this.option,
|
|
2929
2942
|
rowHeader: {
|
|
@@ -2949,7 +2962,7 @@ var Z = class extends e {
|
|
|
2949
2962
|
let r = a.x + a.width, o = a.y + a.height / 2, s = t.x, c = t.y + t.height / 2, l = r < s, u = y ? s - b : s, d = l ? Math.max(r, u) : u, f, p, m, h = this.option.bar?.height ?? 28, g = this.option.bar?.margin ?? 4;
|
|
2950
2963
|
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}` : "";
|
|
2951
2964
|
else if (x === "orthogonal") {
|
|
2952
|
-
let e =
|
|
2965
|
+
let e = G(r, o, s, c, d, h, g, S);
|
|
2953
2966
|
f = e.pathD, p = e.hitPathD;
|
|
2954
2967
|
} else if (l) {
|
|
2955
2968
|
let e = (r + d) / 2;
|
|
@@ -2981,7 +2994,7 @@ var Z = class extends e {
|
|
|
2981
2994
|
}
|
|
2982
2995
|
}
|
|
2983
2996
|
return n`
|
|
2984
|
-
<style>${
|
|
2997
|
+
<style>${q(this.theme, this.option.customTheme)}</style>
|
|
2985
2998
|
${this.isExporting ? n`<style>:host { overflow: visible !important; height: ${this.calendarHeight + a + 2}px !important; width: max-content !important; min-width: auto !important; }</style>` : ""}
|
|
2986
2999
|
<div
|
|
2987
3000
|
class="scroll-container"
|
|
@@ -3155,9 +3168,9 @@ var Z = class extends e {
|
|
|
3155
3168
|
`;
|
|
3156
3169
|
}
|
|
3157
3170
|
};
|
|
3158
|
-
|
|
3171
|
+
B([s({ type: Array })], X.prototype, "rows", void 0), B([s({ type: Object })], X.prototype, "option", void 0), B([s({
|
|
3159
3172
|
type: String,
|
|
3160
3173
|
reflect: !0
|
|
3161
|
-
})],
|
|
3174
|
+
})], X.prototype, "theme", void 0), B([s({ type: Array })], X.prototype, "selectedRowIds", void 0), B([s({ type: Array })], X.prototype, "selectedTaskIds", void 0), B([s({ attribute: !1 })], X.prototype, "externalDraggingTask", void 0), B([c()], X.prototype, "selectedRows", void 0), B([c()], X.prototype, "selectedTasks", void 0), B([c()], X.prototype, "lastClickedRowId", void 0), B([c()], X.prototype, "virtualScrollTop", void 0), B([c()], X.prototype, "dragTargetRowIndex", void 0), B([c()], X.prototype, "draggingTask", void 0), B([c()], X.prototype, "draggingTaskIds", void 0), B([c()], X.prototype, "multiDragDx", void 0), B([c()], X.prototype, "viewportHeight", void 0), B([c()], X.prototype, "calendarHeight", void 0), B([c()], X.prototype, "tooltip", void 0), B([c()], X.prototype, "dragOverRowId", void 0), B([c()], X.prototype, "dragOverPosition", void 0), B([c()], X.prototype, "currentTime", void 0), B([c()], X.prototype, "dragPreview", void 0), B([c()], X.prototype, "currentRowHeaderWidth", void 0), B([c()], X.prototype, "isResizingHeader", void 0), B([c()], X.prototype, "hoveredMilestoneId", void 0), B([c()], X.prototype, "cursorLineX", void 0), B([c()], X.prototype, "connectorDrag", void 0), B([c()], X.prototype, "isExporting", void 0), B([c()], X.prototype, "focusedTaskId", void 0), B([c()], X.prototype, "focusedRowId", void 0), X = B([o("gantt-chart")], X);
|
|
3162
3175
|
//#endregion
|
|
3163
|
-
export {
|
|
3176
|
+
export { m as ALL_BAR_PATTERNS, V as GanttBarElement, H as GanttCalendarElement, X as GanttChartElement, W as GanttRowElement, y as PATTERN_CHECKERBOARD, S as PATTERN_CIRCLE, w as PATTERN_DIAGONAL_GRID, h as PATTERN_DIAGONAL_STRIPE, g as PATTERN_DIAGONAL_STRIPE_REVERSE, b as PATTERN_DOTS, D as PATTERN_DOTS_DENSE, C as PATTERN_GRID, v as PATTERN_HORIZONTAL_STRIPE, E as PATTERN_STRIPE_THICK, T as PATTERN_STRIPE_THIN, x as PATTERN_TRIANGLE, _ as PATTERN_VERTICAL_STRIPE, A as enLocale, O as getPatternStyle, k as jaLocale };
|