@coveo/quantic 3.33.6 → 3.34.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 (24) hide show
  1. package/docs/out/quantic-docs.json +1 -1
  2. package/force-app/main/default/lwc/jsconfig.json +1 -1
  3. package/force-app/main/default/lwc/quanticResultQuickview/__tests__/quanticResultQuickview.test.js +8 -1
  4. package/force-app/main/default/lwc/quanticResultQuickview/quanticResultQuickview.js +13 -5
  5. package/force-app/main/default/lwc/quanticUtils/quanticUtils.js +8 -8
  6. package/force-app/main/default/staticresources/coveoheadless/case-assist/headless.js +2 -2
  7. package/force-app/main/default/staticresources/coveoheadless/definitions/api/commerce/commerce-api-client.d.ts +3 -2
  8. package/force-app/main/default/staticresources/coveoheadless/definitions/api/commerce/commerce-api-params.d.ts +3 -0
  9. package/force-app/main/default/staticresources/coveoheadless/definitions/api/commerce/common/product.d.ts +5 -6
  10. package/force-app/main/default/staticresources/coveoheadless/definitions/api/commerce/common/result.d.ts +52 -0
  11. package/force-app/main/default/staticresources/coveoheadless/definitions/api/commerce/listing/request.d.ts +3 -0
  12. package/force-app/main/default/staticresources/coveoheadless/definitions/api/commerce/listing/response.d.ts +5 -0
  13. package/force-app/main/default/staticresources/coveoheadless/definitions/commerce.index.d.ts +3 -1
  14. package/force-app/main/default/staticresources/coveoheadless/definitions/controllers/commerce/product-listing/headless-product-listing.d.ts +12 -1
  15. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/product-listing/product-listing-actions-loader.d.ts +3 -3
  16. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/product-listing/product-listing-actions.d.ts +12 -4
  17. package/force-app/main/default/staticresources/coveoheadless/definitions/features/commerce/product-listing/product-listing-state.d.ts +2 -0
  18. package/force-app/main/default/staticresources/coveoheadless/definitions/ssr-commerce.index.d.ts +2 -1
  19. package/force-app/main/default/staticresources/coveoheadless/definitions/test/mock-product-listing.d.ts +2 -2
  20. package/force-app/main/default/staticresources/coveoheadless/definitions/test/mock-spotlight-content.d.ts +3 -0
  21. package/force-app/main/default/staticresources/coveoheadless/headless.js +3 -3
  22. package/force-app/main/default/staticresources/coveoheadless/insight/headless.js +3 -3
  23. package/force-app/main/default/staticresources/coveoheadless/recommendation/headless.js +2 -2
  24. package/package.json +3 -3
@@ -3363,7 +3363,7 @@
3363
3363
  "description": "<p>The result to retrieve a quickview for.</p>",
3364
3364
  "required": true,
3365
3365
  "defaultValue": "",
3366
- "type": "Result"
3366
+ "type": "ResultWithFolding"
3367
3367
  },
