@fluentui/web-components 2.5.6 → 2.5.8

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 (37) hide show
  1. package/CHANGELOG.json +46 -1
  2. package/CHANGELOG.md +20 -2
  3. package/dist/dts/combobox/combobox.stories.d.ts +5 -0
  4. package/dist/dts/custom-elements.d.ts +3 -35
  5. package/dist/dts/number-field/index.d.ts +1 -1
  6. package/dist/dts/number-field/number-field.styles.d.ts +1 -2
  7. package/dist/dts/search/index.d.ts +1 -1
  8. package/dist/dts/search/search.styles.d.ts +2 -3
  9. package/dist/dts/select/index.d.ts +1 -1
  10. package/dist/dts/select/select.styles.d.ts +11 -3
  11. package/dist/dts/styles/patterns/button.styles.d.ts +12 -6
  12. package/dist/dts/styles/patterns/input.styles.d.ts +13 -5
  13. package/dist/dts/text-area/index.d.ts +2 -18
  14. package/dist/dts/text-area/text-area.stories.d.ts +1 -17
  15. package/dist/dts/text-area/text-area.styles.d.ts +1 -2
  16. package/dist/dts/text-field/index.d.ts +2 -18
  17. package/dist/dts/text-field/text-field.stories.d.ts +1 -17
  18. package/dist/dts/text-field/text-field.styles.d.ts +1 -2
  19. package/dist/esm/anchor/anchor.styles.js +3 -10
  20. package/dist/esm/button/button.styles.js +14 -39
  21. package/dist/esm/combobox/combobox.stories.js +7 -2
  22. package/dist/esm/combobox/combobox.styles.js +22 -32
  23. package/dist/esm/number-field/number-field.styles.js +5 -16
  24. package/dist/esm/search/search.styles.js +8 -11
  25. package/dist/esm/select/select.stories.js +2 -2
  26. package/dist/esm/select/select.styles.js +35 -100
  27. package/dist/esm/styles/patterns/button.styles.js +190 -149
  28. package/dist/esm/styles/patterns/input.styles.js +112 -93
  29. package/dist/esm/text-area/text-area.styles.js +5 -11
  30. package/dist/esm/text-field/text-field.styles.js +5 -11
  31. package/dist/fluent-web-components.api.json +127 -397
  32. package/dist/web-components.d.ts +39 -90
  33. package/dist/web-components.js +148 -135
  34. package/dist/web-components.min.js +203 -233
  35. package/docs/api-report.md +38 -99
  36. package/karma.conf.js +3 -8
  37. package/package.json +29 -42
@@ -1,9 +1,10 @@
1
1
  import { css } from '@microsoft/fast-element';
2
2
  import { DesignToken, disabledCursor, } from '@microsoft/fast-foundation';
3
3
  import { SystemColors } from '@microsoft/fast-web-utilities';
4
- import { accentFillRest, controlCornerRadius, disabledOpacity, focusStrokeWidth, neutralFillInputFocus, neutralFillInputHover, neutralFillInputRecipe, neutralFillInputRest, neutralFillSecondaryHover, neutralFillSecondaryRecipe, neutralFillSecondaryRest, neutralForegroundHintRecipe, neutralForegroundRest, neutralStrokeInputHover, neutralStrokeInputRest, neutralStrokeRest, strokeWidth, } from '../../design-tokens';
4
+ import { accentFillRest, controlCornerRadius, disabledOpacity, focusStrokeWidth, neutralFillInputFocus, neutralFillInputHover, neutralFillInputRecipe, neutralFillInputRest, neutralFillSecondaryFocus, neutralFillSecondaryHover, neutralFillSecondaryRecipe, neutralFillSecondaryRest, neutralForegroundHintRecipe, neutralForegroundRest, neutralStrokeInputHover, neutralStrokeInputRest, neutralStrokeRest, strokeWidth, } from '../../design-tokens';
5
5
  import { typeRampBase } from '../patterns/type-ramp';
6
6
  import { heightNumber } from '../size';
