@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.
package/dist/esm/index.js CHANGED
@@ -6,7 +6,7 @@ async function main() {
6
6
  const searchBox = document.querySelector("#searchbox");
7
7
  const platformUrl = "https://platform.cloud.coveo.com";
8
8
  const organizationId = "anheuserbuschinbevprod";
9
- const accessToken = "x0ae66480-c272-44bf-bb26-0e89dc2c0239";
9
+ const accessToken = "x7e95c452-b717-4459-a9a1-a808b74c2242";
10
10
  await searchInterface.initialize({
11
11
  accessToken,
12
12
  organizationId,
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, h, g as getElement, f as forceUpdate } from './index-3c594d24.js';
2
- import { i as initializeBindings, n as nw, D as DI } from './index-886ab6f0.js';
2
+ import { i as initializeBindings, n as nw, D as DI } from './index-4e0bf5cd.js';
3
3
  import { w as waitForAtomic } from './atomic-0e957d02.js';
4
4
  import './headless.esm-085e70ed-c4dfb380.js';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, h, g as getElement, H as Host } from './index-3c594d24.js';
2
- import { i as initializeBindings, f as fce, m as mde, $ as $ce } from './index-886ab6f0.js';
2
+ import { i as initializeBindings, f as fce, a as nce, m as mde, $ as $ce } from './index-4e0bf5cd.js';
3
3
  import { w as waitForAtomic } from './atomic-0e957d02.js';
4
4
  import './headless.esm-085e70ed-c4dfb380.js';
5
5
 
@@ -19,15 +19,16 @@ const StandaloneSearchboxListener = class {
19
19
  }
20
20
  }
21
21
  async handleStandaloneSearchbox(ev) {
22
- var _a, _b, _c, _d, _e, _f, _g;
23
- debugger;
22
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
24
23
  let queryActionCreator = fce((_a = this.bindings) === null || _a === void 0 ? void 0 : _a.engine);
25
24
  (_c = (_b = this.bindings) === null || _b === void 0 ? void 0 : _b.engine) === null || _c === void 0 ? void 0 : _c.dispatch(queryActionCreator.updateQuery({
26
25
  q: ev.detail
27
26
  }));
28
- let analyticsActionCreator = mde((_d = this.bindings) === null || _d === void 0 ? void 0 : _d.engine);
29
- let searchActionCreator = $ce((_e = this.bindings) === null || _e === void 0 ? void 0 : _e.engine);
30
- (_g = (_f = this.bindings) === null || _f === void 0 ? void 0 : _f.engine) === null || _g === void 0 ? void 0 : _g.dispatch(searchActionCreator.executeSearch(analyticsActionCreator.logSearchboxSubmit()));
27
+ let paginationActionCreator = nce((_d = this.bindings) === null || _d === void 0 ? void 0 : _d.engine);
28
+ (_f = (_e = this.bindings) === null || _e === void 0 ? void 0 : _e.engine) === null || _f === void 0 ? void 0 : _f.dispatch(paginationActionCreator.updatePage(1));
29
+ let analyticsActionCreator = mde((_g = this.bindings) === null || _g === void 0 ? void 0 : _g.engine);
30
+ let searchActionCreator = $ce((_h = this.bindings) === null || _h === void 0 ? void 0 : _h.engine);
31
+ (_k = (_j = this.bindings) === null || _j === void 0 ? void 0 : _j.engine) === null || _k === void 0 ? void 0 : _k.dispatch(searchActionCreator.executeSearch(analyticsActionCreator.logSearchboxSubmit()));
31
32
  }