3368
3368
  {
3369
3369
  "name": "maximumPreviewSize",
@@ -3,7 +3,7 @@
3
3
  "experimentalDecorators": true,
4
4
  "baseUrl": ".",
5
5
  "checkJs": true,
6
- "target": "es2016",
6
+ "target": "es2023",
7
7
  "module": "esnext",
8
8
  "paths": {
9
9
  "c/exampleSearch": ["exampleSearch/exampleSearch"],
@@ -44,6 +44,8 @@ const exampleResult = {
44
44
  },
45
45
  title: 'abc',
46
46
  uniqueId: '123',
47
+ parentResult: {},
48
+ childResults: [],
47
49
  };
48
50
 
49
51
  const functionMocks = {
@@ -149,8 +151,13 @@ describe('c-quantic-result-quick-view', () => {
149
151
  await quickViewButton.click();
150
152
  await flushPromises();
151
153
 
154
+ // eslint-disable-next-line no-unused-vars
155
+ const {parentResult, childResults, ...expectedPayload} = exampleResult;
156
+
152
157
  expect(functionMocks.pushRecentResult).toHaveBeenCalledTimes(1);
153
- expect(functionMocks.pushRecentResult).toHaveBeenCalledWith(exampleResult);
158
+ expect(functionMocks.pushRecentResult).toHaveBeenCalledWith(
159
+ expectedPayload
160
+ );
154
161
  });
155
162
 
156
163
  describe('when the result has no preview', () => {
@@ -16,6 +16,13 @@ import {LightningElement, api, track} from 'lwc';
16
16
  /** @typedef {import("coveo").QuickviewState} QuickviewState */
17
17
  /** @typedef {import("coveo").SearchEngine} SearchEngine */
18
18
 
19
+ /**
20
+ * @typedef {Object} ResultWithFolding
21
+ * @mixes Result
22
+ * @property {Result} parentResult
23
+ * @property {Result[]} childResults
24
+ */
25
+
19
26
  /**
20
27
  * The `QuanticResultQuickview` component renders a button which the end user can click to open a modal box containing certain information about a result.
21
28
  * @category Result Template
@@ -33,7 +40,7 @@ export default class QuanticResultQuickview extends LightningElement {
33
40
  /**
34
41
  * The result to retrieve a quickview for.
35
42
  * @api
36
- * @type {Result}
43
+ * @type {ResultWithFolding}
37
44
  */
38
45
  @api result;
39
46
  /**
@@ -173,10 +180,11 @@ export default class QuanticResultQuickview extends LightningElement {
173
180
  this.engine
174
181
  );
175
182
 
176
- // Destructuring transforms the Proxy object created by Salesforce to a normal object so no unexpected behaviour will occur with the Headless library.
177
- this.engine.dispatch(
178
- pushRecentResult({...this.result, raw: {...this.result.raw}})
179
- );
183
+ // Exclude parentResult and childResults to prevent Salesforce Proxy extensibility errors.
184
+ // These nested result objects remain proxied after spreading, causing 'isExtensible' trap violations when accessed by the Headless library.
185
+ // eslint-disable-next-line no-unused-vars
186
+ const {parentResult, childResults, ...result} = this.result;
187
+ this.engine.dispatch(pushRecentResult({...result, raw: {...result.raw}}));
180
188
  }
181
189
 
182
190
  closeQuickview() {
@@ -987,6 +987,7 @@ export function getElementPadding(element) {
987
987
 
988
988
  /**
989
989
  * Returns the absolute height of an element.
990
+ * Uses getBoundingClientRect() to ensure synchronous layout calculation.
990
991
  * @param {Element} element
991
992
  * @returns {number} The absolute height of the element including padding.
992
993
  */
@@ -994,15 +995,15 @@ export function getAbsoluteHeight(element) {
994
995
  if (!element) {
995
996
  return 0;
996
997
  }
997
- const paddings = getElementPadding(element);
998
- const padding = paddings.top + paddings.bottom;
999
998
 
1000
- // @ts-ignore
1001
- return Math.ceil(element.offsetHeight + padding);
999
+ // Using getBoundingClientRect ensures accurate height measurements across all browsers, especially Safari.
1000
+ const elementBoundingRect = element.getBoundingClientRect();
1001
+ return Math.ceil(elementBoundingRect.height);
1002
1002
  }
1003
1003
 
1004
1004
  /**
1005
1005
  * Returns the absolute width of an element.
1006
+ * Uses getBoundingClientRect() to ensure synchronous layout calculation.
1006
1007
  * @param {Element} element
1007
1008
  * @returns {number} The absolute width of the element including padding.
1008
1009
  */
@@ -1010,9 +1011,8 @@ export function getAbsoluteWidth(element) {
1010
1011
  if (!element) {
1011
1012
  return 0;
1012
1013
  }
1013
- const paddings = getElementPadding(element);
1014
- const padding = paddings.left + paddings.right;
1015
1014
 
1016
- // @ts-ignore
1017
- return Math.ceil(element.offsetWidth + padding);
1015
+ // Using getBoundingClientRect ensures accurate width measurements across all browsers, especially Safari.
1016
+ const elementBoundingRect = element.getBoundingClientRect();
1017
+ return Math.ceil(elementBoundingRect.width);
1018
1018
  }