@ni/nimble-components 11.8.1 → 11.8.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.
Files changed (30) hide show
  1. package/dist/all-components-bundle.js +98 -164
  2. package/dist/all-components-bundle.js.map +1 -1
  3. package/dist/all-components-bundle.min.js +977 -1002
  4. package/dist/all-components-bundle.min.js.map +1 -1
  5. package/dist/esm/breadcrumb/styles.js +4 -6
  6. package/dist/esm/breadcrumb/styles.js.map +1 -1
  7. package/dist/esm/card-button/styles.js +4 -10
  8. package/dist/esm/card-button/styles.js.map +1 -1
  9. package/dist/esm/combobox/index.js +1 -0
  10. package/dist/esm/combobox/index.js.map +1 -1
  11. package/dist/esm/number-field/styles.js +1 -6
  12. package/dist/esm/number-field/styles.js.map +1 -1
  13. package/dist/esm/switch/styles.js +4 -6
  14. package/dist/esm/switch/styles.js.map +1 -1
  15. package/dist/esm/text-area/styles.js +1 -6
  16. package/dist/esm/text-area/styles.js.map +1 -1
  17. package/dist/esm/text-field/styles.js +5 -13
  18. package/dist/esm/text-field/styles.js.map +1 -1
  19. package/dist/esm/tooltip/styles.js +4 -11
  20. package/dist/esm/tooltip/styles.js.map +1 -1
  21. package/dist/esm/utilities/style/appearance.d.ts +2 -2
  22. package/dist/esm/utilities/style/appearance.js +3 -3
  23. package/dist/esm/utilities/style/appearance.js.map +1 -1
  24. package/dist/esm/utilities/style/multivalue-property-stylesheet-behavior.d.ts +37 -0
  25. package/dist/esm/utilities/style/multivalue-property-stylesheet-behavior.js +56 -0
  26. package/dist/esm/utilities/style/multivalue-property-stylesheet-behavior.js.map +1 -0
  27. package/dist/esm/utilities/style/theme.d.ts +10 -15
  28. package/dist/esm/utilities/style/theme.js +23 -55
  29. package/dist/esm/utilities/style/theme.js.map +1 -1
  30. package/package.json +1 -1
@@ -14226,58 +14226,6 @@
14226
14226
  observable
14227
14227
  ], TreeView$1.prototype, "slottedTreeItems", void 0);
14228
14228
 
