{"version":3,"sources":["src/utils/promise-utils.ts","src/components/common/search-box/text-area-clear-button.tsx","src/components/common/search-box/search-text-area.tsx","src/components/common/search-box/submit-button.tsx","src/components/common/search-box/text-area-submit-button.tsx","src/components/search/atomic-search-box/atomic-search-box.pcss?tag=atomic-search-box&encapsulation=shadow","src/components/search/atomic-search-box/atomic-search-box.tsx"],"names":["promiseTimeout","prom","ms","id","timeout","Promise","_","reject","setTimeout","Error","race","then","clearTimeout","TextAreaClearButton","inputRef","bindings","onClick","defaultButtonProps","h","part","class","Button","style","focus","ariaLabel","i18n","t","icon","ClearSlim","getPopupAttributes","props","role","autocomplete","autocapitalize","autocorrect","aria-activedescendant","activeDescendant","aria-expanded","hasSuggestions","expanded","aria-autocomplete","aria-haspopup","aria-controls","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","aria-label","placeholder","rows","e","key","preventDefault","SubmitButton","SearchIcon","TextAreaSubmitButton","SearchSlimIcon","atomicSearchBoxCss","AtomicSearchBox","[object Object]","hostRef","this","suggestionEvents","suggestions","suggestedQuery","isExpanded","isSearchDisabled","previousActiveDescendantElement","leftSuggestions","leftSuggestionElements","rightSuggestions","rightSuggestionElements","numberOfQueries","suggestionTimeout","disableSearch","minimumQueryLength","clearFilters","enableQuerySyntax","textarea","updateBreakpoints","once","host","renderTextBox","searchLabel","searchBoxState","isLoading","title","target","searchBox","clear","searchBoxCommon","popupId","ref","el","triggerTextAreaChange","SearchInput","randomID","querySetActions","loadQuerySetActions","engine","searchBoxOptions","numberOfSuggestions","highlightOptions","notMatchDelimiters","open","close","correctionDelimiters","redirectionUrl","buildStandaloneSearchBox","options","buildSearchBox","map","event","suggestionBindings","SearchBoxCommon","focusValue","bind","clearSuggestions","getIsSearchDisabled","getIsExpanded","getPanelInFocus","panelInFocus","getActiveDescendant","getActiveDescendantElement","activeDescendantElement","getAllSuggestionElements","allSuggestionElements","redirectTo","analytics","data","storage","SafeStorage","setJSON","StorageItems","STANDALONE_SEARCH_BOX_DATA","afterRedirection","redirect","emit","defaultPrevented","window","location","href","stopPropagation","push","detail","initialize","isStandalone","searchBoxController","triggerSuggestions","getSuggestions","getSuggestionElements","isDoubleList","Boolean","length","newPrevDescendantElement","updateActiveDescendant","hasActiveDescendant","_a","leftPanelRef","querySelector","_b","rightPanelRef","contains","elements","suggestion","renderItems","flat","max","filter","elementHasNoQuery","slice","scrollActiveDescendantIntoView","updateQueryFromSuggestion","updateAriaLiveActiveDescendant","panel","firstElementChild","panelHasActiveDescendant","newValue","updateDescendants","elsLength","elementHasQuery","searchBoxAriaMessage","count","settled","allSettled","resolve","fulfilledSuggestions","forEach","j","status","logger","warn","splitSuggestions","side","isDefault","sort","sortSuggestions","getAndFilterLeftSuggestionElements","defaultSuggestedQuery","find","query","updateSuggestedQuery","updateAriaMessage","a","b","position","trim","updateText","clearSuggestionElements","click","submit","escaped","replace","queryDataAttribute","closest","getAttribute","updateQuery","isMacOS","suggestionsAriaMessage","isPanelInFocus","suggestionElements","filterOnDuplicate","Set","suggestionElement","isNullOrUndefined","has","onSubmit","focusNextValue","firstValue","focusPreviousValue","state","focusPanel","item","thisPanel","dispatchEvent","Event","index","lastIndex","isSelected","hideIfLast","isButton","onSelect","SimpleSearchSuggestion","ButtonSearchSuggestion","onSuggestionClick","onMouseOver","onSuggestionMouseOver","store","isMobile","onSuggestedQueryChange","updateSuggestionElements","setRef","getRef","onMouseDown","renderSuggestion","showSuggestions","renderPanel","aria-hidden","getSearchInputLabel","Submit","Host","renderAbsolutePositionSpacer","SearchBoxWrapper","disabled","textArea","display","onFocusExit","renderSuggestions","__decorate","InitializeBindings","BindStateToController","AriaLiveRegion"],"mappings":"upBAAgBA,EAAkBC,EAAsBC,GACtD,IAAIC,EACJ,MAAMC,EAAU,IAAIC,SAAQ,CAACC,EAAGC,KAC9BJ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,cAAA,KAEEnQ,KAAK,kBACLC,MAAM,uCACNkD,KAAM,IAKLU,SACLE,KAAKkB,oBAEL,MAAMI,EAActB,KAAK6B,gBAAgBwK,oBACvCrM,KAAKc,oBAEP,MAAMwL,EAAStM,KAAKiB,SAAWvB,EAAuBF,EAEtD,OACExD,EAACuQ,EAAI,KACFvM,KAAKiB,SAAWjB,KAAKwM,+BAAiC,KACtD,CACCxQ,EAACyQ,EAAgB,CACfC,SAAU1M,KAAKK,iBACfsM,SAAU3M,KAAKiB,UAEfjF,EAAA,wBAAA,CACEI,MAAO,CAACwQ,QAAS,YACjBC,YAAa,IAAM7M,KAAKwD,oBAEvBxD,KAAKqB,cAAcC,GACpBtF,EAACsQ,EAAM,CACLzQ,SAAUmE,KAAKnE,SACf6Q,SAAU1M,KAAKK,iBACfvE,QAAS,IAAMkE,KAAK2B,UAAU0H,SAC9B5H,MAAOH,IAERtB,KAAK8M,uBAGT9M,KAAKE,YAAY0F,QAChB5J,EAAA,OAAA,KACEA,EAAA,mCAAA,MACAA,EAAA,sCAAA,0GA5vBU+Q,EAAA,CAArBC,uCAcAC,EAAsB,mDAiHvBF,EAAA,CADCG,EAAe,0DAIhBH,EAAA,CADCG,EAAe,qBAAsB","sourcesContent":["export function promiseTimeout(prom: T | Promise, 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 {FunctionalComponent, h} from '@stencil/core';\nimport ClearSlim from '../../../images/clear-slim.svg';\nimport {Button, ButtonProps} from '../button';\nimport {AnyBindings} from '../interface/bindings';\n\ninterface Props extends Partial {\n bindings: AnyBindings;\n inputRef: HTMLInputElement | HTMLTextAreaElement | null;\n}\n\nexport const TextAreaClearButton: FunctionalComponent = ({\n inputRef,\n bindings,\n onClick,\n ...defaultButtonProps\n}) => (\n \n {\n onClick?.();\n inputRef?.focus();\n }}\n ariaLabel={bindings.i18n.t('clear')}\n {...defaultButtonProps}\n >\n \n \n \n);\n","import {FunctionalComponent, h} from '@stencil/core';\nimport {JSXBase} from '@stencil/core/internal';\nimport {AnyBindings} from '../interface/bindings';\nimport {TextAreaClearButton} from './text-area-clear-button';\n\ninterface Props extends JSXBase.TextareaHTMLAttributes {\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['popup']) {\n return {\n role: 'combobox',\n autocomplete: 'off',\n autocapitalize: 'off',\n autocorrect: 'off',\n 'aria-activedescendant': props.activeDescendant,\n 'aria-expanded': `${props.hasSuggestions && props.expanded}`,\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 = ({\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
\n
\n {\n onInput?.(e);\n syncTextWithReplica(textAreaRef);\n }}\n onKeyDown={(e) => {\n onKeyDown?.(e);\n if (e.key === 'Enter') {\n e.preventDefault();\n return;\n }\n syncTextWithReplica(textAreaRef);\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 syncTextWithReplica(textAreaRef);\n expandTextArea(textAreaRef);\n }}\n autocomplete=\"off\"\n {...(popup && getPopupAttributes(popup))}\n {...defaultInputProps}\n value={value}\n />\n
\n\n {loading && (\n
\n \n
\n )}\n {!loading && value && (\n {\n onClear();\n resetReplicaText(textAreaRef);\n }}\n />\n )}\n
\n);\n","import {FunctionalComponent, h} from '@stencil/core';\nimport SearchIcon from '../../../images/search.svg';\nimport {Button, ButtonProps} from '../button';\nimport {AnyBindings} from '../interface/bindings';\n\ninterface Props extends Partial {\n bindings: AnyBindings;\n}\n\nexport const SubmitButton: FunctionalComponent = ({\n bindings,\n onClick,\n ...defaultButtonProps\n}) => (\n {\n onClick?.();\n }}\n {...defaultButtonProps}\n >\n \n \n);\n","import {FunctionalComponent, h} from '@stencil/core';\nimport SearchSlimIcon from '../../../images/search-slim.svg';\nimport {Button, ButtonProps} from '../button';\nimport {AnyBindings} from '../interface/bindings';\n\ninterface Props extends Partial {\n bindings: AnyBindings;\n}\n\nexport const TextAreaSubmitButton: FunctionalComponent = ({\n bindings,\n onClick,\n ...defaultButtonProps\n}) => (\n \n {\n onClick?.();\n }}\n {...defaultButtonProps}\n >\n \n \n \n);\n","@import '../../../global/global.pcss';\n@import '../../common/search-box/search-box.pcss';\n\n[part~='instant-results-item'] {\n @apply p-3;\n}\n\n[part~='instant-results-show-all'] {\n @apply py-1 justify-center;\n border-top: 1px solid var(--atomic-neutral);\n margin-top: auto;\n box-sizing: content-box;\n button {\n background-color: transparent;\n }\n}\n\n[part~='suggestions-left'] + [part~='suggestions-right'] {\n border-left: 1px solid var(--atomic-neutral);\n}\n\n[part~='suggestions-wrapper'] {\n flex-direction: column;\n @media only screen and (min-width: 1024px) {\n flex-direction: row;\n }\n}\n\n:host([textarea]) {\n @apply relative z-10;\n}\n","import {isNullOrUndefined} from '@coveo/bueno';\nimport {\n SearchBox,\n SearchBoxState,\n buildSearchBox,\n loadQuerySetActions,\n QuerySetActionCreators,\n StandaloneSearchBox,\n StandaloneSearchBoxState,\n buildStandaloneSearchBox,\n SearchBoxOptions,\n} from '@coveo/headless';\nimport {\n Component,\n h,\n State,\n Prop,\n Listen,\n Watch,\n Element,\n Event,\n EventEmitter,\n Host,\n} from '@stencil/core';\nimport {AriaLiveRegion} from '../../../utils/accessibility-utils';\nimport {isMacOS} from '../../../utils/device-utils';\nimport {\n BindStateToController,\n InitializeBindings,\n} from '../../../utils/initialization-utils';\nimport {\n SafeStorage,\n StandaloneSearchBoxData,\n StorageItems,\n} from '../../../utils/local-storage-utils';\nimport {promiseTimeout} from '../../../utils/promise-utils';\nimport {updateBreakpoints} from '../../../utils/replace-breakpoint';\nimport {once, randomID} from '../../../utils/utils';\nimport {SearchBoxCommon} from '../../common/search-box/search-box-common';\nimport {SearchBoxWrapper} from '../../common/search-box/search-box-wrapper';\nimport {SearchInput} from '../../common/search-box/search-input';\nimport {SearchTextArea} from '../../common/search-box/search-text-area';\nimport {SubmitButton} from '../../common/search-box/submit-button';\nimport {TextAreaSubmitButton} from '../../common/search-box/text-area-submit-button';\nimport {Bindings} from '../atomic-search-interface/atomic-search-interface';\nimport {\n SearchBoxSuggestionElement,\n SearchBoxSuggestions,\n SearchBoxSuggestionsBindings,\n SearchBoxSuggestionsEvent,\n elementHasNoQuery,\n elementHasQuery,\n} from '../search-box-suggestions/suggestions-common';\nimport {RedirectionPayload} from './redirection-payload';\nimport {\n ButtonSearchSuggestion,\n queryDataAttribute,\n SimpleSearchSuggestion,\n} from './search-suggestion';\n\n/**\n * The `atomic-search-box` component creates a search box with built-in support for suggestions.\n *\n * @part wrapper - The search box wrapper.\n * @part input - The search box input.\n * @part loading - The search box loading animation.\n * @part clear-button - The button to clear the search box of input.\n * @part clear-icon - The clear button's icon.\n * @part submit-button - The search box submit button.\n * @part submit-icon - The search box submit button's icon.\n * @part suggestions - A list of suggested query corrections on each panel.\n * @part suggestions-left - A list of suggested query corrections on the left panel.\n * @part suggestions-right - A list of suggested query corrections on the right panel.\n * @part suggestions-wrapper - The wrapper that contains suggestion panels.\n * @part suggestions-single-list - The wrapper that contains 1 suggestion list.\n * @part suggestions-double-list - The wrapper that contains 2 suggestion lists.\n * @part suggestion - A suggested query correction.\n * @part active-suggestion - The currently active suggestion.\n * @part suggestion-divider - An item in the list that separates groups of suggestions.\n * @part suggestion-with-query - An item in the list that will update the search box query.\n *\n * @part query-suggestion-item - A suggestion from the `atomic-search-box-query-suggestions` component.\n * @part query-suggestion-content - The contents of a suggestion from the `atomic-search-box-query-suggestions` component.\n * @part query-suggestion-icon - The icon of a suggestion from the `atomic-search-box-query-suggestions` component.\n * @part query-suggestion-text - The text of a suggestion from the `atomic-search-box-query-suggestions` component.\n *\n * @part recent-query-item - A suggestion from the `atomic-search-box-recent-queries` component.\n * @part recent-query-content - The contents of a suggestion from the `atomic-search-box-recent-queries` component.\n * @part recent-query-icon - The icon of a suggestion from the `atomic-search-box-recent-queries` component.\n * @part recent-query-text - The text of a suggestion from the `atomic-search-box-recent-queries` component.\n * @part recent-query-text-highlight - The highlighted portion of the text of a suggestion from the `atomic-search-box-recent-queries` component.\n * @part recent-query-title-item - The clear button above suggestions from the `atomic-search-box-recent-queries` component.\n * @part recent-query-title-content - The contents of the clear button above suggestions from the `atomic-search-box-recent-queries` component.\n * @part recent-query-title - The \"recent searches\" text of the clear button above suggestions from the `atomic-search-box-recent-queries` component.\n * @part recent-query-clear - The \"clear\" text of the clear button above suggestions from the `atomic-search-box-recent-queries` component.\n *\n * @part instant-results-item - An instant result rendered by an `atomic-search-box-instant-results` component.\n * @part instant-results-show-all - The clickable suggestion to show all items for the current instant results search rendered by an `atomic-search-box-instant-results` component.\n * @part instant-results-show-all-button - The button inside the clickable suggestion from the `atomic-search-box-instant-results` component.\n */\n@Component({\n tag: 'atomic-search-box',\n styleUrl: 'atomic-search-box.pcss',\n shadow: true,\n})\nexport class AtomicSearchBox {\n @InitializeBindings() public bindings!: Bindings;\n private searchBox!: SearchBox | StandaloneSearchBox;\n private id!: string;\n private inputRef!: HTMLInputElement;\n private textAreaRef!: HTMLTextAreaElement;\n private leftPanelRef: HTMLElement | undefined;\n private rightPanelRef: HTMLElement | undefined;\n private querySetActions!: QuerySetActionCreators;\n private suggestionEvents: SearchBoxSuggestionsEvent[] = [];\n private suggestions: SearchBoxSuggestions[] = [];\n private searchBoxCommon!: SearchBoxCommon;\n\n @Element() private host!: HTMLElement;\n\n @BindStateToController('searchBox')\n @State()\n private searchBoxState!: SearchBoxState | StandaloneSearchBoxState;\n @State() public error!: Error;\n @State() private suggestedQuery = '';\n @State() private isExpanded = false;\n @State() private isSearchDisabled = false;\n @State() private activeDescendant = '';\n @State() private previousActiveDescendantElement: HTMLElement | null = null;\n @State() private leftSuggestions: SearchBoxSuggestions[] = [];\n @State() private leftSuggestionElements: SearchBoxSuggestionElement[] = [];\n @State() private rightSuggestions: SearchBoxSuggestions[] = [];\n @State() private rightSuggestionElements: SearchBoxSuggestionElement[] = [];\n\n /**\n * The amount of queries displayed when the user interacts with the search box.\n * By default, a mix of query suggestions and recent queries will be shown.\n * You can configure those settings using the following components as children:\n * - atomic-search-box-query-suggestions\n * - atomic-search-box-recent-queries\n */\n @Prop({reflect: true}) public numberOfQueries = 8;\n\n /**\n * Defining this option makes the search box standalone (see [Use a\n * Standalone Search Box](https://docs.coveo.com/en/atomic/latest/usage/ssb/)).\n *\n * This option defines the default URL the user should be redirected to, when a query is submitted.\n * If a query pipeline redirect is triggered, it will redirect to that URL instead\n * (see [query pipeline triggers](https://docs.coveo.com/en/1458)).\n */\n @Prop({reflect: true}) public redirectionUrl?: string;\n\n /**\n * The timeout for suggestion queries, in milliseconds.\n * If a suggestion query times out, the suggestions from that particular query won't be shown.\n */\n @Prop() public suggestionTimeout = 400;\n\n /**\n * Whether to prevent the user from triggering searches and query suggestions from the component.\n * Perfect for use cases where you need to disable the search conditionally.\n * For the specific case when you need to disable the search based on the length of the query, refer to {@link minimumQueryLength}.\n */\n @Prop({reflect: true}) public disableSearch = false;\n\n /**\n * The minimum query length required to enable search.\n * For example, to disable the search for empty queries, set this to `1`.\n */\n @Prop({reflect: true}) public minimumQueryLength = 0;\n\n /**\n * Whether to clear all active query filters when the end user submits a new query from the search box.\n * Setting this option to \"false\" is not recommended & can lead to an increasing number of queries returning no results.\n */\n @Prop({reflect: true}) public clearFilters = true;\n\n /**\n * Whether to interpret advanced [Coveo Cloud query syntax](https://docs.coveo.com/en/1814/) in the query.\n * You should only enable query syntax in the search box if you have good reasons to do so, as it\n * requires end users to be familiar with Coveo Cloud query syntax, otherwise they will likely be surprised\n * by the search box behaviour.\n *\n * When the `redirection-url` property is set and redirects to a page with more `atomic-search-box` components, all `atomic-search-box` components need to have the same `enable-query-syntax` value.\n */\n @Prop({reflect: true}) public enableQuerySyntax = false;\n\n /**\n * Whether to render the search box using a [textarea](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/textarea) element.\n * The resulting component will expand to support multi-line queries.\n * When customizing the dimensions of the textarea element using the `\"textarea\"` CSS part, it is important to also apply the styling to its ::after pseudo-element as well as the `\"textarea-spacer\"` part.\n * The buttons within the search box are likely to need adjusting as well.\n *\n * Example:\n * ```css\n * \n * ```\n */\n @Prop({reflect: true}) public textarea = false;\n\n /**\n * Event that is emitted when a standalone search box redirection is triggered. By default, the search box will directly change the URL and redirect accordingly, so if you want to handle the redirection differently, use this event.\n *\n * Example:\n * ```html\n * \n * ...\n * \n * ```\n */\n @Event({\n eventName: 'redirect',\n })\n public redirect!: EventEmitter;\n\n @AriaLiveRegion('search-box')\n protected searchBoxAriaMessage!: string;\n\n @AriaLiveRegion('search-suggestions', true)\n protected suggestionsAriaMessage!: string;\n\n public initialize() {\n this.id = randomID('atomic-search-box-');\n this.querySetActions = loadQuerySetActions(this.bindings.engine);\n this.isSearchDisabled = this.disableSearch || this.minimumQueryLength > 0;\n\n const searchBoxOptions: SearchBoxOptions = {\n id: this.id,\n numberOfSuggestions: 0,\n highlightOptions: {\n notMatchDelimiters: {\n open: '',\n close: '',\n },\n correctionDelimiters: {\n open: '',\n close: '',\n },\n },\n clearFilters: this.clearFilters,\n enableQuerySyntax: this.enableQuerySyntax,\n };\n\n this.searchBox = this.redirectionUrl\n ? buildStandaloneSearchBox(this.bindings.engine, {\n options: {...searchBoxOptions, redirectionUrl: this.redirectionUrl},\n })\n : buildSearchBox(this.bindings.engine, {\n options: searchBoxOptions,\n });\n\n this.suggestions = this.suggestionEvents.map((event) =>\n event(this.suggestionBindings)\n );\n\n this.searchBoxCommon = new SearchBoxCommon({\n id: this.id,\n bindings: this.bindings,\n querySetActions: this.querySetActions,\n focusValue: this.focusValue.bind(this),\n clearSuggestions: this.clearSuggestions.bind(this),\n getIsSearchDisabled: () => this.isSearchDisabled,\n getIsExpanded: () => this.isExpanded,\n getPanelInFocus: () => this.panelInFocus,\n getActiveDescendant: () => this.activeDescendant,\n getActiveDescendantElement: () => this.activeDescendantElement,\n getAllSuggestionElements: () => this.allSuggestionElements,\n });\n }\n\n public componentWillUpdate() {\n if (\n !('redirectTo' in this.searchBoxState) ||\n !('afterRedirection' in this.searchBox)\n ) {\n return;\n }\n\n const {redirectTo, value, analytics} = this.searchBoxState;\n\n if (redirectTo === '') {\n return;\n }\n const data: StandaloneSearchBoxData = {\n value,\n enableQuerySyntax: this.enableQuerySyntax,\n analytics,\n };\n const storage = new SafeStorage();\n storage.setJSON(StorageItems.STANDALONE_SEARCH_BOX_DATA, data);\n\n this.searchBox.afterRedirection();\n const event = this.redirect.emit({redirectTo, value});\n if (!event.defaultPrevented) {\n window.location.href = redirectTo;\n }\n }\n\n @Listen('atomic/searchBoxSuggestion/register')\n public registerSuggestions(event: CustomEvent) {\n event.preventDefault();\n event.stopPropagation();\n this.suggestionEvents.push(event.detail);\n if (this.searchBox) {\n this.suggestions.push(event.detail(this.suggestionBindings));\n }\n }\n\n @Watch('redirectionUrl')\n watchRedirectionUrl() {\n this.initialize();\n }\n\n private get suggestionBindings(): SearchBoxSuggestionsBindings {\n return {\n ...this.bindings,\n id: this.id,\n isStandalone: !!this.redirectionUrl,\n searchBoxController: this.searchBox,\n numberOfQueries: this.numberOfQueries,\n clearFilters: this.clearFilters,\n suggestedQuery: () => this.suggestedQuery,\n clearSuggestions: () => this.clearSuggestions(),\n triggerSuggestions: () => this.triggerSuggestions(),\n getSuggestions: () => this.suggestions,\n getSuggestionElements: () => this.allSuggestionElements,\n };\n }\n private updateBreakpoints = once(() => updateBreakpoints(this.host));\n\n private get isDoubleList() {\n return Boolean(\n this.leftSuggestionElements.length && this.rightSuggestionElements.length\n );\n }\n\n private updateActiveDescendant(activeDescendant = '') {\n this.activeDescendant = activeDescendant;\n }\n\n private updateDescendants(activeDescendant = '') {\n const newPrevDescendantElement = this.activeDescendantElement;\n\n this.updateActiveDescendant(activeDescendant);\n this.previousActiveDescendantElement = newPrevDescendantElement;\n }\n\n private get activeDescendantElement(): HTMLElement | null {\n if (!this.searchBoxCommon.hasActiveDescendant) {\n return null;\n }\n\n return (\n this.leftPanelRef?.querySelector(`#${this.activeDescendant}`) ||\n this.rightPanelRef?.querySelector(`#${this.activeDescendant}`) ||\n null\n );\n }\n\n private get allSuggestionElements() {\n return [...this.leftSuggestionElements, ...this.rightSuggestionElements];\n }\n\n private get panelInFocus() {\n if (this.leftPanelRef?.contains(this.activeDescendantElement)) {\n return this.leftPanelRef;\n }\n if (this.rightPanelRef?.contains(this.activeDescendantElement)) {\n return this.rightPanelRef;\n }\n return this.leftPanelRef || this.rightPanelRef;\n }\n\n private getSuggestionElements(suggestions: SearchBoxSuggestions[]) {\n const elements = suggestions\n .map((suggestion) => suggestion.renderItems())\n .flat();\n const max =\n this.numberOfQueries + elements.filter(elementHasNoQuery).length;\n\n return elements.slice(0, max);\n }\n\n private focusValue(value: HTMLElement) {\n this.updateActiveDescendant(value.id);\n this.searchBoxCommon.scrollActiveDescendantIntoView();\n this.updateQueryFromSuggestion();\n this.updateAriaLiveActiveDescendant(value);\n }\n\n private focusPanel(panel: HTMLElement | undefined) {\n if (this.panelInFocus === panel) {\n return;\n }\n if (panel && 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 this.updateAriaLiveActiveDescendant(newValue);\n }\n }\n\n private updateAriaMessage() {\n const elsLength = this.allSuggestionElements.filter(elementHasQuery).length;\n this.searchBoxAriaMessage = elsLength\n ? this.bindings.i18n.t('query-suggestions-available', {\n count: elsLength,\n })\n : this.bindings.i18n.t('query-suggestions-unavailable');\n }\n\n private async triggerSuggestions() {\n if (this.disableSearch) {\n return;\n }\n const settled = await Promise.allSettled(\n this.suggestions.map((suggestion) =>\n promiseTimeout(\n suggestion.onInput ? suggestion.onInput() : Promise.resolve(),\n this.suggestionTimeout\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.bindings.engine.logger.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 this.updateSuggestedQuery(defaultSuggestedQuery);\n this.updateAriaMessage();\n }\n\n private sortSuggestions(a: SearchBoxSuggestions, b: SearchBoxSuggestions) {\n return a.position - b.position;\n }\n\n private onInput(value: string) {\n this.isSearchDisabled =\n this.disableSearch || this.minimumQueryLength > value.trim().length;\n if (this.isSearchDisabled) {\n return;\n }\n this.isExpanded = true;\n this.searchBox.updateText(value);\n this.updateActiveDescendant();\n this.triggerSuggestions();\n }\n\n private onFocus() {\n this.isExpanded = true;\n this.triggerSuggestions();\n }\n\n private clearSuggestions() {\n this.isExpanded = false;\n this.updateActiveDescendant();\n this.clearSuggestionElements();\n }\n\n private onSubmit() {\n if (this.activeDescendantElement) {\n this.activeDescendantElement.click();\n this.updateActiveDescendant();\n return;\n }\n\n this.searchBox.submit();\n this.updateActiveDescendant();\n this.clearSuggestions();\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 = query.replace(/\"/g, '\\\\\"');\n return !!panel?.querySelector(`[${queryDataAttribute}=\"${escaped}\"]`);\n }\n\n return this.activeDescendantElement?.closest('ul') === panel;\n }\n\n private updateQueryFromSuggestion() {\n const suggestedQuery =\n this.activeDescendantElement?.getAttribute(queryDataAttribute);\n if (suggestedQuery && this.searchBoxState.value !== suggestedQuery) {\n this.searchBoxCommon.updateQuery(suggestedQuery);\n this.updateSuggestedQuery(suggestedQuery);\n }\n }\n\n private updateAriaLiveActiveDescendant(value: HTMLElement) {\n if (isMacOS()) {\n this.suggestionsAriaMessage = value.ariaLabel!;\n }\n }\n\n private updateSuggestionElements(query: string) {\n if (!this.isPanelInFocus(this.leftPanelRef, query)) {\n this.leftSuggestionElements = this.getAndFilterLeftSuggestionElements();\n }\n\n if (!this.isPanelInFocus(this.rightPanelRef, query)) {\n this.rightSuggestionElements = this.getSuggestionElements(\n this.rightSuggestions\n );\n }\n }\n\n private getAndFilterLeftSuggestionElements() {\n const suggestionElements = this.getSuggestionElements(this.leftSuggestions);\n const filterOnDuplicate = new Set();\n\n return 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\n private onKeyDown(e: KeyboardEvent) {\n if (this.isSearchDisabled) {\n return;\n }\n\n switch (e.key) {\n case 'Enter':\n this.onSubmit();\n break;\n case 'Escape':\n this.clearSuggestions();\n break;\n case 'ArrowDown':\n e.preventDefault();\n this.searchBoxCommon.focusNextValue();\n break;\n case 'ArrowUp':\n e.preventDefault();\n if (this.searchBoxCommon.firstValue === this.activeDescendantElement) {\n this.updateActiveDescendant();\n } else {\n this.searchBoxCommon.focusPreviousValue();\n }\n break;\n case 'ArrowRight':\n if (this.activeDescendant || !this.searchBox.state.value) {\n e.preventDefault();\n this.focusPanel(this.rightPanelRef);\n }\n break;\n case 'ArrowLeft':\n if (this.activeDescendant || !this.searchBox.state.value) {\n e.preventDefault();\n this.focusPanel(this.leftPanelRef);\n }\n break;\n case 'Tab':\n this.clearSuggestions();\n break;\n }\n }\n\n private clearSuggestionElements() {\n this.leftSuggestionElements = [];\n this.rightSuggestionElements = [];\n this.searchBoxAriaMessage = '';\n }\n\n private onSuggestionMouseOver(\n item: SearchBoxSuggestionElement,\n side: 'left' | 'right',\n id: string\n ) {\n const thisPanel = side === 'left' ? this.leftPanelRef : this.rightPanelRef;\n if (this.panelInFocus === thisPanel) {\n this.updateActiveDescendant(id);\n } else {\n this.updateDescendants(id);\n }\n if (item.query) {\n this.updateSuggestedQuery(item.query);\n }\n }\n\n private triggerTextAreaChange(value: string) {\n this.textAreaRef.value = value;\n this.textAreaRef.dispatchEvent(new window.Event('change'));\n }\n\n private renderSuggestion(\n item: SearchBoxSuggestionElement,\n index: number,\n lastIndex: number,\n side: 'left' | 'right'\n ) {\n const id = `${this.id}-${side}-suggestion-${item.key}`;\n\n const isSelected = id === this.activeDescendant;\n\n if (index === lastIndex && item.hideIfLast) {\n return null;\n }\n const isButton = item.onSelect || item.query;\n\n if (!isButton) {\n return (\n \n );\n }\n\n return (\n {\n this.searchBoxCommon.onSuggestionClick(item, e);\n if (this.textarea) {\n this.triggerTextAreaChange(item.query ?? '');\n }\n }}\n onMouseOver={() => {\n this.onSuggestionMouseOver(item, side, id);\n }}\n >\n );\n }\n\n private async updateSuggestedQuery(suggestedQuery: string) {\n const query = this.bindings.store.isMobile() ? '' : suggestedQuery;\n await Promise.allSettled(\n this.suggestions.map((suggestion) =>\n promiseTimeout(\n suggestion.onSuggestedQueryChange\n ? suggestion.onSuggestedQueryChange(query)\n : Promise.resolve(),\n this.suggestionTimeout\n )\n )\n );\n this.suggestedQuery = query;\n this.updateSuggestionElements(query);\n }\n\n private renderPanel(\n side: 'left' | 'right',\n elements: SearchBoxSuggestionElement[],\n setRef: (el: HTMLElement | undefined) => void,\n getRef: () => HTMLElement | undefined\n ) {\n if (!elements.length) {\n return null;\n }\n\n return (\n {\n if (e.target === getRef()) {\n e.preventDefault();\n }\n }}\n >\n {elements.map((suggestion, index) =>\n this.renderSuggestion(suggestion, index, elements.length - 1, side)\n )}\n \n );\n }\n\n private renderSuggestions() {\n if (!this.searchBoxCommon.hasSuggestions) {\n return null;\n }\n\n return (\n \n {this.renderPanel(\n 'left',\n this.leftSuggestionElements,\n (el) => (this.leftPanelRef = el),\n () => this.leftPanelRef\n )}\n {this.renderPanel(\n 'right',\n this.rightSuggestionElements,\n (el) => (this.rightPanelRef = el),\n () => this.rightPanelRef\n )}\n \n );\n }\n\n private renderTextBox = (searchLabel: string) => {\n const props = {\n loading: this.searchBoxState.isLoading,\n bindings: this.bindings,\n value: this.searchBoxState.value,\n title: searchLabel,\n ariaLabel: searchLabel,\n onFocus: () => this.onFocus(),\n onInput: (e: Event) =>\n this.onInput(\n (e.target as HTMLInputElement | HTMLTextAreaElement).value\n ),\n onKeyDown: (e: KeyboardEvent) => this.onKeyDown(e),\n onClear: () => this.searchBox.clear(),\n popup: {\n id: this.searchBoxCommon.popupId,\n activeDescendant: this.activeDescendant,\n expanded: this.isExpanded,\n hasSuggestions: this.searchBoxCommon.hasSuggestions,\n },\n };\n\n return this.textarea ? (\n (this.textAreaRef = el as HTMLTextAreaElement)}\n {...props}\n onClear={() => {\n props.onClear();\n this.triggerTextAreaChange('');\n }}\n />\n ) : (\n (this.inputRef = el as HTMLInputElement)}\n {...props}\n />\n );\n };\n\n private renderAbsolutePositionSpacer() {\n return (\n \n );\n }\n\n public render() {\n this.updateBreakpoints();\n\n const searchLabel = this.searchBoxCommon.getSearchInputLabel(\n this.minimumQueryLength\n );\n const Submit = this.textarea ? TextAreaSubmitButton : SubmitButton;\n\n return (\n \n {this.textarea ? this.renderAbsolutePositionSpacer() : null}\n {[\n \n this.clearSuggestions()}\n >\n {this.renderTextBox(searchLabel)}\n this.searchBox.submit()}\n title={searchLabel}\n />\n {this.renderSuggestions()}\n \n ,\n !this.suggestions.length && (\n \n \n \n \n ),\n ]}\n \n );\n }\n}\n"]}