@coveo/atomic 3.33.8-pre.d75d8e5578 → 3.33.8-pre.de35a78164
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/components/_index.js +2 -1
- package/dist/atomic/components/analytics-config.js +1 -1
- package/dist/atomic/components/atomic-insight-search-box.js +3 -4
- package/dist/atomic/components/atomic-insight-search-box.js.map +1 -1
- package/dist/atomic/components/atomic-search-box-instant-results.js +2 -2
- package/dist/atomic/components/atomic-search-box-instant-results.js.map +1 -1
- package/dist/atomic/components/atomic-search-box-query-suggestions2.js +2 -2
- package/dist/atomic/components/atomic-search-box-query-suggestions2.js.map +1 -1
- package/dist/atomic/components/atomic-search-box-recent-queries2.js +2 -2
- package/dist/atomic/components/atomic-search-box-recent-queries2.js.map +1 -1
- package/dist/atomic/components/atomic-search-box.js +5 -6
- package/dist/atomic/components/atomic-search-box.js.map +1 -1
- package/dist/atomic/components/atomic-suggestion-renderer2.js +1 -1
- package/dist/atomic/components/atomic-suggestion-renderer2.js.map +1 -1
- package/dist/atomic/components/components/commerce/atomic-commerce-breadbox/atomic-commerce-breadbox.js +1 -4
- package/dist/atomic/components/components/commerce/atomic-commerce-interface/atomic-commerce-interface.js +50 -8
- package/dist/atomic/components/components/commerce/atomic-commerce-query-summary/atomic-commerce-query-summary.js +2 -2
- package/dist/atomic/components/components/commerce/atomic-commerce-recommendation-interface/atomic-commerce-recommendation-interface.js +25 -10
- package/dist/atomic/components/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.js +1 -1
- package/dist/atomic/components/components/commerce/atomic-commerce-search-box-instant-products/atomic-commerce-search-box-instant-products.js +1 -1
- package/dist/atomic/components/components/commerce/atomic-commerce-search-box-query-suggestions/atomic-commerce-search-box-query-suggestions.js +1 -1
- package/dist/atomic/components/components/commerce/atomic-commerce-search-box-recent-queries/atomic-commerce-search-box-recent-queries.js +1 -1
- package/dist/atomic/components/components/common/atomic-modal/atomic-modal.js +2 -0
- package/dist/atomic/components/components/common/layout/layout-styles-controller.js +1 -1
- package/dist/atomic/components/components/common/suggestions/suggestion-manager.js +1 -1
- package/dist/atomic/components/components/common/suggestions/{suggestions-common.js → suggestions-events.js} +16 -18
- package/dist/atomic/components/components/common/suggestions/suggestions-types.js +1 -0
- package/dist/atomic/components/components/common/suggestions/suggestions-utils.js +18 -0
- package/dist/atomic/components/global/environment.js +1 -1
- package/dist/atomic/components/index.js.map +1 -1
- package/dist/atomic/components/stencil-query-suggestions.js.map +1 -1
- package/dist/atomic/components/stencil-suggestion-manager.js +20 -2
- package/dist/atomic/components/stencil-suggestion-manager.js.map +1 -1
- package/dist/atomic/components/{suggestions-common.js → suggestions-events.js} +18 -20
- package/dist/atomic/components/suggestions-events.js.map +1 -0
- package/dist/atomic/index.esm.js +1 -1
- package/dist/atomic/index.esm.js.map +1 -1
- package/dist/atomic/p-0a051b8d.js +2 -0
- package/dist/atomic/p-0a051b8d.js.map +1 -0
- package/dist/atomic/p-16f4ce98.js +2 -0
- package/dist/atomic/p-16f4ce98.js.map +1 -0
- package/dist/atomic/{p-8867af82.entry.js → p-26a51a77.entry.js} +2 -2
- package/dist/atomic/p-26a51a77.entry.js.map +1 -0
- package/dist/atomic/{p-c1bf43cf.entry.js → p-31f1e44e.entry.js} +2 -2
- package/dist/atomic/p-31f1e44e.entry.js.map +1 -0
- package/dist/atomic/p-4b7a19db.js +2 -0
- package/dist/atomic/p-4b7a19db.js.map +1 -0
- package/dist/atomic/{p-0bfa74d3.entry.js → p-4ca61a15.entry.js} +2 -2
- package/dist/atomic/{p-828d74f8.entry.js → p-9f172e51.entry.js} +2 -2
- package/dist/atomic/p-af93b44c.js.map +1 -1
- package/dist/atomic/{p-caa647d5.js → p-b6d8adf1.js} +2 -2
- package/dist/atomic/{p-3d847e45.entry.js → p-c88a3d2d.entry.js} +2 -2
- package/dist/atomic/p-c88a3d2d.entry.js.map +1 -0
- package/dist/atomic/{p-36e71b99.entry.js → p-d0f47b33.entry.js} +2 -2
- package/dist/atomic/p-d0f47b33.entry.js.map +1 -0
- package/dist/atomic/{p-8b9b8089.entry.js → p-ec43f802.entry.js} +2 -2
- package/dist/atomic/{p-aa4224ea.entry.js → p-fbfe913d.entry.js} +2 -2
- package/dist/atomic/p-fbfe913d.entry.js.map +1 -0
- package/dist/cjs/_index.cjs.js +5 -2
- package/dist/cjs/{analytics-config-75507a47.js → analytics-config-bc4ee794.js} +2 -2
- package/dist/cjs/{analytics-config-75507a47.js.map → analytics-config-bc4ee794.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 +5 -5
- package/dist/cjs/atomic-insight-search-box.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-recs-interface.cjs.entry.js +1 -1
- package/dist/cjs/atomic-search-box-instant-results.cjs.entry.js +3 -3
- package/dist/cjs/atomic-search-box-instant-results.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-search-box-query-suggestions_2.cjs.entry.js +5 -5
- package/dist/cjs/atomic-search-box-query-suggestions_2.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-search-box.cjs.entry.js +7 -7
- package/dist/cjs/atomic-search-box.cjs.entry.js.map +1 -1
- package/dist/cjs/atomic-search-interface.cjs.entry.js +1 -1
- package/dist/cjs/atomic-suggestion-renderer.cjs.entry.js +1 -1
- package/dist/cjs/atomic-suggestion-renderer.cjs.entry.js.map +1 -1
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/stencil-query-suggestions-03268ecc.js.map +1 -1
- package/dist/cjs/{stencil-suggestion-manager-c0878ef2.js → stencil-suggestion-manager-2cba6d69.js} +4 -4
- package/dist/cjs/{stencil-suggestion-manager-c0878ef2.js.map → stencil-suggestion-manager-2cba6d69.js.map} +1 -1
- package/dist/cjs/{suggestions-common-5097a362.js → suggestions-events-63dd0640.js} +17 -21
- package/dist/cjs/suggestions-events-63dd0640.js.map +1 -0
- package/dist/cjs/suggestions-utils-61000808.js +25 -0
- package/dist/cjs/suggestions-utils-61000808.js.map +1 -0
- package/dist/cjs/version.cjs.js +2 -2
- package/dist/esm/_index.js +2 -1
- package/dist/esm/{analytics-config-54cbe2b9.js → analytics-config-37553b6a.js} +2 -2
- package/dist/esm/{analytics-config-54cbe2b9.js.map → analytics-config-37553b6a.js.map} +1 -1
- package/dist/esm/atomic-insight-interface.entry.js +1 -1
- package/dist/esm/atomic-insight-search-box.entry.js +4 -4
- package/dist/esm/atomic-insight-search-box.entry.js.map +1 -1
- package/dist/esm/atomic-recs-interface.entry.js +1 -1
- package/dist/esm/atomic-search-box-instant-results.entry.js +2 -2
- package/dist/esm/atomic-search-box-instant-results.entry.js.map +1 -1
- package/dist/esm/atomic-search-box-query-suggestions_2.entry.js +3 -3
- package/dist/esm/atomic-search-box-query-suggestions_2.entry.js.map +1 -1
- package/dist/esm/atomic-search-box.entry.js +6 -6
- package/dist/esm/atomic-search-box.entry.js.map +1 -1
- package/dist/esm/atomic-search-interface.entry.js +1 -1
- package/dist/esm/atomic-suggestion-renderer.entry.js +1 -1
- package/dist/esm/atomic-suggestion-renderer.entry.js.map +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/stencil-query-suggestions-5d6a46d7.js.map +1 -1
- package/dist/esm/{stencil-suggestion-manager-486094dd.js → stencil-suggestion-manager-376f83e8.js} +2 -2
- package/dist/esm/{stencil-suggestion-manager-486094dd.js.map → stencil-suggestion-manager-376f83e8.js.map} +1 -1
- package/dist/esm/{suggestions-common-2b20db26.js → suggestions-events-b7a6f007.js} +18 -20
- package/dist/esm/suggestions-events-b7a6f007.js.map +1 -0
- package/dist/esm/suggestions-utils-591559a0.js +22 -0
- package/dist/esm/suggestions-utils-591559a0.js.map +1 -0
- package/dist/esm/version.js +2 -2
- package/dist/types/components/commerce/atomic-commerce-breadbox/atomic-commerce-breadbox.d.ts +1 -2
- package/dist/types/components/commerce/atomic-commerce-interface/atomic-commerce-interface.d.ts +29 -2
- package/dist/types/components/commerce/atomic-commerce-recommendation-interface/atomic-commerce-recommendation-interface.d.ts +1 -0
- package/dist/types/components/commerce/atomic-commerce-search-box-instant-products/atomic-commerce-search-box-instant-products.d.ts +1 -1
- package/dist/types/components/commerce/atomic-commerce-search-box-query-suggestions/atomic-commerce-search-box-query-suggestions.d.ts +1 -1
- package/dist/types/components/commerce/atomic-commerce-search-box-recent-queries/atomic-commerce-search-box-recent-queries.d.ts +1 -1
- package/dist/types/components/common/atomic-suggestion-renderer/atomic-suggestion-renderer.d.ts +1 -1
- package/dist/types/components/common/suggestions/instant-item.d.ts +1 -1
- package/dist/types/components/common/suggestions/query-suggestions.d.ts +1 -1
- package/dist/types/components/common/suggestions/recent-queries.d.ts +1 -1
- package/dist/types/components/common/suggestions/stencil-instant-item.d.ts +1 -1
- package/dist/types/components/common/suggestions/stencil-query-suggestions.d.ts +1 -1
- package/dist/types/components/common/suggestions/stencil-recent-queries.d.ts +1 -1
- package/dist/types/components/common/suggestions/stencil-suggestion-manager.d.ts +1 -1
- package/dist/types/components/common/suggestions/suggestion-manager.d.ts +1 -1
- package/dist/types/components/common/suggestions/suggestions-events.d.ts +14 -0
- package/dist/types/components/common/suggestions/{suggestions-common.d.ts → suggestions-types.d.ts} +6 -16
- package/dist/types/components/common/suggestions/suggestions-utils.d.ts +15 -0
- package/dist/types/components/search/atomic-search-box/atomic-search-box.d.ts +1 -1
- package/dist/types/components/search/search-box-suggestions/atomic-search-box-instant-results/atomic-search-box-instant-results.d.ts +1 -1
- package/dist/types/components.d.ts +2 -2
- package/dist/types/decorators/types.d.ts +1 -1
- package/dist/types/index.d.ts +3 -1
- package/docs/atomic-docs.json +3 -3
- package/package.json +3 -3
- package/dist/atomic/components/suggestions-common.js.map +0 -1
- package/dist/atomic/p-29fd6768.js +0 -2
- package/dist/atomic/p-29fd6768.js.map +0 -1
- package/dist/atomic/p-36e71b99.entry.js.map +0 -1
- package/dist/atomic/p-3d847e45.entry.js.map +0 -1
- package/dist/atomic/p-7601c3de.js +0 -2
- package/dist/atomic/p-7601c3de.js.map +0 -1
- package/dist/atomic/p-8867af82.entry.js.map +0 -1
- package/dist/atomic/p-aa4224ea.entry.js.map +0 -1
- package/dist/atomic/p-c1bf43cf.entry.js.map +0 -1
- package/dist/cjs/suggestions-common-5097a362.js.map +0 -1
- package/dist/esm/suggestions-common-2b20db26.js.map +0 -1
- /package/dist/atomic/{p-0bfa74d3.entry.js.map → p-4ca61a15.entry.js.map} +0 -0
- /package/dist/atomic/{p-828d74f8.entry.js.map → p-9f172e51.entry.js.map} +0 -0
- /package/dist/atomic/{p-caa647d5.js.map → p-b6d8adf1.js.map} +0 -0
- /package/dist/atomic/{p-8b9b8089.entry.js.map → p-ec43f802.entry.js.map} +0 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"file":"suggestions-utils-591559a0.js","mappings":"AAEA;;;;;;SAMgB,iBAAiB,CAAC,EAA8B;IAC9D,OAAO,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AAC7C,CAAC;AAED;;;;;;SAMgB,eAAe,CAAC,EAA8B;IAC5D,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AAC9C;;;;","names":[],"sources":["src/components/common/suggestions/suggestions-utils.ts"],"sourcesContent":["import type {SearchBoxSuggestionElement} from './suggestions-types';\n\n/**\n * Checks if a search box suggestion element has no query.\n *\n * @param el - The search box suggestion element to check\n * @returns True if the element has no query or the query is whitespace-only\n */\nexport function elementHasNoQuery(el: SearchBoxSuggestionElement): boolean {\n return !el.query || el.query.trim() === '';\n}\n\n/**\n * Checks if a search box suggestion element has a query.\n *\n * @param el - The search box suggestion element to check\n * @returns True if the element has a non-empty, non-whitespace query\n */\nexport function elementHasQuery(el: SearchBoxSuggestionElement): boolean {\n return !!el.query && el.query.trim() !== '';\n}\n"],"version":3}
|
package/dist/esm/version.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export const headlessVersion = '3.31.
|
2
|
-
export const atomicVersion = '3.33.8-pre.
|
1
|
+
export const headlessVersion = '3.31.1-pre.de35a78164';
|
2
|
+
export const atomicVersion = '3.33.8-pre.de35a78164';
|
package/dist/types/components/commerce/atomic-commerce-breadbox/atomic-commerce-breadbox.d.ts
CHANGED
@@ -53,8 +53,7 @@ export declare class AtomicCommerceBreadbox extends LitElement implements Initia
|
|
53
53
|
pathLimit: number;
|
54
54
|
initialize(): void;
|
55
55
|
willUpdate(changedProperties: Map<string, unknown>): void;
|
56
|
-
|
57
|
-
updateCompleted(): void;
|
56
|
+
updated(): void;
|
58
57
|
private validateProps;
|
59
58
|
disconnectedCallback(): void;
|
60
59
|
private get breadcrumbs();
|
package/dist/types/components/commerce/atomic-commerce-interface/atomic-commerce-interface.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
import { type CommerceEngine, type CommerceEngineConfiguration, type Context, type LogLevel, type ProductListing, type ProductListingSummaryState, type Search, type SearchSummaryState, type Summary, type UrlManager } from '@coveo/headless/commerce';
|
2
|
+
import type { CurrencyCodeISO4217 } from '@coveo/relay-event-types';
|
2
3
|
import { type i18n } from 'i18next';
|
3
4
|
import { type CSSResultGroup, LitElement } from 'lit';
|
4
5
|
import type { CommonBindings } from '../../common/interface/bindings';
|
@@ -26,7 +27,6 @@ export declare class AtomicCommerceInterface extends AtomicCommerceInterface_bas
|
|
26
27
|
private unsubscribeSummary?;
|
27
28
|
private initialized;
|
28
29
|
private store;
|
29
|
-
private _mobileBreakpointController;
|
30
30
|
private interfaceController;
|
31
31
|
static styles: CSSResultGroup;
|
32
32
|
/**
|
@@ -50,7 +50,13 @@ export declare class AtomicCommerceInterface extends AtomicCommerceInterface_bas
|
|
50
50
|
/**
|
51
51
|
* The commerce interface language.
|
52
52
|
*
|
53
|
-
* Will default to the value set in the Headless engine context if not
|
53
|
+
* Will default to the value set in the Headless engine context if not
|
54
|
+
* provided.
|
55
|
+
*
|
56
|
+
* @deprecated - This property will be removed in the next major version of
|
57
|
+
* Atomic (v4). Rather than using this property, set the initial language
|
58
|
+
* through the engine configuration when calling `initializeWithEngine`, and
|
59
|
+
* update the language as needed using the `updateLocale` method.
|
54
60
|
*/
|
55
61
|
language?: string;
|
56
62
|
/**
|
@@ -101,6 +107,26 @@ export declare class AtomicCommerceInterface extends AtomicCommerceInterface_bas
|
|
101
107
|
* Executes the first request after initializing connection to the headless commerce engine.
|
102
108
|
*/
|
103
109
|
executeFirstRequest(): Promise<void>;
|
110
|
+
/**
|
111
|
+
* Updates the locale settings for the commerce interface and headless commerce
|
112
|
+
* engine. Only the provided parameters will be updated.
|
113
|
+
*
|
114
|
+
* Calling this method affects the localization of the interface as well as
|
115
|
+
* the catalog configuration being used by the Commerce API. If the resulting
|
116
|
+
* language-country-currency combination matches no existing catalog
|
117
|
+
* configuration in your Coveo organization, requests made through the
|
118
|
+
* commerce engine will start failing.
|
119
|
+
*
|
120
|
+
* @param language - (Optional) The IETF language code tag (e.g., `en`).
|
121
|
+
* @param country - (Optional) The ISO-3166-1 country tag (e.g., `US`).
|
122
|
+
* @param currency - (Optional) The ISO-4217 currency code (e.g., `USD`).
|
123
|
+
*
|
124
|
+
* @example
|
125
|
+
* ```typescript
|
126
|
+
* interface.updateLocale('fr', 'CA', 'CAD');
|
127
|
+
* ```
|
128
|
+
*/
|
129
|
+
updateLocale(language?: string, country?: string, currency?: CurrencyCodeISO4217): void;
|
104
130
|
toggleAnalytics(): void;
|
105
131
|
updateIconAssetsPath(): void;
|
106
132
|
updateLanguage(): void;
|
@@ -116,6 +142,7 @@ export declare class AtomicCommerceInterface extends AtomicCommerceInterface_bas
|
|
116
142
|
private initSummary;
|
117
143
|
private initUrlManager;
|
118
144
|
private internalInitialization;
|
145
|
+
private isNewLocale;
|
119
146
|
private onHashChange;
|
120
147
|
scrollToTop(): void;
|
121
148
|
private updateHash;
|
@@ -2,7 +2,7 @@ import { type Product, type SearchBox } from '@coveo/headless/commerce';
|
|
2
2
|
import { LitElement } from 'lit';
|
3
3
|
import type { ItemRenderingFunction } from "../../common/item-list/item-list-common";
|
4
4
|
import type { ItemDisplayDensity, ItemDisplayImageSize } from "../../common/layout/display-options";
|
5
|
-
import {
|
5
|
+
import type { SearchBoxSuggestions, SearchBoxSuggestionsBindings } from "../../common/suggestions/suggestions-types";
|
6
6
|
import type { SearchBoxSuggestionsComponent } from "../../../decorators/types";
|
7
7
|
import type { CommerceBindings } from '../atomic-commerce-interface/atomic-commerce-interface';
|
8
8
|
export type AriaLabelGenerator = (bindings: CommerceBindings, product: Product) => string | undefined;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { type SearchBox } from '@coveo/headless/commerce';
|
2
2
|
import { LitElement } from 'lit';
|
3
|
-
import {
|
3
|
+
import type { SearchBoxSuggestions, SearchBoxSuggestionsBindings } from "../../common/suggestions/suggestions-types";
|
4
4
|
import type { SearchBoxSuggestionsComponent } from "../../../decorators/types";
|
5
5
|
import type { CommerceBindings } from '../atomic-commerce-interface/atomic-commerce-interface';
|
6
6
|
/**
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { type SearchBox } from '@coveo/headless/commerce';
|
2
2
|
import { LitElement } from 'lit';
|
3
3
|
import type { SearchBoxSuggestionsComponent } from "../../../decorators/types";
|
4
|
-
import {
|
4
|
+
import type { SearchBoxSuggestions, SearchBoxSuggestionsBindings } from '../../common/suggestions/suggestions-types';
|
5
5
|
import type { CommerceBindings } from '../atomic-commerce-interface/atomic-commerce-interface';
|
6
6
|
/**
|
7
7
|
* The `atomic-commerce-search-box-recent-queries` component can be added as a child of an `atomic-commerce-search-box` component, allowing for the configuration of recent query suggestions.
|
package/dist/types/components/common/atomic-suggestion-renderer/atomic-suggestion-renderer.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { i18n } from 'i18next';
|
2
|
-
import { SearchBoxSuggestionElement } from '../suggestions/suggestions-
|
2
|
+
import { SearchBoxSuggestionElement } from '../suggestions/suggestions-types';
|
3
3
|
/**
|
4
4
|
* The `atomic-suggestion-renderer` component is used to render individual suggestions. It was created to isolate
|
5
5
|
* the rendering logic of the 'content' property of the `SearchBoxSuggestionElement` interface. This property can be Stencil
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { i18n } from 'i18next';
|
2
|
-
import type { SearchBoxSuggestionElement } from './suggestions-
|
2
|
+
import type { SearchBoxSuggestionElement } from './suggestions-types';
|
3
3
|
export declare const getPartialInstantItemElement: (i18n: i18n, itemTitle: string, itemUniqueId: string) => Pick<SearchBoxSuggestionElement, "ariaLabel" | "key" | "part">;
|
4
4
|
export declare const getPartialInstantItemShowAllElement: (i18n: i18n) => Pick<SearchBoxSuggestionElement, "key" | "part" | "ariaLabel">;
|
5
5
|
interface InstantItemShowAllButtonProps {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { i18n } from 'i18next';
|
2
|
-
import type { SearchBoxSuggestionElement } from './suggestions-
|
2
|
+
import type { SearchBoxSuggestionElement } from './suggestions-types';
|
3
3
|
export declare const getPartialRecentQueryElement: (value: string, i18n: i18n) => Pick<SearchBoxSuggestionElement, "ariaLabel" | "key" | "query" | "part">;
|
4
4
|
export declare const getPartialRecentQueryClearElement: (i18n: i18n) => Pick<SearchBoxSuggestionElement, "ariaLabel" | "key" | "part" | "hideIfLast">;
|
5
5
|
export interface RecentQueriesContainerProps {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { FunctionalComponent } from '../../../stencil-public-runtime';
|
2
2
|
import { i18n } from 'i18next';
|
3
|
-
import { SearchBoxSuggestionElement } from './suggestions-
|
3
|
+
import { SearchBoxSuggestionElement } from './suggestions-types';
|
4
4
|
export declare const getPartialInstantItemElement: (i18n: i18n, itemTitle: string, itemUniqueId: string) => Pick<SearchBoxSuggestionElement, "ariaLabel" | "key" | "part">;
|
5
5
|
export declare const getPartialInstantItemShowAllElement: (i18n: i18n) => Pick<SearchBoxSuggestionElement, "key" | "part" | "ariaLabel">;
|
6
6
|
interface InstantItemShowAllButtonProps {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { FunctionalComponent } from '../../../stencil-public-runtime';
|
2
2
|
import { i18n } from 'i18next';
|
3
|
-
import { SearchBoxSuggestionElement } from './suggestions-
|
3
|
+
import { SearchBoxSuggestionElement } from './suggestions-types.js';
|
4
4
|
interface Suggestion {
|
5
5
|
highlightedValue: string;
|
6
6
|
rawValue: string;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { FunctionalComponent } from '../../../stencil-public-runtime';
|
2
2
|
import { i18n } from 'i18next';
|
3
|
-
import { SearchBoxSuggestionElement } from './suggestions-
|
3
|
+
import { SearchBoxSuggestionElement } from './suggestions-types';
|
4
4
|
export declare const getPartialRecentQueryElement: (value: string, i18n: i18n) => Pick<SearchBoxSuggestionElement, "ariaLabel" | "key" | "query" | "part">;
|
5
5
|
export declare const getPartialRecentQueryClearElement: (i18n: i18n) => Pick<SearchBoxSuggestionElement, "ariaLabel" | "key" | "part" | "hideIfLast">;
|
6
6
|
export declare const RecentQueriesContainer: FunctionalComponent;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import type { SearchBoxSuggestionElement, SearchBoxSuggestionsBindings, SearchBoxSuggestionsEvent } from './suggestions-types';
|
2
2
|
/**
|
3
3
|
* List of suggestions that will be displayed along other lists (e.g recent queries) when the search box's input is selected.
|
4
4
|
*/
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { LitElement } from 'lit';
|
2
|
-
import {
|
2
|
+
import type { SearchBoxSuggestionElement, SearchBoxSuggestionsBindings, SearchBoxSuggestionsEvent } from './suggestions-types';
|
3
3
|
/**
|
4
4
|
* List of suggestions that will be displayed along other lists (e.g recent queries) when the search box's input is selected.
|
5
5
|
*/
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import type { AnyBindings } from '../interface/bindings';
|
2
|
+
import type { SearchBoxSuggestionsEvent } from './suggestions-types';
|
3
|
+
/**
|
4
|
+
* Dispatches an event which retrieves the `SearchBoxSuggestionsBindings` on a configured parent search box.
|
5
|
+
*
|
6
|
+
* @param event Event sent from the registered query suggestions to the parent search box
|
7
|
+
* @param element Element on which to dispatch the event, which must be the child of a configured search box
|
8
|
+
* @param allowedSearchBoxElements Optional array of allowed search box element selectors
|
9
|
+
*
|
10
|
+
* @throws Error if the element is not a child of an allowed search box element
|
11
|
+
*/
|
12
|
+
export declare const dispatchSearchBoxSuggestionsEvent: <SearchBoxController, Bindings = AnyBindings>(event: SearchBoxSuggestionsEvent<SearchBoxController, Bindings>, element: HTMLElement, allowedSearchBoxElements?: readonly (typeof searchBoxElements)[number][]) => void;
|
13
|
+
declare const searchBoxElements: readonly ["atomic-search-box", "atomic-insight-search-box", "atomic-commerce-search-box"];
|
14
|
+
export {};
|
package/dist/types/components/common/suggestions/{suggestions-common.d.ts → suggestions-types.d.ts}
RENAMED
@@ -68,15 +68,6 @@ export interface SearchBoxSuggestions {
|
|
68
68
|
*/
|
69
69
|
onSuggestedQueryChange?(q: string): Promise<unknown>;
|
70
70
|
}
|
71
|
-
/**
|
72
|
-
* Event sent from the registered query suggestions to the parent search box.
|
73
|
-
*/
|
74
|
-
export type SearchBoxSuggestionsEvent<SearchBoxController, Bindings = AnyBindings> = (
|
75
|
-
/**
|
76
|
-
* The bindings passed from the search box to the suggestions.
|
77
|
-
*/
|
78
|
-
bindings: SearchBoxSuggestionsBindings<SearchBoxController, Bindings>) => SearchBoxSuggestions;
|
79
|
-
declare const searchBoxElements: readonly ["atomic-search-box", "atomic-insight-search-box", "atomic-commerce-search-box"];
|
80
71
|
/**
|
81
72
|
* The bindings passed from the search box to the suggestions.
|
82
73
|
*/
|
@@ -124,11 +115,10 @@ export type SearchBoxSuggestionsBindings<SearchBoxController, Bindings = AnyBind
|
|
124
115
|
getSuggestionElements(): SearchBoxSuggestionElement[];
|
125
116
|
};
|
126
117
|
/**
|
127
|
-
*
|
128
|
-
* @param event Event sent from the registered query suggestions to the parent search box.
|
129
|
-
* @param element Element on which to dispatch the event, which must be the child of a configured search box.
|
118
|
+
* Event sent from the registered query suggestions to the parent search box.
|
130
119
|
*/
|
131
|
-
export
|
132
|
-
|
133
|
-
|
134
|
-
|
120
|
+
export type SearchBoxSuggestionsEvent<SearchBoxController, Bindings = AnyBindings> = (
|
121
|
+
/**
|
122
|
+
* The bindings passed from the search box to the suggestions.
|
123
|
+
*/
|
124
|
+
bindings: SearchBoxSuggestionsBindings<SearchBoxController, Bindings>) => SearchBoxSuggestions;
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import type { SearchBoxSuggestionElement } from './suggestions-types';
|
2
|
+
/**
|
3
|
+
* Checks if a search box suggestion element has no query.
|
4
|
+
*
|
5
|
+
* @param el - The search box suggestion element to check
|
6
|
+
* @returns True if the element has no query or the query is whitespace-only
|
7
|
+
*/
|
8
|
+
export declare function elementHasNoQuery(el: SearchBoxSuggestionElement): boolean;
|
9
|
+
/**
|
10
|
+
* Checks if a search box suggestion element has a query.
|
11
|
+
*
|
12
|
+
* @param el - The search box suggestion element to check
|
13
|
+
* @returns True if the element has a non-empty, non-whitespace query
|
14
|
+
*/
|
15
|
+
export declare function elementHasQuery(el: SearchBoxSuggestionElement): boolean;
|
@@ -2,7 +2,7 @@ import { SearchBox, StandaloneSearchBox } from '@coveo/headless';
|
|
2
2
|
import { EventEmitter } from '../../../stencil-public-runtime';
|
3
3
|
import { InitializableComponent } from '../../../utils/initialization-utils';
|
4
4
|
import { RedirectionPayload } from '../../common/search-box/redirection-payload';
|
5
|
-
import { SearchBoxSuggestionsEvent } from '../../common/suggestions/suggestions-
|
5
|
+
import type { SearchBoxSuggestionsEvent } from '../../common/suggestions/suggestions-types';
|
6
6
|
import { Bindings } from '../atomic-search-interface/atomic-search-interface';
|
7
7
|
/**
|
8
8
|
* The `atomic-search-box` component creates a search box with built-in support for suggestions.
|
@@ -2,7 +2,7 @@ import { Result, SearchBox } from '@coveo/headless';
|
|
2
2
|
import { InitializableComponent } from '../../../../utils/initialization-utils';
|
3
3
|
import { ItemRenderingFunction } from '../../../common/item-list/stencil-item-list-common';
|
4
4
|
import { ItemDisplayDensity, ItemDisplayImageSize } from '../../../common/layout/display-options';
|
5
|
-
import { SearchBoxSuggestions, SearchBoxSuggestionsBindings } from '../../../common/suggestions/suggestions-
|
5
|
+
import type { SearchBoxSuggestions, SearchBoxSuggestionsBindings } from '../../../common/suggestions/suggestions-types';
|
6
6
|
import { Bindings } from '../../atomic-search-interface/atomic-search-interface';
|
7
7
|
export type AriaLabelGenerator = (bindings: Bindings, result: Result) => string | undefined;
|
8
8
|
/**
|
@@ -26,7 +26,7 @@ import { RedirectionPayload } from "./components/common/search-box/redirection-p
|
|
26
26
|
import { AriaLabelGenerator } from "./components/search/search-box-suggestions/atomic-search-box-instant-results/atomic-search-box-instant-results";
|
27
27
|
import { InitializationOptions } from "./components/search/atomic-search-interface/atomic-search-interface";
|
28
28
|
import { StandaloneSearchBoxData } from "./utils/local-storage-utils";
|
29
|
-
import { SearchBoxSuggestionElement } from "./components/common/suggestions/suggestions-
|
29
|
+
import { SearchBoxSuggestionElement } from "./components/common/suggestions/suggestions-types";
|
30
30
|
export { AutomaticFacet, CategoryFacetSortCriterion, DateFilterRange, DateRangeRequest, FacetResultsMustMatch, FacetSortCriterion, FoldedResult, GeneratedAnswer, GeneratedAnswerCitation, InlineLink, InteractiveCitation, InteractiveResult, LogLevel, NumericFilter, NumericFilterState, RangeFacetRangeAlgorithm, RangeFacetSortCriterion, RelativeDateUnit, Result, ResultTemplate, ResultTemplateCondition, SearchEngine, SearchStatus } from "@coveo/headless";
|
31
31
|
export { AtomicInterface } from "./utils/initialization-utils";
|
32
32
|
export { AnyBindings } from "./components/common/interface/bindings";
|
@@ -48,7 +48,7 @@ export { RedirectionPayload } from "./components/common/search-box/redirection-p
|
|
48
48
|
export { AriaLabelGenerator } from "./components/search/search-box-suggestions/atomic-search-box-instant-results/atomic-search-box-instant-results";
|
49
49
|
export { InitializationOptions } from "./components/search/atomic-search-interface/atomic-search-interface";
|
50
50
|
export { StandaloneSearchBoxData } from "./utils/local-storage-utils";
|
51
|
-
export { SearchBoxSuggestionElement } from "./components/common/suggestions/suggestions-
|
51
|
+
export { SearchBoxSuggestionElement } from "./components/common/suggestions/suggestions-types";
|
52
52
|
export namespace Components {
|
53
53
|
/**
|
54
54
|
* An automatic facet is a special type of facet generated by the automatic facets feature.
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { LitElement, TemplateResult } from 'lit';
|
2
2
|
import type { TemplateResultType } from 'lit/directive-helpers.js';
|
3
3
|
import type { AnyBindings } from '../components/common/interface/bindings';
|
4
|
-
import type { SearchBoxSuggestions } from '../components/common/suggestions/suggestions-
|
4
|
+
import type { SearchBoxSuggestions } from '../components/common/suggestions/suggestions-types';
|
5
5
|
export type GenericRender<T extends TemplateResultType> = TemplateResult<T>;
|
6
6
|
export type RenderGuardDecorator<Component, T extends TemplateResultType, Descriptor = TypedPropertyDescriptor<() => GenericRender<T>>> = (target: Component, propertyKey: 'render', descriptor: Descriptor) => Descriptor;
|
7
7
|
/**
|
package/dist/types/index.d.ts
CHANGED
@@ -5,7 +5,9 @@ export { SelectChildProductEventArgs } from './components/commerce/atomic-produc
|
|
5
5
|
export { productContext } from './components/commerce/product-template-component-utils/stencil-product-template-decorators';
|
6
6
|
export { PopoverChildFacet } from './components/common/facets/popover/popover-type';
|
7
7
|
export { RedirectionPayload } from './components/common/search-box/redirection-payload';
|
8
|
-
export { dispatchSearchBoxSuggestionsEvent
|
8
|
+
export { dispatchSearchBoxSuggestionsEvent } from './components/common/suggestions/suggestions-events';
|
9
|
+
export type { SearchBoxSuggestionElement, SearchBoxSuggestions, SearchBoxSuggestionsBindings, SearchBoxSuggestionsEvent, } from './components/common/suggestions/suggestions-types';
|
10
|
+
export { elementHasNoQuery, elementHasQuery, } from './components/common/suggestions/suggestions-utils';
|
9
11
|
export { RecsBindings } from './components/recommendations/atomic-recs-interface/atomic-recs-interface';
|
10
12
|
export { Bindings } from './components/search/atomic-search-interface/atomic-search-interface';
|
11
13
|
export { resultContext } from './components/search/result-template-components/result-template-decorators';
|
package/docs/atomic-docs.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
{
|
2
|
-
"timestamp": "2025-09-
|
2
|
+
"timestamp": "2025-09-30T15:21:54",
|
3
3
|
"compiler": {
|
4
4
|
"name": "@stencil/core",
|
5
5
|
"version": "4.20.0",
|
@@ -16089,10 +16089,10 @@
|
|
16089
16089
|
"docstring": "",
|
16090
16090
|
"path": "src/components/common/layout/display-options.ts"
|
16091
16091
|
},
|
16092
|
-
"src/components/common/suggestions/suggestions-
|
16092
|
+
"src/components/common/suggestions/suggestions-types.ts::SearchBoxSuggestionElement": {
|
16093
16093
|
"declaration": "export interface SearchBoxSuggestionElement {\n /**\n * Stable identity which enables Stencil to reuse DOM elements for better performance.\n * The best way to pick a key is to use a string that uniquely identifies that list item among its siblings (often your data will already have IDs).\n */\n key: string;\n /**\n * Rendered content of the element.\n *\n * @remarks\n * The `VNode` type will be deprecated in v4 as we are detaching from Stencil.\n */\n content: Element | VNode;\n /**\n * Hook called when the selection is selected.\n * @param e DOM event.\n */\n onSelect?(e: Event): void;\n /**\n * The query associated with the suggestion which will replace the query in the search box if the suggestion is selected.\n */\n query?: string;\n /**\n * For improved accessibility, provide this property with additional information.\n * https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label\n */\n ariaLabel?: string;\n /**\n * Adds a specific shadow part attribute that can be selected with the CSS ::part pseudo-element.\n * https://developer.mozilla.org/en-US/docs/Web/CSS/::part\n */\n part?: string;\n /**\n * Hide the suggestion if it's the last in the list.\n */\n hideIfLast?: boolean;\n}",
|
16094
16094
|
"docstring": "Element which will be rendered in the list of suggestions.",
|
16095
|
-
"path": "src/components/common/suggestions/suggestions-
|
16095
|
+
"path": "src/components/common/suggestions/suggestions-types.ts"
|
16096
16096
|
},
|
16097
16097
|
"../headless/dist/definitions/index.d.ts::RelativeDateUnit": {
|
16098
16098
|
"declaration": "any",
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@coveo/atomic",
|
3
3
|
"type": "module",
|
4
|
-
"version": "3.33.8-pre.
|
4
|
+
"version": "3.33.8-pre.de35a78164",
|
5
5
|
"description": "A web-component library for building modern UIs interfacing with the Coveo platform",
|
6
6
|
"homepage": "https://docs.coveo.com/en/atomic/latest/",
|
7
7
|
"repository": {
|
@@ -81,7 +81,7 @@
|
|
81
81
|
},
|
82
82
|
"dependencies": {
|
83
83
|
"@coveo/bueno": "1.1.2",
|
84
|
-
"@coveo/headless": "3.31.
|
84
|
+
"@coveo/headless": "3.31.1-pre.de35a78164",
|
85
85
|
"@lit/context": "1.1.6",
|
86
86
|
"@open-wc/lit-helpers": "0.7.0",
|
87
87
|
"@popperjs/core": "2.11.8",
|
@@ -153,7 +153,7 @@
|
|
153
153
|
},
|
154
154
|
"peerDependencies": {
|
155
155
|
"@coveo/bueno": "1.1.2",
|
156
|
-
"@coveo/headless": "3.31.
|
156
|
+
"@coveo/headless": "3.31.1-pre.de35a78164",
|
157
157
|
"typescript": ">=5.0.0"
|
158
158
|
},
|
159
159
|
"peerDependenciesMeta": {
|
@@ -1 +0,0 @@
|
|
1
|
-
{"file":"suggestions-common.js","mappings":";;;AA0FA,MAAM,iBAAiB,GAAG;IACxB,mBAAmB;IACnB,2BAA2B;IAC3B,4BAA4B;CACpB,CAAC;AAoDX,MAAM,mBAAmB,GAAG,CAAC,SAAkB,KAC7C,gBAAgB,IAAK,SAAwB;IAC5C,SAAwB,CAAC,cAAc,YAAY,OAAO,CAAC;AAE9D,MAAM,2CAA2C,GAAG,OAIlD,gBAAyB,EACzB,OAAoB,EACpB,KAA+D;IAE/D,MAAM,cAAc,CAAC,WAAW,CAAC,gBAAgB,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;IAC1E,IAAI,mBAAmB,CAAC,gBAAgB,CAAC,EAAE;QACzC,MAAM,gBAAgB,CAAC,cAAc,CAAC;KACvC;SAAM,IAAI,kBAAkB,IAAI,gBAAgB,EAAE;QACjD,MAAO,gBAAuC,CAAC,gBAAgB,EAAE,CAAC;KACnE;IACD,OAAO,CAAC,aAAa,CACnB,gBAAgB,CAAC,qCAAqC,EAAE,KAAK,CAAC,CAC/D,CAAC;AACJ,CAAC,CAAC;AAEF;;;;;MAKa,iCAAiC,GAAG,CAI/C,KAA+D,EAC/D,OAAoB,EACpB,2BAA0E,iBAAiB;IAE3F,MAAM,gBAAgB,GAAG,OAAO,CAAC,OAAO,EAAE,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACxE,IAAI,CAAC,gBAAgB,EAAE;QACrB,MAAM,IAAI,KAAK,CACb,QAAQ,OAAO,CAAC,QAAQ,CAAC,WAAW,EAAE,gFAAgF,wBAAwB,CAAC,IAAI,CACjJ,IAAI,CACL,EAAE,CACJ,CAAC;KACH;IACD,KAAK,2CAA2C,CAC9C,gBAAgB,EAChB,OAAO,EACP,KAAK,CACN,CAAC;AACJ,EAAE;SAEc,iBAAiB,CAAC,EAA8B;IAC9D,OAAO,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AAC7C,CAAC;SAEe,eAAe,CAAC,EAA8B;IAC5D,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AAC9C;;;;","names":[],"sources":["src/components/common/suggestions/suggestions-common.ts"],"sourcesContent":["import type {VNode} from '@stencil/core';\nimport type {HTMLStencilElement} from '@stencil/core/internal';\nimport type {LitElement} from 'lit';\nimport {closest} from '../../../utils/dom-utils';\nimport {buildCustomEvent} from '../../../utils/event-utils';\nimport type {AnyBindings} from '../interface/bindings';\n\n/**\n * Element which will be rendered in the list of suggestions.\n */\nexport interface SearchBoxSuggestionElement {\n /**\n * Stable identity which enables Stencil to reuse DOM elements for better performance.\n * The best way to pick a key is to use a string that uniquely identifies that list item among its siblings (often your data will already have IDs).\n */\n key: string;\n /**\n * Rendered content of the element.\n *\n * @remarks\n * The `VNode` type will be deprecated in v4 as we are detaching from Stencil.\n */\n content: Element | VNode;\n /**\n * Hook called when the selection is selected.\n * @param e DOM event.\n */\n onSelect?(e: Event): void;\n /**\n * The query associated with the suggestion which will replace the query in the search box if the suggestion is selected.\n */\n query?: string;\n /**\n * For improved accessibility, provide this property with additional information.\n * https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label\n */\n ariaLabel?: string;\n /**\n * Adds a specific shadow part attribute that can be selected with the CSS ::part pseudo-element.\n * https://developer.mozilla.org/en-US/docs/Web/CSS/::part\n */\n part?: string;\n /**\n * Hide the suggestion if it's the last in the list.\n */\n hideIfLast?: boolean;\n}\n\n/**\n * List of suggestions that will be displayed along other lists (e.g recent queries) when the search box's input is selected.\n */\nexport interface SearchBoxSuggestions {\n /**\n * The search box will sort the position of suggestions using this value. The lowest value being first.\n * By default, the DOM position will be used.\n */\n position: number;\n /**\n * Whether the suggestions should be listed in the right or left panel. By default, the suggestions are listed in the right panel.\n */\n panel?: 'left' | 'right';\n /**\n * Method that returns the list of elements which will be rendered in the list of suggestions.\n */\n renderItems(): SearchBoxSuggestionElement[];\n /**\n * Hook called when the user changes the search box's input value. This can lead to all the query suggestions being updated.\n */\n onInput?(): Promise<unknown>;\n /**\n * Hook called when the suggested query changes as a user traverses through the list of suggestions.\n * This is used for instant results, which are rendered based on the current suggested query.\n * @param q The new suggested query.\n */\n onSuggestedQueryChange?(q: string): Promise<unknown>;\n}\n\n/**\n * Event sent from the registered query suggestions to the parent search box.\n */\nexport type SearchBoxSuggestionsEvent<\n SearchBoxController,\n Bindings = AnyBindings,\n> = (\n /**\n * The bindings passed from the search box to the suggestions.\n */\n bindings: SearchBoxSuggestionsBindings<SearchBoxController, Bindings>\n) => SearchBoxSuggestions;\n\nconst searchBoxElements = [\n 'atomic-search-box',\n 'atomic-insight-search-box',\n 'atomic-commerce-search-box',\n] as const;\n\n/**\n * The bindings passed from the search box to the suggestions.\n */\nexport type SearchBoxSuggestionsBindings<\n SearchBoxController,\n Bindings = AnyBindings,\n> = Bindings & {\n /**\n * The unique id of the search box.\n */\n id: string;\n /**\n * Whether the search box is [standalone](https://docs.coveo.com/en/atomic/latest/usage/ssb/).\n */\n isStandalone: boolean;\n /**\n * The search box headless controller.\n */\n searchBoxController: SearchBoxController;\n /**\n * The number of queries to display when the user interacts with the search box.\n */\n numberOfQueries: number;\n /**\n * Whether to clear all active query filters when the end user submits a new query from the search box.\n */\n clearFilters: boolean;\n /**\n * Retrieves the suggested query, meaning the query that would be sent if the search is executed.\n * The suggested query changes as a user traverses through the list of suggestions.\n */\n suggestedQuery(): string;\n /**\n * Removes the current suggestions.\n */\n clearSuggestions(): void;\n /**\n * Triggers update & retrieval of all suggestions.\n */\n triggerSuggestions(): void;\n /**\n * Retrieves the current suggestions.\n */\n getSuggestions(): SearchBoxSuggestions[];\n /**\n * Retrieves the current suggestions elements.\n */\n getSuggestionElements(): SearchBoxSuggestionElement[];\n};\n\nconst isLitElementLoosely = (candidate: unknown): candidate is LitElement =>\n 'updateComplete' in (candidate as LitElement) &&\n (candidate as LitElement).updateComplete instanceof Promise;\n\nconst dispatchSearchBoxSuggestionsEventEventually = async <\n SearchBoxController,\n Bindings = AnyBindings,\n>(\n interfaceElement: Element,\n element: HTMLElement,\n event: SearchBoxSuggestionsEvent<SearchBoxController, Bindings>\n) => {\n await customElements.whenDefined(interfaceElement.nodeName.toLowerCase());\n if (isLitElementLoosely(interfaceElement)) {\n await interfaceElement.updateComplete;\n } else if ('componentOnReady' in interfaceElement) {\n await (interfaceElement as HTMLStencilElement).componentOnReady();\n }\n element.dispatchEvent(\n buildCustomEvent('atomic/searchBoxSuggestion/register', event)\n );\n};\n\n/**\n * Dispatches an event which retrieves the `SearchBoxSuggestionsBindings` on a configured parent search box.\n * @param event Event sent from the registered query suggestions to the parent search box.\n * @param element Element on which to dispatch the event, which must be the child of a configured search box.\n */\nexport const dispatchSearchBoxSuggestionsEvent = <\n SearchBoxController,\n Bindings = AnyBindings,\n>(\n event: SearchBoxSuggestionsEvent<SearchBoxController, Bindings>,\n element: HTMLElement,\n allowedSearchBoxElements: readonly (typeof searchBoxElements)[number][] = searchBoxElements\n) => {\n const interfaceElement = closest(element, searchBoxElements.join(', '));\n if (!interfaceElement) {\n throw new Error(\n `The \"${element.nodeName.toLowerCase()}\" component was not handled, as it is not a child of the following elements: ${allowedSearchBoxElements.join(\n ', '\n )}`\n );\n }\n void dispatchSearchBoxSuggestionsEventEventually(\n interfaceElement,\n element,\n event\n );\n};\n\nexport function elementHasNoQuery(el: SearchBoxSuggestionElement) {\n return !el.query || el.query.trim() === '';\n}\n\nexport function elementHasQuery(el: SearchBoxSuggestionElement) {\n return !!el.query && el.query.trim() !== '';\n}\n"],"version":3}
|
@@ -1,2 +0,0 @@
|
|
1
|
-
import{h as t,f as s}from"./p-dc3df5ce.js";import{B as e}from"./p-b93ccff9.js";import{isNullOrUndefined as i}from"@coveo/bueno";import{D as n}from"./p-f284897c.js";import{d as r}from"./p-01c91b69.js";import{e as o,a}from"./p-7601c3de.js";const h=`<svg width="17" height="17" viewBox="0 0 17 17" fill="none" xmlns="http://www.w3.org/2000/svg">\n<circle cx="7" cy="7" r="6.5" stroke="currentColor"/>\n<path d="M16 16L12 12" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>\n</svg>\n`;const u=(s,e)=>{const i=()=>{const t="flex bg-background w-full border border-neutral rounded-md focus-within:ring-3 absolute top-0 left-0";const e=s.disabled?"focus-within:border-disabled focus-within:ring-neutral":"focus-within:border-primary focus-within:ring-ring-primary";return[t,e].join(" ")};return t("div",{part:"wrapper",class:i(),onFocusout:s.onFocusout},e)};const c=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M15 1.00012L1.00012 14.9999" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>\n<path d="M0.999878 1L14.9999 15" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>\n</svg>\n`;const l=({inputRef:s,bindings:i,onClick:n,...r})=>t("div",{part:"clear-button-wrapper",class:"ml-2 flex items-center justify-center py-2"},t(e,{style:"text-transparent",part:"clear-button",class:"text-neutral-dark flex h-8 w-8 shrink-0 items-center justify-center",onClick:()=>{n?.();s?.focus()},ariaLabel:i.i18n.t("clear"),...r},t("atomic-icon",{part:"clear-icon",icon:c,class:"h-4 w-4"})));function g(t){return{autocomplete:"off",autocapitalize:"off",autocorrect:"off",...t.activeDescendant&&{"aria-activedescendant":t.activeDescendant},"aria-autocomplete":"both","aria-haspopup":"true","aria-controls":t.id}}function f(t,s){const e=t?.parentNode;if(!e){return}if(t.value==="\n"){return}e.dataset.replicatedValue=s??t.value}function d(t){const s=t?.parentNode;if(s){delete s.dataset.replicatedValue}}function p(t){const s=t?.parentNode;if(s){s.classList.remove("expanded")}}function m(t){const s=t?.parentNode;if(s){s.classList.add("expanded")}}const w=({textAreaRef:s,loading:e,bindings:i,onInput:n,onFocus:r,onBlur:o,onChange:a,onKeyDown:h,onKeyUp:u,value:c,ariaLabel:w,onClear:b,popup:v,...y})=>t("div",{class:"flex grow overflow-hidden"},t("div",{part:"textarea-expander",class:"grid grow overflow-hidden"},t("textarea",{part:"textarea","aria-label":w,placeholder:i.i18n.t("search"),class:"placeholder-neutral-dark",rows:1,onInput:t=>{n?.(t);f(s)},onKeyDown:t=>{f(s);if(t.key==="Enter"){if(t.shiftKey){return}t.preventDefault()}h?.(t)},onKeyUp:t=>{u?.(t);if(t.key==="Enter"){t.preventDefault();return}f(s)},onBlur:t=>{o?.(t);p(s);f(s)},onChange:t=>{a?.(t);f(s)},onFocus:t=>{r?.(t);const e=t.target;f(s??e);m(s??e)},autocomplete:"off",...v&&g(v),...y,value:c})),e&&t("div",{class:"searchbox-button-wrapper ml-2 flex items-center justify-center"},t("span",{part:"loading",class:"loading mr-2 grid h-5 w-5 animate-spin place-items-center rounded-full bg-linear-to-r"})),!e&&c&&t(l,{inputRef:s,bindings:i,onClick:()=>{b();d(s)}}));function b(t,s){let e;const i=new Promise(((t,i)=>{e=setTimeout((()=>{i(new Error("Promise timed out."))}),s)}));return Promise.race([t,i]).then((()=>{clearTimeout(e)}))}class v{constructor(t){this.ownerSearchBoxProps=t;this.suggestions=[];this.leftSuggestionElements=[];this.rightSuggestionElements=[];this.leftPanel=undefined;this.rightPanel=undefined;this.activeDescendant="";this.suggestedQuery="";this.keyboardActiveDescendant="";this.queryDataAttribute="data-query";this.suggestionEvents=[];this.previousActiveDescendantElement=null;this.leftSuggestions=[];this.rightSuggestions=[];this.triggerSuggestions=r((()=>this.executeQuerySuggestion()),this.ownerSearchBoxProps.getSuggestionDelay())}get partialSuggestionBindings(){return{suggestedQuery:()=>this.suggestedQuery,clearSuggestions:()=>this.clearSuggestions(),triggerSuggestions:()=>this.triggerSuggestions(),getSuggestions:()=>this.suggestions,getSuggestionElements:()=>this.allSuggestionElements}}get activeDescendantElement(){if(!this.hasActiveDescendant){return null}return this.leftPanel?.querySelector(`#${this.activeDescendant}`)||this.rightPanel?.querySelector(`#${this.activeDescendant}`)||null}onSubmit(){this.clickOnActiveElement();this.clearSuggestions()}updateActiveDescendant(t=""){this.activeDescendant=t;s(this.ownerSearchBoxProps.getHost())}updateKeyboardActiveDescendant(t=""){this.keyboardActiveDescendant=t}clickOnActiveElement(){this.activeDescendantElement?.click();this.updateActiveDescendant()}isRightPanelInFocus(){if(i(this.panelInFocus)||i(this.rightPanel)){return false}return this.panelInFocus===this.rightPanel}initializeSuggestions(t){this.suggestions=this.suggestionEvents.map((s=>s(t)))}registerSuggestionsFromEvent(t,s){t.preventDefault();t.stopPropagation();this.suggestionEvents.push(t.detail);this.suggestions.push(t.detail(s))}registerSuggestions(t){this.suggestions.push(t)}get isDoubleList(){return Boolean(this.leftSuggestionElements.length&&this.rightSuggestionElements.length)}focusPanel(t){const s=t==="left"?this.leftPanel:this.rightPanel;if(this.panelInFocus===s){return}if(s?.firstElementChild){const t=this.previousActiveDescendantElement&&s.contains(this.previousActiveDescendantElement);const e=t?this.previousActiveDescendantElement:s.firstElementChild;this.updateDescendants(e.id)}}clearSuggestions(){this.clearSuggestionElements();this.updateActiveDescendant()}async focusNextValue(){if(!this.hasSuggestions||!this.nextOrFirstValue){return}await this.focusValue(this.nextOrFirstValue)}async focusValue(t){this.updateKeyboardActiveDescendant(t.id);this.updateActiveDescendant(t.id);this.scrollActiveDescendantIntoView();await this.updateQueryFromSuggestion()}async onSuggestionMouseOver(t,s,e){const i=s==="left"?this.leftPanel:this.rightPanel;this.updateKeyboardActiveDescendant();if(this.panelInFocus===i){this.updateActiveDescendant(e)}else{this.updateDescendants(e)}if(t.query){await this.updateSuggestedQuery(t.query)}}async onSuggestionClick(t,s){if(t.query){this.clearSuggestions();await this.updateOwnerSearchboxQuery(t.query)}t.onSelect?.(s)}get hasSuggestions(){return!!this.allSuggestionElements.length}get allSuggestionElements(){return[...this.leftSuggestionElements,...this.rightSuggestionElements]}async focusPreviousValue(){if(this.firstValue===this.activeDescendantElement){this.updateKeyboardActiveDescendant();this.updateActiveDescendant();return}if(!this.hasSuggestions||!this.previousOrLastValue){return}await this.focusValue(this.previousOrLastValue)}get hasActiveDescendant(){return this.activeDescendant!==""}async executeQuerySuggestion(){this.updateActiveDescendant();const t=await Promise.allSettled(this.suggestions.map((t=>b(t.onInput?t.onInput():Promise.resolve(),this.ownerSearchBoxProps.getSuggestionTimeout()))));const s=[];t.forEach(((t,e)=>{if(t.status==="fulfilled"){s.push(this.suggestions[e])}else{this.ownerSearchBoxProps.getLogger().warn("Some query suggestions are not being shown because the promise timed out.")}}));const e=(t,e=false)=>s.filter((s=>s.panel===t||!s.panel&&e)).sort(this.sortSuggestions);this.leftSuggestions=e("left",true);this.leftSuggestionElements=this.getAndFilterLeftSuggestionElements();this.rightSuggestions=e("right");this.rightSuggestionElements=this.getSuggestionElements(this.rightSuggestions);const i=this.allSuggestionElements.find(o)?.query||"";await this.updateSuggestedQuery(i)}get lastValue(){return this.panelInFocus?.lastElementChild}get previousOrLastValue(){if(!this.hasActiveDescendant){return this.lastValue?.firstChild}const t=this.activeDescendantElement?.parentElement;return t?.previousElementSibling?.firstChild||this.firstValue?.firstChild}sortSuggestions(t,s){return t.position-s.position}get nextOrFirstValue(){if(!this.hasActiveDescendant){return this.firstValue?.firstChild}const t=this.activeDescendantElement?.parentElement;return t?.nextElementSibling?.firstChild||this.firstValue?.firstChild}get firstValue(){return this.panelInFocus?.firstElementChild}get panelInFocus(){if(this.leftPanel?.contains(this.activeDescendantElement)){return this.leftPanel}if(this.rightPanel?.contains(this.activeDescendantElement)){return this.rightPanel}return this.leftPanel||this.rightPanel}scrollActiveDescendantIntoView(){this.activeDescendantElement?.scrollIntoView({block:"nearest"})}async updateQueryFromSuggestion(){const t=this.activeDescendantElement?.getAttribute(this.queryDataAttribute);await this.updateOwnerSearchboxQuery(t||"")}async updateOwnerSearchboxQuery(t){if(t&&this.ownerSearchBoxProps.getSearchBoxValue()!==t){this.ownerSearchBoxProps.updateQuery(t);await this.updateSuggestedQuery(t)}}async updateSuggestedQuery(t){await Promise.allSettled(this.suggestions.map((s=>b(s.onSuggestedQueryChange?s.onSuggestedQueryChange(t):Promise.resolve(),this.ownerSearchBoxProps.getSuggestionTimeout()))));this.suggestedQuery=t;this.updateSuggestionElements(t);s(this.ownerSearchBoxProps.getHost())}updateSuggestionElements(t){if(!this.isPanelInFocus(this.leftPanel,t)){this.leftSuggestionElements=this.getAndFilterLeftSuggestionElements()}if(!this.isPanelInFocus(this.rightPanel,t)){this.rightSuggestionElements=this.getSuggestionElements(this.rightSuggestions)}}forceUpdate(){this.updateSuggestionElements(this.suggestedQuery);s(this.ownerSearchBoxProps.getHost())}isPanelInFocus(t,s){if(!this.activeDescendantElement){return false}if(s){const e=n.sanitize(s);return!!t?.querySelector(`[${this.queryDataAttribute}="${CSS.escape(e)}"]`)}return this.activeDescendantElement?.closest("ul")===t}getAndFilterLeftSuggestionElements(){const t=this.getSuggestionElements(this.leftSuggestions);const s=new Set;const e=t.filter((t=>{if(i(t.query)){return true}if(s.has(t.query)){return false}else{s.add(t.query);return true}}));return e}getSuggestionElements(t){const s=t.flatMap((t=>t.renderItems()));const e=this.ownerSearchBoxProps.getNumberOfSuggestionsToDisplay()+s.filter(a).length;return s.slice(0,e)}updateDescendants(t=""){const s=this.activeDescendantElement;this.previousActiveDescendantElement=s;this.updateActiveDescendant(t)}clearSuggestionElements(){this.leftSuggestionElements=[];this.rightSuggestionElements=[]}}export{v as S,h as a,w as b,u as c};
|
2
|
-
//# sourceMappingURL=p-29fd6768.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["SearchBoxWrapper","props","children","getClasses","baseClasses","focusClasses","disabled","join","h","part","class","onFocusout","TextAreaClearButton","inputRef","bindings","onClick","defaultButtonProps","Button","style","focus","ariaLabel","i18n","t","icon","ClearSlim","getPopupAttributes","autocomplete","autocapitalize","autocorrect","activeDescendant","id","syncTextWithReplica","elem","value","parent","parentNode","dataset","replicatedValue","resetReplicaText","collapseTextArea","classList","remove","expandTextArea","add","SearchTextArea","textAreaRef","loading","onInput","onFocus","onBlur","onChange","onKeyDown","onKeyUp","onClear","popup","defaultInputProps","placeholder","rows","e","key","shiftKey","preventDefault","target","promiseTimeout","prom","ms","timeout","Promise","_","reject","setTimeout","Error","race","then","clearTimeout","SuggestionManager","constructor","ownerSearchBoxProps","this","suggestions","leftSuggestionElements","rightSuggestionElements","leftPanel","undefined","rightPanel","suggestedQuery","keyboardActiveDescendant","queryDataAttribute","suggestionEvents","previousActiveDescendantElement","leftSuggestions","rightSuggestions","triggerSuggestions","debounce","executeQuerySuggestion","getSuggestionDelay","partialSuggestionBindings","clearSuggestions","getSuggestions","getSuggestionElements","allSuggestionElements","activeDescendantElement","hasActiveDescendant","querySelector","onSubmit","clickOnActiveElement","updateActiveDescendant","forceUpdate","getHost","updateKeyboardActiveDescendant","click","isRightPanelInFocus","isNullOrUndefined","panelInFocus","initializeSuggestions","map","event","registerSuggestionsFromEvent","stopPropagation","push","detail","registerSuggestions","isDoubleList","Boolean","length","focusPanel","side","panel","firstElementChild","panelHasActiveDescendant","contains","newValue","updateDescendants","clearSuggestionElements","focusNextValue","hasSuggestions","nextOrFirstValue","focusValue","scrollActiveDescendantIntoView","updateQueryFromSuggestion","onSuggestionMouseOver","item","thisPanel","query","updateSuggestedQuery","onSuggestionClick","updateOwnerSearchboxQuery","onSelect","focusPreviousValue","firstValue","previousOrLastValue","settled","allSettled","suggestion","resolve","getSuggestionTimeout","fulfilledSuggestions","forEach","j","status","getLogger","warn","splitSuggestions","isDefault","filter","sort","sortSuggestions","getAndFilterLeftSuggestionElements","defaultSuggestedQuery","find","elementHasQuery","lastValue","lastElementChild","firstChild","parentOfActiveDescendant","parentElement","previousElementSibling","a","b","position","nextElementSibling","scrollIntoView","block","getAttribute","getSearchBoxValue","updateQuery","onSuggestedQueryChange","updateSuggestionElements","isPanelInFocus","escaped","DOMPurify","sanitize","CSS","escape","closest","suggestionElements","filterOnDuplicate","Set","out","suggestionElement","has","elements","flatMap","renderItems","max","getNumberOfSuggestionsToDisplay","elementHasNoQuery","slice","newPrevDescendantElement"],"sources":["src/components/common/search-box/stencil-search-box-wrapper.tsx","src/components/common/search-box/stencil-text-area-clear-button.tsx","src/components/common/search-box/stencil-search-text-area.tsx","src/utils/promise-utils.ts","src/components/common/suggestions/stencil-suggestion-manager.ts"],"sourcesContent":["import {FunctionalComponent, h} from '@stencil/core';\n\ninterface Props {\n disabled: boolean;\n onFocusout?: (event: FocusEvent) => void;\n}\n\nexport const SearchBoxWrapper: FunctionalComponent<Props> = (\n props,\n children\n) => {\n const getClasses = () => {\n const baseClasses =\n 'flex bg-background w-full border border-neutral rounded-md focus-within:ring-3 absolute top-0 left-0';\n const focusClasses = props.disabled\n ? 'focus-within:border-disabled focus-within:ring-neutral'\n : 'focus-within:border-primary focus-within:ring-ring-primary';\n\n return [baseClasses, focusClasses].join(' ');\n };\n\n return (\n <div part=\"wrapper\" class={getClasses()} onFocusout={props.onFocusout}>\n {children}\n </div>\n );\n};\n","import {FunctionalComponent, h} from '@stencil/core';\nimport ClearSlim from '../../../images/clear-slim.svg';\nimport {AnyBindings} from '../interface/bindings';\nimport {Button, StencilButtonProps} from '../stencil-button';\n\ninterface Props extends Partial<StencilButtonProps> {\n bindings: AnyBindings;\n inputRef: HTMLInputElement | HTMLTextAreaElement | null;\n}\n\nexport const TextAreaClearButton: FunctionalComponent<Props> = ({\n inputRef,\n bindings,\n onClick,\n ...defaultButtonProps\n}) => (\n <div\n part=\"clear-button-wrapper\"\n class=\"ml-2 flex items-center justify-center py-2\"\n >\n <Button\n style=\"text-transparent\"\n part=\"clear-button\"\n class=\"text-neutral-dark flex h-8 w-8 shrink-0 items-center justify-center\"\n onClick={() => {\n onClick?.();\n inputRef?.focus();\n }}\n ariaLabel={bindings.i18n.t('clear')}\n {...defaultButtonProps}\n >\n <atomic-icon\n part=\"clear-icon\"\n icon={ClearSlim}\n class=\"h-4 w-4\"\n ></atomic-icon>\n </Button>\n </div>\n);\n","import {FunctionalComponent, h} from '@stencil/core';\nimport {JSXBase} from '@stencil/core/internal';\nimport {AnyBindings} from '../interface/bindings';\nimport {TextAreaClearButton} from './stencil-text-area-clear-button';\n\ninterface Props extends JSXBase.TextareaHTMLAttributes<HTMLTextAreaElement> {\n textAreaRef: HTMLTextAreaElement;\n loading: boolean;\n bindings: AnyBindings;\n value: string;\n ariaLabel: string;\n onClear(): void;\n popup?: {\n id: string;\n activeDescendant: string;\n expanded: boolean;\n hasSuggestions: boolean;\n };\n}\n\nfunction getPopupAttributes(props: Required<Props>['popup']) {\n return {\n autocomplete: 'off',\n autocapitalize: 'off',\n autocorrect: 'off',\n ...(props.activeDescendant && {\n 'aria-activedescendant': props.activeDescendant,\n }),\n 'aria-autocomplete': 'both',\n 'aria-haspopup': 'true',\n 'aria-controls': props.id,\n };\n}\n\nfunction syncTextWithReplica(elem: HTMLTextAreaElement, value?: string) {\n const parent = elem?.parentNode as HTMLElement;\n if (!parent) {\n return;\n }\n if (elem.value === '\\n') {\n return;\n }\n parent.dataset.replicatedValue = value ?? elem.value;\n}\n\nfunction resetReplicaText(elem: HTMLTextAreaElement) {\n const parent = elem?.parentNode as HTMLElement;\n if (parent) {\n delete parent.dataset.replicatedValue;\n }\n}\n\nfunction collapseTextArea(elem: HTMLTextAreaElement) {\n const parent = elem?.parentNode as HTMLElement;\n if (parent) {\n parent.classList.remove('expanded');\n }\n}\n\nfunction expandTextArea(elem: HTMLTextAreaElement) {\n const parent = elem?.parentNode as HTMLElement;\n if (parent) {\n parent.classList.add('expanded');\n }\n}\n\nexport const SearchTextArea: FunctionalComponent<Props> = ({\n textAreaRef,\n loading,\n bindings,\n onInput,\n onFocus,\n onBlur,\n onChange,\n onKeyDown,\n onKeyUp,\n value,\n ariaLabel,\n onClear,\n popup,\n ...defaultInputProps\n}) => (\n <div class=\"flex grow overflow-hidden\">\n <div part=\"textarea-expander\" class=\"grid grow overflow-hidden\">\n <textarea\n part=\"textarea\"\n aria-label={ariaLabel}\n placeholder={bindings.i18n.t('search')}\n class=\"placeholder-neutral-dark\"\n rows={1}\n onInput={(e) => {\n onInput?.(e);\n syncTextWithReplica(textAreaRef);\n }}\n onKeyDown={(e) => {\n syncTextWithReplica(textAreaRef);\n if (e.key === 'Enter') {\n if (e.shiftKey) {\n return;\n }\n e.preventDefault();\n }\n onKeyDown?.(e);\n }}\n onKeyUp={(e) => {\n onKeyUp?.(e);\n if (e.key === 'Enter') {\n e.preventDefault();\n return;\n }\n syncTextWithReplica(textAreaRef);\n }}\n onBlur={(e) => {\n onBlur?.(e);\n collapseTextArea(textAreaRef);\n syncTextWithReplica(textAreaRef);\n }}\n onChange={(e) => {\n onChange?.(e);\n syncTextWithReplica(textAreaRef);\n }}\n onFocus={(e) => {\n onFocus?.(e);\n const target = e.target as HTMLTextAreaElement;\n syncTextWithReplica(textAreaRef ?? target);\n expandTextArea(textAreaRef ?? target);\n }}\n autocomplete=\"off\"\n {...(popup && getPopupAttributes(popup))}\n {...defaultInputProps}\n value={value}\n />\n </div>\n\n {loading && (\n <div class=\"searchbox-button-wrapper ml-2 flex items-center justify-center\">\n <span\n part=\"loading\"\n class=\"loading mr-2 grid h-5 w-5 animate-spin place-items-center rounded-full bg-linear-to-r\"\n ></span>\n </div>\n )}\n {!loading && value && (\n <TextAreaClearButton\n inputRef={textAreaRef}\n bindings={bindings}\n onClick={() => {\n onClear();\n resetReplicaText(textAreaRef);\n }}\n />\n )}\n </div>\n);\n","export function promiseTimeout<T>(prom: T | Promise<T>, ms: number) {\n let id: NodeJS.Timeout;\n const timeout = new Promise((_, reject) => {\n id = setTimeout(() => {\n reject(new Error('Promise timed out.'));\n }, ms);\n });\n return Promise.race([prom, timeout]).then(() => {\n clearTimeout(id);\n });\n}\n","import {isNullOrUndefined} from '@coveo/bueno';\nimport {forceUpdate} from '@stencil/core';\nimport DOMPurify from 'dompurify';\nimport {debounce} from '../../../utils/debounce-utils';\nimport {promiseTimeout} from '../../../utils/promise-utils';\nimport {\n elementHasNoQuery,\n elementHasQuery,\n type SearchBoxSuggestionElement,\n type SearchBoxSuggestionsBindings,\n type SearchBoxSuggestionsEvent,\n} from './suggestions-common';\n\n/**\n * List of suggestions that will be displayed along other lists (e.g recent queries) when the search box's input is selected.\n */\nexport interface SearchBoxSuggestions {\n /**\n * The search box will sort the position of suggestions using this value, the lowest value being first.\n * By default, the DOM position will be used.\n */\n position: number;\n /**\n * Whether the suggestions should be listed in the right or left panel. By default, the suggestions are listed in the right panel.\n */\n panel?: 'left' | 'right';\n /**\n * Method that returns the list of elements which will be rendered in the list of suggestions.\n */\n renderItems(): SearchBoxSuggestionElement[];\n /**\n * Hook called when the user changes the search box's input value. This can lead to all the query suggestions being updated.\n */\n onInput?(): Promise<unknown>;\n /**\n * Hook called when the current suggested query changes as the user navigates the list of suggestions.\n * This is used for instant results, which are rendered based on the current suggested query.\n * @param q The new current suggested query.\n */\n onSuggestedQueryChange?(q: string): Promise<unknown>;\n}\n\ninterface SearchBoxProps {\n getSearchBoxValue: () => string;\n updateQuery: (suggestedQuery: string) => void;\n getSuggestionTimeout: () => number;\n getNumberOfSuggestionsToDisplay: () => number;\n getSuggestionDelay: () => number;\n getLogger: () => Pick<typeof console, 'warn'>;\n getHost: () => HTMLElement;\n}\n\nexport class SuggestionManager<SearchBoxController> {\n public suggestions: SearchBoxSuggestions[] = [];\n public leftSuggestionElements: SearchBoxSuggestionElement[] = [];\n public rightSuggestionElements: SearchBoxSuggestionElement[] = [];\n public leftPanel: HTMLElement | undefined = undefined;\n public rightPanel: HTMLElement | undefined = undefined;\n public triggerSuggestions: () => Promise<void>;\n public activeDescendant = '';\n public suggestedQuery = '';\n public keyboardActiveDescendant = '';\n\n private queryDataAttribute = 'data-query';\n private suggestionEvents: SearchBoxSuggestionsEvent<SearchBoxController>[] =\n [];\n\n private previousActiveDescendantElement: HTMLElement | null = null;\n private leftSuggestions: SearchBoxSuggestions[] = [];\n private rightSuggestions: SearchBoxSuggestions[] = [];\n\n constructor(private ownerSearchBoxProps: SearchBoxProps) {\n this.triggerSuggestions = debounce(\n () => this.executeQuerySuggestion(),\n this.ownerSearchBoxProps.getSuggestionDelay()\n );\n }\n\n public get partialSuggestionBindings(): Pick<\n SearchBoxSuggestionsBindings<SearchBoxController>,\n | 'suggestedQuery'\n | 'clearSuggestions'\n | 'triggerSuggestions'\n | 'getSuggestions'\n | 'getSuggestionElements'\n > {\n return {\n suggestedQuery: () => this.suggestedQuery,\n clearSuggestions: () => this.clearSuggestions(),\n triggerSuggestions: () => this.triggerSuggestions(),\n getSuggestions: () => this.suggestions,\n getSuggestionElements: () => this.allSuggestionElements,\n };\n }\n\n public get activeDescendantElement(): HTMLElement | null {\n if (!this.hasActiveDescendant) {\n return null;\n }\n\n return (\n this.leftPanel?.querySelector(`#${this.activeDescendant}`) ||\n this.rightPanel?.querySelector(`#${this.activeDescendant}`) ||\n null\n );\n }\n\n public onSubmit() {\n this.clickOnActiveElement();\n this.clearSuggestions();\n }\n\n public updateActiveDescendant(id = '') {\n this.activeDescendant = id;\n forceUpdate(this.ownerSearchBoxProps.getHost());\n }\n\n public updateKeyboardActiveDescendant(id = '') {\n this.keyboardActiveDescendant = id;\n }\n\n public clickOnActiveElement() {\n this.activeDescendantElement?.click();\n this.updateActiveDescendant();\n }\n\n public isRightPanelInFocus() {\n if (\n isNullOrUndefined(this.panelInFocus) ||\n isNullOrUndefined(this.rightPanel)\n ) {\n return false;\n }\n\n return this.panelInFocus === this.rightPanel;\n }\n\n public initializeSuggestions(\n bindings: SearchBoxSuggestionsBindings<SearchBoxController>\n ) {\n this.suggestions = this.suggestionEvents.map((event) => event(bindings));\n }\n\n public registerSuggestionsFromEvent(\n event: CustomEvent<SearchBoxSuggestionsEvent<SearchBoxController>>,\n bindings: SearchBoxSuggestionsBindings<SearchBoxController>\n ) {\n event.preventDefault();\n event.stopPropagation();\n this.suggestionEvents.push(event.detail);\n this.suggestions.push(event.detail(bindings));\n }\n\n public registerSuggestions(suggestions: SearchBoxSuggestions) {\n this.suggestions.push(suggestions);\n }\n\n public get isDoubleList() {\n return Boolean(\n this.leftSuggestionElements.length && this.rightSuggestionElements.length\n );\n }\n\n public focusPanel(side: 'left' | 'right') {\n const panel = side === 'left' ? this.leftPanel : this.rightPanel;\n\n if (this.panelInFocus === panel) {\n return;\n }\n if (panel?.firstElementChild) {\n const panelHasActiveDescendant =\n this.previousActiveDescendantElement &&\n panel.contains(this.previousActiveDescendantElement);\n const newValue = panelHasActiveDescendant\n ? this.previousActiveDescendantElement!\n : (panel.firstElementChild as HTMLElement);\n this.updateDescendants(newValue.id);\n }\n }\n\n public clearSuggestions() {\n this.clearSuggestionElements();\n this.updateActiveDescendant();\n }\n\n public async focusNextValue() {\n if (!this.hasSuggestions || !this.nextOrFirstValue) {\n return;\n }\n\n await this.focusValue(this.nextOrFirstValue as HTMLElement);\n }\n\n public async focusValue(value: HTMLElement) {\n this.updateKeyboardActiveDescendant(value.id);\n this.updateActiveDescendant(value.id);\n this.scrollActiveDescendantIntoView();\n await this.updateQueryFromSuggestion();\n }\n\n public async onSuggestionMouseOver(\n item: SearchBoxSuggestionElement,\n side: 'left' | 'right',\n id: string\n ) {\n const thisPanel = side === 'left' ? this.leftPanel : this.rightPanel;\n // When hovering, always reset the keyboard active descendant\n this.updateKeyboardActiveDescendant();\n if (this.panelInFocus === thisPanel) {\n this.updateActiveDescendant(id);\n } else {\n this.updateDescendants(id);\n }\n if (item.query) {\n await this.updateSuggestedQuery(item.query);\n }\n }\n\n public async onSuggestionClick(item: SearchBoxSuggestionElement, e: Event) {\n if (item.query) {\n this.clearSuggestions();\n await this.updateOwnerSearchboxQuery(item.query);\n }\n item.onSelect?.(e);\n }\n\n public get hasSuggestions() {\n return !!this.allSuggestionElements.length;\n }\n\n public get allSuggestionElements() {\n return [...this.leftSuggestionElements, ...this.rightSuggestionElements];\n }\n\n public async focusPreviousValue() {\n if (this.firstValue === this.activeDescendantElement) {\n this.updateKeyboardActiveDescendant();\n this.updateActiveDescendant();\n return;\n }\n\n if (!this.hasSuggestions || !this.previousOrLastValue) {\n return;\n }\n\n await this.focusValue(this.previousOrLastValue as HTMLElement);\n }\n\n public get hasActiveDescendant() {\n return this.activeDescendant !== '';\n }\n\n private async executeQuerySuggestion() {\n this.updateActiveDescendant();\n const settled = await Promise.allSettled(\n this.suggestions.map((suggestion) =>\n promiseTimeout(\n suggestion.onInput ? suggestion.onInput() : Promise.resolve(),\n this.ownerSearchBoxProps.getSuggestionTimeout()\n )\n )\n );\n\n const fulfilledSuggestions: SearchBoxSuggestions[] = [];\n\n settled.forEach((prom, j) => {\n if (prom.status === 'fulfilled') {\n fulfilledSuggestions.push(this.suggestions[j]);\n } else {\n this.ownerSearchBoxProps\n .getLogger()\n .warn(\n 'Some query suggestions are not being shown because the promise timed out.'\n );\n }\n });\n\n const splitSuggestions = (side: 'left' | 'right', isDefault = false) =>\n fulfilledSuggestions\n .filter(\n (suggestion) =>\n suggestion.panel === side || (!suggestion.panel && isDefault)\n )\n .sort(this.sortSuggestions);\n\n this.leftSuggestions = splitSuggestions('left', true);\n this.leftSuggestionElements = this.getAndFilterLeftSuggestionElements();\n\n this.rightSuggestions = splitSuggestions('right');\n this.rightSuggestionElements = this.getSuggestionElements(\n this.rightSuggestions\n );\n\n const defaultSuggestedQuery =\n this.allSuggestionElements.find(elementHasQuery)?.query || '';\n\n await this.updateSuggestedQuery(defaultSuggestedQuery);\n }\n\n private get lastValue() {\n return this.panelInFocus?.lastElementChild;\n }\n\n private get previousOrLastValue() {\n if (!this.hasActiveDescendant) {\n return this.lastValue?.firstChild;\n }\n\n const parentOfActiveDescendant =\n this.activeDescendantElement?.parentElement;\n return (\n parentOfActiveDescendant?.previousElementSibling?.firstChild ||\n this.firstValue?.firstChild\n );\n }\n\n private sortSuggestions(a: SearchBoxSuggestions, b: SearchBoxSuggestions) {\n return a.position - b.position;\n }\n\n private get nextOrFirstValue() {\n if (!this.hasActiveDescendant) {\n return this.firstValue?.firstChild;\n }\n\n const parentOfActiveDescendant =\n this.activeDescendantElement?.parentElement;\n return (\n parentOfActiveDescendant?.nextElementSibling?.firstChild ||\n this.firstValue?.firstChild\n );\n }\n\n private get firstValue() {\n return this.panelInFocus?.firstElementChild;\n }\n\n private get panelInFocus() {\n if (this.leftPanel?.contains(this.activeDescendantElement)) {\n return this.leftPanel;\n }\n if (this.rightPanel?.contains(this.activeDescendantElement)) {\n return this.rightPanel;\n }\n return this.leftPanel || this.rightPanel;\n }\n\n private scrollActiveDescendantIntoView() {\n this.activeDescendantElement?.scrollIntoView({\n block: 'nearest',\n });\n }\n\n private async updateQueryFromSuggestion() {\n const suggestedQuery = this.activeDescendantElement?.getAttribute(\n this.queryDataAttribute\n );\n await this.updateOwnerSearchboxQuery(suggestedQuery || '');\n }\n\n private async updateOwnerSearchboxQuery(query: string) {\n if (query && this.ownerSearchBoxProps.getSearchBoxValue() !== query) {\n this.ownerSearchBoxProps.updateQuery(query);\n await this.updateSuggestedQuery(query);\n }\n }\n\n private async updateSuggestedQuery(suggestedQuery: string) {\n await Promise.allSettled(\n this.suggestions.map((suggestion) =>\n promiseTimeout(\n suggestion.onSuggestedQueryChange\n ? suggestion.onSuggestedQueryChange(suggestedQuery)\n : Promise.resolve(),\n this.ownerSearchBoxProps.getSuggestionTimeout()\n )\n )\n );\n this.suggestedQuery = suggestedQuery;\n this.updateSuggestionElements(suggestedQuery);\n forceUpdate(this.ownerSearchBoxProps.getHost());\n }\n\n private updateSuggestionElements(query: string) {\n if (!this.isPanelInFocus(this.leftPanel, query)) {\n this.leftSuggestionElements = this.getAndFilterLeftSuggestionElements();\n }\n\n if (!this.isPanelInFocus(this.rightPanel, query)) {\n this.rightSuggestionElements = this.getSuggestionElements(\n this.rightSuggestions\n );\n }\n }\n\n public forceUpdate() {\n this.updateSuggestionElements(this.suggestedQuery);\n forceUpdate(this.ownerSearchBoxProps.getHost());\n }\n\n private isPanelInFocus(\n panel: HTMLElement | undefined,\n query: string\n ): boolean {\n if (!this.activeDescendantElement) {\n return false;\n }\n\n if (query) {\n const escaped = DOMPurify.sanitize(query);\n return !!panel?.querySelector(\n `[${this.queryDataAttribute}=\"${CSS.escape(escaped)}\"]`\n );\n }\n\n return this.activeDescendantElement?.closest('ul') === panel;\n }\n\n private getAndFilterLeftSuggestionElements() {\n const suggestionElements = this.getSuggestionElements(this.leftSuggestions);\n const filterOnDuplicate = new Set();\n\n const out = suggestionElements.filter((suggestionElement) => {\n if (isNullOrUndefined(suggestionElement.query)) {\n return true;\n }\n if (filterOnDuplicate.has(suggestionElement.query)) {\n return false;\n } else {\n filterOnDuplicate.add(suggestionElement.query);\n return true;\n }\n });\n\n return out;\n }\n\n private getSuggestionElements(suggestions: SearchBoxSuggestions[]) {\n const elements = suggestions.flatMap((suggestion) =>\n suggestion.renderItems()\n );\n\n const max =\n this.ownerSearchBoxProps.getNumberOfSuggestionsToDisplay() +\n elements.filter(elementHasNoQuery).length;\n\n return elements.slice(0, max);\n }\n\n private updateDescendants(activeDescendant = '') {\n const newPrevDescendantElement = this.activeDescendantElement;\n this.previousActiveDescendantElement = newPrevDescendantElement;\n this.updateActiveDescendant(activeDescendant);\n }\n\n private clearSuggestionElements() {\n this.leftSuggestionElements = [];\n this.rightSuggestionElements = [];\n }\n}\n"],"mappings":"8fAOaA,EAA+C,CAC1DC,EACAC,KAEA,MAAMC,EAAa,KACjB,MAAMC,EACJ,uGACF,MAAMC,EAAeJ,EAAMK,SACvB,yDACA,6DAEJ,MAAO,CAACF,EAAaC,GAAcE,KAAK,IAAI,EAG9C,OACEC,EAAA,OAAKC,KAAK,UAAUC,MAAOP,IAAcQ,WAAYV,EAAMU,YACxDT,EACG,E,2UCdH,MAAMU,EAAkD,EAC7DC,WACAC,WACAC,aACGC,KAEHR,EAAA,OACEC,KAAK,uBACLC,MAAM,8CAENF,EAACS,EAAM,CACLC,MAAM,mBACNT,KAAK,eACLC,MAAM,sEACNK,QAAS,KACPA,MACAF,GAAUM,OAAO,EAEnBC,UAAWN,EAASO,KAAKC,EAAE,YACvBN,GAEJR,EAAA,eACEC,KAAK,aACLc,KAAMC,EACNd,MAAM,cCdd,SAASe,EAAmBxB,GAC1B,MAAO,CACLyB,aAAc,MACdC,eAAgB,MAChBC,YAAa,SACT3B,EAAM4B,kBAAoB,CAC5B,wBAAyB5B,EAAM4B,kBAEjC,oBAAqB,OACrB,gBAAiB,OACjB,gBAAiB5B,EAAM6B,GAE3B,CAEA,SAASC,EAAoBC,EAA2BC,GACtD,MAAMC,EAASF,GAAMG,WACrB,IAAKD,EAAQ,CACX,M,CAEF,GAAIF,EAAKC,QAAU,KAAM,CACvB,M,CAEFC,EAAOE,QAAQC,gBAAkBJ,GAASD,EAAKC,KACjD,CAEA,SAASK,EAAiBN,GACxB,MAAME,EAASF,GAA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D,EAAkBzJ,IAAI4J,EAAkBxD,OACxC,OAAO,I,KAIX,OAAOuD,C,CAGD,qBAAAnG,CAAsBpB,GAC5B,MAAM0H,EAAW1H,EAAY2H,SAASjD,GACpCA,EAAWkD,gBAGb,MAAMC,EACJ9H,KAAKD,oBAAoBgI,kCACzBJ,EAASrC,OAAO0C,GAAmBlF,OAErC,OAAO6E,EAASM,MAAM,EAAGH,E,CAGnB,iBAAAxE,CAAkBvG,EAAmB,IAC3C,MAAMmL,EAA2BlI,KAAKuB,wBACtCvB,KAAKW,gCAAkCuH,EACvClI,KAAK4B,uBAAuB7E,E,CAGtB,uBAAAwG,GACNvD,KAAKE,uBAAyB,GAC9BF,KAAKG,wBAA0B,E","ignoreList":[]}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"names":["AtomicSuggestionRenderer","parts","part","this","isSelected","suggestion","query","classes","content","isHTMLElement","h","Fragment","ariaLabel","isButton","contentLabel","i18n","t","labelWithType","isMacOS","label","interpolation","escapeValue","position","index","count","lastIndex","isDoubleList","side","ensureContentForRenderedSuggestion","element","replaceChildren","el","HTMLElement","render","onSelect","Host","key","class","id","onMouseDown","e","preventDefault","onClick","onMouseOver","ref"],"sources":["src/components/common/atomic-suggestion-renderer/atomic-suggestion-renderer.tsx"],"sourcesContent":["import {isMacOS} from '@/src/utils/device-utils';\nimport {Component, Fragment, Host, Prop, VNode, h} from '@stencil/core';\nimport {i18n} from 'i18next';\nimport {SearchBoxSuggestionElement} from '../suggestions/suggestions-common';\n\n/**\n * The `atomic-suggestion-renderer` component is used to render individual suggestions. It was created to isolate\n * the rendering logic of the 'content' property of the `SearchBoxSuggestionElement` interface. This property can be Stencil\n * VNode or native Element so there must be a Stencil component to render it. For Lit components using this component, they will\n * use native Elements.\n *\n * @internal\n */\n@Component({\n tag: 'atomic-suggestion-renderer',\n shadow: false,\n})\nexport class AtomicSuggestionRenderer {\n @Prop() public i18n!: i18n;\n @Prop() public id!: string;\n @Prop() public suggestion!: SearchBoxSuggestionElement;\n @Prop() public isSelected!: boolean;\n @Prop() public side!: 'left' | 'right';\n @Prop() public index!: number;\n @Prop() public lastIndex!: number;\n @Prop() public isDoubleList!: boolean;\n @Prop() public onClick?: (e: Event) => void;\n @Prop() public onMouseOver?: (e: Event) => void;\n\n private get parts() {\n let part = 'suggestion';\n if (this.isSelected) {\n part += ' active-suggestion';\n }\n if (this.suggestion.query) {\n part += ' suggestion-with-query';\n }\n if (this.suggestion.part) {\n part += ` ${this.suggestion.part}`;\n }\n return part;\n }\n\n private get classes() {\n return `flex px-4 min-h-10 items-center text-left text-neutral-dark cursor-pointer ${\n this.isSelected ? 'bg-neutral-light' : ''\n }`;\n }\n\n private get content() {\n return this.isHTMLElement(this.suggestion.content) ? (\n <Fragment></Fragment>\n ) : (\n this.suggestion.content\n );\n }\n\n private ariaLabel(isButton: boolean) {\n const contentLabel =\n this.suggestion.ariaLabel ??\n this.suggestion.query ??\n this.i18n.t('no-title');\n\n const labelWithType =\n isMacOS() && isButton\n ? this.i18n.t('search-suggestion-button', {\n label: contentLabel,\n interpolation: {escapeValue: false},\n })\n : contentLabel;\n\n const position = this.index + 1;\n const count = this.lastIndex + 1;\n\n if (!this.isDoubleList) {\n return this.i18n.t('search-suggestion-single-list', {\n label: labelWithType,\n position,\n count,\n interpolation: {escapeValue: false},\n });\n }\n\n return this.i18n.t('search-suggestion-double-list', {\n label: labelWithType,\n position,\n count,\n side: this.i18n.t(this.side === 'left' ? 'left' : 'right'),\n interpolation: {escapeValue: false},\n });\n }\n\n private ensureContentForRenderedSuggestion(element: HTMLElement) {\n if (this.isHTMLElement(this.suggestion.content)) {\n element.replaceChildren(this.suggestion.content);\n }\n }\n\n private isHTMLElement(el: VNode | Element): el is HTMLElement {\n return el instanceof HTMLElement;\n }\n\n render() {\n const isButton = !!(this.suggestion.onSelect || this.suggestion.query);\n\n return (\n <Host class=\"contents\">\n {isButton ? (\n <button\n id={this.id}\n key={this.suggestion.key}\n part={this.parts}\n class={this.classes}\n onMouseDown={(e) => e.preventDefault()}\n onClick={(e: Event) => this.onClick?.(e)}\n onMouseOver={(e: Event) => this.onMouseOver?.(e)}\n data-query={this.suggestion.query}\n aria-label={this.ariaLabel(isButton)}\n ref={(el) => {\n if (!el) {\n return;\n }\n this.ensureContentForRenderedSuggestion(el);\n }}\n >\n {this.content}\n </button>\n ) : (\n <span\n id={this.id}\n key={this.suggestion.key}\n part={this.parts}\n class={this.classes}\n aria-label={this.ariaLabel(isButton)}\n ref={(el) => {\n if (!el) {\n return;\n }\n this.ensureContentForRenderedSuggestion(el);\n }}\n >\n {this.content}\n </span>\n )}\n </Host>\n );\n }\n}\n"],"mappings":"mGAiBaA,EAAwB,M,mQAYnC,SAAYC,GACV,IAAIC,EAAO,aACX,GAAIC,KAAKC,WAAY,CACnBF,GAAQ,oB,CAEV,GAAIC,KAAKE,WAAWC,MAAO,CACzBJ,GAAQ,wB,CAEV,GAAIC,KAAKE,WAAWH,KAAM,CACxBA,GAAQ,IAAIC,KAAKE,WAAWH,M,CAE9B,OAAOA,C,CAGT,WAAYK,GACV,MAAO,8EACLJ,KAAKC,WAAa,mBAAqB,I,CAI3C,WAAYI,GACV,OAAOL,KAAKM,cAAcN,KAAKE,WAAWG,SACxCE,EAACC,EAAQ,MAETR,KAAKE,WAAkB,O,CAInB,SAAAO,CAAUC,GAChB,MAAMC,EACJX,KAAKE,WAAWO,WAChBT,KAAKE,WAAWC,OAChBH,KAAKY,KAAKC,EAAE,YAEd,MAAMC,EACJC,KAAaL,EACTV,KAAKY,KAAKC,EAAE,2BAA4B,CACtCG,MAAOL,EACPM,cAAe,CAACC,YAAa,SAE/BP,EAEN,MAAMQ,EAAWnB,KAAKoB,MAAQ,EAC9B,MAAMC,EAAQrB,KAAKsB,UAAY,EAE/B,IAAKtB,KAAKuB,aAAc,CACtB,OAAOvB,KAAKY,KAAKC,EAAE,gCAAiC,CAClDG,MAAOF,EACPK,WACAE,QACAJ,cAAe,CAACC,YAAa,Q,CAIjC,OAA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