@coveops/abi 0.4.1 → 0.5.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.
Files changed (61) hide show
  1. package/dist/abi/abi.css +1 -1
  2. package/dist/abi/abi.esm.js +1 -1
  3. package/dist/abi/p-0f4a7ce9.js +49 -0
  4. package/dist/abi/p-52c70e74.js +2 -0
  5. package/dist/abi/p-5a5f74eb.entry.js +1 -0
  6. package/dist/abi/p-adb4a9f9.entry.js +1 -0
  7. package/dist/abi/p-b62c5f66.entry.js +1 -0
  8. package/dist/abi/p-b83bab81.js +1 -0
  9. package/dist/abi/p-d20ee37c.js +18 -0
  10. package/dist/abi/p-e7475cc6.entry.js +1 -0
  11. package/dist/bundle/index.css +1 -1
  12. package/dist/bundle/index.html +6 -6
  13. package/dist/bundle/index.js +170 -91
  14. package/dist/cjs/abi.cjs.js +2 -2
  15. package/dist/cjs/faq-popup-component.cjs.entry.js +10 -36
  16. package/dist/cjs/{index-daa118f5.js → headless.esm-085e70ed-f2e18485.js} +0 -96
  17. package/dist/cjs/index-03be0841.js +100 -0
  18. package/dist/cjs/{index-bea59ea1.js → index-9c1d2337.js} +25 -0
  19. package/dist/cjs/loader.cjs.js +2 -2
  20. package/dist/cjs/result-template-decorators-881a4c8e-4ff46481.js +33 -0
  21. package/dist/cjs/results-manager.cjs.entry.js +11 -11
  22. package/dist/cjs/sample-component.cjs.entry.js +3 -2
  23. package/dist/cjs/strip-html-component.cjs.entry.js +60 -0
  24. package/dist/collection/collection-manifest.json +2 -1
  25. package/dist/collection/components/strip-html-component/strip-html-component.css +3 -0
  26. package/dist/collection/components/strip-html-component/strip-html-component.js +64 -0
  27. package/dist/components/index.d.ts +6 -0
  28. package/dist/components/index.js +92 -12
  29. package/dist/esm/abi.js +2 -2
  30. package/dist/esm/faq-popup-component.entry.js +4 -30
  31. package/dist/esm/{index-77ebb3d5.js → headless.esm-085e70ed-c4dfb380.js} +1 -93
  32. package/dist/esm/index-42e9a708.js +95 -0
  33. package/dist/esm/{index-51334f26.js → index-8b0b351b.js} +25 -0
  34. package/dist/esm/loader.js +2 -2
  35. package/dist/esm/result-template-decorators-881a4c8e-ed85ad21.js +31 -0
  36. package/dist/esm/results-manager.entry.js +11 -11
  37. package/dist/esm/sample-component.entry.js +3 -2
  38. package/dist/esm/strip-html-component.entry.js +56 -0
  39. package/dist/types/components/strip-html-component/strip-html-component.d.ts +14 -0
  40. package/dist/types/components.d.ts +13 -0
  41. package/package.json +1 -1
  42. package/src/components/results-manager/AppTemplate.html +32 -14
  43. package/src/components/results-manager/DocumentsTemplate.html +16 -4
  44. package/src/components/results-manager/ELearningTemplate.html +10 -8
  45. package/src/components/results-manager/FAQTemplate.html +11 -6
  46. package/src/components/results-manager/KATemplate.html +12 -8
  47. package/src/components/results-manager/MediaTemplate.html +18 -0
  48. package/src/components/results-manager/PeopleTemplate.html +3 -3
  49. package/src/components/results-manager/QuickLinksTemplate.html +15 -3
  50. package/src/components/results-manager/SitePagesTemplate.html +8 -2
  51. package/src/components/results-manager/template-1.html +83 -41
  52. package/src/components/strip-html-component/strip-html-component.css +3 -0
  53. package/src/components/strip-html-component/strip-html-component.tsx +77 -0
  54. package/src/components.d.ts +13 -0
  55. package/src/pages/index.html +6 -6
  56. package/src/style/index.css +13 -4
  57. package/dist/abi/p-0ae1e588.js +0 -2
  58. package/dist/abi/p-27bd9f1c.entry.js +0 -1
  59. package/dist/abi/p-63fd8dcd.js +0 -66
  60. package/dist/abi/p-e04b6a2c.entry.js +0 -1
  61. package/dist/abi/p-fc39046e.entry.js +0 -1