7
+ import { focusTreatmentBase } from '../focus';
7
8
  const placeholderRest = DesignToken.create('input-placeholder-rest').withDefault((target) => {
8
9
  const baseRecipe = neutralFillInputRecipe.getValueFor(target);
9
10
  const hintRecipe = neutralForegroundHintRecipe.getValueFor(target);
@@ -25,9 +26,11 @@ const filledPlaceholderHover = DesignToken.create('input-filled-placeholder-hove
25
26
  return hintRecipe.evaluate(target, baseRecipe.evaluate(target).hover);
26
27
  });
27
28
  /**
29
+ * The base styles for input controls, without `appearance` visual differences.
30
+ *
28
31
  * @internal
29
32
  */
30
- export const inputStyles = (context, definition, rootSelector) => css `
33
+ export const baseInputStyles = (context, definition, logicalControlSelector) => css `
31
34
  :host {
32
35
  ${typeRampBase}
33
36
  color: ${neutralForegroundRest};
@@ -36,12 +39,10 @@ export const inputStyles = (context, definition, rootSelector) => css `
36
39
  position: relative;
37
40
  }
38
41
 
39
- ${rootSelector} {
42
+ ${logicalControlSelector} {
40
43
  box-sizing: border-box;
41
44
  position: relative;
42
45
  color: inherit;
43
- background: padding-box linear-gradient(${neutralFillInputRest}, ${neutralFillInputRest}),
44
- border-box ${neutralStrokeInputRest};
45
46
  border: calc(${strokeWidth} * 1px) solid transparent;
46
47
  border-radius: calc(${controlCornerRadius} * 1px);
47
48
  height: calc(${heightNumber} * 1px);
@@ -68,25 +69,9 @@ export const inputStyles = (context, definition, rootSelector) => css `
68
69
  visibility: hidden;
69
70
  }
70
71
 
71
- :host(:hover:not([disabled]):not(:focus-within)) ${rootSelector} {
72
- background: padding-box linear-gradient(${neutralFillInputHover}, ${neutralFillInputHover}),
73
- border-box ${neutralStrokeInputHover};
74
- }
75
-
76
- :host(:not([disabled]):focus-within) ${rootSelector} {
77
- background: padding-box linear-gradient(${neutralFillInputFocus}, ${neutralFillInputFocus}),
78
- border-box ${neutralStrokeInputRest};
79
- }
80
-
81
- .control::placeholder {
82
- color: ${placeholderRest};
83
- }
84
-
85
- :host(:hover:not([disabled]):not(:focus-within)) .control::placeholder {
86
- color: ${placeholderHover};
87
- }
88
-
89
- :host([disabled]) ${rootSelector}, :host([readonly]) ${rootSelector}, :host([disabled]) .label,
72
+ :host([disabled]) ${logicalControlSelector},
73
+ :host([readonly]) ${logicalControlSelector},
74
+ :host([disabled]) .label,
90
75
  :host([readonly]) .label,
91
76
  :host([disabled]) .control,
92
77
  :host([readonly]) .control {
@@ -96,113 +81,147 @@ export const inputStyles = (context, definition, rootSelector) => css `
96
81
  :host([disabled]) {
97
82
  opacity: ${disabledOpacity};
98
83
  }
99
-
100
- :host([disabled]) ${rootSelector} {
101
- background: padding-box linear-gradient(${neutralFillInputRest}, ${neutralFillInputRest}),
102
- border-box ${neutralStrokeRest};
84
+ `;
85
+ /**
86
+ * The styles for active and focus interactions for input controls.
87
+ *
88
+ * @internal
89
+ */
90
+ export const inputStateStyles = (context, definition, logicalControlSelector) => css `
91
+ @media (forced-colors: none) {
92
+ :host(:not([disabled]):active)::after {
93
+ left: 50%;
94
+ width: 40%;
95
+ transform: translateX(-50%);
96
+ border-bottom-left-radius: 0;
97
+ border-bottom-right-radius: 0;
98
+ }
99
+
100
+ :host(:not([disabled]):focus-within)::after {
101
+ left: 0;
102
+ width: 100%;
103
+ transform: none;
104
+ }
105
+
106
+ :host(:not([disabled]):active)::after,
107
+ :host(:not([disabled]):focus-within:not(:active))::after {
108
+ content: '';
109
+ position: absolute;
110
+ height: calc(${focusStrokeWidth} * 1px);
111
+ bottom: 0;
112
+ border-bottom: calc(${focusStrokeWidth} * 1px) solid ${accentFillRest};
113
+ border-bottom-left-radius: calc(${controlCornerRadius} * 1px);
114
+ border-bottom-right-radius: calc(${controlCornerRadius} * 1px);
115
+ z-index: 2;
116
+ transition: all 300ms cubic-bezier(0.1, 0.9, 0.2, 1);
117
+ }
103
118
  }
104
119
  `;
105
120
  /**
121
+ * The visual styles for inputs with `appearance='outline'`.
122
+ *
106
123
  * @internal
107
124
  */
108
- export const inputStateStyles = (context, definition, rootSelector) => css `
109
- :host(:not([disabled]):active)::after {
110
- left: 50%;
111
- width: 40%;
112
- transform: translateX(-50%);
113
- border-bottom-left-radius: 0;
114
- border-bottom-right-radius: 0;
125
+ export const inputOutlineStyles = (context, definition, logicalControlSelector, interactivitySelector = ':not([disabled]):not(:focus-within)') => css `
126
+ ${logicalControlSelector} {
127
+ background: padding-box linear-gradient(${neutralFillInputRest}, ${neutralFillInputRest}),
128
+ border-box ${neutralStrokeInputRest};
115
129
  }
116
130
 
117
- :host(:not([disabled]):focus-within)::after {
118
- left: 0;
119
- width: 100%;
120
- transform: none;
131
+ :host(${interactivitySelector}:hover) ${logicalControlSelector} {
132
+ background: padding-box linear-gradient(${neutralFillInputHover}, ${neutralFillInputHover}),
133
+ border-box ${neutralStrokeInputHover};
121
134
  }
122
135
 
123
- :host(:not([disabled]):active)::after,
124
- :host(:not([disabled]):focus-within:not(:active))::after {
125
- content: '';
126
- position: absolute;
127
- height: calc(${focusStrokeWidth} * 1px);
128
- bottom: 0;
129
- border-bottom: calc(${focusStrokeWidth} * 1px) solid ${accentFillRest};
130
- border-bottom-left-radius: calc(${controlCornerRadius} * 1px);
131
- border-bottom-right-radius: calc(${controlCornerRadius} * 1px);
132
- z-index: 2;
133
- transition: all 300ms cubic-bezier(0.1, 0.9, 0.2, 1);
136
+ :host(:not([disabled]):focus-within) ${logicalControlSelector} {
137
+ background: padding-box linear-gradient(${neutralFillInputFocus}, ${neutralFillInputFocus}),
138
+ border-box ${neutralStrokeInputRest};
139
+ }
140
+
141
+ :host([disabled]) ${logicalControlSelector} {
142
+ background: padding-box linear-gradient(${neutralFillInputRest}, ${neutralFillInputRest}),
143
+ border-box ${neutralStrokeRest};
144
+ }
145
+
146
+ .control::placeholder {
147
+ color: ${placeholderRest};
148
+ }
149
+
150
+ :host(${interactivitySelector}:hover) .control::placeholder {
151
+ color: ${placeholderHover};
134
152
  }
135
153
  `;
136
154
  /**
155
+ * The visual styles for inputs with `appearance='filled'`.
156
+ *
137
157
  * @internal
138
158
  */
139
- export const inputFilledStyles = (context, definition, rootSelector) => css `
140
- :host ${rootSelector} {
159
+ export const inputFilledStyles = (context, definition, logicalControlSelector, interactivitySelector = ':not([disabled]):not(:focus-within)') => css `
160
+ ${logicalControlSelector} {
141
161
  background: ${neutralFillSecondaryRest};
142
- border-color: transparent;
143
162
  }
144
163
 
145
- :host(:hover:not([disabled]):not(:focus-within)) ${rootSelector} {
164
+ :host(${interactivitySelector}:hover) ${logicalControlSelector} {
146
165
  background: ${neutralFillSecondaryHover};
147
- border-color: transparent;
166
+ }
167
+
168
+ :host(:not([disabled]):focus-within) ${logicalControlSelector} {
169
+ background: ${neutralFillSecondaryFocus};
170
+ }
171
+
172
+ :host([disabled]) ${logicalControlSelector} {
173
+ background: ${neutralFillSecondaryRest};
148
174
  }
149
175
 
150
176
  .control::placeholder {
151
177
  color: ${filledPlaceholderRest};
152
178
  }
153
179
 
154
- :host(:hover:not([disabled]):not(:focus-within)) .control::placeholder {
180
+ :host(${interactivitySelector}:hover) .control::placeholder {
155
181
  color: ${filledPlaceholderHover};
156
182
  }
157
-
158
- :host(:focus-within:not([disabled])) ${rootSelector} {
159
- border-color: transparent;
160
- }
161
183
  `;
162
184
  /**
163
185
  * @internal
164
186
  */
165
- export const inputForcedColorStyles = (context, definition, rootSelector) => css `
166
- :host ${rootSelector} {
167
- background: ${SystemColors.Field};
168
- border-color: ${SystemColors.FieldText};
187
+ export const inputForcedColorStyles = (context, definition, logicalControlSelector, interactivitySelector = ':not([disabled]):not(:focus-within)') => css `
188
+ :host {
189
+ color: ${SystemColors.ButtonText};
169
190
  }
170
- :host(:hover:not([disabled]):not(:focus-within)) ${rootSelector} {
191
+
192
+ ${logicalControlSelector} {
193
+ background: ${SystemColors.ButtonFace};
194
+ border-color: ${SystemColors.ButtonText};
195
+ }
196
+
197
+ :host(${interactivitySelector}:hover) ${logicalControlSelector},
198
+ :host(:not([disabled]):focus-within) ${logicalControlSelector} {
171
199
  border-color: ${SystemColors.Highlight};
172
200
  }
173
- :host(:not([disabled]):active)::after,
174
- :host(:not([disabled]):focus-within:not(:active))::after {
175
- border-bottom-color: ${SystemColors.Highlight};
201
+
202
+ :host([disabled]) ${logicalControlSelector} {
203
+ opacity: 1;
204
+ background: ${SystemColors.ButtonFace};
205
+ border-color: ${SystemColors.GrayText};
206
+ }
207
+
208
+ .control::placeholder,
209
+ :host(${interactivitySelector}:hover) .control::placeholder {
210
+ color: ${SystemColors.CanvasText};
211
+ }
212
+
213
+ :host(:not([disabled]):focus) ${logicalControlSelector} {
214
+ ${focusTreatmentBase}
215
+ outline-color: ${SystemColors.Highlight};
176
216
  }
217
+
177
218
  :host([disabled]) {
178
219
  opacity: 1;
220
+ color: ${SystemColors.GrayText};
179
221
  }
180
- :host([disabled]) ${rootSelector} {
181
- border-color: ${SystemColors.GrayText};
182
- }
222
+
183
223
  :host([disabled]) ::placeholder,
184
- :host([disabled]) ::-webkit-input-placeholder,
185
- :host([disabled]) .label {
224
+ :host([disabled]) ::-webkit-input-placeholder {
186
225
  color: ${SystemColors.GrayText};
187
- fill: currentcolor;
188
- }
189
- `;
190
- /**
191
- * @internal
192
- */
193
- export const inputFilledForcedColorStyles = (context, definition, rootSelector) => css `
194
- :host ${rootSelector},
195
- :host(:hover:not([disabled])) ${rootSelector},
196
- :host(:active:not([disabled])) ${rootSelector},
197
- :host(:focus-within:not([disabled])) ${rootSelector} {
198
- background: ${SystemColors.Field};
199
- border-color: ${SystemColors.FieldText};
200
- }
201
- :host(:not([disabled]):active)::after,
202
- :host(:not([disabled]):focus-within:not(:active))::after {
203
- border-bottom-color: ${SystemColors.Highlight};
204
- }
205
- :host([disabled]) ${rootSelector} {
206
- border-color: ${SystemColors.GrayText};
207
226
  }
208
227
  `;
@@ -1,19 +1,15 @@
1
1
  import { css } from '@microsoft/fast-element';
2
2
  import { display, forcedColorsStylesheetBehavior, } from '@microsoft/fast-foundation';
3
- import { heightNumber, inputFilledForcedColorStyles, inputFilledStyles, inputForcedColorStyles, inputStateStyles, inputStyles, } from '../styles';
3
+ import { baseInputStyles, heightNumber, inputFilledStyles, inputForcedColorStyles, inputOutlineStyles, inputStateStyles, } from '../styles';
4
4
  import { appearanceBehavior } from '../utilities/behaviors';
5
5
  import { designUnit } from '../design-tokens';
6
- export const textAreaFilledStyles = (context, definition) => css `
7
- ${inputFilledStyles(context, definition, '.control')}
8
- `.withBehaviors(forcedColorsStylesheetBehavior(css `
9
- ${inputFilledForcedColorStyles(context, definition, '.control')}
10
- `));
6
+ const logicalControlSelector = '.control';
11
7
  export const textAreaStyles = (context, definition) => css `
12
8
  ${display('inline-flex')}
13
9
 
14
- ${inputStyles(context, definition, '.control')}
10
+ ${baseInputStyles(context, definition, logicalControlSelector)}
15
11
 
16
- ${inputStateStyles(context, definition, '.control')}
12
+ ${inputStateStyles(context, definition, logicalControlSelector)}
17
13
 
18
14
  :host {
19
15
  flex-direction: column;
@@ -40,6 +36,4 @@ export const textAreaStyles = (context, definition) => css `
40
36
  :host(.resize-vertical) .control {
41
37
  resize: vertical;
42
38
  }
43
- `.withBehaviors(appearanceBehavior('filled', textAreaFilledStyles(context, definition)), forcedColorsStylesheetBehavior(css `
44
- ${inputForcedColorStyles(context, definition, '.control')}
45
- `));
39
+ `.withBehaviors(appearanceBehavior('outline', inputOutlineStyles(context, definition, logicalControlSelector)), appearanceBehavior('filled', inputFilledStyles(context, definition, logicalControlSelector)), forcedColorsStylesheetBehavior(inputForcedColorStyles(context, definition, logicalControlSelector)));
@@ -1,19 +1,15 @@
1
1
  import { css } from '@microsoft/fast-element';
2
2
  import { display, forcedColorsStylesheetBehavior, } from '@microsoft/fast-foundation';
3
- import { inputFilledForcedColorStyles, inputFilledStyles, inputForcedColorStyles, inputStateStyles, inputStyles, } from '../styles';
3
+ import { baseInputStyles, inputFilledStyles, inputForcedColorStyles, inputOutlineStyles, inputStateStyles, } from '../styles';
4
4
  import { appearanceBehavior } from '../utilities/behaviors';
5
5
  import { designUnit } from '../design-tokens';
6
- export const textFieldFilledStyles = (context, definition) => css `
7
- ${inputFilledStyles(context, definition, '.root')}
8
- `.withBehaviors(forcedColorsStylesheetBehavior(css `
9
- ${inputFilledForcedColorStyles(context, definition, '.root')}
10
- `));
6
+ const logicalControlSelector = '.root';
11
7
  export const textFieldStyles = (context, definition) => css `
12
8
  ${display('inline-block')}
13
9
 
14
- ${inputStyles(context, definition, '.root')}
10
+ ${baseInputStyles(context, definition, logicalControlSelector)}
15
11
 
16
- ${inputStateStyles(context, definition, '.root')}
12
+ ${inputStateStyles(context, definition, logicalControlSelector)}
17
13
 
18
14
  .root {
19
15
  display: flex;
@@ -49,6 +45,4 @@ export const textFieldStyles = (context, definition) => css `
49
45
  display: flex;
50
46
  margin-inline-end: 11px;
51
47
  }
52
- `.withBehaviors(appearanceBehavior('filled', textFieldFilledStyles(context, definition)), forcedColorsStylesheetBehavior(css `
53
- ${inputForcedColorStyles(context, definition, '.root')}
54
- `));
48
+ `.withBehaviors(appearanceBehavior('outline', inputOutlineStyles(context, definition, logicalControlSelector)), appearanceBehavior('filled', inputFilledStyles(context, definition, logicalControlSelector)), forcedColorsStylesheetBehavior(inputForcedColorStyles(context, definition, logicalControlSelector)));