@ni/nimble-components 21.6.2 → 21.6.4

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