@ni/nimble-components 11.8.5 → 11.9.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.
@@ -9518,7 +9518,7 @@
9518
9518
  *
9519
9519
  * @public
9520
9520
  */
9521
- class Dialog extends FoundationElement {
9521
+ class Dialog$1 extends FoundationElement {
9522
9522
  constructor() {
9523
9523
  super(...arguments);
9524
9524
  /**
@@ -9602,7 +9602,7 @@
9602
9602
  };
9603
9603
  this.getTabQueueBounds = () => {
9604
9604
  const bounds = [];
9605
- return Dialog.reduceTabbableItems(bounds, this);
9605
+ return Dialog$1.reduceTabbableItems(bounds, this);
9606
9606
  };
9607
9607
  /**
9608
9608
  * focus on first element of tab queue
@@ -9726,12 +9726,12 @@
9726
9726
  return elements;
9727
9727
  }
9728
9728
  if (isTabbable(element) ||
9729
- (Dialog.isFocusableFastElement(element) && Dialog.hasTabbableShadow(element))) {
9729
+ (Dialog$1.isFocusableFastElement(element) && Dialog$1.hasTabbableShadow(element))) {
9730
9730
  elements.push(element);
9731
9731
  return elements;
9732
9732
  }
9733
9733
  if (element.childElementCount) {
9734
- return elements.concat(Array.from(element.children).reduce(Dialog.reduceTabbableItems, []));
9734
+ return elements.concat(Array.from(element.children).reduce(Dialog$1.reduceTabbableItems, []));
9735
9735
  }
9736
9736
  return elements;
9737
9737
  }
@@ -9762,22 +9762,22 @@
9762
9762
  }
9763
9763
  __decorate$1([
9764
9764
  attr({ mode: "boolean" })
9765
- ], Dialog.prototype, "modal", void 0);
9765
+ ], Dialog$1.prototype, "modal", void 0);
9766
9766
  __decorate$1([
9767
9767
  attr({ mode: "boolean" })
9768
- ], Dialog.prototype, "hidden", void 0);
9768
+ ], Dialog$1.prototype, "hidden", void 0);
9769
9769
  __decorate$1([
9770
9770
  attr({ attribute: "trap-focus", mode: "boolean" })
9771
- ], Dialog.prototype, "trapFocus", void 0);
9771
+ ], Dialog$1.prototype, "trapFocus", void 0);
9772
9772
  __decorate$1([
9773
9773
  attr({ attribute: "aria-describedby" })
9774
- ], Dialog.prototype, "ariaDescribedby", void 0);
9774
+ ], Dialog$1.prototype, "ariaDescribedby", void 0);
9775
9775
  __decorate$1([
9776
9776
  attr({ attribute: "aria-labelledby" })
9777
- ], Dialog.prototype, "ariaLabelledby", void 0);
9777
+ ], Dialog$1.prototype, "ariaLabelledby", void 0);
9778
9778
  __decorate$1([
9779
9779
  attr({ attribute: "aria-label" })
9780
- ], Dialog.prototype, "ariaLabel", void 0);
9780
+ ], Dialog$1.prototype, "ariaLabel", void 0);
9781
9781
 
9782
9782
  /**
9783
9783
  * The template for the {@link @microsoft/fast-foundation#(ListboxOption:class)} component.
@@ -14250,7 +14250,7 @@
14250
14250
  */
14251
14251
  const focusVisible$1 = canUseFocusVisible() ? "focus-visible" : "focus";
14252
14252
 
14253
- const styles$u = css `
14253
+ const styles$v = css `
14254
14254
  :host {
14255
14255
  contain: layout;
14256
14256
  display: block;
@@ -14274,7 +14274,7 @@
14274
14274
  baseName: 'anchored-region',
14275
14275
  baseClass: AnchoredRegion$1,
14276
14276
  template: anchoredRegionTemplate,
14277
- styles: styles$u
14277
+ styles: styles$v
14278
14278
  });
14279
14279
  DesignSystem.getOrCreate()
14280
14280
  .withPrefix('nimble')
@@ -14616,9 +14616,9 @@
14616
14616
  return c > 3 && r && Object.defineProperty(target, key, r), r;
14617
14617
  }
14618
14618
 
14619
- const template$6 = html `<slot></slot>`;
14619
+ const template$7 = html `<slot></slot>`;
14620
14620
 
14621
- const styles$t = css `
14621
+ const styles$u = css `
14622
14622
  :host {
14623
14623
  display: contents;
14624
14624
  }
@@ -14674,8 +14674,8 @@
14674
14674
  ], ThemeProvider.prototype, "theme", void 0);
