@koyori-app/arc-vue 0.1.0-alpha.4 → 0.1.0-alpha.5

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.
@@ -1,5 +1,5 @@
1
1
  import { GanttTask, GanttDep, GanttRow } from './types.ts';
2
- import { PaletteOverrides } from './options';
2
+ import { PaletteOverrides, ProgressLineMode, ViewRange } from './options';
3
3
  type __VLS_Props = {
4
4
  tasks: GanttTask[];
5
5
  deps?: GanttDep[];
@@ -55,6 +55,24 @@ type __VLS_Props = {
55
55
  * in, say) needs `repaint()`, or the palette passed again as a new object.
56
56
  */
57
57
  palette?: PaletteOverrides;
58
+ /** Width of a day in pixels. Left out, the crate's own. */
59
+ pxPerDay?: number;
60
+ /**
61
+ * What the date header marks: `'week'` (the default), `'day'` (every day's
62
+ * number and weekday, and the month above the first day of each), or
63
+ * `'month'`. With `'day'` and no `headerHeight`, the header is 48 px, room
64
+ * for its three tiers. A `headerHeight` below 48 leaves the months out rather
65
+ * than draw them over the days.
66
+ */
67
+ scale?: 'week' | 'day' | 'month';
68
+ /** Weekday numbers drawn as weekend bands, 0 for Monday to 6 for Sunday. */
69
+ weekendDays?: number[];
70
+ /** Seven labels, Monday first, for the `'day'` scale, such as `['月', …, '日']`. */
71
+ weekdayLabels?: string[];
72
+ /** The days the chart shows, both included; left out, every task's days. */
73
+ view?: ViewRange;
74
+ /** How the progress line is drawn; left out, the line as before. */
75
+ progressLine?: ProgressLineMode;
58
76
  /** Render backend — default `svg` preserves existing DOM projection. */
59
77
  backend?: 'svg' | 'canvas';
60
78
  /** Override auto-detected device tier (VRT / Storybook should pin this). */
package/dist/arc-vue.css CHANGED
@@ -1,2 +1,2 @@
1
- .koyori-gantt-scroll[data-v-00f1f19b]{width:100%;overflow:auto}.koyori-gantt-scroll--virtual[data-v-00f1f19b]{max-height:min(70vh,600px)}.koyori-gantt-inner[data-v-00f1f19b]{width:100%;position:relative}.koyori-gantt-error[data-v-00f1f19b]{color:#991b1b;padding:12px}.koyori-gantt-svg[data-v-00f1f19b]{width:100%;position:absolute;top:0;left:0}.koyori-gantt-canvas[data-v-00f1f19b]{display:block;position:absolute;top:0;left:0}.koyori-gantt-svg[data-v-00f1f19b] svg{display:block}.koyori-gantt-skeleton[data-v-00f1f19b]{--koyori-skeleton-gap:4px;--koyori-skeleton-bar-min-w:8px}.koyori-gantt-skeleton-row[data-v-00f1f19b]{height:var(--v578a3030);align-items:center;gap:var(--koyori-skeleton-gap);display:flex}.koyori-gantt-skeleton-label[data-v-00f1f19b]{width:var(--koyori-skeleton-label-w);background:#e5e7eb;border-radius:4px;flex-shrink:0;height:12px}.koyori-gantt-skeleton-bar[data-v-00f1f19b]{height:var(--v5782b517);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-00f1f19b}@keyframes koyori-gantt-shimmer-00f1f19b{0%,to{opacity:.6}50%{opacity:1}}
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}}
2
2
  /*$vite$:1*/
package/dist/arc-vue.js CHANGED
@@ -15,8 +15,30 @@ var ce = [
15
15
  "GridLabel",
16
16
  "ProgressTextOnFg",
17
17
  "ProgressTextOnBg",
18
- "GroupRow"
19
- ], le = { GroupRow: "HeaderBg" };
18
+ "GroupRow",
19
+ "Weekend",
20
+ "BarStroke",
21
+ "DoneBg",
22
+ "DoneStroke",
23
+ "WarnBg",
24
+ "WarnStroke",
25
+ "HardDeadline",
26
+ "Note",
27
+ "NoteBg",
28
+ "ProgressLine"
29
+ ], le = {
30
+ GroupRow: "HeaderBg",
31
+ Weekend: "HeaderBg",
32
+ BarStroke: "GridLabel",
33
+ DoneBg: "BarBg",
34
+ DoneStroke: "GridLabel",
35
+ WarnBg: "BarBg",
36
+ WarnStroke: "Progress",
37
+ HardDeadline: "Progress",
38
+ Note: "GridLabel",
39
+ NoteBg: "HeaderBg",
40
+ ProgressLine: "Progress"
41
+ };
20
42
  function m(e, t) {
21
43
  let n = e.palette.colors.find(([e]) => e === t);
22
44
  if (n) return n[1];
@@ -164,7 +186,10 @@ function fe(e) {
164
186
  //#region src/options.ts
165
187
  function pe(e) {
166
188
  let t = {};
167
- 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), Object.keys(t).length === 0 ? void 0 : JSON.stringify(t);
189
+ 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
+ from: e.view.from,
191
+ to: e.view.to
192
+ }), e.progressLine != null && (t.progress_line = e.progressLine), Object.keys(t).length === 0 ? void 0 : JSON.stringify(t);
168
193
  }
