@shoper/phoenix_design_system 1.6.13 → 1.6.14

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.
@@ -41,7 +41,31 @@ class InputMaskController {
41
41
  this.enable = () => {
42
42
  if (!this.isEnabled) {
43
43
  const $input = this._getInput();
44
- $input.value = '';
44
+ if (!this._isValidPattern($input.value)) {
45
+ const value = tslib_es6.__classPrivateFieldGet(this, _InputMaskController_mask, "f");
46
+ const valueLength = value.length;
47
+ const pastedValue = $input.value;
48
+ const currentPosition = [0, 0];
49
+ let newValue = '';
50
+ for (let i = 0, j = 0; i < valueLength; i += 1) {
51
+ if (i >= currentPosition[0] && pastedValue[j] && tslib_es6.__classPrivateFieldGet(this, _InputMaskController_skipCharacters, "f").indexOf(value[i]) < 0) {
52
+ if (tslib_es6.__classPrivateFieldGet(this, _InputMaskController_skipCharacters, "f").indexOf(pastedValue[j]) < 0) {
53
+ newValue = newValue + pastedValue[j];
54
+ }
55
+ else {
56
+ i -= 1;
57
+ }
58
+ j += 1;
59
+ }
60
+ else {
61
+ newValue = newValue + value[i];
62
+ }
63
+ }
64
+ if (this._isValidPattern(newValue)) {
65
+ $input.value = newValue;
66
+ this._setCursorPosition($input.value.indexOf(MASK_CHARACTER));
67
+ }
68
+ }
45
69
  this.isEnabled = true;
46
70
  }
47
71
  };
@@ -160,31 +184,60 @@ class InputMaskController {
160
184
  if (ev.target instanceof HTMLInputElement) {
161
185
  const $input = ev.target;
162
186
  const value = $input.value;
163
- const currentPosition = this._getCursorPosition();
164
- const skipBy = this._skipCharactersBy.call(this, value, currentPosition[0], 0);
165
- if (skipBy > 0 && value.length !== currentPosition[0] + skipBy) {
166
- this._setCursorPosition(currentPosition.map((position) => {
167
- return position + skipBy;
168
- }));
169
- }
170
- if (!this._isValidPattern(value)) {
187
+ if (ev instanceof InputEvent) {
171
188
  const currentPosition = this._getCursorPosition();
172
- $input.value = tslib_es6.__classPrivateFieldGet(this, _InputMaskController_keydownValue, "f");
173
- if (tslib_es6.__classPrivateFieldGet(this, _InputMaskController_isLastPosition, "f") || tslib_es6.__classPrivateFieldGet(this, _InputMaskController_isFirstPosition, "f")) {
174
- this._setCursorPosition(currentPosition[0]);
175
- tslib_es6.__classPrivateFieldSet(this, _InputMaskController_isLastPosition, false, "f");
176
- tslib_es6.__classPrivateFieldSet(this, _InputMaskController_isFirstPosition, false, "f");
189
+ const skipBy = this._skipCharactersBy.call(this, value, currentPosition[0], 0);
190
+ if (skipBy > 0 && value.length !== currentPosition[0] + skipBy) {
191
+ this._setCursorPosition(currentPosition.map((position) => {
192
+ return position + skipBy;
193
+ }));
177
194
  }
178
- else {
179
- this._setCursorPosition(currentPosition[0] - 1);
195
+ if (!this._isValidPattern(value)) {
196
+ const currentPosition = this._getCursorPosition();
197
+ $input.value = tslib_es6.__classPrivateFieldGet(this, _InputMaskController_keydownValue, "f");
198
+ if (tslib_es6.__classPrivateFieldGet(this, _InputMaskController_isLastPosition, "f") || tslib_es6.__classPrivateFieldGet(this, _InputMaskController_isFirstPosition, "f")) {
199
+ this._setCursorPosition(currentPosition[0]);
200
+ tslib_es6.__classPrivateFieldSet(this, _InputMaskController_isLastPosition, false, "f");
201
+ tslib_es6.__classPrivateFieldSet(this, _InputMaskController_isFirstPosition, false, "f");
202
+ }
203
+ else {
204
+ this._setCursorPosition(currentPosition[0] - 1);
205
+ }
206
+ return false;
207
+ }
208
+ if (tslib_es6.__classPrivateFieldGet(this, _InputMaskController_mask, "f").length !== value.length) {
209
+ $input.value = value.slice(0, tslib_es6.__classPrivateFieldGet(this, _InputMaskController_mask, "f").length);
210
+ const lastMaskCharacterPos = value.indexOf(MASK_CHARACTER);
211
+ if (lastMaskCharacterPos >= 0) {
212
+ this._setCursorPosition(lastMaskCharacterPos);
213
+ }
180
214
  }
181
- return false;
182
215
  }
183
- if (tslib_es6.__classPrivateFieldGet(this, _InputMaskController_mask, "f").length !== value.length) {
184
- $input.value = value.slice(0, tslib_es6.__classPrivateFieldGet(this, _InputMaskController_mask, "f").length);
185
- const lastMaskCharacterPos = value.indexOf(MASK_CHARACTER);
186
- if (lastMaskCharacterPos >= 0) {
187
- this._setCursorPosition(lastMaskCharacterPos);
216
+ else {
217
+ if (!this._isValidPattern($input.value)) {
218
+ const value = tslib_es6.__classPrivateFieldGet(this, _InputMaskController_mask, "f");
219
+ const valueLength = value.length;
220
+ const pastedValue = $input.value;
221
+ const currentPosition = [0, 0];
222
+ let newValue = '';
223
+ for (let i = 0, j = 0; i < valueLength; i += 1) {
224
+ if (i >= currentPosition[0] && pastedValue[j] && tslib_es6.__classPrivateFieldGet(this, _InputMaskController_skipCharacters, "f").indexOf(value[i]) < 0) {
225
+ if (tslib_es6.__classPrivateFieldGet(this, _InputMaskController_skipCharacters, "f").indexOf(pastedValue[j]) < 0) {
226
+ newValue = newValue + pastedValue[j];
227
+ }
228
+ else {
229
+ i -= 1;
230
+ }
231
+ j += 1;
232
+ }
233
+ else {
234
+ newValue = newValue + value[i];
235
+ }
236
+ }
237
+ if (this._isValidPattern(newValue)) {
238
+ $input.value = newValue;
239
+ this._setCursorPosition($input.value.indexOf(MASK_CHARACTER));
240
+ }
188
241
  }
189
242
  }
190
243
  }
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,4CAAgD;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,4CAAgD;AACxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -0,0 +1,15 @@
1
+ import { PhoenixLightLitElement } from "../../core/phoenix_light_lit_element/phoenix_light_lit_element";
2
+ export declare class HSearch extends PhoenixLightLitElement {
3
+ private _searchContextConsumer;
4
+ private _searchContext$;
5
+ private _searchContextObserver;
6
+ private _shouldShowHistory;
7
+ private _searchResults;
8
+ private _searchHistory;
9
+ connectedCallback(): Promise<void>;
10
+ private _setupListeners;
11
+ private _displaySuggester;
12
+ private _displayHistorySuggestions;
13
+ private _displayResults;
14
+ render(): import("lit-html").TemplateResult<1>;
15
+ }
@@ -0,0 +1,94 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { PhoenixLightLitElement } from '@phoenixRoot/core/phoenix_light_lit_element/phoenix_light_lit_element';
3
+ import { phoenixCustomElement } from '@phoenixRoot/core/decorators/phoenix_custom_element';
4
+ import { ContextConsumerController } from '@phoenixRoot/core/context/context_consumer_controller';
5
+ import '@phoenixRoot/core/classes/behavior_subject/behavior_subject';
6
+ import { Observer } from '@phoenixRoot/core/classes/observer/observer';
7
+ import { state } from 'lit/decorators';
8
+ import { html } from 'lit/development';
9
+ import './search_history';
10
+ import './search_results';
11
+ import { when } from 'lit/directives/when.js';
12
+ let HSearch = class HSearch extends PhoenixLightLitElement {
13
+ constructor() {
14
+ super(...arguments);
15
+ this._shouldShowHistory = false;
16
+ // przykladowe dane - to powinno przyjsc z contextu
17
+ this._searchResults = {
18
+ test: 'test'
19
+ };
20
+ // przykladowe dane to powinno przyjsc z contextu
21
+ this._searchHistory = ['test, dupa, dwa'];
22
+ }
23
+ async connectedCallback() {
24
+ super.connectedCallback();
25
+ try {
26
+ this._searchContextConsumer = new ContextConsumerController(this);
27
+ this._searchContext$ = await this._searchContextConsumer.consumeAsync('searchContext');
28
+ this._searchContextObserver = new Observer((searchData) => {
29
+ this._searchResults = searchData.results;
30
+ this._searchHistory = searchData.history;
31
+ });
32
+ this._searchContext$.subscribe(this._searchContextObserver);
33
+ }
34
+ catch (_a) {
35
+ console.error('Search context is not provided');
36
+ }
37
+ this._setupListeners();
38
+ }
39
+ _setupListeners() {
40
+ this.addEventListener('focusin', (ev) => {
41
+ const isSearchInput = ev.target instanceof HTMLInputElement && ev.target.type === 'search';
42
+ if (isSearchInput) {
43
+ const $searchInput = ev.target;
44
+ this._displaySuggester($searchInput.value);
45
+ }
46
+ });
47
+ this.addEventListener('keyup', (ev) => {
48
+ const isSearchInput = ev.target instanceof HTMLInputElement && ev.target.type === 'search';
49
+ if (isSearchInput) {
50
+ const $searchInput = ev.target;
51
+ this._displaySuggester($searchInput.value);
52
+ }
53
+ });
54
+ }
55
+ _displaySuggester(searchPhrase) {
56
+ if (searchPhrase === '') {
57
+ this._displayHistorySuggestions();
58
+ }
59
+ else {
60
+ this._displayResults();
61
+ }
62
+ }
63
+ _displayHistorySuggestions() {
64
+ // oczywiscie ta logika moze powinna byc bardziej skomplikowana ;)
65
+ this._shouldShowHistory = true;
66
+ }
67
+ _displayResults() {
68
+ // oczywiscie ta logika moze powinna byc bardziej skomplikowana ;)
69
+ this._shouldShowHistory = false;
70
+ }
71
+ render() {
72
+ // tutaj tez oczywiscie ta logika jets bledna i bardzo uproszczona - chodzi o sam zamysl i poukladanie teog.
73
+ return html `
74
+ ${when(this._shouldShowHistory, () => html `<h-search-history .history="${this._searchHistory}"></h-search-history>`, () => html `<h-search-results .results="${this._searchResults}"></h-search-results>`)}
75
+ `;
76
+ }
77
+ };
78
+ __decorate([
79
+ state(),
80
+ __metadata("design:type", Boolean)
81
+ ], HSearch.prototype, "_shouldShowHistory", void 0);
82
+ __decorate([
83
+ state(),
84
+ __metadata("design:type", Object)
85
+ ], HSearch.prototype, "_searchResults", void 0);
86
+ __decorate([
87
+ state(),
88
+ __metadata("design:type", Array)
89
+ ], HSearch.prototype, "_searchHistory", void 0);
90
+ HSearch = __decorate([
91
+ phoenixCustomElement('h-search')
92
+ ], HSearch);
93
+ export { HSearch };
94
+ //# sourceMappingURL=search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.js","sourceRoot":"","sources":["../../../../../../../src/components/search/search.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uEAAuE,CAAC;AAC/G,OAAO,EAAE,oBAAoB,EAAE,MAAM,qDAAqD,CAAC;AAC3F,OAAO,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AAClG,OAAgC,6DAA6D,CAAC;AAC9F,OAAO,EAAE,QAAQ,EAAE,MAAM,6CAA6C,CAAC;AACvE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAA+B,kBAAkB,CAAC;AAClD,OAA+B,kBAAkB,CAAC;AACl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+1,5 @@
1
+ import { PhoenixLightLitElement } from "../../core/phoenix_light_lit_element/phoenix_light_lit_element";
2
+ export declare class HSearchHistory extends PhoenixLightLitElement {
3
+ history: string[];
4
+ render(): import("lit-html").TemplateResult<1>;
5
+ }
@@ -0,0 +1,23 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { phoenixCustomElement } from '@phoenixRoot/core/decorators/phoenix_custom_element';
3
+ import { PhoenixLightLitElement } from '@phoenixRoot/core/phoenix_light_lit_element/phoenix_light_lit_element';
4
+ import { property } from 'lit/decorators';
5
+ import { html } from 'lit/development';
6
+ let HSearchHistory = class HSearchHistory extends PhoenixLightLitElement {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.history = [];
10
+ }
11
+ render() {
12
+ return html ` ${this.history} `;
13
+ }
14
+ };
15
+ __decorate([
16
+ property({ type: Array, attribute: 'result-data' }),
17
+ __metadata("design:type", Array)
18
+ ], HSearchHistory.prototype, "history", void 0);
19
+ HSearchHistory = __decorate([
20
+ phoenixCustomElement('h-search-history')
21
+ ], HSearchHistory);
22
+ export { HSearchHistory };
23
+ //# sourceMappingURL=search_history.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search_history.js","sourceRoot":"","sources":["../../../../../../../src/components/search/search_history.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qDAAqD,CAAC;AAC3F,OAAO,EAAE,sBAAsB,EAAE,MAAM,uEAAuE,CAAC;AAC/G,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAGvC,IAAa,cAAc,GAA3B,MAAa,cAAe,SAAQ,sBAAsB;IAA1D;;QAEI,YAAO,GAAa,EAAE,CAAC;IAK3B,CAAC;IAHU,MAAM;QACT,OAAO,IAAI,CAAA,IAAI,IAAI,CAAC,OAAO,GAAG,CAAC;IACnC,CAAC;CACJ,CAAA;AALG;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;;+CAC7B;AAFd,cAAc;IAD1B,oBAAoB,CAAC,kBAAkB,CAAC;GAC5B,cAAc,CAO1B;SAPY,cAAc"}
@@ -0,0 +1,7 @@
1
+ import { PhoenixLightLitElement } from "../../core/phoenix_light_lit_element/phoenix_light_lit_element";
2
+ export declare class HSearch extends PhoenixLightLitElement {
3
+ private _searchContextConsumer;
4
+ private _searchContext$;
5
+ private _searchContextObserver;
6
+ connectedCallback(): Promise<void>;
7
+ }
@@ -0,0 +1,39 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { PhoenixLightLitElement } from '@phoenixRoot/core/phoenix_light_lit_element/phoenix_light_lit_element';
3
+ import { phoenixCustomElement } from '@phoenixRoot/core/decorators/phoenix_custom_element';
4
+ import { ContextConsumerController } from '@phoenixRoot/core/context/context_consumer_controller';
5
+ import '@phoenixRoot/core/classes/behavior_subject/behavior_subject';
6
+ import { Observer } from '@phoenixRoot/core/classes/observer/observer';
7
+ import { state } from 'lit/decorators';
8
+ let HSearch = class HSearch extends PhoenixLightLitElement {
9
+ async connectedCallback() {
10
+ super.connectedCallback();
11
+ try {
12
+ this._searchContextConsumer = new ContextConsumerController(this);
13
+ this._searchContext$ = await this._searchContextConsumer.consumeAsync('searchContext');
14
+ this._searchContextObserver = new Observer((searchData) => {
15
+ if (searchData.searchPhrase === '') {
16
+ const $input = this.querySelector('input[type="search"]');
17
+ if ($input) {
18
+ $input.value = '';
19
+ }
20
+ }
21
+ });
22
+ this._searchContext$.subscribe(this._searchContextObserver);
23
+ }
24
+ catch (_a) {
25
+ console.error('Search context is not provided');
26
+ }
27
+ }
28
+ };
29
+ __decorate([
30
+ state(),
31
+ __metadata("design:type", Function),
32
+ __metadata("design:paramtypes", []),
33
+ __metadata("design:returntype", Promise)
34
+ ], HSearch.prototype, "connectedCallback", null);
35
+ HSearch = __decorate([
36
+ phoenixCustomElement('h-search-input')
37
+ ], HSearch);
38
+ export { HSearch };
39
+ //# sourceMappingURL=search_input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search_input.js","sourceRoot":"","sources":["../../../../../../../src/components/search/search_input.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uEAAuE,CAAC;AAC/G,OAAO,EAAE,oBAAoB,EAAE,MAAM,qDAAqD,CAAC;AAC3F,OAAO,EAAE,yBAAyB,EAAE,MAAM,uDAAuD,CAAC;AAClG,OAAgC,6DAA6D,CAAC;AAC9F,OAAO,EAAE,QAAQ,EAAE,MAAM,6CAA6C,CAAC;AACvE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AASvC,IAAa,OAAO,GAApB,MAAa,OAAQ,SAAQ,sBAAsB;IAMxC,KAAK,CAAC,iBAAiB;QAC1B,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAE1B,IAAI;YACA,IAAI,CAAC,sBAAsB,GAAG,IAAI,yBAAyB,CAAC,IAAI,CAAC,CAAC;YAClE,IAAI,CAAC,eAAe,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;YAEvF,IAAI,CAAC,sBAAsB,GAAG,IAAI,QAAQ,CAAC,CAAC,UAAuB,EAAE,EAAE;gBACnE,IAAI,UAAU,CAAC,YAAY,KAAK,EAAE,EAAE;oBAChC,MAAM,MAAM,GAAG,IAAI,CAAC,aAAa,CAAmB,sBAAsB,CAAC,CAAC;oBAC5E,IAAI,MAAM,EAAE;wBACR,MAAM,CAAC,KAAK,GAAG,EAAE,CAAC;qBACrB;iBACJ;YACL,CAAC,CAAC,CAAC;YAEH,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;SAC/D;QAAC,WAAM;YACJ,OAAO,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;SACnD;IACL,CAAC;CACJ,CAAA;AArBG;IADC,KAAK,EAAE;;;;gDAqBP;AA1BQ,OAAO;IADnB,oBAAoB,CAAC,gBAAgB,CAAC;GAC1B,OAAO,CA2BnB;SA3BY,OAAO"}
@@ -0,0 +1,5 @@
1
+ import { PhoenixLightLitElement } from "../../core/phoenix_light_lit_element/phoenix_light_lit_element";
2
+ export declare class HSearchResults extends PhoenixLightLitElement {
3
+ results: Record<any, any>;
4
+ render(): import("lit-html").TemplateResult<1>;
5
+ }
@@ -0,0 +1,24 @@
1
+ import { __decorate, __metadata } from "tslib";
2
+ import { phoenixCustomElement } from '@phoenixRoot/core/decorators/phoenix_custom_element';
3
+ import { PhoenixLightLitElement } from '@phoenixRoot/core/phoenix_light_lit_element/phoenix_light_lit_element';
4
+ import { property } from 'lit/decorators';
5
+ import { html } from 'lit/development';
6
+ import { repeat } from 'lit/directives/repeat.js';
7
+ let HSearchResults = class HSearchResults extends PhoenixLightLitElement {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.results = {};
11
+ }
12
+ render() {
13
+ return html ` ${repeat(Object.keys(this.results), (key) => key, (key) => html ` ${this.results[key]} `)}`;
14
+ }
15
+ };
16
+ __decorate([
17
+ property({ type: Object, attribute: 'result-data' }),
18
+ __metadata("design:type", Object)
19
+ ], HSearchResults.prototype, "results", void 0);
20
+ HSearchResults = __decorate([
21
+ phoenixCustomElement('h-search-results')
22
+ ], HSearchResults);
23
+ export { HSearchResults };
24
+ //# sourceMappingURL=search_results.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search_results.js","sourceRoot":"","sources":["../../../../../../../src/components/search/search_results.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qDAAqD,CAAC;AAC3F,OAAO,EAAE,sBAAsB,EAAE,MAAM,uEAAuE,CAAC;AAC/G,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAGlD,IAAa,cAAc,GAA3B,MAAa,cAAe,SAAQ,sBAAsB;IAA1D;;QAEI,YAAO,GAAqB,EAAE,CAAC;IASnC,CAAC;IAPU,MAAM;QACT,OAAO,IAAI,CAAA,IAAI,MAAM,CACjB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EACzB,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EACZ,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAA,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CACxC,EAAE,CAAC;IACR,CAAC;CACJ,CAAA;AATG;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC;;+CACtB;AAFtB,cAAc;IAD1B,oBAAoB,CAAC,kBAAkB,CAAC;GAC5B,cAAc,CAW1B;SAXY,cAAc"}
@@ -37,7 +37,31 @@ class InputMaskController {
37
37
  this.enable = () => {
38
38
  if (!this.isEnabled) {
39
39
  const $input = this._getInput();
40
- $input.value = '';
40
+ if (!this._isValidPattern($input.value)) {
41
+ const value = __classPrivateFieldGet(this, _InputMaskController_mask, "f");
42
+ const valueLength = value.length;
43
+ const pastedValue = $input.value;
44
+ const currentPosition = [0, 0];
45
+ let newValue = '';
46
+ for (let i = 0, j = 0; i < valueLength; i += 1) {
47
+ if (i >= currentPosition[0] && pastedValue[j] && __classPrivateFieldGet(this, _InputMaskController_skipCharacters, "f").indexOf(value[i]) < 0) {
48
+ if (__classPrivateFieldGet(this, _InputMaskController_skipCharacters, "f").indexOf(pastedValue[j]) < 0) {
49
+ newValue = newValue + pastedValue[j];
50
+ }
51
+ else {
52
+ i -= 1;
53
+ }
54
+ j += 1;
55
+ }
56
+ else {
57
+ newValue = newValue + value[i];
58
+ }
59
+ }
60
+ if (this._isValidPattern(newValue)) {
61
+ $input.value = newValue;
62
+ this._setCursorPosition($input.value.indexOf(MASK_CHARACTER));
63
+ }
64
+ }
41
65
  this.isEnabled = true;
42
66
  }
43
67
  };
@@ -156,31 +180,60 @@ class InputMaskController {
156
180
  if (ev.target instanceof HTMLInputElement) {
157
181
  const $input = ev.target;
158
182
  const value = $input.value;
159
- const currentPosition = this._getCursorPosition();
160
- const skipBy = this._skipCharactersBy.call(this, value, currentPosition[0], 0);
161
- if (skipBy > 0 && value.length !== currentPosition[0] + skipBy) {
162
- this._setCursorPosition(currentPosition.map((position) => {
163
- return position + skipBy;
164
- }));
165
- }
166
- if (!this._isValidPattern(value)) {
183
+ if (ev instanceof InputEvent) {
167
184
  const currentPosition = this._getCursorPosition();
168
- $input.value = __classPrivateFieldGet(this, _InputMaskController_keydownValue, "f");
169
- if (__classPrivateFieldGet(this, _InputMaskController_isLastPosition, "f") || __classPrivateFieldGet(this, _InputMaskController_isFirstPosition, "f")) {
170
- this._setCursorPosition(currentPosition[0]);
171
- __classPrivateFieldSet(this, _InputMaskController_isLastPosition, false, "f");
172
- __classPrivateFieldSet(this, _InputMaskController_isFirstPosition, false, "f");
185
+ const skipBy = this._skipCharactersBy.call(this, value, currentPosition[0], 0);
186
+ if (skipBy > 0 && value.length !== currentPosition[0] + skipBy) {
187
+ this._setCursorPosition(currentPosition.map((position) => {
188
+ return position + skipBy;
189
+ }));
173
190
  }
174
- else {
175
- this._setCursorPosition(currentPosition[0] - 1);
191
+ if (!this._isValidPattern(value)) {
192
+ const currentPosition = this._getCursorPosition();
193
+ $input.value = __classPrivateFieldGet(this, _InputMaskController_keydownValue, "f");
194
+ if (__classPrivateFieldGet(this, _InputMaskController_isLastPosition, "f") || __classPrivateFieldGet(this, _InputMaskController_isFirstPosition, "f")) {
195
+ this._setCursorPosition(currentPosition[0]);
196
+ __classPrivateFieldSet(this, _InputMaskController_isLastPosition, false, "f");
197
+ __classPrivateFieldSet(this, _InputMaskController_isFirstPosition, false, "f");
198
+ }
199
+ else {
200
+ this._setCursorPosition(currentPosition[0] - 1);
201
+ }
202
+ return false;
203
+ }
204
+ if (__classPrivateFieldGet(this, _InputMaskController_mask, "f").length !== value.length) {
205
+ $input.value = value.slice(0, __classPrivateFieldGet(this, _InputMaskController_mask, "f").length);
206
+ const lastMaskCharacterPos = value.indexOf(MASK_CHARACTER);
207
+ if (lastMaskCharacterPos >= 0) {
208
+ this._setCursorPosition(lastMaskCharacterPos);
209
+ }
176
210
  }
177
- return false;
178
211
  }
179
- if (__classPrivateFieldGet(this, _InputMaskController_mask, "f").length !== value.length) {
180
- $input.value = value.slice(0, __classPrivateFieldGet(this, _InputMaskController_mask, "f").length);
181
- const lastMaskCharacterPos = value.indexOf(MASK_CHARACTER);
182
- if (lastMaskCharacterPos >= 0) {
183
- this._setCursorPosition(lastMaskCharacterPos);
212
+ else {
213
+ if (!this._isValidPattern($input.value)) {
214
+ const value = __classPrivateFieldGet(this, _InputMaskController_mask, "f");
215
+ const valueLength = value.length;
216
+ const pastedValue = $input.value;
217
+ const currentPosition = [0, 0];
218
+ let newValue = '';
219
+ for (let i = 0, j = 0; i < valueLength; i += 1) {
220
+ if (i >= currentPosition[0] && pastedValue[j] && __classPrivateFieldGet(this, _InputMaskController_skipCharacters, "f").indexOf(value[i]) < 0) {
221
+ if (__classPrivateFieldGet(this, _InputMaskController_skipCharacters, "f").indexOf(pastedValue[j]) < 0) {
222
+ newValue = newValue + pastedValue[j];
223
+ }
224
+ else {
225
+ i -= 1;
226
+ }
227
+ j += 1;
228
+ }
229
+ else {
230
+ newValue = newValue + value[i];
231
+ }
232
+ }
233
+ if (this._isValidPattern(newValue)) {
234
+ $input.value = newValue;
235
+ this._setCursorPosition($input.value.indexOf(MASK_CHARACTER));
236
+ }
184
237
  }
185
238
  }
186
239
  }
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,+DAA+D,4CAAgD;AAC/G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,+DAA+D,4CAAgD;AAC/G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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.6.13",
5
+ "version": "1.6.14",
6
6
  "description": "phoenix design system",
7
7
  "author": "zefirek",
8
8
  "license": "MIT",