@salesforcedevs/dx-components 0.16.1 → 0.18.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 +2 -1
- package/package.json +3 -3
- package/src/assets/svg/sidebar-loading.svg +34 -0
- package/src/modules/dx/banner/__tests__/banner.test.ts +31 -0
- package/src/modules/dx/{feedbackBanner/feedbackBanner.css → banner/banner.css} +6 -6
- package/src/modules/dx/banner/banner.html +13 -0
- package/src/modules/dx/banner/banner.ts +14 -0
- package/src/modules/dx/dropdown/dropdown.html +2 -0
- package/src/modules/dx/dropdown/dropdown.ts +4 -2
- package/src/modules/dx/dropdownOption/__tests__/dropdownOption.test.ts +32 -2
- package/src/modules/dx/dropdownOption/dropdownOption.ts +9 -6
- package/src/modules/dx/footer/footer.ts +13 -1
- package/src/modules/dx/header/__tests__/header.test.ts +38 -21
- package/src/modules/dx/header/__tests__/mockProps.ts +29 -37
- package/src/modules/dx/header/header.html +4 -1
- package/src/modules/dx/header/header.stories.ts +30 -0
- package/src/modules/dx/header/header.ts +4 -1
- package/src/modules/dx/headerNav/headerNav.html +1 -0
- package/src/modules/dx/headerSearch/__tests__/headerSearch.test.ts +24 -39
- package/src/modules/dx/headerSearch/__tests__/mockProps.ts +2 -7
- package/src/modules/dx/headerSearch/headerSearch.ts +13 -19
- package/src/modules/dx/lazy/lazy.ts +0 -7
- package/src/modules/dx/newsletterForm/newsletterForm.ts +20 -11
- package/src/modules/dx/sidebar/__tests__/mockSearchChangeEmptyEvent.ts +6 -0
- package/src/modules/dx/sidebar/__tests__/mockSearchChangeEvent.ts +527 -0
- package/src/modules/dx/sidebar/__tests__/sidebar.test.ts +210 -247
- package/src/modules/dx/sidebar/sidebar.css +40 -17
- package/src/modules/dx/sidebar/sidebar.html +58 -34
- package/src/modules/dx/sidebar/sidebar.stories.ts +54 -4
- package/src/modules/dx/sidebar/sidebar.ts +141 -73
- package/src/modules/dx/sidebarOld/__tests__/mockProps.ts +178 -0
- package/src/modules/dx/sidebarOld/__tests__/sidebarOld.test.ts +574 -0
- package/src/modules/dx/sidebarOld/sidebarOld.css +158 -0
- package/src/modules/dx/sidebarOld/sidebarOld.html +70 -0
- package/src/modules/dx/sidebarOld/sidebarOld.stories.ts +139 -0
- package/src/modules/dx/sidebarOld/sidebarOld.ts +187 -0
- package/src/modules/dx/sidebarSearch/__tests__/mockPreloadedState.ts +8843 -0
- package/src/modules/dx/sidebarSearch/__tests__/sidebarSearch.test.ts +113 -0
- package/src/modules/dx/sidebarSearch/sidebarSearch.css +3 -0
- package/src/modules/dx/sidebarSearch/sidebarSearch.html +26 -0
- package/src/modules/dx/sidebarSearch/sidebarSearch.ts +421 -0
- package/src/modules/dx/sidebarSearchResult/__tests__/sidebarSearchResult.test.ts +55 -0
- package/src/modules/dx/sidebarSearchResult/sidebarSearchResult.css +36 -0
- package/src/modules/dx/sidebarSearchResult/sidebarSearchResult.html +14 -0
- package/src/modules/dx/sidebarSearchResult/sidebarSearchResult.ts +56 -0
- package/src/modules/dx/treeTile/__tests__/treeTile.test.ts +27 -38
- package/src/modules/dx/treeTile/treeTile.css +3 -19
- package/src/modules/dx/treeTile/treeTile.html +4 -1
- package/src/modules/dx/treeTile/treeTile.ts +2 -2
- package/src/modules/helpers/sidebar/sidebar.css +21 -0
- package/src/modules/utils/coveo/coveo.ts +69 -0
- package/src/modules/utils/headerBase/headerBase.ts +13 -2
- package/src/modules/utils/highlight/__tests__/highlight.test.ts +108 -0
- package/src/modules/utils/highlight/__tests__/mockProps.ts +45 -0
- package/src/modules/utils/highlight/highlight.ts +2 -1
- package/src/modules/utils/jest/jest.ts +35 -0
- package/src/modules/utils/recentSearches/__tests__/recentSearches.test.ts +79 -0
- package/src/modules/utils/recentSearches/recentSearches.ts +57 -0
- package/src/modules/utils/tests/tests.ts +18 -11
- package/src/modules/dx/feedbackBanner/__tests__/feedbackBanner.test.ts +0 -19
- package/src/modules/dx/feedbackBanner/feedbackBanner.html +0 -13
- package/src/modules/dx/feedbackBanner/feedbackBanner.ts +0 -3
|
@@ -1,27 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
HeadlessEngine,
|
|
3
|
-
buildStandaloneSearchBox,
|
|
4
|
-
searchAppReducers
|
|
5
|
-
} from "@coveo/headless";
|
|
1
|
+
import { buildSearchEngine, buildStandaloneSearchBox } from "@coveo/headless";
|
|
6
2
|
import Input from "dx/input";
|
|
7
3
|
import Button from "dx/button";
|
|
8
4
|
import Dropdown from "dx/dropdown";
|
|
9
5
|
import HeaderSearch from "dx/headerSearch";
|
|
10
6
|
import { PopoverRequestCloseType } from "typings/custom";
|
|
11
7
|
import { createRenderComponent } from "utils/tests";
|
|
8
|
+
import { coveoHeaderConfig } from "utils/coveo";
|
|
12
9
|
import { MOCK_SUGGESTIONS } from "./mockData";
|
|
13
|
-
import mockProps
|
|
10
|
+
import mockProps from "./mockProps";
|
|
14
11
|
|
|
15
12
|
const COVEO_CONFIG = {
|
|
16
13
|
configuration: {
|
|
17
|
-
organizationId:
|
|
18
|
-
accessToken:
|
|
14
|
+
organizationId: coveoHeaderConfig.coveoOrganizationId,
|
|
15
|
+
accessToken: coveoHeaderConfig.coveoPublicAccessToken,
|
|
19
16
|
search: {
|
|
20
|
-
pipeline:
|
|
21
|
-
searchHub:
|
|
17
|
+
pipeline: coveoHeaderConfig.coveoSearchPipeline,
|
|
18
|
+
searchHub: coveoHeaderConfig.coveoSearchHub
|
|
22
19
|
}
|
|
23
|
-
}
|
|
24
|
-
reducers: searchAppReducers
|
|
20
|
+
}
|
|
25
21
|
};
|
|
26
22
|
|
|
27
23
|
const REDIRECT_URL = "https://developer.salesforce.com";
|
|
@@ -37,9 +33,8 @@ const mockUpdateText = jest.fn();
|
|
|
37
33
|
|
|
38
34
|
jest.mock("@coveo/headless", () => {
|
|
39
35
|
return {
|
|
40
|
-
|
|
41
|
-
buildStandaloneSearchBox: jest.fn()
|
|
42
|
-
searchAppReducers: jest.fn()
|
|
36
|
+
buildSearchEngine: jest.fn(),
|
|
37
|
+
buildStandaloneSearchBox: jest.fn()
|
|
43
38
|
};
|
|
44
39
|
});
|
|
45
40
|
|
|
@@ -68,14 +63,11 @@ const expectMobileToDefaultRender = ({
|
|
|
68
63
|
};
|
|
69
64
|
|
|
70
65
|
const expectSearchToInit = () => {
|
|
71
|
-
expect(
|
|
72
|
-
expect(
|
|
66
|
+
expect(buildSearchEngine).toHaveBeenCalledTimes(1);
|
|
67
|
+
expect(buildSearchEngine).toHaveBeenCalledWith(COVEO_CONFIG);
|
|
73
68
|
expect(buildStandaloneSearchBox).toHaveBeenCalledTimes(1);
|
|
74
|
-
const [
|
|
75
|
-
|
|
76
|
-
options
|
|
77
|
-
] = (buildStandaloneSearchBox as jest.Mock).mock.calls[0];
|
|
78
|
-
expect(engine).toBeInstanceOf(HeadlessEngine);
|
|
69
|
+
const options = (buildStandaloneSearchBox as jest.Mock).mock.calls[0][1];
|
|
70
|
+
|
|
79
71
|
expect(options).toEqual({
|
|
80
72
|
options: {
|
|
81
73
|
numberOfSuggestions: 3,
|
|
@@ -85,8 +77,6 @@ const expectSearchToInit = () => {
|
|
|
85
77
|
expect(mockSubscribe).toHaveBeenCalledTimes(1);
|
|
86
78
|
expect(subscribeCallback).not.toBeNull();
|
|
87
79
|
expect(subscribeCallback).toBeInstanceOf(Function);
|
|
88
|
-
expect(mockUpdateText).toHaveBeenCalledTimes(1);
|
|
89
|
-
expect(mockUpdateText).toHaveBeenCalledWith("");
|
|
90
80
|
};
|
|
91
81
|
|
|
92
82
|
describe(TAG, () => {
|
|
@@ -113,9 +103,8 @@ describe(TAG, () => {
|
|
|
113
103
|
expect(container).not.toBeNull();
|
|
114
104
|
expect(container.classList).toContain("desktop_search-container");
|
|
115
105
|
|
|
116
|
-
const suggestionsDropdown: Dropdown =
|
|
117
|
-
"dx-dropdown"
|
|
118
|
-
);
|
|
106
|
+
const suggestionsDropdown: Dropdown =
|
|
107
|
+
element.shadowRoot.querySelector("dx-dropdown");
|
|
119
108
|
expect(suggestionsDropdown.options).toHaveLength(0);
|
|
120
109
|
expect(suggestionsDropdown.open).toBe(false);
|
|
121
110
|
|
|
@@ -132,21 +121,18 @@ describe(TAG, () => {
|
|
|
132
121
|
|
|
133
122
|
it("renders as mobile view", () => {
|
|
134
123
|
const element = render({ ...mockProps, mobile: true });
|
|
135
|
-
const container: HTMLElement =
|
|
136
|
-
"div"
|
|
137
|
-
);
|
|
124
|
+
const container: HTMLElement =
|
|
125
|
+
element.shadowRoot.querySelector("div");
|
|
138
126
|
expect(container).not.toBeNull();
|
|
139
127
|
expect(container.classList).toHaveLength(0);
|
|
140
128
|
|
|
141
|
-
const dropdowns: Dropdown[] =
|
|
142
|
-
"dx-dropdown"
|
|
143
|
-
);
|
|
129
|
+
const dropdowns: Dropdown[] =
|
|
130
|
+
element.shadowRoot.querySelectorAll("dx-dropdown");
|
|
144
131
|
expect(dropdowns).toHaveLength(1);
|
|
145
132
|
const [dropdown] = dropdowns;
|
|
146
133
|
const input: Input = element.shadowRoot.querySelector("dx-input");
|
|
147
|
-
const button: Button =
|
|
148
|
-
"dx-button"
|
|
149
|
-
);
|
|
134
|
+
const button: Button =
|
|
135
|
+
element.shadowRoot.querySelector("dx-button");
|
|
150
136
|
expectMobileToDefaultRender({
|
|
151
137
|
input,
|
|
152
138
|
dropdown,
|
|
@@ -165,9 +151,8 @@ describe(TAG, () => {
|
|
|
165
151
|
const element = render({ ...mockProps, mobile: true });
|
|
166
152
|
|
|
167
153
|
const input: Input = element.shadowRoot.querySelector("dx-input");
|
|
168
|
-
const dropdown: Dropdown =
|
|
169
|
-
"dx-dropdown"
|
|
170
|
-
);
|
|
154
|
+
const dropdown: Dropdown =
|
|
155
|
+
element.shadowRoot.querySelector("dx-dropdown");
|
|
171
156
|
const button = element.shadowRoot.querySelector("dx-button");
|
|
172
157
|
button.click();
|
|
173
158
|
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
coveoOrganizationId: "coveosalesforcetestakshatha",
|
|
3
|
-
coveoPublicAccessToken: "xx8d9c92ef-1018-4d92-a3c7-647dff01c21c",
|
|
4
|
-
coveoSearchPipeline: "salesforcedevdoc",
|
|
5
|
-
coveoSearchHub: "salesforcedevdoc"
|
|
6
|
-
};
|
|
1
|
+
import { coveoHeaderConfig } from "utils/coveo";
|
|
7
2
|
|
|
8
3
|
export default {
|
|
9
4
|
mobile: false,
|
|
10
|
-
...
|
|
5
|
+
...coveoHeaderConfig
|
|
11
6
|
};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { LightningElement, api } from "lwc";
|
|
2
2
|
import cx from "classnames";
|
|
3
3
|
import { PopoverRequestCloseType, Option } from "typings/custom";
|
|
4
|
+
import { buildSearchEngine } from "utils/coveo";
|
|
4
5
|
import {
|
|
5
|
-
HeadlessEngine,
|
|
6
6
|
StandaloneSearchBox as StandaloneSearchBoxType,
|
|
7
|
-
StandaloneSearchBoxOptions,
|
|
8
7
|
StandaloneSearchBoxState,
|
|
9
8
|
buildStandaloneSearchBox,
|
|
10
|
-
|
|
9
|
+
StandaloneSearchBoxOptions
|
|
11
10
|
} from "@coveo/headless";
|
|
12
11
|
|
|
13
12
|
const baseSearchHref = `/search`;
|
|
@@ -32,11 +31,11 @@ export default class HeaderSearch extends LightningElement {
|
|
|
32
31
|
private get suggestions(): Option[] {
|
|
33
32
|
if (this.searchState) {
|
|
34
33
|
return this.searchState.suggestions.map(
|
|
35
|
-
({
|
|
36
|
-
id:
|
|
37
|
-
label:
|
|
34
|
+
({ highlightedValue }: { highlightedValue: string }) => ({
|
|
35
|
+
id: highlightedValue,
|
|
36
|
+
label: highlightedValue,
|
|
38
37
|
link: {
|
|
39
|
-
href: this.createSearchHref(
|
|
38
|
+
href: this.createSearchHref(highlightedValue),
|
|
40
39
|
target: null
|
|
41
40
|
}
|
|
42
41
|
})
|
|
@@ -83,25 +82,20 @@ export default class HeaderSearch extends LightningElement {
|
|
|
83
82
|
redirectionUrl: "https://developer.salesforce.com"
|
|
84
83
|
};
|
|
85
84
|
|
|
86
|
-
const engine =
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
pipeline: this.coveoSearchPipeline,
|
|
92
|
-
searchHub: this.coveoSearchHub
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
reducers: searchAppReducers
|
|
85
|
+
const engine = buildSearchEngine({
|
|
86
|
+
organizationId: this.coveoOrganizationId,
|
|
87
|
+
publicAccessToken: this.coveoPublicAccessToken,
|
|
88
|
+
searchPipeline: this.coveoSearchPipeline,
|
|
89
|
+
searchHub: this.coveoSearchHub
|
|
96
90
|
});
|
|
97
91
|
|
|
98
92
|
this.searchBox = buildStandaloneSearchBox(engine, { options });
|
|
99
|
-
|
|
93
|
+
|
|
94
|
+
this.searchBox?.subscribe(() => {
|
|
100
95
|
if (this.searchBox) {
|
|
101
96
|
this.searchState = this.searchBox.state;
|
|
102
97
|
}
|
|
103
98
|
});
|
|
104
|
-
this.searchBox.updateText("");
|
|
105
99
|
}
|
|
106
100
|
|
|
107
101
|
private createSearchHref = (value: string | null = "") => {
|
|
@@ -2,13 +2,6 @@ import { LightningElement, api } from "lwc";
|
|
|
2
2
|
|
|
3
3
|
import { LazyMode } from "typings/custom";
|
|
4
4
|
|
|
5
|
-
declare global {
|
|
6
|
-
interface Window {
|
|
7
|
-
requestIdleCallback: any;
|
|
8
|
-
cancelIdleCallback: any;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
5
|
/**
|
|
13
6
|
* Defines a fallback for BackgroundTasksAPI for browsers that doesn't support it.
|
|
14
7
|
* Currently BackgroundTasksAPI is supported by all major browsers
|
|
@@ -2,6 +2,18 @@ import { LightningElement, api } from "lwc";
|
|
|
2
2
|
import { track } from "dx/instrumentation";
|
|
3
3
|
import { CountryOptions, CheckboxTextSet } from "typings/custom";
|
|
4
4
|
|
|
5
|
+
const ANALYTICS_INFO = {
|
|
6
|
+
itemTitle: "newsletter sign up submit",
|
|
7
|
+
formName: "newsletter",
|
|
8
|
+
formType: "newsletter",
|
|
9
|
+
method: "email",
|
|
10
|
+
destinationType: "internal",
|
|
11
|
+
clickText: "Subscribe Now",
|
|
12
|
+
clickUrl: "/newsletter/success",
|
|
13
|
+
elementType: "button",
|
|
14
|
+
ctaClick: true
|
|
15
|
+
};
|
|
16
|
+
|
|
5
17
|
export default class Form extends LightningElement {
|
|
6
18
|
@api checkboxTextSet: string = "";
|
|
7
19
|
@api countries: string = "";
|
|
@@ -134,16 +146,13 @@ export default class Form extends LightningElement {
|
|
|
134
146
|
submitButtonEl.textContent = "...Processing request";
|
|
135
147
|
|
|
136
148
|
try {
|
|
137
|
-
const res = await fetch(
|
|
138
|
-
"
|
|
139
|
-
{
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
body: JSON.stringify(formData)
|
|
145
|
-
}
|
|
146
|
-
);
|
|
149
|
+
const res = await fetch("/pages/pardot/footer_optin", {
|
|
150
|
+
method: "POST",
|
|
151
|
+
headers: {
|
|
152
|
+
"Content-Type": "application/json"
|
|
153
|
+
},
|
|
154
|
+
body: JSON.stringify(formData)
|
|
155
|
+
});
|
|
147
156
|
|
|
148
157
|
if (!res.ok) {
|
|
149
158
|
throw new Error(errorMsg);
|
|
@@ -156,7 +165,7 @@ export default class Form extends LightningElement {
|
|
|
156
165
|
}
|
|
157
166
|
|
|
158
167
|
// GTM event
|
|
159
|
-
track(submitButtonEl, "
|
|
168
|
+
track(submitButtonEl, "custEv_formCompletion", ANALYTICS_INFO);
|
|
160
169
|
|
|
161
170
|
window.location.assign("/newsletter/success");
|
|
162
171
|
} catch (error) {
|