@parallelworks/tandem-web 0.192.2 → 0.194.0
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/_virtual/_virtual_i18n/en/common.js +23 -5
- package/_virtual/_virtual_i18n/es/common.js +23 -5
- package/_virtual/_virtual_i18n/ja/common.js +23 -5
- package/_virtual/_virtual_i18n/ko/common.js +23 -5
- package/_virtual/_virtual_i18n/zh/common.js +23 -5
- package/api/queries.js +2 -1
- package/components/DashboardPanel.js +70 -57
- package/components/DocIconPicker.js +17 -8
- package/components/DocLook.js +93 -68
- package/components/DocTable.js +67 -66
- package/components/DocsTree.js +182 -182
- package/components/IssueBreakdown.js +1 -1
- package/components/IssueImport.js +95 -46
- package/components/IssueView.js +397 -397
- package/components/SubPages.js +60 -57
- package/components/SubpageViews.js +379 -365
- package/lib/docs.js +203 -133
- package/lib/menus.js +15 -1
- package/package.json +1 -1
- package/pages/issues.js +421 -455
- package/routes/_workspace/dashboards/_dashboardId2.js +26 -2
- package/routes/_workspace/docs/_doc2.js +227 -227
- package/routes/_workspace/teams/_key/settings2.js +202 -196
- package/routes/_workspace2.js +157 -155
|
@@ -17,9 +17,10 @@ function b(e) {
|
|
|
17
17
|
var x = /* @__PURE__ */ new Set([
|
|
18
18
|
"created_completed",
|
|
19
19
|
"open",
|
|
20
|
-
"throughput"
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
"throughput",
|
|
21
|
+
"active_users"
|
|
22
|
+
]), S = "total", C = (e) => e.days.length > 0 ? e.days : e.weeks;
|
|
23
|
+
function w(e) {
|
|
23
24
|
return [
|
|
24
25
|
{
|
|
25
26
|
title: e("starter.createdCompleted"),
|
|
@@ -59,7 +60,7 @@ function S(e) {
|
|
|
59
60
|
}
|
|
60
61
|
];
|
|
61
62
|
}
|
|
62
|
-
function
|
|
63
|
+
function T(e, t) {
|
|
63
64
|
return [
|
|
64
65
|
{
|
|
65
66
|
value: "private",
|
|
@@ -75,7 +76,7 @@ function C(e, t) {
|
|
|
75
76
|
}))
|
|
76
77
|
];
|
|
77
78
|
}
|
|
78
|
-
function
|
|
79
|
+
function E(e) {
|
|
79
80
|
return e === "private" ? {
|
|
80
81
|
shared: !1,
|
|
81
82
|
team: ""
|
|
@@ -87,7 +88,7 @@ function w(e) {
|
|
|
87
88
|
team: e.slice(5)
|
|
88
89
|
};
|
|
89
90
|
}
|
|
90
|
-
function
|
|
91
|
+
function D({ workspace: t, panel: o, onEdit: s, onDelete: c }) {
|
|
91
92
|
let u = g("dashboards"), { data: d, isPending: f, isError: p } = y({
|
|
92
93
|
...e(t, o.chart, o.spec),
|
|
93
94
|
refetchInterval: 6e4
|
|
@@ -108,7 +109,7 @@ function T({ workspace: t, panel: o, onEdit: s, onDelete: c }) {
|
|
|
108
109
|
size: "sm",
|
|
109
110
|
icon: /* @__PURE__ */ _(n, {}),
|
|
110
111
|
label: u("csv"),
|
|
111
|
-
onClick: () =>
|
|
112
|
+
onClick: () => F(o.title || o.spec.measure, d, u)
|
|
112
113
|
}),
|
|
113
114
|
s && /* @__PURE__ */ _(l, {
|
|
114
115
|
variant: "ghost",
|
|
@@ -133,7 +134,7 @@ function T({ workspace: t, panel: o, onEdit: s, onDelete: c }) {
|
|
|
133
134
|
}) : p || !d ? /* @__PURE__ */ _("p", {
|
|
134
135
|
className: "text-sm text-danger",
|
|
135
136
|
children: u("failed")
|
|
136
|
-
}) : /* @__PURE__ */ _(
|
|
137
|
+
}) : /* @__PURE__ */ _(k, {
|
|
137
138
|
workspace: t,
|
|
138
139
|
panel: o,
|
|
139
140
|
data: d
|
|
@@ -141,12 +142,12 @@ function T({ workspace: t, panel: o, onEdit: s, onDelete: c }) {
|
|
|
141
142
|
})]
|
|
142
143
|
});
|
|
143
144
|
}
|
|
144
|
-
function
|
|
145
|
+
function O(e) {
|
|
145
146
|
let t = h(), n = g("dashboards");
|
|
146
147
|
return (r) => e === "days" ? n("daysValue", { days: t.number(r, { maximumFractionDigits: 1 }) }) : t.number(r, { maximumFractionDigits: +(e === "points") });
|
|
147
148
|
}
|
|
148
|
-
function
|
|
149
|
-
let i = g("dashboards"), a =
|
|
149
|
+
function k({ workspace: e, panel: n, data: r }) {
|
|
150
|
+
let i = g("dashboards"), a = O(r.unit), o = r.series.length > 0 && C(r).length > 0, s = n.chart;
|
|
150
151
|
return s === "number" ? /* @__PURE__ */ v(t, {
|
|
151
152
|
to: "/$workspace/issues",
|
|
152
153
|
params: { workspace: e },
|
|
@@ -159,7 +160,7 @@ function D({ workspace: e, panel: n, data: r }) {
|
|
|
159
160
|
className: "text-xs text-muted-foreground",
|
|
160
161
|
children: i(`units.${r.unit}`)
|
|
161
162
|
})]
|
|
162
|
-
}) : s === "list" ? r.issues.length === 0 ? /* @__PURE__ */ _(
|
|
163
|
+
}) : s === "list" ? r.issues.length === 0 ? /* @__PURE__ */ _(A, {}) : /* @__PURE__ */ _("ul", {
|
|
163
164
|
className: "divide-y divide-border text-sm",
|
|
164
165
|
children: r.issues.map((n) => /* @__PURE__ */ _("li", { children: /* @__PURE__ */ v(t, {
|
|
165
166
|
to: "/$workspace/issues/$identifier",
|
|
@@ -183,7 +184,7 @@ function D({ workspace: e, panel: n, data: r }) {
|
|
|
183
184
|
})
|
|
184
185
|
]
|
|
185
186
|
}) }, n.identifier))
|
|
186
|
-
}) : s === "table" ? r.rows.length === 0 ? /* @__PURE__ */ _(
|
|
187
|
+
}) : s === "table" ? r.rows.length === 0 ? /* @__PURE__ */ _(A, {}) : /* @__PURE__ */ v("table", {
|
|
187
188
|
className: "w-full text-sm",
|
|
188
189
|
children: [/* @__PURE__ */ _("thead", { children: /* @__PURE__ */ v("tr", {
|
|
189
190
|
className: "text-left text-xs text-muted-foreground",
|
|
@@ -203,37 +204,37 @@ function D({ workspace: e, panel: n, data: r }) {
|
|
|
203
204
|
params: { workspace: e },
|
|
204
205
|
search: b(r.filter),
|
|
205
206
|
className: "hover:underline",
|
|
206
|
-
children:
|
|
207
|
+
children: j(r.name, n.spec.groupBy, i)
|
|
207
208
|
})
|
|
208
209
|
}), /* @__PURE__ */ _("td", {
|
|
209
210
|
className: "py-1.5 text-right tabular-nums",
|
|
210
211
|
children: a(r.value)
|
|
211
212
|
})] }, r.key || "-"))
|
|
212
213
|
})]
|
|
213
|
-
}) : o && (s === "line" || s === "stacked" || x.has(n.spec.measure)) ? /* @__PURE__ */ _(
|
|
214
|
+
}) : o && (s === "line" || s === "stacked" || x.has(n.spec.measure)) ? /* @__PURE__ */ _(P, {
|
|
214
215
|
workspace: e,
|
|
215
216
|
data: r,
|
|
216
217
|
stacked: s !== "line",
|
|
217
|
-
names: (e) => e.key === "created" || e.key === "completed" ? i(`series.${e.key}`) :
|
|
218
|
+
names: (e) => e.key === "created" || e.key === "completed" || e.key === S ? i(`series.${e.key}`) : j(e.name, n.spec.groupBy, i),
|
|
218
219
|
value: a
|
|
219
|
-
}) : r.rows.length === 0 || r.rows.every((e) => e.value === 0) ? /* @__PURE__ */ _(
|
|
220
|
+
}) : r.rows.length === 0 || r.rows.every((e) => e.value === 0) ? /* @__PURE__ */ _(A, {}) : _(s === "pie" ? N : M, {
|
|
220
221
|
workspace: e,
|
|
221
222
|
data: r,
|
|
222
223
|
groupBy: n.spec.groupBy,
|
|
223
224
|
value: a
|
|
224
225
|
});
|
|
225
226
|
}
|
|
226
|
-
function
|
|
227
|
+
function A() {
|
|
227
228
|
let e = g("dashboards");
|
|
228
229
|
return /* @__PURE__ */ _("p", {
|
|
229
230
|
className: "text-sm text-muted-foreground",
|
|
230
231
|
children: e("empty")
|
|
231
232
|
});
|
|
232
233
|
}
|
|
233
|
-
function
|
|
234
|
+
function j(e, t, n) {
|
|
234
235
|
return t === "priority" ? n(`priorities.${e}`) : t === "status" && e ? n(`categories.${e}`) : t ? e || n("none") : n("all");
|
|
235
236
|
}
|
|
236
|
-
function
|
|
237
|
+
function M({ workspace: e, data: n, groupBy: r, value: i }) {
|
|
237
238
|
let a = g("dashboards"), o = Math.max(...n.rows.map((e) => e.value), 1);
|
|
238
239
|
return /* @__PURE__ */ _("ul", {
|
|
239
240
|
className: "space-y-1.5",
|
|
@@ -245,7 +246,7 @@ function A({ workspace: e, data: n, groupBy: r, value: i }) {
|
|
|
245
246
|
children: [
|
|
246
247
|
/* @__PURE__ */ _("span", {
|
|
247
248
|
className: "truncate text-muted-foreground group-hover:text-foreground",
|
|
248
|
-
children:
|
|
249
|
+
children: j(n.name, r, a)
|
|
249
250
|
}),
|
|
250
251
|
/* @__PURE__ */ _("span", {
|
|
251
252
|
className: "h-4 rounded-sm bg-muted",
|
|
@@ -262,7 +263,7 @@ function A({ workspace: e, data: n, groupBy: r, value: i }) {
|
|
|
262
263
|
}) }, n.key))
|
|
263
264
|
});
|
|
264
265
|
}
|
|
265
|
-
function
|
|
266
|
+
function N({ workspace: e, data: n, groupBy: r, value: i }) {
|
|
266
267
|
let a = g("dashboards"), o = n.rows.filter((e) => e.value > 0), { keys: s, folded: c } = f(o.map((e) => e.key)), l = p(s), m = s.map((e) => {
|
|
267
268
|
if (e === u) return {
|
|
268
269
|
key: e,
|
|
@@ -273,7 +274,7 @@ function j({ workspace: e, data: n, groupBy: r, value: i }) {
|
|
|
273
274
|
let t = o.find((t) => t.key === e);
|
|
274
275
|
return {
|
|
275
276
|
key: e,
|
|
276
|
-
name:
|
|
277
|
+
name: j(t.name, r, a),
|
|
277
278
|
value: t.value,
|
|
278
279
|
filter: t.filter
|
|
279
280
|
};
|
|
@@ -325,23 +326,30 @@ function j({ workspace: e, data: n, groupBy: r, value: i }) {
|
|
|
325
326
|
})]
|
|
326
327
|
});
|
|
327
328
|
}
|
|
328
|
-
function
|
|
329
|
-
let l = g("dashboards"), d = h(), [y, x] = m(null),
|
|
329
|
+
function P({ workspace: e, data: n, stacked: r, names: i, value: a }) {
|
|
330
|
+
let l = g("dashboards"), d = h(), [y, x] = m(null), w = C(n), T = n.days.length > 0, E = n.series.find((e) => e.key === S), D = E ? n.series.filter((e) => e !== E) : n.series, { keys: O, folded: k } = f(D.map((e) => e.key)), A = {
|
|
331
|
+
...p(O),
|
|
332
|
+
[S]: "var(--color-muted-foreground)"
|
|
333
|
+
}, j = O.map((e) => {
|
|
330
334
|
if (e === u) {
|
|
331
|
-
let t =
|
|
335
|
+
let t = D.filter((e) => k.includes(e.key));
|
|
332
336
|
return {
|
|
333
337
|
key: e,
|
|
334
338
|
name: l("other"),
|
|
335
|
-
values:
|
|
339
|
+
values: w.map((e, n) => t.reduce((e, t) => e + (t.values[n] ?? 0), 0))
|
|
336
340
|
};
|
|
337
341
|
}
|
|
338
|
-
let t =
|
|
342
|
+
let t = D.find((t) => t.key === e);
|
|
339
343
|
return {
|
|
340
344
|
key: e,
|
|
341
345
|
name: i(t),
|
|
342
346
|
values: t.values
|
|
343
347
|
};
|
|
344
|
-
}),
|
|
348
|
+
}), M = E ? [{
|
|
349
|
+
key: S,
|
|
350
|
+
name: i(E),
|
|
351
|
+
values: E.values
|
|
352
|
+
}] : [], N = [...j, ...M], P = w.length, F = w.map((e, t) => j.reduce((e, n) => e + (n.values[t] ?? 0), 0)), I = Math.max(1, ...r ? F : j.flatMap((e) => e.values), ...M.flatMap((e) => e.values)), L = 300 / P, R = (e) => 120 - e / I * 120, z = (e) => d.dateTime(/* @__PURE__ */ new Date(`${w[e]}T00:00:00Z`), {
|
|
345
353
|
month: "short",
|
|
346
354
|
day: "numeric",
|
|
347
355
|
timeZone: "UTC"
|
|
@@ -357,23 +365,23 @@ function M({ workspace: e, data: n, stacked: r, names: i, value: a }) {
|
|
|
357
365
|
viewBox: "0 0 300 134",
|
|
358
366
|
className: "h-40 w-full overflow-visible",
|
|
359
367
|
role: "img",
|
|
360
|
-
"aria-label": l("overTime"),
|
|
368
|
+
"aria-label": l(T ? "overTimeDaily" : "overTime"),
|
|
361
369
|
onPointerMove: (e) => {
|
|
362
370
|
let t = e.currentTarget, n = t.getScreenCTM();
|
|
363
371
|
if (!n) return;
|
|
364
|
-
let r = Math.floor((e.clientX - n.e) / n.a /
|
|
365
|
-
if (r < 0 || r >=
|
|
372
|
+
let r = Math.floor((e.clientX - n.e) / n.a / L);
|
|
373
|
+
if (r < 0 || r >= P) return x(null);
|
|
366
374
|
let i = t.getBoundingClientRect().left;
|
|
367
375
|
x({
|
|
368
376
|
i: r,
|
|
369
|
-
x: n.a * (r + .5) *
|
|
377
|
+
x: n.a * (r + .5) * L + n.e - i
|
|
370
378
|
});
|
|
371
379
|
},
|
|
372
380
|
onPointerLeave: () => x(null),
|
|
373
381
|
children: [
|
|
374
382
|
y && /* @__PURE__ */ _("rect", {
|
|
375
|
-
x: y.i *
|
|
376
|
-
width:
|
|
383
|
+
x: y.i * L,
|
|
384
|
+
width: L,
|
|
377
385
|
y: 0,
|
|
378
386
|
height: 120,
|
|
379
387
|
rx: 3,
|
|
@@ -390,65 +398,70 @@ function M({ workspace: e, data: n, stacked: r, names: i, value: a }) {
|
|
|
390
398
|
x: 0,
|
|
391
399
|
y: 8,
|
|
392
400
|
className: "fill-muted-foreground text-[8px]",
|
|
393
|
-
children: a(
|
|
401
|
+
children: a(I)
|
|
394
402
|
}),
|
|
395
|
-
r ?
|
|
403
|
+
r ? w.map((e, t) => {
|
|
396
404
|
let n = 120;
|
|
397
|
-
return /* @__PURE__ */ _("g", { children:
|
|
398
|
-
let r = (e.values[t] ?? 0) /
|
|
405
|
+
return /* @__PURE__ */ _("g", { children: j.map((e) => {
|
|
406
|
+
let r = (e.values[t] ?? 0) / I * 120;
|
|
399
407
|
return n -= r, /* @__PURE__ */ _("rect", {
|
|
400
|
-
x: t *
|
|
401
|
-
width:
|
|
408
|
+
x: t * L + L * .15,
|
|
409
|
+
width: L * .7,
|
|
402
410
|
y: n,
|
|
403
411
|
height: r,
|
|
404
|
-
fill:
|
|
412
|
+
fill: A[e.key]
|
|
405
413
|
}, e.key);
|
|
406
414
|
}) }, t);
|
|
407
|
-
}) :
|
|
415
|
+
}) : null,
|
|
416
|
+
(r ? M : N).map((e) => /* @__PURE__ */ _("polyline", {
|
|
408
417
|
fill: "none",
|
|
409
|
-
stroke:
|
|
418
|
+
stroke: A[e.key],
|
|
410
419
|
strokeWidth: 2,
|
|
420
|
+
...e.key === S && {
|
|
421
|
+
strokeDasharray: "0 5",
|
|
422
|
+
strokeLinecap: "round"
|
|
423
|
+
},
|
|
411
424
|
vectorEffect: "non-scaling-stroke",
|
|
412
|
-
points: e.values.map((e, t) => `${t *
|
|
425
|
+
points: e.values.map((e, t) => `${t * L + L / 2},${R(e)}`).join(" ")
|
|
413
426
|
}, e.key)),
|
|
414
427
|
[
|
|
415
428
|
0,
|
|
416
|
-
Math.floor((
|
|
417
|
-
|
|
429
|
+
Math.floor((P - 1) / 2),
|
|
430
|
+
P - 1
|
|
418
431
|
].filter((e, t, n) => n.indexOf(e) === t).map((e) => /* @__PURE__ */ _("text", {
|
|
419
|
-
x: e *
|
|
432
|
+
x: e * L + L / 2,
|
|
420
433
|
y: 132,
|
|
421
434
|
textAnchor: "middle",
|
|
422
435
|
className: "fill-muted-foreground text-[8px]",
|
|
423
|
-
children:
|
|
436
|
+
children: z(e)
|
|
424
437
|
}, e))
|
|
425
438
|
]
|
|
426
439
|
}), y && /* @__PURE__ */ _(s, {
|
|
427
440
|
x: y.x,
|
|
428
441
|
children: /* @__PURE__ */ _(c, { ...((e) => ({
|
|
429
|
-
label:
|
|
442
|
+
label: z(e),
|
|
430
443
|
total: !1,
|
|
431
444
|
formatValue: a,
|
|
432
|
-
items:
|
|
445
|
+
items: N.map((t) => ({
|
|
433
446
|
key: t.key,
|
|
434
447
|
name: t.name,
|
|
435
448
|
value: t.values[e] ?? 0,
|
|
436
|
-
color:
|
|
449
|
+
color: A[t.key] ?? ""
|
|
437
450
|
}))
|
|
438
451
|
}))(y.i) })
|
|
439
452
|
})]
|
|
440
|
-
}),
|
|
453
|
+
}), N.length > 1 && /* @__PURE__ */ _(o, { items: N.map((e) => ({
|
|
441
454
|
key: e.key,
|
|
442
455
|
label: e.name,
|
|
443
|
-
color:
|
|
456
|
+
color: A[e.key] ?? ""
|
|
444
457
|
})) })]
|
|
445
458
|
});
|
|
446
459
|
}
|
|
447
|
-
function
|
|
460
|
+
function F(e, t, n) {
|
|
448
461
|
let r = (e) => {
|
|
449
462
|
let t = String(e);
|
|
450
463
|
return /[",\n]/.test(t) ? `"${t.replaceAll("\"", "\"\"")}"` : t;
|
|
451
|
-
}, i = t.series.length > 0 && t.
|
|
464
|
+
}, i = t.series.length > 0 && C(t).length > 0 ? [[n(t.days.length > 0 ? "day" : "week"), ...t.series.map((e) => e.key === S ? n("series.total") : e.name || e.key)], ...C(t).map((e, n) => [e, ...t.series.map((e) => e.values[n] ?? 0)])] : t.issues.length > 0 ? [[
|
|
452
465
|
"identifier",
|
|
453
466
|
"title",
|
|
454
467
|
"status"
|
|
@@ -467,4 +480,4 @@ function N(e, t, n) {
|
|
|
467
480
|
])], a = new Blob([i.map((e) => e.map(r).join(",")).join("\n")], { type: "text/csv" }), o = document.createElement("a");
|
|
468
481
|
o.href = URL.createObjectURL(a), o.download = `${e.replace(/[^\w.-]+/g, "-")}.csv`, o.click(), URL.revokeObjectURL(o.href);
|
|
469
482
|
}
|
|
470
|
-
export {
|
|
483
|
+
export { D as DashboardPanel, k as PanelChart, b as issuesSearch, T as sharingItems, E as sharingOf, w as starterPanels };
|
|
@@ -6,17 +6,26 @@ import { useState as l } from "react";
|
|
|
6
6
|
import { useTranslations as u } from "use-intl";
|
|
7
7
|
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
8
8
|
// src/components/DocIconPicker.tsx
|
|
9
|
-
function m({
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
function m({ icon: e, onPick: t, onUploadFile: n, ...r }) {
|
|
10
|
+
let i = /* @__PURE__ */ f(h, {
|
|
11
|
+
icon: e,
|
|
12
|
+
onPick: t,
|
|
13
|
+
onUploadFile: n
|
|
14
|
+
});
|
|
15
|
+
return "trigger" in r ? /* @__PURE__ */ f(a, {
|
|
16
|
+
trigger: r.trigger,
|
|
17
|
+
align: "start",
|
|
18
|
+
className: "w-80",
|
|
19
|
+
initialFocus: "first-control",
|
|
20
|
+
children: i
|
|
21
|
+
}) : /* @__PURE__ */ f(a, {
|
|
22
|
+
at: r.at,
|
|
23
|
+
open: !0,
|
|
24
|
+
onOpenChange: (e) => !e && r.onClose(),
|
|
12
25
|
align: "start",
|
|
13
26
|
className: "w-80",
|
|
14
27
|
initialFocus: "first-control",
|
|
15
|
-
children:
|
|
16
|
-
icon: t,
|
|
17
|
-
onPick: n,
|
|
18
|
-
onUploadFile: r
|
|
19
|
-
})
|
|
28
|
+
children: i
|
|
20
29
|
});
|
|
21
30
|
}
|
|
22
31
|
function h({ icon: a, onPick: m, onUploadFile: h }) {
|
package/components/DocLook.js
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
import { api as e, unwrap as t } from "../api/client.js";
|
|
2
|
-
import { useDocActions as n } from "../lib/docs.js";
|
|
3
|
-
import { DocIcon as
|
|
4
|
-
import { DocIconPicker as
|
|
5
|
-
import { iconImageURL as
|
|
6
|
-
import { CropDialog as
|
|
7
|
-
import { Button as
|
|
8
|
-
import { useRef as
|
|
9
|
-
import { useErrorMessage as
|
|
10
|
-
import { useTranslations as
|
|
11
|
-
import { Fragment as
|
|
2
|
+
import { useDocActions as n, useIconRequest as r } from "../lib/docs.js";
|
|
3
|
+
import { DocIcon as i } from "./DocIcon.js";
|
|
4
|
+
import { DocIconPicker as a } from "./DocIconPicker.js";
|
|
5
|
+
import { iconImageURL as o } from "./EntityIcon.js";
|
|
6
|
+
import { CropDialog as s } from "./ImageUpload.js";
|
|
7
|
+
import { Button as c, ErrorText as l, FileButton as u } from "@parallelworks/ui";
|
|
8
|
+
import { useRef as d, useState as f } from "react";
|
|
9
|
+
import { useErrorMessage as p } from "@parallelworks/problem/react";
|
|
10
|
+
import { useTranslations as m } from "use-intl";
|
|
11
|
+
import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
12
12
|
// src/components/DocLook.tsx
|
|
13
|
-
var
|
|
14
|
-
async function
|
|
15
|
-
let t = await createImageBitmap(e), n = Math.min(1,
|
|
13
|
+
var v = 2400;
|
|
14
|
+
async function y(e) {
|
|
15
|
+
let t = await createImageBitmap(e), n = Math.min(1, v / t.width, v / t.height), r = document.createElement("canvas");
|
|
16
16
|
return r.width = Math.round(t.width * n), r.height = Math.round(t.height * n), r.getContext("2d")?.drawImage(t, 0, 0, r.width, r.height), t.close(), new Promise((e, t) => r.toBlob((n) => n ? e(n) : t(/* @__PURE__ */ Error("encode")), "image/jpeg", .85));
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
let a =
|
|
18
|
+
function b(r, i) {
|
|
19
|
+
let a = m("docs.look"), o = p(), s = n(r), [c, l] = f(!1), [u, d] = f(null);
|
|
20
20
|
return {
|
|
21
21
|
upload: async (n) => {
|
|
22
22
|
let c = n[0];
|
|
23
23
|
if (c) {
|
|
24
|
-
l(!0),
|
|
24
|
+
l(!0), d(null);
|
|
25
25
|
try {
|
|
26
|
-
let n = await
|
|
26
|
+
let n = await y(c), a = t(await e.POST("/api/v1/workspaces/{workspace}/images", {
|
|
27
27
|
params: {
|
|
28
28
|
path: { workspace: r },
|
|
29
29
|
query: { kind: "cover" }
|
|
@@ -38,7 +38,7 @@ function y(r, i) {
|
|
|
38
38
|
coverPosition: 50
|
|
39
39
|
});
|
|
40
40
|
} catch (e) {
|
|
41
|
-
|
|
41
|
+
d(a("coverFailed", { reason: o(e) }));
|
|
42
42
|
} finally {
|
|
43
43
|
l(!1);
|
|
44
44
|
}
|
|
@@ -48,8 +48,8 @@ function y(r, i) {
|
|
|
48
48
|
error: u
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
let i =
|
|
51
|
+
function x(n, r) {
|
|
52
|
+
let i = p(), [a, o] = f(null);
|
|
53
53
|
return {
|
|
54
54
|
picked: a,
|
|
55
55
|
pick: (e) => {
|
|
@@ -71,30 +71,30 @@ function b(n, r) {
|
|
|
71
71
|
clear: () => o(null)
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
|
-
function
|
|
75
|
-
let i =
|
|
74
|
+
function S({ workspace: e, doc: t, editable: r }) {
|
|
75
|
+
let i = m("docs.look"), a = m("common"), s = n(e), p = b(e, t), v = d(null), y = d(null), [x, S] = f(!1), [C, w] = f(t.coverPosition), T = o(t.cover ?? "");
|
|
76
76
|
if (!T) return null;
|
|
77
77
|
let E = x ? C : t.coverPosition;
|
|
78
|
-
return /* @__PURE__ */
|
|
78
|
+
return /* @__PURE__ */ _("div", {
|
|
79
79
|
className: "group/cover relative",
|
|
80
80
|
children: [
|
|
81
|
-
/* @__PURE__ */
|
|
81
|
+
/* @__PURE__ */ g("div", {
|
|
82
82
|
ref: v,
|
|
83
83
|
className: `h-40 w-full overflow-hidden bg-muted md:h-56 ${x ? "cursor-grab touch-none active:cursor-grabbing" : ""}`,
|
|
84
84
|
onPointerDown: (e) => {
|
|
85
|
-
x && (e.currentTarget.setPointerCapture(e.pointerId),
|
|
85
|
+
x && (e.currentTarget.setPointerCapture(e.pointerId), y.current = {
|
|
86
86
|
y: e.clientY,
|
|
87
87
|
from: C
|
|
88
88
|
});
|
|
89
89
|
},
|
|
90
90
|
onPointerMove: (e) => {
|
|
91
|
-
let t =
|
|
91
|
+
let t = y.current, n = v.current?.offsetHeight ?? 1;
|
|
92
92
|
t && w(Math.round(Math.min(100, Math.max(0, t.from - (e.clientY - t.y) / n * 100))));
|
|
93
93
|
},
|
|
94
94
|
onPointerUp: () => {
|
|
95
|
-
|
|
95
|
+
y.current = null;
|
|
96
96
|
},
|
|
97
|
-
children: /* @__PURE__ */
|
|
97
|
+
children: /* @__PURE__ */ g("img", {
|
|
98
98
|
src: T,
|
|
99
99
|
alt: "",
|
|
100
100
|
draggable: !1,
|
|
@@ -102,40 +102,40 @@ function x({ workspace: e, doc: t, editable: r }) {
|
|
|
102
102
|
style: { objectPosition: `50% ${E}%` }
|
|
103
103
|
})
|
|
104
104
|
}),
|
|
105
|
-
x && /* @__PURE__ */
|
|
105
|
+
x && /* @__PURE__ */ g("p", {
|
|
106
106
|
className: "pointer-events-none absolute inset-x-0 top-1/2 -translate-y-1/2 text-center",
|
|
107
|
-
children: /* @__PURE__ */
|
|
107
|
+
children: /* @__PURE__ */ g("span", {
|
|
108
108
|
className: "rounded-md bg-background/85 px-2 py-1 text-xs",
|
|
109
109
|
children: i("dragToReposition")
|
|
110
110
|
})
|
|
111
111
|
}),
|
|
112
|
-
r && /* @__PURE__ */
|
|
113
|
-
className: `absolute right-4 bottom-3 flex gap-1.5 transition-opacity duration-150 md:right-8 ${x ||
|
|
114
|
-
children: x ? /* @__PURE__ */
|
|
112
|
+
r && /* @__PURE__ */ g("div", {
|
|
113
|
+
className: `absolute right-4 bottom-3 flex gap-1.5 transition-opacity duration-150 md:right-8 ${x || p.busy ? "" : "opacity-0 group-focus-within/cover:opacity-100 group-hover/cover:opacity-100"}`,
|
|
114
|
+
children: x ? /* @__PURE__ */ _(h, { children: [/* @__PURE__ */ g(c, {
|
|
115
115
|
type: "button",
|
|
116
116
|
size: "sm",
|
|
117
117
|
onClick: () => S(!1),
|
|
118
|
-
children:
|
|
119
|
-
}), /* @__PURE__ */
|
|
118
|
+
children: a("cancel")
|
|
119
|
+
}), /* @__PURE__ */ g(c, {
|
|
120
120
|
type: "button",
|
|
121
121
|
size: "sm",
|
|
122
122
|
variant: "primary",
|
|
123
123
|
onClick: () => {
|
|
124
|
-
|
|
124
|
+
s.setLook.mutate({
|
|
125
125
|
doc: t,
|
|
126
126
|
coverPosition: C
|
|
127
127
|
}), S(!1);
|
|
128
128
|
},
|
|
129
129
|
children: i("savePosition")
|
|
130
|
-
})] }) : /* @__PURE__ */
|
|
131
|
-
/* @__PURE__ */
|
|
130
|
+
})] }) : /* @__PURE__ */ _(h, { children: [
|
|
131
|
+
/* @__PURE__ */ g(u, {
|
|
132
132
|
size: "sm",
|
|
133
133
|
accept: "image/png,image/jpeg",
|
|
134
|
-
onFiles:
|
|
135
|
-
loading:
|
|
134
|
+
onFiles: p.upload,
|
|
135
|
+
loading: p.busy,
|
|
136
136
|
children: i("changeCover")
|
|
137
137
|
}),
|
|
138
|
-
/* @__PURE__ */
|
|
138
|
+
/* @__PURE__ */ g(c, {
|
|
139
139
|
type: "button",
|
|
140
140
|
size: "sm",
|
|
141
141
|
onClick: () => {
|
|
@@ -143,10 +143,10 @@ function x({ workspace: e, doc: t, editable: r }) {
|
|
|
143
143
|
},
|
|
144
144
|
children: i("reposition")
|
|
145
145
|
}),
|
|
146
|
-
/* @__PURE__ */
|
|
146
|
+
/* @__PURE__ */ g(c, {
|
|
147
147
|
type: "button",
|
|
148
148
|
size: "sm",
|
|
149
|
-
onClick: () =>
|
|
149
|
+
onClick: () => s.setLook.mutate({
|
|
150
150
|
doc: t,
|
|
151
151
|
cover: ""
|
|
152
152
|
}),
|
|
@@ -154,68 +154,68 @@ function x({ workspace: e, doc: t, editable: r }) {
|
|
|
154
154
|
})
|
|
155
155
|
] })
|
|
156
156
|
}),
|
|
157
|
-
/* @__PURE__ */
|
|
157
|
+
/* @__PURE__ */ g(l, {
|
|
158
158
|
className: "px-4 md:px-8",
|
|
159
|
-
children:
|
|
159
|
+
children: p.error
|
|
160
160
|
})
|
|
161
161
|
]
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
|
-
function
|
|
165
|
-
let
|
|
164
|
+
function C({ workspace: e, doc: t, editable: r }) {
|
|
165
|
+
let o = m("docs.look"), d = n(e), f = b(e, t), p = t.icon ?? "", h = (e) => d.setLook.mutate({
|
|
166
166
|
doc: t,
|
|
167
167
|
icon: e
|
|
168
|
-
}), v =
|
|
169
|
-
icon:
|
|
168
|
+
}), v = x(e, h), y = /* @__PURE__ */ g(i, {
|
|
169
|
+
icon: p,
|
|
170
170
|
className: "size-14",
|
|
171
171
|
emojiClassName: "text-5xl"
|
|
172
172
|
});
|
|
173
|
-
return /* @__PURE__ */
|
|
173
|
+
return /* @__PURE__ */ _("div", {
|
|
174
174
|
className: t.cover ? "-mt-10 md:-mt-12" : "",
|
|
175
175
|
children: [
|
|
176
|
-
|
|
177
|
-
icon:
|
|
178
|
-
onPick:
|
|
176
|
+
p && (r ? /* @__PURE__ */ g(a, {
|
|
177
|
+
icon: p,
|
|
178
|
+
onPick: h,
|
|
179
179
|
onUploadFile: v.pick,
|
|
180
|
-
trigger: /* @__PURE__ */
|
|
180
|
+
trigger: /* @__PURE__ */ g("button", {
|
|
181
181
|
type: "button",
|
|
182
|
-
"aria-label":
|
|
182
|
+
"aria-label": o("changeIcon"),
|
|
183
183
|
className: "relative rounded-lg p-1 hover:bg-muted focus-visible:outline-2 focus-visible:outline-primary",
|
|
184
|
-
children:
|
|
184
|
+
children: y
|
|
185
185
|
})
|
|
186
|
-
}) : /* @__PURE__ */
|
|
186
|
+
}) : /* @__PURE__ */ g("span", {
|
|
187
187
|
className: "relative inline-block p-1",
|
|
188
|
-
children:
|
|
188
|
+
children: y
|
|
189
189
|
})),
|
|
190
|
-
|
|
190
|
+
r && (!p || !t.cover) && /* @__PURE__ */ _("div", {
|
|
191
191
|
className: "flex h-8 items-center gap-1 opacity-0 transition-opacity duration-150 group-hover/doc:opacity-100 focus-within:opacity-100 has-[[aria-expanded=true]]:opacity-100 max-md:opacity-100",
|
|
192
192
|
children: [
|
|
193
|
-
!
|
|
193
|
+
!p && /* @__PURE__ */ g(a, {
|
|
194
194
|
icon: "",
|
|
195
|
-
onPick:
|
|
195
|
+
onPick: h,
|
|
196
196
|
onUploadFile: v.pick,
|
|
197
|
-
trigger: /* @__PURE__ */
|
|
197
|
+
trigger: /* @__PURE__ */ g(c, {
|
|
198
198
|
type: "button",
|
|
199
199
|
size: "sm",
|
|
200
200
|
variant: "ghost",
|
|
201
|
-
children:
|
|
201
|
+
children: o("addIcon")
|
|
202
202
|
})
|
|
203
203
|
}),
|
|
204
|
-
!t.cover && /* @__PURE__ */
|
|
204
|
+
!t.cover && /* @__PURE__ */ g(u, {
|
|
205
205
|
size: "sm",
|
|
206
206
|
variant: "ghost",
|
|
207
207
|
accept: "image/png,image/jpeg",
|
|
208
208
|
onFiles: f.upload,
|
|
209
209
|
loading: f.busy,
|
|
210
|
-
children:
|
|
210
|
+
children: o("addCover")
|
|
211
211
|
}),
|
|
212
|
-
/* @__PURE__ */
|
|
212
|
+
/* @__PURE__ */ g(l, {
|
|
213
213
|
inline: !0,
|
|
214
214
|
children: f.error
|
|
215
215
|
})
|
|
216
216
|
]
|
|
217
217
|
}),
|
|
218
|
-
v.picked && /* @__PURE__ */
|
|
218
|
+
v.picked && /* @__PURE__ */ g(s, {
|
|
219
219
|
image: v.picked,
|
|
220
220
|
name: t.title,
|
|
221
221
|
onSave: v.save,
|
|
@@ -224,4 +224,29 @@ function S({ workspace: e, doc: t, editable: a }) {
|
|
|
224
224
|
]
|
|
225
225
|
});
|
|
226
226
|
}
|
|
227
|
-
|
|
227
|
+
function w({ workspace: e }) {
|
|
228
|
+
let [t, i] = r(), o = n(e), [c, l] = f(null), u = x(e, (e) => c && o.setLook.mutate({
|
|
229
|
+
doc: c,
|
|
230
|
+
icon: e
|
|
231
|
+
}));
|
|
232
|
+
return /* @__PURE__ */ _(h, { children: [t && /* @__PURE__ */ g(a, {
|
|
233
|
+
at: t.at,
|
|
234
|
+
onClose: i,
|
|
235
|
+
icon: t.doc.icon ?? "",
|
|
236
|
+
onPick: (e) => o.setLook.mutate({
|
|
237
|
+
doc: t.doc,
|
|
238
|
+
icon: e
|
|
239
|
+
}),
|
|
240
|
+
onUploadFile: (e) => {
|
|
241
|
+
l(t.doc), u.pick(e);
|
|
242
|
+
}
|
|
243
|
+
}), c && u.picked && /* @__PURE__ */ g(s, {
|
|
244
|
+
image: u.picked,
|
|
245
|
+
name: c.title,
|
|
246
|
+
onSave: u.save,
|
|
247
|
+
onClose: () => {
|
|
248
|
+
u.clear(), l(null);
|
|
249
|
+
}
|
|
250
|
+
})] });
|
|
251
|
+
}
|
|
252
|
+
export { S as DocCover, C as DocLookControls, w as DocMenuHost, x as useIconUpload };
|