@cscfi/csc-ui 2.2.9 → 2.2.10

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.
@@ -1785,9 +1785,10 @@ const CSelect = class {
1785
1785
  this._lastKeyPressTime = null;
1786
1786
  this._searchString = '';
1787
1787
  this._toggleDropdown = (event) => {
1788
+ var _a;
1788
1789
  event.stopPropagation();
1789
1790
  if (this.dropdownVisible) {
1790
- this._dropdownElement.close();
1791
+ (_a = this._dropdownElement) === null || _a === void 0 ? void 0 : _a.close();
1791
1792
  return;
1792
1793
  }
1793
1794
  this._dropdownElement.open();
@@ -1895,6 +1896,7 @@ const CSelect = class {
1895
1896
  this._dropdownElement.updateList();
1896
1897
  }
1897
1898
  handleKeyDown(event) {
1899
+ var _a, _b, _c;
1898
1900
  const alphanumeric = /^[0-9a-zA-Z ]+$/;
1899
1901
  if (this.disabled)
1900
1902
  return;
@@ -1917,12 +1919,12 @@ const CSelect = class {
1917
1919
  }
1918
1920
  if (event.key === 'Escape') {
1919
1921
  this._preventDialogOpen = true;
1920
- this._dropdownElement.close();
1922
+ (_a = this._dropdownElement) === null || _a === void 0 ? void 0 : _a.close();
1921
1923
  this._inputElement.focus();
1922
1924
  return;
1923
1925
  }
1924
1926
  if (event.key === 'Tab') {
1925
- this._dropdownElement.close();
1927
+ (_b = this._dropdownElement) === null || _b === void 0 ? void 0 : _b.close();
1926
1928
  }
1927
1929
  if (event.key === 'ArrowDown') {
1928
1930
  event.preventDefault();
@@ -1940,7 +1942,7 @@ const CSelect = class {
1940
1942
  if (event.key === 'ArrowUp') {
1941
1943
  event.preventDefault();
1942
1944
  if (this.currentIndex === 0) {
1943
- this._dropdownElement.close();
1945
+ (_c = this._dropdownElement) === null || _c === void 0 ? void 0 : _c.close();
1944
1946
  this._inputElement.focus();
1945
1947
  }
1946
1948
  if (!this.dropdownVisible) {
@@ -1980,10 +1982,19 @@ const CSelect = class {
1980
1982
  this._selectOption(this.returnObject ? v : { name: v, value: v });
1981
1983
  }
1982
1984
  onSelectOption(event) {
1985
+ var _a, _b;
1986
+ if (this.returnObject &&
1987
+ this.value.value === event.detail.value) {
1988
+ (_a = this._dropdownElement) === null || _a === void 0 ? void 0 : _a.close();
1989
+ }
1990
+ if (!this.returnObject && this.value === event.detail.value) {
1991
+ (_b = this._dropdownElement) === null || _b === void 0 ? void 0 : _b.close();
1992
+ }
1983
1993
  this._setValue(event.detail);
1984
1994
  }
1985
1995
  _selectOption({ value, name }) {
1986
- this._dropdownElement.close();
1996
+ var _a;
1997
+ (_a = this._dropdownElement) === null || _a === void 0 ? void 0 : _a.close();
1987
1998
  const selection = this._setCurrentIndex({ name, value });
1988
1999
  if (this.optionElementsExist && this.optionAsSelection && selection) {
1989
2000
  const clone = selection.cloneNode(true);
@@ -2078,12 +2089,12 @@ const CSelect = class {
2078
2089
  }
2079
2090
  render() {
2080
2091
  const itemType = this.optionElementsExist ? 'option' : 'item';
2081
- return (index.h(index.Host, { key: '52f875ca03cb88ec39c013c42e235b572ed01cdf' }, index.h("c-dropdown", { key: '4d3f14c317780b32430e871526359509173d9115', ref: (el) => (this._dropdownElement = el), id: `${this._id}-dropdown`, index: this.currentIndex, "items-per-page": this.itemsPerPage, "dropdown-item-type": itemType, items: this._items, parent: this.el, type: "select" }, index.h("c-input", { key: 'c7885524a9a8879856dfce1619e4691654075270', 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.value, variant: "select", onClick: () => !this.disabled && this._dropdownElement.open() }, index.h("slot", { key: '82809542fbc315e95e30de7b3e2fc1dedad208af', name: "pre", slot: "pre" }), index.h("div", { key: '3e52607084d4c0f571a4f4c1158d62593fa0778f', class: "c-input__content" }, this._renderInputElement(), this.loading && this._renderLoader(), !this.loading &&
2092
+ return (index.h(index.Host, { key: '44469f8a65994971033ccdd17db364a7a2b05031' }, index.h("c-dropdown", { key: 'bbc11df651bf6ecfd9bcb3c11b38efc3ace6bfa5', ref: (el) => (this._dropdownElement = el), id: `${this._id}-dropdown`, index: this.currentIndex, "items-per-page": this.itemsPerPage, "dropdown-item-type": itemType, items: this._items, parent: this.el, type: "select" }, index.h("c-input", { key: '6f19558e4ef18b3aec1155d37f86ffcd07062e3a', 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.value, variant: "select", onClick: () => !this.disabled && this._dropdownElement.open() }, index.h("slot", { key: 'e90aa3e9c71cb220dd36b4c48aa606d5432e9216', name: "pre", slot: "pre" }), index.h("div", { key: '542869bf1a8e162798e2d7e38964383d643ac6c5', class: "c-input__content" }, this._renderInputElement(), this.loading && this._renderLoader(), !this.loading &&
2082
2093
  this.value &&
2083
2094
  this.clearable &&
2084
2095
  this._renderReset(), !this.loading &&
2085
2096
  (!this.value || !this.clearable) &&
2086
- this._renderChevron(), index.h("slot", { key: '89b436dbbd01e3d74317da154870dd37f62d131b', onSlotchange: () => this._onSlotChange() })), index.h("slot", { key: '7fc00de1ddf7dfdf38c752372127356796c4037e', name: "post", slot: "post" })))));
2097
+ this._renderChevron(), index.h("slot", { key: '403cf21005383c491f3bbe42517fae4f1785375e', onSlotchange: () => this._onSlotChange() })), index.h("slot", { key: '810329ec1606db953c64c58ee9e77a954aaf2de8', name: "post", slot: "post" })))));
2087
2098
  }
2088
2099
  static get formAssociated() { return true; }
2089
2100
  get el() { return index.getElement(this); }