@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
@@ -1,27 +1,22 @@
1
- /* eslint-disable max-classes-per-file */
2
- import { ElementStyles } from '@microsoft/fast-element';
3
1
  import { theme as themeToken } from '../../theme-provider';
4
2
  /**
5
3
  * Subscription for {@link ThemeStyleSheetBehavior}
6
4
  */
7
5
  class ThemeStyleSheetBehaviorSubscription {
8
- constructor(themeStyles, source) {
9
- this.themeStyles = themeStyles;
6
+ constructor(value, styles, source) {
7
+ this.value = value;
8
+ this.styles = styles;
10
9
  this.source = source;
11
- this.attached = null;
12
10
  }
13
- handleChange({ target, token }) {
14
- this.attach(token.getValueFor(target));
15
- }
16
- attach(theme) {
17
- if (this.attached !== this.themeStyles[theme]) {
18
- if (this.attached !== null) {
19
- this.source.$fastController.removeStyles(this.attached);
20
- }
21
- this.attached = this.themeStyles[theme];
22
- if (this.attached !== null) {
23
- this.source.$fastController.addStyles(this.attached);
24
- }
11
+ handleChange() {
12
+ const theme = themeToken.getValueFor(this.source);
13
+ if (Array.isArray(this.value)
14
+ ? this.value.includes(theme)
15
+ : this.value === theme) {
16
+ this.source.$fastController.addStyles(this.styles);
17
+ }
18
+ else {
19
+ this.source.$fastController.removeStyles(this.styles);
25
20
  }
26
21
  }
27
22
  }
@@ -29,47 +24,22 @@ class ThemeStyleSheetBehaviorSubscription {
29
24
  * Behavior to conditionally apply theme-based stylesheets.
30
25
  */
31
26
  class ThemeStyleSheetBehavior {
32
- constructor(lightStyle, darkStyleOrAlias, colorStyleOrAlias) {
27
+ constructor(theme, styles) {
28
+ this.theme = theme;
29
+ this.styles = styles;
33
30
  this.cache = new WeakMap();
34
- const light = lightStyle;
35
- const dark = ThemeStyleSheetBehavior.resolveTheme(darkStyleOrAlias, {
36
- light,
37
- dark: null,
38
- color: null
39
- });
40
- const color = ThemeStyleSheetBehavior.resolveTheme(colorStyleOrAlias, {
41
- light,
42
- dark,
43
- color: null
44
- });
45
- this.themeStyles = {
46
- light,
47
- dark,
48
- color
49
- };
50
- }
51
- static resolveTheme(value, currentThemeStyles) {
52
- if (value instanceof ElementStyles || value === null) {
53
- return value;
54
- }
55
- const currentStyle = currentThemeStyles[value];
56
- if (currentStyle === null) {
57
- throw new Error(`Tried to alias to theme '${value}' but the theme value is not set to a style.`);
58
- }
59
- return currentStyle;
60
31
  }
61
32
  /**
62
33
  * @internal
63
34
  */
64
35
  bind(source) {
65
36
  const subscriber = this.cache.get(source)
66
- || new ThemeStyleSheetBehaviorSubscription(this.themeStyles, source);
67
- const value = themeToken.getValueFor(source);
37
+ || new ThemeStyleSheetBehaviorSubscription(this.theme, this.styles, source);
68
38
  // Currently subscriber from cache may have gone through unbind
69
39
  // but still be in cache so always resubscribe
70
40
  // See: https://github.com/microsoft/fast/issues/3246#issuecomment-1030424876
71
41
  themeToken.subscribe(subscriber, source);
72
- subscriber.attach(value);
42
+ subscriber.handleChange();
73
43
  this.cache.set(source, subscriber);
74
44
  }
75
45
  /**
@@ -87,20 +57,18 @@ class ThemeStyleSheetBehavior {
87
57
  /**
88
58
  * Behavior to conditionally apply theme-based stylesheets. To determine which to apply,
89
59
  * the behavior will use the nearest ThemeProvider's 'theme' design system value.
90
- * To re-use the same style for multiple themes you can specify the name of an already
91
- * defined theme to alias them together.
92
60
  *
93
61
  * @public
94
62
  * @example
95
63
  * ```ts
96
64
  * css`
97
- * // ...
98
- * `.withBehaviors(new ThemeStyleSheetBehavior(
99
- * css`:host { ... Theme.light style... }`),
100
- * null, // No style needed for Theme.dark style
101
- * Theme.light // For the Theme.color style, re-use the previously set Theme.light style
65
+ * // ...
66
+ * `.withBehaviors(
67
+ * themeBehavior(Theme.light, css` ... `),
68
+ * // Apply style for both dark and color theme
69
+ * themeBehavior([Theme.dark, Theme.color], css` ... `)
102
70
  * )
103
71
  * ```
104
72
  */
105
- export const themeBehavior = (lightStyle, darkStyleOrAlias, colorStyleOrAlias) => new ThemeStyleSheetBehavior(lightStyle, darkStyleOrAlias, colorStyleOrAlias);
73
+ export const themeBehavior = (theme, styles) => new ThemeStyleSheetBehavior(theme, styles);
106
74
  //# sourceMappingURL=theme.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"theme.js","sourceRoot":"","sources":["../../../../src/utilities/style/theme.ts"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,CAAC;SACtC;QAED,iDAAiD;QACjD,6EAA6E;IACjF,CAAC;CACJ;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CACzB,UAAsB,EACtB,gBAAkC,EAClC,iBAAoC,EACb,EAAE,CAAC,IAAI,uBAAuB,CACrD,UAAU,EACV,gBAAgB,EAChB,iBAAiB,CACpB,CAAC"}
1
+ {"version":3,"file":"theme.js","sourceRoot":"","sources":["../../../../src/utilities/style/theme.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,IAAI,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAE3D;;GAEG;AACH,MAAM,mCAAmC;IACrC,YACqB,KAAsB,EACtB,MAAqB,EACrB,MAAiC;QAFjC,UAAK,GAAL,KAAK,CAAiB;QACtB,WAAM,GAAN,MAAM,CAAe;QACrB,WAAM,GAAN,MAAM,CAA2B;IACnD,CAAC;IAEG,YAAY;QACf,MAAM,KAAK,GAAG,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAClD,IACI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;YACrB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC;YAC5B,CAAC,CAAC,IAAI,CAAC,KAAK,KAAK,KAAK,EAC5B;YACE,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SACtD;aAAM;YACH,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SACzD;IACL,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,uBAAuB;IAMzB,YACqB,KAAsB,EACtB,MAAqB;QADrB,UAAK,GAAL,KAAK,CAAiB;QACtB,WAAM,GAAN,MAAM,CAAe;QAPzB,UAAK,GAGlB,IAAI,OAAO,EAAE,CAAC;IAKf,CAAC;IAEJ;;OAEG;IACI,IAAI,CAAC,MAAiC;QACzC,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC;eAClC,IAAI,mCAAmC,CACtC,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,MAAM,EACX,MAAM,CACT,CAAC;QAEN,+DAA+D;QAC/D,8CAA8C;QAC9C,6EAA6E;QAC7E,UAAU,CAAC,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACzC,UAAU,CAAC,YAAY,EAAE,CAAC;QAE1B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACvC,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,MAAiC;QAC3C,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAE1C,IAAI,UAAU,EAAE;YACZ,UAAU,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;SACtC;QAED,iDAAiD;QACjD,6EAA6E;IACjF,CAAC;CACJ;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CACzB,KAAsB,EACtB,MAAqB,EACE,EAAE,CAAC,IAAI,uBAAuB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ni/nimble-components",
3
- "version": "11.8.1",
3
+ "version": "11.8.4",
4
4
  "description": "Styled web components for the NI Nimble Design System",
5
5
  "scripts": {
6
6
  "build": "npm run generate-icons && npm run build-components && npm run bundle-components && npm run generate-scss && npm run build-storybook",