@fluentui/react-field 9.0.0-alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. package/CHANGELOG.json +119 -0
  2. package/CHANGELOG.md +36 -0
  3. package/LICENSE +15 -0
  4. package/README.md +5 -0
  5. package/Spec.md +354 -0
  6. package/dist/index.d.ts +236 -0
  7. package/lib/CheckboxField.js +2 -0
  8. package/lib/CheckboxField.js.map +1 -0
  9. package/lib/ComboboxField.js +2 -0
  10. package/lib/ComboboxField.js.map +1 -0
  11. package/lib/Field.js +2 -0
  12. package/lib/Field.js.map +1 -0
  13. package/lib/InputField.js +2 -0
  14. package/lib/InputField.js.map +1 -0
  15. package/lib/RadioGroupField.js +2 -0
  16. package/lib/RadioGroupField.js.map +1 -0
  17. package/lib/SelectField.js +2 -0
  18. package/lib/SelectField.js.map +1 -0
  19. package/lib/SliderField.js +2 -0
  20. package/lib/SliderField.js.map +1 -0
  21. package/lib/SpinButtonField.js +2 -0
  22. package/lib/SpinButtonField.js.map +1 -0
  23. package/lib/SwitchField.js +2 -0
  24. package/lib/SwitchField.js.map +1 -0
  25. package/lib/TextareaField.js +2 -0
  26. package/lib/TextareaField.js.map +1 -0
  27. package/lib/components/CheckboxField/CheckboxField.js +32 -0
  28. package/lib/components/CheckboxField/CheckboxField.js.map +1 -0
  29. package/lib/components/CheckboxField/index.js +2 -0
  30. package/lib/components/CheckboxField/index.js.map +1 -0
  31. package/lib/components/ComboboxField/ComboboxField.js +14 -0
  32. package/lib/components/ComboboxField/ComboboxField.js.map +1 -0
  33. package/lib/components/ComboboxField/index.js +2 -0
  34. package/lib/components/ComboboxField/index.js.map +1 -0
  35. package/lib/components/Field/Field.types.js +2 -0
  36. package/lib/components/Field/Field.types.js.map +1 -0
  37. package/lib/components/Field/SlotComponent.types.js +2 -0
  38. package/lib/components/Field/SlotComponent.types.js.map +1 -0
  39. package/lib/components/Field/index.js +5 -0
  40. package/lib/components/Field/index.js.map +1 -0
  41. package/lib/components/Field/renderField.js +20 -0
  42. package/lib/components/Field/renderField.js.map +1 -0
  43. package/lib/components/Field/useField.js +139 -0
  44. package/lib/components/Field/useField.js.map +1 -0
  45. package/lib/components/Field/useFieldStyles.js +121 -0
  46. package/lib/components/Field/useFieldStyles.js.map +1 -0
  47. package/lib/components/InputField/InputField.js +14 -0
  48. package/lib/components/InputField/InputField.js.map +1 -0
  49. package/lib/components/InputField/index.js +2 -0
  50. package/lib/components/InputField/index.js.map +1 -0
  51. package/lib/components/RadioGroupField/RadioGroupField.js +15 -0
  52. package/lib/components/RadioGroupField/RadioGroupField.js.map +1 -0
  53. package/lib/components/RadioGroupField/index.js +2 -0
  54. package/lib/components/RadioGroupField/index.js.map +1 -0
  55. package/lib/components/SelectField/SelectField.js +14 -0
  56. package/lib/components/SelectField/SelectField.js.map +1 -0
  57. package/lib/components/SelectField/index.js +2 -0
  58. package/lib/components/SelectField/index.js.map +1 -0
  59. package/lib/components/SliderField/SliderField.js +14 -0
  60. package/lib/components/SliderField/SliderField.js.map +1 -0
  61. package/lib/components/SliderField/index.js +2 -0
  62. package/lib/components/SliderField/index.js.map +1 -0
  63. package/lib/components/SpinButtonField/SpinButtonField.js +14 -0
  64. package/lib/components/SpinButtonField/SpinButtonField.js.map +1 -0
  65. package/lib/components/SpinButtonField/index.js +2 -0
  66. package/lib/components/SpinButtonField/index.js.map +1 -0
  67. package/lib/components/SwitchField/SwitchField.js +14 -0
  68. package/lib/components/SwitchField/SwitchField.js.map +1 -0
  69. package/lib/components/SwitchField/index.js +2 -0
  70. package/lib/components/SwitchField/index.js.map +1 -0
  71. package/lib/components/TextareaField/TextareaField.js +14 -0
  72. package/lib/components/TextareaField/TextareaField.js.map +1 -0
  73. package/lib/components/TextareaField/index.js +2 -0
  74. package/lib/components/TextareaField/index.js.map +1 -0
  75. package/lib/index.js +11 -0
  76. package/lib/index.js.map +1 -0
  77. package/lib-commonjs/CheckboxField.js +10 -0
  78. package/lib-commonjs/CheckboxField.js.map +1 -0
  79. package/lib-commonjs/ComboboxField.js +10 -0
  80. package/lib-commonjs/ComboboxField.js.map +1 -0
  81. package/lib-commonjs/Field.js +10 -0
  82. package/lib-commonjs/Field.js.map +1 -0
  83. package/lib-commonjs/InputField.js +10 -0
  84. package/lib-commonjs/InputField.js.map +1 -0
  85. package/lib-commonjs/RadioGroupField.js +10 -0
  86. package/lib-commonjs/RadioGroupField.js.map +1 -0
  87. package/lib-commonjs/SelectField.js +10 -0
  88. package/lib-commonjs/SelectField.js.map +1 -0
  89. package/lib-commonjs/SliderField.js +10 -0
  90. package/lib-commonjs/SliderField.js.map +1 -0
  91. package/lib-commonjs/SpinButtonField.js +10 -0
  92. package/lib-commonjs/SpinButtonField.js.map +1 -0
  93. package/lib-commonjs/SwitchField.js +10 -0
  94. package/lib-commonjs/SwitchField.js.map +1 -0
  95. package/lib-commonjs/TextareaField.js +10 -0
  96. package/lib-commonjs/TextareaField.js.map +1 -0
  97. package/lib-commonjs/components/CheckboxField/CheckboxField.js +42 -0
  98. package/lib-commonjs/components/CheckboxField/CheckboxField.js.map +1 -0
  99. package/lib-commonjs/components/CheckboxField/index.js +10 -0
  100. package/lib-commonjs/components/CheckboxField/index.js.map +1 -0
  101. package/lib-commonjs/components/ComboboxField/ComboboxField.js +24 -0
  102. package/lib-commonjs/components/ComboboxField/ComboboxField.js.map +1 -0
  103. package/lib-commonjs/components/ComboboxField/index.js +10 -0
  104. package/lib-commonjs/components/ComboboxField/index.js.map +1 -0
  105. package/lib-commonjs/components/Field/Field.types.js +6 -0
  106. package/lib-commonjs/components/Field/Field.types.js.map +1 -0
  107. package/lib-commonjs/components/Field/SlotComponent.types.js +6 -0
  108. package/lib-commonjs/components/Field/SlotComponent.types.js.map +1 -0
  109. package/lib-commonjs/components/Field/index.js +16 -0
  110. package/lib-commonjs/components/Field/index.js.map +1 -0
  111. package/lib-commonjs/components/Field/renderField.js +31 -0
  112. package/lib-commonjs/components/Field/renderField.js.map +1 -0
  113. package/lib-commonjs/components/Field/useField.js +154 -0
  114. package/lib-commonjs/components/Field/useField.js.map +1 -0
  115. package/lib-commonjs/components/Field/useFieldStyles.js +134 -0
  116. package/lib-commonjs/components/Field/useFieldStyles.js.map +1 -0
  117. package/lib-commonjs/components/InputField/InputField.js +24 -0
  118. package/lib-commonjs/components/InputField/InputField.js.map +1 -0
  119. package/lib-commonjs/components/InputField/index.js +10 -0
  120. package/lib-commonjs/components/InputField/index.js.map +1 -0
  121. package/lib-commonjs/components/RadioGroupField/RadioGroupField.js +25 -0
  122. package/lib-commonjs/components/RadioGroupField/RadioGroupField.js.map +1 -0
  123. package/lib-commonjs/components/RadioGroupField/index.js +10 -0
  124. package/lib-commonjs/components/RadioGroupField/index.js.map +1 -0
  125. package/lib-commonjs/components/SelectField/SelectField.js +24 -0
  126. package/lib-commonjs/components/SelectField/SelectField.js.map +1 -0
  127. package/lib-commonjs/components/SelectField/index.js +10 -0
  128. package/lib-commonjs/components/SelectField/index.js.map +1 -0
  129. package/lib-commonjs/components/SliderField/SliderField.js +24 -0
  130. package/lib-commonjs/components/SliderField/SliderField.js.map +1 -0
  131. package/lib-commonjs/components/SliderField/index.js +10 -0
  132. package/lib-commonjs/components/SliderField/index.js.map +1 -0
  133. package/lib-commonjs/components/SpinButtonField/SpinButtonField.js +24 -0
  134. package/lib-commonjs/components/SpinButtonField/SpinButtonField.js.map +1 -0
  135. package/lib-commonjs/components/SpinButtonField/index.js +10 -0
  136. package/lib-commonjs/components/SpinButtonField/index.js.map +1 -0
  137. package/lib-commonjs/components/SwitchField/SwitchField.js +24 -0
  138. package/lib-commonjs/components/SwitchField/SwitchField.js.map +1 -0
  139. package/lib-commonjs/components/SwitchField/index.js +10 -0
  140. package/lib-commonjs/components/SwitchField/index.js.map +1 -0
  141. package/lib-commonjs/components/TextareaField/TextareaField.js +24 -0
  142. package/lib-commonjs/components/TextareaField/TextareaField.js.map +1 -0
  143. package/lib-commonjs/components/TextareaField/index.js +10 -0
  144. package/lib-commonjs/components/TextareaField/index.js.map +1 -0
  145. package/lib-commonjs/index.js +169 -0
  146. package/lib-commonjs/index.js.map +1 -0
  147. package/package.json +64 -0
