@salesforcedevs/docs-components 1.35.0-ver-picker-1 → 1.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +12 -0
- package/package.json +28 -29
- package/src/modules/doc/banner/banner.css +41 -2
- package/src/modules/doc/banner/banner.html +6 -5
- package/src/modules/doc/banner/banner.ts +28 -0
- package/src/modules/doc/contentActionToolbar/constants.ts +43 -0
- package/src/modules/doc/contentActionToolbar/contentActionToolbar.css +34 -6
- package/src/modules/doc/contentActionToolbar/contentActionToolbar.html +63 -28
- package/src/modules/doc/contentActionToolbar/contentActionToolbar.ts +372 -61
- package/src/modules/doc/contentActionToolbar/contentActionToolbarMocks.ts +1 -1
- package/src/modules/doc/contentLayout/contentLayout.html +35 -16
- package/src/modules/doc/contentLayout/contentLayout.ts +87 -8
- package/src/modules/doc/header/header.ts +14 -3
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.html +17 -0
- package/src/modules/doc/lwcContentLayout/lwcContentLayout.ts +9 -0
- package/src/modules/doc/unifiedContentLayout/unifiedContentLayout.ts +46 -8
- package/src/modules/doc/versionPicker/versionPicker.css +0 -114
- package/src/modules/doc/versionPicker/versionPicker.html +0 -37
- package/src/modules/doc/versionPicker/versionPicker.ts +0 -42
- package/src/modules/doc/xmlContent/xmlContent.html +1 -0
- package/src/modules/doc/xmlContent/xmlContent.ts +10 -14
- package/src/modules/docHelpers/contentLayoutStyle/contentLayoutStyle.css +4 -4
- package/src/modules/docUtils/searchClient/searchClient.ts +16 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @lwc/lwc/no-document-query */
|
|
2
|
+
import { isOpenSearchConfigured } from "dxUtils/openSearch";
|
|
2
3
|
import { LightningElement, api, createElement, track } from "lwc";
|
|
3
4
|
import { closest, querySelector } from "kagekiri";
|
|
4
5
|
import { toJson, normalizeBoolean } from "dxUtils/normalizers";
|
|
@@ -31,6 +32,9 @@ const HIGHLIGHTABLE_SELECTOR = [
|
|
|
31
32
|
"td"
|
|
32
33
|
].join(",");
|
|
33
34
|
export const OBSERVER_ATTACH_WAIT_TIME = 500;
|
|
35
|
+
const HASH_SCROLL_DELAY = 500;
|
|
36
|
+
const MAX_HASH_SCROLL_WAIT_TIME = 10000;
|
|
37
|
+
const CODE_BLOCK_TAG = "dx-code-block";
|
|
34
38
|
|
|
35
39
|
const DEFAULT_READING_TIME_LOCALE = "en-us";
|
|
36
40
|
|
|
@@ -75,6 +79,15 @@ export default class ContentLayout extends LightningElement {
|
|
|
75
79
|
@api brand: any;
|
|
76
80
|
@api emptyStateMessage?: string;
|
|
77
81
|
|
|
82
|
+
@api
|
|
83
|
+
get enableOpenSearch() {
|
|
84
|
+
return this._enableOpenSearch;
|
|
85
|
+
}
|
|
86
|
+
set enableOpenSearch(value) {
|
|
87
|
+
this._enableOpenSearch = normalizeBoolean(value);
|
|
88
|
+
}
|
|
89
|
+
private _enableOpenSearch = false;
|
|
90
|
+
|
|
78
91
|
// This is needed for now to prevent failing snapshot tests due to links in the footer
|
|
79
92
|
@api
|
|
80
93
|
get showFooter() {
|
|
@@ -152,6 +165,20 @@ export default class ContentLayout extends LightningElement {
|
|
|
152
165
|
);
|
|
153
166
|
}
|
|
154
167
|
|
|
168
|
+
/** Show the OpenSearch sidebar when enabled, configured, and the old sidebar isn't requested. */
|
|
169
|
+
protected get showOpenSearchSidebar(): boolean {
|
|
170
|
+
return (
|
|
171
|
+
this.enableOpenSearch &&
|
|
172
|
+
!this.useOldSidebar &&
|
|
173
|
+
isOpenSearchConfigured()
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Show the legacy (keyword) sidebar when requested, or when OpenSearch is disabled or not configured. */
|
|
178
|
+
protected get showOldSidebar(): boolean {
|
|
179
|
+
return !this.showOpenSearchSidebar;
|
|
180
|
+
}
|
|
181
|
+
|
|
155
182
|
@track
|
|
156
183
|
protected _sidebarContent: unknown;
|
|
157
184
|
|
|
@@ -191,6 +218,9 @@ export default class ContentLayout extends LightningElement {
|
|
|
191
218
|
// eslint-disable-next-line no-undef
|
|
192
219
|
protected observerTimerId?: NodeJS.Timeout;
|
|
193
220
|
protected didScrollToSelectedHash = false;
|
|
221
|
+
// eslint-disable-next-line no-undef
|
|
222
|
+
protected hashScrollTimerId?: NodeJS.Timeout;
|
|
223
|
+
protected hashScrollWaitStart?: number;
|
|
194
224
|
protected _scrollInterval = 0;
|
|
195
225
|
protected handleLinkClick = buildDocLinkClickHandler();
|
|
196
226
|
|
|
@@ -307,9 +337,10 @@ export default class ContentLayout extends LightningElement {
|
|
|
307
337
|
const toolbar = (this.contentActionToolbarElement ??
|
|
308
338
|
createElement(CONTENT_ACTION_TOOLBAR_TAG, {
|
|
309
339
|
is: ContentActionToolbar
|
|
310
|
-
})) as HTMLElement & { pageUrl?: string };
|
|
340
|
+
})) as HTMLElement & { pageUrl?: string; pageTitle?: string };
|
|
311
341
|
|
|
312
342
|
toolbar.pageUrl = this.sidebarValue;
|
|
343
|
+
toolbar.pageTitle = heading.textContent?.trim() || undefined;
|
|
313
344
|
|
|
314
345
|
if (toolbar.previousElementSibling !== heading) {
|
|
315
346
|
heading.parentNode?.insertBefore(toolbar, heading.nextSibling);
|
|
@@ -334,6 +365,7 @@ export default class ContentLayout extends LightningElement {
|
|
|
334
365
|
this.clearRenderObserverTimer();
|
|
335
366
|
|
|
336
367
|
window.clearInterval(this._scrollInterval);
|
|
368
|
+
clearTimeout(this.hashScrollTimerId);
|
|
337
369
|
|
|
338
370
|
// Remove link click handler
|
|
339
371
|
this.template.removeEventListener("click", this.handleLinkClick);
|
|
@@ -358,7 +390,9 @@ export default class ContentLayout extends LightningElement {
|
|
|
358
390
|
We have to account for the global nav changing height due to animations.
|
|
359
391
|
*/
|
|
360
392
|
adjustNavPosition = () => {
|
|
361
|
-
const sidebarEl =
|
|
393
|
+
const sidebarEl =
|
|
394
|
+
this.template.querySelector("dx-sidebar") ||
|
|
395
|
+
this.template.querySelector("dx-sidebar-old");
|
|
362
396
|
const globalNavEl = document.querySelector(
|
|
363
397
|
"hgf-c360nav"
|
|
364
398
|
) as HTMLElement;
|
|
@@ -495,9 +529,45 @@ export default class ContentLayout extends LightningElement {
|
|
|
495
529
|
}
|
|
496
530
|
|
|
497
531
|
if (!this.didScrollToSelectedHash) {
|
|
532
|
+
this.tryScrollToHash(headingElements);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Scrolls to the hash once available, retrying while code blocks render
|
|
538
|
+
* to avoid unexpected scrolling on observer re-attach.
|
|
539
|
+
*/
|
|
540
|
+
// eslint-disable-next-line no-undef
|
|
541
|
+
protected tryScrollToHash(headingElements: NodeListOf<Element>): void {
|
|
542
|
+
if (!window.location.hash) {
|
|
498
543
|
this.didScrollToSelectedHash = true;
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
this.hashScrollWaitStart ??= Date.now();
|
|
547
|
+
const waitExpired =
|
|
548
|
+
Date.now() - this.hashScrollWaitStart >= MAX_HASH_SCROLL_WAIT_TIME;
|
|
549
|
+
const scrolled =
|
|
550
|
+
(waitExpired || !this.hasPendingCodeBlocks()) &&
|
|
499
551
|
this.scrollToHash(headingElements);
|
|
552
|
+
|
|
553
|
+
if (scrolled || waitExpired) {
|
|
554
|
+
this.didScrollToSelectedHash = true;
|
|
555
|
+
this.hashScrollWaitStart = undefined;
|
|
556
|
+
clearTimeout(this.hashScrollTimerId);
|
|
557
|
+
return;
|
|
500
558
|
}
|
|
559
|
+
|
|
560
|
+
clearTimeout(this.hashScrollTimerId);
|
|
561
|
+
this.hashScrollTimerId = setTimeout(
|
|
562
|
+
() => this.tryScrollToHash(this.getHeadingElements()),
|
|
563
|
+
HASH_SCROLL_DELAY
|
|
564
|
+
);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
protected hasPendingCodeBlocks(): boolean {
|
|
568
|
+
return Array.from(document.querySelectorAll(CODE_BLOCK_TAG)).some(
|
|
569
|
+
(codeBlock) => !(codeBlock as any).rendered
|
|
570
|
+
);
|
|
501
571
|
}
|
|
502
572
|
|
|
503
573
|
attachInteractionObserver = (): void => {
|
|
@@ -584,6 +654,10 @@ export default class ContentLayout extends LightningElement {
|
|
|
584
654
|
this.updateRNB();
|
|
585
655
|
this.updateContentActionToolbar();
|
|
586
656
|
this.contentLoaded = true;
|
|
657
|
+
|
|
658
|
+
if (!this.didScrollToSelectedHash) {
|
|
659
|
+
this.tryScrollToHash(this.getHeadingElements());
|
|
660
|
+
}
|
|
587
661
|
}
|
|
588
662
|
|
|
589
663
|
protected disconnectObserver(): void {
|
|
@@ -594,7 +668,7 @@ export default class ContentLayout extends LightningElement {
|
|
|
594
668
|
}
|
|
595
669
|
|
|
596
670
|
// eslint-disable-next-line no-undef
|
|
597
|
-
protected scrollToHash(headingElements: NodeListOf<Element>):
|
|
671
|
+
protected scrollToHash(headingElements: NodeListOf<Element>): boolean {
|
|
598
672
|
let { hash } = window.location;
|
|
599
673
|
if (hash) {
|
|
600
674
|
hash = hash.substr(1);
|
|
@@ -609,14 +683,18 @@ export default class ContentLayout extends LightningElement {
|
|
|
609
683
|
"hgf-c360contextnav"
|
|
610
684
|
) as HTMLElement;
|
|
611
685
|
|
|
686
|
+
if (!docHeaderEl || !globalNavEl || !contextNavEl) {
|
|
687
|
+
return false;
|
|
688
|
+
}
|
|
689
|
+
|
|
612
690
|
const headerHeight =
|
|
613
|
-
docHeaderEl
|
|
614
|
-
globalNavEl
|
|
615
|
-
contextNavEl
|
|
691
|
+
(docHeaderEl.offsetHeight || 0) +
|
|
692
|
+
(globalNavEl.offsetHeight || 0) +
|
|
693
|
+
(contextNavEl.offsetHeight || 0);
|
|
616
694
|
|
|
617
695
|
const docPhaseEl = (
|
|
618
696
|
this.template.querySelector("[name=doc-phase]")! as any
|
|
619
|
-
)
|
|
697
|
+
)?.assignedElements?.()[0] as HTMLSlotElement | undefined;
|
|
620
698
|
|
|
621
699
|
const offset = docPhaseEl
|
|
622
700
|
? headerHeight + docPhaseEl.offsetHeight
|
|
@@ -625,10 +703,11 @@ export default class ContentLayout extends LightningElement {
|
|
|
625
703
|
for (const headingElement of headingElements as any) {
|
|
626
704
|
if (headingElement.getAttribute("id") === hash) {
|
|
627
705
|
this.scrollIntoViewWithOffset(headingElement, offset);
|
|
628
|
-
|
|
706
|
+
return true;
|
|
629
707
|
}
|
|
630
708
|
}
|
|
631
709
|
}
|
|
710
|
+
return false;
|
|
632
711
|
}
|
|
633
712
|
|
|
634
713
|
protected scrollIntoViewWithOffset(
|
|
@@ -74,6 +74,13 @@ export default class Header extends HeaderBase {
|
|
|
74
74
|
return (this.hideDocHeader && !this.mobile) || this.showDocDivider;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
private get isDocsPath(): boolean {
|
|
78
|
+
return (
|
|
79
|
+
window.location.pathname.includes("/docs/") &&
|
|
80
|
+
window.location.pathname !== "/docs/apis"
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
77
84
|
connectedCallback(): void {
|
|
78
85
|
super.connectedCallback();
|
|
79
86
|
this.tabletMatchMedia = window.matchMedia(
|
|
@@ -83,9 +90,7 @@ export default class Header extends HeaderBase {
|
|
|
83
90
|
this.tabletMatchMedia.addEventListener("change", this.onTabletChange);
|
|
84
91
|
|
|
85
92
|
if (
|
|
86
|
-
(!this.shouldHideHeader &&
|
|
87
|
-
window.location.pathname.includes("/docs/") &&
|
|
88
|
-
window.location.pathname !== "/docs/apis") ||
|
|
93
|
+
(!this.shouldHideHeader && this.isDocsPath) ||
|
|
89
94
|
window.location.pathname ===
|
|
90
95
|
"/tableau/embedding-playground/overview" ||
|
|
91
96
|
isStorybook()
|
|
@@ -109,6 +114,12 @@ export default class Header extends HeaderBase {
|
|
|
109
114
|
);
|
|
110
115
|
}
|
|
111
116
|
|
|
117
|
+
renderedCallback(): void {
|
|
118
|
+
if (this.hideDocHeader) {
|
|
119
|
+
this.shouldRender = !this.shouldHideHeader && this.isDocsPath;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
112
123
|
private onTabletChange = (e: MediaQueryListEvent | MediaQueryList) =>
|
|
113
124
|
(this.tablet = e.matches);
|
|
114
125
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="content">
|
|
3
3
|
<dx-sidebar-old
|
|
4
|
+
lwc:if={showOldSidebar}
|
|
4
5
|
class="is-sticky left-nav-bar"
|
|
5
6
|
trees={sidebarContent}
|
|
6
7
|
value={sidebarValue}
|
|
@@ -15,6 +16,22 @@
|
|
|
15
16
|
>
|
|
16
17
|
<slot name="sidebar-header" slot="version-picker"></slot>
|
|
17
18
|
</dx-sidebar-old>
|
|
19
|
+
<dx-sidebar
|
|
20
|
+
lwc:else
|
|
21
|
+
class="is-sticky left-nav-bar"
|
|
22
|
+
trees={sidebarContent}
|
|
23
|
+
value={sidebarValue}
|
|
24
|
+
header={sidebarHeader}
|
|
25
|
+
ontogglesidebar={onToggleSidebar}
|
|
26
|
+
languages={languages}
|
|
27
|
+
language={language}
|
|
28
|
+
bail-href={bailHref}
|
|
29
|
+
bail-label={bailLabel}
|
|
30
|
+
dev-center={devCenter}
|
|
31
|
+
brand={brand}
|
|
32
|
+
>
|
|
33
|
+
<slot name="sidebar-header" slot="version-picker"></slot>
|
|
34
|
+
</dx-sidebar>
|
|
18
35
|
<div class="content-body-doc-phase-container">
|
|
19
36
|
<div class="doc-phase-wrapper">
|
|
20
37
|
<slot name="doc-phase"></slot>
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { api } from "lwc";
|
|
2
2
|
import ContentLayout from "doc/contentLayout";
|
|
3
3
|
import cx from "classnames";
|
|
4
|
+
import { isOpenSearchConfigured } from "dxUtils/openSearch";
|
|
4
5
|
|
|
5
6
|
const TOC_HEADER_TAG = "doc-heading";
|
|
6
7
|
const RNB_BY_TAB = "docs-tab";
|
|
@@ -26,6 +27,14 @@ export default class LwcContentLayout extends ContentLayout {
|
|
|
26
27
|
);
|
|
27
28
|
}
|
|
28
29
|
|
|
30
|
+
/**
|
|
31
|
+
* This layout uses the OpenSearch sidebar by default (no enable flag), so it
|
|
32
|
+
* falls back to the old sidebar when requested or when search isn't configured.
|
|
33
|
+
*/
|
|
34
|
+
protected get showOldSidebar(): boolean {
|
|
35
|
+
return this.useOldSidebar || !isOpenSearchConfigured();
|
|
36
|
+
}
|
|
37
|
+
|
|
29
38
|
private setRNBByTab() {
|
|
30
39
|
const tabPanelListItem = this.getTabPanelList();
|
|
31
40
|
this.rnbByTab = tabPanelListItem?.id === RNB_BY_TAB;
|
|
@@ -10,11 +10,38 @@ import type { OptionWithLink, TreeNode } from "typings/custom";
|
|
|
10
10
|
*/
|
|
11
11
|
const TOPIC_TYPE_SPEC = "spec";
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Walks down the first-child chain and returns the first markdown content
|
|
15
|
+
* page found, descending through nested content-less parents. Returns
|
|
16
|
+
* undefined if the chain breaks on a spec or external link before reaching a
|
|
17
|
+
* content page.
|
|
18
|
+
*/
|
|
19
|
+
function firstChildContentPage(node: TreeNode): TreeNode | undefined {
|
|
20
|
+
const firstChild = node.children?.[0];
|
|
21
|
+
if (!firstChild) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const isSpec =
|
|
26
|
+
(firstChild as { topicType?: string }).topicType === TOPIC_TYPE_SPEC;
|
|
27
|
+
const isExternal = firstChild.link?.target === "_blank";
|
|
28
|
+
if (isSpec || isExternal) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (firstChild.link?.href) {
|
|
33
|
+
return firstChild;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return firstChildContentPage(firstChild);
|
|
37
|
+
}
|
|
38
|
+
|
|
13
39
|
/**
|
|
14
40
|
* Translates per-topic `topicType` into the generic `showForwardArrow` flag
|
|
15
|
-
* that `dx-tree-tile` reads (spec topics get the forward arrow icon for Redoc)
|
|
41
|
+
* that `dx-tree-tile` reads (spec topics get the forward arrow icon for Redoc),
|
|
42
|
+
* and redirects content-less parent topics whose first child is a content page
|
|
16
43
|
*/
|
|
17
|
-
function
|
|
44
|
+
function decorateTopics(
|
|
18
45
|
topics: Array<TreeNode & { topicType?: string }> | undefined
|
|
19
46
|
): TreeNode[] | undefined {
|
|
20
47
|
return topics?.map((topic) => {
|
|
@@ -23,10 +50,23 @@ function decorateTopicsWithForwardArrow(
|
|
|
23
50
|
decorated.showForwardArrow = true;
|
|
24
51
|
}
|
|
25
52
|
if (decorated.children) {
|
|
26
|
-
decorated.children =
|
|
27
|
-
decorated.children
|
|
28
|
-
);
|
|
53
|
+
decorated.children = decorateTopics(decorated.children);
|
|
29
54
|
}
|
|
55
|
+
|
|
56
|
+
/** Redirect a parent that has no content of its own to its first child
|
|
57
|
+
* but only when that first child is itself a content page
|
|
58
|
+
*/
|
|
59
|
+
const isContentlessParent =
|
|
60
|
+
!!decorated.children?.length && !decorated.link?.href;
|
|
61
|
+
|
|
62
|
+
if (isContentlessParent) {
|
|
63
|
+
decorated.redirectToChild = true;
|
|
64
|
+
const firstChild = firstChildContentPage(topic);
|
|
65
|
+
if (firstChild?.link) {
|
|
66
|
+
decorated.link = { ...firstChild.link };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
30
70
|
return decorated;
|
|
31
71
|
});
|
|
32
72
|
}
|
|
@@ -77,9 +117,7 @@ export default class UnifiedContentLayout extends LightningElement {
|
|
|
77
117
|
}
|
|
78
118
|
|
|
79
119
|
set sidebarContent(value: string) {
|
|
80
|
-
this._sidebarContent =
|
|
81
|
-
toJson(value)?.topics
|
|
82
|
-
);
|
|
120
|
+
this._sidebarContent = decorateTopics(toJson(value)?.topics);
|
|
83
121
|
}
|
|
84
122
|
|
|
85
123
|
private get enableFooter(): boolean {
|
|
@@ -62,117 +62,3 @@ dx-type-badge.not-latest-badge {
|
|
|
62
62
|
|
|
63
63
|
margin-left: var(--dx-g-spacing-sm);
|
|
64
64
|
}
|
|
65
|
-
|
|
66
|
-
/* ------------------------------------------------------------------ *
|
|
67
|
-
* Small "dot" variant (opt-in via `small`). Additive
|
|
68
|
-
* ------------------------------------------------------------------ */
|
|
69
|
-
|
|
70
|
-
/* Scoped hooks so the shared dx-popover/dx-dropdown-option keep their defaults. */
|
|
71
|
-
.version-picker-dropdown-small {
|
|
72
|
-
--dx-c-dropdown-option-font-size: var(--dx-g-text-xs);
|
|
73
|
-
--dx-c-dropdown-option-padding: var(--dx-g-spacing-sm)
|
|
74
|
-
var(--dx-g-spacing-lg);
|
|
75
|
-
--dx-c-dropdown-option-border-radius: 0;
|
|
76
|
-
--dx-c-popover-border: none;
|
|
77
|
-
--dx-c-popover-padding: var(--dx-g-spacing-sm) 0;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.version-picker-button-small {
|
|
81
|
-
display: flex;
|
|
82
|
-
width: fit-content;
|
|
83
|
-
max-width: 104px;
|
|
84
|
-
border-radius: var(--dx-g-spacing-xs);
|
|
85
|
-
|
|
86
|
-
--dx-c-button-font-size: var(--dx-g-text-xs);
|
|
87
|
-
--dx-c-button-font-weight: var(--dx-g-font-normal);
|
|
88
|
-
--dx-c-button-line-height: 18px;
|
|
89
|
-
--dx-g-button-icon-color: var(--dx-g-gray-50);
|
|
90
|
-
--dx-g-spacing-sm: var(--dx-g-spacing-2xs);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/* min-width: 0 on each flex ancestor lets the label truncate: a flex item's
|
|
94
|
-
default min-width: auto refuses to shrink below its content and overrides the
|
|
95
|
-
host's max-width, so without this the trigger overflows instead. */
|
|
96
|
-
.version-picker-button-small::part(content) {
|
|
97
|
-
display: flex;
|
|
98
|
-
flex: 1;
|
|
99
|
-
min-width: 0;
|
|
100
|
-
width: auto;
|
|
101
|
-
overflow: hidden;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
/* Border is an inset box-shadow, not a real border, so thickening it on
|
|
105
|
-
hover/focus doesn't widen the fit-content box (no horizontal shift). */
|
|
106
|
-
.version-picker-button-small::part(container) {
|
|
107
|
-
box-sizing: border-box;
|
|
108
|
-
|
|
109
|
-
/* width:100% re-ties to the 104px-capped host (container is width:inherit,
|
|
110
|
-
which copies width but not max-width). */
|
|
111
|
-
width: 100%;
|
|
112
|
-
height: 24px;
|
|
113
|
-
padding: 0 var(--dx-g-spacing-xs);
|
|
114
|
-
border-radius: var(--dx-g-spacing-xs);
|
|
115
|
-
background: #fff;
|
|
116
|
-
box-shadow: inset 0 0 0 1px var(--dx-g-gray-50);
|
|
117
|
-
color: var(--dx-g-gray-10);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
.version-picker-button-small::part(container):hover {
|
|
121
|
-
background: var(--dx-g-blue-vibrant-95);
|
|
122
|
-
box-shadow: inset 0 0 0 2px var(--dx-g-blue-vibrant-20);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
.version-picker-button-small:hover,
|
|
126
|
-
.version-picker-button-small:focus-within,
|
|
127
|
-
.version-picker-button-small[aria-expanded="true"] {
|
|
128
|
-
--dx-g-button-icon-color: var(--dx-g-blue-vibrant-20);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/* Also matches aria-expanded so the ring stays while the menu is open (opening
|
|
132
|
-
moves focus into the menu, which would otherwise drop :focus-within). */
|
|
133
|
-
.version-picker-button-small:focus-within::part(container),
|
|
134
|
-
.version-picker-button-small[aria-expanded="true"]::part(container) {
|
|
135
|
-
background: var(--dx-g-blue-vibrant-95);
|
|
136
|
-
box-shadow: inset 0 0 0 2px var(--dx-g-blue-vibrant-20), 0 0 0 2px #fff,
|
|
137
|
-
0 0 0 4px var(--dx-g-blue-vibrant-60);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
.selected-version-small {
|
|
141
|
-
flex: 1;
|
|
142
|
-
min-width: 0;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
.version-picker-dot {
|
|
146
|
-
flex: 0 0 auto;
|
|
147
|
-
width: 8px;
|
|
148
|
-
height: 8px;
|
|
149
|
-
margin-right: var(--dx-g-spacing-xs);
|
|
150
|
-
border-radius: 50%;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
.version-picker-dot-latest {
|
|
154
|
-
background: var(--dx-g-green-vibrant-60);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
.version-picker-dot-not-latest {
|
|
158
|
-
background: var(--dx-g-yellow-vibrant-80);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
.version-picker-readonly-small {
|
|
162
|
-
display: inline-flex;
|
|
163
|
-
align-items: center;
|
|
164
|
-
box-sizing: border-box;
|
|
165
|
-
width: fit-content;
|
|
166
|
-
max-width: 104px;
|
|
167
|
-
height: 24px;
|
|
168
|
-
margin: 0;
|
|
169
|
-
padding: 0 var(--dx-g-spacing-xs);
|
|
170
|
-
border: 1px solid var(--dx-g-gray-80);
|
|
171
|
-
border-radius: var(--dx-g-spacing-xs);
|
|
172
|
-
overflow: hidden;
|
|
173
|
-
color: var(--dx-g-gray-10);
|
|
174
|
-
text-overflow: ellipsis;
|
|
175
|
-
white-space: nowrap;
|
|
176
|
-
font: var(--dx-g-font-normal) var(--dx-g-text-xs) / 18px
|
|
177
|
-
var(--dx-g-font-sans), sans-serif;
|
|
178
|
-
}
|
|
@@ -1,43 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div lwc:if={showVersionPicker} class="version-picker-container">
|
|
3
|
-
<!-- Small read-only: plain value, no dropdown -->
|
|
4
|
-
<p lwc:if={readOnly} class="version-picker-readonly-small">
|
|
5
|
-
{selectedVersion.label}
|
|
6
|
-
</p>
|
|
7
|
-
|
|
8
|
-
<!-- Small "dot" variant -->
|
|
9
3
|
<dx-dropdown
|
|
10
|
-
lwc:elseif={small}
|
|
11
|
-
class="version-picker-dropdown-small"
|
|
12
|
-
options={versions}
|
|
13
|
-
analytics-event="custEv_docVersionSelect"
|
|
14
|
-
analytics-payload={analyticsPayload}
|
|
15
|
-
value={selectedVersion.id}
|
|
16
|
-
onchange={onVersionChange}
|
|
17
|
-
>
|
|
18
|
-
<dx-button
|
|
19
|
-
class="version-picker-button version-picker-button-small"
|
|
20
|
-
variant="tertiary"
|
|
21
|
-
size="small"
|
|
22
|
-
font="sans"
|
|
23
|
-
icon-symbol="chevrondown"
|
|
24
|
-
icon-size="xsmall"
|
|
25
|
-
aria-label={smallTriggerAriaLabel}
|
|
26
|
-
>
|
|
27
|
-
<div class="selected-version selected-version-small">
|
|
28
|
-
<template lwc:if={showLatestTag}>
|
|
29
|
-
<span class={dotClass} aria-hidden="true"></span>
|
|
30
|
-
</template>
|
|
31
|
-
<p class="selected-version-label">
|
|
32
|
-
{selectedVersion.label}
|
|
33
|
-
</p>
|
|
34
|
-
</div>
|
|
35
|
-
</dx-button>
|
|
36
|
-
</dx-dropdown>
|
|
37
|
-
|
|
38
|
-
<!-- Default (existing) -->
|
|
39
|
-
<dx-dropdown
|
|
40
|
-
lwc:else
|
|
41
4
|
options={versions}
|
|
42
5
|
analytics-event="custEv_docVersionSelect"
|
|
43
6
|
analytics-payload={analyticsPayload}
|
|
@@ -12,8 +12,6 @@ export default class VersionPicker extends LightningElement {
|
|
|
12
12
|
private _selectedVersion?: OptionWithNested;
|
|
13
13
|
private _latestVersion: boolean = false;
|
|
14
14
|
private _hideBadge: boolean = false;
|
|
15
|
-
private _small: boolean = false;
|
|
16
|
-
private _readOnly: boolean = false;
|
|
17
15
|
|
|
18
16
|
@api
|
|
19
17
|
get versions() {
|
|
@@ -53,27 +51,6 @@ export default class VersionPicker extends LightningElement {
|
|
|
53
51
|
this._hideBadge = normalizeBoolean(value);
|
|
54
52
|
}
|
|
55
53
|
|
|
56
|
-
// Opt-in compact "dot" variant (24px, abbreviated label). Off by default so
|
|
57
|
-
// existing consumers render the default trigger unchanged.
|
|
58
|
-
@api
|
|
59
|
-
get small() {
|
|
60
|
-
return this._small;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
set small(value) {
|
|
64
|
-
this._small = normalizeBoolean(value);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Opt-in read-only state: plain value, no dropdown menu.
|
|
68
|
-
@api
|
|
69
|
-
get readOnly() {
|
|
70
|
-
return this._readOnly;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
set readOnly(value) {
|
|
74
|
-
this._readOnly = normalizeBoolean(value);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
54
|
private get showVersionPicker() {
|
|
78
55
|
return this._versions && this._versions.length !== 0;
|
|
79
56
|
}
|
|
@@ -82,25 +59,6 @@ export default class VersionPicker extends LightningElement {
|
|
|
82
59
|
return !this.hideBadge;
|
|
83
60
|
}
|
|
84
61
|
|
|
85
|
-
private get dotClass(): string {
|
|
86
|
-
return `version-picker-dot ${
|
|
87
|
-
this.latestVersion
|
|
88
|
-
? "version-picker-dot-latest"
|
|
89
|
-
: "version-picker-dot-not-latest"
|
|
90
|
-
}`;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// Accessible name for the small trigger: includes the latest state so it
|
|
94
|
-
// isn't conveyed by the dot's color alone (WCAG 1.4.1). Omits the state
|
|
95
|
-
// when the indicator is hidden.
|
|
96
|
-
private get smallTriggerAriaLabel(): string {
|
|
97
|
-
const label = this.selectedVersion?.label ?? "";
|
|
98
|
-
if (!this.showLatestTag) {
|
|
99
|
-
return label;
|
|
100
|
-
}
|
|
101
|
-
return `${label}, ${this.latestVersion ? "Latest" : "Not Latest"}`;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
62
|
private onVersionChange(e: CustomEvent) {
|
|
105
63
|
this.dispatchEvent(new CustomEvent("change", { detail: e.detail }));
|
|
106
64
|
}
|
|
@@ -130,9 +130,16 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
130
130
|
private get oldVersionInfo(): DocPhaseInfo | null {
|
|
131
131
|
let info = null;
|
|
132
132
|
if (!this.disableVersion) {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
/**
|
|
134
|
+
* The GA version of en-us content has no version id in its url.
|
|
135
|
+
* Localized content can lag behind en-us, so its latest version url
|
|
136
|
+
* does include the version id. In that case, the first version in the
|
|
137
|
+
* list is the latest one.
|
|
138
|
+
**/
|
|
139
|
+
const currentGAVersion =
|
|
140
|
+
this.versionOptions.find(
|
|
141
|
+
(version) => !version.url.includes(version.id)
|
|
142
|
+
) ?? this.versionOptions[0];
|
|
136
143
|
if (currentGAVersion?.link?.href && this.version?.id) {
|
|
137
144
|
const versionNo = currentGAVersion.id;
|
|
138
145
|
/**
|
|
@@ -254,17 +261,6 @@ export default class DocXmlContent extends LightningElementWithState<{
|
|
|
254
261
|
return this.pageReference.deliverable;
|
|
255
262
|
}
|
|
256
263
|
|
|
257
|
-
private get useOldSidebar(): boolean {
|
|
258
|
-
// Coveo is enabled and the version is greater than 51 (within the latest 3 versions)
|
|
259
|
-
// TODO: we need a better fix for version number check
|
|
260
|
-
return !(
|
|
261
|
-
!this.version?.releaseVersion ||
|
|
262
|
-
(this.version?.releaseVersion &&
|
|
263
|
-
parseInt(this.version.releaseVersion.replace("v", ""), 10) >=
|
|
264
|
-
53)
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
264
|
private get pageHeader(): Header {
|
|
269
265
|
if (!this._pageHeader) {
|
|
270
266
|
this._pageHeader = document.querySelector("doc-header")!;
|
|
@@ -148,10 +148,6 @@ dx-toc {
|
|
|
148
148
|
.content-body {
|
|
149
149
|
margin-top: var(--dx-c-content-vertical-spacing);
|
|
150
150
|
}
|
|
151
|
-
|
|
152
|
-
.content-body-doc-phase-container {
|
|
153
|
-
border-left: 0;
|
|
154
|
-
}
|
|
155
151
|
}
|
|
156
152
|
|
|
157
153
|
@media screen and (max-width: 768px) {
|
|
@@ -163,6 +159,10 @@ dx-toc {
|
|
|
163
159
|
flex-direction: column;
|
|
164
160
|
}
|
|
165
161
|
|
|
162
|
+
.content-body-doc-phase-container {
|
|
163
|
+
border-left: 0;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
166
|
.content-body-container {
|
|
167
167
|
padding-right: 0;
|
|
168
168
|
padding-left: 0;
|
|
@@ -23,6 +23,9 @@ export interface SearchResult {
|
|
|
23
23
|
// and existing fixtures still satisfy the type.
|
|
24
24
|
snippet?: string | null;
|
|
25
25
|
snippetSource?: SnippetSource;
|
|
26
|
+
// `url` plus `#anchor` of the page section that matched, or null/absent
|
|
27
|
+
// when the matched chunk has no anchor. Link to it via resultHref().
|
|
28
|
+
sectionUrl?: string | null;
|
|
26
29
|
}
|
|
27
30
|
|
|
28
31
|
export interface FacetBucket {
|
|
@@ -208,6 +211,19 @@ export function sanitizeSnippetHtml(value: unknown): string {
|
|
|
208
211
|
* text path. So for anything but a headline we return `null` and let the
|
|
209
212
|
* caller keep today's text rendering.
|
|
210
213
|
*/
|
|
214
|
+
/**
|
|
215
|
+
* Where a result's title should link: the matched section when the backend
|
|
216
|
+
* returned one, else the page. The section link is only trusted when it is the
|
|
217
|
+
* page URL plus a fragment, so a malformed value can never send the user
|
|
218
|
+
* somewhere else.
|
|
219
|
+
*/
|
|
220
|
+
export function resultHref(result: SearchResult): string {
|
|
221
|
+
const { url, sectionUrl } = result;
|
|
222
|
+
return typeof sectionUrl === "string" && sectionUrl.startsWith(`${url}#`)
|
|
223
|
+
? sectionUrl
|
|
224
|
+
: url;
|
|
225
|
+
}
|
|
226
|
+
|
|
211
227
|
export function highlightedSnippetHtml(result: SearchResult): string | null {
|
|
212
228
|
if (result.snippetSource !== "headline") {
|
|
213
229
|
return null;
|