@ni/nimble-components 7.0.1 → 7.1.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.
@@ -0,0 +1,12 @@
1
+ import { Switch as FoundationSwitch } from '@microsoft/fast-foundation';
2
+ export type { Switch };
3
+ declare global {
4
+ interface HTMLElementTagNameMap {
5
+ 'nimble-switch': Switch;
6
+ }
7
+ }
8
+ /**
9
+ * A nimble-styled switch control.
10
+ */
11
+ declare class Switch extends FoundationSwitch {
12
+ }
@@ -0,0 +1 @@
1
+ export declare const styles: import("@microsoft/fast-element").ElementStyles;
@@ -0,0 +1,2 @@
1
+ import type { Switch } from '.';
2
+ export declare const template: import("@microsoft/fast-element").ViewTemplate<Switch, any>;
@@ -0,0 +1,12 @@
1
+ import { Switch as FoundationSwitch } from '@microsoft/fast-foundation';
2
+ export type { Switch };
3
+ declare global {
4
+ interface HTMLElementTagNameMap {
5
+ 'nimble-switch': Switch;
6
+ }
7
+ }
8
+ /**
9
+ * A nimble-styled switch control.
10
+ */
11
+ declare class Switch extends FoundationSwitch {
12
+ }
@@ -0,0 +1,16 @@
1
+ import { DesignSystem, Switch as FoundationSwitch } from '@microsoft/fast-foundation';
2
+ import { styles } from './styles';
3
+ import { template } from './template';
4
+ /**
5
+ * A nimble-styled switch control.
6
+ */
7
+ class Switch extends FoundationSwitch {
8
+ }
9
+ const nimbleSwitch = Switch.compose({
10
+ baseClass: FoundationSwitch,
11
+ baseName: 'switch',
12
+ template,
13
+ styles
14
+ });
15
+ DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleSwitch());
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/switch/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,YAAY,EACZ,MAAM,IAAI,gBAAgB,EAE7B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAUtC;;GAEG;AACH,MAAM,MAAO,SAAQ,gBAAgB;CAAG;AAExC,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAgB;IAC/C,SAAS,EAAE,gBAAgB;IAC3B,QAAQ,EAAE,QAAQ;IAClB,QAAQ;IACR,MAAM;CACT,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,YAAY,EAAE,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const styles: import("@microsoft/fast-element").ElementStyles;
@@ -0,0 +1,174 @@
1
+ import { css } from '@microsoft/fast-element';
2
+ import { display } from '@microsoft/fast-foundation';
3
+ import { Black15, Black7, Black91, White } from '@ni/nimble-tokens/dist/styledictionary/js/tokens';
4
+ import { borderHoverColor, borderWidth, buttonLabelDisabledFontColor, buttonLabelFont, buttonLabelFontColor, controlHeight, controlLabelDisabledFontColor, controlLabelFont, controlLabelFontColor, fillHoverColor, smallDelay } from '../theme-provider/design-tokens';
5
+ import { hexToRgbaCssColor } from '../utilities/style/colors';
6
+ import { focusVisible } from '../utilities/style/focus';
7
+ import { themeBehavior } from '../utilities/style/theme';
8
+ export const styles = css `
9
+ ${display('inline-flex')}
10
+
11
+ :host {
12
+ outline: none;
13
+ font: ${buttonLabelFont};
14
+ color: ${buttonLabelFontColor};
15
+ flex-direction: column;
16
+ cursor: pointer;
17
+ --ni-private-switch-height: 24px;
18
+ --ni-private-switch-indicator-size: 16px;
19
+ padding-bottom: calc(
20
+ ${controlHeight} - var(--ni-private-switch-height)
21
+ );
22
+ }
23
+
24
+ :host([disabled]) {
25
+ cursor: default;
26
+ color: ${buttonLabelDisabledFontColor};
27
+ }
28
+
29
+ .label {
30
+ color: ${controlLabelFontColor};
31
+ font: ${controlLabelFont};
32
+ }
33
+
34
+ :host([disabled]) .label {
35
+ color: ${controlLabelDisabledFontColor};
36
+ }
37
+
38
+ .label__hidden {
39
+ display: none;
40
+ visibility: hidden;
41
+ }
42
+
43
+ .switch-container {
44
+ display: flex;
45
+ align-items: center;
46
+ }
47
+
48
+ slot[name='unchecked-message']::slotted(*) {
49
+ margin-inline-end: 8px;
50
+ }
51
+
52
+ .switch {
53
+ display: flex;
54
+ height: var(--ni-private-switch-height);
55
+ width: calc(var(--ni-private-switch-height) * 2);
56
+ box-sizing: border-box;
57
+ background-color: ${fillHoverColor};
58
+ border-radius: calc(var(--ni-private-switch-height) / 2);
59
+ align-items: center;
60
+ border: calc(${borderWidth} * 2) solid transparent;
61
+ }
62
+
63
+ :host([disabled]) .switch {
64
+ background-color: var(--ni-private-switch-background-disabled-color);
65
+ }
66
+
67
+ :host(${focusVisible}) .switch {
68
+ border-color: ${borderHoverColor};
69
+ }
70
+
71
+ .checked-indicator-spacer {
72
+ flex-grow: 0;
73
+ transition: flex-grow ${smallDelay} ease-in-out;
74
+ }
75
+
76
+ :host([aria-checked='true']) .checked-indicator-spacer {
77
+ flex-grow: 1;
78
+ transition: flex-grow ${smallDelay} ease-in-out;
79
+ }
80
+
81
+ .checked-indicator {
82
+ display: flex;
83
+ justify-content: center;
84
+ align-items: center;
85
+ background-color: var(--ni-private-switch-indicator-background-color);
86
+ box-sizing: border-box;
87
+ width: var(--ni-private-switch-indicator-size);
88
+ height: var(--ni-private-switch-indicator-size);
89
+ border-radius: calc(var(--ni-private-switch-indicator-size) / 2);
90
+ margin: calc(
91
+ calc(
92
+ var(--ni-private-switch-height) -
93
+ var(--ni-private-switch-indicator-size)
94
+ ) / 2
95
+ );
96
+ border: ${borderWidth} solid
97
+ var(--ni-private-switch-indicator-border-color);
98
+ }
99
+
100
+ :host(:hover) .checked-indicator {
101
+ border: calc(${borderWidth} * 2) solid ${borderHoverColor};
102
+ }
103
+
104
+ :host([disabled]) .checked-indicator {
105
+ background-color: var(
106
+ --ni-private-switch-indicator-background-disabled-color
107
+ );
108
+ border: ${borderWidth} solid
109
+ var(--ni-private-switch-indicator-border-disabled-color);
110
+ }
111
+
112
+ :host(${focusVisible}) .checked-indicator {
113
+ border: ${borderWidth} solid ${borderHoverColor};
114
+ }
115
+
116
+ .checked-indicator-inner {
117
+ width: calc(var(--ni-private-switch-indicator-size) / 2);
118
+ height: calc(var(--ni-private-switch-indicator-size) / 2);
119
+ border-radius: calc(var(--ni-private-switch-indicator-size) / 4);
120
+ background-color: var(--ni-private-switch-indicator-border-color);
121
+ opacity: 0;
122
+ transition: opacity ${smallDelay} ease-in-out;
123
+ }
124
+
125
+ :host([disabled]) .checked-indicator-inner {
126
+ background-color: var(
127
+ --ni-private-switch-indicator-border-disabled-color
128
+ );
129
+ }
130
+
131
+ :host([aria-checked='true']) .checked-indicator-inner {
132
+ opacity: 1;
133
+ transition: opacity ${smallDelay} ease-in-out;
134
+ }
135
+
136
+ slot[name='checked-message']::slotted(*) {
137
+ margin-inline-start: 8px;
138
+ }
139
+
140
+ @media (prefers-reduced-motion) {
141
+ .checked-indicator-inner,
142
+ .checked-indicator-spacer {
143
+ transition-duration: 0s;
144
+ }
145
+ }
146
+ `.withBehaviors(themeBehavior(css `
147
+ ${'' /* Light theme */}
148
+ :host {
149
+ --ni-private-switch-background-disabled-color: ${hexToRgbaCssColor(Black91, 0.07)};
150
+ --ni-private-switch-indicator-background-color: ${White};
151
+ --ni-private-switch-indicator-background-disabled-color: ${hexToRgbaCssColor(White, 0.1)};
152
+ --ni-private-switch-indicator-border-color: ${Black91};
153
+ --ni-private-switch-indicator-border-disabled-color: ${hexToRgbaCssColor(Black91, 0.3)};
154
+ }
155
+ `, css `
156
+ ${'' /* Dark theme */}
157
+ :host {
158
+ --ni-private-switch-background-disabled-color: ${hexToRgbaCssColor(Black15, 0.07)};
159
+ --ni-private-switch-indicator-background-color: ${hexToRgbaCssColor(Black91, 0.3)};
160
+ --ni-private-switch-indicator-background-disabled-color: ${hexToRgbaCssColor(Black91, 0.1)};
161
+ --ni-private-switch-indicator-border-color: ${Black7};
162
+ --ni-private-switch-indicator-border-disabled-color: ${hexToRgbaCssColor(Black7, 0.3)};
163
+ }
164
+ `, css `
165
+ ${'' /* Color theme */}
166
+ :host {
167
+ --ni-private-switch-background-disabled-color: ${hexToRgbaCssColor(White, 0.07)};
168
+ --ni-private-switch-indicator-background-color: ${hexToRgbaCssColor(White, 0.1)};
169
+ --ni-private-switch-indicator-background-disabled-color: ${hexToRgbaCssColor(White, 0.1)};
170
+ --ni-private-switch-indicator-border-color: ${White};
171
+ --ni-private-switch-indicator-border-disabled-color: ${hexToRgbaCssColor(White, 0.3)};
172
+ }
173
+ `));
174
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/switch/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EACH,OAAO,EACP,MAAM,EACN,OAAO,EACP,KAAK,EACR,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACH,gBAAgB,EAChB,WAAW,EACX,4BAA4B,EAC5B,eAAe,EACf,oBAAoB,EACpB,aAAa,EACb,6BAA6B,EAC7B,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,UAAU,EACb,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;MACnB,OAAO,CAAC,aAAa,CAAC;;;;gBAIZ,eAAe;iBACd,oBAAoB;;;;;;cAMvB,aAAa;;;;;;iBAMV,4BAA4B;;;;iBAI5B,qBAAqB;gBACtB,gBAAgB;;;;iBAIf,6BAA6B;;;;;;;;;;;;;;;;;;;;;;4BAsBlB,cAAc;;;uBAGnB,WAAW;;;;;;;YAOtB,YAAY;wBACA,gBAAgB;;;;;gCAKR,UAAU;;;;;gCAKV,UAAU;;;;;;;;;;;;;;;;;;kBAkBxB,WAAW;;;;;uBAKN,WAAW,eAAe,gBAAgB;;;;;;;kBAO/C,WAAW;;;;YAIjB,YAAY;kBACN,WAAW,UAAU,gBAAgB;;;;;;;;;8BASzB,UAAU;;;;;;;;;;;8BAWV,UAAU;;;;;;;;;;;;;CAavC,CAAC,aAAa,CACP,aAAa,CACT,GAAG,CAAA;cACD,EAAE,CAAC,iBAAiB;;iEAE+B,iBAAiB,CAClE,OAAO,EACP,IAAI,CACP;kEACqD,KAAK;2EACI,iBAAiB,CAC5E,KAAK,EACL,GAAG,CACN;8DACiD,OAAO;uEACE,iBAAiB,CACxE,OAAO,EACP,GAAG,CACN;;SAEJ,EACG,GAAG,CAAA;cACD,EAAE,CAAC,gBAAgB;;iEAEgC,iBAAiB,CAClE,OAAO,EACP,IAAI,CACP;kEACqD,iBAAiB,CACnE,OAAO,EACP,GAAG,CACN;2EAC8D,iBAAiB,CAC5E,OAAO,EACP,GAAG,CACN;8DACiD,MAAM;uEACG,iBAAiB,CACxE,MAAM,EACN,GAAG,CACN;;SAEJ,EACG,GAAG,CAAA;cACD,EAAE,CAAC,iBAAiB;;iEAE+B,iBAAiB,CAClE,KAAK,EACL,IAAI,CACP;kEACqD,iBAAiB,CACnE,KAAK,EACL,GAAG,CACN;2EAC8D,iBAAiB,CAC5E,KAAK,EACL,GAAG,CACN;8DACiD,KAAK;uEACI,iBAAiB,CACxE,KAAK,EACL,GAAG,CACN;;SAEJ,CACA,CACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ import type { Switch } from '.';
2
+ export declare const template: import("@microsoft/fast-element").ViewTemplate<Switch, any>;
@@ -0,0 +1,38 @@
1
+ import { html, slotted } from '@microsoft/fast-element';
2
+ // prettier-ignore
3
+ export const template = html `
4
+ <template
5
+ role="switch"
6
+ aria-checked="${x => x.checked}"
7
+ aria-disabled="${x => x.disabled}"
8
+ aria-readonly="${x => x.readOnly}"
9
+ tabindex="${x => (x.disabled ? null : 0)}"
10
+ @keypress="${(x, c) => x.keypressHandler(c.event)}"
11
+ @click="${(x, c) => x.clickHandler(c.event)}"
12
+ class="${x => (x.checked ? 'checked' : '')}"
13
+ >
14
+ <label
15
+ part="label"
16
+ class="${x => (x.defaultSlottedNodes?.length ? 'label' : 'label label__hidden')}"
17
+ >
18
+ <slot ${slotted('defaultSlottedNodes')}></slot>
19
+ </label>
20
+ <div class="switch-container">
21
+ <span class="status-message unchecked-message" part="unchecked-message">
22
+ <slot name="unchecked-message"></slot>
23
+ </span>
24
+ <div part="switch" class="switch">
25
+ <slot name="switch">
26
+ <span class="checked-indicator-spacer"></span>
27
+ <span class="checked-indicator" part="checked-indicator">
28
+ <span class="checked-indicator-inner">
29
+ </span>
30
+ </slot>
31
+ </div>
32
+ <span class="status-message checked-message" part="checked-message">
33
+ <slot name="checked-message"></slot>
34
+ </span>
35
+ </div>
36
+ </template>
37
+ `;
38
+ //# sourceMappingURL=template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.js","sourceRoot":"","sources":["../../../src/switch/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAGxD,kBAAkB;AAClB,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAQ;;;wBAGZ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO;yBACb,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ;yBACf,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ;oBACpB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;qBAC3B,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,KAAsB,CAAC;kBACxD,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,KAAmB,CAAC;iBAChD,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;;;;qBAI7B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,mBAAmB,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,qBAAqB,CAAC;;oBAEvE,OAAO,CAAC,qBAAqB,CAAC;;;;;;;;;;;;;;;;;;;CAmBjD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ni/nimble-components",
3
- "version": "7.0.1",
3
+ "version": "7.1.0",
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 generate-scss && npm run build-storybook",