32
33
  render() {
33
34
  return (h(Host, null));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coveops/abi",
3
3
  "description": "Abi project",
4
- "version": "1.0.1",
4
+ "version": "1.0.3",
5
5
  "private": false,
6
6
  "main": "dist/index.cjs.js",
7
7
  "module": "dist/index.js",
@@ -62,7 +62,7 @@ export class FaqPopupComponent {
62
62
 
63
63
  const questionElement = document.createElement("tr");
64
64
  questionElement.className = "question-row";
65
- questionElement.innerHTML = '<td>Question: </td> <td>' + (this.result?.title || '') + '</td>'
65
+ questionElement.innerHTML = '<td>Question: <a href="https://anheuserbuschinbev.sharepoint.com" autofocus="true" style="display:none;"></a></td> <td>' + (this.result?.title || '') + '</td>'
66
66
  +'<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>';
67
67
 
68
68
  tableEl.appendChild(questionElement);
@@ -76,7 +76,38 @@ export class FaqPopupComponent {
76
76
 
77
77
  // Create a new element to contain the answer content
78
78
  const answerContentElement = document.createElement('td');
79
- answerContentElement.innerHTML = this.result?.raw.answer as string || '';
79
+ if(this.result?.raw?.answer) {
80
+ let value = this.result?.raw?.answer as string;
81
+ try {
82
+ var els = new DOMParser().parseFromString(value,'text/html');
83
+ var html = '';
84
+ Array.from(els.children).forEach(el => {
85
+ el.querySelectorAll('a').forEach(a => {
86
+ if (a.href.startsWith(window.location.origin) && a.href.indexOf('/sites/') > -1) {
87
+ a.href = a.href.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
88
+ }
89
+ if (a.href.startsWith(window.location.origin) && a.href.match(/:.:\/./)) {
90
+ a.href = a.href.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
91
+ }
92
+ });
93
+ el.querySelectorAll('img').forEach(a => {
94
+ if (a.src.startsWith(window.location.origin) && a.src.indexOf('/sites/') > -1) {
95
+ a.src = a.src.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
96
+ }
97
+ if (a.src.startsWith(window.location.origin) && a.src.match(/:.:\/./)) {
98
+ a.src = a.src.replace(window.location.origin, 'https://anheuserbuschinbev.sharepoint.com');
99
+ }
100
+ });
101
+ html = html + el.querySelector('body')?.innerHTML;
102
+ });
103
+ answerContentElement.innerHTML = html;
104
+ }
105
+ catch (e) {
106
+ console.log(e);
107
+ answerContentElement.innerHTML = value;
108
+ }
109
+ }
110
+
80
111
 
81
112
  // Append the answer content element to the answer element
82
113
  answerElement.appendChild(answerContentElement);
@@ -1,7 +1,7 @@
1
1
  import { Bindings, 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
 
6
6
  @Component({
7
7
  tag: "standalone-searchbox-listener",
@@ -27,13 +27,16 @@ export class StandaloneSearchboxListener {
27
27
 
28
28
  @Listen('header/searchbox/query', { target: 'window' })
29
29
  async handleStandaloneSearchbox(ev: CustomEvent) {
30
- debugger;
31
30
  let queryActionCreator = loadQueryActions(this.bindings?.engine!);
32
31
  this.bindings?.engine?.dispatch(
33
32
  queryActionCreator.updateQuery({
34
33
  q: ev.detail
35
34
  })
36
35
  );
36
+ let paginationActionCreator = loadPaginationActions(this.bindings?.engine!);
37
+ this.bindings?.engine?.dispatch(
38
+ paginationActionCreator.updatePage(1)
39
+ );
37
40
  let analyticsActionCreator = loadSearchAnalyticsActions(this.bindings?.engine!);
38
41
  let searchActionCreator = loadSearchActions(this.bindings?.engine!);
39
42
  this.bindings?.engine?.dispatch(
@@ -41,7 +41,7 @@
41
41
  </atomic-search-interface>
42
42
  </section>
43
43
  <section>
44
- <atomic-search-interface id="search" fields-to-include='[
44
+ <atomic-search-interface search-hub="communityCoveo" id="search" fields-to-include='[
45
45
  "sfcaseid", "sfppcustomlinkcpplinkurlc", "sfcaseppstatus", "sfcaseppstatusc", "sfcasestatus",
46
46
  "sfppcustomlinkcppiconc", "sfcasenumber", "sfcaseppprocessc", "sfppleaveabsencecppactiontypec",
47
47
  "sfppleaveabsencecppactionreasonc", "sfppleaveabsencecppenddatecfq", "sfppleaveabsencecppenddatecfy",
@@ -1 +0,0 @@
1
- import{r as t,h as i,g as s,H as o}from"./p-d6d34d34.js";import{i as e,F as d}from"./p-ddacae1a.js";import{r as h}from"./p-b83bab81.js";import"./p-d20ee37c.js";const l=class{constructor(i){t(this,i),this.closeFAQModal=()=>{this.modalElement.setAttribute("is-open","false"),this.modalElement.querySelector("#btn-done").removeEventListener("click",this.closeFAQModal)}}async connectedCallback(){var t;try{this.bindings=await e(this.host),this.result=await h(this.host),this.modalElement=null===(t=this.bindings)||void 0===t?void 0:t.interfaceElement.querySelector("#faq-modal"),this.result&&localStorage.getItem(`visited-${this.result.title}`)&&this.host.classList.add("visited-title")}catch(t){console.error(t),this.host.remove()}}openFAQModal(t){var i,s,o,e;if(this.bindings){const{logClickEvent:i}=d(this.bindings.engine);this.bindings.engine.dispatch(i({evt:"documentQuickview",result:t}))}this.modalElement.source=this.host;const h=this.modalElement.querySelector("[slot=body]");h.innerHTML="";const l=document.createElement("table"),n=document.createElement("tr");n.className="question-row",n.innerHTML="<td>Question: </td> <td>"+((null===(i=this.result)||void 0===i?void 0:i.title)||"")+'</td><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>',l.appendChild(n);const a=document.createElement("tr"),r=document.createElement("td");r.innerText="Answer:",a.appendChild(r);const c=document.createElement("td");if(c.innerHTML=(null===(s=this.result)||void 0===s?void 0:s.raw.answer)||"",a.appendChild(c),l.appendChild(a),null===(o=this.result)||void 0===o?void 0:o.raw.category){const t=document.createElement("tr");t.innerHTML="<td> Category: </td><td>"+this.result.raw.category+"</td>",l.appendChild(t)}if(null===(e=this.result)||void 0===e?void 0:e.raw.newmoreinfo){const t=document.createElement("tr"),i=this.result.raw.newmoreinfo;t.innerHTML='<td> Link: </td><td> <a href="'+i+'" target="_blank">'+i+"</a> </td>",l.appendChild(t)}h.appendChild(l),this.modalElement.querySelector("#faq-modal-close-button").addEventListener("click",this.closeFAQModal),this.modalElement.setAttribute("is-open","true"),this.result&&localStorage.setItem(`visited-${this.result.title}`,"true"),this.host.classList.add("visited-title")}render(){if(this.result)return i(o,{className:"clickable-host",onClick:()=>this.openFAQModal(this.result)},this.result.title)}get host(){return s(this)}};l.style="b{color:var(--atomic-primary)}:host{color:#CAA144 !important;font-size:1.7rem !important;max-height:unset !important;line-height:normal !important}";export{l as faq_popup_component}
@@ -1 +0,0 @@
1
- import{r as s,h as o,g as t,H as a}from"./p-d6d34d34.js";import{i,f as l,m as n,$ as d}from"./p-ddacae1a.js";import{w as e}from"./p-38555fec.js";import"./p-d20ee37c.js";const r=class{constructor(o){s(this,o)}async connectedCallback(){try{await e(),this.bindings=await i(this.host)}catch(s){console.error(s)}}async handleStandaloneSearchbox(s){var o,t,a,i,e,r,c;let h=l(null===(o=this.bindings)||void 0===o?void 0:o.engine);null===(a=null===(t=this.bindings)||void 0===t?void 0:t.engine)||void 0===a||a.dispatch(h.updateQuery({q:s.detail}));let v=n(null===(i=this.bindings)||void 0===i?void 0:i.engine),u=d(null===(e=this.bindings)||void 0===e?void 0:e.engine);null===(c=null===(r=this.bindings)||void 0===r?void 0:r.engine)||void 0===c||c.dispatch(u.executeSearch(v.logSearchboxSubmit()))}render(){return o(a,null)}get host(){return t(this)}};r.style="";export{r as standalone_searchbox_listener}