@salesforcedevs/docs-components 1.34.0-tlv-alpha → 1.34.1-redoc-ver-picker-1
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/docs-components",
|
|
3
|
-
"version": "1.34.
|
|
3
|
+
"version": "1.34.1-redoc-ver-picker-1",
|
|
4
4
|
"description": "Docs Lightning web components for DSC",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "index.js",
|
|
@@ -25,5 +25,6 @@
|
|
|
25
25
|
"@types/lodash.orderby": "4.6.9",
|
|
26
26
|
"@types/lodash.uniqby": "4.7.9"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "4629fdd9ca18a13480044ad43515b91945d16aad"
|
|
28
|
+
"gitHead": "4629fdd9ca18a13480044ad43515b91945d16aad",
|
|
29
|
+
"stableVersion": "1.34.0"
|
|
29
30
|
}
|
|
@@ -4,6 +4,7 @@ import DocPhase from "doc/phase";
|
|
|
4
4
|
import DxFooter from "dx/footer";
|
|
5
5
|
import DxIcon from "dx/icon";
|
|
6
6
|
import SidebarFooterNav from "dx/sidebarFooterNav";
|
|
7
|
+
import VersionPicker from "doc/versionPicker";
|
|
7
8
|
import SprigSurvey from "doc/sprigSurvey";
|
|
8
9
|
import { throttle } from "throttle-debounce";
|
|
9
10
|
import { pollUntil } from "dxUtils/async";
|
|
@@ -33,8 +34,22 @@ type ReferenceItem = {
|
|
|
33
34
|
topic?: ReferenceTopic;
|
|
34
35
|
};
|
|
35
36
|
|
|
37
|
+
/**
|
|
38
|
+
* A selectable spec version. Mirrors `ReferenceVersion` in `doc/amfReference`.
|
|
39
|
+
* Each version's `link.href` makes the picker's dropdown options navigate
|
|
40
|
+
* natively.
|
|
41
|
+
*/
|
|
42
|
+
type ReferenceVersion = {
|
|
43
|
+
id: string;
|
|
44
|
+
label: string;
|
|
45
|
+
deprecated?: boolean;
|
|
46
|
+
selected?: boolean;
|
|
47
|
+
link: { href: string };
|
|
48
|
+
};
|
|
49
|
+
|
|
36
50
|
type ReferenceConfig = {
|
|
37
51
|
refList: ReferenceItem[];
|
|
52
|
+
versions?: ReferenceVersion[];
|
|
38
53
|
};
|
|
39
54
|
|
|
40
55
|
const SCROLL_THROTTLE_DELAY = 50;
|
|
@@ -42,6 +57,7 @@ const ELEMENT_TIMEOUT = 10000;
|
|
|
42
57
|
const ELEMENT_CHECK_INTERVAL = 100;
|
|
43
58
|
const DEFAULT_PROJECT_TITLE = "All Reference";
|
|
44
59
|
const BACK_TARGET_STORAGE_KEY = "redoc-back-target";
|
|
60
|
+
const SELECTED_VIEW_STORAGE_KEY = "redoc-selected-view";
|
|
45
61
|
const DOCS_PATH_SEGMENT = "docs";
|
|
46
62
|
const DEFAULT_LOCALE = "en-us";
|
|
47
63
|
|
|
@@ -152,6 +168,32 @@ export default class RedocReference extends LightningElement {
|
|
|
152
168
|
return refCount > 1;
|
|
153
169
|
}
|
|
154
170
|
|
|
171
|
+
get versions(): ReferenceVersion[] {
|
|
172
|
+
return this._referenceConfig?.versions ?? [];
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** The version flagged `selected`, else the first (the latest/GA version). */
|
|
176
|
+
get selectedVersion(): ReferenceVersion | null {
|
|
177
|
+
const versions = this.versions;
|
|
178
|
+
return versions.find((v) => v.selected) ?? versions[0] ?? null;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** True when the selected version is the latest/GA one (index 0). */
|
|
182
|
+
get latestVersion(): boolean {
|
|
183
|
+
return this.versions.length
|
|
184
|
+
? this.selectedVersion?.id === this.versions[0].id
|
|
185
|
+
: false;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
get hasVersionPicker(): boolean {
|
|
189
|
+
return this.versions.length > 0;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** A single version has nothing to choose, so it renders read-only. */
|
|
193
|
+
get isVersionReadOnly(): boolean {
|
|
194
|
+
return this.versions.length === 1;
|
|
195
|
+
}
|
|
196
|
+
|
|
155
197
|
// Reads stored back target
|
|
156
198
|
private getBackTargetFromSession(): string | null {
|
|
157
199
|
return sessionStorage.getItem(BACK_TARGET_STORAGE_KEY);
|
|
@@ -515,6 +557,9 @@ export default class RedocReference extends LightningElement {
|
|
|
515
557
|
const apiContentDiv = await this.waitForApiContent(redocContainer);
|
|
516
558
|
apiContentDiv.setAttribute("lwc:dom", "manual");
|
|
517
559
|
|
|
560
|
+
// White LNB background + divider between the sidebar and content.
|
|
561
|
+
this.injectRedocStyles(redocContainer);
|
|
562
|
+
|
|
518
563
|
const docPhaseInfo = this.getDocPhaseInfo();
|
|
519
564
|
if (docPhaseInfo) {
|
|
520
565
|
this.insertDocPhase(apiContentDiv, docPhaseInfo);
|
|
@@ -525,6 +570,9 @@ export default class RedocReference extends LightningElement {
|
|
|
525
570
|
// Inject the multi-spec project header into Redoc's left menu only.
|
|
526
571
|
this.insertSidebarNav(redocContainer);
|
|
527
572
|
|
|
573
|
+
// Restore the view selected before a version switch, if any.
|
|
574
|
+
this.restoreSelectedView();
|
|
575
|
+
|
|
528
576
|
// Wait for footer to be rendered before updating styles
|
|
529
577
|
requestAnimationFrame(() => {
|
|
530
578
|
this.updateRedocThirdColumnStyle(redocContainer);
|
|
@@ -553,6 +601,15 @@ export default class RedocReference extends LightningElement {
|
|
|
553
601
|
});
|
|
554
602
|
}
|
|
555
603
|
|
|
604
|
+
// Version picker, inserted directly above Redoc's built-in search box.
|
|
605
|
+
if (this.hasVersionPicker) {
|
|
606
|
+
const menuContent =
|
|
607
|
+
redocContainer.querySelector<HTMLElement>(".menu-content");
|
|
608
|
+
if (menuContent) {
|
|
609
|
+
this.insertVersionPicker(menuContent);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
|
|
556
613
|
// Locale picker
|
|
557
614
|
if (this.hasLocalePicker) {
|
|
558
615
|
const menuContent = redocContainer.querySelector(".menu-content");
|
|
@@ -560,6 +617,133 @@ export default class RedocReference extends LightningElement {
|
|
|
560
617
|
}
|
|
561
618
|
}
|
|
562
619
|
|
|
620
|
+
/**
|
|
621
|
+
* Inserts the version picker into Redoc's left menu, directly above its
|
|
622
|
+
* built-in search box (per the design). Redoc renders the menu
|
|
623
|
+
* asynchronously and uses hashed styled-component class names, so we poll
|
|
624
|
+
* for the search box via a set of stable, semantic selectors and fall back
|
|
625
|
+
* to prepending if it never appears.
|
|
626
|
+
*/
|
|
627
|
+
private async insertVersionPicker(menuContent: HTMLElement): Promise<void> {
|
|
628
|
+
const pickerDom = this.buildVersionPickerDom();
|
|
629
|
+
|
|
630
|
+
const found = await pollUntil(
|
|
631
|
+
() => !!this.findSearchBox(menuContent),
|
|
632
|
+
ELEMENT_CHECK_INTERVAL,
|
|
633
|
+
ELEMENT_TIMEOUT
|
|
634
|
+
);
|
|
635
|
+
|
|
636
|
+
const searchBox = found ? this.findSearchBox(menuContent) : null;
|
|
637
|
+
if (searchBox) {
|
|
638
|
+
// Insert before the search box's top-level child of `.menu-content`.
|
|
639
|
+
let topLevelNode: HTMLElement = searchBox;
|
|
640
|
+
while (
|
|
641
|
+
topLevelNode.parentElement &&
|
|
642
|
+
topLevelNode.parentElement !== menuContent
|
|
643
|
+
) {
|
|
644
|
+
topLevelNode = topLevelNode.parentElement;
|
|
645
|
+
}
|
|
646
|
+
menuContent.insertBefore(pickerDom, topLevelNode);
|
|
647
|
+
} else {
|
|
648
|
+
console.warn(
|
|
649
|
+
"Redoc search box not found; prepending version picker to menu."
|
|
650
|
+
);
|
|
651
|
+
menuContent.insertBefore(pickerDom, menuContent.firstChild);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
/** Finds Redoc's search box via stable, semantic selectors. */
|
|
656
|
+
private findSearchBox(menuContent: HTMLElement): HTMLElement | null {
|
|
657
|
+
return menuContent.querySelector<HTMLElement>(
|
|
658
|
+
'[role="search"], .search-input, input[type="search"], input[placeholder*="Search" i]'
|
|
659
|
+
);
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/** Builds the version picker DOM by reusing `doc-version-picker`. */
|
|
663
|
+
private buildVersionPickerDom(): HTMLElement {
|
|
664
|
+
const wrapper = document.createElement("div");
|
|
665
|
+
wrapper.className = "redoc-version-picker";
|
|
666
|
+
|
|
667
|
+
const picker = createElement("doc-version-picker", {
|
|
668
|
+
is: VersionPicker
|
|
669
|
+
});
|
|
670
|
+
|
|
671
|
+
Object.assign(picker, {
|
|
672
|
+
versions: this.versions,
|
|
673
|
+
selectedVersion: this.selectedVersion,
|
|
674
|
+
latestVersion: this.latestVersion,
|
|
675
|
+
readOnly: this.isVersionReadOnly
|
|
676
|
+
});
|
|
677
|
+
picker.addEventListener("change", this.onVersionChange);
|
|
678
|
+
wrapper.appendChild(picker);
|
|
679
|
+
|
|
680
|
+
return wrapper;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* Stashes the current view (Redoc's operation anchor is the URL hash) before
|
|
685
|
+
* the version link navigates, so `restoreSelectedView` can re-apply it once
|
|
686
|
+
* the target version has loaded.
|
|
687
|
+
*/
|
|
688
|
+
private onVersionChange = (): void => {
|
|
689
|
+
sessionStorage.setItem(
|
|
690
|
+
SELECTED_VIEW_STORAGE_KEY,
|
|
691
|
+
window.location.hash || ""
|
|
692
|
+
);
|
|
693
|
+
};
|
|
694
|
+
|
|
695
|
+
/**
|
|
696
|
+
* Re-applies the view (operation anchor) that was active before a version
|
|
697
|
+
* switch. The version link navigates to the target version's root (no
|
|
698
|
+
* hash), so if a hash was stashed and its target exists in the new spec, we
|
|
699
|
+
* restore it; `handleInitialHashScrollFix` then corrects the scroll offset.
|
|
700
|
+
* A missing anchor is a no-op (lands on the spec root).
|
|
701
|
+
*/
|
|
702
|
+
private restoreSelectedView(): void {
|
|
703
|
+
const storedHash = sessionStorage.getItem(SELECTED_VIEW_STORAGE_KEY);
|
|
704
|
+
sessionStorage.removeItem(SELECTED_VIEW_STORAGE_KEY);
|
|
705
|
+
|
|
706
|
+
if (!storedHash || window.location.hash) {
|
|
707
|
+
return;
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
const targetId = storedHash.replace(/^#/, "");
|
|
711
|
+
if (targetId && document.getElementById(targetId)) {
|
|
712
|
+
window.location.hash = storedHash;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* Injects a scoped stylesheet into Redoc's light-DOM container so the LNB
|
|
718
|
+
* matches the design: white background with a divider between the sidebar
|
|
719
|
+
* and the main content. Component-scoped CSS can't reach Redoc's light DOM,
|
|
720
|
+
* hence the injected `<style>`. Guarded against duplicate insertion.
|
|
721
|
+
*
|
|
722
|
+
* Also suppresses `doc-version-picker`'s own top/bottom dividers for this
|
|
723
|
+
* placement — those are sidebar chrome for other consumers, but the design
|
|
724
|
+
* shows no line between the picker and Redoc's search box. Set via the
|
|
725
|
+
* picker's `--doc-version-picker-divider` custom property, which inherits
|
|
726
|
+
* through the shadow boundary.
|
|
727
|
+
*/
|
|
728
|
+
private injectRedocStyles(redocContainer: HTMLElement): void {
|
|
729
|
+
if (redocContainer.querySelector("style[data-redoc-reference]")) {
|
|
730
|
+
return;
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
const style = document.createElement("style");
|
|
734
|
+
style.setAttribute("data-redoc-reference", "");
|
|
735
|
+
style.textContent = `
|
|
736
|
+
.redoc-container .menu-content {
|
|
737
|
+
background: white;
|
|
738
|
+
border-right: 1px solid var(--dx-g-gray-90);
|
|
739
|
+
}
|
|
740
|
+
.redoc-version-picker {
|
|
741
|
+
--doc-version-picker-divider: none;
|
|
742
|
+
}
|
|
743
|
+
`;
|
|
744
|
+
redocContainer.appendChild(style);
|
|
745
|
+
}
|
|
746
|
+
|
|
563
747
|
/**
|
|
564
748
|
* Builds the locale picker DOM by reusing `dx-sidebar-footer-nav`
|
|
565
749
|
*/
|
|
@@ -4,26 +4,40 @@
|
|
|
4
4
|
:host {
|
|
5
5
|
--dx-c-dropdown-option-font-weight: normal;
|
|
6
6
|
--dx-c-dropdown-option-label-color: var(--dx-g-gray-10);
|
|
7
|
+
--dx-c-dropdown-option-padding: var(--dx-g-spacing-sm)
|
|
8
|
+
var(--dx-g-spacing-lg);
|
|
9
|
+
--dx-c-popover-padding: var(--dx-g-spacing-sm) 0;
|
|
7
10
|
--popover-container-open-transform: translateY(4px);
|
|
8
11
|
}
|
|
9
12
|
|
|
10
13
|
.version-picker-container {
|
|
11
14
|
padding: 8px var(--dx-g-spacing-lg) 8px
|
|
12
15
|
var(--dx-g-global-header-padding-horizontal);
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
|
|
17
|
+
/* Consumers can suppress or restyle the dividers via
|
|
18
|
+
--doc-version-picker-divider (e.g. `none`); defaults to the sidebar rule. */
|
|
19
|
+
border-top: var(
|
|
20
|
+
--doc-version-picker-divider,
|
|
21
|
+
1px solid var(--dx-g-gray-90)
|
|
22
|
+
);
|
|
23
|
+
border-bottom: var(
|
|
24
|
+
--doc-version-picker-divider,
|
|
25
|
+
1px solid var(--dx-g-gray-90)
|
|
26
|
+
);
|
|
15
27
|
}
|
|
16
28
|
|
|
17
29
|
.version-picker-button {
|
|
18
30
|
display: flex;
|
|
19
31
|
width: var(--doc-version-picker-width, 296px);
|
|
32
|
+
|
|
33
|
+
--dx-c-button-horizontal-spacing: var(--dx-g-spacing-sm);
|
|
34
|
+
--dx-g-button-icon-color: var(--dx-g-gray-50);
|
|
20
35
|
}
|
|
21
36
|
|
|
22
37
|
.version-picker-button:hover,
|
|
23
|
-
.version-picker-button:
|
|
24
|
-
.version-picker-button
|
|
25
|
-
--dx-
|
|
26
|
-
--dx-c-button-primary-color: var(--dx-g-blue-vibrant-40);
|
|
38
|
+
.version-picker-button:focus-within,
|
|
39
|
+
.version-picker-button[aria-expanded="true"] {
|
|
40
|
+
--dx-g-button-icon-color: var(--dx-g-blue-vibrant-20);
|
|
27
41
|
}
|
|
28
42
|
|
|
29
43
|
/**
|
|
@@ -35,6 +49,27 @@ dx-button::part(content) {
|
|
|
35
49
|
overflow: hidden;
|
|
36
50
|
}
|
|
37
51
|
|
|
52
|
+
/* The border is an inset box-shadow so thickening it on hover/focus doesn't
|
|
53
|
+
resize the small variant's fit-content box. */
|
|
54
|
+
.version-picker-button::part(container) {
|
|
55
|
+
background: white;
|
|
56
|
+
box-shadow: inset 0 0 0 1px var(--dx-g-gray-50);
|
|
57
|
+
color: var(--dx-g-gray-10);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.version-picker-button::part(container):hover {
|
|
61
|
+
background: var(--dx-g-blue-vibrant-95);
|
|
62
|
+
box-shadow: inset 0 0 0 2px var(--dx-g-blue-vibrant-20);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* aria-expanded keeps the focus ring while the menu is open. */
|
|
66
|
+
.version-picker-button:focus-within::part(container),
|
|
67
|
+
.version-picker-button[aria-expanded="true"]::part(container) {
|
|
68
|
+
background: var(--dx-g-blue-vibrant-95);
|
|
69
|
+
box-shadow: inset 0 0 0 2px var(--dx-g-blue-vibrant-20), 0 0 0 2px white,
|
|
70
|
+
0 0 0 4px var(--dx-g-blue-vibrant-60);
|
|
71
|
+
}
|
|
72
|
+
|
|
38
73
|
.selected-version {
|
|
39
74
|
display: flex;
|
|
40
75
|
flex-direction: row;
|
|
@@ -49,17 +84,8 @@ dx-button::part(content) {
|
|
|
49
84
|
white-space: nowrap;
|
|
50
85
|
}
|
|
51
86
|
|
|
52
|
-
dx-type-badge.latest-badge
|
|
53
|
-
--dx-c-type-badge-color: var(--dx-g-green-vibrant-40);
|
|
54
|
-
--dx-c-type-badge-background: var(--dx-g-green-vibrant-95);
|
|
55
|
-
|
|
56
|
-
margin-left: var(--dx-g-spacing-sm);
|
|
57
|
-
}
|
|
58
|
-
|
|
87
|
+
dx-type-badge.latest-badge,
|
|
59
88
|
dx-type-badge.not-latest-badge {
|
|
60
|
-
--dx-c-type-badge-color: var(--dx-g-red-vibrant-40);
|
|
61
|
-
--dx-c-type-badge-background: var(--dx-g-red-vibrant-95);
|
|
62
|
-
|
|
63
89
|
margin-left: var(--dx-g-spacing-sm);
|
|
64
90
|
}
|
|
65
91
|
|
|
@@ -67,26 +93,23 @@ dx-type-badge.not-latest-badge {
|
|
|
67
93
|
* Small "dot" variant (opt-in via `small`). Additive
|
|
68
94
|
* ------------------------------------------------------------------ */
|
|
69
95
|
|
|
70
|
-
/*
|
|
96
|
+
/* Option padding is sm both axes: the small menu tracks the ~104px trigger, so
|
|
97
|
+
the default 24px horizontal would crowd the labels. */
|
|
71
98
|
.version-picker-dropdown-small {
|
|
72
99
|
--dx-c-dropdown-option-font-size: var(--dx-g-text-xs);
|
|
73
100
|
--dx-c-dropdown-option-padding: var(--dx-g-spacing-sm)
|
|
74
|
-
var(--dx-g-spacing-
|
|
101
|
+
var(--dx-g-spacing-sm);
|
|
75
102
|
--dx-c-dropdown-option-border-radius: 0;
|
|
76
103
|
--dx-c-popover-border: none;
|
|
77
|
-
--dx-c-popover-padding: var(--dx-g-spacing-sm) 0;
|
|
78
104
|
}
|
|
79
105
|
|
|
80
106
|
.version-picker-button-small {
|
|
81
|
-
display: flex;
|
|
82
107
|
width: fit-content;
|
|
83
108
|
max-width: 104px;
|
|
84
|
-
border-radius: var(--dx-g-spacing-xs);
|
|
85
109
|
|
|
86
110
|
--dx-c-button-font-size: var(--dx-g-text-xs);
|
|
87
111
|
--dx-c-button-font-weight: var(--dx-g-font-normal);
|
|
88
|
-
--dx-c-button-line-height:
|
|
89
|
-
--dx-g-button-icon-color: var(--dx-g-gray-50);
|
|
112
|
+
--dx-c-button-line-height: var(--dx-g-spacing-lg);
|
|
90
113
|
--dx-c-button-icon-gap: var(--dx-g-spacing-2xs);
|
|
91
114
|
}
|
|
92
115
|
|
|
@@ -101,43 +124,12 @@ dx-type-badge.not-latest-badge {
|
|
|
101
124
|
overflow: hidden;
|
|
102
125
|
}
|
|
103
126
|
|
|
104
|
-
|
|
105
|
-
.
|
|
106
|
-
box-sizing: border-box;
|
|
107
|
-
height: var(--dx-g-spacing-lg);
|
|
108
|
-
padding: 0 var(--dx-g-spacing-xs);
|
|
109
|
-
border-radius: var(--dx-g-spacing-xs);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/* Border is an inset box-shadow, not a real border, so thickening it on
|
|
113
|
-
hover/focus doesn't widen the fit-content box (no horizontal shift). */
|
|
127
|
+
/* width:100% re-ties to the 104px-capped host (container is width:inherit,
|
|
128
|
+
which copies width but not max-width). Border/bg/states are shared above. */
|
|
114
129
|
.version-picker-button-small::part(container) {
|
|
115
|
-
/* width:100% re-ties to the 104px-capped host (container is width:inherit,
|
|
116
|
-
which copies width but not max-width). */
|
|
117
130
|
width: 100%;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
color: var(--dx-g-gray-10);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
.version-picker-button-small::part(container):hover {
|
|
124
|
-
background: var(--dx-g-blue-vibrant-95);
|
|
125
|
-
box-shadow: inset 0 0 0 2px var(--dx-g-blue-vibrant-20);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
.version-picker-button-small:hover,
|
|
129
|
-
.version-picker-button-small:focus-within,
|
|
130
|
-
.version-picker-button-small[aria-expanded="true"] {
|
|
131
|
-
--dx-g-button-icon-color: var(--dx-g-blue-vibrant-20);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/* Also matches aria-expanded so the ring stays while the menu is open (opening
|
|
135
|
-
moves focus into the menu, which would otherwise drop :focus-within). */
|
|
136
|
-
.version-picker-button-small:focus-within::part(container),
|
|
137
|
-
.version-picker-button-small[aria-expanded="true"]::part(container) {
|
|
138
|
-
background: var(--dx-g-blue-vibrant-95);
|
|
139
|
-
box-shadow: inset 0 0 0 2px var(--dx-g-blue-vibrant-20), 0 0 0 2px white,
|
|
140
|
-
0 0 0 4px var(--dx-g-blue-vibrant-60);
|
|
131
|
+
height: var(--dx-g-spacing-lg);
|
|
132
|
+
padding: 0 var(--dx-g-spacing-xs);
|
|
141
133
|
}
|
|
142
134
|
|
|
143
135
|
.selected-version-small {
|
|
@@ -161,16 +153,31 @@ dx-type-badge.not-latest-badge {
|
|
|
161
153
|
background: var(--dx-g-yellow-vibrant-80);
|
|
162
154
|
}
|
|
163
155
|
|
|
164
|
-
|
|
156
|
+
/* inline-block (not flex) so the label can truncate; line-height centers it. */
|
|
157
|
+
.version-picker-readonly {
|
|
158
|
+
box-sizing: border-box;
|
|
165
159
|
display: inline-block;
|
|
166
|
-
width:
|
|
167
|
-
|
|
160
|
+
width: var(--doc-version-picker-width, 296px);
|
|
161
|
+
height: var(--dx-g-spacing-xl);
|
|
168
162
|
margin: 0;
|
|
163
|
+
padding: 0 var(--dx-g-spacing-sm);
|
|
169
164
|
border: 1px solid var(--dx-g-gray-80);
|
|
165
|
+
border-radius: var(--dx-g-spacing-xs);
|
|
170
166
|
overflow: hidden;
|
|
171
167
|
color: var(--dx-g-gray-10);
|
|
172
168
|
text-overflow: ellipsis;
|
|
173
169
|
white-space: nowrap;
|
|
174
|
-
font: var(--dx-g-font-normal) var(--dx-g-text-
|
|
175
|
-
|
|
170
|
+
font: var(--dx-g-font-normal) var(--dx-g-text-sm) / var(--dx-g-spacing-xl)
|
|
171
|
+
var(--dx-g-font-sans),
|
|
172
|
+
sans-serif;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.version-picker-readonly-small {
|
|
176
|
+
width: fit-content;
|
|
177
|
+
max-width: 104px;
|
|
178
|
+
height: var(--dx-g-spacing-lg);
|
|
179
|
+
padding: 0 var(--dx-g-spacing-xs);
|
|
180
|
+
font: var(--dx-g-font-normal) var(--dx-g-text-xs) / var(--dx-g-spacing-lg)
|
|
181
|
+
var(--dx-g-font-sans),
|
|
182
|
+
sans-serif;
|
|
176
183
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div lwc:if={showVersionPicker} class="version-picker-container">
|
|
3
3
|
<!-- Small read-only: plain value, no dropdown -->
|
|
4
|
-
<p
|
|
4
|
+
<p
|
|
5
|
+
lwc:if={readOnly}
|
|
6
|
+
class={readOnlyClass}
|
|
7
|
+
title={selectedVersion.label}
|
|
8
|
+
>
|
|
5
9
|
{selectedVersion.label}
|
|
6
10
|
</p>
|
|
7
11
|
|
|
@@ -12,14 +16,14 @@
|
|
|
12
16
|
analytics-event="custEv_docVersionSelect"
|
|
13
17
|
analytics-payload={analyticsPayload}
|
|
14
18
|
value={selectedVersion.id}
|
|
15
|
-
width=
|
|
19
|
+
full-width="true"
|
|
16
20
|
onchange={onVersionChange}
|
|
17
21
|
>
|
|
18
22
|
<dx-button
|
|
19
23
|
class={triggerClass}
|
|
20
24
|
variant="tertiary"
|
|
21
25
|
size="small"
|
|
22
|
-
font=
|
|
26
|
+
font="sans"
|
|
23
27
|
icon-symbol="chevrondown"
|
|
24
28
|
icon-size={triggerIconSize}
|
|
25
29
|
aria-label={triggerAriaLabel}
|
|
@@ -30,25 +34,33 @@
|
|
|
30
34
|
<template lwc:if={showLatestTag}>
|
|
31
35
|
<span class={dotClass} aria-hidden="true"></span>
|
|
32
36
|
</template>
|
|
33
|
-
<p
|
|
37
|
+
<p
|
|
38
|
+
class="selected-version-label"
|
|
39
|
+
title={selectedVersion.label}
|
|
40
|
+
>
|
|
34
41
|
{selectedVersion.label}
|
|
35
42
|
</p>
|
|
36
43
|
</template>
|
|
37
44
|
<!-- Default: trailing Latest/Not-Latest badge -->
|
|
38
45
|
<template lwc:else>
|
|
39
|
-
<p
|
|
46
|
+
<p
|
|
47
|
+
class="selected-version-label"
|
|
48
|
+
title={selectedVersion.label}
|
|
49
|
+
>
|
|
40
50
|
{selectedVersion.label}
|
|
41
51
|
</p>
|
|
42
52
|
<template lwc:if={showLatestTag}>
|
|
43
53
|
<dx-type-badge
|
|
44
54
|
class="latest-badge"
|
|
45
55
|
lwc:if={latestVersion}
|
|
56
|
+
variant="status-success"
|
|
46
57
|
value="Latest"
|
|
47
58
|
size="small"
|
|
48
59
|
></dx-type-badge>
|
|
49
60
|
<dx-type-badge
|
|
50
61
|
class="not-latest-badge"
|
|
51
62
|
lwc:else
|
|
63
|
+
variant="status-warning"
|
|
52
64
|
value="Not Latest"
|
|
53
65
|
size="small"
|
|
54
66
|
></dx-type-badge>
|
|
@@ -83,9 +83,11 @@ export default class VersionPicker extends LightningElement {
|
|
|
83
83
|
return !this.hideBadge;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
// Read-only currently only has a small-variant style.
|
|
87
86
|
private get readOnlyClass(): string {
|
|
88
|
-
return
|
|
87
|
+
return cx(
|
|
88
|
+
"version-picker-readonly",
|
|
89
|
+
this.small && "version-picker-readonly-small"
|
|
90
|
+
);
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
private get dotClass(): string {
|
|
@@ -108,9 +110,7 @@ export default class VersionPicker extends LightningElement {
|
|
|
108
110
|
}
|
|
109
111
|
|
|
110
112
|
// --- Per-variant values for the shared dropdown/button markup below. The
|
|
111
|
-
// small variant opts into extra classes and a compact chevron
|
|
112
|
-
// returns undefined so those attributes are omitted (keeps default output
|
|
113
|
-
// unchanged for xmlContent/amfReference).
|
|
113
|
+
// small variant opts into extra classes and a compact chevron.
|
|
114
114
|
|
|
115
115
|
// Not cx(): the default must have NO class attribute (cx returns "", which
|
|
116
116
|
// would render class="" and break the frozen consumer snapshots).
|
|
@@ -118,10 +118,6 @@ export default class VersionPicker extends LightningElement {
|
|
|
118
118
|
return this.small ? "version-picker-dropdown-small" : undefined;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
private get dropdownWidth(): string | undefined {
|
|
122
|
-
return this.small ? undefined : "var(--doc-version-picker-width)";
|
|
123
|
-
}
|
|
124
|
-
|
|
125
121
|
private get triggerClass(): string {
|
|
126
122
|
return cx(
|
|
127
123
|
"version-picker-button",
|
|
@@ -129,10 +125,6 @@ export default class VersionPicker extends LightningElement {
|
|
|
129
125
|
);
|
|
130
126
|
}
|
|
131
127
|
|
|
132
|
-
private get triggerFont(): string {
|
|
133
|
-
return this.small ? "sans" : "display";
|
|
134
|
-
}
|
|
135
|
-
|
|
136
128
|
private get triggerIconSize(): string {
|
|
137
129
|
return this.small ? "xsmall" : "medium";
|
|
138
130
|
}
|
|
@@ -144,10 +136,7 @@ export default class VersionPicker extends LightningElement {
|
|
|
144
136
|
}
|
|
145
137
|
|
|
146
138
|
private get selectedVersionClass(): string {
|
|
147
|
-
return cx(
|
|
148
|
-
"selected-version",
|
|
149
|
-
this.small && "selected-version-small"
|
|
150
|
-
);
|
|
139
|
+
return cx("selected-version", this.small && "selected-version-small");
|
|
151
140
|
}
|
|
152
141
|
|
|
153
142
|
private onVersionChange(e: CustomEvent) {
|