@ni/nimble-components 11.1.1 → 11.2.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.
@@ -1,4 +1,5 @@
1
1
  import { NumberField as FoundationNumberField } from '@microsoft/fast-foundation';
2
+ import { NumberFieldAppearance } from './types';
2
3
  declare global {
3
4
  interface HTMLElementTagNameMap {
4
5
  'nimble-number-field': NumberField;
@@ -8,4 +9,6 @@ declare global {
8
9
  * A nimble-styled HTML number input
9
10
  */
10
11
  export declare class NumberField extends FoundationNumberField {
12
+ appearance: NumberFieldAppearance;
13
+ connectedCallback(): void;
11
14
  }
@@ -1,11 +1,25 @@
1
+ import { __decorate } from "tslib";
2
+ import { attr, html } from '@microsoft/fast-element';
1
3
  import { DesignSystem, NumberField as FoundationNumberField, numberFieldTemplate as template } from '@microsoft/fast-foundation';
2
- import { arrowExpanderDown16X16, arrowExpanderUp16X16 } from '@ni/nimble-tokens/dist/icons/js';
3
4
  import { styles } from './styles';
5
+ import { NumberFieldAppearance } from './types';
4
6
  /**
5
7
  * A nimble-styled HTML number input
6
8
  */
7
9
  export class NumberField extends FoundationNumberField {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.appearance = NumberFieldAppearance.underline;
13
+ }
14
+ connectedCallback() {
15
+ super.connectedCallback();
16
+ // This is a workaround for FAST issue: https://github.com/microsoft/fast/issues/6148
17
+ this.control.setAttribute('role', 'spinbutton');
18
+ }
8
19
  }
20
+ __decorate([
21
+ attr
22
+ ], NumberField.prototype, "appearance", void 0);
9
23
  /**
10
24
  * A function that returns a number-field registration for configuring the component with a DesignSystem.
11
25
  *
@@ -22,8 +36,28 @@ const nimbleNumberField = NumberField.compose({
22
36
  shadowOptions: {
23
37
  delegatesFocus: true
24
38
  },
25
- stepDownGlyph: arrowExpanderDown16X16.data,
26
- stepUpGlyph: arrowExpanderUp16X16.data
39
+ stepDownGlyph: html `
40
+ <nimble-button
41
+ class="step-up-down-button"
42
+ appearance="ghost"
43
+ content-hidden
44
+ tabindex="-1"
45
+ >
46
+ "Decrement"
47
+ <nimble-icon-minus-wide slot="start"></nimble-icon-minus-wide>
48
+ </nimble-button>
49
+ `,
50
+ stepUpGlyph: html `
51
+ <nimble-button
52
+ class="step-up-down-button"
53
+ appearance="ghost"
54
+ content-hidden
55
+ tabindex="-1"
56
+ >
57
+ "Increment"
58
+ <nimble-icon-add slot="start"></nimble-icon-add>
59
+ </nimble-button>
60
+ `
27
61
  });
28
62
  DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleNumberField());
29
63
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/number-field/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,YAAY,EACZ,WAAW,IAAI,qBAAqB,EAEpC,mBAAmB,IAAI,QAAQ,EAClC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACH,sBAAsB,EACtB,oBAAoB,EACvB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAQlC;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,qBAAqB;CAAG;AAEzD;;;;;;;GAOG;AACH,MAAM,iBAAiB,GAAG,WAAW,CAAC,OAAO,CAAqB;IAC9D,QAAQ,EAAE,cAAc;IACxB,SAAS,EAAE,qBAAqB;IAChC,QAAQ;IACR,MAAM;IACN,aAAa,EAAE;QACX,cAAc,EAAE,IAAI;KACvB;IACD,aAAa,EAAE,sBAAsB,CAAC,IAAI;IAC1C,WAAW,EAAE,oBAAoB,CAAC,IAAI;CACzC,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,iBAAiB,EAAE,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/number-field/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EACH,YAAY,EACZ,WAAW,IAAI,qBAAqB,EAEpC,mBAAmB,IAAI,QAAQ,EAClC,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAQhD;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,qBAAqB;IAAtD;;QAEW,eAAU,GAA0B,qBAAqB,CAAC,SAAS,CAAC;IAQ/E,CAAC;IANmB,iBAAiB;QAC7B,KAAK,CAAC,iBAAiB,EAAE,CAAC;QAE1B,qFAAqF;QACrF,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACpD,CAAC;CACJ;AARG;IADC,IAAI;+CACsE;AAU/E;;;;;;;GAOG;AACH,MAAM,iBAAiB,GAAG,WAAW,CAAC,OAAO,CAAqB;IAC9D,QAAQ,EAAE,cAAc;IACxB,SAAS,EAAE,qBAAqB;IAChC,QAAQ;IACR,MAAM;IACN,aAAa,EAAE;QACX,cAAc,EAAE,IAAI;KACvB;IACD,aAAa,EAAE,IAAI,CAAA;;;;;;;;;;KAUlB;IACD,WAAW,EAAE,IAAI,CAAA;;;;;;;;;;KAUhB;CACJ,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,iBAAiB,EAAE,CAAC,CAAC"}
@@ -1,6 +1,8 @@
1
1
  import { css } from '@microsoft/fast-element';
2
2
  import { display } from '@microsoft/fast-foundation';
3
- import { borderColor, borderRgbPartialColor, borderHoverColor, borderWidth, bodyFontColor, bodyDisabledFontColor, controlHeight, fillSelectedRgbPartialColor, iconSize, controlLabelFont, controlLabelFontColor, labelHeight, smallDelay, bodyFont, failColor, standardPadding } from '../theme-provider/design-tokens';
3
+ import { borderRgbPartialColor, borderHoverColor, borderWidth, bodyFontColor, bodyDisabledFontColor, controlHeight, fillSelectedRgbPartialColor, controlLabelFont, controlLabelFontColor, labelHeight, smallDelay, bodyFont, failColor, standardPadding, controlLabelDisabledFontColor } from '../theme-provider/design-tokens';
4
+ import { appearanceBehavior } from '../utilities/style/appearance';
5
+ import { NumberFieldAppearance } from './types';
4
6
  export const styles = css `
5
7
  ${display('inline-block')}
6
8
 
@@ -24,6 +26,10 @@ export const styles = css `
24
26
  font: ${controlLabelFont};
25
27
  }
26
28
 
29
+ :host([disabled]) .label {
30
+ color: ${controlLabelDisabledFontColor};
31
+ }
32
+
27
33
  .root {
28
34
  box-sizing: border-box;
29
35
  position: relative;
@@ -31,7 +37,7 @@ export const styles = css `
31
37
  flex-direction: row;
32
38
  justify-content: center;
33
39
  border-radius: 0px;
34
- border-bottom: ${borderWidth} solid rgba(${borderRgbPartialColor}, 0.3);
40
+ border: 0px solid rgba(${borderRgbPartialColor}, 0.3);
35
41
  gap: calc(${standardPadding} / 2);
36
42
  }
37
43
 
@@ -39,9 +45,8 @@ export const styles = css `
39
45
  border-bottom-color: ${borderHoverColor};
40
46
  }
41
47
 
42
- :host([disabled]) .root,
43
- :host([disabled]) .root:hover {
44
- border-bottom: ${borderWidth} solid ${bodyDisabledFontColor};
48
+ :host([disabled]) .root {
49
+ border-color: rgba(${borderRgbPartialColor}, 0.1);
45
50
  }
46
51
 
47
52
  .root::before {
@@ -90,7 +95,7 @@ export const styles = css `
90
95
  font: inherit;
91
96
  background: transparent;
92
97
  color: inherit;
93
- height: calc(${controlHeight} - ${borderWidth});
98
+ height: ${controlHeight};
94
99
  width: 100%;
95
100
  border: none;
96
101
  padding: 0px;
@@ -122,24 +127,47 @@ export const styles = css `
122
127
 
123
128
  .controls {
124
129
  display: flex;
125
- flex-direction: column;
126
- }
127
-
128
- .step-up,
129
- .step-down {
130
- display: inline-flex;
131
- height: 15px;
132
- width: 15px;
133
- cursor: pointer;
130
+ flex-direction: row-reverse;
134
131
  justify-content: center;
135
132
  align-items: center;
136
133
  }
137
134
 
138
- .step-up svg,
139
- .step-down svg {
140
- height: ${iconSize};
141
- width: ${iconSize};
142
- fill: ${borderColor};
143
- }
144
- `;
135
+ .step-up-down-button {
136
+ ${controlHeight.cssCustomProperty}: 24px;
137
+ }
138
+ `.withBehaviors(appearanceBehavior(NumberFieldAppearance.underline, css `
139
+ .root {
140
+ border-bottom-width: ${borderWidth};
141
+ padding-top: ${borderWidth};
142
+ padding-left: ${borderWidth};
143
+ padding-right: ${borderWidth};
144
+ }
145
+
146
+ .control {
147
+ height: calc(${controlHeight} - 2 * ${borderWidth});
148
+ }
149
+ `), appearanceBehavior(NumberFieldAppearance.block, css `
150
+ .root {
151
+ background-color: rgba(${borderRgbPartialColor}, 0.1);
152
+ padding-left: ${borderWidth};
153
+ padding-right: ${borderWidth};
154
+ }
155
+
156
+ .root:focus-within,
157
+ :host(.invalid) .root {
158
+ border-bottom-width: ${borderWidth};
159
+ }
160
+
161
+ :host([disabled]) .root {
162
+ background-color: rgba(${borderRgbPartialColor}, 0.07);
163
+ }
164
+ `), appearanceBehavior(NumberFieldAppearance.outline, css `
165
+ .root {
166
+ border-width: ${borderWidth};
167
+ }
168
+
169
+ .control {
170
+ height: calc(${controlHeight} - 2 * ${borderWidth});
171
+ }
172
+ `));
145
173
  //# sourceMappingURL=styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../src/number-field/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,yBAAyB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EACH,WAAW,EACX,qBAAqB,EACrB,gBAAgB,EAChB,WAAW,EACX,aAAa,EACb,qBAAqB,EACrB,aAAa,EACb,2BAA2B,EAC3B,QAAQ,EACR,gBAAgB,EAChB,qBAAqB,EACrB,WAAW,EACX,UAAU,EACV,QAAQ,EACR,SAAS,EACT,eAAe,EAClB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OAAO,CAAC,cAAc,CAAC;;;gBAGb,QAAQ;;;iBAGP,aAAa;uBACP,WAAW,MAAM,aAAa;mDACF,WAAW;;;;iBAI7C,qBAAqB;;;;;;iBAMrB,qBAAqB;gBACtB,gBAAgB;;;;iBAIf,6BAA6B;;;;;;;;;;iCAUb,qBAAqB;oBAClC,eAAe;;;;+BAIJ,gBAAgB;;;;6BAIlB,qBAAqB;;;;UAIxC,CAAA,yCAA0C,EAAE;;;;;;;;;;4BAU1B,WAAW;;;yBAGd,gBAAgB;;4BAEb,UAAU;;;;;;;;;;+BAUP,SAAS;;;;;;;;;;;;;;;;;;;;kBAoBtB,aAAa;;;;;;;;;;;;;;iBAcd,qBAAqB;2BACX,2BAA2B;;;;iBAIrC,qBAAqB;;;;;;;;iBAQrB,qBAAqB;;;;;;;;;;;UAW5B,aAAa,CAAC,iBAAiB;;CAExC,CAAC,aAAa,CACP,kBAAkB,CACd,qBAAqB,CAAC,SAAS,EAC/B,GAAG,CAAA;;uCAEwB,WAAW;+BACnB,WAAW;gCACV,WAAW;iCACV,WAAW;;;;+BAIb,aAAa,UAAU,WAAW;;SAExD,CACA,EACD,kBAAkB,CACd,qBAAqB,CAAC,KAAK,EAC3B,GAAG,CAAA;;yCAE0B,qBAAqB;gCAC9B,WAAW;iCACV,WAAW;;;;;uCAKL,WAAW;;;;yCAIT,qBAAqB;;SAErD,CACA,EACD,kBAAkB,CACd,qBAAqB,CAAC,OAAO,EAC7B,GAAG,CAAA;;gCAEiB,WAAW;;;;+BAIZ,aAAa,UAAU,WAAW;;SAExD,CACA,CACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Values for the 'appearance' property of the number field
3
+ */
4
+ export declare const NumberFieldAppearance: {
5
+ readonly underline: "underline";
6
+ readonly outline: "outline";
7
+ readonly block: "block";
8
+ };
9
+ export declare type NumberFieldAppearance = typeof NumberFieldAppearance[keyof typeof NumberFieldAppearance];
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Values for the 'appearance' property of the number field
3
+ */
4
+ export const NumberFieldAppearance = {
5
+ underline: 'underline',
6
+ outline: 'outline',
7
+ block: 'block'
8
+ };
9
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/number-field/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACjC,SAAS,EAAE,WAAW;IACtB,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;CACR,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ni/nimble-components",
3
- "version": "11.1.1",
3
+ "version": "11.2.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 bundle-components && npm run generate-scss && npm run build-storybook",