@salesforcedevs/dx-components 1.40.11 → 1.42.0-final-test
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 +4 -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 +30 -6
- package/src/modules/dx/filterMenu/filterMenu.css +19 -0
- package/src/modules/dx/filterMenu/filterMenu.html +17 -2
- package/src/modules/dx/filterMenu/filterMenu.ts +43 -0
- package/src/modules/dx/popover/popover.ts +119 -7
- package/src/modules/dx/searchHybrid/searchHybrid.css +56 -61
- package/src/modules/dx/searchHybrid/searchHybrid.html +133 -112
- package/src/modules/dx/searchHybrid/searchHybrid.mock.ts +244 -0
- package/src/modules/dx/searchHybrid/searchHybrid.ts +81 -26
- package/src/modules/dx/searchResults/searchResults.css +119 -6
- package/src/modules/dx/searchResults/searchResults.html +89 -91
- package/src/modules/dx/searchResults/searchResults.ts +200 -473
- package/src/modules/dx/sidebar/sidebar.css +1 -0
- package/src/modules/dx/sidebar/sidebar.html +2 -5
- package/src/modules/dx/sidebar/sidebar.ts +44 -29
- package/src/modules/dx/sidebarOld/sidebarOld.html +1 -0
- package/src/modules/dx/sidebarSearch/sidebarSearch.ts +163 -342
- package/src/modules/dx/sidebarSearchResult/sidebarSearchResult.css +61 -23
- package/src/modules/dx/sidebarSearchResult/sidebarSearchResult.ts +12 -4
- 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 +92 -13
- package/src/modules/dx/treeItem/treeItem.css +41 -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 +57 -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/openSearch/openSearch.ts +343 -0
- package/src/modules/dxUtils/topicVersion/topicVersion.ts +758 -0
- package/LICENSE +0 -12
|
@@ -2,34 +2,74 @@
|
|
|
2
2
|
@import "dxHelpers/text";
|
|
3
3
|
@import "dxHelpers/commonTreeItem";
|
|
4
4
|
|
|
5
|
+
/* List item states: Default, Hover (blue-vibrant-50 text only), Selected (cloud blue bar), Focus */
|
|
5
6
|
a {
|
|
6
7
|
display: flex;
|
|
7
8
|
flex-direction: column;
|
|
8
9
|
}
|
|
9
10
|
|
|
11
|
+
/* Match "Results" heading alignment. Less item padding so total height unchanged when box has more inner padding. */
|
|
10
12
|
.sidebar-item {
|
|
11
|
-
padding: var(--dx-g-spacing-
|
|
12
|
-
|
|
13
|
+
padding: 0 var(--dx-g-spacing-lg) 0 var(--dx-c-sidebar-left-padding);
|
|
14
|
+
background: transparent;
|
|
15
|
+
transition: background-color var(--dx-g-transition-hue-1x, 0.1s ease);
|
|
16
|
+
overflow: visible;
|
|
13
17
|
}
|
|
14
18
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
margin:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
border-radius: var(--dx-g-spacing-
|
|
19
|
+
/* Inner block: more vertical padding (12px) so box has more space top/bottom; 8px horizontal. margin-left so text aligns with Results. */
|
|
20
|
+
.search-result {
|
|
21
|
+
margin-left: calc(-1 * var(--dx-g-spacing-sm));
|
|
22
|
+
padding: var(--dx-g-spacing-smd) var(--dx-g-spacing-sm);
|
|
23
|
+
border: none;
|
|
24
|
+
border-radius: var(--dx-g-spacing-xs);
|
|
25
|
+
transition: background-color var(--dx-g-transition-hue-1x, 0.1s ease);
|
|
21
26
|
}
|
|
22
27
|
|
|
28
|
+
/* Hover: no background; text → blue-vibrant-50 (unselected and selected) */
|
|
29
|
+
.sidebar-item:hover .title {
|
|
30
|
+
color: var(--dx-g-blue-vibrant-50);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.sidebar-item:hover .description {
|
|
34
|
+
--dx-g-text-body-color: var(--dx-g-blue-vibrant-50);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/* Selected: full-width cloud blue bar + 4px blue-vibrant-40 left accent; text matches unselected */
|
|
38
|
+
.sidebar-item-selected {
|
|
39
|
+
background: var(--dx-g-cloud-blue-vibrant-95);
|
|
40
|
+
border-radius: 0;
|
|
41
|
+
box-shadow: inset var(--dx-g-spacing-xs) 0 0 0 var(--dx-g-blue-vibrant-40);
|
|
42
|
+
|
|
43
|
+
/* Override commonTreeItem selected text color so .title / .description tokens apply */
|
|
44
|
+
color: unset !important;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.sidebar-item-selected .search-result {
|
|
48
|
+
position: relative;
|
|
49
|
+
z-index: 1;
|
|
50
|
+
background: transparent;
|
|
51
|
+
color: inherit;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* Focus: same ring for selected and unselected (inner .search-result, not full-width bar) */
|
|
55
|
+
.sidebar-item:focus-visible {
|
|
56
|
+
outline: none !important;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* Override commonTreeItem selected:focus padding/outline so focus matches unselected */
|
|
23
60
|
.sidebar-item-selected:focus-visible {
|
|
24
|
-
padding: 0
|
|
25
|
-
|
|
61
|
+
padding-top: 0;
|
|
62
|
+
padding-bottom: 0;
|
|
63
|
+
outline: none !important;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.sidebar-item:focus-visible .search-result {
|
|
26
67
|
outline: none;
|
|
68
|
+
border-radius: var(--dx-g-spacing-xs);
|
|
69
|
+
border: none;
|
|
27
70
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
border-radius: var(--dx-g-spacing-2xs);
|
|
31
|
-
padding: var(--dx-g-spacing-smd) 0;
|
|
32
|
-
}
|
|
71
|
+
/* White inner ring reads clearly on selected (cloud 95) and hover backgrounds */
|
|
72
|
+
box-shadow: 0 0 0 2px white, 0 0 0 4px var(--dx-g-blue-vibrant-60);
|
|
33
73
|
}
|
|
34
74
|
|
|
35
75
|
.search-text {
|
|
@@ -41,6 +81,7 @@ a {
|
|
|
41
81
|
}
|
|
42
82
|
|
|
43
83
|
.description {
|
|
84
|
+
line-clamp: 3;
|
|
44
85
|
-webkit-line-clamp: 3;
|
|
45
86
|
overflow-wrap: break-word;
|
|
46
87
|
|
|
@@ -52,16 +93,13 @@ a {
|
|
|
52
93
|
|
|
53
94
|
.title {
|
|
54
95
|
color: var(--dx-g-text-heading-color);
|
|
96
|
+
line-height: 18px;
|
|
97
|
+
display: block;
|
|
98
|
+
margin-bottom: 4px;
|
|
55
99
|
}
|
|
56
100
|
|
|
57
|
-
|
|
58
|
-
color: var(--dx-g-blue-vibrant-50);
|
|
59
|
-
}
|
|
60
|
-
|
|
101
|
+
/* Match full-doc search highlight: light yellow from dx-css-variables */
|
|
61
102
|
.bold {
|
|
103
|
+
background-color: var(--dx-g-yellow-vibrant-90);
|
|
62
104
|
font-weight: 700;
|
|
63
105
|
}
|
|
64
|
-
|
|
65
|
-
a > *:not(:last-child) {
|
|
66
|
-
margin-bottom: var(--dx-g-spacing-xs);
|
|
67
|
-
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { LightningElement, api } from "lwc";
|
|
2
2
|
import cx from "classnames";
|
|
3
|
-
import {
|
|
3
|
+
import { track } from "dxUtils/analytics";
|
|
4
|
+
import { HighlightedSections } from "typings/custom";
|
|
4
5
|
|
|
5
|
-
const toChunks = (value: string, highlights:
|
|
6
|
+
const toChunks = (value: string, highlights: HighlightedSections) => {
|
|
6
7
|
if (!highlights || highlights.length < 1) {
|
|
7
8
|
return [
|
|
8
9
|
{
|
|
@@ -51,11 +52,11 @@ const toChunks = (value: string, highlights: CoveoHighlights) => {
|
|
|
51
52
|
|
|
52
53
|
export default class SidebarSearchResult extends LightningElement {
|
|
53
54
|
@api description!: string;
|
|
54
|
-
@api descriptionHighlights!:
|
|
55
|
+
@api descriptionHighlights!: HighlightedSections;
|
|
55
56
|
@api href!: string;
|
|
56
57
|
@api selected!: boolean;
|
|
57
58
|
@api header!: string;
|
|
58
|
-
@api titleHighlights!:
|
|
59
|
+
@api titleHighlights!: HighlightedSections;
|
|
59
60
|
@api select!: Function;
|
|
60
61
|
|
|
61
62
|
private get titleChunks() {
|
|
@@ -72,6 +73,13 @@ export default class SidebarSearchResult extends LightningElement {
|
|
|
72
73
|
|
|
73
74
|
private onClick(e: PointerEvent) {
|
|
74
75
|
e.preventDefault();
|
|
76
|
+
track(e.currentTarget!, "custEv_scopedSearchItemSelected", {
|
|
77
|
+
click_text: this.header,
|
|
78
|
+
click_url: this.href,
|
|
79
|
+
element_title: this.header,
|
|
80
|
+
element_type: "link",
|
|
81
|
+
content_category: "documentation"
|
|
82
|
+
});
|
|
75
83
|
this.select();
|
|
76
84
|
window.location.href = this.href;
|
|
77
85
|
}
|
|
@@ -4,6 +4,10 @@ import { toJson } from "dxUtils/normalizers";
|
|
|
4
4
|
import { TreeHandler } from "./treeHandler";
|
|
5
5
|
|
|
6
6
|
export default class Tree extends LightningElement {
|
|
7
|
+
// Must be set before `treeRoot`. Both sidebar templates pass `language`
|
|
8
|
+
// first; the tree resolves stored topic versions with it while being built.
|
|
9
|
+
@api language?: string;
|
|
10
|
+
|
|
7
11
|
@api
|
|
8
12
|
get treeRoot() {
|
|
9
13
|
return this._treeRoot!;
|
|
@@ -11,7 +15,7 @@ export default class Tree extends LightningElement {
|
|
|
11
15
|
|
|
12
16
|
set treeRoot(value: TreeNode | string) {
|
|
13
17
|
value = toJson(value);
|
|
14
|
-
this._treeHandler = new TreeHandler();
|
|
18
|
+
this._treeHandler = new TreeHandler(this.language);
|
|
15
19
|
this._treeRoot = this._treeHandler.initialize(value as TreeNode);
|
|
16
20
|
if (this._value) {
|
|
17
21
|
this.selectedKey = this._treeHandler.getKeyByName(this._value);
|
|
@@ -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,57 @@ 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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
120
|
+
// Prefer the selected version's own topic list when the server sent one.
|
|
121
|
+
// Otherwise keep the latest children and rewrite their hrefs.
|
|
122
|
+
const childNodes = Array.isArray(ownSelected?.children)
|
|
123
|
+
? ownSelected.children
|
|
124
|
+
: node.children;
|
|
125
|
+
if (childNodes && childNodes.length > 0) {
|
|
126
|
+
convertedNode.children = childNodes.map((child, index) =>
|
|
127
|
+
this.convert(child, level + 1, mapItem, index, versionContext)
|
|
76
128
|
);
|
|
77
129
|
}
|
|
78
130
|
|
|
79
131
|
this._nodeMap[convertedNode.key] = mapItem;
|
|
80
|
-
this.
|
|
132
|
+
this.indexName(convertedNode.name, convertedNode.key);
|
|
133
|
+
// A redirect parent can carry a child's href. This index runs after
|
|
134
|
+
// the child, so recording it would make the parent win selection.
|
|
135
|
+
if (!convertedNode.redirectToChild) {
|
|
136
|
+
this.indexName(convertedNode.link?.href, convertedNode.key);
|
|
137
|
+
}
|
|
138
|
+
// Index this topic's own versioned URLs only. Parent-only switching
|
|
139
|
+
// URLs point at a child with content and must not steal that child's
|
|
140
|
+
// selection.
|
|
141
|
+
if (node.name && node.versions) {
|
|
142
|
+
for (const version of node.versions) {
|
|
143
|
+
this.indexName(
|
|
144
|
+
applyVersionToHref(node.name, version, node.versions),
|
|
145
|
+
convertedNode.key
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
81
149
|
return convertedNode;
|
|
82
150
|
}
|
|
83
151
|
|
|
152
|
+
private indexName(name: string | undefined, key: string): void {
|
|
153
|
+
if (!name) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
this._nameKeyMap[name] = key;
|
|
157
|
+
const normalized = normalizePath(name);
|
|
158
|
+
if (normalized && normalized !== name) {
|
|
159
|
+
this._nameKeyMap[normalized] = key;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
84
163
|
private calculateKey(parentKey: string, position?: number): string {
|
|
85
164
|
if (position === undefined) {
|
|
86
165
|
return parentKey;
|
|
@@ -2,6 +2,47 @@
|
|
|
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
|
+
position: relative;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* The tile's keyboard focus layers fill this row, picker included. isolate
|
|
23
|
+
keeps the fill above the row's background and below its content. Only while
|
|
24
|
+
focus is inside: a row that is always isolated traps its picker's menu.
|
|
25
|
+
z-index lifts the open menu above the child items under this row.
|
|
26
|
+
:host(:focus-within) only stacks this item above sibling rows. */
|
|
27
|
+
.tree-item-row:focus-within {
|
|
28
|
+
isolation: isolate;
|
|
29
|
+
z-index: 1;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.tree-item-row dx-tree-tile {
|
|
33
|
+
flex: 1;
|
|
34
|
+
min-width: 0;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.tree-item-version-picker {
|
|
38
|
+
flex: 0 0 auto;
|
|
39
|
+
margin-right: var(--dx-g-spacing-lg);
|
|
40
|
+
overflow: visible;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.tree-item-row-selected {
|
|
44
|
+
background: var(--dx-g-cloud-blue-vibrant-95);
|
|
45
|
+
box-shadow: inset var(--dx-g-spacing-xs) 0 0 0 var(--dx-g-blue-vibrant-40);
|
|
5
46
|
}
|
|
6
47
|
|
|
7
48
|
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
|
|
@@ -66,6 +66,10 @@
|
|
|
66
66
|
white-space: nowrap;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
.tile-with-version-picker {
|
|
70
|
+
padding-right: var(--dx-g-spacing-xs);
|
|
71
|
+
}
|
|
72
|
+
|
|
69
73
|
.tile-with-children .tile-label {
|
|
70
74
|
order: 2;
|
|
71
75
|
}
|
|
@@ -213,3 +217,56 @@ a:visited.tile-root,
|
|
|
213
217
|
a:link.tile-root {
|
|
214
218
|
color: var(--dx-g-blue-vibrant-20);
|
|
215
219
|
}
|
|
220
|
+
|
|
221
|
+
/* Keyboard focus matches dx-dropdown-option: a light fill, a 2px blue inset
|
|
222
|
+
ring, and a white inner band. The layers fill dx-tree-item's row (it sets
|
|
223
|
+
position: relative), so a version picker beside the link sits inside the
|
|
224
|
+
focus box. Undo the shared tree item focus box (commonTreeItem) first. */
|
|
225
|
+
:host .sidebar-item:focus-visible {
|
|
226
|
+
margin: 0;
|
|
227
|
+
padding: 6px var(--dx-g-spacing-lg) 6px
|
|
228
|
+
var(--dx-g-global-header-padding-horizontal);
|
|
229
|
+
outline: none;
|
|
230
|
+
border-radius: 0;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/* Keep the picker row's 4px right padding on focus, so the label does not rewrap. */
|
|
234
|
+
:host .tile-with-version-picker:focus-visible {
|
|
235
|
+
padding-right: var(--dx-g-spacing-xs);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
:host .sidebar-item:focus-visible .indentation {
|
|
239
|
+
padding-top: 0;
|
|
240
|
+
padding-bottom: 0;
|
|
241
|
+
outline: none;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
:host .sidebar-item:focus-visible::before,
|
|
245
|
+
:host .sidebar-item:focus-visible::after {
|
|
246
|
+
content: "";
|
|
247
|
+
position: absolute;
|
|
248
|
+
inset: 0;
|
|
249
|
+
pointer-events: none;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
:host .sidebar-item:focus-visible::before {
|
|
253
|
+
z-index: -1;
|
|
254
|
+
background: var(--dx-g-cloud-blue-vibrant-95);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
:host .sidebar-item:focus-visible::after {
|
|
258
|
+
z-index: 1;
|
|
259
|
+
box-shadow: inset 0 0 0 2px var(--dx-g-blue-vibrant-60),
|
|
260
|
+
inset 0 0 0 4px white;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/* A selected item keeps its left bar, inside the ring, when it also has keyboard focus. */
|
|
264
|
+
:host
|
|
265
|
+
.sidebar-item:is(
|
|
266
|
+
.sidebar-item-selected,
|
|
267
|
+
.sidebar-item-selected-text
|
|
268
|
+
):focus-visible::after {
|
|
269
|
+
box-shadow: inset 0 0 0 2px var(--dx-g-blue-vibrant-60),
|
|
270
|
+
inset 0 0 0 4px white,
|
|
271
|
+
inset calc(2 * var(--dx-g-spacing-xs)) 0 0 0 var(--dx-g-blue-vibrant-40);
|
|
272
|
+
}
|