@shoper/phoenix_design_system 1.5.4 → 1.6.0

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.
Files changed (25) hide show
  1. package/build/cjs/packages/phoenix/src/components/form/input/input_control.js +35 -0
  2. package/build/cjs/packages/phoenix/src/components/form/input/input_control.js.map +1 -1
  3. package/build/cjs/packages/phoenix/src/components/form/select/select.js +6 -6
  4. package/build/cjs/packages/phoenix/src/controllers/input_mask_controller/input_mask_controller.js +365 -0
  5. package/build/cjs/packages/phoenix/src/controllers/input_mask_controller/input_mask_controller.js.map +1 -0
  6. package/build/esm/packages/phoenix/src/components/form/input/input_control.d.ts +9 -1
  7. package/build/esm/packages/phoenix/src/components/form/input/input_control.js +35 -0
  8. package/build/esm/packages/phoenix/src/components/form/input/input_control.js.map +1 -1
  9. package/build/esm/packages/phoenix/src/components/form/select/select.js +6 -6
  10. package/build/esm/packages/phoenix/src/components/search/search.d.ts +15 -0
  11. package/build/esm/packages/phoenix/src/components/search/search.js +94 -0
  12. package/build/esm/packages/phoenix/src/components/search/search.js.map +1 -0
  13. package/build/esm/packages/phoenix/src/components/search/search_history.d.ts +5 -0
  14. package/build/esm/packages/phoenix/src/components/search/search_history.js +23 -0
  15. package/build/esm/packages/phoenix/src/components/search/search_history.js.map +1 -0
  16. package/build/esm/packages/phoenix/src/components/search/search_input.d.ts +7 -0
  17. package/build/esm/packages/phoenix/src/components/search/search_input.js +39 -0
  18. package/build/esm/packages/phoenix/src/components/search/search_input.js.map +1 -0
  19. package/build/esm/packages/phoenix/src/components/search/search_results.d.ts +5 -0
  20. package/build/esm/packages/phoenix/src/components/search/search_results.js +24 -0
  21. package/build/esm/packages/phoenix/src/components/search/search_results.js.map +1 -0
  22. package/build/esm/packages/phoenix/src/controllers/input_mask_controller/input_mask_controller.d.ts +25 -0
  23. package/build/esm/packages/phoenix/src/controllers/input_mask_controller/input_mask_controller.js +361 -0
  24. package/build/esm/packages/phoenix/src/controllers/input_mask_controller/input_mask_controller.js.map +1 -0
  25. package/package.json +1 -1
