@affino/datagrid-vue-app 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/dist/DataGrid.d.ts +4 -4
  2. package/dist/advanced-filter.d.ts +2 -0
  3. package/dist/advanced-filter.js +4 -0
  4. package/dist/chunks/DataGridAdvancedFilterPopover-Bak_CkaO.js +4 -0
  5. package/dist/chunks/DataGridAdvancedFilterPopover.vue_vue_type_script_setup_true_lang-DixN56Qv.js +226 -0
  6. package/dist/chunks/DataGridAggregationsPopover-DfQ3-UV4.js +173 -0
  7. package/dist/chunks/DataGridColumnLayoutPopover-Qt56b3CA.js +136 -0
  8. package/dist/chunks/DataGridFilterableCombobox.vue_vue_type_script_setup_true_lang-_1TDQseN.js +399 -0
  9. package/dist/chunks/DataGridGanttStage.vue_vue_type_script_setup_true_lang-CYwB5Dpa.js +916 -0
  10. package/dist/chunks/DataGridGanttStageEntry-B9YlOHt1.js +40 -0
  11. package/dist/chunks/DataGridTableStage.vue_vue_type_script_setup_true_lang-BJJoBCsA.js +6681 -0
  12. package/dist/chunks/useDataGridAppRowModel-Di-Zatjs.js +2761 -0
  13. package/dist/gantt/DataGridGanttStageEntry.d.ts +52 -0
  14. package/dist/gantt.d.ts +3 -0
  15. package/dist/gantt.js +8 -0
  16. package/dist/host/DataGridRuntimeHost.d.ts +2 -2
  17. package/dist/index.js +32 -30
  18. package/dist/internal.js +39 -35
  19. package/dist/overlays/DataGridAdvancedFilterPopover.vue.d.ts +5 -5
  20. package/dist/overlays/DataGridAggregationsPopover.vue.d.ts +4 -4
  21. package/dist/overlays/DataGridColumnLayoutPopover.vue.d.ts +4 -4
  22. package/dist/overlays/DataGridColumnMenu.vue.d.ts +2 -2
  23. package/dist/overlays/DataGridFilterableCombobox.vue.d.ts +2 -2
  24. package/dist/stage/DataGridTableStageCenterPane.vue.d.ts +1 -1
  25. package/package.json +12 -4
  26. package/dist/chunks/useDataGridAppRowModel-CcTL-h8L.js +0 -11251
