@ni/nimble-components 11.8.3 → 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')
@@ -14700,7 +14700,7 @@
14700
14700
  DesignToken.create(styleNameFromTokenName(tokenNames.sectionBackgroundColor)).withDefault((element) => getColorForTheme(element, Black15, Black80, ForestGreen));
14701
14701
  DesignToken.create(styleNameFromTokenName(tokenNames.dividerBackgroundColor)).withDefault((element) => getColorForTheme(element, Black15, Black80, ForestGreen));
14702
14702
  const fillSelectedColor = DesignToken.create(styleNameFromTokenName(tokenNames.fillSelectedColor)).withDefault((element) => hexToRgbaCssColor(getFillSelectedColorForTheme(element), 0.2));
14703
- const fillSelectedRgbPartialColor = DesignToken.create(styleNameFromTokenName(tokenNames.fillSelectedRgbPartialColor)).withDefault((element) => hexToRgbPartial(getFillSelectedColorForTheme(element)));
14703
+ DesignToken.create(styleNameFromTokenName(tokenNames.fillSelectedRgbPartialColor)).withDefault((element) => hexToRgbPartial(getFillSelectedColorForTheme(element)));
14704
14704
  const fillHoverSelectedColor = DesignToken.create(styleNameFromTokenName(tokenNames.fillHoverSelectedColor)).withDefault((element) => hexToRgbaCssColor(getFillSelectedColorForTheme(element), 0.15));
14705
14705
  const fillHoverColor = DesignToken.create(styleNameFromTokenName(tokenNames.fillHoverColor)).withDefault((element) => hexToRgbaCssColor(getFillHoverColorForTheme(element), 0.1));
14706
14706
  DesignToken.create(styleNameFromTokenName(tokenNames.fillDownColor)).withDefault((element) => hexToRgbaCssColor(getFillDownColorForTheme(element), 0.15));
@@ -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;
@@ -16739,9 +16739,7 @@
16739
16739
  class Combobox extends Combobox$1 {
16740
16740
  constructor() {
16741
16741
  super(...arguments);
16742
- this.focusOutHandler = () => {
16743
- this.open = false;
16744
- };
16742
+ this.valueUpdatedByInput = false;
16745
16743
  }
16746
16744
  // Workaround for https://github.com/microsoft/fast/issues/5123
16747
16745
  setPositioning() {
@@ -16765,10 +16763,6 @@
16765
16763
  // Call setPositioning() after this.forcedPosition is initialized.
16766
16764
  this.setPositioning();
16767
16765
  this.updateInputAriaLabel();
16768
- this.addEventListener('focusout', this.focusOutHandler);
16769
- }
16770
- disconnectedCallback() {
16771
- this.removeEventListener('focusout', this.focusOutHandler);
16772
16766
  }
16773
16767
  toggleButtonClickHandler(e) {
16774
16768
  e.stopImmediatePropagation();
@@ -16795,6 +16789,50 @@
16795
16789
  const enabledOptions = this.filteredOptions.filter(o => !o.disabled);
16796
16790
  this.filteredOptions = enabledOptions;
16797
16791
  }
16792
+ /**
16793
+ * This is a workaround for the issue described here: https://github.com/microsoft/fast/issues/6267
16794
+ * For now, we will update the value ourselves while a user types in text. Note that there is other
16795
+ * implementation related to this (like the 'keydownEventHandler') needed to create the complete set
16796
+ * of desired behavior described in the issue noted above.
16797
+ */
16798
+ // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
16799
+ inputHandler(e) {
16800
+ const returnValue = super.inputHandler(e);
16801
+ if (!this.valueUpdatedByInput) {
16802
+ this.valueBeforeTextUpdate = this.value;
16803
+ }
16804
+ this.value = this.control.value;
16805
+ this.valueUpdatedByInput = true;
16806
+ return returnValue;
16807
+ }
16808
+ // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
16809
+ keydownHandler(e) {
16810
+ const returnValue = super.keydownHandler(e);
16811
+ if (e.ctrlKey || e.altKey) {
16812
+ return returnValue;
16813
+ }
16814
+ switch (e.key) {
16815
+ case keyEnter:
16816
+ this.emitChangeIfValueUpdated();
16817
+ break;
16818
+ case keyArrowDown:
16819
+ case keyArrowUp:
16820
+ if (this.open && this.valueUpdatedByInput) {
16821
+ this.valueUpdatedByInput = false;
16822
+ }
16823
+ break;
16824
+ default:
16825
+ return returnValue;
16826
+ }
16827
+ return returnValue;
16828
+ }
16829
+ // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
16830
+ focusoutHandler(e) {
16831
+ const returnValue = super.focusoutHandler(e);
16832
+ this.open = false;
16833
+ this.emitChangeIfValueUpdated();
16834
+ return returnValue;
16835
+ }
16798
16836
  openChanged() {
16799
16837
  super.openChanged();
16800
16838
  if (this.dropdownButton) {
@@ -16814,6 +16852,24 @@
16814
16852
  inputElement?.removeAttribute('aria-label');
16815
16853
  }
16816
16854
  }
16855
+ /**
16856
+ * This will only emit a `change` event after text entry where the text in the input prior to
16857
+ * typing is different than the text present upon an attempt to commit (e.g. pressing <Enter>).
16858
+ * So, for a concrete example:
16859
+ * 1) User types 'Sue' (when Combobox input was blank).
16860
+ * 2) User presses <Enter> -> 'change' event fires
16861
+ * 3) User deletes 'Sue'
16862
+ * 4) User re-types 'Sue'
16863
+ * 5) User presses <Enter> -> NO 'change' event is fired
16864
+ */
16865
+ emitChangeIfValueUpdated() {
16866
+ if (this.valueUpdatedByInput) {
16867
+ if (this.value !== this.valueBeforeTextUpdate) {
16868
+ this.$emit('change');
16869
+ }
16870
+ this.valueUpdatedByInput = false;
16871
+ }
16872
+ }
16817
16873
  }
