@cscfi/csc-ui 1.2.2 → 1.2.3

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.
@@ -30,8 +30,7 @@ const CAutocomplete = class {
30
30
  ? { name: selection.name, value: selection.value }
31
31
  : selection.value;
32
32
  this.changeValue.emit(this.value);
33
- this.query = selection.name.toString();
34
- this.changeQuery.emit(selection.value);
33
+ this.changeQuery.emit(this.query);
35
34
  this.internals.setFormValue(selection.value.toString());
36
35
  }
37
36
  if (this.optionElements.length && !this.optionElementsExist) {
@@ -114,7 +113,7 @@ const CAutocomplete = class {
114
113
  this.changeQuery.emit('');
115
114
  this._dropdownElement.updateList();
116
115
  }
117
- handleKeyDown(event) {
116
+ _handleKeyDown(event) {
118
117
  const alphanumeric = /^[0-9a-zA-Z ]+$/;
119
118
  if (event.key.match(alphanumeric) && event.key.length === 1) {
120
119
  if (!this.dropdownVisible) {
@@ -211,9 +210,9 @@ const CAutocomplete = class {
211
210
  handleQueryChange() {
212
211
  this._updateStatusText();
213
212
  }
214
- _updateInput(event) {
213
+ _updateInput() {
215
214
  this._dropdownElement.open();
216
- this.query = event.target.value;
215
+ this.query = this._inputElement.value;
217
216
  this.changeQuery.emit(this.query);
218
217
  this._dropdownElement.updateList();
219
218
  }
@@ -232,7 +231,7 @@ const CAutocomplete = class {
232
231
  }
233
232
  _renderInputElement() {
234
233
  var _a;
235
- return (index.h("div", { class: "c-input-menu__input" }, index.h("input", { type: "text", ref: (el) => (this._inputElement = el), "aria-expanded": this.dropdownVisible.toString(), "aria-owns": this._inputId + '-items', "aria-autocomplete": "list", autocomplete: "off", class: "c-input__input", role: "combobox", value: this.query, name: (_a = this.name) !== null && _a !== void 0 ? _a : null, onInput: (event) => this._updateInput(event), onFocus: () => this._onInputFocus() })));
234
+ return (index.h("div", { class: "c-input-menu__input" }, index.h("input", { type: "text", ref: (el) => (this._inputElement = el), "aria-expanded": this.dropdownVisible.toString(), "aria-owns": this._inputId + '-items', "aria-autocomplete": "list", autocomplete: "off", class: "c-input__input", role: "combobox", value: this.query, name: (_a = this.name) !== null && _a !== void 0 ? _a : null, onInput: () => this._updateInput(), onFocus: () => this._onInputFocus() })));
236
235
  }
237
236
  componentWillLoad() {
238
237
  CAutocomplete._uniqueId += 1;
@@ -266,7 +265,7 @@ const CAutocomplete = class {
266
265
  }
267
266
  render() {
268
267
  const itemType = this.optionElementsExist ? 'option' : 'item';
269
- return (index.h(index.Host, null, index.h("c-dropdown", { ref: (el) => (this._dropdownElement = el), id: `${this._id}-dropdown`, index: this.currentIndex, "items-per-page": this.itemsPerPage, "item-type": itemType, items: this._items, parent: this.el, type: "autocomplete" }, index.h("c-input", { slot: "default", ref: (el) => (this._cInputElement = el), active: this.dropdownVisible, disabled: this.disabled, "hide-details": this.hideDetails, hint: this.hint, id: this.hostId, "input-id": this._inputId, label: this.label, name: this.name, placeholder: this.placeholder, required: this.required, shadow: this.shadow, valid: this.valid, validate: this.validate, "validate-on-blur": this.validateOnBlur, validation: this.validation, value: this.query, variant: "select" }, index.h("slot", { name: "pre", slot: "pre" }), index.h("div", { class: "c-input__content" }, this._renderInputElement(), this.loading && this._renderLoader(), !this.loading && this.value && this._renderReset(), !this.loading && !this.value && this._renderChevron(), index.h("slot", { onSlotchange: () => this._handleSlotChange() })), index.h("slot", { name: "post", slot: "post" })))));
268
+ return (index.h(index.Host, null, index.h("c-dropdown", { ref: (el) => (this._dropdownElement = el), id: `${this._id}-dropdown`, index: this.currentIndex, "items-per-page": this.itemsPerPage, "item-type": itemType, items: this._items, parent: this.el, type: "autocomplete", onKeyDown: (event) => this._handleKeyDown(event) }, index.h("c-input", { slot: "default", ref: (el) => (this._cInputElement = el), active: this.dropdownVisible, disabled: this.disabled, "hide-details": this.hideDetails, hint: this.hint, id: this.hostId, "input-id": this._inputId, label: this.label, name: this.name, placeholder: this.placeholder, required: this.required, shadow: this.shadow, valid: this.valid, validate: this.validate, "validate-on-blur": this.validateOnBlur, validation: this.validation, value: this.query, variant: "select" }, index.h("slot", { name: "pre", slot: "pre" }), index.h("div", { class: "c-input__content" }, this._renderInputElement(), this.loading && this._renderLoader(), !this.loading && this.value && this._renderReset(), !this.loading && !this.value && this._renderChevron(), index.h("slot", { onSlotchange: () => this._handleSlotChange() })), index.h("slot", { name: "post", slot: "post" })))));
270
269
  }
271
270
  static get formAssociated() { return true; }
272
271
  get el() { return index.getElement(this); }
@@ -695,7 +694,6 @@ const CDropdown = class {
695
694
  inputSlot = 'input-bottom';
696
695
  this._dialog.style.top = 'auto';
697
696
  this._dialog.style.bottom = `${innerHeight - inputSize.top - 44}px`;
698
- this._inputElement.scrollIntoView();
699
697
  }
700
698
  }
701
699
  this._dummyElement.style.width = `${this._getParentPosition().width}px`;