@coveops/abi 0.3.2 → 0.4.1

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 (62) hide show
  1. package/dist/abi/abi.css +1 -12
  2. package/dist/abi/abi.esm.js +1 -129
  3. package/dist/abi/index.esm.js +1 -16
  4. package/dist/abi/p-0ae1e588.js +2 -0
  5. package/dist/abi/p-27bd9f1c.entry.js +1 -0
  6. package/dist/abi/p-38555fec.js +1 -0
  7. package/dist/abi/p-63fd8dcd.js +66 -0
  8. package/dist/abi/p-e04b6a2c.entry.js +1 -0
  9. package/dist/abi/p-fc39046e.entry.js +1 -0
  10. package/dist/bundle/index.css +1 -0
  11. package/dist/bundle/index.html +61 -0
  12. package/dist/bundle/index.js +832 -0
  13. package/dist/cjs/abi.cjs.js +19 -0
  14. package/dist/cjs/atomic-7321a250.js +7 -0
  15. package/dist/cjs/faq-popup-component.cjs.entry.js +113 -0
  16. package/dist/cjs/index-bea59ea1.js +1093 -0
  17. package/dist/cjs/index-daa118f5.js +1816 -0
  18. package/dist/cjs/index.cjs.js +18 -0
  19. package/dist/cjs/loader.cjs.js +21 -0
  20. package/dist/cjs/results-manager.cjs.entry.js +40 -0
  21. package/dist/cjs/sample-component.cjs.entry.js +86 -0
  22. package/dist/collection/collection-manifest.json +19 -0
  23. package/dist/collection/components/faq-popup-component/faq-popup-component.css +15 -0
  24. package/dist/{abi/faq-popup-component.entry.js → collection/components/faq-popup-component/faq-popup-component.js} +19 -14
  25. package/dist/collection/components/results-manager/results-manager.js +45 -0
  26. package/dist/collection/components/sample-component/sample-component.css +10 -0
  27. package/dist/collection/components/sample-component/sample-component.js +102 -0
  28. package/dist/collection/index.js +15 -0
  29. package/dist/collection/utils/atomic.js +3 -0
  30. package/dist/components/index.js +3006 -0
  31. package/dist/esm/abi.js +17 -0
  32. package/dist/esm/faq-popup-component.entry.js +109 -0
  33. package/dist/esm/index-51334f26.js +1065 -0
  34. package/dist/esm/index-77ebb3d5.js +1809 -0
  35. package/dist/esm/index.js +16 -0
  36. package/dist/esm/loader.js +17 -0
  37. package/dist/esm/polyfills/core-js.js +11 -0
  38. package/dist/esm/polyfills/css-shim.js +1 -0
  39. package/dist/esm/polyfills/dom.js +79 -0
  40. package/dist/esm/polyfills/es5-html-element.js +1 -0
  41. package/dist/esm/polyfills/index.js +34 -0
  42. package/dist/esm/polyfills/system.js +6 -0
  43. package/dist/{abi → esm}/results-manager.entry.js +1 -1
  44. package/dist/{abi → esm}/sample-component.entry.js +2 -2
  45. package/dist/index.cjs.js +1 -0
  46. package/dist/index.js +1 -0
  47. package/dist/loader/cdn.js +3 -0
  48. package/dist/loader/index.cjs.js +3 -0
  49. package/dist/loader/index.d.ts +12 -0
  50. package/dist/loader/index.es2017.js +3 -0
  51. package/dist/loader/index.js +4 -0
  52. package/dist/loader/package.json +10 -0
  53. package/package.json +2 -2
  54. package/src/pages/index.html +0 -37
  55. package/src/style/index.css +42 -0
  56. package/dist/abi/app-globals-0f993ce5.js +0 -3
  57. package/dist/abi/css-shim-04165e59.js +0 -4
  58. package/dist/abi/dom-26e7cb2c.js +0 -73
  59. package/dist/abi/index-54dd422f.js +0 -3064
  60. package/dist/abi/index-d57e5124.js +0 -4179
  61. package/dist/abi/shadow-css-1257b266.js +0 -387
  62. /package/dist/{abi → esm}/atomic-0e957d02.js +0 -0
@@ -0,0 +1,102 @@
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
+ }
@@ -0,0 +1,15 @@
1
+ import { waitForAtomic } from "./utils/atomic";
2
+ async function main() {
3
+ await waitForAtomic();
4
+ const searchInterface = document.querySelector("atomic-search-interface");
5
+ const platformUrl = process.env.PLATFORM_URL;
6
+ const organizationId = process.env.ORGANIZATION_ID;
7
+ const accessToken = process.env.API_KEY;
8
+ await searchInterface.initialize({
9
+ accessToken,
10
+ organizationId,
11
+ platformUrl,
12
+ });
13
+ searchInterface.executeFirstSearch();
14
+ }
15
+ main();
@@ -0,0 +1,3 @@
1
+ export function waitForAtomic() {
2
+ return customElements.whenDefined("atomic-search-interface");
3
+ }