169
194
  var x = {
170
195
  CODE_CANVAS_CAPACITY: "canvas_capacity",
@@ -174,6 +199,7 @@ var x = {
174
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 = {
175
200
  ROW_H: 40,
176
201
  HEADER_H: 30,
202
+ DAY_SCALE_HEADER_H: 48,
177
203
  LEGEND_H: 40,
178
204
  CHART_BOTTOM_PADDING_PX: 10,
179
205
  LABEL_W: 120,
@@ -216,19 +242,22 @@ function _e(e, t, n, r, i) {
216
242
  }
217
243
  //#endregion
218
244
  //#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;
247
+ }
219
248
  function ve(e, t, n = "shown", r = {}) {
220
249
  if (t === 0) return 0;
221
250
  let i = r.rowHeight ?? S.ROW_H;
222
- return (e ? e.reduce((e, t) => e + (t.height ?? i), 0) : t * i) + (r.headerHeight ?? S.HEADER_H) + (n === "hidden" ? 0 : S.LEGEND_H) + S.CHART_BOTTOM_PADDING_PX;
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;
223
252
  }
224
253
  function ye(e) {
225
254
  return e.code === x;
226
255
  }
227
- function T(e, t) {
256
+ function E(e, t) {
228
257
  return e.startsWith("<svg ") && e !== t;
229
258
  }
230
259
  function be(e, t, n) {
231
- return ye(e) && T(t, n) ? {
260
+ return ye(e) && E(t, n) ? {
232
261
  mode: "svg",
233
262
  svg: t
234
263
  } : {
@@ -246,7 +275,7 @@ var Se = {
246
275
  key: 0,
247
276
  class: "koyori-gantt-error",
248
277
  role: "alert"
249
- }, Ce = ["innerHTML"], E = /*#__PURE__*/ ((e, t) => {
278
+ }, Ce = ["innerHTML"], D = /*#__PURE__*/ ((e, t) => {
250
279
  let n = e.__vccOpts || e;
251
280
  for (let [e, r] of t) n[e] = r;
252
281
  return n;
@@ -266,14 +295,20 @@ var Se = {
266
295
  barHeight: {},
267
296
  barAlign: {},
268
297
  palette: {},
298
+ pxPerDay: {},
299
+ scale: {},
300
+ weekendDays: {},
301
+ weekdayLabels: {},
302
+ view: {},
303
+ progressLine: {},
269
304
  backend: {},
270
305
  deviceTier: {}
271
306
  },
272
307
  emits: ["taskClick"],
273
308
  setup(i, { expose: ie, emit: ce }) {
274
309
  ne((e) => ({
275
- v578a3030: le.value,
276
- v5782b517: h
310
+ v59cd6a8e: le.value,
311
+ v59c5ef75: h
277
312
  }));
278
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 = {
279
314
  width: 0,
@@ -302,7 +337,8 @@ var Se = {
302
337
  }, { flush: "post" });
303
338
  let Ee = t(() => z.value ? 0 : ve(g.rows, g.tasks.length, g.legend, {
304
339
  rowHeight: g.rowHeight,
305
- headerHeight: g.headerHeight
340
+ headerHeight: g.headerHeight,
341
+ scale: g.scale
306
342
  })), De = t(() => {
307
343
  if (!(!P.value || !F.value)) return {
308
344
  scroll_y: x.value,
@@ -321,7 +357,13 @@ var Se = {
321
357
  headerHeightPx: g.headerHeight,
322
358
  barHeightPx: g.barHeight,
323
359
  barAlign: g.barAlign,
324
- palette: g.palette
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
325
367
  });
326
368
  }
327
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));
@@ -488,11 +530,11 @@ var Se = {
488
530
  style: s({ width: `${e.progress_pct}%` })
489
531
  }, null, 4)]))), 128))], 4))], 512));
490
532
  }
491
- }), [["__scopeId", "data-v-00f1f19b"]]);
533
+ }), [["__scopeId", "data-v-05f0ec3c"]]);
492
534
  //#endregion
493
535
  //#region src/legend.ts
