@coveops/abi 1.0.1 → 1.0.3

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.
@@ -8,7 +8,7 @@ async function main() {
8
8
  const searchBox = document.querySelector("#searchbox");
9
9
  const platformUrl = "https://platform.cloud.coveo.com";
10
10
  const organizationId = "anheuserbuschinbevprod";
11
- const accessToken = "x0ae66480-c272-44bf-bb26-0e89dc2c0239";
11
+ const accessToken = "x7e95c452-b717-4459-a9a1-a808b74c2242";
12
12
  await searchInterface.initialize({
13
13
  accessToken,
14
14
  organizationId,
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-355878fc.js');
6
- const index$1 = require('./index-8f6652e1.js');
6
+ const index$1 = require('./index-20ac4bdb.js');
7
7
  const atomic = require('./atomic-7321a250.js');
8
8
  require('./headless.esm-085e70ed-f2e18485.js');
9
9
 
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-355878fc.js');
6
- const index$1 = require('./index-8f6652e1.js');
6
+ const index$1 = require('./index-20ac4bdb.js');
7
7
  const atomic = require('./atomic-7321a250.js');
8
8
  require('./headless.esm-085e70ed-f2e18485.js');
9
9
 
@@ -23,15 +23,16 @@ const StandaloneSearchboxListener = class {
23
23
  }
24
24
  }
25
25
  async handleStandaloneSearchbox(ev) {
26
- var _a, _b, _c, _d, _e, _f, _g;
27
- debugger;
26
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
28
27
  let queryActionCreator = index$1.fce((_a = this.bindings) === null || _a === void 0 ? void 0 : _a.engine);
29
28
  (_c = (_b = this.bindings) === null || _b === void 0 ? void 0 : _b.engine) === null || _c === void 0 ? void 0 : _c.dispatch(queryActionCreator.updateQuery({
30
29
  q: ev.detail
31
30
  }));
32
- let analyticsActionCreator = index$1.mde((_d = this.bindings) === null || _d === void 0 ? void 0 : _d.engine);
33
- let searchActionCreator = index$1.$ce((_e = this.bindings) === null || _e === void 0 ? void 0 : _e.engine);
34
- (_g = (_f = this.bindings) === null || _f === void 0 ? void 0 : _f.engine) === null || _g === void 0 ? void 0 : _g.dispatch(searchActionCreator.executeSearch(analyticsActionCreator.logSearchboxSubmit()));
31
+ let paginationActionCreator = index$1.nce((_d = this.bindings) === null || _d === void 0 ? void 0 : _d.engine);
32
+ (_f = (_e = this.bindings) === null || _e === void 0 ? void 0 : _e.engine) === null || _f === void 0 ? void 0 : _f.dispatch(paginationActionCreator.updatePage(1));
33
+ let analyticsActionCreator = index$1.mde((_g = this.bindings) === null || _g === void 0 ? void 0 : _g.engine);
34
+ let searchActionCreator = index$1.$ce((_h = this.bindings) === null || _h === void 0 ? void 0 : _h.engine);
35
+ (_k = (_j = this.bindings) === null || _j === void 0 ? void 0 : _j.engine) === null || _k === void 0 ? void 0 : _k.dispatch(searchActionCreator.executeSearch(analyticsActionCreator.logSearchboxSubmit()));
35
36
  }
36
37
  render() {
37
38
  return (index.h(index.Host, null));
@@ -26,7 +26,7 @@ export class FaqPopupComponent {
26
26
  }
27
27
  }
28
28
  openFAQModal(result) {
29
- var _a, _b, _c, _d;
29
+ var _a, _b, _c, _d, _e, _f, _g;
30
30
  if (this.bindings) {
31
31
  const { logClickEvent } = loadGenericAnalyticsActions(this.bindings.engine);
32
32
  const logClickPayload = {
@@ -43,7 +43,7 @@ export class FaqPopupComponent {
43
43
  const tableEl = document.createElement('table');
44
44
  const questionElement = document.createElement("tr");
45
45
  questionElement.className = "question-row";
46
- questionElement.innerHTML = '<td>Question: </td> <td>' + (((_a = this.result) === null || _a === void 0 ? void 0 : _a.title) || '') + '</td>'
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
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
48
  tableEl.appendChild(questionElement);
49
49
  const answerElement = document.createElement('tr');
@@ -53,17 +53,48 @@ export class FaqPopupComponent {
53
53
  answerElement.appendChild(answerTitleElement);
54
54
  // Create a new element to contain the answer content
55
55
  const answerContentElement = document.createElement('td');
56
- answerContentElement.innerHTML = ((_b = this.result) === null || _b === void 0 ? void 0 : _b.raw.answer) || '';
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
+ }
57
88
  // Append the answer content element to the answer element
58
89
  answerElement.appendChild(answerContentElement);
59
90
  // Now, the answer element has the title and the content properly appended
60
91
  tableEl.appendChild(answerElement);
61
- if ((_c = this.result) === null || _c === void 0 ? void 0 : _c.raw.category) {
92
+ if ((_f = this.result) === null || _f === void 0 ? void 0 : _f.raw.category) {
62
93
  const categoryElement = document.createElement("tr");
63
94
  categoryElement.innerHTML = '<td> Category: </td><td>' + this.result.raw.category + '</td>';
64
95
  tableEl.appendChild(categoryElement);
65
96
  }
66
- if ((_d = this.result) === null || _d === void 0 ? void 0 : _d.raw.newmoreinfo) {
97
+ if ((_g = this.result) === null || _g === void 0 ? void 0 : _g.raw.newmoreinfo) {
67
98
  const linkElement = document.createElement("tr");
68
99
  const linkUrl = this.result.raw.newmoreinfo;
69
100
  linkElement.innerHTML = '<td> Link: </td><td> <a href="' + linkUrl + '" target="_blank">' + linkUrl + '</a> </td>';
@@ -1,7 +1,7 @@
1
1
  import { initializeBindings } from "@coveo/atomic";
2
2
  import { Component, Element, h, Host, Listen } from "@stencil/core";
3
3
  import { waitForAtomic } from "../../utils/atomic";
4
- import { loadQueryActions, loadSearchActions, loadSearchAnalyticsActions } from "@coveo/headless";
4
+ import { loadPaginationActions, loadQueryActions, loadSearchActions, loadSearchAnalyticsActions } from "@coveo/headless";
5
5
  export class StandaloneSearchboxListener {
6
6
  async connectedCallback() {
7
7
  try {
@@ -13,15 +13,16 @@ export class StandaloneSearchboxListener {
13
13
  }
14
14
  }
15
15
  async handleStandaloneSearchbox(ev) {
16
- var _a, _b, _c, _d, _e, _f, _g;
17
- debugger;
16
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
18
17
  let queryActionCreator = loadQueryActions((_a = this.bindings) === null || _a === void 0 ? void 0 : _a.engine);
19
18
  (_c = (_b = this.bindings) === null || _b === void 0 ? void 0 : _b.engine) === null || _c === void 0 ? void 0 : _c.dispatch(queryActionCreator.updateQuery({
20
19
  q: ev.detail
21
20
  }));
22
- let analyticsActionCreator = loadSearchAnalyticsActions((_d = this.bindings) === null || _d === void 0 ? void 0 : _d.engine);
23
- let searchActionCreator = loadSearchActions((_e = this.bindings) === null || _e === void 0 ? void 0 : _e.engine);
24
- (_g = (_f = this.bindings) === null || _f === void 0 ? void 0 : _f.engine) === null || _g === void 0 ? void 0 : _g.dispatch(searchActionCreator.executeSearch(analyticsActionCreator.logSearchboxSubmit()));
21
+ let paginationActionCreator = loadPaginationActions((_d = this.bindings) === null || _d === void 0 ? void 0 : _d.engine);
22
+ (_f = (_e = this.bindings) === null || _e === void 0 ? void 0 : _e.engine) === null || _f === void 0 ? void 0 : _f.dispatch(paginationActionCreator.updatePage(1));
23
+ let analyticsActionCreator = loadSearchAnalyticsActions((_g = this.bindings) === null || _g === void 0 ? void 0 : _g.engine);
24
+ let searchActionCreator = loadSearchActions((_h = this.bindings) === null || _h === void 0 ? void 0 : _h.engine);
25
+ (_k = (_j = this.bindings) === null || _j === void 0 ? void 0 : _j.engine) === null || _k === void 0 ? void 0 : _k.dispatch(searchActionCreator.executeSearch(analyticsActionCreator.logSearchboxSubmit()));
25
26
  }
26
27
  render() {
27
28
  return (h(Host, null));