@vite-hub/ui 0.6.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +106 -46
- package/dist/AttachmentTitle-BWw0ck0T.js +110 -0
- package/dist/BubbleContent-B1a4e3vE.js +45 -0
- package/dist/Chat-CuSthJVg.js +112 -0
- package/dist/ChatMessage-CFQs0v4N.js +94 -0
- package/dist/CodeBlockContent-BjXJm8lO.js +92 -0
- package/dist/CodeBlockTitle-DIu8Ef3V.js +99 -0
- package/dist/CommentRow-XY3FNp30.js +86 -0
- package/dist/CopyButton-Bs6DT-Z8.js +188 -0
- package/dist/Markdown-Da5t-931.js +70 -0
- package/dist/MarkdownCodeBlock-BWDLOWPO.js +127 -0
- package/dist/MarkdownImage-CJN3myt4.js +111 -0
- package/dist/MessageHeader-CJ9eBHSS.js +61 -0
- package/dist/MessageParts-CyJLG34y.js +57 -0
- package/dist/MessageScrollerViewport-BaTlWLki.js +142 -0
- package/dist/MorphText-B6MWdeIv.js +36 -0
- package/dist/RollNumber-CnF52zJM.js +49 -0
- package/dist/SwapIcon-CUIq1TU5.js +67 -0
- package/dist/TraceTitle-Cp0y7RRD.js +133 -0
- package/dist/agent-session-2j2gbGpp.js +875 -0
- package/dist/agent-session-BwZSMi4S.d.ts +312 -0
- package/dist/appendItems-hQ4aBd9Q.js +4047 -0
- package/dist/attachment-BllgHx9Q.d.ts +124 -0
- package/dist/attachment-DQMJNfj0.js +35 -0
- package/dist/avatar-stack-Bj1xUkzY.d.ts +4 -0
- package/dist/avatar-stack-CoLlsmwJ.js +72 -0
- package/dist/bubble-D3M2_InY.js +32 -0
- package/dist/bubble-DmplVxLr.d.ts +64 -0
- package/dist/chat-DWdyMSuj.d.ts +13 -0
- package/dist/chat-message-QLHnX_ED.d.ts +11 -0
- package/dist/chat-session-BOj5L3Ey.d.ts +29 -0
- package/dist/chat-session-cxUzvwdj.js +43 -0
- package/dist/choices-input-DqgXl5a-.d.ts +97 -0
- package/dist/{vue-d2Td6uu2.js → client-BG-oCUtv-5i4sRwXP.js} +4156 -4156
- package/dist/code-block-BqOEVWPh.d.ts +182 -0
- package/dist/code-block-CMERLfew.js +14 -0
- package/dist/code-view-26RY6dX8.js +137 -0
- package/dist/code-view-D8yYdFUc.d.ts +184 -0
- package/dist/{comment-composer-DmDM3XYP.d.ts → comment-composer-CsVOvG9j.d.ts} +6 -6
- package/dist/{comment-composer-X7vJKh5b.js → comment-composer-D_mcH3Ts.js} +175 -37
- package/dist/{comment-layer-KnnVfdRV.d.ts → comment-layer-C3xmg-0_.d.ts} +14 -5
- package/dist/comment-layer-Ci6ipGi2.js +1206 -0
- package/dist/{comment-panel-DoLDOw3E.d.ts → comment-panel-DxN21VoY.d.ts} +24 -17
- package/dist/comment-selection-bar-B_bchB2O.d.ts +33 -0
- package/dist/comment-selection-bar-DZAtiRZ9.js +144 -0
- package/dist/{comment-thread-DPV2kqA4.d.ts → comment-thread-BmsqcjVQ.d.ts} +9 -8
- package/dist/{comment-thread-jqPx6aJ8.js → comment-thread-BzOZVqF2.js} +74 -49
- package/dist/comments-BU8cTt5o.d.ts +50 -0
- package/dist/{comments-9MDSNm-9.js → comments-BaSrroRV.js} +32 -4
- package/dist/{comments-OWjNidkP.d.ts → comments-ZfV6IZs8.d.ts} +9 -2
- package/dist/components-B_2Q0dJ3.js +269 -0
- package/dist/{config-LRonN53j.js → config-BDQYUjjp.js} +10 -29
- package/dist/{config-COSdO-ay.d.ts → config-JmsTI7gs.d.ts} +20 -33
- package/dist/connection-status-BVSH2ZVo.js +72 -0
- package/dist/connection-status-g62BTn44.d.ts +37 -0
- package/dist/copy-button-CRiXUFsl.d.ts +17 -0
- package/dist/device-frame-BW6IjB6P.d.ts +78 -0
- package/dist/device-frame-DDWoyB-G.js +515 -0
- package/dist/diffs-BTKaVnsb.d.ts +272 -0
- package/dist/diffs.d.ts +3 -0
- package/dist/{pierre-code-view-C49BVDrc.js → diffs.js} +147 -4223
- package/dist/drop-field-C0bXv1J-.d.ts +35 -0
- package/dist/drop-field-DeIvKoJs.js +77 -0
- package/dist/editor-BsOTjnnN.d.ts +540 -0
- package/dist/{markdown-editor-D1irG9Xl.js → editor-hXea1i46.js} +833 -106
- package/dist/editor.d.ts +2 -0
- package/dist/editor.js +3 -0
- package/dist/element-BpjNQvZ0.js +6 -0
- package/dist/{file-tree-CRFIdtzw.js → file-tree-B4JKbp4r.js} +19 -18
- package/dist/{file-tree-DOtkeBaq.d.ts → file-tree-BdnKA6UA.d.ts} +33 -8
- package/dist/file-tree-DDSIafDn.d.ts +22 -0
- package/dist/file-tree-DS5shGSL.js +46 -0
- package/dist/file-tree.d.ts +2 -0
- package/dist/file-tree.js +1 -0
- package/dist/files-cuVXzWlx.js +30 -0
- package/dist/filter-search-C9e6sGij.d.ts +28 -0
- package/dist/filter-search-COZsoRiR.js +73 -0
- package/dist/formatCSSVariablePrefix-DLS1Ed1_.js +5 -0
- package/dist/headless-2IcUWHMq.d.ts +51 -0
- package/dist/headless.d.ts +7 -4
- package/dist/headless.js +5 -3
- package/dist/highlight.d.ts +2 -0
- package/dist/highlight.js +1 -0
- package/dist/{highlights-C2AbEdDI.js → highlights-8Al0-h-v.js} +3 -2
- package/dist/{hold-to-delete-BSMrpE-i.d.ts → hold-to-delete-CQc1JaG_.d.ts} +7 -0
- package/dist/{hold-to-delete-Cludb56v.js → hold-to-delete-D1Vy40w5.js} +138 -20
- package/dist/hold-to-delete-DazElJT2.js +85 -0
- package/dist/hold-to-delete-ksBE7wxc.d.ts +58 -0
- package/dist/index-CffOzibW.d.ts +77 -0
- package/dist/{index-B2cbt3py.d.ts → index-D3-uYBqH.d.ts} +1 -1
- package/dist/index.d.ts +165 -52
- package/dist/index.js +126 -670
- package/dist/markdown-BLALLOc0.d.ts +45 -0
- package/dist/{parts/components/markdown-renderer.d.ts → markdown-DkDxdpMU.d.ts} +10 -7
- package/dist/{markdown-renderer-DMyYKeil.js → markdown-_0HhbsOo.js} +125 -127
- package/dist/markdown-editor.d.ts +51 -98
- package/dist/markdown-editor.js +70 -3
- package/dist/markdown.d.ts +2 -0
- package/dist/markdown.js +1 -0
- package/dist/marker-CvcWZ3Zp.d.ts +59 -0
- package/dist/marker-DNL6QR3L.js +63 -0
- package/dist/message-BwivYIEl.js +13 -0
- package/dist/message-DEq4K5cQ.d.ts +72 -0
- package/dist/message-parts-B1BZFVKe.d.ts +3 -0
- package/dist/message-parts-CG3gNWn8.d.ts +11 -0
- package/dist/message-parts.d.ts +2 -0
- package/dist/message-parts.js +1 -0
- package/dist/message-scroller-D7AvM31v.d.ts +41 -0
- package/dist/motion/core.d.ts +4 -4
- package/dist/motion/core.js +5 -11
- package/dist/motion-BH6ShUam.d.ts +12 -0
- package/dist/{install-C4LwcJda.js → motion-BhARaNBB.js} +1 -1
- package/dist/{effects-C1zYpSpg.js → motion-core-JZZiPKEk.js} +1829 -120
- package/dist/{motion-core-Dh20n5Se.d.ts → motion-core-gfsTPLbh.d.ts} +35 -74
- package/dist/motion-list-9vD1hSS0.js +49 -0
- package/dist/motion.d.ts +5 -14
- package/dist/motion.js +6 -13
- package/dist/nuxt-ui-D3Qda35W.js +22 -0
- package/dist/nuxt.d.ts +9 -5
- package/dist/nuxt.js +28 -33
- package/dist/parts/components/agent-session.d.ts +2 -295
- package/dist/parts/components/agent-session.js +1 -659
- package/dist/parts/components/attachment.d.ts +2 -85
- package/dist/parts/components/attachment.js +3 -72
- package/dist/parts/components/avatar-stack.d.ts +3 -2
- package/dist/parts/components/avatar-stack.js +1 -60
- package/dist/parts/components/bubble.d.ts +2 -69
- package/dist/parts/components/bubble.js +3 -52
- package/dist/parts/components/chat-message.d.ts +3 -25
- package/dist/parts/components/chat-message.js +1 -50
- package/dist/parts/components/chat-session.d.ts +2 -26
- package/dist/parts/components/chat-session.js +1 -37
- package/dist/parts/components/chat.d.ts +3 -52
- package/dist/parts/components/chat.js +1 -105
- package/dist/parts/components/code-block.d.ts +2 -102
- package/dist/parts/components/code-block.js +4 -109
- package/dist/parts/components/code-view.d.ts +3 -268
- package/dist/parts/components/code-view.js +1 -1
- package/dist/parts/components/comment-composer.d.ts +1 -1
- package/dist/parts/components/comment-composer.js +1 -1
- package/dist/parts/components/comment-layer.d.ts +1 -1
- package/dist/parts/components/comment-layer.js +1 -634
- package/dist/parts/components/comment-panel.d.ts +2 -2
- package/dist/parts/components/comment-panel.js +22 -16
- package/dist/parts/components/comment-selection-bar.d.ts +2 -2
- package/dist/parts/components/comment-selection-bar.js +1 -116
- package/dist/parts/components/comment-thread.d.ts +1 -1
- package/dist/parts/components/comment-thread.js +1 -3
- package/dist/parts/components/comments.d.ts +8 -9
- package/dist/parts/components/comments.js +5 -9
- package/dist/parts/components/connection-status.d.ts +2 -36
- package/dist/parts/components/connection-status.js +1 -64
- package/dist/parts/components/copy-button.d.ts +3 -126
- package/dist/parts/components/copy-button.js +1 -226
- package/dist/parts/components/device-frame.d.ts +2 -128
- package/dist/parts/components/device-frame.js +1 -470
- package/dist/parts/components/drop-field.d.ts +2 -67
- package/dist/parts/components/drop-field.js +1 -76
- package/dist/parts/components/file-tree.d.ts +3 -2
- package/dist/parts/components/file-tree.js +3 -1
- package/dist/parts/components/filter-search.d.ts +2 -45
- package/dist/parts/components/filter-search.js +1 -57
- package/dist/parts/components/hold-to-delete.d.ts +2 -80
- package/dist/parts/components/hold-to-delete.js +1 -75
- package/dist/parts/components/markdown.d.ts +3 -45
- package/dist/parts/components/markdown.js +1 -46
- package/dist/parts/components/marker.d.ts +2 -32
- package/dist/parts/components/marker.js +1 -22
- package/dist/parts/components/message-parts.d.ts +3 -25
- package/dist/parts/components/message-parts.js +1 -45
- package/dist/parts/components/message.d.ts +2 -32
- package/dist/parts/components/message.js +3 -22
- package/dist/parts/components/motion-list.d.ts +2 -40
- package/dist/parts/components/motion-list.js +1 -41
- package/dist/parts/components/motion.d.ts +5 -118
- package/dist/parts/components/motion.js +5 -163
- package/dist/parts/components/patch-parsers.d.ts +1 -1
- package/dist/parts/components/progress.d.ts +2 -39
- package/dist/parts/components/progress.js +1 -53
- package/dist/parts/components/prompt-input.d.ts +2 -134
- package/dist/parts/components/prompt-input.js +1 -253
- package/dist/parts/components/relative-time.d.ts +2 -71
- package/dist/parts/components/relative-time.js +1 -1
- package/dist/parts/components/status.d.ts +2 -58
- package/dist/parts/components/status.js +1 -47
- package/dist/parts/components/sync-status.d.ts +2 -22
- package/dist/parts/components/sync-status.js +1 -48
- package/dist/parts/components/tool-list.d.ts +2 -28
- package/dist/parts/components/tool-list.js +1 -118
- package/dist/parts/components/trace-run.d.ts +2 -25
- package/dist/parts/components/trace-run.js +1 -89
- package/dist/parts/components/trace.d.ts +2 -59
- package/dist/parts/components/trace.js +1 -76
- package/dist/parts/composables/attachments.js +75 -1
- package/dist/parts/headless/choices-input.d.ts +2 -2
- package/dist/parts/headless/choices-input.js +49 -37
- package/dist/parts/headless/comments.d.ts +1 -1
- package/dist/parts/headless/comments.js +1 -1
- package/dist/parts/headless/message-scroller.d.ts +2 -2
- package/dist/parts/headless/message-scroller.js +211 -309
- package/dist/parts/headless/relative-time.d.ts +2 -0
- package/dist/parts/headless/relative-time.js +1 -0
- package/dist/parts/workspace/browser-support-notice.d.ts +1 -1
- package/dist/parts/workspace/browser-support-notice.js +6 -5
- package/dist/parts/workspace/connect-panel.js +1 -1
- package/dist/parts/workspace/runners/web-container.js +2 -2
- package/dist/parts/workspace/workspace-bar.d.ts +1 -1
- package/dist/parts/workspace/workspace-bar.js +1 -1
- package/dist/parts/workspace/workspace-boot-status.d.ts +1 -1
- package/dist/parts/workspace/workspace-boot-status.js +1 -206
- package/dist/parts/workspace/workspace-editor-head.d.ts +1 -1
- package/dist/parts/workspace/workspace-editor-head.js +1 -1
- package/dist/parts/workspace/workspace-editor.d.ts +2 -2
- package/dist/parts/workspace/workspace-examples.js +1 -1
- package/dist/parts/workspace/workspace-file-tree.d.ts +1 -1
- package/dist/parts/workspace/workspace-file-tree.js +3 -2
- package/dist/parts/workspace/workspace-guide.d.ts +1 -1
- package/dist/parts/workspace/workspace-guide.js +1 -1
- package/dist/parts/workspace/workspace-preview.d.ts +1 -1
- package/dist/parts/workspace/workspace-preview.js +14 -12
- package/dist/parts/workspace/workspace-shell.d.ts +1 -1
- package/dist/parts/workspace/workspace-shell.js +11 -11
- package/dist/parts/workspace/workspace-sidebar.d.ts +2 -2
- package/dist/parts/workspace/workspace-sidebar.js +2 -2
- package/dist/parts/workspace/workspace-start.d.ts +1 -1
- package/dist/parts/workspace/workspace-start.js +1 -1
- package/dist/parts/workspace/workspace-steps.js +1 -1
- package/dist/parts/workspace/workspace.d.ts +3 -3
- package/dist/parts/workspace/workspace.js +5 -5
- package/dist/press-BuEC-XvZ.d.ts +83 -0
- package/dist/progress-8P8RLYMy.js +47 -0
- package/dist/progress-Ch0fA-bf.d.ts +8 -0
- package/dist/prompt-input-CRXEJBAK.js +412 -0
- package/dist/prompt-input-j4OFTF5p.d.ts +116 -0
- package/dist/relative-time-BnJfjeEm.js +131 -0
- package/dist/relative-time-BuP-Gvzn.d.ts +43 -0
- package/dist/{relative-time-DJnw45tr.js → relative-time-Dz2DR4eb.js} +64 -114
- package/dist/relative-time-grHFu1kY.d.ts +11 -0
- package/dist/{ring-GaJsg32c.js → ring-B0nZBnU0.js} +1 -2
- package/dist/runtime/nuxt-plugin.js +2 -5
- package/dist/{shiki-CbfEu_Az.js → shiki-CxzM_xNo.js} +3 -2
- package/dist/stand-ins-CuKM1UH1.js +339 -0
- package/dist/status-B2Yhrwv8.js +67 -0
- package/dist/status-ySiRa-8O.d.ts +38 -0
- package/dist/{stream-tokenizer-ByC3l0HQ.js → stream-tokenizer-BsjV6wxW.js} +1 -1
- package/dist/styles.css +4348 -3410
- package/dist/sync-status-B29eG_n-.js +59 -0
- package/dist/sync-status-D4KdGO6y.d.ts +35 -0
- package/dist/theme.css +3 -0
- package/dist/theme.d.ts +14 -0
- package/dist/theme.js +19 -8
- package/dist/{themes-DKugPHlg.js → themes-B0_ioVT0.js} +1 -1
- package/dist/tool-list-DDaCqpR6.js +209 -0
- package/dist/tool-list-DMRPM0Yi.d.ts +50 -0
- package/dist/trace-KCBvOsw_.d.ts +113 -0
- package/dist/trace-run-Dk962P5a.d.ts +49 -0
- package/dist/trace-run-nh6FIsl6.js +202 -0
- package/dist/{opt-out-D66l60sg.js → tween-1W-LlKk9.js} +65 -2
- package/dist/types-CMU8Vmew.d.ts +71 -0
- package/dist/types-CTk3aNb5.d.ts +15 -0
- package/dist/types-D0a3i4Fw.d.ts +21 -0
- package/dist/types-DTecvcsZ.d.ts +35 -0
- package/dist/types-D_BWab7g.d.ts +75 -0
- package/dist/types-RHaQ4gj1.d.ts +27 -0
- package/dist/ui-components-CKQAPI-W.js +7 -0
- package/dist/unwrapDefault-CExq-4rm.js +5 -0
- package/dist/utils-hi9-xROt.js +37 -0
- package/dist/vite.d.ts +0 -1
- package/dist/vite.js +8 -14
- package/dist/{vue-vUGpdMct.js → vue-BdA18K5-.js} +1 -1
- package/dist/workspace-boot-status-CyGlJS06.js +216 -0
- package/dist/{workspace-shell-ChCwWPyv.d.ts → workspace-shell-B4A7CINd.d.ts} +1 -1
- package/dist/workspace.d.ts +1 -1
- package/dist/workspace.js +1 -2
- package/package.json +46 -15
- package/dist/announce-B0DLwflT.js +0 -31
- package/dist/attachments-DgwoQZKY.js +0 -88
- package/dist/avatar-stack-C0IKwj6g.d.ts +0 -57
- package/dist/choices-input-BUf-QqGj.d.ts +0 -92
- package/dist/code-view-Cg4nyTNA.js +0 -172
- package/dist/comment-attachments-DAzUbRmJ.js +0 -23
- package/dist/comment-list-ncwaCSVX.d.ts +0 -60
- package/dist/comment-person-D_IyIjXo.js +0 -39
- package/dist/comment-pin-hBJFiSYW.d.ts +0 -66
- package/dist/comment-row-DPMWI5Z0.js +0 -38
- package/dist/comment-selection-bar-CVuS-FNL.d.ts +0 -40
- package/dist/comment-send-CUkL3TbZ.js +0 -275
- package/dist/comment-send-MmxFsOQf.d.ts +0 -23
- package/dist/comment-send.css +0 -267
- package/dist/comment-status-nsCdrRk_.js +0 -20
- package/dist/drop-field-CNZgwFVO.js +0 -162
- package/dist/editor-Dmk3k6f6.js +0 -620
- package/dist/format-CPipR1FP.js +0 -19
- package/dist/handlers-CnbkvXjX.js +0 -181
- package/dist/icon-XZaCUZTG.d.ts +0 -29
- package/dist/image-preview-BKVUtfwQ.js +0 -104
- package/dist/index-B_PSX-5h.d.ts +0 -69
- package/dist/list-DUTAo0uC.js +0 -270
- package/dist/markdown-editor-B7gD60tp.d.ts +0 -189
- package/dist/message-scroller-BZqS63IX.d.ts +0 -173
- package/dist/nuxt-ui-7ByUrymx.js +0 -43
- package/dist/parts/components/comment-list.d.ts +0 -2
- package/dist/parts/components/comment-list.js +0 -173
- package/dist/parts/components/comment-pin.d.ts +0 -2
- package/dist/parts/components/comment-pin.js +0 -74
- package/dist/parts/components/comment-send.d.ts +0 -2
- package/dist/parts/components/comment-send.js +0 -1
- package/dist/parts/components/markdown-editor.d.ts +0 -2
- package/dist/parts/components/markdown-editor.js +0 -1
- package/dist/parts/components/markdown-renderer.js +0 -1
- package/dist/payload-text-DQNRbJY5.js +0 -31
- package/dist/progress-DL9k-ERG.js +0 -265
- package/dist/registry-DAIjCjWd.js +0 -77
- package/dist/slot-part-BWHvQ3mK.js +0 -25
- package/dist/text-gacox6bp.js +0 -822
- package/dist/travel-BliEidau.js +0 -180
- package/dist/tween-Dv3IIIQG.js +0 -61
- package/dist/types-Ceh7h7NT.d.ts +0 -31
- package/dist/visual-copy-CHHBfJ6O.js +0 -14
|
@@ -0,0 +1,1206 @@
|
|
|
1
|
+
import { a as useCommentsContext, i as useComments, n as draftPositionKey, o as commentThreadKey, r as provideComments } from "./comments-BaSrroRV.js";
|
|
2
|
+
import { t as uiErrorDiagnostics } from "./error-diagnostics-BlgA9rI2.js";
|
|
3
|
+
import { n as rowSlotScope, r as useCommentAttachments, t as CommentRow_default } from "./CommentRow-XY3FNp30.js";
|
|
4
|
+
import { a as hasDirtyComposer, i as consumedPointerEvents, l as swallowNextClick, o as pathOf, r as commentThreadPortals, s as shakeDirtyComposers, u as useDocumentPointerDown } from "./comments-context-3js2YFl2.js";
|
|
5
|
+
import { t as AvatarStack_default } from "./avatar-stack-CoLlsmwJ.js";
|
|
6
|
+
import { n as useViteHubUIIcons } from "./config-BDQYUjjp.js";
|
|
7
|
+
import { b as morphText, r as createMotionList } from "./motion-core-JZZiPKEk.js";
|
|
8
|
+
import { a as excerpt, i as displayName, l as writerPerson, s as toPerson, t as CommentComposer } from "./comment-composer-D_mcH3Ts.js";
|
|
9
|
+
import { t as useUIComponent } from "./nuxt-ui-D3Qda35W.js";
|
|
10
|
+
import { i as deliveryAttributes, n as CommentThread, r as commentTitle } from "./comment-thread-BzOZVqF2.js";
|
|
11
|
+
import { t as MotionList_default } from "./motion-list-9vD1hSS0.js";
|
|
12
|
+
import { t as RollNumber_default } from "./RollNumber-CnF52zJM.js";
|
|
13
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, h, mergeProps, nextTick, onBeforeUnmount, onMounted, onUpdated, openBlock, provide, reactive, ref, renderList, renderSlot, resolveDynamicComponent, shallowRef, toDisplayString, unref, watch, withCtx } from "vue";
|
|
14
|
+
import { List, MessageCircle, SquarePen } from "@lucide/vue";
|
|
15
|
+
// src/internal/comment-page-island.ts
|
|
16
|
+
/** True when the island shows the thread: a whole-page thread of the state's subject. */
|
|
17
|
+
function isPageIslandThread(state, thread) {
|
|
18
|
+
const subject = state.subject.value;
|
|
19
|
+
return thread.anchor.kind === "page" && thread.subject.kind === subject.kind && thread.subject.id === subject.id;
|
|
20
|
+
}
|
|
21
|
+
const avatarCount = 3;
|
|
22
|
+
const hintText = "Comment on the whole page";
|
|
23
|
+
/**
|
|
24
|
+
* The island at the top center of the screen for comments on the whole page. It shows the count of open whole-page
|
|
25
|
+
* threads, and in comment mode a call to comment on the whole page. A click opens it as a card with those threads and a
|
|
26
|
+
* box for a new one. `CommentLayer` renders it.
|
|
27
|
+
*
|
|
28
|
+
* Motion, from the shared layer (docs/design/motion.md): the card comes down from the top edge with the appear effect
|
|
29
|
+
* when it shows after the threads loaded, and a copy of it goes back up when it hides. When the island stays and its
|
|
30
|
+
* label changes, the label morphs and the card's width follows the letters. The card opens at once, because the person
|
|
31
|
+
* reads it, and the trigger squashes when pressed.
|
|
32
|
+
*/
|
|
33
|
+
const CommentPageIsland = defineComponent({
|
|
34
|
+
name: "CommentPageIsland",
|
|
35
|
+
props: {
|
|
36
|
+
comments: {
|
|
37
|
+
required: true,
|
|
38
|
+
type: Object
|
|
39
|
+
},
|
|
40
|
+
canComment: {
|
|
41
|
+
required: true,
|
|
42
|
+
type: Boolean
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
slots: Object,
|
|
46
|
+
setup(props, { slots }) {
|
|
47
|
+
const UIcon = useUIComponent("UIcon");
|
|
48
|
+
const icons = useViteHubUIIcons();
|
|
49
|
+
const state = props.comments;
|
|
50
|
+
const root = ref();
|
|
51
|
+
const trigger = ref();
|
|
52
|
+
const portals = /* @__PURE__ */ new Set();
|
|
53
|
+
provide(commentThreadPortals, portals);
|
|
54
|
+
const threads = computed(() => state.pageThreads.value.filter((thread) => thread.anchor.kind === "page"));
|
|
55
|
+
const openThreads = computed(() => threads.value.filter((thread) => thread.status === "open"));
|
|
56
|
+
const draft = computed(() => state.draft.value?.anchor.kind === "page" ? state.draft.value : null);
|
|
57
|
+
const opened = computed(() => state.opened.value && isPageIslandThread(state, state.opened.value) ? state.opened.value : null);
|
|
58
|
+
const mayComment = computed(() => props.canComment && Boolean(state.user.value));
|
|
59
|
+
const expanded = ref(false);
|
|
60
|
+
const hidden = computed(() => state.visibility.value === "hidden");
|
|
61
|
+
const listed = computed(() => hidden.value ? threads.value.filter((thread) => state.isShown(thread.id)) : threads.value);
|
|
62
|
+
const uiRoot = () => {
|
|
63
|
+
const node = root.value?.getRootNode();
|
|
64
|
+
return node instanceof ShadowRoot ? node : document;
|
|
65
|
+
};
|
|
66
|
+
const status = computed(() => {
|
|
67
|
+
if (draft.value || opened.value) return "open";
|
|
68
|
+
if (expanded.value && (listed.value.length > 0 || mayComment.value)) return "open";
|
|
69
|
+
if (state.active.value && mayComment.value) return "hint";
|
|
70
|
+
if (hidden.value) return "none";
|
|
71
|
+
return openThreads.value.length > 0 ? "count" : "none";
|
|
72
|
+
});
|
|
73
|
+
const label = ref();
|
|
74
|
+
const count = computed(() => hidden.value ? 0 : openThreads.value.length);
|
|
75
|
+
const labelled = computed(() => status.value === "hint" || status.value === "open" && mayComment.value);
|
|
76
|
+
const labelText = computed(() => labelled.value ? hintText : String(count.value));
|
|
77
|
+
watch([label, labelText], ([element, text], previous) => {
|
|
78
|
+
if (!element) return;
|
|
79
|
+
if (element === previous?.[0]) morphText(element, text);
|
|
80
|
+
else element.textContent = text;
|
|
81
|
+
}, {
|
|
82
|
+
flush: "post",
|
|
83
|
+
immediate: true
|
|
84
|
+
});
|
|
85
|
+
let loaded = false;
|
|
86
|
+
let appears;
|
|
87
|
+
watch(hidden, (value) => {
|
|
88
|
+
if (value) expanded.value = false;
|
|
89
|
+
});
|
|
90
|
+
watch(opened, (thread, previous) => {
|
|
91
|
+
if (thread) {
|
|
92
|
+
expanded.value = true;
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (!previous || status.value !== "open") return;
|
|
96
|
+
const focused = uiRoot().activeElement;
|
|
97
|
+
if (focused && root.value?.contains(focused)) return;
|
|
98
|
+
nextTick(() => root.value?.querySelector(`[data-slot='comment-page-island-item'][data-thread-id='${previous.id}']`)?.focus());
|
|
99
|
+
}, { flush: "post" });
|
|
100
|
+
const dirty = () => (root.value ? hasDirtyComposer(root.value) : false) || (draft.value?.body.trim().length ?? 0) > 0;
|
|
101
|
+
const inPortal = (path) => [...portals].some((portal) => portal.value && path.includes(portal.value));
|
|
102
|
+
const collapse = () => {
|
|
103
|
+
const focused = uiRoot().activeElement;
|
|
104
|
+
const inside = Boolean(focused && root.value?.contains(focused));
|
|
105
|
+
expanded.value = false;
|
|
106
|
+
if (draft.value) state.cancelDraft();
|
|
107
|
+
if (opened.value) state.close();
|
|
108
|
+
if (inside) nextTick(() => trigger.value?.focus({ preventScroll: true }));
|
|
109
|
+
};
|
|
110
|
+
const tryCollapse = (escape = false) => {
|
|
111
|
+
if (dirty()) {
|
|
112
|
+
if (root.value) shakeDirtyComposers(root.value, escape);
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
collapse();
|
|
116
|
+
return true;
|
|
117
|
+
};
|
|
118
|
+
useDocumentPointerDown((event) => {
|
|
119
|
+
if (status.value !== "open" || !root.value) return;
|
|
120
|
+
const path = pathOf(event);
|
|
121
|
+
if (path.includes(root.value) || inPortal(path) || consumedPointerEvents.has(event)) return;
|
|
122
|
+
if (!path.some((element) => element.matches("[data-slot='comment-pin']"))) consumedPointerEvents.add(event);
|
|
123
|
+
if (tryCollapse()) return;
|
|
124
|
+
event.stopPropagation();
|
|
125
|
+
swallowNextClick();
|
|
126
|
+
});
|
|
127
|
+
const onKeydown = (event) => {
|
|
128
|
+
if (event.key !== "Escape" || event.defaultPrevented || event.isComposing || event.repeat || status.value !== "open") return;
|
|
129
|
+
const path = pathOf(event);
|
|
130
|
+
if (inPortal(path) || path.some((element) => element.matches("[data-slot='comment-composer']"))) return;
|
|
131
|
+
event.preventDefault();
|
|
132
|
+
tryCollapse(true);
|
|
133
|
+
};
|
|
134
|
+
onMounted(() => document.addEventListener("keydown", onKeydown, true));
|
|
135
|
+
onBeforeUnmount(() => {
|
|
136
|
+
document.removeEventListener("keydown", onKeydown, true);
|
|
137
|
+
});
|
|
138
|
+
const press = () => {
|
|
139
|
+
if (status.value === "open") {
|
|
140
|
+
tryCollapse();
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (status.value === "hint") {
|
|
144
|
+
try {
|
|
145
|
+
state.startDraft("page");
|
|
146
|
+
} catch {}
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
expanded.value = true;
|
|
150
|
+
};
|
|
151
|
+
const people = () => {
|
|
152
|
+
const seen = /* @__PURE__ */ new Map();
|
|
153
|
+
for (const thread of openThreads.value) {
|
|
154
|
+
const person = writerPerson(thread);
|
|
155
|
+
if (!seen.has(person.id)) seen.set(person.id, person);
|
|
156
|
+
}
|
|
157
|
+
return [...seen.values()].slice(0, avatarCount);
|
|
158
|
+
};
|
|
159
|
+
const rows = () => h("ul", { "data-slot": "comment-page-island-items" }, listed.value.map((thread) => h("li", { key: thread.id }, h("button", {
|
|
160
|
+
"data-focus-inset": "",
|
|
161
|
+
"data-slot": "comment-page-island-item",
|
|
162
|
+
"data-status": thread.status,
|
|
163
|
+
"data-thread-id": thread.id,
|
|
164
|
+
onClick: () => {
|
|
165
|
+
expanded.value = true;
|
|
166
|
+
state.open(thread);
|
|
167
|
+
},
|
|
168
|
+
type: "button"
|
|
169
|
+
}, [h(CommentRow_default, { thread })]))));
|
|
170
|
+
const content = () => {
|
|
171
|
+
const showing = opened.value;
|
|
172
|
+
if (showing && slots.thread) return slots.thread({ thread: showing });
|
|
173
|
+
return [listed.value.length > 0 ? rows() : null, mayComment.value && slots.composer ? h("div", {
|
|
174
|
+
"data-draft": "true",
|
|
175
|
+
"data-slot": "comment-page-island-composer",
|
|
176
|
+
key: "composer"
|
|
177
|
+
}, slots.composer({
|
|
178
|
+
autofocus: Boolean(draft.value),
|
|
179
|
+
draft: draft.value,
|
|
180
|
+
onCancel: collapse
|
|
181
|
+
})) : null];
|
|
182
|
+
};
|
|
183
|
+
return () => {
|
|
184
|
+
const current = status.value;
|
|
185
|
+
const isOpen = current === "open";
|
|
186
|
+
const total = count.value;
|
|
187
|
+
const name = labelled.value ? hintText : `${total} ${total === 1 ? "comment" : "comments"} on the whole page`;
|
|
188
|
+
if (current === "none") appears = void 0;
|
|
189
|
+
else appears ??= loaded && !isOpen;
|
|
190
|
+
loaded = state.status.value === "ready" || state.status.value === "error";
|
|
191
|
+
return h("div", {
|
|
192
|
+
"data-slot": "comment-page-island",
|
|
193
|
+
"data-state": current,
|
|
194
|
+
ref: root
|
|
195
|
+
}, current === "none" ? [] : [h("div", {
|
|
196
|
+
"data-motion-appear": appears ? "" : void 0,
|
|
197
|
+
"data-open": isOpen ? "" : void 0,
|
|
198
|
+
"data-side": "bottom",
|
|
199
|
+
"data-slot": "comment-page-island-card"
|
|
200
|
+
}, [h("button", {
|
|
201
|
+
"aria-expanded": String(isOpen),
|
|
202
|
+
"aria-label": labelled.value && total > 0 ? `${name}, ${total} open` : name,
|
|
203
|
+
"data-motion-press": "",
|
|
204
|
+
"data-slot": "comment-page-island-trigger",
|
|
205
|
+
onClick: press,
|
|
206
|
+
ref: trigger,
|
|
207
|
+
type: "button"
|
|
208
|
+
}, [total > 0 ? h("span", { "data-slot": "comment-page-island-faces" }, h(AvatarStack_default, {
|
|
209
|
+
"aria-hidden": "true",
|
|
210
|
+
max: null,
|
|
211
|
+
people: people(),
|
|
212
|
+
size: "sm"
|
|
213
|
+
})) : h(UIcon, {
|
|
214
|
+
"aria-hidden": "true",
|
|
215
|
+
name: icons.value.commentPage
|
|
216
|
+
}), h("span", {
|
|
217
|
+
"data-slot": "comment-page-island-label",
|
|
218
|
+
ref: label
|
|
219
|
+
})]), isOpen ? h("div", { "data-slot": "comment-page-island-content" }, content()) : null])]);
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
// registry/comments/CommentFilters.vue?vue&type=script&setup=true&lang.ts
|
|
224
|
+
const _hoisted_1$3 = {
|
|
225
|
+
"data-slot": "comment-filters",
|
|
226
|
+
role: "group",
|
|
227
|
+
"aria-label": "Filter comments"
|
|
228
|
+
};
|
|
229
|
+
const _hoisted_2$3 = [
|
|
230
|
+
"data-variant",
|
|
231
|
+
"data-active",
|
|
232
|
+
"aria-pressed",
|
|
233
|
+
"onClick"
|
|
234
|
+
];
|
|
235
|
+
const _hoisted_3$2 = { key: 0 };
|
|
236
|
+
// registry/comments/CommentFilters.vue
|
|
237
|
+
var CommentFilters_default = /* @__PURE__ */ defineComponent({
|
|
238
|
+
name: "CommentFilters",
|
|
239
|
+
__name: "CommentFilters",
|
|
240
|
+
props: { comments: {} },
|
|
241
|
+
setup(__props) {
|
|
242
|
+
const comments = useCommentsContext(__props.comments);
|
|
243
|
+
const filters = computed(() => [
|
|
244
|
+
{
|
|
245
|
+
key: "open",
|
|
246
|
+
label: "Open",
|
|
247
|
+
count: comments.counts.value.open
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
key: "resolved",
|
|
251
|
+
label: "Resolved",
|
|
252
|
+
count: comments.counts.value.resolved
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
key: "mine",
|
|
256
|
+
label: "Mine"
|
|
257
|
+
}
|
|
258
|
+
]);
|
|
259
|
+
return (_ctx, _cache) => {
|
|
260
|
+
return openBlock(), createElementBlock("div", _hoisted_1$3, [(openBlock(true), createElementBlock(Fragment, null, renderList(filters.value, (filter) => {
|
|
261
|
+
return openBlock(), createElementBlock("button", {
|
|
262
|
+
key: filter.key,
|
|
263
|
+
type: "button",
|
|
264
|
+
"data-slot": "comment-filter",
|
|
265
|
+
"data-comment-button": "",
|
|
266
|
+
"data-size": "xs",
|
|
267
|
+
"data-variant": unref(comments).filters[filter.key] ? "soft" : "ghost",
|
|
268
|
+
"data-active": unref(comments).filters[filter.key] ? "" : void 0,
|
|
269
|
+
"aria-pressed": unref(comments).filters[filter.key],
|
|
270
|
+
onClick: ($event) => unref(comments).filters[filter.key] = !unref(comments).filters[filter.key]
|
|
271
|
+
}, [filter.count === void 0 ? (openBlock(), createElementBlock("span", _hoisted_3$2, toDisplayString(filter.label), 1)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(toDisplayString(`${filter.label} `), 1), createVNode(unref(RollNumber_default), { value: filter.count }, null, 8, ["value"])], 64))], 8, _hoisted_2$3);
|
|
272
|
+
}), 128))]);
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
// registry/comments/CommentList.vue?vue&type=script&setup=true&lang.ts
|
|
277
|
+
const _hoisted_1$2 = {
|
|
278
|
+
"data-slot": "comment-list",
|
|
279
|
+
"data-comments-ui": "",
|
|
280
|
+
"aria-label": "Comments"
|
|
281
|
+
};
|
|
282
|
+
const _hoisted_2$2 = { "data-slot": "comment-list-header" };
|
|
283
|
+
const _hoisted_3$1 = {
|
|
284
|
+
"data-slot": "comment-list-scopes",
|
|
285
|
+
role: "group",
|
|
286
|
+
"aria-label": "Scope"
|
|
287
|
+
};
|
|
288
|
+
const _hoisted_4 = [
|
|
289
|
+
"data-variant",
|
|
290
|
+
"aria-pressed",
|
|
291
|
+
"onClick"
|
|
292
|
+
];
|
|
293
|
+
const _hoisted_5 = {
|
|
294
|
+
key: 0,
|
|
295
|
+
"data-slot": "comment-list-empty",
|
|
296
|
+
role: "status"
|
|
297
|
+
};
|
|
298
|
+
const _hoisted_6 = [
|
|
299
|
+
"data-status",
|
|
300
|
+
"data-detached",
|
|
301
|
+
"aria-current",
|
|
302
|
+
"href",
|
|
303
|
+
"onClick"
|
|
304
|
+
];
|
|
305
|
+
// registry/comments/CommentList.vue
|
|
306
|
+
var CommentList_default = /* @__PURE__ */ defineComponent({
|
|
307
|
+
name: "CommentList",
|
|
308
|
+
__name: "CommentList",
|
|
309
|
+
props: {
|
|
310
|
+
comments: {},
|
|
311
|
+
navigate: { type: Function }
|
|
312
|
+
},
|
|
313
|
+
emits: ["select"],
|
|
314
|
+
setup(__props, { emit: __emit }) {
|
|
315
|
+
const props = __props;
|
|
316
|
+
const emit = __emit;
|
|
317
|
+
const comments = useCommentsContext(props.comments);
|
|
318
|
+
const scopes = [{
|
|
319
|
+
value: "page",
|
|
320
|
+
label: "This page"
|
|
321
|
+
}, {
|
|
322
|
+
value: "site",
|
|
323
|
+
label: "All pages"
|
|
324
|
+
}];
|
|
325
|
+
const rows = computed(() => comments.listed.value);
|
|
326
|
+
const empty = computed(() => {
|
|
327
|
+
if (comments.status.value === "loading" && comments.threads.value.length === 0) return "Loading comments.";
|
|
328
|
+
if (comments.status.value === "error") return "The comments could not load.";
|
|
329
|
+
return "No comments here.";
|
|
330
|
+
});
|
|
331
|
+
function select(thread, event) {
|
|
332
|
+
emit("select", { thread });
|
|
333
|
+
if (event.ctrlKey || event.metaKey || event.shiftKey || event.button !== 0) return;
|
|
334
|
+
event.preventDefault();
|
|
335
|
+
if (thread.subject.kind === comments.subject.value.kind && thread.subject.id === comments.subject.value.id) comments.open(thread, { scroll: true });
|
|
336
|
+
else if (comments.close()) (props.navigate ?? ((href) => window.location.assign(href)))(comments.link(thread));
|
|
337
|
+
}
|
|
338
|
+
return (_ctx, _cache) => {
|
|
339
|
+
return openBlock(), createElementBlock("section", _hoisted_1$2, [createElementVNode("header", _hoisted_2$2, [createElementVNode("div", _hoisted_3$1, [(openBlock(), createElementBlock(Fragment, null, renderList(scopes, (scope) => {
|
|
340
|
+
return createElementVNode("button", {
|
|
341
|
+
key: scope.value,
|
|
342
|
+
type: "button",
|
|
343
|
+
"data-slot": "comment-list-scope",
|
|
344
|
+
"data-comment-button": "",
|
|
345
|
+
"data-size": "xs",
|
|
346
|
+
"data-variant": unref(comments).scope.value === scope.value ? "soft" : "ghost",
|
|
347
|
+
"aria-pressed": unref(comments).scope.value === scope.value,
|
|
348
|
+
onClick: ($event) => unref(comments).scope.value = scope.value
|
|
349
|
+
}, [createElementVNode("span", null, toDisplayString(scope.label), 1)], 8, _hoisted_4);
|
|
350
|
+
}), 64))]), createVNode(CommentFilters_default, { comments: unref(comments) }, null, 8, ["comments"])]), rows.value.length === 0 ? (openBlock(), createElementBlock("p", _hoisted_5, toDisplayString(empty.value), 1)) : (openBlock(), createBlock(unref(MotionList_default), { key: 1 }, {
|
|
351
|
+
render: withCtx(({ props: list, children }) => [createElementVNode("ol", mergeProps(list, { "data-slot": "comment-list-items" }), [(openBlock(), createBlock(resolveDynamicComponent(children)))], 16)]),
|
|
352
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(rows.value, (thread) => {
|
|
353
|
+
return openBlock(), createElementBlock("li", { key: thread.id }, [createElementVNode("a", mergeProps({
|
|
354
|
+
"data-slot": "comment-list-item",
|
|
355
|
+
"data-focus-inset": "",
|
|
356
|
+
"data-status": thread.status,
|
|
357
|
+
"data-detached": unref(comments).positions.value.get(thread.id)?.detached === true ? "true" : void 0
|
|
358
|
+
}, { ref_for: true }, unref(deliveryAttributes)(thread.delivery), {
|
|
359
|
+
"aria-current": unref(comments).openId.value === thread.id ? "true" : void 0,
|
|
360
|
+
href: unref(comments).link(thread),
|
|
361
|
+
onClick: ($event) => select(thread, $event)
|
|
362
|
+
}), [renderSlot(_ctx.$slots, "row", mergeProps({ ref_for: true }, unref(rowSlotScope)(thread)), () => [createVNode(CommentRow_default, {
|
|
363
|
+
thread,
|
|
364
|
+
detached: unref(comments).positions.value.get(thread.id)?.detached === true,
|
|
365
|
+
site: unref(comments).scope.value === "site"
|
|
366
|
+
}, createSlots({ _: 2 }, [_ctx.$slots.preview ? {
|
|
367
|
+
name: "preview",
|
|
368
|
+
fn: withCtx(() => [renderSlot(_ctx.$slots, "preview", mergeProps({ ref_for: true }, unref(rowSlotScope)(thread)))]),
|
|
369
|
+
key: "0"
|
|
370
|
+
} : void 0]), 1032, [
|
|
371
|
+
"thread",
|
|
372
|
+
"detached",
|
|
373
|
+
"site"
|
|
374
|
+
])])], 16, _hoisted_6)]);
|
|
375
|
+
}), 128))]),
|
|
376
|
+
_: 3
|
|
377
|
+
}))]);
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
});
|
|
381
|
+
// registry/comments/CommentPin.vue?vue&type=script&setup=true&lang.ts
|
|
382
|
+
const _hoisted_1$1 = [
|
|
383
|
+
"data-status",
|
|
384
|
+
"data-active",
|
|
385
|
+
"data-draft",
|
|
386
|
+
"aria-expanded",
|
|
387
|
+
"aria-label"
|
|
388
|
+
];
|
|
389
|
+
const _hoisted_2$1 = {
|
|
390
|
+
key: 1,
|
|
391
|
+
"data-slot": "comment-pin-number"
|
|
392
|
+
};
|
|
393
|
+
// registry/comments/CommentPin.vue
|
|
394
|
+
var CommentPin_default = /* @__PURE__ */ defineComponent({
|
|
395
|
+
name: "CommentPin",
|
|
396
|
+
__name: "CommentPin",
|
|
397
|
+
props: {
|
|
398
|
+
number: {},
|
|
399
|
+
author: {},
|
|
400
|
+
status: { default: "open" },
|
|
401
|
+
excerpt: {},
|
|
402
|
+
active: {
|
|
403
|
+
type: Boolean,
|
|
404
|
+
default: false
|
|
405
|
+
},
|
|
406
|
+
draft: {
|
|
407
|
+
type: Boolean,
|
|
408
|
+
default: false
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
emits: [
|
|
412
|
+
"select",
|
|
413
|
+
"hover",
|
|
414
|
+
"leave"
|
|
415
|
+
],
|
|
416
|
+
setup(__props, { emit: __emit }) {
|
|
417
|
+
const emit = __emit;
|
|
418
|
+
const label = computed(() => {
|
|
419
|
+
if (__props.draft) return "New comment";
|
|
420
|
+
const by = __props.author ? ` by ${displayName(__props.author)}` : "";
|
|
421
|
+
const text = __props.excerpt ? `: ${__props.excerpt}` : "";
|
|
422
|
+
return `Comment${__props.number === void 0 ? "" : ` ${__props.number}`}${by}${text}${__props.status === "resolved" ? ", resolved" : ""}`;
|
|
423
|
+
});
|
|
424
|
+
let pointed = false;
|
|
425
|
+
let focused = false;
|
|
426
|
+
function onFocus() {
|
|
427
|
+
focused = true;
|
|
428
|
+
emit("hover");
|
|
429
|
+
}
|
|
430
|
+
function onBlur() {
|
|
431
|
+
focused = false;
|
|
432
|
+
if (!pointed) emit("leave");
|
|
433
|
+
}
|
|
434
|
+
function onPointerenter() {
|
|
435
|
+
pointed = true;
|
|
436
|
+
emit("hover");
|
|
437
|
+
}
|
|
438
|
+
function onPointerleave() {
|
|
439
|
+
pointed = false;
|
|
440
|
+
if (!focused) emit("leave");
|
|
441
|
+
}
|
|
442
|
+
return (_ctx, _cache) => {
|
|
443
|
+
return openBlock(), createElementBlock("button", {
|
|
444
|
+
type: "button",
|
|
445
|
+
"data-slot": "comment-pin",
|
|
446
|
+
"data-status": __props.status,
|
|
447
|
+
"data-active": __props.active ? "true" : void 0,
|
|
448
|
+
"data-draft": __props.draft ? "true" : void 0,
|
|
449
|
+
"aria-expanded": __props.draft ? void 0 : __props.active,
|
|
450
|
+
"aria-label": label.value,
|
|
451
|
+
onClick: _cache[0] || (_cache[0] = ($event) => emit("select")),
|
|
452
|
+
onFocus,
|
|
453
|
+
onBlur,
|
|
454
|
+
onPointerenter,
|
|
455
|
+
onPointerleave
|
|
456
|
+
}, [__props.author ? (openBlock(), createBlock(unref(AvatarStack_default), {
|
|
457
|
+
key: 0,
|
|
458
|
+
"aria-hidden": "true",
|
|
459
|
+
people: [unref(toPerson)(__props.author)],
|
|
460
|
+
size: "sm"
|
|
461
|
+
}, null, 8, ["people"])) : createCommentVNode("v-if", true), !__props.draft && __props.number !== void 0 ? (openBlock(), createElementBlock("span", _hoisted_2$1, toDisplayString(__props.number), 1)) : createCommentVNode("v-if", true)], 40, _hoisted_1$1);
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
});
|
|
465
|
+
// registry/comments/CommentToolbar.vue?vue&type=script&setup=true&lang.ts
|
|
466
|
+
const _hoisted_1 = {
|
|
467
|
+
"data-slot": "comment-toolbar",
|
|
468
|
+
"data-comments-ui": "",
|
|
469
|
+
role: "toolbar",
|
|
470
|
+
"aria-label": "Comments"
|
|
471
|
+
};
|
|
472
|
+
const _hoisted_2 = ["data-variant", "aria-pressed"];
|
|
473
|
+
const _hoisted_3 = [
|
|
474
|
+
"data-variant",
|
|
475
|
+
"aria-label",
|
|
476
|
+
"aria-pressed"
|
|
477
|
+
];
|
|
478
|
+
// registry/comments/CommentToolbar.vue
|
|
479
|
+
var CommentToolbar_default = /* @__PURE__ */ defineComponent({
|
|
480
|
+
name: "CommentToolbar",
|
|
481
|
+
__name: "CommentToolbar",
|
|
482
|
+
props: {
|
|
483
|
+
comments: {},
|
|
484
|
+
people: { default: () => [] }
|
|
485
|
+
},
|
|
486
|
+
setup(__props) {
|
|
487
|
+
const props = __props;
|
|
488
|
+
const comments = useCommentsContext(props.comments);
|
|
489
|
+
const open = computed(() => comments.pageThreads.value.length);
|
|
490
|
+
return (_ctx, _cache) => {
|
|
491
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
492
|
+
createElementVNode("button", {
|
|
493
|
+
type: "button",
|
|
494
|
+
"data-slot": "comment-toolbar-mode",
|
|
495
|
+
"data-comment-button": "",
|
|
496
|
+
"data-size": "sm",
|
|
497
|
+
"data-square": "",
|
|
498
|
+
"data-variant": unref(comments).active.value ? "solid" : "ghost",
|
|
499
|
+
"aria-keyshortcuts": "C",
|
|
500
|
+
"aria-label": "Comment mode",
|
|
501
|
+
"aria-pressed": unref(comments).active.value,
|
|
502
|
+
title: "Comment (C)",
|
|
503
|
+
onClick: _cache[0] || (_cache[0] = ($event) => unref(comments).toggle())
|
|
504
|
+
}, [renderSlot(_ctx.$slots, "mode-icon", {}, () => [createVNode(unref(MessageCircle), {
|
|
505
|
+
"data-slot": "comment-icon",
|
|
506
|
+
"aria-hidden": "true"
|
|
507
|
+
})])], 8, _hoisted_2),
|
|
508
|
+
createElementVNode("button", {
|
|
509
|
+
type: "button",
|
|
510
|
+
"data-slot": "comment-toolbar-list",
|
|
511
|
+
"data-comment-button": "",
|
|
512
|
+
"data-size": "sm",
|
|
513
|
+
"data-variant": unref(comments).listOpen.value ? "solid" : "ghost",
|
|
514
|
+
"aria-label": `Comment list, ${open.value} on this page`,
|
|
515
|
+
"aria-pressed": unref(comments).listOpen.value,
|
|
516
|
+
onClick: _cache[1] || (_cache[1] = ($event) => unref(comments).listOpen.value = !unref(comments).listOpen.value)
|
|
517
|
+
}, [renderSlot(_ctx.$slots, "list-icon", {}, () => [createVNode(unref(List), {
|
|
518
|
+
"data-slot": "comment-icon",
|
|
519
|
+
"aria-hidden": "true"
|
|
520
|
+
})]), createElementVNode("span", null, toDisplayString(open.value), 1)], 8, _hoisted_3),
|
|
521
|
+
createElementVNode("button", {
|
|
522
|
+
type: "button",
|
|
523
|
+
"data-slot": "comment-toolbar-page",
|
|
524
|
+
"data-comment-button": "",
|
|
525
|
+
"data-size": "sm",
|
|
526
|
+
"data-square": "",
|
|
527
|
+
"data-variant": "ghost",
|
|
528
|
+
"aria-label": "Comment on page",
|
|
529
|
+
title: "Comment on the whole page",
|
|
530
|
+
onClick: _cache[2] || (_cache[2] = ($event) => unref(comments).startDraft("page"))
|
|
531
|
+
}, [renderSlot(_ctx.$slots, "page-icon", {}, () => [createVNode(unref(SquarePen), {
|
|
532
|
+
"data-slot": "comment-icon",
|
|
533
|
+
"aria-hidden": "true"
|
|
534
|
+
})])]),
|
|
535
|
+
props.people.length > 0 ? (openBlock(), createBlock(unref(AvatarStack_default), {
|
|
536
|
+
key: 0,
|
|
537
|
+
people: props.people,
|
|
538
|
+
size: "sm",
|
|
539
|
+
variant: "outline"
|
|
540
|
+
}, null, 8, ["people"])) : createCommentVNode("v-if", true),
|
|
541
|
+
renderSlot(_ctx.$slots, "default")
|
|
542
|
+
]);
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
});
|
|
546
|
+
// src/components/comment-layer.ts
|
|
547
|
+
const popoverWidth = 360;
|
|
548
|
+
const popoverHeight = 420;
|
|
549
|
+
function placeDraft(point, width, viewport) {
|
|
550
|
+
const inset = (Number.parseFloat(window.getComputedStyle(document.documentElement).fontSize) || 16) / 2;
|
|
551
|
+
const x = point.x;
|
|
552
|
+
const flipX = x > viewport / 2 && x + inset + width > viewport - inset;
|
|
553
|
+
const left = Math.max(inset, Math.min(flipX ? x - inset - width : x + inset, viewport - inset - width));
|
|
554
|
+
return {
|
|
555
|
+
x,
|
|
556
|
+
y: point.y,
|
|
557
|
+
flipX,
|
|
558
|
+
left: left - x
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
const pinShape = (kind) => kind === "area" || kind === "image" ? "round" : "point";
|
|
562
|
+
const clickSlop = 6;
|
|
563
|
+
const pinSpacing = 32;
|
|
564
|
+
const minimumArea = 8;
|
|
565
|
+
const marginMinWidth = 900;
|
|
566
|
+
const marginGap = 8;
|
|
567
|
+
const marginCardHeight = 72;
|
|
568
|
+
function containerOf(box) {
|
|
569
|
+
const center = {
|
|
570
|
+
x: box.left + box.width / 2,
|
|
571
|
+
y: box.top + box.height / 2
|
|
572
|
+
};
|
|
573
|
+
const under = document.elementsFromPoint(center.x, center.y).find((element) => !element.closest("[data-comments-ui]") && !element.localName.startsWith("vitehub-") && element !== document.documentElement);
|
|
574
|
+
for (let element = under ?? null; element && element !== document.documentElement; element = element.parentElement) {
|
|
575
|
+
const rect = element.getBoundingClientRect();
|
|
576
|
+
if (rect.left <= box.left + 1 && rect.top <= box.top + 1 && rect.right >= box.left + box.width - 1 && rect.bottom >= box.top + box.height - 1) return element;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
const CommentLayer = defineComponent({
|
|
580
|
+
name: "CommentLayer",
|
|
581
|
+
props: {
|
|
582
|
+
client: { type: Object },
|
|
583
|
+
subject: { type: Object },
|
|
584
|
+
user: { type: Object },
|
|
585
|
+
comments: { type: Object },
|
|
586
|
+
people: {
|
|
587
|
+
default: () => [],
|
|
588
|
+
type: Array
|
|
589
|
+
},
|
|
590
|
+
hotkey: {
|
|
591
|
+
default: "c",
|
|
592
|
+
type: [String, Boolean]
|
|
593
|
+
},
|
|
594
|
+
readOnly: {
|
|
595
|
+
default: false,
|
|
596
|
+
type: Boolean
|
|
597
|
+
},
|
|
598
|
+
canComment: {
|
|
599
|
+
default: true,
|
|
600
|
+
type: Boolean
|
|
601
|
+
},
|
|
602
|
+
subjectUrl: { type: Function },
|
|
603
|
+
navigate: { type: Function },
|
|
604
|
+
can: { type: Function },
|
|
605
|
+
upload: { type: Function },
|
|
606
|
+
queueFiles: {
|
|
607
|
+
default: false,
|
|
608
|
+
type: Boolean
|
|
609
|
+
},
|
|
610
|
+
accept: { type: String },
|
|
611
|
+
attachmentUrl: { type: Function },
|
|
612
|
+
placement: {
|
|
613
|
+
default: "pin",
|
|
614
|
+
type: String
|
|
615
|
+
},
|
|
616
|
+
size: {
|
|
617
|
+
default: "sm",
|
|
618
|
+
type: String
|
|
619
|
+
}
|
|
620
|
+
},
|
|
621
|
+
setup(props, { slots }) {
|
|
622
|
+
const { client, subject } = props;
|
|
623
|
+
if (!props.comments && !subject) throw uiErrorDiagnostics.UI_R0002({ message: "CommentLayer needs a `subject`, or the `comments` state from useComments()." });
|
|
624
|
+
const layer = ref(null);
|
|
625
|
+
const uiRoot = () => {
|
|
626
|
+
const node = layer.value?.getRootNode();
|
|
627
|
+
return node instanceof ShadowRoot ? node : document;
|
|
628
|
+
};
|
|
629
|
+
const state = props.comments ?? useComments({
|
|
630
|
+
client,
|
|
631
|
+
hotkey: props.hotkey,
|
|
632
|
+
subject: () => props.subject,
|
|
633
|
+
subjectUrl: props.subjectUrl,
|
|
634
|
+
uiRoot,
|
|
635
|
+
user: () => props.user
|
|
636
|
+
});
|
|
637
|
+
provideComments(state);
|
|
638
|
+
const draftFiles = ref([]);
|
|
639
|
+
const uploadingDraft = shallowRef(null);
|
|
640
|
+
watch(() => state.draft.value, (next, previous) => {
|
|
641
|
+
if (next !== previous) draftFiles.value = next?.files ? [...next.files] : [];
|
|
642
|
+
});
|
|
643
|
+
const { enabled: attachmentsOn, prepare, queued } = useCommentAttachments(state, props);
|
|
644
|
+
const user = computed(() => state.user.value);
|
|
645
|
+
const pinned = computed(() => state.threads.value.filter((thread) => state.pageThreads.value.includes(thread) || state.shown.value.has(thread.id) || state.leaving.value.has(thread.id)));
|
|
646
|
+
const drawn = computed(() => pinned.value.filter((thread) => state.shown.value.has(thread.id) || state.leaving.value.has(thread.id)));
|
|
647
|
+
let down = null;
|
|
648
|
+
const drawing = ref(null);
|
|
649
|
+
const boxFrom = (start, event) => ({
|
|
650
|
+
left: Math.min(start.x, event.clientX),
|
|
651
|
+
top: Math.min(start.y, event.clientY),
|
|
652
|
+
width: Math.abs(event.clientX - start.x),
|
|
653
|
+
height: Math.abs(event.clientY - start.y)
|
|
654
|
+
});
|
|
655
|
+
const press = (event) => {
|
|
656
|
+
drawing.value = null;
|
|
657
|
+
down = consumedPointerEvents.has(event) || event.button !== 0 ? null : {
|
|
658
|
+
x: event.clientX,
|
|
659
|
+
y: event.clientY,
|
|
660
|
+
draw: event.pointerType !== "touch"
|
|
661
|
+
};
|
|
662
|
+
if (down?.draw && event.target instanceof Element) event.target.setPointerCapture?.(event.pointerId);
|
|
663
|
+
};
|
|
664
|
+
const move = (event) => {
|
|
665
|
+
if (!down?.draw) return;
|
|
666
|
+
if (!drawing.value && Math.hypot(event.clientX - down.x, event.clientY - down.y) <= clickSlop) return;
|
|
667
|
+
drawing.value = boxFrom(down, event);
|
|
668
|
+
};
|
|
669
|
+
const release = (event) => {
|
|
670
|
+
const start = down;
|
|
671
|
+
const drawn = drawing.value;
|
|
672
|
+
down = null;
|
|
673
|
+
drawing.value = null;
|
|
674
|
+
if (!start) return;
|
|
675
|
+
if (drawn) {
|
|
676
|
+
const box = boxFrom(start, event);
|
|
677
|
+
const element = box.width >= minimumArea && box.height >= minimumArea ? containerOf(box) : void 0;
|
|
678
|
+
if (!element) return;
|
|
679
|
+
event.preventDefault();
|
|
680
|
+
try {
|
|
681
|
+
state.startDraft(element, {
|
|
682
|
+
area: box,
|
|
683
|
+
point: {
|
|
684
|
+
x: box.left,
|
|
685
|
+
y: box.top
|
|
686
|
+
}
|
|
687
|
+
});
|
|
688
|
+
} catch {}
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
if (Math.hypot(event.clientX - start.x, event.clientY - start.y) > clickSlop) return;
|
|
692
|
+
event.preventDefault();
|
|
693
|
+
try {
|
|
694
|
+
state.startDraft({
|
|
695
|
+
x: event.clientX,
|
|
696
|
+
y: event.clientY
|
|
697
|
+
});
|
|
698
|
+
} catch {}
|
|
699
|
+
};
|
|
700
|
+
let returnTo = null;
|
|
701
|
+
let restoring = false;
|
|
702
|
+
watch(() => state.opened.value && commentThreadKey(state.opened.value), (key) => {
|
|
703
|
+
if (key) nextTick(() => layer.value?.querySelector("[data-slot='comment-thread']:not([data-preview])")?.focus());
|
|
704
|
+
});
|
|
705
|
+
watch(() => state.openId.value, (id, previous) => {
|
|
706
|
+
if (id) return;
|
|
707
|
+
returnTo = null;
|
|
708
|
+
const active = uiRoot().activeElement;
|
|
709
|
+
const thread = layer.value?.querySelector("[data-slot='comment-thread']:not([data-preview])");
|
|
710
|
+
const islandThread = state.threads.value.some((entry) => entry.id === previous && isPageIslandThread(state, entry));
|
|
711
|
+
if (previous && !islandThread && (!active || active === document.body || thread?.contains(active))) returnTo = previous;
|
|
712
|
+
}, { flush: "pre" });
|
|
713
|
+
watch(() => state.openId.value, (id) => {
|
|
714
|
+
if (id || !returnTo) return;
|
|
715
|
+
const target = returnTo;
|
|
716
|
+
returnTo = null;
|
|
717
|
+
nextTick(() => {
|
|
718
|
+
const pins = layer.value?.querySelectorAll("[data-slot='comment-pin']") ?? [];
|
|
719
|
+
restoring = true;
|
|
720
|
+
([...pins].find((pin) => pin.getAttribute("data-thread-id") === target) ?? layer.value?.querySelector("[data-slot='comment-toolbar-mode']"))?.focus();
|
|
721
|
+
restoring = false;
|
|
722
|
+
});
|
|
723
|
+
}, { flush: "post" });
|
|
724
|
+
let draftReturn = null;
|
|
725
|
+
watch(() => state.draft.value, (next, previous) => {
|
|
726
|
+
if (next && !previous) {
|
|
727
|
+
const active = document.activeElement;
|
|
728
|
+
const root = uiRoot();
|
|
729
|
+
draftReturn = active instanceof HTMLElement && active !== document.body && !(root instanceof ShadowRoot && active === root.host) && !layer.value?.contains(active) ? active : null;
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
if (next || !previous) return;
|
|
733
|
+
const target = draftReturn;
|
|
734
|
+
draftReturn = null;
|
|
735
|
+
nextTick(() => {
|
|
736
|
+
const focused = uiRoot().activeElement;
|
|
737
|
+
if (target?.isConnected && (!focused || focused === document.body)) target.focus({ preventScroll: true });
|
|
738
|
+
});
|
|
739
|
+
}, { flush: "sync" });
|
|
740
|
+
const draftAboveRoom = 72;
|
|
741
|
+
const draftCard = ref(null);
|
|
742
|
+
const draftBelow = ref(false);
|
|
743
|
+
const draftWidth = ref(0);
|
|
744
|
+
const measureDraft = () => {
|
|
745
|
+
draftWidth.value = draftCard.value?.offsetWidth ?? 0;
|
|
746
|
+
};
|
|
747
|
+
watch(() => state.draft.value, (next, previous) => {
|
|
748
|
+
if (next !== previous) draftBelow.value = false;
|
|
749
|
+
});
|
|
750
|
+
const fits = typeof ResizeObserver === "function" ? new ResizeObserver(() => {
|
|
751
|
+
measureDraft();
|
|
752
|
+
const card = draftCard.value;
|
|
753
|
+
if (card?.parentElement?.hasAttribute("data-above") && card.getBoundingClientRect().top < 8) draftBelow.value = true;
|
|
754
|
+
}) : void 0;
|
|
755
|
+
watch(draftCard, (card, previous) => {
|
|
756
|
+
if (previous) fits?.unobserve(previous);
|
|
757
|
+
if (card) fits?.observe(card);
|
|
758
|
+
measureDraft();
|
|
759
|
+
});
|
|
760
|
+
onBeforeUnmount(() => fits?.disconnect());
|
|
761
|
+
const place = ({ x, y }) => ({
|
|
762
|
+
left: `${x}px`,
|
|
763
|
+
top: `${y}px`,
|
|
764
|
+
"--vh-comment-x": `${x}px`
|
|
765
|
+
});
|
|
766
|
+
const picked = reactive(/* @__PURE__ */ new Map());
|
|
767
|
+
const placedItems = /* @__PURE__ */ new Map();
|
|
768
|
+
const observedCards = /* @__PURE__ */ new Map();
|
|
769
|
+
const observeCard = (key, card) => {
|
|
770
|
+
const previous = observedCards.get(key);
|
|
771
|
+
if (previous === card) return;
|
|
772
|
+
if (previous) cardSizes?.unobserve(previous);
|
|
773
|
+
observedCards.delete(key);
|
|
774
|
+
if (card) {
|
|
775
|
+
observedCards.set(key, card);
|
|
776
|
+
cardSizes?.observe(card);
|
|
777
|
+
}
|
|
778
|
+
};
|
|
779
|
+
const readSides = () => {
|
|
780
|
+
for (const [key, item] of placedItems) {
|
|
781
|
+
const card = item.querySelector(":scope > [data-slot='comment-layer-popover']");
|
|
782
|
+
const area = card ? getComputedStyle(card).getPropertyValue("position-area") : "";
|
|
783
|
+
observeCard(key, card && area && area !== "none" ? card : null);
|
|
784
|
+
if (!card || !area || area === "none") {
|
|
785
|
+
picked.delete(key);
|
|
786
|
+
continue;
|
|
787
|
+
}
|
|
788
|
+
const spot = item.getBoundingClientRect();
|
|
789
|
+
const box = card.getBoundingClientRect();
|
|
790
|
+
const next = {
|
|
791
|
+
x: box.left + box.right < spot.left * 2,
|
|
792
|
+
y: box.top + box.bottom < spot.top * 2
|
|
793
|
+
};
|
|
794
|
+
const now = picked.get(key);
|
|
795
|
+
if (now?.x !== next.x || now?.y !== next.y) picked.set(key, next);
|
|
796
|
+
}
|
|
797
|
+
};
|
|
798
|
+
const cardSizes = typeof ResizeObserver === "function" ? new ResizeObserver(readSides) : void 0;
|
|
799
|
+
let sideFrame = 0;
|
|
800
|
+
const readSidesSoon = () => {
|
|
801
|
+
if (!sideFrame) sideFrame = requestAnimationFrame(() => {
|
|
802
|
+
sideFrame = 0;
|
|
803
|
+
readSides();
|
|
804
|
+
});
|
|
805
|
+
};
|
|
806
|
+
onMounted(() => {
|
|
807
|
+
readSides();
|
|
808
|
+
window.addEventListener("resize", readSidesSoon, { passive: true });
|
|
809
|
+
window.visualViewport?.addEventListener("resize", readSidesSoon, { passive: true });
|
|
810
|
+
});
|
|
811
|
+
let marginList;
|
|
812
|
+
const moveMargin = () => {
|
|
813
|
+
const element = layer.value;
|
|
814
|
+
if (!element) return;
|
|
815
|
+
if (marginList) marginList.play();
|
|
816
|
+
else marginList = createMotionList(element, {
|
|
817
|
+
items: (root) => [...root.querySelectorAll("[data-margin-key]")],
|
|
818
|
+
movesOnly: true
|
|
819
|
+
});
|
|
820
|
+
marginList.measure();
|
|
821
|
+
};
|
|
822
|
+
onMounted(moveMargin);
|
|
823
|
+
onUpdated(() => {
|
|
824
|
+
readSides();
|
|
825
|
+
moveMargin();
|
|
826
|
+
});
|
|
827
|
+
onBeforeUnmount(() => {
|
|
828
|
+
marginList?.destroy();
|
|
829
|
+
cardSizes?.disconnect();
|
|
830
|
+
cancelAnimationFrame(sideFrame);
|
|
831
|
+
window.removeEventListener("resize", readSidesSoon);
|
|
832
|
+
window.visualViewport?.removeEventListener("resize", readSidesSoon);
|
|
833
|
+
});
|
|
834
|
+
const placedItem = (key) => (element) => {
|
|
835
|
+
if (element instanceof HTMLElement) placedItems.set(key, element);
|
|
836
|
+
else {
|
|
837
|
+
placedItems.delete(key);
|
|
838
|
+
observeCard(key, null);
|
|
839
|
+
picked.delete(key);
|
|
840
|
+
}
|
|
841
|
+
};
|
|
842
|
+
const side = (x, y, key) => {
|
|
843
|
+
const seen = key === void 0 ? void 0 : picked.get(key);
|
|
844
|
+
const flipX = seen ? seen.x : x + popoverWidth > window.innerWidth;
|
|
845
|
+
const flipY = seen ? seen.y : y + popoverHeight > window.innerHeight;
|
|
846
|
+
return {
|
|
847
|
+
"data-flip-x": flipX ? "true" : void 0,
|
|
848
|
+
"data-flip-y": flipY ? "true" : void 0
|
|
849
|
+
};
|
|
850
|
+
};
|
|
851
|
+
const pageDraft = (files) => {
|
|
852
|
+
const current = state.draft.value;
|
|
853
|
+
if (current?.anchor.kind === "page") return current;
|
|
854
|
+
try {
|
|
855
|
+
state.startDraft("page", files?.length ? { files } : {});
|
|
856
|
+
} catch {}
|
|
857
|
+
const next = state.draft.value;
|
|
858
|
+
return next?.anchor.kind === "page" ? next : null;
|
|
859
|
+
};
|
|
860
|
+
const composerView = (given, island) => h(CommentComposer, {
|
|
861
|
+
accept: props.accept,
|
|
862
|
+
attachments: attachmentsOn.value,
|
|
863
|
+
autofocus: island ? island.autofocus : true,
|
|
864
|
+
busy: given ? given.busy || uploadingDraft.value === given : false,
|
|
865
|
+
error: given?.error,
|
|
866
|
+
guard: !island,
|
|
867
|
+
key: island ? "page-island-composer" : void 0,
|
|
868
|
+
mentions: given?.mentions ?? [],
|
|
869
|
+
modelValue: given?.body ?? "",
|
|
870
|
+
onCancel: island ? island.onCancel : () => state.cancelDraft(),
|
|
871
|
+
files: draftFiles.value,
|
|
872
|
+
frame: "none",
|
|
873
|
+
layout: "row",
|
|
874
|
+
onSubmit: async (submit) => {
|
|
875
|
+
const draft = given ?? pageDraft(submit.files);
|
|
876
|
+
if (!draft || draft.busy || uploadingDraft.value === draft || state.draft.value !== draft) return;
|
|
877
|
+
draft.error = void 0;
|
|
878
|
+
draft.mentions = submit.mentions;
|
|
879
|
+
const files = queued(submit.files);
|
|
880
|
+
if (files) {
|
|
881
|
+
draft.attachments = [];
|
|
882
|
+
await state.send({ files });
|
|
883
|
+
return;
|
|
884
|
+
}
|
|
885
|
+
uploadingDraft.value = draft;
|
|
886
|
+
const submitted = draftFiles.value;
|
|
887
|
+
const body = draft.body;
|
|
888
|
+
const mentions = draft.mentions;
|
|
889
|
+
try {
|
|
890
|
+
const { attachments, files } = await prepare(submit.files);
|
|
891
|
+
if (state.draft.value !== draft || draft.body !== body || draft.mentions !== mentions || draftFiles.value !== submitted) return;
|
|
892
|
+
draft.attachments = attachments;
|
|
893
|
+
if (await state.send({ files }) && draftFiles.value === submitted) draftFiles.value = [];
|
|
894
|
+
} catch (error) {
|
|
895
|
+
draft.error = error instanceof Error ? error.message : "The files could not be uploaded. Try again.";
|
|
896
|
+
} finally {
|
|
897
|
+
if (uploadingDraft.value === draft) uploadingDraft.value = null;
|
|
898
|
+
}
|
|
899
|
+
},
|
|
900
|
+
"onUpdate:files": (value) => {
|
|
901
|
+
if (given || !value.length) draftFiles.value = value;
|
|
902
|
+
else pageDraft(value);
|
|
903
|
+
},
|
|
904
|
+
"onUpdate:mentions": (value) => {
|
|
905
|
+
const draft = given ?? (value.length ? pageDraft() : null);
|
|
906
|
+
if (draft) draft.mentions = value;
|
|
907
|
+
},
|
|
908
|
+
"onUpdate:modelValue": (value) => {
|
|
909
|
+
const draft = given ?? (value ? pageDraft() : null);
|
|
910
|
+
if (draft) draft.body = value;
|
|
911
|
+
},
|
|
912
|
+
people: user.value ? [user.value] : [],
|
|
913
|
+
size: props.size,
|
|
914
|
+
user: user.value,
|
|
915
|
+
users: state.users
|
|
916
|
+
});
|
|
917
|
+
const screenWidth = ref(0);
|
|
918
|
+
const onResize = () => {
|
|
919
|
+
screenWidth.value = window.innerWidth;
|
|
920
|
+
measureDraft();
|
|
921
|
+
};
|
|
922
|
+
onMounted(() => {
|
|
923
|
+
screenWidth.value = window.innerWidth;
|
|
924
|
+
window.addEventListener("resize", onResize, { passive: true });
|
|
925
|
+
});
|
|
926
|
+
onBeforeUnmount(() => window.removeEventListener("resize", onResize));
|
|
927
|
+
const inMargin = computed(() => props.placement === "margin" && screenWidth.value >= marginMinWidth);
|
|
928
|
+
const cardHeights = reactive(/* @__PURE__ */ new Map());
|
|
929
|
+
const cards = /* @__PURE__ */ new Map();
|
|
930
|
+
const measure = typeof ResizeObserver === "function" ? new ResizeObserver((entries) => {
|
|
931
|
+
for (const entry of entries) {
|
|
932
|
+
const key = entry.target.getAttribute("data-margin-key");
|
|
933
|
+
const height = Math.round(entry.target.getBoundingClientRect().height);
|
|
934
|
+
if (key && height && cardHeights.get(key) !== height) cardHeights.set(key, height);
|
|
935
|
+
}
|
|
936
|
+
}) : void 0;
|
|
937
|
+
onBeforeUnmount(() => measure?.disconnect());
|
|
938
|
+
const measured = (key) => (element) => {
|
|
939
|
+
const before = cards.get(key);
|
|
940
|
+
if (before && before !== element) measure?.unobserve(before);
|
|
941
|
+
if (element instanceof Element) {
|
|
942
|
+
cards.set(key, element);
|
|
943
|
+
measure?.observe(element);
|
|
944
|
+
} else cards.delete(key);
|
|
945
|
+
};
|
|
946
|
+
const statusSlot = () => slots.status ? { status: slots.status } : void 0;
|
|
947
|
+
const threadSlots = () => ({
|
|
948
|
+
...statusSlot(),
|
|
949
|
+
...slots.actions ? { actions: slots.actions } : {}
|
|
950
|
+
});
|
|
951
|
+
const threadView = (thread, inIsland = false) => h(CommentThread, {
|
|
952
|
+
accept: props.accept,
|
|
953
|
+
attachmentUrl: props.attachmentUrl,
|
|
954
|
+
attachments: attachmentsOn.value,
|
|
955
|
+
can: props.can,
|
|
956
|
+
key: commentThreadKey(thread),
|
|
957
|
+
detached: state.positions.value.get(thread.id)?.detached === true,
|
|
958
|
+
...inIsland ? {
|
|
959
|
+
dismissible: false,
|
|
960
|
+
navigation: "back"
|
|
961
|
+
} : {},
|
|
962
|
+
readOnly: props.readOnly,
|
|
963
|
+
size: props.size,
|
|
964
|
+
onClose: () => state.close(),
|
|
965
|
+
onDelete: (messageId) => state.remove(thread.id, messageId),
|
|
966
|
+
onEdit: (messageId, body, mentions) => state.edit(thread.id, messageId, body, mentions),
|
|
967
|
+
onReopen: () => state.reopen(thread.id),
|
|
968
|
+
onReply: async (body, mentions, list) => {
|
|
969
|
+
const { attachments, files } = await prepare(list);
|
|
970
|
+
return state.reply(thread.id, body, mentions, attachments, files);
|
|
971
|
+
},
|
|
972
|
+
onResolve: async () => {
|
|
973
|
+
await state.resolve(thread.id);
|
|
974
|
+
state.close();
|
|
975
|
+
},
|
|
976
|
+
thread,
|
|
977
|
+
user: user.value
|
|
978
|
+
}, threadSlots());
|
|
979
|
+
const marginLayout = (spots, draftY) => {
|
|
980
|
+
const entries = pinned.value.flatMap((thread) => {
|
|
981
|
+
const spot = state.shown.value.has(thread.id) ? spots.get(thread.id) : void 0;
|
|
982
|
+
return spot ? [{
|
|
983
|
+
active: state.openId.value === thread.id,
|
|
984
|
+
key: thread.id,
|
|
985
|
+
thread,
|
|
986
|
+
y: spot.y
|
|
987
|
+
}] : [];
|
|
988
|
+
});
|
|
989
|
+
if (draftY !== void 0) entries.push({
|
|
990
|
+
active: true,
|
|
991
|
+
key: draftPositionKey,
|
|
992
|
+
y: draftY
|
|
993
|
+
});
|
|
994
|
+
entries.sort((a, b) => a.y - b.y);
|
|
995
|
+
const height = (entry) => cardHeights.get(entry.key) ?? (entry.active ? popoverHeight : marginCardHeight);
|
|
996
|
+
const tops = [];
|
|
997
|
+
let below = -Infinity;
|
|
998
|
+
for (const entry of entries) {
|
|
999
|
+
const top = Math.max(entry.y - 16, below + marginGap);
|
|
1000
|
+
tops.push(top);
|
|
1001
|
+
below = top + height(entry);
|
|
1002
|
+
}
|
|
1003
|
+
const edge = window.innerHeight - 16;
|
|
1004
|
+
entries.forEach((entry, index) => {
|
|
1005
|
+
if (!entry.active || tops[index] + height(entry) <= edge) return;
|
|
1006
|
+
tops[index] = Math.max(16, edge - height(entry));
|
|
1007
|
+
for (let before = index - 1; before >= 0; before--) tops[before] = Math.min(tops[before], tops[before + 1] - marginGap - height(entries[before]));
|
|
1008
|
+
for (let after = index + 1; after < entries.length; after++) tops[after] = Math.max(tops[after], tops[after - 1] + marginGap + height(entries[after - 1]));
|
|
1009
|
+
});
|
|
1010
|
+
const at = new Map(entries.map((entry, index) => [entry.key, tops[index]]));
|
|
1011
|
+
const cards = entries.flatMap((entry, index) => {
|
|
1012
|
+
const thread = entry.thread;
|
|
1013
|
+
if (!thread || entry.active) return [];
|
|
1014
|
+
return [h("button", {
|
|
1015
|
+
"aria-label": `${commentTitle(thread)}: ${excerpt(thread.messages[0]?.body ?? "")}`,
|
|
1016
|
+
"data-margin-key": entry.key,
|
|
1017
|
+
"data-slot": "comment-margin-card",
|
|
1018
|
+
"data-status": thread.status,
|
|
1019
|
+
...deliveryAttributes(thread.delivery),
|
|
1020
|
+
key: entry.key,
|
|
1021
|
+
onClick: () => state.open(thread),
|
|
1022
|
+
onPointerenter: () => {
|
|
1023
|
+
if (!state.draft.value) state.hoverId.value = thread.id;
|
|
1024
|
+
},
|
|
1025
|
+
onPointerleave: () => {
|
|
1026
|
+
if (state.hoverId.value === thread.id) state.hoverId.value = null;
|
|
1027
|
+
},
|
|
1028
|
+
ref: measured(entry.key),
|
|
1029
|
+
style: { top: `${tops[index]}px` },
|
|
1030
|
+
type: "button"
|
|
1031
|
+
}, [h(CommentRow_default, { thread })])];
|
|
1032
|
+
});
|
|
1033
|
+
return {
|
|
1034
|
+
at,
|
|
1035
|
+
node: h("div", { "data-slot": "comment-margin" }, cards)
|
|
1036
|
+
};
|
|
1037
|
+
};
|
|
1038
|
+
return () => {
|
|
1039
|
+
const spots = /* @__PURE__ */ new Map();
|
|
1040
|
+
for (const thread of drawn.value) {
|
|
1041
|
+
const position = state.positions.value.get(thread.id);
|
|
1042
|
+
if (!position || position.detached || position.clipped || thread.anchor.kind === "page") continue;
|
|
1043
|
+
const taken = (y) => [...spots.values()].some((spot) => Math.abs(spot.x - position.x) < pinSpacing && Math.abs(spot.y - y) < pinSpacing);
|
|
1044
|
+
let y = position.y;
|
|
1045
|
+
while (taken(y)) y += pinSpacing;
|
|
1046
|
+
if (y !== position.y && y > window.innerHeight - pinSpacing) {
|
|
1047
|
+
y = position.y - pinSpacing;
|
|
1048
|
+
while (taken(y)) y -= pinSpacing;
|
|
1049
|
+
}
|
|
1050
|
+
spots.set(thread.id, {
|
|
1051
|
+
...position,
|
|
1052
|
+
y
|
|
1053
|
+
});
|
|
1054
|
+
}
|
|
1055
|
+
const items = drawn.value.flatMap((thread) => {
|
|
1056
|
+
const position = spots.get(thread.id);
|
|
1057
|
+
if (!position) return [];
|
|
1058
|
+
const leaving = !state.shown.value.has(thread.id);
|
|
1059
|
+
const open = state.openId.value === thread.id;
|
|
1060
|
+
const hover = state.hoverId.value === thread.id && !leaving && !open && !state.draft.value && !inMargin.value;
|
|
1061
|
+
return [h("div", {
|
|
1062
|
+
...side(position.x, position.y, thread.id),
|
|
1063
|
+
"data-kind": thread.anchor.kind,
|
|
1064
|
+
"data-leaving": leaving ? "true" : void 0,
|
|
1065
|
+
"data-slot": "comment-layer-item",
|
|
1066
|
+
inert: leaving || void 0,
|
|
1067
|
+
key: thread.id,
|
|
1068
|
+
ref: placedItem(thread.id),
|
|
1069
|
+
style: place(position)
|
|
1070
|
+
}, [h(CommentPin_default, {
|
|
1071
|
+
active: open,
|
|
1072
|
+
author: thread.author,
|
|
1073
|
+
"data-shape": pinShape(thread.anchor.kind),
|
|
1074
|
+
"data-thread-id": thread.id,
|
|
1075
|
+
...deliveryAttributes(thread.delivery),
|
|
1076
|
+
excerpt: excerpt(thread.messages[0]?.body ?? ""),
|
|
1077
|
+
...thread.n ? { number: thread.n } : {},
|
|
1078
|
+
onHover: () => {
|
|
1079
|
+
if (!open && !restoring && !state.draft.value) state.hoverId.value = thread.id;
|
|
1080
|
+
},
|
|
1081
|
+
onLeave: () => {
|
|
1082
|
+
if (state.hoverId.value === thread.id) state.hoverId.value = null;
|
|
1083
|
+
},
|
|
1084
|
+
onSelect: () => open ? state.close() : state.open(thread),
|
|
1085
|
+
status: thread.status
|
|
1086
|
+
}), hover ? h("div", {
|
|
1087
|
+
"data-preview": "true",
|
|
1088
|
+
"data-slot": "comment-layer-popover"
|
|
1089
|
+
}, h(CommentThread, {
|
|
1090
|
+
preview: true,
|
|
1091
|
+
size: props.size,
|
|
1092
|
+
thread
|
|
1093
|
+
}, statusSlot())) : null])];
|
|
1094
|
+
});
|
|
1095
|
+
const draft = state.draft.value;
|
|
1096
|
+
const draftPosition = draft && state.positions.value.get("draft");
|
|
1097
|
+
const pointDraft = draft && draft.anchor.kind !== "page" ? draft : null;
|
|
1098
|
+
const point = pointDraft && draftPosition && !draftPosition.detached ? draftPosition : pointDraft?.point;
|
|
1099
|
+
const draftInMargin = Boolean(inMargin.value && pointDraft && point);
|
|
1100
|
+
const margin = inMargin.value ? marginLayout(spots, draftInMargin ? point.y : void 0) : null;
|
|
1101
|
+
const inColumn = (key) => {
|
|
1102
|
+
const top = margin?.at.get(key);
|
|
1103
|
+
return top === void 0 ? void 0 : {
|
|
1104
|
+
"data-margin": "true",
|
|
1105
|
+
"data-margin-key": key,
|
|
1106
|
+
style: { top: `${top}px` }
|
|
1107
|
+
};
|
|
1108
|
+
};
|
|
1109
|
+
const shown = state.opened.value;
|
|
1110
|
+
const opened = shown && !isPageIslandThread(state, shown) ? shown : void 0;
|
|
1111
|
+
const openedPosition = opened && state.positions.value.get(opened.id);
|
|
1112
|
+
const pointForThread = opened && openedPosition && !openedPosition.detached && !openedPosition.clipped && opened.anchor.kind !== "page" ? spots.get(opened.id) ?? openedPosition : void 0;
|
|
1113
|
+
const openedColumn = opened && pointForThread ? inColumn(opened.id) : void 0;
|
|
1114
|
+
const openThread = opened ? h("div", {
|
|
1115
|
+
...pointForThread ? side(pointForThread.x, pointForThread.y, "opened-thread") : {},
|
|
1116
|
+
"data-kind": opened.anchor.kind,
|
|
1117
|
+
"data-slot": "comment-layer-item",
|
|
1118
|
+
key: "opened-thread",
|
|
1119
|
+
ref: placedItem("opened-thread"),
|
|
1120
|
+
style: pointForThread ? place(pointForThread) : void 0
|
|
1121
|
+
}, h("div", {
|
|
1122
|
+
...openedColumn,
|
|
1123
|
+
"data-floating": pointForThread ? void 0 : "true",
|
|
1124
|
+
"data-slot": "comment-layer-popover",
|
|
1125
|
+
ref: (element) => openedColumn && measured(opened.id)(element)
|
|
1126
|
+
}, threadView(opened))) : null;
|
|
1127
|
+
const placement = pointDraft && point ? placeDraft(point, draftWidth.value, screenWidth.value) : void 0;
|
|
1128
|
+
const draftColumn = draftInMargin ? inColumn(draftPositionKey) : void 0;
|
|
1129
|
+
const composing = pointDraft && placement ? h("div", {
|
|
1130
|
+
...side(placement.x, placement.y),
|
|
1131
|
+
"data-flip-x": placement.flipX ? "true" : void 0,
|
|
1132
|
+
...(pointDraft.anchor.kind === "area" || pointDraft.anchor.kind === "image") && placement.y > draftAboveRoom && !draftBelow.value ? { "data-above": "true" } : {},
|
|
1133
|
+
"data-draft": "true",
|
|
1134
|
+
"data-kind": pointDraft.anchor.kind,
|
|
1135
|
+
"data-slot": "comment-layer-item",
|
|
1136
|
+
style: place(placement)
|
|
1137
|
+
}, [h(CommentPin_default, {
|
|
1138
|
+
author: user.value,
|
|
1139
|
+
"data-shape": pinShape(pointDraft.anchor.kind),
|
|
1140
|
+
draft: true
|
|
1141
|
+
}), h("div", {
|
|
1142
|
+
...draftColumn,
|
|
1143
|
+
"data-motion-appear": draftColumn ? void 0 : "[data-slot=comment-pin]",
|
|
1144
|
+
"data-slot": "comment-layer-popover",
|
|
1145
|
+
style: draftColumn?.style ?? { "--vh-comment-draft-left": `${placement.left}px` },
|
|
1146
|
+
ref: (element) => {
|
|
1147
|
+
draftCard.value = element instanceof HTMLElement ? element : null;
|
|
1148
|
+
if (draftColumn) measured(draftPositionKey)(element);
|
|
1149
|
+
}
|
|
1150
|
+
}, composerView(pointDraft))]) : null;
|
|
1151
|
+
return h("div", {
|
|
1152
|
+
"data-active": state.active.value ? "true" : void 0,
|
|
1153
|
+
"data-comments-ui": "",
|
|
1154
|
+
"data-slot": "comment-layer",
|
|
1155
|
+
ref: layer
|
|
1156
|
+
}, [
|
|
1157
|
+
state.active.value ? h("div", {
|
|
1158
|
+
"data-slot": "comment-layer-overlay",
|
|
1159
|
+
onPointercancel: () => {
|
|
1160
|
+
down = null;
|
|
1161
|
+
drawing.value = null;
|
|
1162
|
+
},
|
|
1163
|
+
onPointerdown: press,
|
|
1164
|
+
onPointermove: move,
|
|
1165
|
+
onPointerup: release
|
|
1166
|
+
}, drawing.value ? [h("div", {
|
|
1167
|
+
"data-slot": "comment-layer-area",
|
|
1168
|
+
style: {
|
|
1169
|
+
left: `${drawing.value.left}px`,
|
|
1170
|
+
top: `${drawing.value.top}px`,
|
|
1171
|
+
width: `${drawing.value.width}px`,
|
|
1172
|
+
height: `${drawing.value.height}px`
|
|
1173
|
+
}
|
|
1174
|
+
}, [...[
|
|
1175
|
+
"top-left",
|
|
1176
|
+
"top-right",
|
|
1177
|
+
"bottom-left",
|
|
1178
|
+
"bottom-right"
|
|
1179
|
+
].map((corner) => h("span", {
|
|
1180
|
+
"data-corner": corner,
|
|
1181
|
+
"data-slot": "comment-layer-area-handle",
|
|
1182
|
+
key: corner
|
|
1183
|
+
})), h("span", { "data-slot": "comment-layer-area-size" }, `${Math.round(drawing.value.width)} × ${Math.round(drawing.value.height)}`)])] : []) : null,
|
|
1184
|
+
...items,
|
|
1185
|
+
composing,
|
|
1186
|
+
openThread,
|
|
1187
|
+
h(CommentPageIsland, {
|
|
1188
|
+
comments: state,
|
|
1189
|
+
canComment: props.canComment && !props.readOnly
|
|
1190
|
+
}, {
|
|
1191
|
+
composer: (scope) => [composerView(scope.draft, scope)],
|
|
1192
|
+
thread: ({ thread }) => [threadView(thread, true)]
|
|
1193
|
+
}),
|
|
1194
|
+
margin?.node,
|
|
1195
|
+
slots.default?.({ comments: state }) ?? [h(CommentToolbar_default, {
|
|
1196
|
+
comments: state,
|
|
1197
|
+
people: props.people
|
|
1198
|
+
}), state.listOpen.value ? h(CommentList_default, {
|
|
1199
|
+
comments: state,
|
|
1200
|
+
navigate: props.navigate
|
|
1201
|
+
}) : null]
|
|
1202
|
+
]);
|
|
1203
|
+
};
|
|
1204
|
+
}
|
|
1205
|
+
});
|
|
1206
|
+
export { CommentFilters_default as a, CommentList_default as i, CommentToolbar_default as n, CommentPin_default as r, CommentLayer as t };
|