@shoper/phoenix_design_system 1.17.11-1 → 1.17.11-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/packages/phoenix/src/components/form/search/subcomponents/results/search_results.js +4 -0
- package/build/cjs/packages/phoenix/src/components/form/search/subcomponents/results/search_results.js.map +1 -1
- package/build/cjs/packages/phoenix/src/components/form/search/subcomponents/results/search_suggestion_content.js +29 -36
- package/build/cjs/packages/phoenix/src/components/form/search/subcomponents/results/search_suggestion_content.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/form/search/subcomponents/results/search_results.js +4 -0
- package/build/esm/packages/phoenix/src/components/form/search/subcomponents/results/search_results.js.map +1 -1
- package/build/esm/packages/phoenix/src/components/form/search/subcomponents/results/search_suggestion_content.d.ts +5 -5
- package/build/esm/packages/phoenix/src/components/form/search/subcomponents/results/search_suggestion_content.js +29 -36
- package/build/esm/packages/phoenix/src/components/form/search/subcomponents/results/search_suggestion_content.js.map +1 -1
- package/package.json +1 -1
|
@@ -76,6 +76,10 @@ exports.HSearchResults = class HSearchResults extends phoenix_light_lit_element.
|
|
|
76
76
|
locale="${this.locale}"
|
|
77
77
|
view="${this.view}"
|
|
78
78
|
module-instance-id="${this.moduleInstanceId}"
|
|
79
|
+
search-phrase="${this.searchPhrase}"
|
|
80
|
+
.suggestions="${this.results.suggestions}"
|
|
81
|
+
.products="${this.results.products}"
|
|
82
|
+
.categories="${this.results.categories}"
|
|
79
83
|
.suggestionAriaLabel=${this.settings.suggesterItemAriaLabel}
|
|
80
84
|
>
|
|
81
85
|
</h-search-suggestion-content>`)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,qDAAyD;AACjF;AACA;AACA;AACA;AACA,iBAAiB,8DAAkE;AACnF,mBAAmB,8DAAkE;AACrF;AACA,sBAAsB,oDAAwD;AAC9E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,qDAAyD;AACjF;AACA;AACA;AACA;AACA,iBAAiB,8DAAkE;AACnF,mBAAmB,8DAAkE;AACrF;AACA,sBAAsB,oDAAwD;AAC9E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -7,8 +7,6 @@ var lit = require('lit');
|
|
|
7
7
|
var decorators = require('lit/decorators');
|
|
8
8
|
var phoenix_light_lit_element = require('../../../../../core/phoenix_light_lit_element/phoenix_light_lit_element.js');
|
|
9
9
|
var phoenix_custom_element = require('../../../../../core/decorators/phoenix_custom_element.js');
|
|
10
|
-
var observer = require('../../../../../core/classes/observer/observer.js');
|
|
11
|
-
var context_consumer_controller = require('../../../../../core/context/context_consumer_controller.js');
|
|
12
10
|
var when = require('../../../../../../../../external/lit-html/directives/when.js');
|
|
13
11
|
var search_constants = require('../../search_constants.js');
|
|
14
12
|
var repeat = require('../../../../../../../../external/lit-html/directives/repeat.js');
|
|
@@ -16,9 +14,7 @@ var repeat = require('../../../../../../../../external/lit-html/directives/repea
|
|
|
16
14
|
exports.HSearchSuggestionContent = class HSearchSuggestionContent extends phoenix_light_lit_element.PhoenixLightLitElement {
|
|
17
15
|
constructor() {
|
|
18
16
|
super(...arguments);
|
|
19
|
-
this.initialItemIds = {};
|
|
20
17
|
this.translations = {};
|
|
21
|
-
this._searchPhrase = '';
|
|
22
18
|
this._suggestionsData = [];
|
|
23
19
|
this._updateSearchPhrase = (ev, suggestion) => {
|
|
24
20
|
ev.stopPropagation();
|
|
@@ -27,40 +23,29 @@ exports.HSearchSuggestionContent = class HSearchSuggestionContent extends phoeni
|
|
|
27
23
|
}
|
|
28
24
|
async connectedCallback() {
|
|
29
25
|
super.connectedCallback();
|
|
30
|
-
|
|
31
|
-
this._searchContextConsumer = new context_consumer_controller.ContextConsumerController(this);
|
|
32
|
-
this._searchContext$ = await this._searchContextConsumer.consumeAsync(this.moduleInstanceId);
|
|
33
|
-
this._searchContextObserver = new observer.Observer((searchData) => {
|
|
34
|
-
this._searchPhrase = searchData.searchPhrase;
|
|
35
|
-
this._setupSuggestionData(searchData.results);
|
|
36
|
-
});
|
|
37
|
-
this._searchContext$.subscribe(this._searchContextObserver);
|
|
38
|
-
}
|
|
39
|
-
catch (_a) {
|
|
40
|
-
console.error('Search context is not provided');
|
|
41
|
-
}
|
|
26
|
+
this._setupSuggestionData();
|
|
42
27
|
}
|
|
43
|
-
_setupSuggestionData(
|
|
28
|
+
_setupSuggestionData() {
|
|
44
29
|
let suggestionsData = [];
|
|
45
|
-
if (
|
|
46
|
-
|
|
30
|
+
if (this.suggestions.length) {
|
|
31
|
+
this.suggestions.forEach((suggestion, index) => {
|
|
47
32
|
suggestionsData.push({ suggestionName: suggestion, type: search_constants.SUGGESTIONS_TYPE.suggestion });
|
|
48
33
|
if (index)
|
|
49
34
|
return;
|
|
50
|
-
const isProductInTheCategory =
|
|
35
|
+
const isProductInTheCategory = this.products.length;
|
|
51
36
|
if (isProductInTheCategory) {
|
|
52
37
|
const lang = this.locale.split('_')[0];
|
|
53
38
|
suggestionsData.push({
|
|
54
39
|
suggestionName: suggestion,
|
|
55
|
-
categoryName:
|
|
40
|
+
categoryName: this.products[0].category.breadcrumbs,
|
|
56
41
|
type: search_constants.SUGGESTIONS_TYPE.suggestionInCategory,
|
|
57
|
-
url: `/${lang}/c/${
|
|
42
|
+
url: `/${lang}/c/${this.products[0].category.name}/${this.products[0].category.categoryId}/1/${this.view}/1/searchquery/${suggestion}`
|
|
58
43
|
});
|
|
59
44
|
}
|
|
60
|
-
if (
|
|
45
|
+
if (this.categories.length) {
|
|
61
46
|
suggestionsData = [
|
|
62
47
|
...suggestionsData,
|
|
63
|
-
...
|
|
48
|
+
...this.categories.map((category) => ({
|
|
64
49
|
categoryName: category.name,
|
|
65
50
|
url: category.url,
|
|
66
51
|
type: search_constants.SUGGESTIONS_TYPE.category
|
|
@@ -69,9 +54,9 @@ exports.HSearchSuggestionContent = class HSearchSuggestionContent extends phoeni
|
|
|
69
54
|
}
|
|
70
55
|
});
|
|
71
56
|
}
|
|
72
|
-
else if (
|
|
57
|
+
else if (this.categories.length) {
|
|
73
58
|
suggestionsData = [
|
|
74
|
-
...
|
|
59
|
+
...this.categories.map((category) => ({
|
|
75
60
|
categoryName: category.name,
|
|
76
61
|
url: category.url,
|
|
77
62
|
type: search_constants.SUGGESTIONS_TYPE.category
|
|
@@ -94,10 +79,10 @@ exports.HSearchSuggestionContent = class HSearchSuggestionContent extends phoeni
|
|
|
94
79
|
});
|
|
95
80
|
}
|
|
96
81
|
_getMatchedPhrase(phrase) {
|
|
97
|
-
const phraseIncludesSearchPhrase = phrase.toLowerCase().includes(this.
|
|
82
|
+
const phraseIncludesSearchPhrase = phrase.toLowerCase().includes(this.searchPhrase);
|
|
98
83
|
if (!phraseIncludesSearchPhrase)
|
|
99
84
|
return lit.html `${phrase}`;
|
|
100
|
-
const index = phrase.toLowerCase().indexOf(this.
|
|
85
|
+
const index = phrase.toLowerCase().indexOf(this.searchPhrase) + this.searchPhrase.length;
|
|
101
86
|
return lit.html `${phrase.substring(0, index)}<strong>${phrase.substring(index)}</strong>`;
|
|
102
87
|
}
|
|
103
88
|
render() {
|
|
@@ -146,10 +131,6 @@ tslib_es6.__decorate([
|
|
|
146
131
|
decorators.property({ type: String, attribute: 'search-id' }),
|
|
147
132
|
tslib_es6.__metadata("design:type", String)
|
|
148
133
|
], exports.HSearchSuggestionContent.prototype, "searchId", void 0);
|
|
149
|
-
tslib_es6.__decorate([
|
|
150
|
-
decorators.property({ type: Object, reflect: true }),
|
|
151
|
-
tslib_es6.__metadata("design:type", Object)
|
|
152
|
-
], exports.HSearchSuggestionContent.prototype, "initialItemIds", void 0);
|
|
153
134
|
tslib_es6.__decorate([
|
|
154
135
|
decorators.property({ type: Object }),
|
|
155
136
|
tslib_es6.__metadata("design:type", Object)
|
|
@@ -167,13 +148,25 @@ tslib_es6.__decorate([
|
|
|
167
148
|
tslib_es6.__metadata("design:type", String)
|
|
168
149
|
], exports.HSearchSuggestionContent.prototype, "moduleInstanceId", void 0);
|
|
169
150
|
tslib_es6.__decorate([
|
|
170
|
-
decorators.property({ type: String }),
|
|
151
|
+
decorators.property({ type: String, attribute: 'search-phrase' }),
|
|
171
152
|
tslib_es6.__metadata("design:type", String)
|
|
172
|
-
], exports.HSearchSuggestionContent.prototype, "
|
|
153
|
+
], exports.HSearchSuggestionContent.prototype, "searchPhrase", void 0);
|
|
173
154
|
tslib_es6.__decorate([
|
|
174
|
-
decorators.
|
|
155
|
+
decorators.property({ type: Object }),
|
|
156
|
+
tslib_es6.__metadata("design:type", Array)
|
|
157
|
+
], exports.HSearchSuggestionContent.prototype, "suggestions", void 0);
|
|
158
|
+
tslib_es6.__decorate([
|
|
159
|
+
decorators.property({ type: Object }),
|
|
160
|
+
tslib_es6.__metadata("design:type", Array)
|
|
161
|
+
], exports.HSearchSuggestionContent.prototype, "products", void 0);
|
|
162
|
+
tslib_es6.__decorate([
|
|
163
|
+
decorators.property({ type: Object }),
|
|
164
|
+
tslib_es6.__metadata("design:type", Array)
|
|
165
|
+
], exports.HSearchSuggestionContent.prototype, "categories", void 0);
|
|
166
|
+
tslib_es6.__decorate([
|
|
167
|
+
decorators.property({ type: String }),
|
|
175
168
|
tslib_es6.__metadata("design:type", String)
|
|
176
|
-
], exports.HSearchSuggestionContent.prototype, "
|
|
169
|
+
], exports.HSearchSuggestionContent.prototype, "suggestionAriaLabel", void 0);
|
|
177
170
|
tslib_es6.__decorate([
|
|
178
171
|
decorators.state(),
|
|
179
172
|
tslib_es6.__metadata("design:type", Array)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,qDAAyD;AACjF;AACA;AACA;AACA;AACA
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,qDAAyD;AACjF;AACA;AACA;AACA;AACA,mBAAmB,8DAAkE;AACrF;AACA,qBAAqB,gEAAoE;AACzF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -72,6 +72,10 @@ let HSearchResults = class HSearchResults extends PhoenixLightLitElement {
|
|
|
72
72
|
locale="${this.locale}"
|
|
73
73
|
view="${this.view}"
|
|
74
74
|
module-instance-id="${this.moduleInstanceId}"
|
|
75
|
+
search-phrase="${this.searchPhrase}"
|
|
76
|
+
.suggestions="${this.results.suggestions}"
|
|
77
|
+
.products="${this.results.products}"
|
|
78
|
+
.categories="${this.results.categories}"
|
|
75
79
|
.suggestionAriaLabel=${this.settings.suggesterItemAriaLabel}
|
|
76
80
|
>
|
|
77
81
|
</h-search-suggestion-content>`)}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,qDAAyD;AAChG;AACA;AACA;AACA;AACA,eAAe,8DAAkE;AACjF,0BAA0B,8DAAkE;AAC5F;AACA,sBAAsB,oDAAwD;AAC9E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,qDAAyD;AAChG;AACA;AACA;AACA;AACA,eAAe,8DAAkE;AACjF,0BAA0B,8DAAkE;AAC5F;AACA,sBAAsB,oDAAwD;AAC9E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { TemplateResult } from 'lit';
|
|
2
2
|
import { PhoenixLightLitElement } from "../../../../../core/phoenix_light_lit_element/phoenix_light_lit_element";
|
|
3
|
+
import type { TCategory, TProduct } from "../../search_types";
|
|
3
4
|
export declare class HSearchSuggestionContent extends PhoenixLightLitElement {
|
|
4
|
-
private _searchContextConsumer;
|
|
5
|
-
private _searchContext$;
|
|
6
|
-
private _searchContextObserver;
|
|
7
5
|
activeItemId: string;
|
|
8
6
|
searchId: string;
|
|
9
|
-
initialItemIds: Record<string, number>;
|
|
10
7
|
translations: Record<string, string>;
|
|
11
8
|
view: string;
|
|
12
9
|
locale: string;
|
|
13
10
|
moduleInstanceId: string;
|
|
11
|
+
searchPhrase: string;
|
|
12
|
+
suggestions: string[];
|
|
13
|
+
products: TProduct[];
|
|
14
|
+
categories: TCategory[];
|
|
14
15
|
suggestionAriaLabel?: string;
|
|
15
|
-
private _searchPhrase;
|
|
16
16
|
private _suggestionsData;
|
|
17
17
|
connectedCallback(): Promise<void>;
|
|
18
18
|
private _setupSuggestionData;
|
|
@@ -3,8 +3,6 @@ import { html } from 'lit';
|
|
|
3
3
|
import { property, state } from 'lit/decorators';
|
|
4
4
|
import { PhoenixLightLitElement } from '../../../../../core/phoenix_light_lit_element/phoenix_light_lit_element.js';
|
|
5
5
|
import { phoenixCustomElement } from '../../../../../core/decorators/phoenix_custom_element.js';
|
|
6
|
-
import { Observer } from '../../../../../core/classes/observer/observer.js';
|
|
7
|
-
import { ContextConsumerController } from '../../../../../core/context/context_consumer_controller.js';
|
|
8
6
|
import { when as n } from '../../../../../../../../external/lit-html/directives/when.js';
|
|
9
7
|
import { SEARCH_CUSTOM_EVENT_NAMES, SUGGESTIONS_TYPE, SEARCH_CLASS_NAMES, SEARCH_COMPONENT_NAMES } from '../../search_constants.js';
|
|
10
8
|
import { repeat as c } from '../../../../../../../../external/lit-html/directives/repeat.js';
|
|
@@ -12,9 +10,7 @@ import { repeat as c } from '../../../../../../../../external/lit-html/directive
|
|
|
12
10
|
let HSearchSuggestionContent = class HSearchSuggestionContent extends PhoenixLightLitElement {
|
|
13
11
|
constructor() {
|
|
14
12
|
super(...arguments);
|
|
15
|
-
this.initialItemIds = {};
|
|
16
13
|
this.translations = {};
|
|
17
|
-
this._searchPhrase = '';
|
|
18
14
|
this._suggestionsData = [];
|
|
19
15
|
this._updateSearchPhrase = (ev, suggestion) => {
|
|
20
16
|
ev.stopPropagation();
|
|
@@ -23,40 +19,29 @@ let HSearchSuggestionContent = class HSearchSuggestionContent extends PhoenixLig
|
|
|
23
19
|
}
|
|
24
20
|
async connectedCallback() {
|
|
25
21
|
super.connectedCallback();
|
|
26
|
-
|
|
27
|
-
this._searchContextConsumer = new ContextConsumerController(this);
|
|
28
|
-
this._searchContext$ = await this._searchContextConsumer.consumeAsync(this.moduleInstanceId);
|
|
29
|
-
this._searchContextObserver = new Observer((searchData) => {
|
|
30
|
-
this._searchPhrase = searchData.searchPhrase;
|
|
31
|
-
this._setupSuggestionData(searchData.results);
|
|
32
|
-
});
|
|
33
|
-
this._searchContext$.subscribe(this._searchContextObserver);
|
|
34
|
-
}
|
|
35
|
-
catch (_a) {
|
|
36
|
-
console.error('Search context is not provided');
|
|
37
|
-
}
|
|
22
|
+
this._setupSuggestionData();
|
|
38
23
|
}
|
|
39
|
-
_setupSuggestionData(
|
|
24
|
+
_setupSuggestionData() {
|
|
40
25
|
let suggestionsData = [];
|
|
41
|
-
if (
|
|
42
|
-
|
|
26
|
+
if (this.suggestions.length) {
|
|
27
|
+
this.suggestions.forEach((suggestion, index) => {
|
|
43
28
|
suggestionsData.push({ suggestionName: suggestion, type: SUGGESTIONS_TYPE.suggestion });
|
|
44
29
|
if (index)
|
|
45
30
|
return;
|
|
46
|
-
const isProductInTheCategory =
|
|
31
|
+
const isProductInTheCategory = this.products.length;
|
|
47
32
|
if (isProductInTheCategory) {
|
|
48
33
|
const lang = this.locale.split('_')[0];
|
|
49
34
|
suggestionsData.push({
|
|
50
35
|
suggestionName: suggestion,
|
|
51
|
-
categoryName:
|
|
36
|
+
categoryName: this.products[0].category.breadcrumbs,
|
|
52
37
|
type: SUGGESTIONS_TYPE.suggestionInCategory,
|
|
53
|
-
url: `/${lang}/c/${
|
|
38
|
+
url: `/${lang}/c/${this.products[0].category.name}/${this.products[0].category.categoryId}/1/${this.view}/1/searchquery/${suggestion}`
|
|
54
39
|
});
|
|
55
40
|
}
|
|
56
|
-
if (
|
|
41
|
+
if (this.categories.length) {
|
|
57
42
|
suggestionsData = [
|
|
58
43
|
...suggestionsData,
|
|
59
|
-
...
|
|
44
|
+
...this.categories.map((category) => ({
|
|
60
45
|
categoryName: category.name,
|
|
61
46
|
url: category.url,
|
|
62
47
|
type: SUGGESTIONS_TYPE.category
|
|
@@ -65,9 +50,9 @@ let HSearchSuggestionContent = class HSearchSuggestionContent extends PhoenixLig
|
|
|
65
50
|
}
|
|
66
51
|
});
|
|
67
52
|
}
|
|
68
|
-
else if (
|
|
53
|
+
else if (this.categories.length) {
|
|
69
54
|
suggestionsData = [
|
|
70
|
-
...
|
|
55
|
+
...this.categories.map((category) => ({
|
|
71
56
|
categoryName: category.name,
|
|
72
57
|
url: category.url,
|
|
73
58
|
type: SUGGESTIONS_TYPE.category
|
|
@@ -90,10 +75,10 @@ let HSearchSuggestionContent = class HSearchSuggestionContent extends PhoenixLig
|
|
|
90
75
|
});
|
|
91
76
|
}
|
|
92
77
|
_getMatchedPhrase(phrase) {
|
|
93
|
-
const phraseIncludesSearchPhrase = phrase.toLowerCase().includes(this.
|
|
78
|
+
const phraseIncludesSearchPhrase = phrase.toLowerCase().includes(this.searchPhrase);
|
|
94
79
|
if (!phraseIncludesSearchPhrase)
|
|
95
80
|
return html `${phrase}`;
|
|
96
|
-
const index = phrase.toLowerCase().indexOf(this.
|
|
81
|
+
const index = phrase.toLowerCase().indexOf(this.searchPhrase) + this.searchPhrase.length;
|
|
97
82
|
return html `${phrase.substring(0, index)}<strong>${phrase.substring(index)}</strong>`;
|
|
98
83
|
}
|
|
99
84
|
render() {
|
|
@@ -142,10 +127,6 @@ __decorate([
|
|
|
142
127
|
property({ type: String, attribute: 'search-id' }),
|
|
143
128
|
__metadata("design:type", String)
|
|
144
129
|
], HSearchSuggestionContent.prototype, "searchId", void 0);
|
|
145
|
-
__decorate([
|
|
146
|
-
property({ type: Object, reflect: true }),
|
|
147
|
-
__metadata("design:type", Object)
|
|
148
|
-
], HSearchSuggestionContent.prototype, "initialItemIds", void 0);
|
|
149
130
|
__decorate([
|
|
150
131
|
property({ type: Object }),
|
|
151
132
|
__metadata("design:type", Object)
|
|
@@ -163,13 +144,25 @@ __decorate([
|
|
|
163
144
|
__metadata("design:type", String)
|
|
164
145
|
], HSearchSuggestionContent.prototype, "moduleInstanceId", void 0);
|
|
165
146
|
__decorate([
|
|
166
|
-
property({ type: String }),
|
|
147
|
+
property({ type: String, attribute: 'search-phrase' }),
|
|
167
148
|
__metadata("design:type", String)
|
|
168
|
-
], HSearchSuggestionContent.prototype, "
|
|
149
|
+
], HSearchSuggestionContent.prototype, "searchPhrase", void 0);
|
|
169
150
|
__decorate([
|
|
170
|
-
|
|
151
|
+
property({ type: Object }),
|
|
152
|
+
__metadata("design:type", Array)
|
|
153
|
+
], HSearchSuggestionContent.prototype, "suggestions", void 0);
|
|
154
|
+
__decorate([
|
|
155
|
+
property({ type: Object }),
|
|
156
|
+
__metadata("design:type", Array)
|
|
157
|
+
], HSearchSuggestionContent.prototype, "products", void 0);
|
|
158
|
+
__decorate([
|
|
159
|
+
property({ type: Object }),
|
|
160
|
+
__metadata("design:type", Array)
|
|
161
|
+
], HSearchSuggestionContent.prototype, "categories", void 0);
|
|
162
|
+
__decorate([
|
|
163
|
+
property({ type: String }),
|
|
171
164
|
__metadata("design:type", String)
|
|
172
|
-
], HSearchSuggestionContent.prototype, "
|
|
165
|
+
], HSearchSuggestionContent.prototype, "suggestionAriaLabel", void 0);
|
|
173
166
|
__decorate([
|
|
174
167
|
state(),
|
|
175
168
|
__metadata("design:type", Array)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,qDAAyD;AAChG;AACA;AACA;AACA;AACA
|
|
1
|
+
{"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,qDAAyD;AAChG;AACA;AACA;AACA;AACA,0BAA0B,8DAAkE;AAC5F;AACA,4BAA4B,gEAAoE;AAChG;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
|