@salesforcedevs/docs-components 1.34.0-docs-feedback-4 → 1.34.0-integration-alpha
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 +2 -3
- package/src/modules/doc/header/header.ts +3 -14
- package/src/modules/doc/unifiedContentLayout/unifiedContentLayout.ts +16 -48
- package/src/modules/doc/versionPicker/versionPicker.css +137 -12
- package/src/modules/doc/versionPicker/versionPicker.html +54 -21
- package/src/modules/doc/versionPicker/versionPicker.ts +86 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/docs-components",
|
|
3
|
-
"version": "1.34.0-
|
|
3
|
+
"version": "1.34.0-integration-alpha",
|
|
4
4
|
"description": "Docs Lightning web components for DSC",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "index.js",
|
|
@@ -25,6 +25,5 @@
|
|
|
25
25
|
"@types/lodash.orderby": "4.6.9",
|
|
26
26
|
"@types/lodash.uniqby": "4.7.9"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "4629fdd9ca18a13480044ad43515b91945d16aad"
|
|
29
|
-
"stableVersion": "1.34.0"
|
|
28
|
+
"gitHead": "4629fdd9ca18a13480044ad43515b91945d16aad"
|
|
30
29
|
}
|
|
@@ -74,13 +74,6 @@ 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
|
-
|
|
84
77
|
connectedCallback(): void {
|
|
85
78
|
super.connectedCallback();
|
|
86
79
|
this.tabletMatchMedia = window.matchMedia(
|
|
@@ -90,7 +83,9 @@ export default class Header extends HeaderBase {
|
|
|
90
83
|
this.tabletMatchMedia.addEventListener("change", this.onTabletChange);
|
|
91
84
|
|
|
92
85
|
if (
|
|
93
|
-
(!this.shouldHideHeader &&
|
|
86
|
+
(!this.shouldHideHeader &&
|
|
87
|
+
window.location.pathname.includes("/docs/") &&
|
|
88
|
+
window.location.pathname !== "/docs/apis") ||
|
|
94
89
|
window.location.pathname ===
|
|
95
90
|
"/tableau/embedding-playground/overview" ||
|
|
96
91
|
isStorybook()
|
|
@@ -114,12 +109,6 @@ export default class Header extends HeaderBase {
|
|
|
114
109
|
);
|
|
115
110
|
}
|
|
116
111
|
|
|
117
|
-
renderedCallback(): void {
|
|
118
|
-
if (this.hideDocHeader) {
|
|
119
|
-
this.shouldRender = !this.shouldHideHeader && this.isDocsPath;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
112
|
private onTabletChange = (e: MediaQueryListEvent | MediaQueryList) =>
|
|
124
113
|
(this.tablet = e.matches);
|
|
125
114
|
|
|
@@ -10,63 +10,29 @@ 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
|
-
|
|
39
13
|
/**
|
|
40
14
|
* Translates per-topic `topicType` into the generic `showForwardArrow` flag
|
|
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
|
|
15
|
+
* that `dx-tree-tile` reads (spec topics get the forward arrow icon for Redoc).
|
|
43
16
|
*/
|
|
44
|
-
function
|
|
45
|
-
topics:
|
|
17
|
+
function decorateTopicsWithForwardArrow(
|
|
18
|
+
topics:
|
|
19
|
+
| Array<TreeNode & { topicType?: string; versions?: unknown }>
|
|
20
|
+
| undefined
|
|
46
21
|
): TreeNode[] | undefined {
|
|
47
22
|
return topics?.map((topic) => {
|
|
48
|
-
const { topicType, ...decorated } = topic;
|
|
23
|
+
const { topicType, versions, ...decorated } = topic;
|
|
49
24
|
if (topicType === TOPIC_TYPE_SPEC) {
|
|
50
25
|
decorated.showForwardArrow = true;
|
|
26
|
+
// Nested and standalone specs never get a sidebar picker; only the
|
|
27
|
+
// parent MD topic (when versioned) shows one.
|
|
28
|
+
} else if (versions) {
|
|
29
|
+
decorated.versions = versions;
|
|
51
30
|
}
|
|
52
31
|
if (decorated.children) {
|
|
53
|
-
decorated.children =
|
|
32
|
+
decorated.children = decorateTopicsWithForwardArrow(
|
|
33
|
+
decorated.children
|
|
34
|
+
);
|
|
54
35
|
}
|
|
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
|
-
|
|
70
36
|
return decorated;
|
|
71
37
|
});
|
|
72
38
|
}
|
|
@@ -117,7 +83,9 @@ export default class UnifiedContentLayout extends LightningElement {
|
|
|
117
83
|
}
|
|
118
84
|
|
|
119
85
|
set sidebarContent(value: string) {
|
|
120
|
-
this._sidebarContent =
|
|
86
|
+
this._sidebarContent = decorateTopicsWithForwardArrow(
|
|
87
|
+
toJson(value)?.topics
|
|
88
|
+
);
|
|
121
89
|
}
|
|
122
90
|
|
|
123
91
|
private get enableFooter(): boolean {
|
|
@@ -4,9 +4,18 @@
|
|
|
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
|
|
|
13
|
+
/* Open menus must stack above later sibling pickers in the sidebar. */
|
|
14
|
+
:host(:has([aria-expanded="true"])) {
|
|
15
|
+
position: relative;
|
|
16
|
+
z-index: 2;
|
|
17
|
+
}
|
|
18
|
+
|
|
10
19
|
.version-picker-container {
|
|
11
20
|
padding: 8px var(--dx-g-spacing-lg) 8px
|
|
12
21
|
var(--dx-g-global-header-padding-horizontal);
|
|
@@ -14,16 +23,27 @@
|
|
|
14
23
|
border-bottom: 1px solid var(--dx-g-gray-90);
|
|
15
24
|
}
|
|
16
25
|
|
|
26
|
+
/* Inline sidebar variant: drop the header-slot chrome so the picker sits
|
|
27
|
+
beside a tree node without extra padding or divider lines. */
|
|
28
|
+
.version-picker-container-small {
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
padding: 0;
|
|
32
|
+
border: none;
|
|
33
|
+
}
|
|
34
|
+
|
|
17
35
|
.version-picker-button {
|
|
18
36
|
display: flex;
|
|
19
37
|
width: var(--doc-version-picker-width, 296px);
|
|
38
|
+
|
|
39
|
+
--dx-c-button-horizontal-spacing: var(--dx-g-spacing-sm);
|
|
40
|
+
--dx-g-button-icon-color: var(--dx-g-gray-50);
|
|
20
41
|
}
|
|
21
42
|
|
|
22
43
|
.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);
|
|
44
|
+
.version-picker-button:focus-within,
|
|
45
|
+
.version-picker-button[aria-expanded="true"] {
|
|
46
|
+
--dx-g-button-icon-color: var(--dx-g-blue-vibrant-20);
|
|
27
47
|
}
|
|
28
48
|
|
|
29
49
|
/**
|
|
@@ -35,6 +55,27 @@ dx-button::part(content) {
|
|
|
35
55
|
overflow: hidden;
|
|
36
56
|
}
|
|
37
57
|
|
|
58
|
+
/* The border is an inset box-shadow so thickening it on hover/focus doesn't
|
|
59
|
+
resize the small variant's fit-content box. */
|
|
60
|
+
.version-picker-button::part(container) {
|
|
61
|
+
background: white;
|
|
62
|
+
box-shadow: inset 0 0 0 1px var(--dx-g-gray-50);
|
|
63
|
+
color: var(--dx-g-gray-10);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.version-picker-button::part(container):hover {
|
|
67
|
+
background: var(--dx-g-blue-vibrant-95);
|
|
68
|
+
box-shadow: inset 0 0 0 2px var(--dx-g-blue-vibrant-20);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* aria-expanded keeps the focus ring while the menu is open. */
|
|
72
|
+
.version-picker-button:focus-within::part(container),
|
|
73
|
+
.version-picker-button[aria-expanded="true"]::part(container) {
|
|
74
|
+
background: var(--dx-g-blue-vibrant-95);
|
|
75
|
+
box-shadow: inset 0 0 0 2px var(--dx-g-blue-vibrant-20), 0 0 0 2px white,
|
|
76
|
+
0 0 0 4px var(--dx-g-blue-vibrant-60);
|
|
77
|
+
}
|
|
78
|
+
|
|
38
79
|
.selected-version {
|
|
39
80
|
display: flex;
|
|
40
81
|
flex-direction: row;
|
|
@@ -49,16 +90,100 @@ dx-button::part(content) {
|
|
|
49
90
|
white-space: nowrap;
|
|
50
91
|
}
|
|
51
92
|
|
|
52
|
-
dx-type-badge.latest-badge
|
|
53
|
-
|
|
54
|
-
--dx-c-type-badge-background: var(--dx-g-green-vibrant-95);
|
|
55
|
-
|
|
93
|
+
dx-type-badge.latest-badge,
|
|
94
|
+
dx-type-badge.not-latest-badge {
|
|
56
95
|
margin-left: var(--dx-g-spacing-sm);
|
|
57
96
|
}
|
|
58
97
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
98
|
+
/* ------------------------------------------------------------------ *
|
|
99
|
+
* Small "dot" variant (opt-in via `small`). Additive
|
|
100
|
+
* ------------------------------------------------------------------ */
|
|
62
101
|
|
|
63
|
-
|
|
102
|
+
/* Option padding is sm both axes: the small menu tracks the ~104px trigger, so
|
|
103
|
+
the default 24px horizontal would crowd the labels. */
|
|
104
|
+
.version-picker-dropdown-small {
|
|
105
|
+
--dx-c-dropdown-option-font-size: var(--dx-g-text-xs);
|
|
106
|
+
--dx-c-dropdown-option-padding: var(--dx-g-spacing-sm)
|
|
107
|
+
var(--dx-g-spacing-sm);
|
|
108
|
+
--dx-c-dropdown-option-border-radius: 0;
|
|
109
|
+
--dx-c-popover-border: none;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.version-picker-button-small {
|
|
113
|
+
width: fit-content;
|
|
114
|
+
max-width: 104px;
|
|
115
|
+
|
|
116
|
+
--dx-c-button-font-size: var(--dx-g-text-xs);
|
|
117
|
+
--dx-c-button-font-weight: var(--dx-g-font-normal);
|
|
118
|
+
--dx-c-button-line-height: var(--dx-g-spacing-lg);
|
|
119
|
+
--dx-c-button-icon-gap: var(--dx-g-spacing-2xs);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/* min-width: 0 on each flex ancestor lets the label truncate: a flex item's
|
|
123
|
+
default min-width: auto refuses to shrink below its content and overrides the
|
|
124
|
+
host's max-width, so without this the trigger overflows instead. */
|
|
125
|
+
.version-picker-button-small::part(content) {
|
|
126
|
+
display: flex;
|
|
127
|
+
flex: 1;
|
|
128
|
+
min-width: 0;
|
|
129
|
+
width: auto;
|
|
130
|
+
overflow: hidden;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/* width:100% re-ties to the 104px-capped host (container is width:inherit,
|
|
134
|
+
which copies width but not max-width). Border/bg/states are shared above. */
|
|
135
|
+
.version-picker-button-small::part(container) {
|
|
136
|
+
width: 100%;
|
|
137
|
+
height: var(--dx-g-spacing-lg);
|
|
138
|
+
padding: 0 var(--dx-g-spacing-xs);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.selected-version-small {
|
|
142
|
+
flex: 1;
|
|
143
|
+
min-width: 0;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.version-picker-dot {
|
|
147
|
+
flex: 0 0 auto;
|
|
148
|
+
width: var(--dx-g-spacing-sm);
|
|
149
|
+
height: var(--dx-g-spacing-sm);
|
|
150
|
+
margin-right: var(--dx-g-spacing-xs);
|
|
151
|
+
border-radius: 50%;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.version-picker-dot-latest {
|
|
155
|
+
background: var(--dx-g-green-vibrant-60);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.version-picker-dot-not-latest {
|
|
159
|
+
background: var(--dx-g-yellow-vibrant-80);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/* inline-block (not flex) so the label can truncate; line-height centers it. */
|
|
163
|
+
.version-picker-readonly {
|
|
164
|
+
box-sizing: border-box;
|
|
165
|
+
display: inline-block;
|
|
166
|
+
width: var(--doc-version-picker-width, 296px);
|
|
167
|
+
height: var(--dx-g-spacing-xl);
|
|
168
|
+
margin: 0;
|
|
169
|
+
padding: 0 var(--dx-g-spacing-sm);
|
|
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-sm) / var(--dx-g-spacing-xl)
|
|
177
|
+
var(--dx-g-font-sans),
|
|
178
|
+
sans-serif;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.version-picker-readonly-small {
|
|
182
|
+
width: fit-content;
|
|
183
|
+
max-width: 104px;
|
|
184
|
+
height: var(--dx-g-spacing-lg);
|
|
185
|
+
padding: 0 var(--dx-g-spacing-xs);
|
|
186
|
+
font: var(--dx-g-font-normal) var(--dx-g-text-xs) / var(--dx-g-spacing-lg)
|
|
187
|
+
var(--dx-g-font-sans),
|
|
188
|
+
sans-serif;
|
|
64
189
|
}
|
|
@@ -1,37 +1,70 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div lwc:if={showVersionPicker} class=
|
|
2
|
+
<div lwc:if={showVersionPicker} class={containerClass}>
|
|
3
|
+
<!-- Small read-only: plain value, no dropdown -->
|
|
4
|
+
<p
|
|
5
|
+
lwc:if={readOnly}
|
|
6
|
+
class={readOnlyClass}
|
|
7
|
+
title={selectedVersion.label}
|
|
8
|
+
>
|
|
9
|
+
{selectedVersion.label}
|
|
10
|
+
</p>
|
|
11
|
+
|
|
3
12
|
<dx-dropdown
|
|
13
|
+
lwc:else
|
|
14
|
+
class={dropdownClass}
|
|
4
15
|
options={versions}
|
|
5
16
|
analytics-event="custEv_docVersionSelect"
|
|
6
17
|
analytics-payload={analyticsPayload}
|
|
7
18
|
value={selectedVersion.id}
|
|
8
|
-
width="
|
|
19
|
+
full-width="true"
|
|
9
20
|
onchange={onVersionChange}
|
|
10
21
|
>
|
|
11
22
|
<dx-button
|
|
12
|
-
class=
|
|
23
|
+
class={triggerClass}
|
|
13
24
|
variant="tertiary"
|
|
14
25
|
size="small"
|
|
26
|
+
font="sans"
|
|
15
27
|
icon-symbol="chevrondown"
|
|
16
|
-
icon-size=
|
|
28
|
+
icon-size={triggerIconSize}
|
|
29
|
+
aria-label={triggerAriaLabel}
|
|
17
30
|
>
|
|
18
|
-
<div class=
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
<div class={selectedVersionClass}>
|
|
32
|
+
<!-- Small: leading colored dot -->
|
|
33
|
+
<template lwc:if={small}>
|
|
34
|
+
<template lwc:if={showLatestTag}>
|
|
35
|
+
<span class={dotClass} aria-hidden="true"></span>
|
|
36
|
+
</template>
|
|
37
|
+
<p
|
|
38
|
+
class="selected-version-label"
|
|
39
|
+
title={selectedVersion.label}
|
|
40
|
+
>
|
|
41
|
+
{selectedVersion.label}
|
|
42
|
+
</p>
|
|
43
|
+
</template>
|
|
44
|
+
<!-- Default: trailing Latest/Not-Latest badge -->
|
|
45
|
+
<template lwc:else>
|
|
46
|
+
<p
|
|
47
|
+
class="selected-version-label"
|
|
48
|
+
title={selectedVersion.label}
|
|
49
|
+
>
|
|
50
|
+
{selectedVersion.label}
|
|
51
|
+
</p>
|
|
52
|
+
<template lwc:if={showLatestTag}>
|
|
53
|
+
<dx-type-badge
|
|
54
|
+
class="latest-badge"
|
|
55
|
+
lwc:if={latestVersion}
|
|
56
|
+
variant="status-success"
|
|
57
|
+
value="Latest"
|
|
58
|
+
size="small"
|
|
59
|
+
></dx-type-badge>
|
|
60
|
+
<dx-type-badge
|
|
61
|
+
class="not-latest-badge"
|
|
62
|
+
lwc:else
|
|
63
|
+
variant="status-warning"
|
|
64
|
+
value="Not Latest"
|
|
65
|
+
size="small"
|
|
66
|
+
></dx-type-badge>
|
|
67
|
+
</template>
|
|
35
68
|
</template>
|
|
36
69
|
</div>
|
|
37
70
|
</dx-button>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LightningElement, api, track } from "lwc";
|
|
2
|
+
import cx from "classnames";
|
|
2
3
|
|
|
3
4
|
import { AnalyticsPayload, OptionWithNested } from "typings/custom";
|
|
4
5
|
|
|
@@ -12,6 +13,8 @@ export default class VersionPicker extends LightningElement {
|
|
|
12
13
|
private _selectedVersion?: OptionWithNested;
|
|
13
14
|
private _latestVersion: boolean = false;
|
|
14
15
|
private _hideBadge: boolean = false;
|
|
16
|
+
private _small: boolean = false;
|
|
17
|
+
private _readOnly: boolean = false;
|
|
15
18
|
|
|
16
19
|
@api
|
|
17
20
|
get versions() {
|
|
@@ -51,14 +54,97 @@ export default class VersionPicker extends LightningElement {
|
|
|
51
54
|
this._hideBadge = normalizeBoolean(value);
|
|
52
55
|
}
|
|
53
56
|
|
|
57
|
+
// Opt-in compact "dot" variant (24px, abbreviated label). Off by default so
|
|
58
|
+
// existing consumers render the default trigger unchanged.
|
|
59
|
+
@api
|
|
60
|
+
get small() {
|
|
61
|
+
return this._small;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
set small(value) {
|
|
65
|
+
this._small = normalizeBoolean(value);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Opt-in read-only state: plain value, no dropdown menu.
|
|
69
|
+
@api
|
|
70
|
+
get readOnly() {
|
|
71
|
+
return this._readOnly;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
set readOnly(value) {
|
|
75
|
+
this._readOnly = normalizeBoolean(value);
|
|
76
|
+
}
|
|
77
|
+
|
|
54
78
|
private get showVersionPicker() {
|
|
55
79
|
return this._versions && this._versions.length !== 0;
|
|
56
80
|
}
|
|
57
81
|
|
|
82
|
+
private get containerClass(): string {
|
|
83
|
+
return this.small
|
|
84
|
+
? "version-picker-container-small"
|
|
85
|
+
: "version-picker-container";
|
|
86
|
+
}
|
|
87
|
+
|
|
58
88
|
private get showLatestTag(): boolean {
|
|
59
89
|
return !this.hideBadge;
|
|
60
90
|
}
|
|
61
91
|
|
|
92
|
+
private get readOnlyClass(): string {
|
|
93
|
+
return cx(
|
|
94
|
+
"version-picker-readonly",
|
|
95
|
+
this.small && "version-picker-readonly-small"
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private get dotClass(): string {
|
|
100
|
+
return `version-picker-dot ${
|
|
101
|
+
this.latestVersion
|
|
102
|
+
? "version-picker-dot-latest"
|
|
103
|
+
: "version-picker-dot-not-latest"
|
|
104
|
+
}`;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Accessible name for the small trigger: includes the latest state so it
|
|
108
|
+
// isn't conveyed by the dot's color alone (WCAG 1.4.1). Omits the state
|
|
109
|
+
// when the indicator is hidden.
|
|
110
|
+
private get smallTriggerAriaLabel(): string {
|
|
111
|
+
const label = this.selectedVersion?.label ?? "";
|
|
112
|
+
if (!this.showLatestTag) {
|
|
113
|
+
return label;
|
|
114
|
+
}
|
|
115
|
+
return `${label}, ${this.latestVersion ? "Latest" : "Not Latest"}`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// --- Per-variant values for the shared dropdown/button markup below. The
|
|
119
|
+
// small variant opts into extra classes and a compact chevron.
|
|
120
|
+
|
|
121
|
+
// Not cx(): the default must have NO class attribute (cx returns "", which
|
|
122
|
+
// would render class="" and break the frozen consumer snapshots).
|
|
123
|
+
private get dropdownClass(): string | undefined {
|
|
124
|
+
return this.small ? "version-picker-dropdown-small" : undefined;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
private get triggerClass(): string {
|
|
128
|
+
return cx(
|
|
129
|
+
"version-picker-button",
|
|
130
|
+
this.small && "version-picker-button-small"
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private get triggerIconSize(): string {
|
|
135
|
+
return this.small ? "xsmall" : "medium";
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Default returns "" (dx-button's own default) so the trigger's rendered
|
|
139
|
+
// aria-label is unchanged for the default variant.
|
|
140
|
+
private get triggerAriaLabel(): string {
|
|
141
|
+
return this.small ? this.smallTriggerAriaLabel : "";
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
private get selectedVersionClass(): string {
|
|
145
|
+
return cx("selected-version", this.small && "selected-version-small");
|
|
146
|
+
}
|
|
147
|
+
|
|
62
148
|
private onVersionChange(e: CustomEvent) {
|
|
63
149
|
this.dispatchEvent(new CustomEvent("change", { detail: e.detail }));
|
|
64
150
|
}
|