Skip to content

Commit 550ac5e

Browse files
committed
2 parents 365f033 + 32737bf commit 550ac5e

File tree

4 files changed

+52
-25
lines changed

4 files changed

+52
-25
lines changed

packages/atomic/src/components/commerce/atomic-commerce-search-box/atomic-commerce-search-box.ts

+48-14
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
StorageItems,
1313
} from '@/src/utils/local-storage-utils';
1414
import {updateBreakpoints} from '@/src/utils/replace-breakpoint';
15+
import {isNullOrUndefined} from '@coveo/bueno';
1516
import {
1617
buildSearchBox,
1718
buildStandaloneSearchBox,
@@ -33,28 +34,70 @@ import {
3334
spreadProperties,
3435
} from '../../../utils/stencil-utils';
3536
import {RedirectionPayload} from '../../common/search-box/redirection-payload';
37+
import {searchBoxTextArea} from '../../common/search-box/search-box-text-area';
3638
import {
3739
buttonSearchSuggestion,
3840
simpleSearchSuggestion,
3941
} from '../../common/search-box/search-suggestion';
4042
import {submitButton} from '../../common/search-box/submit-button';
41-
import {textArea} from '../../common/search-box/text-area';
4243
import {wrapper} from '../../common/search-box/wrapper';
44+
import {SuggestionManager} from '../../common/suggestions/suggestion-manager';
4345
import {
4446
elementHasQuery,
4547
SearchBoxSuggestionElement,
4648
SearchBoxSuggestionsBindings,
4749
SearchBoxSuggestionsEvent,
48-
} from '../../common/suggestions/stencil-suggestions-common';
49-
import {SuggestionManager} from '../../common/suggestions/suggestion-manager';
50+
} from '../../common/suggestions/suggestions-common';
5051
import {CommerceBindings} from '../atomic-commerce-interface/atomic-commerce-interface';
5152
import {SelectChildProductEventArgs} from '../product-template-components/atomic-product-children/select-child-product-event';
5253
import styles from './atomic-commerce-search-box.tw.css';
5354

5455
/**
5556
* The atomic-commerce-search-box is a component that does something.
5657
*
57-
* @event redirect - TODO
58+
* @slot default - The default slot where you can add child components to the search box.
59+
*
60+
* @part wrapper - The search box wrapper.
61+
* @part input - The search box input.
62+
* @part loading - The search box loading animation.
63+
* @part clear-button - The button to clear the search box of input.
64+
* @part clear-icon - The clear button's icon.
65+
* @part submit-button - The search box submit button.
66+
* @part submit-icon - The search box submit button's icon.
67+
* @part suggestions - A list of suggested query corrections on each panel.
68+
* @part suggestions-left - A list of suggested query corrections on the left panel.
69+
* @part suggestions-right - A list of suggested query corrections on the right panel.
70+
* @part suggestions-wrapper - The wrapper that contains suggestion panels.
71+
* @part suggestions-single-list - The wrapper that contains 1 suggestion list.
72+
* @part suggestions-double-list - The wrapper that contains 2 suggestion lists.
73+
* @part suggestion - A suggested query correction.
74+
* @part active-suggestion - The currently active suggestion.
75+
* @part suggestion-divider - An item in the list that separates groups of suggestions.
76+
* @part suggestion-with-query - An item in the list that will update the search box query.
77+
*
78+
* @part query-suggestion-item - A suggestion from the `atomic-commerce-search-box-query-suggestions` component.
79+
* @part query-suggestion-content - The contents of a suggestion from the `atomic-commerce-search-box-query-suggestions` component.
80+
* @part query-suggestion-icon - The icon of a suggestion from the `atomic-commerce-search-box-query-suggestions` component.
81+
* @part query-suggestion-text - The text of a suggestion from the `atomic-commerce-search-box-query-suggestions` component.
82+
*
83+
* @part recent-query-item - A suggestion from the `atomic-commerce-search-box-recent-queries` component.
84+
* @part recent-query-content - The contents of a suggestion from the `atomic-commerce-search-box-recent-queries` component.
85+
* @part recent-query-icon - The icon of a suggestion from the `atomic-commerce-search-box-recent-queries` component.
86+
* @part recent-query-text - The text of a suggestion from the `atomic-commerce-search-box-recent-queries` component.
87+
* @part recent-query-text-highlight - The highlighted portion of the text of a suggestion from the `atomic-commerce-search-box-recent-queries` component.
88+
* @part recent-query-title-item - The clear button above suggestions from the `atomic-commerce-search-box-recent-queries` component.
89+
* @part recent-query-title-content - The contents of the clear button above suggestions from the `atomic-commerce-search-box-recent-queries` component.
90+
* @part recent-query-title - The "recent searches" text of the clear button above suggestions from the `atomic-commerce-search-box-recent-queries` component.
91+
* @part recent-query-clear - The "clear" text of the clear button above suggestions from the `atomic-commerce-search-box-recent-queries` component.
92+
*
93+
* @part instant-results-item - An instant result rendered by an `atomic-commerce-search-box-instant-products` component.
94+
* @part instant-results-show-all - The clickable suggestion to show all items for the current instant results search rendered by an `atomic-commerce-search-box-instant-products` component.
95+
* @part instant-results-show-all-button - The button inside the clickable suggestion from the `atomic-commerce-search-box-instant-products` component.
96+
*
97+
* @event redirect - 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.
98+
99+
*
100+
* @alpha
58101
*/
59102
@customElement('atomic-commerce-search-box')
60103
@withTailwindStyles
@@ -223,7 +266,6 @@ export class AtomicCommerceSearchBox
223266
}
224267

