@salesforcedevs/dx-components 1.40.6 → 1.40.7-tlv-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/lwc.config.json +3 -2
- package/package.json +46 -47
- package/src/modules/dx/button/button.css +2 -2
- package/src/modules/dx/dropdown/dropdown.css +29 -1
- package/src/modules/dx/dropdown/dropdown.html +1 -1
- package/src/modules/dx/dropdown/dropdown.ts +16 -1
- package/src/modules/dx/dropdownOption/dropdownOption.css +29 -6
- package/src/modules/dx/popover/popover.ts +119 -7
- package/src/modules/dx/searchHybrid/searchHybrid.html +1 -1
- package/src/modules/dx/searchHybrid/searchHybrid.ts +4 -0
- package/src/modules/dx/sidebar/sidebar.html +1 -0
- package/src/modules/dx/sidebarOld/sidebarOld.html +1 -0
- package/src/modules/dx/tree/tree.html +1 -0
- package/src/modules/dx/tree/tree.ts +5 -1
- package/src/modules/dx/tree/treeHandler.ts +85 -11
- package/src/modules/dx/treeItem/treeItem.css +30 -0
- package/src/modules/dx/treeItem/treeItem.html +17 -2
- package/src/modules/dx/treeItem/treeItem.ts +109 -11
- package/src/modules/dx/treeTile/treeTile.css +4 -0
- package/src/modules/dx/treeTile/treeTile.ts +12 -3
- package/src/modules/dx/typeBadge/typeBadge.ts +23 -2
- package/src/modules/dx/versionPicker/versionPicker.css +248 -0
- package/src/modules/dx/versionPicker/versionPicker.html +73 -0
- package/src/modules/dx/versionPicker/versionPicker.ts +157 -0
- package/src/modules/dxHelpers/commonSidebar/commonSidebar.css +3 -3
- package/src/modules/dxHelpers/commonTreeItem/commonTreeItem.css +4 -0
- package/src/modules/dxHelpers/typeBadge/typeBadge.css +22 -0
- package/src/modules/dxUtils/topicVersion/topicVersion.ts +511 -0
- package/LICENSE +0 -12
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import type { InternalTreeNode, TreeNode } from "typings/custom";
|
|
2
|
+
import type { TopicVersionOption } from "dxUtils/topicVersion";
|
|
3
|
+
import {
|
|
4
|
+
applyVersionToHref,
|
|
5
|
+
normalizePath,
|
|
6
|
+
resolveSelectedVersion
|
|
7
|
+
} from "dxUtils/topicVersion";
|
|
8
|
+
|
|
9
|
+
type VersionedTreeNode = TreeNode & { versions?: TopicVersionOption[] };
|
|
10
|
+
type VersionedInternalTreeNode = InternalTreeNode & {
|
|
11
|
+
versions?: TopicVersionOption[];
|
|
12
|
+
};
|
|
13
|
+
|
|
2
14
|
type MapItem = {
|
|
3
|
-
node:
|
|
15
|
+
node: VersionedInternalTreeNode;
|
|
4
16
|
parent?: MapItem;
|
|
5
17
|
setExpanded?: Function;
|
|
6
18
|
};
|
|
@@ -10,8 +22,10 @@ const ROOT_KEY = "0";
|
|
|
10
22
|
export class TreeHandler {
|
|
11
23
|
private _nodeMap: { [key: string]: MapItem };
|
|
12
24
|
private _nameKeyMap: { [key: string]: string };
|
|
25
|
+
private _language?: string;
|
|
13
26
|
|
|
14
|
-
constructor() {
|
|
27
|
+
constructor(language?: string) {
|
|
28
|
+
this._language = language;
|
|
15
29
|
this._nodeMap = {};
|
|
16
30
|
this._nameKeyMap = {};
|
|
17
31
|
}
|
|
@@ -21,7 +35,10 @@ export class TreeHandler {
|
|
|
21
35
|
}
|
|
22
36
|
|
|
23
37
|
getKeyByName(name: string): string | undefined {
|
|
24
|
-
|
|
38
|
+
if (!name) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
return this._nameKeyMap[name] || this._nameKeyMap[normalizePath(name)];
|
|
25
42
|
}
|
|
26
43
|
|
|
27
44
|
initialize(treeRoot: TreeNode): InternalTreeNode {
|
|
@@ -48,12 +65,41 @@ export class TreeHandler {
|
|
|
48
65
|
}
|
|
49
66
|
|
|
50
67
|
private convert(
|
|
51
|
-
node:
|
|
68
|
+
node: VersionedTreeNode,
|
|
52
69
|
level: number = 0,
|
|
53
70
|
parent?: MapItem,
|
|
54
|
-
position?: number
|
|
55
|
-
|
|
56
|
-
|
|
71
|
+
position?: number,
|
|
72
|
+
ancestorVersion?: {
|
|
73
|
+
selected: TopicVersionOption;
|
|
74
|
+
versions: TopicVersionOption[];
|
|
75
|
+
}
|
|
76
|
+
): VersionedInternalTreeNode {
|
|
77
|
+
const ownSelected = node.versions?.length
|
|
78
|
+
? resolveSelectedVersion(node, this._language)
|
|
79
|
+
: undefined;
|
|
80
|
+
const versionContext =
|
|
81
|
+
ownSelected && node.versions
|
|
82
|
+
? { selected: ownSelected, versions: node.versions }
|
|
83
|
+
: ancestorVersion;
|
|
84
|
+
|
|
85
|
+
let link = node.link;
|
|
86
|
+
if (
|
|
87
|
+
versionContext &&
|
|
88
|
+
!node.versions?.length &&
|
|
89
|
+
link?.href &&
|
|
90
|
+
link.target !== "_blank"
|
|
91
|
+
) {
|
|
92
|
+
const rewritten = applyVersionToHref(
|
|
93
|
+
link.href,
|
|
94
|
+
versionContext.selected,
|
|
95
|
+
versionContext.versions
|
|
96
|
+
);
|
|
97
|
+
if (rewritten && rewritten !== link.href) {
|
|
98
|
+
link = { ...link, href: rewritten };
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const convertedNode: VersionedInternalTreeNode = {
|
|
57
103
|
label: node.label,
|
|
58
104
|
name: node.name,
|
|
59
105
|
key: this.calculateKey(
|
|
@@ -63,24 +109,52 @@ export class TreeHandler {
|
|
|
63
109
|
level: level,
|
|
64
110
|
isExpanded: node.isExpanded || false,
|
|
65
111
|
isChildrenLoading: node.isChildrenLoading || false,
|
|
66
|
-
link
|
|
112
|
+
link,
|
|
67
113
|
method: node.method,
|
|
68
114
|
showForwardArrow: node.showForwardArrow,
|
|
69
|
-
redirectToChild: node.redirectToChild
|
|
115
|
+
redirectToChild: node.redirectToChild,
|
|
116
|
+
versions: node.versions
|
|
70
117
|
};
|
|
71
118
|
|
|
72
119
|
const mapItem = { node: convertedNode, parent };
|
|
73
120
|
if (node.children && node.children.length > 0) {
|
|
74
121
|
convertedNode.children = node.children.map((child, index) =>
|
|
75
|
-
this.convert(child, level + 1, mapItem, index)
|
|
122
|
+
this.convert(child, level + 1, mapItem, index, versionContext)
|
|
76
123
|
);
|
|
77
124
|
}
|
|
78
125
|
|
|
79
126
|
this._nodeMap[convertedNode.key] = mapItem;
|
|
80
|
-
this.
|
|
127
|
+
this.indexName(convertedNode.name, convertedNode.key);
|
|
128
|
+
// A redirect parent can carry a child's href. This index runs after
|
|
129
|
+
// the child, so recording it would make the parent win selection.
|
|
130
|
+
if (!convertedNode.redirectToChild) {
|
|
131
|
+
this.indexName(convertedNode.link?.href, convertedNode.key);
|
|
132
|
+
}
|
|
133
|
+
// Index this topic's own versioned URLs only. Parent-only switching
|
|
134
|
+
// URLs point at a child with content and must not steal that child's
|
|
135
|
+
// selection.
|
|
136
|
+
if (node.name && node.versions) {
|
|
137
|
+
for (const version of node.versions) {
|
|
138
|
+
this.indexName(
|
|
139
|
+
applyVersionToHref(node.name, version, node.versions),
|
|
140
|
+
convertedNode.key
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
81
144
|
return convertedNode;
|
|
82
145
|
}
|
|
83
146
|
|
|
147
|
+
private indexName(name: string | undefined, key: string): void {
|
|
148
|
+
if (!name) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
this._nameKeyMap[name] = key;
|
|
152
|
+
const normalized = normalizePath(name);
|
|
153
|
+
if (normalized && normalized !== name) {
|
|
154
|
+
this._nameKeyMap[normalized] = key;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
84
158
|
private calculateKey(parentKey: string, position?: number): string {
|
|
85
159
|
if (position === undefined) {
|
|
86
160
|
return parentKey;
|
|
@@ -2,6 +2,36 @@
|
|
|
2
2
|
|
|
3
3
|
:host {
|
|
4
4
|
display: block;
|
|
5
|
+
|
|
6
|
+
/* Keep a stable containing block; z-index still lifts the open menu. */
|
|
7
|
+
position: relative;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/* Lift this row above later sibling pickers while its menu is open. */
|
|
11
|
+
:host(:focus-within) {
|
|
12
|
+
z-index: 2;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.tree-item-row {
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
min-width: 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.tree-item-row dx-tree-tile {
|
|
22
|
+
flex: 1;
|
|
23
|
+
min-width: 0;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.tree-item-version-picker {
|
|
27
|
+
flex: 0 0 auto;
|
|
28
|
+
margin-right: var(--dx-g-spacing-lg);
|
|
29
|
+
overflow: visible;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.tree-item-row-selected {
|
|
33
|
+
background: var(--dx-g-cloud-blue-vibrant-95);
|
|
34
|
+
box-shadow: inset var(--dx-g-spacing-xs) 0 0 0 var(--dx-g-blue-vibrant-40);
|
|
5
35
|
}
|
|
6
36
|
|
|
7
37
|
button {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
2
|
+
<div class={rowClass}>
|
|
3
3
|
<dx-tree-tile
|
|
4
4
|
href={href}
|
|
5
5
|
is-root={isRoot}
|
|
@@ -7,12 +7,26 @@
|
|
|
7
7
|
is-expanded={isExpanded}
|
|
8
8
|
has-children={hasChildren}
|
|
9
9
|
is-selected={isSelected}
|
|
10
|
+
is-contained-selection={isContainedSelection}
|
|
10
11
|
oniconclick={onIconClick}
|
|
11
12
|
show-arrow={isParent}
|
|
12
13
|
target={target}
|
|
13
14
|
is-external-link={isExternalLink}
|
|
15
|
+
has-version-picker={showVersionPicker}
|
|
16
|
+
onclick={onLinkClick}
|
|
14
17
|
></dx-tree-tile>
|
|
15
|
-
|
|
18
|
+
<dx-version-picker
|
|
19
|
+
if:true={showVersionPicker}
|
|
20
|
+
class="tree-item-version-picker"
|
|
21
|
+
small="true"
|
|
22
|
+
versions={versionPickerOptions}
|
|
23
|
+
selected-version={selectedVersion}
|
|
24
|
+
latest-version={isLatestVersion}
|
|
25
|
+
onchange={onVersionChange}
|
|
26
|
+
onclick={onVersionPickerClick}
|
|
27
|
+
onmousedown={onVersionPickerClick}
|
|
28
|
+
></dx-version-picker>
|
|
29
|
+
</div>
|
|
16
30
|
<img
|
|
17
31
|
if:true={showChildrenLoading}
|
|
18
32
|
class="tree-children-loading"
|
|
@@ -25,6 +39,7 @@
|
|
|
25
39
|
key={child.key}
|
|
26
40
|
tree-node={child}
|
|
27
41
|
selected-key={selectedKey}
|
|
42
|
+
language={language}
|
|
28
43
|
></dx-tree-item>
|
|
29
44
|
</template>
|
|
30
45
|
</template>
|
|
@@ -2,12 +2,28 @@ import { LightningElement, api } from "lwc";
|
|
|
2
2
|
import { InternalTreeNode } from "typings/custom";
|
|
3
3
|
import { track } from "dxUtils/analytics";
|
|
4
4
|
import { isInViewport } from "dxUtils/browser";
|
|
5
|
+
import type { TopicVersionOption } from "dxUtils/topicVersion";
|
|
6
|
+
import {
|
|
7
|
+
firstContentNode,
|
|
8
|
+
getTopicVersionKey,
|
|
9
|
+
getVersionPickerOptions,
|
|
10
|
+
isParentOnlyTopic,
|
|
11
|
+
normalizePath,
|
|
12
|
+
persistTopicVersion,
|
|
13
|
+
resolveSelectedVersion,
|
|
14
|
+
shouldShowTopicVersionPicker
|
|
15
|
+
} from "dxUtils/topicVersion";
|
|
5
16
|
|
|
6
17
|
const DEFAULT_TARGET = "_self";
|
|
7
18
|
|
|
19
|
+
type VersionedInternalTreeNode = InternalTreeNode & {
|
|
20
|
+
versions?: TopicVersionOption[];
|
|
21
|
+
};
|
|
22
|
+
|
|
8
23
|
export default class TreeItem extends LightningElement {
|
|
9
24
|
@api selectedKey?: string;
|
|
10
25
|
@api isRoot: boolean = false;
|
|
26
|
+
@api language?: string;
|
|
11
27
|
|
|
12
28
|
@api
|
|
13
29
|
public get treeNode() {
|
|
@@ -20,7 +36,7 @@ export default class TreeItem extends LightningElement {
|
|
|
20
36
|
this.isChildrenLoading = (node && node.isChildrenLoading) || false;
|
|
21
37
|
}
|
|
22
38
|
|
|
23
|
-
private _treeNode!:
|
|
39
|
+
private _treeNode!: VersionedInternalTreeNode;
|
|
24
40
|
private isExpanded: boolean = false;
|
|
25
41
|
private isChildrenLoading: boolean = false;
|
|
26
42
|
private rootParentLabel: string = "";
|
|
@@ -30,9 +46,22 @@ export default class TreeItem extends LightningElement {
|
|
|
30
46
|
}
|
|
31
47
|
|
|
32
48
|
private get isSelected(): boolean {
|
|
49
|
+
if (isParentOnlyTopic(this._treeNode)) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
33
52
|
return this._treeNode.key === this.selectedKey && !this.isExternalLink;
|
|
34
53
|
}
|
|
35
54
|
|
|
55
|
+
private get rowClass(): string {
|
|
56
|
+
return this.isSelected && this.showVersionPicker
|
|
57
|
+
? "tree-item-row tree-item-row-selected"
|
|
58
|
+
: "tree-item-row";
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private get isContainedSelection(): boolean {
|
|
62
|
+
return this.isSelected && this.showVersionPicker;
|
|
63
|
+
}
|
|
64
|
+
|
|
36
65
|
private get hasChildren(): boolean {
|
|
37
66
|
return !!(
|
|
38
67
|
this.treeNode &&
|
|
@@ -83,8 +112,48 @@ export default class TreeItem extends LightningElement {
|
|
|
83
112
|
return `${parentLabels.reverse().join(":")}:${this.treeNode.label}`;
|
|
84
113
|
}
|
|
85
114
|
|
|
115
|
+
private get versions(): TopicVersionOption[] | undefined {
|
|
116
|
+
return this._treeNode?.versions;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
private get versionPickerOptions(): TopicVersionOption[] | undefined {
|
|
120
|
+
return getVersionPickerOptions(this._treeNode);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private get showVersionPicker(): boolean {
|
|
124
|
+
return shouldShowTopicVersionPicker(
|
|
125
|
+
this.versions,
|
|
126
|
+
this._treeNode?.showForwardArrow
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
private get selectedVersion(): TopicVersionOption | undefined {
|
|
131
|
+
return resolveSelectedVersion(this._treeNode, this.language);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private get topicVersionKey(): string {
|
|
135
|
+
return getTopicVersionKey(this._treeNode, this.language);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
private get isLatestVersion(): boolean {
|
|
139
|
+
return (
|
|
140
|
+
!!this.selectedVersion &&
|
|
141
|
+
this.selectedVersion.id === this.versions?.[0]?.id
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
86
145
|
private get href(): string | undefined {
|
|
146
|
+
if (isParentOnlyTopic(this._treeNode)) {
|
|
147
|
+
const contentNode = firstContentNode(this._treeNode);
|
|
148
|
+
return (
|
|
149
|
+
contentNode?.link?.href ||
|
|
150
|
+
contentNode?.name ||
|
|
151
|
+
this.selectedVersion?.link?.href ||
|
|
152
|
+
""
|
|
153
|
+
);
|
|
154
|
+
}
|
|
87
155
|
return (
|
|
156
|
+
this.selectedVersion?.link?.href ||
|
|
88
157
|
(this._treeNode.link && this._treeNode.link.href) ||
|
|
89
158
|
this._treeNode.name ||
|
|
90
159
|
""
|
|
@@ -104,6 +173,23 @@ export default class TreeItem extends LightningElement {
|
|
|
104
173
|
setExpanded: this.setExpanded.bind(this)
|
|
105
174
|
});
|
|
106
175
|
}
|
|
176
|
+
|
|
177
|
+
// Remember this topic's resolved version (own URL, descendant URL, or
|
|
178
|
+
// session) so sibling pickers stay independent for the tab.
|
|
179
|
+
const selected = this.selectedVersion;
|
|
180
|
+
const topicKey = this.topicVersionKey;
|
|
181
|
+
if (this.versions?.length && selected && topicKey) {
|
|
182
|
+
persistTopicVersion(topicKey, selected.id);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
private onVersionChange(event: CustomEvent): void {
|
|
187
|
+
event.stopPropagation();
|
|
188
|
+
persistTopicVersion(this.topicVersionKey, event.detail);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
private onVersionPickerClick(event: Event): void {
|
|
192
|
+
event.stopPropagation();
|
|
107
193
|
}
|
|
108
194
|
|
|
109
195
|
renderedCallback(): void {
|
|
@@ -132,10 +218,14 @@ export default class TreeItem extends LightningElement {
|
|
|
132
218
|
}
|
|
133
219
|
|
|
134
220
|
private preventDefaultLinkBehavior(event: Event) {
|
|
135
|
-
//
|
|
221
|
+
// Nodes with no link.href (AMF items use name) must not follow the
|
|
222
|
+
// anchor. Parent-only topics are excluded: their href is the child page.
|
|
223
|
+
// Otherwise cancel only an empty href or a click on the current path.
|
|
136
224
|
if (
|
|
137
|
-
!this._treeNode.link?.href
|
|
138
|
-
|
|
225
|
+
(!this._treeNode.link?.href &&
|
|
226
|
+
!isParentOnlyTopic(this._treeNode)) ||
|
|
227
|
+
!this.href ||
|
|
228
|
+
normalizePath(this.href) === normalizePath(window.location.pathname)
|
|
139
229
|
) {
|
|
140
230
|
event.preventDefault();
|
|
141
231
|
}
|
|
@@ -155,10 +245,14 @@ export default class TreeItem extends LightningElement {
|
|
|
155
245
|
this.sendGtm(event);
|
|
156
246
|
return;
|
|
157
247
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
this.
|
|
161
|
-
|
|
248
|
+
// No copied destination. A markdown descendant is selected below.
|
|
249
|
+
// A chain with no content page only expands.
|
|
250
|
+
if (!firstContentNode(this._treeNode)?.link?.href) {
|
|
251
|
+
const isSelectAction = false;
|
|
252
|
+
this.doExpand(isSelectAction);
|
|
253
|
+
this.sendGtm(event);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
162
256
|
}
|
|
163
257
|
|
|
164
258
|
if (this.isParent) {
|
|
@@ -167,8 +261,12 @@ export default class TreeItem extends LightningElement {
|
|
|
167
261
|
}
|
|
168
262
|
|
|
169
263
|
this.sendGtm(event);
|
|
264
|
+
const contentNode = isParentOnlyTopic(this._treeNode)
|
|
265
|
+
? firstContentNode(this._treeNode)
|
|
266
|
+
: undefined;
|
|
170
267
|
this.fireEvent("tileselected", {
|
|
171
|
-
name: this._treeNode.name,
|
|
268
|
+
name: contentNode?.name || this._treeNode.name,
|
|
269
|
+
...(contentNode?.key ? { key: contentNode.key } : {}),
|
|
172
270
|
isExternalLink: this.isExternalLink
|
|
173
271
|
});
|
|
174
272
|
}
|
|
@@ -186,8 +284,8 @@ export default class TreeItem extends LightningElement {
|
|
|
186
284
|
this.dispatchEvent(
|
|
187
285
|
new CustomEvent(type, {
|
|
188
286
|
detail: {
|
|
189
|
-
|
|
190
|
-
|
|
287
|
+
key: this._treeNode.key,
|
|
288
|
+
...detail
|
|
191
289
|
},
|
|
192
290
|
bubbles: true,
|
|
193
291
|
composed: true
|
|
@@ -28,10 +28,12 @@ export default class TreeTile extends LightningElement {
|
|
|
28
28
|
@api isExpanded = false;
|
|
29
29
|
@api hasChildren = false;
|
|
30
30
|
@api isSelected = false;
|
|
31
|
+
@api isContainedSelection = false;
|
|
31
32
|
@api href!: string;
|
|
32
33
|
@api showArrow = false;
|
|
33
34
|
@api target!: string;
|
|
34
35
|
@api isExternalLink = false;
|
|
36
|
+
@api hasVersionPicker = false;
|
|
35
37
|
|
|
36
38
|
get tileAriaLevel() {
|
|
37
39
|
return this.treeNode.level + 2;
|
|
@@ -43,18 +45,21 @@ export default class TreeTile extends LightningElement {
|
|
|
43
45
|
* screen reader users (WCAG 2.4.4)
|
|
44
46
|
*/
|
|
45
47
|
get linkAriaLabel(): string | null {
|
|
46
|
-
if (!this.treeNode.redirectToChild
|
|
48
|
+
if (!this.treeNode.redirectToChild) {
|
|
47
49
|
return null;
|
|
48
50
|
}
|
|
49
51
|
/**
|
|
50
52
|
* The redirect can target a deep descendant, so walk the first-child
|
|
51
53
|
* chain to the node that owns the destination link and name it.
|
|
54
|
+
* The destination href may live on this anchor (parent-only topics do
|
|
55
|
+
* not copy it onto the parent node).
|
|
52
56
|
*/
|
|
53
57
|
let destination = this.treeNode.children?.[0];
|
|
54
58
|
while (destination?.redirectToChild) {
|
|
55
59
|
destination = destination.children?.[0];
|
|
56
60
|
}
|
|
57
|
-
|
|
61
|
+
const triggerHref = this.href || this.treeNode.link?.href;
|
|
62
|
+
return destination?.link?.href && destination.link.href === triggerHref
|
|
58
63
|
? `${this.treeNode.label}, opens ${destination.label}`
|
|
59
64
|
: null;
|
|
60
65
|
}
|
|
@@ -101,7 +106,11 @@ export default class TreeTile extends LightningElement {
|
|
|
101
106
|
"tile-root": this.isRoot,
|
|
102
107
|
"tile-with-children": !this.isRoot && this.hasChildren,
|
|
103
108
|
"tile-root-with-child": this.isRoot && this.showArrow,
|
|
104
|
-
"sidebar-item-selected":
|
|
109
|
+
"sidebar-item-selected":
|
|
110
|
+
this.isSelected && !this.isContainedSelection,
|
|
111
|
+
"sidebar-item-selected-text":
|
|
112
|
+
this.isSelected && this.isContainedSelection,
|
|
113
|
+
"tile-with-version-picker": this.hasVersionPicker
|
|
105
114
|
});
|
|
106
115
|
}
|
|
107
116
|
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
IconSprite,
|
|
8
8
|
IconData,
|
|
9
9
|
IconSymbol,
|
|
10
|
+
StatusBadgeVariant,
|
|
10
11
|
TypeBadgeSize
|
|
11
12
|
} from "typings/custom";
|
|
12
13
|
import { colorToDxColors, buildStyleColorVariables } from "dxUtils/css";
|
|
@@ -20,9 +21,16 @@ import {
|
|
|
20
21
|
getContentTypeColorVariables
|
|
21
22
|
} from "dxUtils/contentTypes";
|
|
22
23
|
|
|
24
|
+
// Opt-in solid status variants (status-success/-warning/-error).
|
|
25
|
+
export const STATUS_BADGE_VARIANTS: StatusBadgeVariant[] = [
|
|
26
|
+
"status-success",
|
|
27
|
+
"status-warning",
|
|
28
|
+
"status-error"
|
|
29
|
+
];
|
|
30
|
+
|
|
23
31
|
export default class TypeBadge extends LightningElement {
|
|
24
32
|
@api size: TypeBadgeSize = "default";
|
|
25
|
-
@api variant: Brand | ContentType = "default";
|
|
33
|
+
@api variant: Brand | ContentType | StatusBadgeVariant = "default";
|
|
26
34
|
@api color?: Color;
|
|
27
35
|
@api dark?: false;
|
|
28
36
|
|
|
@@ -87,11 +95,24 @@ export default class TypeBadge extends LightningElement {
|
|
|
87
95
|
return isContentType(this.variant);
|
|
88
96
|
}
|
|
89
97
|
|
|
98
|
+
private get isStatus(): boolean {
|
|
99
|
+
return STATUS_BADGE_VARIANTS.includes(
|
|
100
|
+
this.variant as StatusBadgeVariant
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
90
104
|
private get className(): string {
|
|
91
|
-
return cx(
|
|
105
|
+
return cx(
|
|
106
|
+
"dx-badge",
|
|
107
|
+
`size-${this.size}`,
|
|
108
|
+
this.isStatus && this.variant
|
|
109
|
+
);
|
|
92
110
|
}
|
|
93
111
|
|
|
94
112
|
private get style(): string {
|
|
113
|
+
if (this.isStatus) {
|
|
114
|
+
return "";
|
|
115
|
+
}
|
|
95
116
|
if (this.dark) {
|
|
96
117
|
return buildStyleColorVariables({
|
|
97
118
|
background: "--dx-g-purple-vibrant-40",
|