package/CHANGELOG.json ADDED
@@ -0,0 +1,119 @@
1
+ {
2
+ "name": "@fluentui/react-field",
3
+ "entries": [
4
+ {
5
+ "date": "Thu, 15 Sep 2022 09:44:25 GMT",
6
+ "tag": "@fluentui/react-field_v9.0.0-alpha.1",
7
+ "version": "9.0.0-alpha.1",
8
+ "comments": {
9
+ "prerelease": [
10
+ {
11
+ "author": "behowell@microsoft.com",
12
+ "package": "@fluentui/react-field",
13
+ "commit": "cd8f5a11fd89c77582950fe714fece2bdf9c08c0",
14
+ "comment": "Initial release"
15
+ },
16
+ {
17
+ "author": "beachball",
18
+ "package": "@fluentui/react-field",
19
+ "comment": "Bump @fluentui/react-checkbox to v9.0.5",
20
+ "commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
21
+ },
22
+ {
23
+ "author": "beachball",
24
+ "package": "@fluentui/react-field",
25
+ "comment": "Bump @fluentui/react-combobox to v9.0.0-beta.9",
26
+ "commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
27
+ },
28
+ {
29
+ "author": "beachball",
30
+ "package": "@fluentui/react-field",
31
+ "comment": "Bump @fluentui/react-context-selector to v9.0.3",
32
+ "commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
33
+ },
34
+ {
35
+ "author": "beachball",
36
+ "package": "@fluentui/react-field",
37
+ "comment": "Bump @fluentui/react-input to v9.1.0",
38
+ "commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
39
+ },
40
+ {
41
+ "author": "beachball",
42
+ "package": "@fluentui/react-field",
43
+ "comment": "Bump @fluentui/react-label to v9.0.5",
44
+ "commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
45
+ },
46
+ {
47
+ "author": "beachball",
48
+ "package": "@fluentui/react-field",
49
+ "comment": "Bump @fluentui/react-radio to v9.0.5",
50
+ "commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
51
+ },
52
+ {
53
+ "author": "beachball",
54
+ "package": "@fluentui/react-field",
55
+ "comment": "Bump @fluentui/react-select to v9.0.0-beta.9",
56
+ "commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
57
+ },
58
+ {
59
+ "author": "beachball",
60
+ "package": "@fluentui/react-field",
61
+ "comment": "Bump @fluentui/react-slider to v9.0.4",
62
+ "commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
63
+ },
64
+ {
65
+ "author": "beachball",
66
+ "package": "@fluentui/react-field",
67
+ "comment": "Bump @fluentui/react-spinbutton to v9.0.1",
68
+ "commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
69
+ },
70
+ {
71
+ "author": "beachball",
72
+ "package": "@fluentui/react-field",
73
+ "comment": "Bump @fluentui/react-switch to v9.0.5",
74
+ "commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
75
+ },
76
+ {
77
+ "author": "beachball",
78
+ "package": "@fluentui/react-field",
79
+ "comment": "Bump @fluentui/react-textarea to v9.0.5",
80
+ "commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
81
+ },
82
+ {
83
+ "author": "beachball",
84
+ "package": "@fluentui/react-field",
85
+ "comment": "Bump @fluentui/react-theme to v9.1.0",
86
+ "commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
87
+ },
88
+ {
89
+ "author": "beachball",
90
+ "package": "@fluentui/react-field",
91
+ "comment": "Bump @fluentui/react-utilities to v9.1.0",
92
+ "commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
93
+ },
94
+ {
95
+ "author": "beachball",
96
+ "package": "@fluentui/react-field",
97
+ "comment": "Bump @fluentui/react-conformance-griffel to v9.0.0-beta.13",
98
+ "commit": "a33448fe4a0f4117686c378f80b893d1406d95a8"
99
+ }
100
+ ]
101
+ }
102
+ },
103
+ {
104
+ "date": "Wed, 03 Aug 2022 16:04:10 GMT",
105
+ "tag": "@fluentui/react-field_v9.0.0-alpha.0",
106
+ "version": "9.0.0-alpha.0",
107
+ "comments": {
108
+ "patch": [
109
+ {
110
+ "author": "beachball",
111
+ "package": "@fluentui/react-field",
112
+ "comment": "Bump @fluentui/react-conformance-griffel to v9.0.0-beta.12",
113
+ "commit": "ee4a8be0d0831a6615f878f98db6a97cc61a802d"
114
+ }
115
+ ]
116
+ }
117
+ }
118
+ ]
119
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,36 @@
1
+ # Change Log - @fluentui/react-field
2
+
3
+ This log was last generated on Thu, 15 Sep 2022 09:44:25 GMT and should not be manually modified.
4
+
5
+ <!-- Start content -->
6
+
7
+ ## [9.0.0-alpha.1](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.1)
8
+
9
+ Thu, 15 Sep 2022 09:44:25 GMT
10
+ [Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-field_v9.0.0-alpha.0..@fluentui/react-field_v9.0.0-alpha.1)
11
+
12
+ ### Changes
13
+
14
+ - Initial release ([PR #24235](https://github.com/microsoft/fluentui/pull/24235) by behowell@microsoft.com)
15
+ - Bump @fluentui/react-checkbox to v9.0.5 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
16
+ - Bump @fluentui/react-combobox to v9.0.0-beta.9 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
17
+ - Bump @fluentui/react-context-selector to v9.0.3 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
18
+ - Bump @fluentui/react-input to v9.1.0 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
19
+ - Bump @fluentui/react-label to v9.0.5 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
20
+ - Bump @fluentui/react-radio to v9.0.5 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
21
+ - Bump @fluentui/react-select to v9.0.0-beta.9 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
22
+ - Bump @fluentui/react-slider to v9.0.4 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
23
+ - Bump @fluentui/react-spinbutton to v9.0.1 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
24
+ - Bump @fluentui/react-switch to v9.0.5 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
25
+ - Bump @fluentui/react-textarea to v9.0.5 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
26
+ - Bump @fluentui/react-theme to v9.1.0 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
27
+ - Bump @fluentui/react-utilities to v9.1.0 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
28
+ - Bump @fluentui/react-conformance-griffel to v9.0.0-beta.13 ([PR #24808](https://github.com/microsoft/fluentui/pull/24808) by beachball)
29
+
30
+ ## [9.0.0-alpha.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-field_v9.0.0-alpha.0)
31
+
32
+ Wed, 03 Aug 2022 16:04:10 GMT
33
+
34
+ ### Patches
35
+
36
+ - Bump @fluentui/react-conformance-griffel to v9.0.0-beta.12 ([PR #24131](https://github.com/microsoft/fluentui/pull/24131) by beachball)
package/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ @fluentui/react-field
2
+
3
+ Copyright (c) Microsoft Corporation
4
+
5
+ All rights reserved.
6
+
7
+ MIT License
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ""Software""), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
+
15
+ Note: Usage of the fonts and icons referenced in Fluent UI React is subject to the terms listed at https://aka.ms/fluentui-assets-license
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # @fluentui/react-field
2
+
3
+ **React Field components for [Fluent UI React](https://react.fluentui.dev/)**
4
+
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.
package/Spec.md ADDED
@@ -0,0 +1,354 @@
1
+ # @fluentui/react-field Spec
2
+
3
+ ## Background
4
+
5
+ Field adds a label, validation text, and hint text to form input components. The existing input components (such as `Input` and `Combobox`) are wrapped to create field versions of them (such as `InputField` and `ComboboxField`).
6
+
7
+ Epic issue tracking implementation: https://github.com/microsoft/fluentui/issues/19627
8
+
9
+ ## Prior Art
10
+
11
+ Existing libraries tend to take one of the following approaches to field.
12
+
13
+ 1. Include support for label, error text, etc. in the base input component. Libraries using this approach include:
14
+ - **FluentUI v8** - [`TextField`](https://developer.microsoft.com/en-us/fluentui#/controls/web/textfield), [`Dropdown`](https://developer.microsoft.com/en-us/fluentui#/controls/web/dropdown), [`ChoiceGroup`](https://developer.microsoft.com/en-us/fluentui#/controls/web/choicegroup), etc.
15
+ - **Spectrum** - [`TextField`](https://react-spectrum.adobe.com/react-spectrum/TextField.html), [`Slider`](https://react-spectrum.adobe.com/react-spectrum/Slider.html), [`RadioGroup`](https://react-spectrum.adobe.com/react-spectrum/RadioGroup.html), etc.
16
+ 2. Provide a set of components that are manually constructed into a field. This requires manually hooking up the components using props like `htmlFor` and `aria-describedby`. Libraries using this approach include:
17
+ - **FluentUI v0** - [`FormField`](https://fluentsite.z22.web.core.windows.net/0.64.0/components/form/props#form-field), [`FormLabel`](https://fluentsite.z22.web.core.windows.net/0.64.0/components/form/props#form-label), [`FormMessage`](https://fluentsite.z22.web.core.windows.net/0.64.0/components/form/props#form-message)
18
+ - **Ant** - [`Form.Item`](https://ant.design/components/form/#Form.Item) (uses context to do some of the hooking up between the item and the field component).
19
+ 3. Provide base components without a label or descriptive text, and then Field versions of those controls. Libraries using this approach include:
20
+ - **FluentUI v0** - [`Input`](https://fluentsite.z22.web.core.windows.net/0.64.0/components/input/props) and [`FormInput`](https://fluentsite.z22.web.core.windows.net/0.64.0/components/form/props#form-input), for example.
21
+ - **Evergreen UI** - [`TextInput`](https://evergreen.segment.com/components/text-input) and [`TextInputField`](https://evergreen.segment.com/components/text-input#textinputfield), for example.
22
+
23
+ The Field implementation in this spec follows pattern (3). There are Field versions of all components that can be used as form inputs. There are several reasons, including:
24
+
25
+ - **Accessibility**: By combining a base component with the field props into a single component, all of the accessibility props like `htmlFor` and `aria-describedby` are set correctly for "free".
26
+ - **Simplicity**: All props related to the component (such as `label`, `id`, `validationState="error"`, etc.) are on the same component, rather than split between multiple components (like separate `Field` and `Input` components).
27
+ - **Consistency**: All of the Field components share a common set of props for the label, validationState, hint, etc.
28
+ - **Bundle size**: When the label and other field functionality is not needed, it is still possible to use the base components without pulling in unnecessary dependencies (like `Label` and the field styling).
29
+
30
+ ## Sample Code
31
+
32
+ Each input component has a field version (such as `InputField`, `ComboboxField`, etc.) that includes the features of Field added to that component.
33
+
34
+ ```jsx
35
+ <>
36
+ <InputField
37
+ // Field-specific props
38
+ label="This is the field label"
39
+ orientation="horizontal"
40
+ validationState="error"
41
+ validationMessage="This is error text"
42
+ // All props and slots of the underlying Input component are supported
43
+ required
44
+ size="small"
45
+ contentBefore="$"
46
+ contentAfter=".00"
47
+ />
48
+ <RadioGroupField label="Radio group field">
49
+ <Radio value="one" label="Option one" />
50
+ <Radio value="two" label="Option two" />
51
+ <Radio value="three" label="Option three" />
52
+ </RadioGroupField>
53
+ <ComboboxField label="Combobox field" validationState="success" validationMessage="Success text">
54
+ <Option value="one">Option one</Option>
55
+ <Option value="two">Option two</Option>
56
+ <Option value="three">Option three</Option>
57
+ </ComboboxField>
58
+ <SliderField label="Slider field" validationState="warning" validationMessage="Warning text" />
59
+ <SpinButtonField label="Spin button field" hint="Hint text" />
60
+ </>
61
+ ```
62
+
63
+ These field versions of the components use a common set of Field hooks, and can be defined using very little code.
64
+
65
+ ```ts
66
+ export type InputFieldProps = FieldProps<typeof Input>;
67
+
68
+ export const InputField: ForwardRefComponent<InputFieldProps> = React.forwardRef((props, ref) => {
69
+ const state = useField_unstable(props, ref, Input);
70
+ useFieldStyles_unstable(state);
71
+ return renderField_unstable(state);
72
+ });
73
+
74
+ InputField.displayName = 'InputField';
75
+ ```
76
+
77
+ ## Components
78
+
79
+ The following field components will be defined. If more form components are added in the future, they should also include a Field version.
80
+
81
+ - `CheckboxField`
82
+ - `ComboboxField`
83
+ - `DropdownField`
84
+ - `InputField`
85
+ - `RadioGroupField`
86
+ - `SelectField`
87
+ - `SliderField`
88
+ - `SpinButtonField`
89
+ - `SwitchField`
90
+ - `TextareaField`
91
+
92
+ ## Variants
93
+
94
+ - **Orientation**: The `orientation` prop affects the layout of the label and field component:
95
+ - `'vertical'` (default) - label is above the field component
96
+ - `'horizontal'` - label is to the left of the field component, and is 33% the width of the field (this allows multiple stacked fields to all align their labels)
97
+ - **Validation state**: The `validationState` prop affects the icon and color used by the `validationMessage`:
98
+ - `'error'` - Red x icon, red text color
99
+ - `'warning'` - Yellow exclamation icon, neutral color text
100
+ - `'success'` - Green check icon, neutral color text
101
+ - `undefined` (default): No validation message icon, neutral color text
102
+ - **Error**: Some control types (like `Input` and `Combobox`) have a prop that makes the border red. This prop will be set `validationState="error"`.
103
+
104
+ Field also forwards some props from the wrapped component to the label as well:
105
+
106
+ - **Size**: If the wrapped component supports a `size` prop, it will also be applied to the field's label.
107
+ - **Required**: If set, the Label will get a required asterisk: `*`
108
+
109
+ ## API
110
+
111
+ ### FieldComponent
112
+
113
+ The `FieldComponent` type defines the minimum set of props that the wrapped component must support. This is used for the generic types as the requirement for the type parameter: `FieldProps<T extends FieldComponent>`
114
+
115
+ ```ts
116
+ /**
117
+ * The minimum requirement for a component used by Field.
118
+ *
119
+ * Note: the use of VoidFunctionComponent means that component is not *required* to have a children prop,
120
+ * but it is still allowed to have a children prop.
121
+ */
122
+ export type FieldComponent = React.VoidFunctionComponent<
123
+ Pick<
124
+ React.HTMLAttributes<HTMLElement>,
125
+ 'id' | 'className' | 'style' | 'aria-labelledby' | 'aria-describedby' | 'aria-invalid' | 'aria-errormessage'
126
+ >
127
+ >;
128
+ ```
129
+
130
+ ### Slots
131
+
132
+ _Note: TypeScript crashes if the `Slot` type is used with a template type parameter. The `SlotComponent` type is a simplified version of that type, which only supports `React.ComponentType`/`React.VoidFunctionComponent`._
133
+
134
+ ```ts
135
+ export type FieldSlots<T extends FieldComponent> = {
136
+ root: NonNullable<Slot<'div'>>;
137
+
138
+ /**
139
+ * The underlying component wrapped by this field.
140
+ *
141
+ * This is the PRIMARY slot: all intrinsic HTML properties will be applied to this slot,
142
+ * except `className` and `style`, which remain on the root slot.
143
+ */
144
+ control: SlotComponent<T>;
145
+
146
+ /**
147
+ * The label associated with the field.
148
+ */
149
+ label?: Slot<typeof Label>;
150
+
151
+ /**
152
+ * A message about the validation state. The appearance of the `validationMessage` depends on `validationState`.
153
+ */
154
+ validationMessage?: Slot<'span'>;
155
+
156
+ /**
157
+ * The icon associated with the `validationMessage`. If the `validationState` prop is set, this will default to an
158
+ * icon corresponding to that state.
159
+ *
160
+ * This will only be displayed if `validationMessage` is set.
161
+ */
162
+ validationMessageIcon?: Slot<'span'>;
163
+
164
+ /**
165
+ * Additional hint text below the field.
166
+ */
167
+ hint?: Slot<'span'>;
168
+ };
169
+ ```
170
+
171
+ ### Props
172
+
173
+ ```ts
174
+ export type FieldProps<T extends FieldComponent> = ComponentProps<Partial<FieldSlots<T>>, 'control'> & {
175
+ /**
176
+ * The orientation of the label relative to the field component.
177
+ * This only affects the label, and not the validationMessage or hint (which always appear below the field component).
178
+ *
179
+ * @default vertical
180
+ */
181
+ orientation?: 'vertical' | 'horizontal';
182
+
183
+ /**
184
+ * The `validationState` affects the color of the `validationMessage`, the `validationMessageIcon`, and for some
185
+ * field components, an `validationState="error"` causes the border to become red.
186
+ *
187
+ * @default undefined
188
+ */
189
+ validationState?: 'error' | 'warning' | 'success';
190
+ };
191
+ ```
192
+
193
+ Field also reads some props from the underlying component. These are not part of `FieldProps` because they are not added to the components that don't support them. However, they are accepted by `useField`:
194
+
195
+ ```ts
196
+ /**
197
+ * Props that are supported by Field, but not required to be supported by the component that implements field.
198
+ */
199
+ export type OptionalFieldComponentProps = {
200
+ /**
201
+ * Whether the field label should be marked as required.
202
+ */
203
+ required?: boolean;
204
+
205
+ /**
206
+ * Size of the field label.
207
+ *
208
+ * Number sizes will be ignored, but are allowed because the HTML <input> element has a `size` prop of type `number`.
209
+ */
210
+ size?: 'small' | 'medium' | 'large' | number;
211
+ };
212
+ ```
213
+
214
+ ### State
215
+
216
+ ```ts
217
+ export type FieldState<T extends FieldComponent> = ComponentState<Required<FieldSlots<T>>> &
218
+ Pick<FieldProps<T>, 'orientation' | 'validationState'> & {
219
+ classNames: SlotClassNames<FieldSlots<T>>;
220
+ };
221
+ ```
222
+
223
+ ### Label for Checkbox and Switch
224
+
225
+ The Checkbox and Switch components already have a `label` prop, which conflicts with the Field's `label`.
226
+
227
+ #### `CheckboxField`
228
+
229
+ - The `label` prop will go to the Checkbox and NOT the Field
230
+ - New `fieldLabel` prop for the label of the Field
231
+
232
+ #### `SwitchField`
233
+
234
+ - New `valueLabel` prop for the label of the Switch
235
+ - The `label` prop will go to the Field and NOT the Switch
236
+
237
+ ## Structure
238
+
239
+ ### Public API
240
+
241
+ ```jsx
242
+ <InputField
243
+ label="This is the field label"
244
+ orientation="horizontal"
245
+ validationState="error"
246
+ validationMessage="This is a validation message"
247
+ hint="This is a hint message"
248
+ />
249
+ ```
250
+
251
+ (similar API for other Field components)
252
+
253
+ ### Slot structure
254
+
255
+ ```jsx
256
+ <slots.root>
257
+ <slots.label {...slotProps.label} />
258
+ <slots.control {...slotProps.control} />
259
+ <slots.validationMessage {...slotProps.validationMessage}>
260
+ <slots.validationMessageIcon {...slotProps.validationMessageIcon} />
261
+ {slotProps.validationMessage.children}
262
+ </slots.validationMessage>
263
+ <slots.hint {...slotProps.hint} />
264
+ </slots.root>
265
+ ```
266
+
267
+ ### DOM structure
268
+
269
+ ```html
270
+ <div className="fui-Field">
271
+ <label className="fui-Field__label fui-Label">This is the field label</label>
272
+ <!-- wrapped field component goes here -->
273
+ <span className="fui-Field__validationMessage">
274
+ <span className="fui-Field__validationMessageIcon"><svg>...</svg></span>
275
+ This is a validation message
276
+ </span>
277
+ <span className="fui-Field__hint">This is a hint message</span>
278
+ </div>
279
+ ```
280
+
281
+ ## Migration
282
+
283
+ ### Migration from v8
284
+
285
+ Migration from v8 will require picking between the normal and `Field` version of an input control, depending on whether the field-specific features are required: (`label`, `validationState="error"`, `validationMessage`, `hint`)
286
+
287
+ See individual input components for more detailed migration guides.
288
+
289
+ | v8 Control | v9 Base control | v9 Field control | Notes |
290
+ | ------------- | --------------------- | ------------------------------- | -------------------------------------------------------------------------------------------- |
291
+ | `Checkbox` | `Checkbox` | `CheckboxField` | Only use `CheckboxField` if an error message is needed, or if required for layout in a form. |
292
+ | `ChoiceGroup` | `RadioGroup` | `RadioGroupField` | |
293
+ | `ComboBox` | `Combobox` | `ComboboxField` | `errorMessage="..."` is replaced by `validationState="error" validationMessage="..."` |
294
+ | `Dropdown` | `Dropdown` | `DropdownField` | `errorMessage="..."` is replaced by `validationState="error" validationMessage="..."` |
295
+ | `Slider` | `Slider` | `SliderField` | |
296
+ | `SpinButton` | `SpinButton` | `SpinButtonField` | |
297
+ | `TextField` | `Input` OR `Textarea` | `InputField` OR `TextareaField` | `errorMessage="..."` is replaced by `validationState="error" validationMessage="..."` |
298
+ | `Toggle` | `Switch` | `SwitchField` | |
299
+
300
+ ### Migration from v0
301
+
302
+ Many components in v0 have `Form___` versions (such as `FormInput`). Those are replaced by the `___Field` equivalent. See the underlying component's migration guides for more detailed migration information.
303
+
304
+ Component mapping:
305
+
306
+ - `FormButton` => Not supported
307
+ - `FormCheckbox` => `CheckboxField` OR `SwitchField`
308
+ - `FormDatepicker` => _(Not yet implemented)_
309
+ - `FormDropdown` => `DropdownField`
310
+ - `FormField` => Not supported
311
+ - `FormFieldCustom` => Not supported
312
+ - `FormLabel` => The `label` prop of the field component
313
+ - `FormMessage` => Either the `validationMessage` or `hint` prop of the field component
314
+ - `FormRadioGroup` => `RadioGroupField`
315
+ - `FormSlider` => `SliderField`
316
+ - `FormTextArea` => `TextareaField`
317
+
318
+ The following props are common to each of the `Form___` components:
319
+
320
+ - `label` => `label`
321
+ - `message` => either `validationMessage` or `hint`
322
+ - `errorMessage` => `validationMessage` with `validationState="error"`
323
+
324
+ ## Behaviors
325
+
326
+ ### Form validation
327
+
328
+ Field has no logic to perform input validation. It is expected that the validation will be done externally (possibly using a third party form validation library like Formik).
329
+
330
+ ### Interaction
331
+
332
+ The Field itself is not interactive. The wrapped component has the same interactions as it does outside of a field.
333
+
334
+ ## Accessibility
335
+
336
+ - **ARIA pattern**
337
+ - Field itself does not implement a defined ARIA pattern. It has no role applied to the root element.
338
+ - **Attributes**
339
+ - The following are applied on the wrapped component:
340
+ - `aria-labelledby={label.id}`, if the label is present.
341
+ - `aria-describedby` is set to one of:
342
+ - `aria-describedby={validationMessage.id}`, if validationMessage is present, and _only if_ `validationState !== 'error'`
343
+ - `aria-describedby={hint.id}`, if hint is present
344
+ - `aria-describedby={validationMessage.id + ' ' + hint.id}`, if both conditions above apply
345
+ - `aria-errormessage={validationMessage.id}`, if validationMessage is present, and _only if_ `validationState === 'error'`
346
+ - `aria-invalid={true}`, _only if_ `validationState === 'error'`
347
+ - On the `label` slot:
348
+ - `htmlFor={control.id}` - the wrapped component's `id` (an ID is generated if not supplied via props).
349
+ - **Live regions** (state change announcements)
350
+ - TBD: Need to determine if the validation message should be an aria live region.
351
+ - **UI parts appearing on hover or focus**
352
+ - None.
353
+ - **Focus behavior**
354
+ - No special focus behavior: no focus trapping or programmatic focus moving.