@flamingo-stack/openframe-frontend-core 0.0.816 → 0.0.817
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/dist/build/export-map.json +1 -1
- package/dist/{case-study-card-NLT2JVI7.cjs → case-study-card-IZBMHA6R.cjs} +3 -3
- package/dist/{chunk-7ERD34HQ.cjs → chunk-24M2JYM5.cjs} +566 -774
- package/dist/{chunk-3E4FIJAM.cjs → chunk-4ROR52OW.cjs} +15 -15
- package/dist/{chunk-SWBLTIN4.cjs → chunk-5TSYOIIZ.cjs} +54 -52
- package/dist/{chunk-JH65CEO4.cjs → chunk-6F4YGHGM.cjs} +36 -36
- package/dist/{chunk-VDXI26G7.cjs → chunk-7KBHLP4E.cjs} +81 -78
- package/dist/{chunk-CNTBGJA7.cjs → chunk-A34UNP5V.cjs} +65 -1
- package/dist/{chunk-633NTKO2.cjs → chunk-BL2J5RJK.cjs} +31 -53
- package/dist/{chunk-7NYWHEQM.cjs → chunk-C2OUXL3Q.cjs} +15 -15
- package/dist/{chunk-53JJLHJM.cjs → chunk-DSBRWP5M.cjs} +20 -20
- package/dist/chunk-DVHSYPDB.cjs +471 -0
- package/dist/{chunk-5TUR7O7H.cjs → chunk-EX7M3VQC.cjs} +90 -90
- package/dist/{chunk-EJCUAADF.cjs → chunk-F2LVBRHC.cjs} +4 -4
- package/dist/{chunk-GAR2IIU6.cjs → chunk-IM366HS6.cjs} +105 -157
- package/dist/{chunk-FUEK43FL.cjs → chunk-IOFIHVVW.cjs} +206 -200
- package/dist/{chunk-JOOZTRXQ.cjs → chunk-JMOCM2SW.cjs} +4 -4
- package/dist/{chunk-PAI4A3UM.cjs → chunk-K5IICQNF.cjs} +61 -54
- package/dist/{chunk-JOKOQOLJ.cjs → chunk-LUID2IB3.cjs} +2 -2
- package/dist/{chunk-L7W4455K.cjs → chunk-MAHJY2PO.cjs} +3 -3
- package/dist/{chunk-4PMD3JUC.cjs → chunk-NPNZAAOB.cjs} +2 -2
- package/dist/{chunk-EB7YAUER.cjs → chunk-P7JQGOX4.cjs} +19 -19
- package/dist/{chunk-O6VWD2SB.cjs → chunk-RDHF3F5R.cjs} +3 -3
- package/dist/{chunk-HM7VCQSX.cjs → chunk-SBFBNOKU.cjs} +4 -4
- package/dist/{chunk-7O7EX7HQ.cjs → chunk-T266OITJ.cjs} +28 -20
- package/dist/{chunk-ZAWHRYJZ.cjs → chunk-TKEYWSDZ.cjs} +45 -45
- package/dist/{chunk-F4ZJRMMM.cjs → chunk-UDLDXVY4.cjs} +8 -8
- package/dist/{chunk-Y6MJMPHV.cjs → chunk-UEULXVW2.cjs} +32 -84
- package/dist/{chunk-RYJJHSHV.cjs → chunk-UFBVOBYR.cjs} +23 -23
- package/dist/{chunk-IKB6AZPV.cjs → chunk-ZECG6GU5.cjs} +2 -2
- package/dist/{chunk-3ELDGEM2.cjs → chunk-ZP4JMX7G.cjs} +87 -84
- package/dist/{cloud-tenants-SRTX2FZC.cjs → cloud-tenants-NMAXIJLL.cjs} +11 -11
- package/dist/components/announcement-bar.d.ts.map +1 -1
- package/dist/components/announcement-bar.js +5 -5
- package/dist/components/case-studies/index.cjs +26 -26
- package/dist/components/chat/chat-markdown-link.d.ts +15 -0
- package/dist/components/chat/chat-markdown-link.d.ts.map +1 -0
- package/dist/components/chat/chat-markdown-link.js +22 -0
- package/dist/components/chat/chat-message-enhanced.d.ts.map +1 -1
- package/dist/components/chat/chat-message-enhanced.js +3 -9
- package/dist/components/chat/embeddable-chat.d.ts +4 -0
- package/dist/components/chat/embeddable-chat.d.ts.map +1 -1
- package/dist/components/chat/embeddable-chat.js +30 -67
- package/dist/components/chat/entity-cards/chat-card-disclosure.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/chat-card-disclosure.js +8 -11
- package/dist/components/chat/entity-cards/dispatch.d.ts +5 -5
- package/dist/components/chat/entity-cards/dispatch.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/dispatch.js +18 -17
- package/dist/components/chat/entity-cards/github-activity-card.d.ts +1 -1
- package/dist/components/chat/entity-cards/use-entity-card-link.d.ts +3 -2
- package/dist/components/chat/entity-cards/use-entity-card-link.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/use-entity-card-link.js +6 -4
- package/dist/components/chat/index.cjs +28 -21
- package/dist/components/chat/index.d.ts +2 -2
- package/dist/components/chat/index.d.ts.map +1 -1
- package/dist/components/chat/index.js +4 -3
- package/dist/components/chat/{inline-app-link-chip.d.ts → inline-chip.d.ts} +1 -14
- package/dist/components/chat/inline-chip.d.ts.map +1 -0
- package/dist/components/chat/inline-chip.js +27 -0
- package/dist/components/chat/nav-link-anchor-via-runtime.d.ts +45 -11
- package/dist/components/chat/nav-link-anchor-via-runtime.d.ts.map +1 -1
- package/dist/components/chat/nav-link-anchor-via-runtime.js +32 -24
- package/dist/components/chat/source-action-button.d.ts +12 -3
- package/dist/components/chat/source-action-button.d.ts.map +1 -1
- package/dist/components/chat/source-action-button.js +41 -26
- package/dist/components/chat/types/component.types.d.ts +1 -1
- package/dist/components/chat/types/message.types.d.ts +1 -1
- package/dist/components/chat/types/message.types.d.ts.map +1 -1
- package/dist/components/chat/utils/chat-nav-resolution.d.ts +1 -6
- package/dist/components/chat/utils/chat-nav-resolution.d.ts.map +1 -1
- package/dist/components/chat/utils/chat-nav-resolution.js +2 -3
- package/dist/components/chat/utils/decide-new-tab.d.ts +0 -3
- package/dist/components/chat/utils/decide-new-tab.d.ts.map +1 -1
- package/dist/components/chat/utils/decide-new-tab.js +0 -1
- package/dist/components/chat/utils/execute-navigation.d.ts +36 -34
- package/dist/components/chat/utils/execute-navigation.d.ts.map +1 -1
- package/dist/components/chat/utils/execute-navigation.js +23 -19
- package/dist/components/chat/utils/index.d.ts +5 -5
- package/dist/components/chat/utils/index.d.ts.map +1 -1
- package/dist/components/chat/utils/index.js +14 -6
- package/dist/components/chat/utils/nav-anchor-props.d.ts +35 -8
- package/dist/components/chat/utils/nav-anchor-props.d.ts.map +1 -1
- package/dist/components/chat/utils/nav-anchor-props.js +14 -5
- package/dist/components/chat/utils/new-tab-rel.d.ts +15 -0
- package/dist/components/chat/utils/new-tab-rel.d.ts.map +1 -0
- package/dist/components/chat/utils/new-tab-rel.js +25 -0
- package/dist/components/contact/index.cjs +12 -12
- package/dist/components/docs/index.cjs +15 -15
- package/dist/components/embeds/index.cjs +12 -12
- package/dist/components/faq/index.cjs +13 -13
- package/dist/components/features/devices/devices-table-columns.d.ts.map +1 -1
- package/dist/components/features/devices/devices-table-columns.js +4 -1
- package/dist/components/features/index.cjs +11 -11
- package/dist/components/help-center-pages/index.cjs +105 -105
- package/dist/components/index.cjs +91 -83
- package/dist/components/meeting-scheduler/index.cjs +50 -50
- package/dist/components/navigation/app-header.d.ts +1 -4
- package/dist/components/navigation/app-header.d.ts.map +1 -1
- package/dist/components/navigation/app-header.js +0 -2
- package/dist/components/navigation/index.cjs +14 -14
- package/dist/components/navigation/ticket-alerts-button.d.ts +1 -4
- package/dist/components/navigation/ticket-alerts-button.d.ts.map +1 -1
- package/dist/components/navigation/ticket-alerts-button.js +5 -5
- package/dist/components/onboarding-guides/index.cjs +14 -14
- package/dist/components/product-demo/index.cjs +20 -20
- package/dist/components/related-content/card-registry.d.ts +1 -1
- package/dist/components/related-content/index.cjs +7 -7
- package/dist/components/related-content/related-content-section.d.ts +3 -3
- package/dist/components/related-content/related-content-section.d.ts.map +1 -1
- package/dist/components/related-content/related-content-section.js +5 -3
- package/dist/components/shared/doc-search/resolve-search-result-action.d.ts +10 -3
- package/dist/components/shared/doc-search/resolve-search-result-action.d.ts.map +1 -1
- package/dist/components/shared/doc-search/resolve-search-result-action.js +8 -17
- package/dist/components/shared/doc-search/use-doc-search.d.ts.map +1 -1
- package/dist/components/shared/doc-search/use-doc-search.js +15 -27
- package/dist/components/shared/product-release/product-release-card.d.ts +2 -2
- package/dist/components/shared/product-release/product-releases-view.d.ts.map +1 -1
- package/dist/components/shared/product-release/product-releases-view.js +1 -3
- package/dist/components/tickets/index.cjs +18 -18
- package/dist/components/tickets/ticket-detail-drawer.d.ts.map +1 -1
- package/dist/components/tickets/ticket-detail-drawer.js +6 -3
- package/dist/components/tickets/types.d.ts +1 -1
- package/dist/components/ui/button/button.d.ts +1 -1
- package/dist/components/ui/hover-dropdown.d.ts +2 -2
- package/dist/components/ui/index.cjs +31 -23
- package/dist/components/ui/service-card.d.ts.map +1 -1
- package/dist/components/ui/service-card.js +4 -1
- package/dist/components/vendor-display-button.d.ts.map +1 -1
- package/dist/components/vendor-display-button.js +4 -1
- package/dist/contexts/chat-runtime-context.d.ts +11 -11
- package/dist/contexts/chat-runtime-context.d.ts.map +1 -1
- package/dist/{devices-DL4YU64N.cjs → devices-QBKWVHE6.cjs} +12 -12
- package/dist/{embeddable-chat-YRKMPFDY.cjs → embeddable-chat-WNPCPMDL.cjs} +96 -137
- package/dist/hooks/index.cjs +5 -5
- package/dist/hooks/use-contact-submission.d.ts.map +1 -1
- package/dist/hooks/use-contact-submission.js +11 -8
- package/dist/index.cjs +40 -34
- package/dist/{knowledge-VQW5JL2Z.cjs → knowledge-FSAYWM25.cjs} +12 -12
- package/dist/{logs-IY3WBLMW.cjs → logs-OZX4SYHG.cjs} +19 -19
- package/dist/{policies-IXWTWMJO.cjs → policies-LPCUCTLX.cjs} +15 -15
- package/dist/{scripts-D5CLO5EG.cjs → scripts-ZNFZSONW.cjs} +16 -16
- package/dist/{software-update-ULNP6CKJ.cjs → software-update-BRYOVQVY.cjs} +14 -14
- package/dist/utils/index.cjs +116 -89
- package/dist/utils/open-in-new-tab.d.ts +2 -1
- package/dist/utils/open-in-new-tab.d.ts.map +1 -1
- package/dist/utils/open-in-new-tab.js +2 -1
- package/dist/utils/scroll-into-view.d.ts +1 -1
- package/eslint-config/base.js +11 -0
- package/eslint-config/navigation.js +142 -0
- package/package.json +1 -1
- package/src/components/announcement-bar.tsx +8 -6
- package/src/components/chat/chat-markdown-link.tsx +42 -0
- package/src/components/chat/chat-message-enhanced.tsx +10 -36
- package/src/components/chat/embeddable-chat.tsx +63 -106
- package/src/components/chat/entity-cards/chat-card-disclosure.tsx +9 -13
- package/src/components/chat/entity-cards/dispatch.tsx +45 -35
- package/src/components/chat/entity-cards/github-activity-card.tsx +1 -1
- package/src/components/chat/entity-cards/use-entity-card-link.ts +11 -16
- package/src/components/chat/index.ts +3 -1
- package/src/components/chat/{inline-app-link-chip.tsx → inline-chip.tsx} +1 -27
- package/src/components/chat/nav-link-anchor-via-runtime.tsx +73 -33
- package/src/components/chat/source-action-button.tsx +57 -33
- package/src/components/chat/types/component.types.ts +1 -1
- package/src/components/chat/types/message.types.ts +1 -1
- package/src/components/chat/utils/chat-nav-resolution.ts +3 -8
- package/src/components/chat/utils/decide-new-tab.ts +0 -3
- package/src/components/chat/utils/execute-navigation.ts +58 -58
- package/src/components/chat/utils/index.ts +13 -6
- package/src/components/chat/utils/nav-anchor-props.ts +56 -9
- package/src/components/chat/utils/new-tab-rel.ts +39 -0
- package/src/components/features/devices/devices-table-columns.tsx +4 -1
- package/src/components/navigation/app-header.tsx +0 -5
- package/src/components/navigation/ticket-alerts-button.tsx +7 -8
- package/src/components/related-content/card-registry.tsx +1 -1
- package/src/components/related-content/related-content-section.tsx +10 -10
- package/src/components/shared/doc-search/resolve-search-result-action.ts +19 -33
- package/src/components/shared/doc-search/use-doc-search.ts +21 -44
- package/src/components/shared/product-release/product-release-card.tsx +4 -4
- package/src/components/shared/product-release/product-releases-view.tsx +2 -5
- package/src/components/tickets/ticket-detail-drawer.tsx +7 -4
- package/src/components/tickets/types.ts +1 -1
- package/src/components/ui/button/button.tsx +2 -2
- package/src/components/ui/hover-dropdown.tsx +2 -2
- package/src/components/ui/service-card.tsx +4 -1
- package/src/components/vendor-display-button.tsx +5 -2
- package/src/contexts/chat-runtime-context.tsx +15 -12
- package/src/hooks/use-contact-submission.ts +13 -8
- package/src/utils/index.ts +1 -1
- package/src/utils/open-in-new-tab.ts +4 -2
- package/src/utils/scroll-into-view.ts +1 -1
- package/dist/chunk-RD66AGUI.cjs +0 -156
- package/dist/components/chat/inline-app-link-chip.d.ts.map +0 -1
- package/dist/components/chat/inline-app-link-chip.js +0 -37
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Lib-portable refactor of the hub's `components/shared/entity-card-dispatch.tsx`.
|
|
7
7
|
* Drops the hub-only imports:
|
|
8
|
-
* - `
|
|
8
|
+
* - `useNavLinkViaRuntime` → click routing flows through `<NavLinkAnchorViaRuntime>`
|
|
9
9
|
* (reads `useRequiredChatRuntime` internally) or
|
|
10
|
-
* the chat-runtime's `
|
|
10
|
+
* the chat-runtime's `executeNavigation` helper.
|
|
11
11
|
* - `currentPlatform` → runtime.source supplies the identifier.
|
|
12
12
|
* - `buildContentURL` → URLs arrive pre-composed by the server's
|
|
13
13
|
* RAG mapper (`ref.url`); the card just renders.
|
|
@@ -33,7 +33,6 @@ import type React from 'react';
|
|
|
33
33
|
import type { ReactNode } from 'react';
|
|
34
34
|
import { useRequiredChatRuntime } from '../../../contexts/chat-runtime-context';
|
|
35
35
|
import Image from '../../../embed-shims/next-image';
|
|
36
|
-
import { useRouter } from '../../../embed-shims/next-navigation';
|
|
37
36
|
import { IMAGE_FIXED_PX } from '../../../styles/image-sizes';
|
|
38
37
|
import type { DesignDoc } from '../../../types/design-doc';
|
|
39
38
|
import {
|
|
@@ -100,10 +99,10 @@ import { formatInvestorUpdatePeriod } from '../types/entities/investor-update';
|
|
|
100
99
|
import type { BaseProgramItem, ProgramConfig } from '../types/entities/program-types';
|
|
101
100
|
import { getStatusColorScheme } from '../utils/agent-status-message';
|
|
102
101
|
import { resolveCardDestination } from '../utils/card-destination';
|
|
103
|
-
import { resolveHrefForRuntime } from '../utils/chat-nav-resolution';
|
|
104
102
|
import { executeNavigation } from '../utils/execute-navigation';
|
|
105
103
|
import { clickupTaskUrl } from '../utils/external-app-urls';
|
|
106
|
-
import {
|
|
104
|
+
import { buildAnchorProps, navLinkTarget } from '../utils/nav-anchor-props';
|
|
105
|
+
import { isRelativeHref } from '../utils/new-tab-rel';
|
|
107
106
|
import { readFetchedCardTitle } from '../utils/resolve-fetched-card-href';
|
|
108
107
|
import { resolveSourceIcon, sourceRowCtxFromRuntime } from '../utils/source-row-cta';
|
|
109
108
|
import { BlockCard } from './block-card';
|
|
@@ -251,7 +250,7 @@ export interface ChatCardRenderOptions {
|
|
|
251
250
|
/** Pre-computed new-tab decision for the inner anchor's `target`
|
|
252
251
|
* attribute. Required — always computed by `ChatCardLoader` via the
|
|
253
252
|
* same rule source chips use, so the rendered `<a target>` matches
|
|
254
|
-
* whatever `ChatCardNavWrap` + `
|
|
253
|
+
* whatever `ChatCardNavWrap` + `executeNavigation` decide at click
|
|
255
254
|
* time. */
|
|
256
255
|
isNewTab: boolean;
|
|
257
256
|
/** Host-provided "Ask Mingo"/"Display" affordance for this card, resolved
|
|
@@ -264,9 +263,9 @@ export interface ChatCardRenderOptions {
|
|
|
264
263
|
// =============================================================================
|
|
265
264
|
// Per-type "no-fetch" wrapper components (ChatRef carries everything).
|
|
266
265
|
// Each wrapper receives `isNewTab` as a prop — `ChatCardLoader` computes
|
|
267
|
-
// it ONCE via `
|
|
268
|
-
// threads it through `renderOpts`. Wrappers must NOT
|
|
269
|
-
//
|
|
266
|
+
// it ONCE via `navLinkTarget` against the resolved `chatRef.url` and
|
|
267
|
+
// threads it through `renderOpts`. Wrappers must NOT decide
|
|
268
|
+
// themselves; the parent's decision is the single
|
|
270
269
|
// source of truth for the rendered `<a target>` AND `ChatCardNavWrap`'s
|
|
271
270
|
// close-on-nav gate.
|
|
272
271
|
// =============================================================================
|
|
@@ -333,7 +332,7 @@ function GitHubChatCard({
|
|
|
333
332
|
description={description}
|
|
334
333
|
icon={githubKindIcon(kind)}
|
|
335
334
|
status={status}
|
|
336
|
-
anchorProps={buildAnchorProps(chatRef.url, isNewTab)}
|
|
335
|
+
anchorProps={buildAnchorProps(chatRef.url, isNewTab, chatRef.targetPlatform)}
|
|
337
336
|
menuGroups={cardMenuGroups(chatRef.url, discuss)}
|
|
338
337
|
menuAriaLabel="Activity actions"
|
|
339
338
|
/>
|
|
@@ -539,7 +538,7 @@ function HubspotTicketChatCard({
|
|
|
539
538
|
description={chatRef.preview ?? undefined}
|
|
540
539
|
icon={<TagIcon size={24} />}
|
|
541
540
|
status={statusText ? { label: statusText, variant: hubspotStatusToVariant(status) } : undefined}
|
|
542
|
-
anchorProps={buildAnchorProps(chatRef.url, isNewTab)}
|
|
541
|
+
anchorProps={buildAnchorProps(chatRef.url, isNewTab, chatRef.targetPlatform)}
|
|
543
542
|
menuGroups={cardMenuGroups(chatRef.url, discuss, {
|
|
544
543
|
label: 'Open Ticket Details',
|
|
545
544
|
icon: <TagIcon size={20} />,
|
|
@@ -572,7 +571,7 @@ function FaqChatCard({
|
|
|
572
571
|
description={chatRef.preview ?? undefined}
|
|
573
572
|
icon={<QuestionCircleIcon size={24} />}
|
|
574
573
|
status={{ label: statusLabel, variant: 'grey' }}
|
|
575
|
-
anchorProps={buildAnchorProps(chatRef.url, isNewTab)}
|
|
574
|
+
anchorProps={buildAnchorProps(chatRef.url, isNewTab, chatRef.targetPlatform)}
|
|
576
575
|
menuGroups={cardMenuGroups(chatRef.url, discuss)}
|
|
577
576
|
menuAriaLabel="FAQ actions"
|
|
578
577
|
/>
|
|
@@ -599,7 +598,7 @@ function SlackChatCard({
|
|
|
599
598
|
title={title}
|
|
600
599
|
description={chatRef.preview ?? undefined}
|
|
601
600
|
icon={<SlackLogoGreyIcon size={24} />}
|
|
602
|
-
anchorProps={buildAnchorProps(chatRef.url, isNewTab)}
|
|
601
|
+
anchorProps={buildAnchorProps(chatRef.url, isNewTab, chatRef.targetPlatform)}
|
|
603
602
|
menuGroups={cardMenuGroups(chatRef.url, discuss)}
|
|
604
603
|
menuAriaLabel="Message actions"
|
|
605
604
|
/>
|
|
@@ -627,7 +626,7 @@ function GlyphChatCard({
|
|
|
627
626
|
title={chatRef.title}
|
|
628
627
|
description={chatRef.preview ?? undefined}
|
|
629
628
|
icon={icon}
|
|
630
|
-
anchorProps={buildAnchorProps(chatRef.url, isNewTab)}
|
|
629
|
+
anchorProps={buildAnchorProps(chatRef.url, isNewTab, chatRef.targetPlatform)}
|
|
631
630
|
menuGroups={cardMenuGroups(chatRef.url, discuss)}
|
|
632
631
|
menuAriaLabel="Card actions"
|
|
633
632
|
/>
|
|
@@ -672,7 +671,7 @@ function TrustCenterChatCard({
|
|
|
672
671
|
description={summary || TRUST_CENTER_TAGLINE}
|
|
673
672
|
icon={<ShieldCheckIcon size={24} />}
|
|
674
673
|
status={lead ? { label: lead.label, variant: TRUST_STATUS_TAG_VARIANT[lead.color] } : undefined}
|
|
675
|
-
anchorProps={buildAnchorProps(chatRef.url, isNewTab)}
|
|
674
|
+
anchorProps={buildAnchorProps(chatRef.url, isNewTab, chatRef.targetPlatform)}
|
|
676
675
|
menuGroups={cardMenuGroups(chatRef.url, discuss, {
|
|
677
676
|
label: 'View trust center',
|
|
678
677
|
icon: <ShieldCheckIcon size={20} />,
|
|
@@ -703,7 +702,7 @@ function DataRoomDocChatCard({
|
|
|
703
702
|
description={chatRef.preview ?? undefined}
|
|
704
703
|
icon={<FileContentIcon size={24} />}
|
|
705
704
|
status={{ label: badgeText, variant: 'grey' }}
|
|
706
|
-
anchorProps={buildAnchorProps(chatRef.url, isNewTab)}
|
|
705
|
+
anchorProps={buildAnchorProps(chatRef.url, isNewTab, chatRef.targetPlatform)}
|
|
707
706
|
menuGroups={cardMenuGroups(chatRef.url, discuss)}
|
|
708
707
|
menuAriaLabel="Document actions"
|
|
709
708
|
/>
|
|
@@ -727,7 +726,7 @@ function GenericFinancialChatCard({
|
|
|
727
726
|
title={chatRef.title}
|
|
728
727
|
description={subtitle}
|
|
729
728
|
icon={icon}
|
|
730
|
-
anchorProps={buildAnchorProps(chatRef.url, isNewTab)}
|
|
729
|
+
anchorProps={buildAnchorProps(chatRef.url, isNewTab, chatRef.targetPlatform)}
|
|
731
730
|
menuGroups={cardMenuGroups(chatRef.url, discuss)}
|
|
732
731
|
menuAriaLabel="Document actions"
|
|
733
732
|
/>
|
|
@@ -920,7 +919,7 @@ function EntityMingoCard({
|
|
|
920
919
|
imageAlt={typeof title === 'string' ? title : undefined}
|
|
921
920
|
icon={fallbackIcon}
|
|
922
921
|
status={status}
|
|
923
|
-
anchorProps={buildAnchorProps(chatRef.url, isNewTab)}
|
|
922
|
+
anchorProps={buildAnchorProps(chatRef.url, isNewTab, chatRef.targetPlatform)}
|
|
924
923
|
menuGroups={cardMenuGroups(chatRef.url, discuss, openDetails, externalLink)}
|
|
925
924
|
menuAriaLabel={menuAriaLabel}
|
|
926
925
|
/>
|
|
@@ -1081,7 +1080,7 @@ function DesignDocChatCard({
|
|
|
1081
1080
|
? { label: readiness.label, variant: readiness.scheme === 'success' ? 'success' : 'grey' }
|
|
1082
1081
|
: { label: 'Design doc', variant: 'grey' }
|
|
1083
1082
|
}
|
|
1084
|
-
anchorProps={buildAnchorProps(displayRef.url, isNewTab)}
|
|
1083
|
+
anchorProps={buildAnchorProps(displayRef.url, isNewTab, displayRef.targetPlatform)}
|
|
1085
1084
|
menuGroups={cardMenuGroups(displayRef.url, discuss)}
|
|
1086
1085
|
menuAriaLabel="Design doc actions"
|
|
1087
1086
|
/>
|
|
@@ -1324,7 +1323,7 @@ interface ChatCardRegistryEntry {
|
|
|
1324
1323
|
* for ChatRef-shaped items). Result is validated via `safeHref`
|
|
1325
1324
|
* before being attached to the resolved ref — so the wrapper sees a
|
|
1326
1325
|
* non-null `href`, the pre-computed `isNewTab` reflects the actual
|
|
1327
|
-
* destination, and the click goes through `
|
|
1326
|
+
* destination, and the click goes through `executeNavigation` (no
|
|
1328
1327
|
* silent bypass of embed-mode / close-on-nav). Takes precedence over
|
|
1329
1328
|
* the `composeContentUrl` fallback below — but NOT over an explicit
|
|
1330
1329
|
* host `override` for the type (see `pickFetchedCardHref`). */
|
|
@@ -1905,20 +1904,20 @@ export function chatCardLabel(docType: string): string | undefined {
|
|
|
1905
1904
|
// card body provides its own `<a href={absolute}>` (per the
|
|
1906
1905
|
// pure-presentation contract) — this wrapper intercepts the primary
|
|
1907
1906
|
// click via `onClickCapture` BEFORE the browser's default navigation
|
|
1908
|
-
// fires, and routes through `
|
|
1907
|
+
// fires, and routes through `executeNavigation` to apply runtime nav
|
|
1909
1908
|
// rules (embed-mode `window.open` / cross-platform new-tab / host
|
|
1910
1909
|
// `runtime.navigation.navigate`). Modifier / non-primary clicks pass
|
|
1911
|
-
// through (`
|
|
1910
|
+
// through (`executeNavigation` returns early so the browser opens
|
|
1912
1911
|
// the inner anchor's href naturally).
|
|
1913
1912
|
//
|
|
1914
|
-
// Same click model as source chips — chips use `<a onClick={
|
|
1915
|
-
// directly; cards use `<span onClickCapture={→
|
|
1916
|
-
// the card's own anchor. Both ultimately call `
|
|
1913
|
+
// Same click model as source chips — chips use `<a onClick={executeNavigation}>`
|
|
1914
|
+
// directly; cards use `<span onClickCapture={→executeNavigation}>` outside
|
|
1915
|
+
// the card's own anchor. Both ultimately call `executeNavigation` with
|
|
1917
1916
|
// the same `{href, targetPlatform}` resolved at `ChatCardLoader` via
|
|
1918
1917
|
// `resolveSourceRowCTA`. The unification:
|
|
1919
1918
|
// - Same URL composition (`resolveSourceRowCTA`)
|
|
1920
|
-
// - Same
|
|
1921
|
-
// - Same click router (`
|
|
1919
|
+
// - Same navigation decision (`navLinkTarget`)
|
|
1920
|
+
// - Same click router (`executeNavigation`)
|
|
1922
1921
|
// - Same conditional close (`ChatPanelContext.closeChat` on same-tab only)
|
|
1923
1922
|
// =============================================================================
|
|
1924
1923
|
|
|
@@ -1930,7 +1929,7 @@ export function chatCardLabel(docType: string): string | undefined {
|
|
|
1930
1929
|
* new-tab decision applied (via `opts.isNewTab` from ChatCardLoader).
|
|
1931
1930
|
*
|
|
1932
1931
|
* Job:
|
|
1933
|
-
* - PRIMARY clicks → preventDefault + route through `
|
|
1932
|
+
* - PRIMARY clicks → preventDefault + route through `executeNavigation`
|
|
1934
1933
|
* - Modifier-clicks → pass through to the browser's native handling
|
|
1935
1934
|
* - Same-tab nav → close the chat panel (so the panel doesn't linger
|
|
1936
1935
|
* over the now-current-page content). New-tab nav leaves it open.
|
|
@@ -1945,13 +1944,14 @@ function ChatCardNavWrap({
|
|
|
1945
1944
|
path,
|
|
1946
1945
|
targetPlatform,
|
|
1947
1946
|
isNewTab,
|
|
1947
|
+
hostRoute,
|
|
1948
1948
|
children,
|
|
1949
1949
|
}: {
|
|
1950
1950
|
href: string | null;
|
|
1951
1951
|
/** In-app doc-tree path for `markdown` / `data_room_doc` refs. The
|
|
1952
1952
|
* runtime's `navigate({path})` opportunistically swaps the active
|
|
1953
1953
|
* documentation section without a full page nav; null for everything
|
|
1954
|
-
* else. Threaded straight through to `
|
|
1954
|
+
* else. Threaded straight through to `executeNavigation` so chips
|
|
1955
1955
|
* and inline cards apply the same routing rule. */
|
|
1956
1956
|
path: string | null;
|
|
1957
1957
|
targetPlatform: string | null;
|
|
@@ -1959,10 +1959,12 @@ function ChatCardNavWrap({
|
|
|
1959
1959
|
* same value the card's `<a target>` already renders with.
|
|
1960
1960
|
* Consumed here ONLY to decide whether to close the panel. */
|
|
1961
1961
|
isNewTab: boolean;
|
|
1962
|
+
/** `href` is the host's own relative route (see `navLinkTarget`), handed to the executor so the click decides as
|
|
1963
|
+
* the render did. */
|
|
1964
|
+
hostRoute: boolean;
|
|
1962
1965
|
children: ReactNode;
|
|
1963
1966
|
}) {
|
|
1964
1967
|
const runtime = useRequiredChatRuntime();
|
|
1965
|
-
const router = useRouter();
|
|
1966
1968
|
const panel = useChatPanel();
|
|
1967
1969
|
const onClickCapture = (e: React.MouseEvent<HTMLElement>) => {
|
|
1968
1970
|
if (!href) return;
|
|
@@ -1987,7 +1989,7 @@ function ChatCardNavWrap({
|
|
|
1987
1989
|
if (targetEl?.closest?.('button')) return;
|
|
1988
1990
|
if (!targetEl?.closest?.('a')) return;
|
|
1989
1991
|
|
|
1990
|
-
const handled = executeNavigation({ event: e, runtime, href, path, targetPlatform,
|
|
1992
|
+
const handled = executeNavigation({ event: e, runtime, href, path, targetPlatform, hostRoute });
|
|
1991
1993
|
if (!handled) return;
|
|
1992
1994
|
// Modifier-clicks fall through (handled=false) without stopPropagation
|
|
1993
1995
|
// so ancestor telemetry handlers still see the bubble.
|
|
@@ -2055,7 +2057,7 @@ function CardWithDisclosure({
|
|
|
2055
2057
|
* - Re-attach the resolved values onto the ref so EVERY downstream
|
|
2056
2058
|
* card — whether it renders an inner `<a>` from `href` prop
|
|
2057
2059
|
* (BlogCard, ProgramCard, …) or pulls `anchorProps` from
|
|
2058
|
-
* `
|
|
2060
|
+
* `navLinkTarget` — sees the SAME canonical URL the
|
|
2059
2061
|
* chip would render.
|
|
2060
2062
|
*
|
|
2061
2063
|
* Eliminates the entire "chip works, inline card doesn't" class of bug.
|
|
@@ -2092,7 +2094,7 @@ export function ChatCardLoader({
|
|
|
2092
2094
|
entry: fetchEntry,
|
|
2093
2095
|
ctx: sourceRowCtxFromRuntime(runtime, { baseRoute, chipBasePlatform }),
|
|
2094
2096
|
composeContentUrl: runtime.composeContentUrl,
|
|
2095
|
-
resolveHref: href =>
|
|
2097
|
+
resolveHref: href => navLinkTarget(runtime, href).href,
|
|
2096
2098
|
});
|
|
2097
2099
|
const hrefResolvedChatRef: ChatRef = {
|
|
2098
2100
|
...chatRef,
|
|
@@ -2117,8 +2119,15 @@ export function ChatCardLoader({
|
|
|
2117
2119
|
// Pre-compute new-tab decision ONCE here (the same rule chips use).
|
|
2118
2120
|
// Render branches that pass `target` / `rel` to their card pull this
|
|
2119
2121
|
// via `renderOpts.isNewTab` so the inner `<a>` agrees with the
|
|
2120
|
-
// runtime nav decision in `ChatCardNavWrap` + `
|
|
2121
|
-
|
|
2122
|
+
// runtime nav decision in `ChatCardNavWrap` + `executeNavigation`.
|
|
2123
|
+
// A url the host composed (`composed`, `hostOverride`) as a relative route of its own is the host's page.
|
|
2124
|
+
const hostRoute =
|
|
2125
|
+
(destination.source === 'composed' || destination.source === 'hostOverride') &&
|
|
2126
|
+
!!finalChatRef.url &&
|
|
2127
|
+
isRelativeHref(finalChatRef.url);
|
|
2128
|
+
const isNewTab = finalChatRef.url
|
|
2129
|
+
? navLinkTarget(runtime, finalChatRef.url, finalChatRef.targetPlatform, { hostRoute }).isNewTab
|
|
2130
|
+
: false;
|
|
2122
2131
|
|
|
2123
2132
|
// Resolve the "Ask Mingo"/"Display" affordance ONCE — same precedence as the
|
|
2124
2133
|
// legacy `ChatCardWithDiscuss` (displayAction + onDisplay → "Display",
|
|
@@ -2153,6 +2162,7 @@ export function ChatCardLoader({
|
|
|
2153
2162
|
path={path}
|
|
2154
2163
|
targetPlatform={finalChatRef.targetPlatform ?? null}
|
|
2155
2164
|
isNewTab={isNewTab}
|
|
2165
|
+
hostRoute={hostRoute}
|
|
2156
2166
|
>
|
|
2157
2167
|
{children}
|
|
2158
2168
|
</ChatCardNavWrap>
|
|
@@ -182,7 +182,7 @@ export interface GitHubActivityCardProps {
|
|
|
182
182
|
item: GitHubActivityItem;
|
|
183
183
|
variant?: 'row' | 'compact';
|
|
184
184
|
className?: string;
|
|
185
|
-
/** Pre-composed `<Link>` prop bundle (typically from a `
|
|
185
|
+
/** Pre-composed `<Link>` prop bundle (typically from a `useNavLinkViaRuntime` hook in
|
|
186
186
|
* the consumer). When provided, the outer renders as a real `<Link>`. */
|
|
187
187
|
anchorProps?: GitHubActivityCardAnchorProps;
|
|
188
188
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Pure-presentation cards (BlogCard, OnboardingGuideCard, etc.)
|
|
7
7
|
* historically required callers to pre-compute `target`/`rel` via a
|
|
8
|
-
*
|
|
8
|
+
* `useNavLinkViaRuntime` because the same-tab-vs-new-tab
|
|
9
9
|
* decision depends on `currentPlatform()` and the cross-platform
|
|
10
10
|
* URL topology — neither of which the lib knows.
|
|
11
11
|
*
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
|
|
26
26
|
import { useMemo } from 'react';
|
|
27
27
|
import { useChatRuntime } from '../../../contexts/chat-runtime-context';
|
|
28
|
-
import {
|
|
28
|
+
import { navLinkTarget, newTabAnchorAttrs } from '../utils/nav-anchor-props';
|
|
29
|
+
import { type NewTabRel, newTabRel } from '../utils/new-tab-rel';
|
|
29
30
|
|
|
30
31
|
export interface UseEntityCardLinkArgs {
|
|
31
32
|
href: string;
|
|
@@ -33,12 +34,12 @@ export interface UseEntityCardLinkArgs {
|
|
|
33
34
|
/** Explicit override. When set, runtime decision is skipped. */
|
|
34
35
|
target?: '_blank';
|
|
35
36
|
/** Explicit override. When set, runtime decision is skipped. */
|
|
36
|
-
rel?:
|
|
37
|
+
rel?: NewTabRel;
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
export interface EntityCardLinkProps {
|
|
40
41
|
target: '_blank' | undefined;
|
|
41
|
-
rel:
|
|
42
|
+
rel: NewTabRel | undefined;
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
export function useEntityCardLink({ href, targetPlatform, target, rel }: UseEntityCardLinkArgs): EntityCardLinkProps {
|
|
@@ -50,19 +51,13 @@ export function useEntityCardLink({ href, targetPlatform, target, rel }: UseEnti
|
|
|
50
51
|
// to close the tabnabbing vector (window.opener access from the
|
|
51
52
|
// new tab back to the parent).
|
|
52
53
|
if (target !== undefined || rel !== undefined) {
|
|
53
|
-
const safeRel = rel ?? (target === '_blank' ?
|
|
54
|
+
const safeRel = rel ?? (target === '_blank' ? newTabRel(href, targetPlatform) : undefined);
|
|
54
55
|
return { target, rel: safeRel };
|
|
55
56
|
}
|
|
56
|
-
//
|
|
57
|
-
// agrees with the click
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
// clicked into a new tab). Hub behavior is unchanged: it wires decideNewTab,
|
|
62
|
-
// which computeIsNewTab consumes identically.
|
|
63
|
-
const newTab = runtime ? computeIsNewTab(runtime, href, targetPlatform ?? null) : false;
|
|
64
|
-
return newTab
|
|
65
|
-
? { target: '_blank' as const, rel: 'noopener noreferrer' as const }
|
|
66
|
-
: { target: undefined, rel: undefined };
|
|
57
|
+
// THE navigation decision (`navLinkTarget`), the one the click handler executes by, so the rendered anchor's
|
|
58
|
+
// target/rel always agrees with the click; `rel` is the one referrer rule.
|
|
59
|
+
const resolved = navLinkTarget(runtime, href, targetPlatform);
|
|
60
|
+
const attrs = newTabAnchorAttrs(resolved.isNewTab, resolved.href, targetPlatform);
|
|
61
|
+
return { target: attrs.target, rel: attrs.rel };
|
|
67
62
|
}, [target, rel, href, targetPlatform, runtime]);
|
|
68
63
|
}
|
|
@@ -70,6 +70,8 @@ export {
|
|
|
70
70
|
type NavLinkAnchorViaRuntimeProps,
|
|
71
71
|
type NavLinkViaRuntimeInput,
|
|
72
72
|
type NavLinkViaRuntimeProps,
|
|
73
|
+
type NavigateViaRuntimeInput,
|
|
74
|
+
useNavigateViaRuntime,
|
|
73
75
|
useNavLinkViaRuntime,
|
|
74
76
|
} from './nav-link-anchor-via-runtime';
|
|
75
77
|
export { SourceActionButton, type SourceActionButtonProps, type SourceActionDensity } from './source-action-button';
|
|
@@ -145,4 +147,4 @@ export {
|
|
|
145
147
|
ASK_AI_TRIGGER_ATTRIBUTE,
|
|
146
148
|
} from './utils/ask-ai-events';
|
|
147
149
|
export * from './proxy-credentials-panel';
|
|
148
|
-
export {
|
|
150
|
+
export { InlineChip } from './inline-chip';
|
|
@@ -12,9 +12,7 @@
|
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import type React from 'react';
|
|
15
|
-
import Link from '../../embed-shims/next-link';
|
|
16
15
|
import { cn } from '../../utils/cn';
|
|
17
|
-
import { BrowserWindowIcon } from '../icons-v2-generated/coding/browser-window-icon';
|
|
18
16
|
import { Tag } from '../ui/tag';
|
|
19
17
|
|
|
20
18
|
/**
|
|
@@ -49,31 +47,7 @@ export function InlineChip({
|
|
|
49
47
|
label={label}
|
|
50
48
|
loading={loading}
|
|
51
49
|
className={cn(INLINE_CHIP_CLASS, className)}
|
|
50
|
+
data-testid="inline-chip"
|
|
52
51
|
/>
|
|
53
52
|
);
|
|
54
53
|
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* A link that stays in this app (the runtime's `computeIsNewTab` keeps it in this window), drawn as an inline box. `anchor` is the host's link element (its
|
|
58
|
-
* `NavLinkAnchor`, so the click follows the host's routing rule), else the lib's boxed `Link`.
|
|
59
|
-
*/
|
|
60
|
-
export function InlineAppLinkChip({
|
|
61
|
-
href,
|
|
62
|
-
children,
|
|
63
|
-
anchor: Anchor,
|
|
64
|
-
}: {
|
|
65
|
-
href: string;
|
|
66
|
-
children: React.ReactNode;
|
|
67
|
-
anchor?: React.ComponentType<{ href: string; className?: string; children?: React.ReactNode }>;
|
|
68
|
-
}): React.ReactElement {
|
|
69
|
-
const chip = <InlineChip icon={<BrowserWindowIcon />} label={children} className="hover:bg-ods-bg-hover" />;
|
|
70
|
-
return Anchor ? (
|
|
71
|
-
<Anchor href={href} className="no-underline">
|
|
72
|
-
{chip}
|
|
73
|
-
</Anchor>
|
|
74
|
-
) : (
|
|
75
|
-
<Link href={href} className="no-underline">
|
|
76
|
-
{chip}
|
|
77
|
-
</Link>
|
|
78
|
-
);
|
|
79
|
-
}
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
* source-chip drill-ins, inline references).
|
|
6
6
|
*
|
|
7
7
|
* Reads the active `ChatRuntime` and routes clicks through
|
|
8
|
-
* `
|
|
8
|
+
* `executeNavigation`. Same single-source rules as source chips and
|
|
9
9
|
* inline cards:
|
|
10
|
-
* - new-tab decision via `
|
|
11
|
-
*
|
|
10
|
+
* - new-tab decision via `navLinkTarget` (the embed rule, then the host's
|
|
11
|
+
* `runtime.navigation.decideNewTab` when it wires one, else the lib's rule)
|
|
12
12
|
* - `target` / `rel` via `newTabAnchorAttrs`
|
|
13
13
|
* - same-tab click → close the chat panel (via `ChatPanelContext`);
|
|
14
14
|
* new-tab click → leave panel open while the new tab loads
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
* plain anchor attributes (`aria-*`, `title`, `data-*`, `style`, `rel`).
|
|
26
26
|
*/
|
|
27
27
|
|
|
28
|
-
import type
|
|
28
|
+
import { type AnchorHTMLAttributes, type MouseEvent, type ReactNode, useCallback } from 'react';
|
|
29
29
|
import { useRequiredChatRuntime } from '../../contexts/chat-runtime-context';
|
|
30
|
-
import { useRouter } from '../../embed-shims/next-navigation';
|
|
31
30
|
import { useChatPanel } from './chat-panel-context';
|
|
32
|
-
import {
|
|
33
|
-
import { executeNavigation } from './utils/execute-navigation';
|
|
34
|
-
import {
|
|
31
|
+
import { isModifierClick } from './utils/chat-nav-resolution';
|
|
32
|
+
import { executeNavigation, executeNavigationImperative, executeNewTabNavigation } from './utils/execute-navigation';
|
|
33
|
+
import { type NavLinkTarget, type NavOpenIn, navLinkTarget, newTabAnchorAttrs } from './utils/nav-anchor-props';
|
|
34
|
+
import type { NewTabRel } from './utils/new-tab-rel';
|
|
35
35
|
|
|
36
36
|
export interface NavLinkAnchorViaRuntimeProps extends Omit<
|
|
37
37
|
AnchorHTMLAttributes<HTMLAnchorElement>,
|
|
@@ -40,6 +40,8 @@ export interface NavLinkAnchorViaRuntimeProps extends Omit<
|
|
|
40
40
|
href: string;
|
|
41
41
|
path?: string | null;
|
|
42
42
|
targetPlatform?: string | null;
|
|
43
|
+
/** The caller's explicit tab (an "open in new tab" control); absent = the rule decides. */
|
|
44
|
+
openIn?: NavOpenIn;
|
|
43
45
|
className?: string;
|
|
44
46
|
/** Optional — matches `NavLinkAnchorComponent`'s contract so the
|
|
45
47
|
* markdown-anchor slot can render an empty anchor (rare but legal). */
|
|
@@ -49,10 +51,14 @@ export interface NavLinkAnchorViaRuntimeProps extends Omit<
|
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
export interface NavLinkViaRuntimeInput {
|
|
52
|
-
|
|
54
|
+
/** The destination. A string always gets a link (as before); `null` / `undefined` means there is none and the hook
|
|
55
|
+
* returns null, so the caller draws no link. */
|
|
56
|
+
href: string | null | undefined;
|
|
53
57
|
path?: string | null;
|
|
54
58
|
/** The platform that owns `href`, by name. */
|
|
55
59
|
targetPlatform?: string | null;
|
|
60
|
+
/** The caller's explicit tab (an admin preview always opens a new one); absent = the rule decides. */
|
|
61
|
+
openIn?: NavOpenIn;
|
|
56
62
|
/** Runs before the navigation; `preventDefault()` cancels it. */
|
|
57
63
|
onClick?: (event: MouseEvent<HTMLAnchorElement>) => void;
|
|
58
64
|
}
|
|
@@ -60,63 +66,97 @@ export interface NavLinkViaRuntimeInput {
|
|
|
60
66
|
export interface NavLinkViaRuntimeProps {
|
|
61
67
|
href: string;
|
|
62
68
|
target?: '_blank';
|
|
63
|
-
rel?:
|
|
69
|
+
rel?: NewTabRel;
|
|
64
70
|
onClick: (event: MouseEvent<HTMLAnchorElement>) => void;
|
|
65
71
|
}
|
|
66
72
|
|
|
73
|
+
/** The navigation decision ({@link navLinkTarget}) for a link rendered inside the chat runtime. */
|
|
74
|
+
export function useNavLinkTarget(href: string, targetPlatform?: string | null, openIn?: NavOpenIn): NavLinkTarget {
|
|
75
|
+
return navLinkTarget(useRequiredChatRuntime(), href, targetPlatform, { openIn });
|
|
76
|
+
}
|
|
77
|
+
|
|
67
78
|
/**
|
|
68
79
|
* The anchor props of {@link NavLinkAnchorViaRuntime}, for an element that is
|
|
69
80
|
* not a bare `<a>` (a `Button`'s `linkProps`). ONE decision and ONE click
|
|
70
81
|
* handler for both forms.
|
|
71
82
|
*
|
|
72
|
-
* A new-tab link to
|
|
73
|
-
*
|
|
74
|
-
* it); any other new-tab link also gets `noreferrer`.
|
|
83
|
+
* A new-tab link to one of our own sites keeps the Referer (`newTabRel`: the
|
|
84
|
+
* cross-domain analytics attribute the visit by it); any other gets `noreferrer`.
|
|
75
85
|
*/
|
|
86
|
+
export function useNavLinkViaRuntime(input: NavLinkViaRuntimeInput & { href: string }): NavLinkViaRuntimeProps;
|
|
87
|
+
export function useNavLinkViaRuntime(input: NavLinkViaRuntimeInput): NavLinkViaRuntimeProps | null;
|
|
76
88
|
export function useNavLinkViaRuntime({
|
|
77
89
|
href,
|
|
78
90
|
path,
|
|
79
91
|
targetPlatform,
|
|
92
|
+
openIn,
|
|
80
93
|
onClick: onClickProp,
|
|
81
|
-
}: NavLinkViaRuntimeInput): NavLinkViaRuntimeProps {
|
|
94
|
+
}: NavLinkViaRuntimeInput): NavLinkViaRuntimeProps | null {
|
|
82
95
|
const runtime = useRequiredChatRuntime();
|
|
83
|
-
const router = useRouter();
|
|
84
96
|
const panel = useChatPanel();
|
|
85
|
-
const resolvedHref =
|
|
86
|
-
|
|
97
|
+
const { href: resolvedHref, isNewTab } = useNavLinkTarget(href ?? '', targetPlatform, openIn);
|
|
98
|
+
if (href == null) return null;
|
|
87
99
|
|
|
88
100
|
const onClick = (e: MouseEvent<HTMLAnchorElement>) => {
|
|
89
101
|
onClickProp?.(e);
|
|
90
102
|
if (e.defaultPrevented) return;
|
|
91
|
-
const handled = executeNavigation({
|
|
92
|
-
event: e,
|
|
93
|
-
runtime,
|
|
94
|
-
href: resolvedHref,
|
|
95
|
-
path,
|
|
96
|
-
targetPlatform,
|
|
97
|
-
fallbackNavigate: router.push,
|
|
98
|
-
});
|
|
103
|
+
const handled = executeNavigation({ event: e, runtime, href: resolvedHref, path, targetPlatform, openIn });
|
|
99
104
|
if (handled && !isNewTab && panel?.closeChat) panel.closeChat();
|
|
100
105
|
};
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
return { href: resolvedHref, ...newTabAnchorAttrs(isNewTab, resolvedHref, targetPlatform), onClick };
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** What {@link useNavigateViaRuntime}'s function is told to follow. */
|
|
110
|
+
export interface NavigateViaRuntimeInput {
|
|
111
|
+
href: string | null | undefined;
|
|
112
|
+
path?: string | null;
|
|
113
|
+
/** The platform that owns `href`, by name. */
|
|
114
|
+
targetPlatform?: string | null;
|
|
115
|
+
/** The caller's explicit tab; absent = the rule decides. */
|
|
116
|
+
openIn?: NavOpenIn;
|
|
117
|
+
/** The click that asked, when there was one: a modifier click or a middle click opens a new tab, as on a link. */
|
|
118
|
+
modifierEvent?: {
|
|
119
|
+
button?: number;
|
|
120
|
+
metaKey?: boolean;
|
|
121
|
+
ctrlKey?: boolean;
|
|
122
|
+
shiftKey?: boolean;
|
|
123
|
+
altKey?: boolean;
|
|
124
|
+
} | null;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Follow a link from code (a button, a card's click, a redirect after a save): the same decision and the same executor
|
|
129
|
+
* as {@link useNavLinkViaRuntime}, for an element that is not an anchor.
|
|
130
|
+
*/
|
|
131
|
+
export function useNavigateViaRuntime(): (input: NavigateViaRuntimeInput) => void {
|
|
132
|
+
const runtime = useRequiredChatRuntime();
|
|
133
|
+
return useCallback(
|
|
134
|
+
({ href, path, targetPlatform, openIn, modifierEvent }: NavigateViaRuntimeInput) => {
|
|
135
|
+
if (!href) return;
|
|
136
|
+
if (modifierEvent && isModifierClick(modifierEvent)) {
|
|
137
|
+
// Not an anchor, so the browser opens nothing itself: a modifier or middle click asks for a new tab, as it
|
|
138
|
+
// does on a link. Another button (a right click) navigates nowhere.
|
|
139
|
+
const button = modifierEvent.button ?? 0;
|
|
140
|
+
if (button === 0 || button === 1) executeNewTabNavigation({ runtime, href, targetPlatform });
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
executeNavigationImperative({ runtime, href, path, targetPlatform, openIn });
|
|
144
|
+
},
|
|
145
|
+
[runtime],
|
|
146
|
+
);
|
|
108
147
|
}
|
|
109
148
|
|
|
110
149
|
export function NavLinkAnchorViaRuntime({
|
|
111
150
|
href,
|
|
112
151
|
path,
|
|
113
152
|
targetPlatform,
|
|
153
|
+
openIn,
|
|
114
154
|
className,
|
|
115
155
|
children,
|
|
116
156
|
onClick,
|
|
117
157
|
...anchorAttrs
|
|
118
158
|
}: NavLinkAnchorViaRuntimeProps) {
|
|
119
|
-
const linkProps = useNavLinkViaRuntime({ href, path, targetPlatform, onClick });
|
|
159
|
+
const linkProps = useNavLinkViaRuntime({ href, path, targetPlatform, openIn, onClick });
|
|
120
160
|
return (
|
|
121
161
|
<a {...linkProps} {...anchorAttrs} className={className}>
|
|
122
162
|
{children}
|