14675
14675
  const nimbleDesignSystemProvider = ThemeProvider.compose({
14676
14676
  baseName: 'theme-provider',
14677
- styles: styles$t,
14678
- template: template$6
14677
+ styles: styles$u,
14678
+ template: template$7
14679
14679
  });
14680
14680
  DesignSystem.getOrCreate()
14681
14681
  .withPrefix('nimble')
@@ -14898,7 +14898,7 @@
14898
14898
  */
14899
14899
  const themeBehavior = (theme, styles) => new ThemeStyleSheetBehavior(theme, styles);
14900
14900
 
14901
- const styles$s = css `
14901
+ const styles$t = css `
14902
14902
  ${display('inline-block')}
14903
14903
 
14904
14904
  :host {
@@ -14958,7 +14958,7 @@
14958
14958
  baseName: 'breadcrumb',
14959
14959
  baseClass: Breadcrumb$1,
14960
14960
  template: breadcrumbTemplate,
14961
- styles: styles$s
14961
+ styles: styles$t
14962
14962
  });
14963
14963
  DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleBreadcrumb());
14964
14964
 
@@ -15544,7 +15544,7 @@
15544
15544
  */
15545
15545
  const focusVisible = `:${focusVisible$1}`;
15546
15546
 
15547
- const styles$r = css `
15547
+ const styles$s = css `
15548
15548
  ${display('inline-flex')}
15549
15549
 
15550
15550
  :host {
@@ -15624,7 +15624,7 @@
15624
15624
  baseName: 'breadcrumb-item',
15625
15625
  baseClass: BreadcrumbItem$1,
15626
15626
  template: breadcrumbItemTemplate,
15627
- styles: styles$r,
15627
+ styles: styles$s,
15628
15628
  separator: forwardSlash16X16.data
15629
15629
  });
15630
15630
  DesignSystem.getOrCreate()
@@ -15709,7 +15709,7 @@
15709
15709
  block: 'block'
15710
15710
  };
15711
15711
 
15712
- const styles$q = css `
15712
+ const styles$r = css `
15713
15713
  ${display('inline-flex')}
15714
15714
 
15715
15715
  :host {
@@ -15916,7 +15916,7 @@
15916
15916
  `));
15917
15917
 
15918
15918
  // prettier-ignore
15919
- const styles$p = styles$q
15919
+ const styles$q = styles$r
15920
15920
  .withBehaviors(appearanceBehavior(ButtonAppearance.outline, css `
15921
15921
  :host(.primary) .control {
15922
15922
  box-shadow: 0px 0px 0px ${borderWidth} rgba(${actionRgbPartialColor}, 0.3) inset;
@@ -16030,7 +16030,7 @@
16030
16030
  baseName: 'button',
16031
16031
  baseClass: Button$1,
16032
16032
  template: buttonTemplate,
16033
- styles: styles$p,
16033
+ styles: styles$q,
16034
16034
  shadowOptions: {
16035
16035
  delegatesFocus: true
16036
16036
  }
@@ -16038,7 +16038,7 @@
16038
16038
  DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleButton());
16039
16039
 
16040
16040
  // prettier-ignore
16041
- const styles$o = css `
16041
+ const styles$p = css `
16042
16042
  ${display('inline-flex')}
16043
16043
 
16044
16044
  :host {
@@ -16201,14 +16201,14 @@
16201
16201
  const nimbleCardButton = CardButton.compose({
16202
16202
  baseName: 'card-button',
16203
16203
  template: buttonTemplate,
16204
- styles: styles$o,
16204
+ styles: styles$p,
16205
16205
  shadowOptions: {
16206
16206
  delegatesFocus: true
16207
16207
  }
16208
16208
  });
16209
16209
  DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleCardButton());
16210
16210
 
16211
- const styles$n = css `
16211
+ const styles$o = css `
16212
16212
  ${display('inline-flex')}
16213
16213
 
16214
16214
  :host {
@@ -16326,7 +16326,7 @@
16326
16326
  baseName: 'checkbox',
16327
16327
  baseClass: Checkbox$1,
16328
16328
  template: checkboxTemplate,
16329
- styles: styles$n,
16329
+ styles: styles$o,
16330
16330
  checkedIndicator: check16X16.data,
16331
16331
  indeterminateIndicator: minus16X16.data
16332
16332
  });
