@salesforcedevs/dx-components 0.44.0 → 0.45.0-alpha2
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/assets/icons/salesforcebrand-sprite/svg/symbols.svg +5 -2
- package/src/modules/base-elements/sidebarBase/sidebarBase.ts +65 -0
- package/src/modules/dx/{cardGrid/cardGrid.css → cardGridDocs/cardGridDocs.css} +3 -15
- package/src/modules/dx/cardGridDocs/cardGridDocs.html +67 -0
- package/src/modules/dx/cardGridDocs/cardGridDocs.ts +73 -0
- package/src/modules/dx/dropdownOption/dropdownOption.ts +7 -2
- package/src/modules/dx/grid/grid.ts +3 -1
- package/src/modules/dx/pagination/pagination.ts +7 -4
- package/src/modules/dx/sidebar/sidebar.html +1 -0
- package/src/modules/dx/sidebar/sidebar.ts +5 -2
- package/src/modules/dx/sidebarOld/sidebarOld.html +2 -1
- package/src/modules/dx/sidebarOld/sidebarOld.ts +8 -2
- package/src/modules/dx/treeItem/treeItem.ts +20 -0
- package/src/modules/utils/browser/browser.ts +17 -0
- package/LICENSE +0 -12
- package/src/modules/dx/cardGrid/cardGrid.html +0 -46
- package/src/modules/dx/cardGrid/cardGrid.ts +0 -140
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dx-components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.0-alpha2",
|
|
4
4
|
"description": "DX Lightning web components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -27,6 +27,5 @@
|
|
|
27
27
|
"@types/debounce": "^1.2.0",
|
|
28
28
|
"@types/lodash.get": "^4.4.6",
|
|
29
29
|
"@types/vimeo__player": "^2.16.2"
|
|
30
|
-
}
|
|
31
|
-
"gitHead": "86bac144ec8f2b4aea5909d2ef091e1e49888b04"
|
|
30
|
+
}
|
|
32
31
|
}
|
|
@@ -258,13 +258,16 @@
|
|
|
258
258
|
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
259
259
|
<g id="Sales-Revenue-Cloud-Icon-Square-2Color-RGB" fill-rule="nonzero">
|
|
260
260
|
<path d="M46.6,29.8 C46,29.2 45.8,28.2 46.3,27.4 C46.8,26.5 47.2,25.5 47.5,24.5 C47.7,23.6 48.5,23 49.4,23 L52,23 L52,19 L49.4,19 C48.5,19 47.7,18.4 47.5,17.5 C47.2,16.5 46.8,15.5 46.3,14.6 C45.9,13.8 46,12.8 46.6,12.2 L48.4,10.4 L45.6,7.6 L43.8,9.4 C43.2,10 42.2,10.2 41.4,9.7 C40.5,9.2 39.5,8.8 38.5,8.5 C37.6,8.3 37,7.5 37,6.6 L37,4 L33,4 L33,6.6 C33,7.5 32.4,8.3 31.5,8.5 C30.5,8.8 29.5,9.2 28.6,9.7 C27.8,10.1 26.8,10 26.2,9.4 L24.4,7.6 L21.6,10.4 L23.4,12.2 C24,12.8 24.2,13.8 23.7,14.6 C23.2,15.5 22.8,16.5 22.5,17.5 C22.3,18.4 21.5,19 20.6,19 L18,19 L18,23 L26.2,23 C26.1,22.4 26,21.7 26,21 C26,16 30,12 35,12 C40,12 44,16 44,21 C44,26 40,30 35,30 C34.3,30 33.7,29.9 33,29.8 L33,38.1 L37,38.1 L37,35.5 C37,34.6 37.6,33.8 38.5,33.6 C39.5,33.3 40.5,32.9 41.4,32.4 C42.2,32 43.2,32.1 43.8,32.7 L45.6,34.5 L48.4,31.7 L46.6,29.8 Z" id="Path" fill="#04E1CB"></path>
|
|
261
|
-
<path d="M39,0 C40.
|
|
261
|
+
<path d="M39,0 C40.1,0 41,0.9 41,2 L41,2 L41,5.1 C41.3,5.2 41.7,5.4 42,5.5 L42,5.5 L44.2,3.3 C45,2.5 46.2,2.5 47,3.3 L47,3.3 L52.7,9 C53.1,9.4 53.3,9.9 53.3,10.4 C53.3,10.9 53.1,11.4 52.7,11.8 L52.7,11.8 L50.5,14 C50.6,14.3 50.8,14.7 50.9,15 L50.9,15 L54,15 C55.1,15 56,15.9 56,17 L56,17 L56,25 C56,25.5 55.8,26 55.4,26.4 C55,26.8 54.5,27 54,27 L54,27 L50.9,27 C50.8,27.3 50.6,27.7 50.5,28 L50.5,28 L52.7,30.2 C53.1,30.6 53.3,31.1 53.3,31.6 C53.3,32.1 53.1,32.6 52.7,33 L52.7,33 L47,38.7 C46.2,39.5 45,39.5 44.2,38.7 L44.2,38.7 L42,36.5 C41.7,36.6 41.3,36.8 41,36.9 L41,36.9 L41,40 C41,41.1 40.1,42 39,42 L39,42 L33,42 L33,43 C33,44.1 32.1,45 31,45 L31,45 L2,45 C0.9,45 0,44.1 0,43 L0,43 L0,25 C0,23.9 0.9,23 2,23 L2,23 L14,23 L14,17 C14,15.9 14.9,15 16,15 L16,15 L19.1,15 C19.2,14.7 19.4,14.3 19.5,14 L19.5,14 L17.3,11.8 C16.5,11 16.5,9.8 17.3,9 L17.3,9 L23,3.3 C23.8,2.5 25,2.5 25.8,3.3 L25.8,3.3 L28,5.5 C28.3,5.4 28.7,5.2 29,5.1 L29,5.1 L29,2 C29,0.9 29.9,0 31,0 L31,0 Z M35,16 C32.2385763,16 30,18.2385763 30,21 C30,23.7614237 32.2385763,26 35,26 C37.7614237,26 40,23.7614237 40,21 C40,18.2385763 37.7614237,16 35,16 Z" id="Combined-Shape" fill="#0B827C"></path>
|
|
262
262
|
<path d="M43.8,32.6 C43.2,32 42.2,31.8 41.4,32.3 C40.5,32.8 39.5,33.2 38.5,33.5 C37.6,33.7 37,34.5 37,35.4 L37,38 L33,38 L33,29.7 C33.6,29.8 34.3,29.9 35,29.9 C40,29.9 44,25.9 44,20.9 C44,15.9 40,11.9 35,11.9 C30,11.9 26,15.9 26,20.9 C26,21.6 26.1,22.3 26.2,22.9 L18,22.9 L18,18.9 L20.6,18.9 C21.5,18.9 22.3,18.3 22.5,17.4 C22.8,16.4 23.2,15.4 23.7,14.5 C24.1,13.7 24,12.7 23.4,12.1 L21.6,10.3 L24.4,7.5 L26.2,9.3 C26.8,9.9 27.8,10.1 28.6,9.6 C29.5,9.1 30.5,8.7 31.5,8.4 C32.4,8.2 33,7.4 33,6.5 L33,3.9 L37,3.9 L37,6.5 C37,7.4 37.6,8.2 38.5,8.4 C39.5,8.7 40.5,9.1 41.4,9.6 C42.2,10 43.2,9.9 43.8,9.3 L45.6,7.5 L48.4,10.3 L46.6,12.1 C46,12.7 45.8,13.7 46.3,14.5 C46.8,15.4 47.2,16.4 47.5,17.4 C47.7,18.3 48.5,18.9 49.4,18.9 L52,18.9 L52,22.9 L49.4,22.9 C48.5,22.9 47.7,23.5 47.5,24.4 C47.2,25.4 46.8,26.4 46.3,27.3 C45.9,28.1 46,29.1 46.6,29.7 L48.4,31.5 L45.6,34.5 L43.8,32.6 Z" id="Path" fill="#04E1CB"></path>
|
|
263
|
-
<
|
|
263
|
+
<polygon id="Path" fill="#0B827C" points="4 27 15.8 27 21.3 27 23.5 27 28.3 27 29 27 29 27.7 29 32.5 29 34.7 29 40.2 29 41 4 41"></polygon>
|
|
264
|
+
<polygon id="Path" fill="#04E1CB" points="29 40.2 29 34.7 29 32.5 29 27.7 29 27 28.3 27 23.5 27 21.3 27 15.8 27 4 27 4 41 29 41"></polygon>
|
|
264
265
|
<path d="M25.8,33.1 C25.9,33.4 26,33.7 26,34 C26,35.1 25.1,36 24,36 C22.9,36 22,35.1 22,34 C22,33.5 22.2,33 22.5,32.6 C22.9,32.2 23.4,32 24,32 C24.8,32 25.4,32.4 25.8,33.1 Z" id="Path" fill="#04E1CB"></path>
|
|
265
266
|
<circle id="Oval" fill="#04E1CB" cx="9" cy="34" r="2"></circle>
|
|
267
|
+
<path d="M16.5,36.5 C15.1,36.5 14,35.4 14,34 C14,32.6 15.1,31.5 16.5,31.5 C16.6,31.5 16.6,31.5 16.7,31.5 C18,31.6 19,32.7 19,34 C19,34.2 19,34.4 18.9,34.7 C18.6,35.7 17.7,36.5 16.5,36.5 Z" id="Path" fill="#04E1CB"></path>
|
|
266
268
|
<path d="M22,34 C22,35.1 22.9,36 24,36 C25.1,36 26,35.1 26,34 C26,33.7 25.9,33.3 25.8,33.1 C25.5,32.5 24.8,32 24,32 C23.4,32 22.9,32.2 22.5,32.6 C22.2,33 22,33.5 22,34 Z" id="Path" fill="#0B827C"></path>
|
|
267
269
|
<circle id="Oval" fill="#0B827C" cx="9" cy="34" r="2"></circle>
|
|
270
|
+
<path d="M16.7,31.5 C16.6,31.5 16.6,31.5 16.5,31.5 C15.1,31.5 14,32.6 14,34 C14,35.4 15.1,36.5 16.5,36.5 C17.6,36.5 18.6,35.7 18.9,34.7 C19,34.5 19,34.3 19,34 C19,32.7 18,31.6 16.7,31.5 Z" id="Path" fill="#FFFFFF"></path>
|
|
268
271
|
</g>
|
|
269
272
|
</g>
|
|
270
273
|
</symbol>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { LightningElement } from "lwc";
|
|
2
|
+
|
|
3
|
+
export const HEIGHT_OF_SIDEBAR_ITEM = 32;
|
|
4
|
+
export const WAIT_TIME_BEFORE_SCROLL_IN_MS = 500;
|
|
5
|
+
|
|
6
|
+
export class SidebarBase extends LightningElement {
|
|
7
|
+
_sidebarContent: HTMLElement | null = null;
|
|
8
|
+
|
|
9
|
+
selectedElement: HTMLElement | null = null;
|
|
10
|
+
timerId: ReturnType<typeof setTimeout> | null = null;
|
|
11
|
+
|
|
12
|
+
get sidebarContent() {
|
|
13
|
+
if (!this._sidebarContent) {
|
|
14
|
+
this._sidebarContent = this.template.querySelector(
|
|
15
|
+
".sidebar-content-tree"
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
return this._sidebarContent;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
renderedCallback(): void {
|
|
22
|
+
/**
|
|
23
|
+
* Implementing debouncing kind of logic here to scroll to selected element once tree rendering is done
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
if (this.timerId) {
|
|
27
|
+
clearTimeout(this.timerId);
|
|
28
|
+
}
|
|
29
|
+
this.timerId = setTimeout(
|
|
30
|
+
this.renderedCallbackWithTimeout,
|
|
31
|
+
WAIT_TIME_BEFORE_SCROLL_IN_MS
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
disconnectedCallback(): void {
|
|
36
|
+
if (this.timerId) {
|
|
37
|
+
clearTimeout(this.timerId);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
renderedCallbackWithTimeout = () => {
|
|
42
|
+
this.scrollToSelectedItem();
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
private onSelectedItemRendered = (event: CustomEvent) => {
|
|
46
|
+
event.stopPropagation();
|
|
47
|
+
this.selectedElement = event.detail.element;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/*Scroll to selected tree item */
|
|
51
|
+
private scrollToSelectedItem() {
|
|
52
|
+
if (this.selectedElement && this.sidebarContent) {
|
|
53
|
+
const scrollHeight: number =
|
|
54
|
+
this.selectedElement.getBoundingClientRect().bottom -
|
|
55
|
+
this.sidebarContent.getBoundingClientRect().bottom + // We need to remove parent bottom
|
|
56
|
+
HEIGHT_OF_SIDEBAR_ITEM * 3 + // add height of 3 more items so that user can see at least three more items after selected item
|
|
57
|
+
this.sidebarContent.offsetTop; // We need to add sidebar offsetTop value as scrollTo will consider it
|
|
58
|
+
this.sidebarContent.scrollTo({
|
|
59
|
+
top: scrollHeight,
|
|
60
|
+
behavior: "smooth"
|
|
61
|
+
});
|
|
62
|
+
this.selectedElement = null;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -16,27 +16,15 @@
|
|
|
16
16
|
display: flex;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
.filter-checkbox-group,
|
|
20
|
-
.filter-button::part(container) {
|
|
21
|
-
--dx-c-checkbox-text-transform: capitalize;
|
|
22
|
-
|
|
23
|
-
text-transform: var(--dx-c-checkbox-text-transform);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
19
|
.docs-action-bar .filters-container > *:not(:first-child),
|
|
27
|
-
|
|
20
|
+
dx-search-input {
|
|
28
21
|
margin-left: var(--dx-g-spacing-sm);
|
|
29
22
|
}
|
|
30
23
|
|
|
31
|
-
|
|
24
|
+
dx-search-input {
|
|
32
25
|
--dx-c-input-width: 285px;
|
|
33
26
|
}
|
|
34
27
|
|
|
35
|
-
.docs-card {
|
|
36
|
-
--dx-c-body-max-lines: 4;
|
|
37
|
-
--dx-c-heading-max-lines: 2;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
28
|
.pagination-container {
|
|
41
29
|
max-width: fit-content;
|
|
42
30
|
max-width: -moz-fit-content;
|
|
@@ -56,7 +44,7 @@
|
|
|
56
44
|
padding: 0;
|
|
57
45
|
}
|
|
58
46
|
|
|
59
|
-
|
|
47
|
+
dx-search-input {
|
|
60
48
|
--dx-c-input-width: 100%;
|
|
61
49
|
|
|
62
50
|
width: 100%;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="card-grid">
|
|
3
|
+
<div class="docs-action-bar">
|
|
4
|
+
<div class="records-container">
|
|
5
|
+
<span if:true={endingRecord}>
|
|
6
|
+
Showing { startingRecord } to { endingRecord } of {
|
|
7
|
+
cards.length }
|
|
8
|
+
</span>
|
|
9
|
+
</div>
|
|
10
|
+
<div class="filters-container">
|
|
11
|
+
<slot name="filters"></slot>
|
|
12
|
+
</div>
|
|
13
|
+
<dx-input
|
|
14
|
+
size="small"
|
|
15
|
+
placeholder="Search..."
|
|
16
|
+
icon-symbol="search"
|
|
17
|
+
shortcut-key="j"
|
|
18
|
+
class="docs-search-input"
|
|
19
|
+
onchange={onSearchChange}
|
|
20
|
+
value={value}
|
|
21
|
+
></dx-input>
|
|
22
|
+
</div>
|
|
23
|
+
<dx-grid columns="four">
|
|
24
|
+
<template for:each={currentPageCards} for:item="card">
|
|
25
|
+
<dx-card-docs
|
|
26
|
+
key={card.title}
|
|
27
|
+
body={card.body}
|
|
28
|
+
href={card.href}
|
|
29
|
+
img-alt={card.imgAlt}
|
|
30
|
+
img-src={card.imgSrc}
|
|
31
|
+
label={card.label}
|
|
32
|
+
title={card.title}
|
|
33
|
+
target={card.target}
|
|
34
|
+
show-mobile-img={card.showMobileImg}
|
|
35
|
+
>
|
|
36
|
+
<template
|
|
37
|
+
if:true={card.links}
|
|
38
|
+
for:each={card.links}
|
|
39
|
+
for:item="link"
|
|
40
|
+
>
|
|
41
|
+
<dx-button
|
|
42
|
+
key={link.title}
|
|
43
|
+
href={link.href}
|
|
44
|
+
variant="inline"
|
|
45
|
+
>
|
|
46
|
+
{ link.title }
|
|
47
|
+
</dx-button>
|
|
48
|
+
</template>
|
|
49
|
+
</dx-card-docs>
|
|
50
|
+
</template>
|
|
51
|
+
</dx-grid>
|
|
52
|
+
<div class="pagination-container" if:false={showEmptyState}>
|
|
53
|
+
<dx-pagination
|
|
54
|
+
current-page={page}
|
|
55
|
+
total-pages={totalPages}
|
|
56
|
+
pages-to-show="5"
|
|
57
|
+
onpagechange={goToPage}
|
|
58
|
+
if:false={hidePagination}
|
|
59
|
+
></dx-pagination>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
<dx-empty-state
|
|
63
|
+
title="Beep boop. That did not compute."
|
|
64
|
+
subtitle={emptyStateSubtitle}
|
|
65
|
+
if:true={showEmptyState}
|
|
66
|
+
></dx-empty-state>
|
|
67
|
+
</template>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { LightningElement, api, track } from "lwc";
|
|
2
|
+
import { toJson } from "utils/normalizers";
|
|
3
|
+
import { DocsCard } from "typings/custom";
|
|
4
|
+
|
|
5
|
+
export default class CardGridDocs extends LightningElement {
|
|
6
|
+
@api pageSize = 24;
|
|
7
|
+
@api
|
|
8
|
+
get cards(): DocsCard[] {
|
|
9
|
+
return this.value
|
|
10
|
+
? this._cards.filter((card: DocsCard) =>
|
|
11
|
+
Object.values(card).some(
|
|
12
|
+
(val) =>
|
|
13
|
+
typeof val === "string" &&
|
|
14
|
+
val.includes(this.value || "")
|
|
15
|
+
)
|
|
16
|
+
)
|
|
17
|
+
: this._cards;
|
|
18
|
+
}
|
|
19
|
+
set cards(value) {
|
|
20
|
+
this._cards = toJson(value);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
private page: number = 1;
|
|
24
|
+
private _cards: DocsCard[] = [];
|
|
25
|
+
@track
|
|
26
|
+
private value?: string;
|
|
27
|
+
|
|
28
|
+
private get currentPageCards() {
|
|
29
|
+
return this.cards.slice(this.startingRecord - 1, this.endingRecord);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private get startingRecord() {
|
|
33
|
+
return this.page === 1
|
|
34
|
+
? this.page
|
|
35
|
+
: (this.page - 1) * this.pageSize + 1;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
private get endingRecord() {
|
|
39
|
+
const defaultEndingRecord = this.pageSize * this.page;
|
|
40
|
+
return defaultEndingRecord > this.cards.length
|
|
41
|
+
? this.cards.length
|
|
42
|
+
: defaultEndingRecord;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private get totalPages() {
|
|
46
|
+
return Math.ceil(this.cards.length / this.pageSize);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private get hidePagination() {
|
|
50
|
+
return this.totalPages < 2;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private get emptyStateSubtitle() {
|
|
54
|
+
return "No results" + (this.value !== "" ? ` for "${this.value}"` : "");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private get showEmptyState() {
|
|
58
|
+
return !this.cards.length;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private onSearchChange(e: InputEvent): void {
|
|
62
|
+
const detail = `${e.detail}`;
|
|
63
|
+
this.value = detail === "" ? undefined : detail;
|
|
64
|
+
|
|
65
|
+
if (this.startingRecord > this.cards.length) {
|
|
66
|
+
this.page = 1;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private goToPage(e: CustomEvent) {
|
|
71
|
+
this.page = e.detail;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -31,11 +31,16 @@ export default class DropdownOption extends LightningElement {
|
|
|
31
31
|
const navSubHeading =
|
|
32
32
|
(this.navItemLabel ? this.option.label : undefined) || undefined;
|
|
33
33
|
|
|
34
|
-
const payload = {
|
|
34
|
+
const payload: any = {
|
|
35
35
|
navHeading,
|
|
36
36
|
navSubHeading,
|
|
37
37
|
clickText: this.keyValue || undefined,
|
|
38
|
-
pageLocation: window.location.pathname || undefined
|
|
38
|
+
pageLocation: window.location.pathname || undefined,
|
|
39
|
+
elementType: "dropdown",
|
|
40
|
+
destinationType: "internal",
|
|
41
|
+
ctaClick: true,
|
|
42
|
+
itemTitle: this.option.label || undefined,
|
|
43
|
+
clickUrl: e.target?.href || undefined
|
|
39
44
|
};
|
|
40
45
|
|
|
41
46
|
if (this.analyticsEvent && e.currentTarget) {
|
|
@@ -67,6 +67,8 @@ export default class Grid extends LightningElement {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
onSlotChange(e: Event) {
|
|
70
|
-
this._itemCount = (
|
|
70
|
+
this._itemCount = (
|
|
71
|
+
e.target as LightningSlotElement
|
|
72
|
+
).assignedElements().length;
|
|
71
73
|
}
|
|
72
74
|
}
|
|
@@ -93,12 +93,15 @@ export default class Pagination extends LightningElement {
|
|
|
93
93
|
const page = this.calculatePage(e);
|
|
94
94
|
const clickType = this.getPaginationClickType(e);
|
|
95
95
|
|
|
96
|
+
const clickText =
|
|
97
|
+
clickType === PaginationClickType.Number
|
|
98
|
+
? page
|
|
99
|
+
: (e.target as HTMLElement).dataset.partId;
|
|
100
|
+
|
|
96
101
|
track(e.currentTarget!, "custEv_pagination", {
|
|
97
102
|
...ANALYTICS_INFO,
|
|
98
|
-
clickText
|
|
99
|
-
|
|
100
|
-
? page
|
|
101
|
-
: (e.target as HTMLElement).dataset.partId
|
|
103
|
+
clickText,
|
|
104
|
+
itemTitle: clickText
|
|
102
105
|
});
|
|
103
106
|
|
|
104
107
|
this.dispatchEvent(new CustomEvent("pagechange", { detail: page }));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import cx from "classnames";
|
|
2
2
|
import { track as trackAnalytics } from "dx/instrumentation";
|
|
3
|
-
import {
|
|
3
|
+
import { api, track } from "lwc";
|
|
4
4
|
import {
|
|
5
5
|
TreeNode,
|
|
6
6
|
SidebarGtmAction,
|
|
@@ -9,11 +9,12 @@ import {
|
|
|
9
9
|
import { getSidebarSearchParams } from "utils/coveo";
|
|
10
10
|
import { toJson } from "utils/normalizers";
|
|
11
11
|
import SidebarSearch from "dx/sidebarSearch";
|
|
12
|
+
import { SidebarBase } from "base-elements/sidebarBase";
|
|
12
13
|
|
|
13
14
|
const MOBILE_SIZE_MATCH = "768px";
|
|
14
15
|
const TOGGLE_BUTTON_LABEL = "Toggle Sidebar";
|
|
15
16
|
|
|
16
|
-
export default class Sidebar extends
|
|
17
|
+
export default class Sidebar extends SidebarBase {
|
|
17
18
|
@api coveoOrganizationId!: string;
|
|
18
19
|
@api coveoPublicAccessToken!: string;
|
|
19
20
|
@api coveoSearchHub!: string;
|
|
@@ -144,6 +145,7 @@ export default class Sidebar extends LightningElement {
|
|
|
144
145
|
}
|
|
145
146
|
|
|
146
147
|
renderedCallback() {
|
|
148
|
+
super.renderedCallback()
|
|
147
149
|
this.initializeSearchScrollPosition();
|
|
148
150
|
}
|
|
149
151
|
|
|
@@ -158,6 +160,7 @@ export default class Sidebar extends LightningElement {
|
|
|
158
160
|
}
|
|
159
161
|
|
|
160
162
|
disconnectedCallback() {
|
|
163
|
+
super.disconnectedCallback()
|
|
161
164
|
this.matchMedia.removeEventListener("change", this.onMediaChange);
|
|
162
165
|
}
|
|
163
166
|
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
></dx-input>
|
|
50
50
|
</div>
|
|
51
51
|
</div>
|
|
52
|
-
<div class="sidebar-content" if:true={anyResultMatch}>
|
|
52
|
+
<div class="sidebar-content sidebar-content-tree" if:true={anyResultMatch}>
|
|
53
53
|
<dx-tree
|
|
54
54
|
for:each={filteredTrees}
|
|
55
55
|
for:item="tree"
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
tree-root={tree.tree}
|
|
58
58
|
onselect={onSelect}
|
|
59
59
|
value={value}
|
|
60
|
+
onselecteditemrendered={onSelectedItemRendered}
|
|
60
61
|
></dx-tree>
|
|
61
62
|
</div>
|
|
62
63
|
<dx-empty-state
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import cx from "classnames";
|
|
2
2
|
import { track } from "dx/instrumentation";
|
|
3
|
-
import {
|
|
3
|
+
import { api } from "lwc";
|
|
4
4
|
|
|
5
5
|
import { TreeNode, SidebarGtmAction } from "typings/custom";
|
|
6
6
|
import { toJson } from "utils/normalizers";
|
|
7
|
+
import { SidebarBase } from "base-elements/sidebarBase";
|
|
7
8
|
|
|
8
9
|
const WAIT_TIME = 500;
|
|
9
10
|
const MOBILE_SIZE_MATCH = "768px";
|
|
10
11
|
const TOGGLE_BUTTON_LABEL = "Toggle Sidebar";
|
|
11
12
|
|
|
12
|
-
export default class Sidebar extends
|
|
13
|
+
export default class Sidebar extends SidebarBase {
|
|
13
14
|
@api header: string = "";
|
|
14
15
|
|
|
15
16
|
@api
|
|
@@ -80,7 +81,12 @@ export default class Sidebar extends LightningElement {
|
|
|
80
81
|
this.matchMedia.addEventListener("change", this.onMediaChange);
|
|
81
82
|
}
|
|
82
83
|
|
|
84
|
+
renderedCallback() {
|
|
85
|
+
super.renderedCallback();
|
|
86
|
+
}
|
|
87
|
+
|
|
83
88
|
disconnectedCallback() {
|
|
89
|
+
super.disconnectedCallback()
|
|
84
90
|
this.matchMedia.removeEventListener("change", this.onMediaChange);
|
|
85
91
|
}
|
|
86
92
|
|
|
@@ -2,6 +2,7 @@ import { LightningElement, api } from "lwc";
|
|
|
2
2
|
import { InternalTreeNode } from "typings/custom";
|
|
3
3
|
import { track } from "dx/instrumentation";
|
|
4
4
|
import { SidebarGtmAction } from "typings/custom";
|
|
5
|
+
import { isInViewport } from "utils/browser";
|
|
5
6
|
|
|
6
7
|
const DEFAULT_TARGET = "_self";
|
|
7
8
|
|
|
@@ -61,6 +62,25 @@ export default class TreeItem extends LightningElement {
|
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
|
|
65
|
+
renderedCallback(): void {
|
|
66
|
+
this.sendEventToParentIfSelected();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private sendEventToParentIfSelected(): void {
|
|
70
|
+
/**
|
|
71
|
+
* This is to send selected element reference to parent if it's not visible in the viewport
|
|
72
|
+
* Parent component will use the elements offsetTop scrollTo that element's position
|
|
73
|
+
*/
|
|
74
|
+
if (this.isSelected) {
|
|
75
|
+
const element = this.template.querySelector("dx-tree-tile");
|
|
76
|
+
if (element && !isInViewport(element)) {
|
|
77
|
+
this.fireEvent("selecteditemrendered", {
|
|
78
|
+
element
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
64
84
|
private onIconClick(event: CustomEvent): void {
|
|
65
85
|
const isSelectAction = false;
|
|
66
86
|
this.doExpand(isSelectAction);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns whether given element is in browser viewport or not
|
|
3
|
+
*/
|
|
4
|
+
function isInViewport(element: HTMLElement): boolean {
|
|
5
|
+
const rect = element?.getBoundingClientRect();
|
|
6
|
+
return (
|
|
7
|
+
rect &&
|
|
8
|
+
rect.top >= 0 &&
|
|
9
|
+
rect.left >= 0 &&
|
|
10
|
+
rect.bottom <=
|
|
11
|
+
(window.innerHeight || document.documentElement.clientHeight) &&
|
|
12
|
+
rect.right <=
|
|
13
|
+
(window.innerWidth || document.documentElement.clientWidth)
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { isInViewport };
|
package/LICENSE
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2020, Salesforce.com, Inc.
|
|
2
|
-
All rights reserved.
|
|
3
|
-
|
|
4
|
-
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
5
|
-
|
|
6
|
-
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
7
|
-
|
|
8
|
-
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
9
|
-
|
|
10
|
-
* Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
11
|
-
|
|
12
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="card-grid">
|
|
3
|
-
<div class="docs-action-bar">
|
|
4
|
-
<div class="records-container">
|
|
5
|
-
<span if:true={endingRecord}>
|
|
6
|
-
Showing { startingRecord } to { endingRecord } of {
|
|
7
|
-
cards.length }
|
|
8
|
-
</span>
|
|
9
|
-
</div>
|
|
10
|
-
<div class="filters-container">
|
|
11
|
-
<slot name="filters"></slot>
|
|
12
|
-
</div>
|
|
13
|
-
<dx-input
|
|
14
|
-
size="small"
|
|
15
|
-
placeholder="Search..."
|
|
16
|
-
icon-symbol="search"
|
|
17
|
-
shortcut-key="j"
|
|
18
|
-
class="docs-search-input"
|
|
19
|
-
onchange={handleSearchChange}
|
|
20
|
-
value={searchTerm}
|
|
21
|
-
></dx-input>
|
|
22
|
-
</div>
|
|
23
|
-
<dx-grid
|
|
24
|
-
columns={tileColumns}
|
|
25
|
-
if:false={showEmptyState}
|
|
26
|
-
class="card-container"
|
|
27
|
-
></dx-grid>
|
|
28
|
-
<div style="display: none">
|
|
29
|
-
<slot name="cards" onslotchange={onSlotChange}></slot>
|
|
30
|
-
</div>
|
|
31
|
-
<div class="pagination-container" if:false={showEmptyState}>
|
|
32
|
-
<dx-pagination
|
|
33
|
-
current-page={page}
|
|
34
|
-
total-pages={totalPages}
|
|
35
|
-
pages-to-show={pagesToShow}
|
|
36
|
-
onpagechange={goToPage}
|
|
37
|
-
if:false={hidePagination}
|
|
38
|
-
></dx-pagination>
|
|
39
|
-
</div>
|
|
40
|
-
</div>
|
|
41
|
-
<dx-empty-state
|
|
42
|
-
title="Beep boop. That did not compute."
|
|
43
|
-
subtitle={emptyStateSubtitle}
|
|
44
|
-
if:true={showEmptyState}
|
|
45
|
-
></dx-empty-state>
|
|
46
|
-
</template>
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { LightningElement, api } from "lwc";
|
|
2
|
-
|
|
3
|
-
export default class CardGrid extends LightningElement {
|
|
4
|
-
@api pageSize = 24;
|
|
5
|
-
@api searchDebounce = 500;
|
|
6
|
-
page = 1;
|
|
7
|
-
|
|
8
|
-
private searchTerm = "";
|
|
9
|
-
private matchDesktop!: MediaQueryList;
|
|
10
|
-
private matchMobile!: MediaQueryList;
|
|
11
|
-
private matchMobileSmall!: MediaQueryList;
|
|
12
|
-
private deviceType: "desktop" | "mobile" | "mobile-small" = "desktop";
|
|
13
|
-
private searchTimeout?: number;
|
|
14
|
-
private cards: any[] = [];
|
|
15
|
-
|
|
16
|
-
private get startingRecord() {
|
|
17
|
-
return this.page === 1
|
|
18
|
-
? this.page
|
|
19
|
-
: (this.page - 1) * this.pageSize + 1;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
private get endingRecord() {
|
|
23
|
-
const defaultEndingRecord = this.pageSize * this.page;
|
|
24
|
-
return defaultEndingRecord > this.cards.length
|
|
25
|
-
? this.cards.length
|
|
26
|
-
: defaultEndingRecord;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
private get totalPages() {
|
|
30
|
-
return Math.ceil(this.cards.length / this.pageSize);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
private get hidePagination() {
|
|
34
|
-
return this.totalPages < 2;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
private get emptyStateSubtitle() {
|
|
38
|
-
return (
|
|
39
|
-
"No results" +
|
|
40
|
-
(this.searchTerm !== "" ? ` for "${this.searchTerm}"` : "")
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
private get showEmptyState() {
|
|
45
|
-
return !this.cards.length;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
private get tileColumns() {
|
|
49
|
-
return this.deviceType === "desktop" ? "three" : "two";
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
private get pagesToShow() {
|
|
53
|
-
return this.deviceType === "mobile-small" ? 3 : 5;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
connectedCallback(): void {
|
|
57
|
-
this.matchDesktop = window.matchMedia("(min-width: 1024px)");
|
|
58
|
-
this.matchDesktop.addEventListener("change", this.handleDesktopView);
|
|
59
|
-
|
|
60
|
-
this.matchMobile = window.matchMedia(
|
|
61
|
-
"(min-width: 401px) and (max-width: 1023px)"
|
|
62
|
-
);
|
|
63
|
-
this.matchMobile.addEventListener("change", this.handleMobileView);
|
|
64
|
-
|
|
65
|
-
this.matchMobileSmall = window.matchMedia("(max-width: 340px)");
|
|
66
|
-
this.matchMobileSmall.addEventListener(
|
|
67
|
-
"change",
|
|
68
|
-
this.handleMobileSmallView
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
if (this.matchMobile.matches) {
|
|
72
|
-
this.deviceType = "mobile";
|
|
73
|
-
}
|
|
74
|
-
if (this.matchMobileSmall.matches) {
|
|
75
|
-
this.deviceType = "mobile-small";
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
disconnectedCallback(): void {
|
|
80
|
-
this.matchDesktop.removeEventListener("change", this.handleDesktopView);
|
|
81
|
-
this.matchMobile.removeEventListener("change", this.handleMobileView);
|
|
82
|
-
this.matchMobileSmall.removeEventListener(
|
|
83
|
-
"change",
|
|
84
|
-
this.handleMobileSmallView
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
renderedCallback(): void {
|
|
89
|
-
this.displayCurrentPage();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
onSlotChange() {
|
|
93
|
-
const slots = Array.from(
|
|
94
|
-
this.template.querySelectorAll("slot")
|
|
95
|
-
) as HTMLSlotElement[];
|
|
96
|
-
this.cards = Array.from(slots[1].assignedElements()[0].children);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
handleDesktopView = (e: MediaQueryListEvent | MediaQueryList) => {
|
|
100
|
-
if (e.matches) {
|
|
101
|
-
this.deviceType = "desktop";
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
handleMobileView = (e: MediaQueryListEvent | MediaQueryList) => {
|
|
106
|
-
if (e.matches) {
|
|
107
|
-
this.deviceType = "mobile";
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
handleMobileSmallView = (e: MediaQueryListEvent | MediaQueryList) => {
|
|
112
|
-
if (e.matches) {
|
|
113
|
-
this.deviceType = "mobile-small";
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
handleSearchChange(event: InputEvent): void {
|
|
118
|
-
window.clearTimeout(this.searchTimeout);
|
|
119
|
-
this.searchTimeout = window.setTimeout(() => {
|
|
120
|
-
this.dispatchEvent(
|
|
121
|
-
new CustomEvent("searchchange", { detail: event.detail })
|
|
122
|
-
);
|
|
123
|
-
}, this.searchDebounce);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
goToPage(e: CustomEvent) {
|
|
127
|
-
this.page = e.detail;
|
|
128
|
-
this.displayCurrentPage();
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
displayCurrentPage() {
|
|
132
|
-
const cardContainer = this.template.querySelector(".card-container");
|
|
133
|
-
if (cardContainer) {
|
|
134
|
-
cardContainer.innerHTML = "";
|
|
135
|
-
this.cards
|
|
136
|
-
.slice(this.startingRecord - 1, this.endingRecord)
|
|
137
|
-
.map((node) => cardContainer?.appendChild(node));
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|