camox 0.75.0 → 0.76.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.
Files changed (30) hide show
  1. package/dist/features/provider/AuthenticatedCamoxProvider.js +75 -63
  2. package/dist/features/routes/pageRuntime.d.ts +6 -4
  3. package/dist/features/routes/pageRuntime.js +5 -1
  4. package/dist/features/studio/components/ChatWidget.js +137 -121
  5. package/dist/features/studio/components/ClearThread.js +121 -0
  6. package/dist/features/studio/components/DeleteDraftDialog.js +67 -65
  7. package/dist/features/studio/components/DraftBar.js +60 -49
  8. package/dist/features/studio/components/DraftNotices.js +149 -0
  9. package/dist/features/studio/components/DraftsControl.js +217 -180
  10. package/dist/features/studio/components/DraftsSheet.js +387 -0
  11. package/dist/features/studio/components/PublishedTab.js +511 -0
  12. package/dist/features/studio/components/ReviewDraftDialog.js +104 -89
  13. package/dist/features/studio/components/SheetTable.js +46 -0
  14. package/dist/features/studio/components/Specialists.js +1 -1
  15. package/dist/features/studio/components/ThreadMessages.js +222 -167
  16. package/dist/features/studio/draftLabel.js +15 -1
  17. package/dist/features/studio/draftNotice.js +1 -0
  18. package/dist/features/studio/studioStore.js +5 -5
  19. package/dist/features/studio/useArchiveDraft.js +60 -0
  20. package/dist/features/studio/useRestoreDraft.js +70 -0
  21. package/dist/features/studio/viewSwitch.js +19 -11
  22. package/dist/lib/draft-scope.d.ts +1 -1
  23. package/dist/lib/draft-scope.js +6 -3
  24. package/dist/lib/queries.js +12 -1
  25. package/dist/lib/studio-reads.js +22 -0
  26. package/dist/lib/use-project-room.js +19 -13
  27. package/dist/lib/use-thread.js +1 -1
  28. package/dist/package.js +1 -1
  29. package/dist/studio.css +1 -1
  30. package/package.json +4 -4
