@salesforcedevs/dx-components 1.3.289 → 1.3.296
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 -2
- package/src/modules/dx/featuredContentHeader/featuredContentHeader.ts +2 -2
- package/src/modules/dxUtils/coveo/coveo.ts +4 -2
- package/src/modules/dx/headerSearch/headerSearch.css +0 -62
- package/src/modules/dx/headerSearch/headerSearch.html +0 -59
- package/src/modules/dx/headerSearch/headerSearch.ts +0 -159
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dx-components",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.296",
|
|
4
4
|
"description": "DX Lightning web components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"volta": {
|
|
47
47
|
"node": "16.19.1"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "7a3e47bb11802dbded4c5bd3814b408cbeedecd7"
|
|
50
50
|
}
|
|
@@ -126,7 +126,7 @@ export default class FeaturedContentHeader extends LightningElement {
|
|
|
126
126
|
|
|
127
127
|
if (slotElements.length) {
|
|
128
128
|
const slotContentElement = slotElements[0];
|
|
129
|
-
const playerElement = slotContentElement
|
|
129
|
+
const playerElement = slotContentElement?.shadowRoot?.querySelector(
|
|
130
130
|
"audio"
|
|
131
131
|
) as HTMLAudioElement;
|
|
132
132
|
if (playerElement) {
|
|
@@ -178,7 +178,7 @@ export default class FeaturedContentHeader extends LightningElement {
|
|
|
178
178
|
// Setting the svgs with innerHTML prevents their IDs from being rewritten
|
|
179
179
|
// which is necessary to preserve the svg masking and other effects
|
|
180
180
|
if (this.backgroundImgId && this.backgroundImgId in svgs) {
|
|
181
|
-
const bgSvg = this.template
|
|
181
|
+
const bgSvg = this.template?.querySelector(".bg-image-container");
|
|
182
182
|
if (bgSvg) {
|
|
183
183
|
// eslint-disable-next-line @lwc/lwc/no-inner-html
|
|
184
184
|
bgSvg.innerHTML = `
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildSearchEngine as _buildSearchEngine,
|
|
3
3
|
SearchAppState,
|
|
4
|
-
SearchEngineOptions
|
|
4
|
+
SearchEngineOptions,
|
|
5
|
+
getOrganizationEndpoints
|
|
5
6
|
} from "@coveo/headless";
|
|
6
7
|
|
|
7
8
|
export const buildSearchEngine = ({
|
|
@@ -24,7 +25,8 @@ export const buildSearchEngine = ({
|
|
|
24
25
|
const configuration = {
|
|
25
26
|
accessToken: publicAccessToken,
|
|
26
27
|
organizationId,
|
|
27
|
-
search
|
|
28
|
+
search,
|
|
29
|
+
organizationEndpoints: getOrganizationEndpoints(organizationId)
|
|
28
30
|
};
|
|
29
31
|
|
|
30
32
|
const engineConfiguration: SearchEngineOptions = preloadedState
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
@import "dxHelpers/reset";
|
|
2
|
-
|
|
3
|
-
/* DESKTOP */
|
|
4
|
-
|
|
5
|
-
:host {
|
|
6
|
-
--toggle-width: var(--dx-g-spacing-5xl);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
.desktop_search-container {
|
|
10
|
-
position: relative;
|
|
11
|
-
display: flex;
|
|
12
|
-
height: var(--dx-g-spacing-xl);
|
|
13
|
-
font-size: var(--dx-g-text-sm);
|
|
14
|
-
font-family: var(--dx-g-font-sans);
|
|
15
|
-
color: var(--dx-g-gray-50);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.desktop_search-container dx-input {
|
|
19
|
-
--dx-c-input-width: calc(
|
|
20
|
-
var(--dx-c-header-search-width) - var(--toggle-width)
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/* MOBILE */
|
|
25
|
-
|
|
26
|
-
.mobile_search-button {
|
|
27
|
-
position: relative;
|
|
28
|
-
z-index: 3;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.mobile_search-dropdown {
|
|
32
|
-
--dx-c-popover-border-radius: 0;
|
|
33
|
-
--dx-c-popover-border: none;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.mobile_search-input {
|
|
37
|
-
position: absolute;
|
|
38
|
-
top: 0;
|
|
39
|
-
left: 0;
|
|
40
|
-
height: 100%;
|
|
41
|
-
width: 100%;
|
|
42
|
-
transition: var(--dx-g-transition-hue-1x);
|
|
43
|
-
opacity: 0;
|
|
44
|
-
pointer-events: none;
|
|
45
|
-
|
|
46
|
-
--dx-c-input-border: none;
|
|
47
|
-
--dx-c-input-border-radius: 0;
|
|
48
|
-
--dx-c-input-border-active: none;
|
|
49
|
-
--dx-c-input-icon-color: var(--dx-g-blue-vibrant-20);
|
|
50
|
-
--dx-c-input-padding: 0 var(--dx-g-spacing-4xl) 0 var(--dx-g-spacing-md);
|
|
51
|
-
--dx-c-input-background: var(--dx-g-brand-current-color-background-2);
|
|
52
|
-
--dx-c-input-background-active: var(
|
|
53
|
-
--dx-g-brand-current-color-background-2
|
|
54
|
-
);
|
|
55
|
-
--dx-c-input-height: 100% !important;
|
|
56
|
-
--dx-c-input-width: 100%;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
.mobile_search-input.state-open {
|
|
60
|
-
opacity: 1;
|
|
61
|
-
pointer-events: auto;
|
|
62
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class={className} role="search" aria-label="Records Search">
|
|
3
|
-
<!-- MOBILE -->
|
|
4
|
-
<template if:true={mobile}>
|
|
5
|
-
<dx-dropdown
|
|
6
|
-
class="mobile_search-dropdown"
|
|
7
|
-
open={isDropdownOpen}
|
|
8
|
-
options={suggestions}
|
|
9
|
-
onrequestclose={onDropdownRequestClose}
|
|
10
|
-
full-width
|
|
11
|
-
page-padding="0"
|
|
12
|
-
>
|
|
13
|
-
<dx-input
|
|
14
|
-
class={mobileSearchInputClassName}
|
|
15
|
-
icon-size="large"
|
|
16
|
-
icon-symbol="search"
|
|
17
|
-
onchange={onInputChange}
|
|
18
|
-
onclear={onInputEscape}
|
|
19
|
-
onsubmit={onInputSubmit}
|
|
20
|
-
onfocus={openDropdown}
|
|
21
|
-
placeholder="Search"
|
|
22
|
-
size="override"
|
|
23
|
-
type="search"
|
|
24
|
-
></dx-input>
|
|
25
|
-
</dx-dropdown>
|
|
26
|
-
<dx-button
|
|
27
|
-
class="mobile_search-button"
|
|
28
|
-
aria-label={mobileSearchButtonAriaLabel}
|
|
29
|
-
icon-size="large"
|
|
30
|
-
icon-symbol={mobileSearchButtonIcon}
|
|
31
|
-
onclick={onMobileSearchButtonClick}
|
|
32
|
-
variant="tertiary"
|
|
33
|
-
></dx-button>
|
|
34
|
-
</template>
|
|
35
|
-
|
|
36
|
-
<!-- DESKTOP -->
|
|
37
|
-
<template if:false={mobile}>
|
|
38
|
-
<dx-dropdown
|
|
39
|
-
options={suggestions}
|
|
40
|
-
open={isDropdownOpen}
|
|
41
|
-
onrequestclose={onDropdownRequestClose}
|
|
42
|
-
offset="small"
|
|
43
|
-
full-width
|
|
44
|
-
>
|
|
45
|
-
<dx-input
|
|
46
|
-
icon-symbol="search"
|
|
47
|
-
onchange={onInputChange}
|
|
48
|
-
onclear={onInputEscape}
|
|
49
|
-
onsubmit={onInputSubmit}
|
|
50
|
-
onfocus={openDropdown}
|
|
51
|
-
placeholder="Search"
|
|
52
|
-
shortcut-key="k"
|
|
53
|
-
size="small"
|
|
54
|
-
type="search"
|
|
55
|
-
></dx-input>
|
|
56
|
-
</dx-dropdown>
|
|
57
|
-
</template>
|
|
58
|
-
</div>
|
|
59
|
-
</template>
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { LightningElement, api } from "lwc";
|
|
2
|
-
import cx from "classnames";
|
|
3
|
-
import { PopoverRequestCloseType, OptionWithLink } from "typings/custom";
|
|
4
|
-
import { buildSearchEngine } from "dxUtils/coveo";
|
|
5
|
-
import {
|
|
6
|
-
StandaloneSearchBox as StandaloneSearchBoxType,
|
|
7
|
-
StandaloneSearchBoxState,
|
|
8
|
-
buildStandaloneSearchBox,
|
|
9
|
-
StandaloneSearchBoxOptions
|
|
10
|
-
} from "@coveo/headless";
|
|
11
|
-
|
|
12
|
-
const baseSearchHref = `/search`;
|
|
13
|
-
|
|
14
|
-
export default class HeaderSearch extends LightningElement {
|
|
15
|
-
@api mobile!: boolean;
|
|
16
|
-
@api coveoOrganizationId!: string;
|
|
17
|
-
@api coveoPublicAccessToken!: string;
|
|
18
|
-
@api coveoSearchPipeline!: string;
|
|
19
|
-
@api coveoSearchHub!: string;
|
|
20
|
-
|
|
21
|
-
private input: HTMLElement | null = null;
|
|
22
|
-
private isDropdownOpen: boolean = false;
|
|
23
|
-
private isMobileSearchOpen: boolean = false;
|
|
24
|
-
private searchBox: StandaloneSearchBoxType | null = null;
|
|
25
|
-
private searchState: StandaloneSearchBoxState | null = null;
|
|
26
|
-
|
|
27
|
-
private get className() {
|
|
28
|
-
return this.mobile ? null : "desktop_search-container";
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
private get suggestions(): OptionWithLink[] {
|
|
32
|
-
if (this.searchState) {
|
|
33
|
-
return this.searchState.suggestions.map(
|
|
34
|
-
({ highlightedValue }: { highlightedValue: string }) => ({
|
|
35
|
-
id: highlightedValue,
|
|
36
|
-
label: highlightedValue,
|
|
37
|
-
link: {
|
|
38
|
-
href: this.createSearchHref(highlightedValue),
|
|
39
|
-
target: null
|
|
40
|
-
}
|
|
41
|
-
})
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
return [];
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
private get mobileSearchInputClassName() {
|
|
48
|
-
return cx(
|
|
49
|
-
"mobile_search-input",
|
|
50
|
-
this.isMobileSearchOpen && "state-open"
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
private get mobileSearchButtonIcon() {
|
|
55
|
-
return this.isMobileSearchOpen ? "close" : "search";
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
private get mobileSearchButtonAriaLabel() {
|
|
59
|
-
return this.isMobileSearchOpen
|
|
60
|
-
? "Hide mobile search"
|
|
61
|
-
: "Show mobile search";
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
connectedCallback() {
|
|
65
|
-
this.instantiateSearchbox();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
private onDropdownRequestClose(e: CustomEvent) {
|
|
69
|
-
switch (e.detail as PopoverRequestCloseType) {
|
|
70
|
-
case "interact-outside":
|
|
71
|
-
case "keypress-escape":
|
|
72
|
-
this.closeDropdown();
|
|
73
|
-
break;
|
|
74
|
-
default:
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
private instantiateSearchbox() {
|
|
80
|
-
try {
|
|
81
|
-
const options: StandaloneSearchBoxOptions = {
|
|
82
|
-
numberOfSuggestions: 3,
|
|
83
|
-
redirectionUrl: "https://developer.salesforce.com"
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
const engine = buildSearchEngine({
|
|
87
|
-
organizationId: this.coveoOrganizationId,
|
|
88
|
-
publicAccessToken: this.coveoPublicAccessToken,
|
|
89
|
-
searchPipeline: this.coveoSearchPipeline,
|
|
90
|
-
searchHub: this.coveoSearchHub
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
this.searchBox = buildStandaloneSearchBox(engine, { options });
|
|
94
|
-
|
|
95
|
-
this.searchBox?.subscribe(() => {
|
|
96
|
-
if (this.searchBox) {
|
|
97
|
-
this.searchState = this.searchBox.state;
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
} catch (e) {
|
|
101
|
-
console.error(`Coveo searchbox failed to initialize (${e})`);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
private createSearchHref = (value: string | null = "") => {
|
|
106
|
-
return `${baseSearchHref}#q=${value}`;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
private onInputChange(e: CustomEvent) {
|
|
110
|
-
if (this.searchBox) {
|
|
111
|
-
this.searchBox.updateText(e.detail);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
private onInputSubmit(e: CustomEvent) {
|
|
116
|
-
const href = this.createSearchHref(e.detail || "");
|
|
117
|
-
window.location.assign(href);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
private onMobileSearchButtonClick() {
|
|
121
|
-
this.isMobileSearchOpen = !this.isMobileSearchOpen;
|
|
122
|
-
const input = this.template.querySelector("dx-input");
|
|
123
|
-
if (this.isMobileSearchOpen && input) {
|
|
124
|
-
input.focus();
|
|
125
|
-
this.openDropdown();
|
|
126
|
-
} else {
|
|
127
|
-
this.closeDropdown();
|
|
128
|
-
}
|
|
129
|
-
if (!this.isMobileSearchOpen && this.searchBox) {
|
|
130
|
-
this.searchBox.updateText("");
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
private openDropdown() {
|
|
135
|
-
this.isDropdownOpen = true;
|
|
136
|
-
this.isMobileSearchOpen = true;
|
|
137
|
-
this.reportState<boolean>(true);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
private closeDropdown() {
|
|
141
|
-
this.isDropdownOpen = false;
|
|
142
|
-
this.isMobileSearchOpen = false;
|
|
143
|
-
this.reportState<boolean>(false);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
private onInputEscape() {
|
|
147
|
-
this.closeDropdown();
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
private reportState<T>(state: T) {
|
|
151
|
-
this.dispatchEvent(
|
|
152
|
-
new CustomEvent("statechange", {
|
|
153
|
-
detail: state,
|
|
154
|
-
bubbles: true,
|
|
155
|
-
composed: true
|
|
156
|
-
})
|
|
157
|
-
);
|
|
158
|
-
}
|
|
159
|
-
}
|