@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,9 +1,16 @@
1
+ import { r as useUIComponent } from "./nuxt-ui-CgvMzO5v.js";
2
+ import { RollNumber } from "./parts/components/motion.js";
3
+ import { a as useViteHubUIIcons } from "./config-B1u7zqMB.js";
4
+ import { Attachment, AttachmentAction, AttachmentActions, AttachmentContent, AttachmentGroup, AttachmentMedia, AttachmentTitle } from "./parts/components/attachment.js";
1
5
  import { AvatarStack } from "./parts/components/avatar-stack.js";
2
- import { a as pathOf, c as swallowNextClick, l as useDocumentPointerDown, n as injectComments, r as consumedPointerEvents, s as shakeEventName } from "./comments-context-C2lOZyQ5.js";
6
+ import { t as ImagePreview } from "./image-preview-BigoAvb3.js";
7
+ import { c as shakeEventName, i as consumedPointerEvents, l as swallowNextClick, n as injectComments, o as pathOf, u as useDocumentPointerDown } from "./comments-context-DhbIdYQ1.js";
3
8
  import { i as toPerson, t as displayName } from "./comment-person-CLPlW_SS.js";
9
+ import { n as shake, t as travel } from "./travel-C87xd5Wh.js";
4
10
  import { i as matchesAccept } from "./attachments-BzTwqRTU.js";
11
+ import { t as createMotionList } from "./list-RCbNZ14q.js";
5
12
  import { PromptInput } from "./parts/components/prompt-input.js";
6
- import { computed, defineComponent, h, nextTick, onBeforeUnmount, onMounted, ref, useId, watch } from "vue";
13
+ import { computed, defineComponent, h, nextTick, onBeforeUnmount, onBeforeUpdate, onMounted, onUpdated, ref, useId, watch } from "vue";
7
14
  import { foldName } from "@vite-hub/comments/client";
8
15
  //#region src/internal/comment-mentions.ts
9
16
  /** The tag of a mention chip in a rendered message. */
@@ -82,6 +89,193 @@ function mentionPlugin(people) {
82
89
  return plugin;
83
90
  }
84
91
  //#endregion