@@ -0,0 +1,387 @@
1
+ import { reads, useReadQuery } from "../../../lib/studio-reads.js";
2
+ import { useRestoreDraft } from "../useRestoreDraft.js";
3
+ import { daysLeft, draftLabel, timeAgo } from "../draftLabel.js";
4
+ import { DeleteDraftDialog } from "./DeleteDraftDialog.js";
5
+ import { Td, Th } from "./SheetTable.js";
6
+ import { PublishedTab } from "./PublishedTab.js";
7
+ import { c } from "react/compiler-runtime";
8
+ import * as React from "react";
9
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
+ import { Button } from "@camox/ui/button";
11
+ import { Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle } from "@camox/ui/sheet";
12
+ import { Spinner } from "@camox/ui/spinner";
13
+ import { Tabs, TabsContent, TabsList, TabsTrigger } from "@camox/ui/tabs";
14
+
15
+ //#region src/features/studio/components/DraftsSheet.tsx
16
+ /**
17
+ * The drafts no longer in progress, opened from the draft picker: a tab of archived drafts to
18
+ * restore or delete (ADR 0046), and a tab of Publications, to read why Live changed (ADR 0045).
19
+ */
20
+ function DraftsSheet(t0) {
21
+ const $ = c(21);
22
+ const { projectId, open, onOpenChange } = t0;
23
+ let t1;
24
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
25
+ t1 = /* @__PURE__ */ jsxs(SheetHeader, {
26
+ className: "border-b",
27
+ children: [/* @__PURE__ */ jsx(SheetTitle, { children: "Drafts" }), /* @__PURE__ */ jsx(SheetDescription, { children: "Drafts set aside, to bring back or delete, and what was published." })]
28
+ });
29
+ $[0] = t1;
30
+ } else t1 = $[0];
31
+ let t2;
32
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
33
+ t2 = /* @__PURE__ */ jsxs(TabsList, { children: [/* @__PURE__ */ jsx(TabsTrigger, {
34
+ value: "archived",
35
+ children: "Archived"
36
+ }), /* @__PURE__ */ jsx(TabsTrigger, {
37
+ value: "published",
38
+ children: "Published"
39
+ })] });
40
+ $[1] = t2;
41
+ } else t2 = $[1];
42
+ let t3;
43
+ if ($[2] !== onOpenChange || $[3] !== open || $[4] !== projectId) {
44
+ t3 = open && /* @__PURE__ */ jsx(ArchivedDrafts, {
45
+ projectId,
46
+ onRestored: () => onOpenChange(false)
47
+ });
48
+ $[2] = onOpenChange;
49
+ $[3] = open;
50
+ $[4] = projectId;
51
+ $[5] = t3;
52
+ } else t3 = $[5];
53
+ let t4;
54
+ if ($[6] !== t3) {
55
+ t4 = /* @__PURE__ */ jsx(TabsContent, {
56
+ value: "archived",
57
+ className: "overflow-y-auto",
58
+ children: t3
59
+ });
60
+ $[6] = t3;
61
+ $[7] = t4;
62
+ } else t4 = $[7];
63
+ let t5;
64
+ if ($[8] !== onOpenChange || $[9] !== open || $[10] !== projectId) {
65
+ t5 = open && /* @__PURE__ */ jsx(PublishedTab, {
66
+ projectId,
67
+ onEntered: () => onOpenChange(false)
68
+ });
69
+ $[8] = onOpenChange;
70
+ $[9] = open;
71
+ $[10] = projectId;
72
+ $[11] = t5;
73
+ } else t5 = $[11];
74
+ let t6;
75
+ if ($[12] !== t5) {
76
+ t6 = /* @__PURE__ */ jsx(TabsContent, {
77
+ value: "published",
78
+ className: "overflow-y-auto",
79
+ children: t5
80
+ });
81
+ $[12] = t5;
82
+ $[13] = t6;
83
+ } else t6 = $[13];
84
+ let t7;
85
+ if ($[14] !== t4 || $[15] !== t6) {
86
+ t7 = /* @__PURE__ */ jsxs(SheetContent, {
87
+ side: "right",
88
+ className: "gap-0 data-[side=right]:sm:max-w-3xl",
89
+ children: [t1, /* @__PURE__ */ jsxs(Tabs, {
90
+ defaultValue: "archived",
91
+ className: "flex-1 overflow-hidden p-4",
92
+ children: [
93
+ t2,
94
+ t4,
95
+ t6
96
+ ]
97
+ })]
98
+ });
99
+ $[14] = t4;
100
+ $[15] = t6;
101
+ $[16] = t7;
102
+ } else t7 = $[16];
103
+ let t8;
104
+ if ($[17] !== onOpenChange || $[18] !== open || $[19] !== t7) {
105
+ t8 = /* @__PURE__ */ jsx(Sheet, {
106
+ open,
107
+ onOpenChange,
108
+ children: t7
109
+ });
110
+ $[17] = onOpenChange;
111
+ $[18] = open;
112
+ $[19] = t7;
113
+ $[20] = t8;
114
+ } else t8 = $[20];
115
+ return t8;
116
+ }
117
+ /** The archived drafts, each with Restore and Delete. */
118
+ function ArchivedDrafts(t0) {
119
+ const $ = c(29);
120
+ const { projectId, onRestored } = t0;
121
+ let t1;
122
+ if ($[0] !== projectId) {
123
+ t1 = reads.archivedDrafts({ projectId });
124
+ $[0] = projectId;
125
+ $[1] = t1;
126
+ } else t1 = $[1];
127
+ const archived = useReadQuery(t1);
128
+ const [deleting, setDeleting] = React.useState(null);
129
+ let t2;
130
+ if ($[2] !== onRestored) {
131
+ t2 = { onRestored };
132
+ $[2] = onRestored;
133
+ $[3] = t2;
134
+ } else t2 = $[3];
135
+ const { restore, restoring } = useRestoreDraft(projectId, t2);
136
+ if (!archived.data) {
137
+ let t3;
138
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
139
+ t3 = /* @__PURE__ */ jsxs("div", {
140
+ className: "text-muted-foreground flex items-center gap-2 py-6 text-sm",
141
+ children: [/* @__PURE__ */ jsx(Spinner, { className: "size-3.5" }), " Loading..."]
142
+ });
143
+ $[4] = t3;
144
+ } else t3 = $[4];
145
+ return t3;
146
+ }
147
+ if (archived.data.length === 0) {
148
+ let t3;
149
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
150
+ t3 = /* @__PURE__ */ jsx("p", {
151
+ className: "text-muted-foreground py-6 text-sm",
152
+ children: "No archived drafts."
153
+ });
154
+ $[5] = t3;
155
+ } else t3 = $[5];
156
+ return t3;
157
+ }
158
+ let t3;
159
+ let t4;
160
+ let t5;
161
+ let t6;
162
+ let t7;
163
+ let t8;
164
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
165
+ t3 = /* @__PURE__ */ jsx(Th, { children: "Name" });
166
+ t4 = /* @__PURE__ */ jsx(Th, { children: "Overview" });
167
+ t5 = /* @__PURE__ */ jsx(Th, { children: "Started by" });
168
+ t6 = /* @__PURE__ */ jsx(Th, { children: "Last activity" });
169
+ t7 = /* @__PURE__ */ jsx(Th, { children: "Archived by" });
170
+ t8 = /* @__PURE__ */ jsx(Th, { children: "Deleted in" });
171
+ $[6] = t3;
172
+ $[7] = t4;
173
+ $[8] = t5;
174
+ $[9] = t6;
175
+ $[10] = t7;
176
+ $[11] = t8;
177
+ } else {
178
+ t3 = $[6];
179
+ t4 = $[7];
180
+ t5 = $[8];
181
+ t6 = $[9];
182
+ t7 = $[10];
183
+ t8 = $[11];
184
+ }
185
+ let t9;
186
+ if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
187
+ t9 = /* @__PURE__ */ jsx("thead", {
188
+ className: "text-muted-foreground text-xs",
189
+ children: /* @__PURE__ */ jsxs("tr", { children: [
190
+ t3,
191
+ t4,
192
+ t5,
193
+ t6,
194
+ t7,
195
+ t8,
196
+ /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx("span", {
197
+ className: "sr-only",
198
+ children: "Actions"
199
+ }) })
200
+ ] })
201
+ });
202
+ $[12] = t9;
203
+ } else t9 = $[12];
204
+ let t10;
205
+ if ($[13] !== archived.data || $[14] !== restore || $[15] !== restoring) {
206
+ let t11;
207
+ if ($[17] !== restore || $[18] !== restoring) {
208
+ t11 = (draft) => /* @__PURE__ */ jsx(ArchivedRow, {
209
+ draft,
210
+ restoring: restoring === draft.id,
211
+ onRestore: () => restore(draft.id, draftLabel(draft)),
212
+ onDelete: () => setDeleting(draft.id)
213
+ }, draft.id);
214
+ $[17] = restore;
215
+ $[18] = restoring;
216
+ $[19] = t11;
217
+ } else t11 = $[19];
218
+ t10 = archived.data.map(t11);
219
+ $[13] = archived.data;
220
+ $[14] = restore;
221
+ $[15] = restoring;
222
+ $[16] = t10;
223
+ } else t10 = $[16];
224
+ let t11;
225
+ if ($[20] !== t10) {
226
+ t11 = /* @__PURE__ */ jsxs("table", {
227
+ className: "w-full text-left text-sm",
228
+ children: [t9, /* @__PURE__ */ jsx("tbody", { children: t10 })]
229
+ });
230
+ $[20] = t10;
231
+ $[21] = t11;
232
+ } else t11 = $[21];
233
+ let t12;
234
+ if ($[22] === Symbol.for("react.memo_cache_sentinel")) {
235
+ t12 = (open) => {
236
+ if (!open) setDeleting(null);
237
+ };
238
+ $[22] = t12;
239
+ } else t12 = $[22];
240
+ let t13;
241
+ if ($[23] !== deleting || $[24] !== projectId) {
242
+ t13 = /* @__PURE__ */ jsx(DeleteDraftDialog, {
243
+ projectId,
244
+ draftId: deleting,
245
+ onOpenChange: t12
246
+ });
247
+ $[23] = deleting;
248
+ $[24] = projectId;
249
+ $[25] = t13;
250
+ } else t13 = $[25];
251
+ let t14;
252
+ if ($[26] !== t11 || $[27] !== t13) {
253
+ t14 = /* @__PURE__ */ jsxs(Fragment, { children: [t11, t13] });
254
+ $[26] = t11;
255
+ $[27] = t13;
256
+ $[28] = t14;
257
+ } else t14 = $[28];
258
+ return t14;
259
+ }
260
+ function ArchivedRow(t0) {
261
+ const $ = c(34);
262
+ const { draft, restoring, onRestore, onDelete } = t0;
263
+ let t1;
264
+ if ($[0] !== draft) {
265
+ t1 = draftLabel(draft);
266
+ $[0] = draft;
267
+ $[1] = t1;
268
+ } else t1 = $[1];
269
+ let t2;
270
+ if ($[2] !== t1) {
271
+ t2 = /* @__PURE__ */ jsx(Td, {
272
+ className: "font-medium",
273
+ children: t1
274
+ });
275
+ $[2] = t1;
276
+ $[3] = t2;
277
+ } else t2 = $[3];
278
+ const t3 = draft.overviewHeadline ?? "";
279
+ let t4;
280
+ if ($[4] !== t3) {
281
+ t4 = /* @__PURE__ */ jsx(Td, {
282
+ className: "text-muted-foreground",
283
+ children: t3
284
+ });
285
+ $[4] = t3;
286
+ $[5] = t4;
287
+ } else t4 = $[5];
288
+ let t5;
289
+ if ($[6] !== draft.createdBy.name) {
290
+ t5 = /* @__PURE__ */ jsx(Td, { children: draft.createdBy.name });
291
+ $[6] = draft.createdBy.name;
292
+ $[7] = t5;
293
+ } else t5 = $[7];
294
+ let t6;
295
+ if ($[8] !== draft.lastActivityAt) {
296
+ t6 = timeAgo(draft.lastActivityAt);
297
+ $[8] = draft.lastActivityAt;
298
+ $[9] = t6;
299
+ } else t6 = $[9];
300
+ let t7;
301
+ if ($[10] !== t6) {
302
+ t7 = /* @__PURE__ */ jsx(Td, { children: t6 });
303
+ $[10] = t6;
304
+ $[11] = t7;
305
+ } else t7 = $[11];
306
+ let t8;
307
+ if ($[12] !== draft.archivedBy.name) {
308
+ t8 = /* @__PURE__ */ jsx(Td, { children: draft.archivedBy.name });
309
+ $[12] = draft.archivedBy.name;
310
+ $[13] = t8;
311
+ } else t8 = $[13];
312
+ let t9;
313
+ if ($[14] !== draft.deletesAt) {
314
+ t9 = daysLeft(draft.deletesAt);
315
+ $[14] = draft.deletesAt;
316
+ $[15] = t9;
317
+ } else t9 = $[15];
318
+ let t10;
319
+ if ($[16] !== t9) {
320
+ t10 = /* @__PURE__ */ jsx(Td, { children: t9 });
321
+ $[16] = t9;
322
+ $[17] = t10;
323
+ } else t10 = $[17];
324
+ let t11;
325
+ if ($[18] !== onRestore || $[19] !== restoring) {
326
+ t11 = /* @__PURE__ */ jsx(Button, {
327
+ type: "button",
328
+ variant: "outline",
329
+ size: "sm",
330
+ disabled: restoring,
331
+ onClick: onRestore,
332
+ children: "Restore"
333
+ });
334
+ $[18] = onRestore;
335
+ $[19] = restoring;
336
+ $[20] = t11;
337
+ } else t11 = $[20];
338
+ let t12;
339
+ if ($[21] !== onDelete) {
340
+ t12 = /* @__PURE__ */ jsx(Button, {
341
+ type: "button",
342
+ variant: "ghost",
343
+ size: "sm",
344
+ onClick: onDelete,
345
+ children: "Delete"
346
+ });
347
+ $[21] = onDelete;
348
+ $[22] = t12;
349
+ } else t12 = $[22];
350
+ let t13;
351
+ if ($[23] !== t11 || $[24] !== t12) {
352
+ t13 = /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs("div", {
353
+ className: "flex justify-end gap-2",
354
+ children: [t11, t12]
355
+ }) });
356
+ $[23] = t11;
357
+ $[24] = t12;
358
+ $[25] = t13;
359
+ } else t13 = $[25];
360
+ let t14;
361
+ if ($[26] !== t10 || $[27] !== t13 || $[28] !== t2 || $[29] !== t4 || $[30] !== t5 || $[31] !== t7 || $[32] !== t8) {
362
+ t14 = /* @__PURE__ */ jsxs("tr", {
363
+ className: "border-t align-top",
364
+ children: [
365
+ t2,
366
+ t4,
367
+ t5,
368
+ t7,
369
+ t8,
370
+ t10,
371
+ t13
372
+ ]
373
+ });
374
+ $[26] = t10;
375
+ $[27] = t13;
376
+ $[28] = t2;
377
+ $[29] = t4;
378
+ $[30] = t5;
379
+ $[31] = t7;
380
+ $[32] = t8;
381
+ $[33] = t14;
382
+ } else t14 = $[33];
383
+ return t14;
384
+ }
385
+
386
+ //#endregion
387
+ export { DraftsSheet };