@vite-hub/ui 0.3.1 → 0.5.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 (176) hide show
  1. package/README.md +107 -81
  2. package/dist/announce-Cy_Tn9wW.js +32 -0
  3. package/dist/{code-view-D0bqhogi.js → code-view-DsU-xzic.js} +4 -4
  4. package/dist/comment-attachments-C4yNbcx5.js +20 -0
  5. package/dist/{comment-composer-jYv2ULNP.js → comment-composer-D7ZytyER.js} +257 -10
  6. package/dist/{comment-composer-Cc8Jvu6u.d.ts → comment-composer-DvKMTrAi.d.ts} +1 -1
  7. package/dist/{comment-layer-ClH4MLj4.d.ts → comment-layer-GTsLdABl.d.ts} +17 -6
  8. package/dist/{comment-list-B8hphLfS.d.ts → comment-list-BI96empx.d.ts} +2 -2
  9. package/dist/comment-marks.css +18 -22
  10. package/dist/{comment-panel-fcKSKwLC.d.ts → comment-panel-CsKWTms_.d.ts} +15 -4
  11. package/dist/{comment-row-Bbm9WwuF.js → comment-row-JmTC0uXr.js} +2 -2
  12. package/dist/comment-selection-bar-CyVBNYl9.d.ts +42 -0
  13. package/dist/comment-send-7bg4NEEM.js +277 -0
  14. package/dist/comment-send-C45dHC22.d.ts +25 -0
  15. package/dist/comment-send.css +267 -0
  16. package/dist/comment-thread-B_Sc2QX6.js +797 -0
  17. package/dist/{comment-thread-CoTLrdal.d.ts → comment-thread-C6U-bsK_.d.ts} +23 -6
  18. package/dist/{comments-CkWc2Khc.js → comments-B88zg9gC.js} +66 -10
  19. package/dist/{comments-Bx2WRsYy.d.ts → comments-D8hulVPy.d.ts} +34 -6
  20. package/dist/{comments-context-C2lOZyQ5.js → comments-context-DhbIdYQ1.js} +2 -1
  21. package/dist/{config-Dk67emQt.js → config-B1u7zqMB.js} +8 -1
  22. package/dist/{config-DgxBW013.d.ts → config-pHazYdq6.d.ts} +11 -0
  23. package/dist/drop-field-3CDRFFRm.js +163 -0
  24. package/dist/{editor-C_wt4RRV.js → editor-BHYGLgty.js} +42 -3
  25. package/dist/effects-Ql6VzCRa.js +2971 -0
  26. package/dist/format-orwcdZL_.js +39 -0
  27. package/dist/headless.d.ts +2 -2
  28. package/dist/headless.js +1 -1
  29. package/dist/hold-to-delete-DjWzRDyY.d.ts +51 -0
  30. package/dist/hold-to-delete-ROLQRZg_.js +434 -0
  31. package/dist/icon-c5Jb_Tl7.d.ts +31 -0
  32. package/dist/{image-preview-C9tdkmEj.js → image-preview-BigoAvb3.js} +2 -2
  33. package/dist/{index-BD1e8vx5.d.ts → index-YUvL2nV8.d.ts} +10 -6
  34. package/dist/index.d.ts +18 -12
  35. package/dist/index.js +47 -45
  36. package/dist/install-D5f6msEU.js +17 -0
  37. package/dist/list-RCbNZ14q.js +271 -0
  38. package/dist/{markdown-editor-CMbNZOdN.js → markdown-editor-Dfl2DgPS.js} +1 -1
  39. package/dist/{markdown-editor-DqdZfIEn.d.ts → markdown-editor-wQF0yD5o.d.ts} +1 -1
  40. package/dist/markdown-editor.d.ts +1 -1
  41. package/dist/markdown-editor.js +1 -1
  42. package/dist/motion/core.d.ts +4 -0
  43. package/dist/motion/core.js +11 -0
  44. package/dist/motion-core-lHRF8PZz.d.ts +456 -0
  45. package/dist/motion.d.ts +16 -0
  46. package/dist/motion.js +13 -0
  47. package/dist/{nuxt-ui-DSQFzq3s.js → nuxt-ui-CgvMzO5v.js} +20 -14
  48. package/dist/nuxt.d.ts +2 -2
  49. package/dist/nuxt.js +20 -5
  50. package/dist/opt-out-b6bnUjIT.js +208 -0
  51. package/dist/parts/components/agent-session.js +1 -1
  52. package/dist/parts/components/attachment.js +1 -1
  53. package/dist/parts/components/avatar-stack.js +3 -2
  54. package/dist/parts/components/chat-session.d.ts +1 -1
  55. package/dist/parts/components/chat.js +2 -2
  56. package/dist/parts/components/code-block.js +1 -1
  57. package/dist/parts/components/code-view.js +1 -1
  58. package/dist/parts/components/comment-composer.d.ts +1 -1
  59. package/dist/parts/components/comment-composer.js +1 -1
  60. package/dist/parts/components/comment-layer.d.ts +1 -1
  61. package/dist/parts/components/comment-layer.js +54 -23
  62. package/dist/parts/components/comment-list.d.ts +1 -1
  63. package/dist/parts/components/comment-list.js +13 -7
  64. package/dist/parts/components/comment-panel.d.ts +1 -1
  65. package/dist/parts/components/comment-panel.js +46 -20
  66. package/dist/parts/components/comment-pin.js +1 -1
  67. package/dist/parts/components/comment-selection-bar.d.ts +2 -0
  68. package/dist/parts/components/comment-selection-bar.js +117 -0
  69. package/dist/parts/components/comment-send.d.ts +2 -0
  70. package/dist/parts/components/comment-send.js +2 -0
  71. package/dist/parts/components/comment-thread.d.ts +2 -2
  72. package/dist/parts/components/comment-thread.js +2 -570
  73. package/dist/parts/components/comments.d.ts +8 -6
  74. package/dist/parts/components/comments.js +6 -4
  75. package/dist/parts/components/copy-button.d.ts +12 -2
  76. package/dist/parts/components/copy-button.js +226 -1
  77. package/dist/parts/components/drop-field.d.ts +69 -0
  78. package/dist/parts/components/drop-field.js +77 -0
  79. package/dist/parts/components/filter-search.js +1 -1
  80. package/dist/parts/components/hold-to-delete.d.ts +82 -0
  81. package/dist/parts/components/hold-to-delete.js +76 -0
  82. package/dist/parts/components/markdown-editor.d.ts +1 -1
  83. package/dist/parts/components/markdown-editor.js +1 -1
  84. package/dist/parts/components/markdown-renderer.js +1 -1
  85. package/dist/parts/components/markdown.js +1 -1
  86. package/dist/parts/components/message-parts.js +13 -5
  87. package/dist/parts/components/motion-list.d.ts +42 -0
  88. package/dist/parts/components/motion-list.js +42 -0
  89. package/dist/parts/components/motion.d.ts +124 -0
  90. package/dist/parts/components/motion.js +172 -0
  91. package/dist/parts/components/progress.d.ts +41 -0
  92. package/dist/parts/components/progress.js +54 -0
  93. package/dist/parts/components/prompt-input.d.ts +3 -3
  94. package/dist/parts/components/prompt-input.js +3 -3
  95. package/dist/parts/components/relative-time.js +1 -1
  96. package/dist/parts/components/sync-status.js +2 -1
  97. package/dist/parts/components/tool-list.d.ts +1 -1
  98. package/dist/parts/components/trace-run.d.ts +1 -1
  99. package/dist/parts/components/trace-run.js +2 -2
  100. package/dist/parts/headless/comments.d.ts +2 -2
  101. package/dist/parts/headless/comments.js +1 -1
  102. package/dist/parts/playground/share.d.ts +36 -2
  103. package/dist/parts/workspace/browser-support-notice.js +12 -4
  104. package/dist/parts/workspace/codemirror.d.ts +9 -0
  105. package/dist/parts/workspace/codemirror.js +37 -4
  106. package/dist/parts/workspace/connect-panel.js +1 -1
  107. package/dist/parts/workspace/file-icons.d.ts +16 -0
  108. package/dist/parts/workspace/file-icons.js +82 -0
  109. package/dist/parts/workspace/icons.d.ts +1 -0
  110. package/dist/parts/workspace/icons.js +1 -0
  111. package/dist/parts/workspace/runners/render.d.ts +26 -0
  112. package/dist/parts/workspace/runners/render.js +124 -0
  113. package/dist/parts/workspace/runners/web-container.d.ts +29 -0
  114. package/dist/parts/workspace/runners/web-container.js +186 -0
  115. package/dist/parts/workspace/workspace-bar.d.ts +51 -0
  116. package/dist/parts/workspace/workspace-bar.js +51 -0
  117. package/dist/parts/workspace/workspace-boot-status.js +1 -1
  118. package/dist/parts/workspace/workspace-editor-head.d.ts +47 -0
  119. package/dist/parts/workspace/workspace-editor-head.js +66 -0
  120. package/dist/parts/workspace/workspace-editor.d.ts +17 -0
  121. package/dist/parts/workspace/workspace-editor.js +29 -3
  122. package/dist/parts/workspace/workspace-examples.d.ts +74 -0
  123. package/dist/parts/workspace/workspace-examples.js +72 -0
  124. package/dist/parts/workspace/workspace-file-link.d.ts +35 -0
  125. package/dist/parts/workspace/workspace-file-link.js +39 -0
  126. package/dist/parts/workspace/workspace-file-tree.d.ts +8 -8
  127. package/dist/parts/workspace/workspace-file-tree.js +26 -19
  128. package/dist/parts/workspace/workspace-guide.d.ts +52 -0
  129. package/dist/parts/workspace/workspace-guide.js +91 -0
  130. package/dist/parts/workspace/workspace-issues.d.ts +46 -0
  131. package/dist/parts/workspace/workspace-issues.js +49 -0
  132. package/dist/parts/workspace/workspace-preview.js +1 -1
  133. package/dist/parts/workspace/workspace-shell.d.ts +2 -88
  134. package/dist/parts/workspace/workspace-shell.js +131 -78
  135. package/dist/parts/workspace/workspace-sidebar.d.ts +75 -0
  136. package/dist/parts/workspace/workspace-sidebar.js +132 -0
  137. package/dist/parts/workspace/workspace-start.d.ts +47 -0
  138. package/dist/parts/workspace/workspace-start.js +60 -0
  139. package/dist/parts/workspace/workspace-status.d.ts +69 -0
  140. package/dist/parts/workspace/workspace-status.js +74 -0
  141. package/dist/parts/workspace/workspace-steps.d.ts +2 -0
  142. package/dist/parts/workspace/workspace-steps.js +128 -0
  143. package/dist/parts/workspace/workspace-task.d.ts +20 -0
  144. package/dist/parts/workspace/workspace-task.js +20 -0
  145. package/dist/parts/workspace/workspace.d.ts +251 -0
  146. package/dist/parts/workspace/workspace.js +665 -0
  147. package/dist/{pierre-code-view-xgBL6DO7.js → pierre-code-view-NE35tkmR.js} +37 -17
  148. package/dist/playground.d.ts +1 -1
  149. package/dist/progress-C7afI5vq.js +266 -0
  150. package/dist/registry-D3-ysX7l.js +78 -0
  151. package/dist/{relative-time-BVmjOsYG.js → relative-time-DgSS3zKN.js} +1 -1
  152. package/dist/ring-B7Qxu7zd.js +175 -0
  153. package/dist/runtime/nuxt-plugin.js +2 -2
  154. package/dist/styles.css +657 -526
  155. package/dist/text-BCJflBJf.js +826 -0
  156. package/dist/theme.d.ts +43 -0
  157. package/dist/theme.js +22 -7
  158. package/dist/travel-C87xd5Wh.js +182 -0
  159. package/dist/tween-CO24nMpf.js +62 -0
  160. package/dist/{types-Dyr6CfBW.d.ts → types-BX64qHlV.d.ts} +1 -1
  161. package/dist/visual-copy-CrVc3z4n.js +15 -0
  162. package/dist/workspace-shell-BJGnoF3p.d.ts +112 -0
  163. package/dist/workspace-steps-Bgph2rpr.d.ts +72 -0
  164. package/dist/workspace.d.ts +17 -4
  165. package/dist/workspace.js +16 -3
  166. package/package.json +22 -11
  167. package/dist/copy-button-CRN3kmSD.js +0 -253
  168. package/dist/format-Du58PlsG.js +0 -18
  169. package/dist/icon-swap.css +0 -69
  170. package/dist/parts/playground/highlight.d.ts +0 -5
  171. package/dist/parts/playground/highlight.js +0 -23
  172. package/dist/parts/playground/playground-render.d.ts +0 -126
  173. package/dist/parts/playground/playground-render.js +0 -356
  174. package/dist/parts/workspace/playground-container.d.ts +0 -192
  175. package/dist/parts/workspace/playground-container.js +0 -603
  176. package/dist/share-DM4eNy4q.d.ts +0 -37
