@taskctrl/canvas-timeline 0.4.5 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsx as se, jsxs as
|
|
2
|
-
import
|
|
3
|
-
import { flushSync as
|
|
4
|
-
import
|
|
5
|
-
const
|
|
1
|
+
import { jsx as se, jsxs as xe, Fragment as $t } from "react/jsx-runtime";
|
|
2
|
+
import me, { useRef as x, useMemo as Q, useCallback as ne, useEffect as he, forwardRef as pi, useState as tt, useImperativeHandle as vi } from "react";
|
|
3
|
+
import { flushSync as bi } from "react-dom";
|
|
4
|
+
import ve from "dayjs";
|
|
5
|
+
const Ce = {
|
|
6
6
|
primary: "#269bf7",
|
|
7
7
|
trainColors: {},
|
|
8
8
|
status: { red: "#EF5350", yellow: "#FBBF24", green: "#31c48d" },
|
|
@@ -12,7 +12,7 @@ const Ee = {
|
|
|
12
12
|
sidebar: { bg: "#F9FAFB", border: "#E5E7EB", text: "#6c737f" },
|
|
13
13
|
header: { bg: "#F9FAFB", border: "#E5E7EB", text: "#6c737f" }
|
|
14
14
|
};
|
|
15
|
-
class
|
|
15
|
+
class ft {
|
|
16
16
|
constructor(e) {
|
|
17
17
|
Object.defineProperty(this, "visibleTimeStart", {
|
|
18
18
|
enumerable: !0,
|
|
@@ -59,6 +59,11 @@ class ut {
|
|
|
59
59
|
configurable: !0,
|
|
60
60
|
writable: !0,
|
|
61
61
|
value: void 0
|
|
62
|
+
}), Object.defineProperty(this, "groupHeights", {
|
|
63
|
+
enumerable: !0,
|
|
64
|
+
configurable: !0,
|
|
65
|
+
writable: !0,
|
|
66
|
+
value: void 0
|
|
62
67
|
}), Object.defineProperty(this, "visibleDuration", {
|
|
63
68
|
enumerable: !0,
|
|
64
69
|
configurable: !0,
|
|
@@ -69,10 +74,25 @@ class ut {
|
|
|
69
74
|
configurable: !0,
|
|
70
75
|
writable: !0,
|
|
71
76
|
value: void 0
|
|
72
|
-
}),
|
|
77
|
+
}), Object.defineProperty(this, "groupYOffsets", {
|
|
78
|
+
enumerable: !0,
|
|
79
|
+
configurable: !0,
|
|
80
|
+
writable: !0,
|
|
81
|
+
value: void 0
|
|
82
|
+
}), 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.groupHeights = e.groupHeights ?? null, this.visibleDuration = this.visibleTimeEnd - this.visibleTimeStart, this.pixelsPerMs = this.canvasWidth / this.visibleDuration, this.groupYOffsets = [], this.recomputeGroupYOffsets();
|
|
73
83
|
}
|
|
74
84
|
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;
|
|
85
|
+
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), e.groupHeights !== void 0 && (this.groupHeights = e.groupHeights ?? null), this.visibleDuration = this.visibleTimeEnd - this.visibleTimeStart, this.pixelsPerMs = this.canvasWidth / this.visibleDuration, this.recomputeGroupYOffsets();
|
|
86
|
+
}
|
|
87
|
+
recomputeGroupYOffsets() {
|
|
88
|
+
var t;
|
|
89
|
+
const e = new Array(this.groupCount + 1);
|
|
90
|
+
e[0] = 0;
|
|
91
|
+
for (let n = 0; n < this.groupCount; n++) {
|
|
92
|
+
const o = ((t = this.groupHeights) == null ? void 0 : t[n]) ?? this.lineHeight;
|
|
93
|
+
e[n + 1] = e[n] + o;
|
|
94
|
+
}
|
|
95
|
+
this.groupYOffsets = e;
|
|
76
96
|
}
|
|
77
97
|
timeToX(e) {
|
|
78
98
|
return (e - this.visibleTimeStart) * this.pixelsPerMs;
|
|
@@ -81,11 +101,26 @@ class ut {
|
|
|
81
101
|
return this.visibleTimeStart + e / this.pixelsPerMs;
|
|
82
102
|
}
|
|
83
103
|
yToGroupIndex(e) {
|
|
84
|
-
|
|
85
|
-
|
|
104
|
+
if (this.groupCount === 0)
|
|
105
|
+
return 0;
|
|
106
|
+
const t = e + this.scrollTop;
|
|
107
|
+
if (t <= 0)
|
|
108
|
+
return 0;
|
|
109
|
+
if (t >= this.groupYOffsets[this.groupCount])
|
|
110
|
+
return this.groupCount - 1;
|
|
111
|
+
let n = 0, o = this.groupCount - 1;
|
|
112
|
+
for (; n < o; ) {
|
|
113
|
+
const d = n + o >>> 1;
|
|
114
|
+
this.groupYOffsets[d + 1] > t ? o = d : n = d + 1;
|
|
115
|
+
}
|
|
116
|
+
return n;
|
|
86
117
|
}
|
|
87
118
|
groupIndexToY(e) {
|
|
88
|
-
return e
|
|
119
|
+
return e < 0 ? -this.scrollTop : e >= this.groupCount ? (this.groupYOffsets[this.groupCount] ?? 0) - this.scrollTop : this.groupYOffsets[e] - this.scrollTop;
|
|
120
|
+
}
|
|
121
|
+
groupIndexToHeight(e) {
|
|
122
|
+
var t;
|
|
123
|
+
return e < 0 || e >= this.groupCount ? this.lineHeight : ((t = this.groupHeights) == null ? void 0 : t[e]) ?? this.lineHeight;
|
|
89
124
|
}
|
|
90
125
|
getBufferBounds() {
|
|
91
126
|
const e = this.visibleDuration * 1.5;
|
|
@@ -95,18 +130,20 @@ class ut {
|
|
|
95
130
|
};
|
|
96
131
|
}
|
|
97
132
|
getVisibleGroupRange() {
|
|
98
|
-
|
|
99
|
-
|
|
133
|
+
if (this.groupCount === 0)
|
|
134
|
+
return { firstVisible: 0, lastVisible: -1 };
|
|
135
|
+
const e = this.yToGroupIndex(0), t = this.yToGroupIndex(this.canvasHeight);
|
|
136
|
+
return { firstVisible: e, lastVisible: t };
|
|
100
137
|
}
|
|
101
138
|
isScrollInBuffer(e) {
|
|
102
139
|
const t = this.visibleDuration * 1.5 * this.pixelsPerMs;
|
|
103
140
|
return Math.abs(e) < t;
|
|
104
141
|
}
|
|
105
142
|
getTotalHeight() {
|
|
106
|
-
return this.groupCount
|
|
143
|
+
return this.groupYOffsets[this.groupCount] ?? 0;
|
|
107
144
|
}
|
|
108
145
|
}
|
|
109
|
-
class
|
|
146
|
+
class yi {
|
|
110
147
|
constructor() {
|
|
111
148
|
Object.defineProperty(this, "root", {
|
|
112
149
|
enumerable: !0,
|
|
@@ -116,42 +153,42 @@ class pi {
|
|
|
116
153
|
});
|
|
117
154
|
}
|
|
118
155
|
buildFromItems(e, t, n) {
|
|
119
|
-
const
|
|
156
|
+
const o = e.map((d) => ({
|
|
120
157
|
item: d,
|
|
121
158
|
start: t(d),
|
|
122
159
|
end: n(d)
|
|
123
160
|
}));
|
|
124
|
-
this.root = this.buildNode(
|
|
161
|
+
this.root = this.buildNode(o);
|
|
125
162
|
}
|
|
126
163
|
buildNode(e) {
|
|
127
164
|
if (e.length === 0)
|
|
128
165
|
return null;
|
|
129
166
|
let t = 1 / 0, n = -1 / 0;
|
|
130
|
-
for (const
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
for (const
|
|
134
|
-
|
|
167
|
+
for (const u of e)
|
|
168
|
+
u.start < t && (t = u.start), u.end > n && (n = u.end);
|
|
169
|
+
const o = (t + n) / 2, d = [], l = [], c = [];
|
|
170
|
+
for (const u of e)
|
|
171
|
+
u.end < o ? d.push(u) : u.start > o ? l.push(u) : c.push(u);
|
|
135
172
|
return {
|
|
136
|
-
center:
|
|
173
|
+
center: o,
|
|
137
174
|
left: this.buildNode(d),
|
|
138
|
-
right: this.buildNode(
|
|
139
|
-
overlapping:
|
|
175
|
+
right: this.buildNode(l),
|
|
176
|
+
overlapping: c
|
|
140
177
|
};
|
|
141
178
|
}
|
|
142
179
|
query(e, t) {
|
|
143
180
|
const n = [];
|
|
144
181
|
return this.queryNode(this.root, e, t, n), n;
|
|
145
182
|
}
|
|
146
|
-
queryNode(e, t, n,
|
|
183
|
+
queryNode(e, t, n, o) {
|
|
147
184
|
if (e !== null) {
|
|
148
185
|
for (const d of e.overlapping)
|
|
149
|
-
d.start <= n && d.end >= t &&
|
|
150
|
-
t <= e.center && e.left !== null && this.queryNode(e.left, t, n,
|
|
186
|
+
d.start <= n && d.end >= t && o.push(d.item);
|
|
187
|
+
t <= e.center && e.left !== null && this.queryNode(e.left, t, n, o), n >= e.center && e.right !== null && this.queryNode(e.right, t, n, o);
|
|
151
188
|
}
|
|
152
189
|
}
|
|
153
190
|
}
|
|
154
|
-
class
|
|
191
|
+
class Ti {
|
|
155
192
|
constructor(e, t) {
|
|
156
193
|
Object.defineProperty(this, "lineHeight", {
|
|
157
194
|
enumerable: !0,
|
|
@@ -177,65 +214,65 @@ class vi {
|
|
|
177
214
|
}
|
|
178
215
|
computeLayout(e, t, n) {
|
|
179
216
|
this.layoutCache = /* @__PURE__ */ new Map(), this.groupMaxStack = /* @__PURE__ */ new Map();
|
|
180
|
-
const
|
|
217
|
+
const o = this.lineHeight * this.itemHeightRatio, d = o * 0.6;
|
|
181
218
|
if (!t) {
|
|
182
|
-
for (const
|
|
183
|
-
const
|
|
184
|
-
this.layoutCache.set(
|
|
219
|
+
for (const c of e) {
|
|
220
|
+
const u = (n == null ? void 0 : n.isParent(c.id)) ?? !1;
|
|
221
|
+
this.layoutCache.set(c.id, { stackLevel: 0, itemHeight: u ? d : o }), this.groupMaxStack.set(c.group, 0);
|
|
185
222
|
}
|
|
186
223
|
return this.layoutCache;
|
|
187
224
|
}
|
|
188
|
-
const
|
|
189
|
-
for (const
|
|
190
|
-
let
|
|
191
|
-
|
|
225
|
+
const l = /* @__PURE__ */ new Map();
|
|
226
|
+
for (const c of e) {
|
|
227
|
+
let u = l.get(c.group);
|
|
228
|
+
u || (u = [], l.set(c.group, u)), u.push(c);
|
|
192
229
|
}
|
|
193
|
-
for (const [
|
|
194
|
-
n ? this.computeHierarchyLayout(
|
|
230
|
+
for (const [c, u] of l)
|
|
231
|
+
n ? this.computeHierarchyLayout(u, n, o, d, c) : this.computeFlatLayout(u, o, c);
|
|
195
232
|
return this.layoutCache;
|
|
196
233
|
}
|
|
197
234
|
computeFlatLayout(e, t, n) {
|
|
198
|
-
e.sort((
|
|
199
|
-
const
|
|
200
|
-
return
|
|
235
|
+
e.sort((l, c) => {
|
|
236
|
+
const u = l.start_time - c.start_time;
|
|
237
|
+
return u !== 0 ? u : c.end_time - c.start_time - (l.end_time - l.start_time);
|
|
201
238
|
});
|
|
202
|
-
const
|
|
239
|
+
const o = [];
|
|
203
240
|
let d = 0;
|
|
204
|
-
for (const
|
|
205
|
-
let
|
|
206
|
-
for (let
|
|
207
|
-
if (
|
|
208
|
-
|
|
241
|
+
for (const l of e) {
|
|
242
|
+
let c = -1;
|
|
243
|
+
for (let u = 0; u < o.length; u++)
|
|
244
|
+
if (o[u] <= l.start_time) {
|
|
245
|
+
c = u;
|
|
209
246
|
break;
|
|
210
247
|
}
|
|
211
|
-
|
|
248
|
+
c === -1 ? (c = o.length, o.push(l.end_time)) : o[c] = l.end_time, c > d && (d = c), this.layoutCache.set(l.id, { stackLevel: c, itemHeight: t });
|
|
212
249
|
}
|
|
213
250
|
this.groupMaxStack.set(n, d);
|
|
214
251
|
}
|
|
215
|
-
computeHierarchyLayout(e, t, n,
|
|
216
|
-
const
|
|
217
|
-
for (const
|
|
218
|
-
t.isParent(
|
|
219
|
-
|
|
220
|
-
const T =
|
|
221
|
-
return T !== 0 ? T : b.end_time - b.start_time - (
|
|
252
|
+
computeHierarchyLayout(e, t, n, o, d) {
|
|
253
|
+
const l = [], c = [];
|
|
254
|
+
for (const m of e)
|
|
255
|
+
t.isParent(m.id) ? c.push(m) : l.push(m);
|
|
256
|
+
l.sort((m, b) => {
|
|
257
|
+
const T = m.start_time - b.start_time;
|
|
258
|
+
return T !== 0 ? T : b.end_time - b.start_time - (m.end_time - m.start_time);
|
|
222
259
|
});
|
|
223
|
-
const
|
|
224
|
-
let
|
|
225
|
-
for (const
|
|
260
|
+
const u = [];
|
|
261
|
+
let p = 0;
|
|
262
|
+
for (const m of l) {
|
|
226
263
|
let b = -1;
|
|
227
|
-
for (let T = 0; T <
|
|
228
|
-
if (
|
|
264
|
+
for (let T = 0; T < u.length; T++)
|
|
265
|
+
if (u[T] <= m.start_time) {
|
|
229
266
|
b = T;
|
|
230
267
|
break;
|
|
231
268
|
}
|
|
232
|
-
b === -1 ? (b =
|
|
269
|
+
b === -1 ? (b = u.length, u.push(m.end_time)) : u[b] = m.end_time, b > p && (p = b), this.layoutCache.set(m.id, { stackLevel: b, itemHeight: n });
|
|
233
270
|
}
|
|
234
|
-
|
|
235
|
-
let
|
|
236
|
-
for (const
|
|
237
|
-
this.layoutCache.set(
|
|
238
|
-
this.groupMaxStack.set(d,
|
|
271
|
+
c.sort((m, b) => t.getNestingDepth(b.id) - t.getNestingDepth(m.id));
|
|
272
|
+
let M = l.length > 0 ? p + 1 : 0;
|
|
273
|
+
for (const m of c)
|
|
274
|
+
this.layoutCache.set(m.id, { stackLevel: M, itemHeight: o }), M > p && (p = M), M++;
|
|
275
|
+
this.groupMaxStack.set(d, p);
|
|
239
276
|
}
|
|
240
277
|
getLayout(e) {
|
|
241
278
|
return this.layoutCache.get(e);
|
|
@@ -244,7 +281,7 @@ class vi {
|
|
|
244
281
|
return ((this.groupMaxStack.get(e) ?? 0) + 1) * this.lineHeight;
|
|
245
282
|
}
|
|
246
283
|
}
|
|
247
|
-
class
|
|
284
|
+
class Si {
|
|
248
285
|
constructor() {
|
|
249
286
|
Object.defineProperty(this, "parentToChildren", {
|
|
250
287
|
enumerable: !0,
|
|
@@ -280,19 +317,19 @@ class bi {
|
|
|
280
317
|
}
|
|
281
318
|
for (const t of this.childToParent.keys()) {
|
|
282
319
|
const n = /* @__PURE__ */ new Set();
|
|
283
|
-
let
|
|
284
|
-
for (;
|
|
285
|
-
if (n.has(
|
|
320
|
+
let o = t;
|
|
321
|
+
for (; o !== void 0; ) {
|
|
322
|
+
if (n.has(o)) {
|
|
286
323
|
const d = this.childToParent.get(t);
|
|
287
324
|
this.childToParent.delete(t);
|
|
288
|
-
const
|
|
289
|
-
if (
|
|
290
|
-
const
|
|
291
|
-
|
|
325
|
+
const l = this.parentToChildren.get(d);
|
|
326
|
+
if (l) {
|
|
327
|
+
const c = l.indexOf(t);
|
|
328
|
+
c !== -1 && l.splice(c, 1), l.length === 0 && this.parentToChildren.delete(d);
|
|
292
329
|
}
|
|
293
330
|
break;
|
|
294
331
|
}
|
|
295
|
-
n.add(
|
|
332
|
+
n.add(o), o = this.childToParent.get(o);
|
|
296
333
|
}
|
|
297
334
|
}
|
|
298
335
|
}
|
|
@@ -309,9 +346,9 @@ class bi {
|
|
|
309
346
|
getDescendants(e) {
|
|
310
347
|
const t = [], n = [...this.getChildren(e)];
|
|
311
348
|
for (; n.length > 0; ) {
|
|
312
|
-
const
|
|
313
|
-
t.push(
|
|
314
|
-
const d = this.parentToChildren.get(
|
|
349
|
+
const o = n.pop();
|
|
350
|
+
t.push(o);
|
|
351
|
+
const d = this.parentToChildren.get(o);
|
|
315
352
|
d && n.push(...d);
|
|
316
353
|
}
|
|
317
354
|
return t;
|
|
@@ -320,31 +357,31 @@ class bi {
|
|
|
320
357
|
const t = this.itemMap.get(e);
|
|
321
358
|
if (!t)
|
|
322
359
|
return { start: 0, end: 0 };
|
|
323
|
-
let n = t.start_time,
|
|
360
|
+
let n = t.start_time, o = t.end_time;
|
|
324
361
|
const d = this.getDescendants(e);
|
|
325
|
-
for (const
|
|
326
|
-
const
|
|
327
|
-
|
|
362
|
+
for (const l of d) {
|
|
363
|
+
const c = this.itemMap.get(l);
|
|
364
|
+
c && (c.start_time < n && (n = c.start_time), c.end_time > o && (o = c.end_time));
|
|
328
365
|
}
|
|
329
|
-
return { start: n, end:
|
|
366
|
+
return { start: n, end: o };
|
|
330
367
|
}
|
|
331
368
|
getNestingDepth(e) {
|
|
332
369
|
const t = this.depthCache.get(e);
|
|
333
370
|
if (t !== void 0)
|
|
334
371
|
return t;
|
|
335
|
-
let n = 0,
|
|
336
|
-
for (;
|
|
337
|
-
n++,
|
|
372
|
+
let n = 0, o = this.childToParent.get(e);
|
|
373
|
+
for (; o !== void 0; )
|
|
374
|
+
n++, o = this.childToParent.get(o);
|
|
338
375
|
return this.depthCache.set(e, n), n;
|
|
339
376
|
}
|
|
340
377
|
getMoveDelta(e, t) {
|
|
341
378
|
const n = this.itemMap.get(e);
|
|
342
379
|
if (!n)
|
|
343
380
|
return [];
|
|
344
|
-
const
|
|
345
|
-
return this.getDescendants(e).map((
|
|
346
|
-
const
|
|
347
|
-
return { itemId:
|
|
381
|
+
const o = t - n.start_time;
|
|
382
|
+
return this.getDescendants(e).map((l) => {
|
|
383
|
+
const c = this.itemMap.get(l);
|
|
384
|
+
return { itemId: l, newStart: c.start_time + o };
|
|
348
385
|
});
|
|
349
386
|
}
|
|
350
387
|
getResizeConstraint(e, t) {
|
|
@@ -352,78 +389,78 @@ class bi {
|
|
|
352
389
|
if (n.length === 0)
|
|
353
390
|
return t === "left" ? { min: -1 / 0, max: 1 / 0 } : { min: -1 / 0, max: 1 / 0 };
|
|
354
391
|
if (t === "left") {
|
|
355
|
-
let
|
|
392
|
+
let o = 1 / 0;
|
|
356
393
|
for (const d of n) {
|
|
357
|
-
const
|
|
358
|
-
|
|
394
|
+
const l = this.itemMap.get(d);
|
|
395
|
+
l && l.start_time < o && (o = l.start_time);
|
|
359
396
|
}
|
|
360
|
-
return { min: -1 / 0, max:
|
|
397
|
+
return { min: -1 / 0, max: o };
|
|
361
398
|
} else {
|
|
362
|
-
let
|
|
399
|
+
let o = -1 / 0;
|
|
363
400
|
for (const d of n) {
|
|
364
|
-
const
|
|
365
|
-
|
|
401
|
+
const l = this.itemMap.get(d);
|
|
402
|
+
l && l.end_time > o && (o = l.end_time);
|
|
366
403
|
}
|
|
367
|
-
return { min:
|
|
404
|
+
return { min: o, max: 1 / 0 };
|
|
368
405
|
}
|
|
369
406
|
}
|
|
370
407
|
}
|
|
371
|
-
function
|
|
372
|
-
const { x:
|
|
373
|
-
i.globalAlpha = 0.15, i.fillStyle =
|
|
374
|
-
const
|
|
375
|
-
i.fillStyle =
|
|
408
|
+
function ki(i, e, t, n, o, d) {
|
|
409
|
+
const { x: l, y: c, width: u, height: p } = t, M = d.primary;
|
|
410
|
+
i.globalAlpha = 0.15, i.fillStyle = M, i.fillRect(l, c, u, p), i.globalAlpha = 1, i.strokeStyle = M, i.lineWidth = 1.5, i.strokeRect(l, c, u, p);
|
|
411
|
+
const m = Math.min(p * 0.5, 6), b = c + p / 2;
|
|
412
|
+
i.fillStyle = M, i.beginPath(), i.moveTo(l, b), i.lineTo(l + m, b - m), i.lineTo(l + m * 2, b), i.lineTo(l + m, b + m), i.closePath(), i.fill(), i.beginPath(), i.moveTo(l + u, b), i.lineTo(l + u - m, b - m), i.lineTo(l + u - m * 2, b), i.lineTo(l + u - m, b + m), i.closePath(), i.fill();
|
|
376
413
|
const T = e.title;
|
|
377
|
-
if (T &&
|
|
414
|
+
if (T && u > 30) {
|
|
378
415
|
i.fillStyle = d.item.text, i.font = '500 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif', i.textBaseline = "middle";
|
|
379
|
-
const
|
|
380
|
-
if (
|
|
381
|
-
const
|
|
382
|
-
i.fillText(
|
|
416
|
+
const H = i.measureText(T).width, O = u - m * 4 - 4;
|
|
417
|
+
if (O > 20) {
|
|
418
|
+
const j = H > O ? T.slice(0, Math.floor(T.length * O / H)) + "..." : T;
|
|
419
|
+
i.fillText(j, l + u / 2 - Math.min(H, O) / 2, b);
|
|
383
420
|
}
|
|
384
421
|
}
|
|
385
|
-
n.selected && (i.strokeStyle = d.item.selectedRing, i.lineWidth = 2, i.strokeRect(
|
|
422
|
+
n.selected && (i.strokeStyle = d.item.selectedRing, i.lineWidth = 2, i.strokeRect(l - 1, c - 1, u + 2, p + 2));
|
|
386
423
|
}
|
|
387
|
-
function
|
|
388
|
-
const
|
|
389
|
-
for (let
|
|
390
|
-
|
|
391
|
-
const
|
|
392
|
-
let
|
|
393
|
-
for (const
|
|
394
|
-
const b =
|
|
424
|
+
function $e(i, e, t, n, o, d) {
|
|
425
|
+
const l = t.xToTime(i), c = /* @__PURE__ */ new Map();
|
|
426
|
+
for (let m = 0; m < d.length; m++)
|
|
427
|
+
c.set(d[m].id, m);
|
|
428
|
+
const u = n.query(l, l);
|
|
429
|
+
let p = null, M = -1 / 0;
|
|
430
|
+
for (const m of u) {
|
|
431
|
+
const b = c.get(m.group);
|
|
395
432
|
if (b === void 0)
|
|
396
433
|
continue;
|
|
397
|
-
const T =
|
|
434
|
+
const T = o.getLayout(m.id);
|
|
398
435
|
if (!T)
|
|
399
436
|
continue;
|
|
400
|
-
const
|
|
401
|
-
if (i <
|
|
437
|
+
const H = t.timeToX(m.start_time), O = t.timeToX(m.end_time) - H;
|
|
438
|
+
if (i < H || i > H + O)
|
|
402
439
|
continue;
|
|
403
|
-
const
|
|
404
|
-
e <
|
|
440
|
+
const re = t.groupIndexToY(b) + T.stackLevel * t.lineHeight + (t.lineHeight - T.itemHeight) / 2, w = T.itemHeight;
|
|
441
|
+
e < re || e > re + w || re > M && (M = re, p = m);
|
|
405
442
|
}
|
|
406
|
-
return
|
|
443
|
+
return p;
|
|
407
444
|
}
|
|
408
|
-
function
|
|
445
|
+
function mt(i, e, t) {
|
|
409
446
|
const n = e.yToGroupIndex(i);
|
|
410
447
|
return t[n] ?? null;
|
|
411
448
|
}
|
|
412
|
-
function
|
|
413
|
-
const
|
|
414
|
-
return i -
|
|
449
|
+
function Bt(i, e, t, n = 6) {
|
|
450
|
+
const o = t.timeToX(e.start_time), d = t.timeToX(e.end_time);
|
|
451
|
+
return i - o <= n ? "left" : d - i <= n ? "right" : "body";
|
|
415
452
|
}
|
|
416
|
-
function
|
|
417
|
-
const n = window.devicePixelRatio || 1,
|
|
418
|
-
(i.width !==
|
|
419
|
-
const
|
|
420
|
-
return
|
|
453
|
+
function gt(i, e, t) {
|
|
454
|
+
const n = window.devicePixelRatio || 1, o = Math.round(e * n), d = Math.round(t * n);
|
|
455
|
+
(i.width !== o || i.height !== d) && (i.width = o, i.height = d, i.style.width = `${e}px`, i.style.height = `${t}px`);
|
|
456
|
+
const l = i.getContext("2d");
|
|
457
|
+
return l.setTransform(n, 0, 0, n, 0, 0), l;
|
|
421
458
|
}
|
|
422
|
-
function
|
|
459
|
+
function pt(i, e) {
|
|
423
460
|
const t = window.devicePixelRatio || 1;
|
|
424
461
|
i.clearRect(0, 0, e.width / t, e.height / t);
|
|
425
462
|
}
|
|
426
|
-
class
|
|
463
|
+
class wi {
|
|
427
464
|
constructor(e) {
|
|
428
465
|
Object.defineProperty(this, "dirty", {
|
|
429
466
|
enumerable: !0,
|
|
@@ -459,101 +496,101 @@ class Ti {
|
|
|
459
496
|
}));
|
|
460
497
|
}
|
|
461
498
|
}
|
|
462
|
-
class
|
|
463
|
-
draw(e, t, n,
|
|
464
|
-
const { firstVisible:
|
|
465
|
-
for (let
|
|
466
|
-
const
|
|
467
|
-
if (!
|
|
499
|
+
class Mi {
|
|
500
|
+
draw(e, t, n, o, d, l, c) {
|
|
501
|
+
const { firstVisible: u, lastVisible: p } = t.getVisibleGroupRange();
|
|
502
|
+
for (let w = u; w <= p; w++) {
|
|
503
|
+
const X = t.groupIndexToY(w), E = t.groupIndexToHeight(w), R = n[w];
|
|
504
|
+
if (!R)
|
|
468
505
|
continue;
|
|
469
|
-
let
|
|
470
|
-
const
|
|
471
|
-
|
|
506
|
+
let z;
|
|
507
|
+
const B = l == null ? void 0 : l(R);
|
|
508
|
+
B != null && B.backgroundColor ? z = B.backgroundColor : z = w % 2 === 0 ? "#FFFFFF" : o.grid.rowAlt, e.fillStyle = z, e.fillRect(0, X, t.canvasWidth, E), e.strokeStyle = (B == null ? void 0 : B.borderBottomColor) ?? o.grid.line, e.lineWidth = 0.5, e.beginPath(), e.moveTo(0, X + E), e.lineTo(t.canvasWidth, X + E), e.stroke();
|
|
472
509
|
}
|
|
473
|
-
if (
|
|
474
|
-
for (const
|
|
475
|
-
const
|
|
476
|
-
if (
|
|
510
|
+
if (c && c.length > 0)
|
|
511
|
+
for (const w of c) {
|
|
512
|
+
const X = t.timeToX(w.start), E = t.timeToX(w.end);
|
|
513
|
+
if (E < 0 || X > t.canvasWidth)
|
|
477
514
|
continue;
|
|
478
|
-
const
|
|
479
|
-
e.fillStyle = `rgb(${Math.round(
|
|
515
|
+
const R = Math.max(0, X), z = Math.min(t.canvasWidth, E) - R, B = w.opacity ?? 0.12, _ = parseInt(w.color.slice(1, 3), 16), G = parseInt(w.color.slice(3, 5), 16), q = parseInt(w.color.slice(5, 7), 16);
|
|
516
|
+
e.fillStyle = `rgb(${Math.round(_ * B + 255 * (1 - B))},${Math.round(G * B + 255 * (1 - B))},${Math.round(q * B + 255 * (1 - B))})`, e.fillRect(R, 0, z, t.canvasHeight);
|
|
480
517
|
}
|
|
481
|
-
const
|
|
482
|
-
let
|
|
483
|
-
|
|
518
|
+
const M = t.visibleTimeStart, m = t.visibleTimeEnd, H = 864e5 / (m - M) * t.canvasWidth;
|
|
519
|
+
let O = "day";
|
|
520
|
+
H < 2 ? O = "month" : H < 8 && (O = "week");
|
|
484
521
|
{
|
|
485
|
-
let
|
|
486
|
-
const
|
|
487
|
-
let
|
|
488
|
-
const
|
|
489
|
-
|
|
522
|
+
let w = ve(M).startOf("day");
|
|
523
|
+
const X = ve(m).endOf("day");
|
|
524
|
+
let E = null, R = 1, z = 0;
|
|
525
|
+
const B = [], _ = (G) => {
|
|
526
|
+
E !== null && (e.fillStyle = E, R !== 1 && (e.globalAlpha = R), e.fillRect(z, 0, G - z, t.canvasHeight), R !== 1 && (e.globalAlpha = 1), E = null, R = 1);
|
|
490
527
|
};
|
|
491
|
-
for (;
|
|
492
|
-
const
|
|
493
|
-
let
|
|
528
|
+
for (; w.isBefore(X); ) {
|
|
529
|
+
const G = t.timeToX(w.valueOf()), q = w.toDate(), J = d == null ? void 0 : d(q);
|
|
530
|
+
let oe = null, ue = 1;
|
|
494
531
|
if (J != null && J.backgroundColor)
|
|
495
|
-
|
|
532
|
+
oe = J.backgroundColor, ue = J.opacity ?? 1;
|
|
496
533
|
else {
|
|
497
|
-
const
|
|
498
|
-
(
|
|
534
|
+
const ye = w.day();
|
|
535
|
+
(ye === 0 || ye === 6) && (oe = o.grid.weekend);
|
|
499
536
|
}
|
|
500
|
-
J != null && J.borderColor &&
|
|
537
|
+
J != null && J.borderColor && B.push({ x: G, color: J.borderColor }), oe === E && ue === R || (_(G), oe !== null && (E = oe, R = ue, z = G)), w = w.add(1, "day");
|
|
501
538
|
}
|
|
502
|
-
|
|
503
|
-
for (const
|
|
504
|
-
e.strokeStyle =
|
|
539
|
+
E !== null && _(t.timeToX(w.valueOf()));
|
|
540
|
+
for (const G of B)
|
|
541
|
+
e.strokeStyle = G.color, e.lineWidth = 0.5, e.beginPath(), e.moveTo(G.x, 0), e.lineTo(G.x, t.canvasHeight), e.stroke();
|
|
505
542
|
}
|
|
506
|
-
let
|
|
507
|
-
const
|
|
508
|
-
for (e.strokeStyle =
|
|
509
|
-
const
|
|
510
|
-
e.moveTo(
|
|
543
|
+
let j = ve(M).startOf(O);
|
|
544
|
+
const re = ve(m).add(1, O);
|
|
545
|
+
for (e.strokeStyle = o.grid.line, e.lineWidth = 0.5, e.beginPath(); j.isBefore(re); ) {
|
|
546
|
+
const w = t.timeToX(j.valueOf());
|
|
547
|
+
e.moveTo(w, 0), e.lineTo(w, t.canvasHeight), j = j.add(1, O);
|
|
511
548
|
}
|
|
512
|
-
if (e.stroke(),
|
|
513
|
-
for (const
|
|
514
|
-
const
|
|
515
|
-
if (!(
|
|
516
|
-
const
|
|
549
|
+
if (e.stroke(), c && c.length > 0)
|
|
550
|
+
for (const w of c) {
|
|
551
|
+
const X = t.timeToX(w.start), E = t.timeToX(w.end);
|
|
552
|
+
if (!(E < 0 || X > t.canvasWidth) && (e.strokeStyle = w.color, e.globalAlpha = 0.4, e.lineWidth = 1, e.beginPath(), X >= 0 && X <= t.canvasWidth && (e.moveTo(X, 0), e.lineTo(X, t.canvasHeight)), E >= 0 && E <= t.canvasWidth && (e.moveTo(E, 0), e.lineTo(E, t.canvasHeight)), e.stroke(), e.globalAlpha = 1, w.label)) {
|
|
553
|
+
const R = Math.max(0, X), z = Math.min(t.canvasWidth, E) - R;
|
|
517
554
|
e.save(), e.font = '600 10px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
|
|
518
|
-
const
|
|
519
|
-
e.fillStyle =
|
|
555
|
+
const B = e.measureText(w.label).width, _ = 6, G = B + _ * 2, q = 18, J = R + (z - G) / 2, oe = 4;
|
|
556
|
+
e.fillStyle = w.color, e.globalAlpha = 0.9, e.beginPath(), e.roundRect(J, oe, G, q, 3), e.fill(), e.globalAlpha = 1, e.fillStyle = "#FFFFFF", e.textBaseline = "middle", e.fillText(w.label, J + _, oe + q / 2), e.restore();
|
|
520
557
|
}
|
|
521
558
|
}
|
|
522
559
|
}
|
|
523
560
|
}
|
|
524
|
-
const
|
|
561
|
+
const Yt = '500 12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
|
|
525
562
|
function xt(i, e) {
|
|
526
563
|
return {
|
|
527
564
|
/**
|
|
528
565
|
* Draws a filled rounded rectangle.
|
|
529
566
|
* Default corner radius is 3px.
|
|
530
567
|
*/
|
|
531
|
-
roundRect(t, n,
|
|
532
|
-
i.beginPath(), i.roundRect(t, n,
|
|
568
|
+
roundRect(t, n, o, d, l = 3) {
|
|
569
|
+
i.beginPath(), i.roundRect(t, n, o, d, l), i.fill();
|
|
533
570
|
},
|
|
534
571
|
/**
|
|
535
572
|
* Draws text at (x, y) using the standard item font.
|
|
536
573
|
* If maxWidth is provided and the text is too wide, binary-search truncates it
|
|
537
574
|
* and appends '...' so it fits within maxWidth.
|
|
538
575
|
*/
|
|
539
|
-
fillText(t, n,
|
|
540
|
-
if (i.font =
|
|
541
|
-
let
|
|
542
|
-
for (;
|
|
543
|
-
const
|
|
544
|
-
i.measureText(
|
|
576
|
+
fillText(t, n, o, d) {
|
|
577
|
+
if (i.font = Yt, d !== void 0 && i.measureText(t).width > d) {
|
|
578
|
+
let l = 0, c = t.length;
|
|
579
|
+
for (; l < c; ) {
|
|
580
|
+
const u = Math.ceil((l + c) / 2), p = t.slice(0, u) + "...";
|
|
581
|
+
i.measureText(p).width <= d ? l = u : c = u - 1;
|
|
545
582
|
}
|
|
546
|
-
i.fillText(t.slice(0,
|
|
583
|
+
i.fillText(t.slice(0, l) + "...", n, o);
|
|
547
584
|
} else
|
|
548
|
-
i.fillText(t, n,
|
|
585
|
+
i.fillText(t, n, o);
|
|
549
586
|
},
|
|
550
587
|
/**
|
|
551
588
|
* Creates a 50/50 linear gradient from color1 (0%–50%) to color2 (50%–100%)
|
|
552
589
|
* spanning the given x position and width.
|
|
553
590
|
*/
|
|
554
|
-
gradient(t, n,
|
|
555
|
-
const
|
|
556
|
-
return
|
|
591
|
+
gradient(t, n, o, d) {
|
|
592
|
+
const l = i.createLinearGradient(t, 0, t + n, 0);
|
|
593
|
+
return l.addColorStop(0, o), l.addColorStop(0.5, o), l.addColorStop(0.5, d), l.addColorStop(1, d), l;
|
|
557
594
|
},
|
|
558
595
|
/**
|
|
559
596
|
* Draws a vertical colored bar on the left edge of the item bounds.
|
|
@@ -567,124 +604,124 @@ function xt(i, e) {
|
|
|
567
604
|
* Supported types: 'check', 'danger-red', 'danger-yellow'.
|
|
568
605
|
* Default size is 14px.
|
|
569
606
|
*/
|
|
570
|
-
icon(t, n,
|
|
607
|
+
icon(t, n, o, d = 14) {
|
|
571
608
|
i.save();
|
|
572
|
-
const
|
|
609
|
+
const l = d / 2;
|
|
573
610
|
if (t === "check") {
|
|
574
|
-
i.fillStyle = "#31c48d", i.beginPath(), i.arc(n +
|
|
575
|
-
const
|
|
576
|
-
i.moveTo(
|
|
611
|
+
i.fillStyle = "#31c48d", i.beginPath(), i.arc(n + l, o + l, l, 0, Math.PI * 2), i.fill(), i.strokeStyle = "#ffffff", i.lineWidth = d * 0.12, i.beginPath();
|
|
612
|
+
const c = n + l, u = o + l;
|
|
613
|
+
i.moveTo(c - l * 0.45, u), i.lineTo(c - l * 0.1, u + l * 0.42), i.lineTo(c + l * 0.45, u - l * 0.35), i.stroke();
|
|
577
614
|
} else if (t === "danger-red" || t === "danger-yellow") {
|
|
578
|
-
const
|
|
579
|
-
i.fillStyle =
|
|
580
|
-
const
|
|
581
|
-
i.fillRect(
|
|
615
|
+
const c = t === "danger-red" ? "#EF5350" : "#FBBF24";
|
|
616
|
+
i.fillStyle = c, i.beginPath(), i.moveTo(n + l, o), i.lineTo(n + d, o + d), i.lineTo(n, o + d), i.closePath(), i.fill(), i.fillStyle = "#ffffff";
|
|
617
|
+
const u = d * 0.12, p = n + l - u / 2;
|
|
618
|
+
i.fillRect(p, o + d * 0.35, u, d * 0.35), i.beginPath(), i.arc(n + l, o + d * 0.82, u * 0.7, 0, Math.PI * 2), i.fill();
|
|
582
619
|
}
|
|
583
620
|
i.restore();
|
|
584
621
|
},
|
|
585
622
|
/**
|
|
586
623
|
* Draws a pill-shaped badge with centered white text on a colored background.
|
|
587
624
|
*/
|
|
588
|
-
badge(t, n,
|
|
589
|
-
i.save(), i.font =
|
|
590
|
-
const
|
|
591
|
-
i.fillStyle = d, i.beginPath(), i.roundRect(n,
|
|
625
|
+
badge(t, n, o, d) {
|
|
626
|
+
i.save(), i.font = Yt;
|
|
627
|
+
const c = i.measureText(t).width, u = 8, M = 12 + 3 * 2, m = c + u * 2, b = M / 2;
|
|
628
|
+
i.fillStyle = d, i.beginPath(), i.roundRect(n, o, m, M, b), i.fill(), i.fillStyle = "#ffffff", i.textAlign = "center", i.textBaseline = "middle", i.fillText(t, n + m / 2, o + M / 2), i.restore();
|
|
592
629
|
}
|
|
593
630
|
};
|
|
594
631
|
}
|
|
595
|
-
class
|
|
596
|
-
draw(e, t, n,
|
|
597
|
-
const
|
|
598
|
-
for (let
|
|
599
|
-
|
|
600
|
-
const
|
|
601
|
-
for (const
|
|
602
|
-
const
|
|
603
|
-
if (
|
|
632
|
+
class Ei {
|
|
633
|
+
draw(e, t, n, o, d, l, c, u, p, M, m, b, T, H) {
|
|
634
|
+
const O = (t.visibleTimeEnd - t.visibleTimeStart) * 0.1, j = t.visibleTimeStart - O, re = t.visibleTimeEnd + O, w = d.query(j, re), X = /* @__PURE__ */ new Map();
|
|
635
|
+
for (let _ = 0; _ < n.length; _++)
|
|
636
|
+
X.set(n[_].id, _);
|
|
637
|
+
const E = new Set(M), R = /* @__PURE__ */ new Map(), z = -t.lineHeight, B = t.canvasHeight + t.lineHeight;
|
|
638
|
+
for (const _ of w) {
|
|
639
|
+
const G = X.get(_.group);
|
|
640
|
+
if (G === void 0)
|
|
604
641
|
continue;
|
|
605
|
-
const q =
|
|
642
|
+
const q = l.getLayout(_.id);
|
|
606
643
|
if (!q)
|
|
607
644
|
continue;
|
|
608
|
-
const
|
|
609
|
-
if (
|
|
645
|
+
const oe = t.groupIndexToY(G) + q.stackLevel * t.lineHeight + (t.lineHeight - q.itemHeight) / 2, ue = q.itemHeight;
|
|
646
|
+
if (oe + ue < z || oe > B)
|
|
610
647
|
continue;
|
|
611
|
-
const
|
|
612
|
-
|
|
613
|
-
const
|
|
614
|
-
selected:
|
|
615
|
-
hovered:
|
|
648
|
+
const ye = t.timeToX(_.start_time), Oe = t.timeToX(_.end_time) - ye, Te = { x: ye, y: oe, width: Oe, height: ue };
|
|
649
|
+
R.set(_.id, Te);
|
|
650
|
+
const Xe = {
|
|
651
|
+
selected: E.has(_.id),
|
|
652
|
+
hovered: m === _.id,
|
|
616
653
|
dragging: !1,
|
|
617
|
-
filtered:
|
|
654
|
+
filtered: _.filtered !== !1
|
|
618
655
|
};
|
|
619
656
|
e.save();
|
|
620
|
-
const
|
|
621
|
-
let
|
|
622
|
-
T && (
|
|
657
|
+
const Ve = xt(e, Te);
|
|
658
|
+
let He;
|
|
659
|
+
T && (H != null && H.isParent(_.id)) ? He = T : u && (_.type === "control_area_group" || _.type === "construction_train") ? He = u : He = c, He(e, _, Te, Xe, Ve), e.restore();
|
|
623
660
|
}
|
|
624
661
|
if (b && b.length > 0) {
|
|
625
|
-
const
|
|
626
|
-
for (const
|
|
627
|
-
|
|
628
|
-
if (
|
|
629
|
-
const
|
|
630
|
-
for (const q of
|
|
631
|
-
|
|
632
|
-
for (const [q, J] of
|
|
633
|
-
const
|
|
634
|
-
if (
|
|
662
|
+
const _ = /* @__PURE__ */ new Set();
|
|
663
|
+
for (const G of b)
|
|
664
|
+
R.has(G.fromItemId) || _.add(G.fromItemId), R.has(G.toItemId) || _.add(G.toItemId);
|
|
665
|
+
if (_.size > 0) {
|
|
666
|
+
const G = /* @__PURE__ */ new Map();
|
|
667
|
+
for (const q of o)
|
|
668
|
+
_.has(q.id) && G.set(q.id, q);
|
|
669
|
+
for (const [q, J] of G) {
|
|
670
|
+
const oe = X.get(J.group);
|
|
671
|
+
if (oe === void 0)
|
|
635
672
|
continue;
|
|
636
|
-
const ue =
|
|
673
|
+
const ue = l.getLayout(q);
|
|
637
674
|
if (!ue)
|
|
638
675
|
continue;
|
|
639
|
-
const
|
|
640
|
-
|
|
676
|
+
const Oe = t.groupIndexToY(oe) + ue.stackLevel * t.lineHeight + (t.lineHeight - ue.itemHeight) / 2, Te = t.timeToX(J.start_time), Xe = t.timeToX(J.end_time) - Te;
|
|
677
|
+
R.set(q, { x: Te, y: Oe, width: Xe, height: ue.itemHeight });
|
|
641
678
|
}
|
|
642
679
|
}
|
|
643
|
-
this.drawDependencies(e, b,
|
|
680
|
+
this.drawDependencies(e, b, R, m, p);
|
|
644
681
|
}
|
|
645
682
|
}
|
|
646
|
-
drawDependencies(e, t, n,
|
|
647
|
-
for (const
|
|
648
|
-
const
|
|
649
|
-
if (!
|
|
683
|
+
drawDependencies(e, t, n, o, d) {
|
|
684
|
+
for (const l of t) {
|
|
685
|
+
const c = n.get(l.fromItemId), u = n.get(l.toItemId);
|
|
686
|
+
if (!c || !u)
|
|
650
687
|
continue;
|
|
651
|
-
const
|
|
652
|
-
e.strokeStyle =
|
|
653
|
-
const
|
|
654
|
-
e.beginPath(), e.moveTo(
|
|
655
|
-
const
|
|
656
|
-
e.fillStyle = e.strokeStyle, e.beginPath(), e.moveTo(b, T), e.lineTo(b -
|
|
688
|
+
const p = o === l.fromItemId || o === l.toItemId;
|
|
689
|
+
e.strokeStyle = p ? d.primary : l.color ?? "#94A3B8", e.lineWidth = p ? 2 : 1.5, e.setLineDash([]);
|
|
690
|
+
const M = c.x + c.width, m = c.y + c.height / 2, b = u.x, T = u.y + u.height / 2, H = Math.abs(b - M), O = Math.max(H * 0.4, 30);
|
|
691
|
+
e.beginPath(), e.moveTo(M, m), e.bezierCurveTo(M + O, m, b - O, T, b, T), e.stroke();
|
|
692
|
+
const j = 6;
|
|
693
|
+
e.fillStyle = e.strokeStyle, e.beginPath(), e.moveTo(b, T), e.lineTo(b - j, T - j / 2), e.lineTo(b - j, T + j / 2), e.closePath(), e.fill();
|
|
657
694
|
}
|
|
658
695
|
}
|
|
659
696
|
}
|
|
660
|
-
class
|
|
661
|
-
draw(e, t, n,
|
|
662
|
-
const { cursorX: d, snapX:
|
|
663
|
-
if (
|
|
664
|
-
for (const
|
|
665
|
-
const
|
|
666
|
-
if (e.fillStyle =
|
|
697
|
+
class Ci {
|
|
698
|
+
draw(e, t, n, o) {
|
|
699
|
+
const { cursorX: d, snapX: l, markers: c, interaction: u } = o;
|
|
700
|
+
if (c)
|
|
701
|
+
for (const p of c) {
|
|
702
|
+
const M = t.timeToX(p.date);
|
|
703
|
+
if (e.fillStyle = p.color, e.fillRect(M - p.width / 2, 0, p.width, t.canvasHeight), p.label) {
|
|
667
704
|
e.save(), e.font = '500 10px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
|
|
668
|
-
const
|
|
669
|
-
e.fillStyle =
|
|
670
|
-
const
|
|
671
|
-
e.fillText(
|
|
705
|
+
const m = e.measureText(p.label).width, b = 8, T = 200, H = Math.min(m + b * 2, T), O = 20, j = M - H / 2, re = 4;
|
|
706
|
+
e.fillStyle = p.color, e.beginPath(), e.roundRect(j, re, H, O, 3), e.fill(), e.fillStyle = "#FFFFFF", e.textBaseline = "middle";
|
|
707
|
+
const w = T - b * 2, X = m > w ? p.label.slice(0, Math.floor(p.label.length * w / m)) + "…" : p.label;
|
|
708
|
+
e.fillText(X, j + b, re + O / 2), e.restore();
|
|
672
709
|
}
|
|
673
710
|
}
|
|
674
|
-
if (d != null && (e.strokeStyle = n.marker.cursor, e.lineWidth = 1, e.beginPath(), e.moveTo(d, 0), e.lineTo(d, t.canvasHeight), e.stroke()),
|
|
675
|
-
|
|
676
|
-
const
|
|
677
|
-
|
|
711
|
+
if (d != null && (e.strokeStyle = n.marker.cursor, e.lineWidth = 1, e.beginPath(), e.moveTo(d, 0), e.lineTo(d, t.canvasHeight), e.stroke()), l != null && (e.strokeStyle = n.primary, e.lineWidth = 1, e.setLineDash([4, 4]), e.beginPath(), e.moveTo(l, 0), e.lineTo(l, t.canvasHeight), e.stroke(), e.setLineDash([])), u) {
|
|
712
|
+
u.groupChanged && u.targetGroupY !== void 0 && (e.fillStyle = "rgba(59, 130, 246, 0.08)", e.fillRect(0, u.targetGroupY, t.canvasWidth, t.lineHeight)), e.save(), e.globalAlpha = 0.5;
|
|
713
|
+
const p = xt(e, u.bounds);
|
|
714
|
+
u.renderer(e, u.item, u.bounds, { selected: !1, hovered: !1, dragging: !0, filtered: !0 }, p), e.restore();
|
|
678
715
|
}
|
|
679
716
|
}
|
|
680
717
|
}
|
|
681
|
-
const
|
|
682
|
-
function
|
|
718
|
+
const Lt = 120;
|
|
719
|
+
function Hi(i) {
|
|
683
720
|
let e = i.deltaY || i.deltaX;
|
|
684
|
-
return i.deltaMode === 1 ? e *= 15 : i.deltaMode === 2 && (e *= 800), Math.max(-
|
|
721
|
+
return i.deltaMode === 1 ? e *= 15 : i.deltaMode === 2 && (e *= 800), Math.max(-Lt, Math.min(Lt, e));
|
|
685
722
|
}
|
|
686
|
-
class
|
|
687
|
-
constructor(e, t, n,
|
|
723
|
+
class Ii {
|
|
724
|
+
constructor(e, t, n, o, d) {
|
|
688
725
|
Object.defineProperty(this, "onZoom", {
|
|
689
726
|
enumerable: !0,
|
|
690
727
|
configurable: !0,
|
|
@@ -710,21 +747,21 @@ class Ei {
|
|
|
710
747
|
configurable: !0,
|
|
711
748
|
writable: !0,
|
|
712
749
|
value: void 0
|
|
713
|
-
}), this.onZoom = e, this.visibleTimeStart = t, this.visibleTimeEnd = n, this.minZoom =
|
|
750
|
+
}), this.onZoom = e, this.visibleTimeStart = t, this.visibleTimeEnd = n, this.minZoom = o, this.maxZoom = d;
|
|
714
751
|
}
|
|
715
752
|
updateBounds(e, t) {
|
|
716
753
|
this.visibleTimeStart = e, this.visibleTimeEnd = t;
|
|
717
754
|
}
|
|
718
755
|
handleWheelZoom(e, t) {
|
|
719
|
-
const n =
|
|
720
|
-
let
|
|
721
|
-
|
|
722
|
-
const
|
|
723
|
-
this.onZoom(
|
|
756
|
+
const n = Hi(e), o = e.ctrlKey ? 10 : e.metaKey ? 3 : 1, d = n > 0 ? 1 + o * n / 500 : 1 / (1 + o * -n / 500), l = this.visibleTimeEnd - this.visibleTimeStart;
|
|
757
|
+
let c = Math.round(l * d);
|
|
758
|
+
c = Math.max(this.minZoom, Math.min(this.maxZoom, c));
|
|
759
|
+
const u = Math.round(this.visibleTimeStart + (l - c) * t), p = u + c;
|
|
760
|
+
this.onZoom(u, p);
|
|
724
761
|
}
|
|
725
762
|
}
|
|
726
|
-
const
|
|
727
|
-
class
|
|
763
|
+
const Ri = 4;
|
|
764
|
+
class Pi {
|
|
728
765
|
constructor(e) {
|
|
729
766
|
Object.defineProperty(this, "state", {
|
|
730
767
|
enumerable: !0,
|
|
@@ -743,21 +780,21 @@ class Hi {
|
|
|
743
780
|
value: !1
|
|
744
781
|
}), this.dragSnap = e;
|
|
745
782
|
}
|
|
746
|
-
startInteraction(e, t, n,
|
|
783
|
+
startInteraction(e, t, n, o) {
|
|
747
784
|
this.state = {
|
|
748
785
|
item: e,
|
|
749
786
|
mode: t,
|
|
750
787
|
startX: n,
|
|
751
|
-
startY:
|
|
788
|
+
startY: o,
|
|
752
789
|
currentX: n,
|
|
753
|
-
currentY:
|
|
790
|
+
currentY: o,
|
|
754
791
|
deltaX: 0,
|
|
755
792
|
originalGroup: e.group,
|
|
756
793
|
currentGroup: e.group
|
|
757
794
|
}, this.activated = !1;
|
|
758
795
|
}
|
|
759
796
|
update(e, t) {
|
|
760
|
-
this.state && (this.state.currentX = e, this.state.currentY = t, this.state.deltaX = e - this.state.startX, !this.activated && Math.abs(this.state.deltaX) >=
|
|
797
|
+
this.state && (this.state.currentX = e, this.state.currentY = t, this.state.deltaX = e - this.state.startX, !this.activated && Math.abs(this.state.deltaX) >= Ri && (this.activated = !0));
|
|
761
798
|
}
|
|
762
799
|
setCurrentGroup(e) {
|
|
763
800
|
this.state && (this.state.currentGroup = e);
|
|
@@ -765,14 +802,14 @@ class Hi {
|
|
|
765
802
|
endMove(e) {
|
|
766
803
|
if (!this.state)
|
|
767
804
|
return null;
|
|
768
|
-
const t = this.state.deltaX / e, n = this.state.item.start_time + t,
|
|
769
|
-
return this.state = null, this.activated = !1, { newStartTime:
|
|
805
|
+
const t = this.state.deltaX / e, n = this.state.item.start_time + t, o = Math.round(n / this.dragSnap) * this.dragSnap, d = this.state.currentGroup;
|
|
806
|
+
return this.state = null, this.activated = !1, { newStartTime: o, newGroupId: d };
|
|
770
807
|
}
|
|
771
808
|
endResize(e) {
|
|
772
809
|
if (!this.state)
|
|
773
810
|
return null;
|
|
774
|
-
const t = this.state.deltaX / e, n = this.state.mode === "resize-left" ? "left" : "right", d = (n === "left" ? this.state.item.start_time : this.state.item.end_time) + t,
|
|
775
|
-
return this.state = null, this.activated = !1, { newTime:
|
|
811
|
+
const t = this.state.deltaX / e, n = this.state.mode === "resize-left" ? "left" : "right", d = (n === "left" ? this.state.item.start_time : this.state.item.end_time) + t, l = Math.round(d / this.dragSnap) * this.dragSnap;
|
|
812
|
+
return this.state = null, this.activated = !1, { newTime: l, edge: n };
|
|
776
813
|
}
|
|
777
814
|
cancel() {
|
|
778
815
|
this.state = null, this.activated = !1;
|
|
@@ -791,105 +828,125 @@ class Hi {
|
|
|
791
828
|
return this.state !== null;
|
|
792
829
|
}
|
|
793
830
|
}
|
|
794
|
-
function
|
|
831
|
+
function vt(i, e, t) {
|
|
795
832
|
const n = [];
|
|
796
|
-
for (const
|
|
797
|
-
|
|
833
|
+
for (const o of i)
|
|
834
|
+
o.id !== e && (n.push(t(o.start_time)), n.push(t(o.end_time)));
|
|
798
835
|
return n;
|
|
799
836
|
}
|
|
800
|
-
function
|
|
837
|
+
function it(i, e, t, n, o) {
|
|
801
838
|
if (e.length === 0)
|
|
802
839
|
return null;
|
|
803
|
-
let d = e[0],
|
|
804
|
-
for (let
|
|
805
|
-
const
|
|
806
|
-
|
|
840
|
+
let d = e[0], l = Math.abs(i - d);
|
|
841
|
+
for (let c = 1; c < e.length; c++) {
|
|
842
|
+
const u = Math.abs(i - e[c]);
|
|
843
|
+
u < l && (l = u, d = e[c]);
|
|
807
844
|
}
|
|
808
|
-
return
|
|
845
|
+
return l <= t ? d : null;
|
|
809
846
|
}
|
|
810
|
-
var
|
|
811
|
-
function
|
|
847
|
+
var Vt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
848
|
+
function Zt(i) {
|
|
812
849
|
return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
|
|
813
850
|
}
|
|
814
|
-
var
|
|
851
|
+
var qt = { exports: {} };
|
|
815
852
|
(function(i, e) {
|
|
816
853
|
(function(t, n) {
|
|
817
854
|
i.exports = n();
|
|
818
|
-
})(
|
|
855
|
+
})(Vt, function() {
|
|
819
856
|
var t = "day";
|
|
820
|
-
return function(n,
|
|
821
|
-
var
|
|
822
|
-
return
|
|
823
|
-
},
|
|
824
|
-
|
|
825
|
-
return
|
|
826
|
-
},
|
|
827
|
-
if (!this.$utils().u(
|
|
828
|
-
var
|
|
829
|
-
return
|
|
830
|
-
},
|
|
831
|
-
return this.$utils().u(
|
|
857
|
+
return function(n, o, d) {
|
|
858
|
+
var l = function(p) {
|
|
859
|
+
return p.add(4 - p.isoWeekday(), t);
|
|
860
|
+
}, c = o.prototype;
|
|
861
|
+
c.isoWeekYear = function() {
|
|
862
|
+
return l(this).year();
|
|
863
|
+
}, c.isoWeek = function(p) {
|
|
864
|
+
if (!this.$utils().u(p)) return this.add(7 * (p - this.isoWeek()), t);
|
|
865
|
+
var M, m, b, T, H = l(this), O = (M = this.isoWeekYear(), m = this.$u, b = (m ? d.utc : d)().year(M).startOf("year"), T = 4 - b.isoWeekday(), b.isoWeekday() > 4 && (T += 7), b.add(T, t));
|
|
866
|
+
return H.diff(O, "week") + 1;
|
|
867
|
+
}, c.isoWeekday = function(p) {
|
|
868
|
+
return this.$utils().u(p) ? this.day() || 7 : this.day(this.day() % 7 ? p : p - 7);
|
|
832
869
|
};
|
|
833
|
-
var
|
|
834
|
-
|
|
835
|
-
var
|
|
836
|
-
return
|
|
870
|
+
var u = c.startOf;
|
|
871
|
+
c.startOf = function(p, M) {
|
|
872
|
+
var m = this.$utils(), b = !!m.u(M) || M;
|
|
873
|
+
return m.p(p) === "isoweek" ? b ? this.date(this.date() - (this.isoWeekday() - 1)).startOf("day") : this.date(this.date() - 1 - (this.isoWeekday() - 1) + 7).endOf("day") : u.bind(this)(p, M);
|
|
837
874
|
};
|
|
838
875
|
};
|
|
839
876
|
});
|
|
840
|
-
})(
|
|
841
|
-
var
|
|
842
|
-
const
|
|
843
|
-
function
|
|
844
|
-
var
|
|
845
|
-
const
|
|
846
|
-
|
|
877
|
+
})(qt);
|
|
878
|
+
var Di = qt.exports;
|
|
879
|
+
const Oi = /* @__PURE__ */ Zt(Di), At = 200;
|
|
880
|
+
function jt({ groups: i, width: e, lineHeight: t, groupHeights: n, scrollTop: o, canvasHeight: d, theme: l, groupRenderer: c, onScroll: u }) {
|
|
881
|
+
var X;
|
|
882
|
+
const p = x(null), M = x(!1), m = Q(() => {
|
|
883
|
+
const E = new Array(i.length + 1);
|
|
884
|
+
E[0] = 0;
|
|
885
|
+
for (let R = 0; R < i.length; R++)
|
|
886
|
+
E[R + 1] = E[R] + ((n == null ? void 0 : n[R]) ?? t);
|
|
887
|
+
return E;
|
|
888
|
+
}, [i.length, n, t]), b = m[i.length] ?? 0, T = d, H = ne((E) => {
|
|
889
|
+
if (i.length === 0 || E <= 0)
|
|
890
|
+
return 0;
|
|
891
|
+
if (E >= b)
|
|
892
|
+
return i.length - 1;
|
|
893
|
+
let R = 0, z = i.length - 1;
|
|
894
|
+
for (; R < z; ) {
|
|
895
|
+
const B = R + z >>> 1;
|
|
896
|
+
m[B + 1] > E ? z = B : R = B + 1;
|
|
897
|
+
}
|
|
898
|
+
return R;
|
|
899
|
+
}, [i.length, m, b]), O = H(o - At), j = H(o + d + At), re = ne((E) => {
|
|
900
|
+
M.current || u(E.currentTarget.scrollTop);
|
|
847
901
|
}, [u]);
|
|
848
902
|
he(() => {
|
|
849
|
-
|
|
850
|
-
|
|
903
|
+
p.current && (M.current = !0, p.current.scrollTop = o, requestAnimationFrame(() => {
|
|
904
|
+
M.current = !1;
|
|
851
905
|
}));
|
|
852
|
-
}, [
|
|
853
|
-
const
|
|
854
|
-
for (let
|
|
855
|
-
const
|
|
856
|
-
|
|
906
|
+
}, [o]);
|
|
907
|
+
const w = [];
|
|
908
|
+
for (let E = O; E <= j; E++) {
|
|
909
|
+
const R = i[E];
|
|
910
|
+
if (!R)
|
|
911
|
+
continue;
|
|
912
|
+
const z = m[E], B = m[E + 1] - z;
|
|
913
|
+
w.push(se("div", { style: {
|
|
857
914
|
position: "absolute",
|
|
858
|
-
top:
|
|
859
|
-
height:
|
|
915
|
+
top: z,
|
|
916
|
+
height: B,
|
|
860
917
|
width: "100%",
|
|
861
918
|
overflow: "hidden",
|
|
862
919
|
display: "flex",
|
|
863
920
|
alignItems: "stretch",
|
|
864
|
-
borderBottom: `1px solid ${((
|
|
921
|
+
borderBottom: `1px solid ${((X = l.grid) == null ? void 0 : X.line) ?? "#E5E5E5"}`,
|
|
865
922
|
boxSizing: "border-box"
|
|
866
|
-
}, children:
|
|
923
|
+
}, children: c(R) }, R.id));
|
|
867
924
|
}
|
|
868
|
-
return se("div", { ref:
|
|
925
|
+
return se("div", { ref: p, onScroll: re, style: {
|
|
869
926
|
width: e,
|
|
870
|
-
height:
|
|
871
|
-
overflowY:
|
|
927
|
+
height: T,
|
|
928
|
+
overflowY: b > d ? "auto" : "hidden",
|
|
872
929
|
overflowX: "hidden",
|
|
873
930
|
position: "relative",
|
|
874
|
-
borderRight: `1px solid ${
|
|
875
|
-
backgroundColor:
|
|
876
|
-
}, children: se("div", { style: { height:
|
|
931
|
+
borderRight: `1px solid ${l.sidebar.border}`,
|
|
932
|
+
backgroundColor: l.sidebar.bg
|
|
933
|
+
}, children: se("div", { style: { height: b, position: "relative" }, children: w }) });
|
|
877
934
|
}
|
|
878
|
-
function
|
|
935
|
+
function Xi(i) {
|
|
879
936
|
return null;
|
|
880
937
|
}
|
|
881
|
-
|
|
882
|
-
function
|
|
938
|
+
Xi.displayName = "TodayMarker";
|
|
939
|
+
function Gt(i) {
|
|
883
940
|
return { date: Math.floor(Date.now() / 6e4) * 6e4, color: i.color ?? "#FD7171", width: i.width ?? 6, label: i.label };
|
|
884
941
|
}
|
|
885
|
-
function
|
|
942
|
+
function _i(i) {
|
|
886
943
|
return i.interval ?? 1e4;
|
|
887
944
|
}
|
|
888
|
-
function
|
|
945
|
+
function Fi(i) {
|
|
889
946
|
return null;
|
|
890
947
|
}
|
|
891
|
-
|
|
892
|
-
function
|
|
948
|
+
Fi.displayName = "CustomMarker";
|
|
949
|
+
function Nt(i) {
|
|
893
950
|
return {
|
|
894
951
|
date: i.date,
|
|
895
952
|
color: i.color ?? "#3B82F6",
|
|
@@ -897,555 +954,571 @@ function At(i) {
|
|
|
897
954
|
label: i.label
|
|
898
955
|
};
|
|
899
956
|
}
|
|
900
|
-
|
|
901
|
-
function
|
|
957
|
+
ve.extend(Oi);
|
|
958
|
+
function Wi(i) {
|
|
902
959
|
return i ? {
|
|
903
|
-
...
|
|
960
|
+
...Ce,
|
|
904
961
|
...i,
|
|
905
|
-
status: { ...
|
|
906
|
-
grid: { ...
|
|
907
|
-
item: { ...
|
|
908
|
-
marker: { ...
|
|
909
|
-
sidebar: { ...
|
|
910
|
-
header: { ...
|
|
911
|
-
} :
|
|
962
|
+
status: { ...Ce.status, ...i.status },
|
|
963
|
+
grid: { ...Ce.grid, ...i.grid },
|
|
964
|
+
item: { ...Ce.item, ...i.item },
|
|
965
|
+
marker: { ...Ce.marker, ...i.marker },
|
|
966
|
+
sidebar: { ...Ce.sidebar, ...i.sidebar },
|
|
967
|
+
header: { ...Ce.header, ...i.header }
|
|
968
|
+
} : Ce;
|
|
912
969
|
}
|
|
913
|
-
const
|
|
914
|
-
const { groups: n, items:
|
|
915
|
-
for (let h = 0; h <
|
|
916
|
-
if (
|
|
970
|
+
const zt = 32, Ui = me.memo(pi(function(e, t) {
|
|
971
|
+
const { groups: n, items: o, defaultTimeStart: d, defaultTimeEnd: l, sidebarWidth: c, lineHeight: u, itemHeightRatio: p, stackItems: M, canMove: m, canChangeGroup: b, canResize: T, dragSnap: H, minZoom: O, maxZoom: j, theme: re, dayStyle: w, rowStyle: X, showCursorLine: E, itemRenderer: R, groupRenderer: z, sidebarGroupRenderer: B, dependencies: _, highlights: G, onItemClick: q, onItemDoubleClick: J, onItemContextMenu: oe, onItemMove: ue, onItemResize: ye, moveResizeValidator: Oe, onItemHover: Te, onCanvasDoubleClick: Xe, onCanvasContextMenu: Ve, onTimeChange: He, onZoom: bt, selected: yt = [], rightSidebarWidth: nt, rightSidebarGroupRenderer: Tt, onReady: Ze, devBadge: Kt, children: ke } = e, Se = Q(() => Wi(re), [re]), St = ne((r, s) => {
|
|
972
|
+
for (let h = 0; h < s.length; h++)
|
|
973
|
+
if (s[h].id === r)
|
|
917
974
|
return h;
|
|
918
975
|
return 0;
|
|
919
|
-
}, []),
|
|
976
|
+
}, []), Jt = yt.join(","), rt = Q(() => yt, [Jt]), kt = x(null), wt = x(null), Mt = x(null), Ye = x(null), Et = x(null), Qt = x(null), [ei, ti] = tt(800);
|
|
920
977
|
he(() => {
|
|
921
|
-
const r =
|
|
978
|
+
const r = Et.current;
|
|
922
979
|
if (!r)
|
|
923
980
|
return;
|
|
924
|
-
const
|
|
981
|
+
const s = new ResizeObserver((h) => {
|
|
925
982
|
const f = h[0];
|
|
926
|
-
f &&
|
|
983
|
+
f && ti(f.contentRect.width);
|
|
927
984
|
});
|
|
928
|
-
return
|
|
985
|
+
return s.observe(r), () => s.disconnect();
|
|
929
986
|
}, []);
|
|
930
|
-
const
|
|
987
|
+
const we = Math.max(0, ei - c - (nt ?? 0)), Ie = Q(() => {
|
|
988
|
+
const r = new Si();
|
|
989
|
+
return r.rebuild(o), r;
|
|
990
|
+
}, [o]), ot = Q(() => {
|
|
991
|
+
const r = new yi();
|
|
992
|
+
return r.buildFromItems(o, (s) => Ie.getEffectiveSpan(s.id).start, (s) => Ie.getEffectiveSpan(s.id).end), r;
|
|
993
|
+
}, [o, Ie]), Le = Q(() => {
|
|
994
|
+
const r = new Ti(u, p);
|
|
995
|
+
return r.computeLayout(o, M, Ie), r;
|
|
996
|
+
}, [o, u, p, M, Ie]), Re = Q(() => n.map((r) => Le.getGroupHeight(r.id)), [n, Le]), Me = Q(() => Re.reduce((r, s) => r + s, 0), [Re]), F = x(new ft({
|
|
931
997
|
visibleTimeStart: e.visibleTimeStart ?? d,
|
|
932
|
-
visibleTimeEnd: e.visibleTimeEnd ??
|
|
933
|
-
canvasWidth:
|
|
934
|
-
canvasHeight:
|
|
935
|
-
sidebarWidth:
|
|
936
|
-
lineHeight:
|
|
998
|
+
visibleTimeEnd: e.visibleTimeEnd ?? l,
|
|
999
|
+
canvasWidth: we,
|
|
1000
|
+
canvasHeight: Me,
|
|
1001
|
+
sidebarWidth: c,
|
|
1002
|
+
lineHeight: u,
|
|
937
1003
|
groupCount: n.length,
|
|
938
1004
|
buffer: e.buffer ?? 3,
|
|
939
|
-
scrollTop: 0
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
1005
|
+
scrollTop: 0,
|
|
1006
|
+
groupHeights: Re
|
|
1007
|
+
})), st = x(null), Ae = x(void 0), be = x(null), Pe = x(!1), Ct = 4, [Ht, ii] = tt(e.visibleTimeStart ?? d), [It, ni] = tt(e.visibleTimeEnd ?? l), [Rt, qe] = tt(0), je = x(null), _e = ne(() => {
|
|
1008
|
+
const r = F.current;
|
|
1009
|
+
ii(r.visibleTimeStart), ni(r.visibleTimeEnd), qe(r.scrollTop), je.current = null;
|
|
1010
|
+
}, []), lt = ne(() => {
|
|
1011
|
+
je.current === null && (je.current = setTimeout(_e, zt));
|
|
1012
|
+
}, [_e]);
|
|
946
1013
|
he(() => () => {
|
|
947
|
-
|
|
1014
|
+
je.current !== null && clearTimeout(je.current);
|
|
948
1015
|
}, []);
|
|
949
|
-
const
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
}, [s]), nt = oe(() => {
|
|
953
|
-
const r = new pi();
|
|
954
|
-
return r.buildFromItems(s, (o) => Ie.getEffectiveSpan(o.id).start, (o) => Ie.getEffectiveSpan(o.id).end), r;
|
|
955
|
-
}, [s, Ie]), rt = oe(() => {
|
|
956
|
-
const r = new vi(c, v);
|
|
957
|
-
return r.computeLayout(s, k, Ie), r;
|
|
958
|
-
}, [s, c, v, k, Ie]), Ht = oe(() => e.summaryRenderer ? e.summaryRenderer : (r, o, h, f, l) => {
|
|
959
|
-
yi(r, o, h, f, l, Te);
|
|
960
|
-
}, [e.summaryRenderer, Te]), Xe = oe(() => new Si(), []), _e = oe(() => new Mi(), []), Fe = oe(() => new ki(), []), Q = oe(() => new Hi(C), [C]), Ge = oe(() => {
|
|
1016
|
+
const Pt = Q(() => e.summaryRenderer ? e.summaryRenderer : (r, s, h, f, a) => {
|
|
1017
|
+
ki(r, s, h, f, a, Se);
|
|
1018
|
+
}, [e.summaryRenderer, Se]), Fe = Q(() => new Mi(), []), We = Q(() => new Ei(), []), Be = Q(() => new Ci(), []), ee = Q(() => new Pi(H), [H]), Ue = Q(() => {
|
|
961
1019
|
const r = [];
|
|
962
|
-
return
|
|
1020
|
+
return me.Children.forEach(ke, (s) => {
|
|
963
1021
|
var f;
|
|
964
|
-
if (!
|
|
1022
|
+
if (!me.isValidElement(s))
|
|
965
1023
|
return;
|
|
966
|
-
const h = (f =
|
|
967
|
-
h === "TodayMarker" ? r.push(
|
|
1024
|
+
const h = (f = s.type) == null ? void 0 : f.displayName;
|
|
1025
|
+
h === "TodayMarker" ? r.push(Gt(s.props)) : h === "CustomMarker" && r.push(Nt(s.props));
|
|
968
1026
|
}), r;
|
|
969
|
-
}, [
|
|
970
|
-
|
|
971
|
-
const
|
|
1027
|
+
}, [ke]), Ke = Q(() => Ue.map((r) => `${r.date}|${r.color}|${r.width}|${r.label ?? ""}`).join(";"), [Ue]), Ge = x(Ue);
|
|
1028
|
+
Ge.current = Ue;
|
|
1029
|
+
const at = Q(() => {
|
|
972
1030
|
let r = 0;
|
|
973
|
-
return
|
|
1031
|
+
return me.Children.forEach(ke, (s) => {
|
|
974
1032
|
var f;
|
|
975
|
-
if (!
|
|
1033
|
+
if (!me.isValidElement(s))
|
|
976
1034
|
return;
|
|
977
|
-
((f =
|
|
1035
|
+
((f = s.type) == null ? void 0 : f.displayName) === "TodayMarker" && (r = _i(s.props));
|
|
978
1036
|
}), r;
|
|
979
|
-
}, [
|
|
1037
|
+
}, [ke]), Y = x({
|
|
980
1038
|
groups: n,
|
|
981
|
-
items:
|
|
982
|
-
intervalTree:
|
|
983
|
-
layoutEngine:
|
|
984
|
-
itemRenderer:
|
|
985
|
-
groupRenderer:
|
|
986
|
-
theme:
|
|
987
|
-
selected:
|
|
988
|
-
dependencies:
|
|
989
|
-
highlights:
|
|
990
|
-
dayStyle:
|
|
991
|
-
rowStyle:
|
|
992
|
-
showCursorLine:
|
|
993
|
-
canvasWidth:
|
|
994
|
-
canvasHeight:
|
|
995
|
-
lineHeight:
|
|
996
|
-
itemHeightRatio:
|
|
997
|
-
onTimeChange:
|
|
998
|
-
onZoom:
|
|
999
|
-
onItemHover:
|
|
1039
|
+
items: o,
|
|
1040
|
+
intervalTree: ot,
|
|
1041
|
+
layoutEngine: Le,
|
|
1042
|
+
itemRenderer: R,
|
|
1043
|
+
groupRenderer: z,
|
|
1044
|
+
theme: Se,
|
|
1045
|
+
selected: rt,
|
|
1046
|
+
dependencies: _,
|
|
1047
|
+
highlights: G,
|
|
1048
|
+
dayStyle: w,
|
|
1049
|
+
rowStyle: X,
|
|
1050
|
+
showCursorLine: E,
|
|
1051
|
+
canvasWidth: we,
|
|
1052
|
+
canvasHeight: Me,
|
|
1053
|
+
lineHeight: u,
|
|
1054
|
+
itemHeightRatio: p,
|
|
1055
|
+
onTimeChange: He,
|
|
1056
|
+
onZoom: bt,
|
|
1057
|
+
onItemHover: Te,
|
|
1000
1058
|
onItemClick: q,
|
|
1001
1059
|
onItemDoubleClick: J,
|
|
1002
|
-
onItemContextMenu:
|
|
1060
|
+
onItemContextMenu: oe,
|
|
1003
1061
|
onItemMove: ue,
|
|
1004
|
-
onItemResize:
|
|
1005
|
-
onCanvasDoubleClick:
|
|
1006
|
-
onCanvasContextMenu:
|
|
1007
|
-
canMove:
|
|
1062
|
+
onItemResize: ye,
|
|
1063
|
+
onCanvasDoubleClick: Xe,
|
|
1064
|
+
onCanvasContextMenu: Ve,
|
|
1065
|
+
canMove: m,
|
|
1008
1066
|
canResize: T,
|
|
1009
1067
|
canChangeGroup: b,
|
|
1010
|
-
dragSnap:
|
|
1011
|
-
sidebarWidth:
|
|
1012
|
-
moveResizeValidator:
|
|
1013
|
-
summaryRenderer:
|
|
1068
|
+
dragSnap: H,
|
|
1069
|
+
sidebarWidth: c,
|
|
1070
|
+
moveResizeValidator: Oe,
|
|
1071
|
+
summaryRenderer: Pt,
|
|
1014
1072
|
hierarchyEngine: Ie
|
|
1015
1073
|
});
|
|
1016
|
-
|
|
1074
|
+
Y.current = {
|
|
1017
1075
|
groups: n,
|
|
1018
|
-
items:
|
|
1019
|
-
intervalTree:
|
|
1020
|
-
layoutEngine:
|
|
1021
|
-
itemRenderer:
|
|
1022
|
-
groupRenderer:
|
|
1023
|
-
theme:
|
|
1024
|
-
selected:
|
|
1025
|
-
dependencies:
|
|
1026
|
-
highlights:
|
|
1027
|
-
dayStyle:
|
|
1028
|
-
rowStyle:
|
|
1029
|
-
showCursorLine:
|
|
1030
|
-
canvasWidth:
|
|
1031
|
-
canvasHeight:
|
|
1032
|
-
lineHeight:
|
|
1033
|
-
itemHeightRatio:
|
|
1034
|
-
onTimeChange:
|
|
1035
|
-
onZoom:
|
|
1036
|
-
onItemHover:
|
|
1076
|
+
items: o,
|
|
1077
|
+
intervalTree: ot,
|
|
1078
|
+
layoutEngine: Le,
|
|
1079
|
+
itemRenderer: R,
|
|
1080
|
+
groupRenderer: z,
|
|
1081
|
+
theme: Se,
|
|
1082
|
+
selected: rt,
|
|
1083
|
+
dependencies: _,
|
|
1084
|
+
highlights: G,
|
|
1085
|
+
dayStyle: w,
|
|
1086
|
+
rowStyle: X,
|
|
1087
|
+
showCursorLine: E,
|
|
1088
|
+
canvasWidth: we,
|
|
1089
|
+
canvasHeight: Me,
|
|
1090
|
+
lineHeight: u,
|
|
1091
|
+
itemHeightRatio: p,
|
|
1092
|
+
onTimeChange: He,
|
|
1093
|
+
onZoom: bt,
|
|
1094
|
+
onItemHover: Te,
|
|
1037
1095
|
onItemClick: q,
|
|
1038
1096
|
onItemDoubleClick: J,
|
|
1039
|
-
onItemContextMenu:
|
|
1097
|
+
onItemContextMenu: oe,
|
|
1040
1098
|
onItemMove: ue,
|
|
1041
|
-
onItemResize:
|
|
1042
|
-
onCanvasDoubleClick:
|
|
1043
|
-
onCanvasContextMenu:
|
|
1044
|
-
canMove:
|
|
1099
|
+
onItemResize: ye,
|
|
1100
|
+
onCanvasDoubleClick: Xe,
|
|
1101
|
+
onCanvasContextMenu: Ve,
|
|
1102
|
+
canMove: m,
|
|
1045
1103
|
canResize: T,
|
|
1046
1104
|
canChangeGroup: b,
|
|
1047
|
-
dragSnap:
|
|
1048
|
-
sidebarWidth:
|
|
1049
|
-
moveResizeValidator:
|
|
1050
|
-
summaryRenderer:
|
|
1105
|
+
dragSnap: H,
|
|
1106
|
+
sidebarWidth: c,
|
|
1107
|
+
moveResizeValidator: Oe,
|
|
1108
|
+
summaryRenderer: Pt,
|
|
1051
1109
|
hierarchyEngine: Ie
|
|
1052
1110
|
};
|
|
1053
|
-
const
|
|
1054
|
-
const r =
|
|
1111
|
+
const ri = ne(() => {
|
|
1112
|
+
const r = kt.current;
|
|
1055
1113
|
if (!r)
|
|
1056
1114
|
return;
|
|
1057
|
-
const
|
|
1058
|
-
|
|
1059
|
-
}, [
|
|
1060
|
-
const r =
|
|
1115
|
+
const s = Y.current, h = gt(r, s.canvasWidth, s.canvasHeight);
|
|
1116
|
+
pt(h, r), Fe.draw(h, F.current, s.groups, s.theme, s.dayStyle, s.rowStyle, s.highlights);
|
|
1117
|
+
}, [Fe]), oi = ne(() => {
|
|
1118
|
+
const r = wt.current;
|
|
1061
1119
|
if (!r)
|
|
1062
1120
|
return;
|
|
1063
|
-
const
|
|
1064
|
-
|
|
1065
|
-
}, [
|
|
1066
|
-
const f =
|
|
1067
|
-
h === "move" ? (
|
|
1068
|
-
const I = (f.visibleTimeEnd - f.visibleTimeStart) * 0.1,
|
|
1069
|
-
for (const
|
|
1070
|
-
const
|
|
1071
|
-
if (
|
|
1072
|
-
return
|
|
1121
|
+
const s = Y.current, h = gt(r, s.canvasWidth, s.canvasHeight);
|
|
1122
|
+
pt(h, r), We.draw(h, F.current, s.groups, s.items, s.intervalTree, s.layoutEngine, s.itemRenderer, s.groupRenderer, s.theme, s.selected, Ae.current, s.dependencies, s.summaryRenderer, s.hierarchyEngine);
|
|
1123
|
+
}, [We]), Dt = ne((r, s, h) => {
|
|
1124
|
+
const f = F.current, a = Y.current, g = a.canvasWidth / (f.visibleTimeEnd - f.visibleTimeStart), y = s / g, k = [];
|
|
1125
|
+
h === "move" ? (k.push(f.timeToX(r.start_time + y)), k.push(f.timeToX(r.end_time + y))) : h === "resize-left" ? k.push(f.timeToX(r.start_time + y)) : k.push(f.timeToX(r.end_time + y));
|
|
1126
|
+
const I = (f.visibleTimeEnd - f.visibleTimeStart) * 0.1, P = a.intervalTree.query(f.visibleTimeStart - I, f.visibleTimeEnd + I), N = vt(P, r.id, (U) => f.timeToX(U));
|
|
1127
|
+
for (const U of k) {
|
|
1128
|
+
const Z = it(U, N, 8, g, a.dragSnap);
|
|
1129
|
+
if (Z !== null)
|
|
1130
|
+
return Z;
|
|
1073
1131
|
}
|
|
1074
|
-
const
|
|
1075
|
-
return f.timeToX(
|
|
1076
|
-
}, []),
|
|
1077
|
-
const r =
|
|
1132
|
+
const te = h === "resize-right" ? r.end_time + y : r.start_time + y, W = Math.round(te / a.dragSnap) * a.dragSnap;
|
|
1133
|
+
return f.timeToX(W);
|
|
1134
|
+
}, []), si = ne(() => {
|
|
1135
|
+
const r = Mt.current;
|
|
1078
1136
|
if (!r)
|
|
1079
1137
|
return;
|
|
1080
|
-
const
|
|
1081
|
-
|
|
1082
|
-
const f =
|
|
1083
|
-
let
|
|
1084
|
-
if (
|
|
1085
|
-
const y = f.timeToX(
|
|
1086
|
-
let I,
|
|
1087
|
-
|
|
1088
|
-
const
|
|
1089
|
-
|
|
1090
|
-
item:
|
|
1091
|
-
mode:
|
|
1092
|
-
bounds: { x: I, y:
|
|
1093
|
-
renderer:
|
|
1094
|
-
targetGroupY:
|
|
1095
|
-
groupChanged:
|
|
1138
|
+
const s = Y.current, h = gt(r, s.canvasWidth, s.canvasHeight);
|
|
1139
|
+
pt(h, r);
|
|
1140
|
+
const f = F.current, a = ee.getState();
|
|
1141
|
+
let g = null;
|
|
1142
|
+
if (a) {
|
|
1143
|
+
const y = f.timeToX(a.item.start_time), k = f.timeToX(a.item.end_time) - y;
|
|
1144
|
+
let I, P;
|
|
1145
|
+
a.mode === "resize-left" ? (I = y + a.deltaX, P = k - a.deltaX) : a.mode === "resize-right" ? (I = y, P = k + a.deltaX) : (I = y + a.deltaX, P = k);
|
|
1146
|
+
const N = St(a.currentGroup, s.groups), te = f.groupIndexToY(N), W = a.currentGroup !== a.originalGroup;
|
|
1147
|
+
g = {
|
|
1148
|
+
item: a.item,
|
|
1149
|
+
mode: a.mode,
|
|
1150
|
+
bounds: { x: I, y: te + (s.lineHeight - s.lineHeight * s.itemHeightRatio) / 2, width: P, height: s.lineHeight * s.itemHeightRatio },
|
|
1151
|
+
renderer: s.itemRenderer,
|
|
1152
|
+
targetGroupY: te,
|
|
1153
|
+
groupChanged: W
|
|
1096
1154
|
};
|
|
1097
1155
|
}
|
|
1098
|
-
|
|
1099
|
-
cursorX:
|
|
1100
|
-
snapX:
|
|
1101
|
-
markers:
|
|
1102
|
-
interaction:
|
|
1156
|
+
Be.draw(h, f, s.theme, {
|
|
1157
|
+
cursorX: s.showCursorLine ? st.current : null,
|
|
1158
|
+
snapX: a ? Dt(a.item, a.deltaX, a.mode) : null,
|
|
1159
|
+
markers: Ge.current,
|
|
1160
|
+
interaction: g
|
|
1103
1161
|
});
|
|
1104
|
-
}, [
|
|
1105
|
-
|
|
1106
|
-
r.grid &&
|
|
1162
|
+
}, [Be, ee, Dt, St]), ut = x(null);
|
|
1163
|
+
ut.current || (ut.current = new wi((r) => {
|
|
1164
|
+
r.grid && ri(), r.items && oi(), r.overlay && si();
|
|
1107
1165
|
}));
|
|
1108
|
-
const
|
|
1109
|
-
he(() => () =>
|
|
1110
|
-
if (!
|
|
1166
|
+
const C = ut.current;
|
|
1167
|
+
he(() => () => C.dispose(), [C]), he(() => {
|
|
1168
|
+
if (!at)
|
|
1111
1169
|
return;
|
|
1112
1170
|
const r = setInterval(() => {
|
|
1113
|
-
const
|
|
1114
|
-
|
|
1115
|
-
var
|
|
1116
|
-
if (!
|
|
1171
|
+
const s = [];
|
|
1172
|
+
me.Children.forEach(ke, (h) => {
|
|
1173
|
+
var a;
|
|
1174
|
+
if (!me.isValidElement(h))
|
|
1117
1175
|
return;
|
|
1118
|
-
const f = (
|
|
1119
|
-
f === "TodayMarker" ?
|
|
1120
|
-
}),
|
|
1121
|
-
},
|
|
1176
|
+
const f = (a = h.type) == null ? void 0 : a.displayName;
|
|
1177
|
+
f === "TodayMarker" ? s.push(Gt(h.props)) : f === "CustomMarker" && s.push(Nt(h.props));
|
|
1178
|
+
}), Ge.current = s, C.markDirty("overlay");
|
|
1179
|
+
}, at);
|
|
1122
1180
|
return () => clearInterval(r);
|
|
1123
|
-
}, [
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1181
|
+
}, [at, ke, C]), he(() => {
|
|
1182
|
+
F.current.update({
|
|
1183
|
+
canvasWidth: we,
|
|
1184
|
+
canvasHeight: Me,
|
|
1185
|
+
sidebarWidth: c,
|
|
1186
|
+
lineHeight: u,
|
|
1187
|
+
groupCount: n.length,
|
|
1188
|
+
groupHeights: Re
|
|
1189
|
+
}), C.markAllDirty();
|
|
1190
|
+
}, [we, Me, c, u, n.length, Re, C]), he(() => {
|
|
1191
|
+
C.markDirty("grid"), C.markDirty("items");
|
|
1192
|
+
}, [o, n, rt, Se, w, X, ot, Le, C]);
|
|
1193
|
+
const Je = Q(() => {
|
|
1129
1194
|
var r;
|
|
1130
|
-
return ((r = e.highlights) == null ? void 0 : r.map((
|
|
1131
|
-
}, [e.highlights]),
|
|
1195
|
+
return ((r = e.highlights) == null ? void 0 : r.map((s) => `${s.start}|${s.end}|${s.color}|${s.label ?? ""}|${s.opacity ?? ""}`).join(";")) ?? "";
|
|
1196
|
+
}, [e.highlights]), Ot = x(Je);
|
|
1132
1197
|
he(() => {
|
|
1133
|
-
|
|
1134
|
-
}, [
|
|
1135
|
-
const
|
|
1198
|
+
Je !== Ot.current && (Ot.current = Je, C.markDirty("grid"));
|
|
1199
|
+
}, [Je, C]);
|
|
1200
|
+
const Xt = x(Ke);
|
|
1136
1201
|
he(() => {
|
|
1137
|
-
|
|
1138
|
-
}, [
|
|
1139
|
-
const
|
|
1140
|
-
e.visibleTimeStart !== void 0 && e.visibleTimeStart !==
|
|
1141
|
-
const
|
|
1142
|
-
|
|
1143
|
-
var f,
|
|
1144
|
-
|
|
1145
|
-
const
|
|
1146
|
-
r === "zoom" ? (f = h.onZoom) == null || f.call(h,
|
|
1147
|
-
},
|
|
1202
|
+
Ke !== Xt.current && (Xt.current = Ke, C.markDirty("overlay"));
|
|
1203
|
+
}, [Ke, C]);
|
|
1204
|
+
const _t = x(e.visibleTimeStart), Ft = x(e.visibleTimeEnd);
|
|
1205
|
+
e.visibleTimeStart !== void 0 && e.visibleTimeStart !== _t.current && (_t.current = e.visibleTimeStart, F.current.update({ visibleTimeStart: e.visibleTimeStart }), C.markAllDirty()), e.visibleTimeEnd !== void 0 && e.visibleTimeEnd !== Ft.current && (Ft.current = e.visibleTimeEnd, F.current.update({ visibleTimeEnd: e.visibleTimeEnd }), C.markAllDirty());
|
|
1206
|
+
const Ne = x(null), ct = ne((r) => {
|
|
1207
|
+
Ne.current === null && (Ne.current = setTimeout(() => {
|
|
1208
|
+
var f, a;
|
|
1209
|
+
Ne.current = null;
|
|
1210
|
+
const s = F.current, h = Y.current;
|
|
1211
|
+
r === "zoom" ? (f = h.onZoom) == null || f.call(h, s.visibleTimeStart, s.visibleTimeEnd) : (a = h.onTimeChange) == null || a.call(h, s.visibleTimeStart, s.visibleTimeEnd);
|
|
1212
|
+
}, zt));
|
|
1148
1213
|
}, []);
|
|
1149
1214
|
he(() => () => {
|
|
1150
|
-
|
|
1215
|
+
Ne.current !== null && clearTimeout(Ne.current);
|
|
1151
1216
|
}, []);
|
|
1152
|
-
const
|
|
1217
|
+
const Qe = x(null), dt = Q(() => new Ii((r, s) => {
|
|
1153
1218
|
var h;
|
|
1154
|
-
|
|
1155
|
-
}, d,
|
|
1156
|
-
|
|
1157
|
-
const
|
|
1158
|
-
const
|
|
1159
|
-
|
|
1160
|
-
}, [
|
|
1161
|
-
var y,
|
|
1162
|
-
const
|
|
1163
|
-
|
|
1164
|
-
}, [
|
|
1219
|
+
F.current.update({ visibleTimeStart: r, visibleTimeEnd: s }), (h = Qe.current) == null || h.updateBounds(r, s), C.markAllDirty(), lt(), ct("zoom");
|
|
1220
|
+
}, d, l, O, j), []);
|
|
1221
|
+
Qe.current = dt;
|
|
1222
|
+
const et = ne((r) => {
|
|
1223
|
+
const s = F.current, h = s.getTotalHeight(), f = Math.max(0, h - s.canvasHeight), a = Math.max(0, Math.min(f, s.scrollTop + r));
|
|
1224
|
+
a !== s.scrollTop && (s.update({ scrollTop: a }), C.markDirty("grid"), C.markDirty("items"), C.markDirty("overlay"), qe(a));
|
|
1225
|
+
}, [C]), ze = ne((r) => {
|
|
1226
|
+
var y, k, I;
|
|
1227
|
+
const s = F.current, h = s.canvasWidth / (s.visibleTimeEnd - s.visibleTimeStart), f = r / h, a = s.visibleTimeStart + f, g = s.visibleTimeEnd + f;
|
|
1228
|
+
s.update({ visibleTimeStart: a, visibleTimeEnd: g }), (y = Qe.current) == null || y.updateBounds(a, g), C.markAllDirty(), bi(() => _e()), (I = (k = Y.current).onTimeChange) == null || I.call(k, a, g);
|
|
1229
|
+
}, [C, _e]);
|
|
1165
1230
|
he(() => {
|
|
1166
|
-
const r =
|
|
1231
|
+
const r = Ye.current;
|
|
1167
1232
|
if (!r)
|
|
1168
1233
|
return;
|
|
1169
|
-
const
|
|
1234
|
+
const s = (h) => {
|
|
1170
1235
|
if (h.ctrlKey || h.metaKey || h.altKey) {
|
|
1171
1236
|
h.preventDefault();
|
|
1172
|
-
const f = r.getBoundingClientRect(),
|
|
1173
|
-
|
|
1237
|
+
const f = r.getBoundingClientRect(), a = (h.clientX - f.left) / f.width;
|
|
1238
|
+
dt.handleWheelZoom(h, a);
|
|
1174
1239
|
} else if (h.shiftKey)
|
|
1175
|
-
h.preventDefault(),
|
|
1240
|
+
h.preventDefault(), ze(h.deltaY || h.deltaX);
|
|
1176
1241
|
else {
|
|
1177
1242
|
const f = h.deltaX;
|
|
1178
|
-
f !== 0 && Math.abs(f) > Math.abs(h.deltaY) ? (h.preventDefault(),
|
|
1243
|
+
f !== 0 && Math.abs(f) > Math.abs(h.deltaY) ? (h.preventDefault(), ze(f)) : h.deltaY !== 0 && et(h.deltaY);
|
|
1179
1244
|
}
|
|
1180
1245
|
};
|
|
1181
|
-
return r.addEventListener("wheel",
|
|
1182
|
-
}, [
|
|
1183
|
-
const
|
|
1246
|
+
return r.addEventListener("wheel", s, { passive: !1 }), () => r.removeEventListener("wheel", s);
|
|
1247
|
+
}, [dt, et, ze]);
|
|
1248
|
+
const Ee = x({ lastDistance: null, lastCenter: null });
|
|
1184
1249
|
he(() => {
|
|
1185
|
-
const r =
|
|
1250
|
+
const r = Ye.current;
|
|
1186
1251
|
if (!r)
|
|
1187
1252
|
return;
|
|
1188
|
-
const
|
|
1189
|
-
y.touches.length === 2 && (y.preventDefault(),
|
|
1190
|
-
},
|
|
1191
|
-
var
|
|
1192
|
-
if (y.touches.length === 2 &&
|
|
1253
|
+
const s = (y, k) => Math.abs(y.clientX - k.clientX), h = (y, k, I) => (y.clientX + k.clientX) / 2 - I.left, f = (y) => {
|
|
1254
|
+
y.touches.length === 2 && (y.preventDefault(), Ee.current.lastDistance = s(y.touches[0], y.touches[1]), Ee.current.lastCenter = null);
|
|
1255
|
+
}, a = (y) => {
|
|
1256
|
+
var k;
|
|
1257
|
+
if (y.touches.length === 2 && Ee.current.lastDistance !== null) {
|
|
1193
1258
|
y.preventDefault();
|
|
1194
|
-
const I =
|
|
1195
|
-
if (I !== 0 &&
|
|
1196
|
-
const
|
|
1197
|
-
let
|
|
1198
|
-
|
|
1199
|
-
const
|
|
1200
|
-
|
|
1259
|
+
const I = s(y.touches[0], y.touches[1]), P = r.getBoundingClientRect(), te = h(y.touches[0], y.touches[1], P) / P.width;
|
|
1260
|
+
if (I !== 0 && Ee.current.lastDistance !== 0) {
|
|
1261
|
+
const W = Ee.current.lastDistance / I, U = F.current, Z = U.visibleTimeEnd - U.visibleTimeStart;
|
|
1262
|
+
let ce = Z * W;
|
|
1263
|
+
ce = Math.max(O, Math.min(j, ce));
|
|
1264
|
+
const $ = U.visibleTimeStart + Z * te, S = $ - ce * te, v = $ + ce * (1 - te);
|
|
1265
|
+
U.update({ visibleTimeStart: S, visibleTimeEnd: v }), (k = Qe.current) == null || k.updateBounds(S, v), C.markAllDirty(), lt(), ct("zoom");
|
|
1201
1266
|
}
|
|
1202
|
-
|
|
1267
|
+
Ee.current.lastDistance = I;
|
|
1203
1268
|
}
|
|
1204
|
-
},
|
|
1205
|
-
|
|
1269
|
+
}, g = () => {
|
|
1270
|
+
Ee.current.lastDistance = null, Ee.current.lastCenter = null;
|
|
1206
1271
|
};
|
|
1207
|
-
return r.addEventListener("touchstart", f, { passive: !1 }), r.addEventListener("touchmove",
|
|
1208
|
-
r.removeEventListener("touchstart", f), r.removeEventListener("touchmove",
|
|
1272
|
+
return r.addEventListener("touchstart", f, { passive: !1 }), r.addEventListener("touchmove", a, { passive: !1 }), r.addEventListener("touchend", g), () => {
|
|
1273
|
+
r.removeEventListener("touchstart", f), r.removeEventListener("touchmove", a), r.removeEventListener("touchend", g);
|
|
1209
1274
|
};
|
|
1210
|
-
}, [
|
|
1211
|
-
const
|
|
1275
|
+
}, [C, lt, ct]);
|
|
1276
|
+
const li = ne((r) => {
|
|
1212
1277
|
var I;
|
|
1213
|
-
const
|
|
1214
|
-
if (
|
|
1215
|
-
const
|
|
1216
|
-
if (!
|
|
1217
|
-
const
|
|
1218
|
-
|
|
1278
|
+
const s = r.currentTarget, h = s.getBoundingClientRect(), f = r.clientX - h.left, a = r.clientY - h.top;
|
|
1279
|
+
if (st.current = f, be.current) {
|
|
1280
|
+
const P = r.clientX - be.current.startX, N = r.clientY - be.current.startY;
|
|
1281
|
+
if (!Pe.current && (Math.abs(P) >= Ct || Math.abs(N) >= Ct) && (Pe.current = !0, s.style.cursor = "grabbing", s.setPointerCapture(r.pointerId)), Pe.current) {
|
|
1282
|
+
const te = r.clientX - be.current.lastX, W = r.clientY - be.current.lastY;
|
|
1283
|
+
be.current.lastX = r.clientX, be.current.lastY = r.clientY, Math.abs(te) > 0 && ze(-te), Math.abs(W) > 0 && et(-W);
|
|
1219
1284
|
}
|
|
1220
1285
|
return;
|
|
1221
1286
|
}
|
|
1222
|
-
if (
|
|
1223
|
-
if (
|
|
1224
|
-
const
|
|
1225
|
-
if (
|
|
1226
|
-
const
|
|
1227
|
-
|
|
1287
|
+
if (ee.isPending()) {
|
|
1288
|
+
if (ee.update(f, a), ee.isActive()) {
|
|
1289
|
+
const P = ee.getState();
|
|
1290
|
+
if (P && P.mode === "move" && Y.current.canChangeGroup) {
|
|
1291
|
+
const N = mt(a, F.current, Y.current.groups);
|
|
1292
|
+
N && ee.setCurrentGroup(N.id);
|
|
1228
1293
|
}
|
|
1229
|
-
|
|
1294
|
+
C.markDirty("overlay");
|
|
1230
1295
|
}
|
|
1231
1296
|
return;
|
|
1232
1297
|
}
|
|
1233
|
-
|
|
1234
|
-
const
|
|
1235
|
-
if (
|
|
1236
|
-
const
|
|
1237
|
-
|
|
1298
|
+
Y.current.showCursorLine && C.markDirty("overlay");
|
|
1299
|
+
const g = Y.current, y = $e(f, a, F.current, g.intervalTree, g.layoutEngine, g.groups), k = y == null ? void 0 : y.id;
|
|
1300
|
+
if (k !== Ae.current && (Ae.current = k, C.markDirty("items"), (I = g.onItemHover) == null || I.call(g, k ?? null, r.nativeEvent)), y) {
|
|
1301
|
+
const P = Bt(f, y, F.current), N = g.canResize;
|
|
1302
|
+
P === "left" && (N === "left" || N === "both") || P === "right" && (N === "right" || N === "both") ? s.style.cursor = "col-resize" : g.canMove ? s.style.cursor = "grab" : s.style.cursor = "default";
|
|
1238
1303
|
} else
|
|
1239
|
-
|
|
1240
|
-
}, [
|
|
1241
|
-
const
|
|
1242
|
-
if (!
|
|
1243
|
-
|
|
1304
|
+
s.style.cursor = "default";
|
|
1305
|
+
}, [ee, C, ze, et]), ai = ne((r) => {
|
|
1306
|
+
const s = Y.current, h = r.currentTarget.getBoundingClientRect(), f = r.clientX - h.left, a = r.clientY - h.top, g = $e(f, a, F.current, s.intervalTree, s.layoutEngine, s.groups);
|
|
1307
|
+
if (!g) {
|
|
1308
|
+
be.current = { startX: r.clientX, startY: r.clientY, lastX: r.clientX, lastY: r.clientY }, Pe.current = !1;
|
|
1244
1309
|
return;
|
|
1245
1310
|
}
|
|
1246
|
-
const y =
|
|
1247
|
-
y === "left" && (
|
|
1248
|
-
}, [
|
|
1249
|
-
var y,
|
|
1250
|
-
const
|
|
1251
|
-
if (
|
|
1252
|
-
const
|
|
1253
|
-
if (
|
|
1311
|
+
const y = Bt(f, g, F.current), k = s.canResize;
|
|
1312
|
+
y === "left" && (k === "left" || k === "both") ? ee.startInteraction(g, "resize-left", f, a) : y === "right" && (k === "right" || k === "both") ? ee.startInteraction(g, "resize-right", f, a) : s.canMove && ee.startInteraction(g, "move", f, a);
|
|
1313
|
+
}, [ee]), ui = ne((r) => {
|
|
1314
|
+
var y, k, I, P, N, te;
|
|
1315
|
+
const s = r.currentTarget;
|
|
1316
|
+
if (be.current) {
|
|
1317
|
+
const W = Pe.current;
|
|
1318
|
+
if (be.current = null, Pe.current = !1, s.style.cursor = "default", W)
|
|
1254
1319
|
return;
|
|
1255
1320
|
}
|
|
1256
|
-
if (
|
|
1257
|
-
const
|
|
1258
|
-
if (
|
|
1259
|
-
const
|
|
1260
|
-
if (
|
|
1261
|
-
const
|
|
1262
|
-
if (
|
|
1263
|
-
const
|
|
1264
|
-
let
|
|
1265
|
-
const
|
|
1266
|
-
if (
|
|
1267
|
-
|
|
1321
|
+
if (ee.isActive()) {
|
|
1322
|
+
const W = ee.getState(), U = F.current, Z = U.canvasWidth / (U.visibleTimeEnd - U.visibleTimeStart);
|
|
1323
|
+
if (W) {
|
|
1324
|
+
const ce = Y.current.moveResizeValidator;
|
|
1325
|
+
if (W.mode === "move") {
|
|
1326
|
+
const $ = ee.endMove(Z);
|
|
1327
|
+
if ($) {
|
|
1328
|
+
const S = F.current, v = Y.current, ge = W.deltaX / Z, L = S.timeToX(W.item.start_time + ge), fe = S.timeToX(W.item.end_time + ge), ae = (S.visibleTimeEnd - S.visibleTimeStart) * 0.1, D = v.intervalTree.query(S.visibleTimeStart - ae, S.visibleTimeEnd + ae), ie = vt(D, W.item.id, (de) => S.timeToX(de));
|
|
1329
|
+
let V = $.newStartTime;
|
|
1330
|
+
const A = it(L, ie, 8, Z, v.dragSnap);
|
|
1331
|
+
if (A !== null)
|
|
1332
|
+
V = S.xToTime(A);
|
|
1268
1333
|
else {
|
|
1269
|
-
const
|
|
1270
|
-
if (
|
|
1271
|
-
const
|
|
1272
|
-
|
|
1334
|
+
const de = it(fe, ie, 8, Z, v.dragSnap);
|
|
1335
|
+
if (de !== null) {
|
|
1336
|
+
const pe = W.item.end_time - W.item.start_time;
|
|
1337
|
+
V = S.xToTime(de) - pe;
|
|
1273
1338
|
}
|
|
1274
1339
|
}
|
|
1275
|
-
const
|
|
1276
|
-
(
|
|
1340
|
+
const K = ce ? ce("move", W.item.id, V) : V, le = Y.current.hierarchyEngine.getMoveDelta(W.item.id, K);
|
|
1341
|
+
(k = (y = Y.current).onItemMove) == null || k.call(y, W.item.id, K, $.newGroupId, le.length > 0 ? le : void 0);
|
|
1277
1342
|
}
|
|
1278
1343
|
} else {
|
|
1279
|
-
const
|
|
1280
|
-
if (
|
|
1281
|
-
const
|
|
1282
|
-
let
|
|
1283
|
-
const
|
|
1284
|
-
|
|
1285
|
-
const
|
|
1286
|
-
(
|
|
1344
|
+
const $ = ee.endResize(Z);
|
|
1345
|
+
if ($) {
|
|
1346
|
+
const S = F.current, v = Y.current, ge = W.deltaX / Z, L = $.edge === "left" ? W.item.start_time + ge : W.item.end_time + ge, fe = S.timeToX(L), ae = (S.visibleTimeEnd - S.visibleTimeStart) * 0.1, D = v.intervalTree.query(S.visibleTimeStart - ae, S.visibleTimeEnd + ae), ie = vt(D, W.item.id, (de) => S.timeToX(de)), V = it(fe, ie, 8, Z, v.dragSnap);
|
|
1347
|
+
let A = V !== null ? S.xToTime(V) : $.newTime;
|
|
1348
|
+
const K = Y.current.hierarchyEngine.getResizeConstraint(W.item.id, $.edge);
|
|
1349
|
+
$.edge === "left" && A > K.max ? A = K.max : $.edge === "right" && A < K.min && (A = K.min);
|
|
1350
|
+
const le = ce ? ce("resize", W.item.id, A, $.edge) : A;
|
|
1351
|
+
(P = (I = Y.current).onItemResize) == null || P.call(I, W.item.id, le, $.edge);
|
|
1287
1352
|
}
|
|
1288
1353
|
}
|
|
1289
1354
|
}
|
|
1290
|
-
|
|
1355
|
+
s.style.cursor = "default", C.markDirty("overlay");
|
|
1291
1356
|
return;
|
|
1292
1357
|
}
|
|
1293
|
-
|
|
1294
|
-
const h =
|
|
1295
|
-
|
|
1296
|
-
}, [
|
|
1297
|
-
var y,
|
|
1298
|
-
const
|
|
1299
|
-
if (
|
|
1300
|
-
(y =
|
|
1358
|
+
ee.isPending() && ee.cancel();
|
|
1359
|
+
const h = s.getBoundingClientRect(), f = r.clientX - h.left, a = r.clientY - h.top, g = $e(f, a, F.current, Y.current.intervalTree, Y.current.layoutEngine, Y.current.groups);
|
|
1360
|
+
g && ((te = (N = Y.current).onItemClick) == null || te.call(N, g.id, r.nativeEvent));
|
|
1361
|
+
}, [ee, C]), ci = ne((r) => {
|
|
1362
|
+
var y, k;
|
|
1363
|
+
const s = r.currentTarget.getBoundingClientRect(), h = r.clientX - s.left, f = r.clientY - s.top, a = Y.current, g = $e(h, f, F.current, a.intervalTree, a.layoutEngine, a.groups);
|
|
1364
|
+
if (g)
|
|
1365
|
+
(y = a.onItemDoubleClick) == null || y.call(a, g.id, r.nativeEvent);
|
|
1301
1366
|
else {
|
|
1302
|
-
const I =
|
|
1303
|
-
I && ((
|
|
1367
|
+
const I = mt(f, F.current, a.groups), P = F.current.xToTime(h);
|
|
1368
|
+
I && ((k = a.onCanvasDoubleClick) == null || k.call(a, I.id, P));
|
|
1304
1369
|
}
|
|
1305
|
-
}, []),
|
|
1306
|
-
var y,
|
|
1370
|
+
}, []), di = ne((r) => {
|
|
1371
|
+
var y, k;
|
|
1307
1372
|
r.preventDefault();
|
|
1308
|
-
const
|
|
1309
|
-
if (
|
|
1310
|
-
(y =
|
|
1373
|
+
const s = r.currentTarget.getBoundingClientRect(), h = r.clientX - s.left, f = r.clientY - s.top, a = Y.current, g = $e(h, f, F.current, a.intervalTree, a.layoutEngine, a.groups);
|
|
1374
|
+
if (g)
|
|
1375
|
+
(y = a.onItemContextMenu) == null || y.call(a, g.id, r.nativeEvent);
|
|
1311
1376
|
else {
|
|
1312
|
-
const I =
|
|
1313
|
-
I && ((
|
|
1377
|
+
const I = mt(f, F.current, a.groups), P = F.current.xToTime(h);
|
|
1378
|
+
I && ((k = a.onCanvasContextMenu) == null || k.call(a, I.id, P, r.nativeEvent));
|
|
1314
1379
|
}
|
|
1315
|
-
}, []),
|
|
1316
|
-
var r,
|
|
1317
|
-
|
|
1318
|
-
}, [
|
|
1380
|
+
}, []), hi = ne(() => {
|
|
1381
|
+
var r, s;
|
|
1382
|
+
be.current = null, Pe.current = !1, st.current = null, Ye.current && (Ye.current.style.cursor = "default"), Ae.current !== void 0 && (Ae.current = void 0, C.markDirty("items"), (s = (r = Y.current).onItemHover) == null || s.call(r, null, new PointerEvent("pointerleave"))), Y.current.showCursorLine && C.markDirty("overlay");
|
|
1383
|
+
}, [C]), fi = Q(() => {
|
|
1319
1384
|
const r = [];
|
|
1320
|
-
return
|
|
1385
|
+
return me.Children.forEach(ke, (s) => {
|
|
1321
1386
|
var f;
|
|
1322
|
-
if (!
|
|
1387
|
+
if (!me.isValidElement(s))
|
|
1323
1388
|
return;
|
|
1324
|
-
if (((f =
|
|
1325
|
-
const
|
|
1326
|
-
r.push(
|
|
1327
|
-
visibleTimeStart:
|
|
1328
|
-
visibleTimeEnd:
|
|
1329
|
-
canvasWidth:
|
|
1330
|
-
sidebarWidth:
|
|
1331
|
-
theme:
|
|
1332
|
-
onZoomToInterval:
|
|
1333
|
-
var
|
|
1334
|
-
|
|
1389
|
+
if (((f = s.type) == null ? void 0 : f.displayName) === "TimelineHeaders") {
|
|
1390
|
+
const a = s.props;
|
|
1391
|
+
r.push(me.cloneElement(s, {
|
|
1392
|
+
visibleTimeStart: a.visibleTimeStart ?? Ht,
|
|
1393
|
+
visibleTimeEnd: a.visibleTimeEnd ?? It,
|
|
1394
|
+
canvasWidth: a.canvasWidth ?? we,
|
|
1395
|
+
sidebarWidth: a.sidebarWidth ?? c,
|
|
1396
|
+
theme: a.theme ?? Se,
|
|
1397
|
+
onZoomToInterval: a.onZoomToInterval ?? ((g, y) => {
|
|
1398
|
+
var k, I, P, N;
|
|
1399
|
+
F.current.update({ visibleTimeStart: g, visibleTimeEnd: y }), C.markAllDirty(), _e(), (I = (k = Y.current).onTimeChange) == null || I.call(k, g, y), (N = (P = Y.current).onZoom) == null || N.call(P, g, y);
|
|
1335
1400
|
})
|
|
1336
1401
|
}));
|
|
1337
1402
|
}
|
|
1338
1403
|
}), r;
|
|
1339
|
-
}, [
|
|
1404
|
+
}, [ke, Ht, It, we, c, Se, C, _e]), Wt = x(!1);
|
|
1340
1405
|
he(() => {
|
|
1341
|
-
|
|
1342
|
-
}, [
|
|
1343
|
-
captureToCanvas({ timeStart: r, timeEnd:
|
|
1344
|
-
const
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1406
|
+
Wt.current || (Wt.current = !0, C.markAllDirty());
|
|
1407
|
+
}, [C]), vi(t, () => ({
|
|
1408
|
+
captureToCanvas({ timeStart: r, timeEnd: s, scale: h, sidebarWidth: f }) {
|
|
1409
|
+
const a = Y.current, g = 28, y = g * 3, k = a.groups.map((L) => a.layoutEngine.getGroupHeight(L.id)), I = [0];
|
|
1410
|
+
for (let L = 0; L < k.length; L++)
|
|
1411
|
+
I.push(I[L] + k[L]);
|
|
1412
|
+
const P = I[k.length], N = F.current, te = a.canvasWidth / (N.visibleTimeEnd - N.visibleTimeStart), W = s - r, U = Math.max(a.canvasWidth, Math.round(W * te)), Z = (f + U) * h, ce = (y + P) * h, $ = document.createElement("canvas");
|
|
1413
|
+
$.width = Z, $.height = ce;
|
|
1414
|
+
const S = $.getContext("2d");
|
|
1415
|
+
S.scale(h, h);
|
|
1416
|
+
for (let L = 0; L < a.groups.length; L++) {
|
|
1417
|
+
const fe = a.groups[L], ae = k[L], D = y + I[L];
|
|
1418
|
+
if (a.rowStyle) {
|
|
1419
|
+
const K = a.rowStyle(fe);
|
|
1420
|
+
K != null && K.backgroundColor && (S.fillStyle = K.backgroundColor, S.fillRect(0, D, f, ae));
|
|
1353
1421
|
}
|
|
1354
|
-
const
|
|
1355
|
-
let
|
|
1356
|
-
|
|
1422
|
+
const ie = fe.type;
|
|
1423
|
+
let V = "400", A = 8;
|
|
1424
|
+
ie === "project" ? V = "700" : ie === "CAG" ? V = "600" : ie === "CA" && (V = "400", A = 24), S.fillStyle = "#111", S.font = `${V} 12px sans-serif`, S.textBaseline = "middle", S.fillText(fe.title, A, D + ae / 2, f - A - 4);
|
|
1357
1425
|
}
|
|
1358
|
-
const
|
|
1359
|
-
var
|
|
1360
|
-
|
|
1361
|
-
let
|
|
1362
|
-
|
|
1363
|
-
const
|
|
1364
|
-
for (;
|
|
1365
|
-
const
|
|
1366
|
-
|
|
1426
|
+
const v = (L, fe, ae) => {
|
|
1427
|
+
var V, A;
|
|
1428
|
+
S.fillStyle = ((V = a.theme.header) == null ? void 0 : V.bg) ?? "#f5f5f5", S.fillRect(f, L, U, g), S.strokeStyle = ((A = a.theme.grid) == null ? void 0 : A.line) ?? "#e0e0e0", S.lineWidth = 1, S.strokeRect(f, L, U, g);
|
|
1429
|
+
let D = ve(r).startOf(ae);
|
|
1430
|
+
D.valueOf() < r && (D = D.add(1, ae));
|
|
1431
|
+
const ie = U / (s - r);
|
|
1432
|
+
for (; D.valueOf() < s; ) {
|
|
1433
|
+
const K = D.add(1, ae), le = f + (D.valueOf() - r) * ie, pe = f + (Math.min(K.valueOf(), s) - r) * ie - le;
|
|
1434
|
+
S.beginPath(), S.moveTo(le, L), S.lineTo(le, L + g), S.stroke(), S.fillStyle = "#333", S.font = "600 11px sans-serif", S.textBaseline = "middle", S.textAlign = "center", S.fillText(fe(D), le + pe / 2, L + g / 2, pe - 4), D = K;
|
|
1367
1435
|
}
|
|
1368
|
-
|
|
1436
|
+
S.textAlign = "start";
|
|
1369
1437
|
};
|
|
1370
|
-
|
|
1371
|
-
const
|
|
1438
|
+
v(0, (L) => L.format("YYYY"), "year"), v(g, (L) => L.format("MM"), "month"), v(g * 2, (L) => String(L.isoWeek()), "week");
|
|
1439
|
+
const ge = new ft({
|
|
1372
1440
|
visibleTimeStart: r,
|
|
1373
|
-
visibleTimeEnd:
|
|
1374
|
-
canvasWidth:
|
|
1375
|
-
canvasHeight:
|
|
1441
|
+
visibleTimeEnd: s,
|
|
1442
|
+
canvasWidth: U,
|
|
1443
|
+
canvasHeight: P,
|
|
1376
1444
|
sidebarWidth: 0,
|
|
1377
|
-
lineHeight:
|
|
1378
|
-
groupCount:
|
|
1445
|
+
lineHeight: a.lineHeight,
|
|
1446
|
+
groupCount: a.groups.length,
|
|
1379
1447
|
buffer: 1,
|
|
1380
|
-
scrollTop: 0
|
|
1448
|
+
scrollTop: 0,
|
|
1449
|
+
groupHeights: k
|
|
1381
1450
|
});
|
|
1382
|
-
return
|
|
1451
|
+
return S.save(), S.translate(f, y), S.beginPath(), S.rect(0, 0, U, P), S.clip(), Fe.draw(S, ge, a.groups, a.theme, a.dayStyle, a.rowStyle, a.highlights), We.draw(S, ge, a.groups, a.items, a.intervalTree, a.layoutEngine, a.itemRenderer, a.groupRenderer, a.theme, a.selected, void 0, a.dependencies, a.summaryRenderer, a.hierarchyEngine), Be.draw(S, ge, a.theme, {
|
|
1383
1452
|
cursorX: null,
|
|
1384
1453
|
snapX: null,
|
|
1385
|
-
markers:
|
|
1454
|
+
markers: Ge.current,
|
|
1386
1455
|
interaction: null
|
|
1387
|
-
}),
|
|
1456
|
+
}), S.restore(), $;
|
|
1388
1457
|
}
|
|
1389
|
-
}), [
|
|
1458
|
+
}), [Fe, We, Be]), he(() => {
|
|
1390
1459
|
const r = {
|
|
1391
|
-
captureToCanvas({ timeStart:
|
|
1392
|
-
var
|
|
1393
|
-
const
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
const
|
|
1404
|
-
|
|
1460
|
+
captureToCanvas({ timeStart: s, timeEnd: h, scale: f, sidebarWidth: a }) {
|
|
1461
|
+
var ae;
|
|
1462
|
+
const g = Y.current, y = 28, k = y * 3, I = g.groups.map((D) => g.layoutEngine.getGroupHeight(D.id)), P = [0];
|
|
1463
|
+
for (let D = 0; D < I.length; D++)
|
|
1464
|
+
P.push(P[D] + I[D]);
|
|
1465
|
+
const N = P[I.length], te = F.current, W = g.canvasWidth / (te.visibleTimeEnd - te.visibleTimeStart), U = h - s, Z = Math.max(g.canvasWidth, Math.round(U * W)), ce = a + Z, $ = k + N, S = document.createElement("canvas");
|
|
1466
|
+
S.width = ce * f, S.height = $ * f;
|
|
1467
|
+
const v = S.getContext("2d");
|
|
1468
|
+
v.scale(f, f), v.fillStyle = "#FFFFFF", v.fillRect(0, 0, ce, $), v.save(), v.beginPath(), v.rect(0, 0, a, $), v.clip(), v.fillStyle = "#F9FAFB", v.fillRect(0, 0, a, k), v.strokeStyle = "#E5E7EB", v.lineWidth = 1, v.strokeRect(0, 0, a, k);
|
|
1469
|
+
for (let D = 0; D < g.groups.length; D++) {
|
|
1470
|
+
const ie = g.groups[D], V = I[D], A = k + P[D], K = (ae = g.rowStyle) == null ? void 0 : ae.call(g, ie);
|
|
1471
|
+
v.fillStyle = (K == null ? void 0 : K.backgroundColor) ?? (D % 2 === 0 ? "#FFFFFF" : "#F7F7F7"), v.fillRect(0, A, a, V), v.strokeStyle = "#E5E5E5", v.lineWidth = 0.5, v.beginPath(), v.moveTo(0, A + V), v.lineTo(a, A + V), v.stroke();
|
|
1472
|
+
const le = ie.type ?? "";
|
|
1473
|
+
let de = 8, pe = "400", De = 11;
|
|
1474
|
+
le === "project" ? (pe = "700", De = 12) : le === "control_area_group" ? pe = "600" : le === "control_area" && (de = 24), v.fillStyle = "#374151", v.font = `${pe} ${De}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`, v.textBaseline = "middle";
|
|
1475
|
+
const gi = typeof ie.title == "string" ? ie.title : String(ie.title);
|
|
1476
|
+
v.fillText(gi, de, A + V / 2, a - de - 8);
|
|
1405
1477
|
}
|
|
1406
|
-
|
|
1407
|
-
const
|
|
1478
|
+
v.strokeStyle = "#E5E7EB", v.lineWidth = 1, v.beginPath(), v.moveTo(a, 0), v.lineTo(a, $), v.stroke(), v.restore(), v.save(), v.beginPath(), v.rect(a, 0, Z, k), v.clip();
|
|
1479
|
+
const ge = h - s, L = [
|
|
1408
1480
|
{ unit: "year", row: 0 },
|
|
1409
1481
|
{ unit: "month", row: 1 },
|
|
1410
1482
|
{ unit: "week", row: 2 }
|
|
1411
1483
|
];
|
|
1412
|
-
for (const { unit:
|
|
1413
|
-
const
|
|
1414
|
-
|
|
1415
|
-
let
|
|
1416
|
-
const
|
|
1417
|
-
for (;
|
|
1418
|
-
const
|
|
1419
|
-
|
|
1420
|
-
let
|
|
1421
|
-
|
|
1484
|
+
for (const { unit: D, row: ie } of L) {
|
|
1485
|
+
const V = ie * y;
|
|
1486
|
+
v.fillStyle = "#F9FAFB", v.fillRect(a, V, Z, y);
|
|
1487
|
+
let A = ve(s).startOf(D);
|
|
1488
|
+
const K = ve(h).add(1, D);
|
|
1489
|
+
for (; A.isBefore(K); ) {
|
|
1490
|
+
const le = A.add(1, D), de = a + (A.valueOf() - s) / ge * Z, pe = (le.valueOf() - A.valueOf()) / ge * Z;
|
|
1491
|
+
v.strokeStyle = "#E5E7EB", v.lineWidth = 0.5, v.strokeRect(de, V, pe, y);
|
|
1492
|
+
let De;
|
|
1493
|
+
D === "year" ? De = A.format("YYYY") : D === "month" ? De = A.format("MM") : De = `${A.week()}`, v.fillStyle = "#6c737f", v.font = D === "year" ? '600 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif' : '400 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif', v.textBaseline = "middle", v.textAlign = "center", pe > 20 && v.fillText(De, de + pe / 2, V + y / 2), A = le;
|
|
1422
1494
|
}
|
|
1423
1495
|
}
|
|
1424
|
-
|
|
1425
|
-
const
|
|
1426
|
-
visibleTimeStart:
|
|
1496
|
+
v.textAlign = "start", v.restore(), v.save(), v.beginPath(), v.rect(a, k, Z, N), v.clip(), v.translate(a, k);
|
|
1497
|
+
const fe = new ft({
|
|
1498
|
+
visibleTimeStart: s,
|
|
1427
1499
|
visibleTimeEnd: h,
|
|
1428
|
-
canvasWidth:
|
|
1429
|
-
canvasHeight:
|
|
1500
|
+
canvasWidth: Z,
|
|
1501
|
+
canvasHeight: N,
|
|
1430
1502
|
sidebarWidth: 0,
|
|
1431
|
-
lineHeight:
|
|
1432
|
-
groupCount:
|
|
1503
|
+
lineHeight: g.lineHeight,
|
|
1504
|
+
groupCount: g.groups.length,
|
|
1433
1505
|
buffer: 1,
|
|
1434
|
-
scrollTop: 0
|
|
1506
|
+
scrollTop: 0,
|
|
1507
|
+
groupHeights: I
|
|
1435
1508
|
});
|
|
1436
|
-
return
|
|
1509
|
+
return Fe.draw(v, fe, g.groups, g.theme, g.dayStyle, g.rowStyle, g.highlights), We.draw(v, fe, g.groups, g.items, g.intervalTree, g.layoutEngine, g.itemRenderer, g.groupRenderer, g.theme, g.selected, void 0, g.dependencies, g.summaryRenderer, g.hierarchyEngine), Be.draw(v, fe, g.theme, { cursorX: null, markers: Ge.current }), v.restore(), S;
|
|
1437
1510
|
}
|
|
1438
1511
|
};
|
|
1439
|
-
|
|
1440
|
-
}, [
|
|
1441
|
-
const
|
|
1512
|
+
Ze == null || Ze(r);
|
|
1513
|
+
}, [Ze, Fe, We, Be]);
|
|
1514
|
+
const mi = {
|
|
1442
1515
|
position: "relative",
|
|
1443
|
-
width:
|
|
1444
|
-
height:
|
|
1516
|
+
width: we,
|
|
1517
|
+
height: Me,
|
|
1445
1518
|
overflow: "hidden",
|
|
1446
1519
|
cursor: "default"
|
|
1447
|
-
},
|
|
1448
|
-
return
|
|
1520
|
+
}, ht = { position: "absolute", top: 0, left: 0 };
|
|
1521
|
+
return xe("div", { ref: Et, style: { display: "flex", flexDirection: "column", width: "100%", position: "relative" }, children: [Kt ? xe("div", { style: {
|
|
1449
1522
|
position: "absolute",
|
|
1450
1523
|
top: 0,
|
|
1451
1524
|
left: 0,
|
|
@@ -1459,28 +1532,28 @@ const jt = 32, Vi = ge.memo(fi(function(e, t) {
|
|
|
1459
1532
|
borderBottomRightRadius: 4,
|
|
1460
1533
|
pointerEvents: "none",
|
|
1461
1534
|
userSelect: "none"
|
|
1462
|
-
}, children: ["v", "0.
|
|
1463
|
-
|
|
1464
|
-
} }),
|
|
1465
|
-
|
|
1535
|
+
}, children: ["v", "0.5.0", " · ", "15:09:31"] }) : null, fi, xe("div", { ref: Qt, style: { display: "flex", overflow: "hidden" }, children: [se(jt, { groups: n, width: c, lineHeight: u, groupHeights: Re, scrollTop: Rt, canvasHeight: Me, theme: Se, groupRenderer: B, onScroll: (r) => {
|
|
1536
|
+
F.current.update({ scrollTop: r }), C.markDirty("grid"), C.markDirty("items"), C.markDirty("overlay"), qe(r);
|
|
1537
|
+
} }), xe("div", { ref: Ye, style: mi, onPointerMove: li, onPointerDown: ai, onPointerUp: ui, onDoubleClick: ci, onContextMenu: di, onPointerLeave: hi, children: [se("canvas", { ref: kt, style: { ...ht, zIndex: 0 } }), se("canvas", { ref: wt, style: { ...ht, zIndex: 1 } }), se("canvas", { ref: Mt, style: { ...ht, zIndex: 2 } })] }), nt && Tt ? se(jt, { groups: n, width: nt, lineHeight: u, groupHeights: Re, scrollTop: Rt, canvasHeight: Me, theme: Se, groupRenderer: Tt, onScroll: (r) => {
|
|
1538
|
+
F.current.update({ scrollTop: r }), C.markDirty("grid"), C.markDirty("items"), C.markDirty("overlay"), qe(r);
|
|
1466
1539
|
} }) : null] })] });
|
|
1467
1540
|
}));
|
|
1468
|
-
function
|
|
1469
|
-
const
|
|
1541
|
+
function Bi({ children: i, theme: e, className: t, classNames: n, style: o, visibleTimeStart: d, visibleTimeEnd: l, canvasWidth: c, sidebarWidth: u = 0, onZoomToInterval: p }) {
|
|
1542
|
+
const M = me.Children.map(i, (m) => {
|
|
1470
1543
|
var T;
|
|
1471
|
-
if (!
|
|
1472
|
-
return
|
|
1473
|
-
if (((T =
|
|
1474
|
-
const
|
|
1475
|
-
visibleTimeStart:
|
|
1476
|
-
visibleTimeEnd:
|
|
1477
|
-
canvasWidth:
|
|
1478
|
-
theme:
|
|
1479
|
-
onZoomToInterval:
|
|
1544
|
+
if (!me.isValidElement(m))
|
|
1545
|
+
return m;
|
|
1546
|
+
if (((T = m.type) == null ? void 0 : T.displayName) === "DateHeader") {
|
|
1547
|
+
const H = m.props, O = me.cloneElement(m, {
|
|
1548
|
+
visibleTimeStart: H.visibleTimeStart ?? d,
|
|
1549
|
+
visibleTimeEnd: H.visibleTimeEnd ?? l,
|
|
1550
|
+
canvasWidth: H.canvasWidth ?? c,
|
|
1551
|
+
theme: H.theme ?? e,
|
|
1552
|
+
onZoomToInterval: H.onIntervalClick ?? H.onZoomToInterval ?? p
|
|
1480
1553
|
});
|
|
1481
|
-
return
|
|
1554
|
+
return xe("div", { style: { display: "flex" }, children: [se("div", { style: { width: u, flexShrink: 0 } }), se("div", { style: { flex: 1, overflow: "hidden" }, children: O })] });
|
|
1482
1555
|
}
|
|
1483
|
-
return
|
|
1556
|
+
return m;
|
|
1484
1557
|
});
|
|
1485
1558
|
return se("div", { className: t, style: {
|
|
1486
1559
|
position: "sticky",
|
|
@@ -1491,65 +1564,65 @@ function Fi({ children: i, theme: e, className: t, classNames: n, style: s, visi
|
|
|
1491
1564
|
backgroundColor: (e == null ? void 0 : e.header.bg) ?? "#F9FAFB",
|
|
1492
1565
|
borderTop: `1px solid ${(e == null ? void 0 : e.header.border) ?? "#E5E7EB"}`,
|
|
1493
1566
|
borderBottom: `1px solid ${(e == null ? void 0 : e.header.border) ?? "#E5E7EB"}`,
|
|
1494
|
-
...
|
|
1495
|
-
}, children:
|
|
1567
|
+
...o
|
|
1568
|
+
}, children: M });
|
|
1496
1569
|
}
|
|
1497
|
-
|
|
1498
|
-
var
|
|
1570
|
+
Bi.displayName = "TimelineHeaders";
|
|
1571
|
+
var Ut = { exports: {} };
|
|
1499
1572
|
(function(i, e) {
|
|
1500
1573
|
(function(t, n) {
|
|
1501
1574
|
i.exports = n();
|
|
1502
|
-
})(
|
|
1575
|
+
})(Vt, function() {
|
|
1503
1576
|
var t = "week", n = "year";
|
|
1504
|
-
return function(
|
|
1505
|
-
var
|
|
1506
|
-
|
|
1507
|
-
if (
|
|
1508
|
-
var
|
|
1577
|
+
return function(o, d, l) {
|
|
1578
|
+
var c = d.prototype;
|
|
1579
|
+
c.week = function(u) {
|
|
1580
|
+
if (u === void 0 && (u = null), u !== null) return this.add(7 * (u - this.week()), "day");
|
|
1581
|
+
var p = this.$locale().yearStart || 1;
|
|
1509
1582
|
if (this.month() === 11 && this.date() > 25) {
|
|
1510
|
-
var
|
|
1511
|
-
if (
|
|
1583
|
+
var M = l(this).startOf(n).add(1, n).date(p), m = l(this).endOf(t);
|
|
1584
|
+
if (M.isBefore(m)) return 1;
|
|
1512
1585
|
}
|
|
1513
|
-
var b =
|
|
1514
|
-
return T < 0 ?
|
|
1515
|
-
},
|
|
1516
|
-
return
|
|
1586
|
+
var b = l(this).startOf(n).date(p).startOf(t).subtract(1, "millisecond"), T = this.diff(b, t, !0);
|
|
1587
|
+
return T < 0 ? l(this).startOf("week").week() : Math.ceil(T);
|
|
1588
|
+
}, c.weeks = function(u) {
|
|
1589
|
+
return u === void 0 && (u = null), this.week(u);
|
|
1517
1590
|
};
|
|
1518
1591
|
};
|
|
1519
1592
|
});
|
|
1520
|
-
})(
|
|
1521
|
-
var
|
|
1522
|
-
const
|
|
1523
|
-
|
|
1524
|
-
const
|
|
1593
|
+
})(Ut);
|
|
1594
|
+
var Yi = Ut.exports;
|
|
1595
|
+
const Li = /* @__PURE__ */ Zt(Yi);
|
|
1596
|
+
ve.extend(Li);
|
|
1597
|
+
const Ai = {
|
|
1525
1598
|
year: 30,
|
|
1526
1599
|
month: 30,
|
|
1527
1600
|
week: 20,
|
|
1528
1601
|
day: 15,
|
|
1529
1602
|
hour: 30
|
|
1530
1603
|
};
|
|
1531
|
-
function
|
|
1532
|
-
const
|
|
1604
|
+
function ji({ unit: i, visibleTimeStart: e = 0, visibleTimeEnd: t = 0, canvasWidth: n = 0, theme: o, height: d = 28, className: l, labelFormat: c, onIntervalClick: u, minCellWidth: p, onZoomToInterval: M }) {
|
|
1605
|
+
const m = Q(() => {
|
|
1533
1606
|
if (!e || !t || !n)
|
|
1534
1607
|
return [];
|
|
1535
|
-
const T = t - e,
|
|
1536
|
-
if (
|
|
1537
|
-
const
|
|
1538
|
-
if ((
|
|
1608
|
+
const T = t - e, H = p ?? Ai[i];
|
|
1609
|
+
if (H > 0) {
|
|
1610
|
+
const w = ve(e).startOf(i);
|
|
1611
|
+
if ((w.add(1, i).valueOf() - w.valueOf()) / T * n < H)
|
|
1539
1612
|
return [];
|
|
1540
1613
|
}
|
|
1541
|
-
const
|
|
1542
|
-
let
|
|
1543
|
-
const
|
|
1544
|
-
for (;
|
|
1545
|
-
const
|
|
1546
|
-
|
|
1614
|
+
const O = [];
|
|
1615
|
+
let j = ve(e).startOf(i).subtract(1, i);
|
|
1616
|
+
const re = ve(t).add(2, i).valueOf();
|
|
1617
|
+
for (; j.valueOf() < re; ) {
|
|
1618
|
+
const w = j.add(1, i), X = j.valueOf(), E = w.valueOf(), R = (X - e) / T * n, z = (E - X) / T * n, B = Gi(j, w, i, c);
|
|
1619
|
+
O.push({ start: X, end: E, label: B, left: R, width: z }), j = w;
|
|
1547
1620
|
}
|
|
1548
|
-
return
|
|
1549
|
-
}, [e, t, n, i,
|
|
1550
|
-
|
|
1551
|
-
}, [
|
|
1552
|
-
return
|
|
1621
|
+
return O;
|
|
1622
|
+
}, [e, t, n, i, c, p]), b = ne((T, H) => {
|
|
1623
|
+
u ? u(T, H) : M && M(T, H);
|
|
1624
|
+
}, [u, M]);
|
|
1625
|
+
return m.length === 0 ? null : se("div", { style: { display: "flex", position: "relative", height: d, overflow: "hidden" }, children: m.map((T) => se("div", { className: l, onClick: () => b(T.start, T.end), style: {
|
|
1553
1626
|
position: "absolute",
|
|
1554
1627
|
left: T.left,
|
|
1555
1628
|
width: T.width,
|
|
@@ -1557,11 +1630,11 @@ function Li({ unit: i, visibleTimeStart: e = 0, visibleTimeEnd: t = 0, canvasWid
|
|
|
1557
1630
|
display: "flex",
|
|
1558
1631
|
alignItems: "center",
|
|
1559
1632
|
justifyContent: "center",
|
|
1560
|
-
borderRight: `1px solid ${(
|
|
1561
|
-
borderBottom: `1px solid ${(
|
|
1633
|
+
borderRight: `1px solid ${(o == null ? void 0 : o.header.border) ?? "#E5E7EB"}`,
|
|
1634
|
+
borderBottom: `1px solid ${(o == null ? void 0 : o.header.border) ?? "#E5E7EB"}`,
|
|
1562
1635
|
fontSize: 12,
|
|
1563
|
-
color: (
|
|
1564
|
-
backgroundColor: (
|
|
1636
|
+
color: (o == null ? void 0 : o.header.text) ?? "#6c737f",
|
|
1637
|
+
backgroundColor: (o == null ? void 0 : o.header.bg) ?? "#F9FAFB",
|
|
1565
1638
|
overflow: "hidden",
|
|
1566
1639
|
whiteSpace: "nowrap",
|
|
1567
1640
|
cursor: "pointer",
|
|
@@ -1570,11 +1643,11 @@ function Li({ unit: i, visibleTimeStart: e = 0, visibleTimeEnd: t = 0, canvasWid
|
|
|
1570
1643
|
boxSizing: "border-box"
|
|
1571
1644
|
}, children: se("span", { children: T.label }) }, T.start)) });
|
|
1572
1645
|
}
|
|
1573
|
-
|
|
1574
|
-
function
|
|
1575
|
-
return typeof n == "function" ? n(i.toDate(), e.toDate(), t) : typeof n == "string" ? i.format(n) :
|
|
1646
|
+
ji.displayName = "DateHeader";
|
|
1647
|
+
function Gi(i, e, t, n, o) {
|
|
1648
|
+
return typeof n == "function" ? n(i.toDate(), e.toDate(), t) : typeof n == "string" ? i.format(n) : Ni(i, t);
|
|
1576
1649
|
}
|
|
1577
|
-
function
|
|
1650
|
+
function Ni(i, e) {
|
|
1578
1651
|
switch (e) {
|
|
1579
1652
|
case "year":
|
|
1580
1653
|
return i.format("YYYY");
|
|
@@ -1588,24 +1661,24 @@ function Ai(i, e) {
|
|
|
1588
1661
|
return i.format("HH:mm");
|
|
1589
1662
|
}
|
|
1590
1663
|
}
|
|
1591
|
-
function
|
|
1664
|
+
function zi({ width: i, children: e, style: t }) {
|
|
1592
1665
|
const n = () => ({ style: { width: i, ...t } });
|
|
1593
|
-
return e ? se(
|
|
1666
|
+
return e ? se($t, { children: e({ getRootProps: n }) }) : se("div", { style: { width: i } });
|
|
1594
1667
|
}
|
|
1595
|
-
|
|
1596
|
-
function
|
|
1597
|
-
return se(
|
|
1668
|
+
zi.displayName = "SidebarHeader";
|
|
1669
|
+
function $i({ children: i }) {
|
|
1670
|
+
return se($t, { children: i });
|
|
1598
1671
|
}
|
|
1599
|
-
|
|
1672
|
+
$i.displayName = "CustomHeader";
|
|
1600
1673
|
export {
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1674
|
+
Ui as CanvasTimeline,
|
|
1675
|
+
$i as CustomHeader,
|
|
1676
|
+
Fi as CustomMarker,
|
|
1677
|
+
Ce as DEFAULT_THEME,
|
|
1678
|
+
ji as DateHeader,
|
|
1679
|
+
Si as HierarchyEngine,
|
|
1680
|
+
zi as SidebarHeader,
|
|
1681
|
+
Bi as TimelineHeaders,
|
|
1682
|
+
Xi as TodayMarker
|
|
1610
1683
|
};
|
|
1611
1684
|
//# sourceMappingURL=canvas-timeline.es.js.map
|