@coveops/abi 1.5.8 → 2.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/dist/abi/abi.css +206 -1
- package/dist/abi/abi.esm.js +129 -1
- package/dist/abi/app-globals-0f993ce5.js +3 -0
- package/dist/abi/css-shim-04165e59.js +4 -0
- package/dist/abi/dom-26e7cb2c.js +73 -0
- package/dist/{esm → abi}/faq-popup-component.entry.js +3 -4
- package/dist/abi/headless.esm-c328011d.js +72 -0
- package/dist/abi/index-4c45f50c.js +3064 -0
- package/dist/abi/index-bf9cad6e.js +4108 -0
- package/dist/abi/index.esm.js +168 -1
- package/dist/{esm → abi}/recs-initialization-helper.entry.js +3 -3
- package/dist/{esm → abi}/recs-results-manager.entry.js +1 -1
- package/dist/{esm → abi}/results-manager.entry.js +1 -1
- package/dist/{esm → abi}/sample-component.entry.js +3 -3
- package/dist/abi/shadow-css-1257b266.js +387 -0
- package/dist/{esm → abi}/standalone-searchbox-listener.entry.js +3 -3
- package/dist/{esm → abi}/strip-html-component.entry.js +2 -3
- package/package.json +2 -2
- package/dist/abi/p-380ced38.entry.js +0 -1
- package/dist/abi/p-9d42030c.entry.js +0 -1
- package/dist/abi/p-ac870f21.js +0 -49
- package/dist/abi/p-b09970bf.entry.js +0 -1
- package/dist/abi/p-b83bab81.js +0 -1
- package/dist/abi/p-c0436bc1.entry.js +0 -1
- package/dist/abi/p-c10b6b7f.js +0 -2
- package/dist/abi/p-c602c74e.entry.js +0 -1
- package/dist/abi/p-c82303fb.js +0 -1
- package/dist/abi/p-cd1744bb.entry.js +0 -1
- package/dist/abi/p-d20ee37c.js +0 -18
- package/dist/abi/p-d5e62885.entry.js +0 -1
- package/dist/bundle/index.css +0 -1
- package/dist/bundle/index.html +0 -72
- package/dist/bundle/index.js +0 -1363
- package/dist/cjs/abi.cjs.js +0 -19
- package/dist/cjs/atomic-70a93c69.js +0 -11
- package/dist/cjs/faq-popup-component.cjs.entry.js +0 -144
- package/dist/cjs/headless.esm-085e70ed-f2e18485.js +0 -1720
- package/dist/cjs/index-3cecd23d.js +0 -1283
- package/dist/cjs/index-d1493bab.js +0 -105
- package/dist/cjs/index.cjs.js +0 -170
- package/dist/cjs/loader.cjs.js +0 -21
- package/dist/cjs/recs-initialization-helper.cjs.entry.js +0 -55
- package/dist/cjs/recs-results-manager.cjs.entry.js +0 -36
- package/dist/cjs/result-template-decorators-881a4c8e-4ff46481.js +0 -33
- package/dist/cjs/results-manager.cjs.entry.js +0 -42
- package/dist/cjs/sample-component.cjs.entry.js +0 -87
- package/dist/cjs/standalone-searchbox-listener.cjs.entry.js +0 -48
- package/dist/cjs/strip-html-component.cjs.entry.js +0 -60
- package/dist/collection/collection-manifest.json +0 -23
- package/dist/collection/components/faq-popup-component/faq-popup-component.css +0 -15
- package/dist/collection/components/faq-popup-component/faq-popup-component.js +0 -162
- package/dist/collection/components/recs-initialization-helper/recs-initialization-helper.js +0 -66
- package/dist/collection/components/recs-results-manager/recs-results-manager.js +0 -39
- package/dist/collection/components/results-manager/results-manager.js +0 -50
- package/dist/collection/components/sample-component/sample-component.css +0 -10
- package/dist/collection/components/sample-component/sample-component.js +0 -102
- package/dist/collection/components/standalone-searchbox-listener/standalone-searchbox-listener.css +0 -1
- package/dist/collection/components/standalone-searchbox-listener/standalone-searchbox-listener.js +0 -50
- package/dist/collection/components/strip-html-component/strip-html-component.css +0 -3
- package/dist/collection/components/strip-html-component/strip-html-component.js +0 -64
- package/dist/collection/images/Default.png +0 -0
- package/dist/collection/images/Documents.png +0 -0
- package/dist/collection/images/FAQ.png +0 -0
- package/dist/collection/images/Images.png +0 -0
- package/dist/collection/images/Link.png +0 -0
- package/dist/collection/images/Movies.png +0 -0
- package/dist/collection/images/ProcessPeople.png +0 -0
- package/dist/collection/index.js +0 -167
- package/dist/collection/utils/atomic.js +0 -6
- package/dist/components/index.js +0 -3576
- package/dist/esm/abi.js +0 -17
- package/dist/esm/headless.esm-085e70ed-c4dfb380.js +0 -1717
- package/dist/esm/index-072be88f.js +0 -95
- package/dist/esm/index-66fdbb35.js +0 -1255
- package/dist/esm/index.js +0 -168
- package/dist/esm/loader.js +0 -17
- package/dist/esm/polyfills/core-js.js +0 -11
- package/dist/esm/polyfills/css-shim.js +0 -1
- package/dist/esm/polyfills/dom.js +0 -79
- package/dist/esm/polyfills/es5-html-element.js +0 -1
- package/dist/esm/polyfills/index.js +0 -34
- package/dist/esm/polyfills/system.js +0 -6
- package/dist/esm/result-template-decorators-881a4c8e-ed85ad21.js +0 -31
- package/dist/index.cjs.js +0 -1
- package/dist/index.js +0 -1
- package/dist/loader/cdn.js +0 -3
- package/dist/loader/index.cjs.js +0 -3
- package/dist/loader/index.d.ts +0 -12
- package/dist/loader/index.es2017.js +0 -3
- package/dist/loader/index.js +0 -4
- package/dist/loader/package.json +0 -10
- /package/dist/{esm → abi}/atomic-7b1e6d55.js +0 -0
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { Component, h, Element, State, Host, Prop } from "@stencil/core";
|
|
2
|
-
import { loadGenericAnalyticsActions } from '@coveo/headless';
|
|
3
|
-
import { resultContext, initializeBindings } from "@coveo/atomic";
|
|
4
|
-
export class FaqPopupComponent {
|
|
5
|
-
constructor() {
|
|
6
|
-
this.closeFAQModal = () => {
|
|
7
|
-
this.modalElement.setAttribute('is-open', 'false');
|
|
8
|
-
this.modalElement.querySelector('#btn-done').removeEventListener('click', this.closeFAQModal);
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
// We recommended fetching the result context using the `connectedCallback` lifecycle method
|
|
12
|
-
// with async/await. Using `componentWillLoad` will hang the parent `atomic-search-interface` initialization.
|
|
13
|
-
async connectedCallback() {
|
|
14
|
-
var _a;
|
|
15
|
-
try {
|
|
16
|
-
this.bindings = await initializeBindings(this.host);
|
|
17
|
-
this.result = await resultContext(this.host);
|
|
18
|
-
this.modalElement = (_a = this.bindings) === null || _a === void 0 ? void 0 : _a.interfaceElement.querySelector('#faq-modal');
|
|
19
|
-
if (this.result && localStorage.getItem(`visited-${this.result.title}`)) {
|
|
20
|
-
this.host.classList.add('visited-title');
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
console.error(error);
|
|
25
|
-
this.host.remove();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
openFAQModal(result) {
|
|
29
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
30
|
-
if (this.bindings) {
|
|
31
|
-
const { logClickEvent } = loadGenericAnalyticsActions(this.bindings.engine);
|
|
32
|
-
const logClickPayload = {
|
|
33
|
-
evt: 'documentQuickview',
|
|
34
|
-
result: result,
|
|
35
|
-
};
|
|
36
|
-
this.bindings.engine.dispatch(logClickEvent(logClickPayload));
|
|
37
|
-
}
|
|
38
|
-
this.modalElement.source = this.host;
|
|
39
|
-
// Get the body slot
|
|
40
|
-
const bodySlot = this.modalElement.querySelector('[slot=body]');
|
|
41
|
-
// Clear any existing content
|
|
42
|
-
bodySlot.innerHTML = '';
|
|
43
|
-
const tableEl = document.createElement('table');
|
|
44
|
-
const questionElement = document.createElement("tr");
|
|
45
|
-
questionElement.className = "question-row";
|
|
46
|
-
questionElement.innerHTML = '<td>Question: <a href="https://anheuserbuschinbev.sharepoint.com" autofocus="true" style="display:none;"></a></td> <td>' + (((_a = this.result) === null || _a === void 0 ? void 0 : _a.title) || '') + '</td>'
|
|
47
|
-
+ '<div id="faq-modal-close-button"><svg width="48" height="49" viewBox="0 0 48 49" fill="black" xmlns="http://www.w3.org/2000/svg"><rect y="0.5" width="48" height="48" rx="24" fill="white"/><path fill-rule="evenodd" clip-rule="evenodd" d="M22.5382 24.5L15 16.9618L16.4618 15.5L24 23.0382L31.5382 15.5L33 16.9618L25.4618 24.5L33 32.0382L31.5382 33.5L24 25.9618L16.4618 33.5L15 32.0382L22.5382 24.5Z" fill="#17171A"/></svg></div>';
|
|
48
|
-
tableEl.appendChild(questionElement);
|
|
49
|
-
const answerElement = document.createElement('tr');
|
|
50
|
-
// Create the answer title element and set its text
|
|
51
|
-
const answerTitleElement = document.createElement('td');
|
|
52
|
-
answerTitleElement.innerText = 'Answer:';
|
|
53
|
-
answerElement.appendChild(answerTitleElement);
|
|
54
|
-
// Create a new element to contain the answer content
|
|
55
|
-
const answerContentElement = document.createElement('td');
|
|
56
|
-
if ((_c = (_b = this.result) === null || _b === void 0 ? void 0 : _b.raw) === null || _c === void 0 ? void 0 : _c.answer) {
|
|
57
|
-
let value = (_e = (_d = this.result) === null || _d === void 0 ? void 0 : _d.raw) === null || _e === void 0 ? void 0 : _e.answer;
|
|
58
|
-
try {
|
|
59
|
-
var els = new DOMParser().parseFromString(value, 'text/html');
|
|
60
|
-
var html = '';
|
|
61
|
-
Array.from(els.children).forEach(el => {
|
|
62
|
-
var _a;
|
|
63
|
-
el.querySelectorAll('a').forEach(a => {
|
|
64
|
-
if (a.href.startsWith(window.location.origin) && a.href.indexOf('/sites/') > -1) {
|
|
65
|
-
a.href = a.href.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
|
|
66
|
-
}
|
|
67
|
-
if (a.href.startsWith(window.location.origin) && a.href.match(/:.:\/./)) {
|
|
68
|
-
a.href = a.href.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
el.querySelectorAll('img').forEach(a => {
|
|
72
|
-
if (a.src.startsWith(window.location.origin) && a.src.indexOf('/sites/') > -1) {
|
|
73
|
-
a.src = a.src.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
|
|
74
|
-
}
|
|
75
|
-
if (a.src.startsWith(window.location.origin) && a.src.match(/:.:\/./)) {
|
|
76
|
-
a.src = a.src.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
html = html + ((_a = el.querySelector('body')) === null || _a === void 0 ? void 0 : _a.innerHTML);
|
|
80
|
-
});
|
|
81
|
-
answerContentElement.innerHTML = html;
|
|
82
|
-
}
|
|
83
|
-
catch (e) {
|
|
84
|
-
console.log(e);
|
|
85
|
-
answerContentElement.innerHTML = value;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
// Append the answer content element to the answer element
|
|
89
|
-
answerElement.appendChild(answerContentElement);
|
|
90
|
-
// Now, the answer element has the title and the content properly appended
|
|
91
|
-
tableEl.appendChild(answerElement);
|
|
92
|
-
if ((_f = this.result) === null || _f === void 0 ? void 0 : _f.raw.category) {
|
|
93
|
-
const categoryElement = document.createElement("tr");
|
|
94
|
-
categoryElement.innerHTML = '<td> Category: </td><td>' + this.result.raw.category + '</td>';
|
|
95
|
-
tableEl.appendChild(categoryElement);
|
|
96
|
-
}
|
|
97
|
-
if ((_g = this.result) === null || _g === void 0 ? void 0 : _g.raw.newmoreinfo) {
|
|
98
|
-
const linkElement = document.createElement("tr");
|
|
99
|
-
const linkUrl = this.result.raw.newmoreinfo;
|
|
100
|
-
linkElement.innerHTML = '<td> Link: </td><td> <a href="' + linkUrl + '" target="_blank">' + linkUrl + '</a> </td>';
|
|
101
|
-
tableEl.appendChild(linkElement);
|
|
102
|
-
}
|
|
103
|
-
// Create and append the category element
|
|
104
|
-
/*const categoryElement = document.createElement('div');
|
|
105
|
-
categoryElement.innerHTML = 'Category: ' + (this.result?.raw.category || '');
|
|
106
|
-
bodySlot.appendChild(categoryElement);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const linkElement = document.createElement('div');
|
|
112
|
-
const linkUrl = this.result?.raw.newmoreinfo || '';
|
|
113
|
-
linkElement.innerHTML = `Link: <a href="${linkUrl}" target="_blank">${linkUrl}</a>`;
|
|
114
|
-
bodySlot.appendChild(linkElement);*/
|
|
115
|
-
bodySlot.appendChild(tableEl);
|
|
116
|
-
this.modalElement.querySelector('#faq-modal-close-button').addEventListener('click', this.closeFAQModal);
|
|
117
|
-
this.modalElement.setAttribute('is-open', 'true');
|
|
118
|
-
if (this.result) {
|
|
119
|
-
localStorage.setItem(`visited-${this.result.title}`, 'true');
|
|
120
|
-
}
|
|
121
|
-
// Add the class to change color
|
|
122
|
-
this.host.classList.add('visited-title');
|
|
123
|
-
}
|
|
124
|
-
render() {
|
|
125
|
-
if (!this.result) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
const cssCondition = this.origin === 'searchResult' ? 'search-css' : '';
|
|
129
|
-
return (h(Host, { className: `clickable-host ${cssCondition}`, onClick: () => this.openFAQModal(this.result) }, this.result.title));
|
|
130
|
-
}
|
|
131
|
-
static get is() { return "faq-popup-component"; }
|
|
132
|
-
static get encapsulation() { return "shadow"; }
|
|
133
|
-
static get originalStyleUrls() { return {
|
|
134
|
-
"$": ["faq-popup-component.css"]
|
|
135
|
-
}; }
|
|
136
|
-
static get styleUrls() { return {
|
|
137
|
-
"$": ["faq-popup-component.css"]
|
|
138
|
-
}; }
|
|
139
|
-
static get properties() { return {
|
|
140
|
-
"origin": {
|
|
141
|
-
"type": "string",
|
|
142
|
-
"mutable": false,
|
|
143
|
-
"complexType": {
|
|
144
|
-
"original": "string",
|
|
145
|
-
"resolved": "string | undefined",
|
|
146
|
-
"references": {}
|
|
147
|
-
},
|
|
148
|
-
"required": false,
|
|
149
|
-
"optional": true,
|
|
150
|
-
"docs": {
|
|
151
|
-
"tags": [],
|
|
152
|
-
"text": ""
|
|
153
|
-
},
|
|
154
|
-
"attribute": "origin",
|
|
155
|
-
"reflect": false
|
|
156
|
-
}
|
|
157
|
-
}; }
|
|
158
|
-
static get states() { return {
|
|
159
|
-
"result": {}
|
|
160
|
-
}; }
|
|
161
|
-
static get elementRef() { return "host"; }
|
|
162
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { initializeBindings } from "@coveo/atomic";
|
|
2
|
-
import { Component, Element, Prop } from "@stencil/core";
|
|
3
|
-
import { waitForAtomic } from "../../utils/atomic";
|
|
4
|
-
import { buildContext } from "@coveo/headless";
|
|
5
|
-
export class RecsInitializationHelper {
|
|
6
|
-
async connectedCallback() {
|
|
7
|
-
var _a;
|
|
8
|
-
try {
|
|
9
|
-
await waitForAtomic();
|
|
10
|
-
this.bindings = await initializeBindings(this.host);
|
|
11
|
-
let toDate = new Date().toISOString();
|
|
12
|
-
let fromDate = new Date();
|
|
13
|
-
if (fromDate.getMonth() == 1) {
|
|
14
|
-
fromDate.setMonth(12);
|
|
15
|
-
fromDate.setFullYear(fromDate.getFullYear() - 1);
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
fromDate.setMonth(fromDate.getMonth() - 1);
|
|
19
|
-
}
|
|
20
|
-
let filter = encodeURIComponent(`(clicks.c_context_user_country_snow=='${this.userCountry}')`);
|
|
21
|
-
let url = `https://${(_a = this.bindings) === null || _a === void 0 ? void 0 : _a.engine.state.configuration.organizationId}.admin.org.coveo.com/rest/ua/v15/stats/combinedData?from=${fromDate.toISOString()}&to=${toDate}&m=DocumentView&d=documentTitle&d=documentURL&d=clicks.c_context_user_country_snow&d=documentSysUriHash&f=${filter}&p=1&n=10&s=DocumentView&asc=false&includeMetadata=true`;
|
|
22
|
-
const reqHeaders = new Headers();
|
|
23
|
-
reqHeaders.append("authorization", "Bearer xxf42da36f-db11-4565-8358-8bac8c307236");
|
|
24
|
-
const requestOptions = {
|
|
25
|
-
method: "GET",
|
|
26
|
-
headers: reqHeaders
|
|
27
|
-
};
|
|
28
|
-
let response = await fetch(url, requestOptions);
|
|
29
|
-
response = await response.json();
|
|
30
|
-
debugger;
|
|
31
|
-
if (response.combinations.length > 0) {
|
|
32
|
-
let dqExp = response.combinations.map((c) => c.documentSysUriHash);
|
|
33
|
-
buildContext(this.bindings.engine).add("dqExp", dqExp);
|
|
34
|
-
this.bindings.interfaceElement.getRecommendations();
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
this.bindings.interfaceElement.style.display = "none";
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
console.error(error);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
static get is() { return "recs-initialization-helper"; }
|
|
45
|
-
static get encapsulation() { return "shadow"; }
|
|
46
|
-
static get properties() { return {
|
|
47
|
-
"userCountry": {
|
|
48
|
-
"type": "string",
|
|
49
|
-
"mutable": false,
|
|
50
|
-
"complexType": {
|
|
51
|
-
"original": "string",
|
|
52
|
-
"resolved": "string",
|
|
53
|
-
"references": {}
|
|
54
|
-
},
|
|
55
|
-
"required": true,
|
|
56
|
-
"optional": false,
|
|
57
|
-
"docs": {
|
|
58
|
-
"tags": [],
|
|
59
|
-
"text": ""
|
|
60
|
-
},
|
|
61
|
-
"attribute": "user-country",
|
|
62
|
-
"reflect": false
|
|
63
|
-
}
|
|
64
|
-
}; }
|
|
65
|
-
static get elementRef() { return "host"; }
|
|
66
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Component, h } from "@stencil/core";
|
|
2
|
-
import { waitForRecsAtomic } from "../../utils/atomic";
|
|
3
|
-
import FaqTemplateRec from "./FaqTemplateRec.html";
|
|
4
|
-
import QuickLinksRec from "./QuickLinksRec.html";
|
|
5
|
-
import defaultRec from "./defaultRec.html";
|
|
6
|
-
import SitePagesTemplateRec from "./SitePagesTemplateRec.html";
|
|
7
|
-
import KATemplateRec from "./KATemplateRec.html";
|
|
8
|
-
import AppTemplateRec from "./AppTemplateRec.html";
|
|
9
|
-
import ELearningTemplateRec from "./ELearningTemplateRec.html";
|
|
10
|
-
import DocumentsTemplateRec from "./DocumentsTemplateRec.html";
|
|
11
|
-
/**
|
|
12
|
-
* Component used to manage results & result templates.
|
|
13
|
-
* See https://docs.coveo.com/en/atomic/latest/usage/create-a-result-list/
|
|
14
|
-
*/
|
|
15
|
-
export class RecsResultsManager {
|
|
16
|
-
async componentWillLoad() {
|
|
17
|
-
return waitForRecsAtomic();
|
|
18
|
-
}
|
|
19
|
-
render() {
|
|
20
|
-
return (h("atomic-recs-list", { "number-of-recommendations": "5" },
|
|
21
|
-
h("atomic-recs-result-template", { "must-match-abicontenttype": 'FAQ' },
|
|
22
|
-
h("template", { innerHTML: FaqTemplateRec })),
|
|
23
|
-
h("atomic-recs-result-template", { "must-match-abicontenttype": 'Quick Links' },
|
|
24
|
-
h("template", { innerHTML: QuickLinksRec })),
|
|
25
|
-
h("atomic-recs-result-template", { "must-match-abicontenttype": 'Site Pages' },
|
|
26
|
-
h("template", { innerHTML: SitePagesTemplateRec })),
|
|
27
|
-
h("atomic-recs-result-template", { "must-match-abicontenttype": 'Knowledge Article' },
|
|
28
|
-
h("template", { innerHTML: KATemplateRec })),
|
|
29
|
-
h("atomic-recs-result-template", { "must-match-abicontenttype": 'Application' },
|
|
30
|
-
h("template", { innerHTML: AppTemplateRec })),
|
|
31
|
-
h("atomic-recs-result-template", { "must-match-abicontenttype": 'eLearning' },
|
|
32
|
-
h("template", { innerHTML: ELearningTemplateRec })),
|
|
33
|
-
h("atomic-recs-result-template", { "must-match-abicontenttype": 'Documents' },
|
|
34
|
-
h("template", { innerHTML: DocumentsTemplateRec })),
|
|
35
|
-
h("atomic-recs-result-template", null,
|
|
36
|
-
h("template", { innerHTML: defaultRec }))));
|
|
37
|
-
}
|
|
38
|
-
static get is() { return "recs-results-manager"; }
|
|
39
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Component, h } from "@stencil/core";
|
|
2
|
-
import { waitForAtomic } from "../../utils/atomic";
|
|
3
|
-
import template1 from "./template-1.html";
|
|
4
|
-
import SitePagesTemplate from "./SitePagesTemplate.html";
|
|
5
|
-
import KATemplate from "./KATemplate.html";
|
|
6
|
-
import FAQTemplate from "./FAQTemplate.html";
|
|
7
|
-
import QuickLinksTemplate from "./QuickLinksTemplate.html";
|
|
8
|
-
import AppTemplate from "./AppTemplate.html";
|
|
9
|
-
import ELearningTemplate from "./ELearningTemplate.html";
|
|
10
|
-
import PeopleTemplate from "./PeopleTemplate.html";
|
|
11
|
-
import DocumentsTemplate from "./DocumentsTemplate.html";
|
|
12
|
-
import MediaTemplate from "./MediaTemplate.html";
|
|
13
|
-
import PeopleSnowTemplate from './PeopleSnowTemplate.html';
|
|
14
|
-
/**
|
|
15
|
-
* Component used to manage results & result templates.
|
|
16
|
-
* See https://docs.coveo.com/en/atomic/latest/usage/create-a-result-list/
|
|
17
|
-
*/
|
|
18
|
-
export class ResultsManager {
|
|
19
|
-
async componentWillLoad() {
|
|
20
|
-
return waitForAtomic();
|
|
21
|
-
}
|
|
22
|
-
render() {
|
|
23
|
-
return (h("atomic-result-list", null,
|
|
24
|
-
h("atomic-result-template", { "must-match-filetype": 'mp4,wmv,avi,MOV,flv,mkv,webm,ogg,ogv,m4v,gif,jpeg,jpg,png,bmp,Image,mp3,mp4,wmv,avi,MOV,flv,mkv,webm,ogg,ogv,m4v,mpg' },
|
|
25
|
-
h("template", { innerHTML: MediaTemplate })),
|
|
26
|
-
h("atomic-result-template", { "must-match-abicontenttype": "Site Pages" },
|
|
27
|
-
h("template", { innerHTML: SitePagesTemplate })),
|
|
28
|
-
h("atomic-result-template", { "must-match-abicontenttype": "Knowledge Article" },
|
|
29
|
-
h("template", { innerHTML: KATemplate })),
|
|
30
|
-
h("atomic-result-template", { "must-match-abicontenttype": 'FAQ' },
|
|
31
|
-
h("template", { innerHTML: FAQTemplate })),
|
|
32
|
-
h("atomic-result-template", { "must-match-abicontenttype": 'Quick Links' },
|
|
33
|
-
h("template", { innerHTML: QuickLinksTemplate })),
|
|
34
|
-
h("atomic-result-template", { "must-match-abicontenttype": 'Application' },
|
|
35
|
-
h("template", { innerHTML: AppTemplate })),
|
|
36
|
-
h("atomic-result-template", { "must-match-abicontenttype": 'eLearning' },
|
|
37
|
-
h("template", { innerHTML: ELearningTemplate })),
|
|
38
|
-
h("atomic-result-template", { "must-match-abicontenttype": 'People', "must-match-objecttype": 'Account' },
|
|
39
|
-
h("template", { innerHTML: PeopleTemplate })),
|
|
40
|
-
h("atomic-result-template", { "must-match-abicontenttype": 'People', "must-match-filetype": 'sys_user' },
|
|
41
|
-
h("template", { innerHTML: PeopleSnowTemplate })),
|
|
42
|
-
h("atomic-result-template", { "must-match-abicontenttype": 'Documents' },
|
|
43
|
-
h("template", { innerHTML: DocumentsTemplate })),
|
|
44
|
-
h("atomic-result-template", { "must-match-abicontenttype": 'Media' },
|
|
45
|
-
h("template", { innerHTML: MediaTemplate })),
|
|
46
|
-
h("atomic-result-template", null,
|
|
47
|
-
h("template", { innerHTML: template1 }))));
|
|
48
|
-
}
|
|
49
|
-
static get is() { return "results-manager"; }
|
|
50
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { initializeBindings } from "@coveo/atomic";
|
|
2
|
-
import { Component, Element, h, State, forceUpdate } from "@stencil/core";
|
|
3
|
-
import { buildSearchStatus, buildPager, } from "@coveo/headless";
|
|
4
|
-
import { waitForAtomic } from "../../utils/atomic";
|
|
5
|
-
/**
|
|
6
|
-
* Sample custom Atomic component, initializing itself against a parent search interface in order to retrieve the bindings.
|
|
7
|
-
*
|
|
8
|
-
* This component showcases a custom-made pagination component, for educational purposes.
|
|
9
|
-
*
|
|
10
|
-
* In a real life scenario, we recommend using either [atomic-pager](https://docs.coveo.com/en/atomic/latest/reference/components/atomic-pager/) or [atomic-load-more-results](https://docs.coveo.com/en/atomic/latest/reference/components/atomic-load-more-results/) instead.
|
|
11
|
-
*/
|
|
12
|
-
export class SampleComponent {
|
|
13
|
-
constructor() {
|
|
14
|
-
// When disconnecting components from the page, we recommend removing
|
|
15
|
-
// state change listeners as well by calling the unsubscribe methods.
|
|
16
|
-
this.pagerUnsubscribe = () => { };
|
|
17
|
-
this.statusUnsubscribe = () => { };
|
|
18
|
-
this.i18nUnsubscribe = () => { };
|
|
19
|
-
}
|
|
20
|
-
// We recommend initializing the bindings and the Headless controllers
|
|
21
|
-
// using the `connectedCallback` lifecycle method with async/await.
|
|
22
|
-
// Using `componentWillLoad` will hang the parent atomic-search-interface initialization.
|
|
23
|
-
async connectedCallback() {
|
|
24
|
-
try {
|
|
25
|
-
// Wait for the Atomic to load and bindings to be resolved.
|
|
26
|
-
await waitForAtomic();
|
|
27
|
-
this.bindings = await initializeBindings(this.host);
|
|
28
|
-
// Initialize controllers.
|
|
29
|
-
const statusController = buildSearchStatus(this.bindings.engine);
|
|
30
|
-
this.pagerController = buildPager(this.bindings.engine);
|
|
31
|
-
// Subscribe to controller state changes.
|
|
32
|
-
this.statusUnsubscribe = statusController.subscribe(() => (this.statusState = statusController.state));
|
|
33
|
-
this.pagerUnsubscribe = this.pagerController.subscribe(() => (this.pagerState = this.pagerController.state));
|
|
34
|
-
// (Optional) To use if component needs to rerender when the Atomic i18n language changes.
|
|
35
|
-
// If your component does not use any strings or does not support multiple languages,
|
|
36
|
-
// you can ignore everything related to i18n.
|
|
37
|
-
const updateLanguage = () => forceUpdate(this);
|
|
38
|
-
this.bindings.i18n.on("languageChanged", updateLanguage);
|
|
39
|
-
this.i18nUnsubscribe = () => this.bindings.i18n.off("languageChanged", updateLanguage);
|
|
40
|
-
}
|
|
41
|
-
catch (error) {
|
|
42
|
-
console.error(error);
|
|
43
|
-
this.error = error;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
// The `disconnectedCallback` lifecycle method should be used to unsubcribe controllers and
|
|
47
|
-
// possibly the i18n language change listener.
|
|
48
|
-
disconnectedCallback() {
|
|
49
|
-
this.pagerUnsubscribe();
|
|
50
|
-
this.statusUnsubscribe();
|
|
51
|
-
this.i18nUnsubscribe();
|
|
52
|
-
}
|
|
53
|
-
get pages() {
|
|
54
|
-
const pages = this.pagerState.currentPages;
|
|
55
|
-
return pages.map((page) => this.buildPage(page));
|
|
56
|
-
}
|
|
57
|
-
buildPage(page) {
|
|
58
|
-
const isSelected = this.pagerController.isCurrentPage(page);
|
|
59
|
-
return (h("button", { onClick: () => {
|
|
60
|
-
this.pagerController.selectPage(page);
|
|
61
|
-
} },
|
|
62
|
-
isSelected ? "✓ " : "",
|
|
63
|
-
page.toLocaleString(this.bindings.i18n.language)));
|
|
64
|
-
}
|
|
65
|
-
get previous() {
|
|
66
|
-
return (h("button", { onClick: () => {
|
|
67
|
-
this.pagerController.previousPage();
|
|
68
|
-
} },
|
|
69
|
-
h("atomic-text", { value: "previous" })));
|
|
70
|
-
}
|
|
71
|
-
get next() {
|
|
72
|
-
return (h("button", { onClick: () => {
|
|
73
|
-
this.pagerController.nextPage();
|
|
74
|
-
} },
|
|
75
|
-
h("atomic-text", { value: "next" })));
|
|
76
|
-
}
|
|
77
|
-
render() {
|
|
78
|
-
if (this.error) {
|
|
79
|
-
return (h("p", null, "Error when initializing the component, please view the console for more information."));
|
|
80
|
-
}
|
|
81
|
-
if (!this.bindings || !this.statusState.hasResults) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
return (h("nav", null,
|
|
85
|
-
this.pagerState.hasPreviousPage && this.previous,
|
|
86
|
-
this.pages,
|
|
87
|
-
this.pagerState.hasNextPage && this.next));
|
|
88
|
-
}
|
|
89
|
-
static get is() { return "sample-component"; }
|
|
90
|
-
static get encapsulation() { return "shadow"; }
|
|
91
|
-
static get originalStyleUrls() { return {
|
|
92
|
-
"$": ["sample-component.css"]
|
|
93
|
-
}; }
|
|
94
|
-
static get styleUrls() { return {
|
|
95
|
-
"$": ["sample-component.css"]
|
|
96
|
-
}; }
|
|
97
|
-
static get states() { return {
|
|
98
|
-
"pagerState": {},
|
|
99
|
-
"statusState": {}
|
|
100
|
-
}; }
|
|
101
|
-
static get elementRef() { return "host"; }
|
|
102
|
-
}
|
package/dist/collection/components/standalone-searchbox-listener/standalone-searchbox-listener.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
package/dist/collection/components/standalone-searchbox-listener/standalone-searchbox-listener.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { initializeBindings } from "@coveo/atomic";
|
|
2
|
-
import { Component, Element, h, Host, Listen } from "@stencil/core";
|
|
3
|
-
import { waitForAtomic } from "../../utils/atomic";
|
|
4
|
-
import { loadPaginationActions, loadQueryActions, loadSearchActions, loadSearchAnalyticsActions } from "@coveo/headless";
|
|
5
|
-
export class StandaloneSearchboxListener {
|
|
6
|
-
async connectedCallback() {
|
|
7
|
-
var _a;
|
|
8
|
-
try {
|
|
9
|
-
await waitForAtomic();
|
|
10
|
-
this.bindings = await initializeBindings(this.host);
|
|
11
|
-
(_a = this.bindings) === null || _a === void 0 ? void 0 : _a.i18n.addResourceBundle('en', 'translation', {
|
|
12
|
-
"search-tips": "You may want to try using different keywords or checking for spelling mistakes."
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
catch (error) {
|
|
16
|
-
console.error(error);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
async handleStandaloneSearchbox(ev) {
|
|
20
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
21
|
-
let queryActionCreator = loadQueryActions((_a = this.bindings) === null || _a === void 0 ? void 0 : _a.engine);
|
|
22
|
-
(_c = (_b = this.bindings) === null || _b === void 0 ? void 0 : _b.engine) === null || _c === void 0 ? void 0 : _c.dispatch(queryActionCreator.updateQuery({
|
|
23
|
-
q: ev.detail
|
|
24
|
-
}));
|
|
25
|
-
let paginationActionCreator = loadPaginationActions((_d = this.bindings) === null || _d === void 0 ? void 0 : _d.engine);
|
|
26
|
-
(_f = (_e = this.bindings) === null || _e === void 0 ? void 0 : _e.engine) === null || _f === void 0 ? void 0 : _f.dispatch(paginationActionCreator.updatePage(1));
|
|
27
|
-
let analyticsActionCreator = loadSearchAnalyticsActions((_g = this.bindings) === null || _g === void 0 ? void 0 : _g.engine);
|
|
28
|
-
let searchActionCreator = loadSearchActions((_h = this.bindings) === null || _h === void 0 ? void 0 : _h.engine);
|
|
29
|
-
(_k = (_j = this.bindings) === null || _j === void 0 ? void 0 : _j.engine) === null || _k === void 0 ? void 0 : _k.dispatch(searchActionCreator.executeSearch(analyticsActionCreator.logSearchboxSubmit()));
|
|
30
|
-
}
|
|
31
|
-
render() {
|
|
32
|
-
return (h(Host, null));
|
|
33
|
-
}
|
|
34
|
-
static get is() { return "standalone-searchbox-listener"; }
|
|
35
|
-
static get encapsulation() { return "shadow"; }
|
|
36
|
-
static get originalStyleUrls() { return {
|
|
37
|
-
"$": ["standalone-searchbox-listener.css"]
|
|
38
|
-
}; }
|
|
39
|
-
static get styleUrls() { return {
|
|
40
|
-
"$": ["standalone-searchbox-listener.css"]
|
|
41
|
-
}; }
|
|
42
|
-
static get elementRef() { return "host"; }
|
|
43
|
-
static get listeners() { return [{
|
|
44
|
-
"name": "header/searchbox/query",
|
|
45
|
-
"method": "handleStandaloneSearchbox",
|
|
46
|
-
"target": "window",
|
|
47
|
-
"capture": false,
|
|
48
|
-
"passive": false
|
|
49
|
-
}]; }
|
|
50
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Component, h, Element, State } from "@stencil/core";
|
|
2
|
-
import { resultContext } from "@coveo/atomic";
|
|
3
|
-
/**
|
|
4
|
-
* Sample custom Atomic result component, to be used inside an Atomic Result Template.
|
|
5
|
-
*
|
|
6
|
-
* This component showcases a component that conditionally renders the author of a result, with a fallback to display "anonymous" in the event that no author is available for a document, for educational purposes.
|
|
7
|
-
*
|
|
8
|
-
* In a real life scenario, we recommend using [result-field-condition](https://docs.coveo.com/en/atomic/latest/reference/result-template-components/atomic-field-condition/) and [atomic-result-text](https://docs.coveo.com/en/atomic/latest/reference/result-template-components/atomic-result-text/).
|
|
9
|
-
*/
|
|
10
|
-
export class StripHtmlComponent {
|
|
11
|
-
// We recommended fetching the result context using the `connectedCallback` lifecycle method
|
|
12
|
-
// with async/await. Using `componentWillLoad` will hang the parent `atomic-search-interface` initialization.
|
|
13
|
-
async connectedCallback() {
|
|
14
|
-
try {
|
|
15
|
-
this.result = await resultContext(this.host);
|
|
16
|
-
}
|
|
17
|
-
catch (error) {
|
|
18
|
-
console.error(error);
|
|
19
|
-
this.host.remove();
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
// Function to strip HTML tags and decode HTML entities
|
|
23
|
-
stripHtmlAndEntities(str) {
|
|
24
|
-
// Create a temporary DOM element
|
|
25
|
-
var tempDiv = document.createElement("div");
|
|
26
|
-
// Set its innerHTML to the input string
|
|
27
|
-
tempDiv.innerHTML = str;
|
|
28
|
-
// Use textContent to get the plain text
|
|
29
|
-
var text = tempDiv.textContent || tempDiv.innerText || "";
|
|
30
|
-
// Replace HTML entities
|
|
31
|
-
var decodedText = text.replace(/&#(\d+);/g, (_, dec) => String.fromCharCode(dec));
|
|
32
|
-
return decodedText;
|
|
33
|
-
}
|
|
34
|
-
render() {
|
|
35
|
-
// Do not render the component until the result object has been resolved.
|
|
36
|
-
if (!this.result) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
let description;
|
|
40
|
-
if (this.result.raw.abicontenttype == "Quick Links") {
|
|
41
|
-
description = this.result.excerpt || "No description available";
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
description = this.result.raw.description;
|
|
45
|
-
}
|
|
46
|
-
let strippedString = '';
|
|
47
|
-
if (typeof description === 'string') {
|
|
48
|
-
strippedString = this.stripHtmlAndEntities(description);
|
|
49
|
-
}
|
|
50
|
-
return (h("div", { style: { fontSize: "1.3rem", maxHeight: "none", lineHeight: "normal" } }, strippedString));
|
|
51
|
-
}
|
|
52
|
-
static get is() { return "strip-html-component"; }
|
|
53
|
-
static get encapsulation() { return "shadow"; }
|
|
54
|
-
static get originalStyleUrls() { return {
|
|
55
|
-
"$": ["strip-html-component.css"]
|
|
56
|
-
}; }
|
|
57
|
-
static get styleUrls() { return {
|
|
58
|
-
"$": ["strip-html-component.css"]
|
|
59
|
-
}; }
|
|
60
|
-
static get states() { return {
|
|
61
|
-
"result": {}
|
|
62
|
-
}; }
|
|
63
|
-
static get elementRef() { return "host"; }
|
|
64
|
-
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|