@xpyjs/gantt-core 0.0.1-rc.1 → 0.0.1-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/x-gantt.js +68 -47
- package/dist/x-gantt.umd.cjs +2 -2
- package/package.json +1 -1
- package/types/store/DataManager.d.ts +6 -0
package/dist/x-gantt.js
CHANGED
|
@@ -5,7 +5,7 @@ import G from "dayjs";
|
|
|
5
5
|
import { default as ai } from "dayjs";
|
|
6
6
|
import { merge as rt, isArray as X, isString as K, isFunction as j, cloneDeep as Z, isObject as Et, isNumber as Ut, omit as yt, throttle as wt, isBoolean as ht, debounce as Xt } from "lodash-es";
|
|
7
7
|
import S from "konva";
|
|
8
|
-
const Ct = "0.0.1-rc.
|
|
8
|
+
const Ct = "0.0.1-rc.3";
|
|
9
9
|
function Kt() {
|
|
10
10
|
const f = "#eca710", t = "#ffffff", e = "#e7209e", i = "#ffffff", s = "#1c42e8";
|
|
11
11
|
[
|
|
@@ -548,8 +548,8 @@ class mt {
|
|
|
548
548
|
}
|
|
549
549
|
/** 切换展示模式时,需要调整时间 */
|
|
550
550
|
updateMode() {
|
|
551
|
-
let t = !1;
|
|
552
|
-
return this.data[this.fields.startTime] && (!this.startTime || !this.startTime.isSame(G(this.data[this.fields.startTime]))) && (this.startTime = G(this.data[this.fields.startTime]), t = !0), this.data[this.fields.endTime] && (!this.endTime || !this.endTime.isSame(G(this.data[this.fields.endTime]))) && (this.endTime = G(this.data[this.fields.endTime]), t = !0), this.startTime && this.endTime && this.duration === 0 && (this.duration = this.endTime.diff(this.startTime)), this.isMilestone() && (!this.endTime || !this.endTime.isSame(this.startTime)) && (this.endTime = this.startTime, t = !0), t;
|
|
551
|
+
let t = !1, e = !1;
|
|
552
|
+
return this.data[this.fields.startTime] && (!this.startTime || !this.startTime.isSame(G(this.data[this.fields.startTime]))) && (this.startTime = G(this.data[this.fields.startTime]), t = !0, e = !0), this.data[this.fields.endTime] && (!this.endTime || !this.endTime.isSame(G(this.data[this.fields.endTime]))) && (this.endTime = G(this.data[this.fields.endTime]), t = !0, e = !0), e && this.store.updateTime(this.startTime, this.endTime), this.startTime && this.endTime && this.duration === 0 && (this.duration = this.endTime.diff(this.startTime)), this.isMilestone() && (!this.endTime || !this.endTime.isSame(this.startTime)) && (this.endTime = this.startTime, t = !0), t;
|
|
553
553
|
}
|
|
554
554
|
updateData(t) {
|
|
555
555
|
this.data = t;
|
|
@@ -686,40 +686,38 @@ class Jt {
|
|
|
686
686
|
* 初始化任务
|
|
687
687
|
*/
|
|
688
688
|
initTasks(t = !1) {
|
|
689
|
-
|
|
689
|
+
this.dataLevel = 0, this.tasks = [], this.taskMap.clear(), this.collapsedTaskIds.clear(), this.rawData.forEach((e) => {
|
|
690
690
|
this.tasks.push(this.createTask(e));
|
|
691
|
-
})
|
|
691
|
+
});
|
|
692
692
|
}
|
|
693
|
-
createTask(t, e) {
|
|
694
|
-
const
|
|
695
|
-
return Array.isArray(t[
|
|
696
|
-
(
|
|
697
|
-
)), this.taskMap.set(
|
|
693
|
+
createTask(t, e, i = !0) {
|
|
694
|
+
const s = this.store.getOptionManager().getOptions().fields, n = new mt(this.store, this.event, t, e);
|
|
695
|
+
return i && Array.isArray(t[s.children]) && (n.children = t[s.children].map(
|
|
696
|
+
(o) => this.createTask(o, n)
|
|
697
|
+
)), this.taskMap.set(n.id, n), this.dataLevel = Math.max(this.dataLevel, n.level), n;
|
|
698
698
|
}
|
|
699
699
|
updateTask(t, e, i) {
|
|
700
700
|
let s = 0;
|
|
701
701
|
for (; s < t.length; ) {
|
|
702
702
|
const n = t[s], o = e[s];
|
|
703
703
|
if (n && !o) {
|
|
704
|
-
const
|
|
705
|
-
e.push(
|
|
706
|
-
} else !n && o ?
|
|
707
|
-
|
|
708
|
-
|
|
704
|
+
const h = this.createTask(n, i, !1);
|
|
705
|
+
e.push(h), this.dataLevel = Math.max(this.dataLevel, h.level);
|
|
706
|
+
} else !n && o ? e.splice(s, 1) : n && o && (n[this.store.getOptionManager().getOptions().fields.id] === o.id ? (o.updateData(n), this.taskMap.set(o.id, o), this.dataLevel = Math.max(this.dataLevel, o.level)) : (e[s] = this.createTask(n, o.parent, !1), this.dataLevel = Math.max(this.dataLevel, e[s].level)));
|
|
707
|
+
const r = n[this.store.getOptionManager().getOptions().fields.children];
|
|
708
|
+
if (r)
|
|
709
709
|
if (o && o.children)
|
|
710
710
|
this.updateTask(r, o.children, o);
|
|
711
711
|
else {
|
|
712
712
|
const h = r.map(
|
|
713
|
-
(c) => this.createTask(c, e[s])
|
|
713
|
+
(c) => this.createTask(c, e[s], !1)
|
|
714
714
|
);
|
|
715
715
|
e[s].children = h;
|
|
716
716
|
}
|
|
717
|
-
|
|
717
|
+
else o && o.children && (o.children = []);
|
|
718
718
|
s++;
|
|
719
719
|
}
|
|
720
|
-
e.length >= s && e.splice(s)
|
|
721
|
-
this.taskMap.delete(o.id);
|
|
722
|
-
});
|
|
720
|
+
e.length >= s && e.splice(s);
|
|
723
721
|
}
|
|
724
722
|
/**
|
|
725
723
|
* 获取源数据
|
|
@@ -733,6 +731,10 @@ class Jt {
|
|
|
733
731
|
getTasks(t = !0) {
|
|
734
732
|
return t ? this.tasks : Array.from(this.taskMap.values());
|
|
735
733
|
}
|
|
734
|
+
/** 获取数据规模 */
|
|
735
|
+
getDataSize() {
|
|
736
|
+
return this.taskMap.size;
|
|
737
|
+
}
|
|
736
738
|
/**
|
|
737
739
|
* 通过 ID 获取任务
|
|
738
740
|
*/
|
|
@@ -844,6 +846,18 @@ class Jt {
|
|
|
844
846
|
};
|
|
845
847
|
return this.tasks.forEach((s) => i(s)), this.visibleTasksCache = t, this.isDirty = !1, t;
|
|
846
848
|
}
|
|
849
|
+
/**
|
|
850
|
+
* 获取一个任务是否可展示
|
|
851
|
+
*/
|
|
852
|
+
isTaskVisible(t) {
|
|
853
|
+
let e = t.parent;
|
|
854
|
+
for (; e; ) {
|
|
855
|
+
if (this.collapsedTaskIds.has(e.id))
|
|
856
|
+
return !1;
|
|
857
|
+
e = e.parent;
|
|
858
|
+
}
|
|
859
|
+
return !0;
|
|
860
|
+
}
|
|
847
861
|
/**
|
|
848
862
|
* 获取可展示任务数量
|
|
849
863
|
*/
|
|
@@ -5086,20 +5100,21 @@ class Fe {
|
|
|
5086
5100
|
* 高亮指定行
|
|
5087
5101
|
*/
|
|
5088
5102
|
highlightRow(t) {
|
|
5089
|
-
if (this.highlightedRowId === t) return;
|
|
5090
|
-
this.highlightedRowId = t;
|
|
5091
|
-
const e = this.rowsCache.get(`chart-row-${t}`);
|
|
5092
|
-
if (!e) return;
|
|
5103
|
+
if (this.highlightedRowId === t || (this.highlightedRowId = t, !this.rowsCache.get(`chart-row-${t}`))) return;
|
|
5093
5104
|
this.highlightRect && this.highlightRect.destroy();
|
|
5094
|
-
const
|
|
5095
|
-
|
|
5096
|
-
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5105
|
+
const i = this.context.store.getDataManager().getTaskById(t);
|
|
5106
|
+
if (i) {
|
|
5107
|
+
const n = i.flatIndex * this.context.getOptions().row.height + this.context.getOptions().header.height;
|
|
5108
|
+
if (this.selectedRowId === t) return;
|
|
5109
|
+
this.highlightRect = new S.Rect({
|
|
5110
|
+
x: 0,
|
|
5111
|
+
y: n + this.offsetY,
|
|
5112
|
+
width: this.width,
|
|
5113
|
+
height: this.context.getOptions().row.height,
|
|
5114
|
+
fill: B(this.context.getOptions().row.hover.backgroundColor).alpha(this.context.getOptions().row.hover.opacity).toHex(),
|
|
5115
|
+
name: "highlight-rect"
|
|
5116
|
+
}), this.layer.add(this.highlightRect), this.highlightRect.moveToBottom(), this.layer.batchDraw();
|
|
5117
|
+
}
|
|
5103
5118
|
}
|
|
5104
5119
|
/**
|
|
5105
5120
|
* 取消行高亮
|
|
@@ -5120,8 +5135,13 @@ class Fe {
|
|
|
5120
5135
|
if (t)
|
|
5121
5136
|
this.highlightRect.y(this.highlightRect.y() + t);
|
|
5122
5137
|
else {
|
|
5123
|
-
const
|
|
5124
|
-
|
|
5138
|
+
const i = this.context.store.getDataManager().getTaskById(e.task.id);
|
|
5139
|
+
if (!i) {
|
|
5140
|
+
this.clearHighlight();
|
|
5141
|
+
return;
|
|
5142
|
+
}
|
|
5143
|
+
const n = i.flatIndex * this.context.getOptions().row.height + this.context.getOptions().header.height;
|
|
5144
|
+
this.highlightRect.y(n + this.offsetY);
|
|
5125
5145
|
}
|
|
5126
5146
|
this.layer.batchDraw();
|
|
5127
5147
|
}
|
|
@@ -5135,15 +5155,15 @@ class Fe {
|
|
|
5135
5155
|
* 选中指定行
|
|
5136
5156
|
*/
|
|
5137
5157
|
selectRow(t) {
|
|
5138
|
-
var
|
|
5139
|
-
this.selectedRowId = t;
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
const
|
|
5158
|
+
var o;
|
|
5159
|
+
if (this.selectedRowId = t, !this.rowsCache.get(`chart-row-${t}`)) return;
|
|
5160
|
+
this.selectedRect && this.selectedRect.destroy(), this.selectedRowId === this.highlightedRowId && ((o = this.highlightRect) == null || o.fill("transparent"));
|
|
5161
|
+
const i = this.context.store.getDataManager().getTaskById(t);
|
|
5162
|
+
if (!i) return;
|
|
5163
|
+
const n = i.flatIndex * this.context.getOptions().row.height + this.context.getOptions().header.height;
|
|
5144
5164
|
this.selectedRect = new S.Rect({
|
|
5145
5165
|
x: 0,
|
|
5146
|
-
y:
|
|
5166
|
+
y: n + this.offsetY,
|
|
5147
5167
|
width: this.width,
|
|
5148
5168
|
height: this.context.getOptions().row.height,
|
|
5149
5169
|
fill: B(this.context.getOptions().row.select.backgroundColor).alpha(this.context.getOptions().row.select.opacity).toHex(),
|
|
@@ -5163,7 +5183,7 @@ class Fe {
|
|
|
5163
5183
|
if (!this.selectedRect || this.selectedRowId === null) return;
|
|
5164
5184
|
const e = this.rowsCache.get(`chart-row-${this.selectedRowId}`);
|
|
5165
5185
|
if (e)
|
|
5166
|
-
if (this.
|
|
5186
|
+
if (this.context.store.getDataManager().getTaskById(e.task.id)) {
|
|
5167
5187
|
const s = e.task.flatIndex * this.context.getOptions().row.height + this.context.getOptions().header.height;
|
|
5168
5188
|
this.selectedRect.y(s + this.offsetY), this.layer.batchDraw();
|
|
5169
5189
|
} else
|
|
@@ -5921,22 +5941,23 @@ class Ye {
|
|
|
5921
5941
|
const i = Q();
|
|
5922
5942
|
e.forEach((s) => {
|
|
5923
5943
|
var g, d, l, m, p, u, y, x;
|
|
5944
|
+
if (s.valid === !1) return;
|
|
5924
5945
|
const n = this.createId(s), o = this.context.store.getDataManager().getTaskById(s.from), r = this.context.store.getDataManager().getTaskById(s.to);
|
|
5925
5946
|
if (!o) {
|
|
5926
5947
|
O.warn(
|
|
5927
5948
|
`No corresponding FROM task [${s.from}] was found for the link. Info:`,
|
|
5928
5949
|
s
|
|
5929
|
-
);
|
|
5950
|
+
), s.valid = !1;
|
|
5930
5951
|
return;
|
|
5931
5952
|
}
|
|
5932
5953
|
if (!r) {
|
|
5933
5954
|
O.warn(
|
|
5934
5955
|
`No corresponding TO task [${s.to}] was found for the link. Info:`,
|
|
5935
5956
|
s
|
|
5936
|
-
);
|
|
5957
|
+
), s.valid = !1;
|
|
5937
5958
|
return;
|
|
5938
5959
|
}
|
|
5939
|
-
if (o.flatIndex < this.tasks[0].flatIndex && r.flatIndex < this.tasks[0].flatIndex || o.flatIndex > this.tasks[this.tasks.length - 1].flatIndex && r.flatIndex > this.tasks[this.tasks.length - 1].flatIndex)
|
|
5960
|
+
if (!this.context.store.getDataManager().isTaskVisible(o) || !this.context.store.getDataManager().isTaskVisible(r) || o.flatIndex < this.tasks[0].flatIndex && r.flatIndex < this.tasks[0].flatIndex || o.flatIndex > this.tasks[this.tasks.length - 1].flatIndex && r.flatIndex > this.tasks[this.tasks.length - 1].flatIndex)
|
|
5940
5961
|
return;
|
|
5941
5962
|
const h = Math.max(0, -this.offsetX), c = h + this.width;
|
|
5942
5963
|
if (!(this.context.store.getTimeAxis().getTimeLeft(((g = s.type) == null ? void 0 : g[0]) === "S" ? o.startTime : o.endTime) < h && this.context.store.getTimeAxis().getTimeLeft(((d = s.type) == null ? void 0 : d[1]) === "F" ? r.endTime : r.startTime) < h) && !(this.context.store.getTimeAxis().getTimeLeft(((l = s.type) == null ? void 0 : l[0]) === "S" ? o.startTime : o.endTime) > c && this.context.store.getTimeAxis().getTimeLeft(((m = s.type) == null ? void 0 : m[1]) === "F" ? r.endTime : r.startTime) > c) && this.context.store.getOptionManager().unpackFunc(this.context.getOptions().bar.show, o) && this.context.store.getOptionManager().unpackFunc(this.context.getOptions().bar.show, r)) {
|
|
@@ -7588,7 +7609,7 @@ class si {
|
|
|
7588
7609
|
* 获取当前数据量总数。该数量为所有数据展开后的数据条数
|
|
7589
7610
|
*/
|
|
7590
7611
|
getDataSize() {
|
|
7591
|
-
return this.context.store.getDataManager().
|
|
7612
|
+
return this.context.store.getDataManager().getDataSize();
|
|
7592
7613
|
}
|
|
7593
7614
|
}
|
|
7594
7615
|
Kt();
|