@koyori-app/arc-vue 0.1.0-alpha.6 → 0.1.0-alpha.7
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 +220 -187
- package/dist/arc-vue.umd.cjs +1 -1
- package/dist/canvasFallback.d.ts +8 -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,7 +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
|
|
4
|
+
var le = [
|
|
5
5
|
"BarBg",
|
|
6
6
|
"TierLow",
|
|
7
7
|
"TierMid",
|
|
@@ -27,7 +27,7 @@ var ce = [
|
|
|
27
27
|
"NoteBg",
|
|
28
28
|
"ProgressLine",
|
|
29
29
|
"DayNumber"
|
|
30
|
-
],
|
|
30
|
+
], ue = {
|
|
31
31
|
GroupRow: "HeaderBg",
|
|
32
32
|
Weekend: "HeaderBg",
|
|
33
33
|
BarStroke: "GridLabel",
|
|
@@ -40,22 +40,22 @@ var ce = [
|
|
|
40
40
|
NoteBg: "HeaderBg",
|
|
41
41
|
ProgressLine: "Progress"
|
|
42
42
|
};
|
|
43
|
-
function
|
|
43
|
+
function p(e, t) {
|
|
44
44
|
let n = e.palette.colors.find(([e]) => e === t);
|
|
45
45
|
if (n) return n[1];
|
|
46
|
-
let r =
|
|
47
|
-
return r ?
|
|
46
|
+
let r = ue[t];
|
|
47
|
+
return r ? p(e, r) : void 0;
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function de(e, t) {
|
|
50
50
|
let n = /^var\((--[A-Za-z0-9_-]+)\)$/.exec(e);
|
|
51
51
|
return n ? !t || typeof getComputedStyle > "u" ? "#000000" : getComputedStyle(t).getPropertyValue(n[1]).trim() || "#000000" : e;
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function m(e, t, n) {
|
|
54
54
|
if (t === 255) return "#374151";
|
|
55
|
-
let r =
|
|
56
|
-
return r ?
|
|
55
|
+
let r = le[t];
|
|
56
|
+
return r ? de(p(e, r) ?? "#000000", n) : "#000000";
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function h(e, t, n, r, i) {
|
|
59
59
|
if (r <= 0 || i <= 0) return e;
|
|
60
60
|
let a = t + r, o = n + i;
|
|
61
61
|
if (e.w === 0 && e.h === 0) return {
|
|
@@ -72,20 +72,20 @@ function _(e, t, n, r, i) {
|
|
|
72
72
|
h: u - c
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function g(e, t, n, r, i, a) {
|
|
76
76
|
if (a > 0 && typeof e.roundRect == "function") {
|
|
77
77
|
e.beginPath(), e.roundRect(t, n, r, i, a), e.fill();
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
80
|
e.fillRect(t, n, r, i);
|
|
81
81
|
}
|
|
82
|
-
function
|
|
83
|
-
if (e.strokeStyle =
|
|
82
|
+
function _(e, t, n, r, i) {
|
|
83
|
+
if (e.strokeStyle = m(t, n, e.canvas), e.lineWidth = r, i) {
|
|
84
84
|
let t = i.split(",").map((e) => Number.parseFloat(e.trim()));
|
|
85
85
|
e.setLineDash(t.every(Number.isFinite) ? t : []);
|
|
86
86
|
} else e.setLineDash([]);
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function fe(e, t) {
|
|
89
89
|
let n = [], r = null, i = {
|
|
90
90
|
x: 0,
|
|
91
91
|
y: 0,
|
|
@@ -120,23 +120,23 @@ function b(e, t) {
|
|
|
120
120
|
}
|
|
121
121
|
if ("FillRect" in a) {
|
|
122
122
|
let { x: n, y: o, w: s, h: c, color_id: l, radius: u } = a.FillRect;
|
|
123
|
-
e.fillStyle =
|
|
123
|
+
e.fillStyle = m(t, l, e.canvas), g(e, n, o, s, c, u), r && (i = h(i, n, o, s, c));
|
|
124
124
|
continue;
|
|
125
125
|
}
|
|
126
126
|
if ("FillPolygon" in a) {
|
|
127
127
|
let { points: n, color_id: o } = a.FillPolygon;
|
|
128
128
|
if (n.length === 0) continue;
|
|
129
|
-
e.fillStyle =
|
|
129
|
+
e.fillStyle = m(t, o, e.canvas), e.beginPath(), e.moveTo(n[0][0], n[0][1]);
|
|
130
130
|
for (let t = 1; t < n.length; t++) e.lineTo(n[t][0], n[t][1]);
|
|
131
131
|
if (e.closePath(), e.fill(), r && n.length > 0) {
|
|
132
132
|
let e = n.map((e) => e[0]), t = n.map((e) => e[1]), r = Math.min(...e), a = Math.min(...t);
|
|
133
|
-
i =
|
|
133
|
+
i = h(i, r, a, Math.max(...e) - r, Math.max(...t) - a);
|
|
134
134
|
}
|
|
135
135
|
continue;
|
|
136
136
|
}
|
|
137
137
|
if ("StrokePath" in a) {
|
|
138
138
|
let { d: n, color_id: r, width: i } = a.StrokePath;
|
|
139
|
-
|
|
139
|
+
_(e, t, r, i, null);
|
|
140
140
|
let o = new Path2D(n);
|
|
141
141
|
e.stroke(o);
|
|
142
142
|
continue;
|
|
@@ -144,19 +144,19 @@ function b(e, t) {
|
|
|
144
144
|
if ("StrokePolyline" in a) {
|
|
145
145
|
let { points: n, color_id: r, width: i, dash: o } = a.StrokePolyline;
|
|
146
146
|
if (n.length < 2) continue;
|
|
147
|
-
|
|
147
|
+
_(e, t, r, i, o), e.beginPath(), e.moveTo(n[0][0], n[0][1]);
|
|
148
148
|
for (let t = 1; t < n.length; t++) e.lineTo(n[t][0], n[t][1]);
|
|
149
149
|
e.stroke();
|
|
150
150
|
continue;
|
|
151
151
|
}
|
|
152
152
|
if ("DrawText" in a) {
|
|
153
153
|
let { x: n, y: r, text: i, color_id: o, anchor: s, size: c, weight: l } = a.DrawText;
|
|
154
|
-
e.fillStyle =
|
|
154
|
+
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
155
|
}
|
|
156
156
|
}
|
|
157
157
|
return { hitRegions: n };
|
|
158
158
|
}
|
|
159
|
-
function
|
|
159
|
+
function pe(e) {
|
|
160
160
|
try {
|
|
161
161
|
return JSON.parse(e);
|
|
162
162
|
} catch {
|
|
@@ -169,7 +169,7 @@ function ue(e) {
|
|
|
169
169
|
};
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
-
function
|
|
172
|
+
function me(e, t, n) {
|
|
173
173
|
for (let r = e.length - 1; r >= 0; r--) {
|
|
174
174
|
let i = e[r];
|
|
175
175
|
if (t >= i.x && t <= i.x + i.w && n >= i.y && n <= i.y + i.h) return i.taskId;
|
|
@@ -178,26 +178,26 @@ function de(e, t, n) {
|
|
|
178
178
|
}
|
|
179
179
|
//#endregion
|
|
180
180
|
//#region src/canvasLifecycle.ts
|
|
181
|
-
function
|
|
181
|
+
function he(e) {
|
|
182
182
|
if (!e) return;
|
|
183
183
|
let t = e.getContext("2d");
|
|
184
184
|
t && t.clearRect(0, 0, e.width, e.height), e.width = 0, e.height = 0, e.style.width = "0px", e.style.height = "0px";
|
|
185
185
|
}
|
|
186
186
|
//#endregion
|
|
187
187
|
//#region src/options.ts
|
|
188
|
-
function
|
|
188
|
+
function ge(e) {
|
|
189
189
|
let t = {};
|
|
190
190
|
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
191
|
from: e.view.from,
|
|
192
192
|
to: e.view.to
|
|
193
193
|
}), e.progressLine != null && (t.progress_line = e.progressLine), Object.keys(t).length === 0 ? void 0 : JSON.stringify(t);
|
|
194
194
|
}
|
|
195
|
-
var
|
|
195
|
+
var v = {
|
|
196
196
|
CODE_CANVAS_CAPACITY: "canvas_capacity",
|
|
197
197
|
CODE_INPUT_LIMIT: "input_limit",
|
|
198
198
|
CODE_PARSE_ERROR: "parse_error",
|
|
199
199
|
CODE_SERIALIZE_ERROR: "serialize_error"
|
|
200
|
-
}.CODE_CANVAS_CAPACITY,
|
|
200
|
+
}.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
201
|
ROW_H: 40,
|
|
202
202
|
HEADER_H: 30,
|
|
203
203
|
DAY_SCALE_HEADER_H: 48,
|
|
@@ -206,11 +206,11 @@ var x = {
|
|
|
206
206
|
LABEL_W: 120,
|
|
207
207
|
BAR_H: 20,
|
|
208
208
|
HIDDEN_LABELS_LEFT_PX: 10
|
|
209
|
-
},
|
|
209
|
+
}, b = {
|
|
210
210
|
MAX_CANVAS_SIDE_PX: 16384,
|
|
211
211
|
MAX_CANVAS_AREA_PX: 32 * 1024 * 1024
|
|
212
212
|
};
|
|
213
|
-
function
|
|
213
|
+
function ve(e) {
|
|
214
214
|
try {
|
|
215
215
|
let t = JSON.parse(e);
|
|
216
216
|
return {
|
|
@@ -223,19 +223,19 @@ function he(e) {
|
|
|
223
223
|
}
|
|
224
224
|
//#endregion
|
|
225
225
|
//#region src/canvasScale.ts
|
|
226
|
-
function
|
|
226
|
+
function x(e, t, n) {
|
|
227
227
|
if (!(e > 0) || !(t > 0) || !(n > 0) || !Number.isFinite(n)) return 1;
|
|
228
|
-
let { MAX_CANVAS_SIDE_PX: r, MAX_CANVAS_AREA_PX: i } =
|
|
228
|
+
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
229
|
return Math.min(n, a);
|
|
230
230
|
}
|
|
231
|
-
function
|
|
232
|
-
let r =
|
|
231
|
+
function ye(e, t, n) {
|
|
232
|
+
let r = x(e, t, n);
|
|
233
233
|
return {
|
|
234
234
|
width: Math.floor(e * r),
|
|
235
235
|
height: Math.floor(t * r)
|
|
236
236
|
};
|
|
237
237
|
}
|
|
238
|
-
function
|
|
238
|
+
function be(e, t, n, r, i) {
|
|
239
239
|
return !(n.width > 0) || !(n.height > 0) ? null : {
|
|
240
240
|
x: (e - n.left) * (r / n.width),
|
|
241
241
|
y: (t - n.top) * (i / n.height)
|
|
@@ -243,22 +243,22 @@ function _e(e, t, n, r, i) {
|
|
|
243
243
|
}
|
|
244
244
|
//#endregion
|
|
245
245
|
//#region src/canvasFallback.ts
|
|
246
|
-
function
|
|
247
|
-
return e.headerHeight == null ? e.scale === "day" ?
|
|
246
|
+
function S(e = {}) {
|
|
247
|
+
return e.headerHeight == null ? e.scale === "day" ? y.DAY_SCALE_HEADER_H : y.HEADER_H : e.headerHeight;
|
|
248
248
|
}
|
|
249
|
-
function
|
|
249
|
+
function xe(e, t, n = "shown", r = {}) {
|
|
250
250
|
if (t === 0) return 0;
|
|
251
|
-
let i = r.rowHeight ??
|
|
252
|
-
return (e ? e.reduce((e, t) => e + (t.height ?? i), 0) : t * i) +
|
|
251
|
+
let i = r.rowHeight ?? y.ROW_H;
|
|
252
|
+
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
253
|
}
|
|
254
|
-
function
|
|
255
|
-
return e.code ===
|
|
254
|
+
function C(e) {
|
|
255
|
+
return e.code === v;
|
|
256
256
|
}
|
|
257
|
-
function
|
|
257
|
+
function w(e, t) {
|
|
258
258
|
return e.startsWith("<svg ") && e !== t;
|
|
259
259
|
}
|
|
260
|
-
function
|
|
261
|
-
return
|
|
260
|
+
function Se(e, t, n) {
|
|
261
|
+
return C(e) && w(t, n) ? {
|
|
262
262
|
mode: "svg",
|
|
263
263
|
svg: t
|
|
264
264
|
} : {
|
|
@@ -266,17 +266,20 @@ function be(e, t, n) {
|
|
|
266
266
|
message: e.message
|
|
267
267
|
};
|
|
268
268
|
}
|
|
269
|
-
function
|
|
270
|
-
let n = (t ??
|
|
271
|
-
return e === "hidden" ? n : Math.max(
|
|
269
|
+
function Ce(e, t) {
|
|
270
|
+
let n = (t ?? y.BAR_H) / 2;
|
|
271
|
+
return e === "hidden" ? n : Math.max(y.LABEL_W, n);
|
|
272
|
+
}
|
|
273
|
+
function we(e, t) {
|
|
274
|
+
return Math.min(e ?? y.BAR_H, t ?? y.ROW_H);
|
|
272
275
|
}
|
|
273
276
|
//#endregion
|
|
274
277
|
//#region src/GanttChart.vue?vue&type=script&setup=true&lang.ts
|
|
275
|
-
var
|
|
278
|
+
var Te = {
|
|
276
279
|
key: 0,
|
|
277
280
|
class: "koyori-gantt-error",
|
|
278
281
|
role: "alert"
|
|
279
|
-
},
|
|
282
|
+
}, Ee = ["innerHTML"], T = /*#__PURE__*/ ((e, t) => {
|
|
280
283
|
let n = e.__vccOpts || e;
|
|
281
284
|
for (let [e, r] of t) n[e] = r;
|
|
282
285
|
return n;
|
|
@@ -303,227 +306,257 @@ var Se = {
|
|
|
303
306
|
view: {},
|
|
304
307
|
progressLine: {},
|
|
305
308
|
backend: {},
|
|
306
|
-
deviceTier: {}
|
|
309
|
+
deviceTier: {},
|
|
310
|
+
scrollContainer: {}
|
|
307
311
|
},
|
|
308
312
|
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 = {
|
|
313
|
+
setup(i, { expose: ae, emit: le }) {
|
|
314
|
+
ne((e) => ({ v73d153a1: ue.value }));
|
|
315
|
+
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
316
|
width: 0,
|
|
316
317
|
height: 0
|
|
317
|
-
},
|
|
318
|
-
function
|
|
319
|
-
let t = e
|
|
320
|
-
|
|
318
|
+
}, k = d(_e), A = t(() => m.backend === "canvas"), j = t(() => m.scrollContainer ?? null);
|
|
319
|
+
function De(e, t) {
|
|
320
|
+
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;
|
|
321
|
+
return {
|
|
322
|
+
scrollY: Math.max(0, i - n),
|
|
323
|
+
clientHeight: a
|
|
324
|
+
};
|
|
321
325
|
}
|
|
322
|
-
|
|
323
|
-
|
|
326
|
+
function M(e) {
|
|
327
|
+
let t = j.value;
|
|
328
|
+
if (t) {
|
|
329
|
+
if (!x.value) return;
|
|
330
|
+
let e = De(t, x.value);
|
|
331
|
+
v.value = e.scrollY, b.value = e.clientHeight;
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
let n = e ?? x.value;
|
|
335
|
+
n && (v.value = n.scrollTop, b.value = n.clientHeight);
|
|
336
|
+
}
|
|
337
|
+
let N = 0, P = null;
|
|
338
|
+
function F() {
|
|
339
|
+
if (N) return;
|
|
340
|
+
let e = () => {
|
|
341
|
+
N = 0, M();
|
|
342
|
+
};
|
|
343
|
+
typeof requestAnimationFrame == "function" ? N = requestAnimationFrame(e) : e();
|
|
344
|
+
}
|
|
345
|
+
function Oe(e) {
|
|
346
|
+
e?.removeEventListener("scroll", F), e && typeof window < "u" && window.removeEventListener("resize", F), P?.disconnect(), P = null;
|
|
347
|
+
}
|
|
348
|
+
f(j, (e, t) => {
|
|
349
|
+
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());
|
|
350
|
+
}, { immediate: !0 }), c(() => {
|
|
351
|
+
Oe(j.value), N && typeof cancelAnimationFrame == "function" && cancelAnimationFrame(N), N = 0;
|
|
352
|
+
}), l(async () => {
|
|
353
|
+
await re(), k.value = ie(), g.value = !0, await a(), M(), I.value && (L.value = !0);
|
|
324
354
|
});
|
|
325
|
-
function
|
|
326
|
-
if (
|
|
355
|
+
function ke() {
|
|
356
|
+
if (m.deviceTier) return m.deviceTier;
|
|
327
357
|
if (typeof navigator > "u") return "low";
|
|
328
358
|
let e = navigator;
|
|
329
359
|
return e.deviceMemory === void 0 || e.deviceMemory <= 4 || navigator.hardwareConcurrency <= 4 ? "low" : "high";
|
|
330
360
|
}
|
|
331
|
-
let
|
|
332
|
-
f(
|
|
361
|
+
let Ae = t(() => ke()), I = t(() => Ae.value === "low"), L = d(!1);
|
|
362
|
+
f(I, async (e) => {
|
|
333
363
|
if (!e) {
|
|
334
|
-
|
|
364
|
+
L.value = !1;
|
|
335
365
|
return;
|
|
336
366
|
}
|
|
337
|
-
|
|
367
|
+
L.value = !1, await a(), M(), L.value = !0;
|
|
338
368
|
}, { flush: "post" });
|
|
339
|
-
let
|
|
340
|
-
rowHeight:
|
|
341
|
-
headerHeight:
|
|
342
|
-
scale:
|
|
343
|
-
})),
|
|
344
|
-
if (!(!
|
|
345
|
-
scroll_y:
|
|
346
|
-
client_height:
|
|
369
|
+
let je = t(() => V.value ? 0 : xe(m.rows, m.tasks.length, m.legend, {
|
|
370
|
+
rowHeight: m.rowHeight,
|
|
371
|
+
headerHeight: m.headerHeight,
|
|
372
|
+
scale: m.scale
|
|
373
|
+
})), Me = t(() => {
|
|
374
|
+
if (!(!I.value || !L.value)) return {
|
|
375
|
+
scroll_y: v.value,
|
|
376
|
+
client_height: b.value
|
|
347
377
|
};
|
|
348
378
|
});
|
|
349
|
-
function
|
|
350
|
-
return
|
|
351
|
-
today:
|
|
379
|
+
function Ne(e) {
|
|
380
|
+
return ge({
|
|
381
|
+
today: m.today,
|
|
352
382
|
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:
|
|
383
|
+
tzOffsetMinutes: m.tzOffsetMinutes,
|
|
384
|
+
legend: m.legend,
|
|
385
|
+
rowLabels: m.rowLabels,
|
|
386
|
+
percentLabels: m.percentLabels,
|
|
387
|
+
rowHeightPx: m.rowHeight,
|
|
388
|
+
headerHeightPx: m.headerHeight,
|
|
389
|
+
barHeightPx: m.barHeight,
|
|
390
|
+
barAlign: m.barAlign,
|
|
391
|
+
palette: m.palette,
|
|
392
|
+
pxPerDay: m.pxPerDay,
|
|
393
|
+
scale: m.scale,
|
|
394
|
+
weekendDays: m.weekendDays,
|
|
395
|
+
weekdayLabels: m.weekdayLabels,
|
|
396
|
+
view: m.view,
|
|
397
|
+
progressLine: m.progressLine
|
|
368
398
|
});
|
|
369
399
|
}
|
|
370
|
-
let
|
|
371
|
-
f(
|
|
372
|
-
e !== null && (
|
|
400
|
+
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));
|
|
401
|
+
f(Fe, (e) => {
|
|
402
|
+
e !== null && (_.value = e);
|
|
373
403
|
}, { immediate: !0 });
|
|
374
|
-
let
|
|
375
|
-
if (!
|
|
376
|
-
let e =
|
|
377
|
-
return e ?
|
|
378
|
-
}),
|
|
379
|
-
function
|
|
380
|
-
|
|
404
|
+
let Ie = t(() => {
|
|
405
|
+
if (!g.value || m.tasks.length === 0 || A.value || Fe.value !== k.value) return null;
|
|
406
|
+
let e = ce(JSON.stringify(m.tasks), JSON.stringify(m.deps ?? []), R.value, ...z.value);
|
|
407
|
+
return e ? ve(e) : null;
|
|
408
|
+
}), V = t(() => E.value || Ie.value?.message || "");
|
|
409
|
+
function H(e) {
|
|
410
|
+
w.value = [], he(e);
|
|
381
411
|
}
|
|
382
|
-
function
|
|
383
|
-
|
|
412
|
+
function U() {
|
|
413
|
+
T.value = "", E.value = "", D.value = null;
|
|
384
414
|
}
|
|
385
|
-
function
|
|
386
|
-
|
|
415
|
+
function Le(e) {
|
|
416
|
+
D.value = e;
|
|
387
417
|
let t = "";
|
|
388
|
-
if (
|
|
389
|
-
t =
|
|
390
|
-
scroll_y:
|
|
391
|
-
client_height: Math.min(
|
|
392
|
-
}), ...
|
|
418
|
+
if (C(e)) try {
|
|
419
|
+
t = se(JSON.stringify(m.tasks), JSON.stringify(m.deps ?? []), Ne({
|
|
420
|
+
scroll_y: v.value,
|
|
421
|
+
client_height: j.value ? b.value : Math.min(b.value, 600)
|
|
422
|
+
}), ...z.value);
|
|
393
423
|
} catch {}
|
|
394
|
-
let n =
|
|
395
|
-
n.mode === "svg" ? (
|
|
424
|
+
let n = Se(e, t, k.value);
|
|
425
|
+
n.mode === "svg" ? (T.value = n.svg, E.value = "") : (T.value = "", E.value = n.message);
|
|
396
426
|
}
|
|
397
|
-
f([
|
|
398
|
-
|
|
427
|
+
f([v, b], () => {
|
|
428
|
+
T.value && D.value && Le(D.value);
|
|
399
429
|
});
|
|
400
|
-
async function
|
|
401
|
-
let e =
|
|
430
|
+
async function W() {
|
|
431
|
+
let e = B.value;
|
|
402
432
|
if (!e) {
|
|
403
|
-
|
|
433
|
+
H(S.value), U();
|
|
404
434
|
return;
|
|
405
435
|
}
|
|
406
|
-
let t =
|
|
407
|
-
if (!t && (
|
|
408
|
-
let n =
|
|
436
|
+
let t = S.value;
|
|
437
|
+
if (!t && (U(), await a(), t = S.value, !t)) return;
|
|
438
|
+
let n = pe(e);
|
|
409
439
|
if (n.error) {
|
|
410
|
-
|
|
440
|
+
H(t), Le({
|
|
411
441
|
message: n.error,
|
|
412
442
|
code: n.code
|
|
413
443
|
});
|
|
414
444
|
return;
|
|
415
445
|
}
|
|
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`,
|
|
446
|
+
U();
|
|
447
|
+
let r = n.viewport_width, i = n.viewport_height, o = ye(r, i, G.value);
|
|
448
|
+
t.width = o.width, t.height = o.height, t.style.width = `${r}px`, t.style.height = `${i}px`, O = {
|
|
419
449
|
width: r,
|
|
420
450
|
height: i
|
|
421
451
|
};
|
|
422
452
|
let s = t.getContext("2d");
|
|
423
453
|
if (!s) {
|
|
424
|
-
|
|
454
|
+
H(t);
|
|
425
455
|
return;
|
|
426
456
|
}
|
|
427
|
-
r > 0 && i > 0 && s.setTransform(o.width / r, 0, 0, o.height / i, 0, 0),
|
|
457
|
+
r > 0 && i > 0 && s.setTransform(o.width / r, 0, 0, o.height / i, 0, 0), w.value = fe(s, n).hitRegions;
|
|
428
458
|
}
|
|
429
|
-
f(
|
|
430
|
-
a().then(
|
|
459
|
+
f(B, () => {
|
|
460
|
+
a().then(W);
|
|
431
461
|
}, { immediate: !0 });
|
|
432
|
-
let
|
|
433
|
-
function
|
|
462
|
+
let G = d(q()), K = null;
|
|
463
|
+
function q() {
|
|
434
464
|
return typeof window > "u" ? 1 : window.devicePixelRatio || 1;
|
|
435
465
|
}
|
|
436
|
-
function
|
|
437
|
-
|
|
466
|
+
function Re() {
|
|
467
|
+
K?.removeEventListener("change", Be), K = null;
|
|
438
468
|
}
|
|
439
|
-
function
|
|
440
|
-
|
|
469
|
+
function ze() {
|
|
470
|
+
Re(), !(typeof window > "u" || typeof window.matchMedia != "function") && (K = window.matchMedia(`(resolution: ${q()}dppx)`), K.addEventListener("change", Be));
|
|
441
471
|
}
|
|
442
|
-
function
|
|
443
|
-
|
|
472
|
+
function Be() {
|
|
473
|
+
G.value = q(), ze();
|
|
444
474
|
}
|
|
445
|
-
l(
|
|
446
|
-
|
|
475
|
+
l(ze), c(Re), f(G, () => {
|
|
476
|
+
S.value && B.value && W();
|
|
447
477
|
});
|
|
448
|
-
let
|
|
449
|
-
function
|
|
450
|
-
if (
|
|
478
|
+
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;
|
|
479
|
+
function Q() {
|
|
480
|
+
if (Z) return;
|
|
451
481
|
let e = () => {
|
|
452
|
-
|
|
482
|
+
Z = 0, S.value && B.value && W();
|
|
453
483
|
};
|
|
454
|
-
typeof requestAnimationFrame == "function" ?
|
|
484
|
+
typeof requestAnimationFrame == "function" ? Z = requestAnimationFrame(e) : e();
|
|
455
485
|
}
|
|
456
|
-
function
|
|
486
|
+
function Ue(e) {
|
|
457
487
|
return e === "class" || e === "style" || (e?.startsWith("data-") ?? !1);
|
|
458
488
|
}
|
|
459
|
-
function
|
|
460
|
-
|
|
489
|
+
function We() {
|
|
490
|
+
Y?.removeEventListener("change", Q), Y = null, X?.disconnect(), X = null;
|
|
461
491
|
}
|
|
462
492
|
function $() {
|
|
463
|
-
if (
|
|
464
|
-
|
|
465
|
-
e.some((e) =>
|
|
493
|
+
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)) {
|
|
494
|
+
X = new MutationObserver((e) => {
|
|
495
|
+
e.some((e) => Ue(e.attributeName)) && Q();
|
|
466
496
|
});
|
|
467
|
-
for (let e =
|
|
497
|
+
for (let e = J.value.parentElement; e; e = e.parentElement) X.observe(e, { attributes: !0 });
|
|
468
498
|
}
|
|
469
499
|
}
|
|
470
|
-
l($), f(
|
|
471
|
-
$(),
|
|
500
|
+
l($), f(He, $), f(() => m.palette, () => {
|
|
501
|
+
$(), A.value && Q();
|
|
472
502
|
}), c(() => {
|
|
473
|
-
|
|
474
|
-
}),
|
|
475
|
-
function
|
|
476
|
-
|
|
503
|
+
We(), Z && typeof cancelAnimationFrame == "function" && cancelAnimationFrame(Z), Z = 0;
|
|
504
|
+
}), ae({ repaint: Q });
|
|
505
|
+
function Ge(e) {
|
|
506
|
+
M(e.target);
|
|
477
507
|
}
|
|
478
|
-
function
|
|
508
|
+
function Ke(e) {
|
|
479
509
|
let t = e.target.closest("[data-task-id]");
|
|
480
510
|
if (!t) return;
|
|
481
|
-
let n = t.getAttribute("data-task-id"), r =
|
|
482
|
-
r &&
|
|
511
|
+
let n = t.getAttribute("data-task-id"), r = m.tasks.find((e) => e.id === n);
|
|
512
|
+
r && h("taskClick", r);
|
|
483
513
|
}
|
|
484
|
-
function
|
|
485
|
-
let t =
|
|
514
|
+
function qe(e) {
|
|
515
|
+
let t = S.value;
|
|
486
516
|
if (!t) return;
|
|
487
|
-
let n =
|
|
517
|
+
let n = be(e.clientX, e.clientY, t.getBoundingClientRect(), O.width, O.height);
|
|
488
518
|
if (!n) return;
|
|
489
|
-
let r =
|
|
519
|
+
let r = me(w.value, n.x, n.y);
|
|
490
520
|
if (!r) return;
|
|
491
|
-
let i =
|
|
492
|
-
i &&
|
|
521
|
+
let i = m.tasks.find((e) => e.id === r);
|
|
522
|
+
i && h("taskClick", i);
|
|
493
523
|
}
|
|
494
524
|
return (t, i) => (u(), n("div", {
|
|
495
525
|
ref_key: "rootRef",
|
|
496
|
-
ref:
|
|
526
|
+
ref: J,
|
|
497
527
|
class: "koyori-gantt",
|
|
498
|
-
onClick: i[0] ||= (e) => (!
|
|
499
|
-
}, [
|
|
528
|
+
onClick: i[0] ||= (e) => (!A.value || T.value) && Ke(e)
|
|
529
|
+
}, [g.value ? (u(), n("div", {
|
|
500
530
|
key: 1,
|
|
501
531
|
ref_key: "scrollRef",
|
|
502
|
-
ref:
|
|
503
|
-
class: o(["koyori-gantt-scroll", { "koyori-gantt-scroll--virtual":
|
|
504
|
-
onScroll:
|
|
505
|
-
}, [
|
|
532
|
+
ref: x,
|
|
533
|
+
class: o(["koyori-gantt-scroll", { "koyori-gantt-scroll--virtual": (I.value || D.value) && !j.value }]),
|
|
534
|
+
onScroll: Ge
|
|
535
|
+
}, [V.value ? (u(), n("div", Te, " Unable to render Gantt chart: " + te(V.value), 1)) : (u(), n("div", {
|
|
506
536
|
key: 1,
|
|
507
537
|
class: "koyori-gantt-inner",
|
|
508
|
-
style: s({ height: `${
|
|
509
|
-
}, [
|
|
538
|
+
style: s({ height: `${je.value}px` })
|
|
539
|
+
}, [A.value && !T.value ? (u(), n("canvas", {
|
|
510
540
|
key: 0,
|
|
511
541
|
ref_key: "canvasRef",
|
|
512
|
-
ref:
|
|
542
|
+
ref: S,
|
|
513
543
|
class: "koyori-gantt-canvas",
|
|
514
544
|
role: "img",
|
|
515
545
|
"aria-label": "Gantt chart",
|
|
516
|
-
onClick:
|
|
546
|
+
onClick: qe
|
|
517
547
|
}, null, 512)) : (u(), n("div", {
|
|
518
548
|
key: 1,
|
|
519
549
|
class: "koyori-gantt-svg",
|
|
520
|
-
innerHTML:
|
|
521
|
-
}, null, 8,
|
|
550
|
+
innerHTML: T.value || _.value
|
|
551
|
+
}, null, 8, Ee))], 4))], 34)) : (u(), n("div", {
|
|
522
552
|
key: 0,
|
|
523
553
|
class: "koyori-gantt-skeleton",
|
|
524
|
-
style: s({
|
|
554
|
+
style: s({
|
|
555
|
+
"--koyori-skeleton-label-w": p.value,
|
|
556
|
+
"--koyori-skeleton-bar-h": de.value
|
|
557
|
+
}),
|
|
525
558
|
"aria-hidden": "true"
|
|
526
|
-
}, [(u(!0), n(e, null, ee(
|
|
559
|
+
}, [(u(!0), n(e, null, ee(m.tasks, (e) => (u(), n("div", {
|
|
527
560
|
key: e.id,
|
|
528
561
|
class: "koyori-gantt-skeleton-row"
|
|
529
562
|
}, [i[1] ||= r("div", { class: "koyori-gantt-skeleton-label" }, null, -1), r("div", {
|
|
@@ -531,11 +564,11 @@ var Se = {
|
|
|
531
564
|
style: s({ width: `${e.progress_pct}%` })
|
|
532
565
|
}, null, 4)]))), 128))], 4))], 512));
|
|
533
566
|
}
|
|
534
|
-
}), [["__scopeId", "data-v-
|
|
567
|
+
}), [["__scopeId", "data-v-816db9f8"]]);
|
|
535
568
|
//#endregion
|
|
536
569
|
//#region src/legend.ts
|
|
537
|
-
async function
|
|
538
|
-
return await
|
|
570
|
+
async function E() {
|
|
571
|
+
return await re(), JSON.parse(ae());
|
|
539
572
|
}
|
|
540
573
|
//#endregion
|
|
541
|
-
export {
|
|
574
|
+
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`],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 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(`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/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.7",
|
|
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.7"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "vite build",
|