@cas-smartdesign/combo-box 7.2.10 → 7.3.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.
@@ -45,6 +45,7 @@ export default class ComboBox extends SDInput {
45
45
  allowCustomValue: boolean;
46
46
  triggerOnly: boolean;
47
47
  nullSettingDisallowed: boolean;
48
+ showIcon: boolean;
48
49
  displayValuePath: string;
49
50
  filterProperty: string;
50
51
  id: string;
@@ -65,6 +66,7 @@ export default class ComboBox extends SDInput {
65
66
  private _openedByFilterTextChange;
66
67
  private _lastRequestedPage;
67
68
  private _lastRequestedFilterText;
69
+ private _icon;
68
70
  constructor();
69
71
  get clearFilterOnLazyLoadedSelection(): boolean;
70
72
  /**
@@ -92,6 +94,11 @@ export default class ComboBox extends SDInput {
92
94
  firstUpdated(changedProperties: PropertyValues): void;
93
95
  private updateComboBoxValueFromValue;
94
96
  updated(changedProperties: PropertyValues): void;
97
+ private initIconWrapper;
98
+ private updateIconFromCurrentValue;
99
+ private updateIcon;
100
+ private updateHasValue;
101
+ protected shouldFloat(): any;
95
102
  private initClearButtton;
96
103
  private initToggleButtton;
97
104
  private debouncedFilterItemsInMemory;
@@ -1,20 +1,21 @@
1
- import { css as g, unsafeCSS as v, html as x } from "lit";
1
+ import { css as g, unsafeCSS as x, html as b } from "lit";
2
2
  import { property as r } from "lit/decorators/property.js";
3
- import { createPopper as b } from "@popperjs/core";
3
+ import { createPopper as v } from "@popperjs/core";
4
4
  import _ from "@cas-smartdesign/lit-input";
5
5
  import p, { ListDataProvider as y, SelectionType as u } from "@cas-smartdesign/virtual-list";
6
6
  import { generator as w } from "@cas-smartdesign/list-item";
7
- const I = ":host{display:inline-flex;position:relative;cursor:text;font-family:Segoe UI,Lucida Sans,Arial,sans-serif;font-size:16px;color:#111;contain:layout style;flex-direction:column}:host([hidden]),:host([type=hidden]){display:none!important}:host([effective-disabled]){opacity:.6;cursor:default;filter:grayscale(100%)}:host([effective-disabled]) .unfocused-line,:host([effective-disabled]) .focused-line{border-bottom-style:dashed}:host(:not([effective-disabled]):focus) .focused-line,:host(:not([effective-disabled])[focused]) .focused-line{transform:none;transition:transform .25s}:host(:not([effective-disabled]):focus) .label.float,:host(:not([effective-disabled])[focused]) .label.float{color:var(--sd-input-focused-color, #1467ba)}:host([inactive]) .input{pointer-events:none}:host([effective-disabled]:focus),:host([effective-disabled][focused]){box-shadow:0 0 0 1px #111}:host(:not([effective-disabled])[validationlevel]) .focused-line,:host(:not([effective-disabled]):invalid) .focused-line{transform:none;transition:transform .25s}:host([validationlevel=warn i]) .focused-line{border-bottom-color:var(--sd-input-validation-color, #555555)}:host([validationlevel=warn i]) .label,:host([validationlevel=warn i]) .validation-message{color:var(--sd-input-validation-color, #555555)!important}:host([validationlevel=suggest i]) .focused-line{border-bottom-color:var(--sd-input-validation-color, #bf8800)}:host([validationlevel=suggest i]) .label,:host([validationlevel=suggest i]) .validation-message{color:var(--sd-input-validation-color, #bf8800)!important}:host([validationlevel=error i]) .focused-line,:host(:not([validationlevel]):invalid) .focused-line{border-bottom-color:var(--sd-input-validation-color, #cc0017)}:host([validationlevel=error i]) .label,:host([validationlevel=error i]) .validation-message,:host(:not([validationlevel]):invalid) .label,:host(:not([validationlevel]):invalid) .validation-message{color:var(--sd-input-validation-color, #cc0017)!important}.validation-message-wrapper{position:relative}.validation-message{position:absolute;left:0;right:0}.label.float{transform:translateY(-75%) scale(.75);width:133%}.label:not(.float){max-width:100%}.floated-label-placeholder{height:20px;width:100%}.label{position:absolute;top:0;left:0;line-height:24px;pointer-events:none;color:var(--sd-input-color, #767676);transition:transform .25s,width .25s;transform-origin:left top}.input-wrapper{position:relative;display:flex;flex-direction:row;align-items:center;background-color:var(--input-wrapper-background-color)}:host([extended-prefix]:focus-within:not([effective-disabled])) .input-wrapper{flex-direction:column;align-items:baseline}:host([extended-prefix]:focus-within:not([effective-disabled])) .input-container{width:100%}:host([extended-prefix]:not(:focus-within)) .input-container,:host([extended-prefix][effective-disabled]) .input-container{width:0px}.input-container{line-height:var(--sd-input-line-height, 24px);flex:1 1 auto}.input{width:100%;background:var(--sd-input-background, transparent);font-family:inherit;font-size:inherit;text-align:inherit;color:inherit;border:none;outline:none;resize:none;padding-left:0;padding-right:0}.input:-webkit-autofill{animation-name:onautofillstart}.input:not(:-webkit-autofill){animation-name:onautofillcancel}@keyframes onautofillstart{0%{outline:none}}@keyframes onautofillcancel{0%{outline:none}}.label,input.input,.validation-message{text-overflow:ellipsis;overflow-x:hidden;white-space:nowrap}.input::placeholder{color:var(--sd-input-color, #767676)}.underline{height:2px;width:100%;position:relative}.unfocused-line,.focused-line{position:absolute;top:0;right:0;bottom:0;left:0}.unfocused-line{border-bottom:1px solid var(--sd-input-underline-color, #959595)}.focused-line{border-bottom:2px solid var(--sd-input-focused-color, #1467ba);transform-origin:center center;transform:scale3d(0,1,1)}.prefix,.suffix{display:flex;flex-wrap:nowrap;max-width:100%}.prefix ::slotted(*),.suffix ::slotted(*){display:flex}:host(:focus){outline:none}.suffix ::slotted(.clear-button),.suffix ::slotted(.toggle-button){cursor:pointer;width:16px;height:32px;padding:0 8px;margin-top:-8px;margin-bottom:-8px;fill:#666;outline:none;flex-shrink:0}.suffix ::slotted(.toggle-button){transition:transform .2s}:host([opened]) .suffix ::slotted(.toggle-button){transform:rotate(180deg)}:host([disabled]) .suffix ::slotted(.clear-button),:host([disabled]) .suffix ::slotted(.toggle-button){display:none!important}:host(:not([has-value])) .suffix ::slotted(.clear-button),:host([null-setting-disallowed]) .suffix ::slotted(.clear-button){display:none!important}:host(:not([allow-custom-value]):not([trigger-only])) .input{caret-color:transparent}:host(:not([allow-custom-value]):not([disabled])) .input{cursor:pointer}#default-slot{display:none}", C = `<svg xmlns="http://www.w3.org/2000/svg" class="toggle-button" slot="suffix" viewBox="0 0 16 16">\r
7
+ import I from "@cas-smartdesign/image-tools";
8
+ const V = ":host{display:inline-flex;position:relative;cursor:text;font-family:Segoe UI,Lucida Sans,Arial,sans-serif;font-size:16px;color:#111;contain:layout style;flex-direction:column}:host([hidden]),:host([type=hidden]){display:none!important}:host([effective-disabled]){opacity:.6;cursor:default;filter:grayscale(100%)}:host([effective-disabled]) .unfocused-line,:host([effective-disabled]) .focused-line{border-bottom-style:dashed}:host(:not([effective-disabled]):focus) .focused-line,:host(:not([effective-disabled])[focused]) .focused-line{transform:none;transition:transform .25s}:host(:not([effective-disabled]):focus) .label.float,:host(:not([effective-disabled])[focused]) .label.float{color:var(--sd-input-focused-color, #1467ba)}:host([inactive]) .input{pointer-events:none}:host([effective-disabled]:focus),:host([effective-disabled][focused]){box-shadow:0 0 0 1px #111}:host(:not([effective-disabled])[validationlevel]) .focused-line,:host(:not([effective-disabled]):invalid) .focused-line{transform:none;transition:transform .25s}:host([validationlevel=warn i]) .focused-line{border-bottom-color:var(--sd-input-validation-color, #555555)}:host([validationlevel=warn i]) .label,:host([validationlevel=warn i]) .validation-message{color:var(--sd-input-validation-color, #555555)!important}:host([validationlevel=suggest i]) .focused-line{border-bottom-color:var(--sd-input-validation-color, #bf8800)}:host([validationlevel=suggest i]) .label,:host([validationlevel=suggest i]) .validation-message{color:var(--sd-input-validation-color, #bf8800)!important}:host([validationlevel=error i]) .focused-line,:host(:not([validationlevel]):invalid) .focused-line{border-bottom-color:var(--sd-input-validation-color, #cc0017)}:host([validationlevel=error i]) .label,:host([validationlevel=error i]) .validation-message,:host(:not([validationlevel]):invalid) .label,:host(:not([validationlevel]):invalid) .validation-message{color:var(--sd-input-validation-color, #cc0017)!important}.validation-message-wrapper{position:relative}.validation-message{position:absolute;left:0;right:0}.label.float{transform:translateY(-75%) scale(.75);width:133%}.label:not(.float){max-width:100%}.floated-label-placeholder{height:20px;width:100%}.label{position:absolute;top:0;left:0;line-height:24px;pointer-events:none;color:var(--sd-input-color, #767676);transition:transform .25s,width .25s;transform-origin:left top}.input-wrapper{position:relative;display:flex;flex-direction:row;align-items:center;background-color:var(--input-wrapper-background-color)}:host([extended-prefix]:focus-within:not([effective-disabled])) .input-wrapper{flex-direction:column;align-items:baseline}:host([extended-prefix]:focus-within:not([effective-disabled])) .input-container{width:100%}:host([extended-prefix]:not(:focus-within)) .input-container,:host([extended-prefix][effective-disabled]) .input-container{width:0px}.input-container{line-height:var(--sd-input-line-height, 24px);flex:1 1 auto}.input{width:100%;background:var(--sd-input-background, transparent);font-family:inherit;font-size:inherit;text-align:inherit;color:inherit;border:none;outline:none;resize:none;padding-left:0;padding-right:0}.input:-webkit-autofill{animation-name:onautofillstart}.input:not(:-webkit-autofill){animation-name:onautofillcancel}@keyframes onautofillstart{0%{outline:none}}@keyframes onautofillcancel{0%{outline:none}}.label,input.input,.validation-message{text-overflow:ellipsis;overflow-x:hidden;white-space:nowrap}.input::placeholder{color:var(--sd-input-color, #767676)}.underline{height:2px;width:100%;position:relative}.unfocused-line,.focused-line{position:absolute;top:0;right:0;bottom:0;left:0}.unfocused-line{border-bottom:1px solid var(--sd-input-underline-color, #959595)}.focused-line{border-bottom:2px solid var(--sd-input-focused-color, #1467ba);transform-origin:center center;transform:scale3d(0,1,1)}.prefix,.suffix{display:flex;flex-wrap:nowrap;max-width:100%}.prefix ::slotted(*),.suffix ::slotted(*){display:flex}:host(:focus){outline:none}.suffix ::slotted(.clear-button),.suffix ::slotted(.toggle-button){cursor:pointer;width:16px;height:32px;padding:0 8px;margin-top:-8px;margin-bottom:-8px;fill:#666;outline:none;flex-shrink:0}.suffix ::slotted(.toggle-button){transition:transform .2s}:host([opened]) .suffix ::slotted(.toggle-button){transform:rotate(180deg)}:host([disabled]) .suffix ::slotted(.clear-button),:host([disabled]) .suffix ::slotted(.toggle-button){display:none!important}.prefix ::slotted(.icon-wrapper){width:32px;height:32px;padding-right:4px;margin-top:-8px;margin-bottom:-8px;display:flex;align-items:center;justify-content:center;flex-shrink:0}:host(:not([has-value])) .suffix ::slotted(.clear-button),:host([null-setting-disallowed]) .suffix ::slotted(.clear-button){display:none!important}:host(:not([allow-custom-value]):not([trigger-only])) .input{caret-color:transparent}:host(:not([allow-custom-value]):not([disabled])) .input{cursor:pointer}#default-slot{display:none}", C = `<svg xmlns="http://www.w3.org/2000/svg" class="toggle-button" slot="suffix" viewBox="0 0 16 16">\r
8
9
  <path d="M13 4v2l-5 5-5-5v-2l5 5z"/>\r
9
10
  </svg>\r
10
- `, V = `<svg xmlns="http://www.w3.org/2000/svg" class="clear-button" slot="suffix" viewBox="0 0 16 16">\r
11
+ `, B = `<svg xmlns="http://www.w3.org/2000/svg" class="clear-button" slot="suffix" viewBox="0 0 16 16">\r
11
12
  <path d="M12.96 4.46l-1.42-1.42-3.54 3.55-3.54-3.55-1.42 1.42 3.55 3.54-3.55 3.54 1.42 1.42 3.54-3.55 3.54 3.55 1.42-1.42-3.55-3.54 3.55-3.54z"/>\r
12
13
  </svg>\r
13
14
  `;
14
- var B = Object.defineProperty, P = Object.getOwnPropertyDescriptor, d = (h, t, e, i) => {
15
- for (var s = i > 1 ? void 0 : i ? P(t, e) : t, n = h.length - 1, l; n >= 0; n--)
16
- (l = h[n]) && (s = (i ? l(t, e, s) : l(s)) || s);
17
- return i && s && B(t, e, s), s;
15
+ var P = Object.defineProperty, S = Object.getOwnPropertyDescriptor, d = (h, t, e, i) => {
16
+ for (var s = i > 1 ? void 0 : i ? S(t, e) : t, n = h.length - 1, a; n >= 0; n--)
17
+ (a = h[n]) && (s = (i ? a(t, e, s) : a(s)) || s);
18
+ return i && s && P(t, e, s), s;
18
19
  };
19
20
  const D = "sd-combo-box";
20
21
  function f(h, t) {
@@ -23,11 +24,11 @@ function f(h, t) {
23
24
  e != null && clearTimeout(e), e = window.setTimeout(() => h(...i), t);
24
25
  };
25
26
  }
26
- let S = 0;
27
+ let L = 0;
27
28
  var o;
28
- const a = (o = class extends _ {
29
+ const l = (o = class extends _ {
29
30
  constructor() {
30
- super(), this.opened = !1, this.itemHeight = 50, this.displayValuePath = "caption", this.id = o.ID + "_" + S++, this.inMemoryFilter = (t, e) => {
31
+ super(), this.opened = !1, this.itemHeight = 50, this.displayValuePath = "caption", this.id = o.ID + "_" + L++, this.inMemoryFilter = (t, e) => {
31
32
  if (!t)
32
33
  return !0;
33
34
  const i = t.toLowerCase();
@@ -54,7 +55,7 @@ const a = (o = class extends _ {
54
55
  break;
55
56
  }
56
57
  case "Escape": {
57
- this.opened && (t.preventDefault(), t.stopPropagation(), this._list.selectedIndices.indexOf(this._list.focusIndex) > -1 && this._dataProvider.items.length > this._list.focusIndex ? this.opened = !1 : (this.clearFilter(), this.updateInputValue(null), this.updateFocusAndSelectedIndexFromValue(), this._list.selectedIndices.push(this._list.focusIndex)));
58
+ this.opened && (t.preventDefault(), t.stopPropagation(), this._list.selectedIndices.indexOf(this._list.focusIndex) > -1 && this._dataProvider.items.length > this._list.focusIndex ? this.opened = !1 : (this.clearFilter(), this.updateInputValue(null), this.updateFocusAndSelectedIndexFromValue(), this._list.selectedIndices.includes(this._list.focusIndex) || this._list.selectedIndices.push(this._list.focusIndex)));
58
59
  break;
59
60
  }
60
61
  case "Tab": {
@@ -106,7 +107,7 @@ const a = (o = class extends _ {
106
107
  return this._comboBoxValue;
107
108
  }
108
109
  set comboBoxValue(t) {
109
- this._comboBoxValue = t, this.updateInputValue(null);
110
+ this._comboBoxValue = t, this.updateInputValue(null), this.updateHasValue();
110
111
  }
111
112
  get selectedIndex() {
112
113
  return this.isCustomValue(this.comboBoxValue) || !this.comboBoxValue ? -1 : this.comboBoxValue.index;
@@ -120,7 +121,7 @@ const a = (o = class extends _ {
120
121
  static get styles() {
121
122
  return [
122
123
  g`
123
- ${v(I)}
124
+ ${x(V)}
124
125
  `
125
126
  ];
126
127
  }
@@ -128,7 +129,7 @@ const a = (o = class extends _ {
128
129
  super.disconnectedCallback(), this._popper && (this._popper.destroy(), this._popper = null);
129
130
  }
130
131
  render() {
131
- return x`
132
+ return b`
132
133
  ${super.render()}
133
134
  <slot @slotchange=${this.onDefaultSlotChange} id="default-slot"></slot>
134
135
  `;
@@ -152,7 +153,7 @@ const a = (o = class extends _ {
152
153
  }
153
154
  firstUpdated(t) {
154
155
  super.firstUpdated(t), this.value && !this.comboBoxValue && this.updateComboBoxValueFromValue(), window.requestAnimationFrame(() => {
155
- this.initClearButtton(), this.initToggleButtton(), this.addEventListener("click", () => {
156
+ this.initClearButtton(), this.initToggleButtton(), this.updateHasValue(), this.addEventListener("click", () => {
156
157
  this.disabled || (this.opened = !this.opened);
157
158
  }), this.addEventListener("keydown", (e) => {
158
159
  this.disabled || this.handleKeyDown(e);
@@ -161,16 +162,41 @@ const a = (o = class extends _ {
161
162
  }
162
163
  updateComboBoxValueFromValue() {
163
164
  if (this.value) {
164
- const t = this._itemCache.findIndex((e) => e[this.displayValuePath] === this.value);
165
- t > -1 ? this._comboBoxValue = { index: t, item: this._itemCache[t] } : this.allowCustomValue ? this._comboBoxValue = this.value : this._comboBoxValue = null;
165
+ const t = this._itemCache.findIndex(
166
+ (e) => (e[this.displayValuePath] ?? "") === this.value
167
+ );
168
+ t > -1 ? this._comboBoxValue = { index: t, item: this._itemCache[t] } : this.allowCustomValue ? this._comboBoxValue = this.value : this._comboBoxValue = null, this.updateHasValue(), this.updateIconFromCurrentValue();
166
169
  }
167
170
  }
168
171
  updated(t) {
169
- super.updated(t), t.has("currentText") ? this.currentText ? (this.setAttribute("has-value", ""), this._clearButton && (this._clearButton.style.display = "")) : this.removeAttribute("has-value") : t.has("triggerOnly") && this._list && (this._list.selectionType = this.triggerOnly ? u.TriggerOnly : u.Single);
172
+ super.updated(t), t.has("showIcon") && (this.showIcon ? this._icon == null && this.initIconWrapper() : this._icon != null && (this._icon.remove(), this._icon = null)), t.has("currentText") && this.updateHasValue(), t.has("triggerOnly") && this._list && (this._list.selectionType = this.triggerOnly ? u.TriggerOnly : u.Single);
173
+ }
174
+ initIconWrapper() {
175
+ this._icon = document.createElement("div"), this._icon.className = "icon-wrapper", this._icon.role = "img";
176
+ const t = document.createElement("div");
177
+ t.style.backgroundRepeat = "no-repeat", t.style.backgroundPosition = "center", t.style.backgroundSize = "cover", t.style.height = "24px", t.style.width = "24px", this._icon.appendChild(t), this._icon.slot = "prefix", this.appendChild(this._icon), this.updateIconFromCurrentValue();
178
+ }
179
+ updateIconFromCurrentValue() {
180
+ var t;
181
+ this.isCustomValue(this.comboBoxValue) ? this.updateIcon(null) : this.updateIcon((t = this.comboBoxValue) == null ? void 0 : t.item);
182
+ }
183
+ updateIcon(t) {
184
+ if (this._icon)
185
+ if (t && (t.icon || t.iconPlaceholder)) {
186
+ const e = t;
187
+ e.attributes == null ? (this._icon.title = "", this._icon.ariaLabel = "") : (this._icon.title = e.attributes["icon-attr-title"] ?? "", this._icon.ariaLabel = e.attributes["icon-attr-aria-label"] ?? ""), this._icon.style.backgroundColor = e.iconBackgroundColor, this._icon.style.display = "", I.showImage(this._icon.querySelector("div"), t.icon, t.iconPlaceholder);
188
+ } else
189
+ this._icon && (this._icon.style.display = "none");
190
+ }
191
+ updateHasValue() {
192
+ this.currentText || this.comboBoxValue != null && this.comboBoxValue != "" ? (this.setAttribute("has-value", ""), this._clearButton && (this._clearButton.style.display = "")) : this.removeAttribute("has-value");
193
+ }
194
+ shouldFloat() {
195
+ return super.shouldFloat() || this.comboBoxValue != null && this.comboBoxValue != "";
170
196
  }
171
197
  initClearButtton() {
172
198
  const t = document.createElement("template");
173
- t.innerHTML = V, this._clearButton = t.content.firstChild, this.appendChild(this._clearButton), this._clearButton.addEventListener("click", (e) => {
199
+ t.innerHTML = B, this._clearButton = t.content.firstChild, this.appendChild(this._clearButton), this._clearButton.addEventListener("click", (e) => {
174
200
  e.preventDefault(), e.stopPropagation(), this.opened = !1, this.clearValue();
175
201
  });
176
202
  }
@@ -184,7 +210,19 @@ const a = (o = class extends _ {
184
210
  if (this.isLazyLoadConfigured)
185
211
  return;
186
212
  let t = !1;
187
- this.filterText && (this.filterProperty ? (this._dataProvider.items = this._itemCache.filter((e) => e[this.filterProperty] && String(e[this.filterProperty]).indexOf(this.filterText) > -1), t = !0) : this.inMemoryFilter && (this._dataProvider.items = this._itemCache.filter((e) => this.inMemoryFilter(this.filterText, e)), t = !0)), t ? this._list.focusIndex = null : this._dataProvider.items = this._itemCache, this.opened && this._popper && this._popper.update();
213
+ if (this.filterText && (this.filterProperty ? (this._dataProvider.items = this._itemCache.filter((e) => e[this.filterProperty] && String(e[this.filterProperty]).indexOf(this.filterText) > -1), t = !0) : this.inMemoryFilter && (this._dataProvider.items = this._itemCache.filter((e) => this.inMemoryFilter(this.filterText, e)), t = !0)), !t)
214
+ this._dataProvider.items = this._itemCache, this._list && this.updateFocusAndSelectedIndexFromValue();
215
+ else if (this._list)
216
+ if (this.comboBoxValue && !this.isCustomValue(this.comboBoxValue)) {
217
+ let e = this._dataProvider.items.indexOf(this.comboBoxValue.item);
218
+ if (e == -1) {
219
+ const i = this.comboBoxValue.item.id;
220
+ i != null && (e = this._dataProvider.items.findIndex((s) => s.id == i));
221
+ }
222
+ this._list.focusIndex = e, this._list.selectedIndices = e == -1 ? [] : [e];
223
+ } else
224
+ this._list.focusIndex = null;
225
+ this.opened && this._popper && this._popper.update();
188
226
  }
189
227
  ensureListAndPopperInitialized() {
190
228
  if (this._list || (this._list = document.createElement(p.ID), this.updateListId(), this._list.classList.add("combo-box-dropdown"), this._list.itemHeight = this.itemHeight, this._list.itemGenerator = this.itemGenerator, this._list.selectionType = this.triggerOnly ? u.TriggerOnly : u.Single, this._list.setAttribute("focus-target", ""), Object.assign(this._list.style, {
@@ -196,7 +234,7 @@ const a = (o = class extends _ {
196
234
  overflowY: "auto"
197
235
  }), this._list.addEventListener("selection", this.handleSelection), this._dataProvider.connectList(this._list)), !this._popper) {
198
236
  const t = this;
199
- this._popper = b(this, this._list, {
237
+ this._popper = v(this, this._list, {
200
238
  placement: "bottom-start",
201
239
  modifiers: [
202
240
  {
@@ -247,7 +285,7 @@ const a = (o = class extends _ {
247
285
  if (this.inputElement.setAttribute("aria-expanded", String(this.opened)), this.opened) {
248
286
  if (!this.disabled) {
249
287
  this.ensureListAndPopperInitialized();
250
- const t = (this.filterText || "") !== (this._lastRequestedFilterText || "");
288
+ const t = (this.filterText ?? "") !== (this._lastRequestedFilterText ?? "");
251
289
  this.isLazyLoadConfigured && (this.items.length == 0 || t) && this.requestData(0, t), this.updateDropdownSizes(), this.ownerDocument.body.appendChild(this._list), this.updateFocusAndSelectedIndexFromValue(), window.requestAnimationFrame(() => {
252
290
  this._popper && this._popper.update();
253
291
  }), window.addEventListener("pointerdown", this.handleWindowPointerDown), !this.allowCustomValue && !this._openedByFilterTextChange && this.select();
@@ -257,27 +295,37 @@ const a = (o = class extends _ {
257
295
  await this._list.updateComplete, this._popper && await this._popper.update, this.ownerDocument.body.removeChild(this._list), window.removeEventListener("pointerdown", this.handleWindowPointerDown), this.updateValueOnClose(), this.clearFilter(), this.setSelectionRange(0, 0), this.inputElement.removeAttribute("aria-activedescendant"), this._popper && (this._popper.destroy(), this._popper = null);
258
296
  }
259
297
  updateValueOnClose() {
260
- const t = this.comboBoxValue || "";
298
+ var e;
299
+ const t = this.comboBoxValue ?? "";
261
300
  if (this.nullSettingDisallowed && !this.value && this.comboBoxValue)
262
301
  this.restorePreviousSelection();
263
- else if (this.value !== this.convertToDisplayValue(null)) {
264
- const e = this._dataProvider.items[this._list.focusIndex];
265
- if (e && e[this.displayValuePath] === this.value) {
266
- if (e.disabled) {
302
+ else if (this.value !== (this.convertToDisplayValue(null) ?? "")) {
303
+ const i = this._dataProvider.items[this._list.focusIndex];
304
+ if (i && (i[this.displayValuePath] ?? "") === this.value) {
305
+ if (i.disabled) {
267
306
  this.restorePreviousSelection();
268
307
  return;
269
308
  }
270
- this.comboBoxValue = { index: this._itemCache.indexOf(e), item: e };
309
+ this.comboBoxValue = { index: this._itemCache.indexOf(i), item: i };
271
310
  } else if (this.allowCustomValue || !this.value)
272
311
  this.comboBoxValue = this.value;
273
312
  else {
274
- const i = this._itemCache.findIndex(
275
- (s) => s[this.displayValuePath] === this.value && !s.disabled
313
+ const s = this._itemCache.findIndex(
314
+ (n) => (n[this.displayValuePath] ?? "") === this.value && !n.disabled
276
315
  );
277
- i > -1 ? this.comboBoxValue = { index: i, item: this._itemCache[i] } : this.restorePreviousSelection();
316
+ s > -1 ? this.comboBoxValue = { index: s, item: this._itemCache[s] } : this.restorePreviousSelection();
317
+ }
318
+ } else {
319
+ const i = this._dataProvider.items[this._list.focusIndex];
320
+ if (i && i.id != null) {
321
+ if (i.disabled) {
322
+ this.restorePreviousSelection();
323
+ return;
324
+ }
325
+ (!this.comboBoxValue || this.isCustomValue(this.comboBoxValue) || this.comboBoxValue.item.id != i.id) && (this.comboBoxValue = { index: this._itemCache.indexOf(i), item: i });
278
326
  }
279
327
  }
280
- t !== (this.comboBoxValue || "") && this.dispatchSelectionChangeEvent();
328
+ t !== (this.comboBoxValue ?? "") && this.dispatchSelectionChangeEvent(), this.updateIcon(this.isCustomValue(this.comboBoxValue) ? null : (e = this.comboBoxValue) == null ? void 0 : e.item);
281
329
  }
282
330
  restorePreviousSelection() {
283
331
  this.updateInputValue(null);
@@ -306,7 +354,7 @@ const a = (o = class extends _ {
306
354
  }
307
355
  updateInputValue(t) {
308
356
  this.updateComplete.then(() => {
309
- this.value = this.convertToDisplayValue(t);
357
+ this.value = this.convertToDisplayValue(t), t ? this.updateIcon(t) : this.updateIconFromCurrentValue();
310
358
  });
311
359
  }
312
360
  convertToDisplayValue(t) {
@@ -314,15 +362,15 @@ const a = (o = class extends _ {
314
362
  }
315
363
  fireValueChange(t) {
316
364
  if (t && this.filterText !== this.value) {
317
- const e = (this.filterText || "") !== this.value;
318
- this.filterText = this.value, this.opened || (this._openedByFilterTextChange = !0, this.opened = !0), e && (this.dispatchFilterChangeEvent(), this.debouncedFilterItemsInMemory());
365
+ const e = (this.filterText ?? "") !== this.value;
366
+ this.filterText = this.value, this.updateIcon(null), this.opened || (this._openedByFilterTextChange = !0, this.opened = !0), e && (this.dispatchFilterChangeEvent(), this.debouncedFilterItemsInMemory());
319
367
  }
320
368
  }
321
369
  clearValue() {
322
- this.nullSettingDisallowed || (this.value = null, this.inputElement.removeAttribute("aria-activedescendant"), this._list && (this._list.selectedIndices = []), this.clearFilter(), this.comboBoxValue && (this.comboBoxValue = null, this.dispatchSelectionChangeEvent()));
370
+ this.nullSettingDisallowed || (this.value = null, this.inputElement.removeAttribute("aria-activedescendant"), this._list && (this._list.selectedIndices = []), this.clearFilter(), this.comboBoxValue && (this.comboBoxValue = null, this.dispatchSelectionChangeEvent()), this.requestUpdate());
323
371
  }
324
372
  clearFilter() {
325
- this.filterText != null && (this.filterText = void 0, this.filterItemsInMemory(), this.dispatchFilterChangeEvent());
373
+ this.filterText != null && (this.filterText = void 0, this.filterItemsInMemory(), this.dispatchFilterChangeEvent(), this.updateIconFromCurrentValue());
326
374
  }
327
375
  updateDropdownSizes() {
328
376
  const e = ((window.innerHeight || document.documentElement.clientHeight) - this.offsetHeight) * 0.5;
@@ -352,7 +400,7 @@ const a = (o = class extends _ {
352
400
  this.comboBoxValue = null;
353
401
  else {
354
402
  const e = this.comboBoxValue;
355
- typeof e == "string" ? this.setFormValue(e) : this.setFormValue((t = e == null ? void 0 : e.item) == null ? void 0 : t.caption);
403
+ this.isCustomValue(e) ? this.setFormValue(e) : this.setFormValue((t = e == null ? void 0 : e.item) == null ? void 0 : t.caption);
356
404
  }
357
405
  }).catch((t) => {
358
406
  console.error("Could not dispatch selection change event due to:", t);
@@ -370,7 +418,7 @@ const a = (o = class extends _ {
370
418
  return !!this._onDataRequest;
371
419
  }
372
420
  requestData(t, e) {
373
- if (e == null && (e = (this.filterText || "") !== (this._lastRequestedFilterText || "")), this.isLazyLoadConfigured) {
421
+ if (e == null && (e = (this.filterText ?? "") !== (this._lastRequestedFilterText ?? "")), this.isLazyLoadConfigured) {
374
422
  if (!this.opened) {
375
423
  e && (this._dataProvider.items = [], this._itemCache = []);
376
424
  return;
@@ -386,12 +434,12 @@ const a = (o = class extends _ {
386
434
  if (this.comboBoxValue && !this.isCustomValue(this.comboBoxValue)) {
387
435
  const n = this.comboBoxValue.item;
388
436
  if (this._list.selectedIndices.length == 0 || this.items[this._list.selectedIndices[0]] != n) {
389
- let l = this.items.indexOf(n);
390
- if (l == -1) {
437
+ let a = this.items.indexOf(n);
438
+ if (a == -1) {
391
439
  const c = n.id;
392
- c != null && (l = this.items.findIndex((m) => m.id == c));
440
+ c != null && (a = this.items.findIndex((m) => m.id == c));
393
441
  }
394
- this.comboBoxValue.index = l, this._list.selectedIndices = l == -1 ? [] : [l];
442
+ this.comboBoxValue.index = a, this._list.selectedIndices = a == -1 ? [] : [a];
395
443
  }
396
444
  }
397
445
  this.updateDropdownSizes(), this._popper.update();
@@ -422,31 +470,34 @@ ${s}`
422
470
  }, o.formAssociated = !0, o.DATA_REQUEST_CANCELLED = "cancel_data_request", o);
423
471
  d([
424
472
  r({ type: Boolean, reflect: !0 })
425
- ], a.prototype, "opened", 2);
473
+ ], l.prototype, "opened", 2);
426
474
  d([
427
475
  r({ type: Number, attribute: "item-height" })
428
- ], a.prototype, "itemHeight", 2);
476
+ ], l.prototype, "itemHeight", 2);
429
477
  d([
430
478
  r({ type: Boolean, attribute: "allow-custom-value", reflect: !0 })
431
- ], a.prototype, "allowCustomValue", 2);
479
+ ], l.prototype, "allowCustomValue", 2);
432
480
  d([
433
481
  r({ type: Boolean, attribute: "trigger-only", reflect: !0 })
434
- ], a.prototype, "triggerOnly", 2);
482
+ ], l.prototype, "triggerOnly", 2);
435
483
  d([
436
484
  r({ type: Boolean, attribute: "null-setting-disallowed", reflect: !0 })
437
- ], a.prototype, "nullSettingDisallowed", 2);
485
+ ], l.prototype, "nullSettingDisallowed", 2);
486
+ d([
487
+ r({ type: Boolean, attribute: "show-icon", reflect: !0 })
488
+ ], l.prototype, "showIcon", 2);
438
489
  d([
439
490
  r({ type: String, attribute: "display-value-path", noAccessor: !0 })
440
- ], a.prototype, "displayValuePath", 2);
491
+ ], l.prototype, "displayValuePath", 2);
441
492
  d([
442
493
  r({ type: String, attribute: "filter-property", noAccessor: !0 })
443
- ], a.prototype, "filterProperty", 2);
494
+ ], l.prototype, "filterProperty", 2);
444
495
  d([
445
496
  r({ type: String, attribute: !0, reflect: !0 })
446
- ], a.prototype, "id", 2);
447
- let L = a;
448
- L.ensureDefined();
497
+ ], l.prototype, "id", 2);
498
+ let E = l;
499
+ E.ensureDefined();
449
500
  export {
450
- L as default
501
+ E as default
451
502
  };
452
503
  //# sourceMappingURL=combo-box.mjs.map