@@ -0,0 +1,916 @@
1
+ import { defineComponent as yn, computed as u, ref as y, watch as de, nextTick as Mt, onMounted as wn, onBeforeUnmount as pn, openBlock as De, createElementBlock as We, createElementVNode as V, normalizeStyle as ne, createVNode as bn, mergeProps as Sn, unref as Mn, createCommentVNode as Tn } from "vue";
2
+ import { o as Pn, q as Dn, _ as Wn } from "./DataGridTableStage.vue_vue_type_script_setup_true_lang-BJJoBCsA.js";
3
+ import { resolveDataGridGanttAnalysis as _n, buildDataGridGanttVisibleBars as kn, buildDataGridGanttDependencyPaths as Rn, resolveDataGridGanttRangeFrame as Xe, buildDataGridTimelineRenderModels as Tt, resolveDataGridTimelineDateToPixel as Pt, resolveDataGridTimelineScrollLeftForDate as En, applyDataGridGanttDragDelta as In, hitTestDataGridGanttBar as Dt, clampDataGridTimelineScrollLeft as xn, buildDataGridGanttRowEditPatch as Cn } from "@affino/datagrid-gantt";
4
+ const be = 0.5, Ln = 1.25;
5
+ function Hn(s) {
6
+ const d = Math.abs(s.deltaX), o = Math.abs(s.deltaY);
7
+ if (s.shiftKey) {
8
+ const v = d > be ? s.deltaX : s.deltaY;
9
+ return Math.abs(v) > be ? { horizontalDelta: v, verticalDelta: 0 } : { horizontalDelta: 0, verticalDelta: 0 };
10
+ }
11
+ return d <= be && o <= be ? {
12
+ horizontalDelta: 0,
13
+ verticalDelta: 0
14
+ } : d > be && d > o * Ln ? {
15
+ horizontalDelta: s.deltaX,
16
+ verticalDelta: 0
17
+ } : {
18
+ horizontalDelta: 0,
19
+ verticalDelta: s.deltaY
20
+ };
21
+ }
22
+ const Bn = 12, Oe = 280, Ke = 240;
23
+ function $e(s, d) {
24
+ return Number.isFinite(s) ? Math.max(1, Math.round(Number(s))) : d;
25
+ }
26
+ function Et(s) {
27
+ const d = $e(
28
+ s.minTableWidth,
29
+ Oe
30
+ ), o = $e(
31
+ s.minTimelineWidth,
32
+ Ke
33
+ ), v = $e(s.requestedWidth, d), S = Number.isFinite(s.stageWidth) ? Math.max(0, Number(s.stageWidth)) : 0, R = Number.isFinite(s.maxTableWidth) ? Math.max(d, Math.round(Number(s.maxTableWidth))) : Number.POSITIVE_INFINITY, w = S > 0 ? Math.max(d, S - o) : Number.POSITIVE_INFINITY;
34
+ return Math.min(
35
+ Math.max(v, d),
36
+ Math.min(R, w)
37
+ );
38
+ }
39
+ function Gn(s) {
40
+ return Et({
41
+ requestedWidth: s.originWidth + s.deltaX,
42
+ stageWidth: s.stageWidth,
43
+ minTableWidth: s.minTableWidth,
44
+ minTimelineWidth: s.minTimelineWidth,
45
+ maxTableWidth: s.maxTableWidth
46
+ });
47
+ }
48
+ const An = 44;
49
+ function Nn(s, d, o) {
50
+ const v = s.trim();
51
+ if (v.length === 0 || d < An)
52
+ return null;
53
+ if (o(v) <= d)
54
+ return v;
55
+ const S = "...";
56
+ if (o(S) > d)
57
+ return null;
58
+ let w = 0, I = v.length, E = "";
59
+ for (; w <= I; ) {
60
+ const M = Math.floor((w + I) / 2), T = `${v.slice(0, M).trimEnd()}${S}`;
61
+ o(T) <= d ? (E = T, w = M + 1) : I = M - 1;
62
+ }
63
+ return E.length > 0 ? E : null;
64
+ }
65
+ const Vn = 6;
66
+ function Se(s) {
67
+ return [
68
+ s.dependencyTaskId,
69
+ s.dependencyType,
70
+ s.sourceBar.rowId,
71
+ s.targetBar.rowId
72
+ ].join("::");
73
+ }
74
+ function zn(s, d, o) {
75
+ const v = o.x - d.x, S = o.y - d.y;
76
+ if (v === 0 && S === 0) {
77
+ const W = s.x - d.x, ue = s.y - d.y;
78
+ return W * W + ue * ue;
79
+ }
80
+ const R = ((s.x - d.x) * v + (s.y - d.y) * S) / (v * v + S * S), w = Math.max(0, Math.min(1, R)), I = d.x + v * w, E = d.y + S * w, M = s.x - I, T = s.y - E;
81
+ return M * M + T * T;
82
+ }
83
+ function Wt(s, d, o = Vn) {
84
+ const v = Math.max(1, o) ** 2;
85
+ let S = null, R = Number.POSITIVE_INFINITY;
86
+ for (const w of s)
87
+ for (let I = 1; I < w.points.length; I += 1) {
88
+ const E = w.points[I - 1], M = w.points[I];
89
+ if (!E || !M)
90
+ continue;
91
+ const T = zn(d, E, M);
92
+ T > v || T >= R || (R = T, S = w);
93
+ }
94
+ return S;
95
+ }
96
+ const Fn = { class: "datagrid-gantt-stage__timeline" }, Xn = { class: "datagrid-gantt-stage__timeline-body" }, $n = {
97
+ key: 0,
98
+ class: "datagrid-gantt-stage__empty"
99
+ }, _t = 48, kt = 240, _e = 40, Rt = 24, Yn = /* @__PURE__ */ yn({
100
+ __name: "DataGridGanttStage",
101
+ props: {
102
+ stageContext: {},
103
+ runtime: {},
104
+ gantt: {},
105
+ baseRowHeight: {},
106
+ rowVersion: {}
107
+ },
108
+ setup(s) {
109
+ Pn();
110
+ const d = /* @__PURE__ */ new Set(), o = s, v = o.stageContext, S = u(() => Dn(v)), R = u(() => v.rows.value), w = u(() => v.viewport.value), I = u(() => v.rowHeightMode.value), E = y(null), M = y(null), T = y(null), W = y(null), ue = y(null), ae = y(null), K = y(null), U = y(_t), ce = y(0), Y = y(0), ke = y(0), D = y(0), A = y(0), g = y(null), ie = y(null), j = y(null), z = y(null), L = y(null), Ue = y(!1), le = y(null);
111
+ let he = !1, ve = !1, Re = null, N = null, Ee = !1;
112
+ function Ie(e) {
113
+ const n = new Date(e);
114
+ return Date.UTC(n.getUTCFullYear(), n.getUTCMonth(), n.getUTCDate());
115
+ }
116
+ function It(e) {
117
+ if (!e)
118
+ return null;
119
+ try {
120
+ return e.getContext("2d");
121
+ } catch {
122
+ return null;
123
+ }
124
+ }
125
+ function P(e, n) {
126
+ const a = M.value?.getStageRootElement() ?? W.value;
127
+ if (!a || typeof window > "u")
128
+ return n;
129
+ const l = window.getComputedStyle(a).getPropertyValue(e).trim();
130
+ return l.length > 0 ? l : n;
131
+ }
132
+ function Ye(e, n, a) {
133
+ const l = It(e);
134
+ if (!e || !l)
135
+ return null;
136
+ const r = typeof window > "u" ? 1 : Math.max(1, window.devicePixelRatio || 1), t = Math.max(1, Math.round(n)), h = Math.max(1, Math.round(a));
137
+ return (e.width !== Math.round(t * r) || e.height !== Math.round(h * r)) && (e.width = Math.round(t * r), e.height = Math.round(h * r)), l.setTransform(r, 0, 0, r, 0, 0), l.clearRect(0, 0, t, h), l;
138
+ }
139
+ function je(e) {
140
+ return e ? Math.max(
141
+ e.clientWidth,
142
+ Math.round(e.getBoundingClientRect().width)
143
+ ) : 0;
144
+ }
145
+ function q(e, n, a, l, r, t) {
146
+ const h = Math.max(0, Math.min(t, l / 2, r / 2));
147
+ e.beginPath(), e.moveTo(n + h, a), e.lineTo(n + l - h, a), e.quadraticCurveTo(n + l, a, n + l, a + h), e.lineTo(n + l, a + r - h), e.quadraticCurveTo(n + l, a + r, n + l - h, a + r), e.lineTo(n + h, a + r), e.quadraticCurveTo(n, a + r, n, a + r - h), e.lineTo(n, a + h), e.quadraticCurveTo(n, a, n + h, a), e.closePath();
148
+ }
149
+ function oe(e, n, a, l) {
150
+ const r = Math.max(1, l / 2);
151
+ e.beginPath(), e.moveTo(n, a - r), e.lineTo(n + r, a), e.lineTo(n, a + r), e.lineTo(n - r, a), e.closePath();
152
+ }
153
+ function qe(e, n, a, l, r) {
154
+ Math.abs(a - n) < 2 || (e.save(), e.strokeStyle = r, e.lineWidth = 1.5, e.lineCap = "round", e.beginPath(), e.moveTo(n, l), e.lineTo(a, l), e.moveTo(n, l - 3), e.lineTo(n, l + 3), e.moveTo(a, l - 3), e.lineTo(a, l + 3), e.stroke(), e.restore());
155
+ }
156
+ function xt(e, n, a, l, r) {
157
+ const t = n[0];
158
+ if (!t || n.length < 2)
159
+ return;
160
+ e.save();
161
+ const h = a === "FS" ? [] : a === "SS" ? [5, 3] : a === "FF" ? [8, 3] : [2, 3];
162
+ e.setLineDash(h), e.strokeStyle = r, e.lineWidth = 4, e.lineJoin = "round", e.lineCap = "round", e.beginPath(), e.moveTo(t.x, t.y);
163
+ for (let _ = 1; _ < n.length; _ += 1) {
164
+ const x = n[_];
165
+ x && e.lineTo(x.x, x.y);
166
+ }
167
+ e.stroke(), e.strokeStyle = l, e.fillStyle = l, e.lineWidth = 1.5, e.lineJoin = "round", e.lineCap = "round", e.beginPath(), e.moveTo(t.x, t.y);
168
+ for (let _ = 1; _ < n.length; _ += 1) {
169
+ const x = n[_];
170
+ x && e.lineTo(x.x, x.y);
171
+ }
172
+ e.stroke();
173
+ const f = n[n.length - 1], H = n[n.length - 2];
174
+ if (f && H) {
175
+ e.fillStyle = "rgba(255, 255, 255, 0.85)", e.beginPath(), e.arc(t.x, t.y, 1.75 + 1.25, 0, Math.PI * 2), e.arc(f.x, f.y, 2.5 + 1.5, 0, Math.PI * 2), e.fill(), e.fillStyle = l, e.beginPath(), e.arc(t.x, t.y, 1.75, 0, Math.PI * 2), e.arc(f.x, f.y, 2.5, 0, Math.PI * 2), e.fill();
176
+ const X = Math.atan2(f.y - H.y, f.x - H.x), $ = 6, B = Math.PI / 8;
177
+ e.beginPath(), e.moveTo(f.x, f.y), e.lineTo(
178
+ f.x - $ * Math.cos(X - B),
179
+ f.y - $ * Math.sin(X - B)
180
+ ), e.lineTo(
181
+ f.x - $ * Math.cos(X + B),
182
+ f.y - $ * Math.sin(X + B)
183
+ ), e.closePath(), e.fill();
184
+ }
185
+ e.restore();
186
+ }
187
+ function Ct(e, n, a, l, r, t) {
188
+ const f = Math.max(0, r - 16), H = Nn(
189
+ n,
190
+ f,
191
+ (_) => e.measureText(_).width
192
+ );
193
+ H && (e.save(), e.beginPath(), e.rect(a, l, r, t), e.clip(), e.fillText(H, a + 8, l + t / 2), e.restore());
194
+ }
195
+ function J() {
196
+ const e = K.value;
197
+ if (!e) {
198
+ ce.value = 0, Y.value = 0;
199
+ return;
200
+ }
201
+ ce.value = e.scrollTop, Y.value = e.clientHeight;
202
+ }
203
+ function fe() {
204
+ const e = M.value?.getHeaderElement() ?? null, n = Math.max(
205
+ 1,
206
+ Math.round(
207
+ e?.offsetHeight || e?.clientHeight || e?.getBoundingClientRect().height || _t
208
+ )
209
+ );
210
+ U.value !== n && (U.value = n);
211
+ }
212
+ function Z() {
213
+ ke.value = E.value?.clientWidth ?? 0;
214
+ }
215
+ function ge() {
216
+ A.value = Math.max(
217
+ je(W.value),
218
+ je(T.value)
219
+ );
220
+ }
221
+ function Je(e) {
222
+ if (!e)
223
+ return;
224
+ const n = Math.max(0, e.clientWidth);
225
+ n > 0 && A.value !== n && (A.value = n);
226
+ }
227
+ function m(e = "both") {
228
+ he = he || e !== "body", ve = ve || e !== "header", !(le.value != null || typeof window > "u") && (le.value = window.requestAnimationFrame(() => {
229
+ const n = he, a = ve;
230
+ le.value = null, he = !1, ve = !1, n && jt(), a && qt();
231
+ }));
232
+ }
233
+ function Lt() {
234
+ le.value == null || typeof window > "u" || (window.cancelAnimationFrame(le.value), le.value = null, he = !1, ve = !1);
235
+ }
236
+ function Ze(e) {
237
+ return o.runtime.api.view.getRowHeightOverride(e) ?? o.baseRowHeight;
238
+ }
239
+ const Me = u(() => o.runtime.api.view.getRowHeightVersion()), Qe = u(() => {
240
+ if (nt.value, Me.value, I.value !== "auto") {
241
+ const e = [];
242
+ let n = w.value.topSpacerHeight;
243
+ for (let a = 0; a < R.value.displayRows.length; a += 1) {
244
+ const l = w.value.viewportRowStart + a, r = Math.max(1, Ze(l));
245
+ e.push({
246
+ top: n,
247
+ height: r
248
+ }), n += r;
249
+ }
250
+ return e;
251
+ }
252
+ return M.value?.getVisibleRowMetrics() ?? [];
253
+ }), et = u(() => o.gantt ? (o.rowVersion, _n({
254
+ getCount: () => o.runtime.api.rows.getCount(),
255
+ get: (e) => o.runtime.api.rows.get(e)
256
+ }, o.gantt)) : null), c = u(() => et.value?.timeline ?? null), Ht = u(() => et.value?.criticalTaskIds ?? d), re = u(() => !o.gantt || !c.value ? [] : (o.rowVersion, Me.value, kn({
257
+ rows: R.value.displayRows,
258
+ rowMetrics: Qe.value,
259
+ viewportRowStart: w.value.viewportRowStart,
260
+ scrollTop: ce.value,
261
+ topSpacerHeight: w.value.topSpacerHeight,
262
+ viewportHeight: Math.max(
263
+ Y.value,
264
+ R.value.displayRows.length * o.baseRowHeight
265
+ ),
266
+ baseRowHeight: o.baseRowHeight,
267
+ resolveRowHeight: Ze,
268
+ timeline: c.value,
269
+ options: o.gantt,
270
+ criticalTaskIds: Ht.value
271
+ }))), tt = u(() => {
272
+ o.rowVersion, Me.value;
273
+ const e = [], n = Math.max(Y.value, 0);
274
+ return Qe.value.forEach((a) => {
275
+ const l = Math.round(a.top - ce.value + a.height) + 0.5;
276
+ l >= -1 && l <= n + 1 && e.push(l);
277
+ }), e;
278
+ }), me = u(() => {
279
+ const e = c.value;
280
+ return !e || !o.gantt ? [] : Rn({
281
+ bars: re.value,
282
+ resolveFrame: (n) => {
283
+ const a = it(n), l = Xe(
284
+ a,
285
+ e,
286
+ o.gantt?.minBarWidth ?? 6,
287
+ n.milestone ? n.height : void 0
288
+ );
289
+ return {
290
+ x: l.x - D.value,
291
+ width: l.width,
292
+ y: n.y,
293
+ height: n.height
294
+ };
295
+ }
296
+ });
297
+ }), Bt = u(() => L.value ? me.value.find((e) => Se(e) === L.value) ?? null : null), Gt = u(() => {
298
+ const e = Bt.value;
299
+ return e ? /* @__PURE__ */ new Set([
300
+ e.sourceBar.rowId,
301
+ e.targetBar.rowId
302
+ ]) : /* @__PURE__ */ new Set();
303
+ }), nt = u(() => R.value.displayRows.map((e, n) => `${e.rowId == null ? n : String(e.rowId)}`).join("|")), At = u(() => {
304
+ if (!o.gantt)
305
+ return "off";
306
+ const e = [
307
+ o.gantt.workingCalendar.workingWeekdays.join(","),
308
+ o.gantt.workingCalendar.holidayDayStarts.join(",")
309
+ ].join("@");
310
+ return [
311
+ o.gantt.startKey,
312
+ o.gantt.endKey,
313
+ o.gantt.baselineStartKey ?? "",
314
+ o.gantt.baselineEndKey ?? "",
315
+ o.gantt.progressKey ?? "",
316
+ o.gantt.dependencyKey ?? "",
317
+ o.gantt.labelKey ?? "",
318
+ o.gantt.idKey ?? "",
319
+ o.gantt.criticalKey ?? "",
320
+ o.gantt.computedCriticalPath ? "computed-critical" : "",
321
+ o.gantt.zoomLevel,
322
+ o.gantt.pixelsPerDay,
323
+ o.gantt.timelineStart == null ? "" : String(o.gantt.timelineStart),
324
+ o.gantt.timelineEnd == null ? "" : String(o.gantt.timelineEnd),
325
+ o.gantt.rangePaddingDays,
326
+ e,
327
+ o.gantt.rowBarHeight,
328
+ o.gantt.minBarWidth,
329
+ o.gantt.resizeHandleWidth,
330
+ o.gantt.paneWidth
331
+ ].join("|");
332
+ }), Nt = u(() => c.value ? [
333
+ c.value.startMs,
334
+ c.value.endMs,
335
+ c.value.totalWidth,
336
+ c.value.pixelsPerDay,
337
+ c.value.zoomLevel
338
+ ].join("|") : "none"), Vt = u(() => re.value.map((e) => [
339
+ String(e.rowUpdateId),
340
+ e.startMs,
341
+ e.endMs,
342
+ e.x,
343
+ e.width,
344
+ e.y,
345
+ e.height,
346
+ e.progress,
347
+ e.critical ? 1 : 0,
348
+ e.criticalSource ?? "",
349
+ e.milestone ? 1 : 0,
350
+ e.summary ? 1 : 0,
351
+ e.baselineStartMs ?? "",
352
+ e.baselineEndMs ?? "",
353
+ e.dependencyRefs.map((n) => `${n.taskId}:${n.type}`).join(",")
354
+ ].join(":")).join("|")), zt = u(() => tt.value.join("|")), xe = y(o.gantt?.paneWidth ?? 520), ye = u(() => Et({
355
+ requestedWidth: xe.value,
356
+ stageWidth: ke.value,
357
+ minTableWidth: Oe,
358
+ minTimelineWidth: Ke
359
+ })), Ft = u(() => ({
360
+ width: `${ye.value}px`,
361
+ minWidth: `${ye.value}px`,
362
+ maxWidth: `${ye.value}px`
363
+ })), Xt = u(() => ({
364
+ left: `${ye.value}px`,
365
+ width: `${Bn}px`
366
+ })), $t = u(() => ({
367
+ height: `${U.value}px`
368
+ })), Ot = u(() => ({
369
+ height: `${U.value}px`
370
+ })), Kt = u(() => ({
371
+ width: `${c.value?.totalWidth ?? 1}px`,
372
+ minWidth: `${c.value?.totalWidth ?? 1}px`,
373
+ height: `${U.value}px`
374
+ })), Ut = u(() => ({
375
+ width: `${c.value?.totalWidth ?? 1}px`,
376
+ minWidth: `${c.value?.totalWidth ?? 1}px`,
377
+ height: `${Math.max(Y.value, 1)}px`
378
+ })), Yt = u(() => ie.value ? "col-resize" : g.value ? g.value.mode === "move" ? "grabbing" : "col-resize" : j.value ? j.value.mode === "move" ? "grab" : "col-resize" : z.value ? "pointer" : "default");
379
+ function at() {
380
+ L.value == null && z.value == null || (L.value = null, z.value = null, m("body"));
381
+ }
382
+ function it(e) {
383
+ const n = g.value;
384
+ return !n || n.rowId !== e.rowId ? {
385
+ startMs: e.startMs,
386
+ endMs: e.endMs
387
+ } : {
388
+ startMs: n.draftStartMs,
389
+ endMs: n.draftEndMs
390
+ };
391
+ }
392
+ function Ce(e) {
393
+ typeof document > "u" || (document.body.style.cursor = e ? "col-resize" : "", document.body.style.userSelect = e ? "none" : "");
394
+ }
395
+ function lt(e, n, a, l, r) {
396
+ for (const t of n) {
397
+ if (t.width < 18)
398
+ continue;
399
+ const h = Math.max(0, t.x), f = Math.min(r, t.x + t.width);
400
+ f <= h || (e.save(), e.beginPath(), e.rect(h, a, f - h, l), e.clip(), e.fillText(
401
+ t.label,
402
+ Math.max(h + 8, t.x + 8),
403
+ a + l / 2
404
+ ), e.restore());
405
+ }
406
+ }
407
+ function jt() {
408
+ const e = c.value, n = T.value;
409
+ if (!e || !n)
410
+ return;
411
+ const a = Math.max(1, U.value), l = Math.max(1, A.value || n.clientWidth || 1), r = Tt({
412
+ timeline: e,
413
+ scrollLeft: D.value,
414
+ viewportWidth: l,
415
+ workingCalendar: o.gantt?.workingCalendar ?? null,
416
+ headerBufferPx: 0,
417
+ bodyBufferPx: kt
418
+ }).header, t = Ye(
419
+ ue.value,
420
+ l,
421
+ a
422
+ );
423
+ if (!t)
424
+ return;
425
+ const h = P("--datagrid-column-divider-color", "rgba(148, 163, 184, 0.24)"), f = P("--datagrid-header-divider-color", "rgba(148, 163, 184, 0.42)"), H = P("--datagrid-header-row-bg", "#f8fafc"), _ = P("--datagrid-weekend-bg", "rgba(148, 163, 184, 0.12)"), x = P("--datagrid-text-primary", "#0f172a"), X = P("--datagrid-font-family", "ui-sans-serif, system-ui, sans-serif"), $ = P("--datagrid-accent-strong", "#2563eb"), B = Math.max(16, Math.round(a * 0.46)), ee = B, we = Math.max(1, a - B);
426
+ t.fillStyle = H, t.fillRect(0, 0, l, a), t.fillStyle = _;
427
+ for (const G of r.nonWorkingSpans) {
428
+ const C = Math.max(0, G.x), Te = Math.min(l, G.x + G.width);
429
+ Te <= C || t.fillRect(C, ee, Te - C, we);
430
+ }
431
+ t.strokeStyle = h, t.lineWidth = 1;
432
+ for (const G of r.secondaryLines) {
433
+ const C = Math.round(G.x) + 0.5;
434
+ t.beginPath(), t.moveTo(C, ee), t.lineTo(C, a), t.stroke();
435
+ }
436
+ t.strokeStyle = f;
437
+ for (const G of r.primaryLines) {
438
+ const C = Math.round(G.x) + 0.5;
439
+ t.beginPath(), t.moveTo(C, 0), t.lineTo(C, a), t.stroke();
440
+ }
441
+ t.beginPath(), t.moveTo(0, ee - 0.5), t.lineTo(l, ee - 0.5), t.stroke(), t.strokeStyle = f, t.beginPath(), t.moveTo(0, a - 0.5), t.lineTo(l, a - 0.5), t.stroke(), t.fillStyle = x, t.font = `12px ${X}`, t.textBaseline = "middle", lt(t, r.primarySegments, 0, B, l), lt(t, r.secondarySegments, ee, we, l);
442
+ const te = Pt(Ie(Date.now()), e) - D.value;
443
+ te >= -1 && te <= l + 1 && (t.strokeStyle = $, t.lineWidth = 2, t.beginPath(), t.moveTo(Math.round(te) + 0.5, 0), t.lineTo(Math.round(te) + 0.5, a), t.stroke());
444
+ }
445
+ function qt() {
446
+ const e = c.value, n = W.value;
447
+ if (!e || !n)
448
+ return;
449
+ const a = Math.max(1, Y.value || n.clientHeight || re.value.length * o.baseRowHeight), l = Math.max(1, A.value || n.clientWidth || 1), r = Tt({
450
+ timeline: e,
451
+ scrollLeft: D.value,
452
+ viewportWidth: l,
453
+ workingCalendar: o.gantt?.workingCalendar ?? null,
454
+ headerBufferPx: 0,
455
+ bodyBufferPx: kt
456
+ }).body, t = Ye(ae.value, l, a);
457
+ if (!t)
458
+ return;
459
+ const h = P("--datagrid-viewport-bg", "#ffffff"), f = P("--datagrid-column-divider-color", "rgba(148, 163, 184, 0.16)"), H = P("--datagrid-row-divider-color", "rgba(148, 163, 184, 0.18)"), _ = P("--datagrid-weekend-bg", "rgba(148, 163, 184, 0.08)"), x = P("--datagrid-accent-strong", "#2563eb"), X = P("--datagrid-selection-range-bg", "rgba(37, 99, 235, 0.16)"), $ = "rgba(30, 64, 175, 0.24)", B = "rgba(30, 64, 175, 0.96)", ee = "rgba(59, 130, 246, 0.92)", we = "rgba(100, 116, 139, 0.28)", te = "rgba(71, 85, 105, 0.44)", G = "rgba(220, 38, 38, 0.62)", C = "rgba(5, 150, 105, 0.56)", Te = "rgba(255, 255, 255, 0.28)", ct = "#dc2626", ht = "rgba(220, 38, 38, 0.76)", sn = "rgba(15, 23, 42, 0.32)", dn = "rgba(255, 255, 255, 0.72)", un = "rgba(15, 23, 42, 0.84)", cn = "rgba(255, 255, 255, 0.94)", hn = P("--datagrid-header-divider-color", "rgba(148, 163, 184, 0.3)"), vn = "#ffffff", fn = P("--datagrid-font-family", "ui-sans-serif, system-ui, sans-serif"), gn = P("--datagrid-accent-strong", "#2563eb"), vt = "rgba(15, 23, 42, 0.85)", ft = "rgba(255, 255, 255, 0.96)";
460
+ t.fillStyle = h, t.fillRect(0, 0, l, a), t.fillStyle = _;
461
+ for (const i of r.nonWorkingSpans) {
462
+ const k = Math.max(0, i.x), pe = Math.min(l, i.x + i.width);
463
+ pe <= k || t.fillRect(k, 0, pe - k, a);
464
+ }
465
+ t.strokeStyle = f, t.lineWidth = 1;
466
+ for (const i of r.secondaryLines) {
467
+ const k = Math.round(i.x) + 0.5;
468
+ t.beginPath(), t.moveTo(k, 0), t.lineTo(k, a), t.stroke();
469
+ }
470
+ t.strokeStyle = hn;
471
+ for (const i of r.primaryLines) {
472
+ const k = Math.round(i.x) + 0.5;
473
+ t.beginPath(), t.moveTo(k, 0), t.lineTo(k, a), t.stroke();
474
+ }
475
+ t.strokeStyle = H;
476
+ for (const i of tt.value)
477
+ t.beginPath(), t.moveTo(0, i), t.lineTo(l, i), t.stroke();
478
+ const Pe = Pt(Ie(Date.now()), e) - D.value;
479
+ Pe >= -1 && Pe <= l + 1 && (t.strokeStyle = gn, t.lineWidth = 2, t.beginPath(), t.moveTo(Math.round(Pe) + 0.5, 0), t.lineTo(Math.round(Pe) + 0.5, a), t.stroke());
480
+ for (const i of me.value) {
481
+ const k = Se(i) === L.value;
482
+ xt(
483
+ t,
484
+ i.points,
485
+ i.dependencyType,
486
+ k ? un : sn,
487
+ k ? cn : dn
488
+ );
489
+ }
490
+ t.font = `12px ${fn}`, t.textBaseline = "middle";
491
+ for (const i of re.value) {
492
+ const k = it(i), pe = Xe(
493
+ k,
494
+ e,
495
+ o.gantt?.minBarWidth ?? 6,
496
+ i.milestone ? i.height : void 0
497
+ ), b = pe.x - D.value, p = pe.width, gt = Gt.value.has(i.rowId), mn = i.baselineStartMs != null && i.baselineEndMs != null && (i.baselineStartMs !== i.startMs || i.baselineEndMs !== i.endMs), mt = i.summary ? $ : g.value?.rowId === i.rowId ? X : x;
498
+ if (mn) {
499
+ const O = Xe(
500
+ {
501
+ startMs: i.baselineStartMs,
502
+ endMs: i.baselineEndMs
503
+ },
504
+ e,
505
+ o.gantt?.minBarWidth ?? 6,
506
+ i.milestone ? i.height : void 0
507
+ ), se = O.x - D.value, yt = b, wt = b + p, pt = se, bt = se + O.width;
508
+ if (i.milestone)
509
+ oe(
510
+ t,
511
+ se + O.width / 2,
512
+ i.y + i.height / 2,
513
+ Math.max(Math.max(8, O.width - 2), i.height - 2)
514
+ ), t.fillStyle = we, t.fill(), oe(
515
+ t,
516
+ se + O.width / 2,
517
+ i.y + i.height / 2,
518
+ Math.max(Math.max(8, O.width - 2), i.height - 2)
519
+ ), t.strokeStyle = te, t.lineWidth = 1, t.stroke();
520
+ else {
521
+ const Fe = Math.max(4, Math.min(6, Math.round(i.height * 0.34))), St = i.y + i.height - Fe;
522
+ q(t, se, St, O.width, Fe, 3), t.fillStyle = we, t.fill(), q(t, se, St, O.width, Fe, 3), t.strokeStyle = te, t.lineWidth = 1, t.stroke();
523
+ }
524
+ qe(
525
+ t,
526
+ pt,
527
+ yt,
528
+ i.y + 2.5,
529
+ yt >= pt ? G : C
530
+ ), qe(
531
+ t,
532
+ bt,
533
+ wt,
534
+ i.y + i.height - 2.5,
535
+ wt >= bt ? G : C
536
+ );
537
+ }
538
+ if (i.milestone) {
539
+ oe(t, b + p / 2, i.y + i.height / 2, Math.max(p, i.height)), t.fillStyle = mt, t.fill(), gt && (oe(t, b + p / 2, i.y + i.height / 2, Math.max(p, i.height)), t.strokeStyle = ft, t.lineWidth = 4, t.stroke(), oe(t, b + p / 2, i.y + i.height / 2, Math.max(p, i.height)), t.strokeStyle = vt, t.lineWidth = 2, t.stroke()), i.critical && (oe(t, b + p / 2, i.y + i.height / 2, Math.max(p, i.height)), t.strokeStyle = i.criticalSource === "computed" ? ht : ct, t.lineWidth = 2, t.stroke());
540
+ continue;
541
+ }
542
+ q(t, b, i.y, p, i.height, i.summary ? 4 : 6), t.fillStyle = mt, t.fill(), i.summary && (t.fillStyle = ee, t.fillRect(b + 4, i.y + 3, Math.max(8, p - 8), 2), t.strokeStyle = B, t.lineWidth = 2.5, t.beginPath(), t.moveTo(b, i.y + i.height), t.lineTo(b + 6, i.y), t.lineTo(b + p - 6, i.y), t.lineTo(b + p, i.y + i.height), t.stroke()), !i.summary && i.progress > 0 && (q(t, b, i.y, Math.max(0, p * i.progress), i.height, 6), t.fillStyle = Te, t.fill()), gt && (q(t, b, i.y, p, i.height, 6), t.strokeStyle = ft, t.lineWidth = 4, t.stroke(), q(t, b, i.y, p, i.height, 6), t.strokeStyle = vt, t.lineWidth = 2, t.stroke()), i.critical && (q(t, b, i.y, p, i.height, 6), t.strokeStyle = i.criticalSource === "computed" ? ht : ct, t.lineWidth = 2, t.stroke()), t.fillStyle = vn, Ct(t, i.label, b, i.y, p, i.height);
543
+ }
544
+ }
545
+ function Jt(e) {
546
+ const n = W.value;
547
+ if (!n)
548
+ return 0;
549
+ const a = n.getBoundingClientRect();
550
+ if (e <= a.left + _e) {
551
+ const r = 1 - Math.max(0, e - a.left) / _e;
552
+ return -Math.max(1, Math.round(Rt * r));
553
+ }
554
+ if (e >= a.right - _e) {
555
+ const r = 1 - Math.max(0, a.right - e) / _e;
556
+ return Math.max(1, Math.round(Rt * r));
557
+ }
558
+ return 0;
559
+ }
560
+ function Q(e, n) {
561
+ if (D.value = xn(
562
+ e,
563
+ c.value?.totalWidth ?? 0,
564
+ A.value
565
+ ), Ee) {
566
+ m();
567
+ return;
568
+ }
569
+ Ee = !0, n !== "header" && T.value && T.value.scrollLeft !== D.value && (T.value.scrollLeft = D.value), n !== "body" && W.value && W.value.scrollLeft !== D.value && (W.value.scrollLeft = D.value), Ee = !1, m();
570
+ }
571
+ function F() {
572
+ if (!c.value) {
573
+ Q(0, "body");
574
+ return;
575
+ }
576
+ Q(D.value, "body");
577
+ }
578
+ function Le() {
579
+ if (Ue.value || !c.value || A.value <= 0)
580
+ return;
581
+ const e = Ie(Date.now()), n = e >= c.value.startMs && e <= c.value.endMs ? En({
582
+ dateMs: e,
583
+ timeline: c.value,
584
+ viewportWidth: A.value,
585
+ align: "center"
586
+ }) : 0;
587
+ Q(n, "body"), Ue.value = !0;
588
+ }
589
+ function Zt(e) {
590
+ const n = e.target;
591
+ n && (Je(n), Q(n.scrollLeft, "body"));
592
+ }
593
+ function Qt(e) {
594
+ const n = e.target;
595
+ n && (Je(n), Q(n.scrollLeft, "header"));
596
+ }
597
+ function He(e) {
598
+ const n = K.value, a = W.value;
599
+ if (!n || !a)
600
+ return;
601
+ const { horizontalDelta: l, verticalDelta: r } = Hn({
602
+ deltaX: e.deltaX,
603
+ deltaY: e.deltaY,
604
+ shiftKey: e.shiftKey
605
+ });
606
+ if (!(l === 0 && r === 0) && (e.preventDefault(), l !== 0 && (a.scrollLeft += l, Q(a.scrollLeft, "body")), r !== 0)) {
607
+ const t = n.scrollTop;
608
+ n.scrollTop = t + r, n.scrollTop !== t && (J(), m("body"));
609
+ }
610
+ }
611
+ function en(e) {
612
+ e != null && ie.value && ie.value.pointerId !== e || (ie.value = null, Ce(!1), typeof window < "u" && (window.removeEventListener("pointermove", Be), window.removeEventListener("pointerup", Ge)));
613
+ }
614
+ function Be(e) {
615
+ const n = ie.value;
616
+ n && (xe.value = Gn({
617
+ originWidth: n.originWidth,
618
+ deltaX: e.clientX - n.originClientX,
619
+ stageWidth: ke.value,
620
+ minTableWidth: Oe,
621
+ minTimelineWidth: Ke
622
+ }), ge(), m());
623
+ }
624
+ function Ge(e) {
625
+ en(e.pointerId);
626
+ }
627
+ function tn(e) {
628
+ e.button === 0 && (e.preventDefault(), Z(), ie.value = {
629
+ pointerId: e.pointerId,
630
+ originClientX: e.clientX,
631
+ originWidth: ye.value
632
+ }, Ce(!0), typeof window < "u" && (window.addEventListener("pointermove", Be), window.addEventListener("pointerup", Ge)));
633
+ }
634
+ function Ae(e) {
635
+ const n = ae.value;
636
+ if (!n)
637
+ return null;
638
+ const a = n.getBoundingClientRect();
639
+ return {
640
+ x: e.clientX - a.left,
641
+ y: e.clientY - a.top
642
+ };
643
+ }
644
+ function Ne(e) {
645
+ const n = Ae(e);
646
+ return n ? {
647
+ x: n.x + D.value,
648
+ y: n.y
649
+ } : null;
650
+ }
651
+ function nn(e) {
652
+ if (!o.gantt) {
653
+ j.value = null;
654
+ return;
655
+ }
656
+ const n = Ae(e), a = Ne(e);
657
+ if (!n || !a) {
658
+ j.value = null, z.value = null;
659
+ return;
660
+ }
661
+ const l = Wt(me.value, n);
662
+ z.value = l ? Se(l) : null, j.value = Dt(
663
+ re.value,
664
+ a,
665
+ o.gantt.resizeHandleWidth
666
+ ), j.value && (z.value = null);
667
+ }
668
+ function an() {
669
+ if (!o.gantt || !g.value) {
670
+ g.value = null;
671
+ return;
672
+ }
673
+ const e = g.value;
674
+ if (g.value = null, e.initialStartMs === e.draftStartMs && e.initialEndMs === e.draftEndMs) {
675
+ m("body");
676
+ return;
677
+ }
678
+ o.runtime.api.rows.applyEdits([Cn(
679
+ e.rowUpdateId,
680
+ {
681
+ startMs: e.draftStartMs,
682
+ endMs: e.draftEndMs
683
+ },
684
+ o.gantt
685
+ )], {
686
+ reapply: !0
687
+ }), m("body");
688
+ }
689
+ function Ve(e) {
690
+ if (!g.value || !c.value)
691
+ return;
692
+ const n = Jt(e.clientX);
693
+ n !== 0 && Q(D.value + n, "body");
694
+ const a = Ne(e);
695
+ if (!a)
696
+ return;
697
+ const l = (a.x - g.value.originX) / c.value.pixelsPerDay, r = In({
698
+ startMs: g.value.initialStartMs,
699
+ endMs: g.value.initialEndMs
700
+ }, g.value.mode, l, c.value.zoomLevel, o.gantt?.workingCalendar);
701
+ g.value = {
702
+ ...g.value,
703
+ draftStartMs: r.startMs,
704
+ draftEndMs: r.endMs
705
+ }, m("body");
706
+ }
707
+ function ze(e) {
708
+ !g.value || e.pointerId !== g.value.pointerId || (ae.value?.hasPointerCapture?.(e.pointerId) && ae.value.releasePointerCapture(e.pointerId), an(), typeof window < "u" && (window.removeEventListener("pointermove", Ve), window.removeEventListener("pointerup", ze)));
709
+ }
710
+ function ln(e) {
711
+ if (!o.gantt || !c.value)
712
+ return;
713
+ const n = Ae(e), a = Ne(e);
714
+ if (!n || !a)
715
+ return;
716
+ const l = Dt(
717
+ re.value,
718
+ a,
719
+ o.gantt.resizeHandleWidth
720
+ );
721
+ if (l && (L.value = null, z.value = null), !l) {
722
+ const r = Wt(me.value, n);
723
+ if (r) {
724
+ e.preventDefault(), L.value = Se(r), m("body");
725
+ return;
726
+ }
727
+ at();
728
+ return;
729
+ }
730
+ e.preventDefault(), ae.value?.setPointerCapture?.(e.pointerId), g.value = {
731
+ pointerId: e.pointerId,
732
+ rowId: l.bar.rowId,
733
+ rowUpdateId: l.bar.rowUpdateId,
734
+ mode: l.mode,
735
+ originX: a.x,
736
+ initialStartMs: l.bar.startMs,
737
+ initialEndMs: l.bar.endMs,
738
+ draftStartMs: l.bar.startMs,
739
+ draftEndMs: l.bar.endMs
740
+ }, typeof window < "u" && (window.addEventListener("pointermove", Ve), window.addEventListener("pointerup", ze)), m("body");
741
+ }
742
+ function on(e) {
743
+ g.value || nn(e);
744
+ }
745
+ function rn() {
746
+ g.value || (j.value = null, z.value = null);
747
+ }
748
+ function ot(e) {
749
+ e.key !== "Escape" || g.value || at();
750
+ }
751
+ function rt() {
752
+ Re?.(), Re = null, K.value = null;
753
+ }
754
+ function st() {
755
+ if (N?.disconnect(), N = null, typeof window > "u" || typeof window.ResizeObserver != "function")
756
+ return;
757
+ N = new window.ResizeObserver(() => {
758
+ Z(), fe(), J(), ge(), F(), m();
759
+ });
760
+ const e = M.value?.getHeaderElement() ?? null;
761
+ e && N.observe(e), K.value && N.observe(K.value), E.value && N.observe(E.value), W.value && N.observe(W.value);
762
+ }
763
+ function dt() {
764
+ const e = M.value?.getBodyViewportElement() ?? null;
765
+ if (e === K.value) {
766
+ Z(), fe(), J(), st(), F(), m();
767
+ return;
768
+ }
769
+ if (rt(), K.value = e, !e) {
770
+ Z(), fe(), F(), m();
771
+ return;
772
+ }
773
+ const n = () => {
774
+ J(), m("body");
775
+ };
776
+ e.addEventListener("scroll", n, { passive: !0 }), Z(), fe(), J(), Re = () => {
777
+ e.removeEventListener("scroll", n);
778
+ }, st(), F(), m();
779
+ }
780
+ function ut() {
781
+ Z(), fe(), J(), ge(), F(), m();
782
+ }
783
+ return de(
784
+ () => o.gantt?.paneWidth,
785
+ (e) => {
786
+ xe.value = e ?? 520;
787
+ },
788
+ { immediate: !0 }
789
+ ), de(
790
+ () => [
791
+ nt.value,
792
+ R.value.displayRows.length,
793
+ w.value.topSpacerHeight,
794
+ w.value.viewportRowStart,
795
+ At.value,
796
+ o.rowVersion,
797
+ Me.value
798
+ ],
799
+ () => {
800
+ Mt(() => {
801
+ dt(), J(), ge(), F(), Le(), m();
802
+ });
803
+ }
804
+ ), de(
805
+ () => [c.value?.totalWidth ?? 0, A.value],
806
+ () => {
807
+ F(), Le();
808
+ }
809
+ ), de(
810
+ () => [
811
+ Vt.value,
812
+ zt.value,
813
+ ce.value,
814
+ Y.value
815
+ ],
816
+ () => {
817
+ m("body");
818
+ }
819
+ ), de(
820
+ () => [
821
+ Nt.value,
822
+ U.value
823
+ ],
824
+ () => {
825
+ m();
826
+ }
827
+ ), de(
828
+ () => me.value.map((e) => Se(e)).join("|"),
829
+ (e) => {
830
+ L.value && !e.split("|").includes(L.value) && (L.value = null, m("body"));
831
+ }
832
+ ), wn(() => {
833
+ Mt(() => {
834
+ Z(), dt(), ge(), F(), Le(), m();
835
+ }), typeof window < "u" && (window.addEventListener("resize", ut), window.addEventListener("keydown", ot));
836
+ }), pn(() => {
837
+ Lt(), rt(), N?.disconnect(), N = null, typeof window < "u" && (window.removeEventListener("resize", ut), window.removeEventListener("keydown", ot), window.removeEventListener("pointermove", Ve), window.removeEventListener("pointerup", ze), window.removeEventListener("pointermove", Be), window.removeEventListener("pointerup", Ge)), Ce(!1);
838
+ }), (e, n) => (De(), We("section", {
839
+ ref_key: "stageRootRef",
840
+ ref: E,
841
+ class: "datagrid-gantt-stage"
842
+ }, [
843
+ V("div", {
844
+ class: "datagrid-gantt-stage__table",
845
+ style: ne(Ft.value)
846
+ }, [
847
+ bn(Wn, Sn({
848
+ ref_key: "tableStageRef",
849
+ ref: M
850
+ }, S.value, { "stage-context": Mn(v) }), null, 16, ["stage-context"])
851
+ ], 4),
852
+ e.gantt ? (De(), We("button", {
853
+ key: 0,
854
+ type: "button",
855
+ class: "datagrid-gantt-stage__splitter",
856
+ style: ne(Xt.value),
857
+ "aria-label": "Resize gantt split",
858
+ onPointerdown: tn
859
+ }, null, 36)) : Tn("", !0),
860
+ V("div", Fn, [
861
+ V("div", {
862
+ class: "datagrid-gantt-stage__timeline-header",
863
+ style: ne($t.value)
864
+ }, [
865
+ V("div", {
866
+ ref_key: "timelineHeaderViewportRef",
867
+ ref: T,
868
+ class: "datagrid-gantt-timeline__viewport datagrid-gantt-timeline__viewport--header",
869
+ style: ne(Ot.value),
870
+ onScroll: Qt,
871
+ onWheel: He
872
+ }, [
873
+ V("div", {
874
+ class: "datagrid-gantt-timeline__track-spacer",
875
+ style: ne(Kt.value)
876
+ }, null, 4)
877
+ ], 36),
878
+ V("canvas", {
879
+ ref_key: "headerCanvasRef",
880
+ ref: ue,
881
+ class: "datagrid-gantt-timeline__canvas datagrid-gantt-timeline__canvas--header",
882
+ "aria-hidden": "true"
883
+ }, null, 512)
884
+ ], 4),
885
+ V("div", Xn, [
886
+ e.gantt ? (De(), We("div", {
887
+ key: 1,
888
+ ref_key: "timelineBodyViewportRef",
889
+ ref: W,
890
+ class: "datagrid-gantt-timeline__viewport datagrid-gantt-timeline__viewport--body",
891
+ onScroll: Zt,
892
+ onWheel: He
893
+ }, [
894
+ V("div", {
895
+ class: "datagrid-gantt-timeline__track-spacer",
896
+ style: ne(Ut.value)
897
+ }, null, 4)
898
+ ], 544)) : (De(), We("div", $n, " Configure `gantt.startKey` and `gantt.endKey` to enable the timeline renderer. ")),
899
+ V("canvas", {
900
+ ref_key: "bodyCanvasRef",
901
+ ref: ae,
902
+ class: "datagrid-gantt-timeline__canvas datagrid-gantt-timeline__canvas--body",
903
+ style: ne({ cursor: Yt.value }),
904
+ onPointerdown: ln,
905
+ onPointermove: on,
906
+ onPointerleave: rn,
907
+ onWheel: He
908
+ }, null, 36)
909
+ ])
910
+ ])
911
+ ], 512));
912
+ }
913
+ });
914
+ export {
915
+ Yn as _
916
+ };