@koyori-app/arc-vue 0.1.0-alpha.3 → 0.1.0-alpha.4
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/dist/GanttChart.vue.d.ts +42 -2
- package/dist/arc-vue.css +1 -1
- package/dist/arc-vue.js +215 -151
- package/dist/arc-vue.umd.cjs +1 -1
- package/dist/canvasFallback.d.ts +23 -0
- package/dist/index.d.ts +3 -3
- package/dist/options.d.ts +28 -0
- package/dist/replayCommands.d.ts +7 -1
- package/dist/types.d.ts +13 -0
- package/dist/wasmContract.d.ts +3 -0
- package/package.json +2 -2
package/dist/GanttChart.vue.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { GanttTask, GanttDep } from './types.ts';
|
|
1
|
+
import { GanttTask, GanttDep, GanttRow } from './types.ts';
|
|
2
|
+
import { PaletteOverrides } from './options';
|
|
2
3
|
type __VLS_Props = {
|
|
3
4
|
tasks: GanttTask[];
|
|
4
5
|
deps?: GanttDep[];
|
|
@@ -19,12 +20,51 @@ type __VLS_Props = {
|
|
|
19
20
|
* legend of every existing caller.
|
|
20
21
|
*/
|
|
21
22
|
legend?: 'shown' | 'hidden';
|
|
23
|
+
/**
|
|
24
|
+
* `'hidden'` leaves the title column out: the days start half a bar
|
|
25
|
+
* (`HIDDEN_LABELS_LEFT_PX`, or half of `barHeight` when it is set) in from
|
|
26
|
+
* the left edge, and a click hits only the bars and the milestones' diamonds.
|
|
27
|
+
* For a caller that lays the chart beside a list of its own. A string for the
|
|
28
|
+
* same reason as `legend`.
|
|
29
|
+
*/
|
|
30
|
+
rowLabels?: 'shown' | 'hidden';
|
|
31
|
+
/** `'hidden'` leaves out the `NN%` on every bar and milestone. */
|
|
32
|
+
percentLabels?: 'shown' | 'hidden';
|
|
33
|
+
/**
|
|
34
|
+
* The chart's rows, top to bottom, for a caller that lays them out itself
|
|
35
|
+
* beside a list of its own: task rows and group rows (a band, no bar). A
|
|
36
|
+
* task left out is not drawn. Left out, one row per task as the crate lays
|
|
37
|
+
* them out. See `docs/design/external-rows.md`.
|
|
38
|
+
*/
|
|
39
|
+
rows?: GanttRow[];
|
|
40
|
+
/** Height of a row in pixels. Left out, the crate's own. */
|
|
41
|
+
rowHeight?: number;
|
|
42
|
+
/** Height of the date header in pixels. Left out, the crate's own. */
|
|
43
|
+
headerHeight?: number;
|
|
44
|
+
/** Height of a bar in pixels. Left out, the crate's own. */
|
|
45
|
+
barHeight?: number;
|
|
46
|
+
/** `'bottom'` sets a bar low in a tall row, leaving the room above it. */
|
|
47
|
+
barAlign?: 'middle' | 'bottom';
|
|
48
|
+
/**
|
|
49
|
+
* Colours that replace the chart's own, by colour name, such as
|
|
50
|
+
* `{ HeaderBg: 'var(--koyori-color-surface)' }`. The SVG path writes
|
|
51
|
+
* `var(--…)` as it is, and the browser follows a token whenever it changes.
|
|
52
|
+
* The canvas path reads it off the canvas's computed style when it paints,
|
|
53
|
+
* and paints again when the colour scheme or an ancestor's `class`, `style`
|
|
54
|
+
* or `data-*` changes. A token changed any other way (a stylesheet swapped
|
|
55
|
+
* in, say) needs `repaint()`, or the palette passed again as a new object.
|
|
56
|
+
*/
|
|
57
|
+
palette?: PaletteOverrides;
|
|
22
58
|
/** Render backend — default `svg` preserves existing DOM projection. */
|
|
23
59
|
backend?: 'svg' | 'canvas';
|
|
24
60
|
/** Override auto-detected device tier (VRT / Storybook should pin this). */
|
|
25
61
|
deviceTier?: 'low' | 'high';
|
|
26
62
|
};
|
|
27
|
-
|
|
63
|
+
/** Paints the canvas again, once per frame however often it is asked. */
|
|
64
|
+
declare function repaint(): void;
|
|
65
|
+
declare const __VLS_export: import('vue').DefineComponent<__VLS_Props, {
|
|
66
|
+
repaint: typeof repaint;
|
|
67
|
+
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
28
68
|
taskClick: (task: GanttTask) => any;
|
|
29
69
|
}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
30
70
|
onTaskClick?: ((task: GanttTask) => any) | undefined;
|
package/dist/arc-vue.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
.koyori-gantt-scroll[data-v-
|
|
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}}
|
|
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
|
|
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";
|
|
3
3
|
//#region src/replayCommands.ts
|
|
4
|
-
var
|
|
4
|
+
var ce = [
|
|
5
5
|
"BarBg",
|
|
6
6
|
"TierLow",
|
|
7
7
|
"TierMid",
|
|
@@ -14,14 +14,25 @@ var g = [
|
|
|
14
14
|
"HeaderBg",
|
|
15
15
|
"GridLabel",
|
|
16
16
|
"ProgressTextOnFg",
|
|
17
|
-
"ProgressTextOnBg"
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
"ProgressTextOnBg",
|
|
18
|
+
"GroupRow"
|
|
19
|
+
], le = { GroupRow: "HeaderBg" };
|
|
20
|
+
function m(e, t) {
|
|
21
|
+
let n = e.palette.colors.find(([e]) => e === t);
|
|
22
|
+
if (n) return n[1];
|
|
23
|
+
let r = le[t];
|
|
24
|
+
return r ? m(e, r) : void 0;
|
|
25
|
+
}
|
|
26
|
+
function h(e, t) {
|
|
27
|
+
let n = /^var\((--[A-Za-z0-9_-]+)\)$/.exec(e);
|
|
28
|
+
return n ? !t || typeof getComputedStyle > "u" ? "#000000" : getComputedStyle(t).getPropertyValue(n[1]).trim() || "#000000" : e;
|
|
29
|
+
}
|
|
30
|
+
function g(e, t, n) {
|
|
20
31
|
if (t === 255) return "#374151";
|
|
21
|
-
let
|
|
22
|
-
return
|
|
32
|
+
let r = ce[t];
|
|
33
|
+
return r ? h(m(e, r) ?? "#000000", n) : "#000000";
|
|
23
34
|
}
|
|
24
|
-
function
|
|
35
|
+
function _(e, t, n, r, i) {
|
|
25
36
|
if (r <= 0 || i <= 0) return e;
|
|
26
37
|
let a = t + r, o = n + i;
|
|
27
38
|
if (e.w === 0 && e.h === 0) return {
|
|
@@ -38,20 +49,20 @@ function v(e, t, n, r, i) {
|
|
|
38
49
|
h: u - c
|
|
39
50
|
};
|
|
40
51
|
}
|
|
41
|
-
function
|
|
52
|
+
function v(e, t, n, r, i, a) {
|
|
42
53
|
if (a > 0 && typeof e.roundRect == "function") {
|
|
43
54
|
e.beginPath(), e.roundRect(t, n, r, i, a), e.fill();
|
|
44
55
|
return;
|
|
45
56
|
}
|
|
46
57
|
e.fillRect(t, n, r, i);
|
|
47
58
|
}
|
|
48
|
-
function
|
|
49
|
-
if (e.strokeStyle =
|
|
59
|
+
function y(e, t, n, r, i) {
|
|
60
|
+
if (e.strokeStyle = g(t, n, e.canvas), e.lineWidth = r, i) {
|
|
50
61
|
let t = i.split(",").map((e) => Number.parseFloat(e.trim()));
|
|
51
62
|
e.setLineDash(t.every(Number.isFinite) ? t : []);
|
|
52
63
|
} else e.setLineDash([]);
|
|
53
64
|
}
|
|
54
|
-
function
|
|
65
|
+
function b(e, t) {
|
|
55
66
|
let n = [], r = null, i = {
|
|
56
67
|
x: 0,
|
|
57
68
|
y: 0,
|
|
@@ -86,23 +97,23 @@ function x(e, t) {
|
|
|
86
97
|
}
|
|
87
98
|
if ("FillRect" in a) {
|
|
88
99
|
let { x: n, y: o, w: s, h: c, color_id: l, radius: u } = a.FillRect;
|
|
89
|
-
e.fillStyle =
|
|
100
|
+
e.fillStyle = g(t, l, e.canvas), v(e, n, o, s, c, u), r && (i = _(i, n, o, s, c));
|
|
90
101
|
continue;
|
|
91
102
|
}
|
|
92
103
|
if ("FillPolygon" in a) {
|
|
93
104
|
let { points: n, color_id: o } = a.FillPolygon;
|
|
94
105
|
if (n.length === 0) continue;
|
|
95
|
-
e.fillStyle =
|
|
106
|
+
e.fillStyle = g(t, o, e.canvas), e.beginPath(), e.moveTo(n[0][0], n[0][1]);
|
|
96
107
|
for (let t = 1; t < n.length; t++) e.lineTo(n[t][0], n[t][1]);
|
|
97
108
|
if (e.closePath(), e.fill(), r && n.length > 0) {
|
|
98
109
|
let e = n.map((e) => e[0]), t = n.map((e) => e[1]), r = Math.min(...e), a = Math.min(...t);
|
|
99
|
-
i =
|
|
110
|
+
i = _(i, r, a, Math.max(...e) - r, Math.max(...t) - a);
|
|
100
111
|
}
|
|
101
112
|
continue;
|
|
102
113
|
}
|
|
103
114
|
if ("StrokePath" in a) {
|
|
104
115
|
let { d: n, color_id: r, width: i } = a.StrokePath;
|
|
105
|
-
|
|
116
|
+
y(e, t, r, i, null);
|
|
106
117
|
let o = new Path2D(n);
|
|
107
118
|
e.stroke(o);
|
|
108
119
|
continue;
|
|
@@ -110,19 +121,19 @@ function x(e, t) {
|
|
|
110
121
|
if ("StrokePolyline" in a) {
|
|
111
122
|
let { points: n, color_id: r, width: i, dash: o } = a.StrokePolyline;
|
|
112
123
|
if (n.length < 2) continue;
|
|
113
|
-
|
|
124
|
+
y(e, t, r, i, o), e.beginPath(), e.moveTo(n[0][0], n[0][1]);
|
|
114
125
|
for (let t = 1; t < n.length; t++) e.lineTo(n[t][0], n[t][1]);
|
|
115
126
|
e.stroke();
|
|
116
127
|
continue;
|
|
117
128
|
}
|
|
118
129
|
if ("DrawText" in a) {
|
|
119
130
|
let { x: n, y: r, text: i, color_id: o, anchor: s, size: c, weight: l } = a.DrawText;
|
|
120
|
-
e.fillStyle =
|
|
131
|
+
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";
|
|
121
132
|
}
|
|
122
133
|
}
|
|
123
134
|
return { hitRegions: n };
|
|
124
135
|
}
|
|
125
|
-
function
|
|
136
|
+
function ue(e) {
|
|
126
137
|
try {
|
|
127
138
|
return JSON.parse(e);
|
|
128
139
|
} catch {
|
|
@@ -135,7 +146,7 @@ function oe(e) {
|
|
|
135
146
|
};
|
|
136
147
|
}
|
|
137
148
|
}
|
|
138
|
-
function
|
|
149
|
+
function de(e, t, n) {
|
|
139
150
|
for (let r = e.length - 1; r >= 0; r--) {
|
|
140
151
|
let i = e[r];
|
|
141
152
|
if (t >= i.x && t <= i.x + i.w && n >= i.y && n <= i.y + i.h) return i.taskId;
|
|
@@ -144,34 +155,35 @@ function S(e, t, n) {
|
|
|
144
155
|
}
|
|
145
156
|
//#endregion
|
|
146
157
|
//#region src/canvasLifecycle.ts
|
|
147
|
-
function
|
|
158
|
+
function fe(e) {
|
|
148
159
|
if (!e) return;
|
|
149
160
|
let t = e.getContext("2d");
|
|
150
161
|
t && t.clearRect(0, 0, e.width, e.height), e.width = 0, e.height = 0, e.style.width = "0px", e.style.height = "0px";
|
|
151
162
|
}
|
|
152
163
|
//#endregion
|
|
153
164
|
//#region src/options.ts
|
|
154
|
-
function
|
|
165
|
+
function pe(e) {
|
|
155
166
|
let t = {};
|
|
156
|
-
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), Object.keys(t).length === 0 ? void 0 : JSON.stringify(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);
|
|
157
168
|
}
|
|
158
|
-
var
|
|
169
|
+
var x = {
|
|
159
170
|
CODE_CANVAS_CAPACITY: "canvas_capacity",
|
|
160
171
|
CODE_INPUT_LIMIT: "input_limit",
|
|
161
172
|
CODE_PARSE_ERROR: "parse_error",
|
|
162
173
|
CODE_SERIALIZE_ERROR: "serialize_error"
|
|
163
|
-
}.CODE_CANVAS_CAPACITY,
|
|
174
|
+
}.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 = {
|
|
164
175
|
ROW_H: 40,
|
|
165
176
|
HEADER_H: 30,
|
|
166
177
|
LEGEND_H: 40,
|
|
167
178
|
CHART_BOTTOM_PADDING_PX: 10,
|
|
168
179
|
LABEL_W: 120,
|
|
169
|
-
BAR_H: 20
|
|
170
|
-
|
|
180
|
+
BAR_H: 20,
|
|
181
|
+
HIDDEN_LABELS_LEFT_PX: 10
|
|
182
|
+
}, C = {
|
|
171
183
|
MAX_CANVAS_SIDE_PX: 16384,
|
|
172
184
|
MAX_CANVAS_AREA_PX: 32 * 1024 * 1024
|
|
173
185
|
};
|
|
174
|
-
function
|
|
186
|
+
function he(e) {
|
|
175
187
|
try {
|
|
176
188
|
let t = JSON.parse(e);
|
|
177
189
|
return {
|
|
@@ -184,19 +196,19 @@ function le(e) {
|
|
|
184
196
|
}
|
|
185
197
|
//#endregion
|
|
186
198
|
//#region src/canvasScale.ts
|
|
187
|
-
function
|
|
199
|
+
function w(e, t, n) {
|
|
188
200
|
if (!(e > 0) || !(t > 0) || !(n > 0) || !Number.isFinite(n)) return 1;
|
|
189
|
-
let { MAX_CANVAS_SIDE_PX: r, MAX_CANVAS_AREA_PX: i } =
|
|
201
|
+
let { MAX_CANVAS_SIDE_PX: r, MAX_CANVAS_AREA_PX: i } = C, a = Math.min(r / e, r / t, Math.sqrt(i / (e * t)));
|
|
190
202
|
return Math.min(n, a);
|
|
191
203
|
}
|
|
192
|
-
function
|
|
193
|
-
let r =
|
|
204
|
+
function ge(e, t, n) {
|
|
205
|
+
let r = w(e, t, n);
|
|
194
206
|
return {
|
|
195
207
|
width: Math.floor(e * r),
|
|
196
208
|
height: Math.floor(t * r)
|
|
197
209
|
};
|
|
198
210
|
}
|
|
199
|
-
function
|
|
211
|
+
function _e(e, t, n, r, i) {
|
|
200
212
|
return !(n.width > 0) || !(n.height > 0) ? null : {
|
|
201
213
|
x: (e - n.left) * (r / n.width),
|
|
202
214
|
y: (t - n.top) * (i / n.height)
|
|
@@ -204,17 +216,19 @@ function de(e, t, n, r, i) {
|
|
|
204
216
|
}
|
|
205
217
|
//#endregion
|
|
206
218
|
//#region src/canvasFallback.ts
|
|
207
|
-
function
|
|
208
|
-
|
|
219
|
+
function ve(e, t, n = "shown", r = {}) {
|
|
220
|
+
if (t === 0) return 0;
|
|
221
|
+
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;
|
|
209
223
|
}
|
|
210
|
-
function
|
|
211
|
-
return e.code ===
|
|
224
|
+
function ye(e) {
|
|
225
|
+
return e.code === x;
|
|
212
226
|
}
|
|
213
|
-
function
|
|
227
|
+
function T(e, t) {
|
|
214
228
|
return e.startsWith("<svg ") && e !== t;
|
|
215
229
|
}
|
|
216
|
-
function
|
|
217
|
-
return
|
|
230
|
+
function be(e, t, n) {
|
|
231
|
+
return ye(e) && T(t, n) ? {
|
|
218
232
|
mode: "svg",
|
|
219
233
|
svg: t
|
|
220
234
|
} : {
|
|
@@ -222,17 +236,17 @@ function pe(e, t, n) {
|
|
|
222
236
|
message: e.message
|
|
223
237
|
};
|
|
224
238
|
}
|
|
239
|
+
function xe(e, t) {
|
|
240
|
+
let n = (t ?? S.BAR_H) / 2;
|
|
241
|
+
return e === "hidden" ? n : Math.max(S.LABEL_W, n);
|
|
242
|
+
}
|
|
225
243
|
//#endregion
|
|
226
244
|
//#region src/GanttChart.vue?vue&type=script&setup=true&lang.ts
|
|
227
|
-
var
|
|
228
|
-
key: 0,
|
|
229
|
-
class: "koyori-gantt-skeleton",
|
|
230
|
-
"aria-hidden": "true"
|
|
231
|
-
}, he = {
|
|
245
|
+
var Se = {
|
|
232
246
|
key: 0,
|
|
233
247
|
class: "koyori-gantt-error",
|
|
234
248
|
role: "alert"
|
|
235
|
-
},
|
|
249
|
+
}, Ce = ["innerHTML"], E = /*#__PURE__*/ ((e, t) => {
|
|
236
250
|
let n = e.__vccOpts || e;
|
|
237
251
|
for (let [e, r] of t) n[e] = r;
|
|
238
252
|
return n;
|
|
@@ -244,191 +258,241 @@ var me = {
|
|
|
244
258
|
today: {},
|
|
245
259
|
tzOffsetMinutes: {},
|
|
246
260
|
legend: {},
|
|
261
|
+
rowLabels: {},
|
|
262
|
+
percentLabels: {},
|
|
263
|
+
rows: {},
|
|
264
|
+
rowHeight: {},
|
|
265
|
+
headerHeight: {},
|
|
266
|
+
barHeight: {},
|
|
267
|
+
barAlign: {},
|
|
268
|
+
palette: {},
|
|
247
269
|
backend: {},
|
|
248
270
|
deviceTier: {}
|
|
249
271
|
},
|
|
250
272
|
emits: ["taskClick"],
|
|
251
|
-
setup(i, { emit:
|
|
273
|
+
setup(i, { expose: ie, emit: ce }) {
|
|
252
274
|
ne((e) => ({
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
v2293e8da: v
|
|
275
|
+
v578a3030: le.value,
|
|
276
|
+
v5782b517: h
|
|
256
277
|
}));
|
|
257
|
-
let
|
|
278
|
+
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 = {
|
|
258
279
|
width: 0,
|
|
259
280
|
height: 0
|
|
260
|
-
},
|
|
261
|
-
function
|
|
262
|
-
let t = e ??
|
|
263
|
-
t && (
|
|
281
|
+
}, j = d(me), M = t(() => g.backend === "canvas");
|
|
282
|
+
function N(e) {
|
|
283
|
+
let t = e ?? w.value;
|
|
284
|
+
t && (x.value = t.scrollTop, C.value = t.clientHeight);
|
|
264
285
|
}
|
|
265
286
|
l(async () => {
|
|
266
|
-
await p(),
|
|
287
|
+
await p(), j.value = re(), v.value = !0, await a(), N(), P.value && (F.value = !0);
|
|
267
288
|
});
|
|
268
|
-
function
|
|
269
|
-
if (
|
|
289
|
+
function we() {
|
|
290
|
+
if (g.deviceTier) return g.deviceTier;
|
|
270
291
|
if (typeof navigator > "u") return "low";
|
|
271
292
|
let e = navigator;
|
|
272
293
|
return e.deviceMemory === void 0 || e.deviceMemory <= 4 || navigator.hardwareConcurrency <= 4 ? "low" : "high";
|
|
273
294
|
}
|
|
274
|
-
let
|
|
275
|
-
f(
|
|
295
|
+
let Te = t(() => we()), P = t(() => Te.value === "low"), F = d(!1);
|
|
296
|
+
f(P, async (e) => {
|
|
276
297
|
if (!e) {
|
|
277
|
-
|
|
298
|
+
F.value = !1;
|
|
278
299
|
return;
|
|
279
300
|
}
|
|
280
|
-
|
|
301
|
+
F.value = !1, await a(), N(), F.value = !0;
|
|
281
302
|
}, { flush: "post" });
|
|
282
|
-
let
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
303
|
+
let Ee = t(() => z.value ? 0 : ve(g.rows, g.tasks.length, g.legend, {
|
|
304
|
+
rowHeight: g.rowHeight,
|
|
305
|
+
headerHeight: g.headerHeight
|
|
306
|
+
})), De = t(() => {
|
|
307
|
+
if (!(!P.value || !F.value)) return {
|
|
308
|
+
scroll_y: x.value,
|
|
309
|
+
client_height: C.value
|
|
286
310
|
};
|
|
287
|
-
})
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
311
|
+
});
|
|
312
|
+
function Oe(e) {
|
|
313
|
+
return pe({
|
|
314
|
+
today: g.today,
|
|
315
|
+
scrollViewport: e,
|
|
316
|
+
tzOffsetMinutes: g.tzOffsetMinutes,
|
|
317
|
+
legend: g.legend,
|
|
318
|
+
rowLabels: g.rowLabels,
|
|
319
|
+
percentLabels: g.percentLabels,
|
|
320
|
+
rowHeightPx: g.rowHeight,
|
|
321
|
+
headerHeightPx: g.headerHeight,
|
|
322
|
+
barHeightPx: g.barHeight,
|
|
323
|
+
barAlign: g.barAlign,
|
|
324
|
+
palette: g.palette
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
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));
|
|
328
|
+
f(Ae, (e) => {
|
|
329
|
+
e !== null && (y.value = e);
|
|
295
330
|
}, { immediate: !0 });
|
|
296
|
-
let
|
|
297
|
-
if (!
|
|
298
|
-
let e =
|
|
299
|
-
return e ?
|
|
300
|
-
}),
|
|
301
|
-
function
|
|
302
|
-
|
|
331
|
+
let je = t(() => {
|
|
332
|
+
if (!v.value || g.tasks.length === 0 || M.value || Ae.value !== j.value) return null;
|
|
333
|
+
let e = se(JSON.stringify(g.tasks), JSON.stringify(g.deps ?? []), I.value, ...L.value);
|
|
334
|
+
return e ? he(e) : null;
|
|
335
|
+
}), z = t(() => O.value || je.value?.message || "");
|
|
336
|
+
function B(e) {
|
|
337
|
+
E.value = [], fe(e);
|
|
303
338
|
}
|
|
304
|
-
function
|
|
305
|
-
|
|
339
|
+
function V() {
|
|
340
|
+
D.value = "", O.value = "", k.value = null;
|
|
306
341
|
}
|
|
307
|
-
function
|
|
308
|
-
|
|
342
|
+
function Me(e) {
|
|
343
|
+
k.value = e;
|
|
309
344
|
let t = "";
|
|
310
|
-
if (
|
|
311
|
-
t =
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
client_height: Math.min(k.value, 600)
|
|
316
|
-
},
|
|
317
|
-
tzOffsetMinutes: y.tzOffsetMinutes,
|
|
318
|
-
legend: y.legend
|
|
319
|
-
}));
|
|
345
|
+
if (ye(e)) try {
|
|
346
|
+
t = oe(JSON.stringify(g.tasks), JSON.stringify(g.deps ?? []), Oe({
|
|
347
|
+
scroll_y: x.value,
|
|
348
|
+
client_height: Math.min(C.value, 600)
|
|
349
|
+
}), ...L.value);
|
|
320
350
|
} catch {}
|
|
321
|
-
let n =
|
|
322
|
-
n.mode === "svg" ? (
|
|
351
|
+
let n = be(e, t, j.value);
|
|
352
|
+
n.mode === "svg" ? (D.value = n.svg, O.value = "") : (D.value = "", O.value = n.message);
|
|
323
353
|
}
|
|
324
|
-
f([
|
|
325
|
-
|
|
354
|
+
f([x, C], () => {
|
|
355
|
+
D.value && k.value && Me(k.value);
|
|
326
356
|
});
|
|
327
|
-
async function
|
|
328
|
-
let e =
|
|
357
|
+
async function H() {
|
|
358
|
+
let e = R.value;
|
|
329
359
|
if (!e) {
|
|
330
|
-
|
|
360
|
+
B(T.value), V();
|
|
331
361
|
return;
|
|
332
362
|
}
|
|
333
|
-
let t =
|
|
334
|
-
if (!t && (
|
|
335
|
-
let n =
|
|
363
|
+
let t = T.value;
|
|
364
|
+
if (!t && (V(), await a(), t = T.value, !t)) return;
|
|
365
|
+
let n = ue(e);
|
|
336
366
|
if (n.error) {
|
|
337
|
-
|
|
367
|
+
B(t), Me({
|
|
338
368
|
message: n.error,
|
|
339
369
|
code: n.code
|
|
340
370
|
});
|
|
341
371
|
return;
|
|
342
372
|
}
|
|
343
|
-
|
|
344
|
-
let r = n.viewport_width, i = n.viewport_height, o =
|
|
345
|
-
t.width = o.width, t.height = o.height, t.style.width = `${r}px`, t.style.height = `${i}px`,
|
|
373
|
+
V();
|
|
374
|
+
let r = n.viewport_width, i = n.viewport_height, o = ge(r, i, U.value);
|
|
375
|
+
t.width = o.width, t.height = o.height, t.style.width = `${r}px`, t.style.height = `${i}px`, A = {
|
|
346
376
|
width: r,
|
|
347
377
|
height: i
|
|
348
378
|
};
|
|
349
379
|
let s = t.getContext("2d");
|
|
350
380
|
if (!s) {
|
|
351
|
-
|
|
381
|
+
B(t);
|
|
352
382
|
return;
|
|
353
383
|
}
|
|
354
|
-
r > 0 && i > 0 && s.setTransform(o.width / r, 0, 0, o.height / i, 0, 0),
|
|
384
|
+
r > 0 && i > 0 && s.setTransform(o.width / r, 0, 0, o.height / i, 0, 0), E.value = b(s, n).hitRegions;
|
|
355
385
|
}
|
|
356
|
-
f(
|
|
357
|
-
a().then(
|
|
386
|
+
f(R, () => {
|
|
387
|
+
a().then(H);
|
|
358
388
|
}, { immediate: !0 });
|
|
359
|
-
let
|
|
360
|
-
function
|
|
389
|
+
let U = d(G()), W = null;
|
|
390
|
+
function G() {
|
|
361
391
|
return typeof window > "u" ? 1 : window.devicePixelRatio || 1;
|
|
362
392
|
}
|
|
363
|
-
function
|
|
364
|
-
|
|
393
|
+
function Ne() {
|
|
394
|
+
W?.removeEventListener("change", Fe), W = null;
|
|
365
395
|
}
|
|
366
|
-
function
|
|
367
|
-
|
|
396
|
+
function Pe() {
|
|
397
|
+
Ne(), !(typeof window > "u" || typeof window.matchMedia != "function") && (W = window.matchMedia(`(resolution: ${G()}dppx)`), W.addEventListener("change", Fe));
|
|
368
398
|
}
|
|
369
|
-
function
|
|
370
|
-
|
|
399
|
+
function Fe() {
|
|
400
|
+
U.value = G(), Pe();
|
|
371
401
|
}
|
|
372
|
-
l(
|
|
373
|
-
|
|
402
|
+
l(Pe), c(Ne), f(U, () => {
|
|
403
|
+
T.value && R.value && H();
|
|
374
404
|
});
|
|
375
|
-
|
|
376
|
-
|
|
405
|
+
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;
|
|
406
|
+
function Z() {
|
|
407
|
+
if (X) return;
|
|
408
|
+
let e = () => {
|
|
409
|
+
X = 0, T.value && R.value && H();
|
|
410
|
+
};
|
|
411
|
+
typeof requestAnimationFrame == "function" ? X = requestAnimationFrame(e) : e();
|
|
412
|
+
}
|
|
413
|
+
function Le(e) {
|
|
414
|
+
return e === "class" || e === "style" || (e?.startsWith("data-") ?? !1);
|
|
415
|
+
}
|
|
416
|
+
function Q() {
|
|
417
|
+
J?.removeEventListener("change", Z), J = null, Y?.disconnect(), Y = null;
|
|
418
|
+
}
|
|
419
|
+
function $() {
|
|
420
|
+
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)) {
|
|
421
|
+
Y = new MutationObserver((e) => {
|
|
422
|
+
e.some((e) => Le(e.attributeName)) && Z();
|
|
423
|
+
});
|
|
424
|
+
for (let e = K.value.parentElement; e; e = e.parentElement) Y.observe(e, { attributes: !0 });
|
|
425
|
+
}
|
|
377
426
|
}
|
|
378
|
-
|
|
427
|
+
l($), f(q, $), f(() => g.palette, () => {
|
|
428
|
+
$(), M.value && Z();
|
|
429
|
+
}), c(() => {
|
|
430
|
+
Q(), X && typeof cancelAnimationFrame == "function" && cancelAnimationFrame(X), X = 0;
|
|
431
|
+
}), ie({ repaint: Z });
|
|
432
|
+
function Re(e) {
|
|
433
|
+
N(e.target);
|
|
434
|
+
}
|
|
435
|
+
function ze(e) {
|
|
379
436
|
let t = e.target.closest("[data-task-id]");
|
|
380
437
|
if (!t) return;
|
|
381
|
-
let n = t.getAttribute("data-task-id"), r =
|
|
382
|
-
r &&
|
|
438
|
+
let n = t.getAttribute("data-task-id"), r = g.tasks.find((e) => e.id === n);
|
|
439
|
+
r && _("taskClick", r);
|
|
383
440
|
}
|
|
384
|
-
function
|
|
385
|
-
let t =
|
|
441
|
+
function Be(e) {
|
|
442
|
+
let t = T.value;
|
|
386
443
|
if (!t) return;
|
|
387
|
-
let n =
|
|
444
|
+
let n = _e(e.clientX, e.clientY, t.getBoundingClientRect(), A.width, A.height);
|
|
388
445
|
if (!n) return;
|
|
389
|
-
let r =
|
|
446
|
+
let r = de(E.value, n.x, n.y);
|
|
390
447
|
if (!r) return;
|
|
391
|
-
let i =
|
|
392
|
-
i &&
|
|
448
|
+
let i = g.tasks.find((e) => e.id === r);
|
|
449
|
+
i && _("taskClick", i);
|
|
393
450
|
}
|
|
394
451
|
return (t, i) => (u(), n("div", {
|
|
452
|
+
ref_key: "rootRef",
|
|
453
|
+
ref: K,
|
|
395
454
|
class: "koyori-gantt",
|
|
396
|
-
onClick: i[0] ||= (e) => (!
|
|
397
|
-
}, [
|
|
455
|
+
onClick: i[0] ||= (e) => (!M.value || D.value) && ze(e)
|
|
456
|
+
}, [v.value ? (u(), n("div", {
|
|
398
457
|
key: 1,
|
|
399
458
|
ref_key: "scrollRef",
|
|
400
|
-
ref:
|
|
401
|
-
class: o(["koyori-gantt-scroll", { "koyori-gantt-scroll--virtual":
|
|
402
|
-
onScroll:
|
|
403
|
-
}, [
|
|
459
|
+
ref: w,
|
|
460
|
+
class: o(["koyori-gantt-scroll", { "koyori-gantt-scroll--virtual": P.value || k.value }]),
|
|
461
|
+
onScroll: Re
|
|
462
|
+
}, [z.value ? (u(), n("div", Se, " Unable to render Gantt chart: " + te(z.value), 1)) : (u(), n("div", {
|
|
404
463
|
key: 1,
|
|
405
464
|
class: "koyori-gantt-inner",
|
|
406
|
-
style: s({ height: `${
|
|
407
|
-
}, [
|
|
465
|
+
style: s({ height: `${Ee.value}px` })
|
|
466
|
+
}, [M.value && !D.value ? (u(), n("canvas", {
|
|
408
467
|
key: 0,
|
|
409
468
|
ref_key: "canvasRef",
|
|
410
|
-
ref:
|
|
469
|
+
ref: T,
|
|
411
470
|
class: "koyori-gantt-canvas",
|
|
412
471
|
role: "img",
|
|
413
472
|
"aria-label": "Gantt chart",
|
|
414
|
-
onClick:
|
|
473
|
+
onClick: Be
|
|
415
474
|
}, null, 512)) : (u(), n("div", {
|
|
416
475
|
key: 1,
|
|
417
476
|
class: "koyori-gantt-svg",
|
|
418
|
-
innerHTML:
|
|
419
|
-
}, null, 8,
|
|
477
|
+
innerHTML: D.value || y.value
|
|
478
|
+
}, null, 8, Ce))], 4))], 34)) : (u(), n("div", {
|
|
479
|
+
key: 0,
|
|
480
|
+
class: "koyori-gantt-skeleton",
|
|
481
|
+
style: s({ "--koyori-skeleton-label-w": m.value }),
|
|
482
|
+
"aria-hidden": "true"
|
|
483
|
+
}, [(u(!0), n(e, null, ee(g.tasks, (e) => (u(), n("div", {
|
|
420
484
|
key: e.id,
|
|
421
485
|
class: "koyori-gantt-skeleton-row"
|
|
422
486
|
}, [i[1] ||= r("div", { class: "koyori-gantt-skeleton-label" }, null, -1), r("div", {
|
|
423
487
|
class: "koyori-gantt-skeleton-bar",
|
|
424
488
|
style: s({ width: `${e.progress_pct}%` })
|
|
425
|
-
}, null, 4)]))), 128))]))]));
|
|
489
|
+
}, null, 4)]))), 128))], 4))], 512));
|
|
426
490
|
}
|
|
427
|
-
}), [["__scopeId", "data-v-
|
|
491
|
+
}), [["__scopeId", "data-v-00f1f19b"]]);
|
|
428
492
|
//#endregion
|
|
429
493
|
//#region src/legend.ts
|
|
430
|
-
async function
|
|
431
|
-
return await p(), JSON.parse(
|
|
494
|
+
async function D() {
|
|
495
|
+
return await p(), JSON.parse(ie());
|
|
432
496
|
}
|
|
433
497
|
//#endregion
|
|
434
|
-
export {
|
|
498
|
+
export { E as GanttChart, de as findTaskAtPoint, D as loadLegendSpec, ue as parseCommandBuffer, b as replayCommands };
|
package/dist/arc-vue.umd.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("vue"),require("@koyori-app/arc")):typeof define==`function`&&define.amd?define([`exports`,`vue`,`@koyori-app/arc`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.ArcVue={},e.Vue,e.KoyoriArc))})(this,function(e,t,n){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var r=Object.create,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.getPrototypeOf,c=Object.prototype.hasOwnProperty,l=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var s=o(t),l=0,u=s.length,d;l<u;l++)d=s[l],!c.call(e,d)&&d!==n&&i(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=a(t,d))||r.enumerable});return e};n=((e,t,n)=>(n=e==null?{}:r(s(e)),l(t||!e||!e.__esModule?i(n,`default`,{value:e,enumerable:!0}):n,e)))(n,1);var u=[`BarBg`,`TierLow`,`TierMid`,`TierHigh`,`TierDone`,`Dep`,`Progress`,`Grid`,`Today`,`HeaderBg`,`GridLabel`,`ProgressTextOnFg`,`ProgressTextOnBg`];function d(e,t){if(t===255)return`#374151`;let n=u[t];return n?e.palette.colors.find(([e])=>e===n)?.[1]??`#000000`:`#000000`}function f(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 p(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 m(e,t,n,r,i){if(e.strokeStyle=d(t,n),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 h(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=d(t,l),p(e,n,o,s,c,u),r&&(i=f(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=d(t,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]);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=f(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;m(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;m(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=d(t,o),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 g(e){try{return JSON.parse(e)}catch{return{viewport_width:0,viewport_height:0,ops:[],palette:{colors:[]},error:`invalid json`}}}function _(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 v(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 y(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),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,x=`<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={ROW_H:40,HEADER_H:30,LEGEND_H:40,CHART_BOTTOM_PADDING_PX:10,LABEL_W:120,BAR_H:20},C={MAX_CANVAS_SIDE_PX:16384,MAX_CANVAS_AREA_PX:32*1024*1024};function w(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 T(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}=C,a=Math.min(r/e,r/t,Math.sqrt(i/(e*t)));return Math.min(n,a)}function E(e,t,n){let r=T(e,t,n);return{width:Math.floor(e*r),height:Math.floor(t*r)}}function ee(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 te(e,t=`shown`){return e===0?0:e*S.ROW_H+S.HEADER_H+(t===`hidden`?0:S.LEGEND_H)+S.CHART_BOTTOM_PADDING_PX}function D(e){return e.code===b}function O(e,t){return e.startsWith(`<svg `)&&e!==t}function ne(e,t,n){return D(e)&&O(t,n)?{mode:`svg`,svg:t}:{mode:`error`,message:e.message}}var re={key:0,class:`koyori-gantt-skeleton`,"aria-hidden":`true`},ie={key:0,class:`koyori-gantt-error`,role:`alert`},ae=[`innerHTML`],k=((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:{},backend:{},deviceTier:{}},emits:[`taskClick`],setup(e,{emit:r}){(0,t.useCssVars)(e=>({v229b63f3:i,v43727630:a,v2293e8da:o}));let i=`${S.ROW_H}px`,a=`${S.LABEL_W}px`,o=`${S.BAR_H}px`,s=e,c=r,l=(0,t.ref)(!1),u=(0,t.ref)(``),d=(0,t.ref)(0),f=(0,t.ref)(600),p=(0,t.ref)(null),m=(0,t.ref)(null),b=(0,t.ref)([]),C=(0,t.ref)(``),T=(0,t.ref)(``),O=(0,t.ref)(null),k={width:0,height:0},A=(0,t.ref)(x),j=(0,t.computed)(()=>s.backend===`canvas`);function M(e){let t=e??p.value;t&&(d.value=t.scrollTop,f.value=t.clientHeight)}(0,t.onMounted)(async()=>{await(0,n.default)(),A.value=(0,n.empty_svg_markup)(),l.value=!0,await(0,t.nextTick)(),M(),F.value&&(I.value=!0)});function N(){if(s.deviceTier)return s.deviceTier;if(typeof navigator>`u`)return`low`;let e=navigator;return e.deviceMemory===void 0||e.deviceMemory<=4||navigator.hardwareConcurrency<=4?`low`:`high`}let P=(0,t.computed)(()=>N()),F=(0,t.computed)(()=>P.value===`low`),I=(0,t.ref)(!1);(0,t.watch)(F,async e=>{if(!e){I.value=!1;return}I.value=!1,await(0,t.nextTick)(),M(),I.value=!0},{flush:`post`});let L=(0,t.computed)(()=>U.value?0:te(s.tasks.length,s.legend)),R=(0,t.computed)(()=>{if(!(!F.value||!I.value))return{scroll_y:d.value,client_height:f.value}}),z=(0,t.computed)(()=>y({today:s.today,scrollViewport:R.value,tzOffsetMinutes:s.tzOffsetMinutes,legend:s.legend})),B=(0,t.computed)(()=>F.value&&!I.value),V=(0,t.computed)(()=>!l.value||s.tasks.length===0||j.value?``:B.value?null:(0,n.render_svg)(JSON.stringify(s.tasks),JSON.stringify(s.deps??[]),z.value)),H=(0,t.computed)(()=>!l.value||s.tasks.length===0||!j.value||B.value?``:(0,n.render_canvas_commands)(JSON.stringify(s.tasks),JSON.stringify(s.deps??[]),z.value));(0,t.watch)(V,e=>{e!==null&&(u.value=e)},{immediate:!0});let oe=(0,t.computed)(()=>{if(!l.value||s.tasks.length===0||j.value||V.value!==A.value)return null;let e=(0,n.render_svg_error)(JSON.stringify(s.tasks),JSON.stringify(s.deps??[]),z.value);return e?w(e):null}),U=(0,t.computed)(()=>T.value||oe.value?.message||``);function W(e){b.value=[],v(e)}function G(){C.value=``,T.value=``,O.value=null}function K(e){O.value=e;let t=``;if(D(e))try{t=(0,n.render_svg)(JSON.stringify(s.tasks),JSON.stringify(s.deps??[]),y({today:s.today,scrollViewport:{scroll_y:d.value,client_height:Math.min(f.value,600)},tzOffsetMinutes:s.tzOffsetMinutes,legend:s.legend}))}catch{}let r=ne(e,t,A.value);r.mode===`svg`?(C.value=r.svg,T.value=``):(C.value=``,T.value=r.message)}(0,t.watch)([d,f],()=>{C.value&&O.value&&K(O.value)});async function q(){let e=H.value;if(!e){W(m.value),G();return}let n=m.value;if(!n&&(G(),await(0,t.nextTick)(),n=m.value,!n))return;let r=g(e);if(r.error){W(n),K({message:r.error,code:r.code});return}G();let i=r.viewport_width,a=r.viewport_height,o=E(i,a,J.value);n.width=o.width,n.height=o.height,n.style.width=`${i}px`,n.style.height=`${a}px`,k={width:i,height:a};let s=n.getContext(`2d`);if(!s){W(n);return}i>0&&a>0&&s.setTransform(o.width/i,0,0,o.height/a,0,0),b.value=h(s,r).hitRegions}(0,t.watch)(H,()=>{(0,t.nextTick)().then(q)},{immediate:!0});let J=(0,t.ref)(X()),Y=null;function X(){return typeof window>`u`?1:window.devicePixelRatio||1}function Z(){Y?.removeEventListener(`change`,$),Y=null}function Q(){Z(),!(typeof window>`u`||typeof window.matchMedia!=`function`)&&(Y=window.matchMedia(`(resolution: ${X()}dppx)`),Y.addEventListener(`change`,$))}function $(){J.value=X(),Q()}(0,t.onMounted)(Q),(0,t.onBeforeUnmount)(Z),(0,t.watch)(J,()=>{m.value&&H.value&&q()});function se(e){M(e.target)}function ce(e){let t=e.target.closest(`[data-task-id]`);if(!t)return;let n=t.getAttribute(`data-task-id`),r=s.tasks.find(e=>e.id===n);r&&c(`taskClick`,r)}function le(e){let t=m.value;if(!t)return;let n=ee(e.clientX,e.clientY,t.getBoundingClientRect(),k.width,k.height);if(!n)return;let r=_(b.value,n.x,n.y);if(!r)return;let i=s.tasks.find(e=>e.id===r);i&&c(`taskClick`,i)}return(e,n)=>((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{class:`koyori-gantt`,onClick:n[0]||=e=>(!j.value||C.value)&&ce(e)},[l.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:1,ref_key:`scrollRef`,ref:p,class:(0,t.normalizeClass)([`koyori-gantt-scroll`,{"koyori-gantt-scroll--virtual":F.value||O.value}]),onScroll:se},[U.value?((0,t.openBlock)(),(0,t.createElementBlock)(`div`,ie,` Unable to render Gantt chart: `+(0,t.toDisplayString)(U.value),1)):((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:1,class:`koyori-gantt-inner`,style:(0,t.normalizeStyle)({height:`${L.value}px`})},[j.value&&!C.value?((0,t.openBlock)(),(0,t.createElementBlock)(`canvas`,{key:0,ref_key:`canvasRef`,ref:m,class:`koyori-gantt-canvas`,role:`img`,"aria-label":`Gantt chart`,onClick:le},null,512)):((0,t.openBlock)(),(0,t.createElementBlock)(`div`,{key:1,class:`koyori-gantt-svg`,innerHTML:C.value||u.value},null,8,ae))],4))],34)):((0,t.openBlock)(),(0,t.createElementBlock)(`div`,re,[((0,t.openBlock)(!0),(0,t.createElementBlock)(t.Fragment,null,(0,t.renderList)(s.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))]))]))}}),[[`__scopeId`,`data-v-73e8a554`]]);async function A(){return await(0,n.default)(),JSON.parse((0,n.legend_spec_json)())}e.GanttChart=k,e.findTaskAtPoint=_,e.loadLegendSpec=A,e.parseCommandBuffer=g,e.replayCommands=h});
|
|
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});
|
package/dist/canvasFallback.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LegendMode } from './options';
|
|
2
|
+
import { GanttRow } from './types.ts';
|
|
2
3
|
import { RenderFailure } from './wasmContract';
|
|
3
4
|
export type CanvasFailureResolution = {
|
|
4
5
|
mode: 'svg';
|
|
@@ -12,6 +13,18 @@ export type CanvasFailureResolution = {
|
|
|
12
13
|
* A hidden legend takes no height, so the band it would occupy is left out.
|
|
13
14
|
*/
|
|
14
15
|
export declare function chartHeightForTaskCount(taskCount: number, legend?: LegendMode): number;
|
|
16
|
+
/** The sizes a caller may set, in pixels; each left out is the crate's own. */
|
|
17
|
+
export interface RowSizes {
|
|
18
|
+
rowHeight?: number;
|
|
19
|
+
headerHeight?: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* `chartHeightForTaskCount` for a chart that may lay out its own rows: the
|
|
23
|
+
* header, every row at its own height (or `rowHeight`), and below them the
|
|
24
|
+
* legend when shown and the bottom padding. Without `rows` it is one row per
|
|
25
|
+
* task, as the crate lays them out.
|
|
26
|
+
*/
|
|
27
|
+
export declare function chartHeightForRows(rows: GanttRow[] | undefined, taskCount: number, legend?: LegendMode, sizes?: RowSizes): number;
|
|
15
28
|
/**
|
|
16
29
|
* Canvas capacity errors can use the independently bounded SVG renderer.
|
|
17
30
|
* Decided by `code` alone — the message beside it is display text and is free
|
|
@@ -27,3 +40,13 @@ export declare function isCanvasCapacityError(failure: RenderFailure): boolean;
|
|
|
27
40
|
*/
|
|
28
41
|
export declare function isRenderedSvg(svg: string, emptySvgMarkup: string): boolean;
|
|
29
42
|
export declare function resolveCanvasFailure(failure: RenderFailure, fallbackSvg: string, emptySvgMarkup: string): CanvasFailureResolution;
|
|
43
|
+
/**
|
|
44
|
+
* The width of the loading skeleton's label column, which stands in for the
|
|
45
|
+
* chart's left margin, so the skeleton's bars start where the drawn chart's
|
|
46
|
+
* do. It reads the bar the chart draws (`barHeight`, or `BAR_H`) the way the
|
|
47
|
+
* crate's `label_width` does: with the titles shown, the title column
|
|
48
|
+
* `LABEL_W` unless half the bar is wider; with them hidden, half the bar
|
|
49
|
+
* (`HIDDEN_LABELS_LEFT_PX` for the default bar). Half the bar is the room a
|
|
50
|
+
* first-day milestone's diamond needs.
|
|
51
|
+
*/
|
|
52
|
+
export declare function skeletonLabelWidthPx(rowLabels?: 'shown' | 'hidden', barHeight?: number): number;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { default as GanttChart } from './GanttChart.vue';
|
|
2
|
-
export type { GanttTask, GanttDep } from './types.ts';
|
|
2
|
+
export type { GanttTask, GanttDep, GanttRow } from './types.ts';
|
|
3
3
|
export { replayCommands, parseCommandBuffer, findTaskAtPoint, } from './replayCommands';
|
|
4
|
-
export type { CommandBuffer, DrawOp, ReplayResult, TaskHitRegion } from './replayCommands';
|
|
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 { ChartOptions, LegendMode } from './options';
|
|
7
|
+
export type { BarAlign, ChartOptions, LabelMode, LegendMode, PaletteOverrides } from './options';
|
package/dist/options.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ColorIdName } from './replayCommands';
|
|
1
2
|
/**
|
|
2
3
|
* The `options_json` string the Wasm entry points take.
|
|
3
4
|
*
|
|
@@ -13,11 +14,31 @@ export interface ScrollViewportOption {
|
|
|
13
14
|
}
|
|
14
15
|
/** Whether the chart draws its own legend. Left out, the legend is drawn. */
|
|
15
16
|
export type LegendMode = 'shown' | 'hidden';
|
|
17
|
+
/**
|
|
18
|
+
* Whether the chart draws one kind of its own text: `rowLabels` the task titles
|
|
19
|
+
* left of the days, `percentLabels` the `NN%` on each bar. Left out, it is drawn.
|
|
20
|
+
*/
|
|
21
|
+
export type LabelMode = 'shown' | 'hidden';
|
|
22
|
+
/**
|
|
23
|
+
* Colours that replace the chart's own, by colour name. A value is a CSS
|
|
24
|
+
* colour: `#hex`, `rgb()`/`hsl()`/`oklch()`, or `var(--name)` to draw with the
|
|
25
|
+
* caller's design tokens. The crate refuses anything else.
|
|
26
|
+
*/
|
|
27
|
+
export type PaletteOverrides = Partial<Record<ColorIdName, string>>;
|
|
28
|
+
/** Where a bar sits in its row. Left out, it is centred. */
|
|
29
|
+
export type BarAlign = 'middle' | 'bottom';
|
|
16
30
|
export interface ChartOptionsInput {
|
|
17
31
|
today?: string | null;
|
|
18
32
|
scrollViewport?: ScrollViewportOption | null;
|
|
19
33
|
tzOffsetMinutes?: number | null;
|
|
20
34
|
legend?: LegendMode | null;
|
|
35
|
+
rowLabels?: LabelMode | null;
|
|
36
|
+
percentLabels?: LabelMode | null;
|
|
37
|
+
rowHeightPx?: number | null;
|
|
38
|
+
headerHeightPx?: number | null;
|
|
39
|
+
barHeightPx?: number | null;
|
|
40
|
+
barAlign?: BarAlign | null;
|
|
41
|
+
palette?: PaletteOverrides | null;
|
|
21
42
|
}
|
|
22
43
|
/**
|
|
23
44
|
* The object `options_json` carries. Every key is optional, and a chart drawn
|
|
@@ -28,5 +49,12 @@ export interface ChartOptions {
|
|
|
28
49
|
scroll_viewport?: ScrollViewportOption;
|
|
29
50
|
tz_offset_minutes?: number | string;
|
|
30
51
|
legend?: LegendMode;
|
|
52
|
+
row_labels?: LabelMode;
|
|
53
|
+
percent_labels?: LabelMode;
|
|
54
|
+
row_height_px?: number;
|
|
55
|
+
header_height_px?: number;
|
|
56
|
+
bar_height_px?: number;
|
|
57
|
+
bar_align?: BarAlign;
|
|
58
|
+
palette?: PaletteOverrides;
|
|
31
59
|
}
|
|
32
60
|
export declare function buildOptionsJson(input: ChartOptionsInput): string | undefined;
|
package/dist/replayCommands.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Mirrors koyori-arc-core `CommandBuffer` JSON (serde externally-tagged `DrawOp`). */
|
|
2
|
-
export type ColorIdName = 'BarBg' | 'TierLow' | 'TierMid' | 'TierHigh' | 'TierDone' | 'Dep' | 'Progress' | 'Grid' | 'Today' | 'HeaderBg' | 'GridLabel' | 'ProgressTextOnFg' | 'ProgressTextOnBg';
|
|
2
|
+
export type ColorIdName = 'BarBg' | 'TierLow' | 'TierMid' | 'TierHigh' | 'TierDone' | 'Dep' | 'Progress' | 'Grid' | 'Today' | 'HeaderBg' | 'GridLabel' | 'ProgressTextOnFg' | 'ProgressTextOnBg' | 'GroupRow';
|
|
3
3
|
export interface CommandBuffer {
|
|
4
4
|
viewport_width: number;
|
|
5
5
|
viewport_height: number;
|
|
@@ -63,6 +63,12 @@ export interface TaskHitRegion {
|
|
|
63
63
|
export interface ReplayResult {
|
|
64
64
|
hitRegions: TaskHitRegion[];
|
|
65
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* A canvas cannot draw `var(--name)`, which the SVG path writes as it is. It is
|
|
68
|
+
* read off the canvas element's computed style, where the caller's tokens are
|
|
69
|
+
* in scope; a name with no value there draws black, as a missing colour does.
|
|
70
|
+
*/
|
|
71
|
+
export declare function resolveCssColor(color: string, el: Element | undefined): string;
|
|
66
72
|
/**
|
|
67
73
|
* Replay a wasm-produced `CommandBuffer` onto a Canvas2D context.
|
|
68
74
|
* Single JS loop — no per-op wasm round-trips.
|
package/dist/types.d.ts
CHANGED
|
@@ -20,6 +20,19 @@ export interface GanttTask {
|
|
|
20
20
|
*/
|
|
21
21
|
end?: string;
|
|
22
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* One row of a chart whose rows the caller lays out (`rows` on `GanttChart`).
|
|
25
|
+
* A task row draws that task's bar; a group row draws a band across the days
|
|
26
|
+
* and no bar. `height` is in pixels; left out, the row is `rowHeight` tall.
|
|
27
|
+
*/
|
|
28
|
+
export type GanttRow = {
|
|
29
|
+
kind: 'task';
|
|
30
|
+
task_id: string;
|
|
31
|
+
height?: number;
|
|
32
|
+
} | {
|
|
33
|
+
kind: 'group';
|
|
34
|
+
height?: number;
|
|
35
|
+
};
|
|
23
36
|
/** Mirrors `task_relations` entity. */
|
|
24
37
|
export interface GanttDep {
|
|
25
38
|
/** `task_relations.blocker_task_id` */
|
package/dist/wasmContract.d.ts
CHANGED
|
@@ -40,6 +40,8 @@ export declare const EMPTY_SVG_MARKUP: string;
|
|
|
40
40
|
* height `chartHeightForTaskCount()` reserves before Wasm answers.
|
|
41
41
|
* - `ROW_H`, `LABEL_W`, `BAR_H` — the loading skeleton's row metrics, which
|
|
42
42
|
* stand in for real rows and must line up with them.
|
|
43
|
+
* - `HIDDEN_LABELS_LEFT_PX` — the skeleton's left margin with the title column
|
|
44
|
+
* hidden: the chart keeps half a bar there for a first-day milestone.
|
|
43
45
|
*/
|
|
44
46
|
export declare const RUST_LAYOUT: {
|
|
45
47
|
readonly ROW_H: 40;
|
|
@@ -48,6 +50,7 @@ export declare const RUST_LAYOUT: {
|
|
|
48
50
|
readonly CHART_BOTTOM_PADDING_PX: 10;
|
|
49
51
|
readonly LABEL_W: 120;
|
|
50
52
|
readonly BAR_H: 20;
|
|
53
|
+
readonly HIDDEN_LABELS_LEFT_PX: 10;
|
|
51
54
|
};
|
|
52
55
|
/**
|
|
53
56
|
* Keys are the Rust constant names in `crates/koyori-arc-core/src/render.rs`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koyori-app/arc-vue",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MPL-2.0 OR GPL-2.0-or-later",
|
|
6
6
|
"repository": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"vitest": "^4.1.10",
|
|
44
44
|
"vue": "^3.5.39",
|
|
45
45
|
"vue-tsc": "^3.3.7",
|
|
46
|
-
"@koyori-app/arc": "0.1.0-alpha.
|
|
46
|
+
"@koyori-app/arc": "0.1.0-alpha.4"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "vite build",
|