@@ -1,7 +1,7 @@
1
- import { i as CommentComposerSlots, r as CommentComposerSize } from "./comment-composer-Cc8Jvu6u.js";
2
- import { t as CommentCan } from "./comments-Bx2WRsYy.js";
1
+ import { i as CommentComposerSlots, r as CommentComposerSize } from "./comment-composer-DvKMTrAi.js";
2
+ import { t as CommentCan } from "./comments-D8hulVPy.js";
3
3
  import { PropType, SlotsType, VNode } from "vue";
4
- import { CommentMessage, CommentThread, CommentUser } from "@vite-hub/comments/client";
4
+ import { CommentDelivery, CommentMessage, CommentThread, CommentUser } from "@vite-hub/comments/client";
5
5
  //#region src/internal/comment-status.d.ts
6
6
  /** The messages written after the thread was resolved. Empty for an open thread. */
7
7
  declare function messagesSinceResolved(thread: Pick<CommentThread, "status" | "resolvedAt" | "messages">): CommentMessage[];
@@ -29,11 +29,28 @@ type CommentAttachmentUrl = (key: string) => string | CommentAttachmentLink | un
29
29
  interface CommentReplySlotScope {
30
30
  message: CommentMessage;
31
31
  }
32
+ /** The scope of the `status` slot: a message that the outbox holds, and what the reader can do with it. */
33
+ interface CommentStatusSlotScope {
34
+ message: CommentMessage;
35
+ /** `pending` while it waits or goes out, `failed` when the server refused it, with `error` saying why. */
36
+ delivery: CommentDelivery;
37
+ /** Sends it again now. Only available with edit permission. */
38
+ retry?: () => Promise<void>;
39
+ /** Throws it away. Only available with delete permission. `false` while it is on its way. */
40
+ dismiss?: () => Promise<boolean>;
41
+ /** Changes its text. Only available with edit permission. A refused one goes back in the queue. */
42
+ edit?: (body: string, mentions?: string[]) => Promise<boolean>;
43
+ }
32
44
  type CommentReplySlots = {
33
45
  /** The text of the message. Replaces the Markdown body with its mention chips. */
34
46
  body?: (scope: CommentReplySlotScope) => VNode[];
35
47
  /** The attachments of the message. Replaces the default thumbnails. */
36
48
  attachments?: (scope: CommentReplySlotScope) => VNode[];
49
+ /**
50
+ * Below a message that has not reached the server, such as "Waiting to send" or a refusal with Retry and Discard.
51
+ * Nothing shows without it. The message also gets `data-pending` or `data-failed`.
52
+ */
53
+ status?: (scope: CommentStatusSlotScope) => VNode[];
37
54
  };
