@coveo/quantic 3.44.2 → 3.45.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 (23) hide show
  1. package/README.md +12 -3
  2. package/docs/out/quantic-docs.json +58 -0
  3. package/force-app/main/default/labels/CustomLabels.labels-meta.xml +28 -0
  4. package/force-app/main/default/lwc/quanticCitation/quanticCitation.js +2 -2
  5. package/force-app/main/default/lwc/quanticHeadlessLoader/quanticHeadlessLoader.js +158 -87
  6. package/force-app/main/default/lwc/quanticLoadMoreResults/quanticLoadMoreResults.css +5 -0
  7. package/force-app/main/default/lwc/quanticLoadMoreResults/quanticLoadMoreResults.html +30 -0
  8. package/force-app/main/default/lwc/quanticLoadMoreResults/quanticLoadMoreResults.js +162 -0
  9. package/force-app/main/default/lwc/quanticLoadMoreResults/quanticLoadMoreResults.js-meta.xml +5 -0
  10. package/force-app/main/default/lwc/quanticResultLink/quanticResultLink.js +2 -2
  11. package/force-app/main/default/staticresources/coveoheadless/case-assist/headless.js +15 -15
  12. package/force-app/main/default/staticresources/coveoheadless/definitions/api/analytics/analytics-relay-client.d.ts +2 -1
  13. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/commerce/factories/build-factory.d.ts +1 -1
  14. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr/common/access-token-manager.d.ts +7 -1
  15. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/build.d.ts +10 -0
  16. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/commerce/types/engine.d.ts +1 -1
  17. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/common/access-token-manager.d.ts +7 -1
  18. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-next/search/types/engine.d.ts +1 -1
  19. package/force-app/main/default/staticresources/coveoheadless/headless.js +17 -17
  20. package/force-app/main/default/staticresources/coveoheadless/insight/headless.js +16 -16
  21. package/force-app/main/default/staticresources/coveoheadless/recommendation/headless.js +15 -15
  22. package/force-app/main/default/staticresources/dompurify/purify.min.js +2 -2
  23. package/package.json +14 -14
