@coveo/atomic 3.34.0-pre.22510cc70c → 3.34.0-pre.272ceb1385

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 (43) hide show
  1. package/dist/atomic/_atomic.esm.js +1 -1
  2. package/dist/atomic/components/analytics-config.js +1 -1
  3. package/dist/atomic/components/atomic-quickview-modal2.js +22 -22
  4. package/dist/atomic/components/atomic-quickview-modal2.js.map +1 -1
  5. package/dist/atomic/components/components/commerce/atomic-commerce-breadbox/atomic-commerce-breadbox.js +17 -32
  6. package/dist/atomic/components/components/common/validate-props-controller/validate-props-controller.js +50 -0
  7. package/dist/atomic/components/components/search/atomic-search-interface/atomic-search-interface.js +6 -1
  8. package/dist/atomic/components/global/environment.js +1 -1
  9. package/dist/atomic/components/utils/compare-utils.js +49 -0
  10. package/dist/atomic/{p-86ca8ef9.entry.js → p-4f4c9a03.entry.js} +2 -2
  11. package/dist/atomic/p-4f4c9a03.entry.js.map +1 -0
  12. package/dist/atomic/{p-aa170b65.entry.js → p-5dc48246.entry.js} +2 -2
  13. package/dist/atomic/{p-4b736e32.js → p-6a7a4083.js} +2 -2
  14. package/dist/atomic/{p-59f1de55.entry.js → p-b362bf3b.entry.js} +2 -2
  15. package/dist/cjs/{analytics-config-9b8c3d9c.js → analytics-config-087f0a85.js} +2 -2
  16. package/dist/cjs/{analytics-config-9b8c3d9c.js.map → analytics-config-087f0a85.js.map} +1 -1
  17. package/dist/cjs/atomic-insight-interface.cjs.entry.js +1 -1
  18. package/dist/cjs/atomic-quickview-modal.cjs.entry.js +22 -22
  19. package/dist/cjs/atomic-quickview-modal.cjs.entry.js.map +1 -1
  20. package/dist/cjs/atomic-recs-interface.cjs.entry.js +1 -1
  21. package/dist/cjs/version.cjs.js +1 -1
  22. package/dist/esm/{analytics-config-8eeb9e21.js → analytics-config-f7948e22.js} +2 -2
  23. package/dist/esm/{analytics-config-8eeb9e21.js.map → analytics-config-f7948e22.js.map} +1 -1
  24. package/dist/esm/atomic-insight-interface.entry.js +1 -1
  25. package/dist/esm/atomic-quickview-modal.entry.js +22 -22
  26. package/dist/esm/atomic-quickview-modal.entry.js.map +1 -1
  27. package/dist/esm/atomic-recs-interface.entry.js +1 -1
  28. package/dist/esm/version.js +1 -1
  29. package/dist/types/components/commerce/atomic-commerce-breadbox/atomic-commerce-breadbox.d.ts +2 -3
  30. package/dist/types/components/common/facets/facet-search/facet-search-input-guard.d.ts +1 -1
  31. package/dist/types/components/common/no-items/guard.d.ts +1 -1
  32. package/dist/types/components/common/refine-modal/guard.d.ts +1 -1
  33. package/dist/types/components/common/sort/sort-guard.d.ts +1 -1
  34. package/dist/types/components/common/validate-props-controller/validate-props-controller.d.ts +32 -0
  35. package/dist/types/components/search/atomic-search-interface/atomic-search-interface.d.ts +1 -0
  36. package/dist/types/directives/hierarchical-path.d.ts +1 -1
  37. package/dist/types/utils/compare-utils.d.ts +9 -0
  38. package/docs/atomic-docs.json +1 -1
  39. package/package.json +1 -1
  40. package/dist/atomic/p-86ca8ef9.entry.js.map +0 -1
  41. /package/dist/atomic/{p-aa170b65.entry.js.map → p-5dc48246.entry.js.map} +0 -0
  42. /package/dist/atomic/{p-4b736e32.js.map → p-6a7a4083.js.map} +0 -0
  43. /package/dist/atomic/{p-59f1de55.entry.js.map → p-b362bf3b.entry.js.map} +0 -0
@@ -8,6 +8,15 @@ import { NumberValue, Schema } from '@coveo/bueno';
8
8
  import { buildContext, buildProductListing, buildSearch, } from '@coveo/headless/commerce';
9
9
  import { html, LitElement, nothing } from 'lit';
10
10
  import { customElement, property, state } from 'lit/decorators.js';
