@fluentui/react-field 9.0.0-alpha.8 → 9.0.0-beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. package/.swcrc +30 -0
  2. package/CHANGELOG.json +668 -1
  3. package/CHANGELOG.md +241 -2
  4. package/README.md +66 -1
  5. package/dist/index.d.ts +153 -80
  6. package/lib/Field.js.map +1 -1
  7. package/lib/components/Field/Field.js +13 -0
  8. package/lib/components/Field/Field.js.map +1 -0
  9. package/lib/components/Field/Field.types.js +1 -1
  10. package/lib/components/Field/Field.types.js.map +1 -1
  11. package/lib/components/Field/index.js +1 -0
  12. package/lib/components/Field/index.js.map +1 -1
  13. package/lib/components/Field/renderField.js +11 -9
  14. package/lib/components/Field/renderField.js.map +1 -1
  15. package/lib/components/Field/useField.js +32 -98
  16. package/lib/components/Field/useField.js.map +1 -1
  17. package/lib/components/Field/useFieldStyles.js +61 -76
  18. package/lib/components/Field/useFieldStyles.js.map +1 -1
  19. package/lib/contexts/FieldContext.js +5 -0
  20. package/lib/contexts/FieldContext.js.map +1 -0
  21. package/lib/contexts/index.js +4 -0
  22. package/lib/contexts/index.js.map +1 -0
  23. package/lib/contexts/useFieldContextValues.js +33 -0
  24. package/lib/contexts/useFieldContextValues.js.map +1 -0
  25. package/lib/contexts/useFieldControlProps.js +65 -0
  26. package/lib/contexts/useFieldControlProps.js.map +1 -0
  27. package/lib/index.js +4 -1
  28. package/lib/index.js.map +1 -1
  29. package/lib/util/makeDeprecatedField.js +68 -0
  30. package/lib/util/makeDeprecatedField.js.map +1 -0
  31. package/lib-commonjs/Field.js +4 -5
  32. package/lib-commonjs/Field.js.map +1 -1
  33. package/lib-commonjs/components/Field/Field.js +23 -0
  34. package/lib-commonjs/components/Field/Field.js.map +1 -0
  35. package/lib-commonjs/components/Field/Field.types.js +5 -2
  36. package/lib-commonjs/components/Field/Field.types.js.map +1 -1
  37. package/lib-commonjs/components/Field/index.js +8 -11
  38. package/lib-commonjs/components/Field/index.js.map +1 -1
  39. package/lib-commonjs/components/Field/renderField.js +19 -26
  40. package/lib-commonjs/components/Field/renderField.js.map +1 -1
  41. package/lib-commonjs/components/Field/useField.js +71 -155
  42. package/lib-commonjs/components/Field/useField.js.map +1 -1
  43. package/lib-commonjs/components/Field/useFieldStyles.js +138 -118
  44. package/lib-commonjs/components/Field/useFieldStyles.js.map +1 -1
  45. package/lib-commonjs/contexts/FieldContext.js +21 -0
  46. package/lib-commonjs/contexts/FieldContext.js.map +1 -0
  47. package/lib-commonjs/contexts/index.js +11 -0
  48. package/lib-commonjs/contexts/index.js.map +1 -0
  49. package/lib-commonjs/contexts/useFieldContextValues.js +44 -0
  50. package/lib-commonjs/contexts/useFieldContextValues.js.map +1 -0
  51. package/lib-commonjs/contexts/useFieldControlProps.js +71 -0
  52. package/lib-commonjs/contexts/useFieldControlProps.js.map +1 -0
  53. package/lib-commonjs/index.js +24 -29
  54. package/lib-commonjs/index.js.map +1 -1
  55. package/lib-commonjs/util/makeDeprecatedField.js +61 -0
  56. package/lib-commonjs/util/makeDeprecatedField.js.map +1 -0
  57. package/package.json +15 -13
  58. package/Spec.md +0 -354
  59. package/lib/components/Field/SlotComponent.types.js +0 -2
  60. package/lib/components/Field/SlotComponent.types.js.map +0 -1
  61. package/lib-commonjs/components/Field/SlotComponent.types.js +0 -6
  62. package/lib-commonjs/components/Field/SlotComponent.types.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,12 +1,251 @@
1
1
  # Change Log - @fluentui/react-field
2
2
 