38
55
  /** The scope of the `actions`, `anchor`, and `after` slots of `CommentThread`. */
39
56
  interface CommentThreadSlotScope {
@@ -355,14 +372,14 @@ declare const CommentThread$1: import("vue").DefineComponent<import("vue").Extra
355
372
  onClose?: ((...args: any[]) => any) | undefined;
356
373
  }>, {
357
374
  size: CommentComposerSize;
358
- people: CommentUser[];
375
+ preview: boolean;
359
376
  busy: boolean;
377
+ people: CommentUser[];
360
378
  attachments: boolean;
361
379
  readOnly: boolean;
362
- preview: boolean;
363
380
  detached: boolean;
364
381
  navigation: "close" | "back";
365
382
  dismissible: boolean;
366
383
  }, SlotsType<CommentThreadSlots>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
367
384
  //#endregion
368
- export { CommentReplySlots as a, CommentThreadSlots as c, CommentReplySlotScope as i, messagesSinceResolved as l, CommentAttachmentUrl as n, CommentThread$1 as o, CommentReply as r, CommentThreadSlotScope as s, CommentAttachmentLink as t, repliedSinceResolved as u };
385
+ export { CommentReplySlots as a, CommentThreadSlotScope as c, repliedSinceResolved as d, CommentReplySlotScope as i, CommentThreadSlots as l, CommentAttachmentUrl as n, CommentStatusSlotScope as o, CommentReply as r, CommentThread$1 as s, CommentAttachmentLink as t, messagesSinceResolved as u };
@@ -1,8 +1,32 @@
1
1
  import { t as uiErrorDiagnostics } from "./error-diagnostics-SXtnk6bz.js";
