@taskctrl/canvas-timeline 0.1.0 → 0.1.1
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/CanvasTimeline.d.ts +3 -0
- package/dist/canvas/CanvasManager.d.ts +23 -0
- package/dist/canvas/DrawHelpers.d.ts +6 -0
- package/dist/canvas/GridLayer.d.ts +5 -0
- package/dist/canvas/ItemsLayer.d.ts +8 -0
- package/dist/canvas/OverlayLayer.d.ts +20 -0
- package/dist/canvas-timeline.cjs.js +2 -0
- package/dist/canvas-timeline.cjs.js.map +1 -0
- package/dist/canvas-timeline.es.js +1316 -0
- package/dist/canvas-timeline.es.js.map +1 -0
- package/dist/core/HitTest.d.ts +7 -0
- package/dist/core/IntervalTree.d.ts +7 -0
- package/dist/core/LayoutEngine.d.ts +15 -0
- package/dist/core/ViewState.d.ts +40 -0
- package/dist/dom/CustomHeader.d.ts +9 -0
- package/dist/dom/CustomMarker.d.ts +13 -0
- package/dist/dom/DateHeader.d.ts +20 -0
- package/dist/dom/Sidebar.d.ts +14 -0
- package/dist/dom/SidebarHeader.d.ts +13 -0
- package/dist/dom/TimelineHeaders.d.ts +18 -0
- package/dist/dom/TodayMarker.d.ts +15 -0
- package/dist/index.d.ts +9 -0
- package/dist/interaction/InteractionHandler.d.ts +35 -0
- package/dist/interaction/ScrollHandler.d.ts +9 -0
- package/dist/interaction/ZoomHandler.d.ts +10 -0
- package/dist/types.d.ts +149 -0
- package/package.json +3 -2
|
@@ -0,0 +1,1316 @@
|
|
|
1
|
+
import { jsx as Z, jsxs as je, Fragment as Ft } from "react/jsx-runtime";
|
|
2
|
+
import ie, { useRef as L, useCallback as $, useEffect as re, forwardRef as tr, useMemo as Q, useState as Ye, useImperativeHandle as rr } from "react";
|
|
3
|
+
import { flushSync as ir } from "react-dom";
|
|
4
|
+
import ne from "dayjs";
|
|
5
|
+
const be = {
|
|
6
|
+
primary: "#269bf7",
|
|
7
|
+
trainColors: {},
|
|
8
|
+
status: { red: "#EF5350", yellow: "#FBBF24", green: "#31c48d" },
|
|
9
|
+
grid: { line: "#E5E5E5", rowAlt: "#F7F7F7", weekend: "rgba(0,0,0,0.03)" },
|
|
10
|
+
item: { radius: 3, text: "#374151", selectedRing: "#a3a3a3" },
|
|
11
|
+
marker: { today: "#FD7171", milestone: "#3B82F6", cursor: "#269bf7" },
|
|
12
|
+
sidebar: { bg: "#F9FAFB", border: "#E5E7EB", text: "#6c737f" },
|
|
13
|
+
header: { bg: "#F9FAFB", border: "#E5E7EB", text: "#6c737f" }
|
|
14
|
+
};
|
|
15
|
+
class rt {
|
|
16
|
+
constructor(e) {
|
|
17
|
+
Object.defineProperty(this, "visibleTimeStart", {
|
|
18
|
+
enumerable: !0,
|
|
19
|
+
configurable: !0,
|
|
20
|
+
writable: !0,
|
|
21
|
+
value: void 0
|
|
22
|
+
}), Object.defineProperty(this, "visibleTimeEnd", {
|
|
23
|
+
enumerable: !0,
|
|
24
|
+
configurable: !0,
|
|
25
|
+
writable: !0,
|
|
26
|
+
value: void 0
|
|
27
|
+
}), Object.defineProperty(this, "canvasWidth", {
|
|
28
|
+
enumerable: !0,
|
|
29
|
+
configurable: !0,
|
|
30
|
+
writable: !0,
|
|
31
|
+
value: void 0
|
|
32
|
+
}), Object.defineProperty(this, "canvasHeight", {
|
|
33
|
+
enumerable: !0,
|
|
34
|
+
configurable: !0,
|
|
35
|
+
writable: !0,
|
|
36
|
+
value: void 0
|
|
37
|
+
}), Object.defineProperty(this, "sidebarWidth", {
|
|
38
|
+
enumerable: !0,
|
|
39
|
+
configurable: !0,
|
|
40
|
+
writable: !0,
|
|
41
|
+
value: void 0
|
|
42
|
+
}), Object.defineProperty(this, "lineHeight", {
|
|
43
|
+
enumerable: !0,
|
|
44
|
+
configurable: !0,
|
|
45
|
+
writable: !0,
|
|
46
|
+
value: void 0
|
|
47
|
+
}), Object.defineProperty(this, "groupCount", {
|
|
48
|
+
enumerable: !0,
|
|
49
|
+
configurable: !0,
|
|
50
|
+
writable: !0,
|
|
51
|
+
value: void 0
|
|
52
|
+
}), Object.defineProperty(this, "buffer", {
|
|
53
|
+
enumerable: !0,
|
|
54
|
+
configurable: !0,
|
|
55
|
+
writable: !0,
|
|
56
|
+
value: void 0
|
|
57
|
+
}), Object.defineProperty(this, "scrollTop", {
|
|
58
|
+
enumerable: !0,
|
|
59
|
+
configurable: !0,
|
|
60
|
+
writable: !0,
|
|
61
|
+
value: void 0
|
|
62
|
+
}), Object.defineProperty(this, "visibleDuration", {
|
|
63
|
+
enumerable: !0,
|
|
64
|
+
configurable: !0,
|
|
65
|
+
writable: !0,
|
|
66
|
+
value: void 0
|
|
67
|
+
}), Object.defineProperty(this, "pixelsPerMs", {
|
|
68
|
+
enumerable: !0,
|
|
69
|
+
configurable: !0,
|
|
70
|
+
writable: !0,
|
|
71
|
+
value: void 0
|
|
72
|
+
}), this.visibleTimeStart = e.visibleTimeStart, this.visibleTimeEnd = e.visibleTimeEnd, this.canvasWidth = e.canvasWidth, this.canvasHeight = e.canvasHeight, this.sidebarWidth = e.sidebarWidth, this.lineHeight = e.lineHeight, this.groupCount = e.groupCount, this.buffer = e.buffer, this.scrollTop = e.scrollTop, this.visibleDuration = this.visibleTimeEnd - this.visibleTimeStart, this.pixelsPerMs = this.canvasWidth / this.visibleDuration;
|
|
73
|
+
}
|
|
74
|
+
update(e) {
|
|
75
|
+
e.visibleTimeStart !== void 0 && (this.visibleTimeStart = e.visibleTimeStart), e.visibleTimeEnd !== void 0 && (this.visibleTimeEnd = e.visibleTimeEnd), e.canvasWidth !== void 0 && (this.canvasWidth = e.canvasWidth), e.canvasHeight !== void 0 && (this.canvasHeight = e.canvasHeight), e.sidebarWidth !== void 0 && (this.sidebarWidth = e.sidebarWidth), e.lineHeight !== void 0 && (this.lineHeight = e.lineHeight), e.groupCount !== void 0 && (this.groupCount = e.groupCount), e.buffer !== void 0 && (this.buffer = e.buffer), e.scrollTop !== void 0 && (this.scrollTop = e.scrollTop), this.visibleDuration = this.visibleTimeEnd - this.visibleTimeStart, this.pixelsPerMs = this.canvasWidth / this.visibleDuration;
|
|
76
|
+
}
|
|
77
|
+
timeToX(e) {
|
|
78
|
+
return (e - this.visibleTimeStart) * this.pixelsPerMs;
|
|
79
|
+
}
|
|
80
|
+
xToTime(e) {
|
|
81
|
+
return this.visibleTimeStart + e / this.pixelsPerMs;
|
|
82
|
+
}
|
|
83
|
+
yToGroupIndex(e) {
|
|
84
|
+
const r = Math.floor((e + this.scrollTop) / this.lineHeight);
|
|
85
|
+
return Math.max(0, Math.min(r, this.groupCount - 1));
|
|
86
|
+
}
|
|
87
|
+
groupIndexToY(e) {
|
|
88
|
+
return e * this.lineHeight - this.scrollTop;
|
|
89
|
+
}
|
|
90
|
+
getBufferBounds() {
|
|
91
|
+
const e = this.visibleDuration * 1.5;
|
|
92
|
+
return {
|
|
93
|
+
bufferStart: this.visibleTimeStart - e,
|
|
94
|
+
bufferEnd: this.visibleTimeEnd + e
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
getVisibleGroupRange() {
|
|
98
|
+
const e = Math.max(0, Math.floor(this.scrollTop / this.lineHeight)), r = Math.ceil(this.canvasHeight / this.lineHeight), s = Math.min(this.groupCount - 1, e + r);
|
|
99
|
+
return { firstVisible: e, lastVisible: s };
|
|
100
|
+
}
|
|
101
|
+
isScrollInBuffer(e) {
|
|
102
|
+
const r = this.visibleDuration * 1.5 * this.pixelsPerMs;
|
|
103
|
+
return Math.abs(e) < r;
|
|
104
|
+
}
|
|
105
|
+
getTotalHeight() {
|
|
106
|
+
return this.groupCount * this.lineHeight;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
class nr {
|
|
110
|
+
constructor() {
|
|
111
|
+
Object.defineProperty(this, "root", {
|
|
112
|
+
enumerable: !0,
|
|
113
|
+
configurable: !0,
|
|
114
|
+
writable: !0,
|
|
115
|
+
value: null
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
buildFromItems(e, r, s) {
|
|
119
|
+
const l = e.map((u) => ({
|
|
120
|
+
item: u,
|
|
121
|
+
start: r(u),
|
|
122
|
+
end: s(u)
|
|
123
|
+
}));
|
|
124
|
+
this.root = this.buildNode(l);
|
|
125
|
+
}
|
|
126
|
+
buildNode(e) {
|
|
127
|
+
if (e.length === 0)
|
|
128
|
+
return null;
|
|
129
|
+
let r = 1 / 0, s = -1 / 0;
|
|
130
|
+
for (const d of e)
|
|
131
|
+
d.start < r && (r = d.start), d.end > s && (s = d.end);
|
|
132
|
+
const l = (r + s) / 2, u = [], a = [], v = [];
|
|
133
|
+
for (const d of e)
|
|
134
|
+
d.end < l ? u.push(d) : d.start > l ? a.push(d) : v.push(d);
|
|
135
|
+
return {
|
|
136
|
+
center: l,
|
|
137
|
+
left: this.buildNode(u),
|
|
138
|
+
right: this.buildNode(a),
|
|
139
|
+
overlapping: v
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
query(e, r) {
|
|
143
|
+
const s = [];
|
|
144
|
+
return this.queryNode(this.root, e, r, s), s;
|
|
145
|
+
}
|
|
146
|
+
queryNode(e, r, s, l) {
|
|
147
|
+
if (e !== null) {
|
|
148
|
+
for (const u of e.overlapping)
|
|
149
|
+
u.start <= s && u.end >= r && l.push(u.item);
|
|
150
|
+
r <= e.center && e.left !== null && this.queryNode(e.left, r, s, l), s >= e.center && e.right !== null && this.queryNode(e.right, r, s, l);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
class or {
|
|
155
|
+
constructor(e, r) {
|
|
156
|
+
Object.defineProperty(this, "lineHeight", {
|
|
157
|
+
enumerable: !0,
|
|
158
|
+
configurable: !0,
|
|
159
|
+
writable: !0,
|
|
160
|
+
value: void 0
|
|
161
|
+
}), Object.defineProperty(this, "itemHeightRatio", {
|
|
162
|
+
enumerable: !0,
|
|
163
|
+
configurable: !0,
|
|
164
|
+
writable: !0,
|
|
165
|
+
value: void 0
|
|
166
|
+
}), Object.defineProperty(this, "layoutCache", {
|
|
167
|
+
enumerable: !0,
|
|
168
|
+
configurable: !0,
|
|
169
|
+
writable: !0,
|
|
170
|
+
value: /* @__PURE__ */ new Map()
|
|
171
|
+
}), Object.defineProperty(this, "groupMaxStack", {
|
|
172
|
+
enumerable: !0,
|
|
173
|
+
configurable: !0,
|
|
174
|
+
writable: !0,
|
|
175
|
+
value: /* @__PURE__ */ new Map()
|
|
176
|
+
}), this.lineHeight = e, this.itemHeightRatio = r;
|
|
177
|
+
}
|
|
178
|
+
computeLayout(e, r) {
|
|
179
|
+
if (this.layoutCache = /* @__PURE__ */ new Map(), this.groupMaxStack = /* @__PURE__ */ new Map(), !r) {
|
|
180
|
+
const u = this.lineHeight * this.itemHeightRatio;
|
|
181
|
+
for (const a of e)
|
|
182
|
+
this.layoutCache.set(a.id, { stackLevel: 0, itemHeight: u }), this.groupMaxStack.set(a.group, 0);
|
|
183
|
+
return this.layoutCache;
|
|
184
|
+
}
|
|
185
|
+
const s = /* @__PURE__ */ new Map();
|
|
186
|
+
for (const u of e) {
|
|
187
|
+
let a = s.get(u.group);
|
|
188
|
+
a || (a = [], s.set(u.group, a)), a.push(u);
|
|
189
|
+
}
|
|
190
|
+
const l = this.lineHeight * this.itemHeightRatio;
|
|
191
|
+
for (const [u, a] of s) {
|
|
192
|
+
a.sort((g, y) => {
|
|
193
|
+
const p = g.start_time - y.start_time;
|
|
194
|
+
return p !== 0 ? p : y.end_time - y.start_time - (g.end_time - g.start_time);
|
|
195
|
+
});
|
|
196
|
+
const v = [];
|
|
197
|
+
let d = 0;
|
|
198
|
+
for (const g of a) {
|
|
199
|
+
let y = -1;
|
|
200
|
+
for (let p = 0; p < v.length; p++)
|
|
201
|
+
if (v[p] <= g.start_time) {
|
|
202
|
+
y = p;
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
y === -1 ? (y = v.length, v.push(g.end_time)) : v[y] = g.end_time, y > d && (d = y), this.layoutCache.set(g.id, { stackLevel: y, itemHeight: l });
|
|
206
|
+
}
|
|
207
|
+
this.groupMaxStack.set(u, d);
|
|
208
|
+
}
|
|
209
|
+
return this.layoutCache;
|
|
210
|
+
}
|
|
211
|
+
getLayout(e) {
|
|
212
|
+
return this.layoutCache.get(e);
|
|
213
|
+
}
|
|
214
|
+
getGroupHeight(e) {
|
|
215
|
+
return ((this.groupMaxStack.get(e) ?? 0) + 1) * this.lineHeight;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
function Fe(t, e, r, s, l, u) {
|
|
219
|
+
const a = r.xToTime(t), v = /* @__PURE__ */ new Map();
|
|
220
|
+
for (let p = 0; p < u.length; p++)
|
|
221
|
+
v.set(u[p].id, p);
|
|
222
|
+
const d = s.query(a, a);
|
|
223
|
+
let g = null, y = -1 / 0;
|
|
224
|
+
for (const p of d) {
|
|
225
|
+
const M = v.get(p.group);
|
|
226
|
+
if (M === void 0)
|
|
227
|
+
continue;
|
|
228
|
+
const T = l.getLayout(p.id);
|
|
229
|
+
if (!T)
|
|
230
|
+
continue;
|
|
231
|
+
const C = r.timeToX(p.start_time), I = r.timeToX(p.end_time) - C;
|
|
232
|
+
if (t < C || t > C + I)
|
|
233
|
+
continue;
|
|
234
|
+
const E = r.groupIndexToY(M) + T.stackLevel * r.lineHeight + (r.lineHeight - T.itemHeight) / 2, P = T.itemHeight;
|
|
235
|
+
e < E || e > E + P || E > y && (y = E, g = p);
|
|
236
|
+
}
|
|
237
|
+
return g;
|
|
238
|
+
}
|
|
239
|
+
function it(t, e, r) {
|
|
240
|
+
const s = e.yToGroupIndex(t);
|
|
241
|
+
return r[s] ?? null;
|
|
242
|
+
}
|
|
243
|
+
function Ct(t, e, r, s = 6) {
|
|
244
|
+
const l = r.timeToX(e.start_time), u = r.timeToX(e.end_time);
|
|
245
|
+
return t - l <= s ? "left" : u - t <= s ? "right" : "body";
|
|
246
|
+
}
|
|
247
|
+
function nt(t, e, r) {
|
|
248
|
+
const s = window.devicePixelRatio || 1, l = Math.round(e * s), u = Math.round(r * s);
|
|
249
|
+
(t.width !== l || t.height !== u) && (t.width = l, t.height = u, t.style.width = `${e}px`, t.style.height = `${r}px`);
|
|
250
|
+
const a = t.getContext("2d");
|
|
251
|
+
return a.setTransform(s, 0, 0, s, 0, 0), a;
|
|
252
|
+
}
|
|
253
|
+
function ot(t, e) {
|
|
254
|
+
const r = window.devicePixelRatio || 1;
|
|
255
|
+
t.clearRect(0, 0, e.width / r, e.height / r);
|
|
256
|
+
}
|
|
257
|
+
class sr {
|
|
258
|
+
constructor(e) {
|
|
259
|
+
Object.defineProperty(this, "dirty", {
|
|
260
|
+
enumerable: !0,
|
|
261
|
+
configurable: !0,
|
|
262
|
+
writable: !0,
|
|
263
|
+
value: { grid: !1, items: !1, overlay: !1 }
|
|
264
|
+
}), Object.defineProperty(this, "rafId", {
|
|
265
|
+
enumerable: !0,
|
|
266
|
+
configurable: !0,
|
|
267
|
+
writable: !0,
|
|
268
|
+
value: null
|
|
269
|
+
}), Object.defineProperty(this, "drawCallback", {
|
|
270
|
+
enumerable: !0,
|
|
271
|
+
configurable: !0,
|
|
272
|
+
writable: !0,
|
|
273
|
+
value: void 0
|
|
274
|
+
}), this.drawCallback = e;
|
|
275
|
+
}
|
|
276
|
+
markDirty(e) {
|
|
277
|
+
this.dirty[e] = !0, this.schedule();
|
|
278
|
+
}
|
|
279
|
+
markAllDirty() {
|
|
280
|
+
this.dirty.grid = !0, this.dirty.items = !0, this.dirty.overlay = !0, this.schedule();
|
|
281
|
+
}
|
|
282
|
+
dispose() {
|
|
283
|
+
this.rafId !== null && (cancelAnimationFrame(this.rafId), this.rafId = null);
|
|
284
|
+
}
|
|
285
|
+
schedule() {
|
|
286
|
+
this.rafId === null && (this.rafId = requestAnimationFrame(() => {
|
|
287
|
+
this.rafId = null;
|
|
288
|
+
const e = { ...this.dirty };
|
|
289
|
+
this.dirty.grid = !1, this.dirty.items = !1, this.dirty.overlay = !1, this.drawCallback(e);
|
|
290
|
+
}));
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
class lr {
|
|
294
|
+
draw(e, r, s, l, u, a) {
|
|
295
|
+
const { firstVisible: v, lastVisible: d } = r.getVisibleGroupRange();
|
|
296
|
+
for (let E = v; E <= d; E++) {
|
|
297
|
+
const P = r.groupIndexToY(E), X = s[E];
|
|
298
|
+
if (!X)
|
|
299
|
+
continue;
|
|
300
|
+
let j;
|
|
301
|
+
const G = a == null ? void 0 : a(X);
|
|
302
|
+
G != null && G.backgroundColor ? j = G.backgroundColor : j = E % 2 === 0 ? "#FFFFFF" : l.grid.rowAlt, e.fillStyle = j, e.fillRect(0, P, r.canvasWidth, r.lineHeight), e.strokeStyle = (G == null ? void 0 : G.borderBottomColor) ?? l.grid.line, e.lineWidth = 0.5, e.beginPath(), e.moveTo(0, P + r.lineHeight), e.lineTo(r.canvasWidth, P + r.lineHeight), e.stroke();
|
|
303
|
+
}
|
|
304
|
+
const g = r.visibleTimeStart, y = r.visibleTimeEnd, T = 864e5 / (y - g) * r.canvasWidth;
|
|
305
|
+
let C = "day";
|
|
306
|
+
T < 2 ? C = "month" : T < 8 && (C = "week");
|
|
307
|
+
{
|
|
308
|
+
let E = ne(g).startOf("day");
|
|
309
|
+
const P = ne(y).endOf("day");
|
|
310
|
+
let X = null, j = 1, G = 0;
|
|
311
|
+
const W = [], le = (V) => {
|
|
312
|
+
X !== null && (e.fillStyle = X, j !== 1 && (e.globalAlpha = j), e.fillRect(G, 0, V - G, r.canvasHeight), j !== 1 && (e.globalAlpha = 1), X = null, j = 1);
|
|
313
|
+
};
|
|
314
|
+
for (; E.isBefore(P); ) {
|
|
315
|
+
const V = r.timeToX(E.valueOf()), He = E.toDate(), q = u == null ? void 0 : u(He);
|
|
316
|
+
let oe = null, ae = 1;
|
|
317
|
+
if (q != null && q.backgroundColor)
|
|
318
|
+
oe = q.backgroundColor, ae = q.opacity ?? 1;
|
|
319
|
+
else {
|
|
320
|
+
const pe = E.day();
|
|
321
|
+
(pe === 0 || pe === 6) && (oe = l.grid.weekend);
|
|
322
|
+
}
|
|
323
|
+
q != null && q.borderColor && W.push({ x: V, color: q.borderColor }), oe === X && ae === j || (le(V), oe !== null && (X = oe, j = ae, G = V)), E = E.add(1, "day");
|
|
324
|
+
}
|
|
325
|
+
X !== null && le(r.timeToX(E.valueOf()));
|
|
326
|
+
for (const V of W)
|
|
327
|
+
e.strokeStyle = V.color, e.lineWidth = 0.5, e.beginPath(), e.moveTo(V.x, 0), e.lineTo(V.x, r.canvasHeight), e.stroke();
|
|
328
|
+
}
|
|
329
|
+
let I = ne(g).startOf(C);
|
|
330
|
+
const B = ne(y).add(1, C);
|
|
331
|
+
for (e.strokeStyle = l.grid.line, e.lineWidth = 0.5, e.beginPath(); I.isBefore(B); ) {
|
|
332
|
+
const E = r.timeToX(I.valueOf());
|
|
333
|
+
e.moveTo(E, 0), e.lineTo(E, r.canvasHeight), I = I.add(1, C);
|
|
334
|
+
}
|
|
335
|
+
e.stroke();
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
const Mt = '500 12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
|
|
339
|
+
function Bt(t, e) {
|
|
340
|
+
return {
|
|
341
|
+
/**
|
|
342
|
+
* Draws a filled rounded rectangle.
|
|
343
|
+
* Default corner radius is 3px.
|
|
344
|
+
*/
|
|
345
|
+
roundRect(r, s, l, u, a = 3) {
|
|
346
|
+
t.beginPath(), t.roundRect(r, s, l, u, a), t.fill();
|
|
347
|
+
},
|
|
348
|
+
/**
|
|
349
|
+
* Draws text at (x, y) using the standard item font.
|
|
350
|
+
* If maxWidth is provided and the text is too wide, binary-search truncates it
|
|
351
|
+
* and appends '...' so it fits within maxWidth.
|
|
352
|
+
*/
|
|
353
|
+
fillText(r, s, l, u) {
|
|
354
|
+
if (t.font = Mt, u !== void 0 && t.measureText(r).width > u) {
|
|
355
|
+
let a = 0, v = r.length;
|
|
356
|
+
for (; a < v; ) {
|
|
357
|
+
const d = Math.ceil((a + v) / 2), g = r.slice(0, d) + "...";
|
|
358
|
+
t.measureText(g).width <= u ? a = d : v = d - 1;
|
|
359
|
+
}
|
|
360
|
+
t.fillText(r.slice(0, a) + "...", s, l);
|
|
361
|
+
} else
|
|
362
|
+
t.fillText(r, s, l);
|
|
363
|
+
},
|
|
364
|
+
/**
|
|
365
|
+
* Creates a 50/50 linear gradient from color1 (0%–50%) to color2 (50%–100%)
|
|
366
|
+
* spanning the given x position and width.
|
|
367
|
+
*/
|
|
368
|
+
gradient(r, s, l, u) {
|
|
369
|
+
const a = t.createLinearGradient(r, 0, r + s, 0);
|
|
370
|
+
return a.addColorStop(0, l), a.addColorStop(0.5, l), a.addColorStop(0.5, u), a.addColorStop(1, u), a;
|
|
371
|
+
},
|
|
372
|
+
/**
|
|
373
|
+
* Draws a vertical colored bar on the left edge of the item bounds.
|
|
374
|
+
* Does nothing if no bounds were provided.
|
|
375
|
+
*/
|
|
376
|
+
leftBar(r, s = 3) {
|
|
377
|
+
e && (t.save(), t.fillStyle = r, t.fillRect(e.x, e.y, s, e.height), t.restore());
|
|
378
|
+
},
|
|
379
|
+
/**
|
|
380
|
+
* Draws a vector icon centered at (x, y).
|
|
381
|
+
* Supported types: 'check', 'danger-red', 'danger-yellow'.
|
|
382
|
+
* Default size is 14px.
|
|
383
|
+
*/
|
|
384
|
+
icon(r, s, l, u = 14) {
|
|
385
|
+
t.save();
|
|
386
|
+
const a = u / 2;
|
|
387
|
+
if (r === "check") {
|
|
388
|
+
t.fillStyle = "#31c48d", t.beginPath(), t.arc(s + a, l + a, a, 0, Math.PI * 2), t.fill(), t.strokeStyle = "#ffffff", t.lineWidth = u * 0.12, t.beginPath();
|
|
389
|
+
const v = s + a, d = l + a;
|
|
390
|
+
t.moveTo(v - a * 0.45, d), t.lineTo(v - a * 0.1, d + a * 0.42), t.lineTo(v + a * 0.45, d - a * 0.35), t.stroke();
|
|
391
|
+
} else if (r === "danger-red" || r === "danger-yellow") {
|
|
392
|
+
const v = r === "danger-red" ? "#EF5350" : "#FBBF24";
|
|
393
|
+
t.fillStyle = v, t.beginPath(), t.moveTo(s + a, l), t.lineTo(s + u, l + u), t.lineTo(s, l + u), t.closePath(), t.fill(), t.fillStyle = "#ffffff";
|
|
394
|
+
const d = u * 0.12, g = s + a - d / 2;
|
|
395
|
+
t.fillRect(g, l + u * 0.35, d, u * 0.35), t.beginPath(), t.arc(s + a, l + u * 0.82, d * 0.7, 0, Math.PI * 2), t.fill();
|
|
396
|
+
}
|
|
397
|
+
t.restore();
|
|
398
|
+
},
|
|
399
|
+
/**
|
|
400
|
+
* Draws a pill-shaped badge with centered white text on a colored background.
|
|
401
|
+
*/
|
|
402
|
+
badge(r, s, l, u) {
|
|
403
|
+
t.save(), t.font = Mt;
|
|
404
|
+
const v = t.measureText(r).width, d = 8, y = 12 + 3 * 2, p = v + d * 2, M = y / 2;
|
|
405
|
+
t.fillStyle = u, t.beginPath(), t.roundRect(s, l, p, y, M), t.fill(), t.fillStyle = "#ffffff", t.textAlign = "center", t.textBaseline = "middle", t.fillText(r, s + p / 2, l + y / 2), t.restore();
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
class ar {
|
|
410
|
+
draw(e, r, s, l, u, a, v, d, g, y, p, M) {
|
|
411
|
+
const T = (r.visibleTimeEnd - r.visibleTimeStart) * 0.1, C = r.visibleTimeStart - T, I = r.visibleTimeEnd + T, B = u.query(C, I), E = /* @__PURE__ */ new Map();
|
|
412
|
+
for (let W = 0; W < s.length; W++)
|
|
413
|
+
E.set(s[W].id, W);
|
|
414
|
+
const P = new Set(y), X = /* @__PURE__ */ new Map(), j = -r.lineHeight, G = r.canvasHeight + r.lineHeight;
|
|
415
|
+
for (const W of B) {
|
|
416
|
+
const le = E.get(W.group);
|
|
417
|
+
if (le === void 0)
|
|
418
|
+
continue;
|
|
419
|
+
const V = a.getLayout(W.id);
|
|
420
|
+
if (!V)
|
|
421
|
+
continue;
|
|
422
|
+
const q = r.groupIndexToY(le) + V.stackLevel * r.lineHeight + (r.lineHeight - V.itemHeight) / 2, oe = V.itemHeight;
|
|
423
|
+
if (q + oe < j || q > G)
|
|
424
|
+
continue;
|
|
425
|
+
const ae = r.timeToX(W.start_time), pe = r.timeToX(W.end_time) - ae, ke = { x: ae, y: q, width: pe, height: oe };
|
|
426
|
+
X.set(W.id, ke);
|
|
427
|
+
const Be = {
|
|
428
|
+
selected: P.has(W.id),
|
|
429
|
+
hovered: p === W.id,
|
|
430
|
+
dragging: !1,
|
|
431
|
+
filtered: W.filtered !== !1
|
|
432
|
+
};
|
|
433
|
+
e.save();
|
|
434
|
+
const We = Bt(e, ke);
|
|
435
|
+
(d && (W.type === "control_area_group" || W.type === "construction_train") ? d : v)(e, W, ke, Be, We), e.restore();
|
|
436
|
+
}
|
|
437
|
+
M && M.length > 0 && this.drawDependencies(e, M, X, p, g);
|
|
438
|
+
}
|
|
439
|
+
drawDependencies(e, r, s, l, u) {
|
|
440
|
+
for (const a of r) {
|
|
441
|
+
const v = s.get(a.fromItemId), d = s.get(a.toItemId);
|
|
442
|
+
if (!v || !d)
|
|
443
|
+
continue;
|
|
444
|
+
const g = l === a.fromItemId || l === a.toItemId;
|
|
445
|
+
e.strokeStyle = g ? u.primary : a.color ?? "#94A3B8", e.lineWidth = g ? 2 : 1.5, e.setLineDash([]);
|
|
446
|
+
const y = v.x + v.width, p = v.y + v.height / 2, M = d.x, T = d.y + d.height / 2, C = Math.abs(M - y), I = Math.max(C * 0.4, 30);
|
|
447
|
+
e.beginPath(), e.moveTo(y, p), e.bezierCurveTo(y + I, p, M - I, T, M, T), e.stroke();
|
|
448
|
+
const B = 6;
|
|
449
|
+
e.fillStyle = e.strokeStyle, e.beginPath(), e.moveTo(M, T), e.lineTo(M - B, T - B / 2), e.lineTo(M - B, T + B / 2), e.closePath(), e.fill();
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
class ur {
|
|
454
|
+
draw(e, r, s, l) {
|
|
455
|
+
const { cursorX: u, snapX: a, markers: v, interaction: d } = l;
|
|
456
|
+
if (v)
|
|
457
|
+
for (const g of v) {
|
|
458
|
+
const y = r.timeToX(g.date);
|
|
459
|
+
if (e.fillStyle = g.color, e.fillRect(y - g.width / 2, 0, g.width, r.canvasHeight), g.label) {
|
|
460
|
+
e.save(), e.font = '500 10px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
|
|
461
|
+
const p = e.measureText(g.label).width, M = 8, T = 200, C = Math.min(p + M * 2, T), I = 20, B = y - C / 2, E = 4;
|
|
462
|
+
e.fillStyle = g.color, e.beginPath(), e.roundRect(B, E, C, I, 3), e.fill(), e.fillStyle = "#FFFFFF", e.textBaseline = "middle";
|
|
463
|
+
const P = T - M * 2, X = p > P ? g.label.slice(0, Math.floor(g.label.length * P / p)) + "…" : g.label;
|
|
464
|
+
e.fillText(X, B + M, E + I / 2), e.restore();
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
if (u != null && (e.strokeStyle = s.marker.cursor, e.lineWidth = 1, e.beginPath(), e.moveTo(u, 0), e.lineTo(u, r.canvasHeight), e.stroke()), a != null && (e.strokeStyle = s.primary, e.lineWidth = 1, e.setLineDash([4, 4]), e.beginPath(), e.moveTo(a, 0), e.lineTo(a, r.canvasHeight), e.stroke(), e.setLineDash([])), d) {
|
|
468
|
+
d.groupChanged && d.targetGroupY !== void 0 && (e.fillStyle = "rgba(59, 130, 246, 0.08)", e.fillRect(0, d.targetGroupY, r.canvasWidth, r.lineHeight)), e.save(), e.globalAlpha = 0.5;
|
|
469
|
+
const g = Bt(e, d.bounds);
|
|
470
|
+
d.renderer(e, d.item, d.bounds, { selected: !1, hovered: !1, dragging: !0, filtered: !0 }, g), e.restore();
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
const Ht = 120;
|
|
475
|
+
function cr(t) {
|
|
476
|
+
let e = t.deltaY || t.deltaX;
|
|
477
|
+
return t.deltaMode === 1 ? e *= 15 : t.deltaMode === 2 && (e *= 800), Math.max(-Ht, Math.min(Ht, e));
|
|
478
|
+
}
|
|
479
|
+
class dr {
|
|
480
|
+
constructor(e, r, s, l, u) {
|
|
481
|
+
Object.defineProperty(this, "onZoom", {
|
|
482
|
+
enumerable: !0,
|
|
483
|
+
configurable: !0,
|
|
484
|
+
writable: !0,
|
|
485
|
+
value: void 0
|
|
486
|
+
}), Object.defineProperty(this, "visibleTimeStart", {
|
|
487
|
+
enumerable: !0,
|
|
488
|
+
configurable: !0,
|
|
489
|
+
writable: !0,
|
|
490
|
+
value: void 0
|
|
491
|
+
}), Object.defineProperty(this, "visibleTimeEnd", {
|
|
492
|
+
enumerable: !0,
|
|
493
|
+
configurable: !0,
|
|
494
|
+
writable: !0,
|
|
495
|
+
value: void 0
|
|
496
|
+
}), Object.defineProperty(this, "minZoom", {
|
|
497
|
+
enumerable: !0,
|
|
498
|
+
configurable: !0,
|
|
499
|
+
writable: !0,
|
|
500
|
+
value: void 0
|
|
501
|
+
}), Object.defineProperty(this, "maxZoom", {
|
|
502
|
+
enumerable: !0,
|
|
503
|
+
configurable: !0,
|
|
504
|
+
writable: !0,
|
|
505
|
+
value: void 0
|
|
506
|
+
}), this.onZoom = e, this.visibleTimeStart = r, this.visibleTimeEnd = s, this.minZoom = l, this.maxZoom = u;
|
|
507
|
+
}
|
|
508
|
+
updateBounds(e, r) {
|
|
509
|
+
this.visibleTimeStart = e, this.visibleTimeEnd = r;
|
|
510
|
+
}
|
|
511
|
+
handleWheelZoom(e, r) {
|
|
512
|
+
const s = cr(e), l = e.ctrlKey ? 10 : e.metaKey ? 3 : 1, u = s > 0 ? 1 + l * s / 500 : 1 / (1 + l * -s / 500), a = this.visibleTimeEnd - this.visibleTimeStart;
|
|
513
|
+
let v = Math.round(a * u);
|
|
514
|
+
v = Math.max(this.minZoom, Math.min(this.maxZoom, v));
|
|
515
|
+
const d = Math.round(this.visibleTimeStart + (a - v) * r), g = d + v;
|
|
516
|
+
this.onZoom(d, g);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
const hr = 4;
|
|
520
|
+
class fr {
|
|
521
|
+
constructor(e) {
|
|
522
|
+
Object.defineProperty(this, "state", {
|
|
523
|
+
enumerable: !0,
|
|
524
|
+
configurable: !0,
|
|
525
|
+
writable: !0,
|
|
526
|
+
value: null
|
|
527
|
+
}), Object.defineProperty(this, "dragSnap", {
|
|
528
|
+
enumerable: !0,
|
|
529
|
+
configurable: !0,
|
|
530
|
+
writable: !0,
|
|
531
|
+
value: void 0
|
|
532
|
+
}), Object.defineProperty(this, "activated", {
|
|
533
|
+
enumerable: !0,
|
|
534
|
+
configurable: !0,
|
|
535
|
+
writable: !0,
|
|
536
|
+
value: !1
|
|
537
|
+
}), this.dragSnap = e;
|
|
538
|
+
}
|
|
539
|
+
startInteraction(e, r, s, l) {
|
|
540
|
+
this.state = {
|
|
541
|
+
item: e,
|
|
542
|
+
mode: r,
|
|
543
|
+
startX: s,
|
|
544
|
+
startY: l,
|
|
545
|
+
currentX: s,
|
|
546
|
+
currentY: l,
|
|
547
|
+
deltaX: 0,
|
|
548
|
+
originalGroup: e.group,
|
|
549
|
+
currentGroup: e.group
|
|
550
|
+
}, this.activated = !1;
|
|
551
|
+
}
|
|
552
|
+
update(e, r) {
|
|
553
|
+
this.state && (this.state.currentX = e, this.state.currentY = r, this.state.deltaX = e - this.state.startX, !this.activated && Math.abs(this.state.deltaX) >= hr && (this.activated = !0));
|
|
554
|
+
}
|
|
555
|
+
setCurrentGroup(e) {
|
|
556
|
+
this.state && (this.state.currentGroup = e);
|
|
557
|
+
}
|
|
558
|
+
endMove(e) {
|
|
559
|
+
if (!this.state)
|
|
560
|
+
return null;
|
|
561
|
+
const r = this.state.deltaX / e, s = this.state.item.start_time + r, l = Math.round(s / this.dragSnap) * this.dragSnap, u = this.state.currentGroup;
|
|
562
|
+
return this.state = null, this.activated = !1, { newStartTime: l, newGroupId: u };
|
|
563
|
+
}
|
|
564
|
+
endResize(e) {
|
|
565
|
+
if (!this.state)
|
|
566
|
+
return null;
|
|
567
|
+
const r = this.state.deltaX / e, s = this.state.mode === "resize-left" ? "left" : "right", u = (s === "left" ? this.state.item.start_time : this.state.item.end_time) + r, a = Math.round(u / this.dragSnap) * this.dragSnap;
|
|
568
|
+
return this.state = null, this.activated = !1, { newTime: a, edge: s };
|
|
569
|
+
}
|
|
570
|
+
cancel() {
|
|
571
|
+
this.state = null, this.activated = !1;
|
|
572
|
+
}
|
|
573
|
+
getState() {
|
|
574
|
+
return this.state;
|
|
575
|
+
}
|
|
576
|
+
getMode() {
|
|
577
|
+
var e;
|
|
578
|
+
return ((e = this.state) == null ? void 0 : e.mode) ?? null;
|
|
579
|
+
}
|
|
580
|
+
isActive() {
|
|
581
|
+
return this.state !== null && this.activated;
|
|
582
|
+
}
|
|
583
|
+
isPending() {
|
|
584
|
+
return this.state !== null;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
var Wt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
588
|
+
function Xt(t) {
|
|
589
|
+
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
590
|
+
}
|
|
591
|
+
var Lt = { exports: {} };
|
|
592
|
+
(function(t, e) {
|
|
593
|
+
(function(r, s) {
|
|
594
|
+
t.exports = s();
|
|
595
|
+
})(Wt, function() {
|
|
596
|
+
var r = "day";
|
|
597
|
+
return function(s, l, u) {
|
|
598
|
+
var a = function(g) {
|
|
599
|
+
return g.add(4 - g.isoWeekday(), r);
|
|
600
|
+
}, v = l.prototype;
|
|
601
|
+
v.isoWeekYear = function() {
|
|
602
|
+
return a(this).year();
|
|
603
|
+
}, v.isoWeek = function(g) {
|
|
604
|
+
if (!this.$utils().u(g)) return this.add(7 * (g - this.isoWeek()), r);
|
|
605
|
+
var y, p, M, T, C = a(this), I = (y = this.isoWeekYear(), p = this.$u, M = (p ? u.utc : u)().year(y).startOf("year"), T = 4 - M.isoWeekday(), M.isoWeekday() > 4 && (T += 7), M.add(T, r));
|
|
606
|
+
return C.diff(I, "week") + 1;
|
|
607
|
+
}, v.isoWeekday = function(g) {
|
|
608
|
+
return this.$utils().u(g) ? this.day() || 7 : this.day(this.day() % 7 ? g : g - 7);
|
|
609
|
+
};
|
|
610
|
+
var d = v.startOf;
|
|
611
|
+
v.startOf = function(g, y) {
|
|
612
|
+
var p = this.$utils(), M = !!p.u(y) || y;
|
|
613
|
+
return p.p(g) === "isoweek" ? M ? this.date(this.date() - (this.isoWeekday() - 1)).startOf("day") : this.date(this.date() - 1 - (this.isoWeekday() - 1) + 7).endOf("day") : d.bind(this)(g, y);
|
|
614
|
+
};
|
|
615
|
+
};
|
|
616
|
+
});
|
|
617
|
+
})(Lt);
|
|
618
|
+
var mr = Lt.exports;
|
|
619
|
+
const gr = /* @__PURE__ */ Xt(mr), Rt = 5;
|
|
620
|
+
function Dt({ groups: t, width: e, lineHeight: r, scrollTop: s, canvasHeight: l, theme: u, groupRenderer: a, onScroll: v }) {
|
|
621
|
+
var B;
|
|
622
|
+
const d = L(null), g = L(!1), y = t.length * r, p = l, M = Math.max(0, Math.floor(s / r) - Rt), T = Math.min(t.length - 1, Math.ceil((s + l) / r) + Rt), C = $((E) => {
|
|
623
|
+
g.current || v(E.currentTarget.scrollTop);
|
|
624
|
+
}, [v]);
|
|
625
|
+
re(() => {
|
|
626
|
+
d.current && (g.current = !0, d.current.scrollTop = s, requestAnimationFrame(() => {
|
|
627
|
+
g.current = !1;
|
|
628
|
+
}));
|
|
629
|
+
}, [s]);
|
|
630
|
+
const I = [];
|
|
631
|
+
for (let E = M; E <= T; E++) {
|
|
632
|
+
const P = t[E];
|
|
633
|
+
P && I.push(Z("div", { style: {
|
|
634
|
+
position: "absolute",
|
|
635
|
+
top: E * r,
|
|
636
|
+
height: r,
|
|
637
|
+
width: "100%",
|
|
638
|
+
overflow: "hidden",
|
|
639
|
+
display: "flex",
|
|
640
|
+
alignItems: "stretch",
|
|
641
|
+
borderBottom: `1px solid ${((B = u.grid) == null ? void 0 : B.line) ?? "#E5E5E5"}`,
|
|
642
|
+
boxSizing: "border-box"
|
|
643
|
+
}, children: a(P) }, P.id));
|
|
644
|
+
}
|
|
645
|
+
return Z("div", { ref: d, onScroll: C, style: {
|
|
646
|
+
width: e,
|
|
647
|
+
height: p,
|
|
648
|
+
overflowY: y > l ? "auto" : "hidden",
|
|
649
|
+
overflowX: "hidden",
|
|
650
|
+
position: "relative",
|
|
651
|
+
borderRight: `1px solid ${u.sidebar.border}`,
|
|
652
|
+
backgroundColor: u.sidebar.bg
|
|
653
|
+
}, children: Z("div", { style: { height: y, position: "relative" }, children: I }) });
|
|
654
|
+
}
|
|
655
|
+
function vr(t) {
|
|
656
|
+
return null;
|
|
657
|
+
}
|
|
658
|
+
vr.displayName = "TodayMarker";
|
|
659
|
+
function It(t) {
|
|
660
|
+
return { date: Math.floor(Date.now() / 6e4) * 6e4, color: t.color ?? "#FD7171", width: t.width ?? 6, label: t.label };
|
|
661
|
+
}
|
|
662
|
+
function br(t) {
|
|
663
|
+
return t.interval ?? 1e4;
|
|
664
|
+
}
|
|
665
|
+
function pr(t) {
|
|
666
|
+
return null;
|
|
667
|
+
}
|
|
668
|
+
pr.displayName = "CustomMarker";
|
|
669
|
+
function Pt(t) {
|
|
670
|
+
return {
|
|
671
|
+
date: t.date,
|
|
672
|
+
color: t.color ?? "#3B82F6",
|
|
673
|
+
width: t.width ?? 4,
|
|
674
|
+
label: t.label
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
ne.extend(gr);
|
|
678
|
+
function yr(t) {
|
|
679
|
+
return t ? {
|
|
680
|
+
...be,
|
|
681
|
+
...t,
|
|
682
|
+
status: { ...be.status, ...t.status },
|
|
683
|
+
grid: { ...be.grid, ...t.grid },
|
|
684
|
+
item: { ...be.item, ...t.item },
|
|
685
|
+
marker: { ...be.marker, ...t.marker },
|
|
686
|
+
sidebar: { ...be.sidebar, ...t.sidebar },
|
|
687
|
+
header: { ...be.header, ...t.header }
|
|
688
|
+
} : be;
|
|
689
|
+
}
|
|
690
|
+
const Ot = 32, Fr = ie.memo(tr(function(e, r) {
|
|
691
|
+
const { groups: s, items: l, defaultTimeStart: u, defaultTimeEnd: a, sidebarWidth: v, lineHeight: d, itemHeightRatio: g, stackItems: y, canMove: p, canChangeGroup: M, canResize: T, dragSnap: C, minZoom: I, maxZoom: B, theme: E, dayStyle: P, rowStyle: X, showCursorLine: j, itemRenderer: G, groupRenderer: W, sidebarGroupRenderer: le, dependencies: V, onItemClick: He, onItemDoubleClick: q, onItemContextMenu: oe, onItemMove: ae, onItemResize: pe, moveResizeValidator: ke, onItemHover: Be, onCanvasDoubleClick: We, onCanvasContextMenu: Ne, onTimeChange: st, onZoom: lt, selected: at = [], rightSidebarWidth: Ge, rightSidebarGroupRenderer: ut, onReady: Xe, children: he } = e, ye = Q(() => yr(E), [E]), ct = $((o, i) => {
|
|
692
|
+
for (let c = 0; c < i.length; c++)
|
|
693
|
+
if (i[c].id === o)
|
|
694
|
+
return c;
|
|
695
|
+
return 0;
|
|
696
|
+
}, []), xt = at.join(","), ze = Q(() => at, [xt]), dt = L(null), ht = L(null), ft = L(null), Re = L(null), mt = L(null), At = L(null), [gt, Yt] = Ye({ width: 800, height: 600 });
|
|
697
|
+
re(() => {
|
|
698
|
+
const o = mt.current;
|
|
699
|
+
if (!o)
|
|
700
|
+
return;
|
|
701
|
+
const i = new ResizeObserver((c) => {
|
|
702
|
+
const f = c[0];
|
|
703
|
+
f && Yt({ width: f.contentRect.width, height: f.contentRect.height });
|
|
704
|
+
});
|
|
705
|
+
return i.observe(o), () => i.disconnect();
|
|
706
|
+
}, []);
|
|
707
|
+
const fe = Math.max(0, gt.width - v - (Ge ?? 0)), me = s.length * d || gt.height, R = L(new rt({
|
|
708
|
+
visibleTimeStart: e.visibleTimeStart ?? u,
|
|
709
|
+
visibleTimeEnd: e.visibleTimeEnd ?? a,
|
|
710
|
+
canvasWidth: fe,
|
|
711
|
+
canvasHeight: me,
|
|
712
|
+
sidebarWidth: v,
|
|
713
|
+
lineHeight: d,
|
|
714
|
+
groupCount: s.length,
|
|
715
|
+
buffer: e.buffer ?? 3,
|
|
716
|
+
scrollTop: 0
|
|
717
|
+
})), $e = L(null), De = L(void 0), [vt, jt] = Ye(e.visibleTimeStart ?? u), [bt, Nt] = Ye(e.visibleTimeEnd ?? a), [pt, Le] = Ye(0), Ie = L(null), we = $(() => {
|
|
718
|
+
const o = R.current;
|
|
719
|
+
jt(o.visibleTimeStart), Nt(o.visibleTimeEnd), Le(o.scrollTop), Ie.current = null;
|
|
720
|
+
}, []), Ve = $(() => {
|
|
721
|
+
Ie.current === null && (Ie.current = setTimeout(we, Ot));
|
|
722
|
+
}, [we]);
|
|
723
|
+
re(() => () => {
|
|
724
|
+
Ie.current !== null && clearTimeout(Ie.current);
|
|
725
|
+
}, []);
|
|
726
|
+
const Ze = Q(() => {
|
|
727
|
+
const o = new nr();
|
|
728
|
+
return o.buildFromItems(l, (i) => i.start_time, (i) => i.end_time), o;
|
|
729
|
+
}, [l]), qe = Q(() => {
|
|
730
|
+
const o = new or(d, g);
|
|
731
|
+
return o.computeLayout(l, y), o;
|
|
732
|
+
}, [l, d, g, y]), Se = Q(() => new lr(), []), Ee = Q(() => new ar(), []), Ce = Q(() => new ur(), []), N = Q(() => new fr(C), [C]), _e = Q(() => {
|
|
733
|
+
const o = [];
|
|
734
|
+
return ie.Children.forEach(he, (i) => {
|
|
735
|
+
var f;
|
|
736
|
+
if (!ie.isValidElement(i))
|
|
737
|
+
return;
|
|
738
|
+
const c = (f = i.type) == null ? void 0 : f.displayName;
|
|
739
|
+
c === "TodayMarker" ? o.push(It(i.props)) : c === "CustomMarker" && o.push(Pt(i.props));
|
|
740
|
+
}), o;
|
|
741
|
+
}, [he]), xe = Q(() => _e.map((o) => `${o.date}|${o.color}|${o.width}|${o.label ?? ""}`).join(";"), [_e]), Pe = L(_e);
|
|
742
|
+
Pe.current = _e;
|
|
743
|
+
const Ue = Q(() => {
|
|
744
|
+
let o = 0;
|
|
745
|
+
return ie.Children.forEach(he, (i) => {
|
|
746
|
+
var f;
|
|
747
|
+
if (!ie.isValidElement(i))
|
|
748
|
+
return;
|
|
749
|
+
((f = i.type) == null ? void 0 : f.displayName) === "TodayMarker" && (o = br(i.props));
|
|
750
|
+
}), o;
|
|
751
|
+
}, [he]), O = L({
|
|
752
|
+
groups: s,
|
|
753
|
+
items: l,
|
|
754
|
+
intervalTree: Ze,
|
|
755
|
+
layoutEngine: qe,
|
|
756
|
+
itemRenderer: G,
|
|
757
|
+
groupRenderer: W,
|
|
758
|
+
theme: ye,
|
|
759
|
+
selected: ze,
|
|
760
|
+
dependencies: V,
|
|
761
|
+
dayStyle: P,
|
|
762
|
+
rowStyle: X,
|
|
763
|
+
showCursorLine: j,
|
|
764
|
+
canvasWidth: fe,
|
|
765
|
+
canvasHeight: me,
|
|
766
|
+
lineHeight: d,
|
|
767
|
+
itemHeightRatio: g,
|
|
768
|
+
onTimeChange: st,
|
|
769
|
+
onZoom: lt,
|
|
770
|
+
onItemHover: Be,
|
|
771
|
+
onItemClick: He,
|
|
772
|
+
onItemDoubleClick: q,
|
|
773
|
+
onItemContextMenu: oe,
|
|
774
|
+
onItemMove: ae,
|
|
775
|
+
onItemResize: pe,
|
|
776
|
+
onCanvasDoubleClick: We,
|
|
777
|
+
onCanvasContextMenu: Ne,
|
|
778
|
+
canMove: p,
|
|
779
|
+
canResize: T,
|
|
780
|
+
canChangeGroup: M,
|
|
781
|
+
dragSnap: C,
|
|
782
|
+
sidebarWidth: v,
|
|
783
|
+
moveResizeValidator: ke
|
|
784
|
+
});
|
|
785
|
+
O.current = {
|
|
786
|
+
groups: s,
|
|
787
|
+
items: l,
|
|
788
|
+
intervalTree: Ze,
|
|
789
|
+
layoutEngine: qe,
|
|
790
|
+
itemRenderer: G,
|
|
791
|
+
groupRenderer: W,
|
|
792
|
+
theme: ye,
|
|
793
|
+
selected: ze,
|
|
794
|
+
dependencies: V,
|
|
795
|
+
dayStyle: P,
|
|
796
|
+
rowStyle: X,
|
|
797
|
+
showCursorLine: j,
|
|
798
|
+
canvasWidth: fe,
|
|
799
|
+
canvasHeight: me,
|
|
800
|
+
lineHeight: d,
|
|
801
|
+
itemHeightRatio: g,
|
|
802
|
+
onTimeChange: st,
|
|
803
|
+
onZoom: lt,
|
|
804
|
+
onItemHover: Be,
|
|
805
|
+
onItemClick: He,
|
|
806
|
+
onItemDoubleClick: q,
|
|
807
|
+
onItemContextMenu: oe,
|
|
808
|
+
onItemMove: ae,
|
|
809
|
+
onItemResize: pe,
|
|
810
|
+
onCanvasDoubleClick: We,
|
|
811
|
+
onCanvasContextMenu: Ne,
|
|
812
|
+
canMove: p,
|
|
813
|
+
canResize: T,
|
|
814
|
+
canChangeGroup: M,
|
|
815
|
+
dragSnap: C,
|
|
816
|
+
sidebarWidth: v,
|
|
817
|
+
moveResizeValidator: ke
|
|
818
|
+
};
|
|
819
|
+
const Gt = $(() => {
|
|
820
|
+
const o = dt.current;
|
|
821
|
+
if (!o)
|
|
822
|
+
return;
|
|
823
|
+
const i = O.current, c = nt(o, i.canvasWidth, i.canvasHeight);
|
|
824
|
+
ot(c, o), Se.draw(c, R.current, i.groups, i.theme, i.dayStyle, i.rowStyle);
|
|
825
|
+
}, [Se]), zt = $(() => {
|
|
826
|
+
const o = ht.current;
|
|
827
|
+
if (!o)
|
|
828
|
+
return;
|
|
829
|
+
const i = O.current, c = nt(o, i.canvasWidth, i.canvasHeight);
|
|
830
|
+
ot(c, o), Ee.draw(c, R.current, i.groups, i.items, i.intervalTree, i.layoutEngine, i.itemRenderer, i.groupRenderer, i.theme, i.selected, De.current, i.dependencies);
|
|
831
|
+
}, [Ee]), yt = $((o, i) => {
|
|
832
|
+
const c = R.current, f = O.current, n = f.canvasWidth / (c.visibleTimeEnd - c.visibleTimeStart), h = i / n, b = o.start_time + h, k = Math.round(b / f.dragSnap) * f.dragSnap;
|
|
833
|
+
return c.timeToX(k);
|
|
834
|
+
}, []), $t = $(() => {
|
|
835
|
+
const o = ft.current;
|
|
836
|
+
if (!o)
|
|
837
|
+
return;
|
|
838
|
+
const i = O.current, c = nt(o, i.canvasWidth, i.canvasHeight);
|
|
839
|
+
ot(c, o);
|
|
840
|
+
const f = R.current, n = N.getState();
|
|
841
|
+
let h = null;
|
|
842
|
+
if (n) {
|
|
843
|
+
const b = f.timeToX(n.item.start_time), k = f.timeToX(n.item.end_time) - b;
|
|
844
|
+
let H, D;
|
|
845
|
+
n.mode === "resize-left" ? (H = b + n.deltaX, D = k - n.deltaX) : n.mode === "resize-right" ? (H = b, D = k + n.deltaX) : (H = b + n.deltaX, D = k);
|
|
846
|
+
const x = ct(n.currentGroup, i.groups), z = f.groupIndexToY(x), A = n.currentGroup !== n.originalGroup;
|
|
847
|
+
h = {
|
|
848
|
+
item: n.item,
|
|
849
|
+
mode: n.mode,
|
|
850
|
+
bounds: { x: H, y: z + (i.lineHeight - i.lineHeight * i.itemHeightRatio) / 2, width: D, height: i.lineHeight * i.itemHeightRatio },
|
|
851
|
+
renderer: i.itemRenderer,
|
|
852
|
+
targetGroupY: z,
|
|
853
|
+
groupChanged: A
|
|
854
|
+
};
|
|
855
|
+
}
|
|
856
|
+
Ce.draw(c, f, i.theme, {
|
|
857
|
+
cursorX: i.showCursorLine ? $e.current : null,
|
|
858
|
+
snapX: n ? yt(n.item, n.deltaX) : null,
|
|
859
|
+
markers: Pe.current,
|
|
860
|
+
interaction: h
|
|
861
|
+
});
|
|
862
|
+
}, [Ce, N, yt, ct]), Ke = L(null);
|
|
863
|
+
Ke.current || (Ke.current = new sr((o) => {
|
|
864
|
+
o.grid && Gt(), o.items && zt(), o.overlay && $t();
|
|
865
|
+
}));
|
|
866
|
+
const S = Ke.current;
|
|
867
|
+
re(() => () => S.dispose(), [S]), re(() => {
|
|
868
|
+
if (!Ue)
|
|
869
|
+
return;
|
|
870
|
+
const o = setInterval(() => {
|
|
871
|
+
const i = [];
|
|
872
|
+
ie.Children.forEach(he, (c) => {
|
|
873
|
+
var n;
|
|
874
|
+
if (!ie.isValidElement(c))
|
|
875
|
+
return;
|
|
876
|
+
const f = (n = c.type) == null ? void 0 : n.displayName;
|
|
877
|
+
f === "TodayMarker" ? i.push(It(c.props)) : f === "CustomMarker" && i.push(Pt(c.props));
|
|
878
|
+
}), Pe.current = i, S.markDirty("overlay");
|
|
879
|
+
}, Ue);
|
|
880
|
+
return () => clearInterval(o);
|
|
881
|
+
}, [Ue, he, S]), re(() => {
|
|
882
|
+
R.current.update({ canvasWidth: fe, canvasHeight: me, sidebarWidth: v, lineHeight: d, groupCount: s.length }), S.markAllDirty();
|
|
883
|
+
}, [fe, me, v, d, s.length, S]), re(() => {
|
|
884
|
+
S.markDirty("grid"), S.markDirty("items");
|
|
885
|
+
}, [l, s, ze, ye, P, X, Ze, qe, S]);
|
|
886
|
+
const Tt = L(xe);
|
|
887
|
+
re(() => {
|
|
888
|
+
xe !== Tt.current && (Tt.current = xe, S.markDirty("overlay"));
|
|
889
|
+
}, [xe, S]);
|
|
890
|
+
const kt = L(e.visibleTimeStart), wt = L(e.visibleTimeEnd);
|
|
891
|
+
e.visibleTimeStart !== void 0 && e.visibleTimeStart !== kt.current && (kt.current = e.visibleTimeStart, R.current.update({ visibleTimeStart: e.visibleTimeStart }), S.markAllDirty()), e.visibleTimeEnd !== void 0 && e.visibleTimeEnd !== wt.current && (wt.current = e.visibleTimeEnd, R.current.update({ visibleTimeEnd: e.visibleTimeEnd }), S.markAllDirty());
|
|
892
|
+
const Oe = L(null), Je = $((o) => {
|
|
893
|
+
Oe.current === null && (Oe.current = setTimeout(() => {
|
|
894
|
+
var f, n;
|
|
895
|
+
Oe.current = null;
|
|
896
|
+
const i = R.current, c = O.current;
|
|
897
|
+
o === "zoom" ? (f = c.onZoom) == null || f.call(c, i.visibleTimeStart, i.visibleTimeEnd) : (n = c.onTimeChange) == null || n.call(c, i.visibleTimeStart, i.visibleTimeEnd);
|
|
898
|
+
}, Ot));
|
|
899
|
+
}, []);
|
|
900
|
+
re(() => () => {
|
|
901
|
+
Oe.current !== null && clearTimeout(Oe.current);
|
|
902
|
+
}, []);
|
|
903
|
+
const Ae = L(null), Qe = Q(() => new dr((o, i) => {
|
|
904
|
+
var c;
|
|
905
|
+
R.current.update({ visibleTimeStart: o, visibleTimeEnd: i }), (c = Ae.current) == null || c.updateBounds(o, i), S.markAllDirty(), Ve(), Je("zoom");
|
|
906
|
+
}, u, a, I, B), []);
|
|
907
|
+
Ae.current = Qe;
|
|
908
|
+
const St = $((o) => {
|
|
909
|
+
const i = R.current, c = i.groupCount * i.lineHeight, f = Math.max(0, c - i.canvasHeight), n = Math.max(0, Math.min(f, i.scrollTop + o));
|
|
910
|
+
n !== i.scrollTop && (i.update({ scrollTop: n }), S.markDirty("grid"), S.markDirty("items"), S.markDirty("overlay"), Le(n));
|
|
911
|
+
}, [S]), et = $((o) => {
|
|
912
|
+
var b, k, H;
|
|
913
|
+
const i = R.current, c = i.canvasWidth / (i.visibleTimeEnd - i.visibleTimeStart), f = o / c, n = i.visibleTimeStart + f, h = i.visibleTimeEnd + f;
|
|
914
|
+
i.update({ visibleTimeStart: n, visibleTimeEnd: h }), (b = Ae.current) == null || b.updateBounds(n, h), S.markAllDirty(), ir(() => we()), (H = (k = O.current).onTimeChange) == null || H.call(k, n, h);
|
|
915
|
+
}, [S, we]);
|
|
916
|
+
re(() => {
|
|
917
|
+
const o = Re.current;
|
|
918
|
+
if (!o)
|
|
919
|
+
return;
|
|
920
|
+
const i = (c) => {
|
|
921
|
+
if (c.ctrlKey || c.metaKey || c.altKey) {
|
|
922
|
+
c.preventDefault();
|
|
923
|
+
const f = o.getBoundingClientRect(), n = (c.clientX - f.left) / f.width;
|
|
924
|
+
Qe.handleWheelZoom(c, n);
|
|
925
|
+
} else if (c.shiftKey)
|
|
926
|
+
c.preventDefault(), et(c.deltaY);
|
|
927
|
+
else {
|
|
928
|
+
const f = c.deltaX;
|
|
929
|
+
f !== 0 && Math.abs(f) > Math.abs(c.deltaY) ? (c.preventDefault(), et(f)) : c.deltaY !== 0 && St(c.deltaY);
|
|
930
|
+
}
|
|
931
|
+
};
|
|
932
|
+
return o.addEventListener("wheel", i, { passive: !1 }), () => o.removeEventListener("wheel", i);
|
|
933
|
+
}, [Qe, St, et]);
|
|
934
|
+
const ge = L({ lastDistance: null, lastCenter: null });
|
|
935
|
+
re(() => {
|
|
936
|
+
const o = Re.current;
|
|
937
|
+
if (!o)
|
|
938
|
+
return;
|
|
939
|
+
const i = (b, k) => Math.abs(b.clientX - k.clientX), c = (b, k, H) => (b.clientX + k.clientX) / 2 - H.left, f = (b) => {
|
|
940
|
+
b.touches.length === 2 && (b.preventDefault(), ge.current.lastDistance = i(b.touches[0], b.touches[1]), ge.current.lastCenter = null);
|
|
941
|
+
}, n = (b) => {
|
|
942
|
+
var k;
|
|
943
|
+
if (b.touches.length === 2 && ge.current.lastDistance !== null) {
|
|
944
|
+
b.preventDefault();
|
|
945
|
+
const H = i(b.touches[0], b.touches[1]), D = o.getBoundingClientRect(), z = c(b.touches[0], b.touches[1], D) / D.width;
|
|
946
|
+
if (H !== 0 && ge.current.lastDistance !== 0) {
|
|
947
|
+
const A = ge.current.lastDistance / H, ee = R.current, U = ee.visibleTimeEnd - ee.visibleTimeStart;
|
|
948
|
+
let w = U * A;
|
|
949
|
+
w = Math.max(I, Math.min(B, w));
|
|
950
|
+
const m = ee.visibleTimeStart + U * z, te = m - w * z, _ = m + w * (1 - z);
|
|
951
|
+
ee.update({ visibleTimeStart: te, visibleTimeEnd: _ }), (k = Ae.current) == null || k.updateBounds(te, _), S.markAllDirty(), Ve(), Je("zoom");
|
|
952
|
+
}
|
|
953
|
+
ge.current.lastDistance = H;
|
|
954
|
+
}
|
|
955
|
+
}, h = () => {
|
|
956
|
+
ge.current.lastDistance = null, ge.current.lastCenter = null;
|
|
957
|
+
};
|
|
958
|
+
return o.addEventListener("touchstart", f, { passive: !1 }), o.addEventListener("touchmove", n, { passive: !1 }), o.addEventListener("touchend", h), () => {
|
|
959
|
+
o.removeEventListener("touchstart", f), o.removeEventListener("touchmove", n), o.removeEventListener("touchend", h);
|
|
960
|
+
};
|
|
961
|
+
}, [S, Ve, Je]);
|
|
962
|
+
const Vt = $((o) => {
|
|
963
|
+
var H;
|
|
964
|
+
const i = o.currentTarget, c = i.getBoundingClientRect(), f = o.clientX - c.left, n = o.clientY - c.top;
|
|
965
|
+
if ($e.current = f, N.isPending()) {
|
|
966
|
+
if (N.update(f, n), N.isActive()) {
|
|
967
|
+
const D = N.getState();
|
|
968
|
+
if (D && D.mode === "move" && O.current.canChangeGroup) {
|
|
969
|
+
const x = it(n, R.current, O.current.groups);
|
|
970
|
+
x && N.setCurrentGroup(x.id);
|
|
971
|
+
}
|
|
972
|
+
S.markDirty("overlay");
|
|
973
|
+
}
|
|
974
|
+
return;
|
|
975
|
+
}
|
|
976
|
+
O.current.showCursorLine && S.markDirty("overlay");
|
|
977
|
+
const h = O.current, b = Fe(f, n, R.current, h.intervalTree, h.layoutEngine, h.groups), k = b == null ? void 0 : b.id;
|
|
978
|
+
if (k !== De.current && (De.current = k, S.markDirty("items"), (H = h.onItemHover) == null || H.call(h, k ?? null, o.nativeEvent)), b) {
|
|
979
|
+
const D = Ct(f, b, R.current), x = h.canResize;
|
|
980
|
+
D === "left" && (x === "left" || x === "both") || D === "right" && (x === "right" || x === "both") ? i.style.cursor = "col-resize" : h.canMove ? i.style.cursor = "grab" : i.style.cursor = "default";
|
|
981
|
+
} else
|
|
982
|
+
i.style.cursor = "default";
|
|
983
|
+
}, [N, S]), Zt = $((o) => {
|
|
984
|
+
const i = O.current, c = o.currentTarget.getBoundingClientRect(), f = o.clientX - c.left, n = o.clientY - c.top, h = Fe(f, n, R.current, i.intervalTree, i.layoutEngine, i.groups);
|
|
985
|
+
if (!h)
|
|
986
|
+
return;
|
|
987
|
+
const b = Ct(f, h, R.current), k = i.canResize;
|
|
988
|
+
b === "left" && (k === "left" || k === "both") ? N.startInteraction(h, "resize-left", f, n) : b === "right" && (k === "right" || k === "both") ? N.startInteraction(h, "resize-right", f, n) : i.canMove && N.startInteraction(h, "move", f, n);
|
|
989
|
+
}, [N]), qt = $((o) => {
|
|
990
|
+
var b, k, H, D, x, z;
|
|
991
|
+
const i = o.currentTarget;
|
|
992
|
+
if (N.isActive()) {
|
|
993
|
+
const A = N.getState(), ee = R.current, U = ee.canvasWidth / (ee.visibleTimeEnd - ee.visibleTimeStart);
|
|
994
|
+
if (A) {
|
|
995
|
+
const w = O.current.moveResizeValidator;
|
|
996
|
+
if (A.mode === "move") {
|
|
997
|
+
const m = N.endMove(U);
|
|
998
|
+
if (m) {
|
|
999
|
+
const te = w ? w("move", A.item.id, m.newStartTime) : m.newStartTime;
|
|
1000
|
+
(k = (b = O.current).onItemMove) == null || k.call(b, A.item.id, te, m.newGroupId);
|
|
1001
|
+
}
|
|
1002
|
+
} else {
|
|
1003
|
+
const m = N.endResize(U);
|
|
1004
|
+
if (m) {
|
|
1005
|
+
const te = w ? w("resize", A.item.id, m.newTime, m.edge) : m.newTime;
|
|
1006
|
+
(D = (H = O.current).onItemResize) == null || D.call(H, A.item.id, te, m.edge);
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
i.style.cursor = "default", S.markDirty("overlay");
|
|
1011
|
+
return;
|
|
1012
|
+
}
|
|
1013
|
+
N.isPending() && N.cancel();
|
|
1014
|
+
const c = i.getBoundingClientRect(), f = o.clientX - c.left, n = o.clientY - c.top, h = Fe(f, n, R.current, O.current.intervalTree, O.current.layoutEngine, O.current.groups);
|
|
1015
|
+
h && ((z = (x = O.current).onItemClick) == null || z.call(x, h.id, o.nativeEvent));
|
|
1016
|
+
}, [N, S]), Ut = $((o) => {
|
|
1017
|
+
var b, k;
|
|
1018
|
+
const i = o.currentTarget.getBoundingClientRect(), c = o.clientX - i.left, f = o.clientY - i.top, n = O.current, h = Fe(c, f, R.current, n.intervalTree, n.layoutEngine, n.groups);
|
|
1019
|
+
if (h)
|
|
1020
|
+
(b = n.onItemDoubleClick) == null || b.call(n, h.id, o.nativeEvent);
|
|
1021
|
+
else {
|
|
1022
|
+
const H = it(f, R.current, n.groups), D = R.current.xToTime(c);
|
|
1023
|
+
H && ((k = n.onCanvasDoubleClick) == null || k.call(n, H.id, D));
|
|
1024
|
+
}
|
|
1025
|
+
}, []), Kt = $((o) => {
|
|
1026
|
+
var b, k;
|
|
1027
|
+
o.preventDefault();
|
|
1028
|
+
const i = o.currentTarget.getBoundingClientRect(), c = o.clientX - i.left, f = o.clientY - i.top, n = O.current, h = Fe(c, f, R.current, n.intervalTree, n.layoutEngine, n.groups);
|
|
1029
|
+
if (h)
|
|
1030
|
+
(b = n.onItemContextMenu) == null || b.call(n, h.id, o.nativeEvent);
|
|
1031
|
+
else {
|
|
1032
|
+
const H = it(f, R.current, n.groups), D = R.current.xToTime(c);
|
|
1033
|
+
H && ((k = n.onCanvasContextMenu) == null || k.call(n, H.id, D, o.nativeEvent));
|
|
1034
|
+
}
|
|
1035
|
+
}, []), Jt = $(() => {
|
|
1036
|
+
var o, i;
|
|
1037
|
+
$e.current = null, Re.current && (Re.current.style.cursor = "default"), De.current !== void 0 && (De.current = void 0, S.markDirty("items"), (i = (o = O.current).onItemHover) == null || i.call(o, null, new PointerEvent("pointerleave"))), O.current.showCursorLine && S.markDirty("overlay");
|
|
1038
|
+
}, [S]), Qt = Q(() => {
|
|
1039
|
+
const o = [];
|
|
1040
|
+
return ie.Children.forEach(he, (i) => {
|
|
1041
|
+
var f;
|
|
1042
|
+
if (!ie.isValidElement(i))
|
|
1043
|
+
return;
|
|
1044
|
+
if (((f = i.type) == null ? void 0 : f.displayName) === "TimelineHeaders") {
|
|
1045
|
+
const n = i.props;
|
|
1046
|
+
o.push(ie.cloneElement(i, {
|
|
1047
|
+
visibleTimeStart: n.visibleTimeStart ?? vt,
|
|
1048
|
+
visibleTimeEnd: n.visibleTimeEnd ?? bt,
|
|
1049
|
+
canvasWidth: n.canvasWidth ?? fe,
|
|
1050
|
+
sidebarWidth: n.sidebarWidth ?? v,
|
|
1051
|
+
theme: n.theme ?? ye,
|
|
1052
|
+
onZoomToInterval: n.onZoomToInterval ?? ((h, b) => {
|
|
1053
|
+
var k, H, D, x;
|
|
1054
|
+
R.current.update({ visibleTimeStart: h, visibleTimeEnd: b }), S.markAllDirty(), we(), (H = (k = O.current).onTimeChange) == null || H.call(k, h, b), (x = (D = O.current).onZoom) == null || x.call(D, h, b);
|
|
1055
|
+
})
|
|
1056
|
+
}));
|
|
1057
|
+
}
|
|
1058
|
+
}), o;
|
|
1059
|
+
}, [he, vt, bt, fe, v, ye, S, we]), Et = L(!1);
|
|
1060
|
+
re(() => {
|
|
1061
|
+
Et.current || (Et.current = !0, S.markAllDirty());
|
|
1062
|
+
}, [S]), rr(r, () => ({
|
|
1063
|
+
captureToCanvas({ timeStart: o, timeEnd: i, scale: c, sidebarWidth: f }) {
|
|
1064
|
+
const n = O.current, h = 28, b = h * 3, k = n.groups.length * n.lineHeight, H = R.current, D = n.canvasWidth / (H.visibleTimeEnd - H.visibleTimeStart), x = i - o, z = Math.max(n.canvasWidth, Math.round(x * D)), A = (f + z) * c, ee = (b + k) * c, U = document.createElement("canvas");
|
|
1065
|
+
U.width = A, U.height = ee;
|
|
1066
|
+
const w = U.getContext("2d");
|
|
1067
|
+
w.scale(c, c);
|
|
1068
|
+
for (let _ = 0; _ < n.groups.length; _++) {
|
|
1069
|
+
const ue = n.groups[_], ce = b + _ * n.lineHeight;
|
|
1070
|
+
if (n.rowStyle) {
|
|
1071
|
+
const Y = n.rowStyle(ue);
|
|
1072
|
+
Y != null && Y.backgroundColor && (w.fillStyle = Y.backgroundColor, w.fillRect(0, ce, f, n.lineHeight));
|
|
1073
|
+
}
|
|
1074
|
+
const F = ue.type;
|
|
1075
|
+
let K = "400", J = 8;
|
|
1076
|
+
F === "project" ? K = "700" : F === "CAG" ? K = "600" : F === "CA" && (K = "400", J = 24), w.fillStyle = "#111", w.font = `${K} 12px sans-serif`, w.textBaseline = "middle", w.fillText(ue.title, J, ce + n.lineHeight / 2, f - J - 4);
|
|
1077
|
+
}
|
|
1078
|
+
const m = (_, ue, ce) => {
|
|
1079
|
+
var J, Y;
|
|
1080
|
+
w.fillStyle = ((J = n.theme.header) == null ? void 0 : J.bg) ?? "#f5f5f5", w.fillRect(f, _, z, h), w.strokeStyle = ((Y = n.theme.grid) == null ? void 0 : Y.line) ?? "#e0e0e0", w.lineWidth = 1, w.strokeRect(f, _, z, h);
|
|
1081
|
+
let F = ne(o).startOf(ce);
|
|
1082
|
+
F.valueOf() < o && (F = F.add(1, ce));
|
|
1083
|
+
const K = z / (i - o);
|
|
1084
|
+
for (; F.valueOf() < i; ) {
|
|
1085
|
+
const ve = F.add(1, ce), se = f + (F.valueOf() - o) * K, de = f + (Math.min(ve.valueOf(), i) - o) * K - se;
|
|
1086
|
+
w.beginPath(), w.moveTo(se, _), w.lineTo(se, _ + h), w.stroke(), w.fillStyle = "#333", w.font = "600 11px sans-serif", w.textBaseline = "middle", w.textAlign = "center", w.fillText(ue(F), se + de / 2, _ + h / 2, de - 4), F = ve;
|
|
1087
|
+
}
|
|
1088
|
+
w.textAlign = "start";
|
|
1089
|
+
};
|
|
1090
|
+
m(0, (_) => _.format("YYYY"), "year"), m(h, (_) => _.format("MM"), "month"), m(h * 2, (_) => String(_.isoWeek()), "week");
|
|
1091
|
+
const te = new rt({
|
|
1092
|
+
visibleTimeStart: o,
|
|
1093
|
+
visibleTimeEnd: i,
|
|
1094
|
+
canvasWidth: z,
|
|
1095
|
+
canvasHeight: k,
|
|
1096
|
+
sidebarWidth: 0,
|
|
1097
|
+
lineHeight: n.lineHeight,
|
|
1098
|
+
groupCount: n.groups.length,
|
|
1099
|
+
buffer: 1,
|
|
1100
|
+
scrollTop: 0
|
|
1101
|
+
});
|
|
1102
|
+
return w.save(), w.translate(f, b), w.beginPath(), w.rect(0, 0, z, k), w.clip(), Se.draw(w, te, n.groups, n.theme, n.dayStyle, n.rowStyle), Ee.draw(w, te, n.groups, n.items, n.intervalTree, n.layoutEngine, n.itemRenderer, n.groupRenderer, n.theme, n.selected, void 0, n.dependencies), Ce.draw(w, te, n.theme, {
|
|
1103
|
+
cursorX: null,
|
|
1104
|
+
snapX: null,
|
|
1105
|
+
markers: Pe.current,
|
|
1106
|
+
interaction: null
|
|
1107
|
+
}), w.restore(), U;
|
|
1108
|
+
}
|
|
1109
|
+
}), [Se, Ee, Ce]), re(() => {
|
|
1110
|
+
const o = {
|
|
1111
|
+
captureToCanvas({ timeStart: i, timeEnd: c, scale: f, sidebarWidth: n }) {
|
|
1112
|
+
var ce;
|
|
1113
|
+
const h = O.current, b = 28, k = b * 3, H = h.groups.length * h.lineHeight, D = R.current, x = h.canvasWidth / (D.visibleTimeEnd - D.visibleTimeStart), z = c - i, A = Math.max(h.canvasWidth, Math.round(z * x)), ee = n + A, U = k + H, w = document.createElement("canvas");
|
|
1114
|
+
w.width = ee * f, w.height = U * f;
|
|
1115
|
+
const m = w.getContext("2d");
|
|
1116
|
+
m.scale(f, f), m.fillStyle = "#FFFFFF", m.fillRect(0, 0, ee, U), m.save(), m.beginPath(), m.rect(0, 0, n, U), m.clip(), m.fillStyle = "#F9FAFB", m.fillRect(0, 0, n, k), m.strokeStyle = "#E5E7EB", m.lineWidth = 1, m.strokeRect(0, 0, n, k);
|
|
1117
|
+
for (let F = 0; F < h.groups.length; F++) {
|
|
1118
|
+
const K = h.groups[F], J = k + F * h.lineHeight, Y = (ce = h.rowStyle) == null ? void 0 : ce.call(h, K);
|
|
1119
|
+
m.fillStyle = (Y == null ? void 0 : Y.backgroundColor) ?? (F % 2 === 0 ? "#FFFFFF" : "#F7F7F7"), m.fillRect(0, J, n, h.lineHeight), m.strokeStyle = "#E5E5E5", m.lineWidth = 0.5, m.beginPath(), m.moveTo(0, J + h.lineHeight), m.lineTo(n, J + h.lineHeight), m.stroke();
|
|
1120
|
+
const ve = K.type ?? "";
|
|
1121
|
+
let se = 8, Te = "400", de = 11;
|
|
1122
|
+
ve === "project" ? (Te = "700", de = 12) : ve === "control_area_group" ? Te = "600" : ve === "control_area" && (se = 24), m.fillStyle = "#374151", m.font = `${Te} ${de}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`, m.textBaseline = "middle";
|
|
1123
|
+
const Me = typeof K.title == "string" ? K.title : String(K.title);
|
|
1124
|
+
m.fillText(Me, se, J + h.lineHeight / 2, n - se - 8);
|
|
1125
|
+
}
|
|
1126
|
+
m.strokeStyle = "#E5E7EB", m.lineWidth = 1, m.beginPath(), m.moveTo(n, 0), m.lineTo(n, U), m.stroke(), m.restore(), m.save(), m.beginPath(), m.rect(n, 0, A, k), m.clip();
|
|
1127
|
+
const te = c - i, _ = [
|
|
1128
|
+
{ unit: "year", row: 0 },
|
|
1129
|
+
{ unit: "month", row: 1 },
|
|
1130
|
+
{ unit: "week", row: 2 }
|
|
1131
|
+
];
|
|
1132
|
+
for (const { unit: F, row: K } of _) {
|
|
1133
|
+
const J = K * b;
|
|
1134
|
+
m.fillStyle = "#F9FAFB", m.fillRect(n, J, A, b);
|
|
1135
|
+
let Y = ne(i).startOf(F);
|
|
1136
|
+
const ve = ne(c).add(1, F);
|
|
1137
|
+
for (; Y.isBefore(ve); ) {
|
|
1138
|
+
const se = Y.add(1, F), Te = n + (Y.valueOf() - i) / te * A, de = (se.valueOf() - Y.valueOf()) / te * A;
|
|
1139
|
+
m.strokeStyle = "#E5E7EB", m.lineWidth = 0.5, m.strokeRect(Te, J, de, b);
|
|
1140
|
+
let Me;
|
|
1141
|
+
F === "year" ? Me = Y.format("YYYY") : F === "month" ? Me = Y.format("MM") : Me = `${Y.week()}`, m.fillStyle = "#6c737f", m.font = F === "year" ? '600 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif' : '400 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif', m.textBaseline = "middle", m.textAlign = "center", de > 20 && m.fillText(Me, Te + de / 2, J + b / 2), Y = se;
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
m.textAlign = "start", m.restore(), m.save(), m.beginPath(), m.rect(n, k, A, H), m.clip(), m.translate(n, k);
|
|
1145
|
+
const ue = new rt({
|
|
1146
|
+
visibleTimeStart: i,
|
|
1147
|
+
visibleTimeEnd: c,
|
|
1148
|
+
canvasWidth: A,
|
|
1149
|
+
canvasHeight: H,
|
|
1150
|
+
sidebarWidth: 0,
|
|
1151
|
+
lineHeight: h.lineHeight,
|
|
1152
|
+
groupCount: h.groups.length,
|
|
1153
|
+
buffer: 1,
|
|
1154
|
+
scrollTop: 0
|
|
1155
|
+
});
|
|
1156
|
+
return Se.draw(m, ue, h.groups, h.theme, h.dayStyle, h.rowStyle), Ee.draw(m, ue, h.groups, h.items, h.intervalTree, h.layoutEngine, h.itemRenderer, h.groupRenderer, h.theme, h.selected, void 0, h.dependencies), Ce.draw(m, ue, h.theme, { cursorX: null, markers: Pe.current }), m.restore(), w;
|
|
1157
|
+
}
|
|
1158
|
+
};
|
|
1159
|
+
Xe == null || Xe(o);
|
|
1160
|
+
}, [Xe, Se, Ee, Ce]);
|
|
1161
|
+
const er = {
|
|
1162
|
+
position: "relative",
|
|
1163
|
+
width: fe,
|
|
1164
|
+
height: me,
|
|
1165
|
+
overflow: "hidden",
|
|
1166
|
+
cursor: "default"
|
|
1167
|
+
}, tt = { position: "absolute", top: 0, left: 0 };
|
|
1168
|
+
return je("div", { ref: mt, style: { display: "flex", flexDirection: "column", width: "100%" }, children: [Qt, je("div", { ref: At, style: { display: "flex", overflow: "hidden" }, children: [Z(Dt, { groups: s, width: v, lineHeight: d, scrollTop: pt, canvasHeight: me, theme: ye, groupRenderer: le, onScroll: (o) => {
|
|
1169
|
+
R.current.update({ scrollTop: o }), S.markDirty("grid"), S.markDirty("items"), S.markDirty("overlay"), Le(o);
|
|
1170
|
+
} }), je("div", { ref: Re, style: er, onPointerMove: Vt, onPointerDown: Zt, onPointerUp: qt, onDoubleClick: Ut, onContextMenu: Kt, onPointerLeave: Jt, children: [Z("canvas", { ref: dt, style: { ...tt, zIndex: 0 } }), Z("canvas", { ref: ht, style: { ...tt, zIndex: 1 } }), Z("canvas", { ref: ft, style: { ...tt, zIndex: 2 } })] }), Ge && ut ? Z(Dt, { groups: s, width: Ge, lineHeight: d, scrollTop: pt, canvasHeight: me, theme: ye, groupRenderer: ut, onScroll: (o) => {
|
|
1171
|
+
R.current.update({ scrollTop: o }), S.markDirty("grid"), S.markDirty("items"), S.markDirty("overlay"), Le(o);
|
|
1172
|
+
} }) : null] })] });
|
|
1173
|
+
}));
|
|
1174
|
+
function Tr({ children: t, theme: e, className: r, classNames: s, style: l, visibleTimeStart: u, visibleTimeEnd: a, canvasWidth: v, sidebarWidth: d = 0, onZoomToInterval: g }) {
|
|
1175
|
+
const y = ie.Children.map(t, (p) => {
|
|
1176
|
+
var T;
|
|
1177
|
+
if (!ie.isValidElement(p))
|
|
1178
|
+
return p;
|
|
1179
|
+
if (((T = p.type) == null ? void 0 : T.displayName) === "DateHeader") {
|
|
1180
|
+
const C = p.props, I = ie.cloneElement(p, {
|
|
1181
|
+
visibleTimeStart: C.visibleTimeStart ?? u,
|
|
1182
|
+
visibleTimeEnd: C.visibleTimeEnd ?? a,
|
|
1183
|
+
canvasWidth: C.canvasWidth ?? v,
|
|
1184
|
+
theme: C.theme ?? e,
|
|
1185
|
+
onZoomToInterval: C.onIntervalClick ?? C.onZoomToInterval ?? g
|
|
1186
|
+
});
|
|
1187
|
+
return je("div", { style: { display: "flex" }, children: [Z("div", { style: { width: d, flexShrink: 0 } }), Z("div", { style: { flex: 1, overflow: "hidden" }, children: I })] });
|
|
1188
|
+
}
|
|
1189
|
+
return p;
|
|
1190
|
+
});
|
|
1191
|
+
return Z("div", { className: r, style: {
|
|
1192
|
+
position: "sticky",
|
|
1193
|
+
top: 0,
|
|
1194
|
+
zIndex: 20,
|
|
1195
|
+
display: "flex",
|
|
1196
|
+
flexDirection: "column",
|
|
1197
|
+
backgroundColor: (e == null ? void 0 : e.header.bg) ?? "#F9FAFB",
|
|
1198
|
+
borderTop: `1px solid ${(e == null ? void 0 : e.header.border) ?? "#E5E7EB"}`,
|
|
1199
|
+
borderBottom: `1px solid ${(e == null ? void 0 : e.header.border) ?? "#E5E7EB"}`,
|
|
1200
|
+
...l
|
|
1201
|
+
}, children: y });
|
|
1202
|
+
}
|
|
1203
|
+
Tr.displayName = "TimelineHeaders";
|
|
1204
|
+
var _t = { exports: {} };
|
|
1205
|
+
(function(t, e) {
|
|
1206
|
+
(function(r, s) {
|
|
1207
|
+
t.exports = s();
|
|
1208
|
+
})(Wt, function() {
|
|
1209
|
+
var r = "week", s = "year";
|
|
1210
|
+
return function(l, u, a) {
|
|
1211
|
+
var v = u.prototype;
|
|
1212
|
+
v.week = function(d) {
|
|
1213
|
+
if (d === void 0 && (d = null), d !== null) return this.add(7 * (d - this.week()), "day");
|
|
1214
|
+
var g = this.$locale().yearStart || 1;
|
|
1215
|
+
if (this.month() === 11 && this.date() > 25) {
|
|
1216
|
+
var y = a(this).startOf(s).add(1, s).date(g), p = a(this).endOf(r);
|
|
1217
|
+
if (y.isBefore(p)) return 1;
|
|
1218
|
+
}
|
|
1219
|
+
var M = a(this).startOf(s).date(g).startOf(r).subtract(1, "millisecond"), T = this.diff(M, r, !0);
|
|
1220
|
+
return T < 0 ? a(this).startOf("week").week() : Math.ceil(T);
|
|
1221
|
+
}, v.weeks = function(d) {
|
|
1222
|
+
return d === void 0 && (d = null), this.week(d);
|
|
1223
|
+
};
|
|
1224
|
+
};
|
|
1225
|
+
});
|
|
1226
|
+
})(_t);
|
|
1227
|
+
var kr = _t.exports;
|
|
1228
|
+
const wr = /* @__PURE__ */ Xt(kr);
|
|
1229
|
+
ne.extend(wr);
|
|
1230
|
+
const Sr = {
|
|
1231
|
+
year: 30,
|
|
1232
|
+
month: 30,
|
|
1233
|
+
week: 20,
|
|
1234
|
+
day: 15,
|
|
1235
|
+
hour: 30
|
|
1236
|
+
};
|
|
1237
|
+
function Er({ unit: t, visibleTimeStart: e = 0, visibleTimeEnd: r = 0, canvasWidth: s = 0, theme: l, height: u = 28, className: a, labelFormat: v, onIntervalClick: d, minCellWidth: g, onZoomToInterval: y }) {
|
|
1238
|
+
const p = Q(() => {
|
|
1239
|
+
if (!e || !r || !s)
|
|
1240
|
+
return [];
|
|
1241
|
+
const T = r - e, C = g ?? Sr[t];
|
|
1242
|
+
if (C > 0) {
|
|
1243
|
+
const P = ne(e).startOf(t);
|
|
1244
|
+
if ((P.add(1, t).valueOf() - P.valueOf()) / T * s < C)
|
|
1245
|
+
return [];
|
|
1246
|
+
}
|
|
1247
|
+
const I = [];
|
|
1248
|
+
let B = ne(e).startOf(t).subtract(1, t);
|
|
1249
|
+
const E = ne(r).add(2, t).valueOf();
|
|
1250
|
+
for (; B.valueOf() < E; ) {
|
|
1251
|
+
const P = B.add(1, t), X = B.valueOf(), j = P.valueOf(), G = (X - e) / T * s, W = (j - X) / T * s, le = Cr(B, P, t, v);
|
|
1252
|
+
I.push({ start: X, end: j, label: le, left: G, width: W }), B = P;
|
|
1253
|
+
}
|
|
1254
|
+
return I;
|
|
1255
|
+
}, [e, r, s, t, v, g]), M = $((T, C) => {
|
|
1256
|
+
d ? d(T, C) : y && y(T, C);
|
|
1257
|
+
}, [d, y]);
|
|
1258
|
+
return p.length === 0 ? null : Z("div", { style: { display: "flex", position: "relative", height: u, overflow: "hidden" }, children: p.map((T) => Z("div", { className: a, onClick: () => M(T.start, T.end), style: {
|
|
1259
|
+
position: "absolute",
|
|
1260
|
+
left: T.left,
|
|
1261
|
+
width: T.width,
|
|
1262
|
+
height: "100%",
|
|
1263
|
+
display: "flex",
|
|
1264
|
+
alignItems: "center",
|
|
1265
|
+
justifyContent: "center",
|
|
1266
|
+
borderRight: `1px solid ${(l == null ? void 0 : l.header.border) ?? "#E5E7EB"}`,
|
|
1267
|
+
borderBottom: `1px solid ${(l == null ? void 0 : l.header.border) ?? "#E5E7EB"}`,
|
|
1268
|
+
fontSize: 12,
|
|
1269
|
+
color: (l == null ? void 0 : l.header.text) ?? "#6c737f",
|
|
1270
|
+
backgroundColor: (l == null ? void 0 : l.header.bg) ?? "#F9FAFB",
|
|
1271
|
+
overflow: "hidden",
|
|
1272
|
+
whiteSpace: "nowrap",
|
|
1273
|
+
cursor: "pointer",
|
|
1274
|
+
userSelect: "none",
|
|
1275
|
+
padding: "0 4px",
|
|
1276
|
+
boxSizing: "border-box"
|
|
1277
|
+
}, children: Z("span", { children: T.label }) }, T.start)) });
|
|
1278
|
+
}
|
|
1279
|
+
Er.displayName = "DateHeader";
|
|
1280
|
+
function Cr(t, e, r, s, l) {
|
|
1281
|
+
return typeof s == "function" ? s(t.toDate(), e.toDate(), r) : typeof s == "string" ? t.format(s) : Mr(t, r);
|
|
1282
|
+
}
|
|
1283
|
+
function Mr(t, e) {
|
|
1284
|
+
switch (e) {
|
|
1285
|
+
case "year":
|
|
1286
|
+
return t.format("YYYY");
|
|
1287
|
+
case "month":
|
|
1288
|
+
return t.format("MM");
|
|
1289
|
+
case "week":
|
|
1290
|
+
return `${t.week()}`;
|
|
1291
|
+
case "day":
|
|
1292
|
+
return t.format("D");
|
|
1293
|
+
case "hour":
|
|
1294
|
+
return t.format("HH:mm");
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
function Hr({ width: t, children: e, style: r }) {
|
|
1298
|
+
const s = () => ({ style: { width: t, ...r } });
|
|
1299
|
+
return e ? Z(Ft, { children: e({ getRootProps: s }) }) : Z("div", { style: { width: t } });
|
|
1300
|
+
}
|
|
1301
|
+
Hr.displayName = "SidebarHeader";
|
|
1302
|
+
function Rr({ children: t }) {
|
|
1303
|
+
return Z(Ft, { children: t });
|
|
1304
|
+
}
|
|
1305
|
+
Rr.displayName = "CustomHeader";
|
|
1306
|
+
export {
|
|
1307
|
+
Fr as CanvasTimeline,
|
|
1308
|
+
Rr as CustomHeader,
|
|
1309
|
+
pr as CustomMarker,
|
|
1310
|
+
be as DEFAULT_THEME,
|
|
1311
|
+
Er as DateHeader,
|
|
1312
|
+
Hr as SidebarHeader,
|
|
1313
|
+
Tr as TimelineHeaders,
|
|
1314
|
+
vr as TodayMarker
|
|
1315
|
+
};
|
|
1316
|
+
//# sourceMappingURL=canvas-timeline.es.js.map
|