14229
- /**
14230
- * A behavior to add or remove a stylesheet from an element based on a property. The behavior ensures that
14231
- * styles are applied while the property matches and that styles are not applied if the property does
14232
- * not match.
14233
- *
14234
- * @public
14235
- */
14236
- class PropertyStyleSheetBehavior {
14237
- /**
14238
- * Constructs a {@link PropertyStyleSheetBehavior} instance.
14239
- * @param propertyName - The property name to operate from.
14240
- * @param value - The property value to operate from.
14241
- * @param styles - The styles to coordinate with the property.
14242
- */
14243
- constructor(propertyName, value, styles) {
14244
- this.propertyName = propertyName;
14245
- this.value = value;
14246
- this.styles = styles;
14247
- }
14248
- /**
14249
- * Binds the behavior to the element.
14250
- * @param elementInstance - The element for which the property is applied.
14251
- */
14252
- bind(elementInstance) {
14253
- Observable.getNotifier(elementInstance).subscribe(this, this.propertyName);
14254
- this.handleChange(elementInstance, this.propertyName);
14255
- }
14256
- /**
14257
- * Unbinds the behavior from the element.
14258
- * @param source - The element for which the behavior is unbinding.
14259
- * @internal
14260
- */
14261
- unbind(source) {
14262
- Observable.getNotifier(source).unsubscribe(this, this.propertyName);
14263
- source.$fastController.removeStyles(this.styles);
14264
- }
14265
- /**
14266
- * Change event for the provided element.
14267
- * @param source - the element for which to attach or detach styles.
14268
- * @param key - the key to lookup to know if the element already has the styles
14269
- * @internal
14270
- */
14271
- handleChange(source, key) {
14272
- if (source[key] === this.value) {
14273
- source.$fastController.addStyles(this.styles);
14274
- }
14275
- else {
14276
- source.$fastController.removeStyles(this.styles);
14277
- }
14278
- }
14279
- }
14280
-
14281
14229
  /**
14282
14230
  * A CSS fragment to set `display: none;` when the host is hidden using the [hidden] attribute.
14283
14231
  * @public
@@ -14752,7 +14700,7 @@
14752
14700
  DesignToken.create(styleNameFromTokenName(tokenNames.sectionBackgroundColor)).withDefault((element) => getColorForTheme(element, Black15, Black80, ForestGreen));
14753
14701
  DesignToken.create(styleNameFromTokenName(tokenNames.dividerBackgroundColor)).withDefault((element) => getColorForTheme(element, Black15, Black80, ForestGreen));
14754
14702
  const fillSelectedColor = DesignToken.create(styleNameFromTokenName(tokenNames.fillSelectedColor)).withDefault((element) => hexToRgbaCssColor(getFillSelectedColorForTheme(element), 0.2));
14755
- const fillSelectedRgbPartialColor = DesignToken.create(styleNameFromTokenName(tokenNames.fillSelectedRgbPartialColor)).withDefault((element) => hexToRgbPartial(getFillSelectedColorForTheme(element)));
14703
+ DesignToken.create(styleNameFromTokenName(tokenNames.fillSelectedRgbPartialColor)).withDefault((element) => hexToRgbPartial(getFillSelectedColorForTheme(element)));
14756
14704
  const fillHoverSelectedColor = DesignToken.create(styleNameFromTokenName(tokenNames.fillHoverSelectedColor)).withDefault((element) => hexToRgbaCssColor(getFillSelectedColorForTheme(element), 0.15));
14757
14705
  const fillHoverColor = DesignToken.create(styleNameFromTokenName(tokenNames.fillHoverColor)).withDefault((element) => hexToRgbaCssColor(getFillHoverColorForTheme(element), 0.1));
14758
14706
  DesignToken.create(styleNameFromTokenName(tokenNames.fillDownColor)).withDefault((element) => hexToRgbaCssColor(getFillDownColorForTheme(element), 0.15));
@@ -14877,28 +14825,24 @@
14877
14825
  return getColorForTheme(element, Black91, Black15, White);
14878
14826
  }
14879
14827
 
14880
- /* eslint-disable max-classes-per-file */
14881
14828
  /**
14882
14829
  * Subscription for {@link ThemeStyleSheetBehavior}
14883
14830
  */
