@ni/nimble-components 21.6.2 → 21.6.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.
@@ -16301,7 +16301,7 @@
16301
16301
 
16302
16302
  /**
16303
16303
  * Do not edit directly
16304
- * Generated on Thu, 22 Feb 2024 00:57:15 GMT
16304
+ * Generated on Thu, 22 Feb 2024 19:25:27 GMT
16305
16305
  */
16306
16306
 
16307
16307
  const Information100DarkUi = "#a46eff";
@@ -21310,6 +21310,10 @@
21310
21310
  display: flex;
21311
21311
  }
21312
21312
 
21313
+ dialog${focusVisible} {
21314
+ outline: 2px solid ${borderHoverColor};
21315
+ }
21316
+
21313
21317
  header {
21314
21318
  min-height: 48px;
21315
21319
  padding: 24px 24px 0px 24px;
@@ -21401,6 +21405,7 @@
21401
21405
  role="dialog"
21402
21406
  part="control"
21403
21407
  @cancel="${(x, c) => x.cancelHandler(c.event)}"
21408
+ @close="${x => x.closeHandler()}"
21404
21409
  aria-labelledby="header"
21405
21410
  >
21406
21411
  <header id="header">
@@ -21480,8 +21485,7 @@
21480
21485
  throw new Error('Dialog is not open');
21481
21486
  }
21482
21487
  this.dialogElement.close();
21483
- this.resolveShow(reason);
21484
- this.resolveShow = undefined;
21488
+ this.doResolveShow(reason);
21485
21489
  }
21486
21490
  slottedFooterElementsChanged(_prev, next) {
21487
21491
  this.footerIsEmpty = !next?.length;
@@ -21494,11 +21498,29 @@
21494
21498
  event.preventDefault();
21495
21499
  }
21496
21500
  else {
21497
- this.resolveShow(UserDismissed);
21498
- this.resolveShow = undefined;
21501
+ this.doResolveShow(UserDismissed);
21499
21502
  }
21500
21503
  return true;
21501
21504
  }
21505
+ /**
21506
+ * @internal
21507
+ */
21508
+ closeHandler() {
21509
+ if (this.resolveShow) {
21510
+ // If
21511
+ // - the browser implements dialogs with the CloseWatcher API, and
21512
+ // - the user presses ESC without first interacting with the dialog (e.g. clicking, scrolling),
21513
+ // the cancel event is not fired, but the close event still is, and the dialog just closes.
21514
+ this.doResolveShow(UserDismissed);
21515
+ }
21516
+ }
21517
+ doResolveShow(reason) {
21518
+ if (!this.resolveShow) {
21519
+ throw new Error('Do not call doResolveShow unless there is a promise to resolve');
21520
+ }
21521
+ this.resolveShow(reason);
21522
+ this.resolveShow = undefined;
21523
+ }
21502
21524
  }
21503
21525
  // We want the member to match the name of the constant
21504
21526
  // eslint-disable-next-line @typescript-eslint/naming-convention
@@ -21685,6 +21707,7 @@
21685
21707
  ${ref('dialog')}
21686
21708
  aria-label="${x => x.ariaLabel}"
21687
21709
  @cancel="${(x, c) => x.cancelHandler(c.event)}"
21710
+ @close="${x => x.closeHandler()}"
21688
21711
  >
21689
21712
  <div class="dialog-contents">
21690
21713
  <slot></slot>
@@ -21755,6 +21778,26 @@
21755
21778
  }
21756
21779
  return true;
21757
21780
  }
21781
+ /**
21782
+ * @internal
21783
+ */
21784
+ closeHandler() {
21785
+ if (this.resolveShow) {
21786
+ // If
21787
+ // - the browser implements dialogs with the CloseWatcher API, and
21788
+ // - the user presses ESC without first interacting with the drawer (e.g. clicking, scrolling),
21789
+ // the cancel event is not fired, but the close event still is, and the drawer just closes.
21790
+ // The animation is never started, so there is no animation end listener to clean up.
21791
+ this.doResolveShow(UserDismissed);
21792
+ }
21793
+ }
21794
+ doResolveShow(reason) {
21795
+ if (!this.resolveShow) {
21796
+ throw new Error('Do not call doResolveShow unless there is a promise to resolve');
21797
+ }
21798
+ this.resolveShow(reason);
21799
+ this.resolveShow = undefined;
21800
+ }
21758
21801
  openDialog() {
21759
21802
  this.dialog.showModal();
21760
21803
  this.triggerAnimation();
@@ -21777,8 +21820,7 @@
21777
21820
  this.dialog.classList.remove('closing');
21778
21821
  this.dialog.close();
21779
21822
  this.closing = false;
21780
- this.resolveShow(this.closeReason);
21781
- this.resolveShow = undefined;
21823
+ this.doResolveShow(this.closeReason);
21782
21824
  }
21783
21825
  }
21784
21826
  }