@coveo/atomic 3.33.8-pre.f62f2d7753 → 3.33.8-pre.f82c4ba7d3
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 +2 -2
- package/dist/atomic/components/_index.js +1 -1
- package/dist/atomic/components/analytics-config.js +1 -1
- package/dist/atomic/components/atomic-insight-history-toggle.js +2 -2
- package/dist/atomic/components/atomic-insight-history-toggle.js.map +1 -1
- package/dist/atomic/components/atomic-insight-search-box.js +2 -29
- package/dist/atomic/components/atomic-insight-search-box.js.map +1 -1
- package/dist/atomic/components/atomic-insight-user-actions-toggle.js +2 -2
- package/dist/atomic/components/atomic-insight-user-actions-toggle.js.map +1 -1
- package/dist/atomic/components/atomic-search-box-query-suggestions.d.ts +11 -0
- package/dist/atomic/components/atomic-search-box-query-suggestions.js +8 -0
- package/dist/atomic/components/atomic-search-box-query-suggestions.js.map +1 -0
- package/dist/atomic/components/atomic-search-box-query-suggestions2.js +89 -0
- package/dist/atomic/components/atomic-search-box-query-suggestions2.js.map +1 -0
- package/dist/atomic/components/atomic-search-box.js +3 -3
- package/dist/atomic/components/clock.js +2 -2
- package/dist/atomic/components/components/commerce/atomic-commerce-breadbox/atomic-commerce-breadbox.js +18 -11
- package/dist/atomic/components/components/commerce/atomic-commerce-interface/atomic-commerce-interface.js +2 -7
- package/dist/atomic/components/components/commerce/atomic-commerce-layout/atomic-commerce-layout.js +19 -10
- package/dist/atomic/components/components/common/layout/layout-styles-controller.js +40 -0
- package/dist/atomic/components/components/common/layout/mobile-breakpoint-controller.js +26 -0
- package/dist/atomic/components/components/search/atomic-search-box-recent-queries/atomic-search-box-recent-queries.js +137 -0
- package/dist/atomic/components/components/search/index.js +1 -1
- package/dist/atomic/components/components/search/lazy-index.js +1 -1
- package/dist/atomic/components/global/environment.js +1 -1
- package/dist/atomic/components/stencil-query-suggestions.js +33 -0
- package/dist/atomic/components/stencil-query-suggestions.js.map +1 -0
- package/dist/atomic/{p-e5352270.entry.js → p-0ce38b0d.entry.js} +2 -2
- package/dist/atomic/p-26a51a77.entry.js +2 -0
- package/dist/atomic/p-26a51a77.entry.js.map +1 -0
- package/dist/atomic/{p-b24d432b.entry.js → p-299555fb.entry.js} +2 -2
- package/dist/atomic/p-2e9db4ca.entry.js +2 -0
- package/dist/atomic/p-2e9db4ca.entry.js.map +1 -0
- package/dist/atomic/{p-b87dbae7.js → p-5bc31a30.js} +2 -2
- package/dist/atomic/{p-6e6d686e.entry.js → p-7383fd32.entry.js} +2 -2
- package/dist/atomic/{p-9d6b988d.entry.js → p-88d5e178.entry.js} +2 -2
- package/dist/atomic/p-af93b44c.js +2 -0
- package/dist/atomic/p-af93b44c.js.map +1 -0
- package/dist/atomic/{p-6329ff94.entry.js → p-ba4bf29f.entry.js} +2 -2
- package/dist/atomic/{p-c280cd05.js → p-e1cc5150.js} +1 -1
- package/dist/cjs/_loader.cjs.js +1 -1
- package/dist/cjs/{analytics-config-de93a689.js → analytics-config-68dbae8e.js} +2 -2
- package/dist/cjs/{analytics-config-de93a689.js.map → analytics-config-68dbae8e.js.map} +1 -1
- package/dist/cjs/atomic-insight-history-toggle.cjs.entry.js +2 -2
- package/dist/cjs/atomic-insight-history-toggle.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-insight-interface.cjs.entry.js +1 -1
- package/dist/cjs/atomic-insight-search-box.cjs.entry.js +4 -30
- package/dist/cjs/atomic-insight-search-box.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-insight-user-actions-toggle.cjs.entry.js +2 -2
- package/dist/cjs/atomic-insight-user-actions-toggle.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-recs-interface.cjs.entry.js +1 -1
- package/dist/cjs/atomic-search-box-query-suggestions.cjs.entry.js +76 -0
- package/dist/cjs/atomic-search-box-query-suggestions.cjs.entry.js.map +1 -0
- package/dist/cjs/atomic-search-interface.cjs.entry.js +1 -1
- package/dist/cjs/atomic.cjs.js +1 -1
- package/dist/cjs/clock-7aeb19d0.js +7 -0
- package/dist/cjs/clock-7aeb19d0.js.map +1 -0
- package/dist/cjs/index-757bc886.js +2 -2
- package/dist/cjs/stencil-query-suggestions-03268ecc.js +38 -0
- package/dist/cjs/stencil-query-suggestions-03268ecc.js.map +1 -0
- package/dist/cjs/version.cjs.js +2 -2
- package/dist/esm/_loader.js +1 -1
- package/dist/esm/{analytics-config-018337bf.js → analytics-config-18d42f83.js} +2 -2
- package/dist/esm/{analytics-config-018337bf.js.map → analytics-config-18d42f83.js.map} +1 -1
- package/dist/esm/atomic-insight-history-toggle.entry.js +2 -2
- package/dist/esm/atomic-insight-history-toggle.entry.js.map +1 -1
- package/dist/esm/atomic-insight-interface.entry.js +1 -1
- package/dist/esm/atomic-insight-search-box.entry.js +3 -29
- package/dist/esm/atomic-insight-search-box.entry.js.map +1 -1
- package/dist/esm/atomic-insight-user-actions-toggle.entry.js +2 -2
- package/dist/esm/atomic-insight-user-actions-toggle.entry.js.map +1 -1
- package/dist/esm/atomic-recs-interface.entry.js +1 -1
- package/dist/esm/atomic-search-box-query-suggestions.entry.js +72 -0
- package/dist/esm/atomic-search-box-query-suggestions.entry.js.map +1 -0
- package/dist/esm/atomic-search-interface.entry.js +1 -1
- package/dist/esm/atomic.js +1 -1
- package/dist/esm/clock-b1f5d7f7.js +5 -0
- package/dist/esm/clock-b1f5d7f7.js.map +1 -0
- package/dist/esm/index-3f35faca.js +2 -2
- package/dist/esm/stencil-query-suggestions-5d6a46d7.js +33 -0
- package/dist/esm/stencil-query-suggestions-5d6a46d7.js.map +1 -0
- package/dist/esm/version.js +2 -2
- package/dist/types/components/commerce/atomic-commerce-breadbox/atomic-commerce-breadbox.d.ts +2 -1
- package/dist/types/components/commerce/atomic-commerce-interface/atomic-commerce-interface.d.ts +0 -1
- package/dist/types/components/commerce/atomic-commerce-layout/atomic-commerce-layout.d.ts +3 -3
- package/dist/types/components/common/layout/layout-styles-controller.d.ts +22 -0
- package/dist/types/components/common/layout/mobile-breakpoint-controller.d.ts +18 -0
- package/dist/types/components/search/{atomic-search-box-query-suggestions/atomic-search-box-query-suggestions.d.ts → atomic-search-box-recent-queries/atomic-search-box-recent-queries.d.ts} +14 -7
- package/dist/types/components/search/index.d.ts +1 -1
- package/dist/types/components/search/search-box-suggestions/{atomic-search-box-recent-queries/atomic-search-box-recent-queries.d.ts → atomic-search-box-query-suggestions/atomic-search-box-query-suggestions.d.ts} +3 -11
- package/dist/types/components.d.ts +14 -14
- package/docs/atomic-docs.json +13 -11
- package/package.json +3 -3
- package/dist/atomic/components/atomic-search-box-recent-queries.d.ts +0 -11
- package/dist/atomic/components/atomic-search-box-recent-queries.js +0 -8
- package/dist/atomic/components/atomic-search-box-recent-queries.js.map +0 -1
- package/dist/atomic/components/atomic-search-box-recent-queries2.js +0 -183
- package/dist/atomic/components/atomic-search-box-recent-queries2.js.map +0 -1
- package/dist/atomic/components/components/search/atomic-search-box-query-suggestions/atomic-search-box-query-suggestions.js +0 -111
- package/dist/atomic/p-7a06a356.entry.js +0 -2
- package/dist/atomic/p-7a06a356.entry.js.map +0 -1
- package/dist/atomic/p-d2b14ff1.entry.js +0 -2
- package/dist/atomic/p-d2b14ff1.entry.js.map +0 -1
- package/dist/cjs/atomic-search-box-recent-queries.cjs.entry.js +0 -171
- package/dist/cjs/atomic-search-box-recent-queries.cjs.entry.js.map +0 -1
- package/dist/cjs/clock-f03ff827.js +0 -7
- package/dist/cjs/clock-f03ff827.js.map +0 -1
- package/dist/esm/atomic-search-box-recent-queries.entry.js +0 -167
- package/dist/esm/atomic-search-box-recent-queries.entry.js.map +0 -1
- package/dist/esm/clock-add3e9a5.js +0 -5
- package/dist/esm/clock-add3e9a5.js.map +0 -1
- /package/dist/atomic/{p-e5352270.entry.js.map → p-0ce38b0d.entry.js.map} +0 -0
- /package/dist/atomic/{p-b24d432b.entry.js.map → p-299555fb.entry.js.map} +0 -0
- /package/dist/atomic/{p-b87dbae7.js.map → p-5bc31a30.js.map} +0 -0
- /package/dist/atomic/{p-6e6d686e.entry.js.map → p-7383fd32.entry.js.map} +0 -0
- /package/dist/atomic/{p-9d6b988d.entry.js.map → p-88d5e178.entry.js.map} +0 -0
- /package/dist/atomic/{p-6329ff94.entry.js.map → p-ba4bf29f.entry.js.map} +0 -0
- /package/dist/atomic/{p-c280cd05.js.map → p-e1cc5150.js.map} +0 -0
package/dist/atomic/components/components/commerce/atomic-commerce-layout/atomic-commerce-layout.js
CHANGED
@@ -4,11 +4,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
4
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
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6
6
|
};
|
7
|
-
import { LitElement
|
7
|
+
import { LitElement } from 'lit';
|
8
8
|
import { customElement, property, state } from 'lit/decorators.js';
|
9
|
+
import { LayoutStylesController } from "../../common/layout/layout-styles-controller";
|
10
|
+
import { watch } from "../../../decorators/watch";
|
9
11
|
import { ChildrenUpdateCompleteMixin } from "../../../mixins/children-update-complete-mixin";
|
10
12
|
import { LightDomMixin } from "../../../mixins/light-dom";
|
11
|
-
import { randomID } from "../../../utils/utils";
|
12
13
|
import { DEFAULT_MOBILE_BREAKPOINT } from '../../../utils/replace-breakpoint-utils';
|
13
14
|
import styles from './atomic-commerce-layout.tw.css';
|
14
15
|
import { buildCommerceLayout } from './commerce-layout';
|
@@ -18,8 +19,6 @@ import { buildCommerceLayout } from './commerce-layout';
|
|
18
19
|
* @cssprop --atomic-layout-max-search-box-input-width: The maximum width that the search box input will take.
|
19
20
|
* @cssprop --atomic-layout-max-search-box-double-suggestions-width: The maximum width that the search box suggestions will take when displaying a double list.
|
20
21
|
* @cssprop --atomic-layout-search-box-left-suggestions-width: The width of the left list when displaying a double list.
|
21
|
-
*
|
22
|
-
* @slot default - The default slot for the layout content.
|
23
22
|
*/
|
24
23
|
let AtomicCommerceLayout = class AtomicCommerceLayout extends LightDomMixin(ChildrenUpdateCompleteMixin(LitElement)) {
|
25
24
|
constructor() {
|
@@ -29,15 +28,22 @@ let AtomicCommerceLayout = class AtomicCommerceLayout extends LightDomMixin(Chil
|
|
29
28
|
* E.g., 800px, 65rem.
|
30
29
|
*/
|
31
30
|
this.mobileBreakpoint = DEFAULT_MOBILE_BREAKPOINT;
|
32
|
-
|
33
|
-
async addStyles() {
|
34
|
-
await this.getUpdateComplete();
|
35
|
-
this.injectStyles(unsafeCSS(buildCommerceLayout(this, this.mobileBreakpoint)));
|
31
|
+
this.layoutStylesController = new LayoutStylesController(this, buildCommerceLayout, 'atomic-commerce-layout-');
|
36
32
|
}
|
37
33
|
connectedCallback() {
|
38
34
|
super.connectedCallback();
|
39
|
-
this.
|
40
|
-
|
35
|
+
this.emitBreakpointChangeEvent();
|
36
|
+
}
|
37
|
+
emitBreakpointChangeEvent() {
|
38
|
+
this.dispatchEvent(new CustomEvent('atomic-layout-breakpoint-change', {
|
39
|
+
detail: { breakpoint: this.mobileBreakpoint },
|
40
|
+
bubbles: true,
|
41
|
+
composed: true,
|
42
|
+
}));
|
43
|
+
}
|
44
|
+
onMobileBreakpointChange() {
|
45
|
+
this.layoutStylesController.updateStyles();
|
46
|
+
this.emitBreakpointChangeEvent();
|
41
47
|
}
|
42
48
|
};
|
43
49
|
AtomicCommerceLayout.styles = [styles];
|
@@ -47,6 +53,9 @@ __decorate([
|
|
47
53
|
__decorate([
|
48
54
|
property({ type: String, reflect: true, attribute: 'mobile-breakpoint' })
|
49
55
|
], AtomicCommerceLayout.prototype, "mobileBreakpoint", void 0);
|
56
|
+
__decorate([
|
57
|
+
watch('mobileBreakpoint')
|
58
|
+
], AtomicCommerceLayout.prototype, "onMobileBreakpointChange", null);
|
50
59
|
AtomicCommerceLayout = __decorate([
|
51
60
|
customElement('atomic-commerce-layout')
|
52
61
|
], AtomicCommerceLayout);
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import { randomID } from "../../../utils/utils";
|
2
|
+
/**
|
3
|
+
* A reactive controller that manages dynamic layout styles.
|
4
|
+
*/
|
5
|
+
export class LayoutStylesController {
|
6
|
+
constructor(host, stylesBuilder, componentPrefix) {
|
7
|
+
this.dynamicStyleSheet = null;
|
8
|
+
this.host = host;
|
9
|
+
this.stylesBuilder = stylesBuilder;
|
10
|
+
this.componentPrefix = componentPrefix;
|
11
|
+
this.host.addController(this);
|
12
|
+
}
|
13
|
+
hostConnected() {
|
14
|
+
if (!this.host.id) {
|
15
|
+
this.host.id = randomID(this.componentPrefix);
|
16
|
+
}
|
17
|
+
this.host.updateComplete.then(() => this.updateStyles());
|
18
|
+
}
|
19
|
+
/**
|
20
|
+
* Updates the dynamic styles based on the current mobile breakpoint
|
21
|
+
*/
|
22
|
+
updateStyles() {
|
23
|
+
const parent = this.host.getRootNode();
|
24
|
+
const isDocumentOrShadowRoot = parent instanceof Document || parent instanceof ShadowRoot;
|
25
|
+
if (!isDocumentOrShadowRoot) {
|
26
|
+
return;
|
27
|
+
}
|
28
|
+
const newStylesCSS = this.stylesBuilder(this.host, this.host.mobileBreakpoint);
|
29
|
+
if (!this.dynamicStyleSheet) {
|
30
|
+
this.dynamicStyleSheet = new CSSStyleSheet();
|
31
|
+
this.dynamicStyleSheet.replaceSync(newStylesCSS);
|
32
|
+
parent.adoptedStyleSheets = [
|
33
|
+
...parent.adoptedStyleSheets,
|
34
|
+
this.dynamicStyleSheet,
|
35
|
+
];
|
36
|
+
return;
|
37
|
+
}
|
38
|
+
this.dynamicStyleSheet.replaceSync(newStylesCSS);
|
39
|
+
}
|
40
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
/**
|
2
|
+
* A reactive controller that manages mobile breakpoint changes through event communication.
|
3
|
+
* This controller listens for 'atomic-layout-breakpoint-change' events and updates a store
|
4
|
+
* with the new breakpoint value.
|
5
|
+
*/
|
6
|
+
export class MobileBreakpointController {
|
7
|
+
constructor(host, store) {
|
8
|
+
this.host = host;
|
9
|
+
this.store = store;
|
10
|
+
this.eventListener = this.handleBreakpointChange.bind(this);
|
11
|
+
this.host.addController(this);
|
12
|
+
}
|
13
|
+
hostConnected() {
|
14
|
+
this.host.addEventListener('atomic-layout-breakpoint-change', this.eventListener);
|
15
|
+
}
|
16
|
+
hostDisconnected() {
|
17
|
+
this.host.removeEventListener('atomic-layout-breakpoint-change', this.eventListener);
|
18
|
+
}
|
19
|
+
handleBreakpointChange(e) {
|
20
|
+
const customEvent = e;
|
21
|
+
const newBreakpoint = customEvent.detail?.breakpoint;
|
22
|
+
if (newBreakpoint && this.store.state.mobileBreakpoint !== newBreakpoint) {
|
23
|
+
this.store.state.mobileBreakpoint = newBreakpoint;
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}
|
@@ -0,0 +1,137 @@
|
|
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 { buildRecentQueriesList, } from '@coveo/headless';
|
8
|
+
import { html, LitElement, nothing } from 'lit';
|
9
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
10
|
+
import { errorGuard } from "../../../decorators/error-guard";
|
11
|
+
import { SafeStorage, StorageItems } from "../../../utils/local-storage-utils";
|
12
|
+
import { once } from "../../../utils/utils";
|
13
|
+
const Clock = "<svg fill=\"none\" stroke=\"currentColor\" stroke-linejoin=\"round\" stroke-linecap=\"round\" viewBox=\"0 0 16 16\" xmlns=\"http://www.w3.org/2000/svg\"><circle cx=\"8\" cy=\"8\" r=\"7.5\"/><path d=\"m8.5 4.5v4\"/><path d=\"m10.3066 10.1387-1.80932-1.5768\"/></svg>";
|
14
|
+
import { getPartialRecentQueryClearElement, getPartialRecentQueryElement, renderRecentQuery, renderRecentQueryClear, } from '../../common/suggestions/recent-queries';
|
15
|
+
import { dispatchSearchBoxSuggestionsEvent } from '../../common/suggestions/suggestions-events';
|
16
|
+
/**
|
17
|
+
* The `atomic-search-box-recent-queries` component can be added as a child of an `atomic-search-box` component, allowing for the configuration of recent query suggestions.
|
18
|
+
*/
|
19
|
+
let AtomicSearchBoxRecentQueries = class AtomicSearchBoxRecentQueries extends LitElement {
|
20
|
+
constructor() {
|
21
|
+
super(...arguments);
|
22
|
+
/**
|
23
|
+
* The maximum number of suggestions that will be displayed if the user has typed something into the input field.
|
24
|
+
*/
|
25
|
+
this.maxWithQuery = 3;
|
26
|
+
this.warnUser = once(() => this.bindings.engine.logger.warn('Because analytics are disabled, the recent queries feature is deactivated.'));
|
27
|
+
}
|
28
|
+
connectedCallback() {
|
29
|
+
super.connectedCallback();
|
30
|
+
try {
|
31
|
+
dispatchSearchBoxSuggestionsEvent((bindings) => {
|
32
|
+
this.bindings = bindings;
|
33
|
+
return this.initialize();
|
34
|
+
}, this, ['atomic-search-box']);
|
35
|
+
}
|
36
|
+
catch (error) {
|
37
|
+
this.error = error;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
initialize() {
|
41
|
+
this.storage = new SafeStorage();
|
42
|
+
this.recentQueriesList = buildRecentQueriesList(this.bindings.engine, {
|
43
|
+
initialState: { queries: this.retrieveLocalStorage() },
|
44
|
+
options: {
|
45
|
+
maxLength: 1000,
|
46
|
+
clearFilters: this.bindings.clearFilters,
|
47
|
+
},
|
48
|
+
});
|
49
|
+
this.recentQueriesList.subscribe(() => this.updateLocalStorage());
|
50
|
+
return {
|
51
|
+
position: Array.from(this.parentNode.children).indexOf(this),
|
52
|
+
renderItems: () => this.renderItems(),
|
53
|
+
};
|
54
|
+
}
|
55
|
+
retrieveLocalStorage() {
|
56
|
+
return this.storage.getParsedJSON(StorageItems.RECENT_QUERIES, []);
|
57
|
+
}
|
58
|
+
updateLocalStorage() {
|
59
|
+
if (!this.recentQueriesList.state.analyticsEnabled) {
|
60
|
+
return this.disableFeature();
|
61
|
+
}
|
62
|
+
return this.storage.setJSON(StorageItems.RECENT_QUERIES, this.recentQueriesList.state.queries);
|
63
|
+
}
|
64
|
+
disableFeature() {
|
65
|
+
this.warnUser();
|
66
|
+
this.storage.removeItem(StorageItems.RECENT_QUERIES);
|
67
|
+
}
|
68
|
+
renderItems() {
|
69
|
+
if (!this.recentQueriesList.state.analyticsEnabled) {
|
70
|
+
return [];
|
71
|
+
}
|
72
|
+
const query = this.bindings.searchBoxController.state.value;
|
73
|
+
const hasQuery = query !== '';
|
74
|
+
const max = hasQuery ? this.maxWithQuery : this.maxWithoutQuery;
|
75
|
+
const filteredQueries = this.recentQueriesList.state.queries
|
76
|
+
.filter((recentQuery) => recentQuery.toLowerCase().startsWith(query.toLowerCase()))
|
77
|
+
.slice(0, max);
|
78
|
+
const suggestionElements = filteredQueries.map((value) => this.renderItem(value));
|
79
|
+
if (suggestionElements.length) {
|
80
|
+
suggestionElements.unshift(this.renderClear());
|
81
|
+
}
|
82
|
+
return suggestionElements;
|
83
|
+
}
|
84
|
+
renderClear() {
|
85
|
+
const partialItem = getPartialRecentQueryClearElement(this.bindings.i18n);
|
86
|
+
return {
|
87
|
+
...partialItem,
|
88
|
+
content: renderRecentQueryClear({ i18n: this.bindings.i18n }),
|
89
|
+
onSelect: () => {
|
90
|
+
this.recentQueriesList.clear();
|
91
|
+
this.bindings.triggerSuggestions();
|
92
|
+
},
|
93
|
+
};
|
94
|
+
}
|
95
|
+
renderItem(value) {
|
96
|
+
const query = this.bindings.searchBoxController.state.value;
|
97
|
+
const partialItem = getPartialRecentQueryElement(value, this.bindings.i18n);
|
98
|
+
return {
|
99
|
+
...partialItem,
|
100
|
+
content: renderRecentQuery({
|
101
|
+
icon: this.icon || Clock,
|
102
|
+
query,
|
103
|
+
value,
|
104
|
+
}),
|
105
|
+
onSelect: () => {
|
106
|
+
if (this.bindings.isStandalone) {
|
107
|
+
this.bindings.searchBoxController.updateText(value);
|
108
|
+
this.bindings.searchBoxController.submit();
|
109
|
+
return;
|
110
|
+
}
|
111
|
+
this.recentQueriesList.executeRecentQuery(this.recentQueriesList.state.queries.indexOf(value));
|
112
|
+
},
|
113
|
+
};
|
114
|
+
}
|
115
|
+
render() {
|
116
|
+
return html `${nothing}`;
|
117
|
+
}
|
118
|
+
};
|
119
|
+
__decorate([
|
120
|
+
state()
|
121
|
+
], AtomicSearchBoxRecentQueries.prototype, "error", void 0);
|
122
|
+
__decorate([
|
123
|
+
property()
|
124
|
+
], AtomicSearchBoxRecentQueries.prototype, "icon", void 0);
|
125
|
+
__decorate([
|
126
|
+
property({ type: Number, attribute: 'max-with-query' })
|
127
|
+
], AtomicSearchBoxRecentQueries.prototype, "maxWithQuery", void 0);
|
128
|
+
__decorate([
|
129
|
+
property({ type: Number, attribute: 'max-without-query' })
|
130
|
+
], AtomicSearchBoxRecentQueries.prototype, "maxWithoutQuery", void 0);
|
131
|
+
__decorate([
|
132
|
+
errorGuard()
|
133
|
+
], AtomicSearchBoxRecentQueries.prototype, "render", null);
|
134
|
+
AtomicSearchBoxRecentQueries = __decorate([
|
135
|
+
customElement('atomic-search-box-recent-queries')
|
136
|
+
], AtomicSearchBoxRecentQueries);
|
137
|
+
export { AtomicSearchBoxRecentQueries };
|
@@ -1,5 +1,5 @@
|
|
1
1
|
// Auto-generated file
|
2
2
|
export { AtomicQuerySummary } from './atomic-query-summary/atomic-query-summary.js';
|
3
3
|
export { AtomicResultsPerPage } from './atomic-results-per-page/atomic-results-per-page.js';
|
4
|
-
export {
|
4
|
+
export { AtomicSearchBoxRecentQueries } from './atomic-search-box-recent-queries/atomic-search-box-recent-queries.js';
|
5
5
|
export { AtomicSearchLayout } from './atomic-search-layout/atomic-search-layout.js';
|
@@ -2,6 +2,6 @@
|
|
2
2
|
export default {
|
3
3
|
'atomic-query-summary': async () => await import('./atomic-query-summary/atomic-query-summary.js'),
|
4
4
|
'atomic-results-per-page': async () => await import('./atomic-results-per-page/atomic-results-per-page.js'),
|
5
|
-
'atomic-search-box-
|
5
|
+
'atomic-search-box-recent-queries': async () => await import('./atomic-search-box-recent-queries/atomic-search-box-recent-queries.js'),
|
6
6
|
'atomic-search-layout': async () => await import('./atomic-search-layout/atomic-search-layout.js'),
|
7
7
|
};
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { h } from '@stencil/core/internal/client';
|
2
|
+
import { e as encodeForDomAttribute } from './string-utils.js';
|
3
|
+
|
4
|
+
const getPartialSearchBoxSuggestionElement = (suggestion, i18n) => {
|
5
|
+
return {
|
6
|
+
part: 'query-suggestion-item',
|
7
|
+
key: `qs-${encodeForDomAttribute(suggestion.rawValue)}`,
|
8
|
+
query: suggestion.rawValue,
|
9
|
+
ariaLabel: i18n.t('query-suggestion-label', {
|
10
|
+
query: suggestion.rawValue,
|
11
|
+
interpolation: { escapeValue: false },
|
12
|
+
}),
|
13
|
+
};
|
14
|
+
};
|
15
|
+
const QuerySuggestionContainer = (_, children) => {
|
16
|
+
return (h("div", { part: "query-suggestion-content", class: "flex items-center" }, children));
|
17
|
+
};
|
18
|
+
const QuerySuggestionIcon = ({ icon, hasSuggestion }) => {
|
19
|
+
if (!hasSuggestion) {
|
20
|
+
return;
|
21
|
+
}
|
22
|
+
return (h("atomic-icon", { part: "query-suggestion-icon", icon: icon, class: "mr-2 h-4 w-4 shrink-0" }));
|
23
|
+
};
|
24
|
+
const QuerySuggestionText = ({ suggestion, hasQuery }) => {
|
25
|
+
if (hasQuery) {
|
26
|
+
return (h("span", { part: "query-suggestion-text", class: "line-clamp-2 break-all", innerHTML: suggestion.highlightedValue }));
|
27
|
+
}
|
28
|
+
return (h("span", { part: "query-suggestion-text", class: "line-clamp-2 break-all" }, suggestion.rawValue));
|
29
|
+
};
|
30
|
+
|
31
|
+
export { QuerySuggestionContainer as Q, QuerySuggestionIcon as a, QuerySuggestionText as b, getPartialSearchBoxSuggestionElement as g };
|
32
|
+
|
33
|
+
//# sourceMappingURL=stencil-query-suggestions.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"file":"stencil-query-suggestions.js","mappings":";;;MAUa,oCAAoC,GAAG,CAClD,UAAsB,EACtB,IAAU;IAEV,OAAO;QACL,IAAI,EAAE,uBAAuB;QAC7B,GAAG,EAAE,MAAM,qBAAqB,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE;QACvD,KAAK,EAAE,UAAU,CAAC,QAAQ;QAC1B,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC,wBAAwB,EAAE;YAC1C,KAAK,EAAE,UAAU,CAAC,QAAQ;YAC1B,aAAa,EAAE,EAAC,WAAW,EAAE,KAAK,EAAC;SACpC,CAAC;KACH,CAAC;AACJ,EAAE;MAEW,wBAAwB,GAAwB,CAAC,CAAC,EAAE,QAAQ;IACvE,QACE,WAAK,IAAI,EAAC,0BAA0B,EAAC,KAAK,EAAC,mBAAmB,IAC3D,QAAQ,CACL,EACN;AACJ,EAAE;MAOW,mBAAmB,GAE5B,CAAC,EAAC,IAAI,EAAE,aAAa,EAAC;IACxB,IAAI,CAAC,aAAa,EAAE;QAClB,OAAO;KACR;IAED,QACE,mBACE,IAAI,EAAC,uBAAuB,EAC5B,IAAI,EAAE,IAAI,EACV,KAAK,EAAC,uBAAuB,GAChB,EACf;AACJ,EAAE;MAOW,mBAAmB,GAE5B,CAAC,EAAC,UAAU,EAAE,QAAQ,EAAC;IACzB,IAAI,QAAQ,EAAE;QACZ,QACE,YACE,IAAI,EAAC,uBAAuB,EAC5B,KAAK,EAAC,wBAAwB,EAC9B,SAAS,EAAE,UAAU,CAAC,gBAAgB,GAChC,EACR;KACH;IAED,QACE,YAAM,IAAI,EAAC,uBAAuB,EAAC,KAAK,EAAC,wBAAwB,IAC9D,UAAU,CAAC,QAAQ,CACf,EACP;AACJ;;;;","names":[],"sources":["src/components/common/suggestions/stencil-query-suggestions.tsx"],"sourcesContent":["import {FunctionalComponent, h} from '@stencil/core';\nimport {i18n} from 'i18next';\nimport {encodeForDomAttribute} from '../../../utils/string-utils.js';\nimport {SearchBoxSuggestionElement} from './suggestions-types.js';\n\ninterface Suggestion {\n highlightedValue: string;\n rawValue: string;\n}\n\nexport const getPartialSearchBoxSuggestionElement = (\n suggestion: Suggestion,\n i18n: i18n\n): Pick<SearchBoxSuggestionElement, 'ariaLabel' | 'key' | 'query' | 'part'> => {\n return {\n part: 'query-suggestion-item',\n key: `qs-${encodeForDomAttribute(suggestion.rawValue)}`,\n query: suggestion.rawValue,\n ariaLabel: i18n.t('query-suggestion-label', {\n query: suggestion.rawValue,\n interpolation: {escapeValue: false},\n }),\n };\n};\n\nexport const QuerySuggestionContainer: FunctionalComponent = (_, children) => {\n return (\n <div part=\"query-suggestion-content\" class=\"flex items-center\">\n {children}\n </div>\n );\n};\n\ninterface QuerySuggestionIconProps {\n icon: string;\n hasSuggestion: boolean;\n}\n\nexport const QuerySuggestionIcon: FunctionalComponent<\n QuerySuggestionIconProps\n> = ({icon, hasSuggestion}) => {\n if (!hasSuggestion) {\n return;\n }\n\n return (\n <atomic-icon\n part=\"query-suggestion-icon\"\n icon={icon}\n class=\"mr-2 h-4 w-4 shrink-0\"\n ></atomic-icon>\n );\n};\n\ninterface QuerySuggestionTextProps {\n suggestion: Suggestion;\n hasQuery: boolean;\n}\n\nexport const QuerySuggestionText: FunctionalComponent<\n QuerySuggestionTextProps\n> = ({suggestion, hasQuery}) => {\n if (hasQuery) {\n return (\n <span\n part=\"query-suggestion-text\"\n class=\"line-clamp-2 break-all\"\n innerHTML={suggestion.highlightedValue}\n ></span>\n );\n }\n\n return (\n <span part=\"query-suggestion-text\" class=\"line-clamp-2 break-all\">\n {suggestion.rawValue}\n </span>\n );\n};\n"],"version":3}
|