@mogura/moguchart-core 0.5.3 → 0.6.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.
@@ -7,12 +7,15 @@ export declare class GanttBarElement extends LitElement {
7
7
  selected: boolean;
8
8
  focused: boolean;
9
9
  multiDragDx: number;
10
+ multiDragDy: number;
10
11
  multiDragActive: boolean;
12
+ multiDragSameRow: boolean;
11
13
  connectorDropTarget: boolean;
12
14
  isExporting: boolean;
13
15
  private _currentDragCursor;
14
16
  private _dragAnimationFrame;
15
17
  private _wasDragging;
18
+ private _connectorEdgeThreshold;
16
19
  static styles: import("lit").CSSResult;
17
20
  private getX;
18
21
  private setupDragEvents;
@@ -23,6 +26,7 @@ export declare class GanttBarElement extends LitElement {
23
26
  private handleKeyDown;
24
27
  private handleKeyUp;
25
28
  private updateCursor;
29
+ private onMouseMoveOnBar;
26
30
  private onMouseEnter;
27
31
  private onMouseLeave;
28
32
  private onDblClick;
@@ -18,6 +18,8 @@ export declare class GanttChartElement extends LitElement {
18
18
  private draggingTask;
19
19
  private draggingTaskIds;
20
20
  private multiDragDx;
21
+ private multiDragDy;
22
+ private multiDragSameRow;
21
23
  private viewportHeight;
22
24
  private dragOverlayInfo;
23
25
  private calendarHeight;
@@ -72,6 +74,11 @@ export declare class GanttChartElement extends LitElement {
72
74
  * ドラッグ中のバーが選択中バーに含まれ、選択数が2以上の場合にtrue。
73
75
  */
74
76
  private isMultiDrag;
77
+ /**
78
+ * 選択中の全タスクが同じ行に属しているかを判定する。
79
+ * 同じ行なら縦方向(行間)の移動を許可する。
80
+ */
81
+ private isMultiDragSameRow;
75
82
  private handleTaskUpdate;
76
83
  private handleBarMouseEnter;
77
84
  private handleBarMouseLeave;
@@ -17,6 +17,8 @@ export declare class GanttRowElement extends LitElement {
17
17
  } | null;
18
18
  draggingTaskIds: string[];
19
19
  multiDragDx: number;
20
+ multiDragDy: number;
21
+ multiDragSameRow: boolean;
20
22
  externalDragTask: {
21
23
  task: GanttTask;
22
24
  currentStart: Date;
@@ -38,6 +40,18 @@ export declare class GanttRowElement extends LitElement {
38
40
  * マーカーのSVGパスを生成する
39
41
  */
40
42
  private getMarkerPath;
43
+ /**
44
+ * マーカーの表示幅を推定する(アイコン+ラベル)
45
+ */
46
+ private estimateMarkerWidth;
47
+ /**
48
+ * マーカーのX方向の占有範囲を計算する
49
+ */
50
+ private getMarkerXRange;
51
+ /**
52
+ * マーカー群のレーン(段)を計算して重なりを回避する
53
+ */
54
+ private calculateMarkerLanes;
41
55
  static styles: import("lit").CSSResult;
42
56
  private handleDragStart;
43
57
  private handleHeaderClick;
@@ -286,10 +286,15 @@ function B(e, t, n, r) {
286
286
  //#region src/components/gantt-bar.ts
287
287
  var V = class extends e {
288
288
  constructor(...e) {
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) => {
289
+ 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._currentDragCursor = null, this._dragAnimationFrame = null, this._wasDragging = !1, this._connectorEdgeThreshold = 30, this.handleKeyDown = (e) => {
290
290
  (e.key === "Control" || e.key === "Alt") && this.updateCursor(!0);
291
291
  }, this.handleKeyUp = (e) => {
292
292
  (e.key === "Control" || e.key === "Alt") && this.updateCursor(!1);
293
+ }, this.onMouseMoveOnBar = (e) => {
294
+ let t = this.shadowRoot?.querySelector(".task-group");
295
+ if (!t || this.option.readOnly) return;
296
+ 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");
297
+ o && o.classList.toggle("show-connector", i), s && s.classList.toggle("show-connector", a);
293
298
  };
294
299
  }
295
300
  static {
@@ -376,8 +381,8 @@ var V = class extends e {
376
381
  transition: opacity 0.15s ease;
377
382
  pointer-events: auto;
378
383
  }
379
- .task-group:hover .connector-left,
380
- .task-group:hover .connector-right {
384
+ .connector-left.show-connector,
385
+ .connector-right.show-connector {
381
386
  opacity: 1;
382
387
  }
383
388
  .connector-left {
@@ -555,7 +560,7 @@ var V = class extends e {
555
560
  let i = e.ctrlKey || e.altKey ? "copy" : "grabbing";
556
561
  this._currentDragCursor = i, t.style.cursor = i;
557
562
  let u = e.clientX - a, d = e.clientY - o;
558
- r === "y" && (u = 0), (r === "x" || this.multiDragActive) && (d = 0);
563
+ r === "y" && (u = 0), r === "x" && (d = 0), this.multiDragActive && !this.multiDragSameRow && (d = 0);
559
564
  let f = u;
560
565
  if (this.option.calendar.pxPerMonth) {
561
566
  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);
@@ -605,7 +610,7 @@ var V = class extends e {
605
610
  t = Math.round(e / n) * n;
606
611
  }
607
612
  let n = i.clientY - o;
608
- if (r === "y" && (t = 0), (r === "x" || this.multiDragActive) && (n = 0), t === 0 && Math.abs(n) < 5) {
613
+ if (r === "y" && (t = 0), r === "x" && (n = 0), this.multiDragActive && !this.multiDragSameRow && (n = 0), t === 0 && Math.abs(n) < 5) {
609
614
  this.dispatchEvent(new CustomEvent("bar-click", {
610
615
  detail: {
611
616
  task: this.task,
@@ -652,9 +657,9 @@ var V = class extends e {
652
657
  },
653
658
  bubbles: !0,
654
659
  composed: !0
655
- })), this._currentDragCursor ? t.style.cursor = this._currentDragCursor : this.option.readOnly || (t.style.cursor = "")), e.has("multiDragDx")) {
660
+ })), this._currentDragCursor ? t.style.cursor = this._currentDragCursor : this.option.readOnly || (t.style.cursor = "")), e.has("multiDragDx") || e.has("multiDragDy")) {
656
661
  let e = this.shadowRoot?.querySelector(".task-group");
657
- e && (this.multiDragDx === 0 ? (e.style.transform = "", e.style.opacity = "", e.style.pointerEvents = "") : (e.style.transform = `translateX(${this.multiDragDx}px)`, e.style.opacity = "0.6", e.style.pointerEvents = "none"));
662
+ 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 = ""));
658
663
  }
659
664
  }
660
665
  disconnectedCallback() {
@@ -667,7 +672,7 @@ var V = class extends e {
667
672
  onMouseEnter(e) {
668
673
  let t = e.currentTarget;
669
674
  if (t.classList.contains("dragging")) return;
670
- this.option.readOnly || (window.addEventListener("keydown", this.handleKeyDown), window.addEventListener("keyup", this.handleKeyUp), (e.ctrlKey || e.altKey) && this.updateCursor(!0));
675
+ 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));
671
676
  let n = t.getBoundingClientRect();
672
677
  this.dispatchEvent(new CustomEvent("bar-mouseenter", {
673
678
  detail: {
@@ -680,7 +685,13 @@ var V = class extends e {
680
685
  }));
681
686
  }
682
687
  onMouseLeave() {
683
- this.option.readOnly || (window.removeEventListener("keydown", this.handleKeyDown), window.removeEventListener("keyup", this.handleKeyUp), this.updateCursor(!1)), this.dispatchEvent(new CustomEvent("bar-mouseleave", {
688
+ let e = this.shadowRoot?.querySelector(".task-group");
689
+ if (!this.option.readOnly) {
690
+ window.removeEventListener("keydown", this.handleKeyDown), window.removeEventListener("keyup", this.handleKeyUp), this.updateCursor(!1), e && e.removeEventListener("mousemove", this.onMouseMoveOnBar);
691
+ let t = this.shadowRoot?.querySelector(".connector-left"), n = this.shadowRoot?.querySelector(".connector-right");
692
+ t && t.classList.remove("show-connector"), n && n.classList.remove("show-connector");
693
+ }
694
+ this.dispatchEvent(new CustomEvent("bar-mouseleave", {
684
695
  bubbles: !0,
685
696
  composed: !0
686
697
  }));
@@ -815,7 +826,7 @@ B([s({ type: Object })], V.prototype, "task", void 0), B([s({ type: Object })],
815
826
  })], V.prototype, "selected", void 0), B([s({
816
827
  type: Boolean,
817
828
  reflect: !0
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({
829
+ })], V.prototype, "focused", void 0), B([s({ type: Number })], V.prototype, "multiDragDx", void 0), B([s({ type: Number })], V.prototype, "multiDragDy", void 0), B([s({ type: Boolean })], V.prototype, "multiDragActive", void 0), B([s({ type: Boolean })], V.prototype, "multiDragSameRow", void 0), B([s({
819
830
  type: Boolean,
820
831
  reflect: !0,
821
832
  attribute: "connector-drop-target"
@@ -1401,7 +1412,7 @@ B([s({ type: Object })], U.prototype, "option", void 0), B([s({ type: String })]
1401
1412
  //#region src/components/gantt-row.ts
1402
1413
  var W = class extends e {
1403
1414
  constructor(...e) {
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;
1415
+ super(...e), this.isDragTarget = !1, this.draggingTask = null, this.draggingTaskIds = [], this.multiDragDx = 0, this.multiDragDy = 0, this.multiDragSameRow = !1, 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;
1405
1416
  }
1406
1417
  getDateX(e) {
1407
1418
  return M(e, this.option.calendar.start, this.option.calendar.pxPerDay, this.option.calendar.pxPerMonth);
@@ -1418,6 +1429,47 @@ var W = class extends e {
1418
1429
  default: return `M 0 ${t} L ${n} 0 L ${t} ${t} Z`;
1419
1430
  }
1420
1431
  }
1432
+ estimateMarkerWidth(e, t) {
1433
+ let n = e.name ? e.name.length * 7 + 4 : 0;
1434
+ return e.anchor === "center" ? t : t + n;
1435
+ }
1436
+ getMarkerXRange(e, t) {
1437
+ let n = this.getDateX(e.date), r = this.estimateMarkerWidth(e, t), i = e.anchor === "center", a = e.anchor === "end", o;
1438
+ if (o = e.anchor === "start" ? n : e.anchor === "end" ? n - t : n - t / 2, i) return {
1439
+ left: o,
1440
+ right: o + t
1441
+ };
1442
+ if (a) {
1443
+ let e = r - t;
1444
+ return {
1445
+ left: o - e,
1446
+ right: o + t
1447
+ };
1448
+ }
1449
+ return {
1450
+ left: o,
1451
+ right: o + r
1452
+ };
1453
+ }
1454
+ calculateMarkerLanes(e, t) {
1455
+ if (!e.length) return [];
1456
+ let n = e.map((e) => ({
1457
+ marker: e,
1458
+ range: this.getMarkerXRange(e, t)
1459
+ })).sort((e, t) => e.range.left - t.range.left), r = [], i = [];
1460
+ for (let e of n) {
1461
+ let t = -1;
1462
+ for (let n = 0; n < r.length; n++) if (e.range.left >= r[n] + 2) {
1463
+ r[n] = e.range.right, t = n;
1464
+ break;
1465
+ }
1466
+ t === -1 && (r.push(e.range.right), t = r.length - 1), i.push({
1467
+ marker: e.marker,
1468
+ lane: t
1469
+ });
1470
+ }
1471
+ return i;
1472
+ }
1421
1473
  static {
1422
1474
  this.styles = t`
1423
1475
  :host {
@@ -1596,11 +1648,11 @@ var W = class extends e {
1596
1648
  let e = P(t);
1597
1649
  r = e.tasksWithLanes, i = e.laneCount;
1598
1650
  }
1599
- let o = this.option.bar?.height ?? 28, s = this.option.bar?.margin ?? 4, c = i * (o + s) + s;
1600
- this.style.height = `${c}px`;
1601
- let l = "", d = null, f = this.option.calendar.start.getTime(), p = this.option.calendar.end.getTime(), m = this.option.calendar.pxPerDay, h = this.option.calendar.pxPerMonth ?? 0;
1602
- if (!this._cachedMonthGridLines || f !== this._cachedMonthGridStartTime || p !== this._cachedMonthGridEndTime || m !== this._cachedMonthGridPxPerDay || h !== this._cachedMonthGridPxPerMonth) {
1603
- this._cachedMonthGridStartTime = f, this._cachedMonthGridEndTime = p, this._cachedMonthGridPxPerDay = m, this._cachedMonthGridPxPerMonth = h;
1651
+ let o = this.option.bar?.height ?? 28, s = this.option.bar?.margin ?? 4, c = this.row.markers ?? [], l = Math.min(o, 12), d = l + 2, f = this.calculateMarkerLanes(c, l), p = f.length > 0 ? Math.max(...f.map((e) => e.lane)) + 1 : 0, m = i * (o + s) + s, h = m + (p > 1 ? (p - 1) * d : 0);
1652
+ this.style.height = `${h}px`;
1653
+ 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;
1654
+ if (!this._cachedMonthGridLines || v !== this._cachedMonthGridStartTime || y !== this._cachedMonthGridEndTime || b !== this._cachedMonthGridPxPerDay || x !== this._cachedMonthGridPxPerMonth) {
1655
+ this._cachedMonthGridStartTime = v, this._cachedMonthGridEndTime = y, this._cachedMonthGridPxPerDay = b, this._cachedMonthGridPxPerMonth = x;
1604
1656
  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);
1605
1657
  for (o.setDate(1), o.setHours(0, 0, 0, 0); o <= r;) {
1606
1658
  let e = this.getDateX(o);
@@ -1615,50 +1667,50 @@ var W = class extends e {
1615
1667
  }
1616
1668
  this._cachedMonthGridLines = a;
1617
1669
  }
1618
- if (d = this._cachedMonthGridLines, this.option.calendar.showMonthsRow) l = "";
1670
+ if (_ = this._cachedMonthGridLines, this.option.calendar.showMonthsRow) g = "";
1619
1671
  else if (this.option.calendar.showTime) {
1620
- 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) / (1440 * 60 * 1e3) * i, c = s % t, u = s % r, d = s === 0 ? "0px 0" : `${-s}px 0`, f = c === 0 ? "0px 0" : `${-c}px 0`, p = u === 0 ? "0px 0" : `${-u}px 0`, m = [
1672
+ 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) / (1440 * 60 * 1e3) * 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 = [
1621
1673
  `linear-gradient(90deg, transparent ${i - 1}px, ${a} ${i - 1}px)`,
1622
1674
  `linear-gradient(90deg, transparent ${t - 1}px, ${e.gridLine} ${t - 1}px)`,
1623
1675
  `linear-gradient(90deg, transparent ${r - 1}px, ${e.subGridLine} ${r - 1}px)`
1624
- ], h = [
1676
+ ], m = [
1625
1677
  `${i}px 100%`,
1626
1678
  `${t}px 100%`,
1627
1679
  `${r}px 100%`
1628
- ], g = [
1680
+ ], h = [
1681
+ u,
1629
1682
  d,
1630
- f,
1631
- p
1683
+ f
1632
1684
  ];
1633
- l = `
1634
- background-image: ${m.join(", ")};
1635
- background-size: ${h.join(", ")};
1636
- background-position: ${g.join(", ")};
1685
+ g = `
1686
+ background-image: ${p.join(", ")};
1687
+ background-size: ${m.join(", ")};
1688
+ background-position: ${h.join(", ")};
1637
1689
  `;
1638
1690
  } else {
1639
1691
  let t = this.option.calendar.pxPerDay, n = this.option.calendar.start, r = (n.getHours() * 60 * 60 * 1e3 + n.getMinutes() * 60 * 1e3 + n.getSeconds() * 1e3) / (1440 * 60 * 1e3) * t, i = r === 0 ? "0px 0" : `${-r}px 0`;
1640
- l = `
1692
+ g = `
1641
1693
  background-image: linear-gradient(90deg, transparent ${t - 1}px, ${e.gridLine} ${t - 1}px);
1642
1694
  background-size: ${t}px 100%;
1643
1695
  background-position: ${i};
1644
1696
  `;
1645
1697
  }
1646
- let g = this.option.enableRowReordering && !this.option.readOnly, _ = this.row.visible === !1, v = this.isSelected ? e.rowSelectedHeader : _ ? e.rowHiddenBg : e.rowHeaderBg, y = v.includes("gradient") ? `background: ${v};` : `background-color: ${v};`;
1698
+ let S = this.option.enableRowReordering && !this.option.readOnly, C = this.row.visible === !1, w = this.isSelected ? e.rowSelectedHeader : C ? e.rowHiddenBg : e.rowHeaderBg, T = w.includes("gradient") ? `background: ${w};` : `background-color: ${w};`;
1647
1699
  return n`
1648
1700
  <style>
1649
1701
  :host {
1650
1702
  color: ${e.text};
1651
- background-color: ${_ ? e.rowHiddenBg : "transparent"};
1703
+ background-color: ${C ? e.rowHiddenBg : "transparent"};
1652
1704
  }
1653
1705
 
1654
1706
  .row-header {
1655
- cursor: ${g ? "grab" : "pointer"};
1707
+ cursor: ${S ? "grab" : "pointer"};
1656
1708
  border-right: 1px solid ${e.border};
1657
1709
  border-bottom: 1px solid ${e.border};
1658
1710
  box-sizing: border-box;
1659
1711
  }
1660
1712
  .row-header:active {
1661
- cursor: ${g ? "grabbing" : "pointer"};
1713
+ cursor: ${S ? "grabbing" : "pointer"};
1662
1714
  }
1663
1715
  .bars-container {
1664
1716
  border-bottom: 1px solid ${e.border};
@@ -1689,9 +1741,9 @@ var W = class extends e {
1689
1741
  <div class="row-container ${this.dropPosition ? `drop-${this.dropPosition}` : ""}">
1690
1742
  <div
1691
1743
  class="row-header"
1692
- style="width: ${this.option.rowHeader?.width ?? 150}px; ${y}"
1693
- draggable="${g ? "true" : "false"}"
1694
- @dragstart="${g ? this.handleDragStart : void 0}"
1744
+ style="width: ${this.option.rowHeader?.width ?? 150}px; ${T}"
1745
+ draggable="${S ? "true" : "false"}"
1746
+ @dragstart="${S ? this.handleDragStart : void 0}"
1695
1747
  @click="${this.handleHeaderClick}"
1696
1748
  @dblclick="${this.handleHeaderDblClick}"
1697
1749
  @contextmenu="${this.handleHeaderContextMenu}"
@@ -1710,18 +1762,18 @@ var W = class extends e {
1710
1762
  })()}px">
1711
1763
  ${this.option.calendar.showRowBackground !== !1 && !this.option.calendar.showMonthsRow ? n`<gantt-row-background .option="${this.option}" .theme="${this.theme}" .rowId="${this.row.id}" /> ` : ""}
1712
1764
  ${this.isSelected ? n`<div class="selected-row-overlay"></div>` : ""}
1713
- ${l ? n`<div class="grid-background" style="${l}"></div>` : ""}
1714
- ${d ? d.map((t) => {
1765
+ ${g ? n`<div class="grid-background" style="${g}"></div>` : ""}
1766
+ ${_ ? _.map((t) => {
1715
1767
  let r;
1716
1768
  return r = t.isYearBoundary ? e.yearGridLine || e.monthGridLine || e.gridLine : this.option.calendar.showMonthsRow || this.option.calendar.showDays === !1 && !this.option.calendar.showWeeks ? e.gridLine : e.monthGridLine || e.gridLine, n`<div style="position: absolute; top: 0; left: ${t.left - 1}px; width: 1px; height: 100%; background-color: ${r}; pointer-events: none; z-index: 1;"></div>`;
1717
1769
  }) : ""}
1718
- ${_ ? n`<div class="hidden-row-overlay" style="background: ${e.rowHiddenBg};"></div>` : ""}
1770
+ ${C ? n`<div class="hidden-row-overlay" style="background: ${e.rowHiddenBg};"></div>` : ""}
1719
1771
  ${u(r, (e) => e.id, (e) => {
1720
1772
  let t = this.draggingTask?.id === e.id, r = !t && this.draggingTaskIds.length >= 2 && this.draggingTaskIds.includes(e.id), i = t ? {
1721
1773
  ...e,
1722
1774
  start: this.draggingTask.start,
1723
1775
  end: this.draggingTask.end
1724
- } : e, a = this.selectedTaskIds.includes(e.id), o = r ? this.multiDragDx : 0, s = t && this.draggingTaskIds.length >= 2;
1776
+ } : e, a = this.selectedTaskIds.includes(e.id), o = r ? this.multiDragDx : 0, s = r ? this.multiDragDy : 0, c = t && this.draggingTaskIds.length >= 2;
1725
1777
  return n`
1726
1778
  <gantt-bar
1727
1779
  .task="${i}"
@@ -1730,23 +1782,25 @@ var W = class extends e {
1730
1782
  .selected="${a}"
1731
1783
  .focused="${this.focusedTaskId === e.id}"
1732
1784
  .multiDragDx="${o}"
1733
- .multiDragActive="${s}"
1785
+ .multiDragDy="${s}"
1786
+ .multiDragActive="${c}"
1787
+ .multiDragSameRow="${this.multiDragSameRow}"
1734
1788
  .isExporting="${this.isExporting}"
1735
1789
  />
1736
1790
  `;
1737
1791
  })}
1738
- ${(this.row.markers ?? []).map((e) => {
1739
- let t = Math.min(o, 12), r = this.getDateX(e.date), i = e.color ?? "#ef4444", a = e.anchor === "center", s = a ? c / 2 - t : (c - t) / 2, l = e.anchor === "start" ? r : e.anchor === "end" ? r - t : r - t / 2, u = e.anchor === "end";
1792
+ ${f.map(({ marker: e, lane: t }) => {
1793
+ let r = this.getDateX(e.date), i = e.color ?? "#ef4444", a = e.anchor === "center", o = (a ? m / 2 - l : (m - l) / 2) + t * d, s = e.anchor === "start" ? r : e.anchor === "end" ? r - l : r - l / 2, c = e.anchor === "end";
1740
1794
  return n`
1741
1795
  <div
1742
1796
  class="marker-wrapper"
1743
1797
  style="
1744
1798
  position: absolute;
1745
- left: ${l}px;
1746
- top: ${s}px;
1799
+ left: ${s}px;
1800
+ top: ${o}px;
1747
1801
  z-index: 2;
1748
1802
  display: flex;
1749
- ${a ? `flex-direction: column; align-items: center; width: ${t}px; overflow: visible;` : `align-items: center; ${u ? "flex-direction: row-reverse;" : ""}`}
1803
+ ${a ? `flex-direction: column; align-items: center; width: ${l}px; overflow: visible;` : `align-items: center; ${c ? "flex-direction: row-reverse;" : ""}`}
1750
1804
  pointer-events: auto;
1751
1805
  cursor: default;
1752
1806
  white-space: nowrap;
@@ -1755,16 +1809,16 @@ var W = class extends e {
1755
1809
  >
1756
1810
  <svg
1757
1811
  class="marker-icon"
1758
- width="${t}"
1759
- height="${t}"
1760
- viewBox="0 0 ${t} ${t}"
1812
+ width="${l}"
1813
+ height="${l}"
1814
+ viewBox="0 0 ${l} ${l}"
1761
1815
  style="
1762
1816
  flex-shrink: 0;
1763
1817
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
1764
1818
  ${e.style ?? ""}
1765
1819
  "
1766
1820
  >
1767
- <path d="${this.getMarkerPath(e.type, t)}" fill="${i}" />
1821
+ <path d="${this.getMarkerPath(e.type, l)}" fill="${i}" />
1768
1822
  </svg>
1769
1823
  ${e.name ? n`<span style="
1770
1824
  font-size: 10px;
@@ -1780,7 +1834,7 @@ var W = class extends e {
1780
1834
  `;
1781
1835
  }
1782
1836
  };
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({
1837
+ 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: Number })], W.prototype, "multiDragDy", void 0), B([s({ type: Boolean })], W.prototype, "multiDragSameRow", void 0), B([s({ type: Object })], W.prototype, "externalDragTask", void 0), B([s({ type: String })], W.prototype, "theme", void 0), B([s({
1784
1838
  type: Boolean,
1785
1839
  reflect: !0
1786
1840
  })], 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({
@@ -2061,7 +2115,7 @@ async function Y(e, t = "png", n = {}) {
2061
2115
  //#region src/components/gantt-chart.ts
2062
2116
  var X = class extends e {
2063
2117
  constructor(...e) {
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) => {
2118
+ 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.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 = /* @__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) => {
2065
2119
  (this.option?.theme === "system" || this.option?.theme !== "light" && this.option?.theme !== "dark") && (this.theme = e.matches ? "dark" : "light");
2066
2120
  }, this.handleScroll = (e) => {
2067
2121
  let t = e.target;
@@ -2294,40 +2348,49 @@ var X = class extends e {
2294
2348
  isMultiDrag(e) {
2295
2349
  return this.selectedTasks.size >= 2 && this.selectedTasks.has(e);
2296
2350
  }
2351
+ isMultiDragSameRow() {
2352
+ if (this.selectedTasks.size < 2) return !1;
2353
+ let e = null;
2354
+ for (let t of this.rows) for (let n of t.tasks) if (this.selectedTasks.has(n.id)) {
2355
+ if (e === null) e = t.id;
2356
+ else if (e !== t.id) return !1;
2357
+ }
2358
+ return e !== null;
2359
+ }
2297
2360
  handleTaskUpdate(e) {
2298
2361
  e.stopPropagation();
2299
- let { id: t, start: n, end: r, dx: i, isDragging: a, mode: o } = e.detail, { dy: s } = e.detail, c = this.isMultiDrag(t);
2300
- c && (s = 0);
2301
- let l = n, u = r;
2362
+ 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();
2363
+ c && !l && (s = 0);
2364
+ let u = n, d = r;
2302
2365
  if (i !== void 0) {
2303
2366
  let e = this.option.calendar.pxPerDay ?? 50, t = this.option.calendar.pxPerMonth, a = this.getDateX(n), o = this.getDateX(r);
2304
- l = N(a + i, this.option.calendar.start, e, t), u = N(o + i, this.option.calendar.start, e, t);
2367
+ u = N(a + i, this.option.calendar.start, e, t), d = N(o + i, this.option.calendar.start, e, t);
2305
2368
  }
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));
2307
- let d = -1, f, p = -1;
2369
+ (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));
2370
+ let f = -1, p, m = -1;
2308
2371
  if (this.rows.find((e, n) => {
2309
2372
  let r = e.tasks.findIndex((e) => e.id === t);
2310
- return r === -1 ? !1 : (d = n, f = e.tasks[r], p = r, !0);
2311
- }), d === -1 || !f) return;
2312
- let { layouts: m } = this.calculateLayout(), h = this.displayRows.findIndex((e) => e.id === this.rows[d].id);
2313
- if (h === -1) return;
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;
2315
- for (let e = 0; e < m.length; e++) {
2316
- let t = m[e];
2317
- if (S >= t.top && S < t.top + t.height) {
2318
- C = e;
2373
+ return r === -1 ? !1 : (f = n, p = e.tasks[r], m = r, !0);
2374
+ }), f === -1 || !p) return;
2375
+ let { layouts: h } = this.calculateLayout(), g = this.displayRows.findIndex((e) => e.id === this.rows[f].id);
2376
+ if (g === -1) return;
2377
+ let _ = h[g].top, { tasksWithLanes: v } = P(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;
2378
+ for (let e = 0; e < h.length; e++) {
2379
+ let t = h[e];
2380
+ if (C >= t.top && C < t.top + t.height) {
2381
+ w = e;
2319
2382
  break;
2320
2383
  }
2321
2384
  }
2322
- let w = C === -1 ? void 0 : this.displayRows[C].id, T = c ? [...this.selectedTasks] : void 0;
2385
+ let T = w === -1 ? void 0 : this.displayRows[w].id, E = c ? [...this.selectedTasks] : void 0;
2323
2386
  if (this.dispatchEvent(new CustomEvent("task-update", {
2324
2387
  detail: {
2325
2388
  ...e.detail,
2326
2389
  dy: s,
2327
- start: l,
2328
- end: u,
2329
- targetRowId: w,
2330
- selectedTaskIds: T
2390
+ start: u,
2391
+ end: d,
2392
+ targetRowId: T,
2393
+ selectedTaskIds: E
2331
2394
  },
2332
2395
  bubbles: !0,
2333
2396
  composed: !0
@@ -2337,11 +2400,11 @@ var X = class extends e {
2337
2400
  name: e.detail.name,
2338
2401
  start: n,
2339
2402
  end: r,
2340
- currentStart: l,
2341
- currentEnd: u,
2403
+ currentStart: u,
2404
+ currentEnd: d,
2342
2405
  mode: o
2343
- }, c ? this.draggingTaskIds = [...this.selectedTasks] : this.draggingTaskIds = []), c ? this.multiDragDx = i ?? 0 : this.multiDragDx !== 0 && (this.multiDragDx = 0), !c) {
2344
- let e = C >= 0 ? C : null;
2406
+ }, 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) {
2407
+ let e = w >= 0 ? w : null;
2345
2408
  this.dragTargetRowIndex !== e && (this.dragTargetRowIndex = e);
2346
2409
  }
2347
2410
  c ? this.dragOverlayInfo = {
@@ -2349,8 +2412,8 @@ var X = class extends e {
2349
2412
  name: (this.option.locale ?? k).dragOverlay.movingTasks(this.selectedTasks.size),
2350
2413
  start: n,
2351
2414
  end: r,
2352
- currentStart: l,
2353
- currentEnd: u,
2415
+ currentStart: u,
2416
+ currentEnd: d,
2354
2417
  visible: !0,
2355
2418
  clientX: e.detail.x,
2356
2419
  clientY: e.detail.y
@@ -2359,62 +2422,86 @@ var X = class extends e {
2359
2422
  name: e.detail.name,
2360
2423
  start: n,
2361
2424
  end: r,
2362
- currentStart: l,
2363
- currentEnd: u,
2364
- targetRow: C >= 0 ? this.displayRows[C] : void 0,
2425
+ currentStart: u,
2426
+ currentEnd: d,
2427
+ targetRow: w >= 0 ? this.displayRows[w] : void 0,
2365
2428
  visible: !0,
2366
2429
  clientX: e.detail.x,
2367
2430
  clientY: e.detail.y
2368
2431
  }, this.updateDragOverlay();
2369
2432
  return;
2370
2433
  }
2371
- let E = this.draggingTaskIds.length >= 2;
2372
- this.draggingTask = null, this.draggingTaskIds = [], this.multiDragDx = 0, this.dragTargetRowIndex = null, this.dragOverlayInfo && (this.dragOverlayInfo = {
2434
+ let D = this.draggingTaskIds.length >= 2, O = this.multiDragSameRow;
2435
+ this.draggingTask = null, this.draggingTaskIds = [], this.multiDragDx = 0, this.multiDragDy = 0, this.multiDragSameRow = !1, this.dragTargetRowIndex = null, this.dragOverlayInfo && (this.dragOverlayInfo = {
2373
2436
  ...this.dragOverlayInfo,
2374
2437
  visible: !1
2375
2438
  }, this.hideDragOverlay()), this.tooltip &&= {
2376
2439
  ...this.tooltip,
2377
2440
  visible: !1
2378
2441
  };
2379
- let D = -1;
2380
- if (C !== -1) {
2381
- let e = this.displayRows[C];
2382
- D = this.rows.findIndex((t) => t.id === e.id);
2442
+ let A = -1;
2443
+ if (w !== -1) {
2444
+ let e = this.displayRows[w];
2445
+ A = this.rows.findIndex((t) => t.id === e.id);
2383
2446
  }
2384
- if (E && i !== void 0) {
2385
- let e = this.option.calendar.pxPerDay ?? 50, t = this.option.calendar.pxPerMonth, n = this.rows.map((n) => n.tasks.some((e) => this.selectedTasks.has(e.id)) ? {
2386
- ...n,
2387
- tasks: n.tasks.map((n) => {
2388
- if (!this.selectedTasks.has(n.id)) return n;
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);
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)), {
2391
- ...n,
2392
- start: o,
2393
- end: s
2394
- };
2395
- })
2396
- } : n);
2397
- requestAnimationFrame(() => {
2398
- this.rows = n, this.dispatchEvent(new CustomEvent("rows-change", {
2399
- detail: this.rows,
2400
- bubbles: !0,
2401
- composed: !0
2402
- }));
2403
- });
2447
+ if (D && i !== void 0) {
2448
+ let e = this.option.calendar.pxPerDay ?? 50, t = this.option.calendar.pxPerMonth;
2449
+ if (O && A !== -1 && f !== A) {
2450
+ let n = [...this.rows], r = { ...n[f] }, a = { ...n[A] };
2451
+ r.tasks = [...r.tasks], a.tasks = [...a.tasks];
2452
+ let o = [];
2453
+ r.tasks = r.tasks.filter((n) => {
2454
+ if (this.selectedTasks.has(n.id)) {
2455
+ let r = this.getDateX(n.start), a = this.getDateX(n.end), s = N(r + i, this.option.calendar.start, e, t), c = N(a + i, this.option.calendar.start, e, t);
2456
+ 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({
2457
+ ...n,
2458
+ start: s,
2459
+ end: c
2460
+ }), !1;
2461
+ }
2462
+ return !0;
2463
+ }), a.tasks.push(...o), n[f] = r, n[A] = a, requestAnimationFrame(() => {
2464
+ this.rows = n, this.dispatchEvent(new CustomEvent("rows-change", {
2465
+ detail: this.rows,
2466
+ bubbles: !0,
2467
+ composed: !0
2468
+ }));
2469
+ });
2470
+ } else {
2471
+ let n = this.rows.map((n) => n.tasks.some((e) => this.selectedTasks.has(e.id)) ? {
2472
+ ...n,
2473
+ tasks: n.tasks.map((n) => {
2474
+ if (!this.selectedTasks.has(n.id)) return n;
2475
+ 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);
2476
+ 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)), {
2477
+ ...n,
2478
+ start: o,
2479
+ end: s
2480
+ };
2481
+ })
2482
+ } : n);
2483
+ requestAnimationFrame(() => {
2484
+ this.rows = n, this.dispatchEvent(new CustomEvent("rows-change", {
2485
+ detail: this.rows,
2486
+ bubbles: !0,
2487
+ composed: !0
2488
+ }));
2489
+ });
2490
+ }
2404
2491
  return;
2405
2492
  }
2406
2493
  if (o === "copy") {
2407
- if (D !== -1) {
2408
- let e = [...this.rows], t = { ...e[D] };
2494
+ if (A !== -1) {
2495
+ let e = [...this.rows], t = { ...e[A] };
2409
2496
  t.tasks = [...t.tasks];
2410
2497
  let n = `task-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, r = {
2411
- ...f,
2498
+ ...p,
2412
2499
  id: n,
2413
- start: l,
2414
- end: u,
2500
+ start: u,
2501
+ end: d,
2415
2502
  dependencies: []
2416
2503
  };
2417
- t.tasks.push(r), e[D] = t, requestAnimationFrame(() => {
2504
+ t.tasks.push(r), e[A] = t, requestAnimationFrame(() => {
2418
2505
  this.rows = e, this.dispatchEvent(new CustomEvent("rows-change", {
2419
2506
  detail: this.rows,
2420
2507
  bubbles: !0,
@@ -2423,20 +2510,20 @@ var X = class extends e {
2423
2510
  });
2424
2511
  }
2425
2512
  } else {
2426
- let e = [...this.rows], t = { ...e[d] };
2427
- if (t.tasks = [...t.tasks], e[d] = t, D !== -1 && d !== D) {
2428
- let n = { ...e[D] };
2429
- n.tasks = [...n.tasks], e[D] = n;
2430
- let [r] = t.tasks.splice(p, 1);
2513
+ let e = [...this.rows], t = { ...e[f] };
2514
+ if (t.tasks = [...t.tasks], e[f] = t, A !== -1 && f !== A) {
2515
+ let n = { ...e[A] };
2516
+ n.tasks = [...n.tasks], e[A] = n;
2517
+ let [r] = t.tasks.splice(m, 1);
2431
2518
  n.tasks.push({
2432
2519
  ...r,
2433
- start: l,
2434
- end: u
2520
+ start: u,
2521
+ end: d
2435
2522
  });
2436
- } else t.tasks[p] = {
2437
- ...f,
2438
- start: l,
2439
- end: u
2523
+ } else t.tasks[m] = {
2524
+ ...p,
2525
+ start: u,
2526
+ end: d
2440
2527
  };
2441
2528
  requestAnimationFrame(() => {
2442
2529
  this.rows = e, this.dispatchEvent(new CustomEvent("rows-change", {
@@ -3140,6 +3227,8 @@ var X = class extends e {
3140
3227
  .draggingTask="${this.draggingTask}"
3141
3228
  .draggingTaskIds="${this.draggingTaskIds}"
3142
3229
  .multiDragDx="${this.multiDragDx}"
3230
+ .multiDragDy="${this.multiDragDy}"
3231
+ .multiDragSameRow="${this.multiDragSameRow}"
3143
3232
  .theme="${this.theme}"
3144
3233
  .dropPosition="${this.dragOverRowId === e.id ? this.dragOverPosition : null}"
3145
3234
  .externalDragTask="${this.dragPreview?.rowId === e.id ? this.dragPreview : null}"
@@ -3171,6 +3260,6 @@ var X = class extends e {
3171
3260
  B([s({ type: Array })], X.prototype, "rows", void 0), B([s({ type: Object })], X.prototype, "option", void 0), B([s({
3172
3261
  type: String,
3173
3262
  reflect: !0
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);
3263
+ })], 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, "multiDragDy", void 0), B([c()], X.prototype, "multiDragSameRow", 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);
3175
3264
  //#endregion
3176
3265
  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 };
@@ -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`},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`}},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())/(1e3*60*60*24)*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())/(1e3*60*60*24)}var B=(e,t,n)=>{let r=n??j,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=``;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=class extends t.LitElement{constructor(...e){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=>{(e.key===`Control`||e.key===`Alt`)&&this.updateCursor(!0)},this.handleKeyUp=e=>{(e.key===`Control`||e.key===`Alt`)&&this.updateCursor(!1)}}static{this.styles=t.css`
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`},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`}},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())/(1e3*60*60*24)*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())/(1e3*60*60*24)}var B=(e,t,n)=>{let r=n??j,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=``;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=class extends t.LitElement{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._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)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;
@@ -134,8 +134,8 @@
134
134
  transition: opacity 0.15s ease;
135
135
  pointer-events: auto;
136
136
  }
137
- .task-group:hover .connector-left,
138
- .task-group:hover .connector-right {
137
+ .connector-left.show-connector,
138
+ .connector-right.show-connector {
139
139
  opacity: 1;
140
140
  }
141
141
  .connector-left {
@@ -206,7 +206,7 @@
206
206
  filter: brightness(1.08);
207
207
  }
208
208
  }
209
- `}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}))})})}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;let i=e.ctrlKey||e.altKey?`copy`:`grabbing`;this._currentDragCursor=i,t.style.cursor=i,t.setPointerCapture(e.pointerId),n.classList.add(`dragging`);let a=e.clientX,o=e.clientY,s=new Date(this.task.start),c=new Date(this.task.end),l=this.option.snapDuration??1440;this.setupDragEvents(t,e.pointerId,e=>{let i=e.ctrlKey||e.altKey?`copy`:`grabbing`;this._currentDragCursor=i,t.style.cursor=i;let u=e.clientX-a,d=e.clientY-o;r===`y`&&(u=0),(r===`x`||this.multiDragActive)&&(d=0);let f=u;if(this.option.calendar.pxPerMonth){let e=F(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);n.setMonth(n.getMonth()+t),f=this.getX(n)-this.getX(s)}else{let e=this.option.calendar.pxPerDay/1440*l;f=Math.round(u/e)*e}n.style.transform=`translate(${f}px, ${d}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:s,end:c,dx:f,dy:d,isDragging:!0,x:e.clientX,y:e.clientY,mode:t?`copy`:`move`},bubbles:!0,composed:!0}))})},(e,i)=>{if(this._currentDragCursor=null,n.classList.remove(`dragging`),n.style.transform=``,t.style.cursor=``,this._dragAnimationFrame&&=(cancelAnimationFrame(this._dragAnimationFrame),null),e)this.requestUpdate(),this.dispatchEvent(new CustomEvent(`task-update`,{detail:{...this.task,start:s,end:c,dx:0,dy:0,isDragging:!1},bubbles:!0,composed:!0}));else if(i){let e=i.clientX-a,t=e;if(this.option.calendar.pxPerMonth){let n=F(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);i.setMonth(i.getMonth()+r),t=this.getX(i)-this.getX(s)}else{let n=this.option.calendar.pxPerDay/1440*l;t=Math.round(e/n)*n}let n=i.clientY-o;if(r===`y`&&(t=0),(r===`x`||this.multiDragActive)&&(n=0),t===0&&Math.abs(n)<5){this.dispatchEvent(new CustomEvent(`bar-click`,{detail:{task:this.task,event:i,isMultiSelect:i.metaKey||i.ctrlKey},bubbles:!0,composed:!0})),this._wasDragging=!0;return}let u=i.ctrlKey||i.altKey;this._wasDragging=!0,this.multiDragActive||this.dispatchEvent(new CustomEvent(`bar-click`,{detail:{task:this.task,event:i,isMultiSelect:!1},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`task-update`,{detail:{...this.task,start:s,end:c,dx:t,dy:n,isDragging:!1,mode:u?`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`)){let e=this.shadowRoot?.querySelector(`.task-group`);e&&(this.multiDragDx===0?(e.style.transform=``,e.style.opacity=``,e.style.pointerEvents=``):(e.style.transform=`translateX(${this.multiDragDx}px)`,e.style.opacity=`0.6`,e.style.pointerEvents=`none`))}}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));let n=t.getBoundingClientRect();this.dispatchEvent(new CustomEvent(`bar-mouseenter`,{detail:{task:this.task,x:n.left+n.width/2,y:n.top},bubbles:!0,composed:!0}))}onMouseLeave(){this.option.readOnly||(window.removeEventListener(`keydown`,this.handleKeyDown),window.removeEventListener(`keyup`,this.handleKeyUp),this.updateCursor(!1)),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`
209
+ `}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}))})})}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;let i=e.ctrlKey||e.altKey?`copy`:`grabbing`;this._currentDragCursor=i,t.style.cursor=i,t.setPointerCapture(e.pointerId),n.classList.add(`dragging`);let a=e.clientX,o=e.clientY,s=new Date(this.task.start),c=new Date(this.task.end),l=this.option.snapDuration??1440;this.setupDragEvents(t,e.pointerId,e=>{let i=e.ctrlKey||e.altKey?`copy`:`grabbing`;this._currentDragCursor=i,t.style.cursor=i;let u=e.clientX-a,d=e.clientY-o;r===`y`&&(u=0),r===`x`&&(d=0),this.multiDragActive&&!this.multiDragSameRow&&(d=0);let f=u;if(this.option.calendar.pxPerMonth){let e=F(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);n.setMonth(n.getMonth()+t),f=this.getX(n)-this.getX(s)}else{let e=this.option.calendar.pxPerDay/1440*l;f=Math.round(u/e)*e}n.style.transform=`translate(${f}px, ${d}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:s,end:c,dx:f,dy:d,isDragging:!0,x:e.clientX,y:e.clientY,mode:t?`copy`:`move`},bubbles:!0,composed:!0}))})},(e,i)=>{if(this._currentDragCursor=null,n.classList.remove(`dragging`),n.style.transform=``,t.style.cursor=``,this._dragAnimationFrame&&=(cancelAnimationFrame(this._dragAnimationFrame),null),e)this.requestUpdate(),this.dispatchEvent(new CustomEvent(`task-update`,{detail:{...this.task,start:s,end:c,dx:0,dy:0,isDragging:!1},bubbles:!0,composed:!0}));else if(i){let e=i.clientX-a,t=e;if(this.option.calendar.pxPerMonth){let n=F(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);i.setMonth(i.getMonth()+r),t=this.getX(i)-this.getX(s)}else{let n=this.option.calendar.pxPerDay/1440*l;t=Math.round(e/n)*n}let n=i.clientY-o;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:i,isMultiSelect:i.metaKey||i.ctrlKey},bubbles:!0,composed:!0})),this._wasDragging=!0;return}let u=i.ctrlKey||i.altKey;this._wasDragging=!0,this.multiDragActive||this.dispatchEvent(new CustomEvent(`bar-click`,{detail:{task:this.task,event:i,isMultiSelect:!1},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`task-update`,{detail:{...this.task,start:s,end:c,dx:t,dy:n,isDragging:!1,mode:u?`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},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`
210
210
  <div
211
211
  class="task-group"
212
212
  style="
@@ -244,7 +244,7 @@
244
244
  ></div>
245
245
  `}
246
246
  </div>
247
- `}};H([(0,n.property)({type:Object})],U.prototype,`task`,void 0),H([(0,n.property)({type:Object})],U.prototype,`option`,void 0),H([(0,n.property)({type:Number})],U.prototype,`lane`,void 0),H([(0,n.property)({type:Boolean,reflect:!0})],U.prototype,`selected`,void 0),H([(0,n.property)({type:Boolean,reflect:!0})],U.prototype,`focused`,void 0),H([(0,n.property)({type:Number})],U.prototype,`multiDragDx`,void 0),H([(0,n.property)({type:Boolean})],U.prototype,`multiDragActive`,void 0),H([(0,n.property)({type:Boolean,reflect:!0,attribute:`connector-drop-target`})],U.prototype,`connectorDropTarget`,void 0),H([(0,n.property)({type:Boolean,reflect:!0})],U.prototype,`isExporting`,void 0),U=H([(0,n.customElement)(`gantt-bar`)],U);var W=class extends t.LitElement{constructor(...e){super(...e),this.theme=`light`,this.currentTime=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}injectCustomContent(e,t,n){let r=e.querySelector(`.${n}`);if(r&&r.remove(),t instanceof HTMLElement)t.classList.add(n),e.appendChild(t);else if(typeof t==`string`){let r=document.createElement(`span`);r.classList.add(n),r.textContent=t,e.appendChild(r)}}updated(){let e=this.shadowRoot?.querySelector(`.label-placeholder`);if(!e)return;let t=e.querySelector(`.corner-content-root`);if(t&&t.remove(),this.cornerContent){let t=this.cornerContent();t instanceof HTMLElement&&(t.classList.add(`corner-content-root`),e.appendChild(t))}this.injectCalendarCustomContent()}injectCalendarCustomContent(){this.calendarMonthContent&&(this.shadowRoot?.querySelectorAll(`[data-calendar-month]`))?.forEach(e=>{let t=e,n={year:parseInt(t.dataset.calendarMonthYear??`0`,10),month:parseInt(t.dataset.calendarMonth??`0`,10),width:parseFloat(t.dataset.calendarMonthWidth??`0`),defaultLabel:t.dataset.calendarMonthLabel??``},r=this.calendarMonthContent(n);this.injectCustomContent(t,r,`custom-month-content`)}),this.calendarDayContent&&(this.shadowRoot?.querySelectorAll(`[data-calendar-day]`))?.forEach(e=>{let t=e,n=t.dataset.calendarDay??``,r={date:new Date(n),width:parseFloat(t.dataset.calendarDayWidth??`0`),isSaturday:t.dataset.calendarDaySaturday===`true`,isSunday:t.dataset.calendarDaySunday===`true`,isHoliday:t.dataset.calendarDayHoliday===`true`,defaultLabel:t.dataset.calendarDayLabel??``},i=this.calendarDayContent(r);this.injectCustomContent(t,i,`custom-day-content`)}),this.calendarWeekContent&&(this.shadowRoot?.querySelectorAll(`[data-calendar-week]`))?.forEach(e=>{let t=e,n=parseInt(t.dataset.calendarWeek??`0`,10),r=t.dataset.calendarWeekStart??``,i={weekNumber:n,startDate:new Date(r),width:parseFloat(t.dataset.calendarWeekWidth??`0`),defaultLabel:t.dataset.calendarWeekLabel??``},a=this.calendarWeekContent(i);this.injectCustomContent(t,a,`custom-week-content`)}),this.calendarHourContent&&(this.shadowRoot?.querySelectorAll(`[data-calendar-hour]`))?.forEach(e=>{let t=e,n=parseInt(t.dataset.calendarHour??`0`,10),r=parseFloat(t.dataset.calendarHourWidth??`0`),i=t.dataset.calendarHourDate??``,a={hour:n,width:r,date:new Date(i)},o=this.calendarHourContent(a);this.injectCustomContent(t,o,`custom-hour-content`)})}get totalDays(){return z(this.option.calendar.start,this.option.calendar.end)}static{this.styles=t.css`
247
+ `}};H([(0,n.property)({type:Object})],U.prototype,`task`,void 0),H([(0,n.property)({type:Object})],U.prototype,`option`,void 0),H([(0,n.property)({type:Number})],U.prototype,`lane`,void 0),H([(0,n.property)({type:Boolean,reflect:!0})],U.prototype,`selected`,void 0),H([(0,n.property)({type:Boolean,reflect:!0})],U.prototype,`focused`,void 0),H([(0,n.property)({type:Number})],U.prototype,`multiDragDx`,void 0),H([(0,n.property)({type:Number})],U.prototype,`multiDragDy`,void 0),H([(0,n.property)({type:Boolean})],U.prototype,`multiDragActive`,void 0),H([(0,n.property)({type:Boolean})],U.prototype,`multiDragSameRow`,void 0),H([(0,n.property)({type:Boolean,reflect:!0,attribute:`connector-drop-target`})],U.prototype,`connectorDropTarget`,void 0),H([(0,n.property)({type:Boolean,reflect:!0})],U.prototype,`isExporting`,void 0),U=H([(0,n.customElement)(`gantt-bar`)],U);var W=class extends t.LitElement{constructor(...e){super(...e),this.theme=`light`,this.currentTime=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}injectCustomContent(e,t,n){let r=e.querySelector(`.${n}`);if(r&&r.remove(),t instanceof HTMLElement)t.classList.add(n),e.appendChild(t);else if(typeof t==`string`){let r=document.createElement(`span`);r.classList.add(n),r.textContent=t,e.appendChild(r)}}updated(){let e=this.shadowRoot?.querySelector(`.label-placeholder`);if(!e)return;let t=e.querySelector(`.corner-content-root`);if(t&&t.remove(),this.cornerContent){let t=this.cornerContent();t instanceof HTMLElement&&(t.classList.add(`corner-content-root`),e.appendChild(t))}this.injectCalendarCustomContent()}injectCalendarCustomContent(){this.calendarMonthContent&&(this.shadowRoot?.querySelectorAll(`[data-calendar-month]`))?.forEach(e=>{let t=e,n={year:parseInt(t.dataset.calendarMonthYear??`0`,10),month:parseInt(t.dataset.calendarMonth??`0`,10),width:parseFloat(t.dataset.calendarMonthWidth??`0`),defaultLabel:t.dataset.calendarMonthLabel??``},r=this.calendarMonthContent(n);this.injectCustomContent(t,r,`custom-month-content`)}),this.calendarDayContent&&(this.shadowRoot?.querySelectorAll(`[data-calendar-day]`))?.forEach(e=>{let t=e,n=t.dataset.calendarDay??``,r={date:new Date(n),width:parseFloat(t.dataset.calendarDayWidth??`0`),isSaturday:t.dataset.calendarDaySaturday===`true`,isSunday:t.dataset.calendarDaySunday===`true`,isHoliday:t.dataset.calendarDayHoliday===`true`,defaultLabel:t.dataset.calendarDayLabel??``},i=this.calendarDayContent(r);this.injectCustomContent(t,i,`custom-day-content`)}),this.calendarWeekContent&&(this.shadowRoot?.querySelectorAll(`[data-calendar-week]`))?.forEach(e=>{let t=e,n=parseInt(t.dataset.calendarWeek??`0`,10),r=t.dataset.calendarWeekStart??``,i={weekNumber:n,startDate:new Date(r),width:parseFloat(t.dataset.calendarWeekWidth??`0`),defaultLabel:t.dataset.calendarWeekLabel??``},a=this.calendarWeekContent(i);this.injectCustomContent(t,a,`custom-week-content`)}),this.calendarHourContent&&(this.shadowRoot?.querySelectorAll(`[data-calendar-hour]`))?.forEach(e=>{let t=e,n=parseInt(t.dataset.calendarHour??`0`,10),r=parseFloat(t.dataset.calendarHourWidth??`0`),i=t.dataset.calendarHourDate??``,a={hour:n,width:r,date:new Date(i)},o=this.calendarHourContent(a);this.injectCustomContent(t,o,`custom-hour-content`)})}get totalDays(){return z(this.option.calendar.start,this.option.calendar.end)}static{this.styles=t.css`
248
248
  :host {
249
249
  display: flex;
250
250
  width: fit-content;
@@ -552,7 +552,7 @@
552
552
  ${this._cachedCells.map(({width:e,color:n})=>t.html`<div
553
553
  style="width: ${e}px; background-color: ${n}; flex-shrink: 0;"
554
554
  ></div>`)}
555
- `}};H([(0,n.property)({type:Object})],G.prototype,`option`,void 0),H([(0,n.property)({type:String})],G.prototype,`theme`,void 0),H([(0,n.property)({type:String})],G.prototype,`rowId`,void 0),G=H([(0,n.customElement)(`gantt-row-background`)],G);var K=class extends t.LitElement{constructor(...e){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}getDateX(e){return P(e,this.option.calendar.start,this.option.calendar.pxPerDay,this.option.calendar.pxPerMonth)}getMarkerPath(e,t){let n=t/2;switch(e){case`triangle-up`:return`M 0 ${t} L ${n} 0 L ${t} ${t} Z`;case`triangle-down`:return`M 0 0 L ${t} 0 L ${n} ${t} Z`;case`triangle-left`:return`M ${t} 0 L 0 ${n} L ${t} ${t} Z`;case`triangle-right`:return`M 0 0 L ${t} ${n} L 0 ${t} Z`;case`diamond`:return`M ${n} 0 L ${t} ${n} L ${n} ${t} L 0 ${n} Z`;case`square`:return`M 0 0 L ${t} 0 L ${t} ${t} L 0 ${t} Z`;default:return`M 0 ${t} L ${n} 0 L ${t} ${t} Z`}}static{this.styles=t.css`
555
+ `}};H([(0,n.property)({type:Object})],G.prototype,`option`,void 0),H([(0,n.property)({type:String})],G.prototype,`theme`,void 0),H([(0,n.property)({type:String})],G.prototype,`rowId`,void 0),G=H([(0,n.customElement)(`gantt-row-background`)],G);var K=class extends t.LitElement{constructor(...e){super(...e),this.isDragTarget=!1,this.draggingTask=null,this.draggingTaskIds=[],this.multiDragDx=0,this.multiDragDy=0,this.multiDragSameRow=!1,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}getDateX(e){return P(e,this.option.calendar.start,this.option.calendar.pxPerDay,this.option.calendar.pxPerMonth)}getMarkerPath(e,t){let n=t/2;switch(e){case`triangle-up`:return`M 0 ${t} L ${n} 0 L ${t} ${t} Z`;case`triangle-down`:return`M 0 0 L ${t} 0 L ${n} ${t} Z`;case`triangle-left`:return`M ${t} 0 L 0 ${n} L ${t} ${t} Z`;case`triangle-right`:return`M 0 0 L ${t} ${n} L 0 ${t} Z`;case`diamond`:return`M ${n} 0 L ${t} ${n} L ${n} ${t} L 0 ${n} Z`;case`square`:return`M 0 0 L ${t} 0 L ${t} ${t} L 0 ${t} Z`;default:return`M 0 ${t} L ${n} 0 L ${t} ${t} Z`}}estimateMarkerWidth(e,t){let n=e.name?e.name.length*7+4:0;return e.anchor===`center`?t:t+n}getMarkerXRange(e,t){let n=this.getDateX(e.date),r=this.estimateMarkerWidth(e,t),i=e.anchor===`center`,a=e.anchor===`end`,o;if(o=e.anchor===`start`?n:e.anchor===`end`?n-t:n-t/2,i)return{left:o,right:o+t};if(a){let e=r-t;return{left:o-e,right:o+t}}return{left:o,right:o+r}}calculateMarkerLanes(e,t){if(!e.length)return[];let n=e.map(e=>({marker:e,range:this.getMarkerXRange(e,t)})).sort((e,t)=>e.range.left-t.range.left),r=[],i=[];for(let e of n){let t=-1;for(let n=0;n<r.length;n++)if(e.range.left>=r[n]+2){r[n]=e.range.right,t=n;break}t===-1&&(r.push(e.range.right),t=r.length-1),i.push({marker:e.marker,lane:t})}return i}static{this.styles=t.css`
556
556
  :host {
557
557
  display: block;
558
558
  width: fit-content;
@@ -623,29 +623,29 @@
623
623
  height: 100%;
624
624
  pointer-events: none;
625
625
  }
626
- `}handleDragStart(e){if(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}))}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&&(0,t.render)(this.option.customRendering?.rowHeaderContent?this.option.customRendering.rowHeaderContent(this.row):this.row.name,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=a*(s+c)+c;this.style.height=`${l}px`;let u=``,d=null,f=this.option.calendar.start.getTime(),p=this.option.calendar.end.getTime(),m=this.option.calendar.pxPerDay,h=this.option.calendar.pxPerMonth??0;if(!this._cachedMonthGridLines||f!==this._cachedMonthGridStartTime||p!==this._cachedMonthGridEndTime||m!==this._cachedMonthGridPxPerDay||h!==this._cachedMonthGridPxPerMonth){this._cachedMonthGridStartTime=f,this._cachedMonthGridEndTime=p,this._cachedMonthGridPxPerDay=m,this._cachedMonthGridPxPerMonth=h;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(d=this._cachedMonthGridLines,this.option.calendar.showMonthsRow)u=``;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)/(1440*60*1e3)*i,c=s%t,l=s%r,d=s===0?`0px 0`:`${-s}px 0`,f=c===0?`0px 0`:`${-c}px 0`,p=l===0?`0px 0`:`${-l}px 0`,m=[`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)`],h=[`${i}px 100%`,`${t}px 100%`,`${r}px 100%`],g=[d,f,p];u=`
627
- background-image: ${m.join(`, `)};
628
- background-size: ${h.join(`, `)};
629
- background-position: ${g.join(`, `)};
630
- `}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)/(1440*60*1e3)*t,i=r===0?`0px 0`:`${-r}px 0`;u=`
626
+ `}handleDragStart(e){if(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}))}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&&(0,t.render)(this.option.customRendering?.rowHeaderContent?this.option.customRendering.rowHeaderContent(this.row):this.row.name,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)/(1440*60*1e3)*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=`
627
+ background-image: ${p.join(`, `)};
628
+ background-size: ${m.join(`, `)};
629
+ background-position: ${h.join(`, `)};
630
+ `}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)/(1440*60*1e3)*t,i=r===0?`0px 0`:`${-r}px 0`;g=`
631
631
  background-image: linear-gradient(90deg, transparent ${t-1}px, ${e.gridLine} ${t-1}px);
632
632
  background-size: ${t}px 100%;
633
633
  background-position: ${i};
634
- `}let g=this.option.enableRowReordering&&!this.option.readOnly,_=this.row.visible===!1,v=this.isSelected?e.rowSelectedHeader:_?e.rowHiddenBg:e.rowHeaderBg,y=v.includes(`gradient`)?`background: ${v};`:`background-color: ${v};`;return t.html`
634
+ `}let S=this.option.enableRowReordering&&!this.option.readOnly,C=this.row.visible===!1,w=this.isSelected?e.rowSelectedHeader:C?e.rowHiddenBg:e.rowHeaderBg,T=w.includes(`gradient`)?`background: ${w};`:`background-color: ${w};`;return t.html`
635
635
  <style>
636
636
  :host {
637
637
  color: ${e.text};
638
- background-color: ${_?e.rowHiddenBg:`transparent`};
638
+ background-color: ${C?e.rowHiddenBg:`transparent`};
639
639
  }
640
640
 
641
641
  .row-header {
642
- cursor: ${g?`grab`:`pointer`};
642
+ cursor: ${S?`grab`:`pointer`};
643
643
  border-right: 1px solid ${e.border};
644
644
  border-bottom: 1px solid ${e.border};
645
645
  box-sizing: border-box;
646
646
  }
647
647
  .row-header:active {
648
- cursor: ${g?`grabbing`:`pointer`};
648
+ cursor: ${S?`grabbing`:`pointer`};
649
649
  }
650
650
  .bars-container {
651
651
  border-bottom: 1px solid ${e.border};
@@ -676,9 +676,9 @@
676
676
  <div class="row-container ${this.dropPosition?`drop-${this.dropPosition}`:``}">
677
677
  <div
678
678
  class="row-header"
679
- style="width: ${this.option.rowHeader?.width??150}px; ${y}"
680
- draggable="${g?`true`:`false`}"
681
- @dragstart="${g?this.handleDragStart:void 0}"
679
+ style="width: ${this.option.rowHeader?.width??150}px; ${T}"
680
+ draggable="${S?`true`:`false`}"
681
+ @dragstart="${S?this.handleDragStart:void 0}"
682
682
  @click="${this.handleHeaderClick}"
683
683
  @dblclick="${this.handleHeaderDblClick}"
684
684
  @contextmenu="${this.handleHeaderContextMenu}"
@@ -691,10 +691,10 @@
691
691
  <div class="bars-container" style="width: ${(()=>{if(this.option.calendar.pxPerMonth!==void 0){let e=this.option.calendar.end;return this.getDateX(new Date(e.getFullYear(),e.getMonth()+1,1))}return this.getDateX(this.option.calendar.end)})()}px">
692
692
  ${this.option.calendar.showRowBackground!==!1&&!this.option.calendar.showMonthsRow?t.html`<gantt-row-background .option="${this.option}" .theme="${this.theme}" .rowId="${this.row.id}" /> `:``}
693
693
  ${this.isSelected?t.html`<div class="selected-row-overlay"></div>`:``}
694
- ${u?t.html`<div class="grid-background" style="${u}"></div>`:``}
695
- ${d?d.map(n=>{let r;return r=n.isYearBoundary?e.yearGridLine||e.monthGridLine||e.gridLine:this.option.calendar.showMonthsRow||this.option.calendar.showDays===!1&&!this.option.calendar.showWeeks?e.gridLine:e.monthGridLine||e.gridLine,t.html`<div style="position: absolute; top: 0; left: ${n.left-1}px; width: 1px; height: 100%; background-color: ${r}; pointer-events: none; z-index: 1;"></div>`}):``}
696
- ${_?t.html`<div class="hidden-row-overlay" style="background: ${e.rowHiddenBg};"></div>`:``}
697
- ${(0,i.repeat)(r,e=>e.id,e=>{let n=this.draggingTask?.id===e.id,r=!n&&this.draggingTaskIds.length>=2&&this.draggingTaskIds.includes(e.id),i=n?{...e,start:this.draggingTask.start,end:this.draggingTask.end}:e,a=this.selectedTaskIds.includes(e.id),o=r?this.multiDragDx:0,s=n&&this.draggingTaskIds.length>=2;return t.html`
694
+ ${g?t.html`<div class="grid-background" style="${g}"></div>`:``}
695
+ ${_?_.map(n=>{let r;return r=n.isYearBoundary?e.yearGridLine||e.monthGridLine||e.gridLine:this.option.calendar.showMonthsRow||this.option.calendar.showDays===!1&&!this.option.calendar.showWeeks?e.gridLine:e.monthGridLine||e.gridLine,t.html`<div style="position: absolute; top: 0; left: ${n.left-1}px; width: 1px; height: 100%; background-color: ${r}; pointer-events: none; z-index: 1;"></div>`}):``}
696
+ ${C?t.html`<div class="hidden-row-overlay" style="background: ${e.rowHiddenBg};"></div>`:``}
697
+ ${(0,i.repeat)(r,e=>e.id,e=>{let n=this.draggingTask?.id===e.id,r=!n&&this.draggingTaskIds.length>=2&&this.draggingTaskIds.includes(e.id),i=n?{...e,start:this.draggingTask.start,end:this.draggingTask.end}:e,a=this.selectedTaskIds.includes(e.id),o=r?this.multiDragDx:0,s=r?this.multiDragDy:0,c=n&&this.draggingTaskIds.length>=2;return t.html`
698
698
  <gantt-bar
699
699
  .task="${i}"
700
700
  .option="${this.option}"
@@ -702,20 +702,22 @@
702
702
  .selected="${a}"
703
703
  .focused="${this.focusedTaskId===e.id}"
704
704
  .multiDragDx="${o}"
705
- .multiDragActive="${s}"
705
+ .multiDragDy="${s}"
706
+ .multiDragActive="${c}"
707
+ .multiDragSameRow="${this.multiDragSameRow}"
706
708
  .isExporting="${this.isExporting}"
707
709
  />
708
710
  `})}
709
- ${(this.row.markers??[]).map(e=>{let n=Math.min(s,12),r=this.getDateX(e.date),i=e.color??`#ef4444`,a=e.anchor===`center`,o=a?l/2-n:(l-n)/2,c=e.anchor===`start`?r:e.anchor===`end`?r-n:r-n/2,u=e.anchor===`end`;return t.html`
711
+ ${f.map(({marker:e,lane:n})=>{let r=this.getDateX(e.date),i=e.color??`#ef4444`,a=e.anchor===`center`,o=(a?m/2-u:(m-u)/2)+n*d,s=e.anchor===`start`?r:e.anchor===`end`?r-u:r-u/2,c=e.anchor===`end`;return t.html`
710
712
  <div
711
713
  class="marker-wrapper"
712
714
  style="
713
715
  position: absolute;
714
- left: ${c}px;
716
+ left: ${s}px;
715
717
  top: ${o}px;
716
718
  z-index: 2;
717
719
  display: flex;
718
- ${a?`flex-direction: column; align-items: center; width: ${n}px; overflow: visible;`:`align-items: center; ${u?`flex-direction: row-reverse;`:``}`}
720
+ ${a?`flex-direction: column; align-items: center; width: ${u}px; overflow: visible;`:`align-items: center; ${c?`flex-direction: row-reverse;`:``}`}
719
721
  pointer-events: auto;
720
722
  cursor: default;
721
723
  white-space: nowrap;
@@ -724,16 +726,16 @@
724
726
  >
725
727
  <svg
726
728
  class="marker-icon"
727
- width="${n}"
728
- height="${n}"
729
- viewBox="0 0 ${n} ${n}"
729
+ width="${u}"
730
+ height="${u}"
731
+ viewBox="0 0 ${u} ${u}"
730
732
  style="
731
733
  flex-shrink: 0;
732
734
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
733
735
  ${e.style??``}
734
736
  "
735
737
  >
736
- <path d="${this.getMarkerPath(e.type,n)}" fill="${i}" />
738
+ <path d="${this.getMarkerPath(e.type,u)}" fill="${i}" />
737
739
  </svg>
738
740
  ${e.name?t.html`<span style="
739
741
  font-size: 10px;
@@ -745,7 +747,7 @@
745
747
  `})}
746
748
  </div>
747
749
  </div>
748
- `}};H([(0,n.property)({type:Object})],K.prototype,`row`,void 0),H([(0,n.property)({type:Object})],K.prototype,`option`,void 0),H([(0,n.property)({type:Boolean})],K.prototype,`isDragTarget`,void 0),H([(0,n.property)({type:Object})],K.prototype,`draggingTask`,void 0),H([(0,n.property)({type:Array})],K.prototype,`draggingTaskIds`,void 0),H([(0,n.property)({type:Number})],K.prototype,`multiDragDx`,void 0),H([(0,n.property)({type:Object})],K.prototype,`externalDragTask`,void 0),H([(0,n.property)({type:String})],K.prototype,`theme`,void 0),H([(0,n.property)({type:Boolean,reflect:!0})],K.prototype,`isSelected`,void 0),H([(0,n.property)({type:String})],K.prototype,`dropPosition`,void 0),H([(0,n.property)({type:Array})],K.prototype,`selectedTaskIds`,void 0),H([(0,n.property)({type:String})],K.prototype,`focusedTaskId`,void 0),H([(0,n.property)({type:Boolean,reflect:!0})],K.prototype,`isExporting`,void 0),K=H([(0,n.customElement)(`gantt-row`)],K);function q(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(` `)}else{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 J=t.css`
750
+ `}};H([(0,n.property)({type:Object})],K.prototype,`row`,void 0),H([(0,n.property)({type:Object})],K.prototype,`option`,void 0),H([(0,n.property)({type:Boolean})],K.prototype,`isDragTarget`,void 0),H([(0,n.property)({type:Object})],K.prototype,`draggingTask`,void 0),H([(0,n.property)({type:Array})],K.prototype,`draggingTaskIds`,void 0),H([(0,n.property)({type:Number})],K.prototype,`multiDragDx`,void 0),H([(0,n.property)({type:Number})],K.prototype,`multiDragDy`,void 0),H([(0,n.property)({type:Boolean})],K.prototype,`multiDragSameRow`,void 0),H([(0,n.property)({type:Object})],K.prototype,`externalDragTask`,void 0),H([(0,n.property)({type:String})],K.prototype,`theme`,void 0),H([(0,n.property)({type:Boolean,reflect:!0})],K.prototype,`isSelected`,void 0),H([(0,n.property)({type:String})],K.prototype,`dropPosition`,void 0),H([(0,n.property)({type:Array})],K.prototype,`selectedTaskIds`,void 0),H([(0,n.property)({type:String})],K.prototype,`focusedTaskId`,void 0),H([(0,n.property)({type:Boolean,reflect:!0})],K.prototype,`isExporting`,void 0),K=H([(0,n.customElement)(`gantt-row`)],K);function q(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(` `)}else{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 J=t.css`
749
751
  :host {
750
752
  display: block;
751
753
  width: 100%;
@@ -924,7 +926,7 @@
924
926
  .header-resizer.resizing {
925
927
  background-color: ${n.border};
926
928
  }
927
- `}function X(e,t){let n=document.createElement(`a`);n.href=e,n.download=t,n.click()}async function Z(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=Math.floor(c*r),a=Math.floor(t*r),o=f.height,s=f.width,l=o-a,u=i-a;if(u>0){let e=Math.ceil(l/u),t=o+(e-1)*a,n=document.createElement(`canvas`);n.width=s,n.height=t;let c=n.getContext(`2d`);if(c){c.drawImage(f,0,0,s,i,0,0,s,i);let l=i,p=i;for(let t=1;t<e;t++){c.drawImage(f,0,0,s,a,0,p,s,a),p+=a;let e=o-l,t=Math.min(u,e);c.drawImage(f,0,l,s,t,0,p,s,t),l+=t,p+=t}f=n,d=t/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&&X(e,`${r}.png`),e}}var Q=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.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._layoutCache=null,this.resizeObserver=null,this._cachedSelectedTaskIds=[],this._cachedSelectedTasksSize=-1,this._cachedCurrentOption=null,this._lastOptionRef=null,this._lastLabelWidth=-1,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.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)}static{this.styles=J}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)}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)}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)),(e.has(`rows`)||e.has(`option`)||e.has(`currentRowHeaderWidth`))&&(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`
929
+ `}function X(e,t){let n=document.createElement(`a`);n.href=e,n.download=t,n.click()}async function Z(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=Math.floor(c*r),a=Math.floor(t*r),o=f.height,s=f.width,l=o-a,u=i-a;if(u>0){let e=Math.ceil(l/u),t=o+(e-1)*a,n=document.createElement(`canvas`);n.width=s,n.height=t;let c=n.getContext(`2d`);if(c){c.drawImage(f,0,0,s,i,0,0,s,i);let l=i,p=i;for(let t=1;t<e;t++){c.drawImage(f,0,0,s,a,0,p,s,a),p+=a;let e=o-l,t=Math.min(u,e);c.drawImage(f,0,l,s,t,0,p,s,t),l+=t,p+=t}f=n,d=t/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&&X(e,`${r}.png`),e}}var Q=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._layoutCache=null,this.resizeObserver=null,this._cachedSelectedTaskIds=[],this._cachedSelectedTasksSize=-1,this._cachedCurrentOption=null,this._lastOptionRef=null,this._lastLabelWidth=-1,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.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)}static{this.styles=J}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)}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)}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)),(e.has(`rows`)||e.has(`option`)||e.has(`currentRowHeaderWidth`))&&(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`
928
930
  <div style="font-weight: bold;">${this.tooltip.task.name}</div>
929
931
  <div class="tooltip-row">
930
932
  ${n.yearMonthFormat(this.tooltip.task.start)} - ${n.yearMonthFormat(r)}
@@ -946,7 +948,7 @@
946
948
  (${B(this.dragOverlayInfo.currentStart,this.dragOverlayInfo.currentEnd,this.option.locale)})
947
949
  </div>
948
950
  ${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>`:``}
949
- `,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.option.calendar.pxPerDay??50,this.option.calendar.pxPerMonth)}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)}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);c&&(s=0);let l=n,u=r;if(i!==void 0){let e=this.option.calendar.pxPerDay??50,t=this.option.calendar.pxPerMonth,a=this.getDateX(n),o=this.getDateX(r);l=F(a+i,this.option.calendar.start,e,t),u=F(o+i,this.option.calendar.start,e,t)}(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));let d=-1,f,p=-1;if(this.rows.find((e,n)=>{let r=e.tasks.findIndex(e=>e.id===t);return r===-1?!1:(d=n,f=e.tasks[r],p=r,!0)}),d===-1||!f)return;let{layouts:m}=this.calculateLayout(),h=this.displayRows.findIndex(e=>e.id===this.rows[d].id);if(h===-1)return;let g=m[h].top,{tasksWithLanes:_}=I(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;for(let e=0;e<m.length;e++){let t=m[e];if(S>=t.top&&S<t.top+t.height){C=e;break}}let w=C===-1?void 0:this.displayRows[C].id,T=c?[...this.selectedTasks]:void 0;if(this.dispatchEvent(new CustomEvent(`task-update`,{detail:{...e.detail,dy:s,start:l,end:u,targetRowId:w,selectedTaskIds:T},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:l,currentEnd:u,mode:o},c?this.draggingTaskIds=[...this.selectedTasks]:this.draggingTaskIds=[]),c?this.multiDragDx=i??0:this.multiDragDx!==0&&(this.multiDragDx=0),!c){let e=C>=0?C: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:l,currentEnd:u,visible:!0,clientX:e.detail.x,clientY:e.detail.y}:this.dragOverlayInfo={id:t,name:e.detail.name,start:n,end:r,currentStart:l,currentEnd:u,targetRow:C>=0?this.displayRows[C]:void 0,visible:!0,clientX:e.detail.x,clientY:e.detail.y},this.updateDragOverlay();return}let E=this.draggingTaskIds.length>=2;this.draggingTask=null,this.draggingTaskIds=[],this.multiDragDx=0,this.dragTargetRowIndex=null,this.dragOverlayInfo&&(this.dragOverlayInfo={...this.dragOverlayInfo,visible:!1},this.hideDragOverlay()),this.tooltip&&={...this.tooltip,visible:!1};let D=-1;if(C!==-1){let e=this.displayRows[C];D=this.rows.findIndex(t=>t.id===e.id)}if(E&&i!==void 0){let e=this.option.calendar.pxPerDay??50,t=this.option.calendar.pxPerMonth,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(D!==-1){let e=[...this.rows],t={...e[D]};t.tasks=[...t.tasks];let n=`task-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,r={...f,id:n,start:l,end:u,dependencies:[]};t.tasks.push(r),e[D]=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[d]};if(t.tasks=[...t.tasks],e[d]=t,D!==-1&&d!==D){let n={...e[D]};n.tasks=[...n.tasks],e[D]=n;let[r]=t.tasks.splice(p,1);n.tasks.push({...r,start:l,end:u})}else t.tasks[p]={...f,start:l,end:u};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}},t):this.tooltip={...e.detail,visible:!0}}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.option.calendar.pxPerDay??50,c=this.option.calendar.pxPerMonth,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.option.calendar.pxPerDay??50,p=this.option.calendar.pxPerMonth,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.option.calendar.pxPerDay??50,o=this.option.calendar.pxPerMonth,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.option.calendar.pxPerDay??50,f=this.option.calendar.pxPerMonth,p=F(u,this.option.calendar.start,d,f);return{rowId:l,date:p}}async exportImage(e=`png`,t={}){this.isExporting=!0,await this.updateComplete,await new Promise(e=>requestAnimationFrame(e));try{return await Z(this,e,t)}finally{this.isExporting=!1,await this.updateComplete}}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._cachedCurrentOption={...this.option,rowHeader:{...this.option.rowHeader,width:o}},this._lastOptionRef=this.option,this._lastLabelWidth=o);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;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,S=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=q(r,o,s,c,d,h,S,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+S: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">
951
+ `,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.option.calendar.pxPerDay??50,this.option.calendar.pxPerMonth)}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.option.calendar.pxPerDay??50,t=this.option.calendar.pxPerMonth,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.option.calendar.pxPerDay??50,t=this.option.calendar.pxPerMonth;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}},t):this.tooltip={...e.detail,visible:!0}}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.option.calendar.pxPerDay??50,c=this.option.calendar.pxPerMonth,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.option.calendar.pxPerDay??50,p=this.option.calendar.pxPerMonth,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.option.calendar.pxPerDay??50,o=this.option.calendar.pxPerMonth,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.option.calendar.pxPerDay??50,f=this.option.calendar.pxPerMonth,p=F(u,this.option.calendar.start,d,f);return{rowId:l,date:p}}async exportImage(e=`png`,t={}){this.isExporting=!0,await this.updateComplete,await new Promise(e=>requestAnimationFrame(e));try{return await Z(this,e,t)}finally{this.isExporting=!1,await this.updateComplete}}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._cachedCurrentOption={...this.option,rowHeader:{...this.option.rowHeader,width:o}},this._lastOptionRef=this.option,this._lastLabelWidth=o);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;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,S=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=q(r,o,s,c,d,h,S,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+S: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">
950
952
  ${_?``:t.svg`<path class="dependency-hit-area" d="${p}" @click="${t=>{t.stopPropagation(),this.handleDependencyLineClick(t,e,i)}}" />`}
951
953
  <path class="dependency-line" d="${f}" />
952
954
  ${v?t.svg`<path class="dependency-line dependency-arrow-line" d="${m}" marker-end="url(#dependency-arrowhead)" />`:``}
@@ -1089,6 +1091,8 @@
1089
1091
  .draggingTask="${this.draggingTask}"
1090
1092
  .draggingTaskIds="${this.draggingTaskIds}"
1091
1093
  .multiDragDx="${this.multiDragDx}"
1094
+ .multiDragDy="${this.multiDragDy}"
1095
+ .multiDragSameRow="${this.multiDragSameRow}"
1092
1096
  .theme="${this.theme}"
1093
1097
  .dropPosition="${this.dragOverRowId===e.id?this.dragOverPosition:null}"
1094
1098
  .externalDragTask="${this.dragPreview?.rowId===e.id?this.dragPreview:null}"
@@ -1113,4 +1117,4 @@
1113
1117
  style="top: ${this.tooltip.y}px; left: ${this.tooltip.x}px;"
1114
1118
  />
1115
1119
  `:``}
1116
- `}};H([(0,n.property)({type:Array})],Q.prototype,`rows`,void 0),H([(0,n.property)({type:Object})],Q.prototype,`option`,void 0),H([(0,n.property)({type:String,reflect:!0})],Q.prototype,`theme`,void 0),H([(0,n.property)({type:Array})],Q.prototype,`selectedRowIds`,void 0),H([(0,n.property)({type:Array})],Q.prototype,`selectedTaskIds`,void 0),H([(0,n.property)({attribute:!1})],Q.prototype,`externalDraggingTask`,void 0),H([(0,n.state)()],Q.prototype,`selectedRows`,void 0),H([(0,n.state)()],Q.prototype,`selectedTasks`,void 0),H([(0,n.state)()],Q.prototype,`lastClickedRowId`,void 0),H([(0,n.state)()],Q.prototype,`virtualScrollTop`,void 0),H([(0,n.state)()],Q.prototype,`dragTargetRowIndex`,void 0),H([(0,n.state)()],Q.prototype,`draggingTask`,void 0),H([(0,n.state)()],Q.prototype,`draggingTaskIds`,void 0),H([(0,n.state)()],Q.prototype,`multiDragDx`,void 0),H([(0,n.state)()],Q.prototype,`viewportHeight`,void 0),H([(0,n.state)()],Q.prototype,`calendarHeight`,void 0),H([(0,n.state)()],Q.prototype,`tooltip`,void 0),H([(0,n.state)()],Q.prototype,`dragOverRowId`,void 0),H([(0,n.state)()],Q.prototype,`dragOverPosition`,void 0),H([(0,n.state)()],Q.prototype,`currentTime`,void 0),H([(0,n.state)()],Q.prototype,`dragPreview`,void 0),H([(0,n.state)()],Q.prototype,`currentRowHeaderWidth`,void 0),H([(0,n.state)()],Q.prototype,`isResizingHeader`,void 0),H([(0,n.state)()],Q.prototype,`hoveredMilestoneId`,void 0),H([(0,n.state)()],Q.prototype,`cursorLineX`,void 0),H([(0,n.state)()],Q.prototype,`connectorDrag`,void 0),H([(0,n.state)()],Q.prototype,`isExporting`,void 0),H([(0,n.state)()],Q.prototype,`focusedTaskId`,void 0),H([(0,n.state)()],Q.prototype,`focusedRowId`,void 0),Q=H([(0,n.customElement)(`gantt-chart`)],Q),e.ALL_BAR_PATTERNS=g,Object.defineProperty(e,`GanttBarElement`,{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,`GanttCalendarElement`,{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,`GanttChartElement`,{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,`GanttRowElement`,{enumerable:!0,get:function(){return K}}),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.enLocale=M,e.getPatternStyle=A,e.jaLocale=j});
1120
+ `}};H([(0,n.property)({type:Array})],Q.prototype,`rows`,void 0),H([(0,n.property)({type:Object})],Q.prototype,`option`,void 0),H([(0,n.property)({type:String,reflect:!0})],Q.prototype,`theme`,void 0),H([(0,n.property)({type:Array})],Q.prototype,`selectedRowIds`,void 0),H([(0,n.property)({type:Array})],Q.prototype,`selectedTaskIds`,void 0),H([(0,n.property)({attribute:!1})],Q.prototype,`externalDraggingTask`,void 0),H([(0,n.state)()],Q.prototype,`selectedRows`,void 0),H([(0,n.state)()],Q.prototype,`selectedTasks`,void 0),H([(0,n.state)()],Q.prototype,`lastClickedRowId`,void 0),H([(0,n.state)()],Q.prototype,`virtualScrollTop`,void 0),H([(0,n.state)()],Q.prototype,`dragTargetRowIndex`,void 0),H([(0,n.state)()],Q.prototype,`draggingTask`,void 0),H([(0,n.state)()],Q.prototype,`draggingTaskIds`,void 0),H([(0,n.state)()],Q.prototype,`multiDragDx`,void 0),H([(0,n.state)()],Q.prototype,`multiDragDy`,void 0),H([(0,n.state)()],Q.prototype,`multiDragSameRow`,void 0),H([(0,n.state)()],Q.prototype,`viewportHeight`,void 0),H([(0,n.state)()],Q.prototype,`calendarHeight`,void 0),H([(0,n.state)()],Q.prototype,`tooltip`,void 0),H([(0,n.state)()],Q.prototype,`dragOverRowId`,void 0),H([(0,n.state)()],Q.prototype,`dragOverPosition`,void 0),H([(0,n.state)()],Q.prototype,`currentTime`,void 0),H([(0,n.state)()],Q.prototype,`dragPreview`,void 0),H([(0,n.state)()],Q.prototype,`currentRowHeaderWidth`,void 0),H([(0,n.state)()],Q.prototype,`isResizingHeader`,void 0),H([(0,n.state)()],Q.prototype,`hoveredMilestoneId`,void 0),H([(0,n.state)()],Q.prototype,`cursorLineX`,void 0),H([(0,n.state)()],Q.prototype,`connectorDrag`,void 0),H([(0,n.state)()],Q.prototype,`isExporting`,void 0),H([(0,n.state)()],Q.prototype,`focusedTaskId`,void 0),H([(0,n.state)()],Q.prototype,`focusedRowId`,void 0),Q=H([(0,n.customElement)(`gantt-chart`)],Q),e.ALL_BAR_PATTERNS=g,Object.defineProperty(e,`GanttBarElement`,{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,`GanttCalendarElement`,{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,`GanttChartElement`,{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,`GanttRowElement`,{enumerable:!0,get:function(){return K}}),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.enLocale=M,e.getPatternStyle=A,e.jaLocale=j});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mogura/moguchart-core",
3
- "version": "0.5.3",
3
+ "version": "0.6.0",
4
4
  "description": "A lightweight, framework-agnostic Gantt chart Web Component built with Lit. Works with Vue, React, Angular, Svelte, and more.",
5
5
  "license": "MIT",
6
6
  "author": "Murakami Hiroyuki",
@@ -41,6 +41,18 @@
41
41
  "require": "./dist/moguchart-core.umd.js"
42
42
  }
43
43
  },
44
+ "scripts": {
45
+ "dev": "vite",
46
+ "build": "vite build && pnpm exec tsc -p tsconfig.build.json",
47
+ "build:demo": "BUILD_MODE=demo vite build && pnpm exec tsc",
48
+ "preview": "vite preview",
49
+ "prepublishOnly": "pnpm run build",
50
+ "test": "vitest",
51
+ "test:run": "vitest run",
52
+ "test:ui": "vitest --ui",
53
+ "test:coverage": "vitest run --coverage",
54
+ "refresh:packages": "rm -rf node_modules pnpm-lock.yaml && pnpm i"
55
+ },
44
56
  "devDependencies": {
45
57
  "@holiday-jp/holiday_jp": "^2.5.1",
46
58
  "@types/lodash-es": "^4.17.12",
@@ -60,16 +72,5 @@
60
72
  "html2canvas-pro": "^2.0.2",
61
73
  "jspdf": "^4.2.1",
62
74
  "lodash-es": "^4.17.21"
63
- },
64
- "scripts": {
65
- "dev": "vite",
66
- "build": "vite build && pnpm exec tsc -p tsconfig.build.json",
67
- "build:demo": "BUILD_MODE=demo vite build && pnpm exec tsc",
68
- "preview": "vite preview",
69
- "test": "vitest",
70
- "test:run": "vitest run",
71
- "test:ui": "vitest --ui",
72
- "test:coverage": "vitest run --coverage",
73
- "refresh:packages": "rm -rf node_modules pnpm-lock.yaml && pnpm i"
74
75
  }
75
76
  }