92
+ //#region src/internal/comment-image-stack.ts
93
+ const closeDelay = 250;
94
+ /**
95
+ * The pictures of a comment box as one stack of cards beside the text, with their count. Hover or focus fans them out
96
+ * above the box, where each card opens full size and has its Remove button. A tap on the stack fans it out too.
97
+ *
98
+ * A new picture comes out of `origin`, such as the text for a paste or the attach button for a pick, and the others
99
+ * move to make room (docs/design/motion.md, "Items are added, removed, or reordered"). The fan travels each card from
100
+ * its place in the stack to its place in the fan and back ("Something moves to a new place").
101
+ */
102
+ const CommentImageStack = defineComponent({
103
+ name: "CommentImageStack",
104
+ props: {
105
+ images: {
106
+ required: true,
107
+ type: Array
108
+ },
109
+ /** The pictures can't be removed, such as while the comment is sent. */
110
+ disabled: {
111
+ default: false,
112
+ type: Boolean
113
+ },
114
+ /** Where the next new picture comes from. Read once for each change of `images`. */
115
+ origin: { type: Function }
116
+ },
117
+ emits: ["remove"],
118
+ setup(props, { emit }) {
119
+ const icons = useViteHubUIIcons();
120
+ const UButton = useUIComponent("UButton");
121
+ const root = ref();
122
+ const cards = ref();
123
+ const fanned = ref(false);
124
+ const bounds = ref({
125
+ left: 0,
126
+ width: 0,
127
+ scrollable: false
128
+ });
129
+ let observer;
130
+ let list;
131
+ let closer;
132
+ let hovered = false;
133
+ let focused = false;
134
+ let refocus = false;
135
+ let fanFrom;
136
+ const cardElements = () => [...cards.value?.children ?? []].filter((child) => child instanceof HTMLElement && child.hasAttribute("data-key") && !child.hasAttribute("data-motion-ghost"));
137
+ function measureBounds() {
138
+ const stack = root.value;
139
+ if (!stack) return;
140
+ const rect = (stack.closest("[data-slot=comment-composer-box]") ?? stack).getBoundingClientRect();
141
+ const left = Math.max(0, rect.left);
142
+ const documentRoot = stack.ownerDocument.documentElement;
143
+ const width = Math.max(0, Math.min(documentRoot.clientWidth, rect.right) - left);
144
+ const offset = left - stack.getBoundingClientRect().left;
145
+ const rem = Number.parseFloat(getComputedStyle(documentRoot).fontSize) || 16;
146
+ const scrollable = width < (props.images.length * 4 + .5) * rem;
147
+ if (bounds.value.left !== offset || bounds.value.width !== width || bounds.value.scrollable !== scrollable) bounds.value = {
148
+ left: offset,
149
+ width,
150
+ scrollable
151
+ };
152
+ }
153
+ function setFanned(value) {
154
+ clearTimeout(closer);
155
+ if (value && props.images.length === 0) value = false;
156
+ if (fanned.value === value) return;
157
+ fanFrom = new Map(cardElements().map((card) => [card, card.getBoundingClientRect()]));
158
+ if (value) measureBounds();
159
+ fanned.value = value;
160
+ }
161
+ const closeSoon = () => {
162
+ clearTimeout(closer);
163
+ closer = setTimeout(() => {
164
+ if (!focused && !hovered) setFanned(false);
165
+ }, closeDelay);
166
+ };
167
+ onMounted(() => {
168
+ if (cards.value) list = createMotionList(cards.value);
169
+ const box = root.value?.closest("[data-slot=comment-composer-box]");
170
+ if (box && typeof ResizeObserver !== "undefined") {
171
+ observer = new ResizeObserver(() => {
172
+ if (fanned.value) measureBounds();
173
+ });
174
+ observer.observe(box);
175
+ }
176
+ });
177
+ onBeforeUpdate(() => {
178
+ if (!fanFrom) list?.measure();
179
+ });
180
+ onUpdated(() => {
181
+ if (props.images.length === 0 && fanned.value) setFanned(false);
182
+ if (fanned.value) measureBounds();
183
+ const from = fanFrom;
184
+ fanFrom = void 0;
185
+ if (!from) return list?.play({ origin: props.origin?.() ?? void 0 });
186
+ for (const [card, box] of from) if (card.isConnected) travel(card, { from: box });
187
+ });
188
+ onBeforeUnmount(() => {
189
+ clearTimeout(closer);
190
+ observer?.disconnect();
191
+ list?.destroy();
192
+ });
193
+ const label = computed(() => props.images.length === 1 ? "1 picture" : `${props.images.length} pictures`);
194
+ return () => {
195
+ const count = props.images.length;
196
+ return h("div", {
197
+ "data-fanned": fanned.value ? "true" : void 0,
198
+ "data-slot": "comment-image-stack",
199
+ onFocusin: (event) => {
200
+ focused = true;
201
+ if (refocus) return;
202
+ if (event.target instanceof Element && event.target.matches(":focus-visible")) setFanned(true);
203
+ },
204
+ onFocusout: (event) => {
205
+ if (event.relatedTarget instanceof Node && root.value?.contains(event.relatedTarget)) return;
206
+ focused = false;
207
+ closeSoon();
208
+ },
209
+ onKeydown: (event) => {
210
+ if (event.key !== "Escape" || !fanned.value) return;
211
+ event.preventDefault();
212
+ event.stopPropagation();
213
+ setFanned(false);
214
+ refocus = true;
215
+ root.value?.querySelector("[data-slot=comment-image-stack-toggle]")?.focus();
216
+ refocus = false;
217
+ },
218
+ onPointerenter: (event) => {
219
+ if (event.pointerType !== "mouse") return;
220
+ hovered = true;
221
+ setFanned(true);
222
+ },
223
+ onPointerleave: (event) => {
224
+ if (event.pointerType !== "mouse") return;
225
+ hovered = false;
226
+ closeSoon();
227
+ },
228
+ ref: root,
229
+ role: "group",
230
+ "aria-label": `Attached ${label.value}`,
231
+ style: {
232
+ "--vh-fan-left": `${bounds.value.left}px`,
233
+ "--vh-fan-room": `${bounds.value.width}px`,
234
+ "--vh-fan-count": count
235
+ }
236
+ }, [
237
+ h("button", {
238
+ "aria-expanded": String(fanned.value),
239
+ "aria-label": `Show ${label.value}`,
240
+ "data-slot": "comment-image-stack-toggle",
241
+ onClick: () => setFanned(hovered || !fanned.value),
242
+ type: "button"
243
+ }),
244
+ h("div", {
245
+ "data-slot": "comment-image-stack-cards",
246
+ "data-scrollable": fanned.value && bounds.value.scrollable ? "true" : void 0,
247
+ ref: cards
248
+ }, props.images.map((image, index) => h("div", {
249
+ "data-key": image.key,
250
+ "data-slot": "comment-image-stack-card",
251
+ inert: fanned.value ? void 0 : true,
252
+ key: image.key,
253
+ style: { "--vh-stack-depth": count - 1 - index }
254
+ }, [h(ImagePreview, {
255
+ alt: image.name,
256
+ compact: true,
257
+ src: image.url
258
+ }), h(UButton, {
259
+ "aria-label": `Remove ${image.name}`,
260
+ color: "neutral",
261
+ "data-slot": "comment-image-stack-remove",
262
+ disabled: props.disabled,
263
+ icon: icons.value.close,
264
+ onClick: () => emit("remove", image.key),
265
+ size: "xs",
266
+ square: true,
267
+ variant: "ghost"
268
+ })]))),
269
+ count > 1 ? h(RollNumber, {
270
+ "aria-hidden": "true",
271
+ "data-slot": "comment-image-stack-count",
272
+ value: count
273
+ }) : null
274
+ ]);
275
+ };
276
+ }
277
+ });
278
+ //#endregion
85
279
  //#region src/components/comment-composer.ts
