dap-design-system 0.38.21 → 0.38.23

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.
package/dist/dds.d.ts CHANGED
@@ -760,10 +760,20 @@ declare class ComboboxBaseElement extends GenericFormElement {
760
760
  selectedItem: any;
761
761
  currentItem: any;
762
762
  selectedText: string;
763
+ private optionListObserver;
763
764
  static readonly styles: CSSResult;
764
765
  protected firstUpdated(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): Promise<void>;
766
+ private setupOptionListObserver;
767
+ private updateComboboxState;
768
+ private cleanupOptionListObserver;
769
+ disconnectedCallback(): void;
765
770
  attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
766
771
  get isAutoComplete(): boolean;
772
+ /**
773
+ * Get all option items directly from the combobox element
774
+ * This is more reliable for dynamic updates than the option list component
775
+ */
776
+ private getComboboxOptions;
767
777
  get isOpenOnEmpty(): boolean;
768
778
  get isOpenOnAutocomplete(): boolean;
769
779
  get shouldHideClearIcon(): boolean;
@@ -775,7 +785,7 @@ declare class ComboboxBaseElement extends GenericFormElement {
775
785
  private handleSelectedItemChange;
776
786
  private handleTextSearch;
777
787
  private handleArrowKeys;
778
- handleKeyDown: (event: KeyboardEvent) => Promise<void | 0>;
788
+ handleKeyDown: (event: KeyboardEvent) => Promise<false | void | 0>;
779
789
  handleInput: (event: InputEvent) => Promise<void>;
780
790
  clearSelection(): Promise<void>;
781
791
  handleListKeyDown: (event: CustomEvent) => void;
package/dist/dds.js CHANGED
@@ -6359,11 +6359,10 @@ var Rv = Object.defineProperty, mt = (t, e, i, o) => {
6359
6359
  };
6360
6360
  const Tn = class Tn extends ve {
6361
6361
  constructor() {
6362
- super(...arguments), this.placement = "bottom-start", this.opened = !1, this.searchMode = "autocomplete", this.search = !1, this.clearButton = "true", this.allowManualInput = !1, this.searchForText = !1, this.searchOnValueSet = "false", this.loading = !1, this.selectable = "true", this.noAnimation = !1, this.textComplete = !1, this.openOnEmpty = !1, this.handleClick = () => {
6363
- var e;
6364
- !((e = this.optionList) != null && e.getAllOptions().length) && !this.openOnEmpty ? this.hideDropDown() : this.opened ? this.hideDropDown() : this.showDropDown();
6362
+ super(...arguments), this.placement = "bottom-start", this.opened = !1, this.searchMode = "autocomplete", this.search = !1, this.clearButton = "true", this.allowManualInput = !1, this.searchForText = !1, this.searchOnValueSet = "false", this.loading = !1, this.selectable = "true", this.noAnimation = !1, this.textComplete = !1, this.openOnEmpty = !1, this.optionListObserver = null, this.handleClick = () => {
6363
+ !this.getComboboxOptions().length && !this.openOnEmpty ? this.hideDropDown() : this.opened ? this.hideDropDown() : this.showDropDown();
6365
6364
  }, this.handleKeyDown = (e) => V(this, null, function* () {
6366
- var i, o;
6365
+ var i;
6367
6366
  if (e.key !== "Tab") {
6368
6367
  if (e.key === "Enter")
6369
6368
  return this.handleEnterKey(e);
@@ -6371,12 +6370,17 @@ const Tn = class Tn extends ve {
6371
6370
  return this.hideDropDown(), this.focus();
6372
6371
  if ((e.key === "ArrowDown" || e.key === "ArrowUp" || e.key === "ArrowLeft" || e.key === "ArrowRight") && this.isAutoComplete)
6373
6372
  return this.handleArrowKeys(e);
6374
- yield this.updateComplete, yield (i = this.optionList) == null ? void 0 : i.updateComplete, (this.openOnEmpty || (o = this.optionList) != null && o.getAllOptions().length) && this.showDropDown();
6373
+ if (this.isAutoComplete && ((i = this.triggerInput) != null && i.value) && !this.opened) {
6374
+ const o = this.getComboboxOptions().length > 0;
6375
+ (this.openOnEmpty || o) && this.showDropDown();
6376
+ }
6375
6377
  }
6376
6378
  }), this.handleInput = (e) => V(this, null, function* () {
6377
- var o, r;
6378
6379
  const i = this.triggerInput;
6379
- e.inputType !== "deleteContentBackward" || e.inputType === "deleteContentBackward" && this.allowManualInput ? (this.selectedText = i.value, this.search && (this.value = i.value)) : this.search ? (this.selectedText = i.value, this.value = i.value) : i.value === "" && e.inputType === "deleteContentBackward" && this.clearSelection(), this.emit("dds-input", { input: i.value, originalEvent: e }), this.setValidity(), this.requestUpdate(), yield this.updateComplete, yield (o = this.optionList) == null ? void 0 : o.updateComplete, !this.openOnEmpty && !((r = this.optionList) != null && r.getAllOptions().length) && this.hideDropDown();
6380
+ if (e.inputType !== "deleteContentBackward" || e.inputType === "deleteContentBackward" && this.allowManualInput ? (this.selectedText = i.value, this.search && (this.value = i.value)) : this.search ? (this.selectedText = i.value, this.value = i.value) : i.value === "" && e.inputType === "deleteContentBackward" && this.clearSelection(), this.emit("dds-input", { input: i.value, originalEvent: e }), this.setValidity(), this.requestUpdate(), this.isAutoComplete && i.value && !this.opened) {
6381
+ const o = this.getComboboxOptions().length > 0;
6382
+ (this.openOnEmpty || o) && this.showDropDown();
6383
+ }
6380
6384
  }), this.handleListKeyDown = (e) => {
6381
6385
  e.detail.key === "Escape" && (this.hideDropDown(), this.currentItem = this.selectedItem, this.selectedText = "", this.triggerInput.value = this.selectedItem.text, this.triggerInput.focus());
6382
6386
  }, this.handleDocumentMouseDown = (e) => {
@@ -6405,18 +6409,55 @@ const Tn = class Tn extends ve {
6405
6409
  firstUpdated(e) {
6406
6410
  return V(this, null, function* () {
6407
6411
  var i, o;
6408
- qt(Tn.prototype, this, "firstUpdated").call(this, e), yield this.optionList.updateComplete, this.value && (this.selectedItem = (i = this.optionList) == null ? void 0 : i.getAllOptions().find((r) => r.value === this.value), this.selectedText = ((o = this.selectedItem) == null ? void 0 : o.optionText) || "", !this.selectedText && (this.allowManualInput || this.searchMode === "none") && (this.selectedText = this.value));
6412
+ qt(Tn.prototype, this, "firstUpdated").call(this, e), yield this.optionList.updateComplete, this.value && (this.selectedItem = (i = this.optionList) == null ? void 0 : i.getAllOptions().find((r) => r.value === this.value), this.selectedText = ((o = this.selectedItem) == null ? void 0 : o.optionText) || "", !this.selectedText && (this.allowManualInput || this.searchMode === "none") && (this.selectedText = this.value)), this.setupOptionListObserver();
6413
+ });
6414
+ }
6415
+ setupOptionListObserver() {
6416
+ this.optionList && (this.optionListObserver && this.optionListObserver.disconnect(), this.optionListObserver = new MutationObserver((e) => {
6417
+ let i = !1;
6418
+ e.forEach((o) => {
6419
+ if (o.type === "childList") {
6420
+ const r = Array.from(o.addedNodes).some(
6421
+ (s) => s.nodeName === "DAP-DS-OPTION-ITEM"
6422
+ ), a = Array.from(o.removedNodes).some(
6423
+ (s) => s.nodeName === "DAP-DS-OPTION-ITEM"
6424
+ );
6425
+ (r || a) && (i = !0);
6426
+ }
6427
+ }), i && this.updateComboboxState();
6428
+ }), this.optionListObserver.observe(this, {
6429
+ childList: !0,
6430
+ subtree: !0
6431
+ }));
6432
+ }
6433
+ updateComboboxState() {
6434
+ requestAnimationFrame(() => {
6435
+ var o;
6436
+ const e = this.getComboboxOptions().length > 0, i = ((o = this.triggerInput) == null ? void 0 : o.value) && this.triggerInput.value.trim() !== "";
6437
+ e && i && this.isAutoComplete ? this.opened || this.showDropDown() : !e && !this.openOnEmpty && i && this.hideDropDown();
6409
6438
  });
6410
6439
  }
6440
+ cleanupOptionListObserver() {
6441
+ this.optionListObserver && (this.optionListObserver.disconnect(), this.optionListObserver = null);
6442
+ }
6443
+ disconnectedCallback() {
6444
+ super.disconnectedCallback(), this.cleanupOptionListObserver();
6445
+ }
6411
6446
  attributeChangedCallback(e, i, o) {
6412
6447
  e === "value" && !o && this.clearSelection(), super.attributeChangedCallback(e, i, o);
6413
6448
  }
6414
6449
  get isAutoComplete() {
6415
6450
  return this.searchMode === "autocomplete" || this.searchMode === "manual";
6416
6451
  }
6452
+ /**
6453
+ * Get all option items directly from the combobox element
6454
+ * This is more reliable for dynamic updates than the option list component
6455
+ */
6456
+ getComboboxOptions() {
6457
+ return Array.from(this.querySelectorAll("dap-ds-option-item"));
6458
+ }
6417
6459
  get isOpenOnEmpty() {
6418
- var e;
6419
- return this.openOnEmpty || !this.openOnEmpty && ((e = this.optionList) == null ? void 0 : e.getAllOptions().length) > 0;
6460
+ return this.openOnEmpty || !this.openOnEmpty && this.getComboboxOptions().length > 0;
6420
6461
  }
6421
6462
  get isOpenOnAutocomplete() {
6422
6463
  return this.isAutoComplete && this.isOpenOnEmpty;
@@ -6448,8 +6489,7 @@ const Tn = class Tn extends ve {
6448
6489
  }
6449
6490
  handleDefaultEnter() {
6450
6491
  return V(this, null, function* () {
6451
- var e;
6452
- return this.opened ? this.hideDropDown() : (this.openOnEmpty || ((e = this.optionList) == null ? void 0 : e.getAllOptions().length)) && this.showDropDown();
6492
+ return this.opened ? this.hideDropDown() : (this.openOnEmpty || this.getComboboxOptions().length || this.isAutoComplete) && this.showDropDown();
6453
6493
  });
6454
6494
  }
6455
6495
  handleSelectedItemChange(e) {
@@ -6464,9 +6504,8 @@ const Tn = class Tn extends ve {
6464
6504
  }
6465
6505
  handleArrowKeys(e) {
6466
6506
  return V(this, null, function* () {
6467
- var i;
6468
6507
  if (e.preventDefault(), !this.opened)
6469
- if (this.openOnEmpty || (i = this.optionList) != null && i.getAllOptions().length)
6508
+ if (this.openOnEmpty || this.getComboboxOptions().length || this.isAutoComplete)
6470
6509
  this.showDropDown();
6471
6510
  else
6472
6511
  return;
@@ -6480,8 +6519,7 @@ const Tn = class Tn extends ve {
6480
6519
  }
6481
6520
  showDropDown() {
6482
6521
  return V(this, null, function* () {
6483
- var e;
6484
- this.disabled || this.readonly || !this.isAutoComplete || this.opened || !this.openOnEmpty && !((e = this.optionList) != null && e.getAllOptions().length) || (this.opened = !0, document.addEventListener("mousedown", this.handleDocumentMouseDown));
6522
+ this.disabled || this.readonly || !this.isAutoComplete || this.opened || !this.openOnEmpty && !this.getComboboxOptions().length && !this.isAutoComplete || (this.opened = !0, document.addEventListener("mousedown", this.handleDocumentMouseDown));
6485
6523
  });
6486
6524
  }
6487
6525
  hideDropDown() {
@@ -13109,22 +13147,30 @@ const xl = class xl extends $ {
13109
13147
  super.updated(e), e.has("open") && e.get("open") !== void 0 && (this.open ? this.handleOpen() : this.handleCloseAction());
13110
13148
  }
13111
13149
  handleOpen() {
13112
- this.emit("dds-before-open"), this.scrollLock(!0), this.previouslyFocusedElement = this.getActiveElement(), this.dialog.showModal(), this.dialog.addEventListener(
13150
+ this.emit("dds-before-open", void 0, {
13151
+ cancelable: !0
13152
+ }).defaultPrevented || (this.scrollLock(!0), this.previouslyFocusedElement = this.getActiveElement(), this.dialog.showModal(), this.dialog.addEventListener(
13113
13153
  "transitionend",
13114
13154
  () => {
13115
- this.emit("dds-opened"), this.focusableElements = this.getFocusableElements(), this.focusableElements.length > 0 && this.focusableElements[0].focus();
13155
+ this.emit("dds-opened", void 0, {
13156
+ cancelable: !0
13157
+ }).defaultPrevented || (this.focusableElements = this.getFocusableElements(), this.focusableElements.length > 0 && this.focusableElements[0].focus());
13116
13158
  },
13117
13159
  { once: !0 }
13118
- ), this.setAttribute("aria-hidden", "false");
13160
+ ), this.setAttribute("aria-hidden", "false"));
13119
13161
  }
13120
13162
  handleCloseAction() {
13121
- this.emit("dds-before-close"), this.dialog.close(), this.scrollLock(!1), this.dialog.addEventListener(
13163
+ this.emit("dds-before-close", void 0, {
13164
+ cancelable: !0
13165
+ }).defaultPrevented || (this.dialog.close(), this.scrollLock(!1), this.dialog.addEventListener(
13122
13166
  "transitionend",
13123
13167
  () => {
13124
- this.emit("dds-closed"), this.previouslyFocusedElement instanceof HTMLElement && this.previouslyFocusedElement.focus();
13168
+ this.emit("dds-closed", void 0, {
13169
+ cancelable: !0
13170
+ }).defaultPrevented || this.previouslyFocusedElement instanceof HTMLElement && this.previouslyFocusedElement.focus();
13125
13171
  },
13126
13172
  { once: !0 }
13127
- ), this.setAttribute("aria-hidden", "true");
13173
+ ), this.setAttribute("aria-hidden", "true"));
13128
13174
  }
13129
13175
  firstUpdated(e) {
13130
13176
  super.firstUpdated(e), this.open ? (this.setAttribute("aria-hidden", "false"), this.dialog.showModal()) : this.setAttribute("aria-hidden", "true");
@@ -13147,20 +13193,40 @@ const xl = class xl extends $ {
13147
13193
  ).defaultPrevented || this.hide();
13148
13194
  }
13149
13195
  handleCancel(e) {
13150
- this.closeOnEsc !== "true" && (e.preventDefault(), this.canceled = !0);
13196
+ if (this.closeOnEsc !== "true") {
13197
+ e.preventDefault(), this.canceled = !0;
13198
+ return;
13199
+ }
13200
+ e.preventDefault();
13151
13201
  }
13152
13202
  handleEscClose(e) {
13153
- if (this.canceled) {
13203
+ if (this.canceled || this.closeOnEsc !== "true") {
13154
13204
  e.preventDefault();
13155
13205
  return;
13156
13206
  }
13157
- this.open && this.handleClose("esc");
13207
+ e.preventDefault();
13158
13208
  }
13159
13209
  handleOkButton() {
13160
- this.emit("dds-ok"), this.handleClose("ok-button");
13210
+ this.emit(
13211
+ "dds-ok",
13212
+ {
13213
+ source: "ok-button"
13214
+ },
13215
+ {
13216
+ cancelable: !0
13217
+ }
13218
+ ).defaultPrevented || this.handleClose("ok-button");
13161
13219
  }
13162
13220
  handleCancelButton() {
13163
- this.emit("dds-cancel"), this.handleClose("cancel-button");
13221
+ this.emit(
13222
+ "dds-cancel",
13223
+ {
13224
+ source: "cancel-button"
13225
+ },
13226
+ {
13227
+ cancelable: !0
13228
+ }
13229
+ ).defaultPrevented || this.handleClose("cancel-button");
13164
13230
  }
13165
13231
  handleClick(e) {
13166
13232
  this.closeOnOverlayClick === "true" && e.target === this.dialog && this.handleClose("overlay");
@@ -13170,7 +13236,7 @@ const xl = class xl extends $ {
13170
13236
  this.handleFocusTrap(e);
13171
13237
  return;
13172
13238
  }
13173
- this.closeOnEsc === "true" && e.key === "Escape" ? this.handleClose("esc") : e.key === "Escape" && (e.preventDefault(), e.stopImmediatePropagation());
13239
+ e.key === "Escape" && (this.closeOnEsc === "true" ? this.handleClose("esc") : (e.preventDefault(), e.stopImmediatePropagation()));
13174
13240
  }
13175
13241
  getFocusableElements() {
13176
13242
  const e = [