@@ -16338,13 +16338,13 @@
16338
16338
  </div>
16339
16339
  `;
16340
16340
 
16341
- const template$5 = html `
16341
+ const template$6 = html `
16342
16342
  <template>
16343
16343
  <div class="icon" :innerHTML=${x => x.icon.data}></div>
16344
16344
  </template
16345
16345
  `;
16346
16346
 
16347
- const styles$m = css `
16347
+ const styles$n = css `
16348
16348
  ${display('inline-flex')}
16349
16349
 
16350
16350
  :host {
@@ -16394,8 +16394,8 @@
16394
16394
  const registerIcon = (baseName, iconClass) => {
16395
16395
  const composedIcon = iconClass.compose({
16396
16396
  baseName,
16397
- template: template$5,
16398
- styles: styles$m,
16397
+ template: template$6,
16398
+ styles: styles$n,
16399
16399
  baseClass: iconClass
16400
16400
  });
16401
16401
  DesignSystem.getOrCreate().withPrefix('nimble').register(composedIcon());
@@ -16423,7 +16423,7 @@
16423
16423
  }
16424
16424
  registerIcon('icon-arrow-expander-down', IconArrowExpanderDown);
16425
16425
 
16426
- const styles$l = css `
16426
+ const styles$m = css `
16427
16427
  ${display('inline-flex')}
16428
16428
 
16429
16429
  :host {
@@ -16609,7 +16609,7 @@
16609
16609
  }
16610
16610
  `;
16611
16611
 
16612
- const styles$k = css `
16612
+ const styles$l = css `
16613
16613
  .error-icon {
16614
16614
  display: none;
16615
16615
  }
@@ -16647,9 +16647,9 @@
16647
16647
  }
16648
16648
  `;
16649
16649
 
16650
- const styles$j = css `
16650
+ const styles$k = css `
16651
+ ${styles$m}
16651
16652
  ${styles$l}
16652
- ${styles$k}
16653
16653
 
16654
16654
  :host {
16655
16655
  --ni-private-hover-bottom-border-width: 2px;
@@ -16881,7 +16881,7 @@
16881
16881
  baseName: 'combobox',
16882
16882
  baseClass: Combobox$1,
16883
16883
  template: comboboxTemplate,
16884
- styles: styles$j,
16884
+ styles: styles$k,
16885
16885
  shadowOptions: {
16886
16886
  delegatesFocus: true
16887
16887
  },
@@ -16918,6 +16918,116 @@
16918
16918
  });
16919
16919
  DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleCombobox());
16920
16920
 
