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