225268
willUpdate() {
226-
//added this
227269
if (!this.searchBoxState || !this.searchBox) {
228270
return;
229271
}
@@ -248,7 +290,6 @@ export class AtomicCommerceSearchBox
248290

249291
this.searchBox.afterRedirection();
250292

251-
//Does this work ?
252293
const event = new CustomEvent<RedirectionPayload>('redirect');
253294
this.dispatchEvent(event);
254295
if (!event.defaultPrevented) {
@@ -513,7 +554,6 @@ export class AtomicCommerceSearchBox
513554
return null;
514555
}
515556

516-
//Does ref work here ?
517557
return html`<div
518558
part="suggestions suggestions-${side}"
519559
${ref(setRef as RefOrCallback<Element>)}
@@ -609,7 +649,7 @@ export class AtomicCommerceSearchBox
609649
},
610650
};
611651

612-
return html`${textArea({
652+
return html`${searchBoxTextArea({
613653
props: {
614654
textAreaRef: this.textAreaRef,
615655
ref: (el) => {
@@ -711,12 +751,6 @@ export class AtomicCommerceSearchBox
711751
this.registerSearchboxSuggestionEvents();
712752
}
713753

714-
//Needs to add more conditions here
715-
console.log(
716-
this.suggestionManager.suggestions.length === 0,
717-
'should render the slots'
718-
);
719-
720754
return html`
721755
${this.renderAbsolutePositionSpacer()}
722756
${wrapper({

packages/atomic/src/components/commerce/search-box-suggestions/atomic-commerce-search-box-instant-products/atomic-commerce-search-box-instant-products.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ import {
1515
SearchBoxSuggestions,
1616
SearchBoxSuggestionsBindings,
1717
} from '@/src/components/common/suggestions/suggestions-common';
18-
import {bindingGuard} from '@/src/decorators/binding-guard';
1918
import {errorGuard} from '@/src/decorators/error-guard';
2019
import {InitializableComponent} from '@/src/decorators/types';
2120
import {withTailwindStyles} from '@/src/decorators/with-tailwind-styles.js';
22-
import {InitializeBindingsMixin} from '@/src/mixins/bindings-mixin';
2321
import {encodeForDomAttribute} from '@/src/utils/string-utils';
2422
import {
2523
buildInstantProducts,
@@ -44,7 +42,7 @@ export type AriaLabelGenerator = (
4442
@customElement('atomic-commerce-search-box-instant-products')
4543
@withTailwindStyles
4644
export class AtomicCommerceSearchBoxInstantProducts
47-
extends InitializeBindingsMixin(LitElement)
45+
extends LitElement
4846
implements InitializableComponent<CommerceBindings>
4947
{
5048
public bindings!: SearchBoxSuggestionsBindings<SearchBox, CommerceBindings>;
@@ -257,10 +255,9 @@ export class AtomicCommerceSearchBoxInstantProducts
257255
});
258256
}
259257

260-
@bindingGuard()
261258
@errorGuard()
262259
render() {
263-
return html`TODO`;
260+
return html``;
264261
}
265262
}
266263

packages/atomic/src/components/commerce/search-box-suggestions/atomic-commerce-search-box-query-suggestions/atomic-commerce-search-box-query-suggestions.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
SearchBoxSuggestions,
1111
SearchBoxSuggestionsBindings,
1212
} from '@/src/components/common/suggestions/suggestions-common';
13-
import {bindingGuard} from '@/src/decorators/binding-guard';
1413
import {errorGuard} from '@/src/decorators/error-guard';
1514
import {InitializableComponent} from '@/src/decorators/types';
1615
import {withTailwindStyles} from '@/src/decorators/with-tailwind-styles.js';
@@ -131,10 +130,9 @@ export class AtomicCommerceSearchBoxQuerySuggestions
131130
};
132131
}
133132

134-
@bindingGuard()
135133
@errorGuard()
136134
render() {
137-
return html`TODO`;
135+
return html``;
138136
}
139137
}
140138

packages/atomic/src/components/commerce/search-box-suggestions/atomic-commerce-search-box-recent-queries/atomic-commerce-search-box-recent-queries.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
SearchBoxSuggestions,
1313
SearchBoxSuggestionsBindings,
1414
} from '@/src/components/common/suggestions/suggestions-common';
15-
import {bindingGuard} from '@/src/decorators/binding-guard';
1615
import {errorGuard} from '@/src/decorators/error-guard';
1716
import {InitializableComponent} from '@/src/decorators/types';
1817
import {withTailwindStyles} from '@/src/decorators/with-tailwind-styles.js';
@@ -191,10 +190,9 @@ export class AtomicCommerceSearchBoxRecentQueries
191190
};
192191
}
193192

194-
@bindingGuard()
195193
@errorGuard()
196194
render() {
197-
return html`TODO, make nothing work here`;
195+
return html``;
198196
}
199197
}
200198

0 commit comments

Comments
 (0)