@@ -10,11 +10,14 @@ var phoenix_custom_element = require('../../../core/decorators/phoenix_custom_el
10
10
  var input_constants = require('./input_constants.js');
11
11
  var ifDefined_js = require('lit-html/directives/if-defined.js');
12
12
  var control_props_sync_consumer_controller = require('../controllers/props_synchronizing/control_props_sync_consumer_controller.js');
13
+ var ref = require('lit/directives/ref');
14
+ var input_mask_controller = require('../../../controllers/input_mask_controller/input_mask_controller.js');
13
15
 
14
16
  exports.HInputControl = class HInputControl extends phoenix_light_lit_element.PhoenixLightLitElement {
15
17
  constructor() {
16
18
  super();
17
19
  this.type = input_constants.INPUT_CONTROL_TYPES.text;
20
+ this._inputRef = ref.createRef();
18
21
  this._handleChangeEvent = (event) => {
19
22
  this.dispatchEvent(new CustomEvent(input_constants.INPUT_CONTROL_EVENTS.change, {
20
23
  detail: event,
@@ -33,12 +36,32 @@ exports.HInputControl = class HInputControl extends phoenix_light_lit_element.Ph
33
36
  }
34
37
  connectedCallback() {
35
38
  super.connectedCallback();
39
+ if (this.mask) {
40
+ this._inputMaskController = new input_mask_controller.InputMaskController({
41
+ host: this,
42
+ input: this._inputRef,
43
+ mask: this.mask,
44
+ pattern: this.pattern,
45
+ validPattern: this.validPattern
46
+ });
47
+ }
36
48
  this.classList.add(input_constants.INPUT_CONTROL_CSS_CLASSES.inputControl);
37
49
  }
50
+ updated(_changedProperties) {
51
+ super.updated(_changedProperties);
52
+ this.mask ? this.enableMask() : this.disableMask();
53
+ }
54
+ enableMask() {
55
+ this._inputMaskController.enable();
56
+ }
57
+ disableMask() {
58
+ this._inputMaskController.disable();
59
+ }
38
60
  render() {
39
61
  super.render();
40
62
  return lit.html `
41
63
  <input
64
+ ${ref.ref(this._inputRef)}
42
65
  id="${ifDefined_js.ifDefined(this.controlId)}"
43
66
  name="${ifDefined_js.ifDefined(this.controlName)}"
44
67
  type="${ifDefined_js.ifDefined(this.type)}"
@@ -90,6 +113,18 @@ tslib_es6.__decorate([
90
113
  decorators.property({ type: String }),
91
114
  tslib_es6.__metadata("design:type", String)
92
115
  ], exports.HInputControl.prototype, "placeholder", void 0);
116
+ tslib_es6.__decorate([
117
+ decorators.property({ type: String }),
118
+ tslib_es6.__metadata("design:type", String)
119
+ ], exports.HInputControl.prototype, "mask", void 0);
120
+ tslib_es6.__decorate([
121
+ decorators.property({ type: String }),
122
+ tslib_es6.__metadata("design:type", String)
123
+ ], exports.HInputControl.prototype, "pattern", void 0);
124
+ tslib_es6.__decorate([
125
+ decorators.property({ type: String, attribute: 'valid-pattern' }),
126
+ tslib_es6.__metadata("design:type", String)
127
+ ], exports.HInputControl.prototype, "validPattern", void 0);
93
128
  exports.HInputControl = tslib_es6.__decorate([
94
129
  phoenix_custom_element.phoenixCustomElement('h-input-control'),
95
130
  tslib_es6.__metadata("design:paramtypes", [])
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA,wBAAwB,+CAAmD;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,+CAAmD;AAC3E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -101,11 +101,7 @@ exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLi
101
101
  this._handleResize = debounce['default'](() => {
102
102
  this._closeSelect();
103
103
  }, select_constants.SELECT_RESIZE_DEBOUNCE_TIME);
104
- const $options = this.hasSlot('content')
105
- ? this.getSlot('content')
106
- .map((litElement) => litElement.values[0])
107
- .filter((element) => element instanceof select_option.HOption)
108
- : Array.from(this.querySelectorAll(select_components_constatns.SELECT_RELATED_COMPONENTS_NAMES.option));
104
+ const $options = Array.from(this.querySelectorAll(select_components_constatns.SELECT_RELATED_COMPONENTS_NAMES.option));
109
105
  $options.forEach(($option) => $option.setAttribute('slot', select_constants.SELECT_SLOT_NAMES.content));
110
106
  this.$placeholder = (_a = this.querySelector(`[slot="${select_components_constatns.SELECT_INPUT_PLACEHOLDER_SLOT_NAME}"]`)) !== null && _a !== void 0 ? _a : 'Select';
111
107
  if (this.multiple)
@@ -167,7 +163,11 @@ exports.HSelect = class HSelect extends phoenix_light_lit_element.PhoenixLightLi
167
163
  this._selectController = this.multiple ? new multi_select_controller.MultiSelectController({ host: this }) : new select_controller.SelectController({ host: this });
168
164
  this._selectContext.provide(select_constants.SELECT_CONTEXTS.selectedOptions$, this._selectController.selectedOptions$);
169
165
  this._selectContext.provide(select_constants.SELECT_CONTEXTS.isMultiselect, this.multiple);
170
- const $options = Array.from(this.querySelectorAll(select_components_constatns.SELECT_RELATED_COMPONENTS_NAMES.option));
166
+ const $options = this.hasSlot(select_constants.SELECT_SLOT_NAMES.content)
167
+ ? this.getSlot(select_constants.SELECT_SLOT_NAMES.content)
168
+ .map((litElement) => litElement.values[0])
169
+ .filter((element) => element instanceof select_option.HOption)
170
+ : Array.from(this.querySelectorAll(select_components_constatns.SELECT_RELATED_COMPONENTS_NAMES.option));
171
171
  this._optionsObserver = new observer.Observer((selectedOptions) => this._updateOptionsView(selectedOptions));
172
172
  this._selectController.options$.subscribe(this._optionsObserver);
173
173
  this._$options = $options.reduce((acc, $option) => {
@@ -0,0 +1,365 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib_es6 = require('../../../../../external/tslib/tslib.es6.js');
6
+ require('lit');
7
+ require('lit/development');
8
+ require('lit/directives/ref');
9
+
10
+ var _InputMaskController_host, _InputMaskController_input, _InputMaskController_mask, _InputMaskController_pattern, _InputMaskController_validPattern, _InputMaskController_skipCharacters, _InputMaskController_skipKeys, _InputMaskController_patternRegexp, _InputMaskController_patternCheck, _InputMaskController_keydownValue, _InputMaskController_isFirstPosition, _InputMaskController_isLastPosition, _InputMaskController_isEnabled;
11
+ const MASK_CHARACTER = '_';
12
+ class InputMaskController {
13
+ constructor({ host, input, mask, pattern, validPattern }) {
14
+ _InputMaskController_host.set(this, void 0);
15
+ _InputMaskController_input.set(this, void 0);
16
+ _InputMaskController_mask.set(this, void 0);
17
+ _InputMaskController_pattern.set(this, void 0);
18
+ _InputMaskController_validPattern.set(this, void 0);
19
+ _InputMaskController_skipCharacters.set(this, []);
20
+ _InputMaskController_skipKeys.set(this, [
21
+ 'Backspace',
22
+ 'Enter',
23
+ 'Escape',
24
+ 'ArrowLeft',
25
+ 'ArrowUp',
26
+ 'ArrowRight',
27
+ 'ArrowDown',
28
+ 'Delete',
29
+ 'CapsLock',
30
+ 'Shift',
31
+ 'Control',
32
+ 'Alt',
33
+ 'AltGraph',
34
+ 'Tab'
35
+ ]);
36
+ _InputMaskController_patternRegexp.set(this, void 0);
37
+ _InputMaskController_patternCheck.set(this, false);
38
+ _InputMaskController_keydownValue.set(this, '');
39
+ _InputMaskController_isFirstPosition.set(this, false);
40
+ _InputMaskController_isLastPosition.set(this, false);
41
+ _InputMaskController_isEnabled.set(this, false);
42
+ this.enable = () => {
43
+ if (!tslib_es6.__classPrivateFieldGet(this, _InputMaskController_isEnabled, "f")) {
44
+ const $input = this._getInput();
45
+ $input.setAttribute('autocomplete', 'off');
46
+ $input.addEventListener('mousedown', this._setInitialMaskWhenEmpty);
47
+ $input.addEventListener('mouseup', this._setCursorOnStartWhenEmpty);
48
+ $input.addEventListener('blur', this._setEmptyValueForNoValue);
49
+ $input.addEventListener('focus', this._setInitialMaskWhenEmpty);
50
+ $input.addEventListener('keydown', this._onKeyDown);
51
+ $input.addEventListener('input', this._onInput);
52
+ $input.addEventListener('keyup', this._onKeyUp);
53
+ $input.addEventListener('paste', this._onPaste);
54
+ $input.addEventListener('change', () => { });
55
+ $input.value = '';
56
+ tslib_es6.__classPrivateFieldSet(this, _InputMaskController_isEnabled, true, "f");
57
+ }
58
+ };
59
+ this.disable = () => {
60
+ if (tslib_es6.__classPrivateFieldGet(this, _InputMaskController_isEnabled, "f")) {
61
+ const $input = this._getInput();
62
+ $input.setAttribute('autocomplete', 'on');
63
+ $input.removeEventListener('mousedown', this._setInitialMaskWhenEmpty);
64
+ $input.removeEventListener('mouseup', this._setCursorOnStartWhenEmpty);
65
+ $input.removeEventListener('blur', this._setEmptyValueForNoValue);
66
+ $input.removeEventListener('focus', this._setInitialMaskWhenEmpty);
67
+ $input.removeEventListener('keydown', this._onKeyDown);
68
+ $input.removeEventListener('input', this._onInput);
69
+ $input.removeEventListener('keyup', this._onKeyUp);
70
+ $input.removeEventListener('paste', this._onPaste);
71
+ $input.removeEventListener('change', () => { });
72
+ tslib_es6.__classPrivateFieldSet(this, _InputMaskController_isEnabled, false, "f");
73
+ }
74
+ };
75
+ this._setInitialMaskWhenEmpty = (ev) => {
76
+ if (ev.target instanceof HTMLInputElement) {
77
+ const $input = ev.target;
78
+ if (!$input.value) {
79
+ $input.value = tslib_es6.__classPrivateFieldGet(this, _InputMaskController_mask, "f");
80
+ this._setCursorPosition();
81
+ }
82
+ }
83
+ };
84
+ this._setCursorOnStartWhenEmpty = (ev) => {
85
+ if (ev.target instanceof HTMLInputElement) {
86
+ const $input = ev.target;
87
+ if ($input.value === tslib_es6.__classPrivateFieldGet(this, _InputMaskController_mask, "f")) {
88
+ this._setCursorPosition();
89
+ }
90
+ }
91
+ };
92
+ this._setEmptyValueForNoValue = (ev) => {
93
+ if (ev.target instanceof HTMLInputElement) {
94
+ const $input = ev.target;
95
+ if ($input.value === tslib_es6.__classPrivateFieldGet(this, _InputMaskController_mask, "f")) {
96
+ $input.value = '';
97
+ }
98
+ }
99
+ };
100
+ this._onKeyDown = (ev) => {
101
+ if (ev.target instanceof HTMLInputElement) {
102
+ const $input = ev.target;
103
+ const value = $input.value;
104
+ let currentPosition = this._getCursorPosition();
105
+ /**
106
+ *selection more than one character was made
107
+ */
108
+ if (currentPosition[0] !== currentPosition[1]) {
109
+ if (ev.key === 'Backspace' || ev.key === 'Delete' || ev.keyCode === 8 || ev.keyCode === 46) {
110
+ const startSubstring = value.substring(0, currentPosition[0]);
111
+ const middleSubstring = value.substring(currentPosition[0], currentPosition[1]);
112
+ const endSubstring = value.substring(currentPosition[1], value.length);
113
+ const deleteRegexp = new RegExp('[^' + tslib_es6.__classPrivateFieldGet(this, _InputMaskController_skipCharacters, "f").join('') + ']', 'g');
114
+ const newValue = startSubstring + middleSubstring.replace(deleteRegexp, MASK_CHARACTER) + endSubstring;
115
+ $input.value = newValue;
116
+ tslib_es6.__classPrivateFieldSet(this, _InputMaskController_keydownValue, newValue, "f");
117
+ if (ev.key === 'Backspace' || ev.keyCode === 8) {
118
+ this._setCursorPosition(currentPosition[0] + 2);
119
+ if (currentPosition[0] == 5) {
120
+ tslib_es6.__classPrivateFieldSet(this, _InputMaskController_isLastPosition, true, "f");
121
+ }
122
+ }
123
+ else {
124
+ this._setCursorPosition(currentPosition[0]);
125
+ }
126
+ return false;
127
+ }
128
+ else if (!this._areKeysCombined(ev) && tslib_es6.__classPrivateFieldGet(this, _InputMaskController_skipKeys, "f").indexOf(ev.key) < 0) {
129
+ currentPosition = [currentPosition[0], currentPosition[0]];
130
+ }
131
+ }
132
+ /**
133
+ * Added keyCode for older browser compatibility, keyCode 8 == backspace, keyCode 46 === delete
134
+ */
135
+ if (ev.key === 'Backspace' || ev.key === 'Delete' || ev.keyCode === 8 || ev.keyCode === 46) {
136
+ if (ev.key === 'Backspace' || ev.keyCode === 8) {
137
+ if (tslib_es6.__classPrivateFieldGet(this, _InputMaskController_skipCharacters, "f").indexOf(value[currentPosition[0] - 1]) >= 0) {
138
+ // skip special characters that are part of the mask
139
+ tslib_es6.__classPrivateFieldSet(this, _InputMaskController_keydownValue, $input.value, "f");
140
+ this._setCursorPosition(currentPosition[0] + 1);
141
+ return false;
142
+ }
143
+ if (currentPosition[0] !== 0) {
144
+ // do nothing if cursor is at the start of the input
145
+ ev.target.value = this._insertCharAt(value, MASK_CHARACTER, currentPosition[0]);
146
+ this._setCursorPosition(currentPosition);
147
+ }
148
+ }
149
+ if (ev.key === 'Delete' || ev.keyCode === 46) {
150
+ if (tslib_es6.__classPrivateFieldGet(this, _InputMaskController_skipCharacters, "f").indexOf(value[currentPosition[0]]) >= 0) {
151
+ // skip special characters that are part of the mask
152
+ tslib_es6.__classPrivateFieldSet(this, _InputMaskController_keydownValue, $input.value, "f");
153
+ this._setCursorPosition(currentPosition[0] + 1);
154
+ return false;
155
+ }
156
+ if (currentPosition[0] !== value.length) {
157
+ ev.target.value = this._replaceCharAt(value, MASK_CHARACTER, currentPosition[0]);
158
+ tslib_es6.__classPrivateFieldSet(this, _InputMaskController_keydownValue, $input.value, "f");
159
+ setTimeout(() => {
160
+ this._setCursorPosition(currentPosition.map(function (position) {
161
+ return (position += 1);
162
+ }));
163
+ });
164
+ return false;
165
+ }
166
+ }
167
+ return true;
168
+ }
169
+ if (tslib_es6.__classPrivateFieldGet(this, _InputMaskController_skipKeys, "f").indexOf(ev.key) >= 0 || this._areKeysCombined(ev)) {
170
+ // no special behaviour for selected keys
171
+ return true;
172
+ }
173
+ currentPosition[1] += 1;
174
+ if (window.navigator.userAgent.indexOf('Edge/') > -1) {
175
+ ev.target.value = this._replaceCharAt(ev.target.value, ev.key, currentPosition[0]);
176
+ }
177
+ this._setCursorPosition(currentPosition);
178
+ tslib_es6.__classPrivateFieldSet(this, _InputMaskController_keydownValue, value, "f");
179
+ }
180
+ };
181
+ this._onInput = (ev) => {
182
+ if (ev.target instanceof HTMLInputElement) {
183
+ const $input = ev.target;
184
+ const value = $input.value;
185
+ const currentPosition = this._getCursorPosition();
186
+ const skipBy = this._skipCharactersBy.call(this, value, currentPosition[0], 0);
187
+ if (skipBy > 0 && value.length !== currentPosition[0] + skipBy) {
188
+ this._setCursorPosition(currentPosition.map((position) => {
189
+ return position + skipBy;
190
+ }));
191
+ }
192
+ if (!this._isValidPattern(value)) {
193
+ const currentPosition = this._getCursorPosition();
194
+ $input.value = tslib_es6.__classPrivateFieldGet(this, _InputMaskController_keydownValue, "f");
195
+ if (tslib_es6.__classPrivateFieldGet(this, _InputMaskController_isLastPosition, "f") || tslib_es6.__classPrivateFieldGet(this, _InputMaskController_isFirstPosition, "f")) {
196
+ this._setCursorPosition(currentPosition[0]);
197
+ tslib_es6.__classPrivateFieldSet(this, _InputMaskController_isLastPosition, false, "f");
198
+ tslib_es6.__classPrivateFieldSet(this, _InputMaskController_isFirstPosition, false, "f");
199
+ }
200
+ else {
201
+ this._setCursorPosition(currentPosition[0] - 1);
202
+ }
203
+ return false;
204
+ }
205
+ if (tslib_es6.__classPrivateFieldGet(this, _InputMaskController_mask, "f").length !== value.length) {
206
+ $input.value = value.slice(0, tslib_es6.__classPrivateFieldGet(this, _InputMaskController_mask, "f").length);
207
+ const lastMaskCharacterPos = value.indexOf(MASK_CHARACTER);
208
+ if (lastMaskCharacterPos >= 0) {
209
+ this._setCursorPosition(lastMaskCharacterPos);
210
+ }
211
+ }
212
+ }
213
+ };
214
+ this._onKeyUp = (ev) => {
215
+ if (ev.target instanceof HTMLInputElement) {
216
+ const $input = ev.target;
217
+ const value = $input.value;
218
+ const currentPosition = this._getCursorPosition();
219
+ let skipBy;
220
+ if (ev.key === 'Backspace' || ev.keyCode === 8) {
221
+ skipBy = this._skipCharactersBy(value, currentPosition[0] - 1, 0, true);
222
+ if (skipBy > 0) {
223
+ this._setCursorPosition(currentPosition.map((position) => {
224
+ return position - skipBy;
225
+ }));
226
+ }
227
+ return true;
228
+ }
229
+ if (ev.key === 'Delete' || ev.keyCode === 46) {
230
+ skipBy = this._skipCharactersBy(value, currentPosition[0], 0);
231
+ if (skipBy > 0) {
232
+ this._setCursorPosition(currentPosition.map((position) => {
233
+ return position + skipBy;
234
+ }));
235
+ }
236
+ return true;
237
+ }
238
+ if (tslib_es6.__classPrivateFieldGet(this, _InputMaskController_skipKeys, "f").indexOf(ev.key) >= 0 || this._areKeysCombined(ev)) {
239
+ return true;
240
+ }
241
+ if (!value) {
242
+ $input.value = tslib_es6.__classPrivateFieldGet(this, _InputMaskController_mask, "f");
243
+ this._setCursorPosition();
244
+ }
245
+ }
246
+ };
247
+ this._onPaste = (ev) => {
248
+ var _a;
249
+ if (ev.target instanceof HTMLInputElement) {
250
+ const $input = ev.target;
251
+ const value = $input.value;
252
+ const valueLength = value.length;
253
+ const pastedValue = (_a = ev.clipboardData) === null || _a === void 0 ? void 0 : _a.getData('Text');
254
+ const currentPosition = this._getCursorPosition();
255
+ let newValue = '';
256
+ ev.preventDefault();
257
+ for (let i = 0, j = 0; i < valueLength; i += 1) {
258
+ if (i >= currentPosition[0] && pastedValue[j] && tslib_es6.__classPrivateFieldGet(this, _InputMaskController_skipCharacters, "f").indexOf(value[i]) < 0) {
259
+ if (tslib_es6.__classPrivateFieldGet(this, _InputMaskController_skipCharacters, "f").indexOf(pastedValue[j]) < 0) {
260
+ newValue = newValue + pastedValue[j];
261
+ }
262
+ else {
263
+ i -= 1;
264
+ }
265
+ j += 1;
266
+ }
267
+ else {
268
+ newValue = newValue + value[i];
269
+ }
270
+ }
271
+ if (this._isValidPattern(newValue)) {
272
+ ev.target.value = newValue;
273
+ this._setCursorPosition($input.value.indexOf(MASK_CHARACTER));
274
+ }
275
+ }
276
+ };
277
+ tslib_es6.__classPrivateFieldSet(this, _InputMaskController_host, host, "f");
278
+ tslib_es6.__classPrivateFieldSet(this, _InputMaskController_input, input, "f");
279
+ tslib_es6.__classPrivateFieldSet(this, _InputMaskController_mask, mask, "f");
280
+ tslib_es6.__classPrivateFieldSet(this, _InputMaskController_pattern, pattern, "f");
281
+ tslib_es6.__classPrivateFieldSet(this, _InputMaskController_validPattern, validPattern, "f");
282
+ if (pattern) {
283
+ tslib_es6.__classPrivateFieldSet(this, _InputMaskController_patternRegexp, new RegExp(tslib_es6.__classPrivateFieldGet(this, _InputMaskController_pattern, "f"), 'g'), "f");
284
+ tslib_es6.__classPrivateFieldSet(this, _InputMaskController_patternCheck, true, "f");
285
+ }
286
+ tslib_es6.__classPrivateFieldGet(this, _InputMaskController_host, "f").addController(this);
287
+ }
288
+ hostConnected() {
289
+ const maskRegexp = new RegExp(MASK_CHARACTER, 'g');
290
+ tslib_es6.__classPrivateFieldSet(this, _InputMaskController_skipCharacters, this._uniqueArr(tslib_es6.__classPrivateFieldGet(this, _InputMaskController_mask, "f").replace(maskRegexp, '').split('')), "f");
291
+ }
292
+ hostDisconnected() {
293
+ // this.#basePropsObservable?.unsubscribe(this.#propsObserver);
294
+ }
295
+ _setCursorPosition(positionStart = 0, positionEnd = positionStart) {
296
+ const $input = this._getInput();
297
+ if (typeof positionStart !== 'number') {
298
+ $input.selectionStart = positionStart[0];
299
+ $input.selectionEnd = positionEnd[1];
300
+ return;
301
+ }
302
+ $input.selectionStart = positionStart;
303
+ if (typeof positionEnd === 'number')
304
+ $input.selectionEnd = positionEnd;
305
+ }
306
+ _getCursorPosition() {
307
+ var _a, _b;
308
+ const $input = this._getInput();
309
+ return [(_a = $input.selectionStart) !== null && _a !== void 0 ? _a : 0, (_b = $input.selectionEnd) !== null && _b !== void 0 ? _b : 0];
310
+ }
311
+ _uniqueArr(arr) {
312
+ const uniqueArr = [];
313
+ const arrLength = arr.length;
314
+ for (let i = 0; i < arrLength; i++) {
315
+ if (uniqueArr.indexOf(arr[i]) === -1 && arr[i] !== '') {
316
+ uniqueArr.push(arr[i]);
317
+ }
318
+ }
319
+ return uniqueArr;
320
+ }
321
+ _getInput() {
322
+ if (!tslib_es6.__classPrivateFieldGet(this, _InputMaskController_input, "f").value) {
323
+ throw new Error('Input element is not defined');
324
+ }
325
+ return tslib_es6.__classPrivateFieldGet(this, _InputMaskController_input, "f").value;
326
+ }
327
+ _areKeysCombined(ev) {
328
+ return ev.altKey || ev.ctrlKey || ev.metaKey;
329
+ }
330
+ _insertCharAt(string, char, position) {
331
+ return string.slice(0, position) + char + string.slice(position);
332
+ }
333
+ _replaceCharAt(string, char, position) {
334
+ return string.substr(0, position) + char + string.substr(position + 1);
335
+ }
336
+ _skipCharactersBy(value, position, skipBy, backward) {
337
+ backward = backward ? backward : false;
338
+ if (tslib_es6.__classPrivateFieldGet(this, _InputMaskController_skipCharacters, "f").indexOf(value[position]) >= 0) {
339
+ if (backward) {
340
+ position -= 1;
341
+ }
342
+ else {
343
+ position += 1;
344
+ }
345
+ skipBy += 1;
346
+ return this._skipCharactersBy.call(this, value, position, skipBy, backward);
347
+ }
348
+ return skipBy;
349
+ }
350
+ _isValidPattern(value) {
351
+ if (tslib_es6.__classPrivateFieldGet(this, _InputMaskController_patternCheck, "f")) {
352
+ const valueLength = value.length;
353
+ let partialValue = '';
354
+ for (let i = 0; i < valueLength; i += 1) {
355
+ partialValue += value[i] !== '_' ? value[i] : tslib_es6.__classPrivateFieldGet(this, _InputMaskController_validPattern, "f")[i];
356
+ }
357
+ return partialValue.match(tslib_es6.__classPrivateFieldGet(this, _InputMaskController_patternRegexp, "f")) !== null;
358
+ }
359
+ return true;
360
+ }
361
+ }
362
+ _InputMaskController_host = new WeakMap(), _InputMaskController_input = new WeakMap(), _InputMaskController_mask = new WeakMap(), _InputMaskController_pattern = new WeakMap(), _InputMaskController_validPattern = new WeakMap(), _InputMaskController_skipCharacters = new WeakMap(), _InputMaskController_skipKeys = new WeakMap(), _InputMaskController_patternRegexp = new WeakMap(), _InputMaskController_patternCheck = new WeakMap(), _InputMaskController_keydownValue = new WeakMap(), _InputMaskController_isFirstPosition = new WeakMap(), _InputMaskController_isLastPosition = new WeakMap(), _InputMaskController_isEnabled = new WeakMap();
363
+
364
+ exports.InputMaskController = InputMaskController;
365
+ //# sourceMappingURL=input_mask_controller.js.map
@@ -0,0 +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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -1,5 +1,5 @@
1
1
  import { PhoenixLightLitElement } from "../../../core/phoenix_light_lit_element/phoenix_light_lit_element";
2
- import { TemplateResult } from 'lit';
2
+ import { PropertyValues, TemplateResult } from 'lit';
3
3
  import type { TInputControlType } from "./input_types";
4
4
  export declare class HInputControl extends PhoenixLightLitElement {
5
5
  controlId: string;
@@ -11,8 +11,16 @@ export declare class HInputControl extends PhoenixLightLitElement {
11
11
  readonly: boolean;
12
12
  value: string;
13
13
  placeholder: string;
14
+ mask: string;
15
+ pattern: string;
16
+ validPattern: string;
17
+ private _inputRef;
18
+ private _inputMaskController;
14
19
  constructor();
15
20
  connectedCallback(): void;
21
+ protected updated(_changedProperties: PropertyValues): void;
22
+ enableMask(): void;
23
+ disableMask(): void;
16
24
  protected render(): TemplateResult;
17
25
  private _handleChangeEvent;
18
26
  private _handleInputEvent;
@@ -6,11 +6,14 @@ import { phoenixCustomElement } from '../../../core/decorators/phoenix_custom_el
6
6
  import { INPUT_CONTROL_TYPES, INPUT_CONTROL_EVENTS, INPUT_CONTROL_CSS_CLASSES } from './input_constants.js';
7
7
  import { ifDefined } from 'lit-html/directives/if-defined.js';
8
8
  import { ControlPropsSyncConsumerController } from '../controllers/props_synchronizing/control_props_sync_consumer_controller.js';
9
+ import { createRef, ref } from 'lit/directives/ref';
10
+ import { InputMaskController } from '../../../controllers/input_mask_controller/input_mask_controller.js';
9
11
 
10
12
  let HInputControl = class HInputControl extends PhoenixLightLitElement {
11
13
  constructor() {
12
14
  super();
13
15
  this.type = INPUT_CONTROL_TYPES.text;
16
+ this._inputRef = createRef();
14
17
  this._handleChangeEvent = (event) => {
15
18
  this.dispatchEvent(new CustomEvent(INPUT_CONTROL_EVENTS.change, {
16
19
  detail: event,
@@ -29,12 +32,32 @@ let HInputControl = class HInputControl extends PhoenixLightLitElement {
29
32
  }
30
33
  connectedCallback() {
31
34
  super.connectedCallback();
35
+ if (this.mask) {
36
+ this._inputMaskController = new InputMaskController({
37
+ host: this,
38
+ input: this._inputRef,
39
+ mask: this.mask,
40
+ pattern: this.pattern,
41
+ validPattern: this.validPattern
42
+ });
43
+ }
32
44
  this.classList.add(INPUT_CONTROL_CSS_CLASSES.inputControl);
33
45
  }
46
+ updated(_changedProperties) {
47
+ super.updated(_changedProperties);
48
+ this.mask ? this.enableMask() : this.disableMask();
49
+ }
50
+ enableMask() {
51
+ this._inputMaskController.enable();
52
+ }
53
+ disableMask() {
54
+ this._inputMaskController.disable();
55
+ }
34
56
  render() {
35
57
  super.render();
36
58
  return html `
37
59
  <input
60
+ ${ref(this._inputRef)}
38
61
  id="${ifDefined(this.controlId)}"
39
62
  name="${ifDefined(this.controlName)}"
40
63
  type="${ifDefined(this.type)}"
@@ -86,6 +109,18 @@ __decorate([
86
109
  property({ type: String }),
87
110
  __metadata("design:type", String)
88
111
  ], HInputControl.prototype, "placeholder", void 0);
112
+ __decorate([
113
+ property({ type: String }),
114
+ __metadata("design:type", String)
115
+ ], HInputControl.prototype, "mask", void 0);
116
+ __decorate([
117
+ property({ type: String }),
118
+ __metadata("design:type", String)
119
+ ], HInputControl.prototype, "pattern", void 0);
120
+ __decorate([
121
+ property({ type: String, attribute: 'valid-pattern' }),
122
+ __metadata("design:type", String)
123
+ ], HInputControl.prototype, "validPattern", void 0);
89
124
  HInputControl = __decorate([
90
125
  phoenixCustomElement('h-input-control'),
91
126
  __metadata("design:paramtypes", [])
@@ -1 +1 @@
1
- {"version":3,"file":null,"sources":[null],"sourcesContent":[null],"names":[],"mappings":"AAAA,uCAAuC,+CAAmD;AAC1F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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,+CAAmD;AAC1F;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;"}
@@ -97,11 +97,7 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
97
97
  this._handleResize = debounce_1(() => {
98
98
  this._closeSelect();
99
99
  }, SELECT_RESIZE_DEBOUNCE_TIME);
100
- const $options = this.hasSlot('content')
101
- ? this.getSlot('content')
102
- .map((litElement) => litElement.values[0])
103
- .filter((element) => element instanceof HOption)
104
- : Array.from(this.querySelectorAll(SELECT_RELATED_COMPONENTS_NAMES.option));
100
+ const $options = Array.from(this.querySelectorAll(SELECT_RELATED_COMPONENTS_NAMES.option));
105
101
  $options.forEach(($option) => $option.setAttribute('slot', SELECT_SLOT_NAMES.content));
106
102
  this.$placeholder = (_a = this.querySelector(`[slot="${SELECT_INPUT_PLACEHOLDER_SLOT_NAME}"]`)) !== null && _a !== void 0 ? _a : 'Select';
107
103
  if (this.multiple)
@@ -163,7 +159,11 @@ let HSelect = class HSelect extends PhoenixLightLitElement {
163
159
  this._selectController = this.multiple ? new MultiSelectController({ host: this }) : new SelectController({ host: this });
164
160
  this._selectContext.provide(SELECT_CONTEXTS.selectedOptions$, this._selectController.selectedOptions$);
165
161
  this._selectContext.provide(SELECT_CONTEXTS.isMultiselect, this.multiple);
166
- const $options = Array.from(this.querySelectorAll(SELECT_RELATED_COMPONENTS_NAMES.option));
162
+ const $options = this.hasSlot(SELECT_SLOT_NAMES.content)
163
+ ? this.getSlot(SELECT_SLOT_NAMES.content)
164
+ .map((litElement) => litElement.values[0])
165
+ .filter((element) => element instanceof HOption)
166
+ : Array.from(this.querySelectorAll(SELECT_RELATED_COMPONENTS_NAMES.option));
167
167
  this._optionsObserver = new Observer((selectedOptions) => this._updateOptionsView(selectedOptions));
168
168
  this._selectController.options$.subscribe(this._optionsObserver);
169
169
  this._$options = $options.reduce((acc, $option) => {
@@ -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;AAClD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAQ9C,IAAa,OAAO,GAApB,MAAa,OAAQ,SAAQ,sBAAsB;IAAnD;;QAMY,uBAAkB,GAAY,KAAK,CAAC;QAE5C,mDAAmD;QAE3C,mBAAc,GAAqB;YACvC,IAAI,EAAE,MAAM;SACf,CAAC;QAEF,iDAAiD;QAEzC,mBAAc,GAAU,CAAC,iBAAiB,CAAC,CAAC;IAsExD,CAAC;IApEU,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,CAAC,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC;gBACzC,IAAI,CAAC,cAAc,GAAG,UAAU,CAAC,OAAO,CAAC;YAC7C,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;QAED,IAAI,CAAC,eAAe,EAAE,CAAC;IAC3B,CAAC;IAEO,eAAe;QACnB,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,CAAC,EAAS,EAAE,EAAE;YAC3C,MAAM,aAAa,GAAG,EAAE,CAAC,MAAM,YAAY,gBAAgB,IAAI,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;YAE3F,IAAI,aAAa,EAAE;gBACf,MAAM,YAAY,GAAG,EAAE,CAAC,MAAM,CAAC;gBAC/B,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;aAC9C;QACL,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,EAAS,EAAE,EAAE;YACzC,MAAM,aAAa,GAAG,EAAE,CAAC,MAAM,YAAY,gBAAgB,IAAI,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,QAAQ,CAAC;YAE3F,IAAI,aAAa,EAAE;gBACf,MAAM,YAAY,GAAG,EAAE,CAAC,MAAM,CAAC;gBAC/B,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;aAC9C;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IAEO,iBAAiB,CAAC,YAAoB;QAC1C,IAAI,YAAY,KAAK,EAAE,EAAE;YACrB,IAAI,CAAC,0BAA0B,EAAE,CAAC;SACrC;aAAM;YACH,IAAI,CAAC,eAAe,EAAE,CAAC;SAC1B;IACL,CAAC;IAEO,0BAA0B;QAC9B,kEAAkE;QAClE,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC;IACnC,CAAC;IAEO,eAAe;QACnB,kEAAkE;QAClE,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC;IACpC,CAAC;IAEM,MAAM;QACT,4GAA4G;QAC5G,OAAO,IAAI,CAAA;cACL,IAAI,CACF,IAAI,CAAC,kBAAkB,EACvB,GAAG,EAAE,CAAC,IAAI,CAAA,+BAA+B,IAAI,CAAC,cAAc,uBAAuB,EACnF,GAAG,EAAE,CAAC,IAAI,CAAA,+BAA+B,IAAI,CAAC,cAAc,uBAAuB,CACtF;SACJ,CAAC;IACN,CAAC;CACJ,CAAA;AAhFG;IADC,KAAK,EAAE;;mDACoC;AAI5C;IADC,KAAK,EAAE;;+CAGN;AAIF;IADC,KAAK,EAAE;;+CAC4C;AAhB3C,OAAO;IADnB,oBAAoB,CAAC,UAAU,CAAC;GACpB,OAAO,CAsFnB;SAtFY,OAAO"}
@@ -0,0 +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"}
@@ -0,0 +1,25 @@
1
+ import { ReactiveController } from 'lit';
2
+ export declare class InputMaskController implements ReactiveController {
3
+ #private;
4
+ constructor({ host, input, mask, pattern, validPattern }: any);
5
+ hostConnected(): void;
6
+ hostDisconnected(): void;
7
+ enable: () => void;
8
+ disable: () => void;
9
+ private _setCursorPosition;
10
+ private _getCursorPosition;
11
+ private _uniqueArr;
12
+ private _setInitialMaskWhenEmpty;
13
+ private _setCursorOnStartWhenEmpty;
14
+ private _setEmptyValueForNoValue;
15
+ private _onKeyDown;
16
+ private _onInput;
17
+ private _onKeyUp;
18
+ private _onPaste;
19
+ private _getInput;
20
+ private _areKeysCombined;
21
+ private _insertCharAt;
22
+ private _replaceCharAt;
23
+ private _skipCharactersBy;
24
+ private _isValidPattern;
25
+ }
@@ -0,0 +1,361 @@
1
+ import { __classPrivateFieldGet, __classPrivateFieldSet } from '../../../../../external/tslib/tslib.es6.js';
2
+ import 'lit';
3
+ import 'lit/development';
4
+ import 'lit/directives/ref';
5
+
6
+ var _InputMaskController_host, _InputMaskController_input, _InputMaskController_mask, _InputMaskController_pattern, _InputMaskController_validPattern, _InputMaskController_skipCharacters, _InputMaskController_skipKeys, _InputMaskController_patternRegexp, _InputMaskController_patternCheck, _InputMaskController_keydownValue, _InputMaskController_isFirstPosition, _InputMaskController_isLastPosition, _InputMaskController_isEnabled;
7
+ const MASK_CHARACTER = '_';
8
+ class InputMaskController {
9
+ constructor({ host, input, mask, pattern, validPattern }) {
10
+ _InputMaskController_host.set(this, void 0);
11
+ _InputMaskController_input.set(this, void 0);
12
+ _InputMaskController_mask.set(this, void 0);
13
+ _InputMaskController_pattern.set(this, void 0);
14
+ _InputMaskController_validPattern.set(this, void 0);
15
+ _InputMaskController_skipCharacters.set(this, []);
16
+ _InputMaskController_skipKeys.set(this, [
17
+ 'Backspace',
18
+ 'Enter',
19
+ 'Escape',
20
+ 'ArrowLeft',
21
+ 'ArrowUp',
22
+ 'ArrowRight',
23
+ 'ArrowDown',
24
+ 'Delete',
25
+ 'CapsLock',
26
+ 'Shift',
27
+ 'Control',
28
+ 'Alt',
29
+ 'AltGraph',
30
+ 'Tab'
31
+ ]);
32
+ _InputMaskController_patternRegexp.set(this, void 0);
33
+ _InputMaskController_patternCheck.set(this, false);
34
+ _InputMaskController_keydownValue.set(this, '');
35
+ _InputMaskController_isFirstPosition.set(this, false);
36
+ _InputMaskController_isLastPosition.set(this, false);
37
+ _InputMaskController_isEnabled.set(this, false);
38
+ this.enable = () => {
39
+ if (!__classPrivateFieldGet(this, _InputMaskController_isEnabled, "f")) {
40
+ const $input = this._getInput();
41
+ $input.setAttribute('autocomplete', 'off');
42
+ $input.addEventListener('mousedown', this._setInitialMaskWhenEmpty);
43
+ $input.addEventListener('mouseup', this._setCursorOnStartWhenEmpty);
44
+ $input.addEventListener('blur', this._setEmptyValueForNoValue);
45
+ $input.addEventListener('focus', this._setInitialMaskWhenEmpty);
46
+ $input.addEventListener('keydown', this._onKeyDown);
47
+ $input.addEventListener('input', this._onInput);
48
+ $input.addEventListener('keyup', this._onKeyUp);
49
+ $input.addEventListener('paste', this._onPaste);
50
+ $input.addEventListener('change', () => { });
51
+ $input.value = '';
52
+ __classPrivateFieldSet(this, _InputMaskController_isEnabled, true, "f");
53
+ }
54
+ };
55
+ this.disable = () => {
56
+ if (__classPrivateFieldGet(this, _InputMaskController_isEnabled, "f")) {
57
+ const $input = this._getInput();
58
+ $input.setAttribute('autocomplete', 'on');
59
+ $input.removeEventListener('mousedown', this._setInitialMaskWhenEmpty);
60
+ $input.removeEventListener('mouseup', this._setCursorOnStartWhenEmpty);
61
+ $input.removeEventListener('blur', this._setEmptyValueForNoValue);
62
+ $input.removeEventListener('focus', this._setInitialMaskWhenEmpty);
63
+ $input.removeEventListener('keydown', this._onKeyDown);
64
+ $input.removeEventListener('input', this._onInput);
65
+ $input.removeEventListener('keyup', this._onKeyUp);
66
+ $input.removeEventListener('paste', this._onPaste);
67
+ $input.removeEventListener('change', () => { });
68
+ __classPrivateFieldSet(this, _InputMaskController_isEnabled, false, "f");
69
+ }
70
+ };
71
+ this._setInitialMaskWhenEmpty = (ev) => {
72
+ if (ev.target instanceof HTMLInputElement) {
73
+ const $input = ev.target;
74
+ if (!$input.value) {
75
+ $input.value = __classPrivateFieldGet(this, _InputMaskController_mask, "f");
76
+ this._setCursorPosition();
77
+ }
78
+ }
79
+ };
80
+ this._setCursorOnStartWhenEmpty = (ev) => {
81
+ if (ev.target instanceof HTMLInputElement) {
82
+ const $input = ev.target;
83
+ if ($input.value === __classPrivateFieldGet(this, _InputMaskController_mask, "f")) {
84
+ this._setCursorPosition();
85
+ }
86
+ }
87
+ };
88
+ this._setEmptyValueForNoValue = (ev) => {
89
+ if (ev.target instanceof HTMLInputElement) {
90
+ const $input = ev.target;
91
+ if ($input.value === __classPrivateFieldGet(this, _InputMaskController_mask, "f")) {
92
+ $input.value = '';
93
+ }
94
+ }
95
+ };
96
+ this._onKeyDown = (ev) => {
97
+ if (ev.target instanceof HTMLInputElement) {
98
+ const $input = ev.target;
99
+ const value = $input.value;
100
+ let currentPosition = this._getCursorPosition();
101
+ /**
102
+ *selection more than one character was made
103
+ */
104
+ if (currentPosition[0] !== currentPosition[1]) {
105
+ if (ev.key === 'Backspace' || ev.key === 'Delete' || ev.keyCode === 8 || ev.keyCode === 46) {
106
+ const startSubstring = value.substring(0, currentPosition[0]);
107
+ const middleSubstring = value.substring(currentPosition[0], currentPosition[1]);
108
+ const endSubstring = value.substring(currentPosition[1], value.length);
109
+ const deleteRegexp = new RegExp('[^' + __classPrivateFieldGet(this, _InputMaskController_skipCharacters, "f").join('') + ']', 'g');
110
+ const newValue = startSubstring + middleSubstring.replace(deleteRegexp, MASK_CHARACTER) + endSubstring;
111
+ $input.value = newValue;
112
+ __classPrivateFieldSet(this, _InputMaskController_keydownValue, newValue, "f");
113
+ if (ev.key === 'Backspace' || ev.keyCode === 8) {
114
+ this._setCursorPosition(currentPosition[0] + 2);
115
+ if (currentPosition[0] == 5) {
116
+ __classPrivateFieldSet(this, _InputMaskController_isLastPosition, true, "f");
117
+ }
118
+ }
119
+ else {
120
+ this._setCursorPosition(currentPosition[0]);
121
+ }
122
+ return false;
123
+ }
124
+ else if (!this._areKeysCombined(ev) && __classPrivateFieldGet(this, _InputMaskController_skipKeys, "f").indexOf(ev.key) < 0) {
125
+ currentPosition = [currentPosition[0], currentPosition[0]];
126
+ }
127
+ }
128
+ /**
129
+ * Added keyCode for older browser compatibility, keyCode 8 == backspace, keyCode 46 === delete
130
+ */
131
+ if (ev.key === 'Backspace' || ev.key === 'Delete' || ev.keyCode === 8 || ev.keyCode === 46) {
132
+ if (ev.key === 'Backspace' || ev.keyCode === 8) {
133
+ if (__classPrivateFieldGet(this, _InputMaskController_skipCharacters, "f").indexOf(value[currentPosition[0] - 1]) >= 0) {
134
+ // skip special characters that are part of the mask
135
+ __classPrivateFieldSet(this, _InputMaskController_keydownValue, $input.value, "f");
136
+ this._setCursorPosition(currentPosition[0] + 1);
137
+ return false;
138
+ }
139
+ if (currentPosition[0] !== 0) {
140
+ // do nothing if cursor is at the start of the input
141
+ ev.target.value = this._insertCharAt(value, MASK_CHARACTER, currentPosition[0]);
142
+ this._setCursorPosition(currentPosition);
143
+ }
144
+ }
145
+ if (ev.key === 'Delete' || ev.keyCode === 46) {
146
+ if (__classPrivateFieldGet(this, _InputMaskController_skipCharacters, "f").indexOf(value[currentPosition[0]]) >= 0) {
147
+ // skip special characters that are part of the mask
148
+ __classPrivateFieldSet(this, _InputMaskController_keydownValue, $input.value, "f");
149
+ this._setCursorPosition(currentPosition[0] + 1);
150
+ return false;
151
+ }
152
+ if (currentPosition[0] !== value.length) {
153
+ ev.target.value = this._replaceCharAt(value, MASK_CHARACTER, currentPosition[0]);
154
+ __classPrivateFieldSet(this, _InputMaskController_keydownValue, $input.value, "f");
155
+ setTimeout(() => {
156
+ this._setCursorPosition(currentPosition.map(function (position) {
157
+ return (position += 1);
158
+ }));
159
+ });
160
+ return false;
161
+ }
162
+ }
163
+ return true;
164
+ }
165
+ if (__classPrivateFieldGet(this, _InputMaskController_skipKeys, "f").indexOf(ev.key) >= 0 || this._areKeysCombined(ev)) {
166
+ // no special behaviour for selected keys
167
+ return true;
168
+ }
169
+ currentPosition[1] += 1;
170
+ if (window.navigator.userAgent.indexOf('Edge/') > -1) {
171
+ ev.target.value = this._replaceCharAt(ev.target.value, ev.key, currentPosition[0]);
172
+ }
173
+ this._setCursorPosition(currentPosition);
174
+ __classPrivateFieldSet(this, _InputMaskController_keydownValue, value, "f");
175
+ }
176
+ };
177
+ this._onInput = (ev) => {
178
+ if (ev.target instanceof HTMLInputElement) {
179
+ const $input = ev.target;
180
+ const value = $input.value;
181
+ const currentPosition = this._getCursorPosition();
182
+ const skipBy = this._skipCharactersBy.call(this, value, currentPosition[0], 0);
183
+ if (skipBy > 0 && value.length !== currentPosition[0] + skipBy) {
184
+ this._setCursorPosition(currentPosition.map((position) => {
185
+ return position + skipBy;
186
+ }));
187
+ }
188
+ if (!this._isValidPattern(value)) {
189
+ const currentPosition = this._getCursorPosition();
190
+ $input.value = __classPrivateFieldGet(this, _InputMaskController_keydownValue, "f");
191
+ if (__classPrivateFieldGet(this, _InputMaskController_isLastPosition, "f") || __classPrivateFieldGet(this, _InputMaskController_isFirstPosition, "f")) {
192
+ this._setCursorPosition(currentPosition[0]);
193
+ __classPrivateFieldSet(this, _InputMaskController_isLastPosition, false, "f");
194
+ __classPrivateFieldSet(this, _InputMaskController_isFirstPosition, false, "f");
195
+ }
196
+ else {
197
+ this._setCursorPosition(currentPosition[0] - 1);
198
+ }
199
+ return false;
200
+ }
201
+ if (__classPrivateFieldGet(this, _InputMaskController_mask, "f").length !== value.length) {
202
+ $input.value = value.slice(0, __classPrivateFieldGet(this, _InputMaskController_mask, "f").length);
203
+ const lastMaskCharacterPos = value.indexOf(MASK_CHARACTER);
204
+ if (lastMaskCharacterPos >= 0) {
205
+ this._setCursorPosition(lastMaskCharacterPos);
206
+ }
207
+ }
208
+ }
209
+ };
210
+ this._onKeyUp = (ev) => {
211
+ if (ev.target instanceof HTMLInputElement) {
212
+ const $input = ev.target;
213
+ const value = $input.value;
214
+ const currentPosition = this._getCursorPosition();
215
+ let skipBy;
216
+ if (ev.key === 'Backspace' || ev.keyCode === 8) {
217
+ skipBy = this._skipCharactersBy(value, currentPosition[0] - 1, 0, true);
218
+ if (skipBy > 0) {
219
+ this._setCursorPosition(currentPosition.map((position) => {
220
+ return position - skipBy;
221
+ }));
222
+ }
223
+ return true;
224
+ }
225
+ if (ev.key === 'Delete' || ev.keyCode === 46) {
226
+ skipBy = this._skipCharactersBy(value, currentPosition[0], 0);
227
+ if (skipBy > 0) {
228
+ this._setCursorPosition(currentPosition.map((position) => {
229
+ return position + skipBy;
230
+ }));
231
+ }
232
+ return true;
233
+ }
234
+ if (__classPrivateFieldGet(this, _InputMaskController_skipKeys, "f").indexOf(ev.key) >= 0 || this._areKeysCombined(ev)) {
235
+ return true;
236
+ }
237
+ if (!value) {
238
+ $input.value = __classPrivateFieldGet(this, _InputMaskController_mask, "f");
239
+ this._setCursorPosition();
240
+ }
241
+ }
242
+ };
243
+ this._onPaste = (ev) => {
244
+ var _a;
245
+ if (ev.target instanceof HTMLInputElement) {
246
+ const $input = ev.target;
247
+ const value = $input.value;
248
+ const valueLength = value.length;
249
+ const pastedValue = (_a = ev.clipboardData) === null || _a === void 0 ? void 0 : _a.getData('Text');
250
+ const currentPosition = this._getCursorPosition();
251
+ let newValue = '';
252
+ ev.preventDefault();
253
+ for (let i = 0, j = 0; i < valueLength; i += 1) {
254
+ if (i >= currentPosition[0] && pastedValue[j] && __classPrivateFieldGet(this, _InputMaskController_skipCharacters, "f").indexOf(value[i]) < 0) {
255
+ if (__classPrivateFieldGet(this, _InputMaskController_skipCharacters, "f").indexOf(pastedValue[j]) < 0) {
256
+ newValue = newValue + pastedValue[j];
257
+ }
258
+ else {
259
+ i -= 1;
260
+ }
261
+ j += 1;
262
+ }
263
+ else {
264
+ newValue = newValue + value[i];
265
+ }
266
+ }
267
+ if (this._isValidPattern(newValue)) {
268
+ ev.target.value = newValue;
269
+ this._setCursorPosition($input.value.indexOf(MASK_CHARACTER));
270
+ }
271
+ }
272
+ };
273
+ __classPrivateFieldSet(this, _InputMaskController_host, host, "f");
274
+ __classPrivateFieldSet(this, _InputMaskController_input, input, "f");
275
+ __classPrivateFieldSet(this, _InputMaskController_mask, mask, "f");
276
+ __classPrivateFieldSet(this, _InputMaskController_pattern, pattern, "f");
277
+ __classPrivateFieldSet(this, _InputMaskController_validPattern, validPattern, "f");
278
+ if (pattern) {
279
+ __classPrivateFieldSet(this, _InputMaskController_patternRegexp, new RegExp(__classPrivateFieldGet(this, _InputMaskController_pattern, "f"), 'g'), "f");
280
+ __classPrivateFieldSet(this, _InputMaskController_patternCheck, true, "f");
281
+ }
282
+ __classPrivateFieldGet(this, _InputMaskController_host, "f").addController(this);
283
+ }
284
+ hostConnected() {
285
+ const maskRegexp = new RegExp(MASK_CHARACTER, 'g');
286
+ __classPrivateFieldSet(this, _InputMaskController_skipCharacters, this._uniqueArr(__classPrivateFieldGet(this, _InputMaskController_mask, "f").replace(maskRegexp, '').split('')), "f");
287
+ }
288
+ hostDisconnected() {
289
+ // this.#basePropsObservable?.unsubscribe(this.#propsObserver);
290
+ }
291
+ _setCursorPosition(positionStart = 0, positionEnd = positionStart) {
292
+ const $input = this._getInput();
293
+ if (typeof positionStart !== 'number') {
294
+ $input.selectionStart = positionStart[0];
295
+ $input.selectionEnd = positionEnd[1];
296
+ return;
297
+ }
298
+ $input.selectionStart = positionStart;
299
+ if (typeof positionEnd === 'number')
300
+ $input.selectionEnd = positionEnd;
301
+ }
302
+ _getCursorPosition() {
303
+ var _a, _b;
304
+ const $input = this._getInput();
305
+ return [(_a = $input.selectionStart) !== null && _a !== void 0 ? _a : 0, (_b = $input.selectionEnd) !== null && _b !== void 0 ? _b : 0];
306
+ }
307
+ _uniqueArr(arr) {
308
+ const uniqueArr = [];
309
+ const arrLength = arr.length;
310
+ for (let i = 0; i < arrLength; i++) {
311
+ if (uniqueArr.indexOf(arr[i]) === -1 && arr[i] !== '') {
312
+ uniqueArr.push(arr[i]);
313
+ }
314
+ }
315
+ return uniqueArr;
316
+ }
317
+ _getInput() {
318
+ if (!__classPrivateFieldGet(this, _InputMaskController_input, "f").value) {
319
+ throw new Error('Input element is not defined');
320
+ }
321
+ return __classPrivateFieldGet(this, _InputMaskController_input, "f").value;
322
+ }
323
+ _areKeysCombined(ev) {
324
+ return ev.altKey || ev.ctrlKey || ev.metaKey;
325
+ }
326
+ _insertCharAt(string, char, position) {
327
+ return string.slice(0, position) + char + string.slice(position);
328
+ }
329
+ _replaceCharAt(string, char, position) {
330
+ return string.substr(0, position) + char + string.substr(position + 1);
331
+ }
332
+ _skipCharactersBy(value, position, skipBy, backward) {
333
+ backward = backward ? backward : false;
334
+ if (__classPrivateFieldGet(this, _InputMaskController_skipCharacters, "f").indexOf(value[position]) >= 0) {
335
+ if (backward) {
336
+ position -= 1;
337
+ }
338
+ else {
339
+ position += 1;
340
+ }
341
+ skipBy += 1;
342
+ return this._skipCharactersBy.call(this, value, position, skipBy, backward);
343
+ }
344
+ return skipBy;
345
+ }
346
+ _isValidPattern(value) {
347
+ if (__classPrivateFieldGet(this, _InputMaskController_patternCheck, "f")) {
348
+ const valueLength = value.length;
349
+ let partialValue = '';
350
+ for (let i = 0; i < valueLength; i += 1) {
351
+ partialValue += value[i] !== '_' ? value[i] : __classPrivateFieldGet(this, _InputMaskController_validPattern, "f")[i];
352
+ }
353
+ return partialValue.match(__classPrivateFieldGet(this, _InputMaskController_patternRegexp, "f")) !== null;
354
+ }
355
+ return true;
356
+ }
357
+ }
358
+ _InputMaskController_host = new WeakMap(), _InputMaskController_input = new WeakMap(), _InputMaskController_mask = new WeakMap(), _InputMaskController_pattern = new WeakMap(), _InputMaskController_validPattern = new WeakMap(), _InputMaskController_skipCharacters = new WeakMap(), _InputMaskController_skipKeys = new WeakMap(), _InputMaskController_patternRegexp = new WeakMap(), _InputMaskController_patternCheck = new WeakMap(), _InputMaskController_keydownValue = new WeakMap(), _InputMaskController_isFirstPosition = new WeakMap(), _InputMaskController_isLastPosition = new WeakMap(), _InputMaskController_isEnabled = new WeakMap();
359
+
360
+ export { InputMaskController };
361
+ //# sourceMappingURL=input_mask_controller.js.map
@@ -0,0 +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;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.5.4",
5
+ "version": "1.6.0",
6
6
  "description": "phoenix design system",
7
7
  "author": "zefirek",
8
8
  "license": "MIT",