@ni/nimble-components 11.11.0 → 11.13.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.
@@ -14419,6 +14419,22 @@
14419
14419
  return {red, green, blue, alpha};
14420
14420
  }
14421
14421
 
14422
+ /**
14423
+ * Convert a hexadecimal color string to an RGBA CSS color string
14424
+ * Example: 'ff0102' or '#ff0102' to 'rgba(255, 1, 2, 1)'
14425
+ * @param hexValue Hex color (with or without a starting '#')
14426
+ * @param alpha CSS alpha value between 0 (transparent) and 1 (opaque)
14427
+ * @returns An rgba()-formatted CSS color string
14428
+ */
14429
+ function hexToRgbaCssColor(hexValue, alpha) {
14430
+ const { red, green, blue } = hexRgb(hexValue);
14431
+ return `rgba(${red}, ${green}, ${blue}, ${alpha})`;
14432
+ }
14433
+
14434
+ const modalBackdropColorThemeLight = hexToRgbaCssColor(Black, 0.3);
14435
+ const modalBackdropColorThemeDark = hexToRgbaCssColor(Black, 0.6);
14436
+ const modalBackdropColorThemeColor = hexToRgbaCssColor(Black, 0.6);
14437
+
14422
14438
  const Theme = {
14423
14439
  light: 'light',
14424
14440
  dark: 'dark',
@@ -14448,6 +14464,7 @@
14448
14464
  informationColor: 'information-color',
14449
14465
  borderHoverColor: 'border-hover-color',
14450
14466
  iconColor: 'icon-color',
14467
+ modalBackdropColor: 'modal-backdrop-color',
14451
14468
  popupBoxShadowColor: 'popup-box-shadow-color',
14452
14469
  popupBorderColor: 'popup-border-color',
14453
14470
  controlHeight: 'control-height',
@@ -14681,18 +14698,6 @@
14681
14698
  .withPrefix('nimble')
14682
14699
  .register(nimbleDesignSystemProvider());
14683
14700
 
14684
- /**
14685
- * Convert a hexadecimal color string to an RGBA CSS color string
14686
- * Example: 'ff0102' or '#ff0102' to 'rgba(255, 1, 2, 1)'
14687
- * @param hexValue Hex color (with or without a starting '#')
14688
- * @param alpha CSS alpha value between 0 (transparent) and 1 (opaque)
14689
- * @returns An rgba()-formatted CSS color string
14690
- */
14691
- function hexToRgbaCssColor(hexValue, alpha) {
14692
- const { red, green, blue } = hexRgb(hexValue);
14693
- return `rgba(${red}, ${green}, ${blue}, ${alpha})`;
14694
- }
14695
-
14696
14701
  // Color Tokens
14697
14702
  const actionRgbPartialColor = DesignToken.create(styleNameFromTokenName(tokenNames.actionRgbPartialColor)).withDefault((element) => hexToRgbPartial(getColorForTheme(element, Black91, Black15, White)));
14698
14703
  const applicationBackgroundColor = DesignToken.create(styleNameFromTokenName(tokenNames.applicationBackgroundColor)).withDefault((element) => getColorForTheme(element, White, Black85, ForestGreen));
@@ -14713,6 +14718,7 @@
14713
14718
  const borderHoverColor = DesignToken.create(styleNameFromTokenName(tokenNames.borderHoverColor)).withDefault((element) => getColorForTheme(element, DigitalGreenLight, DigitalGreenLight, White));
14714
14719
  // Component Color Tokens
14715
14720
  const iconColor = DesignToken.create(styleNameFromTokenName(tokenNames.iconColor)).withDefault((element) => getColorForTheme(element, Black91, Black15, White));
14721
+ const modalBackdropColor = DesignToken.create(styleNameFromTokenName(tokenNames.modalBackdropColor)).withDefault((element) => getModalBackdropForTheme(element));
14716
14722
  const popupBoxShadowColor = DesignToken.create(styleNameFromTokenName(tokenNames.popupBoxShadowColor)).withDefault((element) => hexToRgbaCssColor(getColorForTheme(element, Black75, Black85, Black85), 0.3));
14717
14723
  const popupBorderColor = DesignToken.create(styleNameFromTokenName(tokenNames.popupBorderColor)).withDefault((element) => hexToRgbaCssColor(getColorForTheme(element, Black91, Black15, White), 0.3));
14718
14724
  DesignToken.create(styleNameFromTokenName(tokenNames.tooltipBackgroundColor)).withDefault((element) => getColorForTheme(element, Black15, Black85, ForestGreen));
@@ -14824,6 +14830,18 @@
14824
14830
  function getFillDownColorForTheme(element) {
14825
14831
  return getColorForTheme(element, Black91, Black15, White);
14826
14832
  }
14833
+ function getModalBackdropForTheme(element) {
14834
+ switch (theme.getValueFor(element)) {
14835
+ case Theme.light:
14836
+ return modalBackdropColorThemeLight;
14837
+ case Theme.dark:
14838
+ return modalBackdropColorThemeDark;
14839
+ case Theme.color:
14840
+ return modalBackdropColorThemeColor;
14841
+ default:
14842
+ return modalBackdropColorThemeLight;
14843
+ }
14844
+ }
14827
14845
 
14828
14846
  /**
14829
14847
  * Subscription for {@link ThemeStyleSheetBehavior}
@@ -16998,7 +17016,24 @@
16998
17016
  box-shadow: 0px 2px 3px ${popupBoxShadowColor};
16999
17017
  max-width: 50%;
17000
17018
  }
17001
- `;
17019
+ `.withBehaviors(
17020
+ /*
17021
+ * We cannot use the modalBackdropColor token directly because the backdrop
17022
+ * element is not a descendant of the nimble-theme-provider element.
17023
+ */
17024
+ themeBehavior(Theme.light, css `
17025
+ dialog::backdrop {
17026
+ background: ${modalBackdropColorThemeLight};
17027
+ }
17028
+ `), themeBehavior(Theme.dark, css `
17029
+ dialog::backdrop {
17030
+ background: ${modalBackdropColorThemeDark};
17031
+ }
17032
+ `), themeBehavior(Theme.color, css `
17033
+ dialog::backdrop {
17034
+ background: ${modalBackdropColorThemeColor};
17035
+ }
17036
+ `));
17002
17037
 