14884
14831
  class ThemeStyleSheetBehaviorSubscription {
14885
- constructor(themeStyles, source) {
14886
- this.themeStyles = themeStyles;
14832
+ constructor(value, styles, source) {
14833
+ this.value = value;
14834
+ this.styles = styles;
14887
14835
  this.source = source;
14888
- this.attached = null;
14889
- }
14890
- handleChange({ target, token }) {
14891
- this.attach(token.getValueFor(target));
14892
14836
  }
14893
- attach(theme) {
14894
- if (this.attached !== this.themeStyles[theme]) {
14895
- if (this.attached !== null) {
14896
- this.source.$fastController.removeStyles(this.attached);
14897
- }
14898
- this.attached = this.themeStyles[theme];
14899
- if (this.attached !== null) {
14900
- this.source.$fastController.addStyles(this.attached);
14901
- }
14837
+ handleChange() {
14838
+ const theme$1 = theme.getValueFor(this.source);
14839
+ if (Array.isArray(this.value)
14840
+ ? this.value.includes(theme$1)
14841
+ : this.value === theme$1) {
14842
+ this.source.$fastController.addStyles(this.styles);
14843
+ }
14844
+ else {
14845
+ this.source.$fastController.removeStyles(this.styles);
14902
14846
  }
14903
14847
  }
14904
14848
  }
@@ -14906,47 +14850,22 @@
14906
14850
  * Behavior to conditionally apply theme-based stylesheets.
14907
14851
  */
14908
14852
  class ThemeStyleSheetBehavior {
14909
- constructor(lightStyle, darkStyleOrAlias, colorStyleOrAlias) {
14853
+ constructor(theme, styles) {
14854
+ this.theme = theme;
14855
+ this.styles = styles;
14910
14856
  this.cache = new WeakMap();
14911
- const light = lightStyle;
14912
- const dark = ThemeStyleSheetBehavior.resolveTheme(darkStyleOrAlias, {
14913
- light,
14914
- dark: null,
14915
- color: null
14916
- });
14917
- const color = ThemeStyleSheetBehavior.resolveTheme(colorStyleOrAlias, {
14918
- light,
14919
- dark,
14920
- color: null
14921
- });
14922
- this.themeStyles = {
14923
- light,
14924
- dark,
14925
- color
14926
- };
14927
- }
14928
- static resolveTheme(value, currentThemeStyles) {
14929
- if (value instanceof ElementStyles || value === null) {
14930
- return value;
14931
- }
14932
- const currentStyle = currentThemeStyles[value];
14933
- if (currentStyle === null) {
14934
- throw new Error(`Tried to alias to theme '${value}' but the theme value is not set to a style.`);
14935
- }
14936
- return currentStyle;
14937
14857
  }
14938
14858
  /**
14939
14859
  * @internal
14940
14860
  */
14941
14861
  bind(source) {
14942
14862
  const subscriber = this.cache.get(source)
14943
- || new ThemeStyleSheetBehaviorSubscription(this.themeStyles, source);
14944
- const value = theme.getValueFor(source);
14863
+ || new ThemeStyleSheetBehaviorSubscription(this.theme, this.styles, source);
14945
14864
  // Currently subscriber from cache may have gone through unbind
14946
14865
  // but still be in cache so always resubscribe
14947
14866
  // See: https://github.com/microsoft/fast/issues/3246#issuecomment-1030424876
14948
14867
  theme.subscribe(subscriber, source);
14949
- subscriber.attach(value);
14868
+ subscriber.handleChange();
14950
14869
  this.cache.set(source, subscriber);
14951
14870
  }
14952
14871
  /**
@@ -14964,22 +14883,20 @@
14964
14883
  /**
14965
14884
  * Behavior to conditionally apply theme-based stylesheets. To determine which to apply,
14966
14885
  * the behavior will use the nearest ThemeProvider's 'theme' design system value.
14967
- * To re-use the same style for multiple themes you can specify the name of an already
14968
- * defined theme to alias them together.
14969
14886
  *
14970
14887
  * @public
14971
14888
  * @example
14972
14889
  * ```ts
14973
14890
  * css`
14974
- * // ...
14975
- * `.withBehaviors(new ThemeStyleSheetBehavior(
14976
- * css`:host { ... Theme.light style... }`),
14977
- * null, // No style needed for Theme.dark style
14978
- * Theme.light // For the Theme.color style, re-use the previously set Theme.light style
14891
+ * // ...
14892
+ * `.withBehaviors(
14893
+ * themeBehavior(Theme.light, css` ... `),
14894
+ * // Apply style for both dark and color theme
14895
+ * themeBehavior([Theme.dark, Theme.color], css` ... `)
14979
14896
  * )
14980
14897
  * ```
14981
14898
  */
14982
- const themeBehavior = (lightStyle, darkStyleOrAlias, colorStyleOrAlias) => new ThemeStyleSheetBehavior(lightStyle, darkStyleOrAlias, colorStyleOrAlias);
14899
+ const themeBehavior = (theme, styles) => new ThemeStyleSheetBehavior(theme, styles);
14983
14900
 
14984
14901
  const styles$s = css `
14985
14902
  ${display('inline-block')}
@@ -15006,8 +14923,7 @@
15006
14923
  ::slotted(*:not([href]):last-child) {
15007
14924
  font: ${bodyEmphasizedFont};
15008
14925
  }
15009
- `.withBehaviors(themeBehavior(css `
15010
- ${'' /* Light theme */}
14926
+ `.withBehaviors(themeBehavior(Theme.light, css `
15011
14927
  :host {
15012
14928
  --ni-private-breadcrumb-link-active-font-color: ${DigitalGreenDark};
15013
14929
  }
@@ -15015,8 +14931,7 @@
15015
14931
  :host(.prominent-links) {
15016
14932
  --ni-private-breadcrumb-link-font-color: ${DigitalGreenDark};
15017
14933
  }
15018
- `, css `
15019
- ${'' /* Dark theme */}
14934
+ `), themeBehavior(Theme.dark, css `
15020
14935
  :host {
15021
14936
  --ni-private-breadcrumb-link-active-font-color: ${PowerGreen};
15022
14937
  }
@@ -15024,8 +14939,7 @@
15024
14939
  :host(.prominent-links) {
15025
14940
  --ni-private-breadcrumb-link-font-color: ${PowerGreen};
15026
14941
  }
15027
- `, css `
15028
- ${'' /* Color theme */}
14942
+ `), themeBehavior(Theme.color, css `
15029
14943
  :host {
15030
14944
  --ni-private-breadcrumb-link-active-font-color: ${hexToRgbaCssColor(White, 0.6)};
15031
14945
  }
@@ -15717,17 +15631,72 @@
15717
15631
  .withPrefix('nimble')
15718
15632
  .register(nimbleBreadcrumbItem());
15719
15633
 
15634
+ /**
15635
+ * A behavior to add or remove a stylesheet from an element based on a property. The behavior ensures that
15636
+ * styles are applied while the property matches and that styles are not applied if the property does
15637
+ * not match.
15638
+ *
15639
+ * @public
15640
+ */
15641
+ class MultivaluePropertyStyleSheetBehavior {
15642
+ /**
15643
+ * Constructs a {@link MultivaluePropertyStyleSheetBehavior} instance.
15644
+ * @param propertyName - The property name to operate from.
15645
+ * @param value - The property value or values to operate from.
15646
+ * @param styles - The styles to coordinate with the property.
15647
+ */
15648
+ constructor(propertyName, value, styles) {
15649
+ this.propertyName = propertyName;
15650
+ this.value = value;
15651
+ this.styles = styles;
15652
+ }
15653
+ /**
15654
+ * Binds the behavior to the element.
15655
+ * @param elementInstance - The element for which the property is applied.
15656
+ */
15657
+ bind(elementInstance) {
15658
+ Observable.getNotifier(elementInstance).subscribe(this, this.propertyName);
15659
+ this.handleChange(elementInstance, this.propertyName);
15660
+ }
15661
+ /**
15662
+ * Unbinds the behavior from the element.
15663
+ * @param source - The element for which the behavior is unbinding.
15664
+ */
15665
+ unbind(source) {
15666
+ Observable.getNotifier(source).unsubscribe(this, this.propertyName);
15667
+ source.$fastController.removeStyles(this.styles);
15668
+ }
15669
+ /**
15670
+ * Change event for the provided element.
15671
+ * @param source - the element for which to attach or detach styles.
15672
+ * @param key - the key to lookup to know if the element already has the styles
15673
+ * @internal
15674
+ */
15675
+ handleChange(source, key) {
15676
+ // @ts-expect-error Accessing arbitrary property of an element
15677
+ const currentValue = source[key];
15678
+ if (Array.isArray(this.value)
15679
+ ? this.value.includes(currentValue)
15680
+ : this.value === currentValue) {
15681
+ source.$fastController.addStyles(this.styles);
15682
+ }
15683
+ else {
15684
+ source.$fastController.removeStyles(this.styles);
15685
+ }
15686
+ }
15687
+ }
15688
+
15720
15689
  /**
15721
15690
  * Behavior that will conditionally apply a stylesheet based on the element's
15722
15691
  * appearance property
15723
15692
  *
15724
- * @param value - The value of the appearance property
15693
+ * @param value - The value or values of the appearance property
15725
15694
  * @param styles - The styles to be applied when condition matches
15726
15695
  *
15727
15696
  * @public
15728
15697
  */
15729
15698
  function appearanceBehavior(value, styles) {
15730
- return new PropertyStyleSheetBehavior('appearance', value, styles);
15699
+ return new MultivaluePropertyStyleSheetBehavior('appearance', value, styles);
15731
15700
  }
15732
15701
 
15733
15702
  /**
@@ -16177,10 +16146,7 @@
16177
16146
  transition-duration: 0s;
16178
16147
  }
16179
16148
  }
16180
- `
16181
- .withBehaviors(themeBehavior(
16182
- // Light theme
16183
- css `
16149
+ `.withBehaviors(themeBehavior(Theme.light, css `
16184
16150
  :host {
16185
16151
  --ni-private-card-button-box-shadow-hover-color: ${hexToRgbaCssColor(Black, 0.3)};
16186
16152
  --ni-private-card-button-background-hover-color: ${hexToRgbaCssColor(White, 0.3)};
@@ -16188,9 +16154,7 @@
16188
16154
  --ni-private-card-button-border-active-color: ${hexToRgbaCssColor(Black91, 0.2)};
16189
16155
  --ni-private-card-button-border-selected-color: ${hexToRgbaCssColor(Black91, 0.6)};
16190
16156
  }
16191
- `,
16192
- // Dark theme
16193
- css `
16157
+ `), themeBehavior(Theme.dark, css `
16194
16158
  :host {
16195
16159
  --ni-private-card-button-box-shadow-hover-color: ${hexToRgbaCssColor(Black, 0.77)};
16196
16160
  --ni-private-card-button-background-hover-color: ${hexToRgbaCssColor(Black15, 0.07)};
@@ -16198,9 +16162,7 @@
16198
16162
  --ni-private-card-button-border-active-color: ${hexToRgbaCssColor(Black15, 0.2)};
16199
16163
  --ni-private-card-button-border-selected-color: ${Black15};
16200
16164
  }
16201
- `,
16202
- // Color theme
16203
- css `
16165
+ `), themeBehavior(Theme.color, css `
16204
16166
  :host {
16205
16167
  --ni-private-card-button-box-shadow-hover-color: ${hexToRgbaCssColor(White, 0.77)};
16206
16168
  --ni-private-card-button-background-hover-color: ${hexToRgbaCssColor(White, 0.2)};
@@ -16886,6 +16848,7 @@
16886
16848
  part="button"
16887
16849
  aria-haspopup="true"
16888
16850
  aria-expanded="${x => x.open}"
16851
+ tabindex="-1"
16889
16852
  >
16890
16853
  <nimble-icon-arrow-expander-down
16891
16854
  slot="start"
@@ -20559,11 +20522,6 @@
20559
20522
  outline: none;
20560
20523
  }
20561
20524
 
20562
- .control::selection {
20563
- color: ${controlLabelFontColor};
20564
- background: rgba(${fillSelectedRgbPartialColor}, 0.3);
20565
- }
20566
-
20567
20525
  .control::placeholder {
20568
20526
  color: ${controlLabelFontColor};
20569
20527
  }
@@ -20926,8 +20884,7 @@
20926
20884
  transition-duration: 0s;
20927
20885
  }
20928
20886
  }
20929
- `.withBehaviors(themeBehavior(css `
20930
- ${'' /* Light theme */}
20887
+ `.withBehaviors(themeBehavior(Theme.light, css `
20931
20888
  :host {
20932
20889
  --ni-private-switch-background-disabled-color: ${hexToRgbaCssColor(Black91, 0.07)};
20933
20890
  --ni-private-switch-indicator-background-color: ${White};
@@ -20935,8 +20892,7 @@
20935
20892
  --ni-private-switch-indicator-border-color: ${Black91};
20936
20893
  --ni-private-switch-indicator-border-disabled-color: ${hexToRgbaCssColor(Black91, 0.3)};
20937
20894
  }
20938
- `, css `
20939
- ${'' /* Dark theme */}
20895
+ `), themeBehavior(Theme.dark, css `
20940
20896
  :host {
20941
20897
  --ni-private-switch-background-disabled-color: ${hexToRgbaCssColor(Black15, 0.07)};
20942
20898
  --ni-private-switch-indicator-background-color: ${hexToRgbaCssColor(Black91, 0.3)};
@@ -20944,8 +20900,7 @@
20944
20900
  --ni-private-switch-indicator-border-color: ${Black7};
20945
20901
  --ni-private-switch-indicator-border-disabled-color: ${hexToRgbaCssColor(Black7, 0.3)};
20946
20902
  }
20947
- `, css `
20948
- ${'' /* Color theme */}
20903
+ `), themeBehavior(Theme.color, css `
20949
20904
  :host {
20950
20905
  --ni-private-switch-background-disabled-color: ${hexToRgbaCssColor(White, 0.07)};
20951
20906
  --ni-private-switch-indicator-background-color: ${hexToRgbaCssColor(White, 0.1)};
@@ -21290,11 +21245,6 @@
21290
21245
  box-shadow: none;
21291
21246
  }
21292
21247
 
21293
- .control::selection {
21294
- color: ${controlLabelFontColor};
21295
- background: rgba(${fillSelectedRgbPartialColor}, 0.3);
21296
- }
21297
-
21298
21248
  .control::placeholder {
21299
21249
  color: ${controlLabelFontColor};
21300
21250
  }
@@ -21382,6 +21332,7 @@
21382
21332
  frameless: 'frameless'
21383
21333
  };
21384
21334
 
21335
+ /* eslint-disable @typescript-eslint/indent */
21385
21336
  const styles$4 = css `
21386
21337
  ${display('inline-block')}
21387
21338
  ${styles$k}
@@ -21509,11 +21460,6 @@
21509
21460
  text-overflow: clip;
21510
21461
  }
21511
21462
 
21512
- .control::selection {
21513
- color: ${controlLabelFontColor};
21514
- background: rgba(${fillSelectedRgbPartialColor}, 0.3);
21515
- }
21516
-
21517
21463
  .control::placeholder {
21518
21464
  color: ${controlLabelFontColor};
21519
21465
  }
@@ -21610,19 +21556,15 @@
21610
21556
  :host([readonly]) .root {
21611
21557
  border-color: transparent;
21612
21558
  }
21613
- `), themeBehavior(css `
21614
- ${'' /* Light theme */}
21559
+ `), themeBehavior(Theme.light, css `
21615
21560
  .control::-ms-reveal {
21616
21561
  filter: invert(0%);
21617
21562
  }
21618
- `, css `
21619
- ${'' /* Dark theme */}
21563
+ `), themeBehavior([Theme.dark, Theme.color], css `
21620
21564
  .control::-ms-reveal {
21621
21565
  filter: invert(100%);
21622
21566
  }
21623
- `,
21624
- // Color theme
21625
- Theme.dark));
21567
+ `));
21626
21568
 
21627
21569
  /**
21628
21570
  * A nimble-styed HTML text input
@@ -21753,11 +21695,7 @@
21753
21695
  display: flex;
21754
21696
  flex: 0 0 auto;
21755
21697
  }
21756
- `.withBehaviors(
21757
- /* Local Theme Behaviors for tooltip borders and backgrounds */
21758
- themeBehavior(
21759
- // Light Theme
21760
- css `
21698
+ `.withBehaviors(themeBehavior(Theme.light, css `
21761
21699
  :host(.fail) {
21762
21700
  --ni-private-tooltip-border-color: ${BannerFail100DarkUi};
21763
21701
  --ni-private-tooltip-background-color: ${White};
@@ -21767,9 +21705,7 @@
21767
21705
  --ni-private-tooltip-border-color: ${Information100LightUi};
21768
21706
  --ni-private-tooltip-background-color: ${White};
21769
21707
  }
21770
- `,
21771
- // Dark Theme
21772
- css `
21708
+ `), themeBehavior(Theme.dark, css `
21773
21709
  :host {
21774
21710
  --ni-private-tooltip-border-color: ${hexToRgbaCssColor(Black15, 0.3)};
21775
21711
  --ni-private-tooltip-background-color: ${Black85};
@@ -21782,9 +21718,7 @@
21782
21718
  :host(.fail) {
21783
21719
  --ni-private-tooltip-border-color: ${BannerFail100DarkUi};
21784
21720
  }
21785
- `,
21786
- // Color Theme
21787
- css `
21721
+ `), themeBehavior(Theme.color, css `
21788
21722
  .anchored-region {
21789
21723
  background-color: ${ForestGreen};
21790
21724
  }