3
- This log was last generated on Fri, 11 Nov 2022 14:53:50 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 06 Apr 2023 23:59:47 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
+ ## [9.0.0-beta.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-beta.1)
8
+
9
+ Thu, 06 Apr 2023 23:59:47 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.29..@fluentui/react-field_v9.0.0-beta.1)
11
+
12
+ ### Changes
13
+
14
+ - feat: Add FieldContext to pass props to controls inside Field ([PR #27399](https://github.com/microsoft/fluentui/pull/27399) by behowell@microsoft.com)
15
+ - chore: Bump react-field version to beta ([PR #27458](https://github.com/microsoft/fluentui/pull/27458) by behowell@microsoft.com)
16
+
17
+ ## [9.0.0-alpha.29](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.29)
18
+
19
+ Tue, 04 Apr 2023 18:44:50 GMT
20
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.27..@fluentui/react-field_v9.0.0-alpha.29)
21
+
22
+ ### Changes
23
+
24
+ - Bump @fluentui/react-context-selector to v9.1.16 ([PR #27434](https://github.com/microsoft/fluentui/pull/27434) by beachball)
25
+ - Bump @fluentui/react-label to v9.1.7 ([PR #27434](https://github.com/microsoft/fluentui/pull/27434) by beachball)
26
+ - Bump @fluentui/react-utilities to v9.7.3 ([PR #27434](https://github.com/microsoft/fluentui/pull/27434) by beachball)
27
+
28
+ ## [9.0.0-alpha.27](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.27)
29
+
30
+ Tue, 21 Mar 2023 21:23:34 GMT
31
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.26..@fluentui/react-field_v9.0.0-alpha.27)
32
+
33
+ ### Changes
34
+
35
+ - chore: Bumping version of @fluentui/react-icons to ^2.0.196. ([PR #27100](https://github.com/microsoft/fluentui/pull/27100) by makotom@microsoft.com)
36
+ - chore: migrate to swc transpilation approach. ([PR #27250](https://github.com/microsoft/fluentui/pull/27250) by tristan.watanabe@gmail.com)
37
+ - fix: add node field to package.json exports map. ([PR #27154](https://github.com/microsoft/fluentui/pull/27154) by tristan.watanabe@gmail.com)
38
+ - Bump @fluentui/react-context-selector to v9.1.15 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
39
+ - Bump @fluentui/react-label to v9.1.5 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
40
+ - Bump @fluentui/react-theme to v9.1.7 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
41
+ - Bump @fluentui/react-utilities to v9.7.2 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
42
+ - Bump @fluentui/react-conformance-griffel to v9.0.0-beta.20 ([PR #27271](https://github.com/microsoft/fluentui/pull/27271) by beachball)
43
+
44
+ ## [9.0.0-alpha.26](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.26)
45
+
46
+ Thu, 16 Mar 2023 14:36:59 GMT
47
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.25..@fluentui/react-field_v9.0.0-alpha.26)
48
+
49
+ ### Changes
50
+
51
+ - Bump @fluentui/react-context-selector to v9.1.14 ([PR #27229](https://github.com/microsoft/fluentui/pull/27229) by beachball)
52
+ - Bump @fluentui/react-label to v9.1.4 ([PR #27229](https://github.com/microsoft/fluentui/pull/27229) by beachball)
53
+ - Bump @fluentui/react-utilities to v9.7.1 ([PR #27229](https://github.com/microsoft/fluentui/pull/27229) by beachball)
54
+
55
+ ## [9.0.0-alpha.25](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.25)
56
+
57
+ Wed, 15 Mar 2023 10:19:53 GMT
58
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.24..@fluentui/react-field_v9.0.0-alpha.25)
59
+
60
+ ### Changes
61
+
62
+ - Bump @fluentui/react-label to v9.1.3 ([PR #27213](https://github.com/microsoft/fluentui/pull/27213) by beachball)
63
+ - Bump @fluentui/react-theme to v9.1.6 ([PR #27213](https://github.com/microsoft/fluentui/pull/27213) by beachball)
64
+
65
+ ## [9.0.0-alpha.24](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.24)
66
+
67
+ Mon, 13 Mar 2023 08:58:26 GMT
68
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.23..@fluentui/react-field_v9.0.0-alpha.24)
69
+
70
+ ### Changes
71
+
72
+ - Bump @fluentui/react-context-selector to v9.1.13 ([PR #27161](https://github.com/microsoft/fluentui/pull/27161) by beachball)
73
+ - Bump @fluentui/react-label to v9.1.2 ([PR #27161](https://github.com/microsoft/fluentui/pull/27161) by beachball)
74
+ - Bump @fluentui/react-utilities to v9.7.0 ([PR #27161](https://github.com/microsoft/fluentui/pull/27161) by beachball)
75
+
76
+ ## [9.0.0-alpha.23](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.23)
77
+
78
+ Fri, 10 Mar 2023 07:14:01 GMT
79
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.22..@fluentui/react-field_v9.0.0-alpha.23)
80
+
81
+ ### Changes
82
+
83
+ - Bump @fluentui/react-context-selector to v9.1.12 ([PR #27157](https://github.com/microsoft/fluentui/pull/27157) by beachball)
84
+ - Bump @fluentui/react-label to v9.1.1 ([PR #27157](https://github.com/microsoft/fluentui/pull/27157) by beachball)
85
+ - Bump @fluentui/react-utilities to v9.6.2 ([PR #27157](https://github.com/microsoft/fluentui/pull/27157) by beachball)
86
+
87
+ ## [9.0.0-alpha.22](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.22)
88
+
89
+ Wed, 08 Mar 2023 17:42:51 GMT
90
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.21..@fluentui/react-field_v9.0.0-alpha.22)
91
+
92
+ ### Changes
93
+
94
+ - Bump @fluentui/react-context-selector to v9.1.11 ([PR #27127](https://github.com/microsoft/fluentui/pull/27127) by beachball)
95
+ - Bump @fluentui/react-label to v9.1.0 ([PR #27127](https://github.com/microsoft/fluentui/pull/27127) by beachball)
96
+ - Bump @fluentui/react-utilities to v9.6.1 ([PR #27127](https://github.com/microsoft/fluentui/pull/27127) by beachball)
97
+
98
+ ## [9.0.0-alpha.21](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.21)
99
+
100
+ Wed, 15 Feb 2023 11:44:52 GMT
101
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.20..@fluentui/react-field_v9.0.0-alpha.21)
102
+
103
+ ### Changes
104
+
105
+ - Bump @fluentui/react-context-selector to v9.1.10 ([PR #26845](https://github.com/microsoft/fluentui/pull/26845) by beachball)
106
+ - Bump @fluentui/react-label to v9.0.22 ([PR #26845](https://github.com/microsoft/fluentui/pull/26845) by beachball)
107
+ - Bump @fluentui/react-utilities to v9.6.0 ([PR #26845](https://github.com/microsoft/fluentui/pull/26845) by beachball)
108
+
109
+ ## [9.0.0-alpha.20](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.20)
110
+
111
+ Mon, 13 Feb 2023 23:43:14 GMT
112
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.19..@fluentui/react-field_v9.0.0-alpha.20)
113
+
114
+ ### Changes
115
+
116
+ - Bump @fluentui/react-context-selector to v9.1.9 ([PR #26814](https://github.com/microsoft/fluentui/pull/26814) by beachball)
117
+ - Bump @fluentui/react-label to v9.0.21 ([PR #26814](https://github.com/microsoft/fluentui/pull/26814) by beachball)
118
+ - Bump @fluentui/react-utilities to v9.5.3 ([PR #26814](https://github.com/microsoft/fluentui/pull/26814) by beachball)
119
+
120
+ ## [9.0.0-alpha.19](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.19)
121
+
122
+ Fri, 10 Feb 2023 08:49:59 GMT
123
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.18..@fluentui/react-field_v9.0.0-alpha.19)
124
+
125
+ ### Changes
126
+
127
+ - Bump @fluentui/react-context-selector to v9.1.8 ([commit](https://github.com/microsoft/fluentui/commit/cc62f050f8231e8f21a2cf7dddf33003e0ba3931) by beachball)
128
+ - Bump @fluentui/react-label to v9.0.20 ([commit](https://github.com/microsoft/fluentui/commit/cc62f050f8231e8f21a2cf7dddf33003e0ba3931) by beachball)
129
+ - Bump @fluentui/react-utilities to v9.5.2 ([commit](https://github.com/microsoft/fluentui/commit/cc62f050f8231e8f21a2cf7dddf33003e0ba3931) by beachball)
130
+
131
+ ## [9.0.0-alpha.18](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.18)
132
+
133
+ Tue, 31 Jan 2023 19:53:56 GMT
134
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.17..@fluentui/react-field_v9.0.0-alpha.18)
135
+
136
+ ### Changes
137
+
138
+ - chore: Change the default value of validationState to error when a validationMessage is set. ([PR #26523](https://github.com/microsoft/fluentui/pull/26523) by behowell@microsoft.com)
139
+ - Bump @fluentui/react-context-selector to v9.1.7 ([PR #26557](https://github.com/microsoft/fluentui/pull/26557) by beachball)
140
+ - Bump @fluentui/react-label to v9.0.19 ([PR #26557](https://github.com/microsoft/fluentui/pull/26557) by beachball)
141
+ - Bump @fluentui/react-utilities to v9.5.1 ([PR #26557](https://github.com/microsoft/fluentui/pull/26557) by beachball)
142
+
143
+ ## [9.0.0-alpha.17](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.17)
144
+
145
+ Thu, 26 Jan 2023 13:30:56 GMT
146
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.16..@fluentui/react-field_v9.0.0-alpha.17)
147
+
148
+ ### Changes
149
+
150
+ - Implement Field component to replace InputField, ComboboxField, etc. ([PR #26430](https://github.com/microsoft/fluentui/pull/26430) by behowell@microsoft.com)
151
+ - Bump @fluentui/react-context-selector to v9.1.6 ([PR #26496](https://github.com/microsoft/fluentui/pull/26496) by beachball)
152
+ - Bump @fluentui/react-label to v9.0.18 ([PR #26496](https://github.com/microsoft/fluentui/pull/26496) by beachball)
153
+ - Bump @fluentui/react-utilities to v9.5.0 ([PR #26496](https://github.com/microsoft/fluentui/pull/26496) by beachball)
154
+
155
+ ## [9.0.0-alpha.16](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.16)
156
+
157
+ Mon, 23 Jan 2023 16:43:09 GMT
158
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.15..@fluentui/react-field_v9.0.0-alpha.16)
159
+
160
+ ### Changes
161
+
162
+ - chore: Simplify Field layout styles ([PR #26352](https://github.com/microsoft/fluentui/pull/26352) by behowell@microsoft.com)
163
+ - fix: Stretch Field components to full width ([PR #26412](https://github.com/microsoft/fluentui/pull/26412) by behowell@microsoft.com)
164
+ - fix: Update Field label padding to match spec ([PR #26413](https://github.com/microsoft/fluentui/pull/26413) by behowell@microsoft.com)
165
+ - fix: Field sets role="alert" on its error message so it is announced by screen readers ([PR #26414](https://github.com/microsoft/fluentui/pull/26414) by behowell@microsoft.com)
166
+
167
+ ## [9.0.0-alpha.15](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.15)
168
+
169
+ Mon, 16 Jan 2023 08:39:01 GMT
170
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.14..@fluentui/react-field_v9.0.0-alpha.15)
171
+
172
+ ### Changes
173
+
174
+ - fix: Field styles do not wrap SVG status icon in inline parent to avoid layout bugs ([PR #26150](https://github.com/microsoft/fluentui/pull/26150) by sarah.higley@microsoft.com)
175
+ - Bump @fluentui/react-label to v9.0.17 ([commit](https://github.com/microsoft/fluentui/commit/a870d8360e47f3ea03358c4e75e89e08a74845d7) by beachball)
176
+
177
+ ## [9.0.0-alpha.14](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.14)
178
+
179
+ Mon, 09 Jan 2023 14:35:02 GMT
180
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.13..@fluentui/react-field_v9.0.0-alpha.14)
181
+
182
+ ### Changes
183
+
184
+ - Bump @fluentui/react-context-selector to v9.1.5 ([PR #26255](https://github.com/microsoft/fluentui/pull/26255) by beachball)
185
+ - Bump @fluentui/react-label to v9.0.16 ([PR #26255](https://github.com/microsoft/fluentui/pull/26255) by beachball)
186
+ - Bump @fluentui/react-utilities to v9.4.0 ([PR #26255](https://github.com/microsoft/fluentui/pull/26255) by beachball)
187
+
188
+ ## [9.0.0-alpha.13](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.13)
189
+
190
+ Wed, 04 Jan 2023 01:40:06 GMT
191
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.12..@fluentui/react-field_v9.0.0-alpha.13)
192
+
193
+ ### Changes
194
+
195
+ - chore: Update Griffel to latest version ([PR #26045](https://github.com/microsoft/fluentui/pull/26045) by olfedias@microsoft.com)
196
+ - Bump @fluentui/react-context-selector to v9.1.4 ([PR #26114](https://github.com/microsoft/fluentui/pull/26114) by beachball)
197
+ - Bump @fluentui/react-label to v9.0.15 ([PR #26114](https://github.com/microsoft/fluentui/pull/26114) by beachball)
198
+ - Bump @fluentui/react-utilities to v9.3.1 ([PR #26114](https://github.com/microsoft/fluentui/pull/26114) by beachball)
199
+ - Bump @fluentui/react-conformance-griffel to v9.0.0-beta.19 ([PR #26114](https://github.com/microsoft/fluentui/pull/26114) by beachball)
200
+
201
+ ## [9.0.0-alpha.12](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.12)
202
+
203
+ Wed, 21 Dec 2022 10:20:33 GMT
204
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.11..@fluentui/react-field_v9.0.0-alpha.12)
205
+
206
+ ### Changes
207
+
208
+ - Bump @fluentui/react-label to v9.0.14 ([commit](https://github.com/microsoft/fluentui/commit/66bf89f634cad4a275e957d7a2214c7e73ff8c2e) by beachball)
209
+ - Bump @fluentui/react-theme to v9.1.5 ([commit](https://github.com/microsoft/fluentui/commit/66bf89f634cad4a275e957d7a2214c7e73ff8c2e) by beachball)
210
+
211
+ ## [9.0.0-alpha.11](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.11)
212
+
213
+ Tue, 20 Dec 2022 14:59:25 GMT
214
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.10..@fluentui/react-field_v9.0.0-alpha.11)
215
+
216
+ ### Changes
217
+
218
+ - Bump @fluentui/react-context-selector to v9.1.3 ([PR #26047](https://github.com/microsoft/fluentui/pull/26047) by beachball)
219
+ - Bump @fluentui/react-label to v9.0.13 ([PR #26047](https://github.com/microsoft/fluentui/pull/26047) by beachball)
220
+ - Bump @fluentui/react-theme to v9.1.4 ([PR #26047](https://github.com/microsoft/fluentui/pull/26047) by beachball)
221
+ - Bump @fluentui/react-utilities to v9.3.0 ([PR #26047](https://github.com/microsoft/fluentui/pull/26047) by beachball)
222
+
223
+ ## [9.0.0-alpha.10](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.10)
224
+
225
+ Mon, 05 Dec 2022 18:29:23 GMT
226
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.9..@fluentui/react-field_v9.0.0-alpha.10)
227
+
228
+ ### Changes
229
+
230
+ - fix: Field should use aria-describedby instead of aria-errormessage ([PR #25580](https://github.com/microsoft/fluentui/pull/25580) by behowell@microsoft.com)
231
+ - chore: Migrate to new package structure. ([PR #25817](https://github.com/microsoft/fluentui/pull/25817) by tristan.watanabe@gmail.com)
232
+ - Bump @fluentui/react-label to v9.0.12 ([PR #25798](https://github.com/microsoft/fluentui/pull/25798) by beachball)
233
+ - Bump @fluentui/react-theme to v9.1.3 ([PR #25798](https://github.com/microsoft/fluentui/pull/25798) by beachball)
234
+
235
+ ## [9.0.0-alpha.9](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.9)
236
+
237
+ Thu, 17 Nov 2022 23:05:39 GMT
238
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.8..@fluentui/react-field_v9.0.0-alpha.9)
239
+
240
+ ### Changes
241
+
242
+ - Bump @fluentui/react-context-selector to v9.1.2 ([PR #25683](https://github.com/microsoft/fluentui/pull/25683) by beachball)
243
+ - Bump @fluentui/react-label to v9.0.11 ([PR #25683](https://github.com/microsoft/fluentui/pull/25683) by beachball)
244
+ - Bump @fluentui/react-utilities to v9.2.2 ([PR #25683](https://github.com/microsoft/fluentui/pull/25683) by beachball)
245
+
7
246
  ## [9.0.0-alpha.8](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.8)
8
247
 
9
- Fri, 11 Nov 2022 14:53:50 GMT
248
+ Fri, 11 Nov 2022 14:58:03 GMT
10
249
  [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.7..@fluentui/react-field_v9.0.0-alpha.8)
11
250
 
12
251
  ### Changes
package/README.md CHANGED
@@ -1,5 +1,70 @@
1
1
  # @fluentui/react-field
2
2
 
3
- **React Field components for [Fluent UI React](https://react.fluentui.dev/)**
3
+ **React Field component for [Fluent UI React](https://react.fluentui.dev/)**
4
4
 
5
5
  These are not production-ready components and **should never be used in product**. This space is useful for testing new components whose APIs might change before final release.
6
+
7
+ ## Description
8
+
9
+ Field adds a label, validation message, and hint text to a control. Any single form control can be used as the child of the Field.
10
+
11
+ ## Usage
12
+
13
+ To import Field:
14
+
15
+ ```js
16
+ import { Field } from '@fluentui/react-components/unstable';
17
+ ```
18
+
19
+ ### Examples
20
+
21
+ Works with many form controls, for example:
22
+
23
+ ```jsx
24
+ <>
25
+ <Field label="Name">
26
+ <Input />
27
+ </Field>
28
+ <Field label="Description">
29
+ <Textarea />
30
+ </Field>
31
+ <Field label="Size">
32
+ <RadioGroup>
33
+ <Radio label="Small" />
34
+ <Radio label="Medium" />
35
+ <Radio label="Large" />
36
+ </RadioGroup>
37
+ </Field>
38
+ </>
39
+ ```
40
+
41
+ Display hint text:
42
+
43
+ ```jsx
44
+ <Field label="Password" hint="Must be at least 8 characters long.">
45
+ <Input type="password" />
46
+ </Field>
47
+ ```
48
+
49
+ Display an error message:
50
+
51
+ ```jsx
52
+ <Field label="Re-enter password" validationMessage="Passwords do not match.">
53
+ <Input type="password" />
54
+ </Field>
55
+ ```
56
+
57
+ See [Fluent UI Storybook](https://react.fluentui.dev/) for more detailed usage examples.
58
+
59
+ Alternatively, run Storybook locally with:
60
+
61
+ 1. `yarn start`
62
+ 2. Select `react-field` from the list.
63
+
64
+ ### Specification
65
+
66
+ See [SPEC.md](./SPEC.md).
67
+
68
+ ### Migration Guide
69
+
70
+ If you're upgrading to Fluent UI v9 see [MIGRATION.md](./MIGRATION.md) for guidance on updating the Field component.
package/dist/index.d.ts CHANGED
@@ -2,55 +2,95 @@
2
2
 
3
3
  import type { ComponentProps } from '@fluentui/react-utilities';
4
4
  import type { ComponentState } from '@fluentui/react-utilities';
5
+ import { ForwardRefComponent } from '@fluentui/react-utilities';
5
6
  import { Label } from '@fluentui/react-label';
6
7
  import * as React_2 from 'react';
7
8
  import type { Slot } from '@fluentui/react-utilities';
8
9
  import type { SlotClassNames } from '@fluentui/react-utilities';
9
- import type { SlotRenderFunction } from '@fluentui/react-utilities';
10
- import type { SlotShorthandValue } from '@fluentui/react-utilities';
11
10
 
12
11
  /**
13
- * Configuration parameters for a Field class, passed to useField_unstable
12
+ * @deprecated Only for use to make deprecated [Control]Field shim components.
13
+ * @internal
14
14
  */
15
- export declare type FieldConfig<T extends FieldControl> = {
16
- /**
17
- * The underlying input component that this field is wrapping.
18
- */
19
- component: T;
15
+ export declare type DeprecatedFieldProps<ControlProps> = ControlProps & {
16
+ root?: FieldProps;
17
+ control?: ControlProps;
18
+ } & Pick<FieldProps, 'className' | 'hint' | 'label' | 'orientation' | 'style' | 'validationMessage' | 'validationMessageIcon' | 'validationState'>;
19
+
20
+ export declare const Field: ForwardRefComponent<FieldProps>;
21
+
22
+ export declare const fieldClassNames: SlotClassNames<FieldSlots>;
23
+
24
+ export declare const FieldContextProvider: React_2.Provider<Readonly<Pick<FieldState, "orientation" | "required" | "size" | "validationState" | "generatedControlId"> & {
25
+ labelFor?: string | undefined;
26
+ labelId?: string | undefined;
27
+ validationMessageId?: string | undefined;
28
+ hintId?: string | undefined;
29
+ }> | undefined>;
30
+
31
+ export declare type FieldContextValue = Readonly<Pick<FieldState, 'generatedControlId' | 'orientation' | 'required' | 'size' | 'validationState'> & {
32
+ /** The label's for prop. Undefined if there is no label. */
33
+ labelFor?: string;
34
+ /** The label's id prop. Undefined if there is no label. */
35
+ labelId?: string;
36
+ /** The validationMessage's id prop. Undefined if there is no validationMessage. */
37
+ validationMessageId?: string;
38
+ /** The hint's id prop. Undefined if there is no hint. */
39
+ hintId?: string;
40
+ }>;
41
+
42
+ export declare type FieldContextValues = {
43
+ field: FieldContextValue;
44
+ };
45
+
46
+ /**
47
+ * The props added to the control inside the Field.
48
+ */
49
+ export declare type FieldControlProps = Pick<React_2.HTMLAttributes<HTMLElement>, 'id' | 'aria-labelledby' | 'aria-describedby' | 'aria-invalid' | 'aria-required'>;
50
+
51
+ /**
52
+ * Options for `useFieldControlProps_unstable`.
53
+ */
54
+ export declare type FieldControlPropsOptions = {
20
55
  /**
21
- * Class names for this component, created by `getFieldClassNames`.
56
+ * Skips setting `aria-labelledby` on the control if the `label.htmlFor` refers to the control.
57
+ *
58
+ * This should be used with controls that can be the target of a label's `for` prop:
59
+ * `<button>`, `<input>`, `<progress>`, `<select>`, `<textarea>`.
22
60
  */
23
- classNames: SlotClassNames<FieldSlots<T>>;
61
+ supportsLabelFor?: boolean;
24
62
  /**
25
- * How the label be connected to the control.
26
- * * htmlFor - Set the Label's htmlFor prop to the component's ID (and generate an ID if not provided).
27
- * This is the preferred method for components that use the underlying <input> tag.
28
- * * aria-labelledby - Set the component's aria-labelledby prop to the Label's ID. Use this for components
29
- * that are not directly <input> elements (such as RadioGroup).
63
+ * Sets `required` instead of `aria-required` when the Field is marked required.
30
64
  *
31
- * @default htmlFor
65
+ * This should be used with controls that support the `required` prop:
66
+ * `<input>` (except `range` or `color`), `<select>`, `<textarea>`.
32
67
  */
33
- labelConnection?: 'htmlFor' | 'aria-labelledby';
68
+ supportsRequired?: boolean;
34
69
  /**
35
- * Should the aria-invalid and aria-errormessage attributes be set when validationState="error".
70
+ * Sets the size prop on the control to match the Field's size: `'small' | 'medium' | 'large'`.
36
71
  *
37
- * @default true
72
+ * This should be used with controls that have a custom size prop that matches the Field's size prop.
38
73
  */
39
- ariaInvalidOnError?: boolean;
74
+ supportsSize?: boolean;
40
75
  };
41
76
 
42
- /**
43
- * The minimum requirement for a component used by Field.
44
- *
45
- * Note: the use of VoidFunctionComponent means that component is not *required* to have a children prop,
46
- * but it is still allowed to have a children prop.
47
- */
48
- export declare type FieldControl = React_2.VoidFunctionComponent<Pick<React_2.HTMLAttributes<HTMLElement>, 'id' | 'className' | 'style' | 'aria-labelledby' | 'aria-describedby' | 'aria-invalid' | 'aria-errormessage'>>;
49
-
50
77
  /**
51
78
  * Field Props
52
79
  */
53
- export declare type FieldProps<T extends FieldControl> = ComponentProps<Partial<FieldSlots<T>>, 'control'> & {
80
+ export declare type FieldProps = Omit<ComponentProps<FieldSlots>, 'children'> & {
81
+ /**
82
+ * The Field's child can be a single form control, or a render function that takes the props that should be spread on
83
+ * a form control.
84
+ *
85
+ * All form controls in this library can be used directly as children (such as `<Input>` or `<RadioGroup>`).
86
+ *
87
+ * For other controls, there are two options:
88
+ * 1. The child of Field can be a render function that is given the props that should be spread on the control.
89
+ * `<Field>{(props) => <MyInput {...props} />}</Field>`
90
+ * 2. The control itself can merge props from field with useFieldControlProps_unstable().
91
+ * `props = useFieldControlProps_unstable(props);`
92
+ */
93
+ children?: React_2.ReactNode | ((props: FieldControlProps) => React_2.ReactNode);
54
94
  /**
55
95
  * The orientation of the label relative to the field component.
56
96
  * This only affects the label, and not the validationMessage or hint (which always appear below the field component).
@@ -59,56 +99,53 @@ export declare type FieldProps<T extends FieldControl> = ComponentProps<Partial<
59
99
  */
60
100
  orientation?: 'vertical' | 'horizontal';
61
101
  /**
62
- * The `validationState` affects the color of the `validationMessage`, the `validationMessageIcon`, and for some
63
- * field components, an `validationState="error"` causes the border to become red.
102
+ * The `validationState` affects the display of the `validationMessage` and `validationMessageIcon`.
103
+ *
104
+ * * error: (default) The validation message has a red error icon and red text, with `role="alert"` so it is
105
+ * announced by screen readers. Additionally, the control inside the field has `aria-invalid` set, which adds a
106
+ * red border to some field components (such as `Input`).
107
+ * * success: The validation message has a green checkmark icon and gray text.
108
+ * * warning: The validation message has a yellow exclamation icon and gray text.
109
+ * * none: The validation message has no icon and gray text.
64
110
  *
65
- * @default undefined
111
+ * @default error when validationMessage is set; none otherwise.
66
112
  */
67
- validationState?: 'error' | 'warning' | 'success';
68
- };
69
-
70
- /**
71
- * FieldProps plus extra optional props that are supported by useField_unstable, but not required to be part of the
72
- * API of every Field component.
73
- *
74
- * This allows Field to forward the required and size props to the label if the underlying component supports them,
75
- * but doesn't add them to the public API of fields that don't support them.
76
- */
77
- declare type FieldPropsWithOptionalComponentProps<T extends FieldControl> = FieldProps<T> & {
113
+ validationState?: 'error' | 'warning' | 'success' | 'none';
78
114
  /**
79
- * Whether the field label should be marked as required.
115
+ * Marks the Field as required. If `true`, an asterisk will be appended to the label, and `aria-required` will be set
116
+ * on the Field's child.
80
117
  */
81
118
  required?: boolean;
82
119
  /**
83
- * Size of the field label.
120
+ * The size of the Field's label.
84
121
  *
85
- * Number sizes will be ignored, but are allowed because the HTML `<input>` element has a prop `size?: number`.
122
+ * @default medium
86
123
  */
87
- size?: 'small' | 'medium' | 'large' | number;
124
+ size?: 'small' | 'medium' | 'large';
88
125
  };
89
126
 
90
127
  /**
91
- * Slots added by Field
128
+ * Slots of the Field component
92
129
  */
93
- export declare type FieldSlots<T extends FieldControl> = {
130
+ export declare type FieldSlots = {
94
131
  root: NonNullable<Slot<'div'>>;
95
- /**
96
- * The underlying component wrapped by this field.
97
- */
98
- control: SlotComponent<T>;
99
132
  /**
100
133
  * The label associated with the field.
101
134
  */
102
135
  label?: Slot<typeof Label>;
103
136
  /**
104
- * A message about the validation state. The appearance of the `validationMessage` depends on `validationState`.
137
+ * A message about the validation state. By default, this is an error message, but it can be a success, warning,
138
+ * or custom message by setting `validationState`.
105
139
  */
106
140
  validationMessage?: Slot<'div'>;
107
141
  /**
108
- * The icon associated with the `validationMessage`. If the `validationState` prop is set, this will default to an
109
- * icon corresponding to that state.
142
+ * The icon associated with the `validationMessage`. This will only be displayed if `validationMessage` is set.
110
143
  *
111
- * This will only be displayed if `validationMessage` is set.
144
+ * The default depends on `validationState`:
145
+ * * error: `<ErrorCircle12Filled />`
146
+ * * warning: `<Warning12Filled />`
147
+ * * success: `<CheckmarkCircle12Filled />`
148
+ * * none: `null`
112
149
  */
113
150
  validationMessageIcon?: Slot<'span'>;
114
151
  /**
@@ -120,22 +157,39 @@ export declare type FieldSlots<T extends FieldControl> = {
120
157
  /**
121
158
  * State used in rendering Field
122
159
  */
123
- export declare type FieldState<T extends FieldControl> = ComponentState<Required<FieldSlots<T>>> & Pick<FieldProps<T>, 'orientation' | 'validationState'> & {
124
- classNames: SlotClassNames<FieldSlots<T>>;
160
+ export declare type FieldState = ComponentState<Required<FieldSlots>> & Required<Pick<FieldProps, 'orientation' | 'required' | 'size' | 'validationState'>> & Pick<FieldProps, 'children'> & {
161
+ /**
162
+ * The ID generated for the control inside the field, and the default value of label.htmlFor prop.
163
+ */
164
+ generatedControlId: string;
165
+ };
166
+
167
+ /**
168
+ * @deprecated Only for use to make deprecated [Control]Field shim components.
169
+ * @internal
170
+ */
171
+ export declare const getDeprecatedFieldClassNames: (controlRootClassName: string) => {
172
+ control: string;
173
+ root: string;
174
+ label: string;
175
+ validationMessage: string;
176
+ validationMessageIcon: string;
177
+ hint: string;
125
178
  };
126
179
 
127
- export declare const getFieldClassNames: (name: string) => SlotClassNames<FieldSlots<FieldControl>>;
180
+ /**
181
+ * @deprecated Only for use to make deprecated [Control]Field shim components.
182
+ * @internal
183
+ */
184
+ export declare function makeDeprecatedField<ControlProps>(Control: React_2.ComponentType<ControlProps>, options?: {
185
+ mapProps?: (props: DeprecatedFieldProps<ControlProps>) => DeprecatedFieldProps<ControlProps>;
186
+ displayName?: string;
187
+ }): ForwardRefComponent<DeprecatedFieldProps<ControlProps>>;
128
188
 
129
189
  /**
130
190
  * Render the final JSX of Field
131
191
  */
132
- export declare const renderField_unstable: <T extends FieldControl>(state: FieldState<T>) => JSX.Element;
133
-
134
- declare type SlotComponent<Type extends React_2.ComponentType | React_2.VoidFunctionComponent> = WithSlotShorthandValue<Type extends React_2.ComponentType<infer Props> ? WithSlotRenderFunction<Props extends {
135
- children?: unknown;
136
- } ? Props : Props & {
137
- children?: never;
138
- }> : never>;
192
+ export declare const renderField_unstable: (state: FieldState, contextValues?: FieldContextValues | undefined) => JSX.Element;
139
193
 
140
194
  /**
141
195
  * Create the state required to render Field.
@@ -144,24 +198,43 @@ declare type SlotComponent<Type extends React_2.ComponentType | React_2.VoidFunc
144
198
  * before being passed to renderField_unstable.
145
199
  *
146
200
  * @param props - Props passed to this field
147
- * @param ref - Ref to the control slot (primary slot)
148
- * @param params - Configuration parameters for this Field
201
+ * @param ref - Ref to the root
149
202
  */
150
- export declare const useField_unstable: <T extends FieldControl>(props: FieldPropsWithOptionalComponentProps<T>, ref: React_2.Ref<HTMLElement>, params: FieldConfig<T>) => FieldState<T>;
203
+ export declare const useField_unstable: (props: FieldProps, ref: React_2.Ref<HTMLDivElement>) => FieldState;
204
+
205
+ export declare const useFieldContext_unstable: () => Readonly<Pick<FieldState, "orientation" | "required" | "size" | "validationState" | "generatedControlId"> & {
206
+ labelFor?: string | undefined;
207
+ labelId?: string | undefined;
208
+ validationMessageId?: string | undefined;
209
+ hintId?: string | undefined;
210
+ }> | undefined;
151
211
 
152
212
  /**
153
- * Apply styling to the Field slots based on the state
213
+ * Get the context values used when rendering Field.
154
214
  */
155
- export declare const useFieldStyles_unstable: <T extends FieldControl>(state: FieldState<T>) => void;
215
+ export declare const useFieldContextValues_unstable: (state: FieldState) => FieldContextValues;
156
216
 
157
- declare type WithSlotRenderFunction<Props extends {
158
- children?: unknown;
159
- }> = Props & {
160
- children?: Props['children'] | SlotRenderFunction<Props>;
161
- };
217
+ /**
218
+ * Gets the control props from the field context, if this inside a `<Field>`.
219
+ *
220
+ * When called with no arguments, returns the FieldControlProps that should be applied to the control.
221
+ *
222
+ * @returns A FieldControlProps object if inside a `<Field>`, otherwise undefined.
223
+ */
224
+ export declare function useFieldControlProps_unstable(): FieldControlProps | undefined;
162
225
 
163
- declare type WithSlotShorthandValue<Props extends {
164
- children?: unknown;
165
- }> = Props | Extract<SlotShorthandValue, Props['children']>;
226
+ /**
227
+ * Copies and merges the FieldControlProps with the given props, if this inside a `<Field>`.
228
+ *
229
+ * @param props - The existing props for the control. These will be merged with the control props from the field context.
230
+ * @param options - Option to include the size prop.
231
+ * @returns Merged props if inside a `<Field>`, otherwise the original props, or undefined if no props given.
232
+ */
233
+ export declare function useFieldControlProps_unstable<Props extends FieldControlProps>(props: Props, options?: FieldControlPropsOptions): Props;
234
+
235
+ /**
236
+ * Apply styling to the Field slots based on the state
237
+ */
238
+ export declare const useFieldStyles_unstable: (state: FieldState) => void;
166
239
 
167
240
  export { }
package/lib/Field.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Field.js","sourceRoot":"../src/","sources":["Field.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC","sourcesContent":["export * from './components/Field/index';\n"]}
1
+ {"version":3,"names":[],"sources":["../src/Field.ts"],"sourcesContent":["export * from './components/Field/index';\n"],"mappings":"AAAA,cAAc"}