@coveo/atomic 3.55.3 → 3.56.2
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/custom-elements.json +438 -426
- package/dist/cjs/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.cjs +1 -1
- package/dist/cjs/components/common/atomic-citation/atomic-citation.cjs +1 -1
- package/dist/cjs/components/common/atomic-icon/atomic-icon.cjs +2 -16
- package/dist/cjs/components/common/atomic-icon/fetch-icon.cjs +63 -0
- package/dist/cjs/components/common/search-box/search-text-area.cjs +1 -1
- package/dist/cjs/components/insight/atomic-insight-search-box/atomic-insight-search-box.cjs +1 -1
- package/dist/cjs/components/search/atomic-search-box/atomic-search-box.cjs +1 -1
- package/dist/cjs/global/environment.cjs +1 -1
- package/dist/cjs/index.cjs +12 -24
- package/dist/cjs/utils/memoize.cjs +63 -0
- package/dist/cjs/versions.cjs +1 -1
- package/dist/esm/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.js +1 -1
- package/dist/esm/components/common/atomic-citation/atomic-citation.js +1 -1
- package/dist/esm/components/common/atomic-icon/atomic-icon.js +2 -16
- package/dist/esm/components/common/atomic-icon/fetch-icon.js +26 -0
- package/dist/esm/components/common/search-box/search-text-area.js +1 -1
- package/dist/esm/components/insight/atomic-insight-search-box/atomic-insight-search-box.js +1 -1
- package/dist/esm/components/search/atomic-search-box/atomic-search-box.js +1 -1
- package/dist/esm/global/environment.js +1 -1
- package/dist/esm/index.js +1 -2
- package/dist/esm/utils/memoize.js +29 -0
- package/dist/esm/versions.js +1 -1
- package/dist/types/components/common/atomic-icon/fetch-icon.d.ts +2 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/utils/memoize.d.ts +22 -0
- package/package.json +7 -6
package/dist/cjs/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.cjs
CHANGED
|
@@ -223,7 +223,7 @@ class AtomicCommerceSearchBox extends external_lit_namespaceObject.LitElement {
|
|
|
223
223
|
if (this.isSearchDisabledForEndUser) return;
|
|
224
224
|
switch(e.key){
|
|
225
225
|
case 'Enter':
|
|
226
|
-
this.onSubmit();
|
|
226
|
+
if (!e.shiftKey) this.onSubmit();
|
|
227
227
|
break;
|
|
228
228
|
case 'Escape':
|
|
229
229
|
this.suggestionManager.clearSuggestions();
|
|
@@ -80,7 +80,7 @@ class AtomicCitation extends external_lit_namespaceObject.LitElement {
|
|
|
80
80
|
<div class="relative">
|
|
81
81
|
${(0, item_link_cjs_namespaceObject.renderLinkWithItemAnalytics)({
|
|
82
82
|
props: {
|
|
83
|
-
href: this.anchorUrl(this.citation.clickUri ?? this.citation.uri, this.citation.text, this.citation.fields?.filetype),
|
|
83
|
+
href: this.anchorUrl(this.citation.clickUri ?? this.citation.uri, this.citation.text, this.citation.filetype ?? this.citation.fields?.filetype),
|
|
84
84
|
ref: this.citationRef,
|
|
85
85
|
part: 'citation',
|
|
86
86
|
target: '_blank',
|
|
@@ -47,6 +47,7 @@ const watch_cjs_namespaceObject = require("../../../decorators/watch.cjs");
|
|
|
47
47
|
const bindings_mixin_cjs_namespaceObject = require("../../../mixins/bindings-mixin.cjs");
|
|
48
48
|
const light_dom_cjs_namespaceObject = require("../../../mixins/light-dom.cjs");
|
|
49
49
|
const asset_path_utils_cjs_namespaceObject = require("../../../utils/asset-path-utils.cjs");
|
|
50
|
+
const external_fetch_icon_cjs_namespaceObject = require("./fetch-icon.cjs");
|
|
50
51
|
function _ts_decorate(decorators, target, key, desc) {
|
|
51
52
|
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
52
53
|
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -56,25 +57,10 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
56
57
|
function _ts_metadata(k, v) {
|
|
57
58
|
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
58
59
|
}
|
|
59
|
-
class IconFetchError extends Error {
|
|
60
|
-
static fromStatusCode(url, statusCode, statusText) {
|
|
61
|
-
return new IconFetchError(url, `status code ${statusCode} (${statusText})`);
|
|
62
|
-
}
|
|
63
|
-
static fromError(url, error) {
|
|
64
|
-
return new IconFetchError(url, 'an error', error);
|
|
65
|
-
}
|
|
66
|
-
constructor(url, errorMessage, errorObject){
|
|
67
|
-
super(`Could not fetch icon from ${url}, got ${errorMessage}.`), this.url = url, this.errorObject = errorObject;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
60
|
class AtomicIcon extends (0, light_dom_cjs_namespaceObject.LightDomMixin)((0, bindings_mixin_cjs_namespaceObject.InitializeBindingsMixin)(external_lit_namespaceObject.LitElement)) {
|
|
71
61
|
async fetchIcon(url) {
|
|
72
62
|
try {
|
|
73
|
-
|
|
74
|
-
throw IconFetchError.fromError(url, e);
|
|
75
|
-
});
|
|
76
|
-
if (200 !== response.status && 304 !== response.status) throw IconFetchError.fromStatusCode(url, response.status, response.statusText);
|
|
77
|
-
return await response.text();
|
|
63
|
+
return await (0, external_fetch_icon_cjs_namespaceObject.fetchIcon)(url);
|
|
78
64
|
} catch (e) {
|
|
79
65
|
this.error = e;
|
|
80
66
|
this.requestUpdate();
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
fetchIcon: ()=>fetchIcon,
|
|
28
|
+
clearIconCache: ()=>clearIconCache
|
|
29
|
+
});
|
|
30
|
+
const memoize_cjs_namespaceObject = require("../../../utils/memoize.cjs");
|
|
31
|
+
class IconFetchError extends Error {
|
|
32
|
+
static fromStatusCode(url, statusCode, statusText) {
|
|
33
|
+
return new IconFetchError(url, `status code ${statusCode} (${statusText})`);
|
|
34
|
+
}
|
|
35
|
+
static fromError(url, error) {
|
|
36
|
+
return new IconFetchError(url, 'an error', error);
|
|
37
|
+
}
|
|
38
|
+
constructor(url, errorMessage, errorObject){
|
|
39
|
+
super(`Could not fetch icon from ${url}, got ${errorMessage}.`), this.url = url, this.errorObject = errorObject;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const fetchIconUnmemoized = async (url)=>fetch(url).catch((e)=>{
|
|
43
|
+
throw IconFetchError.fromError(url, e);
|
|
44
|
+
}).then((response)=>{
|
|
45
|
+
if (200 !== response.status && 304 !== response.status) throw IconFetchError.fromStatusCode(url, response.status, response.statusText);
|
|
46
|
+
return response.text();
|
|
47
|
+
});
|
|
48
|
+
const memoizedFetchIcon = (0, memoize_cjs_namespaceObject.memoize)(fetchIconUnmemoized, (url)=>url, {
|
|
49
|
+
maxEntries: 20
|
|
50
|
+
});
|
|
51
|
+
const fetchIcon = memoizedFetchIcon.fn;
|
|
52
|
+
function clearIconCache() {
|
|
53
|
+
memoizedFetchIcon.clearCache();
|
|
54
|
+
}
|
|
55
|
+
exports.clearIconCache = __webpack_exports__.clearIconCache;
|
|
56
|
+
exports.fetchIcon = __webpack_exports__.fetchIcon;
|
|
57
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
58
|
+
"clearIconCache",
|
|
59
|
+
"fetchIcon"
|
|
60
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
61
|
+
Object.defineProperty(exports, '__esModule', {
|
|
62
|
+
value: true
|
|
63
|
+
});
|
|
@@ -72,7 +72,7 @@ const renderSearchBoxTextArea = ({ props: { textAreaRef, loading, i18n, onInput,
|
|
|
72
72
|
}}
|
|
73
73
|
@keyup=${(e)=>{
|
|
74
74
|
onKeyUp?.(e);
|
|
75
|
-
if ('Enter' === e.key) return void e.preventDefault();
|
|
75
|
+
if ('Enter' === e.key && !e.shiftKey) return void e.preventDefault();
|
|
76
76
|
syncTextWithReplica(textAreaRef);
|
|
77
77
|
}}
|
|
78
78
|
@blur=${(e)=>{
|
|
@@ -120,7 +120,7 @@ class AtomicInsightSearchBox extends external_lit_namespaceObject.LitElement {
|
|
|
120
120
|
if (this.disableSearch) return;
|
|
121
121
|
switch(e.key){
|
|
122
122
|
case 'Enter':
|
|
123
|
-
this.onSubmit();
|
|
123
|
+
if (!e.shiftKey) this.onSubmit();
|
|
124
124
|
break;
|
|
125
125
|
case 'Escape':
|
|
126
126
|
this.suggestionManager.clearSuggestions();
|
|
@@ -226,7 +226,7 @@ class AtomicSearchBox extends external_lit_namespaceObject.LitElement {
|
|
|
226
226
|
if (this.isSearchDisabledForEndUser) return;
|
|
227
227
|
switch(e.key){
|
|
228
228
|
case 'Enter':
|
|
229
|
-
this.onSubmit();
|
|
229
|
+
if (!e.shiftKey) this.onSubmit();
|
|
230
230
|
break;
|
|
231
231
|
case 'Escape':
|
|
232
232
|
this.suggestionManager.clearSuggestions();
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -9,9 +9,6 @@ var __webpack_modules__ = {
|
|
|
9
9
|
"./components/common/suggestions/suggestions-utils" (module) {
|
|
10
10
|
module.exports = require("./components/common/suggestions/suggestions-utils.cjs");
|
|
11
11
|
},
|
|
12
|
-
"./components/index.js" (module) {
|
|
13
|
-
module.exports = require("./components/index.cjs");
|
|
14
|
-
},
|
|
15
12
|
"./utils/initialization-common-utils" (module) {
|
|
16
13
|
module.exports = require("./utils/initialization-common-utils.cjs");
|
|
17
14
|
},
|
|
@@ -66,40 +63,33 @@ var __webpack_exports__ = {};
|
|
|
66
63
|
(()=>{
|
|
67
64
|
__webpack_require__.r(__webpack_exports__);
|
|
68
65
|
__webpack_require__.d(__webpack_exports__, {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
fetchProductContext: ()=>_components_commerce_product_template_component_utils_context_fetch_product_context__rspack_import_2.fetchProductContext,
|
|
77
|
-
initializeBindings: ()=>_utils_initialization_common_utils__rspack_import_5.fetchBindings
|
|
66
|
+
MissingInterfaceParentError: ()=>_utils_initialization_common_utils__rspack_import_4.MissingInterfaceParentError,
|
|
67
|
+
bindLogDocumentOpenOnResult: ()=>_utils_result_utils__rspack_import_5.bindLogDocumentOpenOnResult,
|
|
68
|
+
dispatchSearchBoxSuggestionsEvent: ()=>_components_common_suggestions_suggestions_events__rspack_import_2.dispatchSearchBoxSuggestionsEvent,
|
|
69
|
+
elementHasNoQuery: ()=>_components_common_suggestions_suggestions_utils__rspack_import_3.elementHasNoQuery,
|
|
70
|
+
elementHasQuery: ()=>_components_common_suggestions_suggestions_utils__rspack_import_3.elementHasQuery,
|
|
71
|
+
fetchProductContext: ()=>_components_commerce_product_template_component_utils_context_fetch_product_context__rspack_import_1.fetchProductContext,
|
|
72
|
+
initializeBindings: ()=>_utils_initialization_common_utils__rspack_import_4.fetchBindings
|
|
78
73
|
});
|
|
79
74
|
var _coveo_atomic_legacy_item_decorators__rspack_import_0 = __webpack_require__("@coveo/atomic-legacy/item-decorators");
|
|
80
75
|
var __rspack_reexport = {};
|
|
81
76
|
for(const __rspack_import_key in _coveo_atomic_legacy_item_decorators__rspack_import_0)if ([
|
|
82
77
|
"initializeBindings",
|
|
83
78
|
"MissingInterfaceParentError",
|
|
84
|
-
"JSX",
|
|
85
79
|
"default",
|
|
86
80
|
"bindLogDocumentOpenOnResult",
|
|
87
81
|
"fetchProductContext",
|
|
88
|
-
"Components",
|
|
89
82
|
"dispatchSearchBoxSuggestionsEvent",
|
|
90
83
|
"elementHasNoQuery",
|
|
91
84
|
"elementHasQuery"
|
|
92
85
|
].indexOf(__rspack_import_key) < 0) __rspack_reexport[__rspack_import_key] = ()=>_coveo_atomic_legacy_item_decorators__rspack_import_0[__rspack_import_key];
|
|
93
86
|
__webpack_require__.d(__webpack_exports__, __rspack_reexport);
|
|
94
|
-
var
|
|
95
|
-
var
|
|
96
|
-
var
|
|
97
|
-
var
|
|
98
|
-
var
|
|
99
|
-
var _utils_result_utils__rspack_import_6 = __webpack_require__("./utils/result-utils");
|
|
87
|
+
var _components_commerce_product_template_component_utils_context_fetch_product_context__rspack_import_1 = __webpack_require__("./components/commerce/product-template-component-utils/context/fetch-product-context");
|
|
88
|
+
var _components_common_suggestions_suggestions_events__rspack_import_2 = __webpack_require__("./components/common/suggestions/suggestions-events");
|
|
89
|
+
var _components_common_suggestions_suggestions_utils__rspack_import_3 = __webpack_require__("./components/common/suggestions/suggestions-utils");
|
|
90
|
+
var _utils_initialization_common_utils__rspack_import_4 = __webpack_require__("./utils/initialization-common-utils");
|
|
91
|
+
var _utils_result_utils__rspack_import_5 = __webpack_require__("./utils/result-utils");
|
|
100
92
|
})();
|
|
101
|
-
exports.Components = __webpack_exports__.Components;
|
|
102
|
-
exports.JSX = __webpack_exports__.JSX;
|
|
103
93
|
exports.MissingInterfaceParentError = __webpack_exports__.MissingInterfaceParentError;
|
|
104
94
|
exports.bindLogDocumentOpenOnResult = __webpack_exports__.bindLogDocumentOpenOnResult;
|
|
105
95
|
exports.dispatchSearchBoxSuggestionsEvent = __webpack_exports__.dispatchSearchBoxSuggestionsEvent;
|
|
@@ -108,8 +98,6 @@ exports.elementHasQuery = __webpack_exports__.elementHasQuery;
|
|
|
108
98
|
exports.fetchProductContext = __webpack_exports__.fetchProductContext;
|
|
109
99
|
exports.initializeBindings = __webpack_exports__.initializeBindings;
|
|
110
100
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
111
|
-
"Components",
|
|
112
|
-
"JSX",
|
|
113
101
|
"MissingInterfaceParentError",
|
|
114
102
|
"bindLogDocumentOpenOnResult",
|
|
115
103
|
"dispatchSearchBoxSuggestionsEvent",
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
memoize: ()=>memoize
|
|
28
|
+
});
|
|
29
|
+
function memoize(fn, getCacheKey, options = {}) {
|
|
30
|
+
const cache = new Map();
|
|
31
|
+
const { maxEntries } = options;
|
|
32
|
+
return {
|
|
33
|
+
fn: async (...args)=>{
|
|
34
|
+
const key = getCacheKey(...args);
|
|
35
|
+
if (cache.has(key)) {
|
|
36
|
+
const cachedPromise = cache.get(key);
|
|
37
|
+
cache.delete(key);
|
|
38
|
+
cache.set(key, cachedPromise);
|
|
39
|
+
return cachedPromise;
|
|
40
|
+
}
|
|
41
|
+
const promise = fn(...args).catch((error)=>{
|
|
42
|
+
cache.delete(key);
|
|
43
|
+
throw error;
|
|
44
|
+
});
|
|
45
|
+
cache.set(key, promise);
|
|
46
|
+
if (void 0 !== maxEntries && cache.size > maxEntries) {
|
|
47
|
+
const lruKey = cache.keys().next().value;
|
|
48
|
+
if (void 0 !== lruKey) cache.delete(lruKey);
|
|
49
|
+
}
|
|
50
|
+
return promise;
|
|
51
|
+
},
|
|
52
|
+
clearCache: ()=>{
|
|
53
|
+
cache.clear();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
exports.memoize = __webpack_exports__.memoize;
|
|
58
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
59
|
+
"memoize"
|
|
60
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
61
|
+
Object.defineProperty(exports, '__esModule', {
|
|
62
|
+
value: true
|
|
63
|
+
});
|
package/dist/cjs/versions.cjs
CHANGED
|
@@ -28,7 +28,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
28
28
|
atomicVersion: ()=>atomicVersion
|
|
29
29
|
});
|
|
30
30
|
const package_json_namespaceObject = require("@coveo/headless/package.json");
|
|
31
|
-
const atomicVersion = "3.
|
|
31
|
+
const atomicVersion = "3.56.2";
|
|
32
32
|
exports.atomicVersion = __webpack_exports__.atomicVersion;
|
|
33
33
|
exports.headlessVersion = __webpack_exports__.headlessVersion;
|
|
34
34
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
package/dist/esm/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.js
CHANGED
|
@@ -195,7 +195,7 @@ class AtomicCommerceSearchBox extends LitElement {
|
|
|
195
195
|
if (this.isSearchDisabledForEndUser) return;
|
|
196
196
|
switch(e.key){
|
|
197
197
|
case 'Enter':
|
|
198
|
-
this.onSubmit();
|
|
198
|
+
if (!e.shiftKey) this.onSubmit();
|
|
199
199
|
break;
|
|
200
200
|
case 'Escape':
|
|
201
201
|
this.suggestionManager.clearSuggestions();
|
|
@@ -42,7 +42,7 @@ class AtomicCitation extends LitElement {
|
|
|
42
42
|
<div class="relative">
|
|
43
43
|
${renderLinkWithItemAnalytics({
|
|
44
44
|
props: {
|
|
45
|
-
href: this.anchorUrl(this.citation.clickUri ?? this.citation.uri, this.citation.text, this.citation.fields?.filetype),
|
|
45
|
+
href: this.anchorUrl(this.citation.clickUri ?? this.citation.uri, this.citation.text, this.citation.filetype ?? this.citation.fields?.filetype),
|
|
46
46
|
ref: this.citationRef,
|
|
47
47
|
part: 'citation',
|
|
48
48
|
target: '_blank',
|
|
@@ -9,6 +9,7 @@ import { watch } from "../../../decorators/watch.js";
|
|
|
9
9
|
import { InitializeBindingsMixin } from "../../../mixins/bindings-mixin.js";
|
|
10
10
|
import { LightDomMixin } from "../../../mixins/light-dom.js";
|
|
11
11
|
import { parseAssetURL } from "../../../utils/asset-path-utils.js";
|
|
12
|
+
import { fetchIcon } from "./fetch-icon.js";
|
|
12
13
|
function _ts_decorate(decorators, target, key, desc) {
|
|
13
14
|
var c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
14
15
|
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -18,25 +19,10 @@ function _ts_decorate(decorators, target, key, desc) {
|
|
|
18
19
|
function _ts_metadata(k, v) {
|
|
19
20
|
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
20
21
|
}
|
|
21
|
-
class IconFetchError extends Error {
|
|
22
|
-
static fromStatusCode(url, statusCode, statusText) {
|
|
23
|
-
return new IconFetchError(url, `status code ${statusCode} (${statusText})`);
|
|
24
|
-
}
|
|
25
|
-
static fromError(url, error) {
|
|
26
|
-
return new IconFetchError(url, 'an error', error);
|
|
27
|
-
}
|
|
28
|
-
constructor(url, errorMessage, errorObject){
|
|
29
|
-
super(`Could not fetch icon from ${url}, got ${errorMessage}.`), this.url = url, this.errorObject = errorObject;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
22
|
class AtomicIcon extends LightDomMixin(InitializeBindingsMixin(LitElement)) {
|
|
33
23
|
async fetchIcon(url) {
|
|
34
24
|
try {
|
|
35
|
-
|
|
36
|
-
throw IconFetchError.fromError(url, e);
|
|
37
|
-
});
|
|
38
|
-
if (200 !== response.status && 304 !== response.status) throw IconFetchError.fromStatusCode(url, response.status, response.statusText);
|
|
39
|
-
return await response.text();
|
|
25
|
+
return await fetchIcon(url);
|
|
40
26
|
} catch (e) {
|
|
41
27
|
this.error = e;
|
|
42
28
|
this.requestUpdate();
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { memoize } from "../../../utils/memoize.js";
|
|
2
|
+
class IconFetchError extends Error {
|
|
3
|
+
static fromStatusCode(url, statusCode, statusText) {
|
|
4
|
+
return new IconFetchError(url, `status code ${statusCode} (${statusText})`);
|
|
5
|
+
}
|
|
6
|
+
static fromError(url, error) {
|
|
7
|
+
return new IconFetchError(url, 'an error', error);
|
|
8
|
+
}
|
|
9
|
+
constructor(url, errorMessage, errorObject){
|
|
10
|
+
super(`Could not fetch icon from ${url}, got ${errorMessage}.`), this.url = url, this.errorObject = errorObject;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
const fetchIconUnmemoized = async (url)=>fetch(url).catch((e)=>{
|
|
14
|
+
throw IconFetchError.fromError(url, e);
|
|
15
|
+
}).then((response)=>{
|
|
16
|
+
if (200 !== response.status && 304 !== response.status) throw IconFetchError.fromStatusCode(url, response.status, response.statusText);
|
|
17
|
+
return response.text();
|
|
18
|
+
});
|
|
19
|
+
const memoizedFetchIcon = memoize(fetchIconUnmemoized, (url)=>url, {
|
|
20
|
+
maxEntries: 20
|
|
21
|
+
});
|
|
22
|
+
const fetchIcon = memoizedFetchIcon.fn;
|
|
23
|
+
function clearIconCache() {
|
|
24
|
+
memoizedFetchIcon.clearCache();
|
|
25
|
+
}
|
|
26
|
+
export { clearIconCache, fetchIcon };
|
|
@@ -44,7 +44,7 @@ const renderSearchBoxTextArea = ({ props: { textAreaRef, loading, i18n, onInput,
|
|
|
44
44
|
}}
|
|
45
45
|
@keyup=${(e)=>{
|
|
46
46
|
onKeyUp?.(e);
|
|
47
|
-
if ('Enter' === e.key) return void e.preventDefault();
|
|
47
|
+
if ('Enter' === e.key && !e.shiftKey) return void e.preventDefault();
|
|
48
48
|
syncTextWithReplica(textAreaRef);
|
|
49
49
|
}}
|
|
50
50
|
@blur=${(e)=>{
|
|
@@ -198,7 +198,7 @@ class AtomicSearchBox extends LitElement {
|
|
|
198
198
|
if (this.isSearchDisabledForEndUser) return;
|
|
199
199
|
switch(e.key){
|
|
200
200
|
case 'Enter':
|
|
201
|
-
this.onSubmit();
|
|
201
|
+
if (!e.shiftKey) this.onSubmit();
|
|
202
202
|
break;
|
|
203
203
|
case 'Escape':
|
|
204
204
|
this.suggestionManager.clearSuggestions();
|
package/dist/esm/index.js
CHANGED
|
@@ -4,5 +4,4 @@ import { elementHasNoQuery, elementHasQuery } from "./components/common/suggesti
|
|
|
4
4
|
import { MissingInterfaceParentError, fetchBindings } from "./utils/initialization-common-utils.js";
|
|
5
5
|
import { bindLogDocumentOpenOnResult } from "./utils/result-utils.js";
|
|
6
6
|
export * from "@coveo/atomic-legacy/item-decorators";
|
|
7
|
-
|
|
8
|
-
export { __rspack_external__components_index_js_e563dea7 as Components, __rspack_external__components_index_js_e563dea7 as JSX, MissingInterfaceParentError, bindLogDocumentOpenOnResult, dispatchSearchBoxSuggestionsEvent, elementHasNoQuery, elementHasQuery, fetchProductContext, fetchBindings as initializeBindings };
|
|
7
|
+
export { MissingInterfaceParentError, bindLogDocumentOpenOnResult, dispatchSearchBoxSuggestionsEvent, elementHasNoQuery, elementHasQuery, fetchProductContext, fetchBindings as initializeBindings };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
function memoize(fn, getCacheKey, options = {}) {
|
|
2
|
+
const cache = new Map();
|
|
3
|
+
const { maxEntries } = options;
|
|
4
|
+
return {
|
|
5
|
+
fn: async (...args)=>{
|
|
6
|
+
const key = getCacheKey(...args);
|
|
7
|
+
if (cache.has(key)) {
|
|
8
|
+
const cachedPromise = cache.get(key);
|
|
9
|
+
cache.delete(key);
|
|
10
|
+
cache.set(key, cachedPromise);
|
|
11
|
+
return cachedPromise;
|
|
12
|
+
}
|
|
13
|
+
const promise = fn(...args).catch((error)=>{
|
|
14
|
+
cache.delete(key);
|
|
15
|
+
throw error;
|
|
16
|
+
});
|
|
17
|
+
cache.set(key, promise);
|
|
18
|
+
if (void 0 !== maxEntries && cache.size > maxEntries) {
|
|
19
|
+
const lruKey = cache.keys().next().value;
|
|
20
|
+
if (void 0 !== lruKey) cache.delete(lruKey);
|
|
21
|
+
}
|
|
22
|
+
return promise;
|
|
23
|
+
},
|
|
24
|
+
clearCache: ()=>{
|
|
25
|
+
cache.clear();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export { memoize };
|
package/dist/esm/versions.js
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from '@coveo/atomic-legacy/item-decorators';
|
|
2
2
|
export type { i18n } from 'i18next';
|
|
3
|
-
import * as _Components from './components/index.js';
|
|
3
|
+
import type * as _Components from './components/index.js';
|
|
4
4
|
export type { CommerceBindings } from './components/commerce/atomic-commerce-interface/atomic-commerce-interface';
|
|
5
5
|
export type { SelectChildProductEventArgs } from './components/commerce/atomic-product-children/select-child-product-event';
|
|
6
6
|
export { fetchProductContext } from './components/commerce/product-template-component-utils/context/fetch-product-context';
|
|
@@ -13,4 +13,4 @@ export type { RecsBindings } from './components/recommendations/atomic-recs-inte
|
|
|
13
13
|
export type { Bindings } from './components/search/atomic-search-interface/atomic-search-interface';
|
|
14
14
|
export { fetchBindings as initializeBindings, MissingInterfaceParentError, } from './utils/initialization-common-utils';
|
|
15
15
|
export { bindLogDocumentOpenOnResult } from './utils/result-utils';
|
|
16
|
-
export { _Components as Components, _Components as JSX };
|
|
16
|
+
export type { _Components as Components, _Components as JSX };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
type MemoizeOptions = {
|
|
2
|
+
/**
|
|
3
|
+
* Maximum number of successful entries to keep in the cache.
|
|
4
|
+
* When exceeded, the least recently used entry is evicted.
|
|
5
|
+
*/
|
|
6
|
+
maxEntries?: number;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Creates a memoized version of an async function with a custom cache key generator.
|
|
10
|
+
* Only successful results are cached - rejected promises are not remembered.
|
|
11
|
+
* Uses an LRU eviction strategy when `maxEntries` is set.
|
|
12
|
+
*
|
|
13
|
+
* @param fn - The async function to memoize
|
|
14
|
+
* @param getCacheKey - A function that generates a unique cache key from the received `fn` function arguments
|
|
15
|
+
* @param options - Optional cache configuration
|
|
16
|
+
* @returns Object with the memoized function and cache clearing capability
|
|
17
|
+
*/
|
|
18
|
+
export declare function memoize<TArgs extends unknown[], TReturn>(fn: (...args: TArgs) => Promise<TReturn>, getCacheKey: (...args: TArgs) => string, options?: MemoizeOptions): {
|
|
19
|
+
fn: (...args: TArgs) => Promise<TReturn>;
|
|
20
|
+
clearCache: () => void;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coveo/atomic",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.56.2",
|
|
4
4
|
"description": "A web-component library for building modern UIs interfacing with the Coveo platform",
|
|
5
5
|
"homepage": "https://docs.coveo.com/en/atomic/latest/",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -69,11 +69,12 @@
|
|
|
69
69
|
"i18next-http-backend": "3.0.2",
|
|
70
70
|
"lit": "3.3.2",
|
|
71
71
|
"marked": "12.0.2",
|
|
72
|
-
"@coveo/atomic-legacy": "0.0.
|
|
72
|
+
"@coveo/atomic-legacy": "0.0.12",
|
|
73
73
|
"@coveo/bueno": "1.1.9",
|
|
74
|
-
"@coveo/headless": "3.49.
|
|
74
|
+
"@coveo/headless": "3.49.3"
|
|
75
75
|
},
|
|
76
76
|
"devDependencies": {
|
|
77
|
+
"@ag-ui/client": "0.0.45",
|
|
77
78
|
"@custom-elements-manifest/analyzer": "0.10.4",
|
|
78
79
|
"@playwright/test": "1.57.0",
|
|
79
80
|
"@rollup/plugin-replace": "6.0.3",
|
|
@@ -101,7 +102,7 @@
|
|
|
101
102
|
"postcss": "8.5.6",
|
|
102
103
|
"postcss-load-config": "6.0.1",
|
|
103
104
|
"prettier": "3.7.4",
|
|
104
|
-
"puppeteer": "24.
|
|
105
|
+
"puppeteer": "24.40.0",
|
|
105
106
|
"react": "19.2.4",
|
|
106
107
|
"remark-gfm": "4.0.1",
|
|
107
108
|
"shadow-dom-testing-library": "1.12.0",
|
|
@@ -117,7 +118,7 @@
|
|
|
117
118
|
"peerDependencies": {
|
|
118
119
|
"typescript": ">=5.0.0",
|
|
119
120
|
"@coveo/bueno": "1.1.9",
|
|
120
|
-
"@coveo/headless": "3.49.
|
|
121
|
+
"@coveo/headless": "3.49.3"
|
|
121
122
|
},
|
|
122
123
|
"peerDependenciesMeta": {
|
|
123
124
|
"typescript": {
|
|
@@ -154,7 +155,7 @@
|
|
|
154
155
|
"test:storybook": "vitest run --project=storybook",
|
|
155
156
|
"generate-component": "node ./scripts/generate-component.mjs",
|
|
156
157
|
"validate:definitions": "tsc --noEmit --esModuleInterop --skipLibCheck ./dist/types/components.d.ts",
|
|
157
|
-
"chromatic": "chromatic -d=dist-storybook --only-changed",
|
|
158
|
+
"chromatic": "chromatic -d=dist-storybook --only-changed --untraced \"/virtual:*\"",
|
|
158
159
|
"validate:light-dom-styles": "node ./scripts/check-light-dom-host-selectors.mjs",
|
|
159
160
|
"validate:no-new-light-dom": "node ./scripts/check-no-new-light-dom-components.mjs"
|
|
160
161
|
}
|