16818
16874
  __decorate([
16819
16875
  observable
@@ -16825,7 +16881,7 @@
16825
16881
  baseName: 'combobox',
16826
16882
  baseClass: Combobox$1,
16827
16883
  template: comboboxTemplate,
16828
- styles: styles$j,
16884
+ styles: styles$k,
16829
16885
  shadowOptions: {
16830
16886
  delegatesFocus: true
16831
16887
  },
@@ -16862,6 +16918,116 @@
16862
16918
  });
16863
16919
  DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleCombobox());
16864
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
+
16865
17031
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
16866
17032
 
16867
17033
  var dist = {};
@@ -18079,7 +18245,7 @@
18079
18245
  * which animates to be visible with a slide-in / slide-out animation.
18080
18246
  * Configured via 'location', 'state', 'modal', 'preventDismiss' properties.
18081
18247
  */
18082
- class Drawer extends Dialog {
18248
+ class Drawer extends Dialog$1 {
18083
18249
  constructor() {
18084
18250
  super(...arguments);
18085
18251
  this.location = DrawerLocation.left;
@@ -19969,7 +20135,7 @@
19969
20135
  `;
19970
20136
 
19971
20137
  const styles$e = css `
19972
- ${styles$q}
20138
+ ${styles$r}
19973
20139
 
19974
20140
  .control[aria-pressed='true'] {
19975
20141
  background-color: ${fillSelectedColor};
@@ -20409,7 +20575,7 @@
20409
20575
 
20410
20576
  const styles$c = css `
20411
20577
  ${display('inline-block')}
20412
- ${styles$k}
20578
+ ${styles$l}
20413
20579
 
20414
20580
  :host {
20415
20581
  font: ${bodyFont};
@@ -20522,11 +20688,6 @@
20522
20688
  outline: none;
20523
20689
  }
20524
20690
 
20525
- .control::selection {
20526
- color: ${controlLabelFontColor};
20527
- background: rgba(${fillSelectedRgbPartialColor}, 0.3);
20528
- }
20529
-
20530
20691
  .control::placeholder {
20531
20692
  color: ${controlLabelFontColor};
20532
20693
  }
@@ -20670,7 +20831,7 @@
20670
20831
  };
20671
20832
 
20672
20833
  const styles$b = css `
20673
- ${styles$l}
20834
+ ${styles$m}
20674
20835
  `.withBehaviors(appearanceBehavior(DropdownAppearance.underline, css `
20675
20836
  .control {
20676
20837
  padding-top: ${borderWidth};
@@ -21250,11 +21411,6 @@
21250
21411
  box-shadow: none;
21251
21412
  }
21252
21413
 
21253
- .control::selection {
21254
- color: ${controlLabelFontColor};
21255
- background: rgba(${fillSelectedRgbPartialColor}, 0.3);
21256
- }
21257
-
21258
21414
  .control::placeholder {
21259
21415
  color: ${controlLabelFontColor};
21260
21416
  }
@@ -21345,7 +21501,7 @@
21345
21501
  /* eslint-disable @typescript-eslint/indent */
21346
21502
  const styles$4 = css `
21347
21503
  ${display('inline-block')}
21348
- ${styles$k}
21504
+ ${styles$l}
21349
21505
 
21350
21506
  :host {
21351
21507
  font: ${bodyFont};
@@ -21470,11 +21626,6 @@
21470
21626
  text-overflow: clip;
21471
21627
  }
21472
21628
 
21473
- .control::selection {
21474
- color: ${controlLabelFontColor};
21475
- background: rgba(${fillSelectedRgbPartialColor}, 0.3);
21476
- }
21477
-
21478
21629
  .control::placeholder {
21479
21630
  color: ${controlLabelFontColor};
21480
21631
  }