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