2
- import { i as hasDirtyComposer, n as injectComments, o as shakeDirtyComposers, t as commentsKey } from "./comments-context-C2lOZyQ5.js";
2
+ import { a as hasDirtyComposer, n as injectComments, s as shakeDirtyComposers, t as commentsKey } from "./comments-context-DhbIdYQ1.js";
3
3
  import { createCommentVisibility } from "./parts/headless/comment-visibility.js";
4
4
  import { computed, getCurrentInstance, isRef, onBeforeUnmount, onMounted, provide, reactive, ref, shallowRef, toRaw, toValue, watch } from "vue";
5
5
  import { createAnchor, resolveAnchor } from "@vite-hub/comments/client";
6
+ //#region src/internal/comment-selection.ts
7
+ function commentThreadKey(thread) {
8
+ return thread.requestId === void 0 ? thread.id : JSON.stringify([
9
+ thread.subject.kind,
10
+ thread.subject.id,
11
+ thread.author.id,
12
+ thread.requestId
13
+ ]);
14
+ }
15
+ function useSelectedComment(threads, id) {
16
+ const selection = computed((previous) => {
17
+ const selectedId = id.value;
18
+ const items = threads.value;
19
+ const direct = items.find((thread) => thread.id === selectedId);
20
+ const last = previous?.id === selectedId ? previous.thread : void 0;
21
+ const key = last?.requestId === void 0 ? void 0 : commentThreadKey(last);
22
+ return {
23
+ id: selectedId,
24
+ thread: direct ?? (key === void 0 ? void 0 : items.find((thread) => commentThreadKey(thread) === key))
25
+ };
26
+ });
27
+ return computed(() => selection.value.thread);
28
+ }
29
+ //#endregion
6
30
  //#region src/internal/comment-status.ts
7
31
  /** The messages written after the thread was resolved. Empty for an open thread. */
8
32
  function messagesSinceResolved(thread) {
@@ -15,6 +39,17 @@ function messagesSinceResolved(thread) {
15
39
  * resolved, and lists show it with the open threads until someone resolves it again.
16
40
  */
17
41
  const repliedSinceResolved = (thread) => messagesSinceResolved(thread).length > 0;
42
+ /** "Comment 3". A comment that waits in the outbox has no number yet. */
43
+ function commentTitle(thread) {
44
+ return thread.n ? `Comment ${thread.n}` : "Comment";
45
+ }
46
+ /** `data-pending` or `data-failed` for a thread, message, or row that the outbox holds. */
47
+ function deliveryAttributes(delivery) {
48
+ return {
49
+ "data-failed": delivery?.status === "failed" ? "true" : void 0,
50
+ "data-pending": delivery?.status === "pending" ? "true" : void 0
51
+ };
52
+ }
18
53
  //#endregion
19
54
  //#region src/headless/comments.ts
20
55
  /**
@@ -77,6 +112,7 @@ function useComments(options) {
77
112
  });
78
113
  const status = ref(client.status);
79
114
  const threads = shallowRef(client.threads);
115
+ const outboxEntries = shallowRef(client.outbox?.entries ?? []);
80
116
  const positions = shallowRef(/* @__PURE__ */ new Map());
81
117
  const draft = ref(null);
82
118
  const openId = ref(null);
@@ -109,7 +145,10 @@ function useComments(options) {
109
145
  resolved: scoped.filter((thread) => thread.status === "resolved").length
110
146
  };
111
147
  });
112
- const opened = computed(() => threads.value.find((thread) => thread.id === openId.value));
148
+ const opened = useSelectedComment(threads, openId);
149
+ watch(opened, (thread) => {
150
+ if (thread && thread.id !== openId.value) openId.value = thread.id;
151
+ }, { flush: "sync" });
113
152
  const visibility = isRef(options.visibility) ? options.visibility : ref(options.visibility ?? "all");