17003
17038
  const template$5 = html `
17004
17039
  <template>
@@ -17007,7 +17042,6 @@
17007
17042
  role="alertdialog"
17008
17043
  aria-label="${x => x.ariaLabel}"
17009
17044
  @cancel="${(x, c) => x.cancelHandler(c.event)}"
17010
- @close="${x => x.closeHandler()}"
17011
17045
  >
17012
17046
  <slot></slot>
17013
17047
  </dialog>
@@ -17060,16 +17094,9 @@
17060
17094
  if (!this.open) {
17061
17095
  throw new Error('Dialog is not open');
17062
17096
  }
17063
- this.closeReason = reason;
17064
17097
  this.dialogElement.close();
17065
- }
17066
- /**
17067
- * @internal
17068
- */
17069
- closeHandler() {
17070
- this.resolveShow(this.closeReason);
17098
+ this.resolveShow(reason);
17071
17099
  this.resolveShow = undefined;
17072
- return true;
17073
17100
  }
17074
17101
  /**
17075
17102
  * @internal
@@ -17079,11 +17106,15 @@
17079
17106
  event.preventDefault();
17080
17107
  }
17081
17108
  else {
17082
- this.closeReason = USER_DISMISSED;
17109
+ this.resolveShow(USER_DISMISSED);
17110
+ this.resolveShow = undefined;
17083
17111
  }
17084
17112
  return true;
17085
17113
  }
17086
17114
  }
17115
+ // We want the member to match the name of the constant
17116
+ // eslint-disable-next-line @typescript-eslint/naming-convention
17117
+ Dialog.USER_DISMISSED = USER_DISMISSED;
17087
17118
  __decorate([
17088
17119
  attr({ attribute: 'prevent-dismiss', mode: 'boolean' })
17089
17120
  ], Dialog.prototype, "preventDismiss", void 0);
@@ -18232,7 +18263,7 @@
18232
18263
  .overlay {
18233
18264
  position: fixed;
18234
18265
  inset: 0px;
18235
- background: ${popupBorderColor};
18266
+ background: ${modalBackdropColor};
18236
18267
  touch-action: none;
18237
18268
  }
18238
18269