16921
+ const styles$j = css `
16922
+ ${display('grid')}
16923
+
16924
+ dialog {
16925
+ background-color: ${applicationBackgroundColor};
16926
+ border: ${borderWidth} solid ${popupBorderColor};
16927
+ box-shadow: 0px 2px 3px ${popupBoxShadowColor};
16928
+ max-width: 50%;
16929
+ }
16930
+ `;
16931
+
16932
+ const template$5 = html `
16933
+ <template>
16934
+ <dialog
16935
+ ${ref('dialogElement')}
16936
+ role="alertdialog"
16937
+ aria-label="${x => x.ariaLabel}"
16938
+ @cancel="${(x, c) => x.cancelHandler(c.event)}"
16939
+ @close="${x => x.closeHandler()}"
16940
+ >
16941
+ <slot></slot>
16942
+ </dialog>
16943
+ </template>
16944
+ `;
16945
+
16946
+ /**
16947
+ * Symbol that is returned as the dialog close reason (from the Promise returned by show()) when
16948
+ * the dialog was closed by pressing the ESC key (vs. calling the close() function).
16949
+ */
16950
+ const USER_DISMISSED = Symbol('user dismissed');
16951
+ /**
16952
+ * A nimble-styled dialog.
16953
+ */
16954
+ // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
16955
+ class Dialog extends FoundationElement {
16956
+ constructor() {
16957
+ super(...arguments);
16958
+ /**
16959
+ * @public
16960
+ * @description
16961
+ * Prevents dismissing the dialog via the Escape key
16962
+ */
16963
+ this.preventDismiss = false;
16964
+ }
16965
+ /**
16966
+ * True if the dialog is open/showing, false otherwise
16967
+ */
16968
+ get open() {
16969
+ return this.resolveShow !== undefined;
16970
+ }
16971
+ /**
16972
+ * Opens the dialog
16973
+ * @returns Promise that is resolved when the dialog is closed. The value of the resolved Promise is the reason value passed to the close() method, or USER_DISMISSED if the dialog was closed via the ESC key.
16974
+ */
16975
+ async show() {
16976
+ if (this.open) {
16977
+ throw new Error('Dialog is already open');
16978
+ }
16979
+ this.dialogElement.showModal();
16980
+ return new Promise((resolve, _reject) => {
16981
+ this.resolveShow = resolve;
16982
+ });
16983
+ }
16984
+ /**
16985
+ * Closes the dialog
16986
+ * @param reason An optional value indicating how/why the dialog was closed.
16987
+ */
16988
+ close(reason) {
16989
+ if (!this.open) {
16990
+ throw new Error('Dialog is not open');
16991
+ }
16992
+ this.closeReason = reason;
16993
+ this.dialogElement.close();
16994
+ }
16995
+ /**
16996
+ * @internal
16997
+ */
16998
+ closeHandler() {
16999
+ this.resolveShow(this.closeReason);
17000
+ this.resolveShow = undefined;
17001
+ return true;
17002
+ }
17003
+ /**
17004
+ * @internal
17005
+ */
17006
+ cancelHandler(event) {
17007
+ if (this.preventDismiss) {
17008
+ event.preventDefault();
17009
+ }
17010
+ else {
17011
+ this.closeReason = USER_DISMISSED;
17012
+ }
17013
+ return true;
17014
+ }
17015
+ }
17016
+ __decorate([
17017
+ attr({ attribute: 'prevent-dismiss', mode: 'boolean' })
17018
+ ], Dialog.prototype, "preventDismiss", void 0);
17019
+ applyMixins(Dialog, ARIAGlobalStatesAndProperties);
17020
+ const nimbleDialog = Dialog.compose({
17021
+ baseName: 'dialog',
17022
+ template: template$5,
17023
+ styles: styles$j,
17024
+ baseClass: Dialog,
17025
+ shadowOptions: {
17026
+ delegatesFocus: true
17027
+ }
17028
+ });
17029
+ DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleDialog());
17030
+
16921
17031
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
16922
17032
 
16923
17033
  var dist = {};
@@ -18135,7 +18245,7 @@
18135
18245
  * which animates to be visible with a slide-in / slide-out animation.
18136
18246
  * Configured via 'location', 'state', 'modal', 'preventDismiss' properties.
18137
18247
  */
18138
- class Drawer extends Dialog {
18248
+ class Drawer extends Dialog$1 {
18139
18249
  constructor() {
18140
18250
  super(...arguments);
18141
18251
  this.location = DrawerLocation.left;
@@ -20025,7 +20135,7 @@
20025
20135
  `;
20026
20136
 
20027
20137
  const styles$e = css `
20028
- ${styles$q}
20138
+ ${styles$r}
20029
20139
 
20030
20140
  .control[aria-pressed='true'] {
20031
20141
  background-color: ${fillSelectedColor};
@@ -20465,7 +20575,7 @@
20465
20575
 
20466
20576
  const styles$c = css `
20467
20577
  ${display('inline-block')}
20468
- ${styles$k}
20578
+ ${styles$l}
20469
20579
 
20470
20580
  :host {
20471
20581
  font: ${bodyFont};
@@ -20721,7 +20831,7 @@
20721
20831
  };
20722
20832
 
20723
20833
  const styles$b = css `
20724
- ${styles$l}
20834
+ ${styles$m}
20725
20835
  `.withBehaviors(appearanceBehavior(DropdownAppearance.underline, css `
20726
20836
  .control {
20727
20837
  padding-top: ${borderWidth};
@@ -21391,7 +21501,7 @@
21391
21501
  /* eslint-disable @typescript-eslint/indent */
21392
21502
  const styles$4 = css `
21393
21503
  ${display('inline-block')}
21394
- ${styles$k}
21504
+ ${styles$l}
21395
21505
 
21396
21506
  :host {
21397
21507
  font: ${bodyFont};