11
+ import { renderBreadcrumbButton } from "../../common/breadbox/breadcrumb-button";
12
+ import { renderBreadcrumbClearAll } from "../../common/breadbox/breadcrumb-clear-all";
13
+ import { renderBreadcrumbContainer } from "../../common/breadbox/breadcrumb-container";
14
+ import { renderBreadcrumbContent } from "../../common/breadbox/breadcrumb-content";
15
+ import { renderBreadcrumbShowLess } from "../../common/breadbox/breadcrumb-show-less";
16
+ import { renderBreadcrumbShowMore } from "../../common/breadbox/breadcrumb-show-more";
17
+ import { formatHumanReadable } from "../../common/facets/numeric-facet/formatter";
18
+ import { defaultCurrencyFormatter, defaultNumberFormatter, } from "../../common/formats/format-common";
19
+ import { ValidatePropsController } from "../../common/validate-props-controller/validate-props-controller";
11
20
  import { bindStateToController } from "../../../decorators/bind-state";
12
21
  import { bindingGuard } from "../../../decorators/binding-guard";
13
22
  import { bindings } from "../../../decorators/bindings";
@@ -16,14 +25,6 @@ import { withTailwindStyles } from "../../../decorators/with-tailwind-styles.js"
16
25
  import { FocusTargetController } from "../../../utils/accessibility-utils";
17
26
  import { parseDate } from "../../../utils/date-utils";
18
27
  import { getFieldValueCaption } from "../../../utils/field-utils";
19
- import { renderBreadcrumbButton } from '../../common/breadbox/breadcrumb-button';
20
- import { renderBreadcrumbClearAll } from '../../common/breadbox/breadcrumb-clear-all';
21
- import { renderBreadcrumbContainer } from '../../common/breadbox/breadcrumb-container';
22
- import { renderBreadcrumbContent } from '../../common/breadbox/breadcrumb-content';
23
- import { renderBreadcrumbShowLess } from '../../common/breadbox/breadcrumb-show-less';
24
- import { renderBreadcrumbShowMore } from '../../common/breadbox/breadcrumb-show-more';
25
- import { formatHumanReadable } from '../../common/facets/numeric-facet/formatter';
26
- import { defaultCurrencyFormatter, defaultNumberFormatter, } from '../../common/formats/format-common';
27
28
  import styles from './atomic-commerce-breadbox.tw.css';
28
29
  /**
29
30
  * The `atomic-commerce-breadbox` component creates breadcrumbs that display a summary of the currently active facet values.
@@ -42,7 +43,7 @@ import styles from './atomic-commerce-breadbox.tw.css';
42
43
  */
43
44
  let AtomicCommerceBreadbox = class AtomicCommerceBreadbox extends LitElement {
44
45
  constructor() {
45
- super(...arguments);
46
+ super();
46
47
  this.lastRemovedBreadcrumbIndex = 0;
47
48
  this.numberOfBreadcrumbs = 0;
48
49
  this.numberOfCollapsedBreadcrumbs = 0;
@@ -96,9 +97,15 @@ let AtomicCommerceBreadbox = class AtomicCommerceBreadbox extends LitElement {
96
97
  }
97
98
  }
98
99
  };
100
+ new ValidatePropsController(this, () => ({ pathLimit: this.pathLimit }), new Schema({
101
+ pathLimit: new NumberValue({
102
+ default: 3,
103
+ min: 1,
104
+ required: false,
105
+ }),
106
+ }));
99
107
  }
100
108
  initialize() {
101
- this.validateProps();
102
109
  if (this.bindings.interfaceElement.type === 'product-listing') {
103
110
  this.searchOrListing = buildProductListing(this.bindings.engine);
104
111
  }
@@ -115,31 +122,9 @@ let AtomicCommerceBreadbox = class AtomicCommerceBreadbox extends LitElement {
115
122
  this.breadcrumbShowMoreFocus = new FocusTargetController(this, this.bindings);
116
123
  this.breadcrumbShowLessFocus = new FocusTargetController(this, this.bindings);
117
124
  }
118
- willUpdate(changedProperties) {
119
- if (changedProperties.has('pathLimit')) {
120
- this.validateProps();
121
- }
122
- }
123
125
  updated() {
124
126
  this.adaptBreadcrumbs();
125
127
  }
126
- validateProps() {
127
- try {
128
- new Schema({
129
- pathLimit: new NumberValue({
130
- default: 3,
131
- min: 1,
132
- required: false,
133
- }),
134
- }).validate({
135
- pathLimit: this.pathLimit,
136
- });
137
- }
138
- catch (error) {
139
- this.error = error;
140
- return;
141
- }
142
- }
143
128
  disconnectedCallback() {
144
129
  this.resizeObserver?.disconnect();
145
130
  }
@@ -0,0 +1,50 @@
1
+ import { deepEqual } from "../../../utils/compare-utils";
2
+ /**
3
+ * A reactive controller that validates the props of a Lit component against a
4
+ * provided Bueno schema.
5
+ *
6
+ * It validates the props when the host is connected to the DOM and whenever
7
+ * the host updates, revalidating only if the props have changed since the last
8
+ * validation.
9
+ *
10
+ * If validation fails, the controller sets the `error` property on the host.
11
+ */
12
+ export class ValidatePropsController {
13
+ /**
14
+ * Creates a `ValidatePropsController`.
15
+ *
16
+ * @param host The host element.
17
+ * @param getProps A function that returns the current props to validate.
18
+ * @param schema The Bueno schema to validate the props against.
19
+ */
20
+ constructor(host, getProps, schema) {
21
+ this.host = host;
22
+ this.getProps = getProps;
23
+ this.schema = schema;
24
+ host.addController(this);
25
+ }
26
+ hostConnected() {
27
+ this.currentProps = this.getProps();
28
+ this._validateProps();
29
+ }
30
+ hostUpdate() {
31
+ this.currentProps = this.getProps();
32
+ if (deepEqual(this.currentProps, this.previousProps)) {
33
+ return;
34
+ }
35
+ // @ts-expect-error: we need to clear the error.
36
+ this.host.error = undefined;
37
+ this._validateProps();
38
+ }
39
+ _validateProps() {
40
+ try {
41
+ this.schema.validate(this.currentProps);
42
+ }
43
+ catch (error) {
44
+ this.host.error = error;
45
+ }
46
+ finally {
47
+ this.previousProps = this.currentProps;
48
+ }
49
+ }
50
+ }
@@ -123,7 +123,7 @@ let AtomicSearchInterface = class AtomicSearchInterface extends ChildrenUpdateCo
123
123
  willUpdate(changedProperties) {
124
124
  super.willUpdate(changedProperties);
125
125
  if (changedProperties.has('fieldsToInclude')) {
126
- this.initFieldsToInclude();
126
+ this.updateFieldsToInclude();
127
127
  }
128
128
  }
129
129
  disconnectedCallback() {
@@ -256,6 +256,11 @@ let AtomicSearchInterface = class AtomicSearchInterface extends ChildrenUpdateCo
256
256
  const fields = EcommerceDefaultFieldsToInclude.concat(this.fieldsToInclude);
257
257
  this.store.addFieldsToInclude(fields);
258
258
  }
259
+ updateFieldsToInclude() {
260
+ this.store.state.fieldsToInclude = [];
261
+ this.initFieldsToInclude();
262
+ this.registerFieldsToInclude();
263
+ }
259
264
  registerFieldsToInclude() {
260
265
  this.engine?.dispatch(loadFieldActions(this.engine).registerFieldsToInclude(this.store.state.fieldsToInclude));
261
266
  }
@@ -3,7 +3,7 @@ function getWindow() {
3
3
  }
4
4
  export function getAtomicEnvironment(headlessVersion) {
5
5
  return {
6
- version: "3.34.0-pre.22510cc70c",
6
+ version: "3.34.0-pre.272ceb1385",
7
7
  headlessVersion,
8
8
  };
9
9
  }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Performs a deep equality comparison between two values.
3
+ * Handles primitives, null/undefined, arrays, and objects.
4
+ *
5
+ * @param a - First value to compare
6
+ * @param b - Second value to compare
7
+ * @returns true if values are deeply equal, false otherwise
8
+ */
9
+ export function deepEqual(a, b) {
10
+ if (a === b) {
11
+ return true;
12
+ }
13
+ if (a == null || b == null) {
14
+ return false;
15
+ }
16
+ const typeA = typeof a;
17
+ const typeB = typeof b;
18
+ if (typeA !== typeB) {
19
+ return false;
20
+ }
21
+ if (Array.isArray(a)) {
22
+ if (!Array.isArray(b) || a.length !== b.length) {
23
+ return false;
24
+ }
25
+ for (let i = 0; i < a.length; i++) {
26
+ if (!deepEqual(a[i], b[i])) {
27
+ return false;
28
+ }
29
+ }
30
+ return true;
31
+ }
32
+ if (typeA === 'object') {
33
+ const aObj = a;
34
+ const bObj = b;
35
+ const aKeys = Object.keys(aObj);
36
+ const bKeys = Object.keys(bObj);
37
+ if (aKeys.length !== bKeys.length) {
38
+ return false;
39
+ }
40
+ for (let i = 0; i < aKeys.length; i++) {
41
+ const key = aKeys[i];
42
+ if (!deepEqual(aObj[key], bObj[key])) {
43
+ return false;
44
+ }
45
+ }
46
+ return true;
47
+ }
48
+ return false;
49
+ }