@flamingo-stack/openframe-frontend-core 0.0.816 → 0.0.818
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-VDXI26G7.cjs → chunk-4XASD2TL.cjs} +81 -78
- package/dist/{chunk-5TUR7O7H.cjs → chunk-5AIOYEXW.cjs} +90 -90
- package/dist/{chunk-RYJJHSHV.cjs → chunk-5VRSUEC5.cjs} +23 -23
- package/dist/{chunk-633NTKO2.cjs → chunk-6QT5K5I5.cjs} +31 -53
- package/dist/{chunk-CNTBGJA7.cjs → chunk-A34UNP5V.cjs} +65 -1
- package/dist/{chunk-3ELDGEM2.cjs → chunk-AE22KOW3.cjs} +87 -84
- package/dist/{chunk-EJCUAADF.cjs → chunk-BD42NMCT.cjs} +4 -4
- package/dist/{chunk-7NYWHEQM.cjs → chunk-DGAX5WG2.cjs} +15 -15
- package/dist/{chunk-L7W4455K.cjs → chunk-DL4HWYIB.cjs} +3 -3
- package/dist/chunk-DVHSYPDB.cjs +471 -0
- package/dist/{chunk-GAR2IIU6.cjs → chunk-IM366HS6.cjs} +105 -157
- package/dist/{chunk-7ERD34HQ.cjs → chunk-IQCHV7Z2.cjs} +571 -823
- package/dist/{chunk-3E4FIJAM.cjs → chunk-JTBJB4JF.cjs} +15 -15
- package/dist/{chunk-PAI4A3UM.cjs → chunk-K5IICQNF.cjs} +61 -54
- package/dist/{chunk-JOKOQOLJ.cjs → chunk-LUID2IB3.cjs} +2 -2
- package/dist/{chunk-JOOZTRXQ.cjs → chunk-NEXMK6OP.cjs} +4 -4
- package/dist/{chunk-4PMD3JUC.cjs → chunk-NPNZAAOB.cjs} +2 -2
- package/dist/{chunk-JH65CEO4.cjs → chunk-NWIEZUM7.cjs} +36 -36
- package/dist/{chunk-HM7VCQSX.cjs → chunk-SBFBNOKU.cjs} +4 -4
- package/dist/{chunk-7O7EX7HQ.cjs → chunk-T266OITJ.cjs} +28 -20
- package/dist/{chunk-SWBLTIN4.cjs → chunk-U2THWP25.cjs} +54 -52
- package/dist/{chunk-F4ZJRMMM.cjs → chunk-UDLDXVY4.cjs} +8 -8
- package/dist/{chunk-Y6MJMPHV.cjs → chunk-UEULXVW2.cjs} +32 -84
- package/dist/{chunk-O6VWD2SB.cjs → chunk-VGZXB3SY.cjs} +3 -3
- package/dist/{chunk-ZAWHRYJZ.cjs → chunk-VRXDTRIY.cjs} +45 -45
- package/dist/{chunk-EB7YAUER.cjs → chunk-YHPUD4PM.cjs} +19 -19
- package/dist/{chunk-FUEK43FL.cjs → chunk-YMPPE322.cjs} +206 -200
- package/dist/{chunk-IKB6AZPV.cjs → chunk-ZECG6GU5.cjs} +2 -2
- package/dist/{chunk-53JJLHJM.cjs → chunk-ZWAVMZIF.cjs} +20 -20
- package/dist/{cloud-tenants-SRTX2FZC.cjs → cloud-tenants-V6EV4OGK.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 -8
- package/dist/components/chat/embeddable-chat.d.ts.map +1 -1
- package/dist/components/chat/embeddable-chat.js +31 -125
- 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 +8 -15
- package/dist/components/chat/entity-cards/dispatch.d.ts.map +1 -1
- package/dist/components/chat/entity-cards/dispatch.js +22 -40
- 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/entities/data-room-doc.d.ts +0 -12
- package/dist/components/chat/types/entities/data-room-doc.d.ts.map +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/chat/utils/source-row-cta.d.ts +9 -48
- package/dist/components/chat/utils/source-row-cta.d.ts.map +1 -1
- package/dist/components/chat/utils/source-row-cta.js +7 -32
- 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 +14 -25
- package/dist/contexts/chat-runtime-context.d.ts.map +1 -1
- package/dist/{devices-DL4YU64N.cjs → devices-6KZAJAAS.cjs} +12 -12
- package/dist/{embeddable-chat-YRKMPFDY.cjs → embeddable-chat-5IHA5SUZ.cjs} +95 -193
- 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-I7FDQQYJ.cjs} +12 -12
- package/dist/{logs-IY3WBLMW.cjs → logs-Q7PAVJUG.cjs} +19 -19
- package/dist/{policies-IXWTWMJO.cjs → policies-C3DW5CHS.cjs} +15 -15
- package/dist/{scripts-D5CLO5EG.cjs → scripts-BET663HD.cjs} +16 -16
- package/dist/{software-update-ULNP6CKJ.cjs → software-update-W7ZQXEPK.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/dist/utils/source-grouping.d.ts +2 -2
- 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 +66 -173
- package/src/components/chat/entity-cards/chat-card-disclosure.tsx +9 -13
- package/src/components/chat/entity-cards/data-room-doc-card.tsx +1 -1
- package/src/components/chat/entity-cards/dispatch.tsx +51 -66
- 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/entities/data-room-doc.ts +0 -12
- 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/chat/utils/source-row-cta.ts +21 -102
- 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 +18 -23
- 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/src/utils/source-grouping.ts +2 -2
- 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';
|
|
@@ -242,8 +241,6 @@ export interface ChatCardDispatchExtras {
|
|
|
242
241
|
|
|
243
242
|
/** Per-card render options threaded through from the chat shell. */
|
|
244
243
|
export interface ChatCardRenderOptions {
|
|
245
|
-
baseRoute?: string;
|
|
246
|
-
chipBasePlatform?: string;
|
|
247
244
|
/** Host-supplied builders for cards whose derived props live in hub
|
|
248
245
|
* land (programs + product_release). When omitted, these card types
|
|
249
246
|
* render `null` and the shell falls back to title text. */
|
|
@@ -251,7 +248,7 @@ export interface ChatCardRenderOptions {
|
|
|
251
248
|
/** Pre-computed new-tab decision for the inner anchor's `target`
|
|
252
249
|
* attribute. Required — always computed by `ChatCardLoader` via the
|
|
253
250
|
* same rule source chips use, so the rendered `<a target>` matches
|
|
254
|
-
* whatever `ChatCardNavWrap` + `
|
|
251
|
+
* whatever `ChatCardNavWrap` + `executeNavigation` decide at click
|
|
255
252
|
* time. */
|
|
256
253
|
isNewTab: boolean;
|
|
257
254
|
/** Host-provided "Ask Mingo"/"Display" affordance for this card, resolved
|
|
@@ -264,9 +261,9 @@ export interface ChatCardRenderOptions {
|
|
|
264
261
|
// =============================================================================
|
|
265
262
|
// Per-type "no-fetch" wrapper components (ChatRef carries everything).
|
|
266
263
|
// Each wrapper receives `isNewTab` as a prop — `ChatCardLoader` computes
|
|
267
|
-
// it ONCE via `
|
|
268
|
-
// threads it through `renderOpts`. Wrappers must NOT
|
|
269
|
-
//
|
|
264
|
+
// it ONCE via `navLinkTarget` against the resolved `chatRef.url` and
|
|
265
|
+
// threads it through `renderOpts`. Wrappers must NOT decide
|
|
266
|
+
// themselves; the parent's decision is the single
|
|
270
267
|
// source of truth for the rendered `<a target>` AND `ChatCardNavWrap`'s
|
|
271
268
|
// close-on-nav gate.
|
|
272
269
|
// =============================================================================
|
|
@@ -333,7 +330,7 @@ function GitHubChatCard({
|
|
|
333
330
|
description={description}
|
|
334
331
|
icon={githubKindIcon(kind)}
|
|
335
332
|
status={status}
|
|
336
|
-
anchorProps={buildAnchorProps(chatRef.url, isNewTab)}
|
|
333
|
+
anchorProps={buildAnchorProps(chatRef.url, isNewTab, chatRef.targetPlatform)}
|
|
337
334
|
menuGroups={cardMenuGroups(chatRef.url, discuss)}
|
|
338
335
|
menuAriaLabel="Activity actions"
|
|
339
336
|
/>
|
|
@@ -539,7 +536,7 @@ function HubspotTicketChatCard({
|
|
|
539
536
|
description={chatRef.preview ?? undefined}
|
|
540
537
|
icon={<TagIcon size={24} />}
|
|
541
538
|
status={statusText ? { label: statusText, variant: hubspotStatusToVariant(status) } : undefined}
|
|
542
|
-
anchorProps={buildAnchorProps(chatRef.url, isNewTab)}
|
|
539
|
+
anchorProps={buildAnchorProps(chatRef.url, isNewTab, chatRef.targetPlatform)}
|
|
543
540
|
menuGroups={cardMenuGroups(chatRef.url, discuss, {
|
|
544
541
|
label: 'Open Ticket Details',
|
|
545
542
|
icon: <TagIcon size={20} />,
|
|
@@ -572,7 +569,7 @@ function FaqChatCard({
|
|
|
572
569
|
description={chatRef.preview ?? undefined}
|
|
573
570
|
icon={<QuestionCircleIcon size={24} />}
|
|
574
571
|
status={{ label: statusLabel, variant: 'grey' }}
|
|
575
|
-
anchorProps={buildAnchorProps(chatRef.url, isNewTab)}
|
|
572
|
+
anchorProps={buildAnchorProps(chatRef.url, isNewTab, chatRef.targetPlatform)}
|
|
576
573
|
menuGroups={cardMenuGroups(chatRef.url, discuss)}
|
|
577
574
|
menuAriaLabel="FAQ actions"
|
|
578
575
|
/>
|
|
@@ -599,7 +596,7 @@ function SlackChatCard({
|
|
|
599
596
|
title={title}
|
|
600
597
|
description={chatRef.preview ?? undefined}
|
|
601
598
|
icon={<SlackLogoGreyIcon size={24} />}
|
|
602
|
-
anchorProps={buildAnchorProps(chatRef.url, isNewTab)}
|
|
599
|
+
anchorProps={buildAnchorProps(chatRef.url, isNewTab, chatRef.targetPlatform)}
|
|
603
600
|
menuGroups={cardMenuGroups(chatRef.url, discuss)}
|
|
604
601
|
menuAriaLabel="Message actions"
|
|
605
602
|
/>
|
|
@@ -627,7 +624,7 @@ function GlyphChatCard({
|
|
|
627
624
|
title={chatRef.title}
|
|
628
625
|
description={chatRef.preview ?? undefined}
|
|
629
626
|
icon={icon}
|
|
630
|
-
anchorProps={buildAnchorProps(chatRef.url, isNewTab)}
|
|
627
|
+
anchorProps={buildAnchorProps(chatRef.url, isNewTab, chatRef.targetPlatform)}
|
|
631
628
|
menuGroups={cardMenuGroups(chatRef.url, discuss)}
|
|
632
629
|
menuAriaLabel="Card actions"
|
|
633
630
|
/>
|
|
@@ -672,7 +669,7 @@ function TrustCenterChatCard({
|
|
|
672
669
|
description={summary || TRUST_CENTER_TAGLINE}
|
|
673
670
|
icon={<ShieldCheckIcon size={24} />}
|
|
674
671
|
status={lead ? { label: lead.label, variant: TRUST_STATUS_TAG_VARIANT[lead.color] } : undefined}
|
|
675
|
-
anchorProps={buildAnchorProps(chatRef.url, isNewTab)}
|
|
672
|
+
anchorProps={buildAnchorProps(chatRef.url, isNewTab, chatRef.targetPlatform)}
|
|
676
673
|
menuGroups={cardMenuGroups(chatRef.url, discuss, {
|
|
677
674
|
label: 'View trust center',
|
|
678
675
|
icon: <ShieldCheckIcon size={20} />,
|
|
@@ -703,7 +700,7 @@ function DataRoomDocChatCard({
|
|
|
703
700
|
description={chatRef.preview ?? undefined}
|
|
704
701
|
icon={<FileContentIcon size={24} />}
|
|
705
702
|
status={{ label: badgeText, variant: 'grey' }}
|
|
706
|
-
anchorProps={buildAnchorProps(chatRef.url, isNewTab)}
|
|
703
|
+
anchorProps={buildAnchorProps(chatRef.url, isNewTab, chatRef.targetPlatform)}
|
|
707
704
|
menuGroups={cardMenuGroups(chatRef.url, discuss)}
|
|
708
705
|
menuAriaLabel="Document actions"
|
|
709
706
|
/>
|
|
@@ -727,7 +724,7 @@ function GenericFinancialChatCard({
|
|
|
727
724
|
title={chatRef.title}
|
|
728
725
|
description={subtitle}
|
|
729
726
|
icon={icon}
|
|
730
|
-
anchorProps={buildAnchorProps(chatRef.url, isNewTab)}
|
|
727
|
+
anchorProps={buildAnchorProps(chatRef.url, isNewTab, chatRef.targetPlatform)}
|
|
731
728
|
menuGroups={cardMenuGroups(chatRef.url, discuss)}
|
|
732
729
|
menuAriaLabel="Document actions"
|
|
733
730
|
/>
|
|
@@ -920,7 +917,7 @@ function EntityMingoCard({
|
|
|
920
917
|
imageAlt={typeof title === 'string' ? title : undefined}
|
|
921
918
|
icon={fallbackIcon}
|
|
922
919
|
status={status}
|
|
923
|
-
anchorProps={buildAnchorProps(chatRef.url, isNewTab)}
|
|
920
|
+
anchorProps={buildAnchorProps(chatRef.url, isNewTab, chatRef.targetPlatform)}
|
|
924
921
|
menuGroups={cardMenuGroups(chatRef.url, discuss, openDetails, externalLink)}
|
|
925
922
|
menuAriaLabel={menuAriaLabel}
|
|
926
923
|
/>
|
|
@@ -1081,7 +1078,7 @@ function DesignDocChatCard({
|
|
|
1081
1078
|
? { label: readiness.label, variant: readiness.scheme === 'success' ? 'success' : 'grey' }
|
|
1082
1079
|
: { label: 'Design doc', variant: 'grey' }
|
|
1083
1080
|
}
|
|
1084
|
-
anchorProps={buildAnchorProps(displayRef.url, isNewTab)}
|
|
1081
|
+
anchorProps={buildAnchorProps(displayRef.url, isNewTab, displayRef.targetPlatform)}
|
|
1085
1082
|
menuGroups={cardMenuGroups(displayRef.url, discuss)}
|
|
1086
1083
|
menuAriaLabel="Design doc actions"
|
|
1087
1084
|
/>
|
|
@@ -1324,7 +1321,7 @@ interface ChatCardRegistryEntry {
|
|
|
1324
1321
|
* for ChatRef-shaped items). Result is validated via `safeHref`
|
|
1325
1322
|
* before being attached to the resolved ref — so the wrapper sees a
|
|
1326
1323
|
* non-null `href`, the pre-computed `isNewTab` reflects the actual
|
|
1327
|
-
* destination, and the click goes through `
|
|
1324
|
+
* destination, and the click goes through `executeNavigation` (no
|
|
1328
1325
|
* silent bypass of embed-mode / close-on-nav). Takes precedence over
|
|
1329
1326
|
* the `composeContentUrl` fallback below — but NOT over an explicit
|
|
1330
1327
|
* host `override` for the type (see `pickFetchedCardHref`). */
|
|
@@ -1905,20 +1902,20 @@ export function chatCardLabel(docType: string): string | undefined {
|
|
|
1905
1902
|
// card body provides its own `<a href={absolute}>` (per the
|
|
1906
1903
|
// pure-presentation contract) — this wrapper intercepts the primary
|
|
1907
1904
|
// click via `onClickCapture` BEFORE the browser's default navigation
|
|
1908
|
-
// fires, and routes through `
|
|
1905
|
+
// fires, and routes through `executeNavigation` to apply runtime nav
|
|
1909
1906
|
// rules (embed-mode `window.open` / cross-platform new-tab / host
|
|
1910
1907
|
// `runtime.navigation.navigate`). Modifier / non-primary clicks pass
|
|
1911
|
-
// through (`
|
|
1908
|
+
// through (`executeNavigation` returns early so the browser opens
|
|
1912
1909
|
// the inner anchor's href naturally).
|
|
1913
1910
|
//
|
|
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 `
|
|
1911
|
+
// Same click model as source chips — chips use `<a onClick={executeNavigation}>`
|
|
1912
|
+
// directly; cards use `<span onClickCapture={→executeNavigation}>` outside
|
|
1913
|
+
// the card's own anchor. Both ultimately call `executeNavigation` with
|
|
1917
1914
|
// the same `{href, targetPlatform}` resolved at `ChatCardLoader` via
|
|
1918
1915
|
// `resolveSourceRowCTA`. The unification:
|
|
1919
1916
|
// - Same URL composition (`resolveSourceRowCTA`)
|
|
1920
|
-
// - Same
|
|
1921
|
-
// - Same click router (`
|
|
1917
|
+
// - Same navigation decision (`navLinkTarget`)
|
|
1918
|
+
// - Same click router (`executeNavigation`)
|
|
1922
1919
|
// - Same conditional close (`ChatPanelContext.closeChat` on same-tab only)
|
|
1923
1920
|
// =============================================================================
|
|
1924
1921
|
|
|
@@ -1930,7 +1927,7 @@ export function chatCardLabel(docType: string): string | undefined {
|
|
|
1930
1927
|
* new-tab decision applied (via `opts.isNewTab` from ChatCardLoader).
|
|
1931
1928
|
*
|
|
1932
1929
|
* Job:
|
|
1933
|
-
* - PRIMARY clicks → preventDefault + route through `
|
|
1930
|
+
* - PRIMARY clicks → preventDefault + route through `executeNavigation`
|
|
1934
1931
|
* - Modifier-clicks → pass through to the browser's native handling
|
|
1935
1932
|
* - Same-tab nav → close the chat panel (so the panel doesn't linger
|
|
1936
1933
|
* over the now-current-page content). New-tab nav leaves it open.
|
|
@@ -1945,13 +1942,14 @@ function ChatCardNavWrap({
|
|
|
1945
1942
|
path,
|
|
1946
1943
|
targetPlatform,
|
|
1947
1944
|
isNewTab,
|
|
1945
|
+
hostRoute,
|
|
1948
1946
|
children,
|
|
1949
1947
|
}: {
|
|
1950
1948
|
href: string | null;
|
|
1951
1949
|
/** In-app doc-tree path for `markdown` / `data_room_doc` refs. The
|
|
1952
1950
|
* runtime's `navigate({path})` opportunistically swaps the active
|
|
1953
1951
|
* documentation section without a full page nav; null for everything
|
|
1954
|
-
* else. Threaded straight through to `
|
|
1952
|
+
* else. Threaded straight through to `executeNavigation` so chips
|
|
1955
1953
|
* and inline cards apply the same routing rule. */
|
|
1956
1954
|
path: string | null;
|
|
1957
1955
|
targetPlatform: string | null;
|
|
@@ -1959,10 +1957,12 @@ function ChatCardNavWrap({
|
|
|
1959
1957
|
* same value the card's `<a target>` already renders with.
|
|
1960
1958
|
* Consumed here ONLY to decide whether to close the panel. */
|
|
1961
1959
|
isNewTab: boolean;
|
|
1960
|
+
/** `href` is the host's own relative route (see `navLinkTarget`), handed to the executor so the click decides as
|
|
1961
|
+
* the render did. */
|
|
1962
|
+
hostRoute: boolean;
|
|
1962
1963
|
children: ReactNode;
|
|
1963
1964
|
}) {
|
|
1964
1965
|
const runtime = useRequiredChatRuntime();
|
|
1965
|
-
const router = useRouter();
|
|
1966
1966
|
const panel = useChatPanel();
|
|
1967
1967
|
const onClickCapture = (e: React.MouseEvent<HTMLElement>) => {
|
|
1968
1968
|
if (!href) return;
|
|
@@ -1987,7 +1987,7 @@ function ChatCardNavWrap({
|
|
|
1987
1987
|
if (targetEl?.closest?.('button')) return;
|
|
1988
1988
|
if (!targetEl?.closest?.('a')) return;
|
|
1989
1989
|
|
|
1990
|
-
const handled = executeNavigation({ event: e, runtime, href, path, targetPlatform,
|
|
1990
|
+
const handled = executeNavigation({ event: e, runtime, href, path, targetPlatform, hostRoute });
|
|
1991
1991
|
if (!handled) return;
|
|
1992
1992
|
// Modifier-clicks fall through (handled=false) without stopPropagation
|
|
1993
1993
|
// so ancestor telemetry handlers still see the bubble.
|
|
@@ -2009,8 +2009,6 @@ interface ChatCardLoaderProps {
|
|
|
2009
2009
|
chatRef: ChatRef;
|
|
2010
2010
|
onDiscuss?: (ref: ChatRef) => void;
|
|
2011
2011
|
onDisplay?: (ref: ChatRef) => void;
|
|
2012
|
-
baseRoute?: string;
|
|
2013
|
-
chipBasePlatform?: string;
|
|
2014
2012
|
extras?: ChatCardDispatchExtras;
|
|
2015
2013
|
}
|
|
2016
2014
|
|
|
@@ -2047,27 +2045,19 @@ function CardWithDisclosure({
|
|
|
2047
2045
|
* SINGLE URL-RESOLUTION POINT — same code path source chips already
|
|
2048
2046
|
* had. Before render dispatch:
|
|
2049
2047
|
* - Pass the ref through `resolveSourceRowCTA` to compute the
|
|
2050
|
-
* canonical `{href, targetPlatform}`
|
|
2051
|
-
*
|
|
2052
|
-
* awareness).
|
|
2048
|
+
* canonical `{href, targetPlatform}` through the host's composer
|
|
2049
|
+
* (`composeContentUrl`), the one address rule.
|
|
2053
2050
|
* - Pre-resolve href against `runtime.navigation.defaultContentOrigin`
|
|
2054
2051
|
* in embed mode (so modifier-click + copy-link land on the hub).
|
|
2055
2052
|
* - Re-attach the resolved values onto the ref so EVERY downstream
|
|
2056
2053
|
* card — whether it renders an inner `<a>` from `href` prop
|
|
2057
2054
|
* (BlogCard, ProgramCard, …) or pulls `anchorProps` from
|
|
2058
|
-
* `
|
|
2055
|
+
* `navLinkTarget` — sees the SAME canonical URL the
|
|
2059
2056
|
* chip would render.
|
|
2060
2057
|
*
|
|
2061
2058
|
* Eliminates the entire "chip works, inline card doesn't" class of bug.
|
|
2062
2059
|
*/
|
|
2063
|
-
export function ChatCardLoader({
|
|
2064
|
-
chatRef,
|
|
2065
|
-
onDiscuss,
|
|
2066
|
-
onDisplay,
|
|
2067
|
-
baseRoute,
|
|
2068
|
-
chipBasePlatform,
|
|
2069
|
-
extras,
|
|
2070
|
-
}: ChatCardLoaderProps) {
|
|
2060
|
+
export function ChatCardLoader({ chatRef, onDiscuss, onDisplay, extras }: ChatCardLoaderProps) {
|
|
2071
2061
|
const runtime = useRequiredChatRuntime();
|
|
2072
2062
|
const entry = CHAT_CARD_REGISTRY[chatRef.type];
|
|
2073
2063
|
// Hook order MUST be stable across renders — call the data hook
|
|
@@ -2090,9 +2080,9 @@ export function ChatCardLoader({
|
|
|
2090
2080
|
chatRef,
|
|
2091
2081
|
item: fetchEntry ? item : undefined,
|
|
2092
2082
|
entry: fetchEntry,
|
|
2093
|
-
ctx: sourceRowCtxFromRuntime(runtime
|
|
2083
|
+
ctx: sourceRowCtxFromRuntime(runtime),
|
|
2094
2084
|
composeContentUrl: runtime.composeContentUrl,
|
|
2095
|
-
resolveHref: href =>
|
|
2085
|
+
resolveHref: href => navLinkTarget(runtime, href).href,
|
|
2096
2086
|
});
|
|
2097
2087
|
const hrefResolvedChatRef: ChatRef = {
|
|
2098
2088
|
...chatRef,
|
|
@@ -2117,8 +2107,15 @@ export function ChatCardLoader({
|
|
|
2117
2107
|
// Pre-compute new-tab decision ONCE here (the same rule chips use).
|
|
2118
2108
|
// Render branches that pass `target` / `rel` to their card pull this
|
|
2119
2109
|
// via `renderOpts.isNewTab` so the inner `<a>` agrees with the
|
|
2120
|
-
// runtime nav decision in `ChatCardNavWrap` + `
|
|
2121
|
-
|
|
2110
|
+
// runtime nav decision in `ChatCardNavWrap` + `executeNavigation`.
|
|
2111
|
+
// A url the host composed (`composed`, `hostOverride`) as a relative route of its own is the host's page.
|
|
2112
|
+
const hostRoute =
|
|
2113
|
+
(destination.source === 'composed' || destination.source === 'hostOverride') &&
|
|
2114
|
+
!!finalChatRef.url &&
|
|
2115
|
+
isRelativeHref(finalChatRef.url);
|
|
2116
|
+
const isNewTab = finalChatRef.url
|
|
2117
|
+
? navLinkTarget(runtime, finalChatRef.url, finalChatRef.targetPlatform, { hostRoute }).isNewTab
|
|
2118
|
+
: false;
|
|
2122
2119
|
|
|
2123
2120
|
// Resolve the "Ask Mingo"/"Display" affordance ONCE — same precedence as the
|
|
2124
2121
|
// legacy `ChatCardWithDiscuss` (displayAction + onDisplay → "Display",
|
|
@@ -2134,8 +2131,6 @@ export function ChatCardLoader({
|
|
|
2134
2131
|
: undefined;
|
|
2135
2132
|
|
|
2136
2133
|
const renderOpts: ChatCardRenderOptions = {
|
|
2137
|
-
baseRoute,
|
|
2138
|
-
chipBasePlatform,
|
|
2139
2134
|
extras,
|
|
2140
2135
|
isNewTab,
|
|
2141
2136
|
discuss,
|
|
@@ -2153,6 +2148,7 @@ export function ChatCardLoader({
|
|
|
2153
2148
|
path={path}
|
|
2154
2149
|
targetPlatform={finalChatRef.targetPlatform ?? null}
|
|
2155
2150
|
isNewTab={isNewTab}
|
|
2151
|
+
hostRoute={hostRoute}
|
|
2156
2152
|
>
|
|
2157
2153
|
{children}
|
|
2158
2154
|
</ChatCardNavWrap>
|
|
@@ -2255,23 +2251,12 @@ export function renderChatInlineEntityCard(
|
|
|
2255
2251
|
options: {
|
|
2256
2252
|
onDiscuss?: (ref: ChatRef) => void;
|
|
2257
2253
|
onDisplay?: (ref: ChatRef) => void;
|
|
2258
|
-
baseRoute?: string;
|
|
2259
|
-
chipBasePlatform?: string;
|
|
2260
2254
|
extras?: ChatCardDispatchExtras;
|
|
2261
2255
|
} = {},
|
|
2262
2256
|
): React.ReactNode {
|
|
2263
|
-
const { onDiscuss, onDisplay,
|
|
2257
|
+
const { onDiscuss, onDisplay, extras } = options;
|
|
2264
2258
|
|
|
2265
|
-
const loader =
|
|
2266
|
-
<ChatCardLoader
|
|
2267
|
-
chatRef={chatRef}
|
|
2268
|
-
onDiscuss={onDiscuss}
|
|
2269
|
-
onDisplay={onDisplay}
|
|
2270
|
-
baseRoute={baseRoute}
|
|
2271
|
-
chipBasePlatform={chipBasePlatform}
|
|
2272
|
-
extras={extras}
|
|
2273
|
-
/>
|
|
2274
|
-
);
|
|
2259
|
+
const loader = <ChatCardLoader chatRef={chatRef} onDiscuss={onDiscuss} onDisplay={onDisplay} extras={extras} />;
|
|
2275
2260
|
|
|
2276
2261
|
// Embedded videos are SELF-DESCRIBING: the marker id alone recovers the
|
|
2277
2262
|
// playable URL (`decodeVideoMarkerId`), so the player renders on ANY
|
|
@@ -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}
|