@koyori-app/arc-vue 0.1.0-alpha.6 → 0.1.0-alpha.8
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/README.md +1 -0
- package/dist/GanttChart.vue.d.ts +9 -0
- package/dist/arc-vue.css +1 -1
- package/dist/arc-vue.js +227 -213
- package/dist/arc-vue.umd.cjs +1 -1
- package/dist/canvasFallback.d.ts +8 -0
- package/dist/index.d.ts +1 -1
- package/dist/replayCommands.d.ts +9 -2
- package/dist/types.d.ts +27 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -61,6 +61,7 @@ interface GanttDep {
|
|
|
61
61
|
| `legend` | `'shown' \| 'hidden'` | `'hidden'` leaves the colour legend out (see `loadLegendSpec`). |
|
|
62
62
|
| `backend` | `'svg' \| 'canvas'` | Defaults to `svg`. |
|
|
63
63
|
| `deviceTier` | `'low' \| 'high'` | Overrides the detected device tier (useful for visual tests). |
|
|
64
|
+
| `scrollContainer` | `HTMLElement \| Window` | The caller's scroll area the chart sits in. Given, the chart keeps no scroll area of its own (no `min(70vh, 600px)` cap on a low-tier device): the caller's area scrolls it together with what sits beside it, such as the caller's own task list, and a low-tier chart still draws only the rows inside that area's view. |
|
|
64
65
|
|
|
65
66
|
The `taskClick` event receives the clicked `GanttTask`.
|
|
66
67
|
|
package/dist/GanttChart.vue.d.ts
CHANGED
|
@@ -77,6 +77,15 @@ type __VLS_Props = {
|
|
|
77
77
|
backend?: 'svg' | 'canvas';
|
|
78
78
|
/** Override auto-detected device tier (VRT / Storybook should pin this). */
|
|
79
79
|
deviceTier?: 'low' | 'high';
|
|
80
|
+
/**
|
|
81
|
+
* The caller's scroll area the chart sits in (an element, or `window`), for a
|
|
82
|
+
* chart that scrolls together with something beside it, such as the caller's
|
|
83
|
+
* own task list. Given, the chart keeps no scroll area of its own: it is as
|
|
84
|
+
* tall as its rows, the caller's area scrolls it, and on a low-tier device the
|
|
85
|
+
* rows it draws are the ones inside that area's view. Left out, a low-tier
|
|
86
|
+
* chart scrolls inside its own area of at most `min(70vh, 600px)`, as before.
|
|
87
|
+
*/
|
|
88
|
+
scrollContainer?: HTMLElement | Window | null;
|
|
80
89
|
};
|
|
81
90
|
/** Paints the canvas again, once per frame however often it is asked. */
|
|
82
91
|
declare function repaint(): void;
|
package/dist/arc-vue.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
.koyori-gantt-scroll[data-v-
|
|
1
|
+
.koyori-gantt-scroll[data-v-816db9f8]{width:100%;overflow:auto}.koyori-gantt-scroll--virtual[data-v-816db9f8]{max-height:min(70vh,600px)}.koyori-gantt-inner[data-v-816db9f8]{width:100%;position:relative}.koyori-gantt-error[data-v-816db9f8]{color:#991b1b;padding:12px}.koyori-gantt-svg[data-v-816db9f8]{width:100%;position:absolute;top:0;left:0}.koyori-gantt-canvas[data-v-816db9f8]{display:block;position:absolute;top:0;left:0}.koyori-gantt-svg[data-v-816db9f8] svg{display:block}.koyori-gantt-skeleton[data-v-816db9f8]{--koyori-skeleton-gap:4px;--koyori-skeleton-bar-min-w:8px}.koyori-gantt-skeleton-row[data-v-816db9f8]{height:var(--v73d153a1);align-items:center;gap:var(--koyori-skeleton-gap);display:flex}.koyori-gantt-skeleton-label[data-v-816db9f8]{width:var(--koyori-skeleton-label-w);background:#e5e7eb;border-radius:4px;flex-shrink:0;height:12px}.koyori-gantt-skeleton-bar[data-v-816db9f8]{height:var(--koyori-skeleton-bar-h);min-width:var(--koyori-skeleton-bar-min-w);max-width:calc(100% - var(--koyori-skeleton-label-w) - var(--koyori-skeleton-gap) - var(--koyori-skeleton-bar-min-w));background:#d1d5db;border-radius:4px;animation:1.4s ease-in-out infinite koyori-gantt-shimmer-816db9f8}@keyframes koyori-gantt-shimmer-816db9f8{0%,to{opacity:.6}50%{opacity:1}}
|
|
2
2
|
/*$vite$:1*/
|
package/dist/arc-vue.js
CHANGED
|
@@ -1,33 +1,7 @@
|
|
|
1
1
|
import { Fragment as e, computed as t, createElementBlock as n, createElementVNode as r, defineComponent as i, nextTick as a, normalizeClass as o, normalizeStyle as s, onBeforeUnmount as c, onMounted as l, openBlock as u, ref as d, renderList as ee, toDisplayString as te, useCssVars as ne, watch as f } from "vue";
|
|
2
|
-
import
|
|
2
|
+
import re, { empty_svg_markup as ie, legend_spec_json as ae, render_canvas_commands as oe, render_svg as se, render_svg_error as ce } from "@koyori-app/arc";
|
|
3
3
|
//#region src/replayCommands.ts
|
|
4
|
-
var
|
|
5
|
-
"BarBg",
|
|
6
|
-
"TierLow",
|
|
7
|
-
"TierMid",
|
|
8
|
-
"TierHigh",
|
|
9
|
-
"TierDone",
|
|
10
|
-
"Dep",
|
|
11
|
-
"Progress",
|
|
12
|
-
"Grid",
|
|
13
|
-
"Today",
|
|
14
|
-
"HeaderBg",
|
|
15
|
-
"GridLabel",
|
|
16
|
-
"ProgressTextOnFg",
|
|
17
|
-
"ProgressTextOnBg",
|
|
18
|
-
"GroupRow",
|
|
19
|
-
"Weekend",
|
|
20
|
-
"BarStroke",
|
|
21
|
-
"DoneBg",
|
|
22
|
-
"DoneStroke",
|
|
23
|
-
"WarnBg",
|
|
24
|
-
"WarnStroke",
|
|
25
|
-
"HardDeadline",
|
|
26
|
-
"Note",
|
|
27
|
-
"NoteBg",
|
|
28
|
-
"ProgressLine",
|
|
29
|
-
"DayNumber"
|
|
30
|
-
], le = {
|
|
4
|
+
var le = /* @__PURE__ */ "BarBg.TierLow.TierMid.TierHigh.TierDone.Dep.Progress.Grid.Today.HeaderBg.GridLabel.ProgressTextOnFg.ProgressTextOnBg.GroupRow.Weekend.BarStroke.DoneBg.DoneStroke.WarnBg.WarnStroke.HardDeadline.Note.NoteBg.ProgressLine.DayNumber.DepDone.DepDelayed".split("."), ue = {
|
|
31
5
|
GroupRow: "HeaderBg",
|
|
32
6
|
Weekend: "HeaderBg",
|
|
33
7
|
BarStroke: "GridLabel",
|
|
@@ -38,24 +12,26 @@ var ce = [
|
|
|
38
12
|
HardDeadline: "Progress",
|
|
39
13
|
Note: "GridLabel",
|
|
40
14
|
NoteBg: "HeaderBg",
|
|
41
|
-
ProgressLine: "Progress"
|
|
15
|
+
ProgressLine: "Progress",
|
|
16
|
+
DepDone: "Dep",
|
|
17
|
+
DepDelayed: "Dep"
|
|
42
18
|
};
|
|
43
|
-
function
|
|
19
|
+
function p(e, t) {
|
|
44
20
|
let n = e.palette.colors.find(([e]) => e === t);
|
|
45
21
|
if (n) return n[1];
|
|
46
|
-
let r =
|
|
47
|
-
return r ?
|
|
22
|
+
let r = ue[t];
|
|
23
|
+
return r ? p(e, r) : void 0;
|
|
48
24
|
}
|
|
49
|
-
function
|
|
25
|
+
function de(e, t) {
|
|
50
26
|
let n = /^var\((--[A-Za-z0-9_-]+)\)$/.exec(e);
|
|
51
27
|
return n ? !t || typeof getComputedStyle > "u" ? "#000000" : getComputedStyle(t).getPropertyValue(n[1]).trim() || "#000000" : e;
|
|
52
28
|
}
|
|
53
|
-
function
|
|
29
|
+
function m(e, t, n) {
|
|
54
30
|
if (t === 255) return "#374151";
|
|
55
|
-
let r =
|
|
56
|
-
return r ?
|
|
31
|
+
let r = le[t];
|
|
32
|
+
return r ? de(p(e, r) ?? "#000000", n) : "#000000";
|
|
57
33
|
}
|
|
58
|
-
function
|
|
34
|
+
function h(e, t, n, r, i) {
|
|
59
35
|
if (r <= 0 || i <= 0) return e;
|
|
60
36
|
let a = t + r, o = n + i;
|
|
61
37
|
if (e.w === 0 && e.h === 0) return {
|
|
@@ -72,20 +48,20 @@ function _(e, t, n, r, i) {
|
|
|
72
48
|
h: u - c
|
|
73
49
|
};
|
|
74
50
|
}
|
|
75
|
-
function
|
|
51
|
+
function g(e, t, n, r, i, a) {
|
|
76
52
|
if (a > 0 && typeof e.roundRect == "function") {
|
|
77
53
|
e.beginPath(), e.roundRect(t, n, r, i, a), e.fill();
|
|
78
54
|
return;
|
|
79
55
|
}
|
|
80
56
|
e.fillRect(t, n, r, i);
|
|
81
57
|
}
|
|
82
|
-
function
|
|
83
|
-
if (e.strokeStyle =
|
|
58
|
+
function _(e, t, n, r, i) {
|
|
59
|
+
if (e.strokeStyle = m(t, n, e.canvas), e.lineWidth = r, i) {
|
|
84
60
|
let t = i.split(",").map((e) => Number.parseFloat(e.trim()));
|
|
85
61
|
e.setLineDash(t.every(Number.isFinite) ? t : []);
|
|
86
62
|
} else e.setLineDash([]);
|
|
87
63
|
}
|
|
88
|
-
function
|
|
64
|
+
function fe(e, t) {
|
|
89
65
|
let n = [], r = null, i = {
|
|
90
66
|
x: 0,
|
|
91
67
|
y: 0,
|
|
@@ -120,43 +96,48 @@ function b(e, t) {
|
|
|
120
96
|
}
|
|
121
97
|
if ("FillRect" in a) {
|
|
122
98
|
let { x: n, y: o, w: s, h: c, color_id: l, radius: u } = a.FillRect;
|
|
123
|
-
e.fillStyle =
|
|
99
|
+
e.fillStyle = m(t, l, e.canvas), g(e, n, o, s, c, u), r && (i = h(i, n, o, s, c));
|
|
124
100
|
continue;
|
|
125
101
|
}
|
|
126
102
|
if ("FillPolygon" in a) {
|
|
127
103
|
let { points: n, color_id: o } = a.FillPolygon;
|
|
128
104
|
if (n.length === 0) continue;
|
|
129
|
-
e.fillStyle =
|
|
105
|
+
e.fillStyle = m(t, o, e.canvas), e.beginPath(), e.moveTo(n[0][0], n[0][1]);
|
|
130
106
|
for (let t = 1; t < n.length; t++) e.lineTo(n[t][0], n[t][1]);
|
|
131
107
|
if (e.closePath(), e.fill(), r && n.length > 0) {
|
|
132
108
|
let e = n.map((e) => e[0]), t = n.map((e) => e[1]), r = Math.min(...e), a = Math.min(...t);
|
|
133
|
-
i =
|
|
109
|
+
i = h(i, r, a, Math.max(...e) - r, Math.max(...t) - a);
|
|
134
110
|
}
|
|
135
111
|
continue;
|
|
136
112
|
}
|
|
137
113
|
if ("StrokePath" in a) {
|
|
138
114
|
let { d: n, color_id: r, width: i } = a.StrokePath;
|
|
139
|
-
|
|
115
|
+
_(e, t, r, i, null);
|
|
140
116
|
let o = new Path2D(n);
|
|
141
117
|
e.stroke(o);
|
|
142
118
|
continue;
|
|
143
119
|
}
|
|
120
|
+
if ("StrokeDashedPath" in a) {
|
|
121
|
+
let { d: n, color_id: r, width: i, dash: o } = a.StrokeDashedPath;
|
|
122
|
+
_(e, t, r, i, o), e.stroke(new Path2D(n)), e.setLineDash([]);
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
144
125
|
if ("StrokePolyline" in a) {
|
|
145
126
|
let { points: n, color_id: r, width: i, dash: o } = a.StrokePolyline;
|
|
146
127
|
if (n.length < 2) continue;
|
|
147
|
-
|
|
128
|
+
_(e, t, r, i, o), e.beginPath(), e.moveTo(n[0][0], n[0][1]);
|
|
148
129
|
for (let t = 1; t < n.length; t++) e.lineTo(n[t][0], n[t][1]);
|
|
149
130
|
e.stroke();
|
|
150
131
|
continue;
|
|
151
132
|
}
|
|
152
133
|
if ("DrawText" in a) {
|
|
153
134
|
let { x: n, y: r, text: i, color_id: o, anchor: s, size: c, weight: l } = a.DrawText;
|
|
154
|
-
e.fillStyle =
|
|
135
|
+
e.fillStyle = m(t, o, e.canvas), e.font = `${l} ${c}px sans-serif`, e.textBaseline = "alphabetic", s === 1 ? e.textAlign = "center" : s === 2 ? e.textAlign = "end" : e.textAlign = "start", e.fillText(i, n, r), e.textAlign = "start";
|
|
155
136
|
}
|
|
156
137
|
}
|
|
157
138
|
return { hitRegions: n };
|
|
158
139
|
}
|
|
159
|
-
function
|
|
140
|
+
function pe(e) {
|
|
160
141
|
try {
|
|
161
142
|
return JSON.parse(e);
|
|
162
143
|
} catch {
|
|
@@ -169,7 +150,7 @@ function ue(e) {
|
|
|
169
150
|
};
|
|
170
151
|
}
|
|
171
152
|
}
|
|
172
|
-
function
|
|
153
|
+
function me(e, t, n) {
|
|
173
154
|
for (let r = e.length - 1; r >= 0; r--) {
|
|
174
155
|
let i = e[r];
|
|
175
156
|
if (t >= i.x && t <= i.x + i.w && n >= i.y && n <= i.y + i.h) return i.taskId;
|
|
@@ -178,26 +159,26 @@ function de(e, t, n) {
|
|
|
178
159
|
}
|
|
179
160
|
//#endregion
|
|
180
161
|
//#region src/canvasLifecycle.ts
|
|
181
|
-
function
|
|
162
|
+
function he(e) {
|
|
182
163
|
if (!e) return;
|
|
183
164
|
let t = e.getContext("2d");
|
|
184
165
|
t && t.clearRect(0, 0, e.width, e.height), e.width = 0, e.height = 0, e.style.width = "0px", e.style.height = "0px";
|
|
185
166
|
}
|
|
186
167
|
//#endregion
|
|
187
168
|
//#region src/options.ts
|
|
188
|
-
function
|
|
169
|
+
function ge(e) {
|
|
189
170
|
let t = {};
|
|
190
171
|
return e.today != null && (t.today = e.today), e.scrollViewport != null && (t.scroll_viewport = e.scrollViewport), e.tzOffsetMinutes != null && (t.tz_offset_minutes = Number.isFinite(e.tzOffsetMinutes) ? e.tzOffsetMinutes : String(e.tzOffsetMinutes)), e.legend != null && (t.legend = e.legend), e.rowLabels != null && (t.row_labels = e.rowLabels), e.percentLabels != null && (t.percent_labels = e.percentLabels), e.rowHeightPx != null && (t.row_height_px = e.rowHeightPx), e.headerHeightPx != null && (t.header_height_px = e.headerHeightPx), e.barHeightPx != null && (t.bar_height_px = e.barHeightPx), e.barAlign != null && (t.bar_align = e.barAlign), e.palette != null && (t.palette = e.palette), e.pxPerDay != null && (t.px_per_day = e.pxPerDay), e.scale != null && (t.scale = e.scale), e.weekendDays != null && (t.weekend_days = e.weekendDays), e.weekdayLabels != null && (t.weekday_labels = e.weekdayLabels), e.view != null && (t.view = {
|
|
191
172
|
from: e.view.from,
|
|
192
173
|
to: e.view.to
|
|
193
174
|
}), e.progressLine != null && (t.progress_line = e.progressLine), Object.keys(t).length === 0 ? void 0 : JSON.stringify(t);
|
|
194
175
|
}
|
|
195
|
-
var
|
|
176
|
+
var v = {
|
|
196
177
|
CODE_CANVAS_CAPACITY: "canvas_capacity",
|
|
197
178
|
CODE_INPUT_LIMIT: "input_limit",
|
|
198
179
|
CODE_PARSE_ERROR: "parse_error",
|
|
199
180
|
CODE_SERIALIZE_ERROR: "serialize_error"
|
|
200
|
-
}.CODE_CANVAS_CAPACITY,
|
|
181
|
+
}.CODE_CANVAS_CAPACITY, _e = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"0\" height=\"0\" viewBox=\"0 0 0 0\" role=\"img\" aria-label=\"Empty Gantt chart\" font-family=\"sans-serif\" font-size=\"12\"><title>Empty Gantt chart</title><desc>No tasks to display</desc></svg>", y = {
|
|
201
182
|
ROW_H: 40,
|
|
202
183
|
HEADER_H: 30,
|
|
203
184
|
DAY_SCALE_HEADER_H: 48,
|
|
@@ -206,11 +187,11 @@ var x = {
|
|
|
206
187
|
LABEL_W: 120,
|
|
207
188
|
BAR_H: 20,
|
|
208
189
|
HIDDEN_LABELS_LEFT_PX: 10
|
|
209
|
-
},
|
|
190
|
+
}, b = {
|
|
210
191
|
MAX_CANVAS_SIDE_PX: 16384,
|
|
211
192
|
MAX_CANVAS_AREA_PX: 32 * 1024 * 1024
|
|
212
193
|
};
|
|
213
|
-
function
|
|
194
|
+
function ve(e) {
|
|
214
195
|
try {
|
|
215
196
|
let t = JSON.parse(e);
|
|
216
197
|
return {
|
|
@@ -223,19 +204,19 @@ function he(e) {
|
|
|
223
204
|
}
|
|
224
205
|
//#endregion
|
|
225
206
|
//#region src/canvasScale.ts
|
|
226
|
-
function
|
|
207
|
+
function x(e, t, n) {
|
|
227
208
|
if (!(e > 0) || !(t > 0) || !(n > 0) || !Number.isFinite(n)) return 1;
|
|
228
|
-
let { MAX_CANVAS_SIDE_PX: r, MAX_CANVAS_AREA_PX: i } =
|
|
209
|
+
let { MAX_CANVAS_SIDE_PX: r, MAX_CANVAS_AREA_PX: i } = b, a = Math.min(r / e, r / t, Math.sqrt(i / (e * t)));
|
|
229
210
|
return Math.min(n, a);
|
|
230
211
|
}
|
|
231
|
-
function
|
|
232
|
-
let r =
|
|
212
|
+
function ye(e, t, n) {
|
|
213
|
+
let r = x(e, t, n);
|
|
233
214
|
return {
|
|
234
215
|
width: Math.floor(e * r),
|
|
235
216
|
height: Math.floor(t * r)
|
|
236
217
|
};
|
|
237
218
|
}
|
|
238
|
-
function
|
|
219
|
+
function be(e, t, n, r, i) {
|
|
239
220
|
return !(n.width > 0) || !(n.height > 0) ? null : {
|
|
240
221
|
x: (e - n.left) * (r / n.width),
|
|
241
222
|
y: (t - n.top) * (i / n.height)
|
|
@@ -243,22 +224,22 @@ function _e(e, t, n, r, i) {
|
|
|
243
224
|
}
|
|
244
225
|
//#endregion
|
|
245
226
|
//#region src/canvasFallback.ts
|
|
246
|
-
function
|
|
247
|
-
return e.headerHeight == null ? e.scale === "day" ?
|
|
227
|
+
function S(e = {}) {
|
|
228
|
+
return e.headerHeight == null ? e.scale === "day" ? y.DAY_SCALE_HEADER_H : y.HEADER_H : e.headerHeight;
|
|
248
229
|
}
|
|
249
|
-
function
|
|
230
|
+
function xe(e, t, n = "shown", r = {}) {
|
|
250
231
|
if (t === 0) return 0;
|
|
251
|
-
let i = r.rowHeight ??
|
|
252
|
-
return (e ? e.reduce((e, t) => e + (t.height ?? i), 0) : t * i) +
|
|
232
|
+
let i = r.rowHeight ?? y.ROW_H;
|
|
233
|
+
return (e ? e.reduce((e, t) => e + (t.height ?? i), 0) : t * i) + S(r) + (n === "hidden" ? 0 : y.LEGEND_H) + y.CHART_BOTTOM_PADDING_PX;
|
|
253
234
|
}
|
|
254
|
-
function
|
|
255
|
-
return e.code ===
|
|
235
|
+
function C(e) {
|
|
236
|
+
return e.code === v;
|
|
256
237
|
}
|
|
257
|
-
function
|
|
238
|
+
function w(e, t) {
|
|
258
239
|
return e.startsWith("<svg ") && e !== t;
|
|
259
240
|
}
|
|
260
|
-
function
|
|
261
|
-
return
|
|
241
|
+
function Se(e, t, n) {
|
|
242
|
+
return C(e) && w(t, n) ? {
|
|
262
243
|
mode: "svg",
|
|
263
244
|
svg: t
|
|
264
245
|
} : {
|
|
@@ -266,17 +247,20 @@ function be(e, t, n) {
|
|
|
266
247
|
message: e.message
|
|
267
248
|
};
|
|
268
249
|
}
|
|
269
|
-
function
|
|
270
|
-
let n = (t ??
|
|
271
|
-
return e === "hidden" ? n : Math.max(
|
|
250
|
+
function Ce(e, t) {
|
|
251
|
+
let n = (t ?? y.BAR_H) / 2;
|
|
252
|
+
return e === "hidden" ? n : Math.max(y.LABEL_W, n);
|
|
253
|
+
}
|
|
254
|
+
function we(e, t) {
|
|
255
|
+
return Math.min(e ?? y.BAR_H, t ?? y.ROW_H);
|
|
272
256
|
}
|
|
273
257
|
//#endregion
|
|
274
258
|
//#region src/GanttChart.vue?vue&type=script&setup=true&lang.ts
|
|
275
|
-
var
|
|
259
|
+
var Te = {
|
|
276
260
|
key: 0,
|
|
277
261
|
class: "koyori-gantt-error",
|
|
278
262
|
role: "alert"
|
|
279
|
-
},
|
|
263
|
+
}, Ee = ["innerHTML"], T = /*#__PURE__*/ ((e, t) => {
|
|
280
264
|
let n = e.__vccOpts || e;
|
|
281
265
|
for (let [e, r] of t) n[e] = r;
|
|
282
266
|
return n;
|
|
@@ -303,227 +287,257 @@ var Se = {
|
|
|
303
287
|
view: {},
|
|
304
288
|
progressLine: {},
|
|
305
289
|
backend: {},
|
|
306
|
-
deviceTier: {}
|
|
290
|
+
deviceTier: {},
|
|
291
|
+
scrollContainer: {}
|
|
307
292
|
},
|
|
308
293
|
emits: ["taskClick"],
|
|
309
|
-
setup(i, { expose:
|
|
310
|
-
ne((e) => ({
|
|
311
|
-
|
|
312
|
-
v59c5ef75: h
|
|
313
|
-
}));
|
|
314
|
-
let le = t(() => `${g.rowHeight ?? S.ROW_H}px`), m = t(() => `${xe(g.rowLabels, g.barHeight)}px`), h = `${S.BAR_H}px`, g = i, _ = ce, v = d(!1), y = d(""), x = d(0), C = d(600), w = d(null), T = d(null), E = d([]), D = d(""), O = d(""), k = d(null), A = {
|
|
294
|
+
setup(i, { expose: ae, emit: le }) {
|
|
295
|
+
ne((e) => ({ v73d153a1: ue.value }));
|
|
296
|
+
let ue = t(() => `${m.rowHeight ?? y.ROW_H}px`), p = t(() => `${Ce(m.rowLabels, m.barHeight)}px`), de = t(() => `${we(m.barHeight, m.rowHeight)}px`), m = i, h = le, g = d(!1), _ = d(""), v = d(0), b = d(600), x = d(null), S = d(null), w = d([]), T = d(""), E = d(""), D = d(null), O = {
|
|
315
297
|
width: 0,
|
|
316
298
|
height: 0
|
|
317
|
-
},
|
|
318
|
-
function
|
|
319
|
-
let t = e
|
|
320
|
-
|
|
299
|
+
}, k = d(_e), A = t(() => m.backend === "canvas"), j = t(() => m.scrollContainer ?? null);
|
|
300
|
+
function De(e, t) {
|
|
301
|
+
let n = t.getBoundingClientRect().top, r = typeof window < "u" && e === window, i = r ? 0 : e.getBoundingClientRect().top + e.clientTop, a = r ? window.innerHeight : e.clientHeight;
|
|
302
|
+
return {
|
|
303
|
+
scrollY: Math.max(0, i - n),
|
|
304
|
+
clientHeight: a
|
|
305
|
+
};
|
|
321
306
|
}
|
|
322
|
-
|
|
323
|
-
|
|
307
|
+
function M(e) {
|
|
308
|
+
let t = j.value;
|
|
309
|
+
if (t) {
|
|
310
|
+
if (!x.value) return;
|
|
311
|
+
let e = De(t, x.value);
|
|
312
|
+
v.value = e.scrollY, b.value = e.clientHeight;
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
let n = e ?? x.value;
|
|
316
|
+
n && (v.value = n.scrollTop, b.value = n.clientHeight);
|
|
317
|
+
}
|
|
318
|
+
let N = 0, P = null;
|
|
319
|
+
function F() {
|
|
320
|
+
if (N) return;
|
|
321
|
+
let e = () => {
|
|
322
|
+
N = 0, M();
|
|
323
|
+
};
|
|
324
|
+
typeof requestAnimationFrame == "function" ? N = requestAnimationFrame(e) : e();
|
|
325
|
+
}
|
|
326
|
+
function Oe(e) {
|
|
327
|
+
e?.removeEventListener("scroll", F), e && typeof window < "u" && window.removeEventListener("resize", F), P?.disconnect(), P = null;
|
|
328
|
+
}
|
|
329
|
+
f(j, (e, t) => {
|
|
330
|
+
Oe(t ?? null), e && (e.addEventListener("scroll", F, { passive: !0 }), typeof window < "u" && window.addEventListener("resize", F, { passive: !0 }), !(typeof window < "u" && e === window) && typeof ResizeObserver < "u" && (P = new ResizeObserver(F), P.observe(e)), F());
|
|
331
|
+
}, { immediate: !0 }), c(() => {
|
|
332
|
+
Oe(j.value), N && typeof cancelAnimationFrame == "function" && cancelAnimationFrame(N), N = 0;
|
|
333
|
+
}), l(async () => {
|
|
334
|
+
await re(), k.value = ie(), g.value = !0, await a(), M(), I.value && (L.value = !0);
|
|
324
335
|
});
|
|
325
|
-
function
|
|
326
|
-
if (
|
|
336
|
+
function ke() {
|
|
337
|
+
if (m.deviceTier) return m.deviceTier;
|
|
327
338
|
if (typeof navigator > "u") return "low";
|
|
328
339
|
let e = navigator;
|
|
329
340
|
return e.deviceMemory === void 0 || e.deviceMemory <= 4 || navigator.hardwareConcurrency <= 4 ? "low" : "high";
|
|
330
341
|
}
|
|
331
|
-
let
|
|
332
|
-
f(
|
|
342
|
+
let Ae = t(() => ke()), I = t(() => Ae.value === "low"), L = d(!1);
|
|
343
|
+
f(I, async (e) => {
|
|
333
344
|
if (!e) {
|
|
334
|
-
|
|
345
|
+
L.value = !1;
|
|
335
346
|
return;
|
|
336
347
|
}
|
|
337
|
-
|
|
348
|
+
L.value = !1, await a(), M(), L.value = !0;
|
|
338
349
|
}, { flush: "post" });
|
|
339
|
-
let
|
|
340
|
-
rowHeight:
|
|
341
|
-
headerHeight:
|
|
342
|
-
scale:
|
|
343
|
-
})),
|
|
344
|
-
if (!(!
|
|
345
|
-
scroll_y:
|
|
346
|
-
client_height:
|
|
350
|
+
let je = t(() => V.value ? 0 : xe(m.rows, m.tasks.length, m.legend, {
|
|
351
|
+
rowHeight: m.rowHeight,
|
|
352
|
+
headerHeight: m.headerHeight,
|
|
353
|
+
scale: m.scale
|
|
354
|
+
})), Me = t(() => {
|
|
355
|
+
if (!(!I.value || !L.value)) return {
|
|
356
|
+
scroll_y: v.value,
|
|
357
|
+
client_height: b.value
|
|
347
358
|
};
|
|
348
359
|
});
|
|
349
|
-
function
|
|
350
|
-
return
|
|
351
|
-
today:
|
|
360
|
+
function Ne(e) {
|
|
361
|
+
return ge({
|
|
362
|
+
today: m.today,
|
|
352
363
|
scrollViewport: e,
|
|
353
|
-
tzOffsetMinutes:
|
|
354
|
-
legend:
|
|
355
|
-
rowLabels:
|
|
356
|
-
percentLabels:
|
|
357
|
-
rowHeightPx:
|
|
358
|
-
headerHeightPx:
|
|
359
|
-
barHeightPx:
|
|
360
|
-
barAlign:
|
|
361
|
-
palette:
|
|
362
|
-
pxPerDay:
|
|
363
|
-
scale:
|
|
364
|
-
weekendDays:
|
|
365
|
-
weekdayLabels:
|
|
366
|
-
view:
|
|
367
|
-
progressLine:
|
|
364
|
+
tzOffsetMinutes: m.tzOffsetMinutes,
|
|
365
|
+
legend: m.legend,
|
|
366
|
+
rowLabels: m.rowLabels,
|
|
367
|
+
percentLabels: m.percentLabels,
|
|
368
|
+
rowHeightPx: m.rowHeight,
|
|
369
|
+
headerHeightPx: m.headerHeight,
|
|
370
|
+
barHeightPx: m.barHeight,
|
|
371
|
+
barAlign: m.barAlign,
|
|
372
|
+
palette: m.palette,
|
|
373
|
+
pxPerDay: m.pxPerDay,
|
|
374
|
+
scale: m.scale,
|
|
375
|
+
weekendDays: m.weekendDays,
|
|
376
|
+
weekdayLabels: m.weekdayLabels,
|
|
377
|
+
view: m.view,
|
|
378
|
+
progressLine: m.progressLine
|
|
368
379
|
});
|
|
369
380
|
}
|
|
370
|
-
let
|
|
371
|
-
f(
|
|
372
|
-
e !== null && (
|
|
381
|
+
let R = t(() => Ne(Me.value)), z = t(() => m.rows ? [JSON.stringify(m.rows)] : []), Pe = t(() => I.value && !L.value), Fe = t(() => !g.value || m.tasks.length === 0 || A.value ? "" : Pe.value ? null : se(JSON.stringify(m.tasks), JSON.stringify(m.deps ?? []), R.value, ...z.value)), B = t(() => !g.value || m.tasks.length === 0 || !A.value || Pe.value ? "" : oe(JSON.stringify(m.tasks), JSON.stringify(m.deps ?? []), R.value, ...z.value));
|
|
382
|
+
f(Fe, (e) => {
|
|
383
|
+
e !== null && (_.value = e);
|
|
373
384
|
}, { immediate: !0 });
|
|
374
|
-
let
|
|
375
|
-
if (!
|
|
376
|
-
let e =
|
|
377
|
-
return e ?
|
|
378
|
-
}),
|
|
379
|
-
function
|
|
380
|
-
|
|
385
|
+
let Ie = t(() => {
|
|
386
|
+
if (!g.value || m.tasks.length === 0 || A.value || Fe.value !== k.value) return null;
|
|
387
|
+
let e = ce(JSON.stringify(m.tasks), JSON.stringify(m.deps ?? []), R.value, ...z.value);
|
|
388
|
+
return e ? ve(e) : null;
|
|
389
|
+
}), V = t(() => E.value || Ie.value?.message || "");
|
|
390
|
+
function H(e) {
|
|
391
|
+
w.value = [], he(e);
|
|
381
392
|
}
|
|
382
|
-
function
|
|
383
|
-
|
|
393
|
+
function U() {
|
|
394
|
+
T.value = "", E.value = "", D.value = null;
|
|
384
395
|
}
|
|
385
|
-
function
|
|
386
|
-
|
|
396
|
+
function Le(e) {
|
|
397
|
+
D.value = e;
|
|
387
398
|
let t = "";
|
|
388
|
-
if (
|
|
389
|
-
t =
|
|
390
|
-
scroll_y:
|
|
391
|
-
client_height: Math.min(
|
|
392
|
-
}), ...
|
|
399
|
+
if (C(e)) try {
|
|
400
|
+
t = se(JSON.stringify(m.tasks), JSON.stringify(m.deps ?? []), Ne({
|
|
401
|
+
scroll_y: v.value,
|
|
402
|
+
client_height: j.value ? b.value : Math.min(b.value, 600)
|
|
403
|
+
}), ...z.value);
|
|
393
404
|
} catch {}
|
|
394
|
-
let n =
|
|
395
|
-
n.mode === "svg" ? (
|
|
405
|
+
let n = Se(e, t, k.value);
|
|
406
|
+
n.mode === "svg" ? (T.value = n.svg, E.value = "") : (T.value = "", E.value = n.message);
|
|
396
407
|
}
|
|
397
|
-
f([
|
|
398
|
-
|
|
408
|
+
f([v, b], () => {
|
|
409
|
+
T.value && D.value && Le(D.value);
|
|
399
410
|
});
|
|
400
|
-
async function
|
|
401
|
-
let e =
|
|
411
|
+
async function W() {
|
|
412
|
+
let e = B.value;
|
|
402
413
|
if (!e) {
|
|
403
|
-
|
|
414
|
+
H(S.value), U();
|
|
404
415
|
return;
|
|
405
416
|
}
|
|
406
|
-
let t =
|
|
407
|
-
if (!t && (
|
|
408
|
-
let n =
|
|
417
|
+
let t = S.value;
|
|
418
|
+
if (!t && (U(), await a(), t = S.value, !t)) return;
|
|
419
|
+
let n = pe(e);
|
|
409
420
|
if (n.error) {
|
|
410
|
-
|
|
421
|
+
H(t), Le({
|
|
411
422
|
message: n.error,
|
|
412
423
|
code: n.code
|
|
413
424
|
});
|
|
414
425
|
return;
|
|
415
426
|
}
|
|
416
|
-
|
|
417
|
-
let r = n.viewport_width, i = n.viewport_height, o =
|
|
418
|
-
t.width = o.width, t.height = o.height, t.style.width = `${r}px`, t.style.height = `${i}px`,
|
|
427
|
+
U();
|
|
428
|
+
let r = n.viewport_width, i = n.viewport_height, o = ye(r, i, G.value);
|
|
429
|
+
t.width = o.width, t.height = o.height, t.style.width = `${r}px`, t.style.height = `${i}px`, O = {
|
|
419
430
|
width: r,
|
|
420
431
|
height: i
|
|
421
432
|
};
|
|
422
433
|
let s = t.getContext("2d");
|
|
423
434
|
if (!s) {
|
|
424
|
-
|
|
435
|
+
H(t);
|
|
425
436
|
return;
|
|
426
437
|
}
|
|
427
|
-
r > 0 && i > 0 && s.setTransform(o.width / r, 0, 0, o.height / i, 0, 0),
|
|
438
|
+
r > 0 && i > 0 && s.setTransform(o.width / r, 0, 0, o.height / i, 0, 0), w.value = fe(s, n).hitRegions;
|
|
428
439
|
}
|
|
429
|
-
f(
|
|
430
|
-
a().then(
|
|
440
|
+
f(B, () => {
|
|
441
|
+
a().then(W);
|
|
431
442
|
}, { immediate: !0 });
|
|
432
|
-
let
|
|
433
|
-
function
|
|
443
|
+
let G = d(q()), K = null;
|
|
444
|
+
function q() {
|
|
434
445
|
return typeof window > "u" ? 1 : window.devicePixelRatio || 1;
|
|
435
446
|
}
|
|
436
|
-
function
|
|
437
|
-
|
|
447
|
+
function Re() {
|
|
448
|
+
K?.removeEventListener("change", Be), K = null;
|
|
438
449
|
}
|
|
439
|
-
function
|
|
440
|
-
|
|
450
|
+
function ze() {
|
|
451
|
+
Re(), !(typeof window > "u" || typeof window.matchMedia != "function") && (K = window.matchMedia(`(resolution: ${q()}dppx)`), K.addEventListener("change", Be));
|
|
441
452
|
}
|
|
442
|
-
function
|
|
443
|
-
|
|
453
|
+
function Be() {
|
|
454
|
+
G.value = q(), ze();
|
|
444
455
|
}
|
|
445
|
-
l(
|
|
446
|
-
|
|
456
|
+
l(ze), c(Re), f(G, () => {
|
|
457
|
+
S.value && B.value && W();
|
|
447
458
|
});
|
|
448
|
-
let
|
|
449
|
-
function
|
|
450
|
-
if (
|
|
459
|
+
let J = d(null), Ve = t(() => Object.values(m.palette ?? {}).some((e) => typeof e == "string" && e.includes("var("))), He = t(() => A.value && !T.value && Ve.value), Y = null, X = null, Z = 0;
|
|
460
|
+
function Q() {
|
|
461
|
+
if (Z) return;
|
|
451
462
|
let e = () => {
|
|
452
|
-
|
|
463
|
+
Z = 0, S.value && B.value && W();
|
|
453
464
|
};
|
|
454
|
-
typeof requestAnimationFrame == "function" ?
|
|
465
|
+
typeof requestAnimationFrame == "function" ? Z = requestAnimationFrame(e) : e();
|
|
455
466
|
}
|
|
456
|
-
function
|
|
467
|
+
function Ue(e) {
|
|
457
468
|
return e === "class" || e === "style" || (e?.startsWith("data-") ?? !1);
|
|
458
469
|
}
|
|
459
|
-
function
|
|
460
|
-
|
|
470
|
+
function We() {
|
|
471
|
+
Y?.removeEventListener("change", Q), Y = null, X?.disconnect(), X = null;
|
|
461
472
|
}
|
|
462
473
|
function $() {
|
|
463
|
-
if (
|
|
464
|
-
|
|
465
|
-
e.some((e) =>
|
|
474
|
+
if (We(), !(typeof window > "u" || !He.value) && (typeof window.matchMedia == "function" && (Y = window.matchMedia("(prefers-color-scheme: dark)"), Y.addEventListener("change", Q)), typeof MutationObserver < "u" && J.value)) {
|
|
475
|
+
X = new MutationObserver((e) => {
|
|
476
|
+
e.some((e) => Ue(e.attributeName)) && Q();
|
|
466
477
|
});
|
|
467
|
-
for (let e =
|
|
478
|
+
for (let e = J.value.parentElement; e; e = e.parentElement) X.observe(e, { attributes: !0 });
|
|
468
479
|
}
|
|
469
480
|
}
|
|
470
|
-
l($), f(
|
|
471
|
-
$(),
|
|
481
|
+
l($), f(He, $), f(() => m.palette, () => {
|
|
482
|
+
$(), A.value && Q();
|
|
472
483
|
}), c(() => {
|
|
473
|
-
|
|
474
|
-
}),
|
|
475
|
-
function
|
|
476
|
-
|
|
484
|
+
We(), Z && typeof cancelAnimationFrame == "function" && cancelAnimationFrame(Z), Z = 0;
|
|
485
|
+
}), ae({ repaint: Q });
|
|
486
|
+
function Ge(e) {
|
|
487
|
+
M(e.target);
|
|
477
488
|
}
|
|
478
|
-
function
|
|
489
|
+
function Ke(e) {
|
|
479
490
|
let t = e.target.closest("[data-task-id]");
|
|
480
491
|
if (!t) return;
|
|
481
|
-
let n = t.getAttribute("data-task-id"), r =
|
|
482
|
-
r &&
|
|
492
|
+
let n = t.getAttribute("data-task-id"), r = m.tasks.find((e) => e.id === n);
|
|
493
|
+
r && h("taskClick", r);
|
|
483
494
|
}
|
|
484
|
-
function
|
|
485
|
-
let t =
|
|
495
|
+
function qe(e) {
|
|
496
|
+
let t = S.value;
|
|
486
497
|
if (!t) return;
|
|
487
|
-
let n =
|
|
498
|
+
let n = be(e.clientX, e.clientY, t.getBoundingClientRect(), O.width, O.height);
|
|
488
499
|
if (!n) return;
|
|
489
|
-
let r =
|
|
500
|
+
let r = me(w.value, n.x, n.y);
|
|
490
501
|
if (!r) return;
|
|
491
|
-
let i =
|
|
492
|
-
i &&
|
|
502
|
+
let i = m.tasks.find((e) => e.id === r);
|
|
503
|
+
i && h("taskClick", i);
|
|
493
504
|
}
|
|
494
505
|
return (t, i) => (u(), n("div", {
|
|
495
506
|
ref_key: "rootRef",
|
|
496
|
-
ref:
|
|
507
|
+
ref: J,
|
|
497
508
|
class: "koyori-gantt",
|
|
498
|
-
onClick: i[0] ||= (e) => (!
|
|
499
|
-
}, [
|
|
509
|
+
onClick: i[0] ||= (e) => (!A.value || T.value) && Ke(e)
|
|
510
|
+
}, [g.value ? (u(), n("div", {
|
|
500
511
|
key: 1,
|
|
501
512
|
ref_key: "scrollRef",
|
|
502
|
-
ref:
|
|
503
|
-
class: o(["koyori-gantt-scroll", { "koyori-gantt-scroll--virtual":
|
|
504
|
-
onScroll:
|
|
505
|
-
}, [
|
|
513
|
+
ref: x,
|
|
514
|
+
class: o(["koyori-gantt-scroll", { "koyori-gantt-scroll--virtual": (I.value || D.value) && !j.value }]),
|
|
515
|
+
onScroll: Ge
|
|
516
|
+
}, [V.value ? (u(), n("div", Te, " Unable to render Gantt chart: " + te(V.value), 1)) : (u(), n("div", {
|
|
506
517
|
key: 1,
|
|
507
518
|
class: "koyori-gantt-inner",
|
|
508
|
-
style: s({ height: `${
|
|
509
|
-
}, [
|
|
519
|
+
style: s({ height: `${je.value}px` })
|
|
520
|
+
}, [A.value && !T.value ? (u(), n("canvas", {
|
|
510
521
|
key: 0,
|
|
511
522
|
ref_key: "canvasRef",
|
|
512
|
-
ref:
|
|
523
|
+
ref: S,
|
|
513
524
|
class: "koyori-gantt-canvas",
|
|
514
525
|
role: "img",
|
|
515
526
|
"aria-label": "Gantt chart",
|
|
516
|
-
onClick:
|
|
527
|
+
onClick: qe
|
|
517
528
|
}, null, 512)) : (u(), n("div", {
|
|
518
529
|
key: 1,
|
|
519
530
|
class: "koyori-gantt-svg",
|
|
520
|
-
innerHTML:
|
|
521
|
-
}, null, 8,
|
|
531
|
+
innerHTML: T.value || _.value
|
|
532
|
+
}, null, 8, Ee))], 4))], 34)) : (u(), n("div", {
|
|
522
533
|
key: 0,
|
|
523
534
|
class: "koyori-gantt-skeleton",
|
|
524
|
-
style: s({
|
|
535
|
+
style: s({
|
|
536
|
+
"--koyori-skeleton-label-w": p.value,
|
|
537
|
+
"--koyori-skeleton-bar-h": de.value
|
|
538
|
+
}),
|
|
525
539
|
"aria-hidden": "true"
|
|
526
|
-
}, [(u(!0), n(e, null, ee(
|
|
540
|
+
}, [(u(!0), n(e, null, ee(m.tasks, (e) => (u(), n("div", {
|
|
527
541
|
key: e.id,
|
|
528
542
|
class: "koyori-gantt-skeleton-row"
|
|
529
543
|
}, [i[1] ||= r("div", { class: "koyori-gantt-skeleton-label" }, null, -1), r("div", {
|
|
@@ -531,11 +545,11 @@ var Se = {
|
|
|
531
545
|
style: s({ width: `${e.progress_pct}%` })
|
|
532
546
|
}, null, 4)]))), 128))], 4))], 512));
|
|
533
547
|
}
|
|
534
|
-
}), [["__scopeId", "data-v-
|
|
548
|
+
}), [["__scopeId", "data-v-816db9f8"]]);
|
|
535
549
|
//#endregion
|
|
536
550
|
//#region src/legend.ts
|
|
537
|
-
async function
|
|
538
|
-
return await
|
|
551
|
+
async function E() {
|
|
552
|
+
return await re(), JSON.parse(ae());
|
|
539
553
|
}
|
|
540
554
|
//#endregion
|
|
541
|
-
export {
|
|
555
|
+
export { T as GanttChart, me as findTaskAtPoint, E as loadLegendSpec, pe as parseCommandBuffer, fe as replayCommands };
|
package/dist/arc-vue.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("vue"),require("@koyori-app/arc")):typeof define==`function`&&define.amd?define([`exports`,`vue`,`@koyori-app/arc`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ArcVue={},e.Vue,e.KoyoriArc))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var s=o(t),l=0,u=s.length,d;l<u;l++)d=s[l],!c.call(e,d)&&d!==n&&i(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=a(t,d))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:r(s(e)),l(t||!e||!e.__esModule?i(n,`default`,{value:e,enumerable:!0}):n,e)))(n,1);var u=[`BarBg`,`TierLow`,`TierMid`,`TierHigh`,`TierDone`,`Dep`,`Progress`,`Grid`,`Today`,`HeaderBg`,`GridLabel`,`ProgressTextOnFg`,`ProgressTextOnBg`,`GroupRow`,`Weekend`,`BarStroke`,`DoneBg`,`DoneStroke`,`WarnBg`,`WarnStroke`,`HardDeadline`,`Note`,`NoteBg`,`ProgressLine`,`DayNumber`],d={GroupRow:`HeaderBg`,Weekend:`HeaderBg`,BarStroke:`GridLabel`,DoneBg:`BarBg`,DoneStroke:`GridLabel`,WarnBg:`BarBg`,WarnStroke:`Progress`,HardDeadline:`Progress`,Note:`GridLabel`,NoteBg:`HeaderBg`,ProgressLine:`Progress`};function f(e,t){let n=e.palette.colors.find(([e])=>e===t);if(n)return n[1];let r=d[t];return r?f(e,r):void 0}function p(e,t){let n=/^var\((--[A-Za-z0-9_-]+)\)$/.exec(e);return n?!t||typeof getComputedStyle>`u`?`#000000`:getComputedStyle(t).getPropertyValue(n[1]).trim()||`#000000`:e}function m(e,t,n){if(t===255)return`#374151`;let r=u[t];return r?p(f(e,r)??`#000000`,n):`#000000`}function h(e,t,n,r,i){if(r<=0||i<=0)return e;let a=t+r,o=n+i;if(e.w===0&&e.h===0)return{x:t,y:n,w:r,h:i};let s=Math.min(e.x,t),c=Math.min(e.y,n),l=Math.max(e.x+e.w,a),u=Math.max(e.y+e.h,o);return{x:s,y:c,w:l-s,h:u-c}}function g(e,t,n,r,i,a){if(a>0&&typeof e.roundRect==`function`){e.beginPath(),e.roundRect(t,n,r,i,a),e.fill();return}e.fillRect(t,n,r,i)}function _(e,t,n,r,i){if(e.strokeStyle=m(t,n,e.canvas),e.lineWidth=r,i){let t=i.split(`,`).map(e=>Number.parseFloat(e.trim()));e.setLineDash(t.every(Number.isFinite)?t:[])}else e.setLineDash([])}function ee(e,t){let n=[],r=null,i={x:0,y:0,w:0,h:0};e.clearRect(0,0,t.viewport_width,t.viewport_height);for(let a of t.ops){if(a===`GroupEnd`){r&&i.w>0&&i.h>0&&n.push({taskId:r,x:i.x,y:i.y,w:i.w,h:i.h}),r=null,i={x:0,y:0,w:0,h:0};continue}if(`GroupStart`in a){r=a.GroupStart.task_id,i={x:0,y:0,w:0,h:0};continue}if(`FillRect`in a){let{x:n,y:o,w:s,h:c,color_id:l,radius:u}=a.FillRect;e.fillStyle=m(t,l,e.canvas),g(e,n,o,s,c,u),r&&(i=h(i,n,o,s,c));continue}if(`FillPolygon`in a){let{points:n,color_id:o}=a.FillPolygon;if(n.length===0)continue;e.fillStyle=m(t,o,e.canvas),e.beginPath(),e.moveTo(n[0][0],n[0][1]);for(let t=1;t<n.length;t++)e.lineTo(n[t][0],n[t][1]);if(e.closePath(),e.fill(),r&&n.length>0){let e=n.map(e=>e[0]),t=n.map(e=>e[1]),r=Math.min(...e),a=Math.min(...t);i=h(i,r,a,Math.max(...e)-r,Math.max(...t)-a)}continue}if(`StrokePath`in a){let{d:n,color_id:r,width:i}=a.StrokePath;_(e,t,r,i,null);let o=new Path2D(n);e.stroke(o);continue}if(`StrokePolyline`in a){let{points:n,color_id:r,width:i,dash:o}=a.StrokePolyline;if(n.length<2)continue;_(e,t,r,i,o),e.beginPath(),e.moveTo(n[0][0],n[0][1]);for(let t=1;t<n.length;t++)e.lineTo(n[t][0],n[t][1]);e.stroke();continue}if(`DrawText`in a){let{x:n,y:r,text:i,color_id:o,anchor:s,size:c,weight:l}=a.DrawText;e.fillStyle=m(t,o,e.canvas),e.font=`${l} ${c}px sans-serif`,e.textBaseline=`alphabetic`,s===1?e.textAlign=`center`:s===2?e.textAlign=`end`:e.textAlign=`start`,e.fillText(i,n,r),e.textAlign=`start`}}return{hitRegions:n}}function v(e){try{return JSON.parse(e)}catch{return{viewport_width:0,viewport_height:0,ops:[],palette:{colors:[]},error:`invalid json`}}}function y(e,t,n){for(let r=e.length-1;r>=0;r--){let i=e[r];if(t>=i.x&&t<=i.x+i.w&&n>=i.y&&n<=i.y+i.h)return i.taskId}return null}function te(e){if(!e)return;let t=e.getContext(`2d`);t&&t.clearRect(0,0,e.width,e.height),e.width=0,e.height=0,e.style.width=`0px`,e.style.height=`0px`}function ne(e){let t={};return e.today!=null&&(t.today=e.today),e.scrollViewport!=null&&(t.scroll_viewport=e.scrollViewport),e.tzOffsetMinutes!=null&&(t.tz_offset_minutes=Number.isFinite(e.tzOffsetMinutes)?e.tzOffsetMinutes:String(e.tzOffsetMinutes)),e.legend!=null&&(t.legend=e.legend),e.rowLabels!=null&&(t.row_labels=e.rowLabels),e.percentLabels!=null&&(t.percent_labels=e.percentLabels),e.rowHeightPx!=null&&(t.row_height_px=e.rowHeightPx),e.headerHeightPx!=null&&(t.header_height_px=e.headerHeightPx),e.barHeightPx!=null&&(t.bar_height_px=e.barHeightPx),e.barAlign!=null&&(t.bar_align=e.barAlign),e.palette!=null&&(t.palette=e.palette),e.pxPerDay!=null&&(t.px_per_day=e.pxPerDay),e.scale!=null&&(t.scale=e.scale),e.weekendDays!=null&&(t.weekend_days=e.weekendDays),e.weekdayLabels!=null&&(t.weekday_labels=e.weekdayLabels),e.view!=null&&(t.view={from:e.view.from,to:e.view.to}),e.progressLine!=null&&(t.progress_line=e.progressLine),Object.keys(t).length===0?void 0:JSON.stringify(t)}var b={CODE_CANVAS_CAPACITY:`canvas_capacity`,CODE_INPUT_LIMIT:`input_limit`,CODE_PARSE_ERROR:`parse_error`,CODE_SERIALIZE_ERROR:`serialize_error`}.CODE_CANVAS_CAPACITY,re=`<svg xmlns="http://www.w3.org/2000/svg" width="0" height="0" viewBox="0 0 0 0" role="img" aria-label="Empty Gantt chart" font-family="sans-serif" font-size="12"><title>Empty Gantt chart</title><desc>No tasks to display</desc></svg>`,x={ROW_H:40,HEADER_H:30,DAY_SCALE_HEADER_H:48,LEGEND_H:40,CHART_BOTTOM_PADDING_PX:10,LABEL_W:120,BAR_H:20,HIDDEN_LABELS_LEFT_PX:10},S={MAX_CANVAS_SIDE_PX:16384,MAX_CANVAS_AREA_PX:32*1024*1024};function ie(e){try{let t=JSON.parse(e);return{message:typeof t.error==`string`?t.error:e,code:typeof t.code==`string`?t.code:void 0}}catch{return{message:e}}}function C(e,t,n){if(!(e>0)||!(t>0)||!(n>0)||!Number.isFinite(n))return 1;let{MAX_CANVAS_SIDE_PX:r,MAX_CANVAS_AREA_PX:i}=S,a=Math.min(r/e,r/t,Math.sqrt(i/(e*t)));return Math.min(n,a)}function ae(e,t,n){let r=C(e,t,n);return{width:Math.floor(e*r),height:Math.floor(t*r)}}function oe(e,t,n,r,i){return!(n.width>0)||!(n.height>0)?null:{x:(e-n.left)*(r/n.width),y:(t-n.top)*(i/n.height)}}function w(e={}){return e.headerHeight==null?e.scale===`day`?x.DAY_SCALE_HEADER_H:x.HEADER_H:e.headerHeight}function se(e,t,n=`shown`,r={}){if(t===0)return 0;let i=r.rowHeight??x.ROW_H;return(e?e.reduce((e,t)=>e+(t.height??i),0):t*i)+w(r)+(n===`hidden`?0:x.LEGEND_H)+x.CHART_BOTTOM_PADDING_PX}function T(e){return e.code===b}function E(e,t){return e.startsWith(`<svg `)&&e!==t}function ce(e,t,n){return T(e)&&E(t,n)?{mode:`svg`,svg:t}:{mode:`error`,message:e.message}}function le(e,t){let n=(t??x.BAR_H)/2;return e===`hidden`?n:Math.max(x.LABEL_W,n)}var ue={key:0,class:`koyori-gantt-error`,role:`alert`},de=[`innerHTML`],D=((e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n})((0,t.defineComponent)({__name:`GanttChart`,props:{tasks:{},deps:{},today:{},tzOffsetMinutes:{},legend:{},rowLabels:{},percentLabels:{},rows:{},rowHeight:{},headerHeight:{},barHeight:{},barAlign:{},palette:{},pxPerDay:{},scale:{},weekendDays:{},weekdayLabels:{},view:{},progressLine:{},backend:{},deviceTier:{}},emits:[`taskClick`],setup(e,{expose:r,emit:i}){(0,t.useCssVars)(e=>({v59cd6a8e:a.value,v59c5ef75:s}));let a=(0,t.computed)(()=>`${c.rowHeight??x.ROW_H}px`),o=(0,t.computed)(()=>`${le(c.rowLabels,c.barHeight)}px`),s=`${x.BAR_H}px`,c=e,l=i,u=(0,t.ref)(!1),d=(0,t.ref)(``),f=(0,t.ref)(0),p=(0,t.ref)(600),m=(0,t.ref)(null),h=(0,t.ref)(null),g=(0,t.ref)([]),_=(0,t.ref)(``),b=(0,t.ref)(``),S=(0,t.ref)(null),C={width:0,height:0},w=(0,t.ref)(re),E=(0,t.computed)(()=>c.backend===`canvas`);function D(e){let t=e??m.value;t&&(f.value=t.scrollTop,p.value=t.clientHeight)}(0,t.onMounted)(async()=>{await(0,n.default)(),w.value=(0,n.empty_svg_markup)(),u.value=!0,await(0,t.nextTick)(),D(),O.value&&(k.value=!0)});function fe(){if(c.deviceTier)return c.deviceTier;if(typeof navigator>`u`)return`low`;let e=navigator;return e.deviceMemory===void 0||e.deviceMemory<=4||navigator.hardwareConcurrency<=4?`low`:`high`}let pe=(0,t.computed)(()=>fe()),O=(0,t.computed)(()=>pe.value===`low`),k=(0,t.ref)(!1);(0,t.watch)(O,async e=>{if(!e){k.value=!1;return}k.value=!1,await(0,t.nextTick)(),D(),k.value=!0},{flush:`post`});let me=(0,t.computed)(()=>I.value?0:se(c.rows,c.tasks.length,c.legend,{rowHeight:c.rowHeight,headerHeight:c.headerHeight,scale:c.scale})),he=(0,t.computed)(()=>{if(!(!O.value||!k.value))return{scroll_y:f.value,client_height:p.value}});function A(e){return ne({today:c.today,scrollViewport:e,tzOffsetMinutes:c.tzOffsetMinutes,legend:c.legend,rowLabels:c.rowLabels,percentLabels:c.percentLabels,rowHeightPx:c.rowHeight,headerHeightPx:c.headerHeight,barHeightPx:c.barHeight,barAlign:c.barAlign,palette:c.palette,pxPerDay:c.pxPerDay,scale:c.scale,weekendDays:c.weekendDays,weekdayLabels:c.weekdayLabels,view:c.view,progressLine:c.progressLine})}let j=(0,t.computed)(()=>A(he.value)),M=(0,t.computed)(()=>c.rows?[JSON.stringify(c.rows)]:[]),N=(0,t.computed)(()=>O.value&&!k.value),P=(0,t.computed)(()=>!u.value||c.tasks.length===0||E.value?``:N.value?null:(0,n.render_svg)(JSON.stringify(c.tasks),JSON.stringify(c.deps??[]),j.value,...M.value)),F=(0,t.computed)(()=>!u.value||c.tasks.length===0||!E.value||N.value?``:(0,n.render_canvas_commands)(JSON.stringify(c.tasks),JSON.stringify(c.deps??[]),j.value,...M.value));(0,t.watch)(P,e=>{e!==null&&(d.value=e)},{immediate:!0});let ge=(0,t.computed)(()=>{if(!u.value||c.tasks.length===0||E.value||P.value!==w.value)return null;let e=(0,n.render_svg_error)(JSON.stringify(c.tasks),JSON.stringify(c.deps??[]),j.value,...M.value);return e?ie(e):null}),I=(0,t.computed)(()=>b.value||ge.value?.message||``);function L(e){g.value=[],te(e)}function R(){_.value=``,b.value=``,S.value=null}function z(e){S.value=e;let t=``;if(T(e))try{t=(0,n.render_svg)(JSON.stringify(c.tasks),JSON.stringify(c.deps??[]),A({scroll_y:f.value,client_height:Math.min(p.value,600)}),...M.value)}catch{}let r=ce(e,t,w.value);r.mode===`svg`?(_.value=r.svg,b.value=``):(_.value=``,b.value=r.message)}(0,t.watch)([f,p],()=>{_.value&&S.value&&z(S.value)});async function B(){let e=F.value;if(!e){L(h.value),R();return}let n=h.value;if(!n&&(R(),await(0,t.nextTick)(),n=h.value,!n))return;let r=v(e);if(r.error){L(n),z({message:r.error,code:r.code});return}R();let i=r.viewport_width,a=r.viewport_height,o=ae(i,a,V.value);n.width=o.width,n.height=o.height,n.style.width=`${i}px`,n.style.height=`${a}px`,C={width:i,height:a};let s=n.getContext(`2d`);if(!s){L(n);return}i>0&&a>0&&s.setTransform(o.width/i,0,0,o.height/a,0,0),g.value=ee(s,r).hitRegions}(0,t.watch)(F,()=>{(0,t.nextTick)().then(B)},{immediate:!0});let V=(0,t.ref)(U()),H=null;function U(){return typeof window>`u`?1:window.devicePixelRatio||1}function W(){H?.removeEventListener(`change`,K),H=null}function G(){W(),!(typeof window>`u`||typeof window.matchMedia!=`function`)&&(H=window.matchMedia(`(resolution: ${U()}dppx)`),H.addEventListener(`change`,K))}function K(){V.value=U(),G()}(0,t.onMounted)(G),(0,t.onBeforeUnmount)(W),(0,t.watch)(V,()=>{h.value&&F.value&&B()});let q=(0,t.ref)(null),_e=(0,t.computed)(()=>Object.values(c.palette??{}).some(e=>typeof e==`string`&&e.includes(`var(`))),ve=(0,t.computed)(()=>E.value&&!_.value&&_e.value),J=null,Y=null,X=0;function Z(){if(X)return;let e=()=>{X=0,h.value&&F.value&&B()};typeof requestAnimationFrame==`function`?X=requestAnimationFrame(e):e()}function ye(e){return e===`class`||e===`style`||(e?.startsWith(`data-`)??!1)}function Q(){J?.removeEventListener(`change`,Z),J=null,Y?.disconnect(),Y=null}function $(){if(Q(),!(typeof window>`u`||!ve.value)&&(typeof window.matchMedia==`function`&&(J=window.matchMedia(`(prefers-color-scheme: dark)`),J.addEventListener(`change`,Z)),typeof MutationObserver<`u`&&q.value)){Y=new MutationObserver(e=>{e.some(e=>ye(e.attributeName))&&Z()});for(let e=q.value.parentElement;e;e=e.parentElement)Y.observe(e,{attributes:!0})}}(0,t.onMounted)($),(0,t.watch)(ve,$),(0,t.watch)(()=>c.palette,()=>{$(),E.value&&Z()}),(0,t.onBeforeUnmount)(()=>{Q(),X&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(X),X=0}),r({repaint:Z});function be(e){D(e.target)}function xe(e){let t=e.target.closest(`[data-task-id]`);if(!t)return;let n=t.getAttribute(`data-task-id`),r=c.tasks.find(e=>e.id===n);r&&l(`taskClick`,r)}function Se(e){let t=h.value;if(!t)return;let n=oe(e.clientX,e.clientY,t.getBoundingClientRect(),C.width,C.height);if(!n)return;let r=y(g.value,n.x,n.y);if(!r)return;let i=c.tasks.find(e=>e.id===r);i&&l(`taskClick`,i)}return(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{ref_key:`rootRef`,ref:q,class:`koyori-gantt`,onClick:n[0]||=e=>(!E.value||_.value)&&xe(e)},[u.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:1,ref_key:`scrollRef`,ref:m,class:(0,t.normalizeClass)([`koyori-gantt-scroll`,{"koyori-gantt-scroll--virtual":O.value||S.value}]),onScroll:be},[I.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,ue,` Unable to render Gantt chart: `+(0,t.toDisplayString)(I.value),1)):((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:1,class:`koyori-gantt-inner`,style:(0,t.normalizeStyle)({height:`${me.value}px`})},[E.value&&!_.value?((0,t.openBlock)(),(0,t.createElementBlock)(`canvas`,{key:0,ref_key:`canvasRef`,ref:h,class:`koyori-gantt-canvas`,role:`img`,"aria-label":`Gantt chart`,onClick:Se},null,512)):((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:1,class:`koyori-gantt-svg`,innerHTML:_.value||d.value},null,8,de))],4))],34)):((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:0,class:`koyori-gantt-skeleton`,style:(0,t.normalizeStyle)({"--koyori-skeleton-label-w":o.value}),"aria-hidden":`true`},[((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(c.tasks,e=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:e.id,class:`koyori-gantt-skeleton-row`},[n[1]||=(0,t.createElementVNode)(`div`,{class:`koyori-gantt-skeleton-label`},null,-1),(0,t.createElementVNode)(`div`,{class:`koyori-gantt-skeleton-bar`,style:(0,t.normalizeStyle)({width:`${e.progress_pct}%`})},null,4)]))),128))],4))],512))}}),[[`__scopeId`,`data-v-05f0ec3c`]]);async function fe(){return await(0,n.default)(),JSON.parse((0,n.legend_spec_json)())}e.GanttChart=D,e.findTaskAtPoint=y,e.loadLegendSpec=fe,e.parseCommandBuffer=v,e.replayCommands=ee});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("vue"),require("@koyori-app/arc")):typeof define==`function`&&define.amd?define([`exports`,`vue`,`@koyori-app/arc`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ArcVue={},e.Vue,e.KoyoriArc))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var s=o(t),l=0,u=s.length,d;l<u;l++)d=s[l],!c.call(e,d)&&d!==n&&i(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=a(t,d))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:r(s(e)),l(t||!e||!e.__esModule?i(n,`default`,{value:e,enumerable:!0}):n,e)))(n,1);var u=`BarBg.TierLow.TierMid.TierHigh.TierDone.Dep.Progress.Grid.Today.HeaderBg.GridLabel.ProgressTextOnFg.ProgressTextOnBg.GroupRow.Weekend.BarStroke.DoneBg.DoneStroke.WarnBg.WarnStroke.HardDeadline.Note.NoteBg.ProgressLine.DayNumber.DepDone.DepDelayed`.split(`.`),d={GroupRow:`HeaderBg`,Weekend:`HeaderBg`,BarStroke:`GridLabel`,DoneBg:`BarBg`,DoneStroke:`GridLabel`,WarnBg:`BarBg`,WarnStroke:`Progress`,HardDeadline:`Progress`,Note:`GridLabel`,NoteBg:`HeaderBg`,ProgressLine:`Progress`,DepDone:`Dep`,DepDelayed:`Dep`};function f(e,t){let n=e.palette.colors.find(([e])=>e===t);if(n)return n[1];let r=d[t];return r?f(e,r):void 0}function p(e,t){let n=/^var\((--[A-Za-z0-9_-]+)\)$/.exec(e);return n?!t||typeof getComputedStyle>`u`?`#000000`:getComputedStyle(t).getPropertyValue(n[1]).trim()||`#000000`:e}function m(e,t,n){if(t===255)return`#374151`;let r=u[t];return r?p(f(e,r)??`#000000`,n):`#000000`}function h(e,t,n,r,i){if(r<=0||i<=0)return e;let a=t+r,o=n+i;if(e.w===0&&e.h===0)return{x:t,y:n,w:r,h:i};let s=Math.min(e.x,t),c=Math.min(e.y,n),l=Math.max(e.x+e.w,a),u=Math.max(e.y+e.h,o);return{x:s,y:c,w:l-s,h:u-c}}function g(e,t,n,r,i,a){if(a>0&&typeof e.roundRect==`function`){e.beginPath(),e.roundRect(t,n,r,i,a),e.fill();return}e.fillRect(t,n,r,i)}function _(e,t,n,r,i){if(e.strokeStyle=m(t,n,e.canvas),e.lineWidth=r,i){let t=i.split(`,`).map(e=>Number.parseFloat(e.trim()));e.setLineDash(t.every(Number.isFinite)?t:[])}else e.setLineDash([])}function v(e,t){let n=[],r=null,i={x:0,y:0,w:0,h:0};e.clearRect(0,0,t.viewport_width,t.viewport_height);for(let a of t.ops){if(a===`GroupEnd`){r&&i.w>0&&i.h>0&&n.push({taskId:r,x:i.x,y:i.y,w:i.w,h:i.h}),r=null,i={x:0,y:0,w:0,h:0};continue}if(`GroupStart`in a){r=a.GroupStart.task_id,i={x:0,y:0,w:0,h:0};continue}if(`FillRect`in a){let{x:n,y:o,w:s,h:c,color_id:l,radius:u}=a.FillRect;e.fillStyle=m(t,l,e.canvas),g(e,n,o,s,c,u),r&&(i=h(i,n,o,s,c));continue}if(`FillPolygon`in a){let{points:n,color_id:o}=a.FillPolygon;if(n.length===0)continue;e.fillStyle=m(t,o,e.canvas),e.beginPath(),e.moveTo(n[0][0],n[0][1]);for(let t=1;t<n.length;t++)e.lineTo(n[t][0],n[t][1]);if(e.closePath(),e.fill(),r&&n.length>0){let e=n.map(e=>e[0]),t=n.map(e=>e[1]),r=Math.min(...e),a=Math.min(...t);i=h(i,r,a,Math.max(...e)-r,Math.max(...t)-a)}continue}if(`StrokePath`in a){let{d:n,color_id:r,width:i}=a.StrokePath;_(e,t,r,i,null);let o=new Path2D(n);e.stroke(o);continue}if(`StrokeDashedPath`in a){let{d:n,color_id:r,width:i,dash:o}=a.StrokeDashedPath;_(e,t,r,i,o),e.stroke(new Path2D(n)),e.setLineDash([]);continue}if(`StrokePolyline`in a){let{points:n,color_id:r,width:i,dash:o}=a.StrokePolyline;if(n.length<2)continue;_(e,t,r,i,o),e.beginPath(),e.moveTo(n[0][0],n[0][1]);for(let t=1;t<n.length;t++)e.lineTo(n[t][0],n[t][1]);e.stroke();continue}if(`DrawText`in a){let{x:n,y:r,text:i,color_id:o,anchor:s,size:c,weight:l}=a.DrawText;e.fillStyle=m(t,o,e.canvas),e.font=`${l} ${c}px sans-serif`,e.textBaseline=`alphabetic`,s===1?e.textAlign=`center`:s===2?e.textAlign=`end`:e.textAlign=`start`,e.fillText(i,n,r),e.textAlign=`start`}}return{hitRegions:n}}function ee(e){try{return JSON.parse(e)}catch{return{viewport_width:0,viewport_height:0,ops:[],palette:{colors:[]},error:`invalid json`}}}function te(e,t,n){for(let r=e.length-1;r>=0;r--){let i=e[r];if(t>=i.x&&t<=i.x+i.w&&n>=i.y&&n<=i.y+i.h)return i.taskId}return null}function ne(e){if(!e)return;let t=e.getContext(`2d`);t&&t.clearRect(0,0,e.width,e.height),e.width=0,e.height=0,e.style.width=`0px`,e.style.height=`0px`}function re(e){let t={};return e.today!=null&&(t.today=e.today),e.scrollViewport!=null&&(t.scroll_viewport=e.scrollViewport),e.tzOffsetMinutes!=null&&(t.tz_offset_minutes=Number.isFinite(e.tzOffsetMinutes)?e.tzOffsetMinutes:String(e.tzOffsetMinutes)),e.legend!=null&&(t.legend=e.legend),e.rowLabels!=null&&(t.row_labels=e.rowLabels),e.percentLabels!=null&&(t.percent_labels=e.percentLabels),e.rowHeightPx!=null&&(t.row_height_px=e.rowHeightPx),e.headerHeightPx!=null&&(t.header_height_px=e.headerHeightPx),e.barHeightPx!=null&&(t.bar_height_px=e.barHeightPx),e.barAlign!=null&&(t.bar_align=e.barAlign),e.palette!=null&&(t.palette=e.palette),e.pxPerDay!=null&&(t.px_per_day=e.pxPerDay),e.scale!=null&&(t.scale=e.scale),e.weekendDays!=null&&(t.weekend_days=e.weekendDays),e.weekdayLabels!=null&&(t.weekday_labels=e.weekdayLabels),e.view!=null&&(t.view={from:e.view.from,to:e.view.to}),e.progressLine!=null&&(t.progress_line=e.progressLine),Object.keys(t).length===0?void 0:JSON.stringify(t)}var y={CODE_CANVAS_CAPACITY:`canvas_capacity`,CODE_INPUT_LIMIT:`input_limit`,CODE_PARSE_ERROR:`parse_error`,CODE_SERIALIZE_ERROR:`serialize_error`}.CODE_CANVAS_CAPACITY,ie=`<svg xmlns="http://www.w3.org/2000/svg" width="0" height="0" viewBox="0 0 0 0" role="img" aria-label="Empty Gantt chart" font-family="sans-serif" font-size="12"><title>Empty Gantt chart</title><desc>No tasks to display</desc></svg>`,b={ROW_H:40,HEADER_H:30,DAY_SCALE_HEADER_H:48,LEGEND_H:40,CHART_BOTTOM_PADDING_PX:10,LABEL_W:120,BAR_H:20,HIDDEN_LABELS_LEFT_PX:10},x={MAX_CANVAS_SIDE_PX:16384,MAX_CANVAS_AREA_PX:32*1024*1024};function ae(e){try{let t=JSON.parse(e);return{message:typeof t.error==`string`?t.error:e,code:typeof t.code==`string`?t.code:void 0}}catch{return{message:e}}}function S(e,t,n){if(!(e>0)||!(t>0)||!(n>0)||!Number.isFinite(n))return 1;let{MAX_CANVAS_SIDE_PX:r,MAX_CANVAS_AREA_PX:i}=x,a=Math.min(r/e,r/t,Math.sqrt(i/(e*t)));return Math.min(n,a)}function oe(e,t,n){let r=S(e,t,n);return{width:Math.floor(e*r),height:Math.floor(t*r)}}function se(e,t,n,r,i){return!(n.width>0)||!(n.height>0)?null:{x:(e-n.left)*(r/n.width),y:(t-n.top)*(i/n.height)}}function C(e={}){return e.headerHeight==null?e.scale===`day`?b.DAY_SCALE_HEADER_H:b.HEADER_H:e.headerHeight}function ce(e,t,n=`shown`,r={}){if(t===0)return 0;let i=r.rowHeight??b.ROW_H;return(e?e.reduce((e,t)=>e+(t.height??i),0):t*i)+C(r)+(n===`hidden`?0:b.LEGEND_H)+b.CHART_BOTTOM_PADDING_PX}function le(e){return e.code===y}function w(e,t){return e.startsWith(`<svg `)&&e!==t}function ue(e,t,n){return le(e)&&w(t,n)?{mode:`svg`,svg:t}:{mode:`error`,message:e.message}}function de(e,t){let n=(t??b.BAR_H)/2;return e===`hidden`?n:Math.max(b.LABEL_W,n)}function fe(e,t){return Math.min(e??b.BAR_H,t??b.ROW_H)}var pe={key:0,class:`koyori-gantt-error`,role:`alert`},me=[`innerHTML`],T=((e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n})((0,t.defineComponent)({__name:`GanttChart`,props:{tasks:{},deps:{},today:{},tzOffsetMinutes:{},legend:{},rowLabels:{},percentLabels:{},rows:{},rowHeight:{},headerHeight:{},barHeight:{},barAlign:{},palette:{},pxPerDay:{},scale:{},weekendDays:{},weekdayLabels:{},view:{},progressLine:{},backend:{},deviceTier:{},scrollContainer:{}},emits:[`taskClick`],setup(e,{expose:r,emit:i}){(0,t.useCssVars)(e=>({v73d153a1:a.value}));let a=(0,t.computed)(()=>`${c.rowHeight??b.ROW_H}px`),o=(0,t.computed)(()=>`${de(c.rowLabels,c.barHeight)}px`),s=(0,t.computed)(()=>`${fe(c.barHeight,c.rowHeight)}px`),c=e,l=i,u=(0,t.ref)(!1),d=(0,t.ref)(``),f=(0,t.ref)(0),p=(0,t.ref)(600),m=(0,t.ref)(null),h=(0,t.ref)(null),g=(0,t.ref)([]),_=(0,t.ref)(``),y=(0,t.ref)(``),x=(0,t.ref)(null),S={width:0,height:0},C=(0,t.ref)(ie),w=(0,t.computed)(()=>c.backend===`canvas`),T=(0,t.computed)(()=>c.scrollContainer??null);function E(e,t){let n=t.getBoundingClientRect().top,r=typeof window<`u`&&e===window,i=r?0:e.getBoundingClientRect().top+e.clientTop,a=r?window.innerHeight:e.clientHeight;return{scrollY:Math.max(0,i-n),clientHeight:a}}function D(e){let t=T.value;if(t){if(!m.value)return;let e=E(t,m.value);f.value=e.scrollY,p.value=e.clientHeight;return}let n=e??m.value;n&&(f.value=n.scrollTop,p.value=n.clientHeight)}let O=0,k=null;function A(){if(O)return;let e=()=>{O=0,D()};typeof requestAnimationFrame==`function`?O=requestAnimationFrame(e):e()}function he(e){e?.removeEventListener(`scroll`,A),e&&typeof window<`u`&&window.removeEventListener(`resize`,A),k?.disconnect(),k=null}(0,t.watch)(T,(e,t)=>{he(t??null),e&&(e.addEventListener(`scroll`,A,{passive:!0}),typeof window<`u`&&window.addEventListener(`resize`,A,{passive:!0}),!(typeof window<`u`&&e===window)&&typeof ResizeObserver<`u`&&(k=new ResizeObserver(A),k.observe(e)),A())},{immediate:!0}),(0,t.onBeforeUnmount)(()=>{he(T.value),O&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(O),O=0}),(0,t.onMounted)(async()=>{await(0,n.default)(),C.value=(0,n.empty_svg_markup)(),u.value=!0,await(0,t.nextTick)(),D(),j.value&&(M.value=!0)});function ge(){if(c.deviceTier)return c.deviceTier;if(typeof navigator>`u`)return`low`;let e=navigator;return e.deviceMemory===void 0||e.deviceMemory<=4||navigator.hardwareConcurrency<=4?`low`:`high`}let _e=(0,t.computed)(()=>ge()),j=(0,t.computed)(()=>_e.value===`low`),M=(0,t.ref)(!1);(0,t.watch)(j,async e=>{if(!e){M.value=!1;return}M.value=!1,await(0,t.nextTick)(),D(),M.value=!0},{flush:`post`});let ve=(0,t.computed)(()=>z.value?0:ce(c.rows,c.tasks.length,c.legend,{rowHeight:c.rowHeight,headerHeight:c.headerHeight,scale:c.scale})),ye=(0,t.computed)(()=>{if(!(!j.value||!M.value))return{scroll_y:f.value,client_height:p.value}});function N(e){return re({today:c.today,scrollViewport:e,tzOffsetMinutes:c.tzOffsetMinutes,legend:c.legend,rowLabels:c.rowLabels,percentLabels:c.percentLabels,rowHeightPx:c.rowHeight,headerHeightPx:c.headerHeight,barHeightPx:c.barHeight,barAlign:c.barAlign,palette:c.palette,pxPerDay:c.pxPerDay,scale:c.scale,weekendDays:c.weekendDays,weekdayLabels:c.weekdayLabels,view:c.view,progressLine:c.progressLine})}let P=(0,t.computed)(()=>N(ye.value)),F=(0,t.computed)(()=>c.rows?[JSON.stringify(c.rows)]:[]),I=(0,t.computed)(()=>j.value&&!M.value),L=(0,t.computed)(()=>!u.value||c.tasks.length===0||w.value?``:I.value?null:(0,n.render_svg)(JSON.stringify(c.tasks),JSON.stringify(c.deps??[]),P.value,...F.value)),R=(0,t.computed)(()=>!u.value||c.tasks.length===0||!w.value||I.value?``:(0,n.render_canvas_commands)(JSON.stringify(c.tasks),JSON.stringify(c.deps??[]),P.value,...F.value));(0,t.watch)(L,e=>{e!==null&&(d.value=e)},{immediate:!0});let be=(0,t.computed)(()=>{if(!u.value||c.tasks.length===0||w.value||L.value!==C.value)return null;let e=(0,n.render_svg_error)(JSON.stringify(c.tasks),JSON.stringify(c.deps??[]),P.value,...F.value);return e?ae(e):null}),z=(0,t.computed)(()=>y.value||be.value?.message||``);function B(e){g.value=[],ne(e)}function V(){_.value=``,y.value=``,x.value=null}function H(e){x.value=e;let t=``;if(le(e))try{t=(0,n.render_svg)(JSON.stringify(c.tasks),JSON.stringify(c.deps??[]),N({scroll_y:f.value,client_height:T.value?p.value:Math.min(p.value,600)}),...F.value)}catch{}let r=ue(e,t,C.value);r.mode===`svg`?(_.value=r.svg,y.value=``):(_.value=``,y.value=r.message)}(0,t.watch)([f,p],()=>{_.value&&x.value&&H(x.value)});async function U(){let e=R.value;if(!e){B(h.value),V();return}let n=h.value;if(!n&&(V(),await(0,t.nextTick)(),n=h.value,!n))return;let r=ee(e);if(r.error){B(n),H({message:r.error,code:r.code});return}V();let i=r.viewport_width,a=r.viewport_height,o=oe(i,a,W.value);n.width=o.width,n.height=o.height,n.style.width=`${i}px`,n.style.height=`${a}px`,S={width:i,height:a};let s=n.getContext(`2d`);if(!s){B(n);return}i>0&&a>0&&s.setTransform(o.width/i,0,0,o.height/a,0,0),g.value=v(s,r).hitRegions}(0,t.watch)(R,()=>{(0,t.nextTick)().then(U)},{immediate:!0});let W=(0,t.ref)(K()),G=null;function K(){return typeof window>`u`?1:window.devicePixelRatio||1}function xe(){G?.removeEventListener(`change`,Ce),G=null}function Se(){xe(),!(typeof window>`u`||typeof window.matchMedia!=`function`)&&(G=window.matchMedia(`(resolution: ${K()}dppx)`),G.addEventListener(`change`,Ce))}function Ce(){W.value=K(),Se()}(0,t.onMounted)(Se),(0,t.onBeforeUnmount)(xe),(0,t.watch)(W,()=>{h.value&&R.value&&U()});let q=(0,t.ref)(null),we=(0,t.computed)(()=>Object.values(c.palette??{}).some(e=>typeof e==`string`&&e.includes(`var(`))),Te=(0,t.computed)(()=>w.value&&!_.value&&we.value),J=null,Y=null,X=0;function Z(){if(X)return;let e=()=>{X=0,h.value&&R.value&&U()};typeof requestAnimationFrame==`function`?X=requestAnimationFrame(e):e()}function Ee(e){return e===`class`||e===`style`||(e?.startsWith(`data-`)??!1)}function Q(){J?.removeEventListener(`change`,Z),J=null,Y?.disconnect(),Y=null}function $(){if(Q(),!(typeof window>`u`||!Te.value)&&(typeof window.matchMedia==`function`&&(J=window.matchMedia(`(prefers-color-scheme: dark)`),J.addEventListener(`change`,Z)),typeof MutationObserver<`u`&&q.value)){Y=new MutationObserver(e=>{e.some(e=>Ee(e.attributeName))&&Z()});for(let e=q.value.parentElement;e;e=e.parentElement)Y.observe(e,{attributes:!0})}}(0,t.onMounted)($),(0,t.watch)(Te,$),(0,t.watch)(()=>c.palette,()=>{$(),w.value&&Z()}),(0,t.onBeforeUnmount)(()=>{Q(),X&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(X),X=0}),r({repaint:Z});function De(e){D(e.target)}function Oe(e){let t=e.target.closest(`[data-task-id]`);if(!t)return;let n=t.getAttribute(`data-task-id`),r=c.tasks.find(e=>e.id===n);r&&l(`taskClick`,r)}function ke(e){let t=h.value;if(!t)return;let n=se(e.clientX,e.clientY,t.getBoundingClientRect(),S.width,S.height);if(!n)return;let r=te(g.value,n.x,n.y);if(!r)return;let i=c.tasks.find(e=>e.id===r);i&&l(`taskClick`,i)}return(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{ref_key:`rootRef`,ref:q,class:`koyori-gantt`,onClick:n[0]||=e=>(!w.value||_.value)&&Oe(e)},[u.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:1,ref_key:`scrollRef`,ref:m,class:(0,t.normalizeClass)([`koyori-gantt-scroll`,{"koyori-gantt-scroll--virtual":(j.value||x.value)&&!T.value}]),onScroll:De},[z.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,pe,` Unable to render Gantt chart: `+(0,t.toDisplayString)(z.value),1)):((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:1,class:`koyori-gantt-inner`,style:(0,t.normalizeStyle)({height:`${ve.value}px`})},[w.value&&!_.value?((0,t.openBlock)(),(0,t.createElementBlock)(`canvas`,{key:0,ref_key:`canvasRef`,ref:h,class:`koyori-gantt-canvas`,role:`img`,"aria-label":`Gantt chart`,onClick:ke},null,512)):((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:1,class:`koyori-gantt-svg`,innerHTML:_.value||d.value},null,8,me))],4))],34)):((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:0,class:`koyori-gantt-skeleton`,style:(0,t.normalizeStyle)({"--koyori-skeleton-label-w":o.value,"--koyori-skeleton-bar-h":s.value}),"aria-hidden":`true`},[((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(c.tasks,e=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:e.id,class:`koyori-gantt-skeleton-row`},[n[1]||=(0,t.createElementVNode)(`div`,{class:`koyori-gantt-skeleton-label`},null,-1),(0,t.createElementVNode)(`div`,{class:`koyori-gantt-skeleton-bar`,style:(0,t.normalizeStyle)({width:`${e.progress_pct}%`})},null,4)]))),128))],4))],512))}}),[[`__scopeId`,`data-v-816db9f8`]]);async function E(){return await(0,n.default)(),JSON.parse((0,n.legend_spec_json)())}e.GanttChart=T,e.findTaskAtPoint=te,e.loadLegendSpec=E,e.parseCommandBuffer=ee,e.replayCommands=v});
|
package/dist/canvasFallback.d.ts
CHANGED
|
@@ -58,3 +58,11 @@ export declare function resolveCanvasFailure(failure: RenderFailure, fallbackSvg
|
|
|
58
58
|
* first-day milestone's diamond needs.
|
|
59
59
|
*/
|
|
60
60
|
export declare function skeletonLabelWidthPx(rowLabels?: 'shown' | 'hidden', barHeight?: number): number;
|
|
61
|
+
/**
|
|
62
|
+
* The loading skeleton's bar height: the chart's bar, `barHeight` when it is
|
|
63
|
+
* set and `BAR_H` otherwise, as the crate's `RowPlan` reads it. The crate
|
|
64
|
+
* refuses a bar taller than a task row (`bar_height_px … is taller than a task
|
|
65
|
+
* row`), and the skeleton has no error to show while it loads, so it holds the
|
|
66
|
+
* bar to the row (`rowHeight`, or `ROW_H`) instead of drawing past it.
|
|
67
|
+
*/
|
|
68
|
+
export declare function skeletonBarHeightPx(barHeight?: number, rowHeight?: number): number;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { default as GanttChart } from './GanttChart.vue';
|
|
2
|
-
export type { GanttTask, GanttDep, GanttRow, BarState, BarShape } from './types.ts';
|
|
2
|
+
export type { GanttTask, GanttDep, DepState, DepEnd, GanttRow, BarState, BarShape } from './types.ts';
|
|
3
3
|
export { replayCommands, parseCommandBuffer, findTaskAtPoint, } from './replayCommands';
|
|
4
4
|
export type { ColorIdName, CommandBuffer, DrawOp, ReplayResult, TaskHitRegion, } from './replayCommands';
|
|
5
5
|
export { loadLegendSpec } from './legend';
|
package/dist/replayCommands.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Mirrors koyori-arc-core `CommandBuffer` JSON (serde externally-tagged `DrawOp`). */
|
|
2
|
-
export type ColorIdName = 'BarBg' | 'TierLow' | 'TierMid' | 'TierHigh' | 'TierDone' | 'Dep' | 'Progress' | 'Grid' | 'Today' | 'HeaderBg' | 'GridLabel' | 'ProgressTextOnFg' | 'ProgressTextOnBg' | 'GroupRow' | 'Weekend' | 'BarStroke' | 'DoneBg' | 'DoneStroke' | 'WarnBg' | 'WarnStroke' | 'HardDeadline' | 'Note' | 'NoteBg' | 'ProgressLine' | 'DayNumber';
|
|
2
|
+
export type ColorIdName = 'BarBg' | 'TierLow' | 'TierMid' | 'TierHigh' | 'TierDone' | 'Dep' | 'Progress' | 'Grid' | 'Today' | 'HeaderBg' | 'GridLabel' | 'ProgressTextOnFg' | 'ProgressTextOnBg' | 'GroupRow' | 'Weekend' | 'BarStroke' | 'DoneBg' | 'DoneStroke' | 'WarnBg' | 'WarnStroke' | 'HardDeadline' | 'Note' | 'NoteBg' | 'ProgressLine' | 'DayNumber' | 'DepDone' | 'DepDelayed';
|
|
3
3
|
export interface CommandBuffer {
|
|
4
4
|
viewport_width: number;
|
|
5
5
|
viewport_height: number;
|
|
@@ -52,7 +52,14 @@ export type DrawOp = {
|
|
|
52
52
|
GroupStart: {
|
|
53
53
|
task_id: string | null;
|
|
54
54
|
};
|
|
55
|
-
} | 'GroupEnd'
|
|
55
|
+
} | 'GroupEnd' | {
|
|
56
|
+
StrokeDashedPath: {
|
|
57
|
+
d: string;
|
|
58
|
+
color_id: number;
|
|
59
|
+
width: number;
|
|
60
|
+
dash: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
56
63
|
export interface TaskHitRegion {
|
|
57
64
|
taskId: string;
|
|
58
65
|
x: number;
|
package/dist/types.d.ts
CHANGED
|
@@ -55,4 +55,31 @@ export interface GanttDep {
|
|
|
55
55
|
blocker_task_id: string;
|
|
56
56
|
/** `task_relations.blocked_task_id` */
|
|
57
57
|
blocked_task_id: string;
|
|
58
|
+
/**
|
|
59
|
+
* The edge's state. Given (or any key below), the edge is drawn in the
|
|
60
|
+
* styled form under the bars: `'done'` in `DepDone`, `'delayed'` dashed in
|
|
61
|
+
* `DepDelayed`, `'normal'` in `Dep` (docs/design/dependency-states.md).
|
|
62
|
+
*/
|
|
63
|
+
state?: DepState;
|
|
64
|
+
/** Text drawn right of the blocked bar, after the row's own note. */
|
|
65
|
+
note?: string;
|
|
66
|
+
/** Where the edge starts when the blocker has no bar on the chart. */
|
|
67
|
+
blocker_at?: DepEnd;
|
|
68
|
+
/** Where the edge ends when the blocked task has no bar on the chart. */
|
|
69
|
+
blocked_at?: DepEnd;
|
|
58
70
|
}
|
|
71
|
+
/** The state a styled dependency edge is drawn in. */
|
|
72
|
+
export type DepState = 'normal' | 'done' | 'delayed';
|
|
73
|
+
/**
|
|
74
|
+
* The stand-in for an end of an edge the chart does not draw: a point on one
|
|
75
|
+
* of the caller's group rows (`row` counts the rows from 0) on `day`, or an
|
|
76
|
+
* edge of the chart for a task outside the days or the filter it shows.
|
|
77
|
+
*/
|
|
78
|
+
export type DepEnd = {
|
|
79
|
+
row: number;
|
|
80
|
+
day: string;
|
|
81
|
+
label?: string;
|
|
82
|
+
} | {
|
|
83
|
+
edge: 'start' | 'end';
|
|
84
|
+
label?: string;
|
|
85
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koyori-app/arc-vue",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MPL-2.0 OR GPL-2.0-or-later",
|
|
6
6
|
"repository": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"vitest": "^4.1.10",
|
|
44
44
|
"vue": "^3.5.39",
|
|
45
45
|
"vue-tsc": "^3.3.7",
|
|
46
|
-
"@koyori-app/arc": "0.1.0-alpha.
|
|
46
|
+
"@koyori-app/arc": "0.1.0-alpha.8"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "vite build",
|