114
153
  const seen = createCommentVisibility({
115
154
  visibility: visibility.value,
@@ -228,10 +267,11 @@ function useComments(options) {
228
267
  };
229
268
  measure();
230
269
  }
231
- async function send() {
270
+ async function send(sendOptions = {}) {
232
271
  const current = draft.value;
233
272
  const body = current?.body.trim() ?? "";
234
- if (!current || current.busy || !body && current.attachments.length === 0) return void 0;
273
+ const files = sendOptions.files ?? [];
274
+ if (!current || current.busy || !body && current.attachments.length === 0 && files.length === 0) return void 0;
235
275
  const submittedBody = current.body;
236
276
  const mentions = [...current.mentions];
237
277
  const attachments = [...current.attachments];
@@ -243,7 +283,8 @@ function useComments(options) {
243
283
  anchor: toRaw(current.anchor),
244
284
  body,
245
285
  mentions,
246
- ...attachments.length > 0 ? { attachments } : {}
286
+ ...attachments.length > 0 ? { attachments } : {},
287
+ ...files.length > 0 ? { files } : {}
247
288
  });
248
289
  current.busy = false;
249
290
  flash(thread.id);
@@ -328,6 +369,7 @@ function useComments(options) {
328
369
  stops.push(client.onChange(() => {
329
370
  status.value = client.status;
330
371
  threads.value = client.threads;
372
+ outboxEntries.value = client.outbox?.entries ?? [];
331
373
  }));
332
374
  status.value = client.status;
333
375
  threads.value = client.threads;
@@ -459,6 +501,18 @@ function useComments(options) {
459
501
  filters,
460
502
  status,
461
503
  threads,
504
+ outbox: {
505
+ enabled: client.outbox !== void 0,
506
+ queued: computed(() => outboxEntries.value.filter((entry) => entry.status !== "failed")),
507
+ failures: computed(() => outboxEntries.value.filter((entry) => entry.status === "failed")),
508
+ delivery(threadId, messageId) {
509
+ const thread = threads.value.find((item) => item.id === threadId);
510
+ return messageId === void 0 ? thread?.delivery : thread?.messages.find((item) => item.id === messageId)?.delivery;
511
+ },
512
+ retry: async (id) => client.outbox?.retry(id),
513
+ dismiss: async (id) => await client.outbox?.dismiss(id) ?? false,
514
+ edit: async (id, body, mentions) => await client.outbox?.edit(id, body, mentions) ?? false
515
+ },
462
516
  pageThreads,
463
517
  listed,
464
518
  counts,
@@ -483,23 +537,25 @@ function useComments(options) {
483
537
  send,
484
538
  open,
485
539
  close,
486
- create: async ({ anchor = { kind: "page" }, attachments, body, mentions }) => {
540
+ create: async ({ anchor = { kind: "page" }, attachments, body, files, mentions }) => {
487
541
  const thread = await client.create({
488
542
  subject: subject.value,
489
543
  anchor,
490
544
  body,
491
545
  mentions,
492
- ...attachments?.length ? { attachments } : {}
546
+ ...attachments?.length ? { attachments } : {},
547
+ ...files?.length ? { files } : {}
493
548
  });
494
549
  flash(thread.id);
495
550
  return thread;
496
551
  },
497
- reply: async (threadId, body, mentions, attachments) => {
552
+ reply: async (threadId, body, mentions, attachments, files) => {
498
553
  const thread = await client.reply({
499
554
  threadId,
500
555
  body,
501
556
  mentions,
502
- ...attachments?.length ? { attachments } : {}
557
+ ...attachments?.length ? { attachments } : {},
558
+ ...files?.length ? { files } : {}
503
559
  });
504
560
  flash(threadId);
505
561
  return thread;
@@ -548,4 +604,4 @@ function useCommentsContext(state) {
548
604
  return found;
549
605
  }
550
606
  //#endregion
551
- export { useCommentsContext as a, useComments as i, draftPositionKey as n, messagesSinceResolved as o, provideComments as r, repliedSinceResolved as s, defaultCommentCan as t };
607
+ export { useCommentsContext as a, messagesSinceResolved as c, useSelectedComment as d, useComments as i, repliedSinceResolved as l, draftPositionKey as n, commentTitle as o, provideComments as r, deliveryAttributes as s, defaultCommentCan as t, commentThreadKey as u };
@@ -1,6 +1,6 @@
1
1
  import { t as CommentVisibility } from "./comment-visibility-DsVuVndP.js";
2
2
  import { ComputedRef, MaybeRefOrGetter, Ref, ShallowRef } from "vue";
3
- import { AnchorPoint, AnchorPosition, AnchorTarget, CommentAnchor, CommentMessage, CommentSubject, CommentThread, CommentUser, CommentsClient, CommentsClientStatus, CreateAnchorOptions } from "@vite-hub/comments/client";
3
+ import { AnchorPoint, AnchorPosition, AnchorTarget, CommentAnchor, CommentDelivery, CommentMessage, CommentSubject, CommentThread, CommentUser, CommentsClient, CommentsClientStatus, CommentsOutboxEntry, CreateAnchorOptions } from "@vite-hub/comments/client";
4
4
  //#region src/headless/comments.d.ts
5
5
  /**
6
6
  * Each switch shows one kind of thread. Resolved threads stay hidden until `resolved` is on. A resolved thread with a
@@ -74,6 +74,26 @@ interface UseCommentsOptions {
74
74
  /** How long a comment or reply that was just sent shows while comments are hidden. Default `2500`. */
75
75
  flashMs?: number;
76
76
  }
77
+ /**
78
+ * The comments and replies that the client's outbox saved and did not send yet. Without the `outbox` option of
79
+ * `createCommentsClient()`, it is empty and its actions do nothing.
80
+ */
81
+ interface CommentsOutboxState {
82
+ /** `true` when the client has an outbox. */
83
+ readonly enabled: boolean;
84
+ /** The entries that wait or go out now, in order. */
85
+ readonly queued: ComputedRef<readonly CommentsOutboxEntry[]>;
86
+ /** The entries that the server refused. */
87
+ readonly failures: ComputedRef<readonly CommentsOutboxEntry[]>;
88
+ /** Whether the thread, or one of its messages, is waiting or refused. `undefined` when the server has it. */
89
+ delivery: (threadId: string, messageId?: string) => CommentDelivery | undefined;
90
+ /** Sends the waiting comment or reply `id` now. Without `id`, the whole queue tries again, such as after a sign-in. */
91
+ retry: (id?: string) => Promise<void>;
92
+ /** Removes the waiting comment or reply. `false` while it is on its way. */
93
+ dismiss: (id: string) => Promise<boolean>;
94
+ /** Changes the text of the waiting comment or reply. A refused one goes back in the queue. `false` while it is on its way. */
95
+ edit: (id: string, body: string, mentions?: string[]) => Promise<boolean>;
96
+ }
77
97
  interface CommentsState {
78
98
  readonly client: CommentsClient;
79
99
  readonly subject: ComputedRef<CommentSubject>;
@@ -87,8 +107,9 @@ interface CommentsState {
87
107
  readonly scope: Ref<CommentScope>;
88
108
  readonly filters: CommentFilterState;
89
109
  readonly status: Ref<CommentsClientStatus>;
90
- /** Every thread that the client holds. */
110
+ /** Every thread that the client holds, with the ones that wait in the outbox. */
91
111
  readonly threads: ShallowRef<readonly CommentThread[]>;
112
+ readonly outbox: CommentsOutboxState;
92
113
  /** The threads of this page that pass the filters. They get pins. */
93
114
  readonly pageThreads: ComputedRef<CommentThread[]>;
94
115
  /** The threads that pass the filters, for the page or the whole site as `scope` says. The list shows them. */
@@ -131,8 +152,14 @@ interface CommentsState {
131
152
  files?: File[];
132
153
  }) => void;
133
154
  cancelDraft: () => void;
134
- /** Sends the draft. Resolves with the new thread, or `undefined` when there is nothing to send or the send failed. */
135
- send: () => Promise<CommentThread | undefined>;
155
+ /**
156
+ * Sends the draft. Resolves with the new thread, or `undefined` when there is nothing to send or the send failed. With
157
+ * an outbox it resolves, and the draft closes, once the comment is saved, before the server answers. `files` go with
158
+ * the comment, for a client with an outbox.
159
+ */
160
+ send: (options?: {
161
+ files?: Blob[];
162
+ }) => Promise<CommentThread | undefined>;
136
163
  open: (thread: CommentThread | string, options?: {
137
164
  scroll?: boolean;
138
165
  }) => void;
@@ -143,9 +170,10 @@ interface CommentsState {
143
170
  body: string;
144
171
  mentions?: string[];
145
172
  attachments?: string[];
173
+ files?: Blob[];
146
174
  anchor?: CommentAnchor;
147
175
  }) => Promise<CommentThread>;
148
- reply: (threadId: string, body: string, mentions?: string[], attachments?: string[]) => Promise<CommentThread>;
176
+ reply: (threadId: string, body: string, mentions?: string[], attachments?: string[], files?: Blob[]) => Promise<CommentThread>;
149
177
  edit: (threadId: string, messageId: string, body: string, mentions?: string[]) => Promise<CommentThread>;
150
178
  remove: (threadId: string, messageId?: string) => Promise<CommentThread | null>;
151
179
  resolve: (threadId: string) => Promise<CommentThread>;
@@ -167,4 +195,4 @@ declare function provideComments(state: CommentsState): void;
167
195
  /** The state that a comment part uses: the one you pass, else the one of the nearest `CommentLayer` or `provideComments()`. Call it in `setup()`. */
168
196
  declare function useCommentsContext(state?: CommentsState): CommentsState;
169
197
  //#endregion
170
- export { CommentThreadAction as a, defaultCommentCan as c, useComments as d, useCommentsContext as f, CommentScope as i, draftPositionKey as l, CommentDraft as n, CommentsState as o, CommentFilterState as r, UseCommentsOptions as s, CommentCan as t, provideComments as u };
198
+ export { CommentThreadAction as a, UseCommentsOptions as c, provideComments as d, useComments as f, CommentScope as i, defaultCommentCan as l, CommentDraft as n, CommentsOutboxState as o, useCommentsContext as p, CommentFilterState as r, CommentsState as s, CommentCan as t, draftPositionKey as u };
@@ -1,5 +1,6 @@
1
1
  import { inject, onBeforeUnmount, onMounted } from "vue";
2
2
  //#region src/internal/comment-outside.ts
3
+ const commentThreadPortals = Symbol("comment-thread-portals");
3
4
  const consumedPointerEvents = /* @__PURE__ */ new WeakSet();
4
5
  function swallowNextClick() {
5
6
  const stop = (event) => {
@@ -35,4 +36,4 @@ const commentsKey = Symbol("ViteHubComments");
35
36
  /** The state of the nearest `CommentLayer`, `CommentPanel`, or `provideComments()`, if there is one. Call it in `setup()`. */
36
37
  const injectComments = () => inject(commentsKey, null) ?? void 0;
37
38
  //#endregion
38
- export { pathOf as a, swallowNextClick as c, hasDirtyComposer as i, useDocumentPointerDown as l, injectComments as n, shakeDirtyComposers as o, consumedPointerEvents as r, shakeEventName as s, commentsKey as t };
39
+ export { hasDirtyComposer as a, shakeEventName as c, consumedPointerEvents as i, swallowNextClick as l, injectComments as n, pathOf as o, commentThreadPortals as r, shakeDirtyComposers as s, commentsKey as t, useDocumentPointerDown as u };
@@ -1,4 +1,6 @@
1
- import { t as uiComponentsKey } from "./nuxt-ui-DSQFzq3s.js";
1
+ import { t as uiComponentsKey } from "./nuxt-ui-CgvMzO5v.js";
2
+ import { vRing } from "./parts/components/motion.js";
3
+ import { t as installMotion } from "./install-D5f6msEU.js";
2
4
  import { computed, inject, toValue } from "vue";
3
5
  //#region src/config.ts
4
6
  const defaultOptions = {
@@ -14,9 +16,12 @@ const defaultIcons = {
14
16
  arrowLeft: "i-lucide-arrow-left",
15
17
  arrowUp: "i-lucide-arrow-up",
16
18
  check: "i-lucide-check",
19
+ chevronLeft: "i-lucide-chevron-left",
20
+ chevronRight: "i-lucide-chevron-right",
17
21
  close: "i-lucide-x",
18
22
  copy: "i-lucide-copy",
19
23
  copyCheck: "i-lucide-check",
24
+ loading: "i-lucide-loader-circle",
20
25
  external: "i-lucide-external-link",
21
26
  file: "i-lucide-file",
22
27
  plus: "i-lucide-plus",
@@ -57,6 +62,8 @@ function createViteHubUI(options = {}) {
57
62
  if (options.components) app.provide(uiComponentsKey, options.components);
58
63
  if (options.icons) app.provide(iconsKey, options.icons);
59
64
  app.provide(ViteHubUIInjectionKey, resolveViteHubUIDefaults(options));
65
+ if (options.motion !== false && typeof document !== "undefined") app.onUnmount(installMotion());
66
+ app.directive("ring", vRing);
60
67
  } };
61
68
  }
62
69
  //#endregion
@@ -27,10 +27,16 @@ interface ViteHubUIIconOptions {
27
27
  arrowUp?: string;
28
28
  /** Resolve on a comment thread. */
29
29
  check?: string;
30
+ /** The previous picture of an image preview. */
31
+ chevronLeft?: string;
32
+ /** The next picture of an image preview. */
33
+ chevronRight?: string;
30
34
  /** Close a comment thread, an image preview, or remove an attachment. */
31
35
  close?: string;
32
36
  copy?: string;
33
37
  copyCheck?: string;
38
+ /** The spinner of `CopyButton` while its text loads. */
39
+ loading?: string;
34
40
  /** Open the original of an image preview. */
35
41
  external?: string;
36
42
  /** An attachment that is not an image. */
@@ -60,6 +66,11 @@ interface ViteHubUIOptions {
60
66
  components?: ViteHubUIComponents;
61
67
  /** Icons by name, such as `vitehubTheme.icons` from `@vite-hub/ui/theme`. A ref or a getter keeps them reactive. */
62
68
  icons?: MaybeRefOrGetter<ViteHubUIIconOptions | undefined>;
69
+ /**
70
+ * The motion layer of `@vite-hub/ui/motion`: press, toggle, select, drag, and appear motion by role. It starts in the
71
+ * browser and stops when the app unmounts. `false` leaves it off. Default: `true`.
72
+ */
73
+ motion?: boolean;
63
74
  }
64
75
  interface ResolvedViteHubUIDefaults {
65
76
  markdown: {
@@ -0,0 +1,163 @@
1
+ import { a as onEachFrame, t as isMotionOff, u as prefersReducedMotion } from "./opt-out-b6bnUjIT.js";
2
+ //#region src/motion/drop-field.ts
3
+ const gap = 14;
4
+ const reach = 110;
5
+ const lean = 3;
6
+ const powerRate = .15;
7
+ const dotRate = .2;
8
+ const carriesFiles = (event) => [...event.dataTransfer?.types ?? []].includes("Files");
9
+ const rate = (perFrame, seconds) => 1 - (1 - perFrame) ** (seconds * 60);
10
+ /**
11
+ * The drop field of docs/design/motion.md: "Files are dragged in". A grid of dots behind the content of `surface` leans
12
+ * toward the dragged file and rests again when it leaves or drops. It wraps the native file drop of `field`: the drag
13
+ * events, `dropEffect`, and `onFiles`. A click or a key that opens a file picker stays with the field's own controls.
14
+ *
15
+ * The dots use `--vh-drop-dot`, or the text color of the surface. Under reduced motion and inside `data-motion="none"`
16
+ * the dots stay still; `data-over` still marks the field, so its colors change.
17
+ */
18
+ function createDropField(field, options = {}) {
19
+ const surface = options.surface ?? field;
20
+ const accepts = options.accepts ?? carriesFiles;
21
+ const canvas = document.createElement("canvas");
22
+ canvas.dataset.part = "dots";
23
+ canvas.setAttribute("aria-hidden", "true");
24
+ Object.assign(canvas.style, {
25
+ height: "100%",
26
+ inset: "0",
27
+ pointerEvents: "none",
28
+ position: "absolute",
29
+ width: "100%",
30
+ zIndex: "-1"
31
+ });
32
+ if (getComputedStyle(surface).position === "static") surface.style.position = "relative";
33
+ surface.style.isolation = "isolate";
34
+ surface.prepend(canvas);
35
+ const context = canvas.getContext("2d");
36
+ let dots = [];
37
+ let pointer = {
38
+ x: -999,
39
+ y: -999
40
+ };
41
+ let over = false;
42
+ let depth = 0;
43
+ let power = 0;
44
+ let stop;
45
+ const still = () => prefersReducedMotion() || isMotionOff(surface);
46
+ function build() {
47
+ dots = [];
48
+ for (let y = 10; y < surface.clientHeight; y += gap) for (let x = 10; x < surface.clientWidth; x += gap) dots.push({
49
+ x,
50
+ y,
51
+ pull: 0
52
+ });
53
+ }
54
+ function draw(seconds) {
55
+ if (!context) return false;
56
+ const ratio = devicePixelRatio || 1;
57
+ const width = surface.clientWidth;
58
+ const height = surface.clientHeight;
59
+ if (canvas.width !== Math.round(width * ratio) || canvas.height !== Math.round(height * ratio)) {
60
+ canvas.width = Math.round(width * ratio);
61
+ canvas.height = Math.round(height * ratio);
62
+ }
63
+ context.setTransform(ratio, 0, 0, ratio, 0, 0);
64
+ context.clearRect(0, 0, width, height);
65
+ const style = getComputedStyle(surface);
66
+ context.fillStyle = style.getPropertyValue("--vh-drop-dot").trim() || style.color;
67
+ const target = over ? 1 : 0;
68
+ const quiet = still();
69
+ power += (target - power) * rate(powerRate, seconds);
70
+ let moving = false;
71
+ for (const dot of dots) {
72
+ const distance = Math.hypot(dot.x - pointer.x, dot.y - pointer.y);
73
+ const want = quiet ? 0 : power * Math.max(0, 1 - distance / reach) ** 2;
74
+ dot.pull += (want - dot.pull) * rate(dotRate, seconds);
75
+ if (Math.abs(want - dot.pull) > .002) moving = true;
76
+ const shift = quiet ? 0 : dot.pull * lean;
77
+ const angle = Math.atan2(pointer.y - dot.y, pointer.x - dot.x);
78
+ context.globalAlpha = .16 + dot.pull * .7;
79
+ context.beginPath();
80
+ context.arc(dot.x + Math.cos(angle) * shift, dot.y + Math.sin(angle) * shift, .9 + dot.pull * 1.9, 0, Math.PI * 2);
81
+ context.fill();
82
+ }
83
+ context.globalAlpha = 1;
84
+ return moving || Math.abs(power - target) > .01;
85
+ }
86
+ function kick() {
87
+ if (stop) return;
88
+ stop = onEachFrame((seconds) => {
89
+ if (draw(seconds)) return true;
90
+ stop = void 0;
91
+ return false;
92
+ });
93
+ }
94
+ function setOver(next) {
95
+ if (next === over) return;
96
+ over = next;
97
+ if (next) field.dataset.over = "";
98
+ else delete field.dataset.over;
99
+ kick();
100
+ }
101
+ function locate(event) {
102
+ const box = surface.getBoundingClientRect();
103
+ pointer = {
104
+ x: event.clientX - box.left,
105
+ y: event.clientY - box.top
106
+ };
107
+ }
108
+ const onEnter = (event) => {
109
+ if (!accepts(event)) return;
110
+ event.preventDefault();
111
+ depth++;
112
+ locate(event);
113
+ setOver(true);
114
+ };
115
+ const onOver = (event) => {
116
+ if (!accepts(event)) return;
117
+ event.preventDefault();
118
+ if (event.dataTransfer) event.dataTransfer.dropEffect = "copy";
119
+ locate(event);
120
+ setOver(true);
121
+ kick();
122
+ };
123
+ const onLeave = (event) => {
124
+ if (!accepts(event)) return;
125
+ depth = Math.max(0, depth - 1);
126
+ if (!depth) setOver(false);
127
+ };
128
+ const onDrop = (event) => {
129
+ if (!accepts(event)) return;
130
+ event.preventDefault();
131
+ depth = 0;
132
+ setOver(false);
133
+ options.onFiles?.([...event.dataTransfer?.files ?? []], event);
134
+ };
135
+ field.addEventListener("dragenter", onEnter);
136
+ field.addEventListener("dragover", onOver);
137
+ field.addEventListener("dragleave", onLeave);
138
+ field.addEventListener("drop", onDrop);
139
+ const resize = typeof ResizeObserver === "function" ? new ResizeObserver(() => {
140
+ build();
141
+ draw(0);
142
+ }) : void 0;
143
+ resize?.observe(surface);
144
+ build();
145
+ draw(0);
146
+ return {
147
+ get over() {
148
+ return over;
149
+ },
150
+ destroy() {
151
+ stop?.();
152
+ resize?.disconnect();
153
+ field.removeEventListener("dragenter", onEnter);
154
+ field.removeEventListener("dragover", onOver);
155
+ field.removeEventListener("dragleave", onLeave);
156
+ field.removeEventListener("drop", onDrop);
157
+ delete field.dataset.over;
158
+ canvas.remove();
159
+ }
160
+ };
161
+ }
162
+ //#endregion
163
+ export { createDropField as t };
@@ -1,7 +1,8 @@
1
- import { r as useUIComponent } from "./nuxt-ui-DSQFzq3s.js";
2
- import { a as useViteHubUIIcons } from "./config-Dk67emQt.js";
1
+ import { r as useUIComponent } from "./nuxt-ui-CgvMzO5v.js";
2
+ import { a as useViteHubUIIcons } from "./config-B1u7zqMB.js";
3
+ import { t as createMotionList } from "./list-RCbNZ14q.js";
3
4
  import { n as editorHandlersKey, t as createEditorHandlers } from "./handlers-DMl-Na3x.js";
4
- import { computed, defineComponent, h, inject, onMounted, ref, shallowRef } from "vue";
5
+ import { computed, defineComponent, h, inject, onBeforeUnmount, onMounted, ref, shallowRef } from "vue";
5
6
  import { Menu, MenuContent, MenuGroup, MenuGroupLabel, MenuItem, MenuItemIcon, MenuSeparator, MenuTrigger } from "@ui-sdk/vue/menu";
6
7
  import { flip, offset, shift } from "@floating-ui/dom";
7
8
  import DragHandle from "@tiptap/extension-drag-handle-vue-3";
@@ -481,6 +482,36 @@ const UEditorSuggestionMenu = defineComponent({
481
482
  }
482
483
  });
483
484
  /**
485
+ * Moves the drag handle to each new place with the list mover of the motion layer, as a neighbor of a list moves. The
486
+ * drag handle extension places it with `left` and `top`. A handle that was hidden shows at its new place at once.
487
+ */
488
+ function followPlace(element) {
489
+ const parent = element.parentElement;
490
+ if (!parent) return () => {};
491
+ const list = createMotionList(parent, { items: () => [element] });
492
+ const read = () => ({
493
+ place: `${element.style.left} ${element.style.top}`,
494
+ shown: element.style.visibility !== "hidden"
495
+ });
496
+ let last = read();
497
+ list.measure();
498
+ const observer = new MutationObserver(() => {
499
+ const next = read();
500
+ if (next.place === last.place && next.shown === last.shown) return;
501
+ if (next.shown && last.shown) list.play();
502
+ last = next;
503
+ list.measure();
504
+ });
505
+ observer.observe(element, {
506
+ attributes: true,
507
+ attributeFilter: ["style"]
508
+ });
509
+ return () => {
510
+ observer.disconnect();
511
+ list.destroy();
512
+ };
513
+ }
514
+ /**
484
515
  * Nuxt UI's `UEditorDragHandle`: a handle beside the block under the pointer, which drags the block to move it. A press
485
516
  * selects the block and emits `nodeChange`. The default slot replaces the button and gets `onClick`, which selects the
486
517
  * block and returns it, and `ui.handle()`, the class of a handle button.
@@ -542,6 +573,13 @@ const UEditorDragHandle = defineComponent({
542
573
  props.ui.handle,
543
574
  options?.class
544
575
  ].filter(Boolean).join(" ") };
576
+ const handle = ref();
577
+ let stopFollowing;
578
+ onMounted(() => {
579
+ const element = handle.value?.$el;
580
+ if (element instanceof HTMLElement) stopFollowing = followPlace(element);
581
+ });
582
+ onBeforeUnmount(() => stopFollowing?.());
545
583
  const computePositionConfig = {
546
584
  middleware: [
547
585
  offset(({ rects }) => ({
@@ -557,6 +595,7 @@ const UEditorDragHandle = defineComponent({
557
595
  return () => h(BlockHandle, {
558
596
  class: ["vh-editor-drag-handle", props.ui.root].filter(Boolean).join(" "),
559
597
  computePositionConfig,
598
+ ref: handle,
560
599
  "data-slot": "editor-drag-handle",
561
600
  editor: props.editor,
562
601
  nested: props.nested,