494
- async function D() {
536
+ async function O() {
495
537
  return await p(), JSON.parse(ie());
496
538
  }
497
539
  //#endregion
498
- export { E as GanttChart, de as findTaskAtPoint, D as loadLegendSpec, ue as parseCommandBuffer, b as replayCommands };
540
+ export { D as GanttChart, de as findTaskAtPoint, O as loadLegendSpec, ue as parseCommandBuffer, b 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`],d={GroupRow:`HeaderBg`};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),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,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 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)+(r.headerHeight??x.HEADER_H)+(n===`hidden`?0:x.LEGEND_H)+x.CHART_BOTTOM_PADDING_PX}function w(e){return e.code===b}function T(e,t){return e.startsWith(`<svg `)&&e!==t}function ce(e,t,n){return w(e)&&T(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`],E=((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:{},backend:{},deviceTier:{}},emits:[`taskClick`],setup(e,{expose:r,emit:i}){(0,t.useCssVars)(e=>({v578a3030:a.value,v5782b517: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},T=(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)(),T.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})),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})}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!==T.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(w(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,T.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-00f1f19b`]]);async function D(){return await(0,n.default)(),JSON.parse((0,n.legend_spec_json)())}e.GanttChart=E,e.findTaskAtPoint=y,e.loadLegendSpec=D,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`],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});
@@ -17,7 +17,15 @@ export declare function chartHeightForTaskCount(taskCount: number, legend?: Lege
17
17
  export interface RowSizes {
18
18
  rowHeight?: number;
19
19
  headerHeight?: number;
20
+ /** The date header's scale, which decides the header's height when none is set. */
21
+ scale?: 'week' | 'day' | 'month';
20
22
  }
23
+ /**
24
+ * The header's height as the crate draws it: `headerHeight` when set, and
25
+ * otherwise `DAY_SCALE_HEADER_H` for the `'day'` scale, whose month, day and
26
+ * weekday do not fit `HEADER_H`, and `HEADER_H` for the others.
27
+ */
28
+ export declare function headerHeightPx(sizes?: RowSizes): number;
21
29
  /**
22
30
  * `chartHeightForTaskCount` for a chart that may lay out its own rows: the
23
31
  * header, every row at its own height (or `rowHeight`), and below them the
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { default as GanttChart } from './GanttChart.vue';
2
- export type { GanttTask, GanttDep, GanttRow } from './types.ts';
2
+ export type { GanttTask, GanttDep, GanttRow, BarState, BarShape } from './types.ts';
3
3
  export { replayCommands, parseCommandBuffer, findTaskAtPoint, } from './replayCommands';
4
4
  export type { ColorIdName, CommandBuffer, DrawOp, ReplayResult, TaskHitRegion, } from './replayCommands';
5
5
  export { loadLegendSpec } from './legend';
6
6
  export type { LegendSpec, LegendTier, LegendProgressLine } from './legend';
7
- export type { BarAlign, ChartOptions, LabelMode, LegendMode, PaletteOverrides } from './options';
7
+ export type { BarAlign, ChartOptions, LabelMode, LegendMode, PaletteOverrides, ProgressLineMode, Scale, ViewRange, } from './options';
package/dist/options.d.ts CHANGED
@@ -27,6 +27,27 @@ export type LabelMode = 'shown' | 'hidden';
27
27
  export type PaletteOverrides = Partial<Record<ColorIdName, string>>;
28
28
  /** Where a bar sits in its row. Left out, it is centred. */
29
29
  export type BarAlign = 'middle' | 'bottom';
30
+ /**
31
+ * What the date header marks: `'week'` a line and `M/D` at each Monday (the
32
+ * default), `'day'` every day's number and weekday under the month, `'month'`
33
+ * a line and `YYYY/M` at the first of each month.
34
+ */
35
+ export type Scale = 'week' | 'day' | 'month';
36
+ /**
37
+ * The days a chart shows, `from` through `to` (YYYY-MM-DD, both included). A
38
+ * bar running past either end is cut there and marked `← M/D` or `→ M/D`; a
39
+ * task wholly outside is drawn as its mark alone.
40
+ */
41
+ /**
42
+ * How the chart draws the progress line: `'shown'` (the default) is the line as
43
+ * before, `'hidden'` draws none, and `'by_row'` bends out from the today line to
44
+ * each row that is late or ahead and back at its bottom edge.
45
+ */
46
+ export type ProgressLineMode = 'shown' | 'hidden' | 'by_row';
47
+ export interface ViewRange {
48
+ from: string;
49
+ to: string;
50
+ }
30
51
  export interface ChartOptionsInput {
31
52
  today?: string | null;
32
53
  scrollViewport?: ScrollViewportOption | null;
@@ -39,6 +60,14 @@ export interface ChartOptionsInput {
39
60
  barHeightPx?: number | null;
40
61
  barAlign?: BarAlign | null;
41
62
  palette?: PaletteOverrides | null;
63
+ pxPerDay?: number | null;
64
+ scale?: Scale | null;
65
+ /** Weekday numbers drawn as weekend bands, 0 for Monday to 6 for Sunday. */
66
+ weekendDays?: number[] | null;
67
+ /** Seven labels, Monday first, for the `'day'` scale. */
68
+ weekdayLabels?: string[] | null;
69
+ view?: ViewRange | null;
70
+ progressLine?: ProgressLineMode | null;
42
71
  }
43
72
  /**
44
73
  * The object `options_json` carries. Every key is optional, and a chart drawn
@@ -56,5 +85,11 @@ export interface ChartOptions {
56
85
  bar_height_px?: number;
57
86
  bar_align?: BarAlign;
58
87
  palette?: PaletteOverrides;
88
+ px_per_day?: number;
89
+ scale?: Scale;
90
+ weekend_days?: number[];
91
+ weekday_labels?: string[];
92
+ view?: ViewRange;
93
+ progress_line?: ProgressLineMode;
59
94
  }
60
95
  export declare function buildOptionsJson(input: ChartOptionsInput): string | undefined;
@@ -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';
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';
3
3
  export interface CommandBuffer {
4
4
  viewport_width: number;
5
5
  viewport_height: number;
package/dist/types.d.ts CHANGED
@@ -24,15 +24,31 @@ export interface GanttTask {
24
24
  * One row of a chart whose rows the caller lays out (`rows` on `GanttChart`).
25
25
  * A task row draws that task's bar; a group row draws a band across the days
26
26
  * and no bar. `height` is in pixels; left out, the row is `rowHeight` tall.
27
+ *
28
+ * A task row may also carry marks; a row without them draws the bar as a chart
29
+ * without `rows` does.
30
+ * - `hard_deadline` (YYYY-MM-DD): a diamond in the middle of that day.
31
+ * - `state`: fills and outlines the bar (`normal`, `done`, `warn`).
32
+ * - `note`: a line of text past the bar and the diamond (at most 200 characters).
33
+ * - `shape`: `point` draws a dot on the span's last day instead of a bar, with a
34
+ * line to the diamond when the deadline is later.
27
35
  */
28
36
  export type GanttRow = {
29
37
  kind: 'task';
30
38
  task_id: string;
31
39
  height?: number;
40
+ hard_deadline?: string | null;
41
+ state?: BarState | null;
42
+ note?: string | null;
43
+ shape?: BarShape;
32
44
  } | {
33
45
  kind: 'group';
34
46
  height?: number;
35
47
  };
48
+ /** How a task row's bar is filled and outlined. */
49
+ export type BarState = 'normal' | 'done' | 'warn';
50
+ /** A task row drawn as a bar (the default) or as a dot on its last day. */
51
+ export type BarShape = 'bar' | 'point';
36
52
  /** Mirrors `task_relations` entity. */
37
53
  export interface GanttDep {
38
54
  /** `task_relations.blocker_task_id` */
@@ -38,6 +38,8 @@ export declare const EMPTY_SVG_MARKUP: string;
38
38
  * Reproduced where:
39
39
  * - `ROW_H`, `HEADER_H`, `LEGEND_H`, `CHART_BOTTOM_PADDING_PX` — the chart
40
40
  * height `chartHeightForTaskCount()` reserves before Wasm answers.
41
+ * - `DAY_SCALE_HEADER_H` — the header `chartHeightForRows()` reserves for the
42
+ * `'day'` scale when no height is set, the one the crate draws it with.
41
43
  * - `ROW_H`, `LABEL_W`, `BAR_H` — the loading skeleton's row metrics, which
42
44
  * stand in for real rows and must line up with them.
43
45
  * - `HIDDEN_LABELS_LEFT_PX` — the skeleton's left margin with the title column
@@ -46,6 +48,7 @@ export declare const EMPTY_SVG_MARKUP: string;
46
48
  export declare const RUST_LAYOUT: {
47
49
  readonly ROW_H: 40;
48
50
  readonly HEADER_H: 30;
51
+ readonly DAY_SCALE_HEADER_H: 48;
49
52
  readonly LEGEND_H: 40;
50
53
  readonly CHART_BOTTOM_PADDING_PX: 10;
51
54
  readonly LABEL_W: 120;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koyori-app/arc-vue",
3
- "version": "0.1.0-alpha.4",
3
+ "version": "0.1.0-alpha.5",
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.4"
46
+ "@koyori-app/arc": "0.1.0-alpha.5"
47
47
  },
48
48
  "scripts": {
49
49
  "build": "vite build",