@coveo/quantic 3.18.0-pre.2e375b7777 → 3.18.0-pre.49fef96298

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
  */