@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.
- package/dist/all-components-bundle.js +98 -164
- package/dist/all-components-bundle.js.map +1 -1
- package/dist/all-components-bundle.min.js +977 -1002
- package/dist/all-components-bundle.min.js.map +1 -1
- package/dist/esm/breadcrumb/styles.js +4 -6
- package/dist/esm/breadcrumb/styles.js.map +1 -1
- package/dist/esm/card-button/styles.js +4 -10
- package/dist/esm/card-button/styles.js.map +1 -1
- package/dist/esm/combobox/index.js +1 -0
- package/dist/esm/combobox/index.js.map +1 -1
- package/dist/esm/number-field/styles.js +1 -6
- package/dist/esm/number-field/styles.js.map +1 -1
- package/dist/esm/switch/styles.js +4 -6
- package/dist/esm/switch/styles.js.map +1 -1
- package/dist/esm/text-area/styles.js +1 -6
- package/dist/esm/text-area/styles.js.map +1 -1
- package/dist/esm/text-field/styles.js +5 -13
- package/dist/esm/text-field/styles.js.map +1 -1
- package/dist/esm/tooltip/styles.js +4 -11
- package/dist/esm/tooltip/styles.js.map +1 -1
- package/dist/esm/utilities/style/appearance.d.ts +2 -2
- package/dist/esm/utilities/style/appearance.js +3 -3
- package/dist/esm/utilities/style/appearance.js.map +1 -1
- package/dist/esm/utilities/style/multivalue-property-stylesheet-behavior.d.ts +37 -0
- package/dist/esm/utilities/style/multivalue-property-stylesheet-behavior.js +56 -0
- package/dist/esm/utilities/style/multivalue-property-stylesheet-behavior.js.map +1 -0
- package/dist/esm/utilities/style/theme.d.ts +10 -15
- package/dist/esm/utilities/style/theme.js +23 -55
- package/dist/esm/utilities/style/theme.js.map +1 -1
- 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(
|
|
9
|
-
this.
|
|
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(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
this.
|
|
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(
|
|
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.
|
|
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.
|
|
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(
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
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 = (
|
|
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"],"names":[],"mappings":"
|
|
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.
|
|
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",
|