@shoper/phoenix_design_system 1.17.16-6 → 1.17.16-7

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.
@@ -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
- try {
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(results) {
28
+ _setupSuggestionData() {
44
29
  let suggestionsData = [];
45
- if (results.suggestions.length) {
46
- results.suggestions.forEach((suggestion, index) => {
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 = results.products.length;
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: results.products[0].category.breadcrumbs,
40
+ categoryName: this.products[0].category.breadcrumbs,
56
41
  type: search_constants.SUGGESTIONS_TYPE.suggestionInCategory,
57
- url: `/${lang}/c/${results.products[0].category.name}/${results.products[0].category.categoryId}/1/${this.view}/1/searchquery/${suggestion}`
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 (results.categories.length) {
45
+ if (this.categories.length) {
61
46
  suggestionsData = [
62
47
  ...suggestionsData,
63
- ...results.categories.map((category) => ({
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 (results.categories.length) {
57
+ else if (this.categories.length) {
73
58
  suggestionsData = [
74
- ...results.categories.map((category) => ({
59
+ ...this.categories.map((category) => ({
75
60
  categoryName: category.name,
76
61
  url: category.url,
77
62
  type: search_constants.SUGGESTIONS_TYPE.category
@@ -80,6 +65,11 @@ exports.HSearchSuggestionContent = class HSearchSuggestionContent extends phoeni
80
65
  }
81
66
  this._suggestionsData = suggestionsData;
82
67
  }
68
+ _handleSuggestionWithKeyboard(ev, suggestion, suggestionType) {
69
+ if (ev.key !== 'Enter' && ev.key !== ' ')
70
+ return;
71
+ this._handleSuggestion(suggestion, suggestionType);
72
+ }
83
73
  _handleSuggestion(suggestion, suggestionType) {
84
74
  if (suggestionType !== search_constants.SUGGESTIONS_TYPE.suggestion)
85
75
  return;
@@ -94,10 +84,10 @@ exports.HSearchSuggestionContent = class HSearchSuggestionContent extends phoeni
94
84
  });
95
85
  }
96
86
  _getMatchedPhrase(phrase) {
97
- const phraseIncludesSearchPhrase = phrase.toLowerCase().includes(this._searchPhrase);
87
+ const phraseIncludesSearchPhrase = phrase.toLowerCase().includes(this.searchPhrase);
98
88
  if (!phraseIncludesSearchPhrase)
99
89
  return lit.html `${phrase}`;
100
- const index = phrase.toLowerCase().indexOf(this._searchPhrase) + this._searchPhrase.length;
90
+ const index = phrase.toLowerCase().indexOf(this.searchPhrase) + this.searchPhrase.length;
101
91
  return lit.html `${phrase.substring(0, index)}<strong>${phrase.substring(index)}</strong>`;
102
92
  }
103
93
  render() {
@@ -107,6 +97,7 @@ exports.HSearchSuggestionContent = class HSearchSuggestionContent extends phoeni
107
97
  <ul>
108
98
  ${repeat.repeat(this._suggestionsData, (suggestion, index) => lit.html `<li
109
99
  @click=${() => this._handleSuggestion(suggestion.suggestionName, suggestion.type)}
100
+ @keydown=${(ev) => this._handleSuggestionWithKeyboard(ev, suggestion.suggestionName, suggestion.type)}
110
101
  class="${search_constants.SEARCH_CLASS_NAMES.item} ${search_constants.SEARCH_CLASS_NAMES.itemHoverable} ${String(index) === this.activeItemId
111
102
  ? search_constants.SEARCH_CLASS_NAMES.itemActive
112
103
  : ''}"
@@ -146,10 +137,6 @@ tslib_es6.__decorate([
146
137
  decorators.property({ type: String, attribute: 'search-id' }),
147
138
  tslib_es6.__metadata("design:type", String)
148
139
  ], 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
140
  tslib_es6.__decorate([
154
141
  decorators.property({ type: Object }),
155
142
  tslib_es6.__metadata("design:type", Object)
@@ -167,13 +154,25 @@ tslib_es6.__decorate([
167
154
  tslib_es6.__metadata("design:type", String)
168
155
  ], exports.HSearchSuggestionContent.prototype, "moduleInstanceId", void 0);
169
156
  tslib_es6.__decorate([
170
- decorators.property({ type: String }),
157
+ decorators.property({ type: String, attribute: 'search-phrase' }),
171
158
  tslib_es6.__metadata("design:type", String)
172
- ], exports.HSearchSuggestionContent.prototype, "suggestionAriaLabel", void 0);
159
+ ], exports.HSearchSuggestionContent.prototype, "searchPhrase", void 0);
173
160
  tslib_es6.__decorate([
174
- decorators.state(),
161
+ decorators.property({ type: Object }),
162
+ tslib_es6.__metadata("design:type", Array)
163
+ ], exports.HSearchSuggestionContent.prototype, "suggestions", void 0);
164
+ tslib_es6.__decorate([
165
+ decorators.property({ type: Object }),
166
+ tslib_es6.__metadata("design:type", Array)
167
+ ], exports.HSearchSuggestionContent.prototype, "products", void 0);
168
+ tslib_es6.__decorate([
169
+ decorators.property({ type: Object, attribute: false }),
170
+ tslib_es6.__metadata("design:type", Array)
171
+ ], exports.HSearchSuggestionContent.prototype, "categories", void 0);
172
+ tslib_es6.__decorate([
173
+ decorators.property({ type: String }),
175
174
  tslib_es6.__metadata("design:type", String)
176
- ], exports.HSearchSuggestionContent.prototype, "_searchPhrase", void 0);
175
+ ], exports.HSearchSuggestionContent.prototype, "suggestionAriaLabel", void 0);
177
176
  tslib_es6.__decorate([
178
177
  decorators.state(),
179
178
  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;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;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,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;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,21 +1,22 @@
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;
19
+ private _handleSuggestionWithKeyboard;
19
20
  private _handleSuggestion;
20
21
  private _dispatchEventWithSearchPhrase;
21
22
  private _getMatchedPhrase;
@@ -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
- try {
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(results) {
24
+ _setupSuggestionData() {
40
25
  let suggestionsData = [];
41
- if (results.suggestions.length) {
42
- results.suggestions.forEach((suggestion, index) => {
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 = results.products.length;
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: results.products[0].category.breadcrumbs,
36
+ categoryName: this.products[0].category.breadcrumbs,
52
37
  type: SUGGESTIONS_TYPE.suggestionInCategory,
53
- url: `/${lang}/c/${results.products[0].category.name}/${results.products[0].category.categoryId}/1/${this.view}/1/searchquery/${suggestion}`
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 (results.categories.length) {
41
+ if (this.categories.length) {
57
42
  suggestionsData = [
58
43
  ...suggestionsData,
59
- ...results.categories.map((category) => ({
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 (results.categories.length) {
53
+ else if (this.categories.length) {
69
54
  suggestionsData = [
70
- ...results.categories.map((category) => ({
55
+ ...this.categories.map((category) => ({
71
56
  categoryName: category.name,
72
57
  url: category.url,
73
58
  type: SUGGESTIONS_TYPE.category
@@ -76,6 +61,11 @@ let HSearchSuggestionContent = class HSearchSuggestionContent extends PhoenixLig
76
61
  }
77
62
  this._suggestionsData = suggestionsData;
78
63
  }
64
+ _handleSuggestionWithKeyboard(ev, suggestion, suggestionType) {
65
+ if (ev.key !== 'Enter' && ev.key !== ' ')
66
+ return;
67
+ this._handleSuggestion(suggestion, suggestionType);
68
+ }
79
69
  _handleSuggestion(suggestion, suggestionType) {
80
70
  if (suggestionType !== SUGGESTIONS_TYPE.suggestion)
81
71
  return;
@@ -90,10 +80,10 @@ let HSearchSuggestionContent = class HSearchSuggestionContent extends PhoenixLig
90
80
  });
91
81
  }
92
82
  _getMatchedPhrase(phrase) {
93
- const phraseIncludesSearchPhrase = phrase.toLowerCase().includes(this._searchPhrase);
83
+ const phraseIncludesSearchPhrase = phrase.toLowerCase().includes(this.searchPhrase);
94
84
  if (!phraseIncludesSearchPhrase)
95
85
  return html `${phrase}`;
96
- const index = phrase.toLowerCase().indexOf(this._searchPhrase) + this._searchPhrase.length;
86
+ const index = phrase.toLowerCase().indexOf(this.searchPhrase) + this.searchPhrase.length;
97
87
  return html `${phrase.substring(0, index)}<strong>${phrase.substring(index)}</strong>`;
98
88
  }
99
89
  render() {
@@ -103,6 +93,7 @@ let HSearchSuggestionContent = class HSearchSuggestionContent extends PhoenixLig
103
93
  <ul>
104
94
  ${c(this._suggestionsData, (suggestion, index) => html `<li
105
95
  @click=${() => this._handleSuggestion(suggestion.suggestionName, suggestion.type)}
96
+ @keydown=${(ev) => this._handleSuggestionWithKeyboard(ev, suggestion.suggestionName, suggestion.type)}
106
97
  class="${SEARCH_CLASS_NAMES.item} ${SEARCH_CLASS_NAMES.itemHoverable} ${String(index) === this.activeItemId
107
98
  ? SEARCH_CLASS_NAMES.itemActive
108
99
  : ''}"
@@ -142,10 +133,6 @@ __decorate([
142
133
  property({ type: String, attribute: 'search-id' }),
143
134
  __metadata("design:type", String)
144
135
  ], 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
136
  __decorate([
150
137
  property({ type: Object }),
151
138
  __metadata("design:type", Object)
@@ -163,13 +150,25 @@ __decorate([
163
150
  __metadata("design:type", String)
164
151
  ], HSearchSuggestionContent.prototype, "moduleInstanceId", void 0);
165
152
  __decorate([
166
- property({ type: String }),
153
+ property({ type: String, attribute: 'search-phrase' }),
167
154
  __metadata("design:type", String)
168
- ], HSearchSuggestionContent.prototype, "suggestionAriaLabel", void 0);
155
+ ], HSearchSuggestionContent.prototype, "searchPhrase", void 0);
169
156
  __decorate([
170
- state(),
157
+ property({ type: Object }),
158
+ __metadata("design:type", Array)
159
+ ], HSearchSuggestionContent.prototype, "suggestions", void 0);
160
+ __decorate([
161
+ property({ type: Object }),
162
+ __metadata("design:type", Array)
163
+ ], HSearchSuggestionContent.prototype, "products", void 0);
164
+ __decorate([
165
+ property({ type: Object, attribute: false }),
166
+ __metadata("design:type", Array)
167
+ ], HSearchSuggestionContent.prototype, "categories", void 0);
168
+ __decorate([
169
+ property({ type: String }),
171
170
  __metadata("design:type", String)
172
- ], HSearchSuggestionContent.prototype, "_searchPhrase", void 0);
171
+ ], HSearchSuggestionContent.prototype, "suggestionAriaLabel", void 0);
173
172
  __decorate([
174
173
  state(),
175
174
  __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;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;AACA;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;AACA;AACA;AACA;AACA;AACA;AACA;"}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@shoper/phoenix_design_system",
3
3
  "packageManager": "yarn@3.2.0",
4
4
  "sideEffects": false,
5
- "version": "1.17.16-6",
5
+ "version": "1.17.16-7",
6
6
  "description": "phoenix design system",
7
7
  "author": "zefirek",
8
8
  "license": "MIT",