@@ -2,9 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-bea59ea1.js');
6
- const index$1 = require('./index-daa118f5.js');
5
+ const index = require('./index-9c1d2337.js');
6
+ const index$1 = require('./index-03be0841.js');
7
7
  const atomic = require('./atomic-7321a250.js');
8
+ require('./headless.esm-085e70ed-f2e18485.js');
8
9
 
9
10
  const sampleComponentCss = "nav{width:300px;display:flex;justify-content:space-around}button{color:var(--atomic-on-primary);background-color:var(--atomic-primary)}";
10
11
 
@@ -0,0 +1,60 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-9c1d2337.js');
6
+ require('./headless.esm-085e70ed-f2e18485.js');
7
+ const resultTemplateDecorators881a4c8e = require('./result-template-decorators-881a4c8e-4ff46481.js');
8
+
9
+ const stripHtmlComponentCss = "b{color:var(--atomic-primary)}";
10
+
11
+ const StripHtmlComponent = class {
12
+ constructor(hostRef) {
13
+ index.registerInstance(this, hostRef);
14
+ }
15
+ // We recommended fetching the result context using the `connectedCallback` lifecycle method
16
+ // with async/await. Using `componentWillLoad` will hang the parent `atomic-search-interface` initialization.
17
+ async connectedCallback() {
18
+ try {
19
+ this.result = await resultTemplateDecorators881a4c8e.resultContext(this.host);
20
+ }
21
+ catch (error) {
22
+ console.error(error);
23
+ this.host.remove();
24
+ }
25
+ }
26
+ // Function to strip HTML tags and decode HTML entities
27
+ stripHtmlAndEntities(str) {
28
+ // Create a temporary DOM element
29
+ var tempDiv = document.createElement("div");
30
+ // Set its innerHTML to the input string
31
+ tempDiv.innerHTML = str;
32
+ // Use textContent to get the plain text
33
+ var text = tempDiv.textContent || tempDiv.innerText || "";
34
+ // Replace HTML entities
35
+ var decodedText = text.replace(/&#(\d+);/g, (_, dec) => String.fromCharCode(dec));
36
+ return decodedText;
37
+ }
38
+ render() {
39
+ // Do not render the component until the result object has been resolved.
40
+ if (!this.result) {
41
+ return;
42
+ }
43
+ let description;
44
+ if (this.result.raw.abicontenttype == "Quick Links") {
45
+ description = this.result.excerpt || "No description available";
46
+ }
47
+ else {
48
+ description = this.result.raw.description;
49
+ }
50
+ let strippedString = '';
51
+ if (typeof description === 'string') {
52
+ strippedString = this.stripHtmlAndEntities(description);
53
+ }
54
+ return (index.h("div", { style: { fontSize: "13px" } }, strippedString));
55
+ }
56
+ get host() { return index.getElement(this); }
57
+ };
58
+ StripHtmlComponent.style = stripHtmlComponentCss;
59
+
60
+ exports.strip_html_component = StripHtmlComponent;
@@ -2,7 +2,8 @@
2
2
  "entries": [
3
3
  "./components/faq-popup-component/faq-popup-component.js",
4
4
  "./components/results-manager/results-manager.js",
5
- "./components/sample-component/sample-component.js"
5
+ "./components/sample-component/sample-component.js",
6
+ "./components/strip-html-component/strip-html-component.js"
6
7
  ],
7
8
  "compiler": {
8
9
  "name": "@stencil/core",
@@ -0,0 +1,3 @@
1
+ b {
2
+ color: var(--atomic-primary);
3
+ }
@@ -0,0 +1,64 @@
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: "13px" } }, 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
+ }
@@ -20,6 +20,12 @@ export const SampleComponent: {
20
20
  new (): SampleComponent;
21
21
  };
22
22
 
23
+ interface StripHtmlComponent extends Components.StripHtmlComponent, HTMLElement {}
24
+ export const StripHtmlComponent: {
25
+ prototype: StripHtmlComponent;
26
+ new (): StripHtmlComponent;
27
+ };
28
+
23
29
  /**
24
30
  * Utility to define all custom elements within this package using the tag name provided in the component's source.
25
31
  * When defining each custom element, it will also check it's safe to define by: