@salesforcedevs/dw-components 0.79.3 → 1.0.0
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 +10 -1
- package/package.json +16 -12
- package/src/modules/dw/blogsGrid/blogsGrid.css +14 -7
- package/src/modules/dw/blogsGrid/blogsGrid.html +15 -12
- package/src/modules/dw/blogsGrid/blogsGrid.ts +23 -9
- package/src/modules/dw/browseTrials/browseTrials.css +35 -0
- package/src/modules/dw/browseTrials/browseTrials.html +86 -0
- package/src/modules/dw/browseTrials/browseTrials.ts +116 -0
- package/src/modules/dw/cardBlogPostProvider/cardBlogPostProvider.css +2 -0
- package/src/modules/dw/cardBlogPostProvider/cardBlogPostProvider.html +3 -3
- package/src/modules/dw/cardPodcastEpisodeProvider/cardPodcastEpisodeProvider.css +2 -0
- package/src/modules/dw/cardPodcastEpisodeProvider/cardPodcastEpisodeProvider.html +2 -1
- package/src/modules/dw/codeSamplesGrid/codeSamplesGrid.css +85 -4
- package/src/modules/dw/codeSamplesGrid/codeSamplesGrid.html +72 -110
- package/src/modules/dw/codeSamplesGrid/codeSamplesGrid.ts +14 -375
- package/src/modules/dw/contentArchive/contentArchive.css +5 -4
- package/src/modules/dw/contentArchive/contentArchive.html +58 -24
- package/src/modules/dw/contentArchive/contentArchive.ts +46 -8
- package/src/modules/dw/contentArchive/contentArchive.types.ts +8 -4
- package/src/modules/dw/contentArchive/utils.ts +29 -13
- package/src/modules/dw/deSignupForm/deSignupForm.css +11 -10
- package/src/modules/dw/deSignupForm/deSignupForm.html +39 -25
- package/src/modules/dw/deSignupForm/deSignupForm.ts +205 -133
- package/src/modules/dw/deSignupForm/submitForm.ts +7 -3
- package/src/modules/dw/docsGrid/docsGrid.css +0 -1
- package/src/modules/dw/docsGrid/docsGrid.html +6 -2
- package/src/modules/dw/docsGrid/docsGrid.ts +103 -38
- package/src/modules/dw/eventsList/eventsList.css +4 -4
- package/src/modules/dw/eventsList/eventsList.html +5 -5
- package/src/modules/dw/eventsList/eventsList.ts +47 -48
- package/src/modules/dw/j2sCardSequence/j2sCardSequence.css +14 -0
- package/src/modules/dw/j2sCardSequence/j2sCardSequence.html +41 -0
- package/src/modules/dw/j2sCardSequence/j2sCardSequence.ts +487 -0
- package/src/modules/dw/j2sCardSequenceStep/j2sCardSequenceStep.css +76 -0
- package/src/modules/dw/j2sCardSequenceStep/j2sCardSequenceStep.html +64 -0
- package/src/modules/dw/j2sCardSequenceStep/j2sCardSequenceStep.ts +157 -0
- package/src/modules/dw/j2sForm/j2sForm.css +65 -0
- package/src/modules/dw/j2sForm/j2sForm.html +217 -0
- package/src/modules/dw/j2sForm/j2sForm.ts +371 -0
- package/src/modules/dw/j2sForm/mockProps.ts +3102 -0
- package/src/modules/dw/languageSelector/languageSelector.css +86 -0
- package/src/modules/dw/languageSelector/languageSelector.html +36 -0
- package/src/modules/dw/languageSelector/languageSelector.ts +119 -0
- package/src/modules/dw/newsletterForm/newsletterForm.css +2 -2
- package/src/modules/dw/newsletterForm/newsletterForm.html +35 -10
- package/src/modules/dw/newsletterForm/newsletterForm.ts +107 -78
- package/src/modules/dw/podcastSubscription/podcastSubscription.css +8 -8
- package/src/modules/dw/podcastSubscription/podcastSubscription.html +2 -2
- package/src/modules/dw/podcastSubscription/podcastSubscription.ts +3 -3
- package/src/modules/dw/podcastsGrid/podcastsGrid.css +7 -0
- package/src/modules/dw/podcastsGrid/podcastsGrid.html +6 -1
- package/src/modules/dw/podcastsGrid/podcastsGrid.ts +3 -3
- package/src/modules/dw/podcastsPromo/podcastsPromo.css +14 -0
- package/src/modules/dw/podcastsPromo/podcastsPromo.html +16 -8
- package/src/modules/dw/podcastsPromo/podcastsPromo.ts +11 -2
- package/src/modules/dw/rcgTable/altData.ts +72 -9
- package/src/modules/dw/rcgTable/getTableData.ts +1 -1
- package/src/modules/dw/rcgTable/rcgTable.ts +3 -3
- package/src/modules/dw/slackCta/slackCta.css +5 -6
- package/src/modules/dw/slackCta/slackCta.html +1 -1
- package/src/modules/dw/slackSuccess/slackSuccess.css +1 -1
- package/src/modules/dw/slackSuccess/slackSuccess.html +2 -2
- package/src/modules/dw/tbidLoginMenu/tbidLoginMenu.css +119 -0
- package/src/modules/dw/tbidLoginMenu/tbidLoginMenu.html +192 -0
- package/src/modules/dw/tbidLoginMenu/tbidLoginMenu.ts +148 -0
- package/src/modules/dw/videoGrid/types.ts +12 -0
- package/src/modules/dw/videoGrid/videoGrid.css +24 -0
- package/src/modules/dw/videoGrid/videoGrid.html +41 -0
- package/src/modules/dw/videoGrid/videoGrid.ts +41 -0
- package/src/modules/dw/youtubeVideoGrid/types.ts +8 -0
- package/src/modules/dw/youtubeVideoGrid/youtubeVideoGrid.css +18 -0
- package/src/modules/dw/youtubeVideoGrid/youtubeVideoGrid.html +40 -0
- package/src/modules/dw/youtubeVideoGrid/youtubeVideoGrid.ts +66 -0
- package/src/modules/dwHelpers/mobileDividers/mobileDividers.css +19 -0
- package/src/modules/dwUtils/forms/forms.ts +514 -0
- package/src/modules/{dwBaseElements → dwUtils}/postsGrid/postsGrid.ts +10 -13
|
@@ -1,138 +1,100 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<dx-section
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
>
|
|
13
|
-
{featuredCodeSample.body}
|
|
14
|
-
</dx-feature>
|
|
15
|
-
</dx-section>
|
|
16
|
-
|
|
17
|
-
<dx-section title="Browse Demos">
|
|
18
|
-
<div class="docs-action-bar">
|
|
19
|
-
<div class="records-container">
|
|
20
|
-
<span if:true={endingRecord}>
|
|
21
|
-
Showing { startingRecord } to { endingRecord } of {
|
|
22
|
-
filteredSamples.length }
|
|
2
|
+
<dx-section
|
|
3
|
+
class="feature-gradient"
|
|
4
|
+
background-color="linear-gradient(var(--dx-g-indigo-vibrant-90), white)"
|
|
5
|
+
>
|
|
6
|
+
<div class="featured-app-container">
|
|
7
|
+
<div class="featured-app-text">
|
|
8
|
+
<h4>Featured App</h4>
|
|
9
|
+
<h2 class="dx-text-display-5">{featuredCodeSample.title}</h2>
|
|
10
|
+
<span class="feature-card-content dx-text-body-2">
|
|
11
|
+
{featuredCodeSample.body}
|
|
23
12
|
</span>
|
|
13
|
+
<div class="badge-link-container">
|
|
14
|
+
<div class="badge-container">
|
|
15
|
+
<dx-metadata-badge
|
|
16
|
+
for:each={featuredCodeSample.tags}
|
|
17
|
+
for:item="tag"
|
|
18
|
+
key={tag}
|
|
19
|
+
value={tag}
|
|
20
|
+
></dx-metadata-badge>
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
<div class="external-link-container">
|
|
24
|
+
<dx-button
|
|
25
|
+
target={target}
|
|
26
|
+
icon-symbol="new_window"
|
|
27
|
+
variant="primary"
|
|
28
|
+
size="large"
|
|
29
|
+
href={featuredCodeSample.ctaOne.link}
|
|
30
|
+
onclick={handleReadItClick}
|
|
31
|
+
>
|
|
32
|
+
{featuredCodeSample.ctaOne.text}
|
|
33
|
+
</dx-button>
|
|
34
|
+
<dx-button
|
|
35
|
+
target={target}
|
|
36
|
+
variant="secondary"
|
|
37
|
+
size="large"
|
|
38
|
+
href={featuredCodeSample.ctaTwo.link}
|
|
39
|
+
onclick={handleReadItClick}
|
|
40
|
+
>
|
|
41
|
+
{featuredCodeSample.ctaTwo.text}
|
|
42
|
+
</dx-button>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
24
45
|
</div>
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
icon-symbol="chevrondown"
|
|
31
|
-
slot="control"
|
|
32
|
-
>
|
|
33
|
-
Source
|
|
34
|
-
</dx-button>
|
|
35
|
-
<dx-checkbox-group
|
|
36
|
-
legend="Source"
|
|
37
|
-
options={sources}
|
|
38
|
-
slot="content"
|
|
39
|
-
onchange={handleSourceFilterChange}
|
|
40
|
-
value={selectedSourceFilter}
|
|
41
|
-
class="filter-checkbox-group"
|
|
42
|
-
></dx-checkbox-group>
|
|
43
|
-
</dx-popover>
|
|
44
|
-
<dx-popover width="max-content">
|
|
45
|
-
<dx-button
|
|
46
|
-
class="filter-button"
|
|
47
|
-
variant="tertiary"
|
|
48
|
-
icon-symbol="chevrondown"
|
|
49
|
-
slot="control"
|
|
50
|
-
>
|
|
51
|
-
Type
|
|
52
|
-
</dx-button>
|
|
53
|
-
<dx-checkbox-group
|
|
54
|
-
legend="Type"
|
|
55
|
-
options={types}
|
|
56
|
-
slot="content"
|
|
57
|
-
onchange={handleTypeFilterChange}
|
|
58
|
-
value={selectedTypeFilter}
|
|
59
|
-
class="filter-checkbox-group"
|
|
60
|
-
></dx-checkbox-group>
|
|
61
|
-
</dx-popover>
|
|
62
|
-
<dx-popover width="max-content">
|
|
63
|
-
<dx-button
|
|
64
|
-
class="filter-button"
|
|
65
|
-
variant="tertiary"
|
|
66
|
-
icon-symbol="chevrondown"
|
|
67
|
-
slot="control"
|
|
68
|
-
>
|
|
69
|
-
Products
|
|
70
|
-
</dx-button>
|
|
71
|
-
<dx-checkbox-group
|
|
72
|
-
legend="Products"
|
|
73
|
-
options={products}
|
|
74
|
-
slot="content"
|
|
75
|
-
onchange={handleProductFilterChange}
|
|
76
|
-
value={selectedProductFilter}
|
|
77
|
-
class="filter-checkbox-group"
|
|
78
|
-
></dx-checkbox-group>
|
|
79
|
-
</dx-popover>
|
|
80
|
-
</div>
|
|
81
|
-
<dx-input
|
|
82
|
-
size="small"
|
|
83
|
-
placeholder="Search..."
|
|
84
|
-
icon-symbol="search"
|
|
85
|
-
shortcut-key="j"
|
|
86
|
-
class="docs-search-input"
|
|
87
|
-
onchange={handleSearchChange}
|
|
88
|
-
value={searchTerm}
|
|
89
|
-
></dx-input>
|
|
46
|
+
<img
|
|
47
|
+
class="image dx-card-base_image featured-app-image"
|
|
48
|
+
src={featuredCodeSample.img}
|
|
49
|
+
alt={featuredCodeSample.title}
|
|
50
|
+
/>
|
|
90
51
|
</div>
|
|
52
|
+
</dx-section>
|
|
53
|
+
<dx-section header="Explore Salesforce code examples.">
|
|
91
54
|
<dx-grid columns={tileColumns} if:false={showEmptyState}>
|
|
92
55
|
<dx-card-docs
|
|
93
|
-
|
|
94
|
-
for:each={currentPageSamples}
|
|
56
|
+
for:each={samples}
|
|
95
57
|
for:item="item"
|
|
96
58
|
for:index="i"
|
|
97
59
|
key={item.id}
|
|
98
60
|
body={item.body}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
61
|
+
header={item.title}
|
|
62
|
+
href={item.githubLink}
|
|
63
|
+
img-src={item.img}
|
|
64
|
+
show-mobile-img
|
|
102
65
|
>
|
|
103
66
|
<div class="badge-link-container">
|
|
104
67
|
<div class="badge-container">
|
|
105
68
|
<dx-metadata-badge
|
|
106
|
-
|
|
107
|
-
|
|
69
|
+
for:each={item.tags}
|
|
70
|
+
for:item="tag"
|
|
71
|
+
key={tag}
|
|
72
|
+
value={tag}
|
|
108
73
|
></dx-metadata-badge>
|
|
109
74
|
</div>
|
|
110
75
|
<div class="external-link-container">
|
|
111
76
|
<dx-button
|
|
112
77
|
target={target}
|
|
113
78
|
icon-symbol="new_window"
|
|
114
|
-
variant="
|
|
115
|
-
|
|
79
|
+
variant="primary"
|
|
80
|
+
size="large"
|
|
81
|
+
href={item.ctaOne.link}
|
|
82
|
+
onclick={handleReadItClick}
|
|
83
|
+
>
|
|
84
|
+
{item.ctaOne.text}
|
|
85
|
+
</dx-button>
|
|
86
|
+
<dx-button
|
|
87
|
+
target={target}
|
|
88
|
+
variant="secondary"
|
|
89
|
+
size="large"
|
|
90
|
+
href={item.ctaTwo.link}
|
|
91
|
+
onclick={handleReadItClick}
|
|
116
92
|
>
|
|
117
|
-
{item.
|
|
93
|
+
{item.ctaTwo.text}
|
|
118
94
|
</dx-button>
|
|
119
95
|
</div>
|
|
120
96
|
</div>
|
|
121
97
|
</dx-card-docs>
|
|
122
98
|
</dx-grid>
|
|
123
|
-
<div if:false={hidePagination} class="pagination-container">
|
|
124
|
-
<dx-pagination
|
|
125
|
-
if:false={showEmptyState}
|
|
126
|
-
current-page={page}
|
|
127
|
-
total-pages={totalPages}
|
|
128
|
-
pages-to-show={pagesToShow}
|
|
129
|
-
onpagechange={goToPage}
|
|
130
|
-
></dx-pagination>
|
|
131
|
-
</div>
|
|
132
|
-
<dx-empty-state
|
|
133
|
-
title="Beep boop. That did not compute."
|
|
134
|
-
subtitle={emptyStateSubtitle}
|
|
135
|
-
if:true={showEmptyState}
|
|
136
|
-
></dx-empty-state>
|
|
137
99
|
</dx-section>
|
|
138
100
|
</template>
|
|
@@ -1,141 +1,45 @@
|
|
|
1
1
|
import { api, LightningElement } from "lwc";
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import orderBy from "lodash.orderby";
|
|
5
|
-
import cloneDeep from "lodash.clonedeep";
|
|
6
|
-
import { DocsTile, DropdownItem, CodeSample } from "typings/custom";
|
|
2
|
+
|
|
3
|
+
import { CodeSample } from "typings/custom";
|
|
7
4
|
import { toJson } from "dxUtils/normalizers";
|
|
8
5
|
|
|
9
|
-
const PRODUCT_FILTER_ALL_PRODUCTS = "all products";
|
|
10
|
-
const LANGUAGE_FILTER_LABEL = "Type";
|
|
11
|
-
const WAIT_TIME = 500;
|
|
12
6
|
const DEFAULT_BUTTON_TEXT = "Explore on GitHub";
|
|
13
7
|
export default class CodeSamplesGrid extends LightningElement {
|
|
14
|
-
private searchTerm = "";
|
|
15
|
-
private selectedProductFilter: string[] | null = null;
|
|
16
|
-
private selectedTypeFilter: string[] | null = null;
|
|
17
|
-
private selectedSourceFilter: string[] | null = null;
|
|
18
|
-
private page = 1;
|
|
19
|
-
private pageSize = 9;
|
|
20
|
-
private startingRecord = 1;
|
|
21
|
-
private endingRecord = 24;
|
|
22
|
-
private totalRecountCount = 0;
|
|
23
|
-
private totalPages = 1;
|
|
24
8
|
private _featuredCodeSample?: CodeSample = undefined;
|
|
25
|
-
private _samplesList
|
|
26
|
-
private _typesFiltersList?: DropdownItem[] = [];
|
|
27
|
-
private _sourceFiltersList?: DropdownItem[] = [];
|
|
28
|
-
private _productFiltersList?: DropdownItem[] = [];
|
|
29
|
-
private matchDesktop!: MediaQueryList;
|
|
30
|
-
private matchMobile!: MediaQueryList;
|
|
31
|
-
private matchMobileSmall!: MediaQueryList;
|
|
9
|
+
private _samplesList: CodeSample[] = [];
|
|
32
10
|
private deviceType: "desktop" | "mobile" | "mobile-small" = "desktop";
|
|
33
|
-
private _searchTimeout?: number;
|
|
34
11
|
private target = "_blank";
|
|
35
12
|
private isDesktop = "(min-width: 1024px)";
|
|
36
13
|
private isMobile = "(min-width: 401px) and (max-width: 1023px)";
|
|
37
14
|
private isMobileSmall = "(max-width: 400px)";
|
|
38
|
-
private showSourcesFilter = false;
|
|
39
|
-
private filtersDefaultValue = {
|
|
40
|
-
selectedSourceFilter: [],
|
|
41
|
-
selectedTypeFilter: [],
|
|
42
|
-
selectedProductFilter: [],
|
|
43
|
-
searchTerm: "",
|
|
44
|
-
page: "1"
|
|
45
|
-
};
|
|
46
15
|
|
|
47
16
|
connectedCallback(): void {
|
|
48
|
-
|
|
49
|
-
this.matchDesktop.addEventListener("change", this.handleView);
|
|
50
|
-
|
|
51
|
-
this.matchMobile = window.matchMedia(this.isMobile);
|
|
52
|
-
this.matchMobile.addEventListener("change", this.handleView);
|
|
53
|
-
|
|
54
|
-
this.matchMobileSmall = window.matchMedia(this.isMobileSmall);
|
|
55
|
-
this.matchMobileSmall.addEventListener("change", this.handleView);
|
|
56
|
-
window.addEventListener("popstate", this.handleURLStateChange);
|
|
57
|
-
if (this.matchDesktop.matches) {
|
|
58
|
-
this.deviceType = "desktop";
|
|
59
|
-
}
|
|
60
|
-
if (this.matchMobile.matches) {
|
|
61
|
-
this.deviceType = "mobile";
|
|
62
|
-
}
|
|
63
|
-
if (this.matchMobileSmall.matches) {
|
|
64
|
-
this.deviceType = "mobile-small";
|
|
65
|
-
}
|
|
66
|
-
this.evaluateQueryParams(false);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
handleURLStateChange(): void {
|
|
70
|
-
this.evaluateQueryParams(true);
|
|
71
|
-
this.scrollToTop();
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
evaluateQueryParams(resetFilters: boolean): void {
|
|
75
|
-
let page = "1";
|
|
76
|
-
if (resetFilters) {
|
|
77
|
-
this.selectedSourceFilter =
|
|
78
|
-
this.filtersDefaultValue.selectedSourceFilter;
|
|
79
|
-
this.selectedTypeFilter =
|
|
80
|
-
this.filtersDefaultValue.selectedTypeFilter;
|
|
81
|
-
this.selectedProductFilter =
|
|
82
|
-
this.filtersDefaultValue.selectedProductFilter;
|
|
83
|
-
}
|
|
84
|
-
const urlParams = new URLSearchParams(window.location.search);
|
|
85
|
-
if (urlParams.toString()) {
|
|
86
|
-
if (urlParams.has("source")) {
|
|
87
|
-
this.selectedSourceFilter = urlParams.getAll("source");
|
|
88
|
-
}
|
|
89
|
-
if (urlParams.has("type")) {
|
|
90
|
-
this.selectedTypeFilter = urlParams.getAll("type");
|
|
91
|
-
}
|
|
92
|
-
if (urlParams.get("service")) {
|
|
93
|
-
this.selectedProductFilter = urlParams
|
|
94
|
-
.get("service")
|
|
95
|
-
.split(",");
|
|
96
|
-
}
|
|
97
|
-
if (urlParams.get("filter_text")) {
|
|
98
|
-
this.searchTerm = (
|
|
99
|
-
urlParams.get("filter_text") || ""
|
|
100
|
-
).toLowerCase();
|
|
101
|
-
}
|
|
102
|
-
if (urlParams.has("page")) {
|
|
103
|
-
page = urlParams.get("page");
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
this.calculatePagination(page, true);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
disconnectedCallback(): void {
|
|
110
|
-
this.matchDesktop.removeEventListener("change", this.handleView);
|
|
111
|
-
this.matchMobile.removeEventListener("change", this.handleView);
|
|
112
|
-
this.matchMobileSmall.removeEventListener("change", this.handleView);
|
|
113
|
-
window.removeEventListener("popstate", this.handleURLStateChange);
|
|
17
|
+
console.log(this._samplesList);
|
|
114
18
|
}
|
|
115
19
|
|
|
116
20
|
@api
|
|
117
21
|
set featuredCodeSample(value: string) {
|
|
118
22
|
this._featuredCodeSample = toJson(value);
|
|
119
23
|
}
|
|
120
|
-
get featuredCodeSample(): CodeSample {
|
|
24
|
+
get featuredCodeSample(): CodeSample | undefined {
|
|
121
25
|
return this._featuredCodeSample;
|
|
122
26
|
}
|
|
123
27
|
|
|
124
28
|
@api
|
|
125
29
|
set samples(value: string) {
|
|
126
30
|
const jsonSamples = toJson(value) || [];
|
|
127
|
-
this._samplesList = jsonSamples.map((sample, i) => ({
|
|
31
|
+
this._samplesList = jsonSamples.map((sample: any, i: number) => ({
|
|
128
32
|
id: i,
|
|
129
33
|
title: sample.title,
|
|
130
34
|
body: sample.body,
|
|
131
35
|
buttonText: DEFAULT_BUTTON_TEXT,
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
36
|
+
githubLink: sample.githubLink,
|
|
37
|
+
trailheadLink: sample.trailheadLink,
|
|
38
|
+
img: sample.img,
|
|
39
|
+
tags: sample.tags,
|
|
40
|
+
target: this.target,
|
|
41
|
+
ctaOne: sample.ctaOne,
|
|
42
|
+
ctaTwo: sample.ctaTwo
|
|
139
43
|
}));
|
|
140
44
|
}
|
|
141
45
|
|
|
@@ -143,125 +47,8 @@ export default class CodeSamplesGrid extends LightningElement {
|
|
|
143
47
|
return this._samplesList;
|
|
144
48
|
}
|
|
145
49
|
|
|
146
|
-
@api
|
|
147
|
-
set products(value: string) {
|
|
148
|
-
const productsFilters = toJson(value).map((sample: string) => ({
|
|
149
|
-
label: sample,
|
|
150
|
-
value: sample.toLowerCase()
|
|
151
|
-
}));
|
|
152
|
-
|
|
153
|
-
this._productFiltersList = orderBy(
|
|
154
|
-
uniqBy([...productsFilters], "value"),
|
|
155
|
-
["value"],
|
|
156
|
-
["asc"]
|
|
157
|
-
);
|
|
158
|
-
this.selectedProductFilter = this._productFiltersList.map(
|
|
159
|
-
(filter) => filter.value
|
|
160
|
-
);
|
|
161
|
-
this.filtersDefaultValue.selectedProductFilter = cloneDeep(
|
|
162
|
-
this.selectedProductFilter
|
|
163
|
-
);
|
|
164
|
-
}
|
|
165
|
-
get products(): DropdownItem[] {
|
|
166
|
-
return this._productFiltersList;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
@api
|
|
170
|
-
set types(value: string) {
|
|
171
|
-
const typesFilter = toJson(value).map((sample: string) => ({
|
|
172
|
-
label: sample,
|
|
173
|
-
value: sample.toLowerCase()
|
|
174
|
-
}));
|
|
175
|
-
|
|
176
|
-
this._typesFiltersList = orderBy(
|
|
177
|
-
uniqBy([...typesFilter], "value"),
|
|
178
|
-
["value"],
|
|
179
|
-
["asc"]
|
|
180
|
-
);
|
|
181
|
-
this.selectedTypeFilter = this._typesFiltersList.map(
|
|
182
|
-
(filter) => filter.value
|
|
183
|
-
);
|
|
184
|
-
this.filtersDefaultValue.selectedTypeFilter = cloneDeep(
|
|
185
|
-
this.selectedTypeFilter
|
|
186
|
-
);
|
|
187
|
-
}
|
|
188
|
-
get types(): DropdownItem[] {
|
|
189
|
-
return this._typesFiltersList;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
@api
|
|
193
|
-
set sources(value: string) {
|
|
194
|
-
const parsedValues = toJson(value);
|
|
195
|
-
this.showSourcesFilter = parsedValues.length > 0;
|
|
196
|
-
const sourcesFilter = parsedValues.map((sample: string) => ({
|
|
197
|
-
label: sample,
|
|
198
|
-
value: sample.toLowerCase()
|
|
199
|
-
}));
|
|
200
|
-
|
|
201
|
-
this._sourceFiltersList = orderBy(
|
|
202
|
-
uniqBy([...sourcesFilter], "value"),
|
|
203
|
-
["value"],
|
|
204
|
-
["asc"]
|
|
205
|
-
);
|
|
206
|
-
this.selectedSourceFilter = this._sourceFiltersList.map(
|
|
207
|
-
(filter) => filter.value
|
|
208
|
-
);
|
|
209
|
-
this.filtersDefaultValue.selectedSourceFilter = cloneDeep(
|
|
210
|
-
this.selectedSourceFilter
|
|
211
|
-
);
|
|
212
|
-
}
|
|
213
|
-
get sources(): DropdownItem[] {
|
|
214
|
-
return this._sourceFiltersList;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
get filteredSamples(): CodeSample[] {
|
|
218
|
-
return this.filterSamples([...this.samples]);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
get currentPageSamples(): DocsTile[] {
|
|
222
|
-
return this.filteredSamples.slice(
|
|
223
|
-
this.startingRecord - 1,
|
|
224
|
-
this.endingRecord
|
|
225
|
-
);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
get typesList(): DropdownItem[] {
|
|
229
|
-
return this._typesFiltersList || [];
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
get productFiltersList(): DropdownItem[] {
|
|
233
|
-
return this._productFiltersList || [];
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
get showEmptyState(): boolean {
|
|
237
|
-
return !this.filteredSamples.length;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
get typeFilterLabel(): string {
|
|
241
|
-
const selectedLanguage = this.typesList.find(
|
|
242
|
-
(language) => language.value === this.selectedTypeFilter
|
|
243
|
-
);
|
|
244
|
-
const label = selectedLanguage && selectedLanguage.label;
|
|
245
|
-
return label || LANGUAGE_FILTER_LABEL;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
50
|
get tileColumns(): string {
|
|
249
|
-
return this.deviceType === "desktop" ? "
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
get pagesToShow(): number {
|
|
253
|
-
return this.deviceType === "mobile-small" ? 3 : 5;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
get hidePagination(): boolean {
|
|
257
|
-
return this.totalPages < 2;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
get emptyStateSubtitle(): string {
|
|
261
|
-
return (
|
|
262
|
-
"No results" +
|
|
263
|
-
(this.searchTerm !== "" ? ` for "${this.searchTerm}"` : "")
|
|
264
|
-
);
|
|
51
|
+
return this.deviceType === "desktop" ? "two" : "one";
|
|
265
52
|
}
|
|
266
53
|
|
|
267
54
|
handleView = (e: MediaQueryListEvent | MediaQueryList): void => {
|
|
@@ -279,152 +66,4 @@ export default class CodeSamplesGrid extends LightningElement {
|
|
|
279
66
|
this.deviceType = "mobile-small";
|
|
280
67
|
}
|
|
281
68
|
};
|
|
282
|
-
|
|
283
|
-
goToPage(e: CustomEvent): void {
|
|
284
|
-
const page = e.detail;
|
|
285
|
-
this.displayRecordsPerPage(page);
|
|
286
|
-
this.setSearchParams("page", page ? page.toString() : "1");
|
|
287
|
-
this.scrollToTop();
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
displayRecordsPerPage(page: number): void {
|
|
291
|
-
this.page = page;
|
|
292
|
-
this.startingRecord =
|
|
293
|
-
page === 1 ? page : (page - 1) * this.pageSize + 1;
|
|
294
|
-
this.endingRecord = this.pageSize * page;
|
|
295
|
-
this.endingRecord =
|
|
296
|
-
this.endingRecord > this.totalRecountCount
|
|
297
|
-
? this.totalRecountCount
|
|
298
|
-
: this.endingRecord;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
handleSearchChange(event: CustomEvent): void {
|
|
302
|
-
const value = event.detail;
|
|
303
|
-
this.searchTerm = value.toLowerCase();
|
|
304
|
-
window.clearTimeout(this._searchTimeout);
|
|
305
|
-
this._searchTimeout = window.setTimeout(() => {
|
|
306
|
-
this.calculatePagination();
|
|
307
|
-
}, WAIT_TIME);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
handleSourceFilterChange(event: CustomEvent): void {
|
|
311
|
-
this.selectedSourceFilter = event.detail.value;
|
|
312
|
-
this.calculatePagination();
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
handleTypeFilterChange(event: CustomEvent): void {
|
|
316
|
-
this.selectedTypeFilter = event.detail.value;
|
|
317
|
-
this.calculatePagination();
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
handleProductFilterChange(event: CustomEvent): void {
|
|
321
|
-
if (event.detail.checkedValue === PRODUCT_FILTER_ALL_PRODUCTS) {
|
|
322
|
-
if (event.detail.checked) {
|
|
323
|
-
this.selectedProductFilter = this.productFiltersList.map(
|
|
324
|
-
(filter) => filter.value
|
|
325
|
-
);
|
|
326
|
-
} else {
|
|
327
|
-
this.selectedProductFilter = [];
|
|
328
|
-
}
|
|
329
|
-
} else {
|
|
330
|
-
let newList = event.detail.value;
|
|
331
|
-
if (!event.detail.checked) {
|
|
332
|
-
newList = newList.filter(
|
|
333
|
-
(val) => val !== PRODUCT_FILTER_ALL_PRODUCTS
|
|
334
|
-
);
|
|
335
|
-
}
|
|
336
|
-
this.selectedProductFilter = newList;
|
|
337
|
-
}
|
|
338
|
-
this.calculatePagination();
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
handleLanguageFilterChange(event: CustomEvent): void {
|
|
342
|
-
this.selectedTypeFilter = event.detail.value;
|
|
343
|
-
this.setSearchParams("type", this.selectedTypeFilter);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
filterSamples(samples: CodeSample[]): CodeSample[] {
|
|
347
|
-
const filtered = samples
|
|
348
|
-
.filter((contentItem) => {
|
|
349
|
-
const matchesSearchTerm =
|
|
350
|
-
contentItem.body.toLowerCase().includes(this.searchTerm) ||
|
|
351
|
-
contentItem.title.toLowerCase().includes(this.searchTerm);
|
|
352
|
-
const matchesProductFilters =
|
|
353
|
-
!this.selectedProductFilter ||
|
|
354
|
-
!this.selectedProductFilter.length ||
|
|
355
|
-
this.selectedProductFilter.includes(
|
|
356
|
-
PRODUCT_FILTER_ALL_PRODUCTS
|
|
357
|
-
) ||
|
|
358
|
-
(typeof contentItem.product === "string" &&
|
|
359
|
-
this.selectedProductFilter.includes(
|
|
360
|
-
contentItem.product.toLowerCase()
|
|
361
|
-
));
|
|
362
|
-
const matchesTypeFilters =
|
|
363
|
-
!this.selectedTypeFilter ||
|
|
364
|
-
!this.selectedTypeFilter.length ||
|
|
365
|
-
(typeof contentItem.type === "string" &&
|
|
366
|
-
this.selectedTypeFilter.includes(
|
|
367
|
-
contentItem.type.toLowerCase()
|
|
368
|
-
));
|
|
369
|
-
const matchesSourceFilters =
|
|
370
|
-
!this.selectedSourceFilter ||
|
|
371
|
-
!this.selectedSourceFilter.length ||
|
|
372
|
-
(typeof contentItem.source === "string" &&
|
|
373
|
-
this.selectedSourceFilter.includes(
|
|
374
|
-
contentItem.source.toLowerCase()
|
|
375
|
-
));
|
|
376
|
-
|
|
377
|
-
return (
|
|
378
|
-
matchesSearchTerm &&
|
|
379
|
-
matchesProductFilters &&
|
|
380
|
-
matchesTypeFilters &&
|
|
381
|
-
matchesSourceFilters
|
|
382
|
-
);
|
|
383
|
-
})
|
|
384
|
-
.sort((a: CodeSample, b: CodeSample) => {
|
|
385
|
-
return a.title.localeCompare(b.title);
|
|
386
|
-
});
|
|
387
|
-
return filtered;
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
calculatePagination(page?: string, skipSetSearchParams = false): void {
|
|
391
|
-
this.page = +parseInt(page, 10) || 1;
|
|
392
|
-
this.totalRecountCount = this.filteredSamples.length;
|
|
393
|
-
this.totalPages = Math.ceil(this.totalRecountCount / this.pageSize);
|
|
394
|
-
this.displayRecordsPerPage(this.page);
|
|
395
|
-
if (!skipSetSearchParams) {
|
|
396
|
-
this.setSearchParams();
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
scrollToTop(): void {
|
|
401
|
-
this.template
|
|
402
|
-
.querySelector(".docs-grid-container")
|
|
403
|
-
.scrollIntoView({ behavior: "smooth" });
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
setSearchParams(key?: string, val?: string[]): void {
|
|
407
|
-
const service =
|
|
408
|
-
this.selectedProductFilter.length === this.productFiltersList.length
|
|
409
|
-
? ""
|
|
410
|
-
: this.selectedProductFilter.join(",");
|
|
411
|
-
const params = {
|
|
412
|
-
filter_text: this.searchTerm,
|
|
413
|
-
service,
|
|
414
|
-
type: this.selectedTypeFilter,
|
|
415
|
-
page: this.page.toString(),
|
|
416
|
-
source: this.selectedSourceFilter
|
|
417
|
-
};
|
|
418
|
-
if (key) {
|
|
419
|
-
params[key] = key === "service" ? val.join(",") : val;
|
|
420
|
-
}
|
|
421
|
-
for (const _key in params) {
|
|
422
|
-
if (!params[_key]) {
|
|
423
|
-
delete params[_key];
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
const searchParams = qs.stringify(params);
|
|
427
|
-
const newurl = `${window.location.pathname}?${searchParams}`;
|
|
428
|
-
window.history.pushState({ path: newurl }, "", newurl);
|
|
429
|
-
}
|
|
430
69
|
}
|
|
@@ -101,7 +101,7 @@ button:active {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
.empty-state-container {
|
|
104
|
-
background-image: url(/
|
|
104
|
+
background-image: url("https://a.sfdcstatic.com/developer-website/images/no-results-combined.svg");
|
|
105
105
|
background-repeat: no-repeat;
|
|
106
106
|
background-position: center;
|
|
107
107
|
background-size: contain;
|
|
@@ -121,6 +121,7 @@ button:active {
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
.filter-title {
|
|
124
|
+
color: var(--dx-g-text-heading-color);
|
|
124
125
|
font-family: var(--dx-g-font-display);
|
|
125
126
|
font-size: var(--dx-g-text-lg);
|
|
126
127
|
}
|
|
@@ -181,13 +182,13 @@ dx-filter-menu {
|
|
|
181
182
|
|
|
182
183
|
.chip-title {
|
|
183
184
|
font-weight: bold;
|
|
184
|
-
color: rgb(24
|
|
185
|
+
color: rgb(24 24 24);
|
|
185
186
|
}
|
|
186
187
|
|
|
187
188
|
.chip-item {
|
|
188
|
-
border: 2px solid rgb(92
|
|
189
|
+
border: 2px solid rgb(92 92 92);
|
|
189
190
|
border-radius: 4px;
|
|
190
|
-
color: rgb(92
|
|
191
|
+
color: rgb(92 92 92);
|
|
191
192
|
font-weight: 600;
|
|
192
193
|
padding: 2px 4px;
|
|
193
194
|
}
|