@salesforcedevs/dx-components 0.45.0-alpha3 → 0.46.0-tree-loading
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 +0 -1
- package/package.json +1 -1
- package/src/assets/svg/sidebar-item-loading.svg +9 -0
- package/src/modules/dx/button/button.css +11 -5
- package/src/modules/dx/{cardGridDocs/cardGridDocs.css → cardGrid/cardGrid.css} +15 -3
- package/src/modules/dx/cardGrid/cardGrid.html +46 -0
- package/src/modules/dx/cardGrid/cardGrid.ts +140 -0
- package/src/modules/dx/grid/grid.ts +1 -3
- package/src/modules/dx/sidebar/sidebar.ts +2 -2
- package/src/modules/dx/sidebarOld/sidebarOld.html +4 -1
- package/src/modules/dx/sidebarOld/sidebarOld.ts +4 -3
- package/src/modules/dx/tree/treeHandler.ts +1 -0
- package/src/modules/dx/treeItem/treeItem.css +6 -0
- package/src/modules/dx/treeItem/treeItem.html +8 -0
- package/src/modules/dx/treeItem/treeItem.ts +10 -0
- package/src/modules/dx/treeTile/treeTile.html +1 -1
- package/src/modules/dx/treeTile/treeTile.ts +12 -0
- package/src/modules/dx/cardGridDocs/cardGridDocs.html +0 -67
- package/src/modules/dx/cardGridDocs/cardGridDocs.ts +0 -73
package/lwc.config.json
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<svg width="100%" height="128" fill="none"
|
|
2
|
+
xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<mask id="mask0_581_15739" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="16" y="8" width="267" height="112">
|
|
4
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M24 8C19.5817 8 16 11.5817 16 16C16 20.4183 19.5817 24 24 24H252C256.418 24 260 20.4183 260 16C260 11.5817 256.418 8 252 8H24ZM24 40C19.5817 40 16 43.5817 16 48C16 52.4183 19.5817 56 24 56H213C217.418 56 221 52.4183 221 48C221 43.5817 217.418 40 213 40H24ZM16 80C16 75.5817 19.5817 72 24 72H275C279.418 72 283 75.5817 283 80C283 84.4183 279.418 88 275 88H24C19.5817 88 16 84.4183 16 80ZM24 104C19.5817 104 16 107.582 16 112C16 116.418 19.5817 120 24 120H175C179.418 120 183 116.418 183 112C183 107.582 179.418 104 175 104H24Z" fill="#E5E5E5"/>
|
|
5
|
+
</mask>
|
|
6
|
+
<g mask="url(#mask0_581_15739)">
|
|
7
|
+
<rect width="100%" height="128" fill="#E5E5E5"/>
|
|
8
|
+
</g>
|
|
9
|
+
</svg>
|
|
@@ -116,7 +116,8 @@
|
|
|
116
116
|
border: 1px solid var(--dx-c-button-primary-color);
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
.button.variant_primary:hover
|
|
119
|
+
.button.variant_primary:hover,
|
|
120
|
+
:host([aria-expanded="true"]) .button.variant_primary {
|
|
120
121
|
background: var(--dx-c-button-primary-color-hover);
|
|
121
122
|
border-color: var(--dx-c-button-primary-color-hover);
|
|
122
123
|
}
|
|
@@ -129,7 +130,8 @@
|
|
|
129
130
|
border: 1px solid var(--dx-c-button-primary-color);
|
|
130
131
|
}
|
|
131
132
|
|
|
132
|
-
.button.variant_secondary:hover
|
|
133
|
+
.button.variant_secondary:hover,
|
|
134
|
+
:host([aria-expanded="true"]) .button.variant_secondary {
|
|
133
135
|
background: var(--dx-c-button-secondary-color-hover);
|
|
134
136
|
}
|
|
135
137
|
|
|
@@ -146,7 +148,8 @@
|
|
|
146
148
|
color: white;
|
|
147
149
|
}
|
|
148
150
|
|
|
149
|
-
.button.variant_tertiary:hover
|
|
151
|
+
.button.variant_tertiary:hover,
|
|
152
|
+
:host([aria-expanded="true"]) .button.variant_tertiary {
|
|
150
153
|
background: var(--dx-c-button-secondary-color-hover);
|
|
151
154
|
border-color: var(--dx-c-button-secondary-color-hover);
|
|
152
155
|
}
|
|
@@ -161,7 +164,9 @@
|
|
|
161
164
|
}
|
|
162
165
|
|
|
163
166
|
.button.variant_inline:hover,
|
|
164
|
-
.button.variant_inline-inherit:hover
|
|
167
|
+
.button.variant_inline-inherit:hover,
|
|
168
|
+
:host([aria-expanded="true"])
|
|
169
|
+
:is(.button.variant_inline, .button.variant_inline-inherit) {
|
|
165
170
|
color: var(--dx-c-button-inline-color-hover);
|
|
166
171
|
}
|
|
167
172
|
|
|
@@ -176,7 +181,8 @@
|
|
|
176
181
|
border: 1px solid var(--dx-c-button-custom-border);
|
|
177
182
|
}
|
|
178
183
|
|
|
179
|
-
.button.variant_custom:hover
|
|
184
|
+
.button.variant_custom:hover,
|
|
185
|
+
:host([aria-expanded="true"]) .button.variant_custom {
|
|
180
186
|
color: var(--dx-c-button-custom-color-hover);
|
|
181
187
|
background: var(--dx-c-button-custom-background-hover);
|
|
182
188
|
border-color: var(--dx-c-button-custom-border-hover);
|
|
@@ -16,15 +16,27 @@
|
|
|
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
|
+
|
|
19
26
|
.docs-action-bar .filters-container > *:not(:first-child),
|
|
20
|
-
|
|
27
|
+
.docs-search-input {
|
|
21
28
|
margin-left: var(--dx-g-spacing-sm);
|
|
22
29
|
}
|
|
23
30
|
|
|
24
|
-
|
|
31
|
+
.docs-search-input {
|
|
25
32
|
--dx-c-input-width: 285px;
|
|
26
33
|
}
|
|
27
34
|
|
|
35
|
+
.docs-card {
|
|
36
|
+
--dx-c-body-max-lines: 4;
|
|
37
|
+
--dx-c-heading-max-lines: 2;
|
|
38
|
+
}
|
|
39
|
+
|
|
28
40
|
.pagination-container {
|
|
29
41
|
max-width: fit-content;
|
|
30
42
|
max-width: -moz-fit-content;
|
|
@@ -44,7 +56,7 @@ dx-search-input {
|
|
|
44
56
|
padding: 0;
|
|
45
57
|
}
|
|
46
58
|
|
|
47
|
-
|
|
59
|
+
.docs-search-input {
|
|
48
60
|
--dx-c-input-width: 100%;
|
|
49
61
|
|
|
50
62
|
width: 100%;
|
|
@@ -0,0 +1,46 @@
|
|
|
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>
|
|
@@ -0,0 +1,140 @@
|
|
|
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
|
+
}
|
|
@@ -67,8 +67,6 @@ export default class Grid extends LightningElement {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
onSlotChange(e: Event) {
|
|
70
|
-
this._itemCount = (
|
|
71
|
-
e.target as LightningSlotElement
|
|
72
|
-
).assignedElements().length;
|
|
70
|
+
this._itemCount = (e.target as LightningSlotElement).assignedElements().length;
|
|
73
71
|
}
|
|
74
72
|
}
|
|
@@ -145,7 +145,7 @@ export default class Sidebar extends SidebarBase {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
renderedCallback() {
|
|
148
|
-
super.renderedCallback()
|
|
148
|
+
super.renderedCallback();
|
|
149
149
|
this.initializeSearchScrollPosition();
|
|
150
150
|
}
|
|
151
151
|
|
|
@@ -160,7 +160,7 @@ export default class Sidebar extends SidebarBase {
|
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
disconnectedCallback() {
|
|
163
|
-
super.disconnectedCallback()
|
|
163
|
+
super.disconnectedCallback();
|
|
164
164
|
this.matchMedia.removeEventListener("change", this.onMediaChange);
|
|
165
165
|
}
|
|
166
166
|
|
|
@@ -49,7 +49,10 @@
|
|
|
49
49
|
></dx-input>
|
|
50
50
|
</div>
|
|
51
51
|
</div>
|
|
52
|
-
<div
|
|
52
|
+
<div
|
|
53
|
+
class="sidebar-content sidebar-content-tree"
|
|
54
|
+
if:true={anyResultMatch}
|
|
55
|
+
>
|
|
53
56
|
<dx-tree
|
|
54
57
|
for:each={filteredTrees}
|
|
55
58
|
for:item="tree"
|
|
@@ -86,7 +86,7 @@ export default class Sidebar extends SidebarBase {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
disconnectedCallback() {
|
|
89
|
-
super.disconnectedCallback()
|
|
89
|
+
super.disconnectedCallback();
|
|
90
90
|
this.matchMedia.removeEventListener("change", this.onMediaChange);
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -160,8 +160,9 @@ export default class Sidebar extends SidebarBase {
|
|
|
160
160
|
valuePattern: RegExp,
|
|
161
161
|
node: TreeNode
|
|
162
162
|
): TreeNode | undefined {
|
|
163
|
+
const isExpanded = node.isChildrenLoading ? false : true;
|
|
163
164
|
if (valuePattern.test(node.label.toLowerCase())) {
|
|
164
|
-
return { ...node, isExpanded
|
|
165
|
+
return { ...node, isExpanded };
|
|
165
166
|
}
|
|
166
167
|
|
|
167
168
|
const filteredChildren = this.filterChildren(
|
|
@@ -169,7 +170,7 @@ export default class Sidebar extends SidebarBase {
|
|
|
169
170
|
node.children
|
|
170
171
|
);
|
|
171
172
|
return filteredChildren.length > 0
|
|
172
|
-
? { ...node, children: filteredChildren, isExpanded
|
|
173
|
+
? { ...node, children: filteredChildren, isExpanded }
|
|
173
174
|
: undefined;
|
|
174
175
|
}
|
|
175
176
|
|
|
@@ -8,8 +8,16 @@
|
|
|
8
8
|
has-children={hasChildren}
|
|
9
9
|
is-selected={isSelected}
|
|
10
10
|
oniconclick={onIconClick}
|
|
11
|
+
show-arrow={showArrow}
|
|
11
12
|
></dx-tree-tile>
|
|
12
13
|
</a>
|
|
14
|
+
<!-- TODO: Need to change the loading svg or change it to animated component-->
|
|
15
|
+
<img
|
|
16
|
+
if:true={showChildrenLoading}
|
|
17
|
+
class="tree-children-loading"
|
|
18
|
+
src="/assets/svg/sidebar-item-loading.svg"
|
|
19
|
+
alt="childrenLoading"
|
|
20
|
+
/>
|
|
13
21
|
<template if:true={showChildren}>
|
|
14
22
|
<template for:each={treeNode.children} for:item="child">
|
|
15
23
|
<dx-tree-item
|
|
@@ -18,10 +18,12 @@ export default class TreeItem extends LightningElement {
|
|
|
18
18
|
public set treeNode(node) {
|
|
19
19
|
this._treeNode = node;
|
|
20
20
|
this.isExpanded = (node && node.isExpanded) || false;
|
|
21
|
+
this.isChildrenLoading = (node && node.isChildrenLoading) || false;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
private _treeNode!: InternalTreeNode;
|
|
24
25
|
private isExpanded: boolean = false;
|
|
26
|
+
private isChildrenLoading: boolean = false;
|
|
25
27
|
|
|
26
28
|
private get isSelected(): boolean {
|
|
27
29
|
return this._treeNode.key === this.selectedKey;
|
|
@@ -35,6 +37,14 @@ export default class TreeItem extends LightningElement {
|
|
|
35
37
|
);
|
|
36
38
|
}
|
|
37
39
|
|
|
40
|
+
private get showChildrenLoading(): boolean {
|
|
41
|
+
return this.isExpanded && this.isChildrenLoading;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private get showArrow(): boolean {
|
|
45
|
+
return this.hasChildren || this.isChildrenLoading;
|
|
46
|
+
}
|
|
47
|
+
|
|
38
48
|
private get showChildren(): boolean {
|
|
39
49
|
return this.isExpanded && this.hasChildren;
|
|
40
50
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LightningElement, api } from "lwc";
|
|
2
2
|
import cx from "classnames";
|
|
3
3
|
import { InternalTreeNode } from "typings/custom";
|
|
4
|
+
import { normalizeBoolean } from "utils/normalizers";
|
|
4
5
|
|
|
5
6
|
const methodTextMap: {
|
|
6
7
|
[key: string]: string;
|
|
@@ -24,6 +25,17 @@ export default class TreeTile extends LightningElement {
|
|
|
24
25
|
return this.treeNode.level + 2;
|
|
25
26
|
}
|
|
26
27
|
|
|
28
|
+
private _showArrow = false;
|
|
29
|
+
|
|
30
|
+
@api
|
|
31
|
+
get showArrow() {
|
|
32
|
+
return this._showArrow;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
set showArrow(value) {
|
|
36
|
+
this._showArrow = normalizeBoolean(value);
|
|
37
|
+
}
|
|
38
|
+
|
|
27
39
|
private get iconSize() {
|
|
28
40
|
return this.isRoot ? "small" : "xsmall";
|
|
29
41
|
}
|
|
@@ -1,67 +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={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>
|
|
@@ -1,73 +0,0 @@
|
|
|
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
|
-
}
|