86
280
  const emptyLineQuery = /^\S{2,}$/u;
87
281
  const placeholders = {
@@ -105,6 +299,7 @@ const pastedFiles = (clipboard) => {
105
299
  return Array.from(clipboard.files).filter((file) => file.type.startsWith("image/") || !hasText);
106
300
  };
107
301
  const escapeWindow = 2e3;
302
+ const revokeDelay = 1e3;
108
303
  const CommentComposer = defineComponent({
109
304
  name: "CommentComposer",
110
305
  props: {
@@ -224,6 +419,7 @@ const CommentComposer = defineComponent({
224
419
  const allowEmpty = computed(() => props.allowEmpty ?? props.variant === "reply");
225
420
  const parts = /* @__PURE__ */ new WeakMap();
226
421
  const urls = /* @__PURE__ */ new Set();
422
+ const revokers = [];
227
423
  const partOf = (file) => {
228
424
  let part = parts.get(file);
229
425
  if (!part) {
@@ -243,9 +439,11 @@ const CommentComposer = defineComponent({
243
439
  for (const file of previous) {
244
440
  const part = parts.get(file);
245
441
  if (part && !next.includes(file)) {
246
- URL.revokeObjectURL(part.url);
247
- urls.delete(part.url);
248
442
  parts.delete(file);
443
+ revokers.push(setTimeout(() => {
444
+ URL.revokeObjectURL(part.url);
445
+ urls.delete(part.url);
446
+ }, revokeDelay));
249
447
  }
250
448
  }
251
449
  });
@@ -303,19 +501,20 @@ const CommentComposer = defineComponent({
303
501
  () => props.layout,
304
502
  () => props.size
305
503
  ], measureLines, { flush: "post" });
306
- async function shake() {
504
+ async function shake$1() {
307
505
  const reduced = typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
308
506
  shaking.value = null;
309
507
  await nextTick();
310
508
  root.value?.offsetWidth;
311
509
  shaking.value = reduced ? "flash" : "shake";
510
+ if (!reduced && root.value) shake(root.value);
312
511
  clearTimeout(timer);
313
512
  timer = setTimeout(() => shaking.value = null, 450);
314
513
  focus();
315
514
  }
316
515
  const onShake = (event) => {
317
516
  if (event instanceof CustomEvent && event.detail?.escape === true) escaped.value = true;
318
- shake();
517
+ shake$1();
319
518
  };
320
519
  onMounted(() => {
321
520
  root.value?.addEventListener(shakeEventName, onShake);
@@ -329,11 +528,12 @@ const CommentComposer = defineComponent({
329
528
  root.value?.removeEventListener(shakeEventName, onShake);
330
529
  clearTimeout(timer);
331
530
  clearTimeout(escapeTimer);
531
+ for (const revoker of revokers) clearTimeout(revoker);
332
532
  for (const url of urls) URL.revokeObjectURL(url);
333
533
  });
334
534
  expose({
335
535
  focus,
336
- shake
536
+ shake: shake$1
337
537
  });
338
538
  watch(menu, (open) => {
339
539
  const field = textarea();
@@ -356,7 +556,7 @@ const CommentComposer = defineComponent({
356
556
  if (hasContent()) {
357
557
  event.stopPropagation();
358
558
  swallowNextClick();
359
- shake();
559
+ shake$1();
360
560
  } else emit("cancel");
361
561
  });
362
562
  function checkSelection() {
@@ -445,6 +645,7 @@ const CommentComposer = defineComponent({
445
645
  }
446
646
  function keydown(event) {
447
647
  if (event.isComposing) return;
648
+ if (event.target instanceof Element && event.target.closest("[data-slot=comment-image-stack][data-fanned]")) return;
448
649
  const open = menu.value;
449
650
  const listed = open !== null && open.items.length > 0;
450
651
  if (listed && (event.key === "ArrowDown" || event.key === "ArrowUp")) {
@@ -469,7 +670,7 @@ const CommentComposer = defineComponent({
469
670
  menu.value = null;
470
671
  } else if (hasContent() && !escaped.value) {
471
672
  escaped.value = true;
472
- shake();
673
+ shake$1();
473
674
  } else discard();
474
675
  }
475
676
  async function discard() {
@@ -484,6 +685,47 @@ const CommentComposer = defineComponent({
484
685
  emit("cancel");
485
686
  }
486
687
  const hasFiles = (event) => attachmentsOn.value && (event.dataTransfer?.types.includes("Files") ?? false);
688
+ let origin;
689
+ const takeOrigin = () => {
690
+ const from = origin;
691
+ origin = void 0;
692
+ return from;
693
+ };
694
+ const UIcon = useUIComponent("UIcon");
695
+ const icons = useViteHubUIIcons();
696
+ const fileList = ({ files: list, remove }) => {
697
+ const images = [];
698
+ const others = [];
699
+ list.forEach((file, index) => {
700
+ if (file.mediaType.startsWith("image/")) images.push({
701
+ key: file.url,
702
+ name: file.filename ?? "Picture",
703
+ url: file.url
704
+ });
705
+ else others.push({
706
+ file,
707
+ index
708
+ });
709
+ });
710
+ return [h(CommentImageStack, {
711
+ disabled: props.busy,
712
+ images,
713
+ onRemove: (key) => remove(list.findIndex((file) => file.url === key)),
714
+ origin: takeOrigin
715
+ }), others.length > 0 ? h(AttachmentGroup, { "data-slot": "prompt-input-attachments" }, () => others.map(({ file, index }) => h(Attachment, {
716
+ key: file.url,
717
+ size: "xs"
718
+ }, () => [
719
+ h(AttachmentMedia, { variant: "icon" }, () => h(UIcon, { name: icons.value.file })),
720
+ h(AttachmentContent, () => h(AttachmentTitle, () => file.filename ?? file.mediaType)),
721
+ h(AttachmentActions, () => h(AttachmentAction, {
722
+ "aria-label": `Remove ${file.filename ?? "attachment"}`,
723
+ disabled: props.busy,
724
+ icon: icons.value.close,
725
+ onClick: () => remove(index)
726
+ }))
727
+ ]))) : null];
728
+ };
487
729
  return () => h("div", {
488
730
  "data-busy": props.busy ? "true" : void 0,
489
731
  "data-dirty": hasContent() ? "true" : void 0,
@@ -504,6 +746,7 @@ const CommentComposer = defineComponent({
504
746
  },
505
747
  onPasteCapture: (event) => {
506
748
  if (!attachmentsOn.value || !event.clipboardData) return;
749
+ origin = textarea();
507
750
  if (pastedFiles(event.clipboardData).some((file) => matchesAccept(file, props.accept))) event.preventDefault();
508
751
  },
509
752
  onDragover: (event) => {
@@ -518,9 +761,13 @@ const CommentComposer = defineComponent({
518
761
  dragging.value = false;
519
762
  if (!hasFiles(event)) return;
520
763
  event.preventDefault();
764
+ origin = root.value?.querySelector("[data-slot=prompt-input-group]");
521
765
  addFiles(event.dataTransfer?.files ?? []);
522
766
  focus();
523
767
  },
768
+ onChangeCapture: (event) => {
769
+ if (event.target instanceof HTMLInputElement && event.target.type === "file") origin = root.value?.querySelector("[data-slot=prompt-input-toolbar] button[aria-label='Add attachment']");
770
+ },
524
771
  ref: root
525
772
  }, [h("div", { "data-slot": "comment-composer-box" }, [
526
773
  slots.extra ? h("div", { "data-slot": "comment-composer-extra" }, slots.extra()) : null,
@@ -542,7 +789,7 @@ const CommentComposer = defineComponent({
542
789
  onSubmit: submit,
543
790
  "onUpdate:files": (next) => setFiles(files.value.filter((file) => next.includes(partOf(file)))),
544
791
  "onUpdate:modelValue": (value) => emit("update:modelValue", value)
545
- }),
792
+ }, attachmentsOn.value ? { files: fileList } : void 0),
546
793
  menu.value && menu.value.items.length === 0 ? h("div", {
547
794
  "data-slot": "comment-composer-mentions",
548
795
  "data-state": menu.value.failed ? "error" : "empty",
@@ -230,10 +230,10 @@ declare const CommentComposer: import("vue").DefineComponent<import("vue").Extra
230
230
  modelValue: string;
231
231
  autofocus: boolean;
232
232
  variant: CommentComposerVariant;
233
- people: CommentUser[];
234
233
  mentions: string[];
235
234
  busy: boolean;
236
235
  guard: boolean;
236
+ people: CommentUser[];
237
237
  participants: string[];
238
238
  attachments: boolean;
239
239
  allowEmpty: boolean;
@@ -1,8 +1,8 @@
1
1
  import { n as AvatarStackPerson } from "./avatar-stack-DXmCQhxd.js";
2
- import { r as CommentComposerSize } from "./comment-composer-Cc8Jvu6u.js";
3
- import { o as CommentsState, t as CommentCan } from "./comments-Bx2WRsYy.js";
4
- import { n as CommentAttachmentUrl } from "./comment-thread-CoTLrdal.js";
5
- import { c as CommentUpload } from "./comment-panel-fcKSKwLC.js";
2
+ import { r as CommentComposerSize } from "./comment-composer-DvKMTrAi.js";
3
+ import { s as CommentsState, t as CommentCan } from "./comments-D8hulVPy.js";
4
+ import { n as CommentAttachmentUrl } from "./comment-thread-C6U-bsK_.js";
5
+ import { c as CommentUpload } from "./comment-panel-CsKWTms_.js";
6
6
  import { PropType } from "vue";
7
7
  import { CommentSubject, CommentUser, CommentsClient } from "@vite-hub/comments/client";
8
8
  //#region src/components/comment-layer.d.ts
@@ -51,10 +51,15 @@ declare const CommentLayer: import("vue").DefineComponent<import("vue").ExtractP
51
51
  can: {
52
52
  type: PropType<CommentCan>;
53
53
  };
54
- /** Turns attached files into attachment keys. Without it the boxes take no files. */
54
+ /** Turns attached files into attachment keys before the comment is saved or sent. */
55
55
  upload: {
56
56
  type: PropType<CommentUpload>;
57
57
  };
58
+ /** Save raw files with outbox entries. Set only when the server accepts file uploads. `upload` takes precedence. */
59
+ queueFiles: {
60
+ default: boolean;
61
+ type: BooleanConstructor;
62
+ };
58
63
  /** The file types that the boxes take, such as `image/*`. */
59
64
  accept: {
60
65
  type: StringConstructor;
@@ -125,10 +130,15 @@ declare const CommentLayer: import("vue").DefineComponent<import("vue").ExtractP
125
130
  can: {
126
131
  type: PropType<CommentCan>;
127
132
  };
128
- /** Turns attached files into attachment keys. Without it the boxes take no files. */
133
+ /** Turns attached files into attachment keys before the comment is saved or sent. */
129
134
  upload: {
130
135
  type: PropType<CommentUpload>;
131
136
  };
137
+ /** Save raw files with outbox entries. Set only when the server accepts file uploads. `upload` takes precedence. */
138
+ queueFiles: {
139
+ default: boolean;
140
+ type: BooleanConstructor;
141
+ };
132
142
  /** The file types that the boxes take, such as `image/*`. */
133
143
  accept: {
134
144
  type: StringConstructor;
@@ -159,6 +169,7 @@ declare const CommentLayer: import("vue").DefineComponent<import("vue").ExtractP
159
169
  people: AvatarStackPerson[];
160
170
  hotkey: string | false;
161
171
  readOnly: boolean;
172
+ queueFiles: boolean;
162
173
  placement: CommentPlacement;
163
174
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
164
175
  //#endregion
@@ -1,6 +1,6 @@
1
1
  import { n as AvatarStackPerson } from "./avatar-stack-DXmCQhxd.js";
2
- import { o as CommentsState } from "./comments-Bx2WRsYy.js";
3
- import { s as CommentRowSlots } from "./comment-panel-fcKSKwLC.js";
2
+ import { s as CommentsState } from "./comments-D8hulVPy.js";
3
+ import { s as CommentRowSlots } from "./comment-panel-CsKWTms_.js";
4
4
  import { PropType, SlotsType } from "vue";
5
5
  //#region src/components/comment-list.d.ts
6
6
  declare const CommentFilters: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
@@ -11,7 +11,10 @@
11
11
  * firmer (45%), `data-status="resolved"` makes it dashed and grey, and `data-draft="true"` is the area being drawn or
12
12
  * written on: 2px comment blue with a fill. Its `comment-mark-handle` children, with `data-corner="top-left"` and the
13
13
  * other three corners, are round handles.
14
- * - `data-leaving="true"` on a pin or an area: it shrinks and fades out in 130ms (`commentLeaveMs` of `vite-hub/ui/headless`), then the page removes it.
14
+ * - `data-leaving="true"` on a pin or an area fades it out. If the motion layer is installed, it folds a copy away
15
+ * instead. The page removes the mark after `commentLeaveMs` of `vite-hub/ui/headless`.
16
+ * A pin squashes when it is pressed, with the press of the motion layer. Its zoom and its active size are a `transform`,
17
+ * so the press adds to them.
15
18
  * The page places a pin with `left` and `top`, and an area with `left`, `top`, `width`, and `height`.
16
19
  * Commented text uses the CSS Custom Highlight API with the names `vh-comment`, `vh-comment-resolved`,
17
20
  * `vh-comment-active`, and `vh-comment-draft`.
@@ -96,9 +99,9 @@
96
99
  padding: 0;
97
100
  place-items: center;
98
101
  position: absolute;
99
- scale: var(--vh-comment-zoom, 1);
102
+ transform: scale(var(--vh-comment-zoom, 1));
100
103
  transform-origin: 0 100%;
101
- transition: scale 120ms ease-out, opacity 150ms ease-out;
104
+ transition: opacity 150ms ease-out;
102
105
  width: var(--vh-comment-pin-size);
103
106
  }
104
107
 
@@ -123,15 +126,9 @@
123
126
  position: absolute;
124
127
  }
125
128
 
126
- :is([data-slot="comment-mark-pin"], [data-slot="comment-pin"]):is(:hover, :focus-visible, [data-active="true"]) {
127
- scale: calc(var(--vh-comment-zoom, 1) * 1.06);
128
- }
129
-
130
- /* A tap must not leave the pin grown, so only a fine pointer grows it on hover. */
131
- @media not ((hover: hover) and (pointer: fine)) {
132
- :is([data-slot="comment-mark-pin"], [data-slot="comment-pin"]):hover:not(:focus-visible, [data-active="true"]) {
133
- scale: var(--vh-comment-zoom, 1);
134
- }
129
+ /* The open pin and the focused pin are larger. A pin does not move on hover. */
130
+ :is([data-slot="comment-mark-pin"], [data-slot="comment-pin"]):is(:focus-visible, [data-active="true"]) {
131
+ transform: scale(calc(var(--vh-comment-zoom, 1) * 1.06));
135
132
  }
136
133
 
137
134
  :is([data-slot="comment-mark-pin"], [data-slot="comment-pin"])[data-status="resolved"] {
@@ -188,23 +185,23 @@
188
185
  :is([data-slot="comment-mark-handle"], [data-slot="comment-layer-area-handle"])[data-corner$="left"] { left: -5px; }
189
186
  :is([data-slot="comment-mark-handle"], [data-slot="comment-layer-area-handle"])[data-corner$="right"] { right: -5px; }
190
187
 
191
- /* A mark that goes, such as the others when one comment shows on its own: it shrinks and fades. */
188
+ /* A mark that goes, such as the others when one comment shows on its own. The leave effect of the motion layer folds a
189
+ copy of it away. */
192
190
  :is([data-slot="comment-mark-pin"], [data-slot="comment-mark-area"])[data-leaving="true"],
193
191
  [data-slot="comment-layer-item"][data-leaving="true"] > * {
194
- animation: vh-comment-mark-leave 130ms cubic-bezier(0.4, 0, 1, 1) forwards;
195
192
  pointer-events: none;
196
193
  }
197
194
 
198
- [data-slot="comment-mark-area"][data-leaving="true"] {
199
- animation-name: vh-comment-mark-leave-area;
195
+ :is([data-slot="comment-mark-pin"], [data-slot="comment-mark-area"])[data-leaving="true"]:not([data-motion-leave-managed]) {
196
+ animation: vh-comment-mark-fade 130ms cubic-bezier(0.4, 0, 1, 1) forwards;
200
197
  }
201
198
 
202
- @keyframes vh-comment-mark-leave {
203
- to { opacity: 0; scale: calc(var(--vh-comment-zoom, 1) * 0.8); }
199
+ [data-slot="comment-mark-pin"][data-motion-leave-managed] {
200
+ transition: none;
204
201
  }
205
202
 
206
- @keyframes vh-comment-mark-leave-area {
207
- to { opacity: 0; scale: 0.97; }
203
+ @keyframes vh-comment-mark-fade {
204
+ to { opacity: 0; }
208
205
  }
209
206
 
210
207
  @media (prefers-reduced-motion: reduce) {
@@ -212,8 +209,7 @@
212
209
  transition: none;
213
210
  }
214
211
 
215
- :is([data-slot="comment-mark-pin"], [data-slot="comment-mark-area"])[data-leaving="true"],
216
- [data-slot="comment-layer-item"][data-leaving="true"] > * {
212
+ :is([data-slot="comment-mark-pin"], [data-slot="comment-mark-area"])[data-leaving="true"]:not([data-motion-leave-managed]) {
217
213
  animation: none;
218
214
  opacity: 0;
219
215
  }
@@ -1,5 +1,5 @@
1
- import { o as CommentsState, t as CommentCan } from "./comments-Bx2WRsYy.js";
2
- import { c as CommentThreadSlots, n as CommentAttachmentUrl } from "./comment-thread-CoTLrdal.js";
1
+ import { s as CommentsState, t as CommentCan } from "./comments-D8hulVPy.js";
2
+ import { l as CommentThreadSlots, n as CommentAttachmentUrl } from "./comment-thread-C6U-bsK_.js";
3
3
  import { PropType, SlotsType, VNode } from "vue";
4
4
  import { CommentStatus, CommentSubject, CommentThread, CommentUser, CommentsClient } from "@vite-hub/comments/client";
5
5
  //#region src/components/comment-panel.d.ts
@@ -72,10 +72,15 @@ declare const CommentPanel: import("vue").DefineComponent<import("vue").ExtractP
72
72
  default: boolean;
73
73
  type: BooleanConstructor;
74
74
  };
75
- /** Turns attached files into attachment keys. Without it the boxes take no files. */
75
+ /** Turns attached files into attachment keys before the comment is saved or sent. */
76
76
  upload: {
77
77
  type: PropType<CommentUpload>;
78
78
  };
79
+ /** Save raw files with outbox entries. Set only when the server accepts file uploads. `upload` takes precedence. */
80
+ queueFiles: {
81
+ default: boolean;
82
+ type: BooleanConstructor;
83
+ };
79
84
  /** The file types that the boxes take, such as `image/*`. */
80
85
  accept: {
81
86
  type: StringConstructor;
@@ -148,10 +153,15 @@ declare const CommentPanel: import("vue").DefineComponent<import("vue").ExtractP
148
153
  default: boolean;
149
154
  type: BooleanConstructor;
150
155
  };
151
- /** Turns attached files into attachment keys. Without it the boxes take no files. */
156
+ /** Turns attached files into attachment keys before the comment is saved or sent. */
152
157
  upload: {
153
158
  type: PropType<CommentUpload>;
154
159
  };
160
+ /** Save raw files with outbox entries. Set only when the server accepts file uploads. `upload` takes precedence. */
161
+ queueFiles: {
162
+ default: boolean;
163
+ type: BooleanConstructor;
164
+ };
155
165
  /** The file types that the boxes take, such as `image/*`. */
156
166
  accept: {
157
167
  type: StringConstructor;
@@ -191,6 +201,7 @@ declare const CommentPanel: import("vue").DefineComponent<import("vue").ExtractP
191
201
  people: CommentUser[];
192
202
  allowEmpty: boolean;
193
203
  readOnly: boolean;
204
+ queueFiles: boolean;
194
205
  thread: string | null;
195
206
  }, SlotsType<CommentPanelSlots>, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
196
207
  //#endregion
@@ -1,6 +1,6 @@
1
1
  import { AvatarStack } from "./parts/components/avatar-stack.js";
2
2
  import { a as writerName, o as writerPerson, r as plainText } from "./comment-person-CLPlW_SS.js";
3
- import { t as RelativeTime } from "./relative-time-BVmjOsYG.js";
3
+ import { t as RelativeTime } from "./relative-time-DgSS3zKN.js";
4
4
  import { h } from "vue";
5
5
  //#region src/internal/comment-row.ts
6
6
  /** The start of a thread as plain text: its first message, else the text that it is about. */
@@ -19,7 +19,7 @@ function rowSlotScope(thread) {
19
19
  function threadRow(thread, options = {}) {
20
20
  const replies = thread.messages.length - 1;
21
21
  return [
22
- h("span", { "data-slot": "comment-list-number" }, String(thread.n)),
22
+ h("span", { "data-slot": "comment-list-number" }, thread.n ? String(thread.n) : ""),
23
23
  h(AvatarStack, {
24
24
  "aria-hidden": "true",
25
25
  people: [writerPerson(thread)],
@@ -0,0 +1,42 @@
1
+ import { PropType, VNode } from "vue";
2
+ //#region src/components/comment-selection-bar.d.ts
3
+ /** The side of the selected text that the bar sits on. */
4
+ type CommentSelectionBarSide = "top" | "bottom";
5
+ /**
6
+ * The bar over selected text: Comment, and Suggest when the page takes suggested changes. It is the dark surface on a
7
+ * light page and its light twin on a dark one, so it stands out from the text. The page places it and listens for the
8
+ * keys. A press on the bar keeps the selection on the page.
9
+ */
10
+ declare const CommentSelectionBar: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
11
+ /** Show Suggest (E), for a page that takes suggested changes. */
12
+ suggest: {
13
+ default: boolean;
14
+ type: BooleanConstructor;
15
+ };
16
+ /** The side of the text that the bar is on. The bar grows from that side, and its tooltips open away from the text. */
17
+ side: {
18
+ default: string;
19
+ type: PropType<CommentSelectionBarSide>;
20
+ };
21
+ }>, () => VNode<import("vue").RendererNode, import("vue").RendererElement, {
22
+ [key: string]: any;
23
+ }>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("comment" | "suggest")[], "comment" | "suggest", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
24
+ /** Show Suggest (E), for a page that takes suggested changes. */
25
+ suggest: {
26
+ default: boolean;
27
+ type: BooleanConstructor;
28
+ };
29
+ /** The side of the text that the bar is on. The bar grows from that side, and its tooltips open away from the text. */
30
+ side: {
31
+ default: string;
32
+ type: PropType<CommentSelectionBarSide>;
33
+ };
34
+ }>> & Readonly<{
35
+ onComment?: ((...args: any[]) => any) | undefined;
36
+ onSuggest?: ((...args: any[]) => any) | undefined;
37
+ }>, {
38
+ side: CommentSelectionBarSide;
39
+ suggest: boolean;
40
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
41
+ //#endregion
42
+ export { CommentSelectionBarSide as n, CommentSelectionBar as t };