@nextclaw/ui 0.15.22 → 0.15.23
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/CHANGELOG.md +49 -0
- package/dist/assets/{abnfDiagram-VRR7QNED-M4g_AyR8.js → abnfDiagram-VRR7QNED-DvTjgVMf.js} +1 -1
- package/dist/assets/{aiden0z-pptx-renderer.es-Bd99vut2.js → aiden0z-pptx-renderer.es-C1nfBAXR.js} +1 -1
- package/dist/assets/api-Glw2OGXK.js +13 -0
- package/dist/assets/appearance-settings-page-Bl_W_9m7.js +1 -0
- package/dist/assets/{arc-IO7WNWOB.js → arc-BvhODBXv.js} +1 -1
- package/dist/assets/architecture-TIHT7OUA-Bjp9jf0h.js +1 -0
- package/dist/assets/{architectureDiagram-ZJ3FMSHR-Dc-lvdUh.js → architectureDiagram-ZJ3FMSHR-BKO9RgNS.js} +1 -1
- package/dist/assets/{blockDiagram-677ZJIJ3-CcsoWpIY.js → blockDiagram-677ZJIJ3-DHpDXy7D.js} +1 -1
- package/dist/assets/{c4Diagram-LMCZKHZV-Bsrtg6b2.js → c4Diagram-LMCZKHZV-BG_iQnDr.js} +1 -1
- package/dist/assets/channel-5T3pdR-s.js +1 -0
- package/dist/assets/channels-list-page-C7E4Sxwd.js +8 -0
- package/dist/assets/chat-page-BT6dNI-4.js +1 -0
- package/dist/assets/chunk-2Q5K7J3B-DTZ3tGfE.js +1 -0
- package/dist/assets/{chunk-32BRIVSS-Bt08t8oG.js → chunk-32BRIVSS-DR9M0LLx.js} +1 -1
- package/dist/assets/{chunk-52WLFC77-Ddx68Xzx.js → chunk-52WLFC77-698iC3BB.js} +1 -1
- package/dist/assets/{chunk-5FCAYU7R-B7p9_q55.js → chunk-5FCAYU7R-DikTj9Ey.js} +1 -1
- package/dist/assets/{chunk-5HE753X5-D52KvdTm.js → chunk-5HE753X5-ko0o7_q0.js} +1 -1
- package/dist/assets/{chunk-5JV3BV7I-C329h8nI.js → chunk-5JV3BV7I-CEHufhgo.js} +1 -1
- package/dist/assets/{chunk-5TONJI2A-BZyUBxWt.js → chunk-5TONJI2A-CGgno1cu.js} +1 -1
- package/dist/assets/{chunk-5VM5RSS4-BUiYXZmu.js → chunk-5VM5RSS4-DkiB4cUQ.js} +1 -1
- package/dist/assets/{chunk-7BUUIJ7U-B7o-mn4r.js → chunk-7BUUIJ7U-DzptcytQ.js} +1 -1
- package/dist/assets/{chunk-BIQX33UG-Bey9GoRP.js → chunk-BIQX33UG-DMRSQJvT.js} +1 -1
- package/dist/assets/{chunk-C7G6YPKG-C6tosszM.js → chunk-C7G6YPKG-Bw1BwwuY.js} +1 -1
- package/dist/assets/{chunk-CQNSW5MT-BNrdkgGQ.js → chunk-CQNSW5MT-C0z6eHBk.js} +1 -1
- package/dist/assets/{chunk-CYSBUYHQ-DHODFeyB.js → chunk-CYSBUYHQ-ByPyAouO.js} +1 -1
- package/dist/assets/{chunk-EMLP6XTP-BcmLjrcq.js → chunk-EMLP6XTP-CJlAXWZg.js} +1 -1
- package/dist/assets/{chunk-EX3LRPZG-r-_eEtJI.js → chunk-EX3LRPZG-Dqq4zKJu.js} +1 -1
- package/dist/assets/{chunk-FWX5IMBZ-DOObDWbf.js → chunk-FWX5IMBZ-B0SNoCmi.js} +2 -2
- package/dist/assets/{chunk-HOUHSVGY-Bd0FnbWZ.js → chunk-HOUHSVGY-DG_GJih_.js} +1 -1
- package/dist/assets/{chunk-ICXQ74PX-ntNwAm4_.js → chunk-ICXQ74PX-Drxk_6bE.js} +1 -1
- package/dist/assets/{chunk-JG7HCLWE-YtRpblZN.js → chunk-JG7HCLWE-DdLFPpnd.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-De5-D9ta.js → chunk-JWPE2WC7-B8M4G76F.js} +1 -1
- package/dist/assets/{chunk-MOJQB5TN-CdvKhyp2.js → chunk-MOJQB5TN-XP6FJHY_.js} +1 -1
- package/dist/assets/{chunk-MOZMSUNE-DJMMN_lu.js → chunk-MOZMSUNE-C_6x18Qw.js} +1 -1
- package/dist/assets/{chunk-OGEWGWER-DOFWVw3O.js → chunk-OGEWGWER-N25BzCmG.js} +1 -1
- package/dist/assets/{chunk-OSBZ3O6U-DZkrIN9r.js → chunk-OSBZ3O6U-ASDEm7y0.js} +1 -1
- package/dist/assets/{chunk-PUDLZKDR-D1wma2Yf.js → chunk-PUDLZKDR-CTlvAcn7.js} +1 -1
- package/dist/assets/{chunk-Q4XR5HBZ-CjPy94Lz.js → chunk-Q4XR5HBZ-Da9BWfB6.js} +1 -1
- package/dist/assets/{chunk-QBLGF6JB-Hy1bEgS-.js → chunk-QBLGF6JB-Bi6RpTJO.js} +1 -1
- package/dist/assets/{chunk-R7FJI6CG-CUPIHyh-.js → chunk-R7FJI6CG-DkMsSPvK.js} +1 -1
- package/dist/assets/{chunk-RYQCIY6F-D5Ua4pcv.js → chunk-RYQCIY6F-DZp0eU-j.js} +1 -1
- package/dist/assets/{chunk-U6XO7XAA-DaUQcqb7.js → chunk-U6XO7XAA-vfinDSrj.js} +1 -1
- package/dist/assets/{chunk-V7JOEXUC-DX2zLfQe.js → chunk-V7JOEXUC-C9Nksccs.js} +1 -1
- package/dist/assets/chunk-VAUOI2AC-HLGIHQ6k.js +1 -0
- package/dist/assets/{chunk-VR4S4FIN-CFA-WQik.js → chunk-VR4S4FIN-Xv6zfwXs.js} +1 -1
- package/dist/assets/{chunk-WYO6CB5R-Bk2HeDvJ.js → chunk-WYO6CB5R-mOJNzbWl.js} +2 -2
- package/dist/assets/chunk-XXDRQBXY-Dl0m6Ni-.js +1 -0
- package/dist/assets/{chunk-YOTPTUD7-DUG4FpBN.js → chunk-YOTPTUD7-1-aKSu4o.js} +1 -1
- package/dist/assets/{chunk-ZGVPDNZ5-70JdIGo0.js → chunk-ZGVPDNZ5-OJ8veMpK.js} +1 -1
- package/dist/assets/{chunk-ZIRB5QZD-XZdgBt5L.js → chunk-ZIRB5QZD-SR_Nq_PP.js} +1 -1
- package/dist/assets/classDiagram-OUVF2IWQ-DcDnzGNX.js +1 -0
- package/dist/assets/classDiagram-v2-EOCWNBFH-BKXKMzKM.js +1 -0
- package/dist/assets/{config-split-page-BgBsUmp1.js → config-split-page-D5BgtKrm.js} +1 -1
- package/dist/assets/confirm-dialog-Bf907Azu.js +5 -0
- package/dist/assets/{cose-bilkent-JH36ORCC-B-PQoGX-.js → cose-bilkent-JH36ORCC-NjVgz2Bw.js} +1 -1
- package/dist/assets/cynefin-VYW2F7L2-BWg7U2UD.js +1 -0
- package/dist/assets/{cynefinDiagram-TSTJHNR4-BoLCPEM0.js → cynefinDiagram-TSTJHNR4-B_17LDqD.js} +1 -1
- package/dist/assets/{dagre-D7Ie4eXr.js → dagre-CMe101gk.js} +1 -1
- package/dist/assets/{dagre-VKFMJZFB-CKRrwZA-.js → dagre-VKFMJZFB-qo8nLb3B.js} +1 -1
- package/dist/assets/desktop-update-config-BwuyBPJb.js +1 -0
- package/dist/assets/{diagram-FQU43EPY-CASL1J3_.js → diagram-FQU43EPY-Ba3XIklC.js} +1 -1
- package/dist/assets/{diagram-G47NLZAW-CvLPBIzf.js → diagram-G47NLZAW-CG45TcUx.js} +1 -1
- package/dist/assets/{diagram-NH7WQ7WH-Ba6fGdYP.js → diagram-NH7WQ7WH-2F2HrwV-.js} +1 -1
- package/dist/assets/{diagram-OA4YK3LP-DkpfgEjM.js → diagram-OA4YK3LP-CXfWH9NZ.js} +1 -1
- package/dist/assets/{diagram-WEI45ONY-BP5UMVsN.js → diagram-WEI45ONY-CH_4yepc.js} +1 -1
- package/dist/assets/dist-CtLyEJeO.js +1 -0
- package/dist/assets/dist-dv_SUR54.js +1 -0
- package/dist/assets/doc-browser-C23NDGh5.js +1 -0
- package/dist/assets/doc-browser-DlOOhBxI.js +1 -0
- package/dist/assets/doc-browser-context-BIBjkwfV.js +1 -0
- package/dist/assets/{docx-preview-D0tp3a9T.js → docx-preview-CoM4JK7_.js} +1 -1
- package/dist/assets/{ebnfDiagram-CCIWWBDH-TJKbUcmc.js → ebnfDiagram-CCIWWBDH-BwiG4Ea1.js} +1 -1
- package/dist/assets/{erDiagram-Q63AITRT-DzGPKkKH.js → erDiagram-Q63AITRT-BML3hpnQ.js} +1 -1
- package/dist/assets/eventmodeling-45OFAUF4-SB-J4tpq.js +1 -0
- package/dist/assets/flowDiagram-23GEKE2U-BQ_u-eLM.js +1 -0
- package/dist/assets/{form-actions-CgjYZUzM.js → form-actions-DAzi68Cn.js} +1 -1
- package/dist/assets/{ganttDiagram-NO4QXBWP-JhJzsGp2.js → ganttDiagram-NO4QXBWP-80enfWbD.js} +1 -1
- package/dist/assets/gitGraph-TEB2WS4Q-DPxNwsFd.js +1 -0
- package/dist/assets/{gitGraphDiagram-IHSO6WYX-DZ1CKMj8.js → gitGraphDiagram-IHSO6WYX-CVLqXr-b.js} +1 -1
- package/dist/assets/host-capabilities-D9C4CBK5.js +1 -0
- package/dist/assets/index-BLNg2yg0.css +1 -0
- package/dist/assets/index-D3EKjEyK.js +107 -0
- package/dist/assets/info-DKCQHKI2-DNlNGH90.js +1 -0
- package/dist/assets/{infoDiagram-FWYZ7A6U-BNXNKfRQ.js → infoDiagram-FWYZ7A6U-Dyvs2t0i.js} +1 -1
- package/dist/assets/{ishikawaDiagram-FXEZZL3T-DoiEfjNw.js → ishikawaDiagram-FXEZZL3T-sSnxDKfh.js} +1 -1
- package/dist/assets/{journeyDiagram-5HDEW3XC-D6oK2HSy.js → journeyDiagram-5HDEW3XC-D22V71Mf.js} +1 -1
- package/dist/assets/{kanban-definition-HUTT4EX6-B2UnLOH-.js → kanban-definition-HUTT4EX6-D3ds0p-g.js} +1 -1
- package/dist/assets/{line-BM7PoxY5.js → line-CbyFs065.js} +1 -1
- package/dist/assets/{linear-B3DiqMjk.js → linear-4DKtnZBS.js} +1 -1
- package/dist/assets/loader-circle-BSg5u0r4.js +1 -0
- package/dist/assets/{map-BAAdHTqR.js → map-CcZzEoz6.js} +1 -1
- package/dist/assets/mcp-marketplace-page-ByhvQQj5.js +9 -0
- package/dist/assets/mcp-marketplace-page-CytXwnUs.js +1 -0
- package/dist/assets/{mermaid-parser.core-BeMviefY.js → mermaid-parser.core-DPmMOjXD.js} +2 -2
- package/dist/assets/{mermaid.core-D0Q77r9I.js → mermaid.core-BSf-ddRa.js} +3 -3
- package/dist/assets/{mindmap-definition-LN4V7U3C-BQ7r7bR8.js → mindmap-definition-LN4V7U3C-BUTwWPyx.js} +1 -1
- package/dist/assets/model-config-page-bgEx3MjQ.js +1 -0
- package/dist/assets/navigation-link-CB0OQbnY.js +3 -0
- package/dist/assets/{ordinal-Bt2N4IkA.js → ordinal-BgLYtOZE.js} +1 -1
- package/dist/assets/packet-7NZHBO7P-BpeiqkBZ.js +1 -0
- package/dist/assets/{pegDiagram-2B236MQR-B-C9-LGz.js → pegDiagram-2B236MQR-BEu_ZBjc.js} +1 -1
- package/dist/assets/pie-RZYD4A2V-Cy1yxsPd.js +1 -0
- package/dist/assets/{pieDiagram-ENE6RG2P-CtirZLtn.js → pieDiagram-ENE6RG2P-CAwAwuBd.js} +1 -1
- package/dist/assets/plus-CNjWdLhZ.js +1 -0
- package/dist/assets/provider-scoped-model-input-8F6JMd2n.js +1 -0
- package/dist/assets/providers-config-page-CxpTjR81.js +1 -0
- package/dist/assets/{quadrantDiagram-ABIIQ3AL-DiBWAzDU.js → quadrantDiagram-ABIIQ3AL-CwE6F-_2.js} +1 -1
- package/dist/assets/radar-I7S5WNFK-CEcPKCj8.js +1 -0
- package/dist/assets/railroad-3IZDKUUU-CW38eNDs.js +1 -0
- package/dist/assets/railroad-abnf-AHOZXSZD-ByrylcXf.js +1 -0
- package/dist/assets/railroad-ebnf-EBAXGLYW-CNB6GwP-.js +1 -0
- package/dist/assets/railroad-peg-LSFZ7HO6-x6hnqlBG.js +1 -0
- package/dist/assets/{railroadDiagram-RFXS5EU6-CP6b3PBI.js → railroadDiagram-RFXS5EU6-xgLekU3B.js} +1 -1
- package/dist/assets/react-Bk2ydNTe.js +8 -0
- package/dist/assets/{refresh-cw-CkKwPztT.js → refresh-cw-Ba0LZou4.js} +1 -1
- package/dist/assets/remote-Dv38PuMV.js +1 -0
- package/dist/assets/{requirementDiagram-TGXJPOKE-D8YV0-Jz.js → requirementDiagram-TGXJPOKE-CyVUzEX5.js} +1 -1
- package/dist/assets/rotate-cw-IkYVk9JX.js +1 -0
- package/dist/assets/runtime-config-page-C0ByyUVr.js +1 -0
- package/dist/assets/{sankeyDiagram-HTMAVEWB-C2vA4ojE.js → sankeyDiagram-HTMAVEWB-JK6bFmYB.js} +1 -1
- package/dist/assets/{save-BINMWate.js → save-DTOAvqzt.js} +1 -1
- package/dist/assets/{search-7M38azRp.js → search-D4X5DNMe.js} +1 -1
- package/dist/assets/search-config-page-Cr6254K5.js +1 -0
- package/dist/assets/{secrets-config-page-2mVejXf2.js → secrets-config-page-W2Hx332d.js} +2 -2
- package/dist/assets/security-config-1E8OF4kR.js +1 -0
- package/dist/assets/select-CDv0g2Pj.js +41 -0
- package/dist/assets/{sequenceDiagram-DBY2YBRQ-B9LBmpUo.js → sequenceDiagram-DBY2YBRQ-BR5IokXV.js} +1 -1
- package/dist/assets/{settings-2-DqZstREV.js → settings-2-CoxzNABp.js} +1 -1
- package/dist/assets/{sizeCapture-X5ZJPWSS-9UIfya9-.js → sizeCapture-X5ZJPWSS-SxG_YnMA.js} +1 -1
- package/dist/assets/skeleton-DW018fJv.js +1 -0
- package/dist/assets/{src-DKf77Yzo.js → src-vgz8E_-O.js} +1 -1
- package/dist/assets/{stateDiagram-2N3HPSRC-oTW44vds.js → stateDiagram-2N3HPSRC-DD4OoYhn.js} +1 -1
- package/dist/assets/stateDiagram-v2-6OUMAXLB-ZC6dFORv.js +1 -0
- package/dist/assets/{swimlanes-5IMT3BWC-Cf7lcsay.js → swimlanes-5IMT3BWC-BWkFeyCT.js} +2 -2
- package/dist/assets/swimlanesDiagram-G3AALYLV-CRkh51Im.js +8 -0
- package/dist/assets/{tag-chip-BoDaLnWt.js → tag-chip-CjkZEoS2.js} +1 -1
- package/dist/assets/{timeline-definition-FHXFAJF6-DoCuWKDJ.js → timeline-definition-FHXFAJF6-VTRPy6KA.js} +1 -1
- package/dist/assets/treeView-QDETBFTQ-Bw0DSCH7.js +1 -0
- package/dist/assets/treemap-6X3UGDF4-DFWBFcfh.js +1 -0
- package/dist/assets/use-confirm-dialog-CavtY1vJ.js +1 -0
- package/dist/assets/{vennDiagram-L72KCM5P-CpU0pzGe.js → vennDiagram-L72KCM5P-Bvk42Pek.js} +1 -1
- package/dist/assets/wardley-OPB4EBWU-CoWturk0.js +1 -0
- package/dist/assets/{wardleyDiagram-EHGQE667-CkN6nn6-.js → wardleyDiagram-EHGQE667-DOFjx2s3.js} +1 -1
- package/dist/assets/x-PTXYTEwz.js +1 -0
- package/dist/assets/{xychartDiagram-FW5EYKEG-DATpapm2.js → xychartDiagram-FW5EYKEG-DY5yRTUc.js} +1 -1
- package/dist/index.html +30 -32
- package/index.html +8 -0
- package/package.json +9 -9
- package/src/app/components/layout/page-layout.tsx +15 -6
- package/src/app/styles/charcoal-theme.css +85 -0
- package/src/app/styles/design-system.css +11 -13
- package/src/features/agents/components/__tests__/agents-page.test.tsx +36 -24
- package/src/features/agents/components/agent-advanced-config-fields.tsx +7 -7
- package/src/features/agents/components/agent-details-dialog.tsx +8 -8
- package/src/features/agents/components/agent-dialogs.tsx +7 -7
- package/src/features/agents/components/agents-page.tsx +42 -62
- package/src/features/chat/components/conversation/__tests__/chat-conversation-content.test.tsx +27 -3
- package/src/features/chat/components/conversation/__tests__/chat-conversation-header-section.test.tsx +16 -0
- package/src/features/chat/components/conversation/__tests__/chat-conversation-panel.test.tsx +8 -22
- package/src/features/chat/components/conversation/__tests__/chat-conversation-workspace-section.test.tsx +69 -3
- package/src/features/chat/components/conversation/chat-conversation-content.tsx +20 -6
- package/src/features/chat/components/conversation/chat-conversation-header-section.tsx +30 -31
- package/src/features/chat/components/conversation/chat-conversation-panel.tsx +1 -8
- package/src/features/chat/components/conversation/chat-conversation-workspace-section.tsx +16 -4
- package/src/features/chat/components/layout/__tests__/chat-page-shell.test.tsx +23 -0
- package/src/features/chat/components/layout/__tests__/chat-sidebar-toolbar.test.tsx +6 -0
- package/src/features/chat/components/layout/chat-page-shell.tsx +5 -4
- package/src/features/chat/components/layout/chat-sidebar-toolbar.tsx +4 -4
- package/src/features/chat/components/providers/chat-presenter.provider.tsx +2 -0
- package/src/features/chat/features/conversation/components/__tests__/session-conversation-area.test.tsx +84 -12
- package/src/features/chat/features/conversation/components/__tests__/session-conversation-input.streaming.test.tsx +243 -5
- package/src/features/chat/features/conversation/components/session-conversation-area.tsx +48 -31
- package/src/features/chat/features/conversation/components/session-conversation-input.tsx +46 -37
- package/src/features/chat/features/conversation/hooks/__tests__/use-session-conversation-controller.test.tsx +128 -1
- package/src/features/chat/features/conversation/hooks/__tests__/use-session-conversation-input-state.test.tsx +67 -1
- package/src/features/chat/features/conversation/hooks/__tests__/use-session-conversation-slash-commands.test.tsx +4 -0
- package/src/features/chat/features/conversation/hooks/__tests__/use-session-provider-model-catalog.test.tsx +109 -0
- package/src/features/chat/features/conversation/hooks/use-chat-composer-reference-intent.ts +46 -0
- package/src/features/chat/features/conversation/hooks/use-session-conversation-composer-nodes.ts +26 -0
- package/src/features/chat/features/conversation/hooks/use-session-conversation-controller.ts +45 -12
- package/src/features/chat/features/conversation/hooks/use-session-conversation-input-query.ts +28 -3
- package/src/features/chat/features/conversation/hooks/use-session-conversation-input-state.ts +91 -37
- package/src/features/chat/features/conversation/hooks/use-session-conversation-recovery-actions.ts +64 -0
- package/src/features/chat/features/conversation/hooks/use-session-conversation-slash-commands.ts +2 -0
- package/src/features/chat/features/conversation/hooks/use-session-provider-model-catalog.ts +84 -0
- package/src/features/chat/features/conversation/utils/__tests__/session-message-composer.utils.test.ts +34 -0
- package/src/features/chat/features/conversation/utils/session-conversation-input-toolbar.utils.ts +17 -0
- package/src/features/chat/features/conversation/utils/session-message-composer.utils.ts +117 -0
- package/src/features/chat/features/conversation/utils/session-queued-input.utils.ts +10 -98
- package/src/features/chat/features/input/input-surface-plugins/__tests__/slash-command-plugin.test.ts +2 -1
- package/src/features/chat/features/input/input-surface-plugins/slash-command-plugin.utils.ts +3 -1
- package/src/features/chat/features/input/utils/__tests__/chat-composer-state.utils.test.ts +22 -1
- package/src/features/chat/features/input/utils/__tests__/chat-inline-token.utils.test.ts +23 -0
- package/src/features/chat/features/input/utils/__tests__/chat-input-bar.utils.test.ts +102 -0
- package/src/features/chat/features/input/utils/chat-composer-state.utils.ts +27 -2
- package/src/features/chat/features/input/utils/chat-composer-token-protocol.utils.ts +5 -0
- package/src/features/chat/features/input/utils/chat-inline-token.utils.ts +97 -32
- package/src/features/chat/features/input/utils/chat-input-bar.utils.ts +1 -0
- package/src/features/chat/features/input/utils/chat-input-toolbar.utils.ts +61 -10
- package/src/features/chat/features/message/components/__tests__/chat-message-assistant-header.container.test.tsx +149 -0
- package/src/features/chat/features/message/components/__tests__/chat-message-inline-editor.test.tsx +59 -0
- package/src/features/chat/features/message/components/__tests__/chat-message-list.container.test.tsx +123 -90
- package/src/features/chat/features/message/components/__tests__/chat-message-timeline-dividers.test.tsx +43 -0
- package/src/features/chat/features/message/components/chat-message-inline-editor.tsx +111 -0
- package/src/features/chat/features/message/components/chat-message-list.container.tsx +81 -172
- package/src/features/chat/features/message/components/chat-message-timeline-dividers.tsx +75 -0
- package/src/features/chat/features/message/hooks/use-chat-inline-token-actions.ts +125 -0
- package/src/features/chat/features/message/hooks/use-chat-message-actions.tsx +187 -0
- package/src/features/chat/features/message/utils/__tests__/chat-message-action-targets.utils.test.ts +89 -0
- package/src/features/chat/features/message/utils/__tests__/chat-message-timeline-compaction.utils.test.ts +194 -0
- package/src/features/chat/features/message/utils/__tests__/chat-message-timeline-continuation-compaction.utils.test.ts +167 -0
- package/src/features/chat/features/message/utils/__tests__/chat-message-timeline.utils.test.ts +175 -1
- package/src/features/chat/features/message/utils/__tests__/chat-message.utils.test.ts +26 -0
- package/src/features/chat/features/message/utils/chat-message-action-targets.utils.ts +28 -0
- package/src/features/chat/features/message/utils/chat-message-part.utils.ts +38 -0
- package/src/features/chat/features/message/utils/chat-message-texts.utils.ts +1 -0
- package/src/features/chat/features/message/utils/chat-message-timeline.utils.ts +201 -7
- package/src/features/chat/features/ncp/hooks/__tests__/use-ncp-agent-runtime.test.tsx +180 -1
- package/src/features/chat/features/ncp/hooks/__tests__/use-ncp-session-conversation.test.tsx +184 -10
- package/src/features/chat/features/ncp/hooks/use-hydrated-ncp-agent.integration.test.tsx +57 -0
- package/src/features/chat/features/ncp/hooks/use-ncp-session-conversation.ts +90 -1
- package/src/features/chat/features/ncp/utils/__tests__/ncp-chat-query-derived.utils.test.ts +110 -0
- package/src/features/chat/features/ncp/utils/ncp-chat-query-derived.utils.ts +65 -3
- package/src/features/chat/features/session/components/session-header/__tests__/chat-session-header-actions.test.tsx +17 -0
- package/src/features/chat/features/session/components/session-header/chat-session-header-actions.tsx +63 -54
- package/src/features/chat/features/session/hooks/__tests__/use-selected-session-context-window-indicator.test.tsx +87 -0
- package/src/features/chat/features/session/utils/__tests__/ncp-session-adapter.utils.test.ts +19 -0
- package/src/features/chat/features/session/utils/chat-context-window-indicator.utils.ts +44 -5
- package/src/features/chat/features/session/utils/ncp-session-adapter.utils.ts +10 -0
- package/src/features/chat/features/session/utils/ncp-session-context-metadata.utils.ts +42 -4
- package/src/features/chat/features/welcome/components/__tests__/chat-welcome.test.tsx +17 -2
- package/src/features/chat/features/welcome/components/chat-welcome-project-picker.tsx +8 -3
- package/src/features/chat/features/welcome/components/chat-welcome.tsx +2 -2
- package/src/features/chat/features/welcome/utils/__tests__/chat-welcome-project-options.utils.test.ts +22 -6
- package/src/features/chat/features/welcome/utils/chat-welcome-project-options.utils.ts +13 -0
- package/src/features/chat/features/workspace/components/__tests__/chat-session-workspace-panel-content.test.tsx +72 -2
- package/src/features/chat/features/workspace/components/__tests__/chat-session-workspace-panel.test.tsx +21 -1
- package/src/features/chat/features/workspace/components/__tests__/chat-session-workspace-text-selection.test.tsx +75 -0
- package/src/features/chat/features/workspace/components/__tests__/workspace-text-selection-menu.test.tsx +102 -0
- package/src/features/chat/features/workspace/components/chat-session-workspace-directory-browser.tsx +145 -26
- package/src/features/chat/features/workspace/components/chat-session-workspace-file-preview.tsx +42 -18
- package/src/features/chat/features/workspace/components/chat-session-workspace-panel-content.tsx +50 -10
- package/src/features/chat/features/workspace/components/chat-session-workspace-panel-nav.tsx +48 -22
- package/src/features/chat/features/workspace/components/chat-session-workspace-panel.tsx +13 -2
- package/src/features/chat/features/workspace/components/workspace-text-selection-menu.tsx +223 -0
- package/src/features/chat/features/workspace/utils/__tests__/chat-workspace-panel-view-model.utils.test.ts +80 -0
- package/src/features/chat/features/workspace/utils/__tests__/workspace-text-excerpt.utils.test.ts +54 -0
- package/src/features/chat/features/workspace/utils/chat-thread-workspace-session.utils.ts +47 -0
- package/src/features/chat/features/workspace/utils/chat-workspace-file-tab.utils.ts +16 -0
- package/src/features/chat/features/workspace/utils/chat-workspace-panel-view-model.utils.ts +22 -1
- package/src/features/chat/features/workspace/utils/workspace-text-excerpt.utils.ts +53 -0
- package/src/features/chat/index.ts +1 -0
- package/src/features/chat/managers/__tests__/chat-composer-intent.manager.test.ts +106 -0
- package/src/features/chat/managers/__tests__/chat-session-list.manager.test.ts +38 -2
- package/src/features/chat/managers/__tests__/chat-thread-workspace.manager.test.ts +93 -1
- package/src/features/chat/managers/__tests__/provider-model-catalog-notice.manager.test.ts +57 -0
- package/src/features/chat/managers/chat-composer-intent.manager.ts +145 -0
- package/src/features/chat/managers/chat-session-list.manager.ts +13 -4
- package/src/features/chat/managers/chat-thread.manager.ts +30 -11
- package/src/features/chat/managers/provider-model-catalog-notice.manager.ts +121 -0
- package/src/features/chat/presenters/chat.presenter.ts +3 -0
- package/src/features/chat/stores/__tests__/chat-composer-draft.store.test.ts +55 -0
- package/src/features/chat/stores/chat-composer-draft.store.ts +92 -0
- package/src/features/chat/stores/chat-thread.store.ts +2 -4
- package/src/features/chat/types/chat-input-bar.types.ts +5 -0
- package/src/features/chat/types/chat-input.types.ts +5 -0
- package/src/features/chat/types/chat-message.types.ts +5 -0
- package/src/features/cron/components/__tests__/cron-config.test.tsx +100 -19
- package/src/features/cron/components/cron-config.tsx +19 -33
- package/src/features/cron/components/cron-job-detail-dialog.tsx +42 -16
- package/src/features/cron/components/cron-job-row.tsx +18 -1
- package/src/features/inbox/components/inbox-delivery-content.test.tsx +8 -2
- package/src/features/inbox/components/inbox-delivery-content.tsx +1 -1
- package/src/features/inbox/components/inbox-reader-dialog.test.tsx +10 -4
- package/src/features/inbox/components/inbox-reader-dialog.tsx +37 -61
- package/src/features/inbox/pages/inbox-page.tsx +90 -98
- package/src/features/notifications/components/__tests__/app-notification-toast.test.tsx +28 -6
- package/src/features/notifications/components/app-notification-toast.tsx +54 -15
- package/src/features/notifications/managers/__tests__/app-notification.manager.test.ts +2 -0
- package/src/features/notifications/managers/app-notification.manager.ts +3 -0
- package/src/features/panel-apps/utils/panel-app-doc-browser.utils.tsx +1 -0
- package/src/features/pwa/managers/__tests__/pwa-shell-theme.manager.test.ts +9 -0
- package/src/features/pwa/managers/pwa-shell-theme.manager.ts +1 -0
- package/src/features/service-apps/components/__tests__/service-apps-panel.test.tsx +5 -4
- package/src/features/service-apps/components/service-app-list-item.tsx +470 -0
- package/src/features/service-apps/components/service-apps-panel.tsx +76 -490
- package/src/features/settings/components/config/__tests__/provider-models-section.test.tsx +239 -0
- package/src/features/settings/components/config/provider-form-detail-pane.tsx +307 -0
- package/src/features/settings/components/config/provider-form.tsx +149 -360
- package/src/features/settings/components/config/provider-model-list.tsx +293 -0
- package/src/features/settings/components/config/provider-model-suggestions-panel.tsx +151 -0
- package/src/features/settings/components/config/provider-models-section.tsx +178 -149
- package/src/features/settings/hooks/__tests__/use-provider-connectivity.test.tsx +98 -0
- package/src/features/settings/hooks/__tests__/use-provider-model-suggestions.test.tsx +107 -0
- package/src/features/settings/hooks/use-provider-connectivity.ts +132 -0
- package/src/features/settings/hooks/use-provider-model-suggestions.ts +51 -0
- package/src/features/settings/pages/__tests__/appearance-settings-page.test.tsx +2 -2
- package/src/features/settings/pages/__tests__/search-config-page.test.tsx +48 -0
- package/src/features/settings/pages/search-config-page.tsx +17 -8
- package/src/features/settings/utils/__tests__/provider-form-support.utils.test.ts +42 -0
- package/src/features/settings/utils/provider-form-context.utils.ts +2 -0
- package/src/features/settings/utils/provider-form-model.utils.ts +25 -0
- package/src/features/settings/utils/provider-form-support.utils.ts +21 -5
- package/src/index.css +1 -1
- package/src/platforms/desktop/types/desktop-update.types.ts +5 -0
- package/src/shared/components/actions/__tests__/navigation-link.test.tsx +14 -3
- package/src/shared/components/actions/navigation-link.tsx +35 -15
- package/src/shared/components/common/__tests__/agent-avatar.test.tsx +3 -2
- package/src/shared/components/common/agent-avatar.tsx +3 -3
- package/src/shared/components/doc-browser/__tests__/doc-browser.test.tsx +66 -0
- package/src/shared/components/doc-browser/doc-browser-panel-parts.tsx +4 -1
- package/src/shared/components/doc-browser/doc-browser-renderer.types.ts +1 -0
- package/src/shared/components/doc-browser/doc-browser.tsx +9 -0
- package/src/shared/components/doc-browser/hooks/use-doc-browser-scroll-restoration.ts +126 -0
- package/src/shared/components/settings/settings-page.tsx +1 -1
- package/src/shared/components/ui/context-menu/__tests__/context-menu.test.tsx +103 -0
- package/src/shared/components/ui/context-menu/context-menu.tsx +263 -0
- package/src/shared/components/ui/tab-strip/__tests__/compact-tab-strip.test.tsx +19 -6
- package/src/shared/components/ui/tab-strip/compact-tab-strip.tsx +28 -67
- package/src/shared/hooks/use-config.ts +33 -1
- package/src/shared/lib/api/__tests__/ncp-session-query-cache.utils.test.ts +26 -0
- package/src/shared/lib/api/ncp-session-query-cache.utils.ts +7 -10
- package/src/shared/lib/api/ncp-session.types.ts +6 -0
- package/src/shared/lib/api/types.ts +36 -1
- package/src/shared/lib/api/utils/config.utils.ts +14 -0
- package/src/shared/lib/cron/cron-job-view.utils.ts +4 -0
- package/src/shared/lib/host-capabilities/__tests__/host-capability.manager.test.ts +26 -0
- package/src/shared/lib/host-capabilities/host-capability.manager.ts +28 -0
- package/src/shared/lib/i18n/locales/en-US/chat.json +33 -4
- package/src/shared/lib/i18n/locales/en-US/core.json +26 -0
- package/src/shared/lib/i18n/locales/en-US/doc-browser.json +1 -0
- package/src/shared/lib/i18n/locales/en-US/search.json +1 -0
- package/src/shared/lib/i18n/locales/zh-CN/chat.json +33 -4
- package/src/shared/lib/i18n/locales/zh-CN/core.json +26 -0
- package/src/shared/lib/i18n/locales/zh-CN/doc-browser.json +1 -0
- package/src/shared/lib/i18n/locales/zh-CN/search.json +1 -0
- package/src/shared/lib/session-project/__tests__/workspace-file-breadcrumb.test.ts +28 -1
- package/src/shared/lib/session-project/workspace-file-breadcrumb.utils.ts +23 -0
- package/src/shared/lib/theme/index.test.ts +11 -0
- package/src/shared/lib/theme/index.ts +2 -0
- package/dist/assets/api-B1yHQYs-.js +0 -13
- package/dist/assets/app-presenter-provider-D3BuuOyZ.css +0 -1
- package/dist/assets/app-presenter-provider-uP9waOzv.js +0 -108
- package/dist/assets/appearance-settings-page-C9Zq3hP9.js +0 -1
- package/dist/assets/architecture-TIHT7OUA-Cii4JyA2.js +0 -1
- package/dist/assets/book-open-oSmyVXea.js +0 -1
- package/dist/assets/card-CGvJZTZp.js +0 -1
- package/dist/assets/channel-BSKkTPe8.js +0 -1
- package/dist/assets/channels-list-page-5BTxpQHw.js +0 -8
- package/dist/assets/chat-page-jTvli8Jp.js +0 -1
- package/dist/assets/chunk-2Q5K7J3B-CDMOR1xZ.js +0 -1
- package/dist/assets/chunk-VAUOI2AC-BRvqNW76.js +0 -1
- package/dist/assets/chunk-XXDRQBXY-CwX_mqJ3.js +0 -1
- package/dist/assets/classDiagram-OUVF2IWQ-RzbGxG77.js +0 -1
- package/dist/assets/classDiagram-v2-EOCWNBFH-C_gWB7WT.js +0 -1
- package/dist/assets/confirm-dialog-h849QRWO.js +0 -5
- package/dist/assets/cynefin-VYW2F7L2-fSLIS0X3.js +0 -1
- package/dist/assets/desktop-update-config-BGGHxClR.js +0 -1
- package/dist/assets/dist-CxUhurq9.js +0 -41
- package/dist/assets/doc-browser-0eL8AX42.js +0 -1
- package/dist/assets/doc-browser-DEqE9lsh.js +0 -1
- package/dist/assets/doc-browser-context-DkzFIUoK.js +0 -1
- package/dist/assets/eventmodeling-45OFAUF4-XVcQGgha.js +0 -1
- package/dist/assets/eye-gOWQGt8N.js +0 -1
- package/dist/assets/flowDiagram-23GEKE2U-BiFSctqz.js +0 -1
- package/dist/assets/gitGraph-TEB2WS4Q-C014uXqS.js +0 -1
- package/dist/assets/host-capabilities-B-TtABsP.js +0 -1
- package/dist/assets/index-DSAUWCfl.js +0 -2
- package/dist/assets/index-G7cBryJ4.css +0 -1
- package/dist/assets/info-DKCQHKI2-CQ2qjGhU.js +0 -1
- package/dist/assets/loader-circle-BAuycGf6.js +0 -1
- package/dist/assets/logo-badge-BNcsDsUM.js +0 -1
- package/dist/assets/mcp-marketplace-page-BX39MtPa.js +0 -9
- package/dist/assets/mcp-marketplace-page-CkDtOEA4.js +0 -1
- package/dist/assets/model-config-page-7MIXg2fQ.js +0 -1
- package/dist/assets/navigation-link-B3iFOdxx.js +0 -1
- package/dist/assets/packet-7NZHBO7P-6IFyydij.js +0 -1
- package/dist/assets/pie-RZYD4A2V-spXQC_wr.js +0 -1
- package/dist/assets/plus-yvhFgfal.js +0 -1
- package/dist/assets/popover-Cpep_rJe.js +0 -1
- package/dist/assets/provider-models-CUrptZ-o.js +0 -1
- package/dist/assets/provider-scoped-model-input-CHmOzz7x.js +0 -1
- package/dist/assets/providers-config-page-A6J7Y0II.js +0 -1
- package/dist/assets/radar-I7S5WNFK-DWVA8lvY.js +0 -1
- package/dist/assets/railroad-3IZDKUUU-Ce51u8y1.js +0 -1
- package/dist/assets/railroad-abnf-AHOZXSZD-D7i7cqI_.js +0 -1
- package/dist/assets/railroad-ebnf-EBAXGLYW-BEg2hcPs.js +0 -1
- package/dist/assets/railroad-peg-LSFZ7HO6-CxROSzbi.js +0 -1
- package/dist/assets/react-BCJGCjrP.js +0 -8
- package/dist/assets/remote-FD-ZfSIn.js +0 -1
- package/dist/assets/rotate-cw-DrJMfHhp.js +0 -1
- package/dist/assets/runtime-config-page-DwjO-Vs6.js +0 -1
- package/dist/assets/search-config-page-T6tMhXbP.js +0 -1
- package/dist/assets/security-config-DD5RrjDe.js +0 -1
- package/dist/assets/select-BvidP5Oa.js +0 -1
- package/dist/assets/skeleton-BEQW2Dva.js +0 -1
- package/dist/assets/stateDiagram-v2-6OUMAXLB-Bui4RXQK.js +0 -1
- package/dist/assets/swimlanesDiagram-G3AALYLV-DTwUsCBz.js +0 -8
- package/dist/assets/tabs-BeLxVmkt.js +0 -1
- package/dist/assets/trash-2-CYUskMMN.js +0 -1
- package/dist/assets/treeView-QDETBFTQ-D5zsTiuL.js +0 -1
- package/dist/assets/treemap-6X3UGDF4-CR3dxqNs.js +0 -1
- package/dist/assets/use-config-CxKRXXCl.js +0 -1
- package/dist/assets/use-confirm-dialog-HASTvOP2.js +0 -1
- package/dist/assets/use-viewport-layout-CJxkjoRz.js +0 -1
- package/dist/assets/wardley-OPB4EBWU-LatRT_Lx.js +0 -1
- package/dist/assets/x-DdUwjre5.js +0 -1
- /package/dist/assets/{array-CAkJT3no.js → array-NADKd9aU.js} +0 -0
- /package/dist/assets/{chunk-KEIR6QF5-BgdDoWEH.js → chunk-KEIR6QF5-BuyuzJJL.js} +0 -0
- /package/dist/assets/{chunk-Y2CYZVJY-pTllD0P3.js → chunk-Y2CYZVJY-D_B2ZRNt.js} +0 -0
- /package/dist/assets/{config-hints-S3g-UVZb.js → config-hints-BcfVUMij.js} +0 -0
- /package/dist/assets/{cytoscape.esm-DmURt-5G.js → cytoscape.esm-BANTlgza.js} +0 -0
- /package/dist/assets/{defaultLocale-BKy_KP3O.js → defaultLocale-C4_L0aEs.js} +0 -0
- /package/dist/assets/{dist-IgNNB7K9.js → dist-DAPEIJbz.js} +0 -0
- /package/dist/assets/{graphlib-xw_TBHyH.js → graphlib-ChqXg0dI.js} +0 -0
- /package/dist/assets/{init-C9xlLIAu.js → init-D8wZg9xq.js} +0 -0
- /package/dist/assets/{jszip.min-Das2IAnb.js → jszip.min-CkbBfwAQ.js} +0 -0
- /package/dist/assets/{katex-DSy1eD2d.js → katex-TZJFa0J_.js} +0 -0
- /package/dist/assets/{middleware-Df-a4x-q.js → middleware-B3k-TSmZ.js} +0 -0
- /package/dist/assets/{path-DB0USYHi.js → path-DodfxcX7.js} +0 -0
- /package/dist/assets/{rough.esm-B1B52ZQS.js → rough.esm-CUaa1Rbe.js} +0 -0
- /package/dist/assets/{xlsx-DfjC_iml.js → xlsx-CxByi7bR.js} +0 -0
|
@@ -8,6 +8,7 @@ import type {
|
|
|
8
8
|
DocBrowserTab,
|
|
9
9
|
} from "@/shared/components/doc-browser/doc-browser-context";
|
|
10
10
|
import { PANEL_APPS_DOC_BROWSER_RENDERERS } from "@/features/panel-apps";
|
|
11
|
+
import { PANEL_APP_SCROLL_RESTORATION_CONTRACT } from "@nextclaw/shared";
|
|
11
12
|
|
|
12
13
|
const { navigateMock } = vi.hoisted(() => ({
|
|
13
14
|
navigateMock: vi.fn(),
|
|
@@ -460,7 +461,72 @@ describe("DocBrowser", () => {
|
|
|
460
461
|
|
|
461
462
|
expect(screen.getByTitle("Local App").getAttribute("tabindex")).toBeNull();
|
|
462
463
|
});
|
|
464
|
+
});
|
|
463
465
|
|
|
466
|
+
describe("DocBrowser scroll restoration", () => {
|
|
467
|
+
beforeEach(() => {
|
|
468
|
+
resetDocBrowserTestState();
|
|
469
|
+
installDocBrowserPointerTestEnvironment();
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
it("restores the active Panel App scroll surface after refresh", () => {
|
|
473
|
+
const panelAppTab: DocBrowserTab = {
|
|
474
|
+
id: "piano",
|
|
475
|
+
kind: "panel-app" as const,
|
|
476
|
+
title: "Piano",
|
|
477
|
+
currentUrl: "/api/panel-apps/piano/content",
|
|
478
|
+
history: ["/api/panel-apps/piano/content"],
|
|
479
|
+
historyIndex: 0,
|
|
480
|
+
navVersion: 0,
|
|
481
|
+
};
|
|
482
|
+
docBrowserState.tabs = [panelAppTab];
|
|
483
|
+
docBrowserState.activeTabId = panelAppTab.id;
|
|
484
|
+
docBrowserState.currentTab = panelAppTab;
|
|
485
|
+
|
|
486
|
+
const { container } = render(<DocBrowser customTabRenderers={PANEL_APPS_DOC_BROWSER_RENDERERS} />);
|
|
487
|
+
|
|
488
|
+
const initialIframe = container.querySelector('iframe[title="Piano"]') as HTMLIFrameElement;
|
|
489
|
+
const initialWindow = {} as Window;
|
|
490
|
+
Object.defineProperty(initialIframe, "contentWindow", {
|
|
491
|
+
configurable: true,
|
|
492
|
+
value: initialWindow,
|
|
493
|
+
});
|
|
494
|
+
window.dispatchEvent(new MessageEvent("message", {
|
|
495
|
+
data: {
|
|
496
|
+
type: PANEL_APP_SCROLL_RESTORATION_CONTRACT.scrollMessageType,
|
|
497
|
+
version: PANEL_APP_SCROLL_RESTORATION_CONTRACT.version,
|
|
498
|
+
target: {
|
|
499
|
+
kind: "element",
|
|
500
|
+
path: [{ index: 0, tagName: "main" }],
|
|
501
|
+
},
|
|
502
|
+
x: 24,
|
|
503
|
+
y: 360,
|
|
504
|
+
},
|
|
505
|
+
source: initialWindow,
|
|
506
|
+
}));
|
|
507
|
+
|
|
508
|
+
fireEvent.click(screen.getByRole("button", { name: "Refresh current panel app" }));
|
|
509
|
+
|
|
510
|
+
const refreshedIframe = container.querySelector('iframe[title="Piano"]') as HTMLIFrameElement;
|
|
511
|
+
const refreshedPostMessage = vi.fn();
|
|
512
|
+
Object.defineProperty(refreshedIframe, "contentWindow", {
|
|
513
|
+
configurable: true,
|
|
514
|
+
value: { postMessage: refreshedPostMessage },
|
|
515
|
+
});
|
|
516
|
+
fireEvent.load(refreshedIframe);
|
|
517
|
+
|
|
518
|
+
expect(refreshedIframe).not.toBe(initialIframe);
|
|
519
|
+
expect(refreshedPostMessage).toHaveBeenCalledWith({
|
|
520
|
+
type: PANEL_APP_SCROLL_RESTORATION_CONTRACT.restoreScrollMessageType,
|
|
521
|
+
version: PANEL_APP_SCROLL_RESTORATION_CONTRACT.version,
|
|
522
|
+
target: {
|
|
523
|
+
kind: "element",
|
|
524
|
+
path: [{ index: 0, tagName: "main" }],
|
|
525
|
+
},
|
|
526
|
+
x: 24,
|
|
527
|
+
y: 360,
|
|
528
|
+
}, "*");
|
|
529
|
+
});
|
|
464
530
|
});
|
|
465
531
|
|
|
466
532
|
describe("DocBrowser floating interactions", () => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PointerEventHandler, ReactNode, Ref } from 'react';
|
|
1
|
+
import type { PointerEventHandler, ReactNode, Ref, ReactEventHandler } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
RefreshCw,
|
|
4
4
|
Search,
|
|
@@ -30,6 +30,7 @@ type DocBrowserFrameContentProps = {
|
|
|
30
30
|
iframeSandbox?: string;
|
|
31
31
|
isDragging: boolean;
|
|
32
32
|
isResizing: boolean;
|
|
33
|
+
onIframeLoad?: ReactEventHandler<HTMLIFrameElement>;
|
|
33
34
|
onIframePointerOver?: PointerEventHandler<HTMLIFrameElement>;
|
|
34
35
|
};
|
|
35
36
|
|
|
@@ -76,6 +77,7 @@ export function DocBrowserFrameContent({
|
|
|
76
77
|
iframeSandbox,
|
|
77
78
|
isDragging,
|
|
78
79
|
isResizing,
|
|
80
|
+
onIframeLoad,
|
|
79
81
|
onIframePointerOver,
|
|
80
82
|
}: DocBrowserFrameContentProps) {
|
|
81
83
|
return (
|
|
@@ -92,6 +94,7 @@ export function DocBrowserFrameContent({
|
|
|
92
94
|
title={currentTab?.title || 'NextClaw Docs'}
|
|
93
95
|
sandbox={iframeSandbox}
|
|
94
96
|
tabIndex={onIframePointerOver ? 0 : undefined}
|
|
97
|
+
onLoad={onIframeLoad}
|
|
95
98
|
onPointerOver={onIframePointerOver}
|
|
96
99
|
allow="clipboard-read; clipboard-write"
|
|
97
100
|
allowFullScreen
|
|
@@ -24,6 +24,7 @@ export type DocBrowserCustomTabRenderer = {
|
|
|
24
24
|
renderContent?: (params: DocBrowserCustomTabRenderParams) => ReactNode;
|
|
25
25
|
renderIcon?: (tab: DocBrowserTab) => ReactNode;
|
|
26
26
|
renderToolbar?: (params: DocBrowserCustomTabRenderParams) => ReactNode;
|
|
27
|
+
supportsScrollRestoration?: boolean;
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
export type DocBrowserCustomTabRenderers = Record<string, DocBrowserCustomTabRenderer>;
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from './doc-browser-context';
|
|
11
11
|
import { normalizeDocUrl } from './utils/doc-browser-url.utils';
|
|
12
12
|
import { DocBrowserHomePage } from './doc-browser-home-page';
|
|
13
|
+
import { useDocBrowserScrollRestoration } from './hooks/use-doc-browser-scroll-restoration';
|
|
13
14
|
import type { DocBrowserCustomTabRenderers } from './doc-browser-renderer.types';
|
|
14
15
|
import {
|
|
15
16
|
DocBrowserAddressToolbar,
|
|
@@ -200,6 +201,13 @@ export function DocBrowser({ customTabRenderers = {}, displayMode = 'desktop', d
|
|
|
200
201
|
const dockState = dockControls?.getDockState(currentTab);
|
|
201
202
|
const isContentTab = currentTab?.kind === 'content';
|
|
202
203
|
const isAddressToolbarTab = isDocsTab || isContentTab;
|
|
204
|
+
const supportsScrollRestoration = customRenderer?.supportsScrollRestoration === true;
|
|
205
|
+
const restoreScroll = useDocBrowserScrollRestoration({
|
|
206
|
+
currentTab,
|
|
207
|
+
iframeRef,
|
|
208
|
+
isEnabled: supportsScrollRestoration,
|
|
209
|
+
tabs,
|
|
210
|
+
});
|
|
203
211
|
const { handleUrlSubmit, setUrlInput, urlInput } = useDocBrowserAddressBar({
|
|
204
212
|
activeTabId,
|
|
205
213
|
currentUrl,
|
|
@@ -381,6 +389,7 @@ export function DocBrowser({ customTabRenderers = {}, displayMode = 'desktop', d
|
|
|
381
389
|
iframeSandbox={iframeSandbox}
|
|
382
390
|
isDragging={floatInteraction?.kind === 'drag'}
|
|
383
391
|
isResizing={floatInteraction?.kind === 'resize'}
|
|
392
|
+
onIframeLoad={restoreScroll}
|
|
384
393
|
onIframePointerOver={customRenderer?.onIframePointerOver}
|
|
385
394
|
/>
|
|
386
395
|
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, type RefObject } from 'react';
|
|
2
|
+
import { PANEL_APP_SCROLL_RESTORATION_CONTRACT } from '@nextclaw/shared';
|
|
3
|
+
import type { DocBrowserTab } from '@/shared/components/doc-browser/doc-browser-context';
|
|
4
|
+
|
|
5
|
+
type ScrollTarget =
|
|
6
|
+
| { kind: 'document' }
|
|
7
|
+
| { kind: 'element'; path: Array<{ index: number; tagName: string }> };
|
|
8
|
+
|
|
9
|
+
type ScrollPosition = {
|
|
10
|
+
currentUrl: string;
|
|
11
|
+
target: ScrollTarget;
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
type UseDocBrowserScrollRestorationParams = {
|
|
17
|
+
currentTab?: DocBrowserTab;
|
|
18
|
+
iframeRef: RefObject<HTMLIFrameElement | null>;
|
|
19
|
+
isEnabled: boolean;
|
|
20
|
+
tabs: DocBrowserTab[];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function isScrollTarget(value: unknown): value is ScrollTarget {
|
|
24
|
+
if (!value || typeof value !== 'object') {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
const candidate = value as Partial<ScrollTarget>;
|
|
28
|
+
if (candidate.kind === 'document') {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
return candidate.kind === 'element'
|
|
32
|
+
&& Array.isArray(candidate.path)
|
|
33
|
+
&& candidate.path.length > 0
|
|
34
|
+
&& candidate.path.length <= 30
|
|
35
|
+
&& candidate.path.every((segment) => (
|
|
36
|
+
typeof segment?.index === 'number'
|
|
37
|
+
&& Number.isInteger(segment.index)
|
|
38
|
+
&& segment.index >= 0
|
|
39
|
+
&& segment.index <= 1000
|
|
40
|
+
&& typeof segment.tagName === 'string'
|
|
41
|
+
&& segment.tagName.length > 0
|
|
42
|
+
&& segment.tagName.length <= 32
|
|
43
|
+
));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function isScrollMessage(value: unknown): value is {
|
|
47
|
+
target: ScrollTarget;
|
|
48
|
+
type: string;
|
|
49
|
+
version: number;
|
|
50
|
+
x: number;
|
|
51
|
+
y: number;
|
|
52
|
+
} {
|
|
53
|
+
if (!value || typeof value !== 'object') {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
const candidate = value as Partial<{
|
|
57
|
+
target: unknown;
|
|
58
|
+
type: string;
|
|
59
|
+
version: number;
|
|
60
|
+
x: number;
|
|
61
|
+
y: number;
|
|
62
|
+
}>;
|
|
63
|
+
return candidate.type === PANEL_APP_SCROLL_RESTORATION_CONTRACT.scrollMessageType
|
|
64
|
+
&& candidate.version === PANEL_APP_SCROLL_RESTORATION_CONTRACT.version
|
|
65
|
+
&& isScrollTarget(candidate.target)
|
|
66
|
+
&& typeof candidate.x === 'number'
|
|
67
|
+
&& Number.isFinite(candidate.x)
|
|
68
|
+
&& candidate.x >= 0
|
|
69
|
+
&& typeof candidate.y === 'number'
|
|
70
|
+
&& Number.isFinite(candidate.y)
|
|
71
|
+
&& candidate.y >= 0;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export function useDocBrowserScrollRestoration({
|
|
75
|
+
currentTab,
|
|
76
|
+
iframeRef,
|
|
77
|
+
isEnabled,
|
|
78
|
+
tabs,
|
|
79
|
+
}: UseDocBrowserScrollRestorationParams) {
|
|
80
|
+
const positionsRef = useRef(new Map<string, ScrollPosition>());
|
|
81
|
+
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
const activeTabIds = new Set(tabs.map((tab) => tab.id));
|
|
84
|
+
for (const tabId of positionsRef.current.keys()) {
|
|
85
|
+
if (!activeTabIds.has(tabId)) {
|
|
86
|
+
positionsRef.current.delete(tabId);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}, [tabs]);
|
|
90
|
+
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
if (!currentTab || !isEnabled) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const onMessage = (event: MessageEvent) => {
|
|
96
|
+
if (event.source !== iframeRef.current?.contentWindow || !isScrollMessage(event.data)) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
positionsRef.current.set(currentTab.id, {
|
|
100
|
+
currentUrl: currentTab.currentUrl,
|
|
101
|
+
target: event.data.target,
|
|
102
|
+
x: event.data.x,
|
|
103
|
+
y: event.data.y,
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
window.addEventListener('message', onMessage);
|
|
107
|
+
return () => window.removeEventListener('message', onMessage);
|
|
108
|
+
}, [currentTab, iframeRef, isEnabled]);
|
|
109
|
+
|
|
110
|
+
return useCallback(() => {
|
|
111
|
+
if (!currentTab || !isEnabled) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
const position = positionsRef.current.get(currentTab.id);
|
|
115
|
+
if (!position || position.currentUrl !== currentTab.currentUrl) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
iframeRef.current?.contentWindow?.postMessage({
|
|
119
|
+
type: PANEL_APP_SCROLL_RESTORATION_CONTRACT.restoreScrollMessageType,
|
|
120
|
+
version: PANEL_APP_SCROLL_RESTORATION_CONTRACT.version,
|
|
121
|
+
target: position.target,
|
|
122
|
+
x: position.x,
|
|
123
|
+
y: position.y,
|
|
124
|
+
}, '*');
|
|
125
|
+
}, [currentTab, iframeRef, isEnabled]);
|
|
126
|
+
}
|
|
@@ -27,7 +27,7 @@ export function SettingsPage({
|
|
|
27
27
|
className
|
|
28
28
|
)}
|
|
29
29
|
>
|
|
30
|
-
<PageHeader title={title} description={description} actions={actions}
|
|
30
|
+
<PageHeader title={title} description={description} actions={actions} />
|
|
31
31
|
{children}
|
|
32
32
|
</PageLayout>
|
|
33
33
|
);
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
|
2
|
+
import userEvent from "@testing-library/user-event";
|
|
3
|
+
import { describe, expect, it, vi } from "vitest";
|
|
4
|
+
import {
|
|
5
|
+
ContextMenu,
|
|
6
|
+
ContextMenuTrigger,
|
|
7
|
+
} from "@/shared/components/ui/context-menu/context-menu";
|
|
8
|
+
|
|
9
|
+
describe("ContextMenu", () => {
|
|
10
|
+
it("opens at the trigger and supports keyboard selection", async () => {
|
|
11
|
+
const onSelect = vi.fn();
|
|
12
|
+
render(
|
|
13
|
+
<ContextMenu
|
|
14
|
+
label="File actions"
|
|
15
|
+
groups={[
|
|
16
|
+
{
|
|
17
|
+
key: "file",
|
|
18
|
+
items: [
|
|
19
|
+
{ key: "open", label: "Open", onSelect: vi.fn() },
|
|
20
|
+
{ key: "copy", label: "Copy path", onSelect },
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
]}
|
|
24
|
+
>
|
|
25
|
+
<button type="button">README.md</button>
|
|
26
|
+
</ContextMenu>,
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
fireEvent.contextMenu(screen.getByRole("button", { name: "README.md" }), {
|
|
30
|
+
clientX: 120,
|
|
31
|
+
clientY: 80,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
expect(screen.getByRole("menu", { name: "File actions" })).toBeTruthy();
|
|
35
|
+
expect(document.activeElement).toBe(
|
|
36
|
+
screen.getByRole("menuitem", { name: "Open" }),
|
|
37
|
+
);
|
|
38
|
+
await userEvent.keyboard("{ArrowDown}{Enter}");
|
|
39
|
+
expect(onSelect).toHaveBeenCalledTimes(1);
|
|
40
|
+
expect(screen.queryByRole("menu")).toBeNull();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("opens the same menu from an explicit trigger", async () => {
|
|
44
|
+
const onSelect = vi.fn();
|
|
45
|
+
render(
|
|
46
|
+
<ContextMenu
|
|
47
|
+
label="File actions"
|
|
48
|
+
groups={[
|
|
49
|
+
{
|
|
50
|
+
key: "file",
|
|
51
|
+
items: [{ key: "add", label: "Add to chat", onSelect }],
|
|
52
|
+
},
|
|
53
|
+
]}
|
|
54
|
+
>
|
|
55
|
+
<div>
|
|
56
|
+
<span>README.md</span>
|
|
57
|
+
<ContextMenuTrigger>
|
|
58
|
+
<button type="button" aria-label="More actions" />
|
|
59
|
+
</ContextMenuTrigger>
|
|
60
|
+
</div>
|
|
61
|
+
</ContextMenu>,
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
await userEvent.click(screen.getByRole("button", { name: "More actions" }));
|
|
65
|
+
expect(screen.getByRole("menu", { name: "File actions" })).toBeTruthy();
|
|
66
|
+
await userEvent.click(screen.getByRole("menuitem", { name: "Add to chat" }));
|
|
67
|
+
|
|
68
|
+
expect(onSelect).toHaveBeenCalledTimes(1);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("does not steal focus back when an action focuses the composer", async () => {
|
|
72
|
+
render(
|
|
73
|
+
<div>
|
|
74
|
+
<button type="button" data-testid="composer">Composer</button>
|
|
75
|
+
<ContextMenu
|
|
76
|
+
label="File actions"
|
|
77
|
+
groups={[
|
|
78
|
+
{
|
|
79
|
+
key: "chat",
|
|
80
|
+
items: [
|
|
81
|
+
{
|
|
82
|
+
key: "add",
|
|
83
|
+
label: "Add to chat",
|
|
84
|
+
restoreFocus: false,
|
|
85
|
+
onSelect: () => screen.getByTestId("composer").focus(),
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
]}
|
|
90
|
+
>
|
|
91
|
+
<button type="button">README.md</button>
|
|
92
|
+
</ContextMenu>
|
|
93
|
+
</div>,
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
fireEvent.contextMenu(screen.getByRole("button", { name: "README.md" }));
|
|
97
|
+
await userEvent.click(screen.getByRole("menuitem", { name: "Add to chat" }));
|
|
98
|
+
|
|
99
|
+
await waitFor(() => {
|
|
100
|
+
expect(document.activeElement).toBe(screen.getByTestId("composer"));
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
});
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import {
|
|
2
|
+
cloneElement,
|
|
3
|
+
createContext,
|
|
4
|
+
useContext,
|
|
5
|
+
useLayoutEffect,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
type MouseEvent,
|
|
9
|
+
type ReactElement,
|
|
10
|
+
type ReactNode,
|
|
11
|
+
} from "react";
|
|
12
|
+
import { createPortal } from "react-dom";
|
|
13
|
+
import { cn } from "@/shared/lib/utils";
|
|
14
|
+
|
|
15
|
+
export type ContextMenuItem = {
|
|
16
|
+
key: string;
|
|
17
|
+
label: string;
|
|
18
|
+
icon?: ReactNode;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
restoreFocus?: boolean;
|
|
21
|
+
onSelect: () => void;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type ContextMenuGroup = {
|
|
25
|
+
key: string;
|
|
26
|
+
items: readonly ContextMenuItem[];
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type ContextMenuPosition = {
|
|
30
|
+
align: "start" | "end";
|
|
31
|
+
x: number;
|
|
32
|
+
y: number;
|
|
33
|
+
trigger: HTMLElement;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
type ContextMenuController = {
|
|
37
|
+
isOpen: boolean;
|
|
38
|
+
toggleFromButton: (trigger: HTMLElement) => void;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const ContextMenuControllerContext = createContext<ContextMenuController | null>(null);
|
|
42
|
+
|
|
43
|
+
const CONTEXT_MENU_EDGE_GAP = 8;
|
|
44
|
+
|
|
45
|
+
function ContextMenuSurface({
|
|
46
|
+
groups,
|
|
47
|
+
label,
|
|
48
|
+
onClose,
|
|
49
|
+
position,
|
|
50
|
+
}: {
|
|
51
|
+
groups: readonly ContextMenuGroup[];
|
|
52
|
+
label: string;
|
|
53
|
+
onClose: (restoreFocus: boolean) => void;
|
|
54
|
+
position: ContextMenuPosition;
|
|
55
|
+
}) {
|
|
56
|
+
const menuRef = useRef<HTMLDivElement | null>(null);
|
|
57
|
+
|
|
58
|
+
useLayoutEffect(() => {
|
|
59
|
+
const menu = menuRef.current;
|
|
60
|
+
if (!menu) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const rect = menu.getBoundingClientRect();
|
|
64
|
+
const preferredLeft = position.align === "end"
|
|
65
|
+
? position.x - rect.width
|
|
66
|
+
: position.x;
|
|
67
|
+
const left = Math.max(
|
|
68
|
+
CONTEXT_MENU_EDGE_GAP,
|
|
69
|
+
Math.min(preferredLeft, window.innerWidth - rect.width - CONTEXT_MENU_EDGE_GAP),
|
|
70
|
+
);
|
|
71
|
+
const top = Math.max(
|
|
72
|
+
CONTEXT_MENU_EDGE_GAP,
|
|
73
|
+
Math.min(position.y, window.innerHeight - rect.height - CONTEXT_MENU_EDGE_GAP),
|
|
74
|
+
);
|
|
75
|
+
menu.style.left = `${left}px`;
|
|
76
|
+
menu.style.top = `${top}px`;
|
|
77
|
+
menu.querySelector<HTMLButtonElement>('[role="menuitem"]:not(:disabled)')?.focus();
|
|
78
|
+
}, [position]);
|
|
79
|
+
|
|
80
|
+
const moveFocus = (direction: 1 | -1) => {
|
|
81
|
+
const items = Array.from(
|
|
82
|
+
menuRef.current?.querySelectorAll<HTMLButtonElement>(
|
|
83
|
+
'[role="menuitem"]:not(:disabled)',
|
|
84
|
+
) ?? [],
|
|
85
|
+
);
|
|
86
|
+
if (items.length === 0) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const currentIndex = items.indexOf(document.activeElement as HTMLButtonElement);
|
|
90
|
+
const nextIndex = currentIndex < 0
|
|
91
|
+
? 0
|
|
92
|
+
: (currentIndex + direction + items.length) % items.length;
|
|
93
|
+
items[nextIndex]?.focus();
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
return createPortal(
|
|
97
|
+
<div
|
|
98
|
+
className="fixed inset-0 z-[var(--z-tooltip)]"
|
|
99
|
+
onContextMenu={(event) => event.preventDefault()}
|
|
100
|
+
onPointerDown={() => onClose(true)}
|
|
101
|
+
>
|
|
102
|
+
<div
|
|
103
|
+
ref={menuRef}
|
|
104
|
+
role="menu"
|
|
105
|
+
aria-label={label}
|
|
106
|
+
className="fixed min-w-52 max-w-72 overflow-hidden rounded-xl border border-border bg-popover p-1 text-popover-foreground shadow-[0_18px_48px_-20px_rgba(15,23,42,0.42)]"
|
|
107
|
+
style={{ left: position.x, top: position.y }}
|
|
108
|
+
onPointerDown={(event) => event.stopPropagation()}
|
|
109
|
+
onKeyDown={(event) => {
|
|
110
|
+
if (event.key === "Escape") {
|
|
111
|
+
event.preventDefault();
|
|
112
|
+
onClose(true);
|
|
113
|
+
} else if (event.key === "ArrowDown") {
|
|
114
|
+
event.preventDefault();
|
|
115
|
+
moveFocus(1);
|
|
116
|
+
} else if (event.key === "ArrowUp") {
|
|
117
|
+
event.preventDefault();
|
|
118
|
+
moveFocus(-1);
|
|
119
|
+
} else if (event.key === "Home" || event.key === "End") {
|
|
120
|
+
event.preventDefault();
|
|
121
|
+
const items = menuRef.current?.querySelectorAll<HTMLButtonElement>(
|
|
122
|
+
'[role="menuitem"]:not(:disabled)',
|
|
123
|
+
);
|
|
124
|
+
items?.[event.key === "Home" ? 0 : items.length - 1]?.focus();
|
|
125
|
+
}
|
|
126
|
+
}}
|
|
127
|
+
>
|
|
128
|
+
{groups.map((group, groupIndex) => (
|
|
129
|
+
<div key={group.key} role="group">
|
|
130
|
+
{groupIndex > 0 ? <div className="my-1 h-px bg-border" /> : null}
|
|
131
|
+
{group.items.map((item) => (
|
|
132
|
+
<button
|
|
133
|
+
key={item.key}
|
|
134
|
+
type="button"
|
|
135
|
+
role="menuitem"
|
|
136
|
+
disabled={item.disabled}
|
|
137
|
+
className={cn(
|
|
138
|
+
"flex h-8 w-full items-center gap-2 rounded-lg px-2.5 text-left text-[13px] font-medium text-foreground outline-none transition-colors",
|
|
139
|
+
"hover:bg-muted focus-visible:bg-muted disabled:pointer-events-none disabled:opacity-45",
|
|
140
|
+
)}
|
|
141
|
+
onClick={() => {
|
|
142
|
+
item.onSelect();
|
|
143
|
+
onClose(item.restoreFocus !== false);
|
|
144
|
+
}}
|
|
145
|
+
>
|
|
146
|
+
{item.icon ? (
|
|
147
|
+
<span className="inline-flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground">
|
|
148
|
+
{item.icon}
|
|
149
|
+
</span>
|
|
150
|
+
) : null}
|
|
151
|
+
<span className="min-w-0 flex-1 truncate">{item.label}</span>
|
|
152
|
+
</button>
|
|
153
|
+
))}
|
|
154
|
+
</div>
|
|
155
|
+
))}
|
|
156
|
+
</div>
|
|
157
|
+
</div>,
|
|
158
|
+
document.body,
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export function ContextMenu({
|
|
163
|
+
children,
|
|
164
|
+
groups,
|
|
165
|
+
label,
|
|
166
|
+
}: {
|
|
167
|
+
children: ReactElement<{
|
|
168
|
+
"data-context-menu-open"?: string;
|
|
169
|
+
onContextMenu?: (event: MouseEvent) => void;
|
|
170
|
+
}>;
|
|
171
|
+
groups: readonly ContextMenuGroup[];
|
|
172
|
+
label: string;
|
|
173
|
+
}) {
|
|
174
|
+
const [position, setPosition] = useState<ContextMenuPosition | null>(null);
|
|
175
|
+
const visibleGroups = groups.filter((group) => group.items.length > 0);
|
|
176
|
+
const closeMenu = (restoreFocus: boolean) => {
|
|
177
|
+
const trigger = position?.trigger;
|
|
178
|
+
setPosition(null);
|
|
179
|
+
if (restoreFocus && trigger) {
|
|
180
|
+
window.setTimeout(() => trigger.isConnected && trigger.focus(), 0);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const toggleFromButton = (trigger: HTMLElement) => {
|
|
185
|
+
if (position?.trigger === trigger) {
|
|
186
|
+
closeMenu(true);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (visibleGroups.length === 0) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
const bounds = trigger.getBoundingClientRect();
|
|
193
|
+
setPosition({
|
|
194
|
+
align: "end",
|
|
195
|
+
x: bounds.right,
|
|
196
|
+
y: bounds.bottom,
|
|
197
|
+
trigger,
|
|
198
|
+
});
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
const child = cloneElement(children, {
|
|
202
|
+
"data-context-menu-open": position ? "" : undefined,
|
|
203
|
+
onContextMenu: (event: MouseEvent) => {
|
|
204
|
+
children.props.onContextMenu?.(event);
|
|
205
|
+
if (event.defaultPrevented || visibleGroups.length === 0) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
event.preventDefault();
|
|
209
|
+
const trigger = event.currentTarget as HTMLElement;
|
|
210
|
+
const bounds = trigger.getBoundingClientRect();
|
|
211
|
+
setPosition({
|
|
212
|
+
align: "start",
|
|
213
|
+
x: event.clientX || bounds.left,
|
|
214
|
+
y: event.clientY || bounds.bottom,
|
|
215
|
+
trigger,
|
|
216
|
+
});
|
|
217
|
+
},
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
return (
|
|
221
|
+
<ContextMenuControllerContext.Provider
|
|
222
|
+
value={{ isOpen: Boolean(position), toggleFromButton }}
|
|
223
|
+
>
|
|
224
|
+
{child}
|
|
225
|
+
{position ? (
|
|
226
|
+
<ContextMenuSurface
|
|
227
|
+
groups={visibleGroups}
|
|
228
|
+
label={label}
|
|
229
|
+
position={position}
|
|
230
|
+
onClose={closeMenu}
|
|
231
|
+
/>
|
|
232
|
+
) : null}
|
|
233
|
+
</ContextMenuControllerContext.Provider>
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export function ContextMenuTrigger({
|
|
238
|
+
children,
|
|
239
|
+
}: {
|
|
240
|
+
children: ReactElement<{
|
|
241
|
+
"aria-expanded"?: boolean;
|
|
242
|
+
"aria-haspopup"?: "menu";
|
|
243
|
+
onClick?: (event: MouseEvent) => void;
|
|
244
|
+
}>;
|
|
245
|
+
}) {
|
|
246
|
+
const controller = useContext(ContextMenuControllerContext);
|
|
247
|
+
if (!controller) {
|
|
248
|
+
throw new Error("ContextMenuTrigger must be rendered inside ContextMenu");
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return cloneElement(children, {
|
|
252
|
+
"aria-expanded": controller.isOpen,
|
|
253
|
+
"aria-haspopup": "menu",
|
|
254
|
+
onClick: (event: MouseEvent) => {
|
|
255
|
+
children.props.onClick?.(event);
|
|
256
|
+
if (event.defaultPrevented) {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
event.stopPropagation();
|
|
260
|
+
controller.toggleFromButton(event.currentTarget as HTMLElement);
|
|
261
|
+
},
|
|
262
|
+
});
|
|
263
|
+
}
|
|
@@ -141,12 +141,18 @@ describe("CompactTabStrip", () => {
|
|
|
141
141
|
label: "index.html",
|
|
142
142
|
active: true,
|
|
143
143
|
menuLabel: "File actions",
|
|
144
|
-
|
|
144
|
+
menuGroups: [
|
|
145
145
|
{
|
|
146
|
-
key: "
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
146
|
+
key: "file",
|
|
147
|
+
items: [
|
|
148
|
+
{
|
|
149
|
+
key: "preview",
|
|
150
|
+
icon: <span />,
|
|
151
|
+
label: "Open preview",
|
|
152
|
+
restoreFocus: false,
|
|
153
|
+
onSelect: onAction,
|
|
154
|
+
},
|
|
155
|
+
],
|
|
150
156
|
},
|
|
151
157
|
],
|
|
152
158
|
onSelect,
|
|
@@ -160,7 +166,14 @@ describe("CompactTabStrip", () => {
|
|
|
160
166
|
await user.click(menuTrigger);
|
|
161
167
|
await user.click(screen.getByRole("menuitem", { name: "Open preview" }));
|
|
162
168
|
|
|
163
|
-
|
|
169
|
+
const tabItem = screen
|
|
170
|
+
.getByRole("button", { name: "index.html" })
|
|
171
|
+
.closest("[data-compact-tab-item]");
|
|
172
|
+
expect(tabItem).not.toBeNull();
|
|
173
|
+
fireEvent.contextMenu(tabItem!);
|
|
174
|
+
await user.click(screen.getByRole("menuitem", { name: "Open preview" }));
|
|
175
|
+
|
|
176
|
+
expect(onAction).toHaveBeenCalledTimes(2);
|
|
164
177
|
expect(onSelect).not.toHaveBeenCalled();
|
|
165
178
|
expect(document.activeElement).not.toBe(menuTrigger);
|
|
166
179
|
});
|