@@ -0,0 +1,162 @@
1
+ import LOCALE from '@salesforce/i18n/locale';
2
+ import allResultsLoaded from '@salesforce/label/c.quantic_AllResultsLoaded';
3
+ import loadMoreResults from '@salesforce/label/c.quantic_LoadMoreResults';
4
+ import showingResultsOfLoadMore from '@salesforce/label/c.quantic_ShowingResultsOfLoadMore';
5
+ import showingResultsOfLoadMore_plural from '@salesforce/label/c.quantic_ShowingResultsOfLoadMore_plural';
6
+ import {
7
+ registerComponentForInit,
8
+ initializeWithHeadless,
9
+ getHeadlessBundle,
10
+ } from 'c/quanticHeadlessLoader';
11
+ import {AriaLiveRegion, I18nUtils} from 'c/quanticUtils';
12
+ import {LightningElement, api, track} from 'lwc';
13
+
14
+ /** @typedef {import("coveo").SearchEngine} SearchEngine */
15
+ /** @typedef {import("coveo").ResultList} ResultList */
16
+ /** @typedef {import("coveo").ResultListState} ResultListState */
17
+ /** @typedef {import("coveo").QuerySummary} QuerySummary */
18
+ /** @typedef {import("coveo").QuerySummaryState} QuerySummaryState */
19
+
20
+ /**
21
+ * The `QuanticLoadMoreResults` component allows the user to load additional results if more are available.
22
+ *
23
+ * This component is an alternative to the `quantic-pager` component: use one or the other, not both on the same page.
24
+ * @category Search
25
+ * @category Insight Panel
26
+ * @example
27
+ * <c-quantic-load-more-results engine-id={engineId}></c-quantic-load-more-results>
28
+ */
29
+ export default class QuanticLoadMoreResults extends LightningElement {
30
+ /**
31
+ * The ID of the engine instance the component registers to.
32
+ * @api
33
+ * @type {string}
34
+ */
35
+ @api engineId;
36
+
37
+ /** @type {ResultListState} */
38
+ @track resultListState;
39
+ /** @type {QuerySummaryState} */
40
+ @track querySummaryState;
41
+
42
+ /** @type {ResultList} */
43
+ resultList;
44
+ /** @type {QuerySummary} */
45
+ querySummary;
46
+ /** @type {Function} */
47
+ unsubscribeResultList;
48
+ /** @type {Function} */
49
+ unsubscribeQuerySummary;
50
+ /** @type {ResultListState} */
51
+ previousResultListState;
52
+ /** @type {AnyHeadless} */
53
+ headless;
54
+ /** @type {import('c/quanticUtils').AriaLiveUtils} */
55
+ allResultsLoadedAriaMessage;
56
+ /** @type {boolean} */
57
+ hasInitializationError = false;
58
+
59
+ labels = {
60
+ allResultsLoaded,
61
+ loadMoreResults,
62
+ showingResultsOfLoadMore,
63
+ showingResultsOfLoadMore_plural,
64
+ };
65
+
66
+ connectedCallback() {
67
+ registerComponentForInit(this, this.engineId);
68
+ }
69
+
70
+ renderedCallback() {
71
+ initializeWithHeadless(this, this.engineId, this.initialize);
72
+ }
73
+
74
+ /**
75
+ * @param {SearchEngine} engine
76
+ */
77
+ initialize = (engine) => {
78
+ this.headless = getHeadlessBundle(this.engineId);
79
+ this.resultList = this.headless.buildResultList(engine);
80
+ this.querySummary = this.headless.buildQuerySummary(engine);
81
+ this.allResultsLoadedAriaMessage = AriaLiveRegion('loadMoreResults', this);
82
+ this.unsubscribeResultList = this.resultList.subscribe(() =>
83
+ this.updateResultListState()
84
+ );
85
+ this.unsubscribeQuerySummary = this.querySummary.subscribe(() =>
86
+ this.updateQuerySummaryState()
87
+ );
88
+ };
89
+
90
+ disconnectedCallback() {
91
+ this.unsubscribeResultList?.();
92
+ this.unsubscribeQuerySummary?.();
93
+ }
94
+
95
+ updateResultListState() {
96
+ this.previousResultListState = this.resultListState;
97
+ this.resultListState = this.resultList.state;
98
+ this.announceWhenAllResultsAreLoaded();
99
+ }
100
+
101
+ updateQuerySummaryState() {
102
+ this.querySummaryState = this.querySummary.state;
103
+ }
104
+
105
+ announceWhenAllResultsAreLoaded() {
106
+ const isLastBatchLoaded =
107
+ this.previousResultListState?.moreResultsAvailable === true &&
108
+ this.resultListState?.moreResultsAvailable === false &&
109
+ this.previousResultListState?.searchResponseId ===
110
+ this.resultListState?.searchResponseId;
111
+
112
+ if (isLastBatchLoaded) {
113
+ this.allResultsLoadedAriaMessage.dispatchMessage(
114
+ this.labels.allResultsLoaded
115
+ );
116
+ }
117
+ }
118
+
119
+ fetchMoreResults() {
120
+ this.resultList.fetchMoreResults();
121
+ }
122
+
123
+ get hasResults() {
124
+ return !!this.resultListState?.hasResults;
125
+ }
126
+
127
+ get moreResultsAvailable() {
128
+ return !!this.resultListState?.moreResultsAvailable;
129
+ }
130
+
131
+ get summaryLabel() {
132
+ const labelName = I18nUtils.getLabelNameWithCount(
133
+ 'showingResultsOfLoadMore',
134
+ this.querySummaryState?.lastResult
135
+ );
136
+ return I18nUtils.format(
137
+ this.labels[labelName],
138
+ Intl.NumberFormat(LOCALE)
139
+ .format(this.querySummaryState?.lastResult)
140
+ .toString(),
141
+ Intl.NumberFormat(LOCALE).format(this.querySummaryState?.total).toString()
142
+ );
143
+ }
144
+
145
+ /**
146
+ * @returns {number}
147
+ */
148
+ get progressPercentage() {
149
+ const total = this.querySummaryState?.total;
150
+ if (!total) {
151
+ return 0;
152
+ }
153
+ return Math.min(100, (this.querySummaryState?.lastResult / total) * 100);
154
+ }
155
+
156
+ /**
157
+ * Sets the component in the initialization error state.
158
+ */
159
+ setInitializationError() {
160
+ this.hasInitializationError = true;
161
+ }
162
+ }
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
3
+ <apiVersion>64.0</apiVersion>
4
+ <isExposed>false</isExposed>
5
+ </LightningComponentBundle>
@@ -9,9 +9,9 @@ import {NavigationMixin} from 'lightning/navigation';
9
9
  import {LightningElement, api} from 'lwc';
10
10
 
11
11
  /**
12
- * Some document types cannot be opened directly in Salesforce, but we need to open their parent record, as is the case for the Case Comment document type.
12
+ * Some document types cannot be opened directly in Salesforce, so we navigate to their parent record (e.g., CaseComment and FeedComment).
13
13
  */
14
- const documentTypesRequiringParentRecord = ['CaseComment'];
14
+ const documentTypesRequiringParentRecord = ['CaseComment', 'FeedComment'];
15
15
 
16
16
  /** @typedef {import("coveo").Result} Result */
17
17
  /** @typedef {import("coveo").SearchEngine} SearchEngine */