@coveo/quantic 3.18.0-pre.1cdc15abee → 3.18.0-pre.22bf157efb

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.
@@ -38,6 +38,9 @@
38
38
  "c/quanticResultList": ["quanticResultList/quanticResultList.js"],
39
39
  "c/quanticResultLink": ["quanticResultLink/quanticResultLink.js"],
40
40
  "c/quanticSort": ["quanticSort/quanticSort.js"],
41
+ "c/quanticInsightInterface": [
42
+ "quanticInsightInterface/quanticInsightInterface.js"
43
+ ],
41
44
  "c/quanticSummary": ["quanticSummary/quanticSummary.js"],
42
45
  "c/quanticFacetValue": ["quanticFacetValue/quanticFacetValue.js"],
43
46
  "c/quanticNumericFacet": ["quanticNumericFacet/quanticNumericFacet.js"],
@@ -44,11 +44,14 @@ export default class QuanticInsightInterface extends LightningElement {
44
44
  hasRendered = false;
45
45
  /** @type {boolean} */
46
46
  ariaLiveEventsBound = false;
47
+ /** @type {function} */
48
+ unsubscribeInsightInterface;
47
49
 
48
50
  /** @type {string} */
49
51
  analyticsOriginContext = 'InsightPanel';
50
52
 
51
53
  disconnectedCallback() {
54
+ this.unsubscribeInsightInterface?.();
52
55
  destroyEngine(this.engineId);
53
56
  if (this.ariaLiveEventsBound) {
54
57
  this.removeEventListener(
@@ -133,19 +136,36 @@ export default class QuanticInsightInterface extends LightningElement {
133
136
  if (this.initialized) {
134
137
  return;
135
138
  }
136
- this.dispatchEvent(
137
- new CustomEvent(`quantic__insightinterfaceinitialized`, {
138
- detail: {
139
- engineId: this.engineId,
140
- insightId: this.insightId,
141
- },
142
- bubbles: true,
143
- composed: true,
144
- })
139
+ const engine = getHeadlessBindings(this.engineId).engine;
140
+ this.insightInterface = CoveoHeadlessInsight.buildInsightInterface(engine);
141
+ this.unsubscribeInsightInterface = this.insightInterface.subscribe(() =>
142
+ this.updateInsightInterfaceState()
145
143
  );
146
- this.initialized = true;
147
144
  };
148
145
 
146
+ updateInsightInterfaceState() {
147
+ if (this.initialized) {
148
+ return;
149
+ }
150
+ this.isInsightInterfaceReady =
151
+ !this.insightInterface.state.loading &&
152
+ !!this.insightInterface.state.config;
153
+
154
+ if (this.isInsightInterfaceReady) {
155
+ this.dispatchEvent(
156
+ new CustomEvent(`quantic__insightinterfaceinitialized`, {
157
+ detail: {
158
+ engineId: this.engineId,
159
+ insightId: this.insightId,
160
+ },
161
+ bubbles: true,
162
+ composed: true,
163
+ })
164
+ );
165
+ this.initialized = true;
166
+ }
167
+ }
168
+
149
169
  /**
150
170
  * @returns {HTMLInputElement}
151
171
  */
@@ -5,7 +5,7 @@
5
5
  </template>
6
6
  <template lwc:else>
7
7
  <template lwc:if={isFacetEnabled}>
8
- <div data-test="facet-content">
8
+ <div data-testid="facet-content">
9
9
  <template if:true={showPlaceholder}>
10
10
  <c-quantic-placeholder
11
11
  variant="card"
@@ -35,6 +35,7 @@
35
35
  </lightning-button-icon>
36
36
  <template if:true={hasActiveValues}>
37
37
  <button
38
+ data-testid="clear-selection-button"
38
39
  class="facet__clear-filter slds-button slds-grid slds-grid_vertical-align-center slds-var-p-horizontal_x-small slds-m-top_small"
39
40
  onclick={clearSelections}
40
41
  title={clearFilterLabel}
@@ -53,11 +54,13 @@
53
54
  </template>
54
55
  <template if:false={isCollapsed}>
55
56
  <div
57
+ data-testid="facet__body"
56
58
  class="slds-has-dividers_around-space slds-var-m-top_medium"
57
59
  >
58
60
  <template if:true={withInput}>
59
61
  <div class="slds-p-horizontal_x-small">
60
62
  <form
63
+ data-testid="facet__search-form"
61
64
  onsubmit={onApply}
62
65
  class="facet__search-form slds-grid slds-gutters slds-var-p-bottom_small"
63
66
  >
@@ -15,7 +15,6 @@ import numberInputMinimum from '@salesforce/label/c.quantic_NumberInputMinimum';
15
15
  import {
16
16
  registerComponentForInit,
17
17
  initializeWithHeadless,
18
- getHeadlessBindings,
19
18
  registerToStore,
20
19
  getHeadlessBundle,
21
20
  getBueno,
@@ -34,6 +33,7 @@ import {LightningElement, track, api} from 'lwc';
34
33
  /** @typedef {import("coveo").NumericFacetValue} NumericFacetValue */
35
34
  /** @typedef {import("coveo").SearchStatus} SearchStatus */
36
35
  /** @typedef {import("coveo").SearchEngine} SearchEngine */
36
+ /** @typedef {import("coveo").InsightEngine} InsightEngine */
37
37
  /** @typedef {import("coveo").FacetConditionsManager} FacetConditionsManager */
38
38
  /** @typedef {import('../quanticUtils/facetDependenciesUtils').DependsOn} DependsOn */
39
39
  /**
@@ -223,6 +223,8 @@ export default class QuanticNumericFacet extends LightningElement {
223
223
  numericFacetConditionsManager;
224
224
  /** @type {FacetConditionsManager} */
225
225
  numericFilterConditionsManager;
226
+ /** @type {SearchEngine | InsightEngine} */
227
+ engine;
226
228
 
227
229
  /** @type {string} */
228
230
  start;
@@ -262,9 +264,10 @@ export default class QuanticNumericFacet extends LightningElement {
262
264
  }
263
265
 
264
266
  /**
265
- * @param {SearchEngine} engine
267
+ * @param {SearchEngine | InsightEngine} engine
266
268
  */
267
269
  initialize = (engine) => {
270
+ this.engine = engine;
268
271
  this.validateDependsOnProperty();
269
272
  this.headless = getHeadlessBundle(this.engineId);
270
273
  this.searchStatus = this.headless.buildSearchStatus(engine);
@@ -273,15 +276,11 @@ export default class QuanticNumericFacet extends LightningElement {
273
276
  );
274
277
 
275
278
  if (this.numberOfValues > 0) {
276
- this.initializeFacet(engine);
279
+ this.initializeFacet();
277
280
  }
278
281
  if (this.withInput) {
279
- this.initializeFilter(engine);
282
+ this.initializeFilter();
280
283
  }
281
- this.searchStatus = this.headless.buildSearchStatus(engine);
282
- this.unsubscribeSearchStatus = this.searchStatus.subscribe(() =>
283
- this.updateState()
284
- );
285
284
  registerToStore(this.engineId, Store.facetTypes.NUMERICFACETS, {
286
285
  label: this.label,
287
286
  facetId: this.facet?.state.facetId ?? this.field,
@@ -310,11 +309,8 @@ export default class QuanticNumericFacet extends LightningElement {
310
309
  }
311
310
  }
312
311
 
313
- /**
314
- * @param {import("coveo").SearchEngine} engine
315
- */
316
- initializeFacet(engine) {
317
- this.facet = this.headless.buildNumericFacet(engine, {
312
+ initializeFacet() {
313
+ this.facet = this.headless.buildNumericFacet(this.engine, {
318
314
  options: {
319
315
  field: this.field,
320
316
  generateAutomaticRanges: true,
@@ -327,17 +323,14 @@ export default class QuanticNumericFacet extends LightningElement {
327
323
  this.unsubscribe = this.facet.subscribe(() => this.updateState());
328
324
  if (this.dependsOn) {
329
325
  this.numericFacetConditionsManager = this.initFacetConditionManager(
330
- engine,
326
+ this.engine,
331
327
  this.facet.state?.facetId
332
328
  );
333
329
  }
334
330
  }
335
331
 
336
- /**
337
- * @param {import("coveo").SearchEngine} engine
338
- */
339
- initializeFilter(engine) {
340
- this.numericFilter = this.headless.buildNumericFilter(engine, {
332
+ initializeFilter() {
333
+ this.numericFilter = this.headless.buildNumericFilter(this.engine, {
341
334
  options: {
342
335
  field: this.field,
343
336
  facetId: this.facet?.state.facetId
@@ -350,7 +343,7 @@ export default class QuanticNumericFacet extends LightningElement {
350
343
  );
351
344
  if (this.dependsOn) {
352
345
  this.numericFilterConditionsManager = this.initFacetConditionManager(
353
- engine,
346
+ this.engine,
354
347
  this.numericFilter.state?.facetId
355
348
  );
356
349
  }
@@ -580,10 +573,9 @@ export default class QuanticNumericFacet extends LightningElement {
580
573
  }
581
574
 
582
575
  if (this.numberOfValues > 0) {
583
- const engine = getHeadlessBindings(this.engineId).engine;
584
- engine.dispatch(
576
+ this.engine.dispatch(
585
577
  this.headless
586
- .loadNumericFacetSetActions(engine)
578
+ .loadNumericFacetSetActions(this.engine)
587
579
  .deselectAllNumericFacetValues(this.facet.state.facetId)
588
580
  );
589
581
  }