@xpyjs/gantt-core 0.0.1-rc.1 → 0.0.1-rc.2
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 +41 -29
- package/dist/x-gantt.umd.cjs +2 -2
- package/package.json +1 -1
- package/types/store/DataManager.d.ts +4 -0
package/dist/x-gantt.js
CHANGED
|
@@ -3,10 +3,10 @@ var Yt = (f, t, e) => t in f ? Pt(f, t, { enumerable: !0, configurable: !0, writ
|
|
|
3
3
|
var a = (f, t, e) => Yt(f, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import G from "dayjs";
|
|
5
5
|
import { default as ai } from "dayjs";
|
|
6
|
-
import { merge as rt, isArray as X, isString as
|
|
6
|
+
import { merge as rt, isArray as X, isString as V, 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.
|
|
9
|
-
function
|
|
8
|
+
const Ct = "0.0.1-rc.2";
|
|
9
|
+
function Vt() {
|
|
10
10
|
const f = "#eca710", t = "#ffffff", e = "#e7209e", i = "#ffffff", s = "#1c42e8";
|
|
11
11
|
[
|
|
12
12
|
" __ __ _____ _____ _____ _____ _____ ",
|
|
@@ -316,7 +316,7 @@ const lt = () => ({
|
|
|
316
316
|
opacity: 0.1
|
|
317
317
|
}
|
|
318
318
|
});
|
|
319
|
-
class
|
|
319
|
+
class Kt {
|
|
320
320
|
constructor() {
|
|
321
321
|
a(this, "options", lt());
|
|
322
322
|
}
|
|
@@ -354,7 +354,7 @@ class Vt {
|
|
|
354
354
|
var s;
|
|
355
355
|
let e = "";
|
|
356
356
|
const i = (s = this.options.row) == null ? void 0 : s.backgroundColor;
|
|
357
|
-
return
|
|
357
|
+
return V(i) ? e = i : X(i) && i.length > 0 ? e = i[t.level] : j(i) && (e = i(t.getEmitData())), e;
|
|
358
358
|
}
|
|
359
359
|
unpackFunc(t, e) {
|
|
360
360
|
return j(t) ? t(e.getEmitData()) : t;
|
|
@@ -413,7 +413,7 @@ function $(f, t, e) {
|
|
|
413
413
|
}
|
|
414
414
|
function nt(f, t) {
|
|
415
415
|
let e = f;
|
|
416
|
-
return
|
|
416
|
+
return V(e) && (/%$/.test(e) ? e = t * parseFloat(e) / 100 : e = parseFloat(e)), isNaN(e) ? 0 : e;
|
|
417
417
|
}
|
|
418
418
|
function ct(f, t) {
|
|
419
419
|
if (t === 0)
|
|
@@ -532,7 +532,7 @@ class mt {
|
|
|
532
532
|
this.store = t, this.event = e, this.fields = this.store.getOptionManager().getOptions().fields, this.id = n || i[this.fields.id] || Q(), this.data = i, this.name = i[this.fields.name] || "", this.type = i[this.fields.type] || "task", this.updateMode(), this.progress = i[this.fields.progress], this.expanded = this.store.getOptionManager().getOptions().expand.show ? this.store.getOptionManager().getOptions().expand.enabled : !0, this.children = [], this.level = s && s.level !== void 0 ? s.level + 1 : 0, this.parent = s, this.flatIndex = 0, this.store.updateTime(this.startTime, this.endTime);
|
|
533
533
|
}
|
|
534
534
|
getField(t) {
|
|
535
|
-
if (!t ||
|
|
535
|
+
if (!t || V(t) && t.trim() === "")
|
|
536
536
|
return;
|
|
537
537
|
if (!t.includes("."))
|
|
538
538
|
return this.data[t];
|
|
@@ -844,6 +844,18 @@ class Jt {
|
|
|
844
844
|
};
|
|
845
845
|
return this.tasks.forEach((s) => i(s)), this.visibleTasksCache = t, this.isDirty = !1, t;
|
|
846
846
|
}
|
|
847
|
+
/**
|
|
848
|
+
* 获取一个任务是否可展示
|
|
849
|
+
*/
|
|
850
|
+
isTaskVisible(t) {
|
|
851
|
+
let e = t.parent;
|
|
852
|
+
for (; e; ) {
|
|
853
|
+
if (this.collapsedTaskIds.has(e.id))
|
|
854
|
+
return !1;
|
|
855
|
+
e = e.parent;
|
|
856
|
+
}
|
|
857
|
+
return !0;
|
|
858
|
+
}
|
|
847
859
|
/**
|
|
848
860
|
* 获取可展示任务数量
|
|
849
861
|
*/
|
|
@@ -2807,7 +2819,7 @@ class Oe {
|
|
|
2807
2819
|
week: s.cellWidth,
|
|
2808
2820
|
month: s.cellWidth,
|
|
2809
2821
|
quarter: s.cellWidth
|
|
2810
|
-
} :
|
|
2822
|
+
} : V(s.cellWidth) ? this.cellWidth = Z(
|
|
2811
2823
|
ut()[s.cellWidth] || ut().normal
|
|
2812
2824
|
) : Et(s.cellWidth) && (this.cellWidth = Object.assign(this.cellWidth, s.cellWidth))), this.headerCellFormat = s.headerCellFormat, this.headerGroupFormat = s.headerGroupFormat;
|
|
2813
2825
|
}
|
|
@@ -2887,7 +2899,7 @@ class Oe {
|
|
|
2887
2899
|
const i = this.headerGroupFormat(t.toDate(), this.unit);
|
|
2888
2900
|
if (i) return i;
|
|
2889
2901
|
}
|
|
2890
|
-
if (
|
|
2902
|
+
if (V(this.headerGroupFormat))
|
|
2891
2903
|
return t.format(this.headerGroupFormat);
|
|
2892
2904
|
switch (this.getGroupUnit()) {
|
|
2893
2905
|
case "month":
|
|
@@ -2907,7 +2919,7 @@ class Oe {
|
|
|
2907
2919
|
const i = this.headerCellFormat(t.toDate(), this.unit);
|
|
2908
2920
|
if (i) return i;
|
|
2909
2921
|
}
|
|
2910
|
-
if (
|
|
2922
|
+
if (V(this.headerCellFormat))
|
|
2911
2923
|
return t.format(this.headerCellFormat);
|
|
2912
2924
|
switch (this.getChildUnit()) {
|
|
2913
2925
|
case "hour":
|
|
@@ -2956,7 +2968,7 @@ class De {
|
|
|
2956
2968
|
const i = yt(e, ["data"]), s = e == null ? void 0 : e.data;
|
|
2957
2969
|
if (s && !X(s))
|
|
2958
2970
|
throw O.exception("Data should be a array.");
|
|
2959
|
-
this.optionManager = new
|
|
2971
|
+
this.optionManager = new Kt(), this.optionManager.setOptions(i), i.locale && vt(i.locale), this.timeAxis = new Oe(), this.timeAxis.init(this.optionManager.getOptions()), this.columnManager = new ee(this.context), i.table && i.table.columns && this.columnManager.init(i.table.columns), this.dataManager = new Jt(this, this.context.event), s && this.dataManager.setData(s, !0), (n = e == null ? void 0 : e.baselines) != null && n.data && this.dataManager.setBaselines(e.baselines.data), this.linkManager = new ft(this, this.context.event), X((o = e == null ? void 0 : e.links) == null ? void 0 : o.data) && this.linkManager.setLinks(e.links.data, !0), this.linkManager.setCycleDetection(((r = e == null ? void 0 : e.links) == null ? void 0 : r.enableCycleDetection) ?? !0);
|
|
2960
2972
|
}
|
|
2961
2973
|
getOptionManager() {
|
|
2962
2974
|
return this.optionManager;
|
|
@@ -4419,23 +4431,23 @@ class We {
|
|
|
4419
4431
|
fontFamily: zt
|
|
4420
4432
|
}), at = it.measureSize(F);
|
|
4421
4433
|
it.width(at.width);
|
|
4422
|
-
const
|
|
4434
|
+
const K = { x: 0, y: 0 };
|
|
4423
4435
|
switch (z) {
|
|
4424
4436
|
case "top-left":
|
|
4425
|
-
|
|
4437
|
+
K.x = -(12 + at.width), K.y = -8;
|
|
4426
4438
|
break;
|
|
4427
4439
|
case "bottom-left":
|
|
4428
|
-
|
|
4440
|
+
K.x = -(12 + at.width), K.y = 10;
|
|
4429
4441
|
break;
|
|
4430
4442
|
case "bottom-right":
|
|
4431
|
-
|
|
4443
|
+
K.x = 12, K.y = 10;
|
|
4432
4444
|
break;
|
|
4433
4445
|
case "top-right":
|
|
4434
4446
|
default:
|
|
4435
|
-
|
|
4447
|
+
K.x = 12, K.y = -8;
|
|
4436
4448
|
break;
|
|
4437
4449
|
}
|
|
4438
|
-
it.setAttrs(
|
|
4450
|
+
it.setAttrs(K), this.slider.add(it);
|
|
4439
4451
|
}
|
|
4440
4452
|
}
|
|
4441
4453
|
this.sliderType = "milestone";
|
|
@@ -5163,7 +5175,7 @@ class Fe {
|
|
|
5163
5175
|
if (!this.selectedRect || this.selectedRowId === null) return;
|
|
5164
5176
|
const e = this.rowsCache.get(`chart-row-${this.selectedRowId}`);
|
|
5165
5177
|
if (e)
|
|
5166
|
-
if (this.
|
|
5178
|
+
if (this.context.store.getDataManager().getVisibleTasks().find((i) => i.id === e.task.id)) {
|
|
5167
5179
|
const s = e.task.flatIndex * this.context.getOptions().row.height + this.context.getOptions().header.height;
|
|
5168
5180
|
this.selectedRect.y(s + this.offsetY), this.layer.batchDraw();
|
|
5169
5181
|
} else
|
|
@@ -5862,7 +5874,7 @@ class Ye {
|
|
|
5862
5874
|
l.isMilestone() && (u += i / 2);
|
|
5863
5875
|
const y = s + i * l.flatIndex;
|
|
5864
5876
|
let x = !0, T = !0, b = this.context.store.getOptionManager().unpackFunc(this.context.getOptions().links.create.from, l);
|
|
5865
|
-
if (ht(b) ? x = T = b :
|
|
5877
|
+
if (ht(b) ? x = T = b : V(b) && (x = b === "S", T = b === "F"), x) {
|
|
5866
5878
|
const w = new S.Circle({
|
|
5867
5879
|
id: `point-${l.id}-left`,
|
|
5868
5880
|
x: m - u,
|
|
@@ -5936,7 +5948,7 @@ class Ye {
|
|
|
5936
5948
|
);
|
|
5937
5949
|
return;
|
|
5938
5950
|
}
|
|
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)
|
|
5951
|
+
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
5952
|
return;
|
|
5941
5953
|
const h = Math.max(0, -this.offsetX), c = h + this.width;
|
|
5942
5954
|
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)) {
|
|
@@ -6321,7 +6333,7 @@ class Ye {
|
|
|
6321
6333
|
j(r) && (r = r(
|
|
6322
6334
|
t.getEmitData(),
|
|
6323
6335
|
this.context.store.getDataManager().getTaskById(e).getEmitData()
|
|
6324
|
-
)), ht(r) ? n = o = r :
|
|
6336
|
+
)), ht(r) ? n = o = r : V(r) && (n = r === "S", o = r === "F");
|
|
6325
6337
|
const h = this.validateChain(t.id, e, i, s);
|
|
6326
6338
|
return {
|
|
6327
6339
|
allowLeft: n && h.ok,
|
|
@@ -6337,7 +6349,7 @@ class Ye {
|
|
|
6337
6349
|
j(r) && (r = r(
|
|
6338
6350
|
t.getEmitData(),
|
|
6339
6351
|
this.context.store.getDataManager().getTaskById(e).getEmitData()
|
|
6340
|
-
)), ht(r) ? n = o = r :
|
|
6352
|
+
)), ht(r) ? n = o = r : V(r) && (n = r === "S", o = r === "F");
|
|
6341
6353
|
const h = this.validateChain(e, t.id, i, s);
|
|
6342
6354
|
return {
|
|
6343
6355
|
allowLeft: n && h.ok,
|
|
@@ -6581,7 +6593,7 @@ class Ue {
|
|
|
6581
6593
|
this.indicatorGroup.add(p);
|
|
6582
6594
|
let u = `${gt(i.startDiff)}${i.unit} ${m}`;
|
|
6583
6595
|
const y = s.compare.indicator[m].text;
|
|
6584
|
-
j(y) ? u = y(i.startDiff, { ...t.getEmitData(), baseline: e }) :
|
|
6596
|
+
j(y) ? u = y(i.startDiff, { ...t.getEmitData(), baseline: e }) : V(y) && (u = y);
|
|
6585
6597
|
const x = new S.Text({
|
|
6586
6598
|
y: l - n.fontSize / 2,
|
|
6587
6599
|
text: u,
|
|
@@ -6605,7 +6617,7 @@ class Ue {
|
|
|
6605
6617
|
this.indicatorGroup.add(p);
|
|
6606
6618
|
let u = `${gt(i.endDiff)}${i.unit} ${m}`;
|
|
6607
6619
|
const y = s.compare.indicator[m].text;
|
|
6608
|
-
j(y) ? u = y(i.endDiff, { ...t.getEmitData(), baseline: e }) :
|
|
6620
|
+
j(y) ? u = y(i.endDiff, { ...t.getEmitData(), baseline: e }) : V(y) && (u = y);
|
|
6609
6621
|
const x = new S.Text({
|
|
6610
6622
|
x: d + n.size + 5,
|
|
6611
6623
|
y: l - n.fontSize / 2,
|
|
@@ -6679,8 +6691,8 @@ class Xe {
|
|
|
6679
6691
|
this.headerLayer.destroy(), this.gridGroup.destroy(), this.bodyLayer.destroy(), this.todayLayer.destroy(), this.holidayGroup.destroy(), this.flagGroup.destroy(), this.weekendGroup.destroy(), this.linkGroup.destroy(), this.baselineGroup.destroy(), this.axisLayer.destroy(), this.bgLayer.destroy(), this.stage.destroy();
|
|
6680
6692
|
}
|
|
6681
6693
|
}
|
|
6682
|
-
const
|
|
6683
|
-
class
|
|
6694
|
+
const Ve = '<svg style="transition: all 0.3s" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><g fill="none" fill-rule="evenodd"><path d="M24 0v24H0V0zM12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.019-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z"/><path fill="currentColor" d="M8.293 12.707a1 1 0 0 1 0-1.414l5.657-5.657a1 1 0 1 1 1.414 1.414L10.414 12l4.95 4.95a1 1 0 0 1-1.414 1.414z"/></g></svg>';
|
|
6695
|
+
class Ke {
|
|
6684
6696
|
constructor(t, e) {
|
|
6685
6697
|
a(this, "line");
|
|
6686
6698
|
a(this, "initialX", 0);
|
|
@@ -6690,7 +6702,7 @@ class Ve {
|
|
|
6690
6702
|
"border-left-color",
|
|
6691
6703
|
this.root.store.getOptionManager().getOptions().border.color,
|
|
6692
6704
|
"important"
|
|
6693
|
-
), this.line.style.cursor = "col-resize", this.collapseButton = document.createElement("div"), this.collapseButton.className = "x-gantt-collapse-button", this.collapseButton.style.position = "absolute", this.collapseButton.style.top = "50%", this.collapseButton.style.left = "0", this.collapseButton.style.transform = "translateY(-50%)", this.collapseButton.style.cursor = "pointer", this.collapseButton.style.width = "16px", this.collapseButton.style.height = "30px", this.collapseButton.style.backgroundColor = "#fff", this.collapseButton.style.borderRadius = "0 6px 6px 0", this.collapseButton.style.boxShadow = "0 0 2px rgba(0, 0, 0, 0.2)", this.collapseButton.style.display = "flex", this.collapseButton.style.alignItems = "center", this.collapseButton.style.justifyContent = "center", this.collapseButton.innerHTML =
|
|
6705
|
+
), this.line.style.cursor = "col-resize", this.collapseButton = document.createElement("div"), this.collapseButton.className = "x-gantt-collapse-button", this.collapseButton.style.position = "absolute", this.collapseButton.style.top = "50%", this.collapseButton.style.left = "0", this.collapseButton.style.transform = "translateY(-50%)", this.collapseButton.style.cursor = "pointer", this.collapseButton.style.width = "16px", this.collapseButton.style.height = "30px", this.collapseButton.style.backgroundColor = "#fff", this.collapseButton.style.borderRadius = "0 6px 6px 0", this.collapseButton.style.boxShadow = "0 0 2px rgba(0, 0, 0, 0.2)", this.collapseButton.style.display = "flex", this.collapseButton.style.alignItems = "center", this.collapseButton.style.justifyContent = "center", this.collapseButton.innerHTML = Ve, this.collapseButton.addEventListener("click", (i) => {
|
|
6694
6706
|
i.stopPropagation(), this.root.store.getColumnManager().collapse();
|
|
6695
6707
|
}), this.line.appendChild(this.collapseButton), this.container.appendChild(this.line), this.addDragEvents();
|
|
6696
6708
|
}
|
|
@@ -7008,7 +7020,7 @@ class Qe {
|
|
|
7008
7020
|
a(this, "handleColumnWidthChange", () => {
|
|
7009
7021
|
this.table.updateWidth(), this.updateSize();
|
|
7010
7022
|
});
|
|
7011
|
-
this.context = t, this.container = e, this.rootElement = document.createElement("div"), this.rootElement.id = `x-gantt-${this._id}`, this.rootElement.className = "x-gantt", this.rootElement.style.overflow = "hidden", this.rootElement.style.display = "flex", this.rootElement.style.position = "relative", this.container.appendChild(this.rootElement), this.tableContainer = document.createElement("div"), this.tableContainer.className = "x-gantt-table", this.rootElement.appendChild(this.tableContainer), new je(this.context, this.container), this.middleLine = new
|
|
7023
|
+
this.context = t, this.container = e, this.rootElement = document.createElement("div"), this.rootElement.id = `x-gantt-${this._id}`, this.rootElement.className = "x-gantt", this.rootElement.style.overflow = "hidden", this.rootElement.style.display = "flex", this.rootElement.style.position = "relative", this.container.appendChild(this.rootElement), this.tableContainer = document.createElement("div"), this.tableContainer.className = "x-gantt-table", this.rootElement.appendChild(this.tableContainer), new je(this.context, this.container), this.middleLine = new Ke(this.context, this.rootElement), this.chartContainer = document.createElement("div"), this.chartContainer.className = "x-gantt-chart", this.rootElement.appendChild(this.chartContainer), this.table = new He(this.context, this.tableContainer), this.chart = new Xe(this.context, this.chartContainer), this.scrollbar = new _e(
|
|
7012
7024
|
this.context,
|
|
7013
7025
|
this.rootElement,
|
|
7014
7026
|
this.context.store.getOptionManager().getOptions().scrollbar || {}
|
|
@@ -7591,7 +7603,7 @@ class si {
|
|
|
7591
7603
|
return this.context.store.getDataManager().getVisibleSize();
|
|
7592
7604
|
}
|
|
7593
7605
|
}
|
|
7594
|
-
|
|
7606
|
+
Vt();
|
|
7595
7607
|
const ni = Ct;
|
|
7596
7608
|
export {
|
|
7597
7609
|
si as XGantt,
|