@coveo/atomic 3.34.0-pre.1ad38ff1e4 → 3.34.0-pre.22510cc70c
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.
- package/dist/atomic/_atomic.esm.js +1 -1
- package/dist/atomic/atomic.esm.js.map +1 -1
- package/dist/atomic/components/_index.d.ts +0 -2
- package/dist/atomic/components/_index.js +0 -1
- package/dist/atomic/components/analytics-config.js +1 -1
- package/dist/atomic/components/atomic-category-facet.js +1 -1
- package/dist/atomic/components/atomic-facet.js +1 -1
- package/dist/atomic/components/atomic-format-currency.js +1 -1
- package/dist/atomic/components/atomic-format-number.js +1 -1
- package/dist/atomic/components/atomic-format-unit.js +1 -1
- package/dist/atomic/components/atomic-numeric-facet.js +1 -1
- package/dist/atomic/components/atomic-quickview-modal2.js +1 -1
- package/dist/atomic/components/atomic-quickview.js +1 -1
- package/dist/atomic/components/atomic-result-children.js +1 -1
- package/dist/atomic/components/atomic-result-fields-list.js +1 -1
- package/dist/atomic/components/atomic-result-link.js +1 -1
- package/dist/atomic/components/atomic-result-list.js +1 -1
- package/dist/atomic/components/atomic-result-table-placeholder2.js +1 -1
- package/dist/atomic/components/atomic-search-box-query-suggestions2.js +1 -1
- package/dist/atomic/components/atomic-search-box-recent-queries2.js +1 -1
- package/dist/atomic/components/atomic-search-box.js +3 -3
- package/dist/atomic/components/atomic-smart-snippet-feedback-modal2.js +2 -2
- package/dist/atomic/components/atomic-sort-dropdown.js +2 -2
- package/dist/atomic/components/atomic-sort-expression.js +1 -1
- package/dist/atomic/components/atomic-tab-manager.js +1 -1
- package/dist/atomic/components/components/commerce/atomic-product/atomic-product.js +56 -41
- package/dist/atomic/components/components/search/atomic-relevance-inspector/atomic-relevance-inspector.js +100 -0
- package/dist/atomic/components/components/search/atomic-search-interface/atomic-search-interface.js +11 -23
- package/dist/atomic/components/components/search/index.js +1 -0
- package/dist/atomic/components/components/search/lazy-index.js +1 -0
- package/dist/atomic/components/global/environment.js +1 -1
- package/dist/atomic/components/index.js.map +1 -1
- package/dist/atomic/{p-475124d2.entry.js → p-01511388.entry.js} +2 -2
- package/dist/atomic/{p-60800b2f.entry.js → p-0ed76e65.entry.js} +2 -2
- package/dist/atomic/{p-16f6c1f3.entry.js → p-2fb49fe8.entry.js} +2 -2
- package/dist/atomic/{p-13391e75.entry.js → p-3549a469.entry.js} +2 -2
- package/dist/atomic/{p-1b364176.js → p-4b736e32.js} +2 -2
- package/dist/atomic/{p-0c5fff04.entry.js → p-59f1de55.entry.js} +2 -2
- package/dist/atomic/{p-7ec6dd3e.entry.js → p-65dd9017.entry.js} +2 -2
- package/dist/atomic/{p-86bde026.entry.js → p-736f4d7e.entry.js} +2 -2
- package/dist/atomic/{p-3cbab25b.entry.js → p-7e971d15.entry.js} +2 -2
- package/dist/atomic/{p-4601eb93.entry.js → p-83d3857f.entry.js} +2 -2
- package/dist/atomic/{p-7c3c5f07.entry.js → p-86ca8ef9.entry.js} +2 -2
- package/dist/atomic/{p-dbcef3a9.entry.js → p-87f69e53.entry.js} +2 -2
- package/dist/atomic/{p-88af4470.entry.js → p-8bf425b0.entry.js} +2 -2
- package/dist/atomic/{p-8c47cfdb.entry.js → p-aa170b65.entry.js} +2 -2
- package/dist/atomic/{p-e398835b.entry.js → p-b2b9e83f.entry.js} +2 -2
- package/dist/atomic/{p-8fdef8a3.entry.js → p-b313058c.entry.js} +2 -2
- package/dist/atomic/{p-0bdd730f.entry.js → p-b6ae0244.entry.js} +2 -2
- package/dist/atomic/{p-3a7a1a00.entry.js → p-bbfe727a.entry.js} +2 -2
- package/dist/atomic/{p-97ce3384.entry.js → p-be2a43f4.entry.js} +2 -2
- package/dist/atomic/{p-a5714bc4.entry.js → p-d211a422.entry.js} +2 -2
- package/dist/atomic/{p-20764605.entry.js → p-d82b85ab.entry.js} +2 -2
- package/dist/atomic/{p-df4397ab.entry.js → p-ea1b81fa.entry.js} +2 -2
- package/dist/cjs/_loader.cjs.js +1 -1
- package/dist/cjs/{analytics-config-83f4fb5d.js → analytics-config-9b8c3d9c.js} +2 -2
- package/dist/cjs/{analytics-config-83f4fb5d.js.map → analytics-config-9b8c3d9c.js.map} +1 -1
- package/dist/cjs/atomic-category-facet.cjs.entry.js +1 -1
- package/dist/cjs/atomic-facet.cjs.entry.js +1 -1
- package/dist/cjs/atomic-format-currency.cjs.entry.js +1 -1
- package/dist/cjs/atomic-format-number.cjs.entry.js +1 -1
- package/dist/cjs/atomic-format-unit.cjs.entry.js +1 -1
- package/dist/cjs/atomic-insight-interface.cjs.entry.js +1 -1
- package/dist/cjs/atomic-numeric-facet.cjs.entry.js +1 -1
- package/dist/cjs/atomic-quickview-modal.cjs.entry.js +1 -1
- package/dist/cjs/atomic-quickview.cjs.entry.js +1 -1
- package/dist/cjs/atomic-recs-interface.cjs.entry.js +1 -1
- package/dist/cjs/atomic-result-children.cjs.entry.js +1 -1
- package/dist/cjs/atomic-result-fields-list.cjs.entry.js +1 -1
- package/dist/cjs/atomic-result-link.cjs.entry.js +1 -1
- package/dist/cjs/atomic-result-list.cjs.entry.js +1 -1
- package/dist/cjs/atomic-result-placeholder_8.cjs.entry.js +1 -1
- package/dist/cjs/atomic-search-box-query-suggestions_2.cjs.entry.js +2 -2
- package/dist/cjs/atomic-search-box.cjs.entry.js +3 -3
- package/dist/cjs/atomic-smart-snippet-feedback-modal.cjs.entry.js +2 -2
- package/dist/cjs/atomic-sort-dropdown.cjs.entry.js +2 -2
- package/dist/cjs/atomic-sort-expression.cjs.entry.js +1 -1
- package/dist/cjs/atomic-tab-manager.cjs.entry.js +1 -1
- package/dist/cjs/atomic.cjs.js +1 -1
- package/dist/cjs/index-757bc886.js +0 -4
- package/dist/cjs/version.cjs.js +1 -1
- package/dist/esm/_loader.js +1 -1
- package/dist/esm/{analytics-config-b6bd56be.js → analytics-config-8eeb9e21.js} +2 -2
- package/dist/esm/{analytics-config-b6bd56be.js.map → analytics-config-8eeb9e21.js.map} +1 -1
- package/dist/esm/atomic-category-facet.entry.js +1 -1
- package/dist/esm/atomic-facet.entry.js +1 -1
- package/dist/esm/atomic-format-currency.entry.js +1 -1
- package/dist/esm/atomic-format-number.entry.js +1 -1
- package/dist/esm/atomic-format-unit.entry.js +1 -1
- package/dist/esm/atomic-insight-interface.entry.js +1 -1
- package/dist/esm/atomic-numeric-facet.entry.js +1 -1
- package/dist/esm/atomic-quickview-modal.entry.js +1 -1
- package/dist/esm/atomic-quickview.entry.js +1 -1
- package/dist/esm/atomic-recs-interface.entry.js +1 -1
- package/dist/esm/atomic-result-children.entry.js +1 -1
- package/dist/esm/atomic-result-fields-list.entry.js +1 -1
- package/dist/esm/atomic-result-link.entry.js +1 -1
- package/dist/esm/atomic-result-list.entry.js +1 -1
- package/dist/esm/atomic-result-placeholder_8.entry.js +1 -1
- package/dist/esm/atomic-search-box-query-suggestions_2.entry.js +2 -2
- package/dist/esm/atomic-search-box.entry.js +3 -3
- package/dist/esm/atomic-smart-snippet-feedback-modal.entry.js +2 -2
- package/dist/esm/atomic-sort-dropdown.entry.js +2 -2
- package/dist/esm/atomic-sort-expression.entry.js +1 -1
- package/dist/esm/atomic-tab-manager.entry.js +1 -1
- package/dist/esm/atomic.js +1 -1
- package/dist/esm/index-3f35faca.js +0 -4
- package/dist/esm/version.js +1 -1
- package/dist/types/components/commerce/atomic-product/atomic-product.d.ts +13 -10
- package/dist/types/components/search/atomic-relevance-inspector/atomic-relevance-inspector.d.ts +18 -8
- package/dist/types/components/search/atomic-search-interface/atomic-search-interface.d.ts +5 -3
- package/dist/types/components/search/index.d.ts +1 -0
- package/dist/types/components.d.ts +0 -53
- package/docs/atomic-docs.json +1 -88
- package/package.json +1 -1
- package/dist/atomic/components/atomic-relevance-inspector.d.ts +0 -11
- package/dist/atomic/components/atomic-relevance-inspector.js +0 -53
- package/dist/atomic/components/atomic-relevance-inspector.js.map +0 -1
- package/dist/atomic/components/components/common/layout/custom-render-controller.js +0 -48
- package/dist/atomic/components/components/common/layout/item-layout-controller.js +0 -105
- package/dist/atomic/p-de687bed.entry.js +0 -2
- package/dist/atomic/p-de687bed.entry.js.map +0 -1
- package/dist/cjs/atomic-relevance-inspector.cjs.entry.js +0 -38
- package/dist/cjs/atomic-relevance-inspector.cjs.entry.js.map +0 -1
- package/dist/esm/atomic-relevance-inspector.entry.js +0 -34
- package/dist/esm/atomic-relevance-inspector.entry.js.map +0 -1
- package/dist/types/components/common/layout/custom-render-controller.d.ts +0 -28
- package/dist/types/components/common/layout/item-layout-controller.d.ts +0 -46
- /package/dist/atomic/{p-475124d2.entry.js.map → p-01511388.entry.js.map} +0 -0
- /package/dist/atomic/{p-60800b2f.entry.js.map → p-0ed76e65.entry.js.map} +0 -0
- /package/dist/atomic/{p-16f6c1f3.entry.js.map → p-2fb49fe8.entry.js.map} +0 -0
- /package/dist/atomic/{p-13391e75.entry.js.map → p-3549a469.entry.js.map} +0 -0
- /package/dist/atomic/{p-1b364176.js.map → p-4b736e32.js.map} +0 -0
- /package/dist/atomic/{p-0c5fff04.entry.js.map → p-59f1de55.entry.js.map} +0 -0
- /package/dist/atomic/{p-7ec6dd3e.entry.js.map → p-65dd9017.entry.js.map} +0 -0
- /package/dist/atomic/{p-86bde026.entry.js.map → p-736f4d7e.entry.js.map} +0 -0
- /package/dist/atomic/{p-3cbab25b.entry.js.map → p-7e971d15.entry.js.map} +0 -0
- /package/dist/atomic/{p-4601eb93.entry.js.map → p-83d3857f.entry.js.map} +0 -0
- /package/dist/atomic/{p-7c3c5f07.entry.js.map → p-86ca8ef9.entry.js.map} +0 -0
- /package/dist/atomic/{p-dbcef3a9.entry.js.map → p-87f69e53.entry.js.map} +0 -0
- /package/dist/atomic/{p-88af4470.entry.js.map → p-8bf425b0.entry.js.map} +0 -0
- /package/dist/atomic/{p-8c47cfdb.entry.js.map → p-aa170b65.entry.js.map} +0 -0
- /package/dist/atomic/{p-e398835b.entry.js.map → p-b2b9e83f.entry.js.map} +0 -0
- /package/dist/atomic/{p-8fdef8a3.entry.js.map → p-b313058c.entry.js.map} +0 -0
- /package/dist/atomic/{p-0bdd730f.entry.js.map → p-b6ae0244.entry.js.map} +0 -0
- /package/dist/atomic/{p-3a7a1a00.entry.js.map → p-bbfe727a.entry.js.map} +0 -0
- /package/dist/atomic/{p-97ce3384.entry.js.map → p-be2a43f4.entry.js.map} +0 -0
- /package/dist/atomic/{p-a5714bc4.entry.js.map → p-d211a422.entry.js.map} +0 -0
- /package/dist/atomic/{p-20764605.entry.js.map → p-d82b85ab.entry.js.map} +0 -0
- /package/dist/atomic/{p-df4397ab.entry.js.map → p-ea1b81fa.entry.js.map} +0 -0
@@ -8,8 +8,7 @@ import { html, LitElement } from 'lit';
|
|
8
8
|
import { customElement, property } from 'lit/decorators.js';
|
9
9
|
import { ref } from 'lit/directives/ref.js';
|
10
10
|
import { resultComponentClass, } from "../../common/item-list/item-list-common";
|
11
|
-
import {
|
12
|
-
import { ItemLayoutController } from "../../common/layout/item-layout-controller";
|
11
|
+
import { ItemLayout, } from "../../common/layout/display-options";
|
13
12
|
import { booleanConverter } from "../../../converters/boolean-converter";
|
14
13
|
import { withTailwindStyles } from "../../../decorators/with-tailwind-styles";
|
15
14
|
import { ChildrenUpdateCompleteMixin } from "../../../mixins/children-update-complete-mixin";
|
@@ -21,6 +20,7 @@ import styles from './atomic-product.tw.css';
|
|
21
20
|
let AtomicProduct = class AtomicProduct extends ChildrenUpdateCompleteMixin(LitElement) {
|
22
21
|
constructor() {
|
23
22
|
super(...arguments);
|
23
|
+
this.executedRenderingFunctionOnce = false;
|
24
24
|
/**
|
25
25
|
* The product link to use when the product is clicked in a grid layout.
|
26
26
|
*
|
@@ -45,13 +45,6 @@ let AtomicProduct = class AtomicProduct extends ChildrenUpdateCompleteMixin(LitE
|
|
45
45
|
* The classes to add to the product element.
|
46
46
|
*/
|
47
47
|
this.classes = '';
|
48
|
-
/**
|
49
|
-
* Whether to automatically apply layout classes to rendered elements when using a custom rendering function.
|
50
|
-
* When disabled, the component will automatically find and apply layout classes to child elements with 'atomic-product-' prefixes.
|
51
|
-
*
|
52
|
-
* @internal
|
53
|
-
*/
|
54
|
-
this.disableLayoutClassesForCustomRender = false;
|
55
48
|
this.resolveProduct = (event) => {
|
56
49
|
event.preventDefault();
|
57
50
|
event.stopPropagation();
|
@@ -91,27 +84,11 @@ let AtomicProduct = class AtomicProduct extends ChildrenUpdateCompleteMixin(LitE
|
|
91
84
|
}
|
92
85
|
async connectedCallback() {
|
93
86
|
super.connectedCallback();
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
onRenderComplete: (element, output) => {
|
100
|
-
this.itemLayoutController.applyLayoutClassesToElement(element, output);
|
101
|
-
},
|
102
|
-
});
|
103
|
-
this.itemLayoutController = new ItemLayoutController(this, {
|
104
|
-
elementPrefix: 'atomic-product',
|
105
|
-
hasCustomRenderFunction: () => this.customRenderController.hasCustomRenderFunction,
|
106
|
-
disableLayoutClassesForCustomRender: () => this.disableLayoutClassesForCustomRender,
|
107
|
-
content: () => this.content,
|
108
|
-
layoutConfig: () => ({
|
109
|
-
display: this.display,
|
110
|
-
density: this.density,
|
111
|
-
imageSize: this.imageSize,
|
112
|
-
}),
|
113
|
-
itemClasses: () => this.classes,
|
114
|
-
});
|
87
|
+
if (!this.content) {
|
88
|
+
console.warn('AtomicProduct: content property is undefined. Cannot create layout.', this);
|
89
|
+
return;
|
90
|
+
}
|
91
|
+
this.layout = new ItemLayout(this.content.children, this.display, this.density, this.imageSize);
|
115
92
|
this.addEventListener('atomic/resolveResult', this.resolveProduct);
|
116
93
|
this.addEventListener('atomic/resolveInteractiveResult', this.resolveInteractiveProduct);
|
117
94
|
this.addEventListener('atomic/resolveStopPropagation', this.resolveStopPropagation);
|
@@ -128,9 +105,12 @@ let AtomicProduct = class AtomicProduct extends ChildrenUpdateCompleteMixin(LitE
|
|
128
105
|
this.removeEventListener('atomic/resolveResultDisplayConfig', this.resolveProductDisplayConfig);
|
129
106
|
this.removeEventListener('click', this.handleClick);
|
130
107
|
}
|
108
|
+
get isCustomRenderFunctionMode() {
|
109
|
+
return this.renderingFunction !== undefined;
|
110
|
+
}
|
131
111
|
getContentHTML() {
|
132
112
|
if (!this.content) {
|
133
|
-
console.warn('
|
113
|
+
console.warn('AtomicProduct: content property is undefined. Cannot get content HTML.', this);
|
134
114
|
return '';
|
135
115
|
}
|
136
116
|
return parentNodeToString(this.content);
|
@@ -138,8 +118,13 @@ let AtomicProduct = class AtomicProduct extends ChildrenUpdateCompleteMixin(LitE
|
|
138
118
|
getLinkHTML() {
|
139
119
|
return parentNodeToString(this.linkContent ?? new HTMLElement());
|
140
120
|
}
|
121
|
+
shouldExecuteRenderFunction() {
|
122
|
+
return (this.isCustomRenderFunctionMode &&
|
123
|
+
this.productRootRef &&
|
124
|
+
!this.executedRenderingFunctionOnce);
|
125
|
+
}
|
141
126
|
render() {
|
142
|
-
if (this.
|
127
|
+
if (this.isCustomRenderFunctionMode) {
|
143
128
|
return html `
|
144
129
|
<div class=${resultComponentClass}>
|
145
130
|
<div
|
@@ -158,13 +143,16 @@ let AtomicProduct = class AtomicProduct extends ChildrenUpdateCompleteMixin(LitE
|
|
158
143
|
`;
|
159
144
|
}
|
160
145
|
// Handle case where content is undefined and layout was not created
|
161
|
-
if (!this.
|
146
|
+
if (!this.layout) {
|
162
147
|
return html `<div class=${resultComponentClass}></div>`;
|
163
148
|
}
|
164
149
|
return html `
|
165
150
|
<div class=${resultComponentClass}>
|
166
151
|
<div
|
167
|
-
class="result-root ${this.
|
152
|
+
class="result-root ${this.layout
|
153
|
+
.getClasses()
|
154
|
+
.concat(this.classes)
|
155
|
+
.join(' ')}"
|
168
156
|
.innerHTML=${this.getContentHTML()}
|
169
157
|
></div>
|
170
158
|
<div class="link-container" .innerHTML=${this.getLinkHTML()}></div>
|
@@ -176,8 +164,41 @@ let AtomicProduct = class AtomicProduct extends ChildrenUpdateCompleteMixin(LitE
|
|
176
164
|
this.store.unsetLoadingFlag(this.loadingFlag);
|
177
165
|
}
|
178
166
|
}
|
167
|
+
getCombinedClasses(additionalContent) {
|
168
|
+
const layoutClasses = this.layout
|
169
|
+
? this.layout.getClasses(additionalContent)
|
170
|
+
: [];
|
171
|
+
const extraClasses = this.classes.split(/\s+/).filter((c) => c);
|
172
|
+
return [...layoutClasses, ...extraClasses];
|
173
|
+
}
|
174
|
+
applyClassesToChildren() {
|
175
|
+
if (!this.layout) {
|
176
|
+
return;
|
177
|
+
}
|
178
|
+
const classes = this.getCombinedClasses();
|
179
|
+
const root = this.shadowRoot?.querySelector('.result-root');
|
180
|
+
if (!root) {
|
181
|
+
return;
|
182
|
+
}
|
183
|
+
root.querySelectorAll('*').forEach((el) => {
|
184
|
+
const tag = el.tagName.toLowerCase();
|
185
|
+
if (tag.startsWith('atomic-product-')) {
|
186
|
+
el.classList.add(...classes);
|
187
|
+
}
|
188
|
+
});
|
189
|
+
}
|
179
190
|
updated(_changedProperties) {
|
180
|
-
|
191
|
+
if (this.shouldExecuteRenderFunction()) {
|
192
|
+
const customRenderOutputAsString = this.renderingFunction(this.product, this.productRootRef, this.linkContainerRef);
|
193
|
+
if (this.layout) {
|
194
|
+
const classes = this.getCombinedClasses(customRenderOutputAsString);
|
195
|
+
this.productRootRef.classList.add(...classes);
|
196
|
+
}
|
197
|
+
this.executedRenderingFunctionOnce = true;
|
198
|
+
}
|
199
|
+
if (!this.isCustomRenderFunctionMode) {
|
200
|
+
this.applyClassesToChildren();
|
201
|
+
}
|
181
202
|
}
|
182
203
|
};
|
183
204
|
AtomicProduct.styles = styles;
|
@@ -222,12 +243,6 @@ __decorate([
|
|
222
243
|
__decorate([
|
223
244
|
property({ type: Object, attribute: 'rendering-function' })
|
224
245
|
], AtomicProduct.prototype, "renderingFunction", void 0);
|
225
|
-
__decorate([
|
226
|
-
property({
|
227
|
-
attribute: 'disable-layout-classes-for-custom-render',
|
228
|
-
type: Boolean,
|
229
|
-
})
|
230
|
-
], AtomicProduct.prototype, "disableLayoutClassesForCustomRender", void 0);
|
231
246
|
AtomicProduct = __decorate([
|
232
247
|
customElement('atomic-product'),
|
233
248
|
withTailwindStyles
|
@@ -0,0 +1,100 @@
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
|
+
};
|
7
|
+
import { getOrganizationEndpoint } from '@coveo/headless';
|
8
|
+
import { html, LitElement, nothing } from 'lit';
|
9
|
+
import { customElement, state } from 'lit/decorators.js';
|
10
|
+
import { renderButton } from "../../common/button";
|
11
|
+
import { withTailwindStyles } from "../../../decorators/with-tailwind-styles.js";
|
12
|
+
import "../../common/atomic-modal/atomic-modal";
|
13
|
+
import { bindingGuard } from "../../../decorators/binding-guard";
|
14
|
+
import { bindings } from "../../../decorators/bindings";
|
15
|
+
import { errorGuard } from "../../../decorators/error-guard";
|
16
|
+
/**
|
17
|
+
* The `atomic-relevance-inspector` component is used internally to offer insight on search page relevance, as well as information to help troubleshoot issues during development.
|
18
|
+
*
|
19
|
+
* @internal
|
20
|
+
*/
|
21
|
+
let AtomicRelevanceInspector = class AtomicRelevanceInspector extends LitElement {
|
22
|
+
constructor() {
|
23
|
+
super(...arguments);
|
24
|
+
this.open = false;
|
25
|
+
this.initialize = () => {
|
26
|
+
this.bindings.interfaceElement.addEventListener('dblclick', this.handleRelevanceInspectorDoubleClick);
|
27
|
+
};
|
28
|
+
this.handleRelevanceInspectorDoubleClick = (e) => {
|
29
|
+
if (e.altKey) {
|
30
|
+
this.open = !this.open;
|
31
|
+
}
|
32
|
+
};
|
33
|
+
}
|
34
|
+
disconnectedCallback() {
|
35
|
+
this.bindings.interfaceElement.removeEventListener('dblclick', this.handleRelevanceInspectorDoubleClick);
|
36
|
+
}
|
37
|
+
render() {
|
38
|
+
return html `
|
39
|
+
<atomic-modal
|
40
|
+
.isOpen=${this.open}
|
41
|
+
@close=${() => this.handleCloseRelevanceInspector()}
|
42
|
+
exportparts="footer"
|
43
|
+
>
|
44
|
+
<p slot="header">Open the relevance inspector</p>
|
45
|
+
<p slot="body">
|
46
|
+
The Relevance Inspector will open in the Coveo Administration Console.
|
47
|
+
</p>
|
48
|
+
<div slot="footer" class="flex w-full items-center justify-end">
|
49
|
+
${renderButton({
|
50
|
+
props: {
|
51
|
+
style: 'outline-primary',
|
52
|
+
class: 'mr-2 p-2',
|
53
|
+
onClick: () => this.handleCloseRelevanceInspector(),
|
54
|
+
text: 'Ignore',
|
55
|
+
},
|
56
|
+
})(nothing)}
|
57
|
+
${renderButton({
|
58
|
+
props: {
|
59
|
+
style: 'primary',
|
60
|
+
class: 'p-2',
|
61
|
+
onClick: () => {
|
62
|
+
window.open(this.adminHref, '_blank');
|
63
|
+
this.handleCloseRelevanceInspector();
|
64
|
+
},
|
65
|
+
text: 'Open',
|
66
|
+
},
|
67
|
+
})(nothing)}
|
68
|
+
</div>
|
69
|
+
</atomic-modal>
|
70
|
+
`;
|
71
|
+
}
|
72
|
+
handleCloseRelevanceInspector() {
|
73
|
+
this.open = false;
|
74
|
+
}
|
75
|
+
get adminHref() {
|
76
|
+
const { organizationId, environment } = this.bindings.engine.state.configuration;
|
77
|
+
const admin = getOrganizationEndpoint(organizationId, environment, 'admin');
|
78
|
+
const { searchResponseId } = this.bindings.engine.state.search;
|
79
|
+
return `${admin}/admin/#/${organizationId}/search/relevanceInspector/${searchResponseId}`;
|
80
|
+
}
|
81
|
+
};
|
82
|
+
__decorate([
|
83
|
+
state()
|
84
|
+
], AtomicRelevanceInspector.prototype, "bindings", void 0);
|
85
|
+
__decorate([
|
86
|
+
state()
|
87
|
+
], AtomicRelevanceInspector.prototype, "error", void 0);
|
88
|
+
__decorate([
|
89
|
+
state()
|
90
|
+
], AtomicRelevanceInspector.prototype, "open", void 0);
|
91
|
+
__decorate([
|
92
|
+
bindingGuard(),
|
93
|
+
errorGuard()
|
94
|
+
], AtomicRelevanceInspector.prototype, "render", null);
|
95
|
+
AtomicRelevanceInspector = __decorate([
|
96
|
+
customElement('atomic-relevance-inspector'),
|
97
|
+
bindings(),
|
98
|
+
withTailwindStyles
|
99
|
+
], AtomicRelevanceInspector);
|
100
|
+
export { AtomicRelevanceInspector };
|
package/dist/atomic/components/components/search/atomic-search-interface/atomic-search-interface.js
CHANGED
@@ -8,7 +8,7 @@ import { buildSearchEngine, buildSearchStatus, buildUrlManager, EcommerceDefault
|
|
8
8
|
import { provide } from '@lit/context';
|
9
9
|
import i18next from 'i18next';
|
10
10
|
import { css, html, LitElement } from 'lit';
|
11
|
-
import { customElement, property, state } from 'lit/decorators.js';
|
11
|
+
import { customElement, property, query, state } from 'lit/decorators.js';
|
12
12
|
import { when } from 'lit/directives/when.js';
|
13
13
|
import { InterfaceController, } from "../../common/interface/interface-controller";
|
14
14
|
import { MobileBreakpointController } from "../../common/layout/mobile-breakpoint-controller";
|
@@ -21,6 +21,7 @@ import { withTailwindStyles } from "../../../decorators/with-tailwind-styles.js"
|
|
21
21
|
import { ChildrenUpdateCompleteMixin } from "../../../mixins/children-update-complete-mixin";
|
22
22
|
import { markParentAsReady } from "../../../utils/init-queue";
|
23
23
|
import { SafeStorage, StorageItems, } from "../../../utils/local-storage-utils";
|
24
|
+
import "../atomic-relevance-inspector/atomic-relevance-inspector";
|
24
25
|
import { getAnalyticsConfig } from './analytics-config';
|
25
26
|
import { createSearchStore } from './store';
|
26
27
|
// TODO - Remove once all components that use atomic-modal have been migrated.
|
@@ -35,7 +36,6 @@ let AtomicSearchInterface = class AtomicSearchInterface extends ChildrenUpdateCo
|
|
35
36
|
constructor() {
|
36
37
|
super();
|
37
38
|
this.bindings = {};
|
38
|
-
this.relevanceInspectorIsOpen = false;
|
39
39
|
this.unsubscribeUrlManager = () => { };
|
40
40
|
this.unsubscribeSearchStatus = () => { };
|
41
41
|
this.initialized = false;
|
@@ -105,11 +105,6 @@ let AtomicSearchInterface = class AtomicSearchInterface extends ChildrenUpdateCo
|
|
105
105
|
this.handleInitialization = (event) => {
|
106
106
|
this.interfaceController.onComponentInitializing(event);
|
107
107
|
};
|
108
|
-
this.handleRelevanceInspectorDoubleClick = (e) => {
|
109
|
-
if (e.altKey) {
|
110
|
-
this.relevanceInspectorIsOpen = !this.relevanceInspectorIsOpen;
|
111
|
-
}
|
112
|
-
};
|
113
108
|
this.onHashChange = () => {
|
114
109
|
this.urlManager.synchronize(this.fragment);
|
115
110
|
};
|
@@ -122,10 +117,8 @@ let AtomicSearchInterface = class AtomicSearchInterface extends ChildrenUpdateCo
|
|
122
117
|
connectedCallback() {
|
123
118
|
super.connectedCallback();
|
124
119
|
this.store.setLoadingFlag(FirstSearchExecutedFlag);
|
125
|
-
this.initRelevanceInspector();
|
126
120
|
this.addEventListener('atomic/initializeComponent', this.handleInitialization);
|
127
121
|
this.addEventListener('atomic/scrollToTop', this.scrollToTop);
|
128
|
-
this.addEventListener('atomic/relevanceInspector/close', this.closeRelevanceInspector);
|
129
122
|
}
|
130
123
|
willUpdate(changedProperties) {
|
131
124
|
super.willUpdate(changedProperties);
|
@@ -144,8 +137,6 @@ let AtomicSearchInterface = class AtomicSearchInterface extends ChildrenUpdateCo
|
|
144
137
|
window.removeEventListener('hashchange', this.onHashChange);
|
145
138
|
this.removeEventListener('atomic/initializeComponent', this.handleInitialization);
|
146
139
|
this.removeEventListener('atomic/scrollToTop', this.scrollToTop);
|
147
|
-
this.removeEventListener('atomic/relevanceInspector/close', this.closeRelevanceInspector);
|
148
|
-
this.removeEventListener('dblclick', this.handleRelevanceInspectorDoubleClick);
|
149
140
|
}
|
150
141
|
// TODO - (v4) KIT-4991: Make private.
|
151
142
|
scrollToTop() {
|
@@ -156,8 +147,13 @@ let AtomicSearchInterface = class AtomicSearchInterface extends ChildrenUpdateCo
|
|
156
147
|
}
|
157
148
|
scrollContainerElement.scrollIntoView({ behavior: 'smooth' });
|
158
149
|
}
|
150
|
+
/**
|
151
|
+
* @deprecated provided for backward compatibility. set the 'open' property directly on the relevance inspector instead.
|
152
|
+
*/
|
159
153
|
closeRelevanceInspector() {
|
160
|
-
this.
|
154
|
+
if (this.relevanceInspector) {
|
155
|
+
this.relevanceInspector.open = false;
|
156
|
+
}
|
161
157
|
}
|
162
158
|
/**
|
163
159
|
* Initializes the connection with the headless search engine using options for `accessToken` (required), `organizationId` (required), `environment` (defaults to `prod`), and `renewAccessToken`.
|
@@ -314,11 +310,6 @@ let AtomicSearchInterface = class AtomicSearchInterface extends ChildrenUpdateCo
|
|
314
310
|
this.unsubscribeUrlManager = this.urlManager.subscribe(() => this.updateHash());
|
315
311
|
window.addEventListener('hashchange', this.onHashChange);
|
316
312
|
}
|
317
|
-
initRelevanceInspector() {
|
318
|
-
if (this.enableRelevanceInspector && !this.disableRelevanceInspector) {
|
319
|
-
this.addEventListener('dblclick', this.handleRelevanceInspectorDoubleClick);
|
320
|
-
}
|
321
|
-
}
|
322
313
|
initSearchStatus() {
|
323
314
|
this.searchStatus = buildSearchStatus(this.engine);
|
324
315
|
this.unsubscribeSearchStatus = this.searchStatus.subscribe(() => {
|
@@ -363,10 +354,7 @@ let AtomicSearchInterface = class AtomicSearchInterface extends ChildrenUpdateCo
|
|
363
354
|
return html `
|
364
355
|
${when(this.bindings?.engine &&
|
365
356
|
this.enableRelevanceInspector &&
|
366
|
-
!this.disableRelevanceInspector, () => html `<atomic-relevance-inspector
|
367
|
-
?open=${this.relevanceInspectorIsOpen}
|
368
|
-
.bindings=${this.bindings}
|
369
|
-
></atomic-relevance-inspector>`)}
|
357
|
+
!this.disableRelevanceInspector, () => html `<atomic-relevance-inspector></atomic-relevance-inspector>`)}
|
370
358
|
<slot></slot>
|
371
359
|
`;
|
372
360
|
}
|
@@ -382,8 +370,8 @@ __decorate([
|
|
382
370
|
state()
|
383
371
|
], AtomicSearchInterface.prototype, "error", void 0);
|
384
372
|
__decorate([
|
385
|
-
|
386
|
-
], AtomicSearchInterface.prototype, "
|
373
|
+
query('atomic-relevance-inspector')
|
374
|
+
], AtomicSearchInterface.prototype, "relevanceInspector", void 0);
|
387
375
|
__decorate([
|
388
376
|
property({
|
389
377
|
type: Array,
|
@@ -1,6 +1,7 @@
|
|
1
1
|
// Auto-generated file
|
2
2
|
export { AtomicPager } from './atomic-pager/atomic-pager.js';
|
3
3
|
export { AtomicQuerySummary } from './atomic-query-summary/atomic-query-summary.js';
|
4
|
+
export { AtomicRelevanceInspector } from './atomic-relevance-inspector/atomic-relevance-inspector.js';
|
4
5
|
export { AtomicResultsPerPage } from './atomic-results-per-page/atomic-results-per-page.js';
|
5
6
|
export { AtomicSearchInterface } from './atomic-search-interface/atomic-search-interface.js';
|
6
7
|
export { AtomicSearchLayout } from './atomic-search-layout/atomic-search-layout.js';
|
@@ -2,6 +2,7 @@
|
|
2
2
|
export default {
|
3
3
|
'atomic-pager': async () => await import('./atomic-pager/atomic-pager.js'),
|
4
4
|
'atomic-query-summary': async () => await import('./atomic-query-summary/atomic-query-summary.js'),
|
5
|
+
'atomic-relevance-inspector': async () => await import('./atomic-relevance-inspector/atomic-relevance-inspector.js'),
|
5
6
|
'atomic-results-per-page': async () => await import('./atomic-results-per-page/atomic-results-per-page.js'),
|
6
7
|
'atomic-search-interface': async () => await import('./atomic-search-interface/atomic-search-interface.js'),
|
7
8
|
'atomic-search-layout': async () => await import('./atomic-search-layout/atomic-search-layout.js'),
|
@@ -1 +1 @@
|
|
1
|
-
{"file":"index.js","mappings":"
|
1
|
+
{"file":"index.js","mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;;;;;;;;;;;SAYgB,cAAc,CAAoB,OAAgB;IAChE,OAAO,WAAW,CAAI,OAAO,EAAE,gBAAgB,CAAC,CAAC;AACnD;;MCHa,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,WAAmB,EAAE,UAAkB;QACjD,KAAK,CACH,QAAQ,WAAW,sCAAsC,UAAU,YAAY,CAChF,CAAC;KACH;;;ACfH,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;SAIpC,gBAAgB,CAAI,OAAgB,EAAE,UAAkB;IACtE,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM;QACpC,MAAM,KAAK,GAAG,gBAAgB,CAC5B,oBAAoB,EACpB,CAAC,IAAO;YACN,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC;SACtB,CACF,CAAC;QACF,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QAE7B,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE;YACjC,MAAM,CACJ,IAAI,kBAAkB,CAAC,OAAO,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,UAAU,CAAC,CACnE,CAAC;SACH;KACF,CAAC,CAAC;AACL;;ACoDA;;;;;;;;;;SAUgB,mBAAmB,CAAoB,OAAgB;IACrE,OAAO,gBAAgB,CAAI,OAAO,EAAE,gBAAgB,CAAC,CAAC;AACxD;;;;","names":[],"sources":["src/components/commerce/product-template-component-utils/stencil-product-template-decorators.tsx","src/components/common/item-list/context/item-context-controller.ts","src/components/common/item-list/fetch-item-context.ts","src/decorators/commerce/product-template-decorators.ts"],"sourcesContent":["import {Product} from '@coveo/headless/commerce';\nimport {itemContext} from '../../common/item-list/stencil-item-decorators';\n\n/**\n * Retrieves `Product` on a rendered `atomic-product`.\n *\n * This method is useful for building custom product template elements, see [Create a Product List](https://docs.coveo.com/en/atomic/latest/cc-search/create-custom-components/native-components/#custom-product-template-component-example) for more information.\n *\n * You should use the method in the [connectedCallback lifecycle method](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements#using_the_lifecycle_callbacks).\n *\n * @param element - The element that the event is dispatched to, which must be the child of a rendered \"atomic-product\".\n * @returns A promise that resolves on initialization of the parent \"atomic-product\" element, or rejects when there is no parent \"atomic-product\" element.\n *\n * @deprecated should only be used for Stencil components. For Lit components, use `fetchProductContext` from \\@/src/decorators/commerce/product-template-decorators.ts\n */\nexport function productContext<T extends Product>(element: Element) {\n return itemContext<T>(element, 'atomic-product');\n}\n","import type {LitElement, ReactiveController, ReactiveControllerHost} from 'lit';\nimport type {InitializableComponent} from '@/src/decorators/types.js';\nimport {buildCustomEvent} from '@/src/utils/event-utils';\n\ntype LitElementWithError = Omit<\n Pick<InitializableComponent, 'error'>,\n 'error'\n> &\n LitElement & {\n error: Error | null;\n };\n\nconst itemContextEventName = 'atomic/resolveResult';\n\nexport class MissingParentError extends Error {\n constructor(elementName: string, parentName: string) {\n super(\n `The \"${elementName}\" element must be the child of an \"${parentName}\" element.`\n );\n }\n}\n\nfunction extractFolded<T = Record<string, unknown>>(\n item: Record<string, unknown>,\n returnFolded: boolean\n): T {\n if (returnFolded) {\n if ('children' in item) {\n return item as T;\n } else {\n return {children: [], result: item} as T;\n }\n }\n\n if ('children' in item && 'result' in item) {\n return item.result as T;\n }\n return item as T;\n}\n\n/**\n * A reactive controller that manages item context data from parent components.\n * Handles fetching item data via custom events and manages error states.\n */\nexport class ItemContextController<T = Record<string, unknown>>\n implements ReactiveController\n{\n private host: ReactiveControllerHost & LitElementWithError;\n private parentName: string;\n private folded: boolean;\n private _item: T | null = null;\n private _error: MissingParentError | null = null;\n\n constructor(\n host: ReactiveControllerHost & LitElementWithError,\n options: {parentName?: string; folded?: boolean} = {}\n ) {\n this.host = host;\n this.parentName = options.parentName ?? 'atomic-result';\n this.folded = options.folded ?? false;\n host.addController(this);\n }\n\n get item(): T | null {\n return this._error ? null : this._item;\n }\n\n get error(): MissingParentError | null {\n return this._error;\n }\n\n get hasError(): boolean {\n return this._error !== null;\n }\n\n hostConnected(): void {\n this._resolveItemContext();\n }\n\n private _resolveItemContext(): void {\n const event = buildCustomEvent(\n itemContextEventName,\n (item: Record<string, unknown>) => {\n this._item = extractFolded<T>(item, this.folded);\n this._error = null;\n this.host.error = null;\n this.host.requestUpdate();\n }\n );\n\n const canceled = this.host.dispatchEvent(event);\n if (canceled) {\n const elementName = (this.host as Element).nodeName.toLowerCase();\n this._error = new MissingParentError(elementName, this.parentName);\n this._item = null;\n this.host.error = this._error;\n this.host.requestUpdate();\n }\n }\n}\n\ntype ItemContextEventHandler<T> = (item: T) => void;\nexport type ItemContextEvent<T> = CustomEvent<ItemContextEventHandler<T>>;\n","import {closest} from '../../../utils/dom-utils.js';\nimport {buildCustomEvent} from '../../../utils/event-utils.js';\nimport {MissingParentError} from './context/item-context-controller.js';\n\nconst itemContextEventName = 'atomic/resolveResult';\n\ntype ItemContextEventHandler<T> = (item: T) => void;\n\nexport function fetchItemContext<T>(element: Element, parentName: string) {\n return new Promise<T>((resolve, reject) => {\n const event = buildCustomEvent<ItemContextEventHandler<T>>(\n itemContextEventName,\n (item: T) => {\n return resolve(item);\n }\n );\n element.dispatchEvent(event);\n\n if (!closest(element, parentName)) {\n reject(\n new MissingParentError(element.nodeName.toLowerCase(), parentName)\n );\n }\n });\n}\n","import type {InteractiveProduct, Product} from '@coveo/headless/commerce';\nimport type {LitElement} from 'lit';\nimport {\n InteractiveItemContextController,\n type InteractiveItemContextEvent,\n} from '@/src/components/common/item-list/context/interactive-item-context-controller';\nimport {\n ItemContextController,\n type ItemContextEvent,\n} from '@/src/components/common/item-list/context/item-context-controller';\nimport {fetchItemContext} from '@/src/components/common/item-list/fetch-item-context';\n\n/**\n * Creates a [Lit reactive controller](https://lit.dev/docs/composition/controllers/) for managing product context in product template components.\n *\n * @param host - The Lit component instance\n * @param options - Configuration options\n * @returns ItemContextController instance configured for atomic-product\n *\n * @example\n * ```typescript\n * @customElement('my-product-component')\n * export class MyProductComponent extends LitElement {\n * private productController = createProductContextController(this);\n *\n * @state() product!: Product;\n *\n * render() {\n * this.product = this.productController.item;\n * return html`<div>${this.product?.ec_name}</div>`;\n * }\n * }\n * ```\n */\nexport function createProductContextController(\n host: LitElement & {error: Error | null},\n options: {folded?: boolean} = {}\n): ItemContextController<Product> {\n return new ItemContextController<Product>(host, {\n parentName: 'atomic-product',\n folded: options.folded ?? false,\n });\n}\n\n/**\n * Creates a [Lit reactive controller](https://lit.dev/docs/composition/controllers/) for managing interactive product context in product template components.\n *\n * @param host - The Lit component instance\n * @returns InteractiveItemContextController instance\n *\n * @example\n * ```typescript\n * @customElement('my-interactive-product-component')\n * export class MyInteractiveProductComponent extends LitElement {\n * private interactiveProductController = createInteractiveProductContextController(this);\n *\n * @state() product!: Product;\n *\n * render() {\n * this.product = this.interactiveProductController.interactiveItem;\n * return html`<div>${this.product?.ec_name}</div>`;\n * }\n * }\n * ```\n */\nexport function createInteractiveProductContextController(\n host: LitElement & {error: Error}\n): InteractiveItemContextController<InteractiveProduct> {\n return new InteractiveItemContextController<InteractiveProduct>(host);\n}\n\nexport type ProductContextEvent<T = Product> = ItemContextEvent<T>;\nexport type InteractiveProductContextEvent<\n T extends InteractiveProduct = InteractiveProduct,\n> = InteractiveItemContextEvent<T>;\n\n/**\n * Retrieves `Product` on a rendered `atomic-product`.\n *\n * This utility function is useful for building custom product template elements, see [Create a Product List](https://docs.coveo.com/en/atomic/latest/cc-search/create-custom-components/native-components/#custom-product-template-component-example) for more information.\n *\n * You should use the utility function in the [`connectedCallback` lifecycle method](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements#using_the_lifecycle_callbacks).\n *\n * @param element - The element that the event is dispatched to, which must be the child of a rendered `atomic-product`.\n * @returns A promise that resolves on initialization of the parent `atomic-product` element, or rejects when there is no parent `atomic-product` element.\n */\nexport function fetchProductContext<T extends Product>(element: Element) {\n return fetchItemContext<T>(element, 'atomic-product');\n}\n"],"version":3}
|