@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.
@@ -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
- function S(e) {
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 C(e, t) {
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 w(e) {
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 T({ workspace: t, panel: o, onEdit: s, onDelete: c }) {
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: () => N(o.title || o.spec.measure, d, u)
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__ */ _(D, {
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 E(e) {
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 D({ workspace: e, panel: n, data: r }) {
149
- let i = g("dashboards"), a = E(r.unit), o = r.series.length > 0 && r.weeks.length > 0, s = n.chart;
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__ */ _(O, {}) : /* @__PURE__ */ _("ul", {
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__ */ _(O, {}) : /* @__PURE__ */ v("table", {
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: k(r.name, n.spec.groupBy, i)
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__ */ _(M, {
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}`) : k(e.name, n.spec.groupBy, i),
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__ */ _(O, {}) : _(s === "pie" ? j : A, {
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 O() {
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 k(e, t, n) {
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 A({ workspace: e, data: n, groupBy: r, value: i }) {
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: k(n.name, r, a)
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 j({ workspace: e, data: n, groupBy: r, value: i }) {
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: k(t.name, r, a),
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 M({ workspace: e, data: n, stacked: r, names: i, value: a }) {
329
- let l = g("dashboards"), d = h(), [y, x] = m(null), { keys: S, folded: C } = f(n.series.map((e) => e.key)), w = p(S), T = S.map((e) => {
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 = n.series.filter((e) => C.includes(e.key));
335
+ let t = D.filter((e) => k.includes(e.key));
332
336
  return {
333
337
  key: e,
334
338
  name: l("other"),
335
- values: n.weeks.map((e, n) => t.reduce((e, t) => e + (t.values[n] ?? 0), 0))
339
+ values: w.map((e, n) => t.reduce((e, t) => e + (t.values[n] ?? 0), 0))
336
340
  };
337
341
  }
338
- let t = n.series.find((t) => t.key === e);
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
- }), E = n.weeks.length, D = n.weeks.map((e, t) => T.reduce((e, n) => e + (n.values[t] ?? 0), 0)), O = Math.max(1, ...r ? D : T.flatMap((e) => e.values)), k = 300 / E, A = (e) => 120 - e / O * 120, j = (e) => d.dateTime(/* @__PURE__ */ new Date(`${n.weeks[e]}T00:00:00Z`), {
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 / k);
365
- if (r < 0 || r >= E) return x(null);
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) * k + n.e - i
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 * k,
376
- width: k,
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(O)
401
+ children: a(I)
394
402
  }),
395
- r ? n.weeks.map((e, t) => {
403
+ r ? w.map((e, t) => {
396
404
  let n = 120;
397
- return /* @__PURE__ */ _("g", { children: T.map((e) => {
398
- let r = (e.values[t] ?? 0) / O * 120;
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 * k + k * .15,
401
- width: k * .7,
408
+ x: t * L + L * .15,
409
+ width: L * .7,
402
410
  y: n,
403
411
  height: r,
404
- fill: w[e.key]
412
+ fill: A[e.key]
405
413
  }, e.key);
406
414
  }) }, t);
407
- }) : T.map((e) => /* @__PURE__ */ _("polyline", {
415
+ }) : null,
416
+ (r ? M : N).map((e) => /* @__PURE__ */ _("polyline", {
408
417
  fill: "none",
409
- stroke: w[e.key],
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 * k + k / 2},${A(e)}`).join(" ")
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((E - 1) / 2),
417
- E - 1
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 * k + k / 2,
432
+ x: e * L + L / 2,
420
433
  y: 132,
421
434
  textAnchor: "middle",
422
435
  className: "fill-muted-foreground text-[8px]",
423
- children: j(e)
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: j(e),
442
+ label: z(e),
430
443
  total: !1,
431
444
  formatValue: a,
432
- items: T.map((t) => ({
445
+ items: N.map((t) => ({
433
446
  key: t.key,
434
447
  name: t.name,
435
448
  value: t.values[e] ?? 0,
436
- color: w[t.key] ?? ""
449
+ color: A[t.key] ?? ""
437
450
  }))
438
451
  }))(y.i) })
439
452
  })]
440
- }), T.length > 1 && /* @__PURE__ */ _(o, { items: T.map((e) => ({
453
+ }), N.length > 1 && /* @__PURE__ */ _(o, { items: N.map((e) => ({
441
454
  key: e.key,
442
455
  label: e.name,
443
- color: w[e.key] ?? ""
456
+ color: A[e.key] ?? ""
444
457
  })) })]
445
458
  });
446
459
  }
447
- function N(e, t, n) {
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.weeks.length > 0 ? [[n("week"), ...t.series.map((e) => e.name || e.key)], ...t.weeks.map((e, n) => [e, ...t.series.map((e) => e.values[n] ?? 0)])] : t.issues.length > 0 ? [[
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 { T as DashboardPanel, D as PanelChart, b as issuesSearch, C as sharingItems, w as sharingOf, S as starterPanels };
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({ trigger: e, icon: t, onPick: n, onUploadFile: r }) {
10
- return /* @__PURE__ */ f(a, {
11
- trigger: e,
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: /* @__PURE__ */ f(h, {
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 }) {
@@ -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 r } from "./DocIcon.js";
4
- import { DocIconPicker as i } from "./DocIconPicker.js";
5
- import { iconImageURL as a } from "./EntityIcon.js";
6
- import { CropDialog as o } from "./ImageUpload.js";
7
- import { Button as s, ErrorText as c, FileButton as l } from "@parallelworks/ui";
8
- import { useRef as u, useState as d } from "react";
9
- import { useErrorMessage as f } from "@parallelworks/problem/react";
10
- import { useTranslations as p } from "use-intl";
11
- import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
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 _ = 2400;
14
- async function v(e) {
15
- let t = await createImageBitmap(e), n = Math.min(1, _ / t.width, _ / t.height), r = document.createElement("canvas");
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 y(r, i) {
19
- let a = p("docs.look"), o = f(), s = n(r), [c, l] = d(!1), [u, m] = d(null);
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), m(null);
24
+ l(!0), d(null);
25
25
  try {
26
- let n = await v(c), a = t(await e.POST("/api/v1/workspaces/{workspace}/images", {
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
- m(a("coverFailed", { reason: o(e) }));
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 b(n, r) {
52
- let i = f(), [a, o] = d(null);
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 x({ workspace: e, doc: t, editable: r }) {
75
- let i = p("docs.look"), o = p("common"), f = n(e), _ = y(e, t), v = u(null), b = u(null), [x, S] = d(!1), [C, w] = d(t.coverPosition), T = a(t.cover ?? "");
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__ */ g("div", {
78
+ return /* @__PURE__ */ _("div", {
79
79
  className: "group/cover relative",
80
80
  children: [
81
- /* @__PURE__ */ h("div", {
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), b.current = {
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 = b.current, n = v.current?.offsetHeight ?? 1;
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
- b.current = null;
95
+ y.current = null;
96
96
  },
97
- children: /* @__PURE__ */ h("img", {
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__ */ h("p", {
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__ */ h("span", {
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__ */ h("div", {
113
- className: `absolute right-4 bottom-3 flex gap-1.5 transition-opacity duration-150 md:right-8 ${x || _.busy ? "" : "opacity-0 group-focus-within/cover:opacity-100 group-hover/cover:opacity-100"}`,
114
- children: x ? /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h(s, {
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: o("cancel")
119
- }), /* @__PURE__ */ h(s, {
118
+ children: a("cancel")
119
+ }), /* @__PURE__ */ g(c, {
120
120
  type: "button",
121
121
  size: "sm",
122
122
  variant: "primary",
123
123
  onClick: () => {
124
- f.setLook.mutate({
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__ */ g(m, { children: [
131
- /* @__PURE__ */ h(l, {
130
+ })] }) : /* @__PURE__ */ _(h, { children: [
131
+ /* @__PURE__ */ g(u, {
132
132
  size: "sm",
133
133
  accept: "image/png,image/jpeg",
134
- onFiles: _.upload,
135
- loading: _.busy,
134
+ onFiles: p.upload,
135
+ loading: p.busy,
136
136
  children: i("changeCover")
137
137
  }),
138
- /* @__PURE__ */ h(s, {
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__ */ h(s, {
146
+ /* @__PURE__ */ g(c, {
147
147
  type: "button",
148
148
  size: "sm",
149
- onClick: () => f.setLook.mutate({
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__ */ h(c, {
157
+ /* @__PURE__ */ g(l, {
158
158
  className: "px-4 md:px-8",
159
- children: _.error
159
+ children: p.error
160
160
  })
161
161
  ]
162
162
  });
163
163
  }
164
- function S({ workspace: e, doc: t, editable: a }) {
165
- let u = p("docs.look"), d = n(e), f = y(e, t), m = t.icon ?? "", _ = (e) => d.setLook.mutate({
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 = b(e, _), x = /* @__PURE__ */ h(r, {
169
- icon: m,
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__ */ g("div", {
173
+ return /* @__PURE__ */ _("div", {
174
174
  className: t.cover ? "-mt-10 md:-mt-12" : "",
175
175
  children: [
176
- m && (a ? /* @__PURE__ */ h(i, {
177
- icon: m,
178
- onPick: _,
176
+ p && (r ? /* @__PURE__ */ g(a, {
177
+ icon: p,
178
+ onPick: h,
179
179
  onUploadFile: v.pick,
180
- trigger: /* @__PURE__ */ h("button", {
180
+ trigger: /* @__PURE__ */ g("button", {
181
181
  type: "button",
182
- "aria-label": u("changeIcon"),
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: x
184
+ children: y
185
185
  })
186
- }) : /* @__PURE__ */ h("span", {
186
+ }) : /* @__PURE__ */ g("span", {
187
187
  className: "relative inline-block p-1",
188
- children: x
188
+ children: y
189
189
  })),
190
- a && (!m || !t.cover) && /* @__PURE__ */ g("div", {
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
- !m && /* @__PURE__ */ h(i, {
193
+ !p && /* @__PURE__ */ g(a, {
194
194
  icon: "",
195
- onPick: _,
195
+ onPick: h,
196
196
  onUploadFile: v.pick,
197
- trigger: /* @__PURE__ */ h(s, {
197
+ trigger: /* @__PURE__ */ g(c, {
198
198
  type: "button",
199
199
  size: "sm",
200
200
  variant: "ghost",
201
- children: u("addIcon")
201
+ children: o("addIcon")
202
202
  })
203
203
  }),
204
- !t.cover && /* @__PURE__ */ h(l, {
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: u("addCover")
210
+ children: o("addCover")
211
211
  }),
212
- /* @__PURE__ */ h(c, {
212
+ /* @__PURE__ */ g(l, {
213
213
  inline: !0,
214
214
  children: f.error
215
215
  })
216
216
  ]
217
217
  }),
218
- v.picked && /* @__PURE__ */ h(o, {
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
- export { x as DocCover, S